[FFmpeg-trac] #9132(ffmpeg:open): Wrong pixel format/output when converting video to yuv444p*

FFmpeg trac at avcodec.org
Mon Mar 22 17:20:28 EET 2021


#9132: Wrong pixel format/output when converting video to yuv444p*
------------------------------------+----------------------------------
             Reporter:  viley       |                    Owner:
                 Type:  defect      |                   Status:  open
             Priority:  important   |                Component:  ffmpeg
              Version:  git-master  |               Resolution:
             Keywords:  regression  |               Blocked By:
             Blocking:              |  Reproduced by developer:  1
Analyzed by developer:  0           |
------------------------------------+----------------------------------

Comment (by JEEB):

 Alright, this seems to be an issue in the scale filter not overriding
 color metadata properly in case of a pixel format conversion :) Thus the
 issue itself is much older, but it just never popped up until my change
 started passing the information further.

 If I apply the following patch I can see that the scale filter is happily
 doing the flagging after copying props from the input frame.
 {{{
 diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
 index 58eee96744..8377be2e39 100644
 --- a/libavfilter/vf_scale.c
 +++ b/libavfilter/vf_scale.c
 @@ -647,6 +647,22 @@ static int scale_slice(AVFilterLink *link, AVFrame
 *out_buf, AVFrame *cur_pic, s
                           out,out_stride);
  }

 +static void log_avframe(AVFilterContext *ctx, const char *prefix, AVFrame
 *frame)
 +{
 +    if (!frame)
 +        return;
 +
 +    av_log(ctx, AV_LOG_VERBOSE,
 +           "%s picture info: w=%d , h=%d, pix_fmt=%s (range=%s,
 primaries=%s, transfer=%s, cspace=%s, cloc=%s)\n",
 +           prefix, frame->width, frame->height,
 +           av_get_pix_fmt_name(frame->format),
 +           av_color_range_name(frame->color_range),
 +           av_color_primaries_name(frame->color_primaries),
 +           av_color_transfer_name(frame->color_trc),
 +           av_color_space_name(frame->colorspace),
 +           av_chroma_location_name(frame->chroma_location));
 +}
 +
  static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame
 **frame_out)
  {
      AVFilterContext *ctx = link->dst;
 @@ -806,6 +822,9 @@ scale:
          scale_slice(link, out, in, scale->sws, 0, link->h, 1, 0);
      }

 +    log_avframe(link->dst, "Input", in);
 +    log_avframe(link->dst, "Output", out);
 +
      av_frame_free(&in);
      return 0;
  }

 }}}

 {{{
 [auto_scaler_0 @ 00000179d2dc2200] Input picture info: w=420 , h=212,
 pix_fmt=gbrp (range=pc, primaries=unknown, transfer=unknown, cspace=gbr,
 cloc=left)
 [auto_scaler_0 @ 00000179d2dc2200] Output picture info: w=420 , h=212,
 pix_fmt=yuv444p (range=tv, primaries=unknown, transfer=unknown,
 cspace=gbr, cloc=left)
 }}}

 Of course, the color space should no longer be "gbr" at that point.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/9132#comment:7>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list