summaryrefslogtreecommitdiff
path: root/libavcodec/h264_slice.c
diff options
context:
space:
mode:
authorRémi Denis-Courmont <remi@remlab.net>2014-12-19 19:15:06 +0200
committerAnton Khirnov <anton@khirnov.net>2014-12-25 20:47:48 +0100
commit4cfbeef31d4e6096c0596359d212f5d99a7ba4b5 (patch)
tree8da6b7f0c8254ad8b2d73a33ba057db4bafa91bc /libavcodec/h264_slice.c
parent9cfa68c560bdec82d2d5ec079f9c5b0f9ca37af0 (diff)
h264: factor hwaccel pixel formats list
This is to avoid proliferation of similar tables in following changes. Signed-off-by: Rémi Denis-Courmont <remi@remlab.net> Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/h264_slice.c')
-rw-r--r--libavcodec/h264_slice.c89
1 files changed, 35 insertions, 54 deletions
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 9169ff4a19..c2826e69da 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -143,42 +143,6 @@ static const uint8_t dequant8_coeff_init[6][6] = {
{ 36, 32, 58, 34, 46, 43 },
};
-static const enum AVPixelFormat h264_hwaccel_pixfmt_list_420[] = {
-#if CONFIG_H264_DXVA2_HWACCEL
- AV_PIX_FMT_DXVA2_VLD,
-#endif
-#if CONFIG_H264_VAAPI_HWACCEL
- AV_PIX_FMT_VAAPI_VLD,
-#endif
-#if CONFIG_H264_VDA_HWACCEL
- AV_PIX_FMT_VDA_VLD,
- AV_PIX_FMT_VDA,
-#endif
-#if CONFIG_H264_VDPAU_HWACCEL
- AV_PIX_FMT_VDPAU,
-#endif
- AV_PIX_FMT_YUV420P,
- AV_PIX_FMT_NONE
-};
-
-static const enum AVPixelFormat h264_hwaccel_pixfmt_list_jpeg_420[] = {
-#if CONFIG_H264_DXVA2_HWACCEL
- AV_PIX_FMT_DXVA2_VLD,
-#endif
-#if CONFIG_H264_VAAPI_HWACCEL
- AV_PIX_FMT_VAAPI_VLD,
-#endif
-#if CONFIG_H264_VDA_HWACCEL
- AV_PIX_FMT_VDA_VLD,
- AV_PIX_FMT_VDA,
-#endif
-#if CONFIG_H264_VDPAU_HWACCEL
- AV_PIX_FMT_VDPAU,
-#endif
- AV_PIX_FMT_YUVJ420P,
- AV_PIX_FMT_NONE
-};
-
static void release_unused_pictures(H264Context *h, int remove_current)
{
@@ -975,54 +939,69 @@ static int clone_slice(H264Context *dst, H264Context *src)
static enum AVPixelFormat get_pixel_format(H264Context *h)
{
- enum AVPixelFormat pix_fmts[2];
+#define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \
+ CONFIG_H264_VAAPI_HWACCEL + \
+ (CONFIG_H264_VDA_HWACCEL * 2) + \
+ CONFIG_H264_VDPAU_HWACCEL)
+ enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;
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) {
- pix_fmts[0] = AV_PIX_FMT_GBRP9;
+ *fmt++ = AV_PIX_FMT_GBRP9;
} else
- pix_fmts[0] = AV_PIX_FMT_YUV444P9;
+ *fmt++ = AV_PIX_FMT_YUV444P9;
} else if (CHROMA422(h))
- pix_fmts[0] = AV_PIX_FMT_YUV422P9;
+ *fmt++ = AV_PIX_FMT_YUV422P9;
else
- pix_fmts[0] = AV_PIX_FMT_YUV420P9;
+ *fmt++ = AV_PIX_FMT_YUV420P9;
break;
case 10:
if (CHROMA444(h)) {
if (h->avctx->colorspace == AVCOL_SPC_RGB) {
- pix_fmts[0] = AV_PIX_FMT_GBRP10;
+ *fmt++ = AV_PIX_FMT_GBRP10;
} else
- pix_fmts[0] = AV_PIX_FMT_YUV444P10;
+ *fmt++ = AV_PIX_FMT_YUV444P10;
} else if (CHROMA422(h))
- pix_fmts[0] = AV_PIX_FMT_YUV422P10;
+ *fmt++ = AV_PIX_FMT_YUV422P10;
else
- pix_fmts[0] = AV_PIX_FMT_YUV420P10;
+ *fmt++ = AV_PIX_FMT_YUV420P10;
break;
case 8:
if (CHROMA444(h)) {
if (h->avctx->colorspace == AVCOL_SPC_RGB)
- pix_fmts[0] = AV_PIX_FMT_GBRP;
+ *fmt++ = AV_PIX_FMT_GBRP;
else if (h->avctx->color_range == AVCOL_RANGE_JPEG)
- pix_fmts[0] = AV_PIX_FMT_YUVJ444P;
+ *fmt++ = AV_PIX_FMT_YUVJ444P;
else
- pix_fmts[0] = AV_PIX_FMT_YUV444P;
+ *fmt++ = AV_PIX_FMT_YUV444P;
} else if (CHROMA422(h)) {
if (h->avctx->color_range == AVCOL_RANGE_JPEG)
- pix_fmts[0] = AV_PIX_FMT_YUVJ422P;
+ *fmt++ = AV_PIX_FMT_YUVJ422P;
else
- pix_fmts[0] = AV_PIX_FMT_YUV422P;
+ *fmt++ = AV_PIX_FMT_YUV422P;
} else {
+#if CONFIG_H264_DXVA2_HWACCEL
+ *fmt++ = AV_PIX_FMT_DXVA2_VLD;
+#endif
+#if CONFIG_H264_VAAPI_HWACCEL
+ *fmt++ = AV_PIX_FMT_VAAPI_VLD;
+#endif
+#if CONFIG_H264_VDA_HWACCEL
+ *fmt++ = AV_PIX_FMT_VDA_VLD;
+ *fmt++ = AV_PIX_FMT_VDA;
+#endif
+#if CONFIG_H264_VDPAU_HWACCEL
+ *fmt++ = AV_PIX_FMT_VDPAU;
+#endif
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;
+ *fmt++ = AV_PIX_FMT_YUVJ420P;
else
- choices = h264_hwaccel_pixfmt_list_420;
+ *fmt++ = AV_PIX_FMT_YUV420P;
}
break;
default:
@@ -1031,6 +1010,8 @@ static enum AVPixelFormat get_pixel_format(H264Context *h)
return AVERROR_INVALIDDATA;
}
+ *fmt = AV_PIX_FMT_NONE;
+
return ff_get_format(h->avctx, choices);
}