[FFmpeg-devel] [PATCH 03/27] avfilter/buffersrc: recognize color_range as additonal parameter and set it to input link

Paul B Mahol onemda at gmail.com
Sat Dec 9 17:37:55 EET 2017


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)
+            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" },
+    { "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;
 
 /**
-- 
2.11.0



More information about the ffmpeg-devel mailing list