X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Flibaomdec.c;h=6a2de6d47a760431982e02818454c302de22d502;hb=8f146b526ff8d63adc02e1c5db15850f4589230b;hp=5158ea8d76a3041acb58fdec7612a85a7f6e5429;hpb=0dc11d8bbd470db89fbc17b7434e992c9129b310;p=ffmpeg diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c index 5158ea8d76a..6a2de6d47a7 100644 --- a/libavcodec/libaomdec.c +++ b/libavcodec/libaomdec.c @@ -31,6 +31,7 @@ #include "avcodec.h" #include "internal.h" +#include "profiles.h" typedef struct AV1DecodeContext { struct aom_codec_ctx decoder; @@ -60,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; @@ -84,82 +86,65 @@ static void image_copy_16_to_8(AVFrame *pic, struct aom_image *img) // returns 0 on success, AVERROR_INVALIDDATA otherwise static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img) { - static const enum AVColorSpace colorspaces[10] = { - AVCOL_SPC_UNSPECIFIED, AVCOL_SPC_BT470BG, AVCOL_SPC_BT709, AVCOL_SPC_SMPTE170M, - AVCOL_SPC_SMPTE240M, AVCOL_SPC_BT2020_NCL, AVCOL_SPC_BT2020_CL, AVCOL_SPC_RGB, - AVCOL_SPC_ICTCP, AVCOL_SPC_RESERVED - }; static const enum AVColorRange color_ranges[] = { AVCOL_RANGE_MPEG, AVCOL_RANGE_JPEG }; avctx->color_range = color_ranges[img->range]; - avctx->colorspace = colorspaces[img->cs]; + avctx->color_primaries = img->cp; + avctx->colorspace = img->mc; + avctx->color_trc = img->tc; switch (img->fmt) { case AOM_IMG_FMT_I420: - avctx->pix_fmt = AV_PIX_FMT_YUV420P; - return 0; - case AOM_IMG_FMT_I422: - avctx->pix_fmt = AV_PIX_FMT_YUV422P; - return 0; - case AOM_IMG_FMT_I440: - avctx->pix_fmt = AV_PIX_FMT_YUV440P; - return 0; - case AOM_IMG_FMT_I444: - avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ? - AV_PIX_FMT_GBRP : AV_PIX_FMT_YUV444P; - return 0; 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) { - avctx->pix_fmt = AV_PIX_FMT_YUV420P10; + avctx->pix_fmt = img->monochrome ? + AV_PIX_FMT_GRAY10 : AV_PIX_FMT_YUV420P10; + avctx->profile = FF_PROFILE_AV1_MAIN; return 0; } else if (img->bit_depth == 12) { - avctx->pix_fmt = AV_PIX_FMT_YUV420P12; + avctx->pix_fmt = img->monochrome ? + AV_PIX_FMT_GRAY12 : AV_PIX_FMT_YUV420P12; + avctx->profile = FF_PROFILE_AV1_PROFESSIONAL; return 0; } else { return AVERROR_INVALIDDATA; } + case AOM_IMG_FMT_I422: case AOM_IMG_FMT_I42216: if (img->bit_depth == 8) { avctx->pix_fmt = AV_PIX_FMT_YUV422P; + avctx->profile = FF_PROFILE_AV1_PROFESSIONAL; return 0; } else if (img->bit_depth == 10) { avctx->pix_fmt = AV_PIX_FMT_YUV422P10; + avctx->profile = FF_PROFILE_AV1_PROFESSIONAL; return 0; } else if (img->bit_depth == 12) { avctx->pix_fmt = AV_PIX_FMT_YUV422P12; + avctx->profile = FF_PROFILE_AV1_PROFESSIONAL; return 0; } else { return AVERROR_INVALIDDATA; } - case AOM_IMG_FMT_I44016: - if (img->bit_depth == 8) { - avctx->pix_fmt = AV_PIX_FMT_YUV440P; - return 0; - } else if (img->bit_depth == 10) { - avctx->pix_fmt = AV_PIX_FMT_YUV440P10; - return 0; - } else if (img->bit_depth == 12) { - avctx->pix_fmt = AV_PIX_FMT_YUV440P12; - return 0; - } else { - return AVERROR_INVALIDDATA; - } + case AOM_IMG_FMT_I444: case AOM_IMG_FMT_I44416: if (img->bit_depth == 8) { - avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ? - AV_PIX_FMT_GBRP : AV_PIX_FMT_YUV444P; + avctx->pix_fmt = AV_PIX_FMT_YUV444P; + avctx->profile = FF_PROFILE_AV1_HIGH; return 0; } else if (img->bit_depth == 10) { - avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ? - AV_PIX_FMT_GBRP10 : AV_PIX_FMT_YUV444P10; + avctx->pix_fmt = AV_PIX_FMT_YUV444P10; + avctx->profile = FF_PROFILE_AV1_HIGH; return 0; } else if (img->bit_depth == 12) { - avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ? - AV_PIX_FMT_GBRP12 : AV_PIX_FMT_YUV444P12; + avctx->pix_fmt = AV_PIX_FMT_YUV444P12; + avctx->profile = FF_PROFILE_AV1_PROFESSIONAL; return 0; } else { return AVERROR_INVALIDDATA; @@ -245,5 +230,6 @@ AVCodec ff_libaom_av1_decoder = { .close = aom_free, .decode = aom_decode, .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1, + .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles), .wrapper_name = "libaom", };