On Mon, Jul 29, 2019 at 7:59 PM James Almer <jamr...@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.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to