From patchwork Sat Jul 20 13:51:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 14005 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id BB92B4492B9 for ; Sat, 20 Jul 2019 16:51:56 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9524068ABCE; Sat, 20 Jul 2019 16:51:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6DC9268ABCC for ; Sat, 20 Jul 2019 16:51:50 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id y4so34903107wrm.2 for ; Sat, 20 Jul 2019 06:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YHQkRn+fC1cSG1pmgEbEA78txIoqHvdgQTeIX4vvND4=; b=Pv/T/PV6y+lAuV0gYxDmsfhc8IcS7Za9giK3d+2etUBJWR+9r0Iqhpni+oDxBngw6z 9kJ7JT7uh+uCHb3SqBFQnGv44S4HroYarrBMGbyPxd1873catw9rmxOugDaW3Npr18iv Fgbpf1TO6DqKHREe0mJHxtrPXfpT/RRhVF/ExKmTb+Ew+GJ2/yy20VTGlnC/yaFIC0vs IFxo2PNdnVxk8Qz0X+dUs4PYTz2ZC9MLH0Ye3TnaCpXJla7V2iL5LM1ezyDB8FDDB5Of RiJ9Ojbee0LQ7NmJG9pPXsybrZacf9fmC8BL8fxInn+F/Jg4jtw4h33s1rKWSajhUade 6zGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YHQkRn+fC1cSG1pmgEbEA78txIoqHvdgQTeIX4vvND4=; b=V5u0+K8cE9Ia4Y6KJ15TNpVHWz1/i5pWN+b1k4Jde6TEfy09Phwi3jK0c0TfdKpqsn EibpatV8T+wu/ssk4FNSQFslX0wCcID1V5P2WrTw5cDMNue2GCnoeYgoh67oHuEZJIXC r4non944Hn/AivH+4Yn4XIE7FRFpIswJkEpXVCIGErNgNFia9NxQvQCOf1YZpASaWm5w ZUgXTw2xoXiHw4OMGEQ3iEpfuu6gawA0kLErAkC2XciXhjtZ8RmAhqSl2jZMvUdRqvM0 Mq07fYyFKZj2By7AzbLFoL2kqShtnEK3/JlOYof+GqVpC3N6IlvYjgw5holcCZOD6Blt 7T8A== X-Gm-Message-State: APjAAAWG96RztS5/cqqj293myB8Tuma0tQ4Y6PAlspD69G5mesYt0KV1 9bGams6x0R+42A1Xb//Vqp1lZuxY X-Google-Smtp-Source: APXvYqy3cWV53Bj9k9fGZUF8V7DzKM0aoxOZqr5JRQB3KE1M933A7l/D6cHURE7X4NrDHyYqrH7QDQ== X-Received: by 2002:a5d:4e8a:: with SMTP id e10mr66176802wru.26.1563630709694; Sat, 20 Jul 2019 06:51:49 -0700 (PDT) Received: from localhost.localdomain (ipbcc08b8f.dynamic.kabel-deutschland.de. [188.192.139.143]) by smtp.gmail.com with ESMTPSA id a6sm25286349wmj.15.2019.07.20.06.51.48 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 20 Jul 2019 06:51:49 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 20 Jul 2019 15:51:25 +0200 Message-Id: <20190720135125.59174-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] vp3data, mpc8huff: Make some arrays unsigned to prevent overflow X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Some of the VP3 arrays (namely vp31_intra_y_dequant, vp31_intra_c_dequant and vp31_inter_dequant) are currently declared as array of (const) int8_t despite them being only used to directly initialize an array of uint8_t. vp31_inter_dequant even contains the value 128 which is not representible in int8_t and might generate overflow warnings by compilers. Similarly, mpc8_q4_syms is an array of int8_t that is initialized using values not in the range of an int8_t and that is only accessed via a pointer to uint8_t in ff_init_vlc_sparse. The latter applies to all the other *_bits and *_syms tables in mpc8huff.h, so make them all unsigned. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpc8huff.h | 34 +++++++++++++++++----------------- libavcodec/vp3data.h | 6 +++--- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libavcodec/mpc8huff.h b/libavcodec/mpc8huff.h index 8491037aa4..0566c910ca 100644 --- a/libavcodec/mpc8huff.h +++ b/libavcodec/mpc8huff.h @@ -34,7 +34,7 @@ static const uint8_t mpc8_bands_codes[MPC8_BANDS_SIZE] = { 0x08, 0x09, 0x06, 0x07, 0x05, 0x05, 0x03, 0x03, 0x01, }; -static const int8_t mpc8_bands_bits[MPC8_BANDS_SIZE] = { +static const uint8_t mpc8_bands_bits[MPC8_BANDS_SIZE] = { 1, 3, 5, 6, 7, 8, 8, 9, 10, 11, 12, 12, 12, 13, 12, 12, 12, 12, 12, 13, 12, 12, 12, 11, @@ -48,7 +48,7 @@ static const int8_t mpc8_bands_bits[MPC8_BANDS_SIZE] = { static const uint8_t mpc8_scfi0_codes[MPC8_SCFI0_SIZE] = { 0x00, 0x01, 0x01, 0x01, }; -static const int8_t mpc8_scfi0_bits[MPC8_SCFI0_SIZE] = { +static const uint8_t mpc8_scfi0_bits[MPC8_SCFI0_SIZE] = { 3, 3, 1, 2, }; @@ -60,7 +60,7 @@ static const uint8_t mpc8_scfi1_codes[MPC8_SCFI1_SIZE] = { 0x04, 0x06, 0x02, 0x02, 0x05, 0x07, 0x03, 0x03, }; -static const int8_t mpc8_scfi1_bits[MPC8_SCFI1_SIZE] = { +static const uint8_t mpc8_scfi1_bits[MPC8_SCFI1_SIZE] = { 6, 7, 6, 6, 7, 5, 5, 5, 6, 5, 2, 3, 6, 5, 3, 2, @@ -79,7 +79,7 @@ static const uint8_t mpc8_dscf0_codes[MPC8_DSCF0_SIZE] = { 0x0C, 0x0D, 0x07, 0x08, 0x09, 0x06, 0x07, 0x03, 0x04, 0x05, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, }; -static const int8_t mpc8_dscf0_bits[MPC8_DSCF0_SIZE] = { +static const uint8_t mpc8_dscf0_bits[MPC8_DSCF0_SIZE] = { 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, @@ -105,7 +105,7 @@ static const uint8_t mpc8_dscf1_codes[MPC8_DSCF1_SIZE] = { 0x05, 0x06, 0x07, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0D, }; -static const int8_t mpc8_dscf1_bits[MPC8_DSCF1_SIZE] = { +static const uint8_t mpc8_dscf1_bits[MPC8_DSCF1_SIZE] = { 15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 8, 8, 7, @@ -132,7 +132,7 @@ static const uint8_t mpc8_res_codes[2][MPC8_RES_SIZE] = { 0x03, } }; -static const int8_t mpc8_res_bits[2][MPC8_RES_SIZE] = { +static const uint8_t mpc8_res_bits[2][MPC8_RES_SIZE] = { { 1, 2, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 16, 8, @@ -153,7 +153,7 @@ static const uint8_t mpc8_q1_codes[MPC8_Q1_SIZE] = { 0x03, 0x04, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, }; -static const int8_t mpc8_q1_bits[MPC8_Q1_SIZE] = { +static const uint8_t mpc8_q1_bits[MPC8_Q1_SIZE] = { 6, 4, 4, 3, 3, 3, 3, 3, 4, 4, 4, 5, 7, 8, 9, 10, 11, 12, 12, @@ -196,7 +196,7 @@ static const uint8_t mpc8_q9up_codes[MPC8_Q9UP_SIZE] = { 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x06, 0x07, 0x08, 0x09, 0x00, 0x01, }; -static const int8_t mpc8_q9up_bits[MPC8_Q9UP_SIZE] = { +static const uint8_t mpc8_q9up_bits[MPC8_Q9UP_SIZE] = { 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 9, 9, 9, @@ -272,7 +272,7 @@ static const uint8_t mpc8_q2_codes[2][MPC8_Q2_SIZE] = { 0x03, 0x1C, 0x17, 0x1D, 0x05, } }; -static const int8_t mpc8_q2_bits[2][MPC8_Q2_SIZE] = { +static const uint8_t mpc8_q2_bits[2][MPC8_Q2_SIZE] = { { 12, 11, 10, 11, 13, 11, 9, 8, 9, 11, 11, 8, 7, 8, 11, 11, @@ -324,7 +324,7 @@ static const uint8_t mpc8_q3_codes[MPC8_Q3_SIZE] = { 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x01, 0x00, }; -static const int8_t mpc8_q3_bits[MPC8_Q3_SIZE] = { +static const uint8_t mpc8_q3_bits[MPC8_Q3_SIZE] = { 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, @@ -333,7 +333,7 @@ static const int8_t mpc8_q3_bits[MPC8_Q3_SIZE] = { 8, 8, 8, 8, 8, 9, 9, 9, 9, }; -static const int8_t mpc8_q3_syms[MPC8_Q3_SIZE] = { +static const uint8_t mpc8_q3_syms[MPC8_Q3_SIZE] = { 48, 65, 64, 49, 63, 32, 47, 80, 79, 50, 62, 33, 16, 82, 81, 95, 94, 66, 78, 34, 46, 17, 31, 30, @@ -360,7 +360,7 @@ static const uint8_t mpc8_q4_codes[MPC8_Q4_SIZE] = { 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x01, 0x00, }; -static const int8_t mpc8_q4_bits[MPC8_Q4_SIZE] = { +static const uint8_t mpc8_q4_bits[MPC8_Q4_SIZE] = { 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, @@ -373,7 +373,7 @@ static const int8_t mpc8_q4_bits[MPC8_Q4_SIZE] = { 9, 9, 9, 9, 9, 10, 10, 10, 10, }; -static const int8_t mpc8_q4_syms[MPC8_Q4_SIZE] = { +static const uint8_t mpc8_q4_syms[MPC8_Q4_SIZE] = { 64, 96, 81, 80, 95, 66, 65, 79, 78, 49, 48, 63, 32, 113, 112, 98, 97, 111, 110, 83, 82, 94, 93, 67, @@ -401,7 +401,7 @@ static const uint8_t mpc8_q5_codes[2][MPC8_Q5_SIZE] = { 0x06, 0x07, 0x04, 0x05, 0x03, 0x02, 0x03, } }; -static const int8_t mpc8_q5_bits[2][MPC8_Q5_SIZE] = { +static const uint8_t mpc8_q5_bits[2][MPC8_Q5_SIZE] = { { 7, 7, 6, 5, 4, 3, 3, 2, 3, 3, 4, 5, 6, 7, 7, @@ -430,7 +430,7 @@ static const uint8_t mpc8_q6_codes[2][MPC8_Q6_SIZE] = { 0x06, 0x07, 0x05, 0x06, 0x07, 0x02, 0x03, } }; -static const int8_t mpc8_q6_bits[2][MPC8_Q6_SIZE] = { +static const uint8_t mpc8_q6_bits[2][MPC8_Q6_SIZE] = { { 9, 9, 9, 9, 8, 8, 7, 6, 6, 6, 5, 5, 4, 4, 3, 2, @@ -471,7 +471,7 @@ static const uint8_t mpc8_q7_codes[2][MPC8_Q7_SIZE] = { 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x02, 0x03, } }; -static const int8_t mpc8_q7_bits[2][MPC8_Q7_SIZE] = { +static const uint8_t mpc8_q7_bits[2][MPC8_Q7_SIZE] = { { 10, 10, 10, 9, 9, 10, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, @@ -536,7 +536,7 @@ static const uint8_t mpc8_q8_codes[2][MPC8_Q8_SIZE] = { 0x27, 0x28, 0x29, 0x04, 0x05, 0x06, 0x07, } }; -static const int8_t mpc8_q8_bits[2][MPC8_Q8_SIZE] = { +static const uint8_t mpc8_q8_bits[2][MPC8_Q8_SIZE] = { { 11, 11, 10, 10, 10, 10, 10, 9, 10, 9, 10, 12, 12, 11, 11, 11, diff --git a/libavcodec/vp3data.h b/libavcodec/vp3data.h index d520a10c76..3f24d5f7f6 100644 --- a/libavcodec/vp3data.h +++ b/libavcodec/vp3data.h @@ -26,7 +26,7 @@ /* these coefficients dequantize intraframe Y plane coefficients * (note: same as JPEG) */ -static const int8_t vp31_intra_y_dequant[64] = { +static const uint8_t vp31_intra_y_dequant[64] = { 16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, @@ -39,7 +39,7 @@ static const int8_t vp31_intra_y_dequant[64] = { /* these coefficients dequantize intraframe C plane coefficients * (note: same as JPEG) */ -static const int8_t vp31_intra_c_dequant[64] = { +static const uint8_t vp31_intra_c_dequant[64] = { 17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99, @@ -51,7 +51,7 @@ static const int8_t vp31_intra_c_dequant[64] = { }; /* these coefficients dequantize interframe coefficients (all planes) */ -static const int8_t vp31_inter_dequant[64] = { +static const uint8_t vp31_inter_dequant[64] = { 16, 16, 16, 20, 24, 28, 32, 40, 16, 16, 20, 24, 28, 32, 40, 48, 16, 20, 24, 28, 32, 40, 48, 64,