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

Michael Niedermayer michael at niedermayer.cc
Fri May 28 14:48:47 EEST 2021


On Thu, May 27, 2021 at 09:44:10AM -0700, Mohammad Izadi wrote:
> 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 | 92 ++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/packet.h    |  8 ++++
>  libavcodec/version.h   |  2 +-
>  6 files changed, 105 insertions(+), 1 deletion(-)
[...]
> @@ -316,6 +323,53 @@ static av_cold void free_frame_list(struct FrameListData *list)
>      }
>  }
>  
> +static av_cold int add_hdr10_plus(AVFifoBuffer *fifo, struct FrameHDR10Plus *data)
> +{
> +    int err = av_fifo_grow(fifo, sizeof(FrameHDR10Plus));
> +    if (err < 0)
> +        return err;
> +    av_fifo_generic_write(fifo, data, sizeof(FrameHDR10Plus), NULL);
> +    return 0;
> +}
> +
> +static av_cold void free_hdr10_plus(struct FrameHDR10Plus *p)
> +{
> +    if (!p)
> +        return;
> +    av_buffer_unref(&p->hdr10_plus);
> +    av_free(p);
> +}
> +
> +static av_cold void free_hdr10_plus_fifo(AVFifoBuffer **fifo)
> +{
> +    FrameHDR10Plus *frame_hdr10_plus = NULL;
> +    while (av_fifo_generic_read(*fifo, frame_hdr10_plus, sizeof(*frame_hdr10_plus), NULL) > 0)
> +        free_hdr10_plus(frame_hdr10_plus);
> +    av_fifo_freep(fifo);
> +}

This seems crashing

frame=    3 fps=0.1 q=0.0 Lsize=      18kB time=00:00:01.03 bitrate= 145.7kbits/s speed=0.0346x    
video:3kB audio:14kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 7.865490%
==21306== Invalid read of size 8
==21306==    at 0x12203B3: av_fifo_generic_read (fifo.c:218)
==21306==    by 0x9F5DA3: free_hdr10_plus_fifo (libvpxenc.c:346)
==21306==    by 0x9F627A: vpx_free (libvpxenc.c:441)
==21306==    by 0x7A1B02: avcodec_close (avcodec.c:472)
==21306==    by 0xAE48E0: avcodec_free_context (options.c:163)
==21306==    by 0x24AA21: ffmpeg_cleanup (ffmpeg.c:609)
==21306==    by 0x24239C: exit_program (cmdutils.c:135)
==21306==    by 0x25C3AB: main (ffmpeg.c:5030)
==21306==  Address 0x18 is not stack'd, malloc'd or (recently) free'd

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210528/343f8827/attachment.sig>


More information about the ffmpeg-devel mailing list