From 84f9d78a9601671ea9d5ad0e4eefdfc085eadc1f Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Tue, 7 Aug 2012 19:47:55 +0200 Subject: [PATCH 01/19] fate: add G.723.1 decoder tests --- tests/fate/voice.mak | 21 ++++++++ tests/ref/fate/g723_1-dec-1 | 3 ++ tests/ref/fate/g723_1-dec-2 | 27 ++++++++++ tests/ref/fate/g723_1-dec-3 | 34 ++++++++++++ tests/ref/fate/g723_1-dec-4 | 5 ++ tests/ref/fate/g723_1-dec-5 | 101 ++++++++++++++++++++++++++++++++++++ tests/ref/fate/g723_1-dec-6 | 101 ++++++++++++++++++++++++++++++++++++ 7 files changed, 292 insertions(+) create mode 100644 tests/ref/fate/g723_1-dec-1 create mode 100644 tests/ref/fate/g723_1-dec-2 create mode 100644 tests/ref/fate/g723_1-dec-3 create mode 100644 tests/ref/fate/g723_1-dec-4 create mode 100644 tests/ref/fate/g723_1-dec-5 create mode 100644 tests/ref/fate/g723_1-dec-6 diff --git a/tests/fate/voice.mak b/tests/fate/voice.mak index fc0e530ee6..ea765d2e39 100644 --- a/tests/fate/voice.mak +++ b/tests/fate/voice.mak @@ -9,6 +9,27 @@ fate-g722-encode: CMD = enc_dec_pcm wav md5 s16le $(SRC) -c:a g722 FATE_SAMPLES_AVCONV += $(FATE_G722) fate-g722: $(FATE_G722) +FATE_G723_1 += fate-g723_1-dec-1 +fate-g723_1-dec-1: CMD = framecrc -postfilter 0 -i $(SAMPLES)/g723_1/ineqd53.tco + +FATE_G723_1 += fate-g723_1-dec-2 +fate-g723_1-dec-2: CMD = framecrc -postfilter 0 -i $(SAMPLES)/g723_1/overd53.tco + +FATE_G723_1 += fate-g723_1-dec-3 +fate-g723_1-dec-3: CMD = framecrc -postfilter 1 -i $(SAMPLES)/g723_1/overd63p.tco + +FATE_G723_1 += fate-g723_1-dec-4 +fate-g723_1-dec-4: CMD = framecrc -postfilter 0 -i $(SAMPLES)/g723_1/pathd53.tco + +FATE_G723_1 += fate-g723_1-dec-5 +fate-g723_1-dec-5: CMD = framecrc -postfilter 1 -i $(SAMPLES)/g723_1/pathd63p.tco + +FATE_G723_1 += fate-g723_1-dec-6 +fate-g723_1-dec-6: CMD = framecrc -postfilter 1 -i $(SAMPLES)/g723_1/tamed63p.tco + +FATE_SAMPLES_AVCONV += $(FATE_G723_1) +fate-g723_1: $(FATE_G723_1) + 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 diff --git a/tests/ref/fate/g723_1-dec-1 b/tests/ref/fate/g723_1-dec-1 new file mode 100644 index 0000000000..a3a7f67b44 --- /dev/null +++ b/tests/ref/fate/g723_1-dec-1 @@ -0,0 +1,3 @@ +#tb 0: 1/8000 +0, 0, 0, 240, 480, 0x7f6f3970 +0, 240, 240, 240, 480, 0x1105a0d3 diff --git a/tests/ref/fate/g723_1-dec-2 b/tests/ref/fate/g723_1-dec-2 new file mode 100644 index 0000000000..e7fc9b2059 --- /dev/null +++ b/tests/ref/fate/g723_1-dec-2 @@ -0,0 +1,27 @@ +#tb 0: 1/8000 +0, 0, 0, 240, 480, 0x5d9d9091 +0, 240, 240, 240, 480, 0x425095b7 +0, 480, 480, 240, 480, 0xe7b6a1a7 +0, 720, 720, 240, 480, 0x9397af19 +0, 960, 960, 240, 480, 0xe671adf7 +0, 1200, 1200, 240, 480, 0x77deb313 +0, 1440, 1440, 240, 480, 0x64abbb5f +0, 1680, 1680, 240, 480, 0x000bc879 +0, 1920, 1920, 240, 480, 0x5a88c7aa +0, 2160, 2160, 240, 480, 0xb041cbad +0, 2400, 2400, 240, 480, 0x3257cd54 +0, 2640, 2640, 240, 480, 0xd6e7d4b3 +0, 2880, 2880, 240, 480, 0x0054d6b6 +0, 3120, 3120, 240, 480, 0x10bcd58e +0, 3360, 3360, 240, 480, 0x702ed981 +0, 3600, 3600, 240, 480, 0x9870d4e3 +0, 3840, 3840, 240, 480, 0x9c12d6d1 +0, 4080, 4080, 240, 480, 0xc41be449 +0, 4320, 4320, 240, 480, 0xf4bddc5a +0, 4560, 4560, 240, 480, 0x1c03e0d4 +0, 4800, 4800, 240, 480, 0xc287e4f8 +0, 5040, 5040, 240, 480, 0xf705ec20 +0, 5280, 5280, 240, 480, 0x7835f458 +0, 5520, 5520, 240, 480, 0xa8b3e632 +0, 5760, 5760, 240, 480, 0xd358df57 +0, 6000, 6000, 240, 480, 0x934dab80 diff --git a/tests/ref/fate/g723_1-dec-3 b/tests/ref/fate/g723_1-dec-3 new file mode 100644 index 0000000000..eabdd738ce --- /dev/null +++ b/tests/ref/fate/g723_1-dec-3 @@ -0,0 +1,34 @@ +#tb 0: 1/8000 +0, 0, 0, 240, 480, 0xce908869 +0, 240, 240, 240, 480, 0xfa63588e +0, 480, 480, 240, 480, 0x11ce850c +0, 720, 720, 240, 480, 0x76c459cf +0, 960, 960, 240, 480, 0x13ed8bf0 +0, 1200, 1200, 240, 480, 0x33d10b77 +0, 1440, 1440, 240, 480, 0xdf41e03c +0, 1680, 1680, 240, 480, 0xa31aad71 +0, 1920, 1920, 240, 480, 0x83c2b48d +0, 2160, 2160, 240, 480, 0xaf41ba01 +0, 2400, 2400, 240, 480, 0xeeecbadc +0, 2640, 2640, 240, 480, 0xe253c7e1 +0, 2880, 2880, 240, 480, 0x672cbf0a +0, 3120, 3120, 240, 480, 0x5f32aa27 +0, 3360, 3360, 240, 480, 0x8646a245 +0, 3600, 3600, 240, 480, 0x4819e5bc +0, 3840, 3840, 240, 480, 0x423dec60 +0, 4080, 4080, 240, 480, 0xafefe289 +0, 4320, 4320, 240, 480, 0x8dc5f136 +0, 4560, 4560, 240, 480, 0x549cee78 +0, 4800, 4800, 240, 480, 0xe589ebdc +0, 5040, 5040, 240, 480, 0x786cef17 +0, 5280, 5280, 240, 480, 0xdafded31 +0, 5520, 5520, 240, 480, 0xe58bedf8 +0, 5760, 5760, 240, 480, 0x44daf26c +0, 6000, 6000, 240, 480, 0x03fcf149 +0, 6240, 6240, 240, 480, 0x97a5f4ae +0, 6480, 6480, 240, 480, 0x2114f4f6 +0, 6720, 6720, 240, 480, 0x9a44f234 +0, 6960, 6960, 240, 480, 0x5b47f339 +0, 7200, 7200, 240, 480, 0x9248edcb +0, 7440, 7440, 240, 480, 0x47caf226 +0, 7680, 7680, 240, 480, 0x73d4ef48 diff --git a/tests/ref/fate/g723_1-dec-4 b/tests/ref/fate/g723_1-dec-4 new file mode 100644 index 0000000000..792899d38c --- /dev/null +++ b/tests/ref/fate/g723_1-dec-4 @@ -0,0 +1,5 @@ +#tb 0: 1/8000 +0, 0, 0, 240, 480, 0xa697b314 +0, 240, 240, 240, 480, 0x43c5dc5a +0, 480, 480, 240, 480, 0xd2438147 +0, 720, 720, 240, 480, 0x3b1ead64 diff --git a/tests/ref/fate/g723_1-dec-5 b/tests/ref/fate/g723_1-dec-5 new file mode 100644 index 0000000000..bdc2982740 --- /dev/null +++ b/tests/ref/fate/g723_1-dec-5 @@ -0,0 +1,101 @@ +#tb 0: 1/8000 +0, 0, 0, 240, 480, 0x4dce9773 +0, 240, 240, 240, 480, 0xe6367ab8 +0, 480, 480, 240, 480, 0xf36a589d +0, 720, 720, 240, 480, 0xf94efd31 +0, 960, 960, 240, 480, 0x984e6d33 +0, 1200, 1200, 240, 480, 0x84eaa191 +0, 1440, 1440, 240, 480, 0xed6e0c10 +0, 1680, 1680, 240, 480, 0x3627e7a0 +0, 1920, 1920, 240, 480, 0x2421b42d +0, 2160, 2160, 240, 480, 0x71e00d6f +0, 2400, 2400, 240, 480, 0xd49cdb95 +0, 2640, 2640, 240, 480, 0xa167e890 +0, 2880, 2880, 240, 480, 0xbb3fd7c0 +0, 3120, 3120, 240, 480, 0xa3d5bc27 +0, 3360, 3360, 240, 480, 0x8107ca9c +0, 3600, 3600, 240, 480, 0xcd4ce998 +0, 3840, 3840, 240, 480, 0x14e3ee73 +0, 4080, 4080, 240, 480, 0x5fc3eaf0 +0, 4320, 4320, 240, 480, 0xf166f33d +0, 4560, 4560, 240, 480, 0xe8b3f701 +0, 4800, 4800, 240, 480, 0x50aaeafd +0, 5040, 5040, 240, 480, 0xc7f2daec +0, 5280, 5280, 240, 480, 0x3960e5d0 +0, 5520, 5520, 240, 480, 0xadc8ec32 +0, 5760, 5760, 240, 480, 0x8741e7b0 +0, 6000, 6000, 240, 480, 0x1a1bd910 +0, 6240, 6240, 240, 480, 0x76a4ef7f +0, 6480, 6480, 240, 480, 0x19e6e5f5 +0, 6720, 6720, 240, 480, 0x6365e871 +0, 6960, 6960, 240, 480, 0xb2bee161 +0, 7200, 7200, 240, 480, 0x5098cba4 +0, 7440, 7440, 240, 480, 0x1009c4c5 +0, 7680, 7680, 240, 480, 0xbf20cfe3 +0, 7920, 7920, 240, 480, 0x91ddd028 +0, 8160, 8160, 240, 480, 0x4fedce37 +0, 8400, 8400, 240, 480, 0x43bcd4d8 +0, 8640, 8640, 240, 480, 0x41b3e782 +0, 8880, 8880, 240, 480, 0xa272f4a6 +0, 9120, 9120, 240, 480, 0x46b2f2cb +0, 9360, 9360, 240, 480, 0xc47dee7d +0, 9600, 9600, 240, 480, 0x699fe668 +0, 9840, 9840, 240, 480, 0x72b5daf8 +0, 10080, 10080, 240, 480, 0x0c0cf25e +0, 10320, 10320, 240, 480, 0xdafff519 +0, 10560, 10560, 240, 480, 0xf1f2e42f +0, 10800, 10800, 240, 480, 0xe04fe7f4 +0, 11040, 11040, 240, 480, 0x1157d789 +0, 11280, 11280, 240, 480, 0xe598ede6 +0, 11520, 11520, 240, 480, 0xbd06dc2f +0, 11760, 11760, 240, 480, 0x2aa6d2d9 +0, 12000, 12000, 240, 480, 0xa61ff1a3 +0, 12240, 12240, 240, 480, 0x6f57eb35 +0, 12480, 12480, 240, 480, 0x68c1f4a9 +0, 12720, 12720, 240, 480, 0x5c0ae6f2 +0, 12960, 12960, 240, 480, 0xdffbef45 +0, 13200, 13200, 240, 480, 0xf0daf893 +0, 13440, 13440, 240, 480, 0x680cf0c4 +0, 13680, 13680, 240, 480, 0xbbc1d42f +0, 13920, 13920, 240, 480, 0x9b66eddd +0, 14160, 14160, 240, 480, 0xc18be7a3 +0, 14400, 14400, 240, 480, 0x1deae025 +0, 14640, 14640, 240, 480, 0x6c12e002 +0, 14880, 14880, 240, 480, 0x004bf27e +0, 15120, 15120, 240, 480, 0xc97de444 +0, 15360, 15360, 240, 480, 0xc650de6b +0, 15600, 15600, 240, 480, 0xe614ecd6 +0, 15840, 15840, 240, 480, 0x2c20d111 +0, 16080, 16080, 240, 480, 0x8562c091 +0, 16320, 16320, 240, 480, 0x4fcddd08 +0, 16560, 16560, 240, 480, 0xc1b2c3cb +0, 16800, 16800, 240, 480, 0x5dcfdf24 +0, 17040, 17040, 240, 480, 0xf348d7be +0, 17280, 17280, 240, 480, 0x31b3ead7 +0, 17520, 17520, 240, 480, 0xb30dee68 +0, 17760, 17760, 240, 480, 0x1f44e9ac +0, 18000, 18000, 240, 480, 0x3cafe61e +0, 18240, 18240, 240, 480, 0x5800ea95 +0, 18480, 18480, 240, 480, 0xeaeeec19 +0, 18720, 18720, 240, 480, 0x47f9eff3 +0, 18960, 18960, 240, 480, 0xdc10edf1 +0, 19200, 19200, 240, 480, 0x5b1bd3ff +0, 19440, 19440, 240, 480, 0x039bea64 +0, 19680, 19680, 240, 480, 0xa93ac953 +0, 19920, 19920, 240, 480, 0x1b55f01c +0, 20160, 20160, 240, 480, 0x32b7db90 +0, 20400, 20400, 240, 480, 0x2f8ce0a8 +0, 20640, 20640, 240, 480, 0x53f4f7d5 +0, 20880, 20880, 240, 480, 0x880ee517 +0, 21120, 21120, 240, 480, 0xe793f2fd +0, 21360, 21360, 240, 480, 0x498beaf5 +0, 21600, 21600, 240, 480, 0x8c25f623 +0, 21840, 21840, 240, 480, 0xdc0df527 +0, 22080, 22080, 240, 480, 0x9d21e9b4 +0, 22320, 22320, 240, 480, 0x6d51d9e6 +0, 22560, 22560, 240, 480, 0xaf3ee6ba +0, 22800, 22800, 240, 480, 0xbef0ea44 +0, 23040, 23040, 240, 480, 0x50c6e9ab +0, 23280, 23280, 240, 480, 0x76a7d80c +0, 23520, 23520, 240, 480, 0x8d68ef94 +0, 23760, 23760, 240, 480, 0x213ce600 diff --git a/tests/ref/fate/g723_1-dec-6 b/tests/ref/fate/g723_1-dec-6 new file mode 100644 index 0000000000..eb0e4fa12c --- /dev/null +++ b/tests/ref/fate/g723_1-dec-6 @@ -0,0 +1,101 @@ +#tb 0: 1/8000 +0, 0, 0, 240, 480, 0x4fa1aed9 +0, 240, 240, 240, 480, 0x6d7ef391 +0, 480, 480, 240, 480, 0xaecaf2c1 +0, 720, 720, 240, 480, 0xd3b2ed0a +0, 960, 960, 240, 480, 0x33dceb4e +0, 1200, 1200, 240, 480, 0xc10eeb64 +0, 1440, 1440, 240, 480, 0x7c0febff +0, 1680, 1680, 240, 480, 0x0c09eecd +0, 1920, 1920, 240, 480, 0xa5efdcf8 +0, 2160, 2160, 240, 480, 0xb643edd2 +0, 2400, 2400, 240, 480, 0x46bef26d +0, 2640, 2640, 240, 480, 0x4310f101 +0, 2880, 2880, 240, 480, 0x3664ec16 +0, 3120, 3120, 240, 480, 0xcc17e5e8 +0, 3360, 3360, 240, 480, 0xff4cf35b +0, 3600, 3600, 240, 480, 0xdf4cf2e5 +0, 3840, 3840, 240, 480, 0x093bf570 +0, 4080, 4080, 240, 480, 0xd950ec75 +0, 4320, 4320, 240, 480, 0xa469f2f8 +0, 4560, 4560, 240, 480, 0x3558ee9d +0, 4800, 4800, 240, 480, 0x4102f252 +0, 5040, 5040, 240, 480, 0xf9dff318 +0, 5280, 5280, 240, 480, 0xd7cbef4d +0, 5520, 5520, 240, 480, 0x76c4eed3 +0, 5760, 5760, 240, 480, 0xe3d6e9d1 +0, 6000, 6000, 240, 480, 0x63baf340 +0, 6240, 6240, 240, 480, 0xd2dff2ff +0, 6480, 6480, 240, 480, 0x3355ebc4 +0, 6720, 6720, 240, 480, 0x7183ed76 +0, 6960, 6960, 240, 480, 0x9806eff7 +0, 7200, 7200, 240, 480, 0xc090ec04 +0, 7440, 7440, 240, 480, 0xe76ff174 +0, 7680, 7680, 240, 480, 0x2cdfe8f1 +0, 7920, 7920, 240, 480, 0xbb69ee8a +0, 8160, 8160, 240, 480, 0x3e03f522 +0, 8400, 8400, 240, 480, 0xe7e6e659 +0, 8640, 8640, 240, 480, 0x4dbaf063 +0, 8880, 8880, 240, 480, 0xc9b9f381 +0, 9120, 9120, 240, 480, 0x3866edc9 +0, 9360, 9360, 240, 480, 0x7e0defca +0, 9600, 9600, 240, 480, 0xa88bf700 +0, 9840, 9840, 240, 480, 0x65a7f029 +0, 10080, 10080, 240, 480, 0xaf8cf09d +0, 10320, 10320, 240, 480, 0x679bee1e +0, 10560, 10560, 240, 480, 0x8dc1e9a4 +0, 10800, 10800, 240, 480, 0xe3c2f0ac +0, 11040, 11040, 240, 480, 0x35d0eb14 +0, 11280, 11280, 240, 480, 0xfeb3ed00 +0, 11520, 11520, 240, 480, 0x9da3ecb4 +0, 11760, 11760, 240, 480, 0xa0e3f3c2 +0, 12000, 12000, 240, 480, 0x05ffe9de +0, 12240, 12240, 240, 480, 0xf7adef05 +0, 12480, 12480, 240, 480, 0x71bef669 +0, 12720, 12720, 240, 480, 0x4b9feca8 +0, 12960, 12960, 240, 480, 0x85e5ecd8 +0, 13200, 13200, 240, 480, 0xa4cbe90e +0, 13440, 13440, 240, 480, 0xe689f958 +0, 13680, 13680, 240, 480, 0xa936f168 +0, 13920, 13920, 240, 480, 0x496ff059 +0, 14160, 14160, 240, 480, 0x0bb6eb82 +0, 14400, 14400, 240, 480, 0x7727ef53 +0, 14640, 14640, 240, 480, 0xede3eaab +0, 14880, 14880, 240, 480, 0xe961ef58 +0, 15120, 15120, 240, 480, 0x454fef58 +0, 15360, 15360, 240, 480, 0x9305e76d +0, 15600, 15600, 240, 480, 0xfe5ce6ed +0, 15840, 15840, 240, 480, 0x84d1efdc +0, 16080, 16080, 240, 480, 0x4b23ed7a +0, 16320, 16320, 240, 480, 0x1380eb91 +0, 16560, 16560, 240, 480, 0xf705eca3 +0, 16800, 16800, 240, 480, 0x26f7e707 +0, 17040, 17040, 240, 480, 0x3fe3f27f +0, 17280, 17280, 240, 480, 0xa030f177 +0, 17520, 17520, 240, 480, 0xaf72ed92 +0, 17760, 17760, 240, 480, 0x00b8f1e7 +0, 18000, 18000, 240, 480, 0x681fecca +0, 18240, 18240, 240, 480, 0x3ca1ef63 +0, 18480, 18480, 240, 480, 0xd6fcedac +0, 18720, 18720, 240, 480, 0x6928ed04 +0, 18960, 18960, 240, 480, 0x8bdeeebe +0, 19200, 19200, 240, 480, 0x24b6f59d +0, 19440, 19440, 240, 480, 0xd49deebf +0, 19680, 19680, 240, 480, 0xe798f2c8 +0, 19920, 19920, 240, 480, 0x280fefb8 +0, 20160, 20160, 240, 480, 0xe0a8f40d +0, 20400, 20400, 240, 480, 0x4d48f511 +0, 20640, 20640, 240, 480, 0x6bf3eef0 +0, 20880, 20880, 240, 480, 0x1573f1cd +0, 21120, 21120, 240, 480, 0x6245e961 +0, 21360, 21360, 240, 480, 0xe05af091 +0, 21600, 21600, 240, 480, 0xfcc3e9e3 +0, 21840, 21840, 240, 480, 0x6d5febae +0, 22080, 22080, 240, 480, 0x4a96ef58 +0, 22320, 22320, 240, 480, 0x1586f156 +0, 22560, 22560, 240, 480, 0x50b0e99e +0, 22800, 22800, 240, 480, 0xf25dfa9b +0, 23040, 23040, 240, 480, 0x49b5f932 +0, 23280, 23280, 240, 480, 0xe1ddef32 +0, 23520, 23520, 240, 480, 0x2307ed94 +0, 23760, 23760, 240, 480, 0x6a2beb17 From 2804ba6a3b862be37986b9c2be3bad6bf4ccb6c7 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 8 Aug 2012 15:51:59 +0200 Subject: [PATCH 02/19] swf: Move swf_audio_codec_tags table to the only place it is used --- libavformat/swf.h | 9 --------- libavformat/swfdec.c | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libavformat/swf.h b/libavformat/swf.h index 14330c1e08..10a05f51b3 100644 --- a/libavformat/swf.h +++ b/libavformat/swf.h @@ -84,13 +84,4 @@ static const AVCodecTag swf_codec_tags[] = { { AV_CODEC_ID_NONE, 0}, }; -static const AVCodecTag swf_audio_codec_tags[] = { - { AV_CODEC_ID_PCM_S16LE, 0x00}, - { AV_CODEC_ID_ADPCM_SWF, 0x01}, - { AV_CODEC_ID_MP3, 0x02}, - { AV_CODEC_ID_PCM_S16LE, 0x03}, - //{ AV_CODEC_ID_NELLYMOSER, 0x06}, - { AV_CODEC_ID_NONE, 0}, -}; - #endif /* AVFORMAT_SWF_H */ diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c index 3666f93672..cef486c40f 100644 --- a/libavformat/swfdec.c +++ b/libavformat/swfdec.c @@ -23,6 +23,15 @@ #include "libavutil/intreadwrite.h" #include "swf.h" +static const AVCodecTag swf_audio_codec_tags[] = { + { CODEC_ID_PCM_S16LE, 0x00 }, + { CODEC_ID_ADPCM_SWF, 0x01 }, + { CODEC_ID_MP3, 0x02 }, + { CODEC_ID_PCM_S16LE, 0x03 }, +// { CODEC_ID_NELLYMOSER, 0x06 }, + { CODEC_ID_NONE, 0 }, +}; + static int get_swf_tag(AVIOContext *pb, int *len_ptr) { int tag, len; From 90f7e6176938487a77b8b4cdc8b4eaeeaca3e094 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 8 Aug 2012 15:54:02 +0200 Subject: [PATCH 03/19] swf: Move shared table out of the header file --- libavformat/Makefile | 6 +++--- libavformat/swf.c | 29 +++++++++++++++++++++++++++++ libavformat/swf.h | 6 +----- libavformat/swfdec.c | 2 +- libavformat/swfenc.c | 2 +- 5 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 libavformat/swf.c diff --git a/libavformat/Makefile b/libavformat/Makefile index ffb234f3d4..82dc1c1470 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -47,7 +47,7 @@ OBJS-$(CONFIG_AU_MUXER) += au.o OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o OBJS-$(CONFIG_AVI_MUXER) += avienc.o OBJS-$(CONFIG_AVISYNTH) += avisynth.o -OBJS-$(CONFIG_AVM2_MUXER) += swfenc.o +OBJS-$(CONFIG_AVM2_MUXER) += swfenc.o swf.o OBJS-$(CONFIG_AVS_DEMUXER) += avs.o vocdec.o voc.o OBJS-$(CONFIG_BETHSOFTVID_DEMUXER) += bethsoftvid.o OBJS-$(CONFIG_BFI_DEMUXER) += bfi.o @@ -299,8 +299,8 @@ OBJS-$(CONFIG_SPDIF_MUXER) += spdif.o spdifenc.o OBJS-$(CONFIG_SRT_DEMUXER) += srtdec.o OBJS-$(CONFIG_SRT_MUXER) += rawenc.o OBJS-$(CONFIG_STR_DEMUXER) += psxstr.o -OBJS-$(CONFIG_SWF_DEMUXER) += swfdec.o -OBJS-$(CONFIG_SWF_MUXER) += swfenc.o +OBJS-$(CONFIG_SWF_DEMUXER) += swfdec.o swf.o +OBJS-$(CONFIG_SWF_MUXER) += swfenc.o swf.o OBJS-$(CONFIG_THP_DEMUXER) += thp.o OBJS-$(CONFIG_TIERTEXSEQ_DEMUXER) += tiertexseq.o OBJS-$(CONFIG_TMV_DEMUXER) += tmv.o diff --git a/libavformat/swf.c b/libavformat/swf.c new file mode 100644 index 0000000000..1762991d2b --- /dev/null +++ b/libavformat/swf.c @@ -0,0 +1,29 @@ +/* + * Flash Compatible Streaming Format + * Copyright (c) 2000 Fabrice Bellard + * Copyright (c) 2003 Tinic Uro + * + * 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 + */ + +#include "internal.h" + +const AVCodecTag ff_swf_codec_tags[] = { + { CODEC_ID_FLV1, 0x02 }, + { CODEC_ID_VP6F, 0x04 }, + { CODEC_ID_NONE, 0 }, +}; diff --git a/libavformat/swf.h b/libavformat/swf.h index 10a05f51b3..b1e477b828 100644 --- a/libavformat/swf.h +++ b/libavformat/swf.h @@ -78,10 +78,6 @@ typedef struct { AVCodecContext *audio_enc, *video_enc; } SWFContext; -static const AVCodecTag swf_codec_tags[] = { - { AV_CODEC_ID_FLV1, 0x02}, - { AV_CODEC_ID_VP6F, 0x04}, - { AV_CODEC_ID_NONE, 0}, -}; +extern const AVCodecTag ff_swf_codec_tags[]; #endif /* AVFORMAT_SWF_H */ diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c index cef486c40f..09770f4f4a 100644 --- a/libavformat/swfdec.c +++ b/libavformat/swfdec.c @@ -120,7 +120,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) return -1; vst->id = ch_id; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; - vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, avio_r8(pb)); + vst->codec->codec_id = ff_codec_get_id(ff_swf_codec_tags, avio_r8(pb)); avpriv_set_pts_info(vst, 16, 256, swf->frame_rate); len -= 8; } else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) { diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c index 65ffe261fe..19166503e8 100644 --- a/libavformat/swfenc.c +++ b/libavformat/swfenc.c @@ -347,7 +347,7 @@ static int swf_write_video(AVFormatContext *s, avio_wl16(pb, enc->width); avio_wl16(pb, enc->height); avio_w8(pb, 0); - avio_w8(pb,ff_codec_get_tag(swf_codec_tags,enc->codec_id)); + avio_w8(pb,ff_codec_get_tag(ff_swf_codec_tags, enc->codec_id)); put_swf_end_tag(s); /* place the video object for the first time */ From 52561d011658e64fc3d0edb25f5f1b64f9aa7430 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 9 Aug 2012 15:30:24 +0200 Subject: [PATCH 04/19] doc: Drop obsolete shared libs cflags hint to workaround Cygwin gcc bugs --- doc/platform.texi | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/doc/platform.texi b/doc/platform.texi index 2049031f11..0ed8e07637 100644 --- a/doc/platform.texi +++ b/doc/platform.texi @@ -292,21 +292,6 @@ In order to run FATE you will also need the following "Utils" packages: bc, diffutils @end example -Then run - -@example -./configure -@end example - -to make a static build. - -To build shared libraries add a special compiler flag to work around current -@code{gcc4-core} package bugs in addition to the normal configure flags: - -@example -./configure --enable-shared --disable-static --extra-cflags=-fno-reorder-functions -@end example - If you want to build Libav with additional libraries, download Cygwin "Devel" packages for Ogg and Vorbis from any Cygwin packages repository: @example From 804d7a1aa6fd33fbe405698d90d02121423e540c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 9 Aug 2012 03:06:01 +0200 Subject: [PATCH 05/19] doxygen: Fix function parameter names to match the code --- libavcodec/vp8.c | 2 +- libavfilter/buffersink.h | 6 +++--- libavresample/audio_convert.h | 2 +- libavresample/audio_mix.h | 2 +- libavutil/xtea.h | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 3f88d78306..e50d7c99b7 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -751,7 +751,7 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, #ifndef decode_block_coeffs_internal /** - * @param c arithmetic bitstream reader context + * @param r arithmetic bitstream reader context * @param block destination for block coefficients * @param probs probabilities to use when reading trees from the bitstream * @param i initial coeff index, 0 unless a separate DC block is coded diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h index 8f94a9c94d..e358ac3412 100644 --- a/libavfilter/buffersink.h +++ b/libavfilter/buffersink.h @@ -29,7 +29,7 @@ /** * Get a buffer with filtered data from sink and put it in buf. * - * @param sink pointer to a context of a buffersink or abuffersink AVFilter. + * @param ctx pointer to a context of a buffersink or abuffersink AVFilter. * @param buf pointer to the buffer will be written here if buf is non-NULL. buf * must be freed by the caller using avfilter_unref_buffer(). * Buf may also be NULL to query whether a buffer is ready to be @@ -38,14 +38,14 @@ * @return >= 0 in case of success, a negative AVERROR code in case of * failure. */ -int av_buffersink_read(AVFilterContext *sink, AVFilterBufferRef **buf); +int av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf); /** * Same as av_buffersink_read, but with the ability to specify the number of * samples read. This function is less efficient than av_buffersink_read(), * because it copies the data around. * - * @param sink pointer to a context of the abuffersink AVFilter. + * @param ctx pointer to a context of the abuffersink AVFilter. * @param buf pointer to the buffer will be written here if buf is non-NULL. buf * must be freed by the caller using avfilter_unref_buffer(). buf * will contain exactly nb_samples audio samples, except at the end diff --git a/libavresample/audio_convert.h b/libavresample/audio_convert.h index 9227763628..eefffbb12c 100644 --- a/libavresample/audio_convert.h +++ b/libavresample/audio_convert.h @@ -42,7 +42,7 @@ typedef struct AudioConvert AudioConvert; * @param in_fmt input sample format * @param channels number of channels, or 0 for any number of channels * @param ptr_align buffer pointer alignment, in bytes - * @param sample_align buffer size alignment, in samples + * @param samples_align buffer size alignment, in samples * @param descr function type description (e.g. "C" or "SSE") * @param conv conversion function pointer */ diff --git a/libavresample/audio_mix.h b/libavresample/audio_mix.h index 61db33047d..2199fffe0e 100644 --- a/libavresample/audio_mix.h +++ b/libavresample/audio_mix.h @@ -69,7 +69,7 @@ typedef struct AudioMix { * @param in_channels number of input channels, or 0 for any number of channels * @param out_channels number of output channels, or 0 for any number of channels * @param ptr_align buffer pointer alignment, in bytes - * @param sample_align buffer size alignment, in samples + * @param samples_align buffer size alignment, in samples * @param descr function type description (e.g. "C" or "SSE") * @param mix_func mixing function pointer */ diff --git a/libavutil/xtea.h b/libavutil/xtea.h index cf305c6632..7d2b07bbc7 100644 --- a/libavutil/xtea.h +++ b/libavutil/xtea.h @@ -36,7 +36,7 @@ typedef struct AVXTEA { /** * Initialize an AVXTEA context. * - * @param x an AVXTEA context + * @param ctx an AVXTEA context * @param key a key of 16 bytes used for encryption/decryption */ void av_xtea_init(struct AVXTEA *ctx, const uint8_t key[16]); @@ -44,7 +44,7 @@ void av_xtea_init(struct AVXTEA *ctx, const uint8_t key[16]); /** * Encrypt or decrypt a buffer using a previously initialized context. * - * @param x an AVXTEA context + * @param ctx an AVXTEA context * @param dst destination array, can be equal to src * @param src source array, can be equal to dst * @param count number of 8 byte blocks From c72f12cbae93671cbd390eb51ce62573b443bf6c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 9 Aug 2012 17:14:32 +0200 Subject: [PATCH 06/19] configure: suncc: Add -xc99 to dependency flags, required on Solaris --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 241663c07d..aeb9928f70 100755 --- a/configure +++ b/configure @@ -2196,7 +2196,7 @@ probe_cc(){ _type=suncc _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-) _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)' - _DEPFLAGS='-xM1' + _DEPFLAGS='-xM1 -xc99' _ldflags='-std=c99' _cflags_speed='-O5' _cflags_size='-O5 -xspace' From 83c93fe74af013a1c376a39ee28759c89c483542 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 8 Aug 2012 16:01:01 +0200 Subject: [PATCH 07/19] configure: Check for a sctp struct instead of just the header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes build failures on debian/kfreebsd, which has the sctp.h header, but it is currently broken (a cpp test succeeds, but a compile test fails), see http://bugs.debian.org/684330 for details. Also remove the checked item from HAVE_LIST, since the corresponding HAVE_* define isn't used by the source code. Signed-off-by: Martin Storsjö --- configure | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/configure b/configure index aeb9928f70..c5f4567006 100755 --- a/configure +++ b/configure @@ -1153,7 +1153,6 @@ HAVE_LIST=" mm_empty mmap nanosleep - netinet_sctp_h poll_h posix_memalign rdtsc @@ -1605,7 +1604,7 @@ rtmpt_protocol_select="ffrtmphttp_protocol" rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol" rtmpts_protocol_select="ffrtmphttp_protocol https_protocol" rtp_protocol_select="udp_protocol" -sctp_protocol_deps="network netinet_sctp_h" +sctp_protocol_deps="network struct_sctp_event_subscribe" tcp_protocol_deps="network" tls_protocol_deps_any="openssl gnutls" tls_protocol_select="tcp_protocol" @@ -2979,7 +2978,7 @@ if enabled network; then check_type poll.h "struct pollfd" check_type "sys/types.h sys/socket.h" "struct sockaddr_storage" check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len - check_header netinet/sctp.h + check_type netinet/sctp.h "struct sctp_event_subscribe" check_func getaddrinfo $network_extralibs # Prefer arpa/inet.h over winsock2 if check_header arpa/inet.h ; then From d913fd1f00adbbba50c58384906ef40f5ec4850d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 8 Aug 2012 18:18:14 +0100 Subject: [PATCH 08/19] libavutil: drop fallback definitions of INTxx_MIN/MAX This list is incomplete (we also use UINT16_MAX), so there does not appear to be any system we care about that needs these. Signed-off-by: Mans Rullgard --- libavutil/internal.h | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/libavutil/internal.h b/libavutil/internal.h index 4c1d2f6648..58e556860f 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -52,38 +52,6 @@ struct AVDictionary { #endif #endif -#ifndef INT16_MIN -#define INT16_MIN (-0x7fff - 1) -#endif - -#ifndef INT16_MAX -#define INT16_MAX 0x7fff -#endif - -#ifndef INT32_MIN -#define INT32_MIN (-0x7fffffff - 1) -#endif - -#ifndef INT32_MAX -#define INT32_MAX 0x7fffffff -#endif - -#ifndef UINT32_MAX -#define UINT32_MAX 0xffffffff -#endif - -#ifndef INT64_MIN -#define INT64_MIN (-0x7fffffffffffffffLL - 1) -#endif - -#ifndef INT64_MAX -#define INT64_MAX INT64_C(9223372036854775807) -#endif - -#ifndef UINT64_MAX -#define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) -#endif - #ifndef INT_BIT # define INT_BIT (CHAR_BIT * sizeof(int)) #endif From 1c4ab37c38e4ede6bbdf95221ad6cbf1bbcb7e9d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 8 Aug 2012 20:09:33 +0100 Subject: [PATCH 09/19] libavutil: drop offsetof() fallback definition The only compiler I have that does not define the standard offsetof() macro is "Bruce's C Compiler", a simple compiler for producing 8/16-bit 8086 code, usually for use in early stages of PC booting. Signed-off-by: Mans Rullgard --- libavutil/internal.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavutil/internal.h b/libavutil/internal.h index 58e556860f..aa56c0578c 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -56,10 +56,6 @@ struct AVDictionary { # define INT_BIT (CHAR_BIT * sizeof(int)) #endif -#ifndef offsetof -# define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F)) -#endif - /* debug stuff */ #define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) From 6d3783d16001810885603b39857d48bc84744ea2 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 8 Aug 2012 22:57:12 +0100 Subject: [PATCH 10/19] ffmenc: replace if/abort with assert() The condition is trivially true, but keeping the assert() is sensible to avoid FFM_HEADER_SIZE ever getting out of sync with the actual code. Signed-off-by: Mans Rullgard --- libavformat/ffmenc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c index ab69267f54..806930948b 100644 --- a/libavformat/ffmenc.c +++ b/libavformat/ffmenc.c @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "libavutil/intreadwrite.h" #include "libavutil/intfloat.h" #include "avformat.h" @@ -34,8 +36,7 @@ static void flush_packet(AVFormatContext *s) fill_size = ffm->packet_end - ffm->packet_ptr; memset(ffm->packet_ptr, 0, fill_size); - if (avio_tell(pb) % ffm->packet_size) - av_abort(); + assert(avio_tell(pb) % ffm->packet_size == 0); /* put header */ avio_wb16(pb, PACKET_ID); From 54918d0394dda4fce52e7cddde0d35ff4e6add7e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 8 Aug 2012 22:58:07 +0100 Subject: [PATCH 11/19] libavutil: remove unused av_abort() macro Signed-off-by: Mans Rullgard --- libavutil/internal.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavutil/internal.h b/libavutil/internal.h index aa56c0578c..75c5156d0f 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -56,10 +56,6 @@ struct AVDictionary { # define INT_BIT (CHAR_BIT * sizeof(int)) #endif -/* debug stuff */ - -#define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) - /* avoid usage of dangerous/inappropriate system functions */ #undef malloc #define malloc please_use_av_malloc From 5e6001db8f235e3665df2bde489d96b19b4cfad5 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 9 Aug 2012 14:57:49 +0200 Subject: [PATCH 12/19] rtmp: Factorize the code by adding handle_invoke_result Signed-off-by: Luca Barbato --- libavformat/rtmpproto.c | 147 +++++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 69 deletions(-) diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 6ad90b828f..c2021deee1 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -1021,12 +1021,88 @@ static int handle_server_bw(URLContext *s, RTMPPacket *pkt) return 0; } +static int handle_invoke_result(URLContext *s, RTMPPacket *pkt) +{ + RTMPContext *rt = s->priv_data; + char *tracked_method = NULL; + GetByteContext gbc; + double pkt_id; + int ret = 0; + int i; + + bytestream2_init(&gbc, pkt->data + 10, pkt->data_size); + if ((ret = ff_amf_read_number(&gbc, &pkt_id)) < 0) + return ret; + + for (i = 0; i < rt->nb_tracked_methods; i++) { + if (rt->tracked_methods[i].id != pkt_id) + continue; + + tracked_method = rt->tracked_methods[i].name; + del_tracked_method(rt, i); + break; + } + + if (!tracked_method) { + /* Ignore this reply when the current method is not tracked. */ + return ret; + } + + if (!memcmp(tracked_method, "connect", 7)) { + if (!rt->is_input) { + if ((ret = gen_release_stream(s, rt)) < 0) + goto fail; + + if ((ret = gen_fcpublish_stream(s, rt)) < 0) + goto fail; + } else { + if ((ret = gen_server_bw(s, rt)) < 0) + goto fail; + } + + if ((ret = gen_create_stream(s, rt)) < 0) + goto fail; + + if (rt->is_input) { + /* Send the FCSubscribe command when the name of live + * stream is defined by the user or if it's a live stream. */ + if (rt->subscribe) { + if ((ret = gen_fcsubscribe_stream(s, rt, rt->subscribe)) < 0) + goto fail; + } else if (rt->live == -1) { + if ((ret = gen_fcsubscribe_stream(s, rt, rt->playpath)) < 0) + goto fail; + } + } + } else if (!memcmp(tracked_method, "createStream", 12)) { + //extract a number from the result + if (pkt->data[10] || pkt->data[19] != 5 || pkt->data[20]) { + av_log(s, AV_LOG_WARNING, "Unexpected reply on connect()\n"); + } else { + rt->main_channel_id = av_int2double(AV_RB64(pkt->data + 21)); + } + + if (!rt->is_input) { + if ((ret = gen_publish(s, rt)) < 0) + goto fail; + } else { + if ((ret = gen_play(s, rt)) < 0) + goto fail; + if ((ret = gen_buffer_time(s, rt)) < 0) + goto fail; + } + } + +fail: + av_free(tracked_method); + return ret; +} + static int handle_invoke(URLContext *s, RTMPPacket *pkt) { RTMPContext *rt = s->priv_data; int i, t; const uint8_t *data_end = pkt->data + pkt->data_size; - char *tracked_method = NULL; int ret = 0; //TODO: check for the messages sent for wrong state? @@ -1038,73 +1114,8 @@ static int handle_invoke(URLContext *s, RTMPPacket *pkt) av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr); return -1; } else if (!memcmp(pkt->data, "\002\000\007_result", 10)) { - GetByteContext gbc; - double pkt_id; - - bytestream2_init(&gbc, pkt->data + 10, pkt->data_size); - if ((ret = ff_amf_read_number(&gbc, &pkt_id)) < 0) + if ((ret = handle_invoke_result(s, pkt)) < 0) return ret; - - for (i = 0; i < rt->nb_tracked_methods; i++) { - if (rt->tracked_methods[i].id != pkt_id) - continue; - - tracked_method = rt->tracked_methods[i].name; - del_tracked_method(rt, i); - break; - } - - if (!tracked_method) { - /* Ignore this reply when the current method is not tracked. */ - return 0; - } - - if (!memcmp(tracked_method, "connect", 7)) { - if (!rt->is_input) { - if ((ret = gen_release_stream(s, rt)) < 0) - goto invoke_fail; - - if ((ret = gen_fcpublish_stream(s, rt)) < 0) - goto invoke_fail; - } else { - if ((ret = gen_server_bw(s, rt)) < 0) - goto invoke_fail; - } - - if ((ret = gen_create_stream(s, rt)) < 0) - goto invoke_fail; - - if (rt->is_input) { - /* Send the FCSubscribe command when the name of live - * stream is defined by the user or if it's a live stream. */ - if (rt->subscribe) { - if ((ret = gen_fcsubscribe_stream(s, rt, - rt->subscribe)) < 0) - goto invoke_fail; - } else if (rt->live == -1) { - if ((ret = gen_fcsubscribe_stream(s, rt, - rt->playpath)) < 0) - goto invoke_fail; - } - } - } else if (!memcmp(tracked_method, "createStream", 12)) { - //extract a number from the result - if (pkt->data[10] || pkt->data[19] != 5 || pkt->data[20]) { - av_log(s, AV_LOG_WARNING, "Unexpected reply on connect()\n"); - } else { - rt->main_channel_id = av_int2double(AV_RB64(pkt->data + 21)); - } - - if (!rt->is_input) { - if ((ret = gen_publish(s, rt)) < 0) - goto invoke_fail; - } else { - if ((ret = gen_play(s, rt)) < 0) - goto invoke_fail; - if ((ret = gen_buffer_time(s, rt)) < 0) - goto invoke_fail; - } - } } else if (!memcmp(pkt->data, "\002\000\010onStatus", 11)) { const uint8_t* ptr = pkt->data + 11; uint8_t tmpstr[256]; @@ -1134,8 +1145,6 @@ static int handle_invoke(URLContext *s, RTMPPacket *pkt) return ret; } -invoke_fail: - av_free(tracked_method); return ret; } From 71036a3a5eeda1c0a7eef6acf37aa0c33d488a36 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 9 Aug 2012 14:57:50 +0200 Subject: [PATCH 13/19] rtmp: Factorize the code by adding handle_invoke_status Signed-off-by: Luca Barbato --- libavformat/rtmpproto.c | 58 ++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index c2021deee1..a2d2529aa1 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -1098,10 +1098,41 @@ fail: return ret; } +static int handle_invoke_status(URLContext *s, RTMPPacket *pkt) +{ + RTMPContext *rt = s->priv_data; + const uint8_t *data_end = pkt->data + pkt->data_size; + const uint8_t *ptr = pkt->data + 11; + uint8_t tmpstr[256]; + int i, t; + + for (i = 0; i < 2; i++) { + t = ff_amf_tag_size(ptr, data_end); + if (t < 0) + return 1; + ptr += t; + } + + t = ff_amf_get_field_value(ptr, data_end, "level", tmpstr, sizeof(tmpstr)); + if (!t && !strcmp(tmpstr, "error")) { + if (!ff_amf_get_field_value(ptr, data_end, + "description", tmpstr, sizeof(tmpstr))) + av_log(s, AV_LOG_ERROR, "Server error: %s\n", tmpstr); + return -1; + } + + t = ff_amf_get_field_value(ptr, data_end, "code", tmpstr, sizeof(tmpstr)); + if (!t && !strcmp(tmpstr, "NetStream.Play.Start")) rt->state = STATE_PLAYING; + if (!t && !strcmp(tmpstr, "NetStream.Play.Stop")) rt->state = STATE_STOPPED; + if (!t && !strcmp(tmpstr, "NetStream.Play.UnpublishNotify")) rt->state = STATE_STOPPED; + if (!t && !strcmp(tmpstr, "NetStream.Publish.Start")) rt->state = STATE_PUBLISHING; + + return 0; +} + static int handle_invoke(URLContext *s, RTMPPacket *pkt) { RTMPContext *rt = s->priv_data; - int i, t; const uint8_t *data_end = pkt->data + pkt->data_size; int ret = 0; @@ -1117,29 +1148,8 @@ static int handle_invoke(URLContext *s, RTMPPacket *pkt) if ((ret = handle_invoke_result(s, pkt)) < 0) return ret; } else if (!memcmp(pkt->data, "\002\000\010onStatus", 11)) { - const uint8_t* ptr = pkt->data + 11; - uint8_t tmpstr[256]; - - for (i = 0; i < 2; i++) { - t = ff_amf_tag_size(ptr, data_end); - if (t < 0) - return 1; - ptr += t; - } - t = ff_amf_get_field_value(ptr, data_end, - "level", tmpstr, sizeof(tmpstr)); - if (!t && !strcmp(tmpstr, "error")) { - if (!ff_amf_get_field_value(ptr, data_end, - "description", tmpstr, sizeof(tmpstr))) - av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr); - return -1; - } - t = ff_amf_get_field_value(ptr, data_end, - "code", tmpstr, sizeof(tmpstr)); - if (!t && !strcmp(tmpstr, "NetStream.Play.Start")) rt->state = STATE_PLAYING; - if (!t && !strcmp(tmpstr, "NetStream.Play.Stop")) rt->state = STATE_STOPPED; - if (!t && !strcmp(tmpstr, "NetStream.Play.UnpublishNotify")) rt->state = STATE_STOPPED; - if (!t && !strcmp(tmpstr, "NetStream.Publish.Start")) rt->state = STATE_PUBLISHING; + if ((ret = handle_invoke_status(s, pkt)) < 0) + return ret; } else if (!memcmp(pkt->data, "\002\000\010onBWDone", 11)) { if ((ret = gen_check_bw(s, rt)) < 0) return ret; From 3eebc1e1743c6e4855d29f73e9f4fbd1c9e1fa60 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 9 Aug 2012 14:57:51 +0200 Subject: [PATCH 14/19] rtmp: Factorize the code by adding handle_invoke_error Signed-off-by: Luca Barbato --- libavformat/rtmpproto.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index a2d2529aa1..c85424e32c 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -1021,6 +1021,20 @@ static int handle_server_bw(URLContext *s, RTMPPacket *pkt) return 0; } +static int handle_invoke_error(URLContext *s, RTMPPacket *pkt) +{ + const uint8_t *data_end = pkt->data + pkt->data_size; + uint8_t tmpstr[256]; + + if (!ff_amf_get_field_value(pkt->data + 9, data_end, + "description", tmpstr, sizeof(tmpstr))) { + av_log(s, AV_LOG_ERROR, "Server error: %s\n", tmpstr); + return -1; + } + + return 0; +} + static int handle_invoke_result(URLContext *s, RTMPPacket *pkt) { RTMPContext *rt = s->priv_data; @@ -1133,17 +1147,12 @@ static int handle_invoke_status(URLContext *s, RTMPPacket *pkt) static int handle_invoke(URLContext *s, RTMPPacket *pkt) { RTMPContext *rt = s->priv_data; - const uint8_t *data_end = pkt->data + pkt->data_size; int ret = 0; //TODO: check for the messages sent for wrong state? if (!memcmp(pkt->data, "\002\000\006_error", 9)) { - uint8_t tmpstr[256]; - - if (!ff_amf_get_field_value(pkt->data + 9, data_end, - "description", tmpstr, sizeof(tmpstr))) - av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr); - return -1; + if ((ret = handle_invoke_error(s, pkt)) < 0) + return ret; } else if (!memcmp(pkt->data, "\002\000\007_result", 10)) { if ((ret = handle_invoke_result(s, pkt)) < 0) return ret; From 0d735ca214b32aa6e9a4bf4dd5d8a6c242dbaa29 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 9 Aug 2012 22:45:51 +0100 Subject: [PATCH 15/19] ARM: add missing "cc" clobber in av_clipl_int32_arm() Signed-off-by: Mans Rullgard --- libavutil/arm/intmath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/arm/intmath.h b/libavutil/arm/intmath.h index fa31ecf6a5..ce73404b37 100644 --- a/libavutil/arm/intmath.h +++ b/libavutil/arm/intmath.h @@ -108,7 +108,7 @@ static av_always_inline av_const int32_t av_clipl_int32_arm(int64_t a) "mvnne %1, #1<<31 \n\t" "moveq %0, %Q2 \n\t" "eorne %0, %1, %R2, asr #31 \n\t" - : "=r"(x), "=&r"(y) : "r"(a)); + : "=r"(x), "=&r"(y) : "r"(a) : "cc"); return x; } From e2b7c5783d34fa36a265c1e475de71ba3dd49a19 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 9 Aug 2012 21:02:46 +0100 Subject: [PATCH 16/19] g723.1: remove unused #includes Signed-off-by: Mans Rullgard --- libavcodec/g723_1.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c index e917f5a50c..bf753ab182 100644 --- a/libavcodec/g723_1.c +++ b/libavcodec/g723_1.c @@ -33,8 +33,6 @@ #include "get_bits.h" #include "acelp_vectors.h" #include "celp_filters.h" -#include "celp_math.h" -#include "lsp.h" #include "g723_1_data.h" /** From e141cf2c5794cd9884f2806b7766a1e0bb47ebe5 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 10 Aug 2012 00:13:46 +0100 Subject: [PATCH 17/19] g723.1: deobfuscate an expression (x << 2) - x is just an optimisation of 3 * x the compiler is perfectly capable of doing on its own. Signed-off-by: Mans Rullgard --- libavcodec/g723_1.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c index bf753ab182..c337deb881 100644 --- a/libavcodec/g723_1.c +++ b/libavcodec/g723_1.c @@ -974,8 +974,7 @@ static void formant_postfilter(G723_1_Context *p, int16_t *lpc, int16_t *buf) if (temp) { temp = (auto_corr[0] >> 2) / temp; } - p->reflection_coef = ((p->reflection_coef << 2) - p->reflection_coef + - temp + 2) >> 2; + p->reflection_coef = (3 * p->reflection_coef + temp + 2) >> 2; temp = (p->reflection_coef * 0xffffc >> 3) & 0xfffc; /* Compensation filter */ From 52aa3015a3c895cf74e555c4bb56c08cd067383e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 10 Aug 2012 01:14:32 +0100 Subject: [PATCH 18/19] g723.1: simplify and fix multiplication overflow In 16-bit arithmetic, x * 0xffffc is simply x * -4 with extra overflows, (and the constant was probably meant to be 0xfffc). Combined with the shift, this simplifies to -x >> 1. Finally, clearing the low two bits with a 32-bit mask and switching to a 32-bit type allows more efficient code on 32-bit machines. Signed-off-by: Mans Rullgard --- libavcodec/g723_1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c index c337deb881..53b9adedd4 100644 --- a/libavcodec/g723_1.c +++ b/libavcodec/g723_1.c @@ -956,7 +956,7 @@ static void formant_postfilter(G723_1_Context *p, int16_t *lpc, int16_t *buf) signal_ptr = filter_signal + LPC_ORDER; for (i = 0; i < SUBFRAMES; i++) { int16_t temp_vector[SUBFRAME_LEN]; - int16_t temp; + int temp; int auto_corr[2]; int scale, energy; @@ -975,7 +975,7 @@ static void formant_postfilter(G723_1_Context *p, int16_t *lpc, int16_t *buf) temp = (auto_corr[0] >> 2) / temp; } p->reflection_coef = (3 * p->reflection_coef + temp + 2) >> 2; - temp = (p->reflection_coef * 0xffffc >> 3) & 0xfffc; + temp = -p->reflection_coef >> 1 & ~3; /* Compensation filter */ for (j = 0; j < SUBFRAME_LEN; j++) { From 05c36e0e5fbf0b75dbbbd327ad2f6a62992f9262 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 10 Aug 2012 01:17:20 +0100 Subject: [PATCH 19/19] g723.1: fix addition overflow This addition must be done as 64-bit to avoid overflow and for the subsequent clipping to be meaningful. Signed-off-by: Mans Rullgard --- libavcodec/g723_1.c | 2 +- tests/ref/fate/g723_1-dec-3 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c index 53b9adedd4..7d8a48e18a 100644 --- a/libavcodec/g723_1.c +++ b/libavcodec/g723_1.c @@ -979,7 +979,7 @@ static void formant_postfilter(G723_1_Context *p, int16_t *lpc, int16_t *buf) /* Compensation filter */ for (j = 0; j < SUBFRAME_LEN; j++) { - buf_ptr[j] = av_clipl_int32(signal_ptr[j] + + buf_ptr[j] = av_clipl_int32((int64_t)signal_ptr[j] + ((signal_ptr[j - 1] >> 16) * temp << 1)) >> 16; } diff --git a/tests/ref/fate/g723_1-dec-3 b/tests/ref/fate/g723_1-dec-3 index eabdd738ce..d1a29464e9 100644 --- a/tests/ref/fate/g723_1-dec-3 +++ b/tests/ref/fate/g723_1-dec-3 @@ -13,7 +13,7 @@ 0, 2640, 2640, 240, 480, 0xe253c7e1 0, 2880, 2880, 240, 480, 0x672cbf0a 0, 3120, 3120, 240, 480, 0x5f32aa27 -0, 3360, 3360, 240, 480, 0x8646a245 +0, 3360, 3360, 240, 480, 0x0b3da147 0, 3600, 3600, 240, 480, 0x4819e5bc 0, 3840, 3840, 240, 480, 0x423dec60 0, 4080, 4080, 240, 480, 0xafefe289