On piÄ…tek, 28 marca 2008, Michael Niedermayer wrote:
> There are 3 types in EAC3
> Type 0: always start a frame and may or may not have further parts
> following Type 1: never start a frame and may or may not have further parts
> following Type 2: always start a frame and never have further parts
> following
>
> That is
>
> |T0 | T0 T1 | T0 T1 T1 ... T1 | T2 |
>
> are all and the only valid combinations accoriding to my spec
>
> I cannot map this to your code at all
>
> [...]

You're right I forgot about frames EAC3_STREAM_TYPE_AC3_CONVERT type, which 
should be given FRAME_COMPLETE flag

-- 
Bartlomiej Wolowiec
Index: libavcodec/aac_ac3_parser.c
===================================================================
--- libavcodec/aac_ac3_parser.c	(wersja 12621)
+++ libavcodec/aac_ac3_parser.c	(kopia robocza)
@@ -29,6 +29,7 @@
                      const uint8_t *buf, int buf_size)
 {
     AACAC3ParseContext *s = s1->priv_data;
+    AACAC3FrameFlag frame_flag;
     const uint8_t *buf_ptr;
     int len;
 
@@ -50,7 +51,7 @@
 
         if (s->frame_size == 0) {
             if ((s->inbuf_ptr - s->inbuf) == s->header_size) {
-                len = s->sync(s);
+                len = s->sync(s, &frame_flag);
                 if (len == 0) {
                     /* no sync found : move by one byte (inefficient, but simple!) */
                     memmove(s->inbuf, s->inbuf + 1, s->header_size - 1);
Index: libavcodec/aac_ac3_parser.h
===================================================================
--- libavcodec/aac_ac3_parser.h	(wersja 12621)
+++ libavcodec/aac_ac3_parser.h	(kopia robocza)
@@ -26,18 +26,27 @@
 #include <stdint.h>
 #include "avcodec.h"
 
+typedef enum{
+    /** finishes portions of data */
+    FRAME_COMPLETE,
+    /** starts portions of data
+     * (if there are any frames in the buffer they're send) */
+    FRAME_START,
+    /** continues portions of data (adds them to buffer) */
+    FRAME_CONTINUATION
+}AACAC3FrameFlag;
+
 typedef struct AACAC3ParseContext {
     uint8_t *inbuf_ptr;
     int frame_size;
     int header_size;
-    int (*sync)(struct AACAC3ParseContext *hdr_info);
+    int (*sync)(struct AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag);
     uint8_t inbuf[8192]; /* input buffer */
 
     int channels;
     int sample_rate;
     int bit_rate;
     int samples;
-    uint8_t stream_type;
 } AACAC3ParseContext;
 
 int ff_aac_ac3_parse(AVCodecParserContext *s1,
Index: libavcodec/aac_parser.c
===================================================================
--- libavcodec/aac_parser.c	(wersja 12621)
+++ libavcodec/aac_parser.c	(kopia robocza)
@@ -23,7 +23,6 @@
 #include "parser.h"
 #include "aac_ac3_parser.h"
 #include "bitstream.h"
-#include "ac3.h"
 
 
 #define AAC_HEADER_SIZE 7
@@ -39,7 +38,7 @@
 };
 
 
-static int aac_sync(AACAC3ParseContext *hdr_info)
+static int aac_sync(AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag)
 {
     GetBitContext bits;
     int size, rdb, ch, sr;
@@ -77,6 +76,7 @@
     hdr_info->sample_rate = aac_sample_rates[sr];
     hdr_info->samples = (rdb + 1) * 1024;
     hdr_info->bit_rate = size * 8 * hdr_info->sample_rate / hdr_info->samples;
+    *flag = FRAME_COMPLETE;
 
     return size;
 }
@@ -84,7 +84,6 @@
 static av_cold int aac_parse_init(AVCodecParserContext *s1)
 {
     AACAC3ParseContext *s = s1->priv_data;
-    s->stream_type = EAC3_STREAM_TYPE_INDEPENDENT;
     s->inbuf_ptr = s->inbuf;
     s->header_size = AAC_HEADER_SIZE;
     s->sync = aac_sync;
Index: libavcodec/ac3_parser.c
===================================================================
--- libavcodec/ac3_parser.c	(wersja 12621)
+++ libavcodec/ac3_parser.c	(kopia robocza)
@@ -123,7 +123,7 @@
     return 0;
 }
 
-static int ac3_sync(AACAC3ParseContext *hdr_info)
+static int ac3_sync(AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag)
 {
     int err;
     AC3HeaderInfo hdr;
@@ -137,6 +137,18 @@
     hdr_info->bit_rate = hdr.bit_rate;
     hdr_info->channels = hdr.channels;
     hdr_info->samples = AC3_FRAME_SIZE;
+
+    switch(hdr.stream_type){
+        case EAC3_STREAM_TYPE_INDEPENDENT:
+            *flag = FRAME_START;
+            break;
+        case EAC3_STREAM_TYPE_DEPENDENT:
+            *flag = FRAME_CONTINUATION;
+            break;
+        case EAC3_STREAM_TYPE_AC3_CONVERT:
+            *flag = FRAME_COMPLETE;
+            break;
+    }
     return hdr.frame_size;
 }
 
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to