From patchwork Sun Feb 2 19:03:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 17663 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 8F11144B481 for ; Sun, 2 Feb 2020 21:03:14 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 80A3D688191; Sun, 2 Feb 2020 21:03:14 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A40B687FE0 for ; Sun, 2 Feb 2020 21:03:07 +0200 (EET) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailnew.nyi.internal (Postfix) with ESMTP id 384D268AF for ; Sun, 2 Feb 2020 14:03:06 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sun, 02 Feb 2020 14:03:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jailuthra.in; h= from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=hufq26b0K5k5y Qz0LF7mQl9YmhZcLeLpVJT8ptxbiU0=; b=r0dRnvlCYkoJ4JMuWn8276jV/hwAr KgRI2uhfpXlbEmfRJBwcBCDBvTIjaV0TMv0L121gVa4wmF2yKHpf38/dYWBgwKDu TWzWg1qLAXDuksRpcFctsOeVfpi/rof1pV/DWq6L3svfKql8s6Y0OgNUBjFWVuQV i6d/cwvrOMzlgdkj+aJRXF4n72qMBR0a7jNIBVu0q+YQ4/apH+a4swB+YZUv1WNG dBsLcHrjb6s1K1eZ+JYBnHkr7jZ1/WLq7z4mZ3M57QJi88AuGatSmqvLl4hyyVQW s+O4C3TMjXSI5IB8VQc5xitY/Gz6MECJi1NUZ41RocRoXH42OLsPVhXLA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=hufq26b0K5k5yQz0LF7mQl9YmhZcLeLpVJT8ptxbiU0=; b=At/pVhbO EnKD5VLsGojQRNSbWpG5wY33czxCDDXNgGwI6wwrofGE5VZ5ZmOxrdkc0rkwtd78 f4XTLX/KLiyZa/xK3ZW+7mL9d/h6EaanUbJ281ZxnQe5ArtuvfsRDHoHQMdDtmIt b7y4aWEv8GI/REjSvMFoRbmE2vb0fXEDCmKDzaDeIVGTUhgUCM0GeJNgxcgo0nuU e3cOn78ZqhYG/ofN5jzAohakqP8PsnQHZS0OUkPmHY3aVbXRtvhWuc8WNPApGJ1P WD907MR+8fOA2oor/OOl0pJ9YLsrZazSbdo000BjX0HPCTM1NKU2/1aI5h2rF7Sa /gxrrqaALWcmjg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrgeehgdduudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheplfgrihcunfhuthhhrhgruceomhgvsehjrghilhhuthhhrhgr rdhinheqnecuffhomhgrihhnpehlhihnnhgvrdgvvgenucfkphepgeelrddvtdejrdehhe drudegvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pehmvgesjhgrihhluhhthhhrrgdrihhn X-ME-Proxy: Received: from localhost.localdomain (unknown [49.207.55.142]) by mail.messagingengine.com (Postfix) with ESMTPA id A721B30602AD for ; Sun, 2 Feb 2020 14:03:04 -0500 (EST) From: Jai Luthra To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 Feb 2020 00:33:00 +0530 Message-Id: <20200202190300.156267-2-me@jailuthra.in> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200202190300.156267-1-me@jailuthra.in> References: <20200124103334.110855-1-me@jailuthra.in> <20200202190300.156267-1-me@jailuthra.in> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/7] mlp: check huff_lsbs only when codebook is 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" When no codebook is used, huff_lsbs can be more than 24 and still decode to original values once filters are applied. Signed-off-by: Jai Luthra --- libavcodec/mlpdec.c | 2 +- libavcodec/mlpenc.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) Fixes lossless check failures caused with https://lynne.ee/files/sample.flac diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 39c40914cd..22a6efd63d 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -829,7 +829,7 @@ static int read_channel_params(MLPDecodeContext *m, unsigned int substr, cp->codebook = get_bits(gbp, 2); cp->huff_lsbs = get_bits(gbp, 5); - if (cp->huff_lsbs > 24) { + if (cp->codebook > 0 && cp->huff_lsbs > 24) { av_log(m->avctx, AV_LOG_ERROR, "Invalid huff_lsbs.\n"); cp->huff_lsbs = 0; return AVERROR_INVALIDDATA; diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index af04648097..4e60ffd217 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -987,6 +987,9 @@ static void write_decoding_params(MLPEncodeContext *ctx, PutBitContext *pb, put_bits(pb, 1, 0); } } + if (cp->codebook > 0 && cp->huff_lsbs > 24) { + av_log(ctx->avctx, AV_LOG_ERROR, "Invalid Huff LSBs\n"); + } put_bits(pb, 2, cp->codebook ); put_bits(pb, 5, cp->huff_lsbs);