[FFmpeg-devel] [PATCH] Extract QP from h264 encoded videos

Juan De León juandl at google.com
Tue Jul 30 20:49:00 EEST 2019


On Mon, Jul 29, 2019 at 7:59 PM James Almer <jamrial at gmail.com> wrote:

> Side data, or more specifically, any AVBufferRef, must be a flat array.
> You can't have pointers to some other allocated buffer within them since
> you can't really control their lifetime.
>
Here's a snippet of how I'm doing it right now:
        // mb_xy = number of blocks in the frame
        size_t buf_size = sizeof(AVQuantizationParamsArray) + mb_xy *
sizeof(AVQuantizationParams);
        AVBufferRef *buffer = av_buffer_alloc(buf_size);
        AVQuantizationParamsArray *params = (AVQuantizationParamsArray
*)buffer->data;

        // offset memory for qp_block_array in same buffer
        params->qp_block_array = (AVQuantizationParams*) (params + 1);

        AVFrameSideData *sd;
        sd = av_frame_new_side_data_from_buf(dst,
AV_FRAME_DATA_QUANTIZATION_PARAMS, buffer);

The idea is to keep everything in the same buffer so that it can all be
freed when AVFrameSideData is freed.
Let me know if this doesn't look right to you.


More information about the ffmpeg-devel mailing list