1 /*
2 * MPEG Audio parser
3 * Copyright (c) 2003 Fabrice Bellard
4 * Copyright (c) 2003 Michael Niedermayer
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
27
35
36 #define MPA_HEADER_SIZE 4
37
38 /* header + layer + freq + lsf/mpeg25 */
39 #define SAME_HEADER_MASK \
40 (0xffe00000 | (3 << 17) | (3 << 10) | (3 << 19))
41
44 const uint8_t **poutbuf,
int *poutbuf_size,
46 {
50 int i;
52 int flush = !buf_size;
53
54 for(i=0; i<buf_size; ){
57 i += inc;
59 state = 0;
60
62 next= i;
63 break;
64 }
65 }else{
66 while(i<buf_size){
69
70 state= (state<<8) + buf[i++];
71
73 if (ret < 4) {
74 if (i > 4)
76 } else {
83
92 }
93 }
94
97 next = buf_size;
100 "MP3ADU full parser");
101 return 0; /* parsers must not return error codes */
102 }
103
104 break;
105 }
106 }
107 }
108 }
109
113 *poutbuf_size = 0;
114 return buf_size;
115 }
116
117 if (flush && buf_size >=
ID3v1_TAG_SIZE && memcmp(buf,
"TAG", 3) == 0) {
119 *poutbuf_size = 0;
120 return next;
121 }
122
124 *poutbuf_size = buf_size;
125 return next;
126 }
127
128
134 };
static void flush(AVCodecContext *avctx)
int64_t bit_rate
the average bitrate
int duration
Duration of the current frame.
static int mpegaudio_parse(AVCodecParserContext *s1, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
AVCodecID
Identify the syntax and semantics of the bitstream.
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
preferred ID for decoding MPEG audio layer 1, 2 or 3
void ff_parse_close(AVCodecParserContext *s)
int sample_rate
samples per second
main external API structure.
uint32_t state
contains the last few bytes in MSB order
AVCodecParser ff_mpegaudio_parser
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
common internal and external API header
#define PARSER_FLAG_COMPLETE_FRAMES
int channels
number of audio channels