[FFmpeg-devel] [PATCH 06/11] avcodec/aac_parser: set key_frame and profile

James Almer jamrial at gmail.com
Mon Nov 18 04:04:18 EET 2024


This is in preparation for a following change.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/aac_ac3_parser.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index f45631d09f..2b4f92dd18 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -25,6 +25,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "parser.h"
+#include "profiles.h"
 #include "aac_ac3_parser.h"
 #include "ac3_parser_internal.h"
 #include "adts_header.h"
@@ -40,6 +41,8 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1,
     int new_frame_start;
     int got_frame = 0;
 
+    s1->key_frame = -1;
+
     if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) {
         i = buf_size;
         got_frame = 1;
@@ -145,10 +148,21 @@ get_next:
         } else {
 #if CONFIG_AAC_PARSER
             AACADTSHeaderInfo hdr;
+            GetBitContext gb;
+            int profile;
+            init_get_bits8(&gb, buf, buf_size);
             if (buf_size < AV_AAC_ADTS_HEADER_SIZE ||
-                ff_adts_header_parse_buf(buf, &hdr) < 0)
+                ff_adts_header_parse(&gb, &hdr) < 0)
                 return i;
 
+            profile = hdr.object_type - 1;
+            for (int j = 0; avctx->profile != profile &&
+                            ff_aac_profiles[j].profile != AV_PROFILE_UNKNOWN; j++) {
+                if (profile != ff_aac_profiles[j].profile)
+                    continue;
+                avctx->profile = profile; // ensure it's a known profile
+            }
+            s1->key_frame = (avctx->profile == AV_PROFILE_AAC_USAC) ? get_bits1(&gb) : 1;
             bit_rate = hdr.bit_rate;
 #endif
         }
-- 
2.47.0



More information about the ffmpeg-devel mailing list