diff options
author | Anton Khirnov <anton@khirnov.net> | 2016-02-01 15:39:50 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-02-14 22:29:52 +0100 |
commit | 7b3214d0050613bd347a2e41c9f78ffb766da25e (patch) | |
tree | 3fcde9d9a7e5998e5828235066e31c3cd8815f13 /libavcodec/utils.c | |
parent | 21f7cd4acd8dc4b4796b55966dd015cb037164d8 (diff) | |
download | ffmpeg-7b3214d0050613bd347a2e41c9f78ffb766da25e.tar.gz |
lavc: add a field for passing AVHWFramesContext to encoders
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index e06ee664b5..94ec1e8047 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -32,6 +32,7 @@ #include "libavutil/channel_layout.h" #include "libavutil/crc.h" #include "libavutil/frame.h" +#include "libavutil/hwcontext.h" #include "libavutil/internal.h" #include "libavutil/mathematics.h" #include "libavutil/pixdesc.h" @@ -1059,6 +1060,16 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->time_base.den); goto free_and_end; } + + if (avctx->hw_frames_ctx) { + AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; + if (frames_ctx->format != avctx->pix_fmt) { + av_log(avctx, AV_LOG_ERROR, + "Mismatching AVCodecContext.pix_fmt and AVHWFramesContext.format\n"); + ret = AVERROR(EINVAL); + goto free_and_end; + } + } } if (avctx->codec->init && !(avctx->active_thread_type & FF_THREAD_FRAME)) { @@ -1639,6 +1650,8 @@ av_cold int avcodec_close(AVCodecContext *avctx) av_freep(&avctx->coded_side_data); avctx->nb_coded_side_data = 0; + av_buffer_unref(&avctx->hw_frames_ctx); + if (avctx->priv_data && avctx->codec && avctx->codec->priv_class) av_opt_free(avctx->priv_data); av_opt_free(avctx); |