[FFmpeg-devel] [PATCH v5 4/4] avformat/flvdec: support demux av1 in Enhanced FLV

Steven Liu lq at chinaffmpeg.org
Wed Apr 12 07:37:37 EEST 2023


Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
 libavformat/flv.h    |  1 +
 libavformat/flvdec.c | 20 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/libavformat/flv.h b/libavformat/flv.h
index 44d3b04ff9..398a958e60 100644
--- a/libavformat/flv.h
+++ b/libavformat/flv.h
@@ -117,6 +117,7 @@ enum {
     FLV_CODECID_REALH263= 8,
     FLV_CODECID_MPEG4   = 9,
     FLV_CODECID_HEVC    = 10,
+    FLV_CODECID_AV1     = 11,
 };
 
 enum {
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 8060c43772..525c5b2e97 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -319,6 +319,9 @@ static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters *vpar, int
             case MKBETAG('h', 'v', 'c', '1'):
                 flv_codecid = FLV_CODECID_HEVC;
                 break;
+            case MKBETAG('a', 'v', '0', '1'):
+                flv_codecid = FLV_CODECID_AV1;
+                break;
             default:
                 break;
         }
@@ -339,6 +342,8 @@ static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters *vpar, int
         return vpar->codec_id == AV_CODEC_ID_H264;
     case FLV_CODECID_HEVC:
         return vpar->codec_id == AV_CODEC_ID_HEVC;
+    case FLV_CODECID_AV1:
+        return vpar->codec_id == AV_CODEC_ID_AV1;
     default:
         return vpar->codec_tag == flv_codecid;
     }
@@ -361,6 +366,9 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,
             case MKBETAG('h', 'v', 'c', '1'):
                 flv_codecid = FLV_CODECID_HEVC;
                 break;
+            case MKBETAG('a', 'v', '0', '1'):
+                flv_codecid = FLV_CODECID_AV1;
+                break;
             default:
                 break;
         }
@@ -408,6 +416,12 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,
         vstreami->need_parsing = AVSTREAM_PARSE_HEADERS;
         ret = 3;
         break;
+    case FLV_CODECID_AV1:
+        par->codec_id = AV_CODEC_ID_AV1;
+        vstreami->need_parsing = AVSTREAM_PARSE_HEADERS;
+        ret = 3;
+        break;
+
     default:
         avpriv_request_sample(s, "Video codec (%x)", flv_codecid);
         par->codec_tag = flv_codecid;
@@ -1285,7 +1299,8 @@ retry_duration:
     if (st->codecpar->codec_id == AV_CODEC_ID_AAC ||
         st->codecpar->codec_id == AV_CODEC_ID_H264 ||
         st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
-        st->codecpar->codec_id == AV_CODEC_ID_HEVC) {
+        st->codecpar->codec_id == AV_CODEC_ID_HEVC ||
+        st->codecpar->codec_id == AV_CODEC_ID_AV1) {
         int type = 0;
         if (flv->exheader) {
             type = flags & 0x0F;
@@ -1316,7 +1331,8 @@ retry_duration:
             }
         }
         if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC ||
-            st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_HEVC)) {
+            st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_HEVC ||
+            st->codecpar->codec_id == AV_CODEC_ID_AV1)) {
             AVDictionaryEntry *t;
 
             if (st->codecpar->extradata) {
-- 
2.40.0



More information about the ffmpeg-devel mailing list