muxer. Originally committed as revision 17606 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -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 | |||
| @@ -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; | |||
| @@ -0,0 +1,29 @@ | |||
| /* | |||
| * raw FLAC muxer | |||
| * Copyright (C) 2009 Justin Ruggles | |||
| * | |||
| * This file is part of FFmpeg. | |||
| * | |||
| * FFmpeg is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU Lesser General Public | |||
| * License as published by the Free Software Foundation; either | |||
| * version 2.1 of the License, or (at your option) any later version. | |||
| * | |||
| * FFmpeg is distributed in the hope that it will be useful, | |||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
| * Lesser General Public License for more details. | |||
| * | |||
| * You should have received a copy of the GNU Lesser General Public | |||
| * License along with FFmpeg; if not, write to the Free Software | |||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||
| */ | |||
| #ifndef AVFORMAT_FLACENC_H | |||
| #define AVFORMAT_FLACENC_H | |||
| #include "avformat.h" | |||
| int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec); | |||
| #endif /* AVFORMAT_FLACENC_H */ | |||
| @@ -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) | |||