[FFmpeg-devel] [PATCH] avcodec: Pass the HDR10+ metadata to the packet side data in VP9 encoder

Mohammad Izadi izadi at google.com
Thu Jun 17 01:54:55 EEST 2021


On Tue, Jun 15, 2021 at 5:18 PM Andreas Rheinhardt <
andreas.rheinhardt at outlook.com> wrote:

> Mohammad Izadi:
> > HDR10+ metadata is stored in the bit stream for HEVC. The story is
> different for VP9 and cannot store the metadata in the bit stream. HDR10+
> should be passed to packet side data an stored in the container (mkv) for
> VP9.
> >
> > This CL is taking HDR10+ from AVFrame side data in libvpxenc and is
> passing it to the AVPacket side data.
> > ---
> >  doc/APIchanges         |  2 +
> >  libavcodec/avpacket.c  |  1 +
> >  libavcodec/decode.c    |  1 +
> >  libavcodec/libvpxenc.c | 91 ++++++++++++++++++++++++++++++++++++++++++
> >  libavcodec/packet.h    |  8 ++++
> >  libavcodec/version.h   |  4 +-
> >  6 files changed, 105 insertions(+), 2 deletions(-)
> >
> > @@ -1620,6 +1692,25 @@ static int vpx_encode(AVCodecContext *avctx,
> AVPacket *pkt,
> >                  vp9_encode_set_roi(avctx, frame->width, frame->height,
> sd);
> >              }
> >          }
> > +
> > +        if (!ctx->discard_hdr10_plus) {
> > +            AVFrameSideData *hdr10_plus_metadata;
> > +            // Add HDR10+ metadata to queue.
> > +            hdr10_plus_metadata = av_frame_get_side_data(frame,
> AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
> > +            if (hdr10_plus_metadata) {
> > +                int err;
> > +                struct FrameHDR10Plus data;
> > +                data.pts = frame->pts;
> > +                data.hdr10_plus =
> av_buffer_ref(hdr10_plus_metadata->buf);
> > +                if (!data.hdr10_plus)
> > +                    return AVERROR(ENOMEM);
> > +                err = add_hdr10_plus(ctx->hdr10_plus_fifo, &data);
> > +                if (err < 0) {
> > +                    av_freep(&data.hdr10_plus);
>
> This is not how you free an AVBufferRef.
>
Fixed.

>
> > +                    return err;
> > +                }
> > +            }
> > +        }
> >      }
> >
> >      // this is for encoding with preset temporal layering patterns
> defined in
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list