|
|
@ -44,7 +44,7 @@ typedef struct MpegAudioParseContext { |
|
|
|
|
|
|
|
|
|
|
|
/* useful helper to get mpeg audio stream infos. Return -1 if error in
|
|
|
|
/* useful helper to get mpeg audio stream infos. Return -1 if error in
|
|
|
|
header, otherwise the coded frame size in bytes */ |
|
|
|
header, otherwise the coded frame size in bytes */ |
|
|
|
int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate) |
|
|
|
int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MPADecodeContext s1, *s = &s1; |
|
|
|
MPADecodeContext s1, *s = &s1; |
|
|
|
s1.avctx = avctx; |
|
|
|
s1.avctx = avctx; |
|
|
@ -58,23 +58,23 @@ int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate) |
|
|
|
|
|
|
|
|
|
|
|
switch(s->layer) { |
|
|
|
switch(s->layer) { |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
avctx->frame_size = 384; |
|
|
|
*frame_size = 384; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
avctx->frame_size = 1152; |
|
|
|
*frame_size = 1152; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
case 3: |
|
|
|
case 3: |
|
|
|
if (s->lsf) |
|
|
|
if (s->lsf) |
|
|
|
avctx->frame_size = 576; |
|
|
|
*frame_size = 576; |
|
|
|
else |
|
|
|
else |
|
|
|
avctx->frame_size = 1152; |
|
|
|
*frame_size = 1152; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
*sample_rate = s->sample_rate; |
|
|
|
*sample_rate = s->sample_rate; |
|
|
|
avctx->channels = s->nb_channels; |
|
|
|
*channels = s->nb_channels; |
|
|
|
avctx->bit_rate = s->bit_rate; |
|
|
|
*bit_rate = s->bit_rate; |
|
|
|
avctx->sub_id = s->layer; |
|
|
|
avctx->sub_id = s->layer; |
|
|
|
return s->frame_size; |
|
|
|
return s->frame_size; |
|
|
|
} |
|
|
|
} |
|
|
@ -92,7 +92,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1, |
|
|
|
const uint8_t *buf, int buf_size) |
|
|
|
const uint8_t *buf, int buf_size) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MpegAudioParseContext *s = s1->priv_data; |
|
|
|
MpegAudioParseContext *s = s1->priv_data; |
|
|
|
int len, ret, sr; |
|
|
|
int len, ret, sr, channels, bit_rate, frame_size; |
|
|
|
uint32_t header; |
|
|
|
uint32_t header; |
|
|
|
const uint8_t *buf_ptr; |
|
|
|
const uint8_t *buf_ptr; |
|
|
|
|
|
|
|
|
|
|
@ -123,7 +123,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1, |
|
|
|
got_header: |
|
|
|
got_header: |
|
|
|
header = AV_RB32(s->inbuf); |
|
|
|
header = AV_RB32(s->inbuf); |
|
|
|
|
|
|
|
|
|
|
|
ret = ff_mpa_decode_header(avctx, header, &sr); |
|
|
|
ret = ff_mpa_decode_header(avctx, header, &sr, &channels, &frame_size, &bit_rate); |
|
|
|
if (ret < 0) { |
|
|
|
if (ret < 0) { |
|
|
|
s->header_count= -2; |
|
|
|
s->header_count= -2; |
|
|
|
/* no sync found : move by one byte (inefficient, but simple!) */ |
|
|
|
/* no sync found : move by one byte (inefficient, but simple!) */ |
|
|
@ -146,8 +146,12 @@ static int mpegaudio_parse(AVCodecParserContext *s1, |
|
|
|
s->frame_size = -1; |
|
|
|
s->frame_size = -1; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if(s->header_count > 1) |
|
|
|
if(s->header_count > 1){ |
|
|
|
avctx->sample_rate= sr; |
|
|
|
avctx->sample_rate= sr; |
|
|
|
|
|
|
|
avctx->channels = channels; |
|
|
|
|
|
|
|
avctx->frame_size = frame_size; |
|
|
|
|
|
|
|
avctx->bit_rate = bit_rate; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else |
|
|
|
} else |
|
|
|