From patchwork Sun Jan 5 14:45:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 17202 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 1FC0A44A990 for ; Sun, 5 Jan 2020 16:53:12 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E7A2C68A97C; Sun, 5 Jan 2020 16:53:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 22A7C689A59 for ; Sun, 5 Jan 2020 16:53:05 +0200 (EET) Received: by mail-wm1-f68.google.com with SMTP id a5so12509689wmb.0 for ; Sun, 05 Jan 2020 06:53:05 -0800 (PST) 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=VwusONVAPqo1rD2yZxxy8NqFrsa5JqRNZ2Iprlmr42k=; b=PTMOQifmtVYfHUgOA22zDUHDawmvAL2ymrSEgLjaNWfAwjnvlnykLf7cfQF9daLXT7 20Vih3uyDEeCUV20hWy3P0LCXyw7PMi1nd9HM1X2rU7tg1H1v43h/yXdptnIFyxNBeia r/QHHthHHAyyaqsyt8qFh9IkYfs9Xp24Lo7q5O4q9LxoJTw2H22osLH9iEHLPdThqJIE 1PrOpn/rPLJQRHgakciErwwTPU7rOhcd1ioUVButXa1tvuxRmdlXqBFdj72bBqi/OPlO bi2/TfeQGh5JELVlvb/1L3mAMyYyu71GMX5FAwmeESfJOFkjT4UQQybvosoV94I5F0gd 8tFw== 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=VwusONVAPqo1rD2yZxxy8NqFrsa5JqRNZ2Iprlmr42k=; b=R9mPUof/mMccX3fHA5KxTFzBEZ3xRl74WSeZZcifA69uvSnyOKzsxEne5/wSTZrdvq IChpTKlP1JOF0YC9zzqMHKfQrivrbO7gDjSny2Q3/LEx+PtWqNrAPwQda3nXEr2urokB Q/Jo28CEcfFFNy3z23R484SAVtLRgerogCNPPCFcpNggmn9bcGu+RyoZGcpTrzQNKDFt r1IphJ9G1UYumicTCjv3wy5+0duUvdAS4HfnEW3khhOTBtBVddbj5YIdMxm0ALvuyfUW Qg4mFSuD8hyl39nrRG/FXSX0ok9dI+Pb1YWENsPZV1idWrM1jOXa2mkRKequmrrivSGI AAOg== X-Gm-Message-State: APjAAAU5jNCQhbm8WpdSwsA9A5xK2ix4A4HbdEpDZXmJkNGZES1fAJIF xFXv7O50DNOmyzBl+mtz3Ar6lz/O X-Google-Smtp-Source: APXvYqzf9g/oRkLLs7n5AqSS5vc2HfD7OB0tnPwtDIbK/pFmEUMWBn0X0y2tuMdnmCksQZwiUtfYYw== X-Received: by 2002:a05:600c:1007:: with SMTP id c7mr31509881wmc.158.1578235559855; Sun, 05 Jan 2020 06:45:59 -0800 (PST) Received: from localhost.localdomain ([82.129.88.112]) by smtp.gmail.com with ESMTPSA id f1sm69455037wrp.93.2020.01.05.06.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 06:45:59 -0800 (PST) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Sun, 5 Jan 2020 14:45:25 +0000 Message-Id: <20200105144525.6716-1-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.25.0.rc0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] lavc/ffv1: Properly check that the 4th and 5th quant tables are zeroes 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: jerome@mediaarea.net Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Currently, the decoder checks the 128th value of the 4th quant table during while deriving the context on each sample, in order to speed itself up. This is due to relying on the behavior of FFmpeg's FFV1 encoder, in which if that value is zero, the entire 4th and 5th quant tables are assumed to be entirely zero. This does not match the FFV1 spec, which has no such restriction, and after some discussion, it was decided to fix FFmpeg to abide by the spec, rather than change the spec. We will now check whether the 4th and 5th quant tables are zero properly, by checking the 128th valye of both tables (which means they are zero due to the way they're coded in the bitstream). For further context, the FFV1 issue in question is located at: https://github.com/FFmpeg/FFV1/issues/169 Signed-off-by: Derek Buitenhuis --- libavcodec/ffv1_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ffv1_template.c b/libavcodec/ffv1_template.c index f2ab93313a..c5f61b0182 100644 --- a/libavcodec/ffv1_template.c +++ b/libavcodec/ffv1_template.c @@ -37,7 +37,7 @@ static inline int RENAME(get_context)(PlaneContext *p, TYPE *src, const int RT = last[1]; const int L = src[-1]; - if (p->quant_table[3][127]) { + if (p->quant_table[3][127] || p->quant_table[4][127]) { const int TT = last2[0]; const int LL = src[-2]; return p->quant_table[0][(L - LT) & 0xFF] +