Add a slice_dir parameter to avfilter_draw_slice().
Avoid the need to implement slice direction detection code, thus reducing code duplication. See the thread: "[FFmpeg-devel] [PATCH] Add a slice_dir parameter to avfilter_start_frame()". Originally committed as revision 20734 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
78149213cc
commit
a13a543797
@ -287,13 +287,13 @@ void avfilter_end_frame(AVFilterLink *link)
|
||||
|
||||
}
|
||||
|
||||
void avfilter_draw_slice(AVFilterLink *link, int y, int h)
|
||||
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
|
||||
{
|
||||
uint8_t *src[4], *dst[4];
|
||||
int i, j, hsub, vsub;
|
||||
void (*draw_slice)(AVFilterLink *, int, int);
|
||||
void (*draw_slice)(AVFilterLink *, int, int, int);
|
||||
|
||||
DPRINTF_START(NULL, draw_slice); dprintf_link(NULL, link, 0); dprintf(NULL, " y:%d h:%d\n", y, h);
|
||||
DPRINTF_START(NULL, draw_slice); dprintf_link(NULL, link, 0); dprintf(NULL, " y:%d h:%d dir:%d\n", y, h, slice_dir);
|
||||
|
||||
/* copy the slice if needed for permission reasons */
|
||||
if(link->srcpic) {
|
||||
@ -325,7 +325,7 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h)
|
||||
|
||||
if(!(draw_slice = link_dpad(link).draw_slice))
|
||||
draw_slice = avfilter_default_draw_slice;
|
||||
draw_slice(link, y, h);
|
||||
draw_slice(link, y, h, slice_dir);
|
||||
}
|
||||
|
||||
#define MAX_REGISTERED_AVFILTERS_NB 64
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVFILTER_VERSION_MAJOR 1
|
||||
#define LIBAVFILTER_VERSION_MINOR 11
|
||||
#define LIBAVFILTER_VERSION_MINOR 12
|
||||
#define LIBAVFILTER_VERSION_MICRO 0
|
||||
|
||||
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
|
||||
@ -322,7 +322,7 @@ struct AVFilterPad
|
||||
*
|
||||
* Input video pads only.
|
||||
*/
|
||||
void (*draw_slice)(AVFilterLink *link, int y, int height);
|
||||
void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
|
||||
|
||||
/**
|
||||
* Frame poll callback. This returns the number of immediately available
|
||||
@ -364,7 +364,7 @@ struct AVFilterPad
|
||||
/** default handler for start_frame() for video inputs */
|
||||
void avfilter_default_start_frame(AVFilterLink *link, AVFilterPicRef *picref);
|
||||
/** default handler for draw_slice() for video inputs */
|
||||
void avfilter_default_draw_slice(AVFilterLink *link, int y, int h);
|
||||
void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
|
||||
/** default handler for end_frame() for video inputs */
|
||||
void avfilter_default_end_frame(AVFilterLink *link);
|
||||
/** default handler for config_props() for video outputs */
|
||||
@ -566,8 +566,12 @@ void avfilter_end_frame(AVFilterLink *link);
|
||||
* @param link the output link over which the frame is being sent
|
||||
* @param y offset in pixels from the top of the image for this slice
|
||||
* @param h height of this slice in pixels
|
||||
* @param slice_dir the assumed direction for sending slices,
|
||||
* from the top slice to the bottom slice if the value is 1,
|
||||
* from the bottom slice to the top slice if the value is -1,
|
||||
* for other values the behavior of the function is undefined.
|
||||
*/
|
||||
void avfilter_draw_slice(AVFilterLink *link, int y, int h);
|
||||
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
|
||||
|
||||
/** Initializes the filter system. Registers all builtin filters. */
|
||||
void avfilter_register_all(void);
|
||||
|
@ -78,7 +78,7 @@ void avfilter_default_start_frame(AVFilterLink *link, AVFilterPicRef *picref)
|
||||
}
|
||||
}
|
||||
|
||||
void avfilter_default_draw_slice(AVFilterLink *link, int y, int h)
|
||||
void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
|
||||
{
|
||||
AVFilterLink *out = NULL;
|
||||
|
||||
@ -86,7 +86,7 @@ void avfilter_default_draw_slice(AVFilterLink *link, int y, int h)
|
||||
out = link->dst->outputs[0];
|
||||
|
||||
if(out)
|
||||
avfilter_draw_slice(out, y, h);
|
||||
avfilter_draw_slice(out, y, h, slice_dir);
|
||||
}
|
||||
|
||||
void avfilter_default_end_frame(AVFilterLink *link)
|
||||
|
@ -195,7 +195,7 @@ static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
|
||||
avfilter_start_frame(link->dst->outputs[0], ref2);
|
||||
}
|
||||
|
||||
static void draw_slice(AVFilterLink *link, int y, int h)
|
||||
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
|
||||
{
|
||||
AVFilterContext *ctx = link->dst;
|
||||
CropContext *crop = ctx->priv;
|
||||
@ -210,7 +210,7 @@ static void draw_slice(AVFilterLink *link, int y, int h)
|
||||
if (y + h > crop->y + crop->h)
|
||||
h = crop->y + crop->h - y;
|
||||
|
||||
avfilter_draw_slice(ctx->outputs[0], y - crop->y, h);
|
||||
avfilter_draw_slice(ctx->outputs[0], y - crop->y, h, slice_dir);
|
||||
}
|
||||
|
||||
AVFilter avfilter_vf_crop = {
|
||||
|
@ -112,9 +112,9 @@ static void end_frame(AVFilterLink *link)
|
||||
avfilter_end_frame(link->dst->outputs[0]);
|
||||
}
|
||||
|
||||
static void draw_slice(AVFilterLink *link, int y, int h)
|
||||
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
|
||||
{
|
||||
avfilter_draw_slice(link->dst->outputs[0], y, h);
|
||||
avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir);
|
||||
}
|
||||
|
||||
AVFilter avfilter_vf_format = {
|
||||
|
@ -38,7 +38,6 @@ typedef struct {
|
||||
|
||||
int hsub, vsub; ///< chroma subsampling
|
||||
int slice_y; ///< top of current output slice
|
||||
int slice_dir; ///< detected slice direction order for the current frame
|
||||
int input_is_pal; ///< set to 1 if the input format is paletted
|
||||
} ScaleContext;
|
||||
|
||||
@ -141,25 +140,19 @@ static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
|
||||
(int64_t)picref->pixel_aspect.den * outlink->w * link->h,
|
||||
INT_MAX);
|
||||
|
||||
scale->slice_dir = 0;
|
||||
scale->slice_y = 0;
|
||||
avfilter_start_frame(outlink, avfilter_ref_pic(outpicref, ~0));
|
||||
}
|
||||
|
||||
static void draw_slice(AVFilterLink *link, int y, int h)
|
||||
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
|
||||
{
|
||||
ScaleContext *scale = link->dst->priv;
|
||||
int out_h;
|
||||
AVFilterPicRef *cur_pic = link->cur_pic;
|
||||
uint8_t *data[4];
|
||||
|
||||
if (!scale->slice_dir) {
|
||||
if (y != 0 && y + h != link->h) {
|
||||
av_log(link->dst, AV_LOG_ERROR, "Slices start in the middle!\n");
|
||||
return;
|
||||
}
|
||||
scale->slice_dir = y ? -1 : 1;
|
||||
scale->slice_y = y ? link->dst->outputs[0]->h : y;
|
||||
}
|
||||
if (scale->slice_y == 0 && slice_dir == -1)
|
||||
scale->slice_y = link->dst->outputs[0]->h;
|
||||
|
||||
data[0] = cur_pic->data[0] + y * cur_pic->linesize[0];
|
||||
data[1] = scale->input_is_pal ?
|
||||
@ -172,10 +165,10 @@ static void draw_slice(AVFilterLink *link, int y, int h)
|
||||
link->dst->outputs[0]->outpic->data,
|
||||
link->dst->outputs[0]->outpic->linesize);
|
||||
|
||||
if (scale->slice_dir == -1)
|
||||
if (slice_dir == -1)
|
||||
scale->slice_y -= out_h;
|
||||
avfilter_draw_slice(link->dst->outputs[0], scale->slice_y, out_h);
|
||||
if (scale->slice_dir == 1)
|
||||
avfilter_draw_slice(link->dst->outputs[0], scale->slice_y, out_h, slice_dir);
|
||||
if (slice_dir == 1)
|
||||
scale->slice_y += out_h;
|
||||
}
|
||||
|
||||
|
@ -73,16 +73,16 @@ static void end_frame(AVFilterLink *link)
|
||||
avfilter_end_frame(link->dst->outputs[0]);
|
||||
}
|
||||
|
||||
static void draw_slice(AVFilterLink *link, int y, int h)
|
||||
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
|
||||
{
|
||||
SliceContext *slice = link->dst->priv;
|
||||
int y2;
|
||||
|
||||
for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h)
|
||||
avfilter_draw_slice(link->dst->outputs[0], y2, slice->h);
|
||||
avfilter_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir);
|
||||
|
||||
if (y2 < y + h)
|
||||
avfilter_draw_slice(link->dst->outputs[0], y2, y + h - y2);
|
||||
avfilter_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir);
|
||||
}
|
||||
|
||||
AVFilter avfilter_vf_slicify = {
|
||||
|
@ -78,11 +78,11 @@ static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
|
||||
avfilter_start_frame(link->dst->outputs[0], ref2);
|
||||
}
|
||||
|
||||
static void draw_slice(AVFilterLink *link, int y, int h)
|
||||
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
|
||||
{
|
||||
AVFilterContext *ctx = link->dst;
|
||||
|
||||
avfilter_draw_slice(ctx->outputs[0], link->h - (y+h), h);
|
||||
avfilter_draw_slice(ctx->outputs[0], link->h - (y+h), h, -1 * slice_dir);
|
||||
}
|
||||
|
||||
AVFilter avfilter_vf_vflip = {
|
||||
|
Loading…
Reference in New Issue
Block a user