Commit 28b1698a authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'ce423163'

* commit 'ce423163':
  h264: Always invoke the get_format() callback

Conflicts:
	libavcodec/h264_slice.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 01831fd0 ce423163
...@@ -1025,76 +1025,79 @@ static int clone_slice(H264Context *dst, H264Context *src) ...@@ -1025,76 +1025,79 @@ static int clone_slice(H264Context *dst, H264Context *src)
static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback)
{ {
enum AVPixelFormat pix_fmts[2];
const enum AVPixelFormat *choices = pix_fmts;
int i;
pix_fmts[1] = AV_PIX_FMT_NONE;
switch (h->sps.bit_depth_luma) { switch (h->sps.bit_depth_luma) {
case 9: case 9:
if (CHROMA444(h)) { if (CHROMA444(h)) {
if (h->avctx->colorspace == AVCOL_SPC_RGB) { if (h->avctx->colorspace == AVCOL_SPC_RGB) {
return AV_PIX_FMT_GBRP9; pix_fmts[0] = AV_PIX_FMT_GBRP9;
} else } else
return AV_PIX_FMT_YUV444P9; pix_fmts[0] = AV_PIX_FMT_YUV444P9;
} else if (CHROMA422(h)) } else if (CHROMA422(h))
return AV_PIX_FMT_YUV422P9; pix_fmts[0] = AV_PIX_FMT_YUV422P9;
else else
return AV_PIX_FMT_YUV420P9; pix_fmts[0] = AV_PIX_FMT_YUV420P9;
break; break;
case 10: case 10:
if (CHROMA444(h)) { if (CHROMA444(h)) {
if (h->avctx->colorspace == AVCOL_SPC_RGB) { if (h->avctx->colorspace == AVCOL_SPC_RGB) {
return AV_PIX_FMT_GBRP10; pix_fmts[0] = AV_PIX_FMT_GBRP10;
} else } else
return AV_PIX_FMT_YUV444P10; pix_fmts[0] = AV_PIX_FMT_YUV444P10;
} else if (CHROMA422(h)) } else if (CHROMA422(h))
return AV_PIX_FMT_YUV422P10; pix_fmts[0] = AV_PIX_FMT_YUV422P10;
else else
return AV_PIX_FMT_YUV420P10; pix_fmts[0] = AV_PIX_FMT_YUV420P10;
break; break;
case 12: case 12:
if (CHROMA444(h)) { if (CHROMA444(h)) {
if (h->avctx->colorspace == AVCOL_SPC_RGB) { if (h->avctx->colorspace == AVCOL_SPC_RGB) {
return AV_PIX_FMT_GBRP12; pix_fmts[0] = AV_PIX_FMT_GBRP12;
} else } else
return AV_PIX_FMT_YUV444P12; pix_fmts[0] = AV_PIX_FMT_YUV444P12;
} else if (CHROMA422(h)) } else if (CHROMA422(h))
return AV_PIX_FMT_YUV422P12; pix_fmts[0] = AV_PIX_FMT_YUV422P12;
else else
return AV_PIX_FMT_YUV420P12; pix_fmts[0] = AV_PIX_FMT_YUV420P12;
break; break;
case 14: case 14:
if (CHROMA444(h)) { if (CHROMA444(h)) {
if (h->avctx->colorspace == AVCOL_SPC_RGB) { if (h->avctx->colorspace == AVCOL_SPC_RGB) {
return AV_PIX_FMT_GBRP14; pix_fmts[0] = AV_PIX_FMT_GBRP14;
} else } else
return AV_PIX_FMT_YUV444P14; pix_fmts[0] = AV_PIX_FMT_YUV444P14;
} else if (CHROMA422(h)) } else if (CHROMA422(h))
return AV_PIX_FMT_YUV422P14; pix_fmts[0] = AV_PIX_FMT_YUV422P14;
else else
return AV_PIX_FMT_YUV420P14; pix_fmts[0] = AV_PIX_FMT_YUV420P14;
break; break;
case 8: case 8:
if (CHROMA444(h)) { if (CHROMA444(h)) {
if (h->avctx->colorspace == AVCOL_SPC_RGB) { if (h->avctx->colorspace == AVCOL_SPC_YCGCO)
av_log(h->avctx, AV_LOG_DEBUG, "Detected GBR colorspace.\n");
return AV_PIX_FMT_GBR24P;
} else if (h->avctx->colorspace == AVCOL_SPC_YCGCO) {
av_log(h->avctx, AV_LOG_WARNING, "Detected unsupported YCgCo colorspace.\n"); av_log(h->avctx, AV_LOG_WARNING, "Detected unsupported YCgCo colorspace.\n");
} if (h->avctx->colorspace == AVCOL_SPC_RGB)
return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ444P pix_fmts[0] = AV_PIX_FMT_GBRP;
: AV_PIX_FMT_YUV444P; 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)) { } else if (CHROMA422(h)) {
return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ422P if (h->avctx->color_range == AVCOL_RANGE_JPEG)
: AV_PIX_FMT_YUV422P; pix_fmts[0] = AV_PIX_FMT_YUVJ422P;
else
pix_fmts[0] = AV_PIX_FMT_YUV422P;
} else { } else {
int i; if (h->avctx->codec->pix_fmts)
const enum AVPixelFormat * fmt = h->avctx->codec->pix_fmts ? choices = h->avctx->codec->pix_fmts;
h->avctx->codec->pix_fmts : else if (h->avctx->color_range == AVCOL_RANGE_JPEG)
h->avctx->color_range == AVCOL_RANGE_JPEG ? choices = h264_hwaccel_pixfmt_list_jpeg_420;
h264_hwaccel_pixfmt_list_jpeg_420 : else
h264_hwaccel_pixfmt_list_420; choices = h264_hwaccel_pixfmt_list_420;
for (i=0; fmt[i] != AV_PIX_FMT_NONE; i++)
if (fmt[i] == h->avctx->pix_fmt && !force_callback)
return fmt[i];
return ff_thread_get_format(h->avctx, fmt);
} }
break; break;
default: default:
...@@ -1102,6 +1105,11 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) ...@@ -1102,6 +1105,11 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback)
"Unsupported bit depth %d\n", h->sps.bit_depth_luma); "Unsupported bit depth %d\n", h->sps.bit_depth_luma);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
for (i=0; choices[i] != AV_PIX_FMT_NONE; i++)
if (choices[i] == h->avctx->pix_fmt && !force_callback)
return choices[i];
return ff_thread_get_format(h->avctx, choices);
} }
/* export coded and cropped frame dimensions to AVCodecContext */ /* export coded and cropped frame dimensions to AVCodecContext */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment