Commit 9b62a2ea authored by Sebastian Jedruszkiewicz's avatar Sebastian Jedruszkiewicz
Browse files

Alloc hw_frames_ctx for hw frames wrapped in AVFrames.

parent a2a9d14c
......@@ -326,6 +326,31 @@ static int mediacodec_wrap_hw_buffer(AVCodecContext *avctx,
buffer->pts = info->presentationTimeUs;
frame->data[3] = (uint8_t *)buffer;
if (!frame->hw_frames_ctx) {
AVHWFramesContext* hwframes_ctx;
AVBufferRef* hw_frames_ctx = av_hwframe_ctx_alloc(avctx->hw_device_ctx);
if (!avctx->hw_frames_ctx) {
av_log(avctx, AV_LOG_ERROR, "av_hwframe_ctx_alloc failed\n");
ret = AVERROR(ENOMEM);
goto fail;
}
hwframes_ctx = (AVHWFramesContext*)hw_frames_ctx->data;
hwframes_ctx->width = avctx->width;
hwframes_ctx->height = avctx->height;
hwframes_ctx->format = AV_PIX_FMT_MEDIACODEC;
hwframes_ctx->sw_format = avctx->sw_pix_fmt;
ret = av_hwframe_ctx_init(avctx->hw_frames_ctx);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error initializing hwframe ctx\n");
av_buffer_unref(&hw_frames_ctx);
goto fail;
}
frame->hw_frames_ctx = av_buffer_ref(hw_frames_ctx);
}
atomic_fetch_add(&s->hw_buffer_count, 1);
av_log(avctx, AV_LOG_DEBUG,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment