From patchwork Tue May 3 16:30:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 35577 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp505557pzb; Tue, 3 May 2022 09:31:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxb1/P1rqJZdF1FUeDyq4iKCnKHRh0yxUL+ZJKCrppShKSnMlr5gIsYyBuTkl79SwEcsXdU X-Received: by 2002:a05:6402:2318:b0:413:7645:fa51 with SMTP id l24-20020a056402231800b004137645fa51mr18686834eda.201.1651595486366; Tue, 03 May 2022 09:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651595486; cv=none; d=google.com; s=arc-20160816; b=IXrVns9uAY0finWco8EY6qrcnEy1Svfe38h4e0lUiPSlAMB76L+3EYTIJNb4ONpMlf aqAL0v11ySyGUG+PORV+2d+e1/3cMa9o+dQx8MjRLOUWmzdQfj/HijoHDVHulcXS6amO bq+h2tHayE8o5Gzk3nwZTFkKT9RPautRxnK6IM7CbxnCsXWlMFti3hCCM2OMStcPWGHv 4OLM5CMUzPPXpF5YF4aZ1LU7bvJSdUXaClnyxSquqNuSatMiO7hdRR7fDsQUK7Dq6zjE 5L5LHBqs0QD32ecWWU+W+qt5hclLZlkOEsvABfSop86S1d1jRjqp5S17LIBWMxSK3tZa GYhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=PcH8LDdBvVz4I7c9dXbeAOoIM5JzYs30zQs26EhObOg=; b=ptAWrmwhkQAQ45pOuFCjACJdw9dx/ffN4P1Ir5KIeMQdPyLxpPewXDk5tdpcpb3G2f azCCYXSSCb+AmlGTr93XXMxnpAAwcMfrn4v/lI+69wRkjM59FukwHSMXLiqthDc6zvZr fROpDwU9onYNEKxBbQhuNDwGYHqqchpyWTobZJfMqh1CBLvPE8g7QpTBFX5kQpVBDsSu NFilxSHsl89tL/MPzBLWsDdx891aIXSnOl5qIn6zvUNhRULFKFmv4jeTmZhTnseUzR09 tpotVp8sokn0yOArmGFlUNTGpZJLgKjClkQppnCUvr9x5STVUhESMCwP0kv9OhkPEelw lO2g== 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 sd26-20020a170906ce3a00b006f41625e74asi7385214ejb.17.2022.05.03.09.31.26; Tue, 03 May 2022 09:31:26 -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 7104968B3D4; Tue, 3 May 2022 19:31:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-at02-3.mx.upcmail.net (vie01a-dmta-at02-3.mx.upcmail.net [62.179.121.150]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E158F68B323 for ; Tue, 3 May 2022 19:31:16 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-at02.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1nlvQh-0007Al-OG for ffmpeg-devel@ffmpeg.org; Tue, 03 May 2022 18:31:15 +0200 Received: from ren-mail-psmtp-mg02. ([80.109.253.241]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id lvQhnlMcuSgGFlvQhnKMWk; Tue, 03 May 2022 18:31:15 +0200 Received: from localhost ([213.47.68.29]) by ren-mail-psmtp-mg02. with ESMTP id lvQSnJnkT8eSWlvQSnfB6y; Tue, 03 May 2022 18:31:00 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.4 cv=KKE5sHJo c=1 sm=1 tr=0 ts=627158d3 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=TBRyIjXBjLUW-Ng_AUEA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 3 May 2022 18:30:59 +0200 Message-Id: <20220503163059.26728-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220503163059.26728-1-michael@niedermayer.cc> References: <20220503163059.26728-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfCVfypRd5PGEZbgc8q/Xcyxh94VZ8ObZ6fE4PJHdYoZGbc2cVZSty413KZHWoGd5a0mtIEE4lAADSOoaZC8XWuTqMTpZRNJe+CkLXYpnqLrKqNEi90kP Np+0E/oWhhjWCENcgCFdFTdVr1XSg/z3Hpbka/Wk0a638W9xlUsiVNaNEV5FwwuEWX2D0Z40TIvVwA== Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/smacker: Optimize constant 16bit audio output 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bwh77ikvy2Ju Signed-off-by: Michael Niedermayer --- libavcodec/smacker.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 179c70f1ee..5d94a54179 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -601,7 +601,7 @@ static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame, int i, res, ret; int unp_size; int bits, stereo; - unsigned pred[2], val; + unsigned pred[2], val, val2; if (buf_size <= 4) { av_log(avctx, AV_LOG_ERROR, "packet is too small\n"); @@ -672,7 +672,11 @@ static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame, pred[i] = av_bswap16(get_bits(&gb, 16)); for(i = 0; i <= stereo; i++) *samples++ = pred[i]; - for(; i < unp_size / 2; i++) { + unp_size /= 2; + + if (vlc[0 ].table || vlc[ 1].table || + vlc[2*stereo].table || vlc[2*stereo+1].table) { + for(; i < unp_size ; i++) { unsigned idx = 2 * (i & stereo); if (get_bits_left(&gb) < 0) { ret = AVERROR_INVALIDDATA; @@ -691,6 +695,22 @@ static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame, pred[idx / 2] += val; *samples++ = pred[idx / 2]; } + } else if (stereo) { + val = 256*values[1] + values[0]; + val2 = 256*values[3] + values[2]; + for(; i < unp_size; i+=2) { + pred[0] += val; + pred[1] += val2; + *samples++ = pred[0]; + *samples++ = pred[1]; + } + } else { + val = 256*values[1] + values[0]; + for(; i < unp_size; i++) { + pred[0] += val; + *samples++ = pred[0]; + } + } } else { //8-bit data for(i = stereo; i >= 0; i--) pred[i] = get_bits(&gb, 8);