From patchwork Wed Jul 24 06:51:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ross X-Patchwork-Id: 50721 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:a742:0:b0:482:c625:d099 with SMTP id f2csp3286537vqm; Wed, 24 Jul 2024 07:36:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX3HHTvYb77S0KIRoT687jRR8e51FOnz9MkyjyTNQzRxXgGTKcibEqMtLl9hQ53NVHmp01gg9Oic+IjFist2YUf3HodHR18JEPLeA== X-Google-Smtp-Source: AGHT+IGz+y/qLNXj5uoSGc/oJpIhKPOCQ1DquLvY1+6uTKii0BlCWAFCUlqeUm1kbd7R9Rim2cgC X-Received: by 2002:a17:907:3fa5:b0:a7a:a7b8:ada6 with SMTP id a640c23a62f3a-a7aa7b8af91mr306477566b.39.1721831809443; Wed, 24 Jul 2024 07:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721831809; cv=none; d=google.com; s=arc-20160816; b=vpPogM1vz52smVGU/P6FIDEF2RVc/38zDl2qjizqHvh3866EUj8kcTIk5AzNgcpPTY 2ItfaMj9VhBZzCIHFB1xv5GoqywXIsTp4tOp74pnuxiKh1yVBLnnCk0zb1c9zhLcRqLd u80J6N587odYxmMFJVqpzTt6mhzoc+VIM8ZJu9zzz/7JtxbpiEOXw+b3K0/IvW3TPOzh a/BL3U+8ueKSzFF4loFD47IWapDSADMd+gwZ29SGqACph037/1qJ3ESH/2a60CJTd8F1 MILVprweWXxjBspQ2HuQbBISEmMsaHE+HgCOotmKR3fRfcy2U1cTmC1qqlTHMylmoq/2 d37A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:to:from:date:delivered-to; bh=P15F/Got9gmCMZ76iM1u3jOIKyuH4mCGizlR0kCqXtg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=NSvS1RFOrKvTxdjN6Dx72gDppGPqNjLYMcg+m1PkkdqjUCcWQT/IUA4q8n9Q8DlPrA DPug4d8kAPbrnVOfl9JK9yU5xsKTfjV5GgjYSkvClkocJNJ491IQHy59mmPrwKy+Xt83 lomISRbVuBN9wi0B3JvDc2ohJVQ6+Yf5gw7yNPqYVA44lyno08/nXLBM/PWH3wTJbj0Y JZxkcrTis1ZhYgVvKIUZG83VuYWF4vT/s66lZeGrbcQRuvr4OYppvnRgGQf0RKhFXrAD 43WzztQNRRObQV7OuS0FKfwbTUEb96PtnzrL3XwVOCdddB3g+lQCwPjWHros3gV1EwqO 4CBA==; dara=google.com ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a7aaa847347si144837966b.358.2024.07.24.07.36.48; Wed, 24 Jul 2024 07:36:49 -0700 (PDT) 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 991E368D4AE; Wed, 24 Jul 2024 09:51:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0A19468CC49 for ; Wed, 24 Jul 2024 09:51:35 +0300 (EEST) Received: from 7ba90722f570c2b0104f5b8afe4fa274 ([1.145.233.243]) (authenticated (0 bits)) by mx.sdf.org (8.18.1/8.14.3) with ESMTPSA id 46O6pS5i002008 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for ; Wed, 24 Jul 2024 06:51:32 GMT Date: Wed, 24 Jul 2024 16:51:22 +1000 From: Peter Ross To: ffmpeg-devel@ffmpeg.org Message-ID: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/adpcm: only process right samples when decoding stereo X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: UVsBJfxSoYjl Fixes Coverity issue #1610760. --- libavcodec/adpcm.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index afdbeaa15e..58f2ef0dfb 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -1684,22 +1684,24 @@ static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame, for (int count2 = 0; count2 < (channels == 2 ? 28 : 14); count2++) { byte = bytestream2_get_byteu(&gb); next_left_sample = sign_extend(byte >> 4, 4) * (1 << shift_left); - next_right_sample = sign_extend(byte, 4) * (1 << shift_right); next_left_sample = (next_left_sample + (current_left_sample * coeff1l) + (previous_left_sample * coeff2l) + 0x80) >> 8; - next_right_sample = (next_right_sample + - (current_right_sample * coeff1r) + - (previous_right_sample * coeff2r) + 0x80) >> 8; previous_left_sample = current_left_sample; current_left_sample = av_clip_int16(next_left_sample); - previous_right_sample = current_right_sample; - current_right_sample = av_clip_int16(next_right_sample); *samples++ = current_left_sample; if (channels == 2){ + next_right_sample = sign_extend(byte, 4) * (1 << shift_right); + + next_right_sample = (next_right_sample + + (current_right_sample * coeff1r) + + (previous_right_sample * coeff2r) + 0x80) >> 8; + + previous_right_sample = current_right_sample; + current_right_sample = av_clip_int16(next_right_sample); *samples++ = current_right_sample; } else { next_left_sample = sign_extend(byte, 4) * (1 << shift_left);