avcodec: add AVHWAccel.free_frame_priv callback

This commit is contained in:
Lynne
2022-03-10 18:03:05 +01:00
parent 09dc9193ea
commit be07145109
9 changed files with 50 additions and 7 deletions
+20
View File
@@ -1718,3 +1718,23 @@ int ff_copy_palette(void *dst, const AVPacket *src, void *logctx)
}
return 0;
}
AVBufferRef *ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx,
const AVHWAccel *hwaccel)
{
AVBufferRef *ref;
AVHWFramesContext *frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
uint8_t *data = av_mallocz(hwaccel->frame_priv_data_size);
if (!data)
return NULL;
ref = av_buffer_create(data, hwaccel->frame_priv_data_size,
hwaccel->free_frame_priv,
frames_ctx->device_ctx, 0);
if (!ref) {
av_free(data);
return NULL;
}
return ref;
}