diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-05-19 01:02:54 +0200 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-05-19 23:15:33 +0200 |
commit | 50764e19a8edc018b6e5276f1b3e4215ba66217f (patch) | |
tree | 4c5163e93f48c9ef06cc9ddce978fbbd3cfaaf7d | |
parent | 509b32cf5d5656473e277ac43dbb2ce9da66bff2 (diff) | |
download | ffmpeg-50764e19a8edc018b6e5276f1b3e4215ba66217f.tar.gz |
vsrc_buffer: make the source accept sws_param in init
Avoid the need of two distinct av_vsrc_add_video_buffer_ref*
functions. Simplify the interface.
-rw-r--r-- | doc/filters.texi | 10 | ||||
-rw-r--r-- | ffmpeg.c | 2 | ||||
-rw-r--r-- | libavfilter/avfilter.h | 2 | ||||
-rw-r--r-- | libavfilter/vsrc_buffer.c | 33 | ||||
-rw-r--r-- | libavfilter/vsrc_buffer.h | 3 |
5 files changed, 24 insertions, 26 deletions
diff --git a/doc/filters.texi b/doc/filters.texi index 523e279d46..1407828cbe 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1536,9 +1536,10 @@ This source is mainly intended for a programmatic use, in particular through the interface defined in @file{libavfilter/vsrc_buffer.h}. It accepts the following parameters: -@var{width}:@var{height}:@var{pix_fmt_string}:@var{timebase_num}:@var{timebase_den}:@var{sample_aspect_ratio_num}:@var{sample_aspect_ratio.den} +@var{width}:@var{height}:@var{pix_fmt_string}:@var{timebase_num}:@var{timebase_den}:@var{sample_aspect_ratio_num}:@var{sample_aspect_ratio.den}:@var{scale_params} -All the parameters need to be explicitely defined. +All the parameters but @var{scale_params} need to be explicitely +defined. Follows the list of the accepted parameters. @@ -1559,6 +1560,11 @@ timestamps of the buffered frames. @item sample_aspect_ratio.num, sample_aspect_ratio.den Specify numerator and denominator of the sample aspect ratio assumed by the video frames. + +@item scale_params +Specify the optional parameters to be used for the scale filter which +is automatically inserted when an input change is detected in the +input size or format. @end table For example: @@ -1652,7 +1652,7 @@ static int output_packet(AVInputStream *ist, int ist_index, picref = avfilter_get_video_buffer_ref_from_frame(&picture, AV_PERM_WRITE); - av_vsrc_buffer_add_video_buffer_ref(ost->input_video_filter, picref, ""); //TODO user setable params + av_vsrc_buffer_add_video_buffer_ref(ost->input_video_filter, picref); picref->buf->data[0] = NULL; avfilter_unref_buffer(picref); } diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 171c9e4c74..a0ad35882f 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -26,7 +26,7 @@ #include "libavutil/samplefmt.h" #define LIBAVFILTER_VERSION_MAJOR 2 -#define LIBAVFILTER_VERSION_MINOR 6 +#define LIBAVFILTER_VERSION_MINOR 7 #define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c index effc232d5e..9815f945da 100644 --- a/libavfilter/vsrc_buffer.c +++ b/libavfilter/vsrc_buffer.c @@ -37,8 +37,7 @@ typedef struct { char sws_param[256]; } BufferSourceContext; -int av_vsrc_buffer_add_video_buffer_ref2(AVFilterContext *buffer_filter, AVFilterBufferRef *picref, - const char *sws_param) +int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter, AVFilterBufferRef *picref) { BufferSourceContext *c = buffer_filter->priv; AVFilterLink *outlink = buffer_filter->outputs[0]; @@ -52,13 +51,10 @@ int av_vsrc_buffer_add_video_buffer_ref2(AVFilterContext *buffer_filter, AVFilte //return -1; } - if (!c->sws_param[0]) { - snprintf(c->sws_param, 255, "%d:%d:%s", c->w, c->h, sws_param); - } - if (picref->video->w != c->w || picref->video->h != c->h || picref->format != c->pix_fmt) { AVFilterContext *scale = buffer_filter->outputs[0]->dst; AVFilterLink *link; + char scale_param[1024]; av_log(buffer_filter, AV_LOG_INFO, "Buffer video input changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n", @@ -72,7 +68,8 @@ int av_vsrc_buffer_add_video_buffer_ref2(AVFilterContext *buffer_filter, AVFilte if ((ret = avfilter_open(&scale, f, "Input equalizer")) < 0) return ret; - if ((ret = avfilter_init_filter(scale, c->sws_param, NULL)) < 0) { + snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s", c->w, c->h, c->sws_param); + if ((ret = avfilter_init_filter(scale, scale_param, NULL)) < 0) { avfilter_free(scale); return ret; } @@ -85,8 +82,9 @@ int av_vsrc_buffer_add_video_buffer_ref2(AVFilterContext *buffer_filter, AVFilte scale->outputs[0]->format= c->pix_fmt; } else if (!strcmp(scale->filter->name, "scale")) { - snprintf(c->sws_param, 255, "%d:%d:%s", scale->outputs[0]->w, scale->outputs[0]->h, sws_param); - scale->filter->init(scale, c->sws_param, NULL); + snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s", + scale->outputs[0]->w, scale->outputs[0]->h, c->sws_param); + scale->filter->init(scale, scale_param, NULL); } c->pix_fmt = scale->inputs[0]->format = picref->format; @@ -108,24 +106,21 @@ int av_vsrc_buffer_add_video_buffer_ref2(AVFilterContext *buffer_filter, AVFilte return 0; } -int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter, AVFilterBufferRef *picref) -{ - return av_vsrc_buffer_add_video_buffer_ref2(buffer_filter, picref, ""); -} - static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) { BufferSourceContext *c = ctx->priv; char pix_fmt_str[128]; int n = 0; + *c->sws_param = 0; if (!args || - (n = sscanf(args, "%d:%d:%127[^:]:%d:%d:%d:%d", &c->w, &c->h, pix_fmt_str, + (n = sscanf(args, "%d:%d:%127[^:]:%d:%d:%d:%d:%255c", &c->w, &c->h, pix_fmt_str, &c->time_base.num, &c->time_base.den, - &c->sample_aspect_ratio.num, &c->sample_aspect_ratio.den)) != 7) { - av_log(ctx, AV_LOG_ERROR, "Expected 7 arguments, but only %d found in '%s'\n", n, args); + &c->sample_aspect_ratio.num, &c->sample_aspect_ratio.den, c->sws_param)) < 7) { + av_log(ctx, AV_LOG_ERROR, "Expected at least 7 arguments, but only %d found in '%s'\n", n, args); return AVERROR(EINVAL); } + if ((c->pix_fmt = av_get_pix_fmt(pix_fmt_str)) == PIX_FMT_NONE) { char *tail; c->pix_fmt = strtol(pix_fmt_str, &tail, 10); @@ -135,10 +130,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) } } - av_log(ctx, AV_LOG_INFO, "w:%d h:%d pixfmt:%s tb:%d/%d sar:%d/%d\n", + av_log(ctx, AV_LOG_INFO, "w:%d h:%d pixfmt:%s tb:%d/%d sar:%d/%d sws_param:%s\n", c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name, c->time_base.num, c->time_base.den, - c->sample_aspect_ratio.num, c->sample_aspect_ratio.den); + c->sample_aspect_ratio.num, c->sample_aspect_ratio.den, c->sws_param); return 0; } diff --git a/libavfilter/vsrc_buffer.h b/libavfilter/vsrc_buffer.h index eb9ec56edd..34fec0e61a 100644 --- a/libavfilter/vsrc_buffer.h +++ b/libavfilter/vsrc_buffer.h @@ -31,7 +31,4 @@ int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter, AVFilterBufferRef *picref); -int av_vsrc_buffer_add_video_buffer_ref2(AVFilterContext *buffer_filter, AVFilterBufferRef *picref, - const char *sws_param); - #endif /* AVFILTER_VSRC_BUFFER_H */ |