mp3enc: simplify mp3_write_xing()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2011-11-14 20:45:02 +01:00
parent ecf5e70548
commit 1fea432b7a

View File

@ -185,13 +185,11 @@ static int mp3_write_xing(AVFormatContext *s)
header |= (srate_idx << 2) << 8; header |= (srate_idx << 2) << 8;
header |= channels << 6; header |= channels << 6;
for (;;) { for (;; 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
@ -203,9 +201,6 @@ static int mp3_write_xing(AVFormatContext *s)
if (needed <= c.frame_size) if (needed <= c.frame_size)
break; break;
header &= ~mask;
++bitrate_idx;
} }
avio_wb32(s->pb, header); avio_wb32(s->pb, header);