[FFmpeg-cvslog] lavf/flacenc: use metadata_header_padding

James Darnley git at videolan.org
Fri Jan 24 23:19:10 CET 2014


ffmpeg | branch: master | James Darnley <james.darnley at gmail.com> | Sun Dec 29 22:58:27 2013 +0100| [72eeb18468b0bf654ef64caf6da3e0df6537652d] | committer: Michael Niedermayer

lavf/flacenc: use metadata_header_padding

Allows a user to control the amount, if any, of padding they want added
to the file.  If set to zero the block will not be written at all.  If
set to some positive number four more bytes will be added to the file
due to the small header required for the block.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=72eeb18468b0bf654ef64caf6da3e0df6537652d
---

 libavformat/flacenc.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index d2e274c..ebb9e62 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -71,6 +71,7 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
 static int flac_write_header(struct AVFormatContext *s)
 {
     int ret;
+    int padding = s->metadata_header_padding;
     AVCodecContext *codec = s->streams[0]->codec;
     FlacMuxerContext *c   = s->priv_data;
 
@@ -86,11 +87,17 @@ static int flac_write_header(struct AVFormatContext *s)
         return AVERROR(EINVAL);
     }
 
+    if (padding < 0)
+        padding = 8192;
+    /* The FLAC specification states that 24 bits are used to represent the
+     * size of a metadata block so we must clip this value to 2^24-1. */
+    padding = av_clip_c(padding, 0, 16777215);
+
     ret = ff_flac_write_header(s->pb, codec, 0);
     if (ret)
         return ret;
 
-    ret = flac_write_block_comment(s->pb, &s->metadata, 0,
+    ret = flac_write_block_comment(s->pb, &s->metadata, !padding,
                                    codec->flags & CODEC_FLAG_BITEXACT);
     if (ret)
         return ret;
@@ -99,7 +106,8 @@ static int flac_write_header(struct AVFormatContext *s)
      * every 10s.  So one might add padding to allow that later
      * but there seems to be no simple way to get the duration here.
      * So let's try the flac default of 8192 bytes */
-    flac_write_block_padding(s->pb, 8192, 1);
+    if (padding)
+        flac_write_block_padding(s->pb, padding, 1);
 
     return ret;
 }



More information about the ffmpeg-cvslog mailing list