~ubuntu-branches/ubuntu/lucid/ffmpeg/lucid-updates

« back to all changes in this revision

Viewing changes to libavcodec/mpegaudio_parser.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-01-20 17:51:19 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120175119-gu6kw1arv5tmf1vr
Tags: 3:0.svn20090119-1ubuntu1+unstripped1
* merge with the ubuntu.jaunty branch
* reenable x264 LP: #303537
* build against vdpau
* enable xvmc support

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
/* useful helper to get mpeg audio stream infos. Return -1 if error in
46
46
   header, otherwise the coded frame size in bytes */
47
 
int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate)
 
47
int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate)
48
48
{
49
49
    MPADecodeContext s1, *s = &s1;
50
50
    s1.avctx = avctx;
58
58
 
59
59
    switch(s->layer) {
60
60
    case 1:
61
 
        avctx->frame_size = 384;
 
61
        avctx->codec_id = CODEC_ID_MP1;
 
62
        *frame_size = 384;
62
63
        break;
63
64
    case 2:
64
 
        avctx->frame_size = 1152;
 
65
        avctx->codec_id = CODEC_ID_MP2;
 
66
        *frame_size = 1152;
65
67
        break;
66
68
    default:
67
69
    case 3:
 
70
        avctx->codec_id = CODEC_ID_MP3;
68
71
        if (s->lsf)
69
 
            avctx->frame_size = 576;
 
72
            *frame_size = 576;
70
73
        else
71
 
            avctx->frame_size = 1152;
 
74
            *frame_size = 1152;
72
75
        break;
73
76
    }
74
77
 
75
78
    *sample_rate = s->sample_rate;
76
 
    avctx->channels = s->nb_channels;
77
 
    avctx->bit_rate = s->bit_rate;
 
79
    *channels = s->nb_channels;
 
80
    *bit_rate = s->bit_rate;
78
81
    avctx->sub_id = s->layer;
79
82
    return s->frame_size;
80
83
}
92
95
                           const uint8_t *buf, int buf_size)
93
96
{
94
97
    MpegAudioParseContext *s = s1->priv_data;
95
 
    int len, ret, sr;
 
98
    int len, ret, sr, channels, bit_rate, frame_size;
96
99
    uint32_t header;
97
100
    const uint8_t *buf_ptr;
98
101
 
123
126
            got_header:
124
127
                header = AV_RB32(s->inbuf);
125
128
 
126
 
                ret = ff_mpa_decode_header(avctx, header, &sr);
 
129
                ret = ff_mpa_decode_header(avctx, header, &sr, &channels, &frame_size, &bit_rate);
127
130
                if (ret < 0) {
128
131
                    s->header_count= -2;
129
132
                    /* no sync found : move by one byte (inefficient, but simple!) */
146
149
                        s->frame_size = -1;
147
150
                    }
148
151
#endif
149
 
                    if(s->header_count > 1)
 
152
                    if(s->header_count > 1){
150
153
                        avctx->sample_rate= sr;
 
154
                        avctx->channels   = channels;
 
155
                        avctx->frame_size = frame_size;
 
156
                        avctx->bit_rate   = bit_rate;
 
157
                    }
151
158
                }
152
159
            }
153
160
        } else
244
251
 
245
252
 
246
253
AVCodecParser mpegaudio_parser = {
247
 
    { CODEC_ID_MP2, CODEC_ID_MP3 },
 
254
    { CODEC_ID_MP1, CODEC_ID_MP2, CODEC_ID_MP3 },
248
255
    sizeof(MpegAudioParseContext),
249
256
    mpegaudio_parse_init,
250
257
    mpegaudio_parse,