Revision 4bd8e17c libavcodec/mpegaudio_parser.c

View differences:

libavcodec/mpegaudio_parser.c
22 22

  
23 23
#include "parser.h"
24 24
#include "mpegaudio.h"
25
#include "mpegaudiodecheader.h"
25 26

  
26 27

  
27 28
typedef struct MpegAudioParseContext {
......
41 42
#define SAME_HEADER_MASK \
42 43
   (0xffe00000 | (3 << 17) | (3 << 10) | (3 << 19))
43 44

  
45
/* useful helper to get mpeg audio stream infos. Return -1 if error in
46
   header, otherwise the coded frame size in bytes */
47
int mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate)
48
{
49
    MPADecodeContext s1, *s = &s1;
50
    s1.avctx = avctx;
51

  
52
    if (ff_mpa_check_header(head) != 0)
53
        return -1;
54

  
55
    if (decode_header(s, head) != 0) {
56
        return -1;
57
    }
58

  
59
    switch(s->layer) {
60
    case 1:
61
        avctx->frame_size = 384;
62
        break;
63
    case 2:
64
        avctx->frame_size = 1152;
65
        break;
66
    default:
67
    case 3:
68
        if (s->lsf)
69
            avctx->frame_size = 576;
70
        else
71
            avctx->frame_size = 1152;
72
        break;
73
    }
74

  
75
    *sample_rate = s->sample_rate;
76
    avctx->channels = s->nb_channels;
77
    avctx->bit_rate = s->bit_rate;
78
    avctx->sub_id = s->layer;
79
    return s->frame_size;
80
}
81

  
44 82
static int mpegaudio_parse_init(AVCodecParserContext *s1)
45 83
{
46 84
    MpegAudioParseContext *s = s1->priv_data;

Also available in: Unified diff