Originally committed as revision 547 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -5,10 +5,13 @@ PWD=$(shell pwd) | |||
| CFLAGS= $(OPTFLAGS) -Wall -g -I.. -I$(SRC_PATH) -I$(SRC_PATH)/libavcodec -DHAVE_AV_CONFIG_H | |||
| OBJS= rm.o mpeg.o asf.o avienc.o jpeg.o swf.o wav.o raw.o \ | |||
| avidec.o ffm.o \ | |||
| avio.o aviobuf.o utils.o \ | |||
| file.o img.o au.o gif.o mov.o crc.o | |||
| OBJS= utils.o | |||
| # mux and demuxes | |||
| OBJS+=mpeg.o mpegts.o ffm.o crc.o img.o raw.o rm.o asf.o \ | |||
| avienc.o avidec.o wav.o swf.o au.o gif.o mov.o jpeg.o | |||
| # file I/O | |||
| OBJS+= avio.o aviobuf.o file.o | |||
| ifeq ($(CONFIG_GRAB),yes) | |||
| OBJS+= grab.o audio.o | |||
| @@ -420,12 +420,7 @@ static int asf_write_header1(AVFormatContext *s, INT64 file_size, INT64 data_chu | |||
| static int asf_write_header(AVFormatContext *s) | |||
| { | |||
| ASFContext *asf; | |||
| asf = av_mallocz(sizeof(ASFContext)); | |||
| if (!asf) | |||
| return -1; | |||
| s->priv_data = asf; | |||
| ASFContext *asf = s->priv_data; | |||
| asf->packet_size = PACKET_SIZE; | |||
| asf->nb_packets = 0; | |||
| @@ -614,8 +609,6 @@ static int asf_write_trailer(AVFormatContext *s) | |||
| } | |||
| put_flush_packet(&s->pb); | |||
| av_free(asf); | |||
| return 0; | |||
| } | |||
| @@ -679,9 +672,34 @@ static void get_str16_nolen(ByteIOContext *pb, int len, char *buf, int buf_size) | |||
| *q = '\0'; | |||
| } | |||
| static int asf_probe(AVProbeData *pd) | |||
| { | |||
| GUID g; | |||
| const unsigned char *p; | |||
| int i; | |||
| /* check file header */ | |||
| if (pd->buf_size <= 32) | |||
| return 0; | |||
| p = pd->buf; | |||
| g.v1 = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); | |||
| p += 4; | |||
| g.v2 = p[0] | (p[1] << 8); | |||
| p += 2; | |||
| g.v3 = p[0] | (p[1] << 8); | |||
| p += 2; | |||
| for(i=0;i<8;i++) | |||
| g.v4[i] = *p++; | |||
| if (!memcmp(&g, &asf_header, sizeof(GUID))) | |||
| return AVPROBE_SCORE_MAX; | |||
| else | |||
| return 0; | |||
| } | |||
| static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| { | |||
| ASFContext *asf; | |||
| ASFContext *asf = s->priv_data; | |||
| GUID g; | |||
| ByteIOContext *pb = &s->pb; | |||
| AVStream *st; | |||
| @@ -689,11 +707,6 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| int size, i, bps; | |||
| INT64 gsize; | |||
| asf = av_mallocz(sizeof(ASFContext)); | |||
| if (!asf) | |||
| return -1; | |||
| s->priv_data = asf; | |||
| get_guid(pb, &g); | |||
| if (memcmp(&g, &asf_header, sizeof(GUID))) | |||
| goto fail; | |||
| @@ -1015,11 +1028,22 @@ static int asf_read_close(AVFormatContext *s) | |||
| return 0; | |||
| } | |||
| AVFormat asf_format = { | |||
| AVInputFormat asf_iformat = { | |||
| "asf", | |||
| "asf format", | |||
| sizeof(ASFContext), | |||
| asf_probe, | |||
| asf_read_header, | |||
| asf_read_packet, | |||
| asf_read_close, | |||
| }; | |||
| AVOutputFormat asf_oformat = { | |||
| "asf", | |||
| "asf format", | |||
| "application/octet-stream", | |||
| "asf,wmv", | |||
| sizeof(ASFContext), | |||
| #ifdef CONFIG_MP3LAME | |||
| CODEC_ID_MP3LAME, | |||
| #else | |||
| @@ -1029,8 +1053,11 @@ AVFormat asf_format = { | |||
| asf_write_header, | |||
| asf_write_packet, | |||
| asf_write_trailer, | |||
| asf_read_header, | |||
| asf_read_packet, | |||
| asf_read_close, | |||
| }; | |||
| int asf_init(void) | |||
| { | |||
| av_register_input_format(&asf_iformat); | |||
| av_register_output_format(&asf_oformat); | |||
| return 0; | |||
| } | |||
| @@ -99,6 +99,18 @@ static int au_write_trailer(AVFormatContext *s) | |||
| return 0; | |||
| } | |||
| static int au_probe(AVProbeData *p) | |||
| { | |||
| /* check file header */ | |||
| if (p->buf_size <= 24) | |||
| return 0; | |||
| if (p->buf[0] == '.' && p->buf[1] == 's' && | |||
| p->buf[2] == 'n' && p->buf[3] == 'd') | |||
| return AVPROBE_SCORE_MAX; | |||
| else | |||
| return 0; | |||
| } | |||
| /* au input */ | |||
| static int au_read_header(AVFormatContext *s, | |||
| AVFormatParameters *ap) | |||
| @@ -175,18 +187,32 @@ static int au_read_close(AVFormatContext *s) | |||
| return 0; | |||
| } | |||
| AVFormat au_format = { | |||
| static AVInputFormat au_iformat = { | |||
| "au", | |||
| "SUN AU Format", | |||
| 0, | |||
| au_probe, | |||
| au_read_header, | |||
| au_read_packet, | |||
| au_read_close, | |||
| }; | |||
| static AVOutputFormat au_oformat = { | |||
| "au", | |||
| "SUN AU Format", | |||
| "audio/basic", | |||
| "au", | |||
| 0, | |||
| CODEC_ID_PCM_S16BE, | |||
| CODEC_ID_NONE, | |||
| au_write_header, | |||
| au_write_packet, | |||
| au_write_trailer, | |||
| au_read_header, | |||
| au_read_packet, | |||
| au_read_close, | |||
| }; | |||
| int au_init(void) | |||
| { | |||
| av_register_input_format(&au_iformat); | |||
| av_register_output_format(&au_oformat); | |||
| return 0; | |||
| } | |||
| @@ -147,21 +147,15 @@ static int audio_close(AudioData *s) | |||
| /* sound output support */ | |||
| static int audio_write_header(AVFormatContext *s1) | |||
| { | |||
| AudioData *s; | |||
| AudioData *s = s1->priv_data; | |||
| AVStream *st; | |||
| int ret; | |||
| s = av_mallocz(sizeof(AudioData)); | |||
| if (!s) | |||
| return -ENOMEM; | |||
| s1->priv_data = s; | |||
| st = s1->streams[0]; | |||
| s->sample_rate = st->codec.sample_rate; | |||
| s->channels = st->codec.channels; | |||
| ret = audio_open(s, 1); | |||
| if (ret < 0) { | |||
| av_free(s); | |||
| return -EIO; | |||
| } else { | |||
| return 0; | |||
| @@ -201,7 +195,6 @@ static int audio_write_trailer(AVFormatContext *s1) | |||
| AudioData *s = s1->priv_data; | |||
| audio_close(s); | |||
| av_free(s); | |||
| return 0; | |||
| } | |||
| @@ -209,31 +202,23 @@ static int audio_write_trailer(AVFormatContext *s1) | |||
| static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap) | |||
| { | |||
| AudioData *s; | |||
| AudioData *s = s1->priv_data; | |||
| AVStream *st; | |||
| int ret; | |||
| if (!ap || ap->sample_rate <= 0 || ap->channels <= 0) | |||
| return -1; | |||
| s = av_mallocz(sizeof(AudioData)); | |||
| if (!s) | |||
| return -ENOMEM; | |||
| st = av_mallocz(sizeof(AVStream)); | |||
| st = av_new_stream(s1, 0); | |||
| if (!st) { | |||
| av_free(s); | |||
| return -ENOMEM; | |||
| } | |||
| s1->priv_data = s; | |||
| s1->nb_streams = 1; | |||
| s1->streams[0] = st; | |||
| s->sample_rate = ap->sample_rate; | |||
| s->channels = ap->channels; | |||
| ret = audio_open(s, 0); | |||
| if (ret < 0) { | |||
| av_free(st); | |||
| av_free(s); | |||
| return -EIO; | |||
| } else { | |||
| /* take real parameters */ | |||
| @@ -284,15 +269,26 @@ static int audio_read_close(AVFormatContext *s1) | |||
| AudioData *s = s1->priv_data; | |||
| audio_close(s); | |||
| av_free(s); | |||
| return 0; | |||
| } | |||
| AVFormat audio_device_format = { | |||
| AVInputFormat audio_in_format = { | |||
| "audio_device", | |||
| "audio grab and output", | |||
| sizeof(AudioData), | |||
| NULL, | |||
| audio_read_header, | |||
| audio_read_packet, | |||
| audio_read_close, | |||
| flags: AVFMT_NOFILE, | |||
| }; | |||
| AVOutputFormat audio_out_format = { | |||
| "audio_device", | |||
| "audio grab and output", | |||
| "", | |||
| "", | |||
| sizeof(AudioData), | |||
| /* XXX: we make the assumption that the soundcard accepts this format */ | |||
| /* XXX: find better solution with "preinit" method, needed also in | |||
| other formats */ | |||
| @@ -305,10 +301,12 @@ AVFormat audio_device_format = { | |||
| audio_write_header, | |||
| audio_write_packet, | |||
| audio_write_trailer, | |||
| audio_read_header, | |||
| audio_read_packet, | |||
| audio_read_close, | |||
| NULL, | |||
| AVFMT_NOFILE, | |||
| flags: AVFMT_NOFILE, | |||
| }; | |||
| int audio_init(void) | |||
| { | |||
| av_register_input_format(&audio_in_format); | |||
| av_register_output_format(&audio_out_format); | |||
| return 0; | |||
| } | |||
| @@ -23,8 +23,3 @@ extern CodecTag codec_wav_tags[]; | |||
| unsigned int codec_get_tag(const CodecTag *tags, int id); | |||
| int codec_get_id(const CodecTag *tags, unsigned int tag); | |||
| /* avidec.c */ | |||
| int avi_read_header(AVFormatContext *s, AVFormatParameters *ap); | |||
| int avi_read_packet(AVFormatContext *s, AVPacket *pkt); | |||
| int avi_read_close(AVFormatContext *s); | |||
| @@ -47,19 +47,13 @@ void print_tag(const char *str, unsigned int tag, int size) | |||
| int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| { | |||
| AVIContext *avi; | |||
| AVIContext *avi = s->priv_data; | |||
| ByteIOContext *pb = &s->pb; | |||
| UINT32 tag, tag1; | |||
| int codec_type, stream_index, size, frame_period, bit_rate; | |||
| int i, bps; | |||
| AVStream *st; | |||
| avi = av_malloc(sizeof(AVIContext)); | |||
| if (!avi) | |||
| return -1; | |||
| memset(avi, 0, sizeof(AVIContext)); | |||
| s->priv_data = avi; | |||
| /* check RIFF header */ | |||
| tag = get_le32(pb); | |||
| @@ -246,7 +240,35 @@ int avi_read_packet(AVFormatContext *s, AVPacket *pkt) | |||
| int avi_read_close(AVFormatContext *s) | |||
| { | |||
| AVIContext *avi = s->priv_data; | |||
| av_free(avi); | |||
| return 0; | |||
| } | |||
| static int avi_probe(AVProbeData *p) | |||
| { | |||
| /* check file header */ | |||
| if (p->buf_size <= 32) | |||
| return 0; | |||
| if (p->buf[0] == 'R' && p->buf[1] == 'I' && | |||
| p->buf[2] == 'F' && p->buf[3] == 'F' && | |||
| p->buf[8] == 'A' && p->buf[9] == 'V' && | |||
| p->buf[10] == 'I' && p->buf[11] == ' ') | |||
| return AVPROBE_SCORE_MAX; | |||
| else | |||
| return 0; | |||
| } | |||
| static AVInputFormat avi_iformat = { | |||
| "avi", | |||
| "avi format", | |||
| sizeof(AVIContext), | |||
| avi_probe, | |||
| avi_read_header, | |||
| avi_read_packet, | |||
| avi_read_close, | |||
| }; | |||
| int avidec_init(void) | |||
| { | |||
| av_register_input_format(&avi_iformat); | |||
| return 0; | |||
| } | |||
| @@ -143,18 +143,12 @@ void parse_specific_params(AVCodecContext *stream, int *au_byterate, int *au_ssi | |||
| static int avi_write_header(AVFormatContext *s) | |||
| { | |||
| AVIContext *avi; | |||
| AVIContext *avi = s->priv_data; | |||
| ByteIOContext *pb = &s->pb; | |||
| int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale; | |||
| AVCodecContext *stream, *video_enc; | |||
| offset_t list1, list2, strh, strf; | |||
| avi = av_malloc(sizeof(AVIContext)); | |||
| if (!avi) | |||
| return -1; | |||
| memset(avi, 0, sizeof(AVIContext)); | |||
| s->priv_data = avi; | |||
| put_tag(pb, "RIFF"); | |||
| put_le32(pb, 0); /* file length */ | |||
| put_tag(pb, "AVI "); | |||
| @@ -388,23 +382,24 @@ static int avi_write_trailer(AVFormatContext *s) | |||
| url_fseek(pb, file_size, SEEK_SET); | |||
| } | |||
| put_flush_packet(pb); | |||
| av_free(avi); | |||
| return 0; | |||
| } | |||
| AVFormat avi_format = { | |||
| static AVOutputFormat avi_oformat = { | |||
| "avi", | |||
| "avi format", | |||
| "video/x-msvideo", | |||
| "avi", | |||
| sizeof(AVIContext), | |||
| CODEC_ID_MP2, | |||
| CODEC_ID_MSMPEG4, | |||
| avi_write_header, | |||
| avi_write_packet, | |||
| avi_write_trailer, | |||
| avi_read_header, | |||
| avi_read_packet, | |||
| avi_read_close, | |||
| }; | |||
| int avienc_init(void) | |||
| { | |||
| av_register_output_format(&avi_oformat); | |||
| return 0; | |||
| } | |||
| @@ -105,14 +105,6 @@ offset_t url_seek(URLContext *h, offset_t pos, int whence) | |||
| return ret; | |||
| } | |||
| int url_getformat(URLContext *h, URLFormat *f) | |||
| { | |||
| memset(f, 0, sizeof(*f)); | |||
| if (!h->prot->url_getformat) | |||
| return -ENODATA; | |||
| return h->prot->url_getformat(h, f); | |||
| } | |||
| int url_close(URLContext *h) | |||
| { | |||
| int ret; | |||
| @@ -12,16 +12,6 @@ struct URLContext { | |||
| void *priv_data; | |||
| }; | |||
| typedef struct URLFormat { | |||
| char format_name[32]; | |||
| int sample_rate; | |||
| int frame_rate; | |||
| int channels; | |||
| int height; | |||
| int width; | |||
| enum PixelFormat pix_fmt; | |||
| } URLFormat; | |||
| typedef struct URLContext URLContext; | |||
| typedef struct URLPollEntry { | |||
| @@ -36,7 +26,6 @@ int url_open(URLContext **h, const char *filename, int flags); | |||
| int url_read(URLContext *h, unsigned char *buf, int size); | |||
| int url_write(URLContext *h, unsigned char *buf, int size); | |||
| offset_t url_seek(URLContext *h, offset_t pos, int whence); | |||
| int url_getformat(URLContext *h, URLFormat *f); | |||
| int url_close(URLContext *h); | |||
| int url_exist(const char *filename); | |||
| offset_t url_filesize(URLContext *h); | |||
| @@ -50,9 +39,6 @@ typedef struct URLProtocol { | |||
| int (*url_write)(URLContext *h, unsigned char *buf, int size); | |||
| offset_t (*url_seek)(URLContext *h, offset_t pos, int whence); | |||
| int (*url_close)(URLContext *h); | |||
| /* get precise information about the format, if available. return | |||
| -ENODATA if not available */ | |||
| int (*url_getformat)(URLContext *h, URLFormat *f); | |||
| struct URLProtocol *next; | |||
| } URLProtocol; | |||
| @@ -61,15 +61,10 @@ typedef struct CRCState { | |||
| UINT32 crcval; | |||
| } CRCState; | |||
| /* simple formats */ | |||
| static int crc_write_header(struct AVFormatContext *s) | |||
| { | |||
| CRCState *crc; | |||
| crc = av_malloc(sizeof(CRCState)); | |||
| if (!crc) | |||
| return -1; | |||
| s->priv_data = crc; | |||
| CRCState *crc = s->priv_data; | |||
| /* init CRC */ | |||
| crc->crcval = adler32(0, NULL, 0); | |||
| @@ -93,18 +88,24 @@ static int crc_write_trailer(struct AVFormatContext *s) | |||
| snprintf(buf, sizeof(buf), "CRC=%08x\n", crc->crcval); | |||
| put_buffer(&s->pb, buf, strlen(buf)); | |||
| put_flush_packet(&s->pb); | |||
| av_free(crc); | |||
| return 0; | |||
| } | |||
| AVFormat crc_format = { | |||
| AVOutputFormat crc_format = { | |||
| "crc", | |||
| "crc testing format", | |||
| NULL, | |||
| "", | |||
| sizeof(CRCState), | |||
| CODEC_ID_PCM_S16LE, | |||
| CODEC_ID_RAWVIDEO, | |||
| crc_write_header, | |||
| crc_write_packet, | |||
| crc_write_trailer, | |||
| }; | |||
| int crc_init(void) | |||
| { | |||
| av_register_output_format(&crc_format); | |||
| return 0; | |||
| } | |||
| @@ -51,6 +51,9 @@ typedef struct FFMContext { | |||
| UINT8 packet[1]; /* must be last */ | |||
| } FFMContext; | |||
| /* disable pts hack for testing */ | |||
| int ffm_nopts = 0; | |||
| static void flush_packet(AVFormatContext *s) | |||
| { | |||
| FFMContext *ffm = s->priv_data; | |||
| @@ -112,18 +115,13 @@ static void ffm_write_data(AVFormatContext *s, | |||
| static int ffm_write_header(AVFormatContext *s) | |||
| { | |||
| FFMContext *ffm = s->priv_data; | |||
| AVStream *st; | |||
| FFMStream *fst; | |||
| FFMContext *ffm; | |||
| ByteIOContext *pb = &s->pb; | |||
| AVCodecContext *codec; | |||
| int bit_rate, i; | |||
| ffm = av_mallocz(sizeof(FFMContext) + FFM_PACKET_SIZE); | |||
| if (!ffm) | |||
| return -1; | |||
| s->priv_data = ffm; | |||
| ffm->packet_size = FFM_PACKET_SIZE; | |||
| /* header */ | |||
| @@ -177,7 +175,10 @@ static int ffm_write_header(AVFormatContext *s) | |||
| abort(); | |||
| } | |||
| /* hack to have real time */ | |||
| fst->pts = gettime(); | |||
| if (ffm_nopts) | |||
| fst->pts = 0; | |||
| else | |||
| fst->pts = gettime(); | |||
| } | |||
| /* flush until end of block reached */ | |||
| @@ -200,7 +201,6 @@ static int ffm_write_header(AVFormatContext *s) | |||
| fst = st->priv_data; | |||
| av_free(fst); | |||
| } | |||
| av_free(ffm); | |||
| return -1; | |||
| } | |||
| @@ -252,7 +252,6 @@ static int ffm_write_trailer(AVFormatContext *s) | |||
| for(i=0;i<s->nb_streams;i++) | |||
| av_free(s->streams[i]->priv_data); | |||
| av_free(ffm); | |||
| return 0; | |||
| } | |||
| @@ -342,20 +341,14 @@ static int ffm_read_data(AVFormatContext *s, | |||
| static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| { | |||
| FFMContext *ffm = s->priv_data; | |||
| AVStream *st; | |||
| FFMStream *fst; | |||
| FFMContext *ffm; | |||
| ByteIOContext *pb = &s->pb; | |||
| AVCodecContext *codec; | |||
| int i; | |||
| UINT32 tag; | |||
| ffm = av_mallocz(sizeof(FFMContext) + FFM_PACKET_SIZE); | |||
| if (!ffm) | |||
| return -1; | |||
| s->priv_data = ffm; | |||
| /* header */ | |||
| tag = get_le32(pb); | |||
| if (tag != MKTAG('F', 'F', 'M', '1')) | |||
| @@ -436,8 +429,6 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| av_free(st); | |||
| } | |||
| } | |||
| if (ffm) | |||
| av_free(ffm); | |||
| return -1; | |||
| } | |||
| @@ -619,19 +610,35 @@ static int ffm_read_close(AVFormatContext *s) | |||
| return 0; | |||
| } | |||
| AVFormat ffm_format = { | |||
| AVInputFormat ffm_iformat = { | |||
| "ffm", | |||
| "ffm format", | |||
| sizeof(FFMContext), | |||
| NULL, | |||
| ffm_read_header, | |||
| ffm_read_packet, | |||
| ffm_read_close, | |||
| ffm_seek, | |||
| extensions: "ffm", | |||
| }; | |||
| AVOutputFormat ffm_oformat = { | |||
| "ffm", | |||
| "ffm format", | |||
| "", | |||
| "ffm", | |||
| sizeof(FFMContext) + FFM_PACKET_SIZE, | |||
| /* not really used */ | |||
| CODEC_ID_MP2, | |||
| CODEC_ID_MPEG1VIDEO, | |||
| ffm_write_header, | |||
| ffm_write_packet, | |||
| ffm_write_trailer, | |||
| ffm_read_header, | |||
| ffm_read_packet, | |||
| ffm_read_close, | |||
| ffm_seek, | |||
| }; | |||
| int ffm_init(void) | |||
| { | |||
| av_register_input_format(&ffm_iformat); | |||
| av_register_output_format(&ffm_oformat); | |||
| return 0; | |||
| } | |||
| @@ -192,7 +192,7 @@ typedef struct { | |||
| static int gif_write_header(AVFormatContext *s) | |||
| { | |||
| GIFContext *gif; | |||
| GIFContext *gif = s->priv_data; | |||
| ByteIOContext *pb = &s->pb; | |||
| AVCodecContext *enc, *video_enc; | |||
| int i, width, height, rate; | |||
| @@ -201,12 +201,6 @@ static int gif_write_header(AVFormatContext *s) | |||
| if(s->nb_streams > 1) | |||
| return -1; | |||
| */ | |||
| gif = av_malloc(sizeof(GIFContext)); | |||
| if (!gif) | |||
| return -1; | |||
| s->priv_data = gif; | |||
| gif->time = 0; | |||
| gif->file_time = 0; | |||
| @@ -376,28 +370,28 @@ static int gif_write_packet(AVFormatContext *s, int stream_index, | |||
| static int gif_write_trailer(AVFormatContext *s) | |||
| { | |||
| GIFContext *gif = s->priv_data; | |||
| ByteIOContext *pb = &s->pb; | |||
| put_byte(pb, 0x3b); | |||
| put_flush_packet(&s->pb); | |||
| av_free(gif); | |||
| return 0; | |||
| } | |||
| AVFormat gif_format = { | |||
| static AVOutputFormat gif_oformat = { | |||
| "gif", | |||
| "GIF Animation", | |||
| "image/gif", | |||
| "gif", | |||
| sizeof(GIFContext), | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_RAWVIDEO, | |||
| gif_write_header, | |||
| gif_write_packet, | |||
| gif_write_trailer, | |||
| NULL, /* read_header */ | |||
| NULL, /* read_packet */ | |||
| NULL, /* read_close */ | |||
| }; | |||
| int gif_init(void) | |||
| { | |||
| av_register_output_format(&gif_oformat); | |||
| return 0; | |||
| } | |||
| @@ -48,7 +48,7 @@ static int gb_frame = 0; | |||
| static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) | |||
| { | |||
| VideoData *s; | |||
| VideoData *s = s1->priv_data; | |||
| AVStream *st; | |||
| int width, height; | |||
| int video_fd, frame_size; | |||
| @@ -62,17 +62,9 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) | |||
| height = ap->height; | |||
| frame_rate = ap->frame_rate; | |||
| s = av_mallocz(sizeof(VideoData)); | |||
| if (!s) | |||
| return -ENOMEM; | |||
| st = av_mallocz(sizeof(AVStream)); | |||
| if (!st) { | |||
| av_free(s); | |||
| st = av_new_stream(s1, 0); | |||
| if (!st) | |||
| return -ENOMEM; | |||
| } | |||
| s1->priv_data = s; | |||
| s1->nb_streams = 1; | |||
| s1->streams[0] = st; | |||
| s->width = width; | |||
| s->height = height; | |||
| @@ -232,7 +224,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) | |||
| if (video_fd >= 0) | |||
| close(video_fd); | |||
| av_free(st); | |||
| av_free(s); | |||
| return -EIO; | |||
| } | |||
| @@ -327,24 +318,22 @@ static int grab_read_close(AVFormatContext *s1) | |||
| ioctl(s->fd, VIDIOCSAUDIO, &audio_saved); | |||
| close(s->fd); | |||
| av_free(s); | |||
| return 0; | |||
| } | |||
| AVFormat video_grab_device_format = { | |||
| AVInputFormat video_grab_device_format = { | |||
| "video_grab_device", | |||
| "video grab", | |||
| "", | |||
| "", | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_NONE, | |||
| sizeof(VideoData), | |||
| NULL, | |||
| NULL, | |||
| NULL, | |||
| grab_read_header, | |||
| grab_read_packet, | |||
| grab_read_close, | |||
| NULL, | |||
| AVFMT_NOFILE, | |||
| flags: AVFMT_NOFILE, | |||
| }; | |||
| int video_grab_init(void) | |||
| { | |||
| av_register_input_format(&video_grab_device_format); | |||
| return 0; | |||
| } | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * Image format | |||
| * Copyright (c) 2000, 2001 Gerard Lantau. | |||
| * Copyright (c) 2000, 2001, 2002 Gerard Lantau. | |||
| * | |||
| * This program is free software; you can redistribute it and/or modify | |||
| * it under the terms of the GNU General Public License as published by | |||
| @@ -18,6 +18,21 @@ | |||
| */ | |||
| #include "avformat.h" | |||
| extern AVInputFormat pgm_iformat; | |||
| extern AVOutputFormat pgm_oformat; | |||
| extern AVInputFormat pgmyuv_iformat; | |||
| extern AVOutputFormat pgmyuv_oformat; | |||
| extern AVInputFormat ppm_iformat; | |||
| extern AVOutputFormat ppm_oformat; | |||
| extern AVInputFormat imgyuv_iformat; | |||
| extern AVOutputFormat imgyuv_oformat; | |||
| extern AVInputFormat pgmpipe_iformat; | |||
| extern AVOutputFormat pgmpipe_oformat; | |||
| extern AVInputFormat pgmyuvpipe_iformat; | |||
| extern AVOutputFormat pgmyuvpipe_oformat; | |||
| extern AVInputFormat ppmpipe_iformat; | |||
| extern AVOutputFormat ppmpipe_oformat; | |||
| #define IMGFMT_YUV 1 | |||
| #define IMGFMT_PGMYUV 2 | |||
| #define IMGFMT_PGM 3 | |||
| @@ -248,46 +263,38 @@ static int infer_size(int *width_ptr, int *height_ptr, int size) | |||
| static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) | |||
| { | |||
| VideoData *s; | |||
| VideoData *s = s1->priv_data; | |||
| int i, h; | |||
| char buf[1024]; | |||
| char buf1[32]; | |||
| ByteIOContext pb1, *f = &pb1; | |||
| AVStream *st; | |||
| s = av_malloc(sizeof(VideoData)); | |||
| if (!s) | |||
| return -ENOMEM; | |||
| s1->priv_data = s; | |||
| s1->nb_streams = 1; | |||
| st = av_mallocz(sizeof(AVStream)); | |||
| st = av_new_stream(s1, 0); | |||
| if (!st) { | |||
| av_free(s); | |||
| return -ENOMEM; | |||
| } | |||
| s1->streams[0] = st; | |||
| strcpy(s->path, s1->filename); | |||
| s->img_number = 0; | |||
| /* find format */ | |||
| if (s1->format->flags & AVFMT_NOFILE) | |||
| if (s1->iformat->flags & AVFMT_NOFILE) | |||
| s->is_pipe = 0; | |||
| else | |||
| s->is_pipe = 1; | |||
| if (s1->format == &pgmyuvpipe_format || | |||
| s1->format == &pgmyuv_format) | |||
| if (s1->iformat == &pgmyuvpipe_iformat || | |||
| s1->iformat == &pgmyuv_iformat) | |||
| s->img_fmt = IMGFMT_PGMYUV; | |||
| else if (s1->format == &pgmpipe_format || | |||
| s1->format == &pgm_format) | |||
| else if (s1->iformat == &pgmpipe_iformat || | |||
| s1->iformat == &pgm_iformat) | |||
| s->img_fmt = IMGFMT_PGM; | |||
| else if (s1->format == &imgyuv_format) | |||
| else if (s1->iformat == &imgyuv_iformat) | |||
| s->img_fmt = IMGFMT_YUV; | |||
| else if (s1->format == &ppmpipe_format || | |||
| s1->format == &ppm_format) | |||
| else if (s1->iformat == &ppmpipe_iformat || | |||
| s1->iformat == &ppm_iformat) | |||
| s->img_fmt = IMGFMT_PPM; | |||
| else | |||
| goto fail; | |||
| @@ -378,8 +385,6 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) | |||
| static int img_read_close(AVFormatContext *s1) | |||
| { | |||
| VideoData *s = s1->priv_data; | |||
| av_free(s); | |||
| return 0; | |||
| } | |||
| @@ -479,31 +484,27 @@ static int yuv_save(AVPicture *picture, int width, int height, const char *filen | |||
| static int img_write_header(AVFormatContext *s) | |||
| { | |||
| VideoData *img; | |||
| VideoData *img = s->priv_data; | |||
| img = av_mallocz(sizeof(VideoData)); | |||
| if (!img) | |||
| return -1; | |||
| s->priv_data = img; | |||
| img->img_number = 1; | |||
| strcpy(img->path, s->filename); | |||
| /* find format */ | |||
| if (s->format->flags & AVFMT_NOFILE) | |||
| if (s->oformat->flags & AVFMT_NOFILE) | |||
| img->is_pipe = 0; | |||
| else | |||
| img->is_pipe = 1; | |||
| if (s->format == &pgmyuvpipe_format || | |||
| s->format == &pgmyuv_format) { | |||
| if (s->oformat == &pgmyuvpipe_oformat || | |||
| s->oformat == &pgmyuv_oformat) { | |||
| img->img_fmt = IMGFMT_PGMYUV; | |||
| } else if (s->format == &pgmpipe_format || | |||
| s->format == &pgm_format) { | |||
| } else if (s->oformat == &pgmpipe_oformat || | |||
| s->oformat == &pgm_oformat) { | |||
| img->img_fmt = IMGFMT_PGM; | |||
| } else if (s->format == &imgyuv_format) { | |||
| } else if (s->oformat == &imgyuv_oformat) { | |||
| img->img_fmt = IMGFMT_YUV; | |||
| } else if (s->format == &ppmpipe_format || | |||
| s->format == &ppm_format) { | |||
| } else if (s->oformat == &ppmpipe_oformat || | |||
| s->oformat == &ppm_oformat) { | |||
| img->img_fmt = IMGFMT_PPM; | |||
| } else { | |||
| goto fail; | |||
| @@ -590,22 +591,41 @@ static int img_write_packet(AVFormatContext *s, int stream_index, | |||
| static int img_write_trailer(AVFormatContext *s) | |||
| { | |||
| VideoData *img = s->priv_data; | |||
| av_free(img); | |||
| return 0; | |||
| } | |||
| AVFormat pgm_format = { | |||
| AVInputFormat pgm_iformat = { | |||
| "pgm", | |||
| "pgm image format", | |||
| sizeof(VideoData), | |||
| NULL, | |||
| img_read_header, | |||
| img_read_packet, | |||
| img_read_close, | |||
| NULL, | |||
| AVFMT_NOFILE | AVFMT_NEEDNUMBER, | |||
| extensions: "pgm", | |||
| }; | |||
| AVOutputFormat pgm_oformat = { | |||
| "pgm", | |||
| "pgm image format", | |||
| "", | |||
| "pgm", | |||
| sizeof(VideoData), | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_RAWVIDEO, | |||
| img_write_header, | |||
| img_write_packet, | |||
| img_write_trailer, | |||
| AVFMT_NOFILE | AVFMT_NEEDNUMBER, | |||
| }; | |||
| AVInputFormat pgmyuv_iformat = { | |||
| "pgmyuv", | |||
| "pgm with YUV content image format", | |||
| sizeof(VideoData), | |||
| NULL, /* no probe */ | |||
| img_read_header, | |||
| img_read_packet, | |||
| img_read_close, | |||
| @@ -613,107 +633,170 @@ AVFormat pgm_format = { | |||
| AVFMT_NOFILE | AVFMT_NEEDNUMBER, | |||
| }; | |||
| AVFormat pgmyuv_format = { | |||
| AVOutputFormat pgmyuv_oformat = { | |||
| "pgmyuv", | |||
| "pgm with YUV content image format", | |||
| "", | |||
| "pgm", | |||
| sizeof(VideoData), | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_RAWVIDEO, | |||
| img_write_header, | |||
| img_write_packet, | |||
| img_write_trailer, | |||
| AVFMT_NOFILE | AVFMT_NEEDNUMBER, | |||
| }; | |||
| AVInputFormat ppm_iformat = { | |||
| "ppm", | |||
| "ppm image format", | |||
| sizeof(VideoData), | |||
| NULL, | |||
| img_read_header, | |||
| img_read_packet, | |||
| img_read_close, | |||
| NULL, | |||
| AVFMT_NOFILE | AVFMT_NEEDNUMBER, | |||
| AVFMT_NOFILE | AVFMT_NEEDNUMBER | AVFMT_RGB24, | |||
| extensions: "ppm", | |||
| }; | |||
| AVFormat ppm_format = { | |||
| AVOutputFormat ppm_oformat = { | |||
| "ppm", | |||
| "ppm image format", | |||
| "", | |||
| "ppm", | |||
| sizeof(VideoData), | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_RAWVIDEO, | |||
| img_write_header, | |||
| img_write_packet, | |||
| img_write_trailer, | |||
| AVFMT_NOFILE | AVFMT_NEEDNUMBER | AVFMT_RGB24, | |||
| }; | |||
| AVInputFormat imgyuv_iformat = { | |||
| ".Y.U.V", | |||
| ".Y.U.V format", | |||
| sizeof(VideoData), | |||
| NULL, | |||
| img_read_header, | |||
| img_read_packet, | |||
| img_read_close, | |||
| NULL, | |||
| AVFMT_NOFILE | AVFMT_NEEDNUMBER, | |||
| extensions: "Y", | |||
| }; | |||
| AVFormat imgyuv_format = { | |||
| AVOutputFormat imgyuv_oformat = { | |||
| ".Y.U.V", | |||
| ".Y.U.V format", | |||
| "", | |||
| "Y", | |||
| sizeof(VideoData), | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_RAWVIDEO, | |||
| img_write_header, | |||
| img_write_packet, | |||
| img_write_trailer, | |||
| AVFMT_NOFILE | AVFMT_NEEDNUMBER, | |||
| }; | |||
| AVInputFormat pgmpipe_iformat = { | |||
| "pgmpipe", | |||
| "PGM pipe format", | |||
| sizeof(VideoData), | |||
| NULL, /* no probe */ | |||
| img_read_header, | |||
| img_read_packet, | |||
| img_read_close, | |||
| NULL, | |||
| AVFMT_NOFILE | AVFMT_NEEDNUMBER, | |||
| }; | |||
| AVFormat pgmpipe_format = { | |||
| AVOutputFormat pgmpipe_oformat = { | |||
| "pgmpipe", | |||
| "PGM pipe format", | |||
| "", | |||
| "pgm", | |||
| sizeof(VideoData), | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_RAWVIDEO, | |||
| img_write_header, | |||
| img_write_packet, | |||
| img_write_trailer, | |||
| }; | |||
| AVInputFormat pgmyuvpipe_iformat = { | |||
| "pgmyuvpipe", | |||
| "PGM YUV pipe format", | |||
| sizeof(VideoData), | |||
| NULL, /* no probe */ | |||
| img_read_header, | |||
| img_read_packet, | |||
| img_read_close, | |||
| NULL, | |||
| }; | |||
| AVFormat pgmyuvpipe_format = { | |||
| AVOutputFormat pgmyuvpipe_oformat = { | |||
| "pgmyuvpipe", | |||
| "PGM YUV pipe format", | |||
| "", | |||
| "pgm", | |||
| sizeof(VideoData), | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_RAWVIDEO, | |||
| img_write_header, | |||
| img_write_packet, | |||
| img_write_trailer, | |||
| }; | |||
| AVInputFormat ppmpipe_iformat = { | |||
| "ppmpipe", | |||
| "PPM pipe format", | |||
| sizeof(VideoData), | |||
| NULL, /* no probe */ | |||
| img_read_header, | |||
| img_read_packet, | |||
| img_read_close, | |||
| NULL, | |||
| flags: AVFMT_RGB24, | |||
| }; | |||
| AVFormat ppmpipe_format = { | |||
| AVOutputFormat ppmpipe_oformat = { | |||
| "ppmpipe", | |||
| "PPM pipe format", | |||
| "", | |||
| "ppm", | |||
| sizeof(VideoData), | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_RAWVIDEO, | |||
| img_write_header, | |||
| img_write_packet, | |||
| img_write_trailer, | |||
| img_read_header, | |||
| img_read_packet, | |||
| img_read_close, | |||
| NULL, | |||
| flags: AVFMT_RGB24, | |||
| }; | |||
| int img_init(void) | |||
| { | |||
| av_register_input_format(&pgm_iformat); | |||
| av_register_output_format(&pgm_oformat); | |||
| av_register_input_format(&pgmyuv_iformat); | |||
| av_register_output_format(&pgmyuv_oformat); | |||
| av_register_input_format(&ppm_iformat); | |||
| av_register_output_format(&ppm_oformat); | |||
| av_register_input_format(&imgyuv_iformat); | |||
| av_register_output_format(&imgyuv_oformat); | |||
| av_register_input_format(&pgmpipe_iformat); | |||
| av_register_output_format(&pgmpipe_oformat); | |||
| av_register_input_format(&pgmyuvpipe_iformat); | |||
| av_register_output_format(&pgmyuvpipe_oformat); | |||
| av_register_input_format(&ppmpipe_iformat); | |||
| av_register_output_format(&ppmpipe_oformat); | |||
| return 0; | |||
| } | |||
| @@ -52,11 +52,12 @@ static int mpjpeg_write_trailer(AVFormatContext *s) | |||
| return 0; | |||
| } | |||
| AVFormat mpjpeg_format = { | |||
| static AVOutputFormat mpjpeg_format = { | |||
| "mpjpeg", | |||
| "Mime multipart JPEG format", | |||
| "multipart/x-mixed-replace;boundary=" BOUNDARY_TAG, | |||
| "mjpg", | |||
| 0, | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_MJPEG, | |||
| mpjpeg_write_header, | |||
| @@ -86,11 +87,12 @@ static int single_jpeg_write_trailer(AVFormatContext *s) | |||
| return 0; | |||
| } | |||
| AVFormat single_jpeg_format = { | |||
| static AVOutputFormat single_jpeg_format = { | |||
| "singlejpeg", | |||
| "single JPEG image", | |||
| "image/jpeg", | |||
| "jpg,jpeg", | |||
| 0, | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_MJPEG, | |||
| single_jpeg_write_header, | |||
| @@ -114,7 +116,7 @@ static int jpeg_write_header(AVFormatContext *s1) | |||
| if (!s) | |||
| return -1; | |||
| s1->priv_data = s; | |||
| nstrcpy(s->path, sizeof(s->path), s1->filename); | |||
| pstrcpy(s->path, sizeof(s->path), s1->filename); | |||
| s->img_number = 1; | |||
| return 0; | |||
| } | |||
| @@ -162,7 +164,7 @@ static int jpeg_read_header(AVFormatContext *s1, AVFormatParameters *ap) | |||
| if (!s) | |||
| return -1; | |||
| s1->priv_data = s; | |||
| nstrcpy(s->path, sizeof(s->path), s1->filename); | |||
| pstrcpy(s->path, sizeof(s->path), s1->filename); | |||
| s1->nb_streams = 1; | |||
| st = av_mallocz(sizeof(AVStream)); | |||
| @@ -231,20 +233,38 @@ static int jpeg_read_close(AVFormatContext *s1) | |||
| return 0; | |||
| } | |||
| AVFormat jpeg_format = { | |||
| static AVInputFormat jpeg_iformat = { | |||
| "jpeg", | |||
| "JPEG image", | |||
| sizeof(JpegContext), | |||
| NULL, | |||
| jpeg_read_header, | |||
| jpeg_read_packet, | |||
| jpeg_read_close, | |||
| NULL, | |||
| flags: AVFMT_NOFILE | AVFMT_NEEDNUMBER, | |||
| extensions: "jpg,jpeg", | |||
| }; | |||
| static AVOutputFormat jpeg_oformat = { | |||
| "jpeg", | |||
| "JPEG image", | |||
| "image/jpeg", | |||
| "jpg,jpeg", | |||
| sizeof(JpegContext), | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_MJPEG, | |||
| jpeg_write_header, | |||
| jpeg_write_packet, | |||
| jpeg_write_trailer, | |||
| jpeg_read_header, | |||
| jpeg_read_packet, | |||
| jpeg_read_close, | |||
| NULL, | |||
| AVFMT_NOFILE | AVFMT_NEEDNUMBER, | |||
| flags: AVFMT_NOFILE | AVFMT_NEEDNUMBER, | |||
| }; | |||
| int jpeg_init(void) | |||
| { | |||
| av_register_output_format(&mpjpeg_format); | |||
| av_register_output_format(&single_jpeg_format); | |||
| av_register_input_format(&jpeg_iformat); | |||
| av_register_output_format(&jpeg_oformat); | |||
| return 0; | |||
| } | |||
| @@ -44,7 +44,7 @@ | |||
| * QuickTime is a trademark of Apple (AFAIK :)) | |||
| */ | |||
| #define DEBUG | |||
| //#define DEBUG | |||
| #ifdef DEBUG | |||
| /* | |||
| @@ -394,7 +394,7 @@ static int parse_hdlr(const MOVParseTableEntry *parse_table, ByteIOContext *pb, | |||
| { | |||
| MOVContext *c; | |||
| int len; | |||
| char *buf, ch; | |||
| char *buf; | |||
| UINT32 type; | |||
| AVStream *st; | |||
| UINT32 ctype; | |||
| @@ -453,21 +453,23 @@ static int parse_hdlr(const MOVParseTableEntry *parse_table, ByteIOContext *pb, | |||
| return 0; /* nothing left to read */ | |||
| /* XXX: MP4 uses a C string, not a pascal one */ | |||
| /* component name */ | |||
| if(c->mp4) { | |||
| len = get_byte(pb); | |||
| /* XXX: use a better heuristic */ | |||
| if(len < 32) { | |||
| /* assume that it is a Pascal like string */ | |||
| buf = av_malloc(len+1); | |||
| get_buffer(pb, buf, len); | |||
| buf[len] = '\0'; | |||
| #ifdef DEBUG | |||
| puts("MP4!!!"); | |||
| printf("**buf='%s'\n", buf); | |||
| #endif | |||
| while ((ch = get_byte(pb))); | |||
| av_free(buf); | |||
| } else { | |||
| len = get_byte(pb); | |||
| if(len) { | |||
| buf = av_malloc(len+1); | |||
| get_buffer(pb, buf, len); | |||
| buf[len] = '\0'; | |||
| #ifdef DEBUG | |||
| puts(buf); | |||
| #endif | |||
| av_free(buf); | |||
| /* MP4 string */ | |||
| for(;;) { | |||
| if (len == 0) | |||
| break; | |||
| len = get_byte(pb); | |||
| } | |||
| } | |||
| @@ -763,21 +765,34 @@ static void mov_free_stream_context(MOVStreamContext *sc) | |||
| } | |||
| } | |||
| /* XXX: is it suffisant ? */ | |||
| static int mov_probe(AVProbeData *p) | |||
| { | |||
| /* check file header */ | |||
| if (p->buf_size <= 12) | |||
| return 0; | |||
| if ((p->buf[4] == 'm' && p->buf[5] == 'o' && | |||
| p->buf[6] == 'o' && p->buf[7] == 'v') || | |||
| (p->buf[4] == 'm' && p->buf[5] == 'd' && | |||
| p->buf[6] == 'a' && p->buf[7] == 't')) | |||
| return AVPROBE_SCORE_MAX; | |||
| else | |||
| return 0; | |||
| } | |||
| static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| { | |||
| MOVContext *mov; | |||
| MOVContext *mov = s->priv_data; | |||
| ByteIOContext *pb = &s->pb; | |||
| int i, j, nb, err; | |||
| INT64 size; | |||
| mov = av_mallocz(sizeof(MOVContext)); | |||
| if (!mov) | |||
| return -1; | |||
| s->priv_data = mov; | |||
| mov->fc = s; | |||
| if(s->format->name[1] == 'p') | |||
| #if 0 | |||
| /* XXX: I think we should auto detect */ | |||
| if(s->iformat->name[1] == 'p') | |||
| mov->mp4 = 1; | |||
| #endif | |||
| if(!url_is_streamed(pb)) /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ | |||
| size = url_filesize(url_fileno(pb)); | |||
| else | |||
| @@ -916,38 +931,21 @@ static int mov_read_close(AVFormatContext *s) | |||
| mov_free_stream_context(mov->streams[i]); | |||
| for(i=0; i<s->nb_streams; i++) | |||
| av_free(s->streams[i]); | |||
| av_free(mov); | |||
| return 0; | |||
| } | |||
| AVFormat mov_format = { | |||
| "mov", | |||
| "QuickTime format", | |||
| "video/quicktime", | |||
| static AVInputFormat mov_iformat = { | |||
| "mov", | |||
| CODEC_ID_MP2, | |||
| CODEC_ID_MJPEG, | |||
| NULL, | |||
| NULL, | |||
| NULL, | |||
| "QuickTime/MPEG4 format", | |||
| sizeof(MOVContext), | |||
| mov_probe, | |||
| mov_read_header, | |||
| mov_read_packet, | |||
| mov_read_close, | |||
| }; | |||
| AVFormat mp4_format = { | |||
| "mp4", | |||
| "MPEG4 file format", | |||
| "video/mpeg4", | |||
| "mp4", | |||
| CODEC_ID_MP2, | |||
| CODEC_ID_MJPEG, | |||
| NULL, | |||
| NULL, | |||
| NULL, | |||
| mov_read_header, | |||
| mov_read_packet, | |||
| mov_read_close, | |||
| }; | |||
| int mov_init(void) | |||
| { | |||
| av_register_input_format(&mov_iformat); | |||
| return 0; | |||
| } | |||
| @@ -43,27 +43,20 @@ static int raw_read_header(AVFormatContext *s, | |||
| AVFormatParameters *ap) | |||
| { | |||
| AVStream *st; | |||
| int id; | |||
| st = av_malloc(sizeof(AVStream)); | |||
| st = av_new_stream(s, 0); | |||
| if (!st) | |||
| return -1; | |||
| s->nb_streams = 1; | |||
| s->streams[0] = st; | |||
| st->id = 0; | |||
| return AVERROR_NOMEM; | |||
| if (ap) { | |||
| if (s->format->audio_codec != CODEC_ID_NONE) { | |||
| st->codec.codec_type = CODEC_TYPE_AUDIO; | |||
| st->codec.codec_id = s->format->audio_codec; | |||
| } else if (s->format->video_codec != CODEC_ID_NONE) { | |||
| id = s->iformat->value; | |||
| if (id == CODEC_ID_RAWVIDEO) { | |||
| st->codec.codec_type = CODEC_TYPE_VIDEO; | |||
| st->codec.codec_id = s->format->video_codec; | |||
| } else { | |||
| av_free(st); | |||
| return -1; | |||
| st->codec.codec_type = CODEC_TYPE_AUDIO; | |||
| } | |||
| st->codec.codec_id = id; | |||
| switch(st->codec.codec_type) { | |||
| case CODEC_TYPE_AUDIO: | |||
| st->codec.sample_rate = ap->sample_rate; | |||
| @@ -116,13 +109,9 @@ static int mp3_read_header(AVFormatContext *s, | |||
| { | |||
| AVStream *st; | |||
| st = av_malloc(sizeof(AVStream)); | |||
| st = av_new_stream(s, 0); | |||
| if (!st) | |||
| return -1; | |||
| s->nb_streams = 1; | |||
| s->streams[0] = st; | |||
| st->id = 0; | |||
| return AVERROR_NOMEM; | |||
| st->codec.codec_type = CODEC_TYPE_AUDIO; | |||
| st->codec.codec_id = CODEC_ID_MP2; | |||
| @@ -136,14 +125,12 @@ static int video_read_header(AVFormatContext *s, | |||
| { | |||
| AVStream *st; | |||
| st = av_mallocz(sizeof(AVStream)); | |||
| st = av_new_stream(s, 0); | |||
| if (!st) | |||
| return -1; | |||
| s->nb_streams = 1; | |||
| s->streams[0] = st; | |||
| return AVERROR_NOMEM; | |||
| st->codec.codec_type = CODEC_TYPE_VIDEO; | |||
| st->codec.codec_id = s->format->video_codec; | |||
| st->codec.codec_id = s->iformat->value; | |||
| /* for mjpeg, specify frame rate */ | |||
| if (st->codec.codec_id == CODEC_ID_MJPEG) { | |||
| if (ap) { | |||
| @@ -155,227 +142,206 @@ static int video_read_header(AVFormatContext *s, | |||
| return 0; | |||
| } | |||
| AVFormat mp2_format = { | |||
| "mp2", | |||
| #define SEQ_START_CODE 0x000001b3 | |||
| #define GOP_START_CODE 0x000001b8 | |||
| #define PICTURE_START_CODE 0x00000100 | |||
| /* XXX: improve that by looking at several start codes */ | |||
| static int mpegvideo_probe(AVProbeData *p) | |||
| { | |||
| int code, c, i; | |||
| code = 0xff; | |||
| /* we search the first start code. If it is a sequence, gop or | |||
| picture start code then we decide it is an mpeg video | |||
| stream. We do not send highest value to give a chance to mpegts */ | |||
| for(i=0;i<p->buf_size;i++) { | |||
| c = p->buf[i]; | |||
| code = (code << 8) | c; | |||
| if ((code & 0xffffff00) == 0x100) { | |||
| if (code == SEQ_START_CODE || | |||
| code == GOP_START_CODE || | |||
| code == PICTURE_START_CODE) | |||
| return AVPROBE_SCORE_MAX - 1; | |||
| else | |||
| return 0; | |||
| } | |||
| } | |||
| return 0; | |||
| } | |||
| AVInputFormat mp3_iformat = { | |||
| "mp3", | |||
| "MPEG audio", | |||
| 0, | |||
| NULL, | |||
| mp3_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| extensions: "mp2,mp3", /* XXX: use probe */ | |||
| }; | |||
| AVOutputFormat mp2_oformat = { | |||
| "mp2", | |||
| "MPEG audio layer 2", | |||
| "audio/x-mpeg", | |||
| "mp2,mp3", | |||
| 0, | |||
| CODEC_ID_MP2, | |||
| 0, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| }; | |||
| mp3_read_header, | |||
| AVInputFormat ac3_iformat = { | |||
| "ac3", | |||
| "raw ac3", | |||
| 0, | |||
| NULL, | |||
| raw_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| extensions: "ac3", | |||
| value: CODEC_ID_AC3, | |||
| }; | |||
| AVFormat ac3_format = { | |||
| AVOutputFormat ac3_oformat = { | |||
| "ac3", | |||
| "raw ac3", | |||
| "audio/x-ac3", | |||
| "ac3", | |||
| 0, | |||
| CODEC_ID_AC3, | |||
| 0, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| raw_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| }; | |||
| AVFormat h263_format = { | |||
| AVOutputFormat h263_oformat = { | |||
| "h263", | |||
| "raw h263", | |||
| "video/x-h263", | |||
| "h263", | |||
| 0, | |||
| 0, | |||
| CODEC_ID_H263, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| }; | |||
| AVInputFormat mpegvideo_iformat = { | |||
| "mpegvideo", | |||
| "MPEG video", | |||
| 0, | |||
| mpegvideo_probe, | |||
| video_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| value: CODEC_ID_MPEG1VIDEO, | |||
| }; | |||
| AVFormat mpeg1video_format = { | |||
| "mpegvideo", | |||
| AVOutputFormat mpeg1video_oformat = { | |||
| "mpeg1video", | |||
| "MPEG video", | |||
| "video/x-mpeg", | |||
| "mpg,mpeg", | |||
| 0, | |||
| 0, | |||
| CODEC_ID_MPEG1VIDEO, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| video_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| }; | |||
| AVFormat mjpeg_format = { | |||
| AVInputFormat mjpeg_iformat = { | |||
| "mjpeg", | |||
| "MJPEG video", | |||
| "video/x-mjpeg", | |||
| "mjpg,mjpeg", | |||
| 0, | |||
| CODEC_ID_MJPEG, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| NULL, | |||
| video_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| extensions: "mjpg,mjpeg", | |||
| value: CODEC_ID_MJPEG, | |||
| }; | |||
| /* pcm formats */ | |||
| AVFormat pcm_s16le_format = { | |||
| "s16le", | |||
| "pcm signed 16 bit little endian format", | |||
| NULL, | |||
| #ifdef WORDS_BIGENDIAN | |||
| "", | |||
| #else | |||
| "sw", | |||
| #endif | |||
| CODEC_ID_PCM_S16LE, | |||
| AVOutputFormat mjpeg_oformat = { | |||
| "mjpeg", | |||
| "MJPEG video", | |||
| "video/x-mjpeg", | |||
| "mjpg,mjpeg", | |||
| 0, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| raw_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| }; | |||
| AVFormat pcm_s16be_format = { | |||
| "s16be", | |||
| "pcm signed 16 bit big endian format", | |||
| NULL, | |||
| #ifdef WORDS_BIGENDIAN | |||
| "sw", | |||
| #else | |||
| "", | |||
| #endif | |||
| CODEC_ID_PCM_S16BE, | |||
| 0, | |||
| CODEC_ID_MJPEG, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| raw_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| }; | |||
| AVFormat pcm_u16le_format = { | |||
| "u16le", | |||
| "pcm unsigned 16 bit little endian format", | |||
| NULL, | |||
| #ifdef WORDS_BIGENDIAN | |||
| "", | |||
| #else | |||
| "uw", | |||
| #endif | |||
| CODEC_ID_PCM_U16LE, | |||
| 0, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| /* pcm formats */ | |||
| raw_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| #define PCMDEF(name, long_name, ext, codec) \ | |||
| AVInputFormat pcm_ ## name ## _iformat = {\ | |||
| #name,\ | |||
| long_name,\ | |||
| 0,\ | |||
| NULL,\ | |||
| raw_read_header,\ | |||
| raw_read_packet,\ | |||
| raw_read_close,\ | |||
| extensions: ext,\ | |||
| value: codec,\ | |||
| };\ | |||
| \ | |||
| AVOutputFormat pcm_ ## name ## _oformat = {\ | |||
| #name,\ | |||
| long_name,\ | |||
| NULL,\ | |||
| ext,\ | |||
| 0,\ | |||
| codec,\ | |||
| 0,\ | |||
| raw_write_header,\ | |||
| raw_write_packet,\ | |||
| raw_write_trailer,\ | |||
| }; | |||
| AVFormat pcm_u16be_format = { | |||
| "u16be", | |||
| "pcm unsigned 16 bit big endian format", | |||
| NULL, | |||
| #ifdef WORDS_BIGENDIAN | |||
| "uw", | |||
| #define BE_DEF(s) s | |||
| #define LE_DEF(s) NULL | |||
| #else | |||
| "", | |||
| #define BE_DEF(s) NULL | |||
| #define LE_DEF(s) s | |||
| #endif | |||
| CODEC_ID_PCM_U16BE, | |||
| 0, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| raw_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| }; | |||
| AVFormat pcm_s8_format = { | |||
| "s8", | |||
| "pcm signed 8 bit format", | |||
| NULL, | |||
| "sb", | |||
| CODEC_ID_PCM_S8, | |||
| 0, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| PCMDEF(s16le, "pcm signed 16 bit little endian format", | |||
| LE_DEF("sw"), CODEC_ID_PCM_S16LE) | |||
| raw_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| }; | |||
| PCMDEF(s16be, "pcm signed 16 bit big endian format", | |||
| BE_DEF("sw"), CODEC_ID_PCM_S16BE) | |||
| AVFormat pcm_u8_format = { | |||
| "u8", | |||
| "pcm unsigned 8 bit format", | |||
| NULL, | |||
| "ub", | |||
| CODEC_ID_PCM_U8, | |||
| 0, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| PCMDEF(u16le, "pcm unsigned 16 bit little endian format", | |||
| LE_DEF("uw"), CODEC_ID_PCM_U16LE) | |||
| raw_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| }; | |||
| PCMDEF(u16be, "pcm unsigned 16 bit big endian format", | |||
| BE_DEF("uw"), CODEC_ID_PCM_U16BE) | |||
| AVFormat pcm_mulaw_format = { | |||
| "mulaw", | |||
| "pcm mu law format", | |||
| NULL, | |||
| "ul", | |||
| CODEC_ID_PCM_MULAW, | |||
| 0, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| PCMDEF(s8, "pcm signed 8 bit format", | |||
| "sb", CODEC_ID_PCM_S8) | |||
| raw_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| }; | |||
| PCMDEF(u8, "pcm unsigned 8 bit format", | |||
| "ub", CODEC_ID_PCM_U8) | |||
| AVFormat pcm_alaw_format = { | |||
| "alaw", | |||
| "pcm A law format", | |||
| NULL, | |||
| "al", | |||
| CODEC_ID_PCM_ALAW, | |||
| 0, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| PCMDEF(mulaw, "pcm mu law format", | |||
| "ul", CODEC_ID_PCM_MULAW) | |||
| raw_read_header, | |||
| raw_read_packet, | |||
| raw_read_close, | |||
| }; | |||
| PCMDEF(alaw, "pcm A law format", | |||
| "al", CODEC_ID_PCM_ALAW) | |||
| int rawvideo_read_packet(AVFormatContext *s, | |||
| AVPacket *pkt) | |||
| @@ -416,18 +382,65 @@ int rawvideo_read_packet(AVFormatContext *s, | |||
| } | |||
| } | |||
| AVFormat rawvideo_format = { | |||
| AVInputFormat rawvideo_iformat = { | |||
| "rawvideo", | |||
| "raw video format", | |||
| 0, | |||
| NULL, | |||
| raw_read_header, | |||
| rawvideo_read_packet, | |||
| raw_read_close, | |||
| extensions: "yuv", | |||
| value: CODEC_ID_RAWVIDEO, | |||
| }; | |||
| AVOutputFormat rawvideo_oformat = { | |||
| "rawvideo", | |||
| "raw video format", | |||
| NULL, | |||
| "yuv", | |||
| 0, | |||
| CODEC_ID_NONE, | |||
| CODEC_ID_RAWVIDEO, | |||
| raw_write_header, | |||
| raw_write_packet, | |||
| raw_write_trailer, | |||
| raw_read_header, | |||
| rawvideo_read_packet, | |||
| raw_read_close, | |||
| }; | |||
| int raw_init(void) | |||
| { | |||
| av_register_input_format(&mp3_iformat); | |||
| av_register_output_format(&mp2_oformat); | |||
| av_register_input_format(&ac3_iformat); | |||
| av_register_output_format(&ac3_oformat); | |||
| av_register_output_format(&h263_oformat); | |||
| av_register_input_format(&mpegvideo_iformat); | |||
| av_register_output_format(&mpeg1video_oformat); | |||
| av_register_input_format(&mjpeg_iformat); | |||
| av_register_output_format(&mjpeg_oformat); | |||
| av_register_input_format(&pcm_s16le_iformat); | |||
| av_register_output_format(&pcm_s16le_oformat); | |||
| av_register_input_format(&pcm_s16be_iformat); | |||
| av_register_output_format(&pcm_s16be_oformat); | |||
| av_register_input_format(&pcm_u16le_iformat); | |||
| av_register_output_format(&pcm_u16le_oformat); | |||
| av_register_input_format(&pcm_u16be_iformat); | |||
| av_register_output_format(&pcm_u16be_oformat); | |||
| av_register_input_format(&pcm_s8_iformat); | |||
| av_register_output_format(&pcm_s8_oformat); | |||
| av_register_input_format(&pcm_u8_iformat); | |||
| av_register_output_format(&pcm_u8_oformat); | |||
| av_register_input_format(&pcm_mulaw_iformat); | |||
| av_register_output_format(&pcm_mulaw_oformat); | |||
| av_register_input_format(&pcm_alaw_iformat); | |||
| av_register_output_format(&pcm_alaw_oformat); | |||
| av_register_input_format(&rawvideo_iformat); | |||
| av_register_output_format(&rawvideo_oformat); | |||
| return 0; | |||
| } | |||
| @@ -281,17 +281,11 @@ static void write_packet_header(AVFormatContext *ctx, StreamInfo *stream, | |||
| static int rm_write_header(AVFormatContext *s) | |||
| { | |||
| RMContext *rm = s->priv_data; | |||
| StreamInfo *stream; | |||
| RMContext *rm; | |||
| int n; | |||
| AVCodecContext *codec; | |||
| rm = av_malloc(sizeof(RMContext)); | |||
| if (!rm) | |||
| return -1; | |||
| memset(rm, 0, sizeof(RMContext)); | |||
| s->priv_data = rm; | |||
| for(n=0;n<s->nb_streams;n++) { | |||
| s->streams[n]->id = n; | |||
| codec = &s->streams[n]->codec; | |||
| @@ -438,8 +432,6 @@ static int rm_write_trailer(AVFormatContext *s) | |||
| put_be32(pb, 0); | |||
| } | |||
| put_flush_packet(pb); | |||
| av_free(rm); | |||
| return 0; | |||
| } | |||
| @@ -475,7 +467,7 @@ static void get_str8(ByteIOContext *pb, char *buf, int buf_size) | |||
| static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| { | |||
| RMContext *rm; | |||
| RMContext *rm = s->priv_data; | |||
| AVStream *st; | |||
| ByteIOContext *pb = &s->pb; | |||
| unsigned int tag, v; | |||
| @@ -487,10 +479,6 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| if (get_le32(pb) != MKTAG('.', 'R', 'M', 'F')) | |||
| return -EIO; | |||
| rm = av_mallocz(sizeof(RMContext)); | |||
| if (!rm) | |||
| return -ENOMEM; | |||
| s->priv_data = rm; | |||
| get_be32(pb); /* header size */ | |||
| get_be16(pb); | |||
| @@ -579,7 +567,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| st->codec.codec_id = CODEC_ID_AC3; | |||
| } else { | |||
| st->codec.codec_id = CODEC_ID_NONE; | |||
| nstrcpy(st->codec.codec_name, sizeof(st->codec.codec_name), | |||
| pstrcpy(st->codec.codec_name, sizeof(st->codec.codec_name), | |||
| buf); | |||
| } | |||
| } else { | |||
| @@ -706,23 +694,48 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) | |||
| static int rm_read_close(AVFormatContext *s) | |||
| { | |||
| RMContext *rm = s->priv_data; | |||
| av_free(rm); | |||
| return 0; | |||
| } | |||
| AVFormat rm_format = { | |||
| static int rm_probe(AVProbeData *p) | |||
| { | |||
| /* check file header */ | |||
| if (p->buf_size <= 32) | |||
| return 0; | |||
| if (p->buf[0] == '.' && p->buf[1] == 'R' && | |||
| p->buf[2] == 'M' && p->buf[3] == 'F' && | |||
| p->buf[4] == 0 && p->buf[5] == 0) | |||
| return AVPROBE_SCORE_MAX; | |||
| else | |||
| return 0; | |||
| } | |||
| AVInputFormat rm_iformat = { | |||
| "rm", | |||
| "rm format", | |||
| sizeof(RMContext), | |||
| rm_probe, | |||
| rm_read_header, | |||
| rm_read_packet, | |||
| rm_read_close, | |||
| }; | |||
| AVOutputFormat rm_oformat = { | |||
| "rm", | |||
| "rm format", | |||
| "audio/x-pn-realaudio", | |||
| "rm,ra", | |||
| sizeof(RMContext), | |||
| CODEC_ID_AC3, | |||
| CODEC_ID_RV10, | |||
| rm_write_header, | |||
| rm_write_packet, | |||
| rm_write_trailer, | |||
| rm_read_header, | |||
| rm_read_packet, | |||
| rm_read_close, | |||
| }; | |||
| int rm_init(void) | |||
| { | |||
| av_register_input_format(&rm_iformat); | |||
| av_register_output_format(&rm_oformat); | |||
| return 0; | |||
| } | |||
| @@ -438,6 +438,19 @@ static int get_swf_tag(ByteIOContext *pb, int *len_ptr) | |||
| return tag; | |||
| } | |||
| static int swf_probe(AVProbeData *p) | |||
| { | |||
| /* check file header */ | |||
| if (p->buf_size <= 16) | |||
| return 0; | |||
| if (p->buf[0] == 'F' && p->buf[1] == 'W' && | |||
| p->buf[2] == 'S' && p->buf[3] == '\0') | |||
| return AVPROBE_SCORE_MAX; | |||
| else | |||
| return 0; | |||
| } | |||
| static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| { | |||
| ByteIOContext *pb = &s->pb; | |||
| @@ -528,18 +541,32 @@ static int swf_read_close(AVFormatContext *s) | |||
| return 0; | |||
| } | |||
| AVFormat swf_format = { | |||
| static AVInputFormat swf_iformat = { | |||
| "swf", | |||
| "Flash format", | |||
| 0, | |||
| swf_probe, | |||
| swf_read_header, | |||
| swf_read_packet, | |||
| swf_read_close, | |||
| }; | |||
| static AVOutputFormat swf_oformat = { | |||
| "swf", | |||
| "Flash format", | |||
| "application/x-shockwave-flash", | |||
| "swf", | |||
| sizeof(SWFContext), | |||
| CODEC_ID_MP2, | |||
| CODEC_ID_MJPEG, | |||
| swf_write_header, | |||
| swf_write_packet, | |||
| swf_write_trailer, | |||
| swf_read_header, | |||
| swf_read_packet, | |||
| swf_read_close, | |||
| }; | |||
| int swf_init(void) | |||
| { | |||
| av_register_input_format(&swf_iformat); | |||
| av_register_output_format(&swf_oformat); | |||
| return 0; | |||
| } | |||
| @@ -110,16 +110,10 @@ typedef struct { | |||
| static int wav_write_header(AVFormatContext *s) | |||
| { | |||
| WAVContext *wav; | |||
| WAVContext *wav = s->priv_data; | |||
| ByteIOContext *pb = &s->pb; | |||
| offset_t fmt; | |||
| wav = av_malloc(sizeof(WAVContext)); | |||
| if (!wav) | |||
| return -1; | |||
| memset(wav, 0, sizeof(WAVContext)); | |||
| s->priv_data = wav; | |||
| put_tag(pb, "RIFF"); | |||
| put_le32(pb, 0); /* file length */ | |||
| put_tag(pb, "WAVE"); | |||
| @@ -165,8 +159,6 @@ static int wav_write_trailer(AVFormatContext *s) | |||
| put_flush_packet(pb); | |||
| } | |||
| av_free(wav); | |||
| return 0; | |||
| } | |||
| @@ -191,6 +183,20 @@ static int find_tag(ByteIOContext *pb, UINT32 tag1) | |||
| return size; | |||
| } | |||
| static int wav_probe(AVProbeData *p) | |||
| { | |||
| /* check file header */ | |||
| if (p->buf_size <= 32) | |||
| return 0; | |||
| if (p->buf[0] == 'R' && p->buf[1] == 'I' && | |||
| p->buf[2] == 'F' && p->buf[3] == 'F' && | |||
| p->buf[8] == 'W' && p->buf[9] == 'A' && | |||
| p->buf[10] == 'V' && p->buf[11] == 'E') | |||
| return AVPROBE_SCORE_MAX; | |||
| else | |||
| return 0; | |||
| } | |||
| /* wav input */ | |||
| static int wav_read_header(AVFormatContext *s, | |||
| AVFormatParameters *ap) | |||
| @@ -233,14 +239,10 @@ static int wav_read_header(AVFormatContext *s, | |||
| return -1; | |||
| /* now we are ready: build format streams */ | |||
| st = av_malloc(sizeof(AVStream)); | |||
| st = av_new_stream(s, 0); | |||
| if (!st) | |||
| return -1; | |||
| s->nb_streams = 1; | |||
| s->streams[0] = st; | |||
| return AVERROR_NOMEM; | |||
| st->id = 0; | |||
| st->codec.codec_type = CODEC_TYPE_AUDIO; | |||
| st->codec.codec_tag = id; | |||
| st->codec.codec_id = wav_codec_get_id(id, bps); | |||
| @@ -280,18 +282,32 @@ static int wav_read_close(AVFormatContext *s) | |||
| return 0; | |||
| } | |||
| AVFormat wav_format = { | |||
| static AVInputFormat wav_iformat = { | |||
| "wav", | |||
| "wav format", | |||
| 0, | |||
| wav_probe, | |||
| wav_read_header, | |||
| wav_read_packet, | |||
| wav_read_close, | |||
| }; | |||
| static AVOutputFormat wav_oformat = { | |||
| "wav", | |||
| "wav format", | |||
| "audio/x-wav", | |||
| "wav", | |||
| sizeof(WAVContext), | |||
| CODEC_ID_PCM_S16LE, | |||
| CODEC_ID_NONE, | |||
| wav_write_header, | |||
| wav_write_packet, | |||
| wav_write_trailer, | |||
| wav_read_header, | |||
| wav_read_packet, | |||
| wav_read_close, | |||
| }; | |||
| int wav_init(void) | |||
| { | |||
| av_register_input_format(&wav_iformat); | |||
| av_register_output_format(&wav_oformat); | |||
| return 0; | |||
| } | |||