From patchwork Sun Aug 1 16:22:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mapul Bhola X-Patchwork-Id: 29167 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp908059ioh; Sun, 1 Aug 2021 09:22:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsFYkz9ueMlCpod+jfu7YEMU1YAQrKphftLHcxlYla6VmZn77H77sW4lN0Qd9n11t4S4iS X-Received: by 2002:a17:906:c1da:: with SMTP id bw26mr11887637ejb.253.1627834961793; Sun, 01 Aug 2021 09:22:41 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q22si7820451edw.208.2021.08.01.09.22.41; Sun, 01 Aug 2021 09:22:41 -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; dkim=neutral (body hash did not verify) header.i=@e.email header.s=mail1 header.b=sZaxD7mq; arc=fail (body hash mismatch); 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; dmarc=fail (p=QUARANTINE sp=REJECT dis=NONE) header.from=e.email Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 434B068A5AD; Sun, 1 Aug 2021 19:22:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.ecloud.global (mail.ecloud.global [135.181.85.105]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2B0F768A516 for ; Sun, 1 Aug 2021 19:22:30 +0300 (EEST) Received: from authenticated-user (mail.ecloud.global [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.ecloud.global (Postfix) with ESMTPSA id E077820001050A7E for ; Sun, 1 Aug 2021 16:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=e.email; s=mail1; t=1627834948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8iQGu5WeAbbsXqQ4Yd5O3M1pvTbZ+meN7nql3pya0y8=; b=sZaxD7mqGgEvmzJJHHog+teE0Vbu0vGDfi9M7s66chzCkF9scSA8NV2ASgIC7piZWRfvw/ ytFqltr7/hvtwJTHSkpxwOkbzJt9GM+QpU3TyVTAJK37kjMxqhUJmDtIT6Ds55zfbHjHIt 64XB1xEVDttfeSPuqL4hNrlktQcF5+g= MIME-Version: 1.0 Date: Sun, 01 Aug 2021 16:22:28 +0000 From: ffmpegandmahanstreamer@e.email Message-ID: <5fd309896c6b7278ec4a93029f8827f2@e.email> To: ffmpeg-devel@ffmpeg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=e.email; s=mail1; t=1627834948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8iQGu5WeAbbsXqQ4Yd5O3M1pvTbZ+meN7nql3pya0y8=; b=hpBVRoPvqT2V4OxYaKg+e0vbStiqjmQ+eRAbRTJydNwzkSL/qNg5AHCZ84PJ3NZX6GmH55 Z/8Ddu0Z1RSdu3FC8wDidF+bKN4GdA5F1T27BcAOY1wM0NkwjlZSZVRodPF14iq1Z5MFIB k9WVCrtbbECBnNfGFujaP3Ct6YZSFUA= ARC-Seal: i=1; s=mail1; d=e.email; t=1627834948; a=rsa-sha256; cv=none; b=LxUEVL5LTwWA42T0ln3sRl/JCYUkPlj9y5aTH1tlQrANhvaK53srNee91rct/HV3HTVItM mlRU52+TzesBoM0QA+i33VKSWLecAy8N/FB+CLZTgxDJa0j+n68vk34veHDGiKcohY8Qiu Ad74yblSprS8cj//D0iE3s0ARGodZVU= ARC-Authentication-Results: i=1; mail.ecloud.global; auth=pass smtp.mailfrom=ffmpegandmahanstreamer@e.email Subject: [FFmpeg-devel] Subject: [PATCH] Cleanup code in truemotion1 decoder 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: ZMeiejlZdIoO Per Andreas Rheinhardt request i'm splitting the working patches in two. --- This cleans up the code in the decode24bit and decode16bit functions by putting it in way that expresses the true intent while making it easier to read. libavcodec/truemotion1.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index 32d8fb4005..50c90e732d 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -655,25 +655,19 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s) while (pixels_left > 0) { if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) { - + switch (y & 3) { case 0: /* if macroblock width is 2, apply C-Y-C-Y; else * apply C-Y-Y */ + APPLY_C_PREDICTOR(); + APPLY_Y_PREDICTOR(); + OUTPUT_PIXEL_PAIR(); if (s->block_width == 2) { APPLY_C_PREDICTOR(); - APPLY_Y_PREDICTOR(); - OUTPUT_PIXEL_PAIR(); - APPLY_C_PREDICTOR(); - APPLY_Y_PREDICTOR(); - OUTPUT_PIXEL_PAIR(); - } else { - APPLY_C_PREDICTOR(); - APPLY_Y_PREDICTOR(); - OUTPUT_PIXEL_PAIR(); - APPLY_Y_PREDICTOR(); - OUTPUT_PIXEL_PAIR(); } + APPLY_Y_PREDICTOR(); + OUTPUT_PIXEL_PAIR(); break; case 1: @@ -781,25 +775,19 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s) while (pixels_left > 0) { if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) { - + switch (y & 3) { case 0: /* if macroblock width is 2, apply C-Y-C-Y; else * apply C-Y-Y */ + APPLY_C_PREDICTOR_24(); + APPLY_Y_PREDICTOR_24(); + OUTPUT_PIXEL_PAIR(); if (s->block_width == 2) { APPLY_C_PREDICTOR_24(); - APPLY_Y_PREDICTOR_24(); - OUTPUT_PIXEL_PAIR(); - APPLY_C_PREDICTOR_24(); - APPLY_Y_PREDICTOR_24(); - OUTPUT_PIXEL_PAIR(); - } else { - APPLY_C_PREDICTOR_24(); - APPLY_Y_PREDICTOR_24(); - OUTPUT_PIXEL_PAIR(); - APPLY_Y_PREDICTOR_24(); - OUTPUT_PIXEL_PAIR(); } + APPLY_Y_PREDICTOR_24(); + OUTPUT_PIXEL_PAIR(); break; case 1: