[FFmpeg-cvslog] r17606 - in trunk/libavformat: Makefile flacenc.c flacenc.h matroskaenc.c
jbr
subversion
Thu Feb 26 03:41:53 CET 2009
Author: jbr
Date: Thu Feb 26 03:41:53 2009
New Revision: 17606
Log:
Share the function to write a raw FLAC header and use it in the Matroska
muxer.
Added:
trunk/libavformat/flacenc.h (contents, props changed)
- copied, changed from r17601, trunk/libavformat/raw.h
Modified:
trunk/libavformat/Makefile
trunk/libavformat/flacenc.c
trunk/libavformat/matroskaenc.c
Modified: trunk/libavformat/Makefile
==============================================================================
--- trunk/libavformat/Makefile Thu Feb 26 03:33:19 2009 (r17605)
+++ trunk/libavformat/Makefile Thu Feb 26 03:41:53 2009 (r17606)
@@ -83,9 +83,9 @@ OBJS-$(CONFIG_ISS_DEMUXER)
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
Modified: trunk/libavformat/flacenc.c
==============================================================================
--- trunk/libavformat/flacenc.c Thu Feb 26 03:33:19 2009 (r17605)
+++ trunk/libavformat/flacenc.c Thu Feb 26 03:41:53 2009 (r17606)
@@ -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 AVFo
/* 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;
Copied and modified: trunk/libavformat/flacenc.h (from r17601, trunk/libavformat/raw.h)
==============================================================================
--- trunk/libavformat/raw.h Thu Feb 26 03:21:43 2009 (r17601, copy source)
+++ trunk/libavformat/flacenc.h Thu Feb 26 03:41:53 2009 (r17606)
@@ -1,6 +1,6 @@
/*
- * RAW muxer and demuxer
- * Copyright (C) 2007 Aurelien Jacobs <aurel at gnuage.org>
+ * raw FLAC muxer
+ * Copyright (C) 2009 Justin Ruggles
*
* This file is part of FFmpeg.
*
@@ -19,12 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVFORMAT_RAW_H
-#define AVFORMAT_RAW_H
+#ifndef AVFORMAT_FLACENC_H
+#define AVFORMAT_FLACENC_H
#include "avformat.h"
-int pcm_read_seek(AVFormatContext *s,
- int stream_index, int64_t timestamp, int flags);
+int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec);
-#endif /* AVFORMAT_RAW_H */
+#endif /* AVFORMAT_FLACENC_H */
Modified: trunk/libavformat/matroskaenc.c
==============================================================================
--- trunk/libavformat/matroskaenc.c Thu Feb 26 03:33:19 2009 (r17605)
+++ trunk/libavformat/matroskaenc.c Thu Feb 26 03:41:53 2009 (r17606)
@@ -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(AVFormatCo
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(AVForm
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)
More information about the ffmpeg-cvslog
mailing list