From patchwork Thu Mar 25 15:49:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26606 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 A407344B722 for ; Thu, 25 Mar 2021 17:50:50 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 87A3768AA62; Thu, 25 Mar 2021 17:50:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1FE0468AAC7 for ; Thu, 25 Mar 2021 17:50:37 +0200 (EET) Received: by mail-ej1-f47.google.com with SMTP id ce10so3711532ejb.6 for ; Thu, 25 Mar 2021 08:50:37 -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:reply-to :mime-version:content-transfer-encoding; bh=OjjIZPei1LY64DpCJFChunL8ucCC3DKMhDc67nCs+mQ=; b=CkjvAr6KqZU7V5LXcsZdJ1KBLA2C11vNf3BVt6SXZZ9VAkPSvONB91My1CZ1d6FIAP iTZvXBg0lQfZMJNplLRfMTCLKEEpr5ttC45GjT/JPdCFF0M93lZsnY17gVPUmVD3PM7Y yB27pK1br6HjSW92ASds3u1zH0GTDkSn/R9CgoIPVvEwm0YdoExNmjaf/qq+rJpOPxUR zcora0mFjhSm71n3Y9lHZIBpVMQQUI8x9eVN4El9G4PkkzRUYT2W62/0wnBGwJtWA0fd K6SxlL+F8HrDzEmBZpQQENv7rLrODHqT8W6Hf5nfKed7dNTgbfXC4TPWjbvPSQtRGnSu G5OQ== 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:reply-to:mime-version:content-transfer-encoding; bh=OjjIZPei1LY64DpCJFChunL8ucCC3DKMhDc67nCs+mQ=; b=FOY5d0LvRq0QaNcZrpZPV/ElsvnHcCOM8D4vBYjw4SCHPE1J9JU8q9TT3akkLo8y17 qDyRRDPjazyuJh2AwcO9LqGBGlDPFcGozlQcZdIMC87D+ye9ckeGdPpRQ1omihWSmDqo TjyqBbgG/F3613jyj2aDmwcMEVMC3/W+GeSISAVHehQPu6Rdt9gytHsDwPIWbPx0KUCg KanXEZKt3bZOyGSsPeBSuQj8d0j2GITEXZ42KJyFhpHbORPigW3xLdPpBsvmYHOuCoS5 T06PlNgJkaXTPFxKPKBaHAMptjUH+OqZmY+5pwCpLb9j9oLksSMqrJq5HUxHTpRVdKtr LE8w== X-Gm-Message-State: AOAM530XHo1txiSnZnKCnzTiEztCwldDLDK7Ezpo6XaqYNpk6wXDBOMV SHLXTS2YPyAjJsEYlCiCehxBR5h10hfplw== X-Google-Smtp-Source: ABdhPJwXB59c5NpqVy7MOGYwtnTU0LPf8jWspNIfba/WKkAp/tEj3uQveKEr8Zm3ND3WpsFU1sCkFQ== X-Received: by 2002:a17:906:f84b:: with SMTP id ks11mr10098713ejb.296.1616687436494; Thu, 25 Mar 2021 08:50:36 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id o6sm2859103edw.24.2021.03.25.08.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 08:50:36 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Mar 2021 16:49:52 +0100 Message-Id: <20210325154956.2405162-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210325154956.2405162-1-andreas.rheinhardt@gmail.com> References: <20210325154956.2405162-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/12] avcodec/utvideoenc: Don't use bitcounts when byte-aligned 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" Despite write_huff_codes() receiving an ordinary buffer (not a PutBitContext), it returned the amount of data written in bits, not in bytes. This has been changed: There is now no intermediate bitcount any more. Signed-off-by: Andreas Rheinhardt --- libavcodec/utvideoenc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c index 5c87eb50ac..32c204a898 100644 --- a/libavcodec/utvideoenc.c +++ b/libavcodec/utvideoenc.c @@ -398,13 +398,11 @@ static int write_huff_codes(uint8_t *src, uint8_t *dst, int dst_size, if (count) put_bits(&pb, 32 - count, 0); - /* Get the amount of bits written */ - count = put_bits_count(&pb); - /* Flush the rest with zeroes */ flush_put_bits(&pb); - return count; + /* Return the amount of bytes written */ + return put_bytes_output(&pb); } static int encode_plane(AVCodecContext *avctx, uint8_t *src, @@ -512,11 +510,11 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src, /* * Write the huffman codes to a buffer, - * get the offset in bits and convert to bytes. + * get the offset in bytes. */ offset += write_huff_codes(dst + sstart * width, c->slice_bits, width * height + 4, width, - send - sstart, he) >> 3; + send - sstart, he); slice_len = offset - slice_len;