From ce2649af3d012d36d2f70d77867f18270f0e296d Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 29 Jun 2011 14:33:33 -0700 Subject: [PATCH 01/17] aacenc: Make chan_map const correct --- libavcodec/aacenc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h index 3f590fefea..acd185a809 100644 --- a/libavcodec/aacenc.h +++ b/libavcodec/aacenc.h @@ -61,7 +61,7 @@ typedef struct AACEncContext { int16_t *samples; ///< saved preprocessed input int samplerate_index; ///< MPEG-4 samplerate index - uint8_t *chan_map; ///< channel configuration map + const uint8_t *chan_map; ///< channel configuration map ChannelElement *cpe; ///< channel elements FFPsyContext psy; From e0b8fff6c7a293e35079ba1931bd19372686b3f6 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 29 Jun 2011 21:04:45 -0700 Subject: [PATCH 02/17] swscale: fix yuv range correction when using 16-bit scaling. --- libswscale/swscale.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 987afff2d2..644f84858c 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1982,8 +1982,8 @@ static void chrRangeToJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) int32_t *dstU = (int32_t *) _dstU; int32_t *dstV = (int32_t *) _dstV; for (i = 0; i < width; i++) { - dstU[i] = (FFMIN(dstU[i],30775)*4663 - 9289992)>>12; //-264 - dstV[i] = (FFMIN(dstV[i],30775)*4663 - 9289992)>>12; //-264 + dstU[i] = (FFMIN(dstU[i],30775<<4)*4663 - (9289992<<4))>>12; //-264 + dstV[i] = (FFMIN(dstV[i],30775<<4)*4663 - (9289992<<4))>>12; //-264 } } static void chrRangeFromJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) @@ -1992,8 +1992,8 @@ static void chrRangeFromJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) int32_t *dstU = (int32_t *) _dstU; int32_t *dstV = (int32_t *) _dstV; for (i = 0; i < width; i++) { - dstU[i] = (dstU[i]*1799 + 4081085)>>11; //1469 - dstV[i] = (dstV[i]*1799 + 4081085)>>11; //1469 + dstU[i] = (dstU[i]*1799 + (4081085<<4))>>11; //1469 + dstV[i] = (dstV[i]*1799 + (4081085<<4))>>11; //1469 } } static void lumRangeToJpeg16_c(int16_t *_dst, int width) @@ -2001,14 +2001,14 @@ static void lumRangeToJpeg16_c(int16_t *_dst, int width) int i; int32_t *dst = (int32_t *) _dst; for (i = 0; i < width; i++) - dst[i] = (FFMIN(dst[i],30189)*19077 - 39057361)>>14; + dst[i] = (FFMIN(dst[i],30189<<4)*19077 - (39057361<<4))>>14; } static void lumRangeFromJpeg16_c(int16_t *_dst, int width) { int i; int32_t *dst = (int32_t *) _dst; for (i = 0; i < width; i++) - dst[i] = (dst[i]*14071 + 33561947)>>14; + dst[i] = (dst[i]*14071 + (33561947<<4))>>14; } static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, From f6252b48455dc8aa5413a480bc208ea4ac0c9136 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 29 Jun 2011 19:33:10 +0100 Subject: [PATCH 03/17] adler32: make test program more useful and add fate test Signed-off-by: Mans Rullgard --- libavutil/adler32.c | 22 +++++++++++++++------- tests/fate2.mak | 5 +++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/libavutil/adler32.c b/libavutil/adler32.c index 4f2001025b..ee1f70e479 100644 --- a/libavutil/adler32.c +++ b/libavutil/adler32.c @@ -52,22 +52,30 @@ unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, unsigne } #ifdef TEST +#include #include "log.h" #include "timer.h" #define LEN 7001 volatile int checksum; -int main(void){ +int main(int argc, char **argv) +{ int i; char data[LEN]; av_log_set_level(AV_LOG_DEBUG); for(i=0; i>3) + 123*i; - for(i=0; i<1000; i++){ - START_TIMER - checksum= av_adler32_update(1, data, LEN); - STOP_TIMER("adler") + + if (argc > 1 && !strcmp(argv[1], "-t")) { + for (i = 0; i < 1000; i++) { + START_TIMER; + checksum = av_adler32_update(1, data, LEN); + STOP_TIMER("adler"); + } + } else { + checksum = av_adler32_update(1, data, LEN); } - av_log(NULL, AV_LOG_DEBUG, "%X == 50E6E508\n", checksum); - return 0; + + av_log(NULL, AV_LOG_DEBUG, "%X (expected 50E6E508)\n", checksum); + return checksum == 0x50e6e508? 0 : 1; } #endif diff --git a/tests/fate2.mak b/tests/fate2.mak index f8bae65536..d247dededb 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -217,6 +217,11 @@ FATE_TESTS += fate-sha fate-sha: libavutil/sha-test$(EXESUF) fate-sha: CMD = run libavutil/sha-test +FATE_TESTS += fate-adler32 +fate-adler32: libavutil/adler32-test$(EXESUF) +fate-adler32: CMD = run libavutil/adler32-test +fate-adler32: REF = /dev/null + FATE_TESTS += fate-musepack7 fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc fate-musepack7: CMP = oneoff From 744765a9c58107951136a3552f441662f231e91d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 29 Jun 2011 23:27:07 +0100 Subject: [PATCH 04/17] aes: improve test program and add fate test Signed-off-by: Mans Rullgard --- libavutil/aes.c | 54 ++++++++++++++++++++++++++++++------------------- tests/fate2.mak | 5 +++++ 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/libavutil/aes.c b/libavutil/aes.c index 346676bae3..72ddf99a16 100644 --- a/libavutil/aes.c +++ b/libavutil/aes.c @@ -203,12 +203,14 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) { } #ifdef TEST +#include #include "lfg.h" #include "log.h" -int main(void){ +int main(int argc, char **argv) +{ int i,j; - AVAES ae, ad, b; + AVAES b; uint8_t rkey[2][16]= { {0}, {0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3, 0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59}}; @@ -219,37 +221,47 @@ int main(void){ {0x73, 0x22, 0x81, 0xc0, 0xa0, 0xaa, 0xb8, 0xf7, 0xa5, 0x4a, 0x0c, 0x67, 0xa0, 0xc4, 0x5e, 0xcf}, {0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0, 0x4e, 0xaa, 0x6f, 0xb4, 0xdb, 0xf7, 0x84, 0x65}}; uint8_t temp[16]; - AVLFG prng; + int err = 0; - av_aes_init(&ae, "PI=3.141592654..", 128, 0); - av_aes_init(&ad, "PI=3.141592654..", 128, 1); av_log_set_level(AV_LOG_DEBUG); - av_lfg_init(&prng, 1); for(i=0; i<2; i++){ av_aes_init(&b, rkey[i], 128, 1); av_aes_crypt(&b, temp, rct[i], 1, NULL, 1); for(j=0; j<16; j++) - if(rpt[i][j] != temp[j]) + if(rpt[i][j] != temp[j]) { av_log(NULL, AV_LOG_ERROR, "%d %02X %02X\n", j, rpt[i][j], temp[j]); + err = 1; + } } - for(i=0; i<10000; i++){ - for(j=0; j<16; j++){ - pt[j] = av_lfg_get(&prng); - } -{START_TIMER - av_aes_crypt(&ae, temp, pt, 1, NULL, 0); - if(!(i&(i-1))) - av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", temp[0], temp[5], temp[10], temp[15]); - av_aes_crypt(&ad, temp, temp, 1, NULL, 1); -STOP_TIMER("aes")} - for(j=0; j<16; j++){ - if(pt[j] != temp[j]){ - av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", i,j, pt[j], temp[j]); + if (argc > 1 && !strcmp(argv[1], "-t")) { + AVAES ae, ad; + AVLFG prng; + + av_aes_init(&ae, "PI=3.141592654..", 128, 0); + av_aes_init(&ad, "PI=3.141592654..", 128, 1); + av_lfg_init(&prng, 1); + + for(i=0; i<10000; i++){ + for(j=0; j<16; j++){ + pt[j] = av_lfg_get(&prng); + } + { + START_TIMER; + av_aes_crypt(&ae, temp, pt, 1, NULL, 0); + if(!(i&(i-1))) + av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", temp[0], temp[5], temp[10], temp[15]); + av_aes_crypt(&ad, temp, temp, 1, NULL, 1); + STOP_TIMER("aes"); + } + for(j=0; j<16; j++){ + if(pt[j] != temp[j]){ + av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", i,j, pt[j], temp[j]); + } } } } - return 0; + return err; } #endif diff --git a/tests/fate2.mak b/tests/fate2.mak index d247dededb..ad0309f305 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -222,6 +222,11 @@ fate-adler32: libavutil/adler32-test$(EXESUF) fate-adler32: CMD = run libavutil/adler32-test fate-adler32: REF = /dev/null +FATE_TESTS += fate-aes +fate-aes: libavutil/aes-test$(EXESUF) +fate-aes: CMD = run libavutil/aes-test +fate-aes: REF = /dev/null + FATE_TESTS += fate-musepack7 fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc fate-musepack7: CMP = oneoff From 71f029146c963f5bab61bce000839f20bd06549a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 29 Jun 2011 23:34:09 +0100 Subject: [PATCH 05/17] base64: add fate test Signed-off-by: Mans Rullgard --- tests/fate2.mak | 4 ++++ tests/ref/fate/base64 | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 tests/ref/fate/base64 diff --git a/tests/fate2.mak b/tests/fate2.mak index ad0309f305..5603c314dd 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -227,6 +227,10 @@ fate-aes: libavutil/aes-test$(EXESUF) fate-aes: CMD = run libavutil/aes-test fate-aes: REF = /dev/null +FATE_TESTS += fate-base64 +fate-base64: libavutil/base64-test$(EXESUF) +fate-base64: CMD = run libavutil/base64-test + FATE_TESTS += fate-musepack7 fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc fate-musepack7: CMP = oneoff diff --git a/tests/ref/fate/base64 b/tests/ref/fate/base64 new file mode 100644 index 0000000000..24fa9ad909 --- /dev/null +++ b/tests/ref/fate/base64 @@ -0,0 +1,9 @@ +Encoding/decoding tests +Passed! +Passed! +Passed! +Passed! +Passed! +Passed! +Passed! +Passed! From 705b21a06ed357ed2b432b967c4fcb09fb992d02 Mon Sep 17 00:00:00 2001 From: Mohamed Naufal Date: Thu, 30 Jun 2011 11:57:32 +0300 Subject: [PATCH 06/17] swscale: Unbreak build with --enable-small MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes building with --enable-small, by using the correct variable name. Signed-off-by: Martin Storsjö --- libswscale/swscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 644f84858c..1e4994ca6b 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -977,7 +977,7 @@ yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2, const uint32_t *b = (const uint32_t *) _b; #if CONFIG_SMALL - int sh = hasAlpha ? ((fmt == PIX_FMT_RGB32_1 || fmt == PIX_FMT_BGR32_1) ? 0 : 24) : 0; + int sh = hasAlpha ? ((target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24) : 0; dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0); dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0); From 5d62d0b114807cc143079a8a0430b86d585ab606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 17 Jun 2011 10:08:23 +0300 Subject: [PATCH 07/17] udp: Fix a compilation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes this compilation warning, by making endptr a non-const pointer, as required by strtol: In function ‘udp_open’: warning: passing argument 2 of ‘strtol’ from incompatible pointer type Signed-off-by: Martin Storsjö --- libavformat/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index 724ff0197d..bd95a811de 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -328,7 +328,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) p = strchr(uri, '?'); if (p) { if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) { - const char *endptr=NULL; + char *endptr = NULL; s->reuse_socket = strtol(buf, &endptr, 10); /* assume if no digits were found it is a request to enable it */ if (buf == endptr) From bd9a9a2f1801895c8e69fcb50ce31a35d1938146 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 25 Jun 2011 18:12:36 +0200 Subject: [PATCH 08/17] build: Eliminate obsolete test targets. The targets are now part of FATE and can be run as individual FATE targets. --- Makefile | 2 -- tests/Makefile | 9 +-------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Makefile b/Makefile index da12fba8a4..2cb5f65c6f 100644 --- a/Makefile +++ b/Makefile @@ -185,8 +185,6 @@ distclean:: config: $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION) -check: test checkheaders - include $(SRC_PATH)/doc/Makefile include $(SRC_PATH)/tests/Makefile diff --git a/tests/Makefile b/tests/Makefile index 38d85fbab7..e6640b35dd 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,12 +1,5 @@ -fulltest test: codectest lavftest lavfitest seektest - FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref -codectest: fate-codec -lavftest: fate-lavf -lavfitest: fate-lavfi -seektest: fate-seek - AREF = fate-acodec-aref VREF = fate-vsynth1-vref fate-vsynth2-vref REFS = $(AREF) $(VREF) @@ -120,4 +113,4 @@ testclean: -include $(wildcard tests/*.d) -.PHONY: fate* *test +.PHONY: fate* From ce1e181b1346ee3fc32cd4159e1ebae75fa7d4bb Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 26 Jun 2011 13:50:37 +0200 Subject: [PATCH 09/17] opt-test: Add missing braces to silence compiler warnings. libavutil/opt.c:604:1: warning: missing braces around initializer [-Wmissing-braces] --- libavutil/opt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 518863a8b8..f65f31fcda 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -601,14 +601,14 @@ typedef struct TestContext #define TEST_FLAG_MU 04 static const AVOption test_options[]= { -{"num", "set num", OFFSET(num), FF_OPT_TYPE_INT, 0, 0, 100 }, -{"toggle", "set toggle", OFFSET(toggle), FF_OPT_TYPE_INT, 0, 0, 1 }, -{"rational", "set rational", OFFSET(rational), FF_OPT_TYPE_RATIONAL, 0, 0, 10 }, -{"string", "set string", OFFSET(string), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX }, -{"flags", "set flags", OFFSET(flags), FF_OPT_TYPE_FLAGS, 0, 0, INT_MAX, 0, "flags" }, -{"cool", "set cool flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_COOL, INT_MIN, INT_MAX, 0, "flags" }, -{"lame", "set lame flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_LAME, INT_MIN, INT_MAX, 0, "flags" }, -{"mu", "set mu flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_MU, INT_MIN, INT_MAX, 0, "flags" }, +{"num", "set num", OFFSET(num), FF_OPT_TYPE_INT, {0}, 0, 100 }, +{"toggle", "set toggle", OFFSET(toggle), FF_OPT_TYPE_INT, {0}, 0, 1 }, +{"rational", "set rational", OFFSET(rational), FF_OPT_TYPE_RATIONAL, {0}, 0, 10 }, +{"string", "set string", OFFSET(string), FF_OPT_TYPE_STRING, {0}, CHAR_MIN, CHAR_MAX }, +{"flags", "set flags", OFFSET(flags), FF_OPT_TYPE_FLAGS, {0}, 0, INT_MAX, 0, "flags" }, +{"cool", "set cool flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_COOL}, INT_MIN, INT_MAX, 0, "flags" }, +{"lame", "set lame flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_LAME}, INT_MIN, INT_MAX, 0, "flags" }, +{"mu", "set mu flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" }, {NULL}, }; From c31bc5371e1b261f487a8795e8f57eb88290cd06 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 30 Jun 2011 14:03:54 +0100 Subject: [PATCH 10/17] Fix cpu flags test program Signed-off-by: Mans Rullgard --- libavutil/cpu.c | 55 ++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/libavutil/cpu.c b/libavutil/cpu.c index ddccd000bc..baa7922daa 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -39,32 +39,45 @@ int av_get_cpu_flags(void) #undef printf #include +static const struct { + int flag; + const char *name; +} cpu_flag_tab[] = { +#if ARCH_ARM + { AV_CPU_FLAG_IWMMXT, "iwmmxt" }, +#elif ARCH_PPC + { AV_CPU_FLAG_ALTIVEC, "altivec" }, +#elif ARCH_X86 + { AV_CPU_FLAG_MMX, "mmx" }, + { AV_CPU_FLAG_MMX2, "mmx2" }, + { AV_CPU_FLAG_SSE, "sse" }, + { AV_CPU_FLAG_SSE2, "sse2" }, + { AV_CPU_FLAG_SSE2SLOW, "sse2(slow)" }, + { AV_CPU_FLAG_SSE3, "sse3" }, + { AV_CPU_FLAG_SSE3SLOW, "sse3(slow)" }, + { AV_CPU_FLAG_SSSE3, "ssse3" }, + { AV_CPU_FLAG_ATOM, "atom" }, + { AV_CPU_FLAG_SSE4, "sse4.1" }, + { AV_CPU_FLAG_SSE42, "sse4.2" }, + { AV_CPU_FLAG_AVX, "avx" }, + { AV_CPU_FLAG_3DNOW, "3dnow" }, + { AV_CPU_FLAG_3DNOWEXT, "3dnowext" }, +#endif + { 0 } +}; + int main(void) { int cpu_flags = av_get_cpu_flags(); + int i; printf("cpu_flags = 0x%08X\n", cpu_flags); - printf("cpu_flags = %s%s%s%s%s%s%s%s%s%s%s%s%s\n", -#if ARCH_ARM - cpu_flags & AV_CPU_FLAG_IWMMXT ? "IWMMXT " : "", -#elif ARCH_PPC - cpu_flags & AV_CPU_FLAG_ALTIVEC ? "ALTIVEC " : "", -#elif ARCH_X86 - cpu_flags & AV_CPU_FLAG_MMX ? "MMX " : "", - cpu_flags & AV_CPU_FLAG_MMX2 ? "MMX2 " : "", - cpu_flags & AV_CPU_FLAG_SSE ? "SSE " : "", - cpu_flags & AV_CPU_FLAG_SSE2 ? "SSE2 " : "", - cpu_flags & AV_CPU_FLAG_SSE2SLOW ? "SSE2(slow) " : "", - cpu_flags & AV_CPU_FLAG_SSE3 ? "SSE3 " : "", - cpu_flags & AV_CPU_FLAG_SSE3SLOW ? "SSE3(slow) " : "", - cpu_flags & AV_CPU_FLAG_SSSE3 ? "SSSE3 " : "", - cpu_flags & AV_CPU_FLAG_ATOM ? "Atom " : "", - cpu_flags & AV_CPU_FLAG_SSE4 ? "SSE4.1 " : "", - cpu_flags & AV_CPU_FLAG_SSE42 ? "SSE4.2 " : "", - cpu_flags & AV_CPU_FLAG_AVX ? "AVX " : "", - cpu_flags & AV_CPU_FLAG_3DNOW ? "3DNow " : "", - cpu_flags & AV_CPU_FLAG_3DNOWEXT ? "3DNowExt " : ""); -#endif + printf("cpu_flags ="); + for (i = 0; cpu_flag_tab[i].flag; i++) + if (cpu_flags & cpu_flag_tab[i].flag) + printf(" %s", cpu_flag_tab[i].name); + printf("\n"); + return 0; } From 81cc7d0bd1eab0aa782ff8dd49e087025a42cdee Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 30 Jun 2011 07:05:52 -0700 Subject: [PATCH 11/17] swscale: fix another yuv range conversion overflow in 16bit scaling. --- libswscale/swscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 1e4994ca6b..ef8fc39c48 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2001,7 +2001,7 @@ static void lumRangeToJpeg16_c(int16_t *_dst, int width) int i; int32_t *dst = (int32_t *) _dst; for (i = 0; i < width; i++) - dst[i] = (FFMIN(dst[i],30189<<4)*19077 - (39057361<<4))>>14; + dst[i] = (FFMIN(dst[i],30189<<4)*4769 - (39057361<<2))>>12; } static void lumRangeFromJpeg16_c(int16_t *_dst, int width) { From bd55da1c08b5d560db357f0023dadf38d8c0cf7d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 30 Jun 2011 10:15:10 +0100 Subject: [PATCH 12/17] adler32: whitespace cosmetics Signed-off-by: Mans Rullgard --- libavutil/adler32.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/libavutil/adler32.c b/libavutil/adler32.c index ee1f70e479..9d3d896506 100644 --- a/libavutil/adler32.c +++ b/libavutil/adler32.c @@ -26,24 +26,28 @@ #define BASE 65521L /* largest prime smaller than 65536 */ -#define DO1(buf) {s1 += *buf++; s2 += s1;} +#define DO1(buf) { s1 += *buf++; s2 += s1; } #define DO4(buf) DO1(buf); DO1(buf); DO1(buf); DO1(buf); #define DO16(buf) DO4(buf); DO4(buf); DO4(buf); DO4(buf); -unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, unsigned int len) +unsigned long av_adler32_update(unsigned long adler, const uint8_t * buf, + unsigned int len) { unsigned long s1 = adler & 0xffff; unsigned long s2 = adler >> 16; - while (len>0) { + while (len > 0) { #if CONFIG_SMALL - while(len>4 && s2 < (1U<<31)){ - DO4(buf); len-=4; -#else - while(len>16 && s2 < (1U<<31)){ - DO16(buf); len-=16; -#endif + while (len > 4 && s2 < (1U << 31)) { + DO4(buf); + len -= 4; } +#else + while (len > 16 && s2 < (1U << 31)) { + DO16(buf); + len -= 16; + } +#endif DO1(buf); len--; s1 %= BASE; s2 %= BASE; @@ -61,9 +65,11 @@ int main(int argc, char **argv) { int i; char data[LEN]; + av_log_set_level(AV_LOG_DEBUG); - for(i=0; i>3) + 123*i; + + for (i = 0; i < LEN; i++) + data[i] = ((i * i) >> 3) + 123 * i; if (argc > 1 && !strcmp(argv[1], "-t")) { for (i = 0; i < 1000; i++) { @@ -76,6 +82,6 @@ int main(int argc, char **argv) } av_log(NULL, AV_LOG_DEBUG, "%X (expected 50E6E508)\n", checksum); - return checksum == 0x50e6e508? 0 : 1; + return checksum == 0x50e6e508 ? 0 : 1; } #endif From 4bfe0644606264c2c81ccc8b044ca46e52e7b24a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 30 Jun 2011 12:29:25 +0100 Subject: [PATCH 13/17] aes: whitespace cosmetics Signed-off-by: Mans Rullgard --- libavutil/aes.c | 219 +++++++++++++++++++++++++++++------------------- 1 file changed, 132 insertions(+), 87 deletions(-) diff --git a/libavutil/aes.c b/libavutil/aes.c index 72ddf99a16..fc6c4168cd 100644 --- a/libavutil/aes.c +++ b/libavutil/aes.c @@ -30,13 +30,13 @@ typedef union { uint8_t u8[16]; } av_aes_block; -typedef struct AVAES{ +typedef struct AVAES { // Note: round_key[16] is accessed in the init code, but this only // overwrites state, which does not matter (see also r7471). av_aes_block round_key[15]; av_aes_block state[2]; int rounds; -}AVAES; +} AVAES; const int av_aes_size= sizeof(AVAES); @@ -54,18 +54,34 @@ static uint32_t enc_multbl[4][256]; static uint32_t dec_multbl[4][256]; #endif -static inline void addkey(av_aes_block *dst, const av_aes_block *src, const av_aes_block *round_key){ +static inline void addkey(av_aes_block *dst, const av_aes_block *src, + const av_aes_block *round_key) +{ dst->u64[0] = src->u64[0] ^ round_key->u64[0]; dst->u64[1] = src->u64[1] ^ round_key->u64[1]; } -static void subshift(av_aes_block s0[2], int s, const uint8_t *box){ - av_aes_block *s1= (av_aes_block *)(s0[0].u8 - s); - av_aes_block *s3= (av_aes_block *)(s0[0].u8 + s); - s0[0].u8[0]=box[s0[1].u8[ 0]]; s0[0].u8[ 4]=box[s0[1].u8[ 4]]; s0[0].u8[ 8]=box[s0[1].u8[ 8]]; s0[0].u8[12]=box[s0[1].u8[12]]; - s1[0].u8[3]=box[s1[1].u8[ 7]]; s1[0].u8[ 7]=box[s1[1].u8[11]]; s1[0].u8[11]=box[s1[1].u8[15]]; s1[0].u8[15]=box[s1[1].u8[ 3]]; - s0[0].u8[2]=box[s0[1].u8[10]]; s0[0].u8[10]=box[s0[1].u8[ 2]]; s0[0].u8[ 6]=box[s0[1].u8[14]]; s0[0].u8[14]=box[s0[1].u8[ 6]]; - s3[0].u8[1]=box[s3[1].u8[13]]; s3[0].u8[13]=box[s3[1].u8[ 9]]; s3[0].u8[ 9]=box[s3[1].u8[ 5]]; s3[0].u8[ 5]=box[s3[1].u8[ 1]]; +static void subshift(av_aes_block s0[2], int s, const uint8_t *box) +{ + av_aes_block *s1 = (av_aes_block *) (s0[0].u8 - s); + av_aes_block *s3 = (av_aes_block *) (s0[0].u8 + s); + + s0[0].u8[ 0] = box[s0[1].u8[ 0]]; + s0[0].u8[ 4] = box[s0[1].u8[ 4]]; + s0[0].u8[ 8] = box[s0[1].u8[ 8]]; + s0[0].u8[12] = box[s0[1].u8[12]]; + s1[0].u8[ 3] = box[s1[1].u8[ 7]]; + s1[0].u8[ 7] = box[s1[1].u8[11]]; + s1[0].u8[11] = box[s1[1].u8[15]]; + s1[0].u8[15] = box[s1[1].u8[ 3]]; + s0[0].u8[ 2] = box[s0[1].u8[10]]; + s0[0].u8[10] = box[s0[1].u8[ 2]]; + s0[0].u8[ 6] = box[s0[1].u8[14]]; + s0[0].u8[14] = box[s0[1].u8[ 6]]; + s3[0].u8[ 1] = box[s3[1].u8[13]]; + s3[0].u8[13] = box[s3[1].u8[ 9]]; + s3[0].u8[ 9] = box[s3[1].u8[ 5]]; + s3[0].u8[ 5] = box[s3[1].u8[ 1]]; } static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){ @@ -85,116 +101,134 @@ static inline void mix(av_aes_block state[2], uint32_t multbl[][256], int s1, in state[0].u32[3] = mix_core(multbl, src[3][0], src[s1-1][1], src[1][2], src[s3-1][3]); } -static inline void crypt(AVAES *a, int s, const uint8_t *sbox, uint32_t multbl[][256]){ +static inline void crypt(AVAES *a, int s, const uint8_t *sbox, + uint32_t multbl[][256]) +{ int r; - for(r=a->rounds-1; r>0; r--){ - mix(a->state, multbl, 3-s, 1+s); + for (r = a->rounds - 1; r > 0; r--) { + mix(a->state, multbl, 3 - s, 1 + s); addkey(&a->state[1], &a->state[0], &a->round_key[r]); } + subshift(&a->state[0], s, sbox); } -void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_, int count, uint8_t *iv_, int decrypt){ - av_aes_block *dst = (av_aes_block *)dst_; - const av_aes_block *src = (const av_aes_block *)src_; - av_aes_block *iv = (av_aes_block *)iv_; - while(count--){ +void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_, + int count, uint8_t *iv_, int decrypt) +{ + av_aes_block *dst = (av_aes_block *) dst_; + const av_aes_block *src = (const av_aes_block *) src_; + av_aes_block *iv = (av_aes_block *) iv_; + + while (count--) { addkey(&a->state[1], src, &a->round_key[a->rounds]); - if(decrypt) { + if (decrypt) { crypt(a, 0, inv_sbox, dec_multbl); - if(iv){ + if (iv) { addkey(&a->state[0], &a->state[0], iv); memcpy(iv, src, 16); } addkey(dst, &a->state[0], &a->round_key[0]); - }else{ - if(iv) addkey(&a->state[1], &a->state[1], iv); - crypt(a, 2, sbox, enc_multbl); + } else { + if (iv) + addkey(&a->state[1], &a->state[1], iv); + crypt(a, 2, sbox, enc_multbl); addkey(dst, &a->state[0], &a->round_key[0]); - if(iv) memcpy(iv, dst, 16); + if (iv) + memcpy(iv, dst, 16); } src++; dst++; } } -static void init_multbl2(uint8_t tbl[1024], const int c[4], const uint8_t *log8, const uint8_t *alog8, const uint8_t *sbox){ +static void init_multbl2(uint8_t tbl[1024], const int c[4], + const uint8_t *log8, const uint8_t *alog8, + const uint8_t *sbox) +{ int i, j; - for(i=0; i<1024; i++){ - int x= sbox[i>>2]; - if(x) tbl[i]= alog8[ log8[x] + log8[c[i&3]] ]; + + for (i = 0; i < 1024; i++) { + int x = sbox[i >> 2]; + if (x) + tbl[i] = alog8[log8[x] + log8[c[i & 3]]]; } #if !CONFIG_SMALL - for(j=256; j<1024; j++) - for(i=0; i<4; i++) - tbl[4*j+i]= tbl[4*j + ((i-1)&3) - 1024]; + for (j = 256; j < 1024; j++) + for (i = 0; i < 4; i++) + tbl[4*j + i] = tbl[4*j + ((i - 1) & 3) - 1024]; #endif } // this is based on the reference AES code by Paulo Barreto and Vincent Rijmen -int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) { +int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) +{ int i, j, t, rconpointer = 0; uint8_t tk[8][4]; - int KC= key_bits>>5; - int rounds= KC + 6; - uint8_t log8[256]; + int KC = key_bits >> 5; + int rounds = KC + 6; + uint8_t log8[256]; uint8_t alog8[512]; - if(!enc_multbl[FF_ARRAY_ELEMS(enc_multbl)-1][FF_ARRAY_ELEMS(enc_multbl[0])-1]){ - j=1; - for(i=0; i<255; i++){ - alog8[i]= - alog8[i+255]= j; - log8[j]= i; - j^= j+j; - if(j>255) j^= 0x11B; + if (!enc_multbl[FF_ARRAY_ELEMS(enc_multbl)-1][FF_ARRAY_ELEMS(enc_multbl[0])-1]) { + j = 1; + for (i = 0; i < 255; i++) { + alog8[i] = alog8[i + 255] = j; + log8[j] = i; + j ^= j + j; + if (j > 255) + j ^= 0x11B; } - for(i=0; i<256; i++){ - j= i ? alog8[255-log8[i]] : 0; - j ^= (j<<1) ^ (j<<2) ^ (j<<3) ^ (j<<4); - j = (j ^ (j>>8) ^ 99) & 255; - inv_sbox[j]= i; - sbox [i]= j; + for (i = 0; i < 256; i++) { + j = i ? alog8[255 - log8[i]] : 0; + j ^= (j << 1) ^ (j << 2) ^ (j << 3) ^ (j << 4); + j = (j ^ (j >> 8) ^ 99) & 255; + inv_sbox[j] = i; + sbox[i] = j; } - init_multbl2(dec_multbl[0], (const int[4]){0xe, 0x9, 0xd, 0xb}, log8, alog8, inv_sbox); - init_multbl2(enc_multbl[0], (const int[4]){0x2, 0x1, 0x1, 0x3}, log8, alog8, sbox); + init_multbl2(dec_multbl[0], (const int[4]) { 0xe, 0x9, 0xd, 0xb }, + log8, alog8, inv_sbox); + init_multbl2(enc_multbl[0], (const int[4]) { 0x2, 0x1, 0x1, 0x3 }, + log8, alog8, sbox); } - if(key_bits!=128 && key_bits!=192 && key_bits!=256) + if (key_bits != 128 && key_bits != 192 && key_bits != 256) return -1; - a->rounds= rounds; + a->rounds = rounds; - memcpy(tk, key, KC*4); + memcpy(tk, key, KC * 4); - for(t= 0; t < (rounds+1)*16;) { - memcpy(a->round_key[0].u8+t, tk, KC*4); - t+= KC*4; + for (t = 0; t < (rounds + 1) * 16;) { + memcpy(a->round_key[0].u8 + t, tk, KC * 4); + t += KC * 4; - for(i = 0; i < 4; i++) - tk[0][i] ^= sbox[tk[KC-1][(i+1)&3]]; + for (i = 0; i < 4; i++) + tk[0][i] ^= sbox[tk[KC - 1][(i + 1) & 3]]; tk[0][0] ^= rcon[rconpointer++]; - for(j = 1; j < KC; j++){ - if(KC != 8 || j != KC>>1) - for(i = 0; i < 4; i++) tk[j][i] ^= tk[j-1][i]; + for (j = 1; j < KC; j++) { + if (KC != 8 || j != KC >> 1) + for (i = 0; i < 4; i++) + tk[j][i] ^= tk[j - 1][i]; else - for(i = 0; i < 4; i++) tk[j][i] ^= sbox[tk[j-1][i]]; + for (i = 0; i < 4; i++) + tk[j][i] ^= sbox[tk[j - 1][i]]; } } - if(decrypt){ - for(i=1; iround_key[i], 16); subshift(&tmp[1], 0, sbox); mix(tmp, dec_multbl, 1, 3); memcpy(&a->round_key[i], &tmp[0], 16); } - }else{ - for(i=0; i<(rounds+1)>>1; i++){ - for(j=0; j<16; j++) + } else { + for (i = 0; i < (rounds + 1) >> 1; i++) { + for (j = 0; j < 16; j++) FFSWAP(int, a->round_key[i].u8[j], a->round_key[rounds-i].u8[j]); } } @@ -209,30 +243,39 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) { int main(int argc, char **argv) { - int i,j; + int i, j; AVAES b; - uint8_t rkey[2][16]= { - {0}, - {0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3, 0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59}}; + uint8_t rkey[2][16] = { + { 0 }, + { 0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3, + 0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59 } + }; uint8_t pt[16], rpt[2][16]= { - {0x6a, 0x84, 0x86, 0x7c, 0xd7, 0x7e, 0x12, 0xad, 0x07, 0xea, 0x1b, 0xe8, 0x95, 0xc5, 0x3f, 0xa3}, - {0}}; + { 0x6a, 0x84, 0x86, 0x7c, 0xd7, 0x7e, 0x12, 0xad, + 0x07, 0xea, 0x1b, 0xe8, 0x95, 0xc5, 0x3f, 0xa3 }, + { 0 } + }; uint8_t rct[2][16]= { - {0x73, 0x22, 0x81, 0xc0, 0xa0, 0xaa, 0xb8, 0xf7, 0xa5, 0x4a, 0x0c, 0x67, 0xa0, 0xc4, 0x5e, 0xcf}, - {0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0, 0x4e, 0xaa, 0x6f, 0xb4, 0xdb, 0xf7, 0x84, 0x65}}; + { 0x73, 0x22, 0x81, 0xc0, 0xa0, 0xaa, 0xb8, 0xf7, + 0xa5, 0x4a, 0x0c, 0x67, 0xa0, 0xc4, 0x5e, 0xcf }, + { 0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0, + 0x4e, 0xaa, 0x6f, 0xb4, 0xdb, 0xf7, 0x84, 0x65 } + }; uint8_t temp[16]; int err = 0; av_log_set_level(AV_LOG_DEBUG); - for(i=0; i<2; i++){ + for (i = 0; i < 2; i++) { av_aes_init(&b, rkey[i], 128, 1); av_aes_crypt(&b, temp, rct[i], 1, NULL, 1); - for(j=0; j<16; j++) - if(rpt[i][j] != temp[j]) { - av_log(NULL, AV_LOG_ERROR, "%d %02X %02X\n", j, rpt[i][j], temp[j]); + for (j = 0; j < 16; j++) { + if (rpt[i][j] != temp[j]) { + av_log(NULL, AV_LOG_ERROR, "%d %02X %02X\n", + j, rpt[i][j], temp[j]); err = 1; } + } } if (argc > 1 && !strcmp(argv[1], "-t")) { @@ -243,21 +286,23 @@ int main(int argc, char **argv) av_aes_init(&ad, "PI=3.141592654..", 128, 1); av_lfg_init(&prng, 1); - for(i=0; i<10000; i++){ - for(j=0; j<16; j++){ + for (i = 0; i < 10000; i++) { + for (j = 0; j < 16; j++) { pt[j] = av_lfg_get(&prng); } { START_TIMER; av_aes_crypt(&ae, temp, pt, 1, NULL, 0); - if(!(i&(i-1))) - av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", temp[0], temp[5], temp[10], temp[15]); + if (!(i & (i - 1))) + av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", + temp[0], temp[5], temp[10], temp[15]); av_aes_crypt(&ad, temp, temp, 1, NULL, 1); STOP_TIMER("aes"); } - for(j=0; j<16; j++){ - if(pt[j] != temp[j]){ - av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", i,j, pt[j], temp[j]); + for (j = 0; j < 16; j++) { + if (pt[j] != temp[j]) { + av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", + i, j, pt[j], temp[j]); } } } From dafaef2fe1e1af7c40adc1855547fd4cba9862a9 Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Mon, 27 Jun 2011 23:39:12 -0700 Subject: [PATCH 14/17] Add support for aac streams in mp4/mov without extradata. --- libavcodec/aacdec.c | 42 ++++++++++++++++++++++++++++++++++++++++++ libavformat/utils.c | 25 +++++++++++-------------- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 26ce204257..f26a4b74a7 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -530,6 +530,22 @@ static void reset_all_predictors(PredictorState *ps) reset_predict_state(&ps[i]); } +static int sample_rate_idx (int rate) +{ + if (92017 <= rate) return 0; + else if (75132 <= rate) return 1; + else if (55426 <= rate) return 2; + else if (46009 <= rate) return 3; + else if (37566 <= rate) return 4; + else if (27713 <= rate) return 5; + else if (23004 <= rate) return 6; + else if (18783 <= rate) return 7; + else if (13856 <= rate) return 8; + else if (11502 <= rate) return 9; + else if (9391 <= rate) return 10; + else return 11; +} + static void reset_predictor_group(PredictorState *ps, int group_num) { int i; @@ -552,10 +568,33 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) ac->m4ac.sample_rate = avctx->sample_rate; if (avctx->extradata_size > 0) { + avctx->channels = 0; + avctx->frame_size = 0; + avctx->sample_rate = 0; if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac, avctx->extradata, avctx->extradata_size) < 0) return -1; + } else { + int sr, i; + enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; + + sr = sample_rate_idx(avctx->sample_rate); + ac->m4ac.sampling_index = sr; + ac->m4ac.channels = avctx->channels; + + for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++) + if (ff_mpeg4audio_channels[i] == avctx->channels) + break; + if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) { + i = 0; + } + ac->m4ac.chan_config = i; + + if (ac->m4ac.chan_config) { + set_default_channel_config(avctx, new_che_pos, ac->m4ac.chan_config); + output_configure(ac, ac->che_pos, new_che_pos, ac->m4ac.chan_config, OC_GLOBAL_HDR); + } } if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) { @@ -2047,6 +2086,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME)) return -7; } else if (ac->output_configured != OC_LOCKED) { + ac->m4ac.chan_config = 0; ac->output_configured = OC_NONE; } if (ac->output_configured != OC_LOCKED) { @@ -2514,6 +2554,7 @@ AVCodec ff_aac_decoder = { .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .capabilities = CODEC_CAP_CHANNEL_CONF, .channel_layouts = aac_channel_layout, }; @@ -2534,5 +2575,6 @@ AVCodec ff_aac_latm_decoder = { .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .capabilities = CODEC_CAP_CHANNEL_CONF, .channel_layouts = aac_channel_layout, }; diff --git a/libavformat/utils.c b/libavformat/utils.c index b12f785565..776697b5bb 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2207,11 +2207,7 @@ int av_find_stream_info(AVFormatContext *ic) for(i=0;inb_streams;i++) { AVCodec *codec; st = ic->streams[i]; - if (st->codec->codec_id == CODEC_ID_AAC) { - st->codec->sample_rate = 0; - st->codec->frame_size = 0; - st->codec->channels = 0; - } + if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { /* if(!st->time_base.num) @@ -2229,13 +2225,6 @@ int av_find_stream_info(AVFormatContext *ic) assert(!st->codec->codec); codec = avcodec_find_decoder(st->codec->codec_id); - /* Force decoding of at least one frame of codec data - * this makes sure the codec initializes the channel configuration - * and does not trust the values from the container. - */ - if (codec && codec->capabilities & CODEC_CAP_CHANNEL_CONF) - st->codec->channels = 0; - /* Ensure that subtitle_header is properly set. */ if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE && codec && !st->codec->codec) @@ -2377,8 +2366,16 @@ int av_find_stream_info(AVFormatContext *ic) /* if still no information, we try to open the codec and to decompress the frame. We try to avoid that in most cases as it takes longer and uses more memory. For MPEG-4, we need to - decompress for QuickTime. */ - if (!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st)) + decompress for QuickTime. + + If CODEC_CAP_CHANNEL_CONF is set this will force decoding of at + least one frame of codec data, this makes sure the codec initializes + the channel configuration and does not only trust the values from the container. + */ + if (!has_codec_parameters(st->codec) || + !has_decode_delay_been_guessed(st) || + (st->codec->codec && + st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF)) try_decode_frame(st, pkt); st->codec_info_nb_frames++; From 192bfbc1f18d50afea03c2d62ce5325fabb2f141 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 30 Jun 2011 20:44:46 +0200 Subject: [PATCH 15/17] avutil: elaborate documentation for av_get_random_seed --- libavutil/random_seed.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavutil/random_seed.h b/libavutil/random_seed.h index 8157d42d73..5bfeb8b835 100644 --- a/libavutil/random_seed.h +++ b/libavutil/random_seed.h @@ -24,7 +24,12 @@ #include /** - * Get a seed to use in conjunction with random functions. + * Get random data. + * + * This function can be called repeatedly to generate more random bits + * as needed. It is generally quite slow, and usually used to seed a + * PRNG. As it uses /dev/urandom and /dev/random, the quality of the + * returned random data depends on the platform. */ uint32_t av_get_random_seed(void); From d7537a6fce140876405a66f059f14e190527388d Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 30 Jun 2011 21:06:25 +0200 Subject: [PATCH 16/17] doxygen: Include libavcodec and libavformat examples into the documentation --- Doxyfile | 2 +- libavcodec/api-example.c | 3 ++- libavformat/output-example.c | 13 ++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Doxyfile b/Doxyfile index 5d80a2b6f5..6f32da6540 100644 --- a/Doxyfile +++ b/Doxyfile @@ -591,7 +591,7 @@ EXCLUDE_SYMBOLS = # directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = libavcodec/api-example.c libavformat/output-example.c # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp diff --git a/libavcodec/api-example.c b/libavcodec/api-example.c index 0221a30925..1792d60d77 100644 --- a/libavcodec/api-example.c +++ b/libavcodec/api-example.c @@ -20,8 +20,9 @@ /** * @file - * avcodec API use example. + * libavcodec API use example. * + * @example libavcodec/api-example.c * Note that this library only handles codecs (mpeg, mpeg4, etc...), * not file formats (avi, vob, etc...). See library 'libavformat' for the * format handling diff --git a/libavformat/output-example.c b/libavformat/output-example.c index ddd16f1eed..4453c03039 100644 --- a/libavformat/output-example.c +++ b/libavformat/output-example.c @@ -1,7 +1,4 @@ /* - * Libavformat API example: Output a media file in any supported - * libavformat format. The default codecs are used. - * * Copyright (c) 2003 Fabrice Bellard * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -22,6 +19,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + +/** + * @file + * libavformat API example. + * + * @example libavformat/output-example.c + * Output a media file in any supported libavformat format. + * The default codecs are used. + */ + #include #include #include From be73d76b34481686020e423ccabcca77042d0ede Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 20:53:59 +0200 Subject: [PATCH 17/17] cosmetics: fix some then/than typos --- libavcodec/avcodec.h | 2 +- libavcodec/dca.c | 2 +- libavcodec/dsputil.h | 4 ++-- libavcodec/get_bits.h | 4 ++-- libavcodec/mpegvideo_enc.c | 4 ++-- libavcodec/pgssubdec.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 40c30fc8e4..1a45009968 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1363,7 +1363,7 @@ typedef struct AVCodecContext { * A demuxer should set this to what is stored in the field used to identify the codec. * If there are multiple such fields in a container then the demuxer should choose the one * which maximizes the information about the used codec. - * If the codec tag field in a container is larger then 32 bits then the demuxer should + * If the codec tag field in a container is larger than 32 bits then the demuxer should * remap the longer ID to 32 bits with a table or other structure. Alternatively a new * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated * first. diff --git a/libavcodec/dca.c b/libavcodec/dca.c index 68731c9033..e87a9e3ed4 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -1316,7 +1316,7 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds PutBitContext pb; if ((unsigned)src_size > (unsigned)max_size) { -// av_log(NULL, AV_LOG_ERROR, "Input frame size larger then DCA_MAX_FRAME_SIZE!\n"); +// av_log(NULL, AV_LOG_ERROR, "Input frame size larger than DCA_MAX_FRAME_SIZE!\n"); // return -1; src_size = max_size; } diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 7a28b06fd5..ea135ca1ba 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -150,7 +150,7 @@ void clear_blocks_c(DCTELEM *blocks); /* add and put pixel (decoding) */ // blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16 -//h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller then 4 +//h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller than 4 typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h); typedef void (*tpel_mc_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int w, int h); typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride); @@ -183,7 +183,7 @@ static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ } /* motion estimation */ -// h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller then 2 +// h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller than 2 // although currently h<4 is not used as functions with width <8 are neither used nor implemented typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size, int h)/* __attribute__ ((const))*/; diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h index 4136498c71..b592b9a9a5 100644 --- a/libavcodec/get_bits.h +++ b/libavcodec/get_bits.h @@ -381,7 +381,7 @@ static inline int check_marker(GetBitContext *s, const char *msg) /** * init GetBitContext. - * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits + * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger than the actual read bits * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end * @param bit_size the size of the buffer in bits * @@ -504,7 +504,7 @@ void free_vlc(VLC *vlc); /** - * parses a vlc code, faster then get_vlc() + * parses a vlc code, faster than get_vlc() * @param bits is the number of bits which will be read at once, must be * identical to nb_bits in init_vlc() * @param max_depth is the number of times bits bits must be read to completely diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index b5a1872eb1..f3885626c1 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1787,7 +1787,7 @@ static av_always_inline void encode_mb(MpegEncContext *s, int motion_x, int moti static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){ int i; - memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster then a loop? + memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster than a loop? /* mpeg1 */ d->mb_skip_run= s->mb_skip_run; @@ -1816,7 +1816,7 @@ static inline void copy_context_after_encode(MpegEncContext *d, MpegEncContext * int i; memcpy(d->mv, s->mv, 2*4*2*sizeof(int)); - memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster then a loop? + memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster than a loop? /* mpeg1 */ d->mb_skip_run= s->mb_skip_run; diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 9546c38882..71b8242e70 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -198,7 +198,7 @@ static int parse_picture_segment(AVCodecContext *avctx, /* Make sure the bitmap is not too large */ if (avctx->width < width || avctx->height < height) { - av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger then video.\n"); + av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger than video.\n"); return -1; }