comparison raw.c @ 4577:1cc2041c2e03 libavformat

Separate the raw FLAC muxer from raw.c to its own file, flacenc.c.
author jbr
date Thu, 26 Feb 2009 02:21:43 +0000
parents 90e0047f90b6
children 41542d2edcf4
comparison
equal deleted inserted replaced
4576:df7cc2eac54f 4577:1cc2041c2e03
27 #include "avformat.h" 27 #include "avformat.h"
28 #include "raw.h" 28 #include "raw.h"
29 #include "id3v2.h" 29 #include "id3v2.h"
30 30
31 /* simple formats */ 31 /* simple formats */
32 #if CONFIG_FLAC_MUXER
33 static int flac_write_header(struct AVFormatContext *s)
34 {
35 static const uint8_t header[8] = {
36 0x66, 0x4C, 0x61, 0x43, 0x80, 0x00, 0x00, 0x22
37 };
38 uint8_t *streaminfo = s->streams[0]->codec->extradata;
39 int len = s->streams[0]->codec->extradata_size;
40 if(streaminfo != NULL && len > 0) {
41 put_buffer(s->pb, header, 8);
42 put_buffer(s->pb, streaminfo, len);
43 }
44 return 0;
45 }
46
47 static int flac_write_trailer(struct AVFormatContext *s)
48 {
49 ByteIOContext *pb = s->pb;
50 uint8_t *streaminfo = s->streams[0]->codec->extradata;
51 int len = s->streams[0]->codec->extradata_size;
52 int64_t file_size;
53
54 if (streaminfo && len > 0 && !url_is_streamed(s->pb)) {
55 file_size = url_ftell(pb);
56 url_fseek(pb, 8, SEEK_SET);
57 put_buffer(pb, streaminfo, len);
58 url_fseek(pb, file_size, SEEK_SET);
59 put_flush_packet(pb);
60 }
61 return 0;
62 }
63 #endif
64 32
65 #if CONFIG_ROQ_MUXER 33 #if CONFIG_ROQ_MUXER
66 static int roq_write_header(struct AVFormatContext *s) 34 static int roq_write_header(struct AVFormatContext *s)
67 { 35 {
68 static const uint8_t header[] = { 36 static const uint8_t header[] = {
849 .extensions = "flac", 817 .extensions = "flac",
850 .value = CODEC_ID_FLAC, 818 .value = CODEC_ID_FLAC,
851 }; 819 };
852 #endif 820 #endif
853 821
854 #if CONFIG_FLAC_MUXER
855 AVOutputFormat flac_muxer = {
856 "flac",
857 NULL_IF_CONFIG_SMALL("raw FLAC"),
858 "audio/x-flac",
859 "flac",
860 0,
861 CODEC_ID_FLAC,
862 CODEC_ID_NONE,
863 flac_write_header,
864 raw_write_packet,
865 flac_write_trailer,
866 .flags= AVFMT_NOTIMESTAMPS,
867 };
868 #endif
869
870 #if CONFIG_GSM_DEMUXER 822 #if CONFIG_GSM_DEMUXER
871 AVInputFormat gsm_demuxer = { 823 AVInputFormat gsm_demuxer = {
872 "gsm", 824 "gsm",
873 NULL_IF_CONFIG_SMALL("raw GSM"), 825 NULL_IF_CONFIG_SMALL("raw GSM"),
874 0, 826 0,