From 0c0d1bce7c582b82e49843acaa7d0fb4b1774b21 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Fri, 23 Mar 2012 17:45:48 -0400 Subject: [PATCH 1/8] avutil: add audio fifo buffer The functions operate on the sample level rather than the byte level and work with all audio sample formats. --- doc/APIchanges | 12 +++ libavutil/Makefile | 2 + libavutil/audio_fifo.c | 193 +++++++++++++++++++++++++++++++++++++++++ libavutil/audio_fifo.h | 146 +++++++++++++++++++++++++++++++ libavutil/avutil.h | 4 +- 5 files changed, 355 insertions(+), 2 deletions(-) create mode 100644 libavutil/audio_fifo.c create mode 100644 libavutil/audio_fifo.h diff --git a/doc/APIchanges b/doc/APIchanges index 5114e14191..fed77b0eb5 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -12,6 +12,18 @@ libavutil: 2011-04-18 API changes, most recent first: +2012-xx-xx - xxxxxxx - lavu 51.28.0 - audio_fifo.h + Add audio FIFO functions: + av_audio_fifo_free() + av_audio_fifo_alloc() + av_audio_fifo_realloc() + av_audio_fifo_write() + av_audio_fifo_read() + av_audio_fifo_drain() + av_audio_fifo_reset() + av_audio_fifo_size() + av_audio_fifo_space() + 2012-xx-xx - xxxxxxx - lavfi 2.16.0 - avfiltergraph.h Add avfilter_graph_parse2(), avfilter_inout_alloc() and avfilter_inout_free() functions. diff --git a/libavutil/Makefile b/libavutil/Makefile index 820abb1429..69f2acd72e 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -3,6 +3,7 @@ NAME = avutil HEADERS = adler32.h \ aes.h \ attributes.h \ + audio_fifo.h \ audioconvert.h \ avassert.h \ avstring.h \ @@ -40,6 +41,7 @@ BUILT_HEADERS = avconfig.h OBJS = adler32.o \ aes.o \ + audio_fifo.o \ audioconvert.o \ avstring.o \ base64.o \ diff --git a/libavutil/audio_fifo.c b/libavutil/audio_fifo.c new file mode 100644 index 0000000000..97c51a72c1 --- /dev/null +++ b/libavutil/audio_fifo.c @@ -0,0 +1,193 @@ +/* + * Audio FIFO + * Copyright (c) 2012 Justin Ruggles + * + * 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 + * Audio FIFO + */ + +#include "avutil.h" +#include "audio_fifo.h" +#include "fifo.h" +#include "mem.h" +#include "samplefmt.h" + +struct AVAudioFifo { + AVFifoBuffer **buf; /**< single buffer for interleaved, per-channel buffers for planar */ + int nb_buffers; /**< number of buffers */ + int nb_samples; /**< number of samples currently in the FIFO */ + int allocated_samples; /**< current allocated size, in samples */ + + int channels; /**< number of channels */ + enum AVSampleFormat sample_fmt; /**< sample format */ + int sample_size; /**< size, in bytes, of one sample in a buffer */ +}; + +void av_audio_fifo_free(AVAudioFifo *af) +{ + if (af) { + if (af->buf) { + int i; + for (i = 0; i < af->nb_buffers; i++) { + if (af->buf[i]) + av_fifo_free(af->buf[i]); + } + av_free(af->buf); + } + av_free(af); + } +} + +AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, + int nb_samples) +{ + AVAudioFifo *af; + int buf_size, i; + + /* get channel buffer size (also validates parameters) */ + if (av_samples_get_buffer_size(&buf_size, channels, nb_samples, sample_fmt, 1) < 0) + return NULL; + + af = av_mallocz(sizeof(*af)); + if (!af) + return NULL; + + af->channels = channels; + af->sample_fmt = sample_fmt; + af->sample_size = buf_size / nb_samples; + af->nb_buffers = av_sample_fmt_is_planar(sample_fmt) ? channels : 1; + + af->buf = av_mallocz(af->nb_buffers * sizeof(*af->buf)); + if (!af->buf) + goto error; + + for (i = 0; i < af->nb_buffers; i++) { + af->buf[i] = av_fifo_alloc(buf_size); + if (!af->buf[i]) + goto error; + } + af->allocated_samples = nb_samples; + + return af; + +error: + av_audio_fifo_free(af); + return NULL; +} + +int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples) +{ + int i, ret, buf_size; + + if ((ret = av_samples_get_buffer_size(&buf_size, af->channels, nb_samples, + af->sample_fmt, 1)) < 0) + return ret; + + for (i = 0; i < af->nb_buffers; i++) { + if ((ret = av_fifo_realloc2(af->buf[i], buf_size)) < 0) + return ret; + } + af->allocated_samples = nb_samples; + return 0; +} + +int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples) +{ + int i, ret, size; + + /* automatically reallocate buffers if needed */ + if (av_audio_fifo_space(af) < nb_samples) { + int current_size = av_audio_fifo_size(af); + /* check for integer overflow in new size calculation */ + if (INT_MAX / 2 - current_size < nb_samples) + return AVERROR(EINVAL); + /* reallocate buffers */ + if ((ret = av_audio_fifo_realloc(af, 2 * (current_size + nb_samples))) < 0) + return ret; + } + + size = nb_samples * af->sample_size; + for (i = 0; i < af->nb_buffers; i++) { + ret = av_fifo_generic_write(af->buf[i], data[i], size, NULL); + if (ret != size) + return AVERROR_BUG; + } + af->nb_samples += nb_samples; + + return nb_samples; +} + +int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples) +{ + int i, ret, size; + + if (nb_samples < 0) + return AVERROR(EINVAL); + nb_samples = FFMIN(nb_samples, af->nb_samples); + if (!nb_samples) + return 0; + + size = nb_samples * af->sample_size; + for (i = 0; i < af->nb_buffers; i++) { + if ((ret = av_fifo_generic_read(af->buf[i], data[i], size, NULL)) < 0) + return AVERROR_BUG; + } + af->nb_samples -= nb_samples; + + return nb_samples; +} + +int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples) +{ + int i, size; + + if (nb_samples < 0) + return AVERROR(EINVAL); + nb_samples = FFMIN(nb_samples, af->nb_samples); + + if (nb_samples) { + size = nb_samples * af->sample_size; + for (i = 0; i < af->nb_buffers; i++) + av_fifo_drain(af->buf[i], size); + af->nb_samples -= nb_samples; + } + return 0; +} + +void av_audio_fifo_reset(AVAudioFifo *af) +{ + int i; + + for (i = 0; i < af->nb_buffers; i++) + av_fifo_reset(af->buf[i]); + + af->nb_samples = 0; +} + +int av_audio_fifo_size(AVAudioFifo *af) +{ + return af->nb_samples; +} + +int av_audio_fifo_space(AVAudioFifo *af) +{ + return af->allocated_samples - af->nb_samples; +} diff --git a/libavutil/audio_fifo.h b/libavutil/audio_fifo.h new file mode 100644 index 0000000000..8c76388255 --- /dev/null +++ b/libavutil/audio_fifo.h @@ -0,0 +1,146 @@ +/* + * Audio FIFO + * Copyright (c) 2012 Justin Ruggles + * + * 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 + * Audio FIFO Buffer + */ + +#ifndef AVUTIL_AUDIO_FIFO_H +#define AVUTIL_AUDIO_FIFO_H + +#include "avutil.h" +#include "fifo.h" +#include "samplefmt.h" + +/** + * @addtogroup lavu_audio + * @{ + */ + +/** + * Context for an Audio FIFO Buffer. + * + * - Operates at the sample level rather than the byte level. + * - Supports multiple channels with either planar or packed sample format. + * - Automatic reallocation when writing to a full buffer. + */ +typedef struct AVAudioFifo AVAudioFifo; + +/** + * Free an AVAudioFifo. + * + * @param af AVAudioFifo to free + */ +void av_audio_fifo_free(AVAudioFifo *af); + +/** + * Allocate an AVAudioFifo. + * + * @param sample_fmt sample format + * @param channels number of channels + * @param nb_samples initial allocation size, in samples + * @return newly allocated AVAudioFifo, or NULL on error + */ +AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, + int nb_samples); + +/** + * Reallocate an AVAudioFifo. + * + * @param af AVAudioFifo to reallocate + * @param nb_samples new allocation size, in samples + * @return 0 if OK, or negative AVERROR code on failure + */ +int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples); + +/** + * Write data to an AVAudioFifo. + * + * The AVAudioFifo will be reallocated automatically if the available space + * is less than nb_samples. + * + * @see enum AVSampleFormat + * The documentation for AVSampleFormat describes the data layout. + * + * @param af AVAudioFifo to write to + * @param data audio data plane pointers + * @param nb_samples number of samples to write + * @return number of samples actually written, or negative AVERROR + * code on failure. + */ +int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples); + +/** + * Read data from an AVAudioFifo. + * + * @see enum AVSampleFormat + * The documentation for AVSampleFormat describes the data layout. + * + * @param af AVAudioFifo to read from + * @param data audio data plane pointers + * @param nb_samples number of samples to read + * @return number of samples actually read, or negative AVERROR code + * on failure. + */ +int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples); + +/** + * Drain data from an AVAudioFifo. + * + * Removes the data without reading it. + * + * @param af AVAudioFifo to drain + * @param nb_samples number of samples to drain + * @return 0 if OK, or negative AVERROR code on failure + */ +int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples); + +/** + * Reset the AVAudioFifo buffer. + * + * This empties all data in the buffer. + * + * @param af AVAudioFifo to reset + */ +void av_audio_fifo_reset(AVAudioFifo *af); + +/** + * Get the current number of samples in the AVAudioFifo available for reading. + * + * @param af the AVAudioFifo to query + * @return number of samples available for reading + */ +int av_audio_fifo_size(AVAudioFifo *af); + +/** + * Get the current number of samples in the AVAudioFifo available for writing. + * + * @param af the AVAudioFifo to query + * @return number of samples available for writing + */ +int av_audio_fifo_space(AVAudioFifo *af); + +/** + * @} + */ + +#endif /* AVUTIL_AUDIO_FIFO_H */ diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 7319c22bfa..6673f0f53b 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -152,8 +152,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 27 -#define LIBAVUTIL_VERSION_MICRO 2 +#define LIBAVUTIL_VERSION_MINOR 28 +#define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ From 010943c6ce85385cadd6fd6070fb1d88fd1e24e7 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 17 Apr 2012 10:12:38 -0400 Subject: [PATCH 2/8] FATE: optionally write a WAVE header in audiogen --- tests/audiogen.c | 56 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/tests/audiogen.c b/tests/audiogen.c index c4d73aa86f..8d27dc2632 100644 --- a/tests/audiogen.c +++ b/tests/audiogen.c @@ -22,7 +22,9 @@ */ #include +#include #include +#include #define MAX_CHANNELS 8 @@ -93,12 +95,45 @@ static int int_cos(int a) FILE *outfile; -static void put_sample(int v) +static void put16(int16_t v) { - fputc(v & 0xff, outfile); + fputc( v & 0xff, outfile); fputc((v >> 8) & 0xff, outfile); } +static void put32(uint32_t v) +{ + fputc( v & 0xff, outfile); + fputc((v >> 8) & 0xff, outfile); + fputc((v >> 16) & 0xff, outfile); + fputc((v >> 24) & 0xff, outfile); +} + +#define HEADER_SIZE 46 +#define FMT_SIZE 18 +#define SAMPLE_SIZE 2 +#define WFORMAT_PCM 0x0001 + +static void put_wav_header(int sample_rate, int channels, int nb_samples) +{ + int block_align = SAMPLE_SIZE * channels; + int data_size = block_align * nb_samples; + + fputs("RIFF", outfile); + put32(HEADER_SIZE + data_size); + fputs("WAVEfmt ", outfile); + put32(FMT_SIZE); + put16(WFORMAT_PCM); + put16(channels); + put32(sample_rate); + put32(block_align * sample_rate); + put16(block_align); + put16(SAMPLE_SIZE * 8); + put16(0); + fputs("data", outfile); + put32(data_size); +} + int main(int argc, char **argv) { int i, a, v, j, f, amp, ampa; @@ -107,10 +142,12 @@ int main(int argc, char **argv) int taba[MAX_CHANNELS]; int sample_rate = 44100; int nb_channels = 2; + char *ext; if (argc < 2 || argc > 4) { printf("usage: %s file [ []]\n" "generate a test raw 16 bit audio stream\n" + "If the file extension is .wav a WAVE header will be added.\n" "default: 44100 Hz stereo\n", argv[0]); exit(1); } @@ -137,12 +174,15 @@ int main(int argc, char **argv) return 1; } + if ((ext = strrchr(argv[1], '.')) != NULL && !strcmp(ext, ".wav")) + put_wav_header(sample_rate, nb_channels, 6 * sample_rate); + /* 1 second of single freq sinus at 1000 Hz */ a = 0; for (i = 0; i < 1 * sample_rate; i++) { v = (int_cos(a) * 10000) >> FRAC_BITS; for (j = 0; j < nb_channels; j++) - put_sample(v); + put16(v); a += (1000 * FRAC_ONE) / sample_rate; } @@ -151,7 +191,7 @@ int main(int argc, char **argv) for (i = 0; i < 1 * sample_rate; i++) { v = (int_cos(a) * 10000) >> FRAC_BITS; for (j = 0; j < nb_channels; j++) - put_sample(v); + put16(v); f = 100 + (((10000 - 100) * i) / sample_rate); a += (f * FRAC_ONE) / sample_rate; } @@ -160,14 +200,14 @@ int main(int argc, char **argv) for (i = 0; i < sample_rate / 2; i++) { v = myrnd(&seed, 20000) - 10000; for (j = 0; j < nb_channels; j++) - put_sample(v); + put16(v); } /* 0.5 second of high amplitude white noise */ for (i = 0; i < sample_rate / 2; i++) { v = myrnd(&seed, 65535) - 32768; for (j = 0; j < nb_channels; j++) - put_sample(v); + put16(v); } /* 1 second of unrelated ramps for each channel */ @@ -179,7 +219,7 @@ int main(int argc, char **argv) for (i = 0; i < 1 * sample_rate; i++) { for (j = 0; j < nb_channels; j++) { v = (int_cos(taba[j]) * 10000) >> FRAC_BITS; - put_sample(v); + put16(v); f = tabf1[j] + (((tabf2[j] - tabf1[j]) * i) / sample_rate); taba[j] += (f * FRAC_ONE) / sample_rate; } @@ -194,7 +234,7 @@ int main(int argc, char **argv) if (j & 1) amp = 10000 - amp; v = (int_cos(a) * amp) >> FRAC_BITS; - put_sample(v); + put16(v); a += (500 * FRAC_ONE) / sample_rate; ampa += (2 * FRAC_ONE) / sample_rate; } From 870165e217fcdebf721e8e8b0e9acf96395efd1b Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 18 Apr 2012 21:41:01 -0400 Subject: [PATCH 3/8] FATE: add a pattern rule for generating asynth wav files --- tests/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Makefile b/tests/Makefile index 52a9fa34aa..07c7b9dd6e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -19,7 +19,10 @@ tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF) | tests/data tests/data/asynth-16000-1.sw: tests/audiogen$(HOSTEXESUF) | tests/data $(M)./$< $@ 16000 1 -tests/data/asynth%.sw tests/vsynth%/00.pgm: TAG = GEN +tests/data/asynth-%.wav: tests/audiogen$(HOSTEXESUF) | tests/data + $(M)./$< $@ $(subst -, ,$*) + +tests/data/asynth% tests/vsynth%/00.pgm: TAG = GEN include $(SRC_PATH)/tests/fate/aac.mak include $(SRC_PATH)/tests/fate/ac3.mak From a6c8cca2a82c8cd9ffdaaa2af8b922b15ab035a7 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 16 Apr 2012 21:49:11 -0400 Subject: [PATCH 4/8] FATE: replace current g722 encoding tests with an encode/decode test Avoids resampling and channel mixing. This only tests the behavior with respect to input and output audio rather than also testing changes to the encoder or muxer that do not affect the resulting decoded output. --- tests/Makefile | 3 --- tests/codec-regression.sh | 5 ----- tests/fate/voice.mak | 12 ++++++++---- tests/ref/acodec/g722 | 4 ---- tests/ref/fate/g722-encode | 1 + tests/ref/fate/g722enc | 1 - 6 files changed, 9 insertions(+), 17 deletions(-) delete mode 100644 tests/ref/acodec/g722 create mode 100644 tests/ref/fate/g722-encode delete mode 100644 tests/ref/fate/g722enc diff --git a/tests/Makefile b/tests/Makefile index 07c7b9dd6e..19fbe11fd2 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -16,9 +16,6 @@ tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF) | tests/vsynth2 tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF) | tests/data $(M)./$< $@ -tests/data/asynth-16000-1.sw: tests/audiogen$(HOSTEXESUF) | tests/data - $(M)./$< $@ 16000 1 - tests/data/asynth-%.wav: tests/audiogen$(HOSTEXESUF) | tests/data $(M)./$< $@ $(subst -, ,$*) diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh index f3932d4c29..50e45032ff 100755 --- a/tests/codec-regression.sh +++ b/tests/codec-regression.sh @@ -311,11 +311,6 @@ do_audio_encoding ac3.ac3 "-vn -acodec ac3_fixed" #$tiny_psnr $pcm_dst $pcm_ref 2 1024 fi -if [ -n "$do_g722" ] ; then -do_audio_encoding g722.wav "-b 64k -ac 1 -ar 16000 -acodec g722" -do_audio_decoding -fi - if [ -n "$do_g726" ] ; then do_audio_encoding g726.wav "-b 32k -ac 1 -ar 8000 -acodec g726" do_audio_decoding diff --git a/tests/fate/voice.mak b/tests/fate/voice.mak index 834b0ffc1f..8e5f86b083 100644 --- a/tests/fate/voice.mak +++ b/tests/fate/voice.mak @@ -1,9 +1,13 @@ -FATE_TESTS += fate-g722dec-1 +FATE_G722 += fate-g722dec-1 fate-g722dec-1: CMD = framecrc -i $(SAMPLES)/g722/conf-adminmenu-162.g722 -FATE_TESTS += fate-g722enc -fate-g722enc: tests/data/asynth-16000-1.sw -fate-g722enc: CMD = md5 -ar 16000 -ac 1 -f s16le -i $(TARGET_PATH)/tests/data/asynth-16000-1.sw -acodec g722 -ac 1 -f g722 +FATE_G722 += fate-g722-encode +fate-g722-encode: tests/data/asynth-16000-1.wav +fate-g722-encode: SRC = tests/data/asynth-16000-1.wav +fate-g722-encode: CMD = enc_dec_pcm wav md5 s16le $(SRC) -c:a g722 + +FATE_TESTS += $(FATE_G722) +fate-g722: $(FATE_G722) FATE_GSM += fate-gsm-ms fate-gsm-ms: CMD = framecrc -i $(SAMPLES)/gsm/ciao.wav diff --git a/tests/ref/acodec/g722 b/tests/ref/acodec/g722 deleted file mode 100644 index e3a5af3d7a..0000000000 --- a/tests/ref/acodec/g722 +++ /dev/null @@ -1,4 +0,0 @@ -f30e8e99cfd3f38ba66f1d4131602a19 *./tests/data/acodec/g722.wav -48053 ./tests/data/acodec/g722.wav -b5568e0e3930ff563824156e8e1015f0 *./tests/data/g722.acodec.out.wav -stddev: 8939.44 PSNR: 17.30 MAXDIFF:40370 bytes: 191980/ 1058400 diff --git a/tests/ref/fate/g722-encode b/tests/ref/fate/g722-encode new file mode 100644 index 0000000000..c7198cf83c --- /dev/null +++ b/tests/ref/fate/g722-encode @@ -0,0 +1 @@ +MD5=7106189574186051c0497b287e2e5f19 diff --git a/tests/ref/fate/g722enc b/tests/ref/fate/g722enc deleted file mode 100644 index 9b8e469a8b..0000000000 --- a/tests/ref/fate/g722enc +++ /dev/null @@ -1 +0,0 @@ -94e2f200d6e05b47cec4aa3e94571cf3 From 03caef1bedf3b31d933cc32c3f3b44c598fdeb21 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 16 Apr 2012 22:42:53 -0400 Subject: [PATCH 5/8] FATE: replace the acodec-g726 test with 4 new encode/decode tests Avoids resampling and channel mixing. This only tests the behavior with respect to input and output audio rather than also testing changes to the encoder or muxer that do not affect the resulting decoded output. --- tests/codec-regression.sh | 5 ---- tests/fate/voice.mak | 23 ++++++++++++++ tests/ref/acodec/g726 | 4 --- tests/ref/fate/g726-encode-2bit | 1 + tests/ref/fate/g726-encode-3bit | 1 + tests/ref/fate/g726-encode-4bit | 1 + tests/ref/fate/g726-encode-5bit | 1 + tests/ref/seek/g726_wav | 53 --------------------------------- 8 files changed, 27 insertions(+), 62 deletions(-) delete mode 100644 tests/ref/acodec/g726 create mode 100644 tests/ref/fate/g726-encode-2bit create mode 100644 tests/ref/fate/g726-encode-3bit create mode 100644 tests/ref/fate/g726-encode-4bit create mode 100644 tests/ref/fate/g726-encode-5bit delete mode 100644 tests/ref/seek/g726_wav diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh index 50e45032ff..e2bc8dbbe6 100755 --- a/tests/codec-regression.sh +++ b/tests/codec-regression.sh @@ -311,11 +311,6 @@ do_audio_encoding ac3.ac3 "-vn -acodec ac3_fixed" #$tiny_psnr $pcm_dst $pcm_ref 2 1024 fi -if [ -n "$do_g726" ] ; then -do_audio_encoding g726.wav "-b 32k -ac 1 -ar 8000 -acodec g726" -do_audio_decoding -fi - if [ -n "$do_adpcm_adx" ] ; then do_audio_encoding adpcm_adx.adx "-acodec adpcm_adx" do_audio_decoding diff --git a/tests/fate/voice.mak b/tests/fate/voice.mak index 8e5f86b083..73534afa91 100644 --- a/tests/fate/voice.mak +++ b/tests/fate/voice.mak @@ -9,6 +9,29 @@ fate-g722-encode: CMD = enc_dec_pcm wav md5 s16le $(SRC) -c:a g722 FATE_TESTS += $(FATE_G722) fate-g722: $(FATE_G722) +FATE_G726 += fate-g726-encode-2bit +fate-g726-encode-2bit: tests/data/asynth-8000-1.wav +fate-g726-encode-2bit: SRC = tests/data/asynth-8000-1.wav +fate-g726-encode-2bit: CMD = enc_dec_pcm wav md5 s16le $(SRC) -c:a g726 -b:a 16k + +FATE_G726 += fate-g726-encode-3bit +fate-g726-encode-3bit: tests/data/asynth-8000-1.wav +fate-g726-encode-3bit: SRC = tests/data/asynth-8000-1.wav +fate-g726-encode-3bit: CMD = enc_dec_pcm wav md5 s16le $(SRC) -c:a g726 -b:a 24k + +FATE_G726 += fate-g726-encode-4bit +fate-g726-encode-4bit: tests/data/asynth-8000-1.wav +fate-g726-encode-4bit: SRC = tests/data/asynth-8000-1.wav +fate-g726-encode-4bit: CMD = enc_dec_pcm wav md5 s16le $(SRC) -c:a g726 -b:a 32k + +FATE_G726 += fate-g726-encode-5bit +fate-g726-encode-5bit: tests/data/asynth-8000-1.wav +fate-g726-encode-5bit: SRC = tests/data/asynth-8000-1.wav +fate-g726-encode-5bit: CMD = enc_dec_pcm wav md5 s16le $(SRC) -c:a g726 -b:a 40k + +FATE_TESTS += $(FATE_G726) +fate-g726: $(FATE_G726) + FATE_GSM += fate-gsm-ms fate-gsm-ms: CMD = framecrc -i $(SAMPLES)/gsm/ciao.wav diff --git a/tests/ref/acodec/g726 b/tests/ref/acodec/g726 deleted file mode 100644 index 9abed4b3bc..0000000000 --- a/tests/ref/acodec/g726 +++ /dev/null @@ -1,4 +0,0 @@ -64bfac75bd371304b704be5b3dbcd04a *./tests/data/acodec/g726.wav -24054 ./tests/data/acodec/g726.wav -79523adfec05760931fda877e1eaf7b4 *./tests/data/g726.acodec.out.wav -stddev: 8554.55 PSNR: 17.69 MAXDIFF:29353 bytes: 95984/ 1058400 diff --git a/tests/ref/fate/g726-encode-2bit b/tests/ref/fate/g726-encode-2bit new file mode 100644 index 0000000000..26a12190fc --- /dev/null +++ b/tests/ref/fate/g726-encode-2bit @@ -0,0 +1 @@ +MD5=215eaef5778a16e2bf4f3725a557f355 diff --git a/tests/ref/fate/g726-encode-3bit b/tests/ref/fate/g726-encode-3bit new file mode 100644 index 0000000000..f9c6940217 --- /dev/null +++ b/tests/ref/fate/g726-encode-3bit @@ -0,0 +1 @@ +MD5=0bebd949dfd5ac0ae3f2c3ceb2e3fac1 diff --git a/tests/ref/fate/g726-encode-4bit b/tests/ref/fate/g726-encode-4bit new file mode 100644 index 0000000000..6d03517164 --- /dev/null +++ b/tests/ref/fate/g726-encode-4bit @@ -0,0 +1 @@ +MD5=a21cfea116ab2179eabe5d84b6bfc09a diff --git a/tests/ref/fate/g726-encode-5bit b/tests/ref/fate/g726-encode-5bit new file mode 100644 index 0000000000..459ebb39f2 --- /dev/null +++ b/tests/ref/fate/g726-encode-5bit @@ -0,0 +1 @@ +MD5=9cad98cf5205bf76d6e9d1241e56141a diff --git a/tests/ref/seek/g726_wav b/tests/ref/seek/g726_wav deleted file mode 100644 index 0e145a2722..0000000000 --- a/tests/ref/seek/g726_wav +++ /dev/null @@ -1,53 +0,0 @@ -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096 -ret: 0 st:-1 flags:0 ts:-1.000000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096 -ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:1 dts: 1.894000 pts: 1.894000 pos: 7634 size: 4096 -ret: 0 st: 0 flags:0 ts: 0.788375 -ret: 0 st: 0 flags:1 dts: 0.788500 pts: 0.788500 pos: 3212 size: 4096 -ret: 0 st: 0 flags:1 ts:-0.317500 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096 -ret: 0 st:-1 flags:0 ts: 2.576668 -ret: 0 st: 0 flags:1 dts: 2.576750 pts: 2.576750 pos: 10365 size: 4096 -ret: 0 st:-1 flags:1 ts: 1.470835 -ret: 0 st: 0 flags:1 dts: 1.470750 pts: 1.470750 pos: 5941 size: 4096 -ret: 0 st: 0 flags:0 ts: 0.365000 -ret: 0 st: 0 flags:1 dts: 0.365000 pts: 0.365000 pos: 1518 size: 4096 -ret: 0 st: 0 flags:1 ts:-0.740875 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096 -ret: 0 st:-1 flags:0 ts: 2.153336 -ret: 0 st: 0 flags:1 dts: 2.153500 pts: 2.153500 pos: 8672 size: 4096 -ret: 0 st:-1 flags:1 ts: 1.047503 -ret: 0 st: 0 flags:1 dts: 1.047500 pts: 1.047500 pos: 4248 size: 4096 -ret: 0 st: 0 flags:0 ts:-0.058375 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096 -ret: 0 st: 0 flags:1 ts: 2.835875 -ret: 0 st: 0 flags:1 dts: 2.835750 pts: 2.835750 pos: 11401 size: 4096 -ret: 0 st:-1 flags:0 ts: 1.730004 -ret: 0 st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos: 6978 size: 4096 -ret: 0 st:-1 flags:1 ts: 0.624171 -ret: 0 st: 0 flags:1 dts: 0.624000 pts: 0.624000 pos: 2554 size: 4096 -ret: 0 st: 0 flags:0 ts:-0.481625 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096 -ret: 0 st: 0 flags:1 ts: 2.412500 -ret: 0 st: 0 flags:1 dts: 2.412500 pts: 2.412500 pos: 9708 size: 4096 -ret: 0 st:-1 flags:0 ts: 1.306672 -ret: 0 st: 0 flags:1 dts: 1.306750 pts: 1.306750 pos: 5285 size: 4096 -ret: 0 st:-1 flags:1 ts: 0.200839 -ret: 0 st: 0 flags:1 dts: 0.200750 pts: 0.200750 pos: 861 size: 4096 -ret: 0 st: 0 flags:0 ts:-0.905000 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096 -ret: 0 st: 0 flags:1 ts: 1.989125 -ret: 0 st: 0 flags:1 dts: 1.989000 pts: 1.989000 pos: 8014 size: 4096 -ret: 0 st:-1 flags:0 ts: 0.883340 -ret: 0 st: 0 flags:1 dts: 0.883500 pts: 0.883500 pos: 3592 size: 4096 -ret: 0 st:-1 flags:1 ts:-0.222493 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096 -ret: 0 st: 0 flags:0 ts: 2.671625 -ret: 0 st: 0 flags:1 dts: 2.671750 pts: 2.671750 pos: 10745 size: 4096 -ret: 0 st: 0 flags:1 ts: 1.565875 -ret: 0 st: 0 flags:1 dts: 1.565750 pts: 1.565750 pos: 6321 size: 4096 -ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 1898 size: 4096 -ret: 0 st:-1 flags:1 ts:-0.645825 -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096 From 5052980400e244000ade57043a1f13016847f6b1 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 16 Apr 2012 21:21:30 -0400 Subject: [PATCH 6/8] FATE: replace the acodec-pcm_s24daud test with an enc_dec_pcm checksum test This avoids resampling and channel mixing by using a source with the correct channel layout and sample rate. --- tests/codec-regression.sh | 3 --- tests/fate/pcm.mak | 5 +++++ tests/ref/acodec/pcm_s24daud | 4 ---- tests/ref/fate/dcinema-encode | 1 + tests/ref/seek/pcm_s24daud_302 | 27 --------------------------- 5 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 tests/ref/acodec/pcm_s24daud create mode 100644 tests/ref/fate/dcinema-encode delete mode 100644 tests/ref/seek/pcm_s24daud_302 diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh index e2bc8dbbe6..80dd269126 100755 --- a/tests/codec-regression.sh +++ b/tests/codec-regression.sh @@ -419,6 +419,3 @@ fi if [ -n "$do_pcm_f64le" ] ; then do_audio_enc_dec wav dbl pcm_f64le fi -if [ -n "$do_pcm_s24daud" ] ; then -do_audio_enc_dec 302 s16 pcm_s24daud "-ac 6 -ar 96000" -fi diff --git a/tests/fate/pcm.mak b/tests/fate/pcm.mak index 3ce04f9cea..4b271346f6 100644 --- a/tests/fate/pcm.mak +++ b/tests/fate/pcm.mak @@ -25,5 +25,10 @@ fate-pcm_u8-stereo: CMD = md5 -i $(SAMPLES)/qt-surge-suite/surge-2-8-raw.mov -f FATE_PCM += fate-w64 fate-w64: CMD = crc -i $(SAMPLES)/w64/w64-pcm16.w64 +FATE_PCM += fate-dcinema-encode +fate-dcinema-encode: tests/data/asynth-96000-6.wav +fate-dcinema-encode: SRC = tests/data/asynth-96000-6.wav +fate-dcinema-encode: CMD = enc_dec_pcm daud md5 s16le $(SRC) -c:a pcm_s24daud + FATE_TESTS += $(FATE_PCM) fate-pcm: $(FATE_PCM) diff --git a/tests/ref/acodec/pcm_s24daud b/tests/ref/acodec/pcm_s24daud deleted file mode 100644 index fb7cad1d89..0000000000 --- a/tests/ref/acodec/pcm_s24daud +++ /dev/null @@ -1,4 +0,0 @@ -8168a5c1343553ef027541830f2cb879 *./tests/data/acodec/pcm_s24daud.302 -10368730 ./tests/data/acodec/pcm_s24daud.302 -7ce988d6c5b2bf0ebf0216ba15bc5cee *./tests/data/pcm_s24daud.acodec.out.wav -stddev: 9416.28 PSNR: 16.85 MAXDIFF:42744 bytes: 6911796/ 1058400 diff --git a/tests/ref/fate/dcinema-encode b/tests/ref/fate/dcinema-encode new file mode 100644 index 0000000000..8aeb21526c --- /dev/null +++ b/tests/ref/fate/dcinema-encode @@ -0,0 +1 @@ +MD5=2d7c6897c315493647db159f4bfd6edc diff --git a/tests/ref/seek/pcm_s24daud_302 b/tests/ref/seek/pcm_s24daud_302 deleted file mode 100644 index 5c9b6d976b..0000000000 --- a/tests/ref/seek/pcm_s24daud_302 +++ /dev/null @@ -1,27 +0,0 @@ -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 4 size: 39816 -ret:-1 st:-1 flags:0 ts:-1.000000 -ret:-1 st:-1 flags:1 ts: 1.894167 -ret:-1 st: 0 flags:0 ts: 0.788333 -ret:-1 st: 0 flags:1 ts:-0.317500 -ret:-1 st:-1 flags:0 ts: 2.576668 -ret:-1 st:-1 flags:1 ts: 1.470835 -ret:-1 st: 0 flags:0 ts: 0.365000 -ret:-1 st: 0 flags:1 ts:-0.740833 -ret:-1 st:-1 flags:0 ts: 2.153336 -ret:-1 st:-1 flags:1 ts: 1.047503 -ret:-1 st: 0 flags:0 ts:-0.058333 -ret:-1 st: 0 flags:1 ts: 2.835833 -ret:-1 st:-1 flags:0 ts: 1.730004 -ret:-1 st:-1 flags:1 ts: 0.624171 -ret:-1 st: 0 flags:0 ts:-0.481667 -ret:-1 st: 0 flags:1 ts: 2.412500 -ret:-1 st:-1 flags:0 ts: 1.306672 -ret:-1 st:-1 flags:1 ts: 0.200839 -ret:-1 st: 0 flags:0 ts:-0.904989 -ret:-1 st: 0 flags:1 ts: 1.989178 -ret:-1 st:-1 flags:0 ts: 0.883340 -ret:-1 st:-1 flags:1 ts:-0.222493 -ret:-1 st: 0 flags:0 ts: 2.671678 -ret:-1 st: 0 flags:1 ts: 1.565844 -ret:-1 st:-1 flags:0 ts: 0.460008 -ret:-1 st:-1 flags:1 ts:-0.645825 From acb1730218f1c614dc8ca3ba45d9de1e05059515 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 16 Apr 2012 23:38:34 -0400 Subject: [PATCH 7/8] FATE: allow lavf tests to alter input parameters Change some lavf tests to avoid resampling and channel mixing. --- tests/lavf-regression.sh | 28 ++++++++++++++-------------- tests/ref/lavf/dv_fmt | 6 +++--- tests/ref/lavf/gxf | 4 ++-- tests/ref/lavf/mxf | 4 ++-- tests/ref/lavf/mxf_d10 | 4 ++-- tests/ref/seek/lavf_dv | 26 +++++++++++++------------- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh index c779bbd887..54da522b96 100755 --- a/tests/lavf-regression.sh +++ b/tests/lavf-regression.sh @@ -14,8 +14,8 @@ eval do_$test=y do_lavf() { file=${outfile}lavf.$1 - do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -b:a 64k -t 1 -qscale:v 10 $2 - do_avconv_crc $file $DEC_OPTS -i $target_path/$file $3 + do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le $2 -i $pcm_src $ENC_OPTS -b:a 64k -t 1 -qscale:v 10 $3 + do_avconv_crc $file $DEC_OPTS -i $target_path/$file $4 } do_streamed_images() @@ -44,11 +44,11 @@ do_audio_only() } if [ -n "$do_avi" ] ; then -do_lavf avi "-acodec mp2" +do_lavf avi "" "-acodec mp2" fi if [ -n "$do_asf" ] ; then -do_lavf asf "-acodec mp2" "-r 25" +do_lavf asf "" "-acodec mp2" "-r 25" fi if [ -n "$do_rm" ] ; then @@ -63,19 +63,19 @@ do_lavf mpg fi if [ -n "$do_mxf" ] ; then -do_lavf mxf "-ar 48000 -bf 2 -timecode_frame_start 264363" +do_lavf mxf "-ar 48000" "-bf 2 -timecode_frame_start 264363" fi if [ -n "$do_mxf_d10" ]; then -do_lavf mxf_d10 "-ar 48000 -ac 2 -r 25 -s 720x576 -vf pad=720:608:0:32 -vcodec mpeg2video -g 0 -flags +ildct+low_delay -dc 10 -non_linear_quant 1 -intra_vlc 1 -qscale 1 -ps 1 -qmin 1 -rc_max_vbv_use 1 -rc_min_vbv_use 1 -pix_fmt yuv422p -minrate 30000k -maxrate 30000k -b 30000k -bufsize 1200000 -top 1 -rc_init_occupancy 1200000 -qmax 12 -f mxf_d10" +do_lavf mxf_d10 "-ar 48000 -ac 2" "-r 25 -s 720x576 -vf pad=720:608:0:32 -vcodec mpeg2video -g 0 -flags +ildct+low_delay -dc 10 -non_linear_quant 1 -intra_vlc 1 -qscale 1 -ps 1 -qmin 1 -rc_max_vbv_use 1 -rc_min_vbv_use 1 -pix_fmt yuv422p -minrate 30000k -maxrate 30000k -b 30000k -bufsize 1200000 -top 1 -rc_init_occupancy 1200000 -qmax 12 -f mxf_d10" fi if [ -n "$do_ts" ] ; then -do_lavf ts "-mpegts_transport_stream_id 42" +do_lavf ts "" "-mpegts_transport_stream_id 42" fi if [ -n "$do_swf" ] ; then -do_lavf swf -an +do_lavf swf "" "-an" fi if [ -n "$do_ffm" ] ; then @@ -83,27 +83,27 @@ do_lavf ffm fi if [ -n "$do_flv_fmt" ] ; then -do_lavf flv -an +do_lavf flv "" "-an" fi if [ -n "$do_mov" ] ; then -do_lavf mov "-acodec pcm_alaw -c:v mpeg4" +do_lavf mov "" "-acodec pcm_alaw -c:v mpeg4" fi if [ -n "$do_dv_fmt" ] ; then -do_lavf dv "-ar 48000 -r 25 -s pal -ac 2" +do_lavf dv "-ar 48000" "-r 25 -s pal -ac 2" fi if [ -n "$do_gxf" ] ; then -do_lavf gxf "-ar 48000 -r 25 -s pal -ac 1" +do_lavf gxf "-ar 48000" "-r 25 -s pal -ac 1" fi if [ -n "$do_nut" ] ; then -do_lavf nut "-acodec mp2" +do_lavf nut "" "-acodec mp2" fi if [ -n "$do_mkv" ] ; then -do_lavf mkv "-c:a mp2 -c:v mpeg4" +do_lavf mkv "" "-c:a mp2 -c:v mpeg4" fi diff --git a/tests/ref/lavf/dv_fmt b/tests/ref/lavf/dv_fmt index 7406dff532..7615fb50ec 100644 --- a/tests/ref/lavf/dv_fmt +++ b/tests/ref/lavf/dv_fmt @@ -1,3 +1,3 @@ -522e5e5a46b99f8ad8aabdaf3d2f1869 *./tests/data/lavf/lavf.dv -3600000 ./tests/data/lavf/lavf.dv -./tests/data/lavf/lavf.dv CRC=0x02c0af30 +62577aa72e7c7fb3e781e3717a7c36cb *./tests/data/lavf/lavf.dv +3456000 ./tests/data/lavf/lavf.dv +./tests/data/lavf/lavf.dv CRC=0x37e63092 diff --git a/tests/ref/lavf/gxf b/tests/ref/lavf/gxf index efdcfd5e9e..0d28ac5518 100644 --- a/tests/ref/lavf/gxf +++ b/tests/ref/lavf/gxf @@ -1,3 +1,3 @@ -346d38d330ab5cb0caa6b5537167bc0d *./tests/data/lavf/lavf.gxf +32e34e23f3740e27e5bcf1621a698aad *./tests/data/lavf/lavf.gxf 796392 ./tests/data/lavf/lavf.gxf -./tests/data/lavf/lavf.gxf CRC=0x246186eb +./tests/data/lavf/lavf.gxf CRC=0x4f52fc7f diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf index b5aea3c17e..c69e278133 100644 --- a/tests/ref/lavf/mxf +++ b/tests/ref/lavf/mxf @@ -1,3 +1,3 @@ -6e9bd63c5cadd7550ad313553ebf665f *./tests/data/lavf/lavf.mxf +21d359aecf0453a5910d2c1a9ec906b2 *./tests/data/lavf/lavf.mxf 525881 ./tests/data/lavf/lavf.mxf -./tests/data/lavf/lavf.mxf CRC=0x4ace0849 +./tests/data/lavf/lavf.mxf CRC=0x773f059a diff --git a/tests/ref/lavf/mxf_d10 b/tests/ref/lavf/mxf_d10 index f59a99ee0f..98569c469b 100644 --- a/tests/ref/lavf/mxf_d10 +++ b/tests/ref/lavf/mxf_d10 @@ -1,3 +1,3 @@ -e7168856f2b54c6272685967e707fb21 *./tests/data/lavf/lavf.mxf_d10 +b66087558cd1ff8e64290ffd856c88bc *./tests/data/lavf/lavf.mxf_d10 5330989 ./tests/data/lavf/lavf.mxf_d10 -./tests/data/lavf/lavf.mxf_d10 CRC=0xc3f4f92e +./tests/data/lavf/lavf.mxf_d10 CRC=0x4474d480 diff --git a/tests/ref/seek/lavf_dv b/tests/ref/seek/lavf_dv index 3c49749a6b..8ac9404194 100644 --- a/tests/ref/seek/lavf_dv +++ b/tests/ref/seek/lavf_dv @@ -2,51 +2,51 @@ ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:144000 ret: 0 st:-1 flags:0 ts:-1.000000 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:144000 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st: 0 flags:0 ts: 0.800000 ret: 0 st: 0 flags:1 dts: 0.800000 pts: 0.800000 pos: -1 size:144000 ret: 0 st: 0 flags:1 ts:-0.320000 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:144000 ret: 0 st: 1 flags:0 ts: 2.576667 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st: 1 flags:1 ts: 1.470833 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st:-1 flags:0 ts: 0.365002 ret: 0 st: 0 flags:1 dts: 0.360000 pts: 0.360000 pos: -1 size:144000 ret: 0 st:-1 flags:1 ts:-0.740831 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:144000 ret: 0 st: 0 flags:0 ts: 2.160000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st: 0 flags:1 ts: 1.040000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st: 1 flags:0 ts:-0.058333 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:144000 ret: 0 st: 1 flags:1 ts: 2.835833 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st:-1 flags:0 ts: 1.730004 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st:-1 flags:1 ts: 0.624171 ret: 0 st: 0 flags:1 dts: 0.640000 pts: 0.640000 pos: -1 size:144000 ret: 0 st: 0 flags:0 ts:-0.480000 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:144000 ret: 0 st: 0 flags:1 ts: 2.400000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st: 1 flags:0 ts: 1.306667 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st: 1 flags:1 ts: 0.200833 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st:-1 flags:0 ts:-0.904994 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:144000 ret: 0 st:-1 flags:1 ts: 1.989173 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st: 0 flags:0 ts: 0.880000 ret: 0 st: 0 flags:1 dts: 0.880000 pts: 0.880000 pos: -1 size:144000 ret: 0 st: 0 flags:1 ts:-0.240000 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:144000 ret: 0 st: 1 flags:0 ts: 2.671667 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st: 1 flags:1 ts: 1.565833 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: -1 size:144000 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos: -1 size:144000 ret: 0 st:-1 flags:0 ts: 0.460008 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: -1 size:144000 ret: 0 st:-1 flags:1 ts:-0.645825 From b0e9edc44f1722787adacbff9aa60343206a58c0 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 10 Apr 2012 16:33:45 -0400 Subject: [PATCH 8/8] avcodec: add a cook parser to get subpacket duration Fixes jittery video playback of rm files with cook audio. --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/cook_parser.c | 59 ++++++++++++++++++++++++++++++++++++++++ libavcodec/version.h | 4 +-- libavformat/rmdec.c | 1 + 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 libavcodec/cook_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 4dc218aa47..b3309e57cb 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -620,6 +620,7 @@ OBJS-$(CONFIG_AC3_PARSER) += ac3_parser.o ac3tab.o \ aac_ac3_parser.o OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o adx.o OBJS-$(CONFIG_CAVSVIDEO_PARSER) += cavs_parser.o +OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o OBJS-$(CONFIG_DCA_PARSER) += dca_parser.o OBJS-$(CONFIG_DIRAC_PARSER) += dirac_parser.o OBJS-$(CONFIG_DNXHD_PARSER) += dnxhd_parser.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 60b3e08d17..0b519bbf82 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -400,6 +400,7 @@ void avcodec_register_all(void) REGISTER_PARSER (AC3, ac3); REGISTER_PARSER (ADX, adx); REGISTER_PARSER (CAVSVIDEO, cavsvideo); + REGISTER_PARSER (COOK, cook); REGISTER_PARSER (DCA, dca); REGISTER_PARSER (DIRAC, dirac); REGISTER_PARSER (DNXHD, dnxhd); diff --git a/libavcodec/cook_parser.c b/libavcodec/cook_parser.c new file mode 100644 index 0000000000..c16f7c8a5f --- /dev/null +++ b/libavcodec/cook_parser.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2012 Justin Ruggles + * + * 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 + * Cook audio parser + * + * Determines subpacket duration from extradata. + */ + +#include + +#include "libavutil/intreadwrite.h" +#include "parser.h" + +typedef struct CookParseContext { + int duration; +} CookParseContext; + +static int cook_parse(AVCodecParserContext *s1, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ + CookParseContext *s = s1->priv_data; + + if (s->duration) + s1->duration = s->duration; + else if (avctx->extradata && avctx->extradata_size >= 8 && avctx->channels) + s->duration = AV_RB16(avctx->extradata + 4) / avctx->channels; + + /* always return the full packet. this parser isn't doing any splitting or + combining, only setting packet duration */ + *poutbuf = buf; + *poutbuf_size = buf_size; + return buf_size; +} + +AVCodecParser ff_cook_parser = { + .codec_ids = { CODEC_ID_COOK }, + .priv_data_size = sizeof(CookParseContext), + .parser_parse = cook_parse, +}; diff --git a/libavcodec/version.h b/libavcodec/version.h index c35fce40e3..58a228c4a2 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -27,8 +27,8 @@ */ #define LIBAVCODEC_VERSION_MAJOR 54 -#define LIBAVCODEC_VERSION_MINOR 11 -#define LIBAVCODEC_VERSION_MICRO 1 +#define LIBAVCODEC_VERSION_MINOR 12 +#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index c85208b3fb..0113251bc6 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -205,6 +205,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, st->codec->block_align = coded_framesize; break; case CODEC_ID_COOK: + st->need_parsing = AVSTREAM_PARSE_HEADERS; case CODEC_ID_ATRAC3: case CODEC_ID_SIPR: avio_rb16(pb); avio_r8(pb);