From patchwork Thu Oct 8 19:53:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22769 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 EA35844B58C for ; Thu, 8 Oct 2020 22:53:48 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D3C5D68B955; Thu, 8 Oct 2020 22:53:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7865068B7F0 for ; Thu, 8 Oct 2020 22:53:41 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id d3so7702344wma.4 for ; Thu, 08 Oct 2020 12:53:41 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=ETYKIs9UMCQw1WMOFqyd4J23vxBZ8fs4SWMylweZF3M=; b=u32zFoLfBWrdXsyeouP/MccuygcJ0mNp1DPK94MR2B4dgRFFL2FLZ4zFE6bWR8igFI /Q5XORbdW81l0gKoWdTjzbFJH7madlBah/zE40DHFEcNzlOBPpUi7Azr6qSUfbP4geJt fYGQnKpgy4Nmfe6TnaBoSIxSRIvBNEZT/ZGFKovRKpzRtvbbVtFpm/KS0FR6+SvCsFKV 2WwI6Yf9xxhymEJi7HS4nRqmcU29Epc06VpynWWsdpLcj63TVbH8V/qGu7+7UgOw2eFq 5bCJAMYCMJVXvINUaFPykRr1Ulac4IBxGRFgstn2lbce4y4VdEXeaTjwvsElBrVcADCW heBQ== 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:mime-version:content-transfer-encoding; bh=ETYKIs9UMCQw1WMOFqyd4J23vxBZ8fs4SWMylweZF3M=; b=dQVBmddEV9NNldSrYKmfO3Lf9q2KpFNgAkxCIap3mb0N1Sh3lg7Lw9S5qdNUQH7Enj F3prnnGXIv3Yu+NejGD/BkaDU+3LC3iFxSj2RswmQPZjD1CSahVzPWzjgEmG4gQiACTU zw9lRlKT2xI3CLwdn2r/DYB0pJlPxChvB8nEhWhpZ3qjDGwdulX9qRhgR57p16icblv0 xITRo9UgkU+ZFBhwYVthfzSLysJiGmlLb1+Tl0YsCAi6OHXtwH1wXcz0b0Ij7+ouQShU Js083RV/kZhol7QQl0aK28+Ce0kxw+scUbyLi7O/gEA8QNXpqEDZPoh+9dzYCsgMagt0 IAOQ== X-Gm-Message-State: AOAM530mnQIC0ZRPS03OA0W8m6mqxgL1JffMgaEhVfGe3qZbZZKa1RAa x4r6RHF22YNQbwbWYVAlvgBj4HfqnMU= X-Google-Smtp-Source: ABdhPJwtXV2BfQjxRtFyni8luhuqQg4oeo1ua3RScEX0FEVeIGdMj+YYkq6sojSi/yvYfgQEYwAvbQ== X-Received: by 2002:a7b:cb46:: with SMTP id v6mr7588991wmj.146.1602186820637; Thu, 08 Oct 2020 12:53:40 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id g14sm8776203wrx.22.2020.10.08.12.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 12:53:39 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Oct 2020 21:53:13 +0200 Message-Id: <20201008195313.471755-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201008195313.471755-1-andreas.rheinhardt@gmail.com> References: <20201008195313.471755-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/mpeg12dec: Optimize reading mpeg2 intra escape codes 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" Said escape code is only six bits long, so that one has at least 25 - 6 bits in the bitstream reader's cache after reading it; therefore the whole following 18 bits (containing the actual code) are already in the bitstream reader's cache, making it unnecessary to reload the cache. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg12dec.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 7b448d3648..3be90d7f25 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -524,10 +524,9 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, } else { /* escape */ run = SHOW_UBITS(re, &s->gb, 6) + 1; - LAST_SKIP_BITS(re, &s->gb, 6); - UPDATE_CACHE(re, &s->gb); + SKIP_BITS(re, &s->gb, 6); level = SHOW_SBITS(re, &s->gb, 12); - SKIP_BITS(re, &s->gb, 12); + LAST_SKIP_BITS(re, &s->gb, 12); i += run; if (i > MAX_INDEX) break; @@ -606,10 +605,9 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, } else { /* escape */ run = SHOW_UBITS(re, &s->gb, 6) + 1; - LAST_SKIP_BITS(re, &s->gb, 6); - UPDATE_CACHE(re, &s->gb); + SKIP_BITS(re, &s->gb, 6); level = SHOW_SBITS(re, &s->gb, 12); - SKIP_BITS(re, &s->gb, 12); + LAST_SKIP_BITS(re, &s->gb, 12); i += run; j = scantable[i]; if (level < 0) {