summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2016-09-28 13:22:00 -0300
committerJames Almer <jamrial@gmail.com>2016-09-28 13:22:00 -0300
commit32c25f06b79f9edcda726f6e043325d40036cdce (patch)
tree46e89e540424ad2111c5d65910d2351645ef67f0 /libavcodec/utils.c
parent0153cc49b20ac6c54d5bcd86f5ce53357e6b29aa (diff)
parente85f6f7f8d037c0af0f294000718d9ba22753baa (diff)
Merge commit 'e85f6f7f8d037c0af0f294000718d9ba22753baa'
* commit 'e85f6f7f8d037c0af0f294000718d9ba22753baa': lavc: allow using AVCodecContext.hw_frames_ctx for decoding Conflicts: doc/APIchanges libavcodec/version.h Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b0345b63af..0d78f0bf57 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -724,6 +724,9 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags
{
int ret;
+ if (avctx->hw_frames_ctx)
+ return av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0);
+
if ((ret = update_frame_pool(avctx, frame)) < 0)
return ret;
@@ -1119,6 +1122,8 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
av_freep(&avctx->internal->hwaccel_priv_data);
avctx->hwaccel = NULL;
+ av_buffer_unref(&avctx->hw_frames_ctx);
+
ret = avctx->get_format(avctx, choices);
desc = av_pix_fmt_desc_get(ret);
@@ -1134,6 +1139,16 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
break;
#endif
+ if (avctx->hw_frames_ctx) {
+ AVHWFramesContext *hw_frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
+ if (hw_frames_ctx->format != ret) {
+ av_log(avctx, AV_LOG_ERROR, "Format returned from get_buffer() "
+ "does not match the format of provided AVHWFramesContext\n");
+ ret = AV_PIX_FMT_NONE;
+ break;
+ }
+ }
+
if (!setup_hwaccel(avctx, ret, desc->name))
break;