[FFmpeg-devel] [PATCH 5/5] lavf/mp3enc: write trailing_padding in Xing header

Jon Toohill jtoohill at google.com
Wed Jul 13 02:19:56 EEST 2016


---
 libavformat/mp3enc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 3b77d29..da70d13 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -248,11 +248,14 @@ static int mp3_write_xing(AVFormatContext *s)
     avio_w8(dyn_ctx, 0);      // unknown encoding flags
     avio_w8(dyn_ctx, 0);      // unknown abr/minimal bitrate
 
-    // encoder delay
+    // encoder delay/padding
     if (par->initial_padding >= 1 << 12) {
         av_log(s, AV_LOG_WARNING, "Too many samples of initial padding.\n");
     }
-    avio_wb24(dyn_ctx, par->initial_padding << 12);
+    if (par->trailing_padding >= 1 << 12) {
+        av_log(s, AV_LOG_WARNING, "Too many samples of trailing padding.\n");
+    }
+    avio_wb24(dyn_ctx, (par->initial_padding << 12) | (par->trailing_padding & 0xFFF));
 
     avio_w8(dyn_ctx,   0); // misc
     avio_w8(dyn_ctx,   0); // mp3gain
-- 
2.8.0.rc3.226.g39d4020



More information about the ffmpeg-devel mailing list