From eed691f7d1cacf2c0a44a86a0f034a9524c6edfc Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 27 Mar 2012 14:08:27 -0400 Subject: [PATCH 01/20] oggdec: calculate correct timestamps in Ogg/FLAC We need to parse the individual packet durations when there is more than one packet in a page. --- libavformat/oggparseflac.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c index b1d18ed12d..229cdcb9fa 100644 --- a/libavformat/oggparseflac.c +++ b/libavformat/oggparseflac.c @@ -60,6 +60,7 @@ flac_header (AVFormatContext * s, int idx) st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_FLAC; + st->need_parsing = AVSTREAM_PARSE_HEADERS; st->codec->extradata = av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); From e74d6daa29627c0d28e524579f8aecbb9330daf4 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 27 Mar 2012 12:56:51 -0700 Subject: [PATCH 02/20] fate: add kgv1 fate test. Tested to be bit-exact across x86-64, x86-32 and ppc. --- tests/fate/video.mak | 3 + tests/ref/fate/kgv1 | 314 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 317 insertions(+) create mode 100644 tests/ref/fate/kgv1 diff --git a/tests/fate/video.mak b/tests/fate/video.mak index 5c53c11fca..a676cd10d1 100644 --- a/tests/fate/video.mak +++ b/tests/fate/video.mak @@ -127,6 +127,9 @@ fate-iff-ilbm: CMD = framecrc -i $(SAMPLES)/iff/lms-matriks.ilbm -pix_fmt rgb24 FATE_TESTS += $(FATE_IFF) fate-iff: $(FATE_IFF) +FATE_TESTS += fate-kgv1 +fate-kgv1: CMD = framecrc -i $(SAMPLES)/kega/kgv1.avi -pix_fmt rgb555le -an + FATE_TESTS += fate-kmvc fate-kmvc: CMD = framecrc -i $(SAMPLES)/KMVC/LOGO1.AVI -an -t 3 -pix_fmt rgb24 diff --git a/tests/ref/fate/kgv1 b/tests/ref/fate/kgv1 new file mode 100644 index 0000000000..6f35893f83 --- /dev/null +++ b/tests/ref/fate/kgv1 @@ -0,0 +1,314 @@ +#tb 0: 1/60 +0, 0, 0, 1, 153600, 0x00000000 +0, 1, 1, 1, 153600, 0x00000000 +0, 2, 2, 1, 153600, 0x00000000 +0, 3, 3, 1, 153600, 0x00000000 +0, 4, 4, 1, 153600, 0x00000000 +0, 5, 5, 1, 153600, 0x00000000 +0, 6, 6, 1, 153600, 0x00000000 +0, 7, 7, 1, 153600, 0x00000000 +0, 8, 8, 1, 153600, 0x00000000 +0, 9, 9, 1, 153600, 0x00000000 +0, 10, 10, 1, 153600, 0x00000000 +0, 11, 11, 1, 153600, 0x00000000 +0, 12, 12, 1, 153600, 0x00000000 +0, 13, 13, 1, 153600, 0x00000000 +0, 14, 14, 1, 153600, 0x00000000 +0, 15, 15, 1, 153600, 0x00000000 +0, 16, 16, 1, 153600, 0x00000000 +0, 17, 17, 1, 153600, 0x00000000 +0, 18, 18, 1, 153600, 0x00000000 +0, 19, 19, 1, 153600, 0x00000000 +0, 20, 20, 1, 153600, 0x00000000 +0, 21, 21, 1, 153600, 0x00000000 +0, 22, 22, 1, 153600, 0x00000000 +0, 23, 23, 1, 153600, 0x00000000 +0, 24, 24, 1, 153600, 0x00000000 +0, 25, 25, 1, 153600, 0x00000000 +0, 26, 26, 1, 153600, 0x00000000 +0, 27, 27, 1, 153600, 0x00000000 +0, 28, 28, 1, 153600, 0x00000000 +0, 29, 29, 1, 153600, 0x00000000 +0, 30, 30, 1, 153600, 0x00000000 +0, 31, 31, 1, 153600, 0x00000000 +0, 32, 32, 1, 153600, 0x00000000 +0, 33, 33, 1, 153600, 0x00000000 +0, 34, 34, 1, 153600, 0x00000000 +0, 35, 35, 1, 153600, 0x00000000 +0, 36, 36, 1, 153600, 0x00000000 +0, 37, 37, 1, 153600, 0x00000000 +0, 38, 38, 1, 153600, 0x00000000 +0, 39, 39, 1, 153600, 0x00000000 +0, 40, 40, 1, 153600, 0x00000000 +0, 41, 41, 1, 153600, 0x00000000 +0, 42, 42, 1, 153600, 0x00000000 +0, 43, 43, 1, 153600, 0x00000000 +0, 44, 44, 1, 153600, 0x00000000 +0, 45, 45, 1, 153600, 0x00000000 +0, 46, 46, 1, 153600, 0x00000000 +0, 47, 47, 1, 153600, 0xab738fc1 +0, 48, 48, 1, 153600, 0x520c9bd3 +0, 49, 49, 1, 153600, 0x19347233 +0, 50, 50, 1, 153600, 0x9e81fe64 +0, 51, 51, 1, 153600, 0x75be7504 +0, 52, 52, 1, 153600, 0x29374d04 +0, 53, 53, 1, 153600, 0xc6b92fd4 +0, 54, 54, 1, 153600, 0xeeec5124 +0, 55, 55, 1, 153600, 0x2fc36324 +0, 56, 56, 1, 153600, 0x112580f4 +0, 57, 57, 1, 153600, 0x177b9a84 +0, 58, 58, 1, 153600, 0x214abb44 +0, 59, 59, 1, 153600, 0x83580173 +0, 60, 60, 1, 153600, 0x95f49284 +0, 61, 61, 1, 153600, 0xe31c5984 +0, 62, 62, 1, 153600, 0xf1756984 +0, 63, 63, 1, 153600, 0x6c004804 +0, 64, 64, 1, 153600, 0xbe6631b4 +0, 65, 65, 1, 153600, 0x1d910494 +0, 66, 66, 1, 153600, 0xd8ecfc25 +0, 67, 67, 1, 153600, 0xdd281364 +0, 68, 68, 1, 153600, 0x52545084 +0, 69, 69, 1, 153600, 0xfed6b944 +0, 70, 70, 1, 153600, 0x6e0b7ee4 +0, 71, 71, 1, 153600, 0x516a5724 +0, 72, 72, 1, 153600, 0xaffd7844 +0, 73, 73, 1, 153600, 0x5a304ba4 +0, 74, 74, 1, 153600, 0xea365ce4 +0, 75, 75, 1, 153600, 0xef654a84 +0, 76, 76, 1, 153600, 0x32d14584 +0, 77, 77, 1, 153600, 0x6bf843e4 +0, 78, 78, 1, 153600, 0x023d5b94 +0, 79, 79, 1, 153600, 0xd4506154 +0, 80, 80, 1, 153600, 0xeaf0bd24 +0, 81, 81, 1, 153600, 0x426efb94 +0, 82, 82, 1, 153600, 0x98bcde64 +0, 83, 83, 1, 153600, 0xa1bbb4a4 +0, 84, 84, 1, 153600, 0x36688414 +0, 85, 85, 1, 153600, 0x2e4b75d4 +0, 86, 86, 1, 153600, 0x33885884 +0, 87, 87, 1, 153600, 0x6c065224 +0, 88, 88, 1, 153600, 0x1a0252b4 +0, 89, 89, 1, 153600, 0x55896084 +0, 90, 90, 1, 153600, 0xb9df7a04 +0, 91, 91, 1, 153600, 0x6f8a9734 +0, 92, 92, 1, 153600, 0xa3d3dbb4 +0, 93, 93, 1, 153600, 0x907a2483 +0, 94, 94, 1, 153600, 0xf4816ad3 +0, 95, 95, 1, 153600, 0x4e9195e3 +0, 96, 96, 1, 153600, 0xf486a373 +0, 97, 97, 1, 153600, 0x8f6aa693 +0, 98, 98, 1, 153600, 0x8f6aa693 +0, 99, 99, 1, 153600, 0x8f6aa693 +0, 100, 100, 1, 153600, 0x8f6aa693 +0, 101, 101, 1, 153600, 0x8f6aa693 +0, 102, 102, 1, 153600, 0x8f6aa693 +0, 103, 103, 1, 153600, 0x17d9c117 +0, 104, 104, 1, 153600, 0x17d9c117 +0, 105, 105, 1, 153600, 0x17d9c117 +0, 106, 106, 1, 153600, 0x17d9c117 +0, 107, 107, 1, 153600, 0x17d9c117 +0, 108, 108, 1, 153600, 0x7a47386f +0, 109, 109, 1, 153600, 0x7a47386f +0, 110, 110, 1, 153600, 0x7a47386f +0, 111, 111, 1, 153600, 0x7a47386f +0, 112, 112, 1, 153600, 0x7a47386f +0, 113, 113, 1, 153600, 0x829dccaa +0, 114, 114, 1, 153600, 0x829dccaa +0, 115, 115, 1, 153600, 0x829dccaa +0, 116, 116, 1, 153600, 0x829dccaa +0, 117, 117, 1, 153600, 0x829dccaa +0, 118, 118, 1, 153600, 0x2d58ab4a +0, 119, 119, 1, 153600, 0x2d58ab4a +0, 120, 120, 1, 153600, 0x2d58ab4a +0, 121, 121, 1, 153600, 0x2d58ab4a +0, 122, 122, 1, 153600, 0x2d58ab4a +0, 123, 123, 1, 153600, 0x2d58ab4a +0, 124, 124, 1, 153600, 0x2d58ab4a +0, 125, 125, 1, 153600, 0x2d58ab4a +0, 126, 126, 1, 153600, 0x2d58ab4a +0, 127, 127, 1, 153600, 0x2d58ab4a +0, 128, 128, 1, 153600, 0x2d58ab4a +0, 129, 129, 1, 153600, 0x2d58ab4a +0, 130, 130, 1, 153600, 0x2d58ab4a +0, 131, 131, 1, 153600, 0x2d58ab4a +0, 132, 132, 1, 153600, 0x2d58ab4a +0, 133, 133, 1, 153600, 0x2d58ab4a +0, 134, 134, 1, 153600, 0x2d58ab4a +0, 135, 135, 1, 153600, 0x2d58ab4a +0, 136, 136, 1, 153600, 0x2d58ab4a +0, 137, 137, 1, 153600, 0x2d58ab4a +0, 138, 138, 1, 153600, 0x2d58ab4a +0, 139, 139, 1, 153600, 0x2d58ab4a +0, 140, 140, 1, 153600, 0x2d58ab4a +0, 141, 141, 1, 153600, 0x2d58ab4a +0, 142, 142, 1, 153600, 0x2d58ab4a +0, 143, 143, 1, 153600, 0x2d58ab4a +0, 144, 144, 1, 153600, 0x2d58ab4a +0, 145, 145, 1, 153600, 0x2d58ab4a +0, 146, 146, 1, 153600, 0x2d58ab4a +0, 147, 147, 1, 153600, 0x2d58ab4a +0, 148, 148, 1, 153600, 0x2d58ab4a +0, 149, 149, 1, 153600, 0x2d58ab4a +0, 150, 150, 1, 153600, 0x2d58ab4a +0, 151, 151, 1, 153600, 0x2d58ab4a +0, 152, 152, 1, 153600, 0x2d58ab4a +0, 153, 153, 1, 153600, 0x2d58ab4a +0, 154, 154, 1, 153600, 0x2d58ab4a +0, 155, 155, 1, 153600, 0x2d58ab4a +0, 156, 156, 1, 153600, 0x2d58ab4a +0, 157, 157, 1, 153600, 0x2d58ab4a +0, 158, 158, 1, 153600, 0x2d58ab4a +0, 159, 159, 1, 153600, 0x2d58ab4a +0, 160, 160, 1, 153600, 0x2d58ab4a +0, 161, 161, 1, 153600, 0x2d58ab4a +0, 162, 162, 1, 153600, 0x2d58ab4a +0, 163, 163, 1, 153600, 0x2d58ab4a +0, 164, 164, 1, 153600, 0x2d58ab4a +0, 165, 165, 1, 153600, 0x2d58ab4a +0, 166, 166, 1, 153600, 0x2d58ab4a +0, 167, 167, 1, 153600, 0x2d58ab4a +0, 168, 168, 1, 153600, 0x2d58ab4a +0, 169, 169, 1, 153600, 0x2d58ab4a +0, 170, 170, 1, 153600, 0x2d58ab4a +0, 171, 171, 1, 153600, 0x2d58ab4a +0, 172, 172, 1, 153600, 0x2d58ab4a +0, 173, 173, 1, 153600, 0x2d58ab4a +0, 174, 174, 1, 153600, 0x2d58ab4a +0, 175, 175, 1, 153600, 0x2d58ab4a +0, 176, 176, 1, 153600, 0x2d58ab4a +0, 177, 177, 1, 153600, 0x2d58ab4a +0, 178, 178, 1, 153600, 0x2d58ab4a +0, 179, 179, 1, 153600, 0x2d58ab4a +0, 180, 180, 1, 153600, 0x2d58ab4a +0, 181, 181, 1, 153600, 0x2d58ab4a +0, 182, 182, 1, 153600, 0x2d58ab4a +0, 183, 183, 1, 153600, 0x2d58ab4a +0, 184, 184, 1, 153600, 0x2d58ab4a +0, 185, 185, 1, 153600, 0x2d58ab4a +0, 186, 186, 1, 153600, 0x2d58ab4a +0, 187, 187, 1, 153600, 0x2d58ab4a +0, 188, 188, 1, 153600, 0x2d58ab4a +0, 189, 189, 1, 153600, 0x2d58ab4a +0, 190, 190, 1, 153600, 0x2d58ab4a +0, 191, 191, 1, 153600, 0x2d58ab4a +0, 192, 192, 1, 153600, 0x2d58ab4a +0, 193, 193, 1, 153600, 0x2d58ab4a +0, 194, 194, 1, 153600, 0x2d58ab4a +0, 195, 195, 1, 153600, 0x2d58ab4a +0, 196, 196, 1, 153600, 0x2d58ab4a +0, 197, 197, 1, 153600, 0x2d58ab4a +0, 198, 198, 1, 153600, 0x2d58ab4a +0, 199, 199, 1, 153600, 0x2d58ab4a +0, 200, 200, 1, 153600, 0x2d58ab4a +0, 201, 201, 1, 153600, 0x2d58ab4a +0, 202, 202, 1, 153600, 0x2d58ab4a +0, 203, 203, 1, 153600, 0x2d58ab4a +0, 204, 204, 1, 153600, 0x2d58ab4a +0, 205, 205, 1, 153600, 0x2d58ab4a +0, 206, 206, 1, 153600, 0x2d58ab4a +0, 207, 207, 1, 153600, 0x2d58ab4a +0, 208, 208, 1, 153600, 0x2d58ab4a +0, 209, 209, 1, 153600, 0x2d58ab4a +0, 210, 210, 1, 153600, 0x2d58ab4a +0, 211, 211, 1, 153600, 0x2d58ab4a +0, 212, 212, 1, 153600, 0x2d58ab4a +0, 213, 213, 1, 153600, 0x2d58ab4a +0, 214, 214, 1, 153600, 0x2d58ab4a +0, 215, 215, 1, 153600, 0x2d58ab4a +0, 216, 216, 1, 153600, 0x2d58ab4a +0, 217, 217, 1, 153600, 0x2d58ab4a +0, 218, 218, 1, 153600, 0x2d58ab4a +0, 219, 219, 1, 153600, 0x2d58ab4a +0, 220, 220, 1, 153600, 0x2d58ab4a +0, 221, 221, 1, 153600, 0x2d58ab4a +0, 222, 222, 1, 153600, 0x2d58ab4a +0, 223, 223, 1, 153600, 0x2d58ab4a +0, 224, 224, 1, 153600, 0x2d58ab4a +0, 225, 225, 1, 153600, 0x2d58ab4a +0, 226, 226, 1, 153600, 0x2d58ab4a +0, 227, 227, 1, 153600, 0x2d58ab4a +0, 228, 228, 1, 153600, 0x2d58ab4a +0, 229, 229, 1, 153600, 0x2d58ab4a +0, 230, 230, 1, 153600, 0x2d58ab4a +0, 231, 231, 1, 153600, 0x2d58ab4a +0, 232, 232, 1, 153600, 0x2d58ab4a +0, 233, 233, 1, 153600, 0x2d58ab4a +0, 234, 234, 1, 153600, 0x2d58ab4a +0, 235, 235, 1, 153600, 0x2d58ab4a +0, 236, 236, 1, 153600, 0x2d58ab4a +0, 237, 237, 1, 153600, 0x2d58ab4a +0, 238, 238, 1, 153600, 0x2d58ab4a +0, 239, 239, 1, 153600, 0x2d58ab4a +0, 240, 240, 1, 153600, 0x2d58ab4a +0, 241, 241, 1, 153600, 0x2d58ab4a +0, 242, 242, 1, 153600, 0x2d58ab4a +0, 243, 243, 1, 153600, 0x2d58ab4a +0, 244, 244, 1, 153600, 0x2d58ab4a +0, 245, 245, 1, 153600, 0x2d58ab4a +0, 246, 246, 1, 153600, 0x2d58ab4a +0, 247, 247, 1, 153600, 0x2d58ab4a +0, 248, 248, 1, 153600, 0x2d58ab4a +0, 249, 249, 1, 153600, 0x2d58ab4a +0, 250, 250, 1, 153600, 0x2d58ab4a +0, 251, 251, 1, 153600, 0x2d58ab4a +0, 252, 252, 1, 153600, 0x2d58ab4a +0, 253, 253, 1, 153600, 0x2d58ab4a +0, 254, 254, 1, 153600, 0x2d58ab4a +0, 255, 255, 1, 153600, 0x2d58ab4a +0, 256, 256, 1, 153600, 0x2d58ab4a +0, 257, 257, 1, 153600, 0x2d58ab4a +0, 258, 258, 1, 153600, 0x2d58ab4a +0, 259, 259, 1, 153600, 0x2d58ab4a +0, 260, 260, 1, 153600, 0x2d58ab4a +0, 261, 261, 1, 153600, 0x2d58ab4a +0, 262, 262, 1, 153600, 0x2d58ab4a +0, 263, 263, 1, 153600, 0x2d58ab4a +0, 264, 264, 1, 153600, 0x2d58ab4a +0, 265, 265, 1, 153600, 0x2d58ab4a +0, 266, 266, 1, 153600, 0x2d58ab4a +0, 267, 267, 1, 153600, 0x2d58ab4a +0, 268, 268, 1, 153600, 0x2d58ab4a +0, 269, 269, 1, 153600, 0x2d58ab4a +0, 270, 270, 1, 153600, 0x2d58ab4a +0, 271, 271, 1, 153600, 0x2d58ab4a +0, 272, 272, 1, 153600, 0x2d58ab4a +0, 273, 273, 1, 153600, 0x2d58ab4a +0, 274, 274, 1, 153600, 0x2d58ab4a +0, 275, 275, 1, 153600, 0x2d58ab4a +0, 276, 276, 1, 153600, 0x2d58ab4a +0, 277, 277, 1, 153600, 0x2d58ab4a +0, 278, 278, 1, 153600, 0x2d58ab4a +0, 279, 279, 1, 153600, 0x2d58ab4a +0, 280, 280, 1, 153600, 0x2d58ab4a +0, 281, 281, 1, 153600, 0x2d58ab4a +0, 282, 282, 1, 153600, 0x2d58ab4a +0, 283, 283, 1, 153600, 0x2d58ab4a +0, 284, 284, 1, 153600, 0x7815bb72 +0, 285, 285, 1, 153600, 0x47ec1353 +0, 286, 286, 1, 153600, 0x6599fabc +0, 287, 287, 1, 153600, 0x3d8a8690 +0, 288, 288, 1, 153600, 0xc0bc1ba5 +0, 289, 289, 1, 153600, 0x07368f2a +0, 290, 290, 1, 153600, 0x81c54b89 +0, 291, 291, 1, 153600, 0xbfcae7bf +0, 292, 292, 1, 153600, 0x1348310e +0, 293, 293, 1, 153600, 0xb5489dad +0, 294, 294, 1, 153600, 0xa1eb1408 +0, 295, 295, 1, 153600, 0x15e1832c +0, 296, 296, 1, 153600, 0xb789cba5 +0, 297, 297, 1, 153600, 0x3ee86e4f +0, 298, 298, 1, 153600, 0x06ea3883 +0, 299, 299, 1, 153600, 0xcedd02b7 +0, 300, 300, 1, 153600, 0xbce6ce58 +0, 301, 301, 1, 153600, 0xaadf9a00 +0, 302, 302, 1, 153600, 0x98c865a0 +0, 303, 303, 1, 153600, 0x4c8432e0 +0, 304, 304, 1, 153600, 0x00000000 +0, 305, 305, 1, 153600, 0x00000000 +0, 306, 306, 1, 153600, 0x00000000 +0, 307, 307, 1, 153600, 0x00000000 +0, 308, 308, 1, 153600, 0x00000000 +0, 309, 309, 1, 153600, 0x00000000 +0, 310, 310, 1, 153600, 0x00000000 +0, 311, 311, 1, 153600, 0x00000000 +0, 312, 312, 1, 153600, 0x00000000 From e2e165c00fa0dd45d2fa9a0863190f112accd387 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 26 Mar 2012 20:53:10 +0200 Subject: [PATCH 03/20] FATE: add a test for vp8 with changing frame size. --- tests/fate/vpx.mak | 4 ++++ tests/ref/fate/vp8-size-change | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/ref/fate/vp8-size-change diff --git a/tests/fate/vpx.mak b/tests/fate/vpx.mak index 1560fe9d68..d7b2f22dd3 100644 --- a/tests/fate/vpx.mak +++ b/tests/fate/vpx.mak @@ -38,6 +38,10 @@ $(foreach N,$(VP8_SUITE),$(eval $(call FATE_VP8_SUITE,$(N),$(1),$(2)))) FATE_VP8 += fate-vp8-sign-bias$(1) fate-vp8-sign-bias$(1): CMD = framemd5 $(2) -i $(SAMPLES)/vp8/sintel-signbias.ivf fate-vp8-sign-bias$(1): REF = $(SRC_PATH)/tests/ref/fate/vp8-sign-bias + +FATE_VP8 += fate-vp8-size-change$(1) +fate-vp8-size-change$(1): CMD = framemd5 $(2) -i $(SAMPLES)/vp8/frame_size_change.webm -frames:v 30 +fate-vp8-size-change$(1): REF = $(SRC_PATH)/tests/ref/fate/vp8-size-change endef $(eval $(call FATE_VP8_FULL)) diff --git a/tests/ref/fate/vp8-size-change b/tests/ref/fate/vp8-size-change new file mode 100644 index 0000000000..d87c563b7d --- /dev/null +++ b/tests/ref/fate/vp8-size-change @@ -0,0 +1,31 @@ +#tb 0: 1/1000 +0, 0, 0, 0, 3110400, 649f0f2e3e09e6938161bb07bede5282 +0, 33, 33, 0, 3110400, f24f632d50eafef73fa89391ca98c375 +0, 67, 67, 0, 3110400, 57b6d2ed51bfaf6588f39eb73e7922b8 +0, 100, 100, 0, 3110400, 463e0988ce28eb1c30669c06113deb4c +0, 133, 133, 0, 3110400, 3c4ac119f998a0ccd7d3a6361f4d10a0 +0, 167, 167, 0, 3110400, 0f11c5cc9c1ac9055e21e417e1259c69 +0, 200, 200, 0, 3110400, 08c6e70f101c61013f2969b6a370d3f9 +0, 233, 233, 0, 3110400, ea8cb37017d8a9d20bf443b730fd8365 +0, 267, 267, 0, 3110400, 3f614203f054c89151680f4b1b0c6c4c +0, 300, 300, 0, 3110400, 90488ee40d06c0f05eee8348dde57325 +0, 333, 333, 0, 3110400, f48117b74ac7455e69fd14e9b68ce95d +0, 367, 367, 0, 3110400, 37ee06b6267b5ec25fd642525cf4469a +0, 400, 400, 0, 3110400, cd5e0988e7c084f29bda4a18cb38c1e8 +0, 433, 433, 0, 3110400, 1fe943b01f00b8bc0cb5722010cef03c +0, 467, 467, 0, 3110400, 40d8e8150326c7eb061d3f6cfd307d97 +0, 500, 500, 0, 3110400, 49812cbf928858cb56331c8c8aaaf556 +0, 533, 533, 0, 3110400, 3df607c752273ebcac21123e2c4c010c +0, 567, 567, 0, 3110400, 020a0ae162c8326f83f8f4d8bf1627d2 +0, 600, 600, 0, 3110400, 459ac9f9488a6a2f4e378703a6b2a45a +0, 633, 633, 0, 3110400, b1baf9a56f7667e4b8f4e3007b9ebe0f +0, 667, 667, 0, 3110400, eea61a72a05c380450a96b575ba25f65 +0, 700, 700, 0, 3110400, e013a9f233824631d8c6e3f93106eebe +0, 733, 733, 0, 3110400, 6c64147ebdee4b36728c6978b290ffb5 +0, 767, 767, 0, 3110400, c37956235667345d92fdfc7c62496e84 +0, 800, 800, 0, 3110400, 0ac58c28575b804d9e63395653c3aef2 +0, 833, 833, 0, 3110400, 641f2a78e338c733ef159bd36ec7966f +0, 867, 867, 0, 3110400, 9402d455fa5bd556b85f479c42c3a4d2 +0, 900, 900, 0, 3110400, ca86e16b05db0c79b028d709c19e1f13 +0, 933, 933, 0, 3110400, 9167d622809df07eef9bcb3cb09de0f0 +0, 967, 967, 0, 3110400, e1d52ae2a2eb6aabb9bdc7e7ed05253e From 3c6607eb6f946ed3e108db3f0694cab7e5a5df7e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 27 Mar 2012 08:21:02 +0200 Subject: [PATCH 04/20] avcodec_encode_{audio,video}: only reallocate output packet when it has non-zero size. Otherwise realloc would free it, which would result in double free later. --- libavcodec/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 7d50bd51d0..aa0f5b6d86 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -960,7 +960,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, avctx->frame_size = fs_tmp; } if (!ret) { - if (!user_packet && avpkt->data) { + if (!user_packet && avpkt->size) { uint8_t *new_data = av_realloc(avpkt->data, avpkt->size); if (new_data) avpkt->data = new_data; @@ -1123,7 +1123,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, else if (!(avctx->codec->capabilities & CODEC_CAP_DELAY)) avpkt->pts = avpkt->dts = frame->pts; - if (!user_packet && avpkt->data) { + if (!user_packet && avpkt->size) { uint8_t *new_data = av_realloc(avpkt->data, avpkt->size); if (new_data) avpkt->data = new_data; From a839dbb94ed9244a1678339dbb05355d8257a126 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 26 Mar 2012 13:02:54 +0200 Subject: [PATCH 05/20] dvenc: print allowed profiles if the video doesn't conform to any of them. --- libavcodec/dv.c | 6 ++++-- libavcodec/dvdata.c | 12 ++++++++++++ libavcodec/dvdata.h | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index aba94eba4f..83b6960f38 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -323,9 +323,11 @@ av_cold int ff_dvvideo_init(AVCodecContext *avctx) static av_cold int dvvideo_init_encoder(AVCodecContext *avctx) { if (!avpriv_dv_codec_profile(avctx)) { - av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video\n", + av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. " + "Valid DV profiles are:\n", avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt)); - return -1; + ff_dv_print_profiles(avctx, AV_LOG_ERROR); + return AVERROR(EINVAL); } return ff_dvvideo_init(avctx); diff --git a/libavcodec/dvdata.c b/libavcodec/dvdata.c index 1d32304edf..6d123a9741 100644 --- a/libavcodec/dvdata.c +++ b/libavcodec/dvdata.c @@ -25,6 +25,7 @@ */ #include "libavutil/rational.h" +#include "libavutil/pixdesc.h" #include "avcodec.h" #include "dvdata.h" @@ -322,3 +323,14 @@ const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec) return NULL; } + +void ff_dv_print_profiles(void *logctx, int loglevel) +{ + int i; + for (i = 0; i < FF_ARRAY_ELEMS(dv_profiles); i++) { + const DVprofile *p = &dv_profiles[i]; + av_log(logctx, loglevel, "Frame size: %dx%d; pixel format: %s, " + "framerate: %d/%d\n", p->width, p->height, av_get_pix_fmt_name(p->pix_fmt), + p->time_base.den, p->time_base.num); + } +} diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h index 8544d61a58..8b4811ac69 100644 --- a/libavcodec/dvdata.h +++ b/libavcodec/dvdata.h @@ -154,4 +154,9 @@ static inline void dv_calculate_mb_xy(DVVideoContext *s, DVwork_chunk *work_chun } } +/** + * Print all allowed DV profiles into logctx at specified logging level. + */ +void ff_dv_print_profiles(void *logctx, int loglevel); + #endif /* AVCODEC_DVDATA_H */ From 856c8e0a049dc7069b7504d3aaa48549c75852de Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 27 Mar 2012 16:42:23 +0200 Subject: [PATCH 06/20] faandct: Remove FAAN_POSTSCALE define and related code. It is not a user-accessible option and unlikely to ever be changed. --- libavcodec/dct-test.c | 8 +------- libavcodec/faandct.c | 37 ++++++++++++++++--------------------- libavcodec/faandct.h | 2 -- libavcodec/mpegvideo_enc.c | 25 +++++-------------------- 4 files changed, 22 insertions(+), 50 deletions(-) diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index 1787ef668a..bc5f2c5aaa 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -74,17 +74,11 @@ struct algo { int nonspec; }; -#ifndef FAAN_POSTSCALE -#define FAAN_SCALE SCALE_PERM -#else -#define FAAN_SCALE NO_PERM -#endif - static int cpu_flags; static const struct algo fdct_tab[] = { { "REF-DBL", ff_ref_fdct, NO_PERM }, - { "FAAN", ff_faandct, FAAN_SCALE }, + { "FAAN", ff_faandct, NO_PERM }, { "IJG-AAN-INT", ff_fdct_ifast, SCALE_PERM }, { "IJG-LLM-INT", ff_jpeg_fdct_islow_8, NO_PERM }, diff --git a/libavcodec/faandct.c b/libavcodec/faandct.c index a986f65440..eaf4b65f41 100644 --- a/libavcodec/faandct.c +++ b/libavcodec/faandct.c @@ -29,11 +29,6 @@ #include "faandct.h" #define FLOAT float -#ifdef FAAN_POSTSCALE -# define SCALE(x) postscale[x] -#else -# define SCALE(x) 1 -#endif //numbers generated by simple c code (not as accurate as they could be) /* @@ -150,13 +145,13 @@ void ff_faandct(DCTELEM * data) tmp11= tmp1 + tmp2; tmp12= tmp1 - tmp2; - data[8*0 + i]= lrintf(SCALE(8*0 + i) * (tmp10 + tmp11)); - data[8*4 + i]= lrintf(SCALE(8*4 + i) * (tmp10 - tmp11)); + data[8*0 + i]= lrintf(postscale[8*0 + i] * (tmp10 + tmp11)); + data[8*4 + i]= lrintf(postscale[8*4 + i] * (tmp10 - tmp11)); tmp12 += tmp13; tmp12 *= A1; - data[8*2 + i]= lrintf(SCALE(8*2 + i) * (tmp13 + tmp12)); - data[8*6 + i]= lrintf(SCALE(8*6 + i) * (tmp13 - tmp12)); + data[8*2 + i]= lrintf(postscale[8*2 + i] * (tmp13 + tmp12)); + data[8*6 + i]= lrintf(postscale[8*6 + i] * (tmp13 - tmp12)); tmp4 += tmp5; tmp5 += tmp6; @@ -175,10 +170,10 @@ void ff_faandct(DCTELEM * data) z11= tmp7 + tmp5; z13= tmp7 - tmp5; - data[8*5 + i]= lrintf(SCALE(8*5 + i) * (z13 + z2)); - data[8*3 + i]= lrintf(SCALE(8*3 + i) * (z13 - z2)); - data[8*1 + i]= lrintf(SCALE(8*1 + i) * (z11 + z4)); - data[8*7 + i]= lrintf(SCALE(8*7 + i) * (z11 - z4)); + data[8*5 + i]= lrintf(postscale[8*5 + i] * (z13 + z2)); + data[8*3 + i]= lrintf(postscale[8*3 + i] * (z13 - z2)); + data[8*1 + i]= lrintf(postscale[8*1 + i] * (z11 + z4)); + data[8*7 + i]= lrintf(postscale[8*7 + i] * (z11 - z4)); } } @@ -208,25 +203,25 @@ void ff_faandct248(DCTELEM * data) tmp12 = tmp1 - tmp2; tmp13 = tmp0 - tmp3; - data[8*0 + i] = lrintf(SCALE(8*0 + i) * (tmp10 + tmp11)); - data[8*4 + i] = lrintf(SCALE(8*4 + i) * (tmp10 - tmp11)); + data[8*0 + i] = lrintf(postscale[8*0 + i] * (tmp10 + tmp11)); + data[8*4 + i] = lrintf(postscale[8*4 + i] * (tmp10 - tmp11)); tmp12 += tmp13; tmp12 *= A1; - data[8*2 + i] = lrintf(SCALE(8*2 + i) * (tmp13 + tmp12)); - data[8*6 + i] = lrintf(SCALE(8*6 + i) * (tmp13 - tmp12)); + data[8*2 + i] = lrintf(postscale[8*2 + i] * (tmp13 + tmp12)); + data[8*6 + i] = lrintf(postscale[8*6 + i] * (tmp13 - tmp12)); tmp10 = tmp4 + tmp7; tmp11 = tmp5 + tmp6; tmp12 = tmp5 - tmp6; tmp13 = tmp4 - tmp7; - data[8*1 + i] = lrintf(SCALE(8*0 + i) * (tmp10 + tmp11)); - data[8*5 + i] = lrintf(SCALE(8*4 + i) * (tmp10 - tmp11)); + data[8*1 + i] = lrintf(postscale[8*0 + i] * (tmp10 + tmp11)); + data[8*5 + i] = lrintf(postscale[8*4 + i] * (tmp10 - tmp11)); tmp12 += tmp13; tmp12 *= A1; - data[8*3 + i] = lrintf(SCALE(8*2 + i) * (tmp13 + tmp12)); - data[8*7 + i] = lrintf(SCALE(8*6 + i) * (tmp13 - tmp12)); + data[8*3 + i] = lrintf(postscale[8*2 + i] * (tmp13 + tmp12)); + data[8*7 + i] = lrintf(postscale[8*6 + i] * (tmp13 - tmp12)); } } diff --git a/libavcodec/faandct.h b/libavcodec/faandct.h index da8c0e42d9..cd9823618b 100644 --- a/libavcodec/faandct.h +++ b/libavcodec/faandct.h @@ -31,8 +31,6 @@ #include "dsputil.h" -#define FAAN_POSTSCALE - void ff_faandct(DCTELEM * data); void ff_faandct248(DCTELEM * data); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 7074ddaeec..19aa4b45fc 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -79,11 +79,8 @@ void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], for (qscale = qmin; qscale <= qmax; qscale++) { int i; if (dsp->fdct == ff_jpeg_fdct_islow_8 || - dsp->fdct == ff_jpeg_fdct_islow_10 -#ifdef FAAN_POSTSCALE - || dsp->fdct == ff_faandct -#endif - ) { + dsp->fdct == ff_jpeg_fdct_islow_10 || + dsp->fdct == ff_faandct) { for (i = 0; i < 64; i++) { const int j = dsp->idct_permutation[i]; /* 16 <= qscale * quant_matrix[i] <= 7905 @@ -95,11 +92,7 @@ void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j])); } - } else if (dsp->fdct == ff_fdct_ifast -#ifndef FAAN_POSTSCALE - || dsp->fdct == ff_faandct -#endif - ) { + } else if (dsp->fdct == ff_fdct_ifast) { for (i = 0; i < 64; i++) { const int j = dsp->idct_permutation[i]; /* 16 <= qscale * quant_matrix[i] <= 7905 @@ -138,11 +131,7 @@ void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], for (i = intra; i < 64; i++) { int64_t max = 8191; - if (dsp->fdct == ff_fdct_ifast -#ifndef FAAN_POSTSCALE - || dsp->fdct == ff_faandct -#endif - ) { + if (dsp->fdct == ff_fdct_ifast) { max = (8191LL * ff_aanscales[i]) >> 14; } while (((max * qmat[qscale][i]) >> shift) > INT_MAX) { @@ -3474,11 +3463,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s, int dct_coeff= FFABS(block[ scantable[i] ]); int best_score=256*256*256*120; - if ( s->dsp.fdct == ff_fdct_ifast -#ifndef FAAN_POSTSCALE - || s->dsp.fdct == ff_faandct -#endif - ) + if (s->dsp.fdct == ff_fdct_ifast) dct_coeff= (dct_coeff*ff_inv_aanscales[ scantable[i] ]) >> 12; zero_distortion= dct_coeff*dct_coeff; From a92be9b856bd11b081041c43c25d442028fe9a63 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 6 Jun 2011 14:13:02 +0200 Subject: [PATCH 07/20] Replace memset(0) by zero initializations. Also remove one pointless zero initialization in rangecoder.c. --- avplay.c | 3 +-- avserver.c | 9 +++------ libavcodec/4xm.c | 6 ++---- libavcodec/aaccoder.c | 3 +-- libavcodec/aacpsy.c | 6 ++---- libavcodec/ac3dec.c | 4 +--- libavcodec/alsdec.c | 11 +++-------- libavcodec/bink.c | 3 +-- libavcodec/cook.c | 20 ++++++-------------- libavcodec/dvdsubdec.c | 6 ++---- libavcodec/dxva2.c | 3 +-- libavcodec/flac_parser.c | 3 +-- libavcodec/intrax8dsp.c | 6 ++---- libavcodec/jpeglsenc.c | 3 +-- libavcodec/libxvid_rc.c | 9 +++------ libavcodec/libxvidff.c | 21 +++++++-------------- libavcodec/mjpegdec.c | 3 +-- libavcodec/motion_est.c | 3 +-- libavcodec/mpegaudiodec.c | 7 ++----- libavcodec/ra144enc.c | 3 +-- libavcodec/rangecoder.c | 2 +- libavcodec/rv34.c | 5 +---- libavcodec/smacker.c | 11 +++-------- libavcodec/tiff.c | 3 +-- libavcodec/truemotion1.c | 3 +-- libavcodec/wmaprodec.c | 4 +--- libavcodec/wmavoice.c | 3 +-- libavdevice/bktr.c | 3 +-- libavformat/asfcrypt.c | 3 +-- libavformat/movenc.c | 3 +-- libavformat/rtsp.c | 9 +++------ libavformat/sapenc.c | 3 +-- libavformat/sdp.c | 6 ++---- libavformat/seek-test.c | 3 +-- libavformat/tcp.c | 3 +-- libavformat/udp.c | 3 +-- libavformat/utils.c | 3 +-- libavutil/imgutils.c | 4 +--- libavutil/parseutils.c | 4 +--- 39 files changed, 66 insertions(+), 144 deletions(-) diff --git a/avplay.c b/avplay.c index beb8dd152e..d9c178604f 100644 --- a/avplay.c +++ b/avplay.c @@ -1371,7 +1371,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t /* if the frame is not skipped, then display it */ if (vp->bmp) { - AVPicture pict; + AVPicture pict = { { 0 } }; #if CONFIG_AVFILTER if (vp->picref) avfilter_unref_buffer(vp->picref); @@ -1381,7 +1381,6 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t /* get a pointer on the bitmap */ SDL_LockYUVOverlay (vp->bmp); - memset(&pict, 0, sizeof(AVPicture)); pict.data[0] = vp->bmp->pixels[0]; pict.data[1] = vp->bmp->pixels[2]; pict.data[2] = vp->bmp->pixels[1]; diff --git a/avserver.c b/avserver.c index 4df8a3e8a4..2b16932ab1 100644 --- a/avserver.c +++ b/avserver.c @@ -335,8 +335,7 @@ static int resolve_host(struct in_addr *sin_addr, const char *hostname) if (!ff_inet_aton(hostname, sin_addr)) { #if HAVE_GETADDRINFO struct addrinfo *ai, *cur; - struct addrinfo hints; - memset(&hints, 0, sizeof(hints)); + struct addrinfo hints = { 0 }; hints.ai_family = AF_INET; if (getaddrinfo(hostname, NULL, &hints, &ai)) return -1; @@ -2822,7 +2821,7 @@ static int rtsp_parse_request(HTTPContext *c) char protocol[32]; char line[1024]; int len; - RTSPMessageHeader header1, *header = &header1; + RTSPMessageHeader header1 = { 0 }, *header = &header1; c->buffer_ptr[0] = '\0'; p = c->buffer; @@ -2848,7 +2847,6 @@ static int rtsp_parse_request(HTTPContext *c) } /* parse each header line */ - memset(header, 0, sizeof(*header)); /* skip to next line */ while (*p != '\n' && *p != '\0') p++; @@ -4647,7 +4645,7 @@ static const OptionDef options[] = { int main(int argc, char **argv) { - struct sigaction sigact; + struct sigaction sigact = { { 0 } }; parse_loglevel(argc, argv, options); av_register_all(); @@ -4665,7 +4663,6 @@ int main(int argc, char **argv) av_lfg_init(&random_state, av_get_random_seed()); - memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit; sigact.sa_flags = SA_NOCLDSTOP | SA_RESTART; sigaction(SIGCHLD, &sigact, 0); diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 139a642a47..8cc5592c73 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -552,7 +552,7 @@ static int decode_i_mb(FourXContext *f) static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t * const buf) { - int frequency[512]; + int frequency[512] = { 0 }; uint8_t flag[512]; int up[512]; uint8_t len_tab[257]; @@ -561,7 +561,6 @@ static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t *ptr = buf; int j; - memset(frequency, 0, sizeof(frequency)); memset(up, -1, sizeof(up)); start = *ptr++; @@ -661,8 +660,7 @@ static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length) for (y = 0; y < height; y += 16) { for (x = 0; x < width; x += 16) { - unsigned int color[4], bits; - memset(color, 0, sizeof(color)); + unsigned int color[4] = { 0 }, bits; // warning following is purely guessed ... color[0] = bytestream2_get_le16u(&g3); color[1] = bytestream2_get_le16u(&g3); diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 72be2a272b..36a49a7538 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -714,7 +714,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, { int start = 0, i, w, w2, g; int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels; - float dists[128], uplims[128]; + float dists[128] = { 0 }, uplims[128]; float maxvals[128]; int fflag, minscaler; int its = 0; @@ -722,7 +722,6 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, float minthr = INFINITY; //XXX: some heuristic to determine initial quantizers will reduce search time - memset(dists, 0, sizeof(dists)); //determine zero bands and upper limits for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (g = 0; g < sce->ics.num_swb; g++) { diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index 8ee393ad1d..42db471428 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -389,9 +389,8 @@ static av_unused FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx, AacPsyChannel *pch = &pctx->ch[channel]; uint8_t grouping = 0; int next_type = pch->next_window_seq; - FFPsyWindowInfo wi; + FFPsyWindowInfo wi = { { 0 } }; - memset(&wi, 0, sizeof(wi)); if (la) { float s[8], v; int switch_to_eight = 0; @@ -785,9 +784,8 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio, int uselongblock = 1; int attacks[AAC_NUM_BLOCKS_SHORT + 1] = { 0 }; int i; - FFPsyWindowInfo wi; + FFPsyWindowInfo wi = { { 0 } }; - memset(&wi, 0, sizeof(wi)); if (la) { float hpfsmpl[AAC_BLOCK_SIZE_LONG]; float const *pf = hpfsmpl; diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index a8bc48ab6e..3056403dcf 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -753,9 +753,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) int downmix_output; int cpl_in_use; GetBitContext *gbc = &s->gbc; - uint8_t bit_alloc_stages[AC3_MAX_CHANNELS]; - - memset(bit_alloc_stages, 0, AC3_MAX_CHANNELS); + uint8_t bit_alloc_stages[AC3_MAX_CHANNELS] = { 0 }; /* block switch flags */ different_transforms = 0; diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 1b916e4ff2..35952ae21f 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -1026,9 +1026,7 @@ static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame, unsigned int *js_blocks) { unsigned int b; - ALSBlockData bd; - - memset(&bd, 0, sizeof(ALSBlockData)); + ALSBlockData bd = { 0 }; bd.ra_block = ra_frame; bd.const_block = ctx->const_block; @@ -1069,9 +1067,7 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame, ALSSpecificConfig *sconf = &ctx->sconf; unsigned int offset = 0; unsigned int b; - ALSBlockData bd[2]; - - memset(bd, 0, 2 * sizeof(ALSBlockData)); + ALSBlockData bd[2] = { { 0 } }; bd[0].ra_block = ra_frame; bd[0].const_block = ctx->const_block; @@ -1337,7 +1333,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) sizeof(*ctx->raw_samples[c]) * sconf->max_order); } } else { // multi-channel coding - ALSBlockData bd; + ALSBlockData bd = { 0 }; int b; int *reverted_channels = ctx->reverted_channels; unsigned int offset = 0; @@ -1348,7 +1344,6 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) return -1; } - memset(&bd, 0, sizeof(ALSBlockData)); memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels); bd.ra_block = ra_frame; diff --git a/libavcodec/bink.c b/libavcodec/bink.c index 4e9b1a8ca2..47f4b72733 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -233,7 +233,7 @@ static void merge(GetBitContext *gb, uint8_t *dst, uint8_t *src, int size) */ static void read_tree(GetBitContext *gb, Tree *tree) { - uint8_t tmp1[16], tmp2[16], *in = tmp1, *out = tmp2; + uint8_t tmp1[16] = { 0 }, tmp2[16], *in = tmp1, *out = tmp2; int i, t, len; tree->vlc_num = get_bits(gb, 4); @@ -244,7 +244,6 @@ static void read_tree(GetBitContext *gb, Tree *tree) } if (get_bits1(gb)) { len = get_bits(gb, 3); - memset(tmp1, 0, sizeof(tmp1)); for (i = 0; i <= len; i++) { tree->syms[i] = get_bits(gb, 4); tmp1[tree->syms[i]] = 1; diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 74378521b3..217abcf117 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -411,10 +411,10 @@ static void categorize(COOKContext *q, COOKSubpacket *p, int *quant_index_table, int *category, int *category_index) { int exp_idx, bias, tmpbias1, tmpbias2, bits_left, num_bits, index, v, i, j; - int exp_index2[102]; - int exp_index1[102]; + int exp_index2[102] = { 0 }; + int exp_index1[102] = { 0 }; - int tmp_categorize_array[128 * 2]; + int tmp_categorize_array[128 * 2] = { 0 }; int tmp_categorize_array1_idx = p->numvector_size; int tmp_categorize_array2_idx = p->numvector_size; @@ -426,10 +426,6 @@ static void categorize(COOKContext *q, COOKSubpacket *p, int *quant_index_table, //av_log(q->avctx, AV_LOG_ERROR, "bits_left = %d\n",bits_left); } - memset(&exp_index1, 0, sizeof(exp_index1)); - memset(&exp_index2, 0, sizeof(exp_index2)); - memset(&tmp_categorize_array, 0, sizeof(tmp_categorize_array)); - bias = -32; /* Estimate bias. */ @@ -649,14 +645,11 @@ static void decode_vectors(COOKContext *q, COOKSubpacket *p, int *category, */ static int mono_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer) { - int category_index[128]; + int category_index[128] = { 0 }; + int category[128] = { 0 }; int quant_index_table[102]; - int category[128]; int res; - memset(&category, 0, sizeof(category)); - memset(&category_index, 0, sizeof(category_index)); - if ((res = decode_envelope(q, p, quant_index_table)) < 0) return res; q->num_vectors = get_bits(&q->gb, p->log2_numvector_size); @@ -818,13 +811,12 @@ static int joint_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer1, float *mlt_buffer2) { int i, j, res; - int decouple_tab[SUBBAND_SIZE]; + int decouple_tab[SUBBAND_SIZE] = { 0 }; float *decode_buffer = q->decode_buffer_0; int idx, cpl_tmp; float f1, f2; const float *cplscale; - memset(decouple_tab, 0, sizeof(decouple_tab)); memset(decode_buffer, 0, sizeof(q->decode_buffer_0)); /* Make sure the buffers are zeroed out. */ diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index ee9331cabe..83e71d1238 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -120,13 +120,12 @@ static void guess_palette(uint32_t *rgba_palette, uint8_t *alpha, uint32_t subtitle_color) { - uint8_t color_used[16]; + uint8_t color_used[16] = { 0 }; int nb_opaque_colors, i, level, j, r, g, b; for(i = 0; i < 4; i++) rgba_palette[i] = 0; - memset(color_used, 0, 16); nb_opaque_colors = 0; for(i = 0; i < 4; i++) { if (alpha[i] != 0 && !color_used[colormap[i]]) { @@ -371,14 +370,13 @@ static int is_transp(const uint8_t *buf, int pitch, int n, /* return 0 if empty rectangle, 1 if non empty */ static int find_smallest_bounding_rectangle(AVSubtitle *s) { - uint8_t transp_color[256]; + uint8_t transp_color[256] = { 0 }; int y1, y2, x1, x2, y, w, h, i; uint8_t *bitmap; if (s->num_rects == 0 || s->rects == NULL || s->rects[0]->w <= 0 || s->rects[0]->h <= 0) return 0; - memset(transp_color, 0, 256); for(i = 0; i < s->rects[0]->nb_colors; i++) { if ((((uint32_t*)s->rects[0]->pict.data[1])[i] >> 24) == 0) transp_color[i] = 1; diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index d7d893c457..71c8405feb 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -86,7 +86,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, MpegEncContext *s, struct dxva_context *ctx = avctx->hwaccel_context; unsigned buffer_count = 0; DXVA2_DecodeBufferDesc buffer[4]; - DXVA2_DecodeExecuteParams exec; + DXVA2_DecodeExecuteParams exec = { 0 }; int result; if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder, @@ -132,7 +132,6 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, MpegEncContext *s, assert(buffer_count == 1 + (qm_size > 0) + 2); - memset(&exec, 0, sizeof(exec)); exec.NumCompBuffers = buffer_count; exec.pCompressedBuffers = buffer; exec.pExtensionData = NULL; diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index 6a4032ded6..8ce7a23f8b 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -573,8 +573,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, av_fifo_generic_write(fpc->fifo_buf, (void*) read_start, read_end - read_start, NULL); } else { - int8_t pad[MAX_FRAME_HEADER_SIZE]; - memset(pad, 0, sizeof(pad)); + int8_t pad[MAX_FRAME_HEADER_SIZE] = { 0 }; av_fifo_generic_write(fpc->fifo_buf, (void*) pad, sizeof(pad), NULL); } diff --git a/libavcodec/intrax8dsp.c b/libavcodec/intrax8dsp.c index 1a62fcde77..0e79276b82 100644 --- a/libavcodec/intrax8dsp.c +++ b/libavcodec/intrax8dsp.c @@ -152,10 +152,8 @@ static void spatial_compensation_0(uint8_t *src , uint8_t *dst, int linesize){ int x,y; unsigned int p;//power divided by 2 int a; - uint16_t left_sum[2][8]; - uint16_t top_sum[2][8]; - memset(left_sum,0,2*8*sizeof(uint16_t)); - memset( top_sum,0,2*8*sizeof(uint16_t)); + uint16_t left_sum[2][8] = { { 0 } }; + uint16_t top_sum[2][8] = { { 0 } }; for(i=0;i<8;i++){ a=src[area2+7-i]<<4; diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index d3f2e0fe84..2606706bbc 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -210,8 +210,7 @@ static inline void ls_encode_line(JLSState *state, PutBitContext *pb, void *last static void ls_store_lse(JLSState *state, PutBitContext *pb){ /* Test if we have default params and don't need to store LSE */ - JLSState state2; - memset(&state2, 0, sizeof(JLSState)); + JLSState state2 = { 0 }; state2.bpp = state->bpp; state2.near = state->near; ff_jpegls_reset_coding_parameters(&state2, 1); diff --git a/libavcodec/libxvid_rc.c b/libavcodec/libxvid_rc.c index 7a0e60dd09..e87142749e 100644 --- a/libavcodec/libxvid_rc.c +++ b/libavcodec/libxvid_rc.c @@ -35,8 +35,8 @@ extern unsigned int xvid_debug; int ff_xvid_rate_control_init(MpegEncContext *s){ char *tmp_name; int fd, i; - xvid_plg_create_t xvid_plg_create; - xvid_plugin_2pass2_t xvid_2pass2; + xvid_plg_create_t xvid_plg_create = { 0 }; + xvid_plugin_2pass2_t xvid_2pass2 = { 0 }; //xvid_debug=-1; @@ -63,7 +63,6 @@ int ff_xvid_rate_control_init(MpegEncContext *s){ close(fd); - memset(&xvid_2pass2, 0, sizeof(xvid_2pass2)); xvid_2pass2.version= XVID_MAKE_VERSION(1,1,0); xvid_2pass2.filename= tmp_name; xvid_2pass2.bitrate= s->avctx->bit_rate; @@ -71,7 +70,6 @@ int ff_xvid_rate_control_init(MpegEncContext *s){ xvid_2pass2.vbv_maxrate= s->avctx->rc_max_rate; xvid_2pass2.vbv_initial= s->avctx->rc_initial_buffer_occupancy; - memset(&xvid_plg_create, 0, sizeof(xvid_plg_create)); xvid_plg_create.version= XVID_MAKE_VERSION(1,1,0); xvid_plg_create.fbase= s->avctx->time_base.den; xvid_plg_create.fincr= s->avctx->time_base.num; @@ -85,9 +83,8 @@ int ff_xvid_rate_control_init(MpegEncContext *s){ } float ff_xvid_rate_estimate_qscale(MpegEncContext *s, int dry_run){ - xvid_plg_data_t xvid_plg_data; + xvid_plg_data_t xvid_plg_data = { 0 }; - memset(&xvid_plg_data, 0, sizeof(xvid_plg_data)); xvid_plg_data.version= XVID_MAKE_VERSION(1,1,0); xvid_plg_data.width = s->width; xvid_plg_data.height= s->height; diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c index 44580d1364..0193bc8751 100644 --- a/libavcodec/libxvidff.c +++ b/libavcodec/libxvidff.c @@ -131,11 +131,11 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { uint16_t *intra, *inter; int fd; - xvid_plugin_single_t single; - struct xvid_ff_pass1 rc2pass1; - xvid_plugin_2pass2_t rc2pass2; - xvid_gbl_init_t xvid_gbl_init; - xvid_enc_create_t xvid_enc_create; + xvid_plugin_single_t single = { 0 }; + struct xvid_ff_pass1 rc2pass1 = { 0 }; + xvid_plugin_2pass2_t rc2pass2 = { 0 }; + xvid_gbl_init_t xvid_gbl_init = { 0 }; + xvid_enc_create_t xvid_enc_create = { 0 }; xvid_enc_plugin_t plugins[7]; /* Bring in VOP flags from avconv command-line */ @@ -205,7 +205,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { x->me_flags |= XVID_ME_QUARTERPELREFINE8; } - memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init)); xvid_gbl_init.version = XVID_VERSION; xvid_gbl_init.debug = 0; @@ -226,7 +225,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL); /* Create the encoder reference */ - memset(&xvid_enc_create, 0, sizeof(xvid_enc_create)); xvid_enc_create.version = XVID_VERSION; /* Store the desired frame size */ @@ -251,7 +249,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { x->twopassfile = NULL; if( xvid_flags & CODEC_FLAG_PASS1 ) { - memset(&rc2pass1, 0, sizeof(struct xvid_ff_pass1)); rc2pass1.version = XVID_VERSION; rc2pass1.context = x; x->twopassbuffer = av_malloc(BUFFER_SIZE); @@ -267,7 +264,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { plugins[xvid_enc_create.num_plugins].param = &rc2pass1; xvid_enc_create.num_plugins++; } else if( xvid_flags & CODEC_FLAG_PASS2 ) { - memset(&rc2pass2, 0, sizeof(xvid_plugin_2pass2_t)); rc2pass2.version = XVID_VERSION; rc2pass2.bitrate = avctx->bit_rate; @@ -299,7 +295,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { xvid_enc_create.num_plugins++; } else if( !(xvid_flags & CODEC_FLAG_QSCALE) ) { /* Single Pass Bitrate Control! */ - memset(&single, 0, sizeof(xvid_plugin_single_t)); single.version = XVID_VERSION; single.bitrate = avctx->bit_rate; @@ -419,8 +414,8 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int mb_width = (avctx->width + 15) / 16; int mb_height = (avctx->height + 15) / 16; - xvid_enc_frame_t xvid_enc_frame; - xvid_enc_stats_t xvid_enc_stats; + xvid_enc_frame_t xvid_enc_frame = { 0 }; + xvid_enc_stats_t xvid_enc_stats = { 0 }; if (!user_packet && (ret = av_new_packet(pkt, mb_width*mb_height*MAX_MB_BYTES + FF_MIN_BUFFER_SIZE)) < 0) { @@ -429,9 +424,7 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } /* Start setting up the frame */ - memset(&xvid_enc_frame, 0, sizeof(xvid_enc_frame)); xvid_enc_frame.version = XVID_VERSION; - memset(&xvid_enc_stats, 0, sizeof(xvid_enc_stats)); xvid_enc_stats.version = XVID_VERSION; *p = *picture; diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 1c5fa79f39..5eab559f84 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -46,14 +46,13 @@ static int build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table, int nb_codes, int use_static, int is_ac) { - uint8_t huff_size[256]; + uint8_t huff_size[256] = { 0 }; uint16_t huff_code[256]; uint16_t huff_sym[256]; int i; assert(nb_codes <= 256); - memset(huff_size, 0, sizeof(huff_size)); ff_mjpeg_build_huffman_codes(huff_size, huff_code, bits_table, val_table); for (i = 0; i < 256; i++) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 2aa89786a1..ce802e5d1b 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1424,9 +1424,8 @@ static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y) #define HASH(fx,fy,bx,by) ((fx)+17*(fy)+63*(bx)+117*(by)) #define HASH8(fx,fy,bx,by) ((uint8_t)HASH(fx,fy,bx,by)) int hashidx= HASH(motion_fx,motion_fy, motion_bx, motion_by); - uint8_t map[256]; + uint8_t map[256] = { 0 }; - memset(map,0,sizeof(map)); map[hashidx&255] = 1; fbmin= check_bidir_mv(s, motion_fx, motion_fy, diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index dd43beb4fe..6ed124b5f1 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -304,11 +304,8 @@ static av_cold void decode_init_static(void) for (i = 1; i < 16; i++) { const HuffTable *h = &mpa_huff_tables[i]; int xsize, x, y; - uint8_t tmp_bits [512]; - uint16_t tmp_codes[512]; - - memset(tmp_bits , 0, sizeof(tmp_bits )); - memset(tmp_codes, 0, sizeof(tmp_codes)); + uint8_t tmp_bits [512] = { 0 }; + uint16_t tmp_codes[512] = { 0 }; xsize = h->xsize; diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index bbea9d7f2a..47f0d6d414 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -342,7 +342,7 @@ static void ra144_encode_subblock(RA144Context *ractx, const int16_t *lpc_coefs, unsigned int rms, PutBitContext *pb) { - float data[BLOCKSIZE], work[LPC_ORDER + BLOCKSIZE]; + float data[BLOCKSIZE] = { 0 }, work[LPC_ORDER + BLOCKSIZE]; float coefs[LPC_ORDER]; float zero[BLOCKSIZE], cba[BLOCKSIZE], cb1[BLOCKSIZE], cb2[BLOCKSIZE]; int16_t cba_vect[BLOCKSIZE]; @@ -360,7 +360,6 @@ static void ra144_encode_subblock(RA144Context *ractx, * Calculate the zero-input response of the LPC filter and subtract it from * input data. */ - memset(data, 0, sizeof(data)); ff_celp_lp_synthesis_filterf(work + LPC_ORDER, coefs, data, BLOCKSIZE, LPC_ORDER); for (i = 0; i < BLOCKSIZE; i++) { diff --git a/libavcodec/rangecoder.c b/libavcodec/rangecoder.c index 1cd6762cb5..b0c9f21512 100644 --- a/libavcodec/rangecoder.c +++ b/libavcodec/rangecoder.c @@ -119,7 +119,7 @@ int main(void){ uint8_t b[9*SIZE]; uint8_t r[9*SIZE]; int i; - uint8_t state[10]= {0}; + uint8_t state[10]; AVLFG prng; av_lfg_init(&prng, 1); diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index b366ead776..3ad1717d13 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -554,7 +554,7 @@ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir) MpegEncContext *s = &r->s; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; - int A[2], B[2], C[2]; + int A[2] = { 0 }, B[2] = { 0 }, C[2] = { 0 }; int has_A = 0, has_B = 0, has_C = 0; int mx, my; int i, j; @@ -562,9 +562,6 @@ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir) const int mask = dir ? MB_TYPE_L1 : MB_TYPE_L0; int type = cur_pic->f.mb_type[mb_pos]; - memset(A, 0, sizeof(A)); - memset(B, 0, sizeof(B)); - memset(C, 0, sizeof(C)); if((r->avail_cache[6-1] & type) & mask){ A[0] = cur_pic->f.motion_val[dir][mv_pos - 1][0]; A[1] = cur_pic->f.motion_val[dir][mv_pos - 1][1]; diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 05f4a925fb..d4253873c5 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -180,7 +180,7 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int int res; HuffContext huff; HuffContext tmp1, tmp2; - VLC vlc[2]; + VLC vlc[2] = { { 0 } }; int escapes[3]; DBCtx ctx; int err = 0; @@ -204,9 +204,6 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int tmp2.lengths = av_mallocz(256 * sizeof(int)); tmp2.values = av_mallocz(256 * sizeof(int)); - memset(&vlc[0], 0, sizeof(VLC)); - memset(&vlc[1], 0, sizeof(VLC)); - if(get_bits1(gb)) { smacker_decode_tree(gb, &tmp1, 0, 0); skip_bits1(gb); @@ -591,8 +588,8 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; GetBitContext gb; - HuffContext h[4]; - VLC vlc[4]; + HuffContext h[4] = { { 0 } }; + VLC vlc[4] = { { 0 } }; int16_t *samples; uint8_t *samples8; int val; @@ -635,8 +632,6 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, samples = (int16_t *)s->frame.data[0]; samples8 = s->frame.data[0]; - memset(vlc, 0, sizeof(VLC) * 4); - memset(h, 0, sizeof(HuffContext) * 4); // Initialize for(i = 0; i < (1 << (bits + stereo)); i++) { h[i].length = 256; diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 9ca91636a1..adbd15cbeb 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -83,10 +83,9 @@ static unsigned tget(const uint8_t **p, int type, int le) { #if CONFIG_ZLIB static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t *src, int size) { - z_stream zstream; + z_stream zstream = { 0 }; int zret; - memset(&zstream, 0, sizeof(zstream)); zstream.next_in = src; zstream.avail_in = size; zstream.next_out = dst; diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index fcf6004c51..a3bd3730fb 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -310,7 +310,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) int width_shift = 0; int new_pix_fmt; struct frame_header header; - uint8_t header_buffer[128]; /* logical maximum size of the header */ + uint8_t header_buffer[128] = { 0 }; /* logical maximum size of the header */ const uint8_t *sel_vector_table; header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f; @@ -321,7 +321,6 @@ static int truemotion1_decode_header(TrueMotion1Context *s) } /* unscramble the header bytes with a XOR operation */ - memset(header_buffer, 0, 128); for (i = 1; i < header.header_size; i++) header_buffer[i - 1] = s->buf[i] ^ s->buf[i + 1]; diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 65ca3c8e58..ce87aeffc2 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -521,7 +521,7 @@ static int decode_subframe_length(WMAProDecodeCtx *s, int offset) */ static int decode_tilehdr(WMAProDecodeCtx *s) { - uint16_t num_samples[WMAPRO_MAX_CHANNELS]; /**< sum of samples for all currently known subframes of a channel */ + uint16_t num_samples[WMAPRO_MAX_CHANNELS] = { 0 };/**< sum of samples for all currently known subframes of a channel */ uint8_t contains_subframe[WMAPRO_MAX_CHANNELS]; /**< flag indicating if a channel contains the current subframe */ int channels_for_cur_subframe = s->num_channels; /**< number of channels that contain the current subframe */ int fixed_channel_layout = 0; /**< flag indicating that all channels use the same subframe offsets and sizes */ @@ -538,8 +538,6 @@ static int decode_tilehdr(WMAProDecodeCtx *s) for (c = 0; c < s->num_channels; c++) s->channel[c].num_subframes = 0; - memset(num_samples, 0, sizeof(num_samples)); - if (s->max_num_subframes == 1 || get_bits1(&s->gb)) fixed_channel_layout = 1; diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index a222f09f90..ebc6a59ae9 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -318,10 +318,9 @@ static av_cold int decode_vbmtree(GetBitContext *gb, int8_t vbm_tree[25]) 0x0ffc, 0x0ffd, 0x0ffe, // 1111111111+00/01/10 0x3ffc, 0x3ffd, 0x3ffe, 0x3fff // 111111111111+xx }; - int cntr[8], n, res; + int cntr[8] = { 0 }, n, res; memset(vbm_tree, 0xff, sizeof(vbm_tree[0]) * 25); - memset(cntr, 0, sizeof(cntr)); for (n = 0; n < 17; n++) { res = get_bits(gb, 3); if (cntr[res] > 3) // should be >= 3 + (res == 7)) diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index b35ec7cc87..42ee0b317d 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -102,7 +102,7 @@ static av_cold int bktr_init(const char *video_device, int width, int height, long ioctl_frequency; char *arg; int c; - struct sigaction act, old; + struct sigaction act = { 0 }, old; if (idev < 0 || idev > 4) { @@ -131,7 +131,6 @@ static av_cold int bktr_init(const char *video_device, int width, int height, frequency = 0.0; } - memset(&act, 0, sizeof(act)); sigemptyset(&act.sa_mask); act.sa_handler = catchsignal; sigaction(SIGUSR1, &act, &old); diff --git a/libavformat/asfcrypt.c b/libavformat/asfcrypt.c index aea3d4f345..6c48a1967a 100644 --- a/libavformat/asfcrypt.c +++ b/libavformat/asfcrypt.c @@ -140,7 +140,7 @@ void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len) { struct AVRC4 rc4; int num_qwords = len >> 3; uint8_t *qwords = data; - uint64_t rc4buff[8]; + uint64_t rc4buff[8] = { 0 }; uint64_t packetkey; uint32_t ms_keys[12]; uint64_t ms_state; @@ -151,7 +151,6 @@ void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len) { return; } - memset(rc4buff, 0, sizeof(rc4buff)); av_rc4_init(&rc4, key, 12 * 8, 1); av_rc4_crypt(&rc4, (uint8_t *)rc4buff, NULL, sizeof(rc4buff), NULL, 1); multiswap_init((uint8_t *)rc4buff, ms_keys); diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 1d808f128f..f776c7575c 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -983,7 +983,7 @@ static int mov_write_pasp_tag(AVIOContext *pb, MOVTrack *track) static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); - char compressor_name[32]; + char compressor_name[32] = { 0 }; avio_wb32(pb, 0); /* size */ avio_wl32(pb, track->tag); // store it byteswapped @@ -1014,7 +1014,6 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, 0); /* Data size (= 0) */ avio_wb16(pb, 1); /* Frame count (= 1) */ - memset(compressor_name,0,32); /* FIXME not sure, ISO 14496-1 draft where it shall be set to 0 */ if (track->mode == MODE_MOV && track->enc->codec && track->enc->codec->name) av_strlcpy(compressor_name,track->enc->codec->name,32); diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 07cf80992e..fa761f54a8 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -157,8 +157,7 @@ static void rtsp_parse_range_npt(const char *p, int64_t *start, int64_t *end) static int get_sockaddr(const char *buf, struct sockaddr_storage *sock) { - struct addrinfo hints, *ai = NULL; - memset(&hints, 0, sizeof(hints)); + struct addrinfo hints = { 0 }, *ai = NULL; hints.ai_flags = AI_NUMERICHOST; if (getaddrinfo(buf, NULL, &hints, &ai)) return -1; @@ -497,9 +496,8 @@ int ff_sdp_parse(AVFormatContext *s, const char *content) * The Vorbis FMTP line can be up to 16KB - see xiph_parse_sdp_line * in rtpdec_xiph.c. */ char buf[16384], *q; - SDPParseState sdp_parse_state, *s1 = &sdp_parse_state; + SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state; - memset(s1, 0, sizeof(SDPParseState)); p = content; for (;;) { p += strspn(p, SPACE_CHARS); @@ -1955,7 +1953,7 @@ static int rtp_read_header(AVFormatContext *s) int ret, port; URLContext* in = NULL; int payload_type; - AVCodecContext codec; + AVCodecContext codec = { 0 }; struct sockaddr_storage addr; AVIOContext pb; socklen_t addrlen = sizeof(addr); @@ -1996,7 +1994,6 @@ static int rtp_read_header(AVFormatContext *s) ffurl_close(in); in = NULL; - memset(&codec, 0, sizeof(codec)); if (ff_rtp_get_codec_info(&codec, payload_type)) { av_log(s, AV_LOG_ERROR, "Unable to receive RTP payload type %d " "without an SDP file describing it\n", diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index dbd7bdb7b9..0913dd7a45 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -104,8 +104,7 @@ static int sap_write_header(AVFormatContext *s) } if (!announce_addr[0]) { - struct addrinfo hints, *ai = NULL; - memset(&hints, 0, sizeof(hints)); + struct addrinfo hints = { 0 }, *ai = NULL; hints.ai_family = AF_UNSPEC; if (getaddrinfo(host, NULL, &hints, &ai)) { av_log(s, AV_LOG_ERROR, "Unable to resolve %s\n", host); diff --git a/libavformat/sdp.c b/libavformat/sdp.c index b2c4f7bcd8..9692aabbc0 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -88,7 +88,7 @@ static void sdp_write_header(char *buff, int size, struct sdp_session_level *s) static int resolve_destination(char *dest_addr, int size, char *type, int type_size) { - struct addrinfo hints, *ai; + struct addrinfo hints = { 0 }, *ai; int is_multicast; av_strlcpy(type, "IP4", type_size); @@ -98,7 +98,6 @@ static int resolve_destination(char *dest_addr, int size, char *type, /* Resolve the destination, since it must be written * as a numeric IP address in the SDP. */ - memset(&hints, 0, sizeof(hints)); if (getaddrinfo(dest_addr, NULL, &hints, &ai)) return 0; getnameinfo(ai->ai_addr, ai->ai_addrlen, dest_addr, size, @@ -581,12 +580,11 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size) { AVDictionaryEntry *title = av_dict_get(ac[0]->metadata, "title", NULL, 0); - struct sdp_session_level s; + struct sdp_session_level s = { 0 }; int i, j, port, ttl, is_multicast; char dst[32], dst_type[5]; memset(buf, 0, size); - memset(&s, 0, sizeof(struct sdp_session_level)); s.user = "-"; s.src_addr = "127.0.0.1"; /* FIXME: Properly set this */ s.src_type = "IP4"; diff --git a/libavformat/seek-test.c b/libavformat/seek-test.c index 699c693c3f..57d3fa4da5 100644 --- a/libavformat/seek-test.c +++ b/libavformat/seek-test.c @@ -93,11 +93,10 @@ int main(int argc, char **argv) } for(i=0; ; i++){ - AVPacket pkt; + AVPacket pkt = { 0 }; AVStream *av_uninit(st); char ts_buf[60]; - memset(&pkt, 0, sizeof(pkt)); if(ret>=0){ ret= av_read_frame(ic, &pkt); if(ret>=0){ diff --git a/libavformat/tcp.c b/libavformat/tcp.c index fdb457e8c5..0ed11f321f 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -37,7 +37,7 @@ typedef struct TCPContext { /* return non zero if error */ static int tcp_open(URLContext *h, const char *uri, int flags) { - struct addrinfo hints, *ai, *cur_ai; + struct addrinfo hints = { 0 }, *ai, *cur_ai; int port, fd = -1; TCPContext *s = h->priv_data; int listen_socket = 0; @@ -62,7 +62,6 @@ static int tcp_open(URLContext *h, const char *uri, int flags) timeout = strtol(buf, NULL, 10); } } - memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; snprintf(portstr, sizeof(portstr), "%d", port); diff --git a/libavformat/udp.c b/libavformat/udp.c index 37b76559e9..6571ab5d42 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -140,7 +140,7 @@ static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr) static struct addrinfo* udp_resolve_host(const char *hostname, int port, int type, int family, int flags) { - struct addrinfo hints, *res = 0; + struct addrinfo hints = { 0 }, *res = 0; int error; char sport[16]; const char *node = 0, *service = "0"; @@ -152,7 +152,6 @@ static struct addrinfo* udp_resolve_host(const char *hostname, int port, if ((hostname) && (hostname[0] != '\0') && (hostname[0] != '?')) { node = hostname; } - memset(&hints, 0, sizeof(hints)); hints.ai_socktype = type; hints.ai_family = family; hints.ai_flags = flags; diff --git a/libavformat/utils.c b/libavformat/utils.c index cb708addf4..f38045c5dd 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3668,7 +3668,7 @@ int ff_url_join(char *str, int size, const char *proto, int port, const char *fmt, ...) { #if CONFIG_NETWORK - struct addrinfo hints, *ai; + struct addrinfo hints = { 0 }, *ai; #endif str[0] = '\0'; @@ -3679,7 +3679,6 @@ int ff_url_join(char *str, int size, const char *proto, #if CONFIG_NETWORK && defined(AF_INET6) /* Determine if hostname is a numerical IPv6 address, * properly escape it within [] in that case. */ - memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_NUMERICHOST; if (!getaddrinfo(hostname, NULL, &hints, &ai)) { if (ai->ai_family == AF_INET6) { diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index 8c8251bddb..3d28e5659b 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -93,12 +93,10 @@ int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int widt int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, uint8_t *ptr, const int linesizes[4]) { - int i, total_size, size[4], has_plane[4]; + int i, total_size, size[4] = { 0 }, has_plane[4] = { 0 }; const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; memset(data , 0, sizeof(data[0])*4); - memset(size , 0, sizeof(size)); - memset(has_plane, 0, sizeof(has_plane)); if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL) return AVERROR(EINVAL); diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index a1d221b62a..ed147eef3d 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -484,7 +484,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration) { const char *p; int64_t t; - struct tm dt; + struct tm dt = { 0 }; int i; static const char * const date_fmt[] = { "%Y-%m-%d", @@ -509,8 +509,6 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration) lastch = '\0'; is_utc = (lastch == 'z' || lastch == 'Z'); - memset(&dt, 0, sizeof(dt)); - p = timestr; q = NULL; if (!duration) { From 2efb710a3432f1bab381ed66fbae42c7d638e2c9 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 27 Mar 2012 22:42:41 +0100 Subject: [PATCH 08/20] build: fix doc generation errors in parallel builds The $(dir) function used to construct OBJDIRS includes a trailing slash in the names returned, which GNU make 3.82 does not match to the slash-less 'doc' in the documentation dependencies, causing parallel build to fail. Adding a slash fixes this and still works with make 3.81. Signed-off-by: Mans Rullgard --- doc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Makefile b/doc/Makefile index ffb3c5ce4a..15e7323acc 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -40,7 +40,7 @@ doc/%.1: TAG = MAN doc/%.1: doc/%.pod $(GENTEXI) $(M)pod2man --section=1 --center=" " --release=" " $< > $@ -$(DOCS): | doc +$(DOCS): | doc/ install-progs-$(CONFIG_DOC): install-man From c0b34e61483aa08524dd9c0383419d11d09b0181 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 28 Mar 2012 15:44:18 +0200 Subject: [PATCH 09/20] dvdec: drop unnecessary dv_tablegen.h #include dvdec.c uses nothing from dv_tablegen.h. As a welcome side-effect, this fixes compilation of that file with hardcoded tables enabled. --- libavcodec/dvdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 689ae7c405..aeea01076e 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -43,7 +43,6 @@ #include "simple_idct.h" #include "dvdata.h" #include "dvquant.h" -#include "dv_tablegen.h" typedef struct BlockInfo { const uint32_t *factor_table; From 0a82f5275f719e6e369a807720a2c3603aa0ddd9 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 27 Mar 2012 12:26:46 -0700 Subject: [PATCH 10/20] lagarith: fix buffer overreads. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org --- libavcodec/lagarith.c | 74 +++++++++++++++++++++++++++------------- libavcodec/lagarithrac.c | 5 +-- 2 files changed, 54 insertions(+), 25 deletions(-) diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c index 3a47f4c632..201f77dda3 100644 --- a/libavcodec/lagarith.c +++ b/libavcodec/lagarith.c @@ -247,24 +247,26 @@ static void lag_pred_line(LagarithContext *l, uint8_t *buf, { int L, TL; - /* Left pixel is actually prev_row[width] */ - L = buf[width - stride - 1]; if (!line) { /* Left prediction only for first line */ L = l->dsp.add_hfyu_left_prediction(buf + 1, buf + 1, width - 1, buf[0]); - return; - } else if (line == 1) { - /* Second line, left predict first pixel, the rest of the line is median predicted - * NOTE: In the case of RGB this pixel is top predicted */ - TL = l->avctx->pix_fmt == PIX_FMT_YUV420P ? buf[-stride] : L; } else { - /* Top left is 2 rows back, last pixel */ - TL = buf[width - (2 * stride) - 1]; - } + /* Left pixel is actually prev_row[width] */ + L = buf[width - stride - 1]; - add_lag_median_prediction(buf, buf - stride, buf, - width, &L, &TL); + if (line == 1) { + /* Second line, left predict first pixel, the rest of the line is median predicted + * NOTE: In the case of RGB this pixel is top predicted */ + TL = l->avctx->pix_fmt == PIX_FMT_YUV420P ? buf[-stride] : L; + } else { + /* Top left is 2 rows back, last pixel */ + TL = buf[width - (2 * stride) - 1]; + } + + add_lag_median_prediction(buf, buf - stride, buf, + width, &L, &TL); + } } static int lag_decode_line(LagarithContext *l, lag_rac *rac, @@ -310,13 +312,13 @@ handle_zeros: } static int lag_decode_zero_run_line(LagarithContext *l, uint8_t *dst, - const uint8_t *src, int width, - int esc_count) + const uint8_t *src, const uint8_t *src_end, + int width, int esc_count) { int i = 0; int count; uint8_t zero_run = 0; - const uint8_t *start = src; + const uint8_t *src_start = src; uint8_t mask1 = -(esc_count < 2); uint8_t mask2 = -(esc_count < 3); uint8_t *end = dst + (width - 2); @@ -333,6 +335,8 @@ output_zeros: i = 0; while (!zero_run && dst + i < end) { i++; + if (src + i >= src_end) + return AVERROR_INVALIDDATA; zero_run = !(src[i] | (src[i + 1] & mask1) | (src[i + 2] & mask2)); } @@ -348,9 +352,10 @@ output_zeros: } else { memcpy(dst, src, i); src += i; + dst += i; } } - return start - src; + return src_start - src; } @@ -366,6 +371,7 @@ static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst, int esc_count = src[0]; GetBitContext gb; lag_rac rac; + const uint8_t *src_end = src + src_size; rac.avctx = l->avctx; l->zeros = 0; @@ -396,10 +402,16 @@ static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst, esc_count -= 4; if (esc_count > 0) { /* Zero run coding only, no range coding. */ - for (i = 0; i < height; i++) - src += lag_decode_zero_run_line(l, dst + (i * stride), src, - width, esc_count); + for (i = 0; i < height; i++) { + int res = lag_decode_zero_run_line(l, dst + (i * stride), src, + src_end, width, esc_count); + if (res < 0) + return res; + src += res; + } } else { + if (src_size < width * height) + return AVERROR_INVALIDDATA; // buffer not big enough /* Plane is stored uncompressed */ for (i = 0; i < height; i++) { memcpy(dst + (i * stride), src, width); @@ -506,11 +518,19 @@ static int lag_decode_frame(AVCodecContext *avctx, } for (i = 0; i < planes; i++) srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride; + if (offset_ry >= buf_size || + offset_gu >= buf_size || + offset_bv >= buf_size || + (planes == 4 && offs[3] >= buf_size)) { + av_log(avctx, AV_LOG_ERROR, + "Invalid frame offsets\n"); + return AVERROR_INVALIDDATA; + } for (i = 0; i < planes; i++) lag_decode_arith_plane(l, srcs[i], avctx->width, avctx->height, -l->rgb_stride, buf + offs[i], - buf_size); + buf_size - offs[i]); dst = p->data[0]; for (i = 0; i < planes; i++) srcs[i] = l->rgb_planes + i * l->rgb_stride * avctx->height; @@ -544,15 +564,23 @@ static int lag_decode_frame(AVCodecContext *avctx, return -1; } + if (offset_ry >= buf_size || + offset_gu >= buf_size || + offset_bv >= buf_size) { + av_log(avctx, AV_LOG_ERROR, + "Invalid frame offsets\n"); + return AVERROR_INVALIDDATA; + } + lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height, p->linesize[0], buf + offset_ry, - buf_size); + buf_size - offset_ry); lag_decode_arith_plane(l, p->data[2], avctx->width / 2, avctx->height / 2, p->linesize[2], - buf + offset_gu, buf_size); + buf + offset_gu, buf_size - offset_gu); lag_decode_arith_plane(l, p->data[1], avctx->width / 2, avctx->height / 2, p->linesize[1], - buf + offset_bv, buf_size); + buf + offset_bv, buf_size - offset_bv); break; default: av_log(avctx, AV_LOG_ERROR, diff --git a/libavcodec/lagarithrac.c b/libavcodec/lagarithrac.c index 33dc6e4bd4..edfb18fb74 100644 --- a/libavcodec/lagarithrac.c +++ b/libavcodec/lagarithrac.c @@ -32,15 +32,16 @@ void ff_lag_rac_init(lag_rac *l, GetBitContext *gb, int length) { - int i, j; + int i, j, left; /* According to reference decoder "1st byte is garbage", * however, it gets skipped by the call to align_get_bits() */ align_get_bits(gb); + left = get_bits_left(gb) >> 3; l->bytestream_start = l->bytestream = gb->buffer + get_bits_count(gb) / 8; - l->bytestream_end = l->bytestream_start + length; + l->bytestream_end = l->bytestream_start + FFMIN(length, left); l->range = 0x80; l->low = *l->bytestream >> 1; From d360dd902c602aea2d634a0091cc7754eab4839e Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 28 Mar 2012 07:14:21 -0700 Subject: [PATCH 11/20] wmall: fix seeking. --- libavcodec/wmalosslessdec.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 0ecf5dea3f..3ee6285d79 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -903,6 +903,7 @@ static int decode_subframe(WmallDecodeCtx *s) } else if (!s->cdlms[0][0].order) { av_log(s->avctx, AV_LOG_DEBUG, "Waiting for seekable tile\n"); + s->frame.nb_samples = 0; return -1; } @@ -1265,6 +1266,17 @@ static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; } +static void flush(AVCodecContext *avctx) +{ + WmallDecodeCtx *s = avctx->priv_data; + s->packet_loss = 1; + s->packet_done = 0; + s->num_saved_bits = 0; + s->frame_offset = 0; + s->next_packet_start = 0; + s->cdlms[0][0].order = 0; + s->frame.nb_samples = 0; +} AVCodec ff_wmalossless_decoder = { .name = "wmalossless", @@ -1273,6 +1285,7 @@ AVCodec ff_wmalossless_decoder = { .priv_data_size = sizeof(WmallDecodeCtx), .init = decode_init, .decode = decode_packet, + .flush = flush, .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1 | CODEC_CAP_DELAY, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Lossless"), }; From 7374fac80406d6c1a67a0e3265cfe6dfcc51ce61 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 16 Mar 2012 21:56:40 -0700 Subject: [PATCH 12/20] h264: fix overreads in cabac reader. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org --- libavcodec/cabac_functions.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/cabac_functions.h b/libavcodec/cabac_functions.h index b150aabcc4..4c74cf7b23 100644 --- a/libavcodec/cabac_functions.h +++ b/libavcodec/cabac_functions.h @@ -47,7 +47,8 @@ static void refill(CABACContext *c){ c->low+= c->bytestream[0]<<1; #endif c->low -= CABAC_MASK; - c->bytestream+= CABAC_BITS/8; + if (c->bytestream < c->bytestream_end) + c->bytestream += CABAC_BITS / 8; } static inline void renorm_cabac_decoder_once(CABACContext *c){ @@ -74,7 +75,8 @@ static void refill2(CABACContext *c){ #endif c->low += x<bytestream+= CABAC_BITS/8; + if (c->bytestream < c->bytestream_end) + c->bytestream += CABAC_BITS/8; } static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){ From db025929f202bc32459a1278ee06920a06564762 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 16 Mar 2012 22:41:17 -0700 Subject: [PATCH 13/20] h264: use struct offsets in get_cabac_bypass_sign_x86(). --- libavcodec/x86/cabac.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index 3c3652d5f0..7d8976c0bf 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -105,8 +105,8 @@ static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val) { x86_reg tmp; __asm__ volatile( - "movl %4, %k1 \n\t" - "movl %2, %%eax \n\t" + "movl %a5(%2), %k1 \n\t" + "movl %a3(%2), %%eax \n\t" "shl $17, %k1 \n\t" "add %%eax, %%eax \n\t" "sub %k1, %%eax \n\t" @@ -117,20 +117,23 @@ static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val) "sub %%edx, %%ecx \n\t" "test %%ax, %%ax \n\t" " jnz 1f \n\t" - "mov %3, %1 \n\t" + "mov %a4(%2), %1 \n\t" "subl $0xFFFF, %%eax \n\t" "movzwl (%1), %%edx \n\t" "bswap %%edx \n\t" "shrl $15, %%edx \n\t" "add $2, %1 \n\t" "addl %%edx, %%eax \n\t" - "mov %1, %3 \n\t" + "mov %1, %a4(%2) \n\t" "1: \n\t" - "movl %%eax, %2 \n\t" + "movl %%eax, %a3(%2) \n\t" - :"+c"(val), "=&r"(tmp), "+m"(c->low), "+m"(c->bytestream) - :"m"(c->range) - : "%eax", "%edx" + : "+c"(val), "=&r"(tmp) + : "r"(c), + "i"(offsetof(CABACContext, low)), + "i"(offsetof(CABACContext, bytestream)), + "i"(offsetof(CABACContext, range)) + : "%eax", "%edx", "memory" ); return val; } From 95bfa4ead7b837c4b2b43750b7208eb4e4806da3 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 17 Mar 2012 09:32:03 -0700 Subject: [PATCH 14/20] h264: reindent get_cabac_bypass_sign_x86(). --- libavcodec/x86/cabac.h | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index 7d8976c0bf..b00652be94 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -105,28 +105,28 @@ static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val) { x86_reg tmp; __asm__ volatile( - "movl %a5(%2), %k1 \n\t" - "movl %a3(%2), %%eax \n\t" - "shl $17, %k1 \n\t" - "add %%eax, %%eax \n\t" - "sub %k1, %%eax \n\t" - "cltd \n\t" - "and %%edx, %k1 \n\t" - "add %k1, %%eax \n\t" - "xor %%edx, %%ecx \n\t" - "sub %%edx, %%ecx \n\t" - "test %%ax, %%ax \n\t" - " jnz 1f \n\t" - "mov %a4(%2), %1 \n\t" - "subl $0xFFFF, %%eax \n\t" - "movzwl (%1), %%edx \n\t" - "bswap %%edx \n\t" - "shrl $15, %%edx \n\t" - "add $2, %1 \n\t" - "addl %%edx, %%eax \n\t" - "mov %1, %a4(%2) \n\t" - "1: \n\t" - "movl %%eax, %a3(%2) \n\t" + "movl %a5(%2), %k1 \n\t" + "movl %a3(%2), %%eax \n\t" + "shl $17, %k1 \n\t" + "add %%eax, %%eax \n\t" + "sub %k1, %%eax \n\t" + "cltd \n\t" + "and %%edx, %k1 \n\t" + "add %k1, %%eax \n\t" + "xor %%edx, %%ecx \n\t" + "sub %%edx, %%ecx \n\t" + "test %%ax, %%ax \n\t" + "jnz 1f \n\t" + "mov %a4(%2), %1 \n\t" + "subl $0xFFFF, %%eax \n\t" + "movzwl (%1), %%edx \n\t" + "bswap %%edx \n\t" + "shrl $15, %%edx \n\t" + "add $2, %1 \n\t" + "addl %%edx, %%eax \n\t" + "mov %1, %a4(%2) \n\t" + "1: \n\t" + "movl %%eax, %a3(%2) \n\t" : "+c"(val), "=&r"(tmp) : "r"(c), From a0bdcb019e24f8a75ebef54289c4b8c015f77f41 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 17 Mar 2012 08:58:48 -0700 Subject: [PATCH 15/20] h264: add overread protection to get_cabac_bypass_sign_x86(). --- libavcodec/x86/cabac.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index b00652be94..adf4fc39b2 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -105,7 +105,7 @@ static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val) { x86_reg tmp; __asm__ volatile( - "movl %a5(%2), %k1 \n\t" + "movl %a6(%2), %k1 \n\t" "movl %a3(%2), %%eax \n\t" "shl $17, %k1 \n\t" "add %%eax, %%eax \n\t" @@ -122,9 +122,10 @@ static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val) "movzwl (%1), %%edx \n\t" "bswap %%edx \n\t" "shrl $15, %%edx \n\t" - "add $2, %1 \n\t" "addl %%edx, %%eax \n\t" - "mov %1, %a4(%2) \n\t" + "cmp %a5(%2), %1 \n\t" + "jge 1f \n\t" + "add"OPSIZE" $2, %a4(%2) \n\t" "1: \n\t" "movl %%eax, %a3(%2) \n\t" @@ -132,6 +133,7 @@ static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val) : "r"(c), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)), + "i"(offsetof(CABACContext, bytestream_end)), "i"(offsetof(CABACContext, range)) : "%eax", "%edx", "memory" ); From 951014e5bb8a1c20865118bf5bdf5e4ee7eac265 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 17 Mar 2012 09:02:44 -0700 Subject: [PATCH 16/20] cabac: use struct+offset instead of memory operand in BRANCHLESS_GET_CABAC(). --- libavcodec/x86/cabac.h | 10 +++++----- libavcodec/x86/h264_i386.h | 32 +++++++++++++++++--------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index adf4fc39b2..e03a4dec9c 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -89,11 +89,11 @@ static av_always_inline int get_cabac_inline_x86(CABACContext *c, int bit, tmp; __asm__ volatile( - BRANCHLESS_GET_CABAC("%0", "(%5)", "%1", "%w1", "%2", - "%3", "%b3", "%4") - :"=&r"(bit), "+&r"(c->low), "+&r"(c->range), "=&q"(tmp), - "+m"(c->bytestream) - :"r"(state) + BRANCHLESS_GET_CABAC("%0", "(%4)", "%1", "%w1", + "%2", "%3", "%b3", "%a6(%5)") + : "=&r"(bit), "+&r"(c->low), "+&r"(c->range), "=&q"(tmp) + : "r"(state), "r"(c), + "i"(offsetof(CABACContext, bytestream)) : "%"REG_c, "memory" ); return bit & 1; diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index e195e04879..2cfcbddfb2 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -48,15 +48,15 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, __asm__ volatile( "2: \n\t" - BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", - "%w3", "%5", "%k0", "%b0", "%6") + BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", "%w3", + "%5", "%k0", "%b0", "%a11(%6)") "test $1, %4 \n\t" " jz 3f \n\t" "add %10, %1 \n\t" - BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", - "%w3", "%5", "%k0", "%b0", "%6") + BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", "%w3", + "%5", "%k0", "%b0", "%a11(%6)") "sub %10, %1 \n\t" "mov %2, %0 \n\t" @@ -80,10 +80,10 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "4: \n\t" "add %9, %k0 \n\t" "shr $2, %k0 \n\t" - :"=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), - "+&r"(c->low), "=&r"(bit), "+&r"(c->range), - "+m"(c->bytestream) - :"m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off) + : "=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), + "+&r"(c->low), "=&r"(bit), "+&r"(c->range) + : "r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), + "i"(offsetof(CABACContext, bytestream)) : "%"REG_c, "memory" ); return coeff_count; @@ -105,8 +105,8 @@ static int decode_significance_8x8_x86(CABACContext *c, "movzbl (%0, %6), %k6 \n\t" "add %9, %6 \n\t" - BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", - "%w3", "%5", "%k0", "%b0", "%7") + BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", "%w3", + "%5", "%k0", "%b0", "%a12(%7)") "mov %1, %k6 \n\t" "test $1, %4 \n\t" @@ -115,8 +115,8 @@ static int decode_significance_8x8_x86(CABACContext *c, "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t" "add %11, %6 \n\t" - BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", - "%w3", "%5", "%k0", "%b0", "%7") + BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", "%w3", + "%5", "%k0", "%b0", "%a12(%7)") "mov %2, %0 \n\t" "mov %1, %k6 \n\t" @@ -137,9 +137,11 @@ static int decode_significance_8x8_x86(CABACContext *c, "4: \n\t" "addl %8, %k0 \n\t" "shr $2, %k0 \n\t" - :"=&q"(coeff_count),"+m"(last), "+m"(index), "+&r"(c->low), "=&r"(bit), - "+&r"(c->range), "=&r"(state), "+m"(c->bytestream) - :"m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_coeff_ctx_base) + : "=&q"(coeff_count), "+m"(last), "+m"(index), "+&r"(c->low), + "=&r"(bit), "+&r"(c->range), "=&r"(state) + : "r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), + "m"(sig_off), "m"(last_coeff_ctx_base), + "i"(offsetof(CABACContext, bytestream)) : "%"REG_c, "memory" ); return coeff_count; From 16f6e83f749fcd5f7073986769e97bc45ccb6ca9 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 17 Mar 2012 09:03:22 -0700 Subject: [PATCH 17/20] cabac: remove unused argument from BRANCHLESS_GET_CABAC_UPDATE(). --- libavcodec/x86/cabac.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index e03a4dec9c..ca8a1d5b5f 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -27,7 +27,7 @@ #include "config.h" #if HAVE_FAST_CMOV -#define BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, lowword, range, tmp)\ +#define BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, range, tmp)\ "mov "tmp" , %%ecx \n\t"\ "shl $17 , "tmp" \n\t"\ "cmp "low" , "tmp" \n\t"\ @@ -37,7 +37,7 @@ "xor %%ecx , "ret" \n\t"\ "sub "tmp" , "low" \n\t" #else /* HAVE_FAST_CMOV */ -#define BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, lowword, range, tmp)\ +#define BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, range, tmp)\ "mov "tmp" , %%ecx \n\t"\ "shl $17 , "tmp" \n\t"\ "sub "low" , "tmp" \n\t"\ @@ -57,7 +57,7 @@ "and $0xC0 , "range" \n\t"\ "movzbl "MANGLE(ff_h264_lps_range)"("ret", "range", 2), "range" \n\t"\ "sub "range" , "tmp" \n\t"\ - BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, lowword, range, tmp) \ + BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, range, tmp) \ "movzbl " MANGLE(ff_h264_norm_shift) "("range"), %%ecx \n\t"\ "shl %%cl , "range" \n\t"\ "movzbl "MANGLE(ff_h264_mlps_state)"+128("ret"), "tmp" \n\t"\ From 448dc42571edc5bc91da7b0b017daa61118ba2f5 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 17 Mar 2012 09:04:32 -0700 Subject: [PATCH 18/20] cabac: increment jump locations by one in callers of BRANCHLESS_GET_CABAC(). --- libavcodec/x86/h264_i386.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index 2cfcbddfb2..31ddaf6ee9 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -46,13 +46,13 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, int bit; x86_reg coeff_count; __asm__ volatile( - "2: \n\t" + "3: \n\t" BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", "%w3", "%5", "%k0", "%b0", "%a11(%6)") "test $1, %4 \n\t" - " jz 3f \n\t" + " jz 4f \n\t" "add %10, %1 \n\t" BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", "%w3", @@ -65,19 +65,19 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "movl %%ecx, (%0) \n\t" "test $1, %4 \n\t" - " jnz 4f \n\t" + " jnz 5f \n\t" "add"OPSIZE" $4, %2 \n\t" - "3: \n\t" + "4: \n\t" "add $1, %1 \n\t" "cmp %8, %1 \n\t" - " jb 2b \n\t" + " jb 3b \n\t" "mov %2, %0 \n\t" "movl %7, %%ecx \n\t" "add %1, %%"REG_c" \n\t" "movl %%ecx, (%0) \n\t" - "4: \n\t" + "5: \n\t" "add %9, %k0 \n\t" "shr $2, %k0 \n\t" : "=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), @@ -99,7 +99,7 @@ static int decode_significance_8x8_x86(CABACContext *c, x86_reg state; __asm__ volatile( "mov %1, %6 \n\t" - "2: \n\t" + "3: \n\t" "mov %10, %0 \n\t" "movzbl (%0, %6), %k6 \n\t" @@ -110,7 +110,7 @@ static int decode_significance_8x8_x86(CABACContext *c, "mov %1, %k6 \n\t" "test $1, %4 \n\t" - " jz 3f \n\t" + " jz 4f \n\t" "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t" "add %11, %6 \n\t" @@ -123,18 +123,18 @@ static int decode_significance_8x8_x86(CABACContext *c, "movl %k6, (%0) \n\t" "test $1, %4 \n\t" - " jnz 4f \n\t" + " jnz 5f \n\t" "add"OPSIZE" $4, %2 \n\t" - "3: \n\t" + "4: \n\t" "addl $1, %k6 \n\t" "mov %k6, %1 \n\t" "cmpl $63, %k6 \n\t" - " jb 2b \n\t" + " jb 3b \n\t" "mov %2, %0 \n\t" "movl %k6, (%0) \n\t" - "4: \n\t" + "5: \n\t" "addl %8, %k0 \n\t" "shr $2, %k0 \n\t" : "=&q"(coeff_count), "+m"(last), "+m"(index), "+&r"(c->low), From a940198130de3ab0c50d832bf7a27a70cfed11cc Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 17 Mar 2012 09:09:41 -0700 Subject: [PATCH 19/20] cabac: add overread protection to BRANCHLESS_GET_CABAC(). Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind --- libavcodec/x86/cabac.h | 15 ++++++++++----- libavcodec/x86/h264_i386.h | 18 ++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index ca8a1d5b5f..a6ec22831d 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -51,7 +51,7 @@ "xor "tmp" , "ret" \n\t" #endif /* HAVE_FAST_CMOV */ -#define BRANCHLESS_GET_CABAC(ret, statep, low, lowword, range, tmp, tmpbyte, byte) \ +#define BRANCHLESS_GET_CABAC(ret, statep, low, lowword, range, tmp, tmpbyte, byte, end) \ "movzbl "statep" , "ret" \n\t"\ "mov "range" , "tmp" \n\t"\ "and $0xC0 , "range" \n\t"\ @@ -64,9 +64,12 @@ "shl %%cl , "low" \n\t"\ "mov "tmpbyte" , "statep" \n\t"\ "test "lowword" , "lowword" \n\t"\ - " jnz 1f \n\t"\ + " jnz 2f \n\t"\ "mov "byte" , %%"REG_c" \n\t"\ + "cmp "end" , %%"REG_c" \n\t"\ + "jge 1f \n\t"\ "add"OPSIZE" $2 , "byte" \n\t"\ + "1: \n\t"\ "movzwl (%%"REG_c") , "tmp" \n\t"\ "lea -1("low") , %%ecx \n\t"\ "xor "low" , %%ecx \n\t"\ @@ -79,7 +82,7 @@ "add $7 , %%ecx \n\t"\ "shl %%cl , "tmp" \n\t"\ "add "tmp" , "low" \n\t"\ - "1: \n\t" + "2: \n\t" #if HAVE_7REGS && !defined(BROKEN_RELOCATIONS) #define get_cabac_inline get_cabac_inline_x86 @@ -90,10 +93,12 @@ static av_always_inline int get_cabac_inline_x86(CABACContext *c, __asm__ volatile( BRANCHLESS_GET_CABAC("%0", "(%4)", "%1", "%w1", - "%2", "%3", "%b3", "%a6(%5)") + "%2", "%3", "%b3", + "%a6(%5)", "%a7(%5)") : "=&r"(bit), "+&r"(c->low), "+&r"(c->range), "=&q"(tmp) : "r"(state), "r"(c), - "i"(offsetof(CABACContext, bytestream)) + "i"(offsetof(CABACContext, bytestream)), + "i"(offsetof(CABACContext, bytestream_end)) : "%"REG_c, "memory" ); return bit & 1; diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index 31ddaf6ee9..e849a3d90c 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -49,14 +49,16 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "3: \n\t" BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", "%w3", - "%5", "%k0", "%b0", "%a11(%6)") + "%5", "%k0", "%b0", + "%a11(%6)", "%a12(%6)") "test $1, %4 \n\t" " jz 4f \n\t" "add %10, %1 \n\t" BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", "%w3", - "%5", "%k0", "%b0", "%a11(%6)") + "%5", "%k0", "%b0", + "%a11(%6)", "%a12(%6)") "sub %10, %1 \n\t" "mov %2, %0 \n\t" @@ -83,7 +85,8 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, : "=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), "+&r"(c->low), "=&r"(bit), "+&r"(c->range) : "r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), - "i"(offsetof(CABACContext, bytestream)) + "i"(offsetof(CABACContext, bytestream)), + "i"(offsetof(CABACContext, bytestream_end)) : "%"REG_c, "memory" ); return coeff_count; @@ -106,7 +109,8 @@ static int decode_significance_8x8_x86(CABACContext *c, "add %9, %6 \n\t" BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", "%w3", - "%5", "%k0", "%b0", "%a12(%7)") + "%5", "%k0", "%b0", + "%a12(%7)", "%a13(%7)") "mov %1, %k6 \n\t" "test $1, %4 \n\t" @@ -116,7 +120,8 @@ static int decode_significance_8x8_x86(CABACContext *c, "add %11, %6 \n\t" BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", "%w3", - "%5", "%k0", "%b0", "%a12(%7)") + "%5", "%k0", "%b0", + "%a12(%7)", "%a13(%7)") "mov %2, %0 \n\t" "mov %1, %k6 \n\t" @@ -141,7 +146,8 @@ static int decode_significance_8x8_x86(CABACContext *c, "=&r"(bit), "+&r"(c->range), "=&r"(state) : "r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_coeff_ctx_base), - "i"(offsetof(CABACContext, bytestream)) + "i"(offsetof(CABACContext, bytestream)), + "i"(offsetof(CABACContext, bytestream_end)) : "%"REG_c, "memory" ); return coeff_count; From 44257ef4267f01dd698c8ab8abf50fd77136a8ce Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 28 Mar 2012 10:22:25 -0700 Subject: [PATCH 20/20] asf: only set index_read if the index contained entries. This allows falling back to a binary search if the file contains no index, thus fixing seeking in such files (e.g. luckynight.wma). --- libavformat/asfdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index d3869b427b..f094647ba0 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -1235,7 +1235,7 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index) last_pos=pos; } } - asf->index_read= 1; + asf->index_read= ict > 0; } avio_seek(s->pb, current_pos, SEEK_SET); }