Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Rapp <t.rapp@noa-audio.com>2012-05-07 13:55:05 +0400
committerMichael Niedermayer <michaelni@gmx.at>2012-05-07 18:24:19 +0400
commit8da0a6cda1bd59471df6a4a18988c2381c05cee7 (patch)
tree04cb4f56e612c47f3566dd149ee4ea93aeb135dc /libavformat/mp3enc.c
parent16b9156b7ec3eedf8d5a109f1fb1a103a8b5d6f0 (diff)
mp3enc: Fix Xing tag identification string for CBR files
Fixes the Xing tag identification string to be "Info" for MP3 files with constant bitrate. The previous "Xing" caused some decoders to recognize the file as VBR. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mp3enc.c')
-rw-r--r--libavformat/mp3enc.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 29c0780b90..415fdba79f 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -94,6 +94,8 @@ typedef struct MP3Context {
uint32_t seen;
uint32_t pos;
uint64_t bag[VBR_NUM_BAGS];
+ int initial_bitrate;
+ int has_variable_bitrate;
/* index of the audio stream */
int audio_stream_idx;
@@ -238,6 +240,16 @@ static void mp3_fix_xing(AVFormatContext *s)
int i;
avio_flush(s->pb);
+
+ /* replace "Xing" identification string with "Info" for CBR files. */
+ if (!mp3->has_variable_bitrate) {
+ int64_t tag_offset = mp3->frames_offset
+ - 4 // frames/size/toc flags
+ - 4; // xing tag
+ avio_seek(s->pb, tag_offset, SEEK_SET);
+ avio_wb32(s->pb, MKBETAG('I', 'n', 'f', 'o'));
+ }
+
avio_seek(s->pb, mp3->frames_offset, SEEK_SET);
avio_wb32(s->pb, mp3->frames);
avio_wb32(s->pb, mp3->size);
@@ -260,12 +272,21 @@ static int mp3_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
return ff_raw_write_packet(s, pkt);
else {
MP3Context *mp3 = s->priv_data;
-#ifdef FILTER_VBR_HEADERS
MPADecodeHeader c;
+#ifdef FILTER_VBR_HEADERS
int base;
+#endif
+
+ avpriv_mpegaudio_decode_header(&c, AV_RB32(pkt->data));
- ff_mpegaudio_decode_header(&c, AV_RB32(pkt->data));
+ if (!mp3->initial_bitrate)
+ mp3->initial_bitrate = c.bit_rate;
+ if (!mp3->has_variable_bitrate) {
+ if ((c.bit_rate == 0) || (mp3->initial_bitrate != c.bit_rate))
+ mp3->has_variable_bitrate = 1;
+ }
+#ifdef FILTER_VBR_HEADERS
/* filter out XING and INFO headers. */
base = 4 + xing_offtbl[c.lsf == 1][c.nb_channels == 1];