[FFmpeg-cvslog] avcode/profiles: add AV1 profiles

James Almer git at videolan.org
Thu Mar 29 06:24:39 EEST 2018


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Mar 28 23:28:34 2018 -0300| [c0f0c9f5318786904bc87f9278868ff3c3a7802d] | committer: James Almer

avcode/profiles: add AV1 profiles

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c0f0c9f5318786904bc87f9278868ff3c3a7802d
---

 libavcodec/codec_desc.c |  1 +
 libavcodec/libaomdec.c  | 14 ++++++++++++++
 libavcodec/libaomenc.c  |  2 ++
 libavcodec/profiles.c   |  7 +++++++
 libavcodec/profiles.h   |  1 +
 5 files changed, 25 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index da7c0871a2..79552a910d 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1602,6 +1602,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
         .name      = "av1",
         .long_name = NULL_IF_CONFIG_SMALL("Alliance for Open Media AV1"),
         .props     = AV_CODEC_PROP_LOSSY,
+        .profiles  = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
     },
     {
         .id        = AV_CODEC_ID_BITPACKED,
diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c
index 29f0afd2ac..05e476c342 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;
@@ -98,23 +99,29 @@ static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img)
     switch (img->fmt) {
     case AOM_IMG_FMT_I420:
         avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+        avctx->profile = FF_PROFILE_AV1_MAIN;
         return 0;
     case AOM_IMG_FMT_I422:
         avctx->pix_fmt = AV_PIX_FMT_YUV422P;
+        avctx->profile = FF_PROFILE_AV1_PROFESSIONAL;
         return 0;
     case AOM_IMG_FMT_I444:
         avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ?
                          AV_PIX_FMT_GBRP : AV_PIX_FMT_YUV444P;
+        avctx->profile = FF_PROFILE_AV1_HIGH;
         return 0;
     case AOM_IMG_FMT_I42016:
         if (img->bit_depth == 8) {
             avctx->pix_fmt = 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->profile = FF_PROFILE_AV1_MAIN;
             return 0;
         } else if (img->bit_depth == 12) {
             avctx->pix_fmt = AV_PIX_FMT_YUV420P12;
+            avctx->profile = FF_PROFILE_AV1_PROFESSIONAL;
             return 0;
         } else {
             return AVERROR_INVALIDDATA;
@@ -122,12 +129,15 @@ static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img)
     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;
@@ -136,14 +146,17 @@ static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img)
         if (img->bit_depth == 8) {
             avctx->pix_fmt = avctx->colorspace == AVCOL_SPC_RGB ?
                              AV_PIX_FMT_GBRP : 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->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->profile = FF_PROFILE_AV1_PROFESSIONAL;
             return 0;
         } else {
             return AVERROR_INVALIDDATA;
@@ -229,5 +242,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",
 };
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index a80bcbf522..e5665cb5fa 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -35,6 +35,7 @@
 
 #include "avcodec.h"
 #include "internal.h"
+#include "profiles.h"
 
 /*
  * Portion of struct aom_codec_cx_pkt from aom_encoder.h.
@@ -735,6 +736,7 @@ AVCodec ff_libaom_av1_encoder = {
     .encode2        = aom_encode,
     .close          = aom_free,
     .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_EXPERIMENTAL,
+    .profiles       = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
     .priv_class     = &class_aom,
     .defaults       = defaults,
     .init_static_data = av1_init_static,
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 721587b3a6..d7dc960f36 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -140,6 +140,13 @@ const AVProfile ff_vp9_profiles[] = {
     { FF_PROFILE_UNKNOWN },
 };
 
+const AVProfile ff_av1_profiles[] = {
+    { FF_PROFILE_AV1_MAIN,         "Main" },
+    { FF_PROFILE_AV1_HIGH,         "High" },
+    { FF_PROFILE_AV1_PROFESSIONAL, "Professional" },
+    { FF_PROFILE_UNKNOWN },
+};
+
 const AVProfile ff_sbc_profiles[] = {
     { FF_PROFILE_SBC_MSBC, "mSBC" },
     { FF_PROFILE_UNKNOWN },
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 3783c10c39..9d7e211e15 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -31,6 +31,7 @@ extern const AVProfile ff_mpeg2_video_profiles[];
 extern const AVProfile ff_mpeg4_video_profiles[];
 extern const AVProfile ff_vc1_profiles[];
 extern const AVProfile ff_vp9_profiles[];
+extern const AVProfile ff_av1_profiles[];
 extern const AVProfile ff_sbc_profiles[];
 
 #endif /* AVCODEC_PROFILES_H */



More information about the ffmpeg-cvslog mailing list