[FFmpeg-cvslog] flac muxer: add option to disable writing the global header

Justin Ruggles git at videolan.org
Fri Jan 10 02:50:21 CET 2014


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Thu Jan  9 12:11:26 2014 -0500| [aa69cbc9e08281db6ecb98a2c8b4f60e8b12e558] | committer: Justin Ruggles

flac muxer: add option to disable writing the global header

The global header is not explicitly required for playback, and
omitting it allows for simple concatenation.

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

 libavformat/flacenc.c |   28 ++++++++++++++++++++++++++++
 libavformat/version.h |    2 +-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 1e4042e..83ddf44 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/opt.h"
 #include "libavcodec/flac.h"
 #include "avformat.h"
 #include "flacenc.h"
@@ -26,6 +27,11 @@
 #include "libavcodec/bytestream.h"
 
 
+typedef struct FlacMuxerContext {
+    const AVClass *class;
+    int write_header;
+} FlacMuxerContext;
+
 static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_bytes,
                                     int last_block)
 {
@@ -68,6 +74,10 @@ static int flac_write_header(struct AVFormatContext *s)
 {
     int ret;
     AVCodecContext *codec = s->streams[0]->codec;
+    FlacMuxerContext *c   = s->priv_data;
+
+    if (!c->write_header)
+        return 0;
 
     ret = ff_flac_write_header(s->pb, codec, 0);
     if (ret)
@@ -93,6 +103,10 @@ static int flac_write_trailer(struct AVFormatContext *s)
     uint8_t *streaminfo;
     enum FLACExtradataFormat format;
     int64_t file_size;
+    FlacMuxerContext *c = s->priv_data;
+
+    if (!c->write_header)
+        return 0;
 
     if (!avpriv_flac_is_extradata_valid(s->streams[0]->codec, &format, &streaminfo))
         return -1;
@@ -116,9 +130,22 @@ static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
     return 0;
 }
 
+static const AVOption flacenc_options[] = {
+    { "write_header", "Write the file header", offsetof(FlacMuxerContext, write_header), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+    { NULL },
+};
+
+static const AVClass flac_muxer_class = {
+    .class_name = "flac muxer",
+    .item_name  = av_default_item_name,
+    .option     = flacenc_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
 AVOutputFormat ff_flac_muxer = {
     .name              = "flac",
     .long_name         = NULL_IF_CONFIG_SMALL("raw FLAC"),
+    .priv_data_size    = sizeof(FlacMuxerContext),
     .mime_type         = "audio/x-flac",
     .extensions        = "flac",
     .audio_codec       = AV_CODEC_ID_FLAC,
@@ -127,4 +154,5 @@ AVOutputFormat ff_flac_muxer = {
     .write_packet      = flac_write_packet,
     .write_trailer     = flac_write_trailer,
     .flags             = AVFMT_NOTIMESTAMPS,
+    .priv_class        = &flac_muxer_class,
 };
diff --git a/libavformat/version.h b/libavformat/version.h
index a170c06..6768426 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFORMAT_VERSION_MAJOR 55
 #define LIBAVFORMAT_VERSION_MINOR 10
-#define LIBAVFORMAT_VERSION_MICRO  1
+#define LIBAVFORMAT_VERSION_MICRO  2
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list