mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-09 14:14:39 +02:00
dont set the sampling rate just because 1 mp3 packet header says so (fixes playback speed on some old mencoder generated avis which where then dumped to mp3)
Originally committed as revision 6837 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
c0d8052b50
commit
498c544ad2
@ -72,7 +72,7 @@ typedef int32_t MPA_INT;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int l2_select_table(int bitrate, int nb_channels, int freq, int lsf);
|
int l2_select_table(int bitrate, int nb_channels, int freq, int lsf);
|
||||||
int mpa_decode_header(AVCodecContext *avctx, uint32_t head);
|
int mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate);
|
||||||
void ff_mpa_synth_init(MPA_INT *window);
|
void ff_mpa_synth_init(MPA_INT *window);
|
||||||
void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
|
void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
|
||||||
MPA_INT *window, int *dither_state,
|
MPA_INT *window, int *dither_state,
|
||||||
|
@ -1190,7 +1190,7 @@ static int decode_header(MPADecodeContext *s, uint32_t header)
|
|||||||
|
|
||||||
/* 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 mpa_decode_header(AVCodecContext *avctx, uint32_t head)
|
int mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate)
|
||||||
{
|
{
|
||||||
MPADecodeContext s1, *s = &s1;
|
MPADecodeContext s1, *s = &s1;
|
||||||
|
|
||||||
@ -1217,7 +1217,7 @@ int mpa_decode_header(AVCodecContext *avctx, uint32_t head)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
avctx->sample_rate = s->sample_rate;
|
*sample_rate = s->sample_rate;
|
||||||
avctx->channels = s->nb_channels;
|
avctx->channels = s->nb_channels;
|
||||||
avctx->bit_rate = s->bit_rate;
|
avctx->bit_rate = s->bit_rate;
|
||||||
avctx->sub_id = s->layer;
|
avctx->sub_id = s->layer;
|
||||||
@ -2547,7 +2547,6 @@ retry:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* update codec info */
|
/* update codec info */
|
||||||
avctx->sample_rate = s->sample_rate;
|
|
||||||
avctx->channels = s->nb_channels;
|
avctx->channels = s->nb_channels;
|
||||||
avctx->bit_rate = s->bit_rate;
|
avctx->bit_rate = s->bit_rate;
|
||||||
avctx->sub_id = s->layer;
|
avctx->sub_id = s->layer;
|
||||||
@ -2574,9 +2573,11 @@ retry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
out_size = mp_decode_frame(s, out_samples, buf, buf_size);
|
out_size = mp_decode_frame(s, out_samples, buf, buf_size);
|
||||||
if(out_size>=0)
|
if(out_size>=0){
|
||||||
*data_size = out_size;
|
*data_size = out_size;
|
||||||
else
|
avctx->sample_rate = s->sample_rate;
|
||||||
|
//FIXME maybe move the other codec info stuff from above here too
|
||||||
|
}else
|
||||||
av_log(avctx, AV_LOG_DEBUG, "Error while decoding MPEG audio frame.\n"); //FIXME return -1 / but also return the number of bytes consumed
|
av_log(avctx, AV_LOG_DEBUG, "Error while decoding MPEG audio frame.\n"); //FIXME return -1 / but also return the number of bytes consumed
|
||||||
s->frame_size = 0;
|
s->frame_size = 0;
|
||||||
return buf_size;
|
return buf_size;
|
||||||
|
@ -666,11 +666,10 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
|
|||||||
}
|
}
|
||||||
if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) {
|
if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) {
|
||||||
got_header:
|
got_header:
|
||||||
sr= avctx->sample_rate;
|
|
||||||
header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
|
header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
|
||||||
(s->inbuf[2] << 8) | s->inbuf[3];
|
(s->inbuf[2] << 8) | s->inbuf[3];
|
||||||
|
|
||||||
ret = mpa_decode_header(avctx, header);
|
ret = mpa_decode_header(avctx, header, &sr);
|
||||||
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!) */
|
||||||
@ -694,8 +693,8 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if(s->header_count <= 0)
|
if(s->header_count > 1)
|
||||||
avctx->sample_rate= sr; //FIXME ugly
|
avctx->sample_rate= sr;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -247,7 +247,7 @@ static void id3_create_tag(AVFormatContext *s, uint8_t *buf)
|
|||||||
static int mp3_read_probe(AVProbeData *p)
|
static int mp3_read_probe(AVProbeData *p)
|
||||||
{
|
{
|
||||||
int max_frames, first_frames;
|
int max_frames, first_frames;
|
||||||
int fsize, frames;
|
int fsize, frames, sample_rate;
|
||||||
uint32_t header;
|
uint32_t header;
|
||||||
uint8_t *buf, *buf2, *end;
|
uint8_t *buf, *buf2, *end;
|
||||||
AVCodecContext avctx;
|
AVCodecContext avctx;
|
||||||
@ -267,7 +267,7 @@ static int mp3_read_probe(AVProbeData *p)
|
|||||||
|
|
||||||
for(frames = 0; buf2 < end; frames++) {
|
for(frames = 0; buf2 < end; frames++) {
|
||||||
header = (buf2[0] << 24) | (buf2[1] << 16) | (buf2[2] << 8) | buf2[3];
|
header = (buf2[0] << 24) | (buf2[1] << 16) | (buf2[2] << 8) | buf2[3];
|
||||||
fsize = mpa_decode_header(&avctx, header);
|
fsize = mpa_decode_header(&avctx, header, &sample_rate);
|
||||||
if(fsize < 0)
|
if(fsize < 0)
|
||||||
break;
|
break;
|
||||||
buf2 += fsize;
|
buf2 += fsize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user