Originally committed as revision 12622 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -29,6 +29,7 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1, |
| 29 | 29 |
const uint8_t *buf, int buf_size) |
| 30 | 30 |
{
|
| 31 | 31 |
AACAC3ParseContext *s = s1->priv_data; |
| 32 |
+ AACAC3FrameFlag frame_flag; |
|
| 32 | 33 |
const uint8_t *buf_ptr; |
| 33 | 34 |
int len; |
| 34 | 35 |
|
| ... | ... |
@@ -50,7 +51,7 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1, |
| 50 | 50 |
|
| 51 | 51 |
if (s->frame_size == 0) {
|
| 52 | 52 |
if ((s->inbuf_ptr - s->inbuf) == s->header_size) {
|
| 53 |
- len = s->sync(s); |
|
| 53 |
+ len = s->sync(s, &frame_flag); |
|
| 54 | 54 |
if (len == 0) {
|
| 55 | 55 |
/* no sync found : move by one byte (inefficient, but simple!) */ |
| 56 | 56 |
memmove(s->inbuf, s->inbuf + 1, s->header_size - 1); |
| ... | ... |
@@ -26,18 +26,23 @@ |
| 26 | 26 |
#include <stdint.h> |
| 27 | 27 |
#include "avcodec.h" |
| 28 | 28 |
|
| 29 |
+typedef enum{
|
|
| 30 |
+ FRAME_COMPLETE, ///< Complete frame, ends previous frame |
|
| 31 |
+ FRAME_START, ///< Frame start, ends previous frame |
|
| 32 |
+ FRAME_CONTINUATION ///< Part of the previous frame |
|
| 33 |
+}AACAC3FrameFlag; |
|
| 34 |
+ |
|
| 29 | 35 |
typedef struct AACAC3ParseContext {
|
| 30 | 36 |
uint8_t *inbuf_ptr; |
| 31 | 37 |
int frame_size; |
| 32 | 38 |
int header_size; |
| 33 |
- int (*sync)(struct AACAC3ParseContext *hdr_info); |
|
| 39 |
+ int (*sync)(struct AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag); |
|
| 34 | 40 |
uint8_t inbuf[8192]; /* input buffer */ |
| 35 | 41 |
|
| 36 | 42 |
int channels; |
| 37 | 43 |
int sample_rate; |
| 38 | 44 |
int bit_rate; |
| 39 | 45 |
int samples; |
| 40 |
- uint8_t stream_type; |
|
| 41 | 46 |
} AACAC3ParseContext; |
| 42 | 47 |
|
| 43 | 48 |
int ff_aac_ac3_parse(AVCodecParserContext *s1, |
| ... | ... |
@@ -23,7 +23,6 @@ |
| 23 | 23 |
#include "parser.h" |
| 24 | 24 |
#include "aac_ac3_parser.h" |
| 25 | 25 |
#include "bitstream.h" |
| 26 |
-#include "ac3.h" |
|
| 27 | 26 |
|
| 28 | 27 |
|
| 29 | 28 |
#define AAC_HEADER_SIZE 7 |
| ... | ... |
@@ -39,7 +38,7 @@ static const int aac_channels[8] = {
|
| 39 | 39 |
}; |
| 40 | 40 |
|
| 41 | 41 |
|
| 42 |
-static int aac_sync(AACAC3ParseContext *hdr_info) |
|
| 42 |
+static int aac_sync(AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag) |
|
| 43 | 43 |
{
|
| 44 | 44 |
GetBitContext bits; |
| 45 | 45 |
int size, rdb, ch, sr; |
| ... | ... |
@@ -77,6 +76,7 @@ static int aac_sync(AACAC3ParseContext *hdr_info) |
| 77 | 77 |
hdr_info->sample_rate = aac_sample_rates[sr]; |
| 78 | 78 |
hdr_info->samples = (rdb + 1) * 1024; |
| 79 | 79 |
hdr_info->bit_rate = size * 8 * hdr_info->sample_rate / hdr_info->samples; |
| 80 |
+ *flag = FRAME_COMPLETE; |
|
| 80 | 81 |
|
| 81 | 82 |
return size; |
| 82 | 83 |
} |
| ... | ... |
@@ -84,7 +84,6 @@ static int aac_sync(AACAC3ParseContext *hdr_info) |
| 84 | 84 |
static av_cold int aac_parse_init(AVCodecParserContext *s1) |
| 85 | 85 |
{
|
| 86 | 86 |
AACAC3ParseContext *s = s1->priv_data; |
| 87 |
- s->stream_type = EAC3_STREAM_TYPE_INDEPENDENT; |
|
| 88 | 87 |
s->inbuf_ptr = s->inbuf; |
| 89 | 88 |
s->header_size = AAC_HEADER_SIZE; |
| 90 | 89 |
s->sync = aac_sync; |
| ... | ... |
@@ -123,7 +123,7 @@ int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr) |
| 123 | 123 |
return 0; |
| 124 | 124 |
} |
| 125 | 125 |
|
| 126 |
-static int ac3_sync(AACAC3ParseContext *hdr_info) |
|
| 126 |
+static int ac3_sync(AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag) |
|
| 127 | 127 |
{
|
| 128 | 128 |
int err; |
| 129 | 129 |
AC3HeaderInfo hdr; |
| ... | ... |
@@ -137,6 +137,18 @@ static int ac3_sync(AACAC3ParseContext *hdr_info) |
| 137 | 137 |
hdr_info->bit_rate = hdr.bit_rate; |
| 138 | 138 |
hdr_info->channels = hdr.channels; |
| 139 | 139 |
hdr_info->samples = AC3_FRAME_SIZE; |
| 140 |
+ |
|
| 141 |
+ switch(hdr.stream_type){
|
|
| 142 |
+ case EAC3_STREAM_TYPE_INDEPENDENT: |
|
| 143 |
+ *flag = FRAME_START; |
|
| 144 |
+ break; |
|
| 145 |
+ case EAC3_STREAM_TYPE_DEPENDENT: |
|
| 146 |
+ *flag = FRAME_CONTINUATION; |
|
| 147 |
+ break; |
|
| 148 |
+ case EAC3_STREAM_TYPE_AC3_CONVERT: |
|
| 149 |
+ *flag = FRAME_COMPLETE; |
|
| 150 |
+ break; |
|
| 151 |
+ } |
|
| 140 | 152 |
return hdr.frame_size; |
| 141 | 153 |
} |
| 142 | 154 |
|