Revision be1e2a2b

View differences:

libavcodec/aac_ac3_parser.c
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 51

  
51 52
        if (s->frame_size == 0) {
52 53
            if ((s->inbuf_ptr - s->inbuf) == s->header_size) {
53
                len = s->sync(s);
54
                len = s->sync(s, &frame_flag);
54 55
                if (len == 0) {
55 56
                    /* no sync found : move by one byte (inefficient, but simple!) */
56 57
                    memmove(s->inbuf, s->inbuf + 1, s->header_size - 1);
libavcodec/aac_ac3_parser.h
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,
libavcodec/aac_parser.c
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 38
};
40 39

  
41 40

  
42
static int aac_sync(AACAC3ParseContext *hdr_info)
41
static int aac_sync(AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag)
43 42
{
44 43
    GetBitContext bits;
45 44
    int size, rdb, ch, sr;
......
77 76
    hdr_info->sample_rate = aac_sample_rates[sr];
78 77
    hdr_info->samples = (rdb + 1) * 1024;
79 78
    hdr_info->bit_rate = size * 8 * hdr_info->sample_rate / hdr_info->samples;
79
    *flag = FRAME_COMPLETE;
80 80

  
81 81
    return size;
82 82
}
......
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;
libavcodec/ac3_parser.c
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 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

  

Also available in: Unified diff