[FFmpeg-devel] [PATCH 03/27] avfilter/buffersrc: recognize color_range as additonal parameter and set it to input link
Nicolas George
george at nsup.org
Sun Dec 10 12:52:37 EET 2017
Paul B Mahol (2017-12-09):
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
> libavfilter/buffersrc.c | 13 +++++++++++++
> libavfilter/buffersrc.h | 5 +++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
> index cd56f8ca45..67f8bdf158 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 > 0)
Compare with AVCOL_RANGE_UNSPECIFIED, not 0.
> + 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) {
> @@ -309,6 +312,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 = 0 }, 0, INT_MAX, V, "range" },
Default should be AVCOL_RANGE_UNSPECIFIED.
And I do not like the INT_MAX upper bound, but I see no other solution.
The value probably needs to be validated at init.
> + { "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 +446,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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20171210/fa4bb14c/attachment.sig>
More information about the ffmpeg-devel
mailing list