diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-01-24 02:41:53 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-24 02:41:53 +0100 |
commit | 0bb57f8bf029427059be21a562527dcfa0e264c9 (patch) | |
tree | 8e6743c4fc1f16f36899bdea87e485735c0d8d59 /libavformat | |
parent | b955d4072e3e563b230c9ab4d6575577a3dc7314 (diff) | |
parent | 0fec2cb15cc6ff1fcc724c774ec36abadcb7b6ad (diff) | |
download | ffmpeg-0bb57f8bf029427059be21a562527dcfa0e264c9.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
Remove ffmpeg.
aacenc: Simplify windowing
aacenc: Move saved overlap samples to the beginning of the same buffer as incoming samples.
aacenc: Deinterleave input samples before processing.
aacenc: Store channel count in AACEncContext.
aacenc: Move Q^3/4 calculation to it's own table
aacenc: Request normalized float samples instead of converting s16 samples to float.
aacpsy: Replace an if with FFMAX in LAME windowing.
aacenc: cosmetics, replace 'rd' with 'bits' in codebook_trellis_rate to make it more clear what is being calculated.
aacpsy: cosmetics, change a FIXME to a NOTE about subshort comparisons
aacenc: cosmetics: move init() and end() to the bottom of the file.
aacenc: aac_encode_init() cleanup
XWD encoder and decoder
vc1: don't read the interpfrm and bfraction elements for interlaced frames
mxfdec: fix memleak on mxf_read_close()
westwood: split the AUD and VQA demuxers into separate files.
Conflicts:
.gitignore
Changelog
Makefile
configure
doc/ffmpeg.texi
ffmpeg.c
libavcodec/Makefile
libavcodec/aacenc.c
libavcodec/allcodecs.c
libavcodec/avcodec.h
libavcodec/version.h
libavformat/Makefile
libavformat/img2.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/Makefile | 4 | ||||
-rw-r--r-- | libavformat/img2.c | 3 | ||||
-rw-r--r-- | libavformat/westwood_aud.c | 173 | ||||
-rw-r--r-- | libavformat/westwood_vqa.c (renamed from libavformat/westwood.c) | 147 |
4 files changed, 179 insertions, 148 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile index 7c7cea5aad..e4e32afba2 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -326,8 +326,8 @@ OBJS-$(CONFIG_WC3_DEMUXER) += wc3movie.o OBJS-$(CONFIG_WEBM_MUXER) += matroskaenc.o matroska.o \ riff.o isom.o avc.o \ flacenc_header.o avlanguage.o -OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood.o -OBJS-$(CONFIG_WSVQA_DEMUXER) += westwood.o +OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood_aud.o +OBJS-$(CONFIG_WSVQA_DEMUXER) += westwood_vqa.o OBJS-$(CONFIG_WTV_DEMUXER) += wtvdec.o wtv.o asfdec.o asf.o asfcrypt.o \ avlanguage.o mpegts.o isom.o riff.o OBJS-$(CONFIG_WTV_MUXER) += wtvenc.o wtv.o asf.o asfenc.o riff.o diff --git a/libavformat/img2.c b/libavformat/img2.c index 775f5e7a05..8adba0ac5f 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -91,6 +91,7 @@ static const IdStrMap img_tags[] = { { CODEC_ID_JPEG2000 , "jpc"}, { CODEC_ID_DPX , "dpx"}, { CODEC_ID_PICTOR , "pic"}, + { CODEC_ID_XWD , "xwd"}, { CODEC_ID_NONE , NULL} }; @@ -528,7 +529,7 @@ AVOutputFormat ff_image2_muxer = { .name = "image2", .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), .extensions = "bmp,dpx,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png," - "ppm,sgi,tga,tif,tiff,jp2,j2c", + "ppm,sgi,tga,tif,tiff,jp2,j2c,xwd", .priv_data_size = sizeof(VideoData), .video_codec = CODEC_ID_MJPEG, .write_header = write_header, diff --git a/libavformat/westwood_aud.c b/libavformat/westwood_aud.c new file mode 100644 index 0000000000..b1eb768016 --- /dev/null +++ b/libavformat/westwood_aud.c @@ -0,0 +1,173 @@ +/* + * Westwood Studios AUD Format Demuxer + * Copyright (c) 2003 The ffmpeg Project + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Westwood Studios AUD file demuxer + * by Mike Melanson (melanson@pcisys.net) + * for more information on the Westwood file formats, visit: + * http://www.pcisys.net/~melanson/codecs/ + * http://www.geocities.com/SiliconValley/8682/aud3.txt + * + * Implementation note: There is no definite file signature for AUD files. + * The demuxer uses a probabilistic strategy for content detection. This + * entails performing sanity checks on certain header values in order to + * qualify a file. Refer to wsaud_probe() for the precise parameters. + */ + +#include "libavutil/intreadwrite.h" +#include "avformat.h" +#include "internal.h" + +#define AUD_HEADER_SIZE 12 +#define AUD_CHUNK_PREAMBLE_SIZE 8 +#define AUD_CHUNK_SIGNATURE 0x0000DEAF + +typedef struct WsAudDemuxContext { + int audio_samplerate; + int audio_channels; + int audio_bits; + enum CodecID audio_type; + int audio_stream_index; + int64_t audio_frame_counter; +} WsAudDemuxContext; + +static int wsaud_probe(AVProbeData *p) +{ + int field; + + /* Probabilistic content detection strategy: There is no file signature + * so perform sanity checks on various header parameters: + * 8000 <= sample rate (16 bits) <= 48000 ==> 40001 acceptable numbers + * flags <= 0x03 (2 LSBs are used) ==> 4 acceptable numbers + * compression type (8 bits) = 1 or 99 ==> 2 acceptable numbers + * first audio chunk signature (32 bits) ==> 1 acceptable number + * The number space contains 2^64 numbers. There are 40001 * 4 * 2 * 1 = + * 320008 acceptable number combinations. + */ + + if (p->buf_size < AUD_HEADER_SIZE + AUD_CHUNK_PREAMBLE_SIZE) + return 0; + + /* check sample rate */ + field = AV_RL16(&p->buf[0]); + if ((field < 8000) || (field > 48000)) + return 0; + + /* enforce the rule that the top 6 bits of this flags field are reserved (0); + * this might not be true, but enforce it until deemed unnecessary */ + if (p->buf[10] & 0xFC) + return 0; + + /* note: only check for WS IMA (type 99) right now since there is no + * support for type 1 */ + if (p->buf[11] != 99) + return 0; + + /* read ahead to the first audio chunk and validate the first header signature */ + if (AV_RL32(&p->buf[16]) != AUD_CHUNK_SIGNATURE) + return 0; + + /* return 1/2 certainty since this file check is a little sketchy */ + return AVPROBE_SCORE_MAX / 2; +} + +static int wsaud_read_header(AVFormatContext *s, + AVFormatParameters *ap) +{ + WsAudDemuxContext *wsaud = s->priv_data; + AVIOContext *pb = s->pb; + AVStream *st; + unsigned char header[AUD_HEADER_SIZE]; + + if (avio_read(pb, header, AUD_HEADER_SIZE) != AUD_HEADER_SIZE) + return AVERROR(EIO); + wsaud->audio_samplerate = AV_RL16(&header[0]); + if (header[11] == 99) + wsaud->audio_type = CODEC_ID_ADPCM_IMA_WS; + else + return AVERROR_INVALIDDATA; + + /* flag 0 indicates stereo */ + wsaud->audio_channels = (header[10] & 0x1) + 1; + /* flag 1 indicates 16 bit audio */ + wsaud->audio_bits = (((header[10] & 0x2) >> 1) + 1) * 8; + + /* initialize the audio decoder stream */ + st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + avpriv_set_pts_info(st, 33, 1, wsaud->audio_samplerate); + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; + st->codec->codec_id = wsaud->audio_type; + st->codec->codec_tag = 0; /* no tag */ + st->codec->channels = wsaud->audio_channels; + st->codec->sample_rate = wsaud->audio_samplerate; + st->codec->bits_per_coded_sample = wsaud->audio_bits; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_coded_sample / 4; + st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample; + + wsaud->audio_stream_index = st->index; + wsaud->audio_frame_counter = 0; + + return 0; +} + +static int wsaud_read_packet(AVFormatContext *s, + AVPacket *pkt) +{ + WsAudDemuxContext *wsaud = s->priv_data; + AVIOContext *pb = s->pb; + unsigned char preamble[AUD_CHUNK_PREAMBLE_SIZE]; + unsigned int chunk_size; + int ret = 0; + + if (avio_read(pb, preamble, AUD_CHUNK_PREAMBLE_SIZE) != + AUD_CHUNK_PREAMBLE_SIZE) + return AVERROR(EIO); + + /* validate the chunk */ + if (AV_RL32(&preamble[4]) != AUD_CHUNK_SIGNATURE) + return AVERROR_INVALIDDATA; + + chunk_size = AV_RL16(&preamble[0]); + ret= av_get_packet(pb, pkt, chunk_size); + if (ret != chunk_size) + return AVERROR(EIO); + pkt->stream_index = wsaud->audio_stream_index; + pkt->pts = wsaud->audio_frame_counter; + pkt->pts /= wsaud->audio_samplerate; + + /* 2 samples/byte, 1 or 2 samples per frame depending on stereo */ + wsaud->audio_frame_counter += (chunk_size * 2) / wsaud->audio_channels; + + return ret; +} + +AVInputFormat ff_wsaud_demuxer = { + .name = "wsaud", + .long_name = NULL_IF_CONFIG_SMALL("Westwood Studios audio format"), + .priv_data_size = sizeof(WsAudDemuxContext), + .read_probe = wsaud_probe, + .read_header = wsaud_read_header, + .read_packet = wsaud_read_packet, +}; diff --git a/libavformat/westwood.c b/libavformat/westwood_vqa.c index 4cbd5be396..4a851473b2 100644 --- a/libavformat/westwood.c +++ b/libavformat/westwood_vqa.c @@ -1,5 +1,5 @@ /* - * Westwood Studios Multimedia Formats Demuxer (VQA, AUD) + * Westwood Studios VQA Format Demuxer * Copyright (c) 2003 The ffmpeg Project * * This file is part of FFmpeg. @@ -21,26 +21,17 @@ /** * @file - * Westwood Studios VQA & AUD file demuxers + * Westwood Studios VQA file demuxer * by Mike Melanson (melanson@pcisys.net) * for more information on the Westwood file formats, visit: * http://www.pcisys.net/~melanson/codecs/ * http://www.geocities.com/SiliconValley/8682/aud3.txt - * - * Implementation note: There is no definite file signature for AUD files. - * The demuxer uses a probabilistic strategy for content detection. This - * entails performing sanity checks on certain header values in order to - * qualify a file. Refer to wsaud_probe() for the precise parameters. */ #include "libavutil/intreadwrite.h" #include "avformat.h" #include "internal.h" -#define AUD_HEADER_SIZE 12 -#define AUD_CHUNK_PREAMBLE_SIZE 8 -#define AUD_CHUNK_SIGNATURE 0x0000DEAF - #define FORM_TAG MKBETAG('F', 'O', 'R', 'M') #define WVQA_TAG MKBETAG('W', 'V', 'Q', 'A') #define VQHD_TAG MKBETAG('V', 'Q', 'H', 'D') @@ -63,15 +54,6 @@ #define VQA_FRAMERATE 15 #define VQA_PREAMBLE_SIZE 8 -typedef struct WsAudDemuxContext { - int audio_samplerate; - int audio_channels; - int audio_bits; - enum CodecID audio_type; - int audio_stream_index; - int64_t audio_frame_counter; -} WsAudDemuxContext; - typedef struct WsVqaDemuxContext { int audio_samplerate; int audio_channels; @@ -83,119 +65,6 @@ typedef struct WsVqaDemuxContext { int64_t audio_frame_counter; } WsVqaDemuxContext; -static int wsaud_probe(AVProbeData *p) -{ - int field; - - /* Probabilistic content detection strategy: There is no file signature - * so perform sanity checks on various header parameters: - * 8000 <= sample rate (16 bits) <= 48000 ==> 40001 acceptable numbers - * flags <= 0x03 (2 LSBs are used) ==> 4 acceptable numbers - * compression type (8 bits) = 1 or 99 ==> 2 acceptable numbers - * first audio chunk signature (32 bits) ==> 1 acceptable number - * The number space contains 2^64 numbers. There are 40001 * 4 * 2 * 1 = - * 320008 acceptable number combinations. - */ - - if (p->buf_size < AUD_HEADER_SIZE + AUD_CHUNK_PREAMBLE_SIZE) - return 0; - - /* check sample rate */ - field = AV_RL16(&p->buf[0]); - if ((field < 8000) || (field > 48000)) - return 0; - - /* enforce the rule that the top 6 bits of this flags field are reserved (0); - * this might not be true, but enforce it until deemed unnecessary */ - if (p->buf[10] & 0xFC) - return 0; - - /* note: only check for WS IMA (type 99) right now since there is no - * support for type 1 */ - if (p->buf[11] != 99) - return 0; - - /* read ahead to the first audio chunk and validate the first header signature */ - if (AV_RL32(&p->buf[16]) != AUD_CHUNK_SIGNATURE) - return 0; - - /* return 1/2 certainty since this file check is a little sketchy */ - return AVPROBE_SCORE_MAX / 2; -} - -static int wsaud_read_header(AVFormatContext *s, - AVFormatParameters *ap) -{ - WsAudDemuxContext *wsaud = s->priv_data; - AVIOContext *pb = s->pb; - AVStream *st; - unsigned char header[AUD_HEADER_SIZE]; - - if (avio_read(pb, header, AUD_HEADER_SIZE) != AUD_HEADER_SIZE) - return AVERROR(EIO); - wsaud->audio_samplerate = AV_RL16(&header[0]); - if (header[11] == 99) - wsaud->audio_type = CODEC_ID_ADPCM_IMA_WS; - else - return AVERROR_INVALIDDATA; - - /* flag 0 indicates stereo */ - wsaud->audio_channels = (header[10] & 0x1) + 1; - /* flag 1 indicates 16 bit audio */ - wsaud->audio_bits = (((header[10] & 0x2) >> 1) + 1) * 8; - - /* initialize the audio decoder stream */ - st = avformat_new_stream(s, NULL); - if (!st) - return AVERROR(ENOMEM); - avpriv_set_pts_info(st, 33, 1, wsaud->audio_samplerate); - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = wsaud->audio_type; - st->codec->codec_tag = 0; /* no tag */ - st->codec->channels = wsaud->audio_channels; - st->codec->sample_rate = wsaud->audio_samplerate; - st->codec->bits_per_coded_sample = wsaud->audio_bits; - st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * - st->codec->bits_per_coded_sample / 4; - st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample; - - wsaud->audio_stream_index = st->index; - wsaud->audio_frame_counter = 0; - - return 0; -} - -static int wsaud_read_packet(AVFormatContext *s, - AVPacket *pkt) -{ - WsAudDemuxContext *wsaud = s->priv_data; - AVIOContext *pb = s->pb; - unsigned char preamble[AUD_CHUNK_PREAMBLE_SIZE]; - unsigned int chunk_size; - int ret = 0; - - if (avio_read(pb, preamble, AUD_CHUNK_PREAMBLE_SIZE) != - AUD_CHUNK_PREAMBLE_SIZE) - return AVERROR(EIO); - - /* validate the chunk */ - if (AV_RL32(&preamble[4]) != AUD_CHUNK_SIGNATURE) - return AVERROR_INVALIDDATA; - - chunk_size = AV_RL16(&preamble[0]); - ret= av_get_packet(pb, pkt, chunk_size); - if (ret != chunk_size) - return AVERROR(EIO); - pkt->stream_index = wsaud->audio_stream_index; - pkt->pts = wsaud->audio_frame_counter; - pkt->pts /= wsaud->audio_samplerate; - - /* 2 samples/byte, 1 or 2 samples per frame depending on stereo */ - wsaud->audio_frame_counter += (chunk_size * 2) / wsaud->audio_channels; - - return ret; -} - static int wsvqa_probe(AVProbeData *p) { /* need 12 bytes to qualify */ @@ -367,17 +236,6 @@ static int wsvqa_read_packet(AVFormatContext *s, return ret; } -#if CONFIG_WSAUD_DEMUXER -AVInputFormat ff_wsaud_demuxer = { - .name = "wsaud", - .long_name = NULL_IF_CONFIG_SMALL("Westwood Studios audio format"), - .priv_data_size = sizeof(WsAudDemuxContext), - .read_probe = wsaud_probe, - .read_header = wsaud_read_header, - .read_packet = wsaud_read_packet, -}; -#endif -#if CONFIG_WSVQA_DEMUXER AVInputFormat ff_wsvqa_demuxer = { .name = "wsvqa", .long_name = NULL_IF_CONFIG_SMALL("Westwood Studios VQA format"), @@ -386,4 +244,3 @@ AVInputFormat ff_wsvqa_demuxer = { .read_header = wsvqa_read_header, .read_packet = wsvqa_read_packet, }; -#endif |