|
|
@@ -70,7 +70,6 @@ static av_cold int vpx_init(AVCodecContext *avctx, |
|
|
static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img, |
|
|
static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img, |
|
|
int has_alpha_channel) |
|
|
int has_alpha_channel) |
|
|
{ |
|
|
{ |
|
|
#if VPX_IMAGE_ABI_VERSION >= 3 |
|
|
|
|
|
static const enum AVColorSpace colorspaces[8] = { |
|
|
static const enum AVColorSpace colorspaces[8] = { |
|
|
AVCOL_SPC_UNSPECIFIED, AVCOL_SPC_BT470BG, AVCOL_SPC_BT709, AVCOL_SPC_SMPTE170M, |
|
|
AVCOL_SPC_UNSPECIFIED, AVCOL_SPC_BT470BG, AVCOL_SPC_BT709, AVCOL_SPC_SMPTE170M, |
|
|
AVCOL_SPC_SMPTE240M, AVCOL_SPC_BT2020_NCL, AVCOL_SPC_RESERVED, AVCOL_SPC_RGB, |
|
|
AVCOL_SPC_SMPTE240M, AVCOL_SPC_BT2020_NCL, AVCOL_SPC_RESERVED, AVCOL_SPC_RGB, |
|
|
@@ -82,7 +81,6 @@ static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img, |
|
|
avctx->color_range = color_ranges[img->range]; |
|
|
avctx->color_range = color_ranges[img->range]; |
|
|
#endif |
|
|
#endif |
|
|
avctx->colorspace = colorspaces[img->cs]; |
|
|
avctx->colorspace = colorspaces[img->cs]; |
|
|
#endif |
|
|
|
|
|
if (avctx->codec_id == AV_CODEC_ID_VP8 && img->fmt != VPX_IMG_FMT_I420) |
|
|
if (avctx->codec_id == AV_CODEC_ID_VP8 && img->fmt != VPX_IMG_FMT_I420) |
|
|
return AVERROR_INVALIDDATA; |
|
|
return AVERROR_INVALIDDATA; |
|
|
switch (img->fmt) { |
|
|
switch (img->fmt) { |
|
|
@@ -97,22 +95,15 @@ static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img, |
|
|
avctx->profile = FF_PROFILE_VP9_1; |
|
|
avctx->profile = FF_PROFILE_VP9_1; |
|
|
avctx->pix_fmt = AV_PIX_FMT_YUV422P; |
|
|
avctx->pix_fmt = AV_PIX_FMT_YUV422P; |
|
|
return 0; |
|
|
return 0; |
|
|
#if VPX_IMAGE_ABI_VERSION >= 3 |
|
|
|
|
|
case VPX_IMG_FMT_I440: |
|
|
case VPX_IMG_FMT_I440: |
|
|
avctx->profile = FF_PROFILE_VP9_1; |
|
|
avctx->profile = FF_PROFILE_VP9_1; |
|
|
avctx->pix_fmt = AV_PIX_FMT_YUV440P; |
|
|
avctx->pix_fmt = AV_PIX_FMT_YUV440P; |
|
|
return 0; |
|
|
return 0; |
|
|
#endif |
|
|
|
|
|
case VPX_IMG_FMT_I444: |
|
|
case VPX_IMG_FMT_I444: |
|
|
avctx->profile = FF_PROFILE_VP9_1; |
|
|
avctx->profile = FF_PROFILE_VP9_1; |
|
|
#if VPX_IMAGE_ABI_VERSION >= 3 |
|
|
|
|
|
avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ? |
|
|
avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ? |
|
|
AV_PIX_FMT_GBRP : AV_PIX_FMT_YUV444P; |
|
|
AV_PIX_FMT_GBRP : AV_PIX_FMT_YUV444P; |
|
|
#else |
|
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_YUV444P; |
|
|
|
|
|
#endif |
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
#ifdef VPX_IMG_FMT_HIGHBITDEPTH |
|
|
|
|
|
case VPX_IMG_FMT_I42016: |
|
|
case VPX_IMG_FMT_I42016: |
|
|
avctx->profile = FF_PROFILE_VP9_2; |
|
|
avctx->profile = FF_PROFILE_VP9_2; |
|
|
if (img->bit_depth == 10) { |
|
|
if (img->bit_depth == 10) { |
|
|
@@ -135,7 +126,6 @@ static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img, |
|
|
} else { |
|
|
} else { |
|
|
return AVERROR_INVALIDDATA; |
|
|
return AVERROR_INVALIDDATA; |
|
|
} |
|
|
} |
|
|
#if VPX_IMAGE_ABI_VERSION >= 3 |
|
|
|
|
|
case VPX_IMG_FMT_I44016: |
|
|
case VPX_IMG_FMT_I44016: |
|
|
avctx->profile = FF_PROFILE_VP9_3; |
|
|
avctx->profile = FF_PROFILE_VP9_3; |
|
|
if (img->bit_depth == 10) { |
|
|
if (img->bit_depth == 10) { |
|
|
@@ -147,29 +137,19 @@ static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img, |
|
|
} else { |
|
|
} else { |
|
|
return AVERROR_INVALIDDATA; |
|
|
return AVERROR_INVALIDDATA; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
|
|
|
case VPX_IMG_FMT_I44416: |
|
|
case VPX_IMG_FMT_I44416: |
|
|
avctx->profile = FF_PROFILE_VP9_3; |
|
|
avctx->profile = FF_PROFILE_VP9_3; |
|
|
if (img->bit_depth == 10) { |
|
|
if (img->bit_depth == 10) { |
|
|
#if VPX_IMAGE_ABI_VERSION >= 3 |
|
|
|
|
|
avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ? |
|
|
avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ? |
|
|
AV_PIX_FMT_GBRP10 : AV_PIX_FMT_YUV444P10; |
|
|
AV_PIX_FMT_GBRP10 : AV_PIX_FMT_YUV444P10; |
|
|
#else |
|
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_YUV444P10; |
|
|
|
|
|
#endif |
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} else if (img->bit_depth == 12) { |
|
|
} else if (img->bit_depth == 12) { |
|
|
#if VPX_IMAGE_ABI_VERSION >= 3 |
|
|
|
|
|
avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ? |
|
|
avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ? |
|
|
AV_PIX_FMT_GBRP12 : AV_PIX_FMT_YUV444P12; |
|
|
AV_PIX_FMT_GBRP12 : AV_PIX_FMT_YUV444P12; |
|
|
#else |
|
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_YUV444P12; |
|
|
|
|
|
#endif |
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} else { |
|
|
} else { |
|
|
return AVERROR_INVALIDDATA; |
|
|
return AVERROR_INVALIDDATA; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
|
|
|
#endif |
|
|
#endif |
|
|
default: |
|
|
default: |
|
|
return AVERROR_INVALIDDATA; |
|
|
return AVERROR_INVALIDDATA; |
|
|
@@ -252,13 +232,8 @@ static int vpx_decode(AVCodecContext *avctx, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ((ret = set_pix_fmt(avctx, img, ctx->has_alpha_channel)) < 0) { |
|
|
if ((ret = set_pix_fmt(avctx, img, ctx->has_alpha_channel)) < 0) { |
|
|
#ifdef VPX_IMG_FMT_HIGHBITDEPTH |
|
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d) / bit_depth (%d)\n", |
|
|
av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d) / bit_depth (%d)\n", |
|
|
img->fmt, img->bit_depth); |
|
|
img->fmt, img->bit_depth); |
|
|
#else |
|
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d) / bit_depth (%d)\n", |
|
|
|
|
|
img->fmt, 8); |
|
|
|
|
|
#endif |
|
|
|
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|