[FFmpeg-devel] [PATCH] avformat/westwood_aud: Adds PCM format demux.
Michael Niedermayer
michael at niedermayer.cc
Fri Mar 1 02:02:09 EET 2019
On Wed, Feb 27, 2019 at 11:12:08PM +0000, Aidan R wrote:
> PCM format AUD files are found in Westwood's Blade Runner game.
> ---
> libavformat/westwood_aud.c | 80 ++++++++++++++++++++++++++++++++++++----------
> 1 file changed, 63 insertions(+), 17 deletions(-)
>
> diff --git a/libavformat/westwood_aud.c b/libavformat/westwood_aud.c
> index 9c2d35cb8a..5d7e827bc1 100644
> --- a/libavformat/westwood_aud.c
> +++ b/libavformat/westwood_aud.c
> @@ -41,6 +41,12 @@
> #define AUD_HEADER_SIZE 12
> #define AUD_CHUNK_PREAMBLE_SIZE 8
> #define AUD_CHUNK_SIGNATURE 0x0000DEAF
> +#define AUD_PCM_CHUNK_SIZE 2048 /* arbitrary size to pull out of PCM data*/
> +
> +typedef struct AUDDemuxContext {
> + int size;
> + int pos;
> +} AUDDemuxContext;
>
> static int wsaud_probe(AVProbeData *p)
> {
> @@ -50,10 +56,10 @@ static int wsaud_probe(AVProbeData *p)
> * 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
> + * compression type (8 bits) = 0, 1 or 99 ==> 3 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.
> + * The number space contains 2^64 numbers. There are 40001 * 4 * 3 * 1 =
> + * 480012 acceptable number combinations.
> */
>
> if (p->buf_size < AUD_HEADER_SIZE + AUD_CHUNK_PREAMBLE_SIZE)
> @@ -69,13 +75,22 @@ static int wsaud_probe(AVProbeData *p)
> if (p->buf[10] & 0xFC)
> return 0;
>
> - if (p->buf[11] != 99 && p->buf[11] != 1)
> + /* valid format values are 99 == adpcm, 1 == snd1 and 0 == pcm */
> + if (p->buf[11] != 99 && p->buf[11] != 1 && p->buf[11] != 0)
> return 0;
>
> - /* read ahead to the first audio chunk and validate the first header signature */
> - if (AV_RL32(&p->buf[16]) != AUD_CHUNK_SIGNATURE)
> + /* read ahead to the first audio chunk and validate the first header
> + * signature pcm format does not use a chunk format, so don't check
> + * for that codec */
> + if (p->buf[11] != 0 && AV_RL32(&p->buf[16]) != AUD_CHUNK_SIGNATURE)
> return 0;
>
> + /* if we have pcm format then compressed size should equal
> + * uncompressed size */
> + if (p->buf[11] == 0 && AV_RL32(&p->buf[2]) != AV_RL32(&p->buf[6])) {
> + return 0;
> + }
> +
> /* return 1/2 certainty since this file check is a little sketchy */
> return AVPROBE_SCORE_EXTENSION;
> }
this seems to break probetest
tools/probetest 256 1024
testing size=1
testing size=2
testing size=4
testing size=8
testing size=16
testing size=32
Failure of wsaud probing code with score=50 type=0 p=EBC size=32
testing size=64
testing size=128
testing size=256
testing size=512
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190301/16d6841e/attachment.sig>
More information about the ffmpeg-devel
mailing list