From patchwork Tue Nov 10 10:47:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23504 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 8331D440F50 for ; Tue, 10 Nov 2020 12:57:03 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 08AF468BE46; Tue, 10 Nov 2020 12:50:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE6B268BE23 for ; Tue, 10 Nov 2020 12:49:53 +0200 (EET) Received: by mail-wr1-f66.google.com with SMTP id d12so10633205wrr.13 for ; Tue, 10 Nov 2020 02:49:53 -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:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=bpvjtuL0904bHagDoLTOGnC3g0rjuC8b7GCnYbcjLBA=; b=ZZFHxr1Gxh8yzcoS6//sJmXW9ojVnGdKPot6U7FqiTEsIjciQ36jpwTopfvzpm1MGE DGWqESM9xRZgLgN1Rqst6zftcv58b2rSKP2mnZX6eQejrEhkgB0je1lwVrp+u1/z0owp L2exwWi+IPG/jJWSFHMnGSO24ZpPIXGeqEEaKI9h4FsznRC+sjnLM8H83ueoFi7FyUpd p4gczLDF4ykhjAqf0/7ifAagx+FbRf4mJuifcea77b3cN3p8fnOrVWnUNidNwQWc8W0t V/mxs42fQpsKsxKwT/U/tmp/9EKCnoSn1r+ApDjCCZIFY53wHafrUKOw2UsozKATxipX 1I8g== 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:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=bpvjtuL0904bHagDoLTOGnC3g0rjuC8b7GCnYbcjLBA=; b=Aw1c6hOv3n1ucoWW7TIpPQiFvFqhcxEVz/qBOEaIBhGB5oAZvXNMaI2eTRn11lw5uX wFN9MfW1JTxIVYw7/DwLHS5v9yC5iH5Djw9FMOe4OmU1BmUhk/YyiqUPUHIAUrq86v7n 4QAZeOxhEmgUqMBf6HD6gn8pQ9CYP/4g3g3pK0i9QVdBEpVWBiUGiomT0LXKAnBp/J7Q Zy8hDwamqqnhVMsg1DkIwIOJdFZ3uPgC+AS/baV8N6jqceALz9L0JQS+9z7tEjkihxTG 7X5bA4AB7/wEzZV55PFpce34QrG5+mEaujQ45QJzlvQ+G+mnzJXkStqWNkqKCBlei5pc 75hw== X-Gm-Message-State: AOAM532ktNzqvwWyB8OgphKsyaKuRiby6B0byu/6jI864PzWMgw4gOGk OXp+SgThX2OC9BLNWuzZQ6uyPEcdddg= X-Google-Smtp-Source: ABdhPJwPBbuE7qOegiNsozpeewfmLdu0yoWtfINMxx1kbYsSxRT7oXHqWmB7NCZPsj8qU9AAuUrhmA== X-Received: by 2002:a05:6000:100f:: with SMTP id a15mr22625425wrx.309.1605005393092; Tue, 10 Nov 2020 02:49:53 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id l24sm2572543wmi.7.2020.11.10.02.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 02:49:52 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Nov 2020 11:47:30 +0100 Message-Id: <20201110104851.321029-34-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> References: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 033/114] avcodec/motionpixels: Only create VLC iff it is going to be used 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" If the Huffman tree consists of only one entry (which has length zero), no tree is used at all for parsing as the VLC API currently can't handle this. So it makes no sense to create a VLC in this case. Commit 41b7389cade702383e59343561776f83bb26e17f added a check for whether creating the VLC should be skipped, but it also skipped decoding the packet and it used the wrong check: It checked max_codes_bits, the maximum length of code; but this value is only updated iff there is more than one Huffman entry. So if there is only one Huffman entry, and there was a previous frame with more than one entry, then a VLC was created unnecessarily; yet if there was no previous frame with more than one entry, then this frame will be skipped which is probably spec-incompliant. I have no sample for the latter. This commit improves the check to create a VLC iff it is going to be used. Signed-off-by: Andreas Rheinhardt --- libavcodec/motionpixels.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index b48200b017..0bf153f883 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -324,8 +324,7 @@ static int mp_decode_frame(AVCodecContext *avctx, if (sz == 0) goto end; - if (mp->max_codes_bits <= 0) - goto end; + if (mp->codes_count > 1) if (init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0)) goto end; mp_decode_frame_helper(mp, &gb);