mp3enc: fix playback with mp3 encoded files on some devices.

This partially reverts 1fea432b; header variable needs to keep its value
in case it triggers "if (needed <= c.frame_size)".
This commit is contained in:
Clément Bœsch 2012-01-02 09:39:11 +01:00 committed by Clément Bœsch
parent 940d3cc0b0
commit e1a8164d62

View File

@ -160,7 +160,7 @@ static int mp3_write_xing(AVFormatContext *s)
int best_bitrate_idx; int best_bitrate_idx;
int best_bitrate_error= INT_MAX; int best_bitrate_error= INT_MAX;
int64_t xing_offset; int64_t xing_offset;
int32_t header; int32_t header, mask;
MPADecodeHeader c; MPADecodeHeader c;
int srate_idx, i, channels; int srate_idx, i, channels;
int needed; int needed;
@ -200,8 +200,9 @@ static int mp3_write_xing(AVFormatContext *s)
for (bitrate_idx= best_bitrate_idx;; bitrate_idx++) { for (bitrate_idx= best_bitrate_idx;; bitrate_idx++) {
if (15 == bitrate_idx) if (15 == bitrate_idx)
return -1; return -1;
mask = bitrate_idx << (4+8);
avpriv_mpegaudio_decode_header(&c, header | (bitrate_idx << (4+8))); header |= mask;
avpriv_mpegaudio_decode_header(&c, header);
xing_offset=xing_offtbl[c.lsf == 1][c.nb_channels == 1]; xing_offset=xing_offtbl[c.lsf == 1][c.nb_channels == 1];
needed = 4 // header needed = 4 // header
+ xing_offset + xing_offset
@ -213,6 +214,7 @@ static int mp3_write_xing(AVFormatContext *s)
if (needed <= c.frame_size) if (needed <= c.frame_size)
break; break;
header &= ~mask;
} }
avio_wb32(s->pb, header); avio_wb32(s->pb, header);