From patchwork Sat Aug 14 11:29:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mapul Bhola X-Patchwork-Id: 29507 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp376200iov; Sat, 14 Aug 2021 04:29:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnUAIlDDtfEpkeAMYZbRNrETJ4frgzoKSSLr2lpW2iTMz7t+12CDZlZWtZH9JNDezNFxWD X-Received: by 2002:a17:906:c7c2:: with SMTP id dc2mr7195995ejb.472.1628940591376; Sat, 14 Aug 2021 04:29:51 -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 i14si4312682ejc.361.2021.08.14.04.29.51; Sat, 14 Aug 2021 04:29:51 -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="V/cLvBV+"; 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 79AB868A628; Sat, 14 Aug 2021 14:29:48 +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 46F4568A588 for ; Sat, 14 Aug 2021 14:29:41 +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 AFD7D2000126A2D3 for ; Sat, 14 Aug 2021 11:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=e.email; s=mail1; t=1628940580; 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=+5ArEpRl9kKv/WLhh6bAVEtH5fkpNaWMJYmqMBXoQQM=; b=V/cLvBV+vnpEtm6LnRl/8+ZJNjBmuQFT4wIhqFo66DKblxl/XV2WqEYG27H/gcZM+lVlQ1 8eKUVI2ZG8HFoiE86cn/k0Nxtgn7P0oJ6GKXlCGCTZ8nFECah2Y7V/2OpMv3bPzc5WdFOw DnmadZ6LtdLpzpkU0YdRSEVOc3v6Mr0= MIME-Version: 1.0 Date: Sat, 14 Aug 2021 11:29:40 +0000 From: ffmpegandmahanstreamer@e.email Message-ID: To: ffmpeg-devel@ffmpeg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=e.email; s=mail1; t=1628940580; 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=+5ArEpRl9kKv/WLhh6bAVEtH5fkpNaWMJYmqMBXoQQM=; b=HFTN42S30AP4lYJG5OlDLd2wT97AfumpBrKxP7IXj9f80JQSFb1TOU5o4KxSiGcP2KrTYP UmUTDN4Vz+57sZc6iMwgDwFxxMt4EroJjXtW8WSrB5+DZhgl1cW4YcWRZLTjBbGfxmF3dr FCWGx0qX3wz24gBSZypOUvQpc5ssiW4= ARC-Seal: i=1; s=mail1; d=e.email; t=1628940580; a=rsa-sha256; cv=none; b=YI+3axUBSa+poSTh1zjDZfx0lP3Nmy77hhLjqLUepfSHAF47IzpaHI8Au68iJqzXkreMAz WBjVvlXJpElP/alJT3iZkEwz2WpOwXCKMft1HuHUf04w1F03l05TSM8EGpB1s5K9oPLbgI ISutvJECz5rjPK0Wwqwjy9OSIr/gJVw= ARC-Authentication-Results: i=1; mail.ecloud.global; auth=pass smtp.mailfrom=ffmpegandmahanstreamer@e.email Subject: [FFmpeg-devel] [PATCH] avcodec/truemotion1: Cleanup prediction code in truemotion1_decode_16bit and truemotion1_decode_24bit 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: GV5fLUSzhPHN 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 | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index 32d8fb4005..3f13de0ff8 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -660,20 +660,14 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s) 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_C_PREDICTOR(); } + APPLY_Y_PREDICTOR(); + OUTPUT_PIXEL_PAIR(); break; case 1: @@ -786,22 +780,17 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s) 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: case 3: /* always apply 2 Y predictors on these iterations */