loosen dependencies over mpegaudiodec

Originally committed as revision 9080 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Aurelien Jacobs
2007-05-20 13:40:07 +00:00
parent 663deb54af
commit 4bd8e17c8d
7 changed files with 234 additions and 155 deletions

View File

@@ -22,6 +22,7 @@
#include "parser.h"
#include "mpegaudio.h"
#include "mpegaudiodecheader.h"
typedef struct MpegAudioParseContext {
@@ -41,6 +42,43 @@ typedef struct MpegAudioParseContext {
#define SAME_HEADER_MASK \
(0xffe00000 | (3 << 17) | (3 << 10) | (3 << 19))
/* useful helper to get mpeg audio stream infos. Return -1 if error in
header, otherwise the coded frame size in bytes */
int mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate)
{
MPADecodeContext s1, *s = &s1;
s1.avctx = avctx;
if (ff_mpa_check_header(head) != 0)
return -1;
if (decode_header(s, head) != 0) {
return -1;
}
switch(s->layer) {
case 1:
avctx->frame_size = 384;
break;
case 2:
avctx->frame_size = 1152;
break;
default:
case 3:
if (s->lsf)
avctx->frame_size = 576;
else
avctx->frame_size = 1152;
break;
}
*sample_rate = s->sample_rate;
avctx->channels = s->nb_channels;
avctx->bit_rate = s->bit_rate;
avctx->sub_id = s->layer;
return s->frame_size;
}
static int mpegaudio_parse_init(AVCodecParserContext *s1)
{
MpegAudioParseContext *s = s1->priv_data;