diff mbox

[FFmpeg-devel,3/3] fftools/ffmpeg: Support passing colour range from decoder to encoder

Message ID 20180221222538.7255-4-philipl@overt.org
State New
Headers show

Commit Message

Philip Langdale Feb. 21, 2018, 10:25 p.m. UTC
This is relatively straightforward; we set the colour range from the
encoder context into the buffersrc parameters and then set the range
on the decoder from the buffersink.

I did not touch ifilter as part of this change, as I'm not sure whether
it is relevant. ifilter initialisation seems to be done from an AVFrame,
and it seems conceptually undesirable to set the link colour range on
that basis. The one possible reason to handle this is if if the input
is not a decoder and so the color range would come from codecpar. If
so, it could be handled as a separate change.

Signed-off-by: Philip Langdale <philipl@overt.org>
---
 fftools/ffmpeg.c        | 2 ++
 fftools/ffmpeg_filter.c | 1 +
 2 files changed, 3 insertions(+)
diff mbox

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index a37de2ff98..ff824b864f 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3385,6 +3385,8 @@  static int init_output_stream_encode(OutputStream *ost)
             av_mul_q(ost->frame_aspect_ratio, (AVRational){ enc_ctx->height, enc_ctx->width }) :
             av_buffersink_get_sample_aspect_ratio(ost->filter->filter);
 
+        enc_ctx->color_range = av_buffersink_get_color_range(ost->filter->filter);
+
         enc_ctx->pix_fmt = av_buffersink_get_format(ost->filter->filter);
         if (dec_ctx)
             enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample,
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 877fd670e6..30cb0bc378 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -755,6 +755,7 @@  static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
         return AVERROR(ENOMEM);
     memset(par, 0, sizeof(*par));
     par->format = AV_PIX_FMT_NONE;
+    par->color_range = ist->dec_ctx->color_range;
 
     if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
         av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");