[FFmpeg-cvslog] h264: Always invoke the get_format() callback
Rémi Denis-Courmont
git at videolan.org
Sat Nov 1 15:25:29 CET 2014
ffmpeg | branch: release/2.2 | Rémi Denis-Courmont <remi at remlab.net> | Thu Sep 25 11:59:57 2014 +0300| [c7caed88a03567e8777a606f4bd42f093c6b302c] | committer: Luca Barbato
h264: Always invoke the get_format() callback
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c7caed88a03567e8777a606f4bd42f093c6b302c
---
libavcodec/h264.c | 51 +++++++++++++++++++++++++++++++--------------------
1 file changed, 31 insertions(+), 20 deletions(-)
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index aee8db0..7e62881 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3083,45 +3083,54 @@ static int h264_set_parameter_from_sps(H264Context *h)
static enum AVPixelFormat get_pixel_format(H264Context *h)
{
+ enum AVPixelFormat pix_fmts[2];
+ const enum AVPixelFormat *choices = pix_fmts;
+
+ pix_fmts[1] = AV_PIX_FMT_NONE;
+
switch (h->sps.bit_depth_luma) {
case 9:
if (CHROMA444(h)) {
if (h->avctx->colorspace == AVCOL_SPC_RGB) {
- return AV_PIX_FMT_GBRP9;
+ pix_fmts[0] = AV_PIX_FMT_GBRP9;
} else
- return AV_PIX_FMT_YUV444P9;
+ pix_fmts[0] = AV_PIX_FMT_YUV444P9;
} else if (CHROMA422(h))
- return AV_PIX_FMT_YUV422P9;
+ pix_fmts[0] = AV_PIX_FMT_YUV422P9;
else
- return AV_PIX_FMT_YUV420P9;
+ pix_fmts[0] = AV_PIX_FMT_YUV420P9;
break;
case 10:
if (CHROMA444(h)) {
if (h->avctx->colorspace == AVCOL_SPC_RGB) {
- return AV_PIX_FMT_GBRP10;
+ pix_fmts[0] = AV_PIX_FMT_GBRP10;
} else
- return AV_PIX_FMT_YUV444P10;
+ pix_fmts[0] = AV_PIX_FMT_YUV444P10;
} else if (CHROMA422(h))
- return AV_PIX_FMT_YUV422P10;
+ pix_fmts[0] = AV_PIX_FMT_YUV422P10;
else
- return AV_PIX_FMT_YUV420P10;
+ pix_fmts[0] = AV_PIX_FMT_YUV420P10;
break;
case 8:
if (CHROMA444(h)) {
- if (h->avctx->colorspace == AVCOL_SPC_RGB) {
- return AV_PIX_FMT_GBRP;
- } else
- return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ444P
- : AV_PIX_FMT_YUV444P;
+ if (h->avctx->colorspace == AVCOL_SPC_RGB)
+ pix_fmts[0] = AV_PIX_FMT_GBRP;
+ else if (h->avctx->color_range == AVCOL_RANGE_JPEG)
+ pix_fmts[0] = AV_PIX_FMT_YUVJ444P;
+ else
+ pix_fmts[0] = AV_PIX_FMT_YUV444P;
} else if (CHROMA422(h)) {
- return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ422P
- : AV_PIX_FMT_YUV422P;
+ if (h->avctx->color_range == AVCOL_RANGE_JPEG)
+ pix_fmts[0] = AV_PIX_FMT_YUVJ422P;
+ else
+ pix_fmts[0] = AV_PIX_FMT_YUV422P;
} else {
- return h->avctx->get_format(h->avctx, h->avctx->codec->pix_fmts ?
- h->avctx->codec->pix_fmts :
- h->avctx->color_range == AVCOL_RANGE_JPEG ?
- h264_hwaccel_pixfmt_list_jpeg_420 :
- h264_hwaccel_pixfmt_list_420);
+ if (h->avctx->codec->pix_fmts)
+ choices = h->avctx->codec->pix_fmts;
+ else if (h->avctx->color_range == AVCOL_RANGE_JPEG)
+ choices = h264_hwaccel_pixfmt_list_jpeg_420;
+ else
+ choices = h264_hwaccel_pixfmt_list_420;
}
break;
default:
@@ -3129,6 +3138,8 @@ static enum AVPixelFormat get_pixel_format(H264Context *h)
"Unsupported bit depth %d\n", h->sps.bit_depth_luma);
return AVERROR_INVALIDDATA;
}
+
+ return h->avctx->get_format(h->avctx, choices);
}
/* export coded and cropped frame dimensions to AVCodecContext */
More information about the ffmpeg-cvslog
mailing list