Paul B Mahol (2017-12-10): > Signed-off-by: Paul B Mahol <[email protected]> > --- > libavfilter/buffersrc.c | 18 ++++++++++++++++++ > libavfilter/buffersrc.h | 5 +++++ > 2 files changed, 23 insertions(+) > > diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c > index cd56f8ca45..9e6d07c7df 100644 > --- a/libavfilter/buffersrc.c > +++ b/libavfilter/buffersrc.c > @@ -52,6 +52,7 @@ typedef struct BufferSourceContext { > int w, h; > enum AVPixelFormat pix_fmt; > AVRational pixel_aspect; > + int color_range; > char *sws_param; > > AVBufferRef *hw_frames_ctx; > @@ -109,6 +110,8 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, > AVBufferSrcParameters *par > s->h = param->height; > if (param->sample_aspect_ratio.num > 0 && > param->sample_aspect_ratio.den > 0) > s->pixel_aspect = param->sample_aspect_ratio; > + if (param->color_range > AVCOL_RANGE_UNSPECIFIED) > + s->color_range = param->color_range; > if (param->frame_rate.num > 0 && param->frame_rate.den > 0) > s->frame_rate = param->frame_rate; > if (param->hw_frames_ctx) { > @@ -279,6 +282,11 @@ static av_cold int init_video(AVFilterContext *ctx) > return AVERROR(EINVAL); > } >
> + if (c->color_range > AVCOL_RANGE_JPEG) {
> + av_log(ctx, AV_LOG_ERROR, "Invalid color_range parameter
> provided.\n");
> + return AVERROR(EINVAL);
> + }
A static test here is suboptimal. If you accept a static test, then just
set the max field in the option structure. But it will not accept future
new values. For that, use a dynamic test, for example checking if
av_color_range_name() returns a value.
> +
> if (!(c->fifo = av_fifo_alloc(sizeof(AVFrame*))))
> return AVERROR(ENOMEM);
>
> @@ -309,6 +317,15 @@ static const AVOption buffer_options[] = {
> { "time_base", NULL, OFFSET(time_base),
> AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
> { "frame_rate", NULL, OFFSET(frame_rate),
> AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
> { "sws_param", NULL, OFFSET(sws_param),
> AV_OPT_TYPE_STRING, .flags = V },
> + { "color_range", NULL, OFFSET(color_range),
> AV_OPT_TYPE_INT, { .i64 = AVCOL_RANGE_UNSPECIFIED }, 0, INT_MAX, V,
> "range" },
> + { "unspecified", NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, V, "range"},
> + { "unknown", NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, V, "range"},
> + { "limited", NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, "range"},
> + { "tv", NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, "range"},
> + { "mpeg", NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, "range"},
> + { "full", NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, "range"},
> + { "pc", NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, "range"},
> + { "jpeg", NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, "range"},
> { NULL },
> };
>
> @@ -434,6 +451,7 @@ static int config_props(AVFilterLink *link)
> link->w = c->w;
> link->h = c->h;
> link->sample_aspect_ratio = c->pixel_aspect;
> + link->color_range = c->color_range;
>
> if (c->hw_frames_ctx) {
> link->hw_frames_ctx = av_buffer_ref(c->hw_frames_ctx);
> diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h
> index 0652113f2b..cc32d532c2 100644
> --- a/libavfilter/buffersrc.h
> +++ b/libavfilter/buffersrc.h
> @@ -114,6 +114,11 @@ typedef struct AVBufferSrcParameters {
> * Audio only, the audio channel layout
> */
> uint64_t channel_layout;
> +
> + /**
> + * Video only
> + */
> + int color_range;
> } AVBufferSrcParameters;
>
> /**
Regards,
--
Nicolas George
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list [email protected] http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
