[SCM] libav/experimental: Share the function to write a raw FLAC header and use it in the Matroska muxer.
siretart at users.alioth.debian.org
siretart at users.alioth.debian.org
Sun Jun 30 16:39:38 UTC 2013
The following commit has been merged in the experimental branch:
commit 2578326f13e5ea7945e2da810238118832dfb7a1
Author: Justin Ruggles <justin.ruggles at gmail.com>
Date: Thu Feb 26 02:41:53 2009 +0000
Share the function to write a raw FLAC header and use it in the Matroska
muxer.
Originally committed as revision 17606 to svn://svn.ffmpeg.org/ffmpeg/trunk
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 505a6ba..c6b99e7 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -83,9 +83,9 @@ OBJS-$(CONFIG_ISS_DEMUXER) += iss.o
OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o
OBJS-$(CONFIG_M4V_DEMUXER) += raw.o
OBJS-$(CONFIG_M4V_MUXER) += raw.o
-OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += matroskaenc.o matroska.o riff.o isom.o avc.o
+OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += matroskaenc.o matroska.o riff.o isom.o avc.o flacenc.o
OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o riff.o isom.o
-OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o riff.o isom.o avc.o
+OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o riff.o isom.o avc.o flacenc.o
OBJS-$(CONFIG_MJPEG_DEMUXER) += raw.o
OBJS-$(CONFIG_MJPEG_MUXER) += raw.o
OBJS-$(CONFIG_MLP_DEMUXER) += raw.o id3v2.o
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index b391f88..81844cc 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -21,13 +21,13 @@
#include "libavcodec/flac.h"
#include "avformat.h"
+#include "flacenc.h"
-static int flac_write_header(struct AVFormatContext *s)
+int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec)
{
static const uint8_t header[8] = {
0x66, 0x4C, 0x61, 0x43, 0x80, 0x00, 0x00, 0x22
};
- AVCodecContext *codec = s->streams[0]->codec;
uint8_t *streaminfo;
enum FLACExtradataFormat format;
@@ -36,15 +36,20 @@ static int flac_write_header(struct AVFormatContext *s)
/* write "fLaC" stream marker and first metadata block header if needed */
if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) {
- put_buffer(s->pb, header, 8);
+ put_buffer(pb, header, 8);
}
/* write STREAMINFO or full header */
- put_buffer(s->pb, codec->extradata, codec->extradata_size);
+ put_buffer(pb, codec->extradata, codec->extradata_size);
return 0;
}
+static int flac_write_header(struct AVFormatContext *s)
+{
+ return ff_flac_write_header(s->pb, s->streams[0]->codec);
+}
+
static int flac_write_trailer(struct AVFormatContext *s)
{
ByteIOContext *pb = s->pb;
diff --git a/libavformat/rm.c b/libavformat/flacenc.h
similarity index 76%
copy from libavformat/rm.c
copy to libavformat/flacenc.h
index 9911aac..a9b7f62 100644
--- a/libavformat/rm.c
+++ b/libavformat/flacenc.h
@@ -1,6 +1,6 @@
/*
- * "Real" compatible muxer and demuxer common code.
- * Copyright (c) 2009 Aurelien Jacobs <aurel at gnuage.org>
+ * raw FLAC muxer
+ * Copyright (C) 2009 Justin Ruggles
*
* This file is part of FFmpeg.
*
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "rm.h"
+#ifndef AVFORMAT_FLACENC_H
+#define AVFORMAT_FLACENC_H
-const char *ff_rm_metadata[4] = {
- "title",
- "author",
- "copyright",
- "comment"
-};
+#include "avformat.h"
+
+int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec);
+
+#endif /* AVFORMAT_FLACENC_H */
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 0b0adef..051fb1b 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -24,11 +24,11 @@
#include "isom.h"
#include "matroska.h"
#include "avc.h"
+#include "flacenc.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/md5.h"
#include "libavcodec/xiph.h"
#include "libavcodec/mpeg4audio.h"
-#include "libavcodec/flac.h"
typedef struct ebml_master {
int64_t pos; ///< absolute offset in the file where the master's elements start
@@ -421,25 +421,6 @@ static int put_xiph_codecpriv(AVFormatContext *s, ByteIOContext *pb, AVCodecCont
return 0;
}
-static int put_flac_codecpriv(AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec)
-{
- uint8_t *streaminfo;
- enum FLACExtradataFormat format;
-
- if (!ff_flac_is_extradata_valid(codec, &format, &streaminfo)) {
- av_log(s, AV_LOG_ERROR, "Invalid FLAC extradata\n");
- return -1;
- }
- if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) {
- // only the streaminfo packet
- put_buffer(pb, "fLaC", 4);
- put_byte(pb, 0x80);
- put_be24(pb, FLAC_STREAMINFO_SIZE);
- }
- put_buffer(pb, codec->extradata, codec->extradata_size);
- return 0;
-}
-
static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int *sample_rate, int *output_sample_rate)
{
int sri;
@@ -481,7 +462,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodec
if (codec->codec_id == CODEC_ID_VORBIS || codec->codec_id == CODEC_ID_THEORA)
ret = put_xiph_codecpriv(s, dyn_cp, codec);
else if (codec->codec_id == CODEC_ID_FLAC)
- ret = put_flac_codecpriv(s, dyn_cp, codec);
+ ret = ff_flac_write_header(dyn_cp, codec);
else if (codec->codec_id == CODEC_ID_H264)
ret = ff_isom_write_avcc(dyn_cp, codec->extradata, codec->extradata_size);
else if (codec->extradata_size)
--
Libav/FFmpeg packaging
More information about the pkg-multimedia-commits
mailing list