From patchwork Sat Feb 18 18:41:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Steinar H. Gunderson" X-Patchwork-Id: 2600 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.22 with SMTP id n22csp203717vsb; Sat, 18 Feb 2017 11:35:52 -0800 (PST) X-Received: by 10.28.6.210 with SMTP id 201mr10820324wmg.85.1487446552429; Sat, 18 Feb 2017 11:35:52 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p197si6508830wmg.0.2017.02.18.11.35.51; Sat, 18 Feb 2017 11:35:52 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8B2DB689A6C; Sat, 18 Feb 2017 21:35:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [193.35.52.29]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 94307680AB1 for ; Sat, 18 Feb 2017 20:50:33 +0200 (EET) Received: from pannekake.samfundet.no ([2001:67c:29f4::50] ident=unknown) by cassarossa.samfundet.no with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <2f19873f7a9fa90798e69a53cd2824f843a0e1be@pannekake.samfundet.no>) id 1cfA5f-0003P7-5v for ffmpeg-devel@ffmpeg.org; Sat, 18 Feb 2017 19:50:39 +0100 Received: from sesse by pannekake.samfundet.no with local (Exim 4.84_2) (envelope-from <2f19873f7a9fa90798e69a53cd2824f843a0e1be@pannekake.samfundet.no>) id 1cfA5f-0006Z7-34 for ffmpeg-devel@ffmpeg.org; Sat, 18 Feb 2017 19:50:39 +0100 From: "Steinar H. Gunderson" Date: Sat, 18 Feb 2017 19:41:02 +0100 To: ffmpeg-devel@ffmpeg.org Message-Id: X-Mailman-Approved-At: Sat, 18 Feb 2017 21:35:40 +0200 Subject: [FFmpeg-devel] [PATCH] speedhq: fix decoding artifacts 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The quantization table is stored in the natural order, but when we access it, we use an index that's in zigzag order, causing us to read the wrong value. This causes artifacts, especially in areas with horizontal or vertical edges. The artifacts look a lot like the DCT ringing artifacts you'd expect to see from a low-bitrate file, but when comparing to NewTek's own decoder, it's obvious they're not supposed to be there. Fix by simply storing the scaled quantization table in zigzag order. Performance is unchanged. --- libavcodec/speedhq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c index 45ee37a4e6..60efb0222b 100644 --- a/libavcodec/speedhq.c +++ b/libavcodec/speedhq.c @@ -409,7 +409,7 @@ static int decode_speedhq_field(const SHQContext *s, const uint8_t *buf, int buf static void compute_quant_matrix(int *output, int qscale) { int i; - for (i = 0; i < 64; i++) output[i] = unscaled_quant_matrix[i] * qscale; + for (i = 0; i < 64; i++) output[i] = unscaled_quant_matrix[ff_zigzag_direct[i]] * qscale; } static int speedhq_decode_frame(AVCodecContext *avctx,