summaryrefslogtreecommitdiff
path: root/libavformat/flacenc.c
diff options
context:
space:
mode:
authorJames Darnley <james.darnley@gmail.com>2013-12-29 22:58:27 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-24 22:40:23 +0100
commit72eeb18468b0bf654ef64caf6da3e0df6537652d (patch)
tree32178b59d9eb4b1851f9a22cbb8d33538fb897df /libavformat/flacenc.c
parent86bee7984e30cf7df6ad353be7c5153f5988e797 (diff)
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@gmx.at>
Diffstat (limited to 'libavformat/flacenc.c')
-rw-r--r--libavformat/flacenc.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index d2e274cf2f..ebb9e6276b 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;
}