comparison flacenc.c @ 4581:c52d40f0a955 libavformat

Share the function to write a raw FLAC header and use it in the Matroska muxer.
author jbr
date Thu, 26 Feb 2009 02:41:53 +0000
parents f9775a0b7fdb
children 121d6994c20e
comparison
equal deleted inserted replaced
4580:f9775a0b7fdb 4581:c52d40f0a955
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */ 20 */
21 21
22 #include "libavcodec/flac.h" 22 #include "libavcodec/flac.h"
23 #include "avformat.h" 23 #include "avformat.h"
24 #include "flacenc.h"
24 25
25 static int flac_write_header(struct AVFormatContext *s) 26 int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec)
26 { 27 {
27 static const uint8_t header[8] = { 28 static const uint8_t header[8] = {
28 0x66, 0x4C, 0x61, 0x43, 0x80, 0x00, 0x00, 0x22 29 0x66, 0x4C, 0x61, 0x43, 0x80, 0x00, 0x00, 0x22
29 }; 30 };
30 AVCodecContext *codec = s->streams[0]->codec;
31 uint8_t *streaminfo; 31 uint8_t *streaminfo;
32 enum FLACExtradataFormat format; 32 enum FLACExtradataFormat format;
33 33
34 if (!ff_flac_is_extradata_valid(codec, &format, &streaminfo)) 34 if (!ff_flac_is_extradata_valid(codec, &format, &streaminfo))
35 return -1; 35 return -1;
36 36
37 /* write "fLaC" stream marker and first metadata block header if needed */ 37 /* write "fLaC" stream marker and first metadata block header if needed */
38 if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) { 38 if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) {
39 put_buffer(s->pb, header, 8); 39 put_buffer(pb, header, 8);
40 } 40 }
41 41
42 /* write STREAMINFO or full header */ 42 /* write STREAMINFO or full header */
43 put_buffer(s->pb, codec->extradata, codec->extradata_size); 43 put_buffer(pb, codec->extradata, codec->extradata_size);
44 44
45 return 0; 45 return 0;
46 }
47
48 static int flac_write_header(struct AVFormatContext *s)
49 {
50 return ff_flac_write_header(s->pb, s->streams[0]->codec);
46 } 51 }
47 52
48 static int flac_write_trailer(struct AVFormatContext *s) 53 static int flac_write_trailer(struct AVFormatContext *s)
49 { 54 {
50 ByteIOContext *pb = s->pb; 55 ByteIOContext *pb = s->pb;