comparison mp3.c @ 1107:921c8af78310 libavformat

probe for mpeg audio
author mru
date Mon, 05 Jun 2006 22:41:14 +0000
parents edbe5c3717f9
children d89d7ef290da
comparison
equal deleted inserted replaced
1106:8f78a071554d 1107:921c8af78310
238 } 238 }
239 } 239 }
240 } 240 }
241 241
242 /* mp3 read */ 242 /* mp3 read */
243
244 static int mp3_read_probe(AVProbeData *p)
245 {
246 int d;
247
248 if(p->buf_size < 4)
249 return 0;
250
251 if(p->buf[0] == 'I' && p->buf[1] == 'D' && p->buf[2] == '3' &&
252 p->buf[3] < 5)
253 return AVPROBE_SCORE_MAX;
254
255 if(p->buf[0] != 0xff)
256 return 0;
257
258 d = p->buf[1];
259 if((d & 0xe0) != 0xe0 || ((d & 0x18) == 0x08 || (d & 0x06) == 0))
260 return 0;
261
262 d = p->buf[2];
263 if((d & 0xf0) == 0xf0 || (d & 0x0c) == 0x0c)
264 return 0;
265
266 return AVPROBE_SCORE_MAX;
267 }
268
243 static int mp3_read_header(AVFormatContext *s, 269 static int mp3_read_header(AVFormatContext *s,
244 AVFormatParameters *ap) 270 AVFormatParameters *ap)
245 { 271 {
246 AVStream *st; 272 AVStream *st;
247 uint8_t buf[ID3_TAG_SIZE]; 273 uint8_t buf[ID3_TAG_SIZE];
344 370
345 AVInputFormat mp3_iformat = { 371 AVInputFormat mp3_iformat = {
346 "mp3", 372 "mp3",
347 "MPEG audio", 373 "MPEG audio",
348 0, 374 0,
349 NULL, 375 mp3_read_probe,
350 mp3_read_header, 376 mp3_read_header,
351 mp3_read_packet, 377 mp3_read_packet,
352 mp3_read_close, 378 mp3_read_close,
353 .extensions = "mp2,mp3,m2a", /* XXX: use probe */ 379 .extensions = "mp2,mp3,m2a", /* XXX: use probe */
354 }; 380 };