diff options
author | RĂ©mi Denis-Courmont <remi@remlab.net> | 2014-12-19 19:15:07 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-12-25 20:47:49 +0100 |
commit | 57b6704ecd0f56d6a3092e448687cfd837bb0ac1 (patch) | |
tree | c4359d6b659f48d9352ab996d59c612928f98133 /libavcodec/utils.c | |
parent | 4cfbeef31d4e6096c0596359d212f5d99a7ba4b5 (diff) | |
download | ffmpeg-57b6704ecd0f56d6a3092e448687cfd837bb0ac1.tar.gz |
avcodec: add AVCodecContext.sw_pix_fmt
This carries the pixel format that would be used if it were not for
hardware acceleration. This is equal to AVCodecContext.pix_fmt if
hardware acceleration is not in use.
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 8cbd47b84d..fcc7dde789 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -665,10 +665,13 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) if (ret < 0) return ret; - if (hwaccel && hwaccel->alloc_frame) { - ret = hwaccel->alloc_frame(avctx, frame); - goto end; - } + if (hwaccel) { + if (hwaccel->alloc_frame) { + ret = hwaccel->alloc_frame(avctx, frame); + goto end; + } + } else + avctx->sw_pix_fmt = avctx->pix_fmt; #if FF_API_GET_BUFFER FF_DISABLE_DEPRECATION_WARNINGS @@ -933,6 +936,10 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) while (fmt[n] != AV_PIX_FMT_NONE) ++n; + av_assert0(n >= 1); + avctx->sw_pix_fmt = fmt[n - 1]; + av_assert2(!is_hwaccel_pix_fmt(avctx->sw_pix_fmt)); + choices = av_malloc_array(n + 1, sizeof(*choices)); if (!choices) return AV_PIX_FMT_NONE; |