Browse Source

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>
tags/n2.2-rc1
James Darnley Michael Niedermayer 12 years ago
parent
commit
72eeb18468
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      libavformat/flacenc.c

+ 10
- 2
libavformat/flacenc.c View File

@@ -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;
}


Loading…
Cancel
Save