diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2002-05-20 16:31:13 +0000 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2002-05-20 16:31:13 +0000 |
commit | c9a65ca8c306071b3c359b56a384a1594cd505df (patch) | |
tree | a33c4b156673f2c1404042501c1cebaae6a35457 /libav/asf.c | |
parent | db7f1f95acc050bb5ddf62b0008eab8c8305d369 (diff) | |
download | ffmpeg-c9a65ca8c306071b3c359b56a384a1594cd505df.tar.gz |
converted to new API
Originally committed as revision 547 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libav/asf.c')
-rw-r--r-- | libav/asf.c | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/libav/asf.c b/libav/asf.c index 7cb9fca067..93e801bd0c 100644 --- a/libav/asf.c +++ b/libav/asf.c @@ -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; +} |