aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-04-03 15:33:48 -0300
committerJames Almer <jamrial@gmail.com>2018-04-03 15:33:48 -0300
commitf3fae82042595f6ea31c832df7b8ca2941bb9620 (patch)
treef2631b718adec4194e02e7cf5a9f1dab1cd7eb9a
parentd5343a5005af770b7dfa31e53d41a05041b7f75c (diff)
downloadffmpeg-f3fae82042595f6ea31c832df7b8ca2941bb9620.tar.gz
avcodec/libaomdec: add support for monochrome files
All such files are signaled as I42016, as there's no monochrome value in aom_img_fmt_t. Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/libaomdec.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c
index fdc53e4520..9991af96c8 100644
--- a/libavcodec/libaomdec.c
+++ b/libavcodec/libaomdec.c
@@ -61,9 +61,10 @@ static av_cold int aom_init(AVCodecContext *avctx,
static void image_copy_16_to_8(AVFrame *pic, struct aom_image *img)
{
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pic->format);
int i;
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < desc->nb_components; i++) {
int w = img->d_w;
int h = img->d_h;
int x, y;
@@ -97,7 +98,8 @@ static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img)
case AOM_IMG_FMT_I420:
case AOM_IMG_FMT_I42016:
if (img->bit_depth == 8) {
- avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+ avctx->pix_fmt = img->monochrome ?
+ AV_PIX_FMT_GRAY8 : AV_PIX_FMT_YUV420P;
avctx->profile = FF_PROFILE_AV1_MAIN;
return 0;
} else if (img->bit_depth == 10) {
@@ -114,7 +116,8 @@ static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img)
case AOM_IMG_FMT_I422:
case AOM_IMG_FMT_I42216:
if (img->bit_depth == 8) {
- avctx->pix_fmt = AV_PIX_FMT_YUV422P;
+ avctx->pix_fmt = img->monochrome ?
+ AV_PIX_FMT_GRAY10 : AV_PIX_FMT_YUV420P10;
avctx->profile = FF_PROFILE_AV1_PROFESSIONAL;
return 0;
} else if (img->bit_depth == 10) {
@@ -131,7 +134,8 @@ static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img)
case AOM_IMG_FMT_I444:
case AOM_IMG_FMT_I44416:
if (img->bit_depth == 8) {
- avctx->pix_fmt = AV_PIX_FMT_YUV444P;
+ avctx->pix_fmt = img->monochrome ?
+ AV_PIX_FMT_GRAY12 : AV_PIX_FMT_YUV420P12;
avctx->profile = FF_PROFILE_AV1_HIGH;
return 0;
} else if (img->bit_depth == 10) {