Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Lynne <dev@lynne.ee>
To: ffmpeg-devel@ffmpeg.org
Cc: Lynne <dev@lynne.ee>
Subject: [FFmpeg-devel] [PATCH 4/7] lavc/vulkan/common: sign-ify lengths
Date: Fri, 11 Jul 2025 00:13:32 +0900
Message-ID: <20250710151349.1157547-4-dev@lynne.ee> (raw)
In-Reply-To: <20250710151349.1157547-1-dev@lynne.ee>

This makes left_bits return useful data rather than overflowing, and
also saves some 64-bit integer operations, which is still always a plus sadly.
---
 libavcodec/vulkan/common.comp | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavcodec/vulkan/common.comp b/libavcodec/vulkan/common.comp
index 10af9c0623..6825693fa3 100644
--- a/libavcodec/vulkan/common.comp
+++ b/libavcodec/vulkan/common.comp
@@ -193,8 +193,8 @@ struct GetBitContext {
     uint64_t buf_end;
 
     uint64_t bits;
-    uint bits_valid;
-    uint size_in_bits;
+    int bits_valid;
+    int size_in_bits;
 };
 
 #define LOAD64()                                       \
@@ -216,11 +216,11 @@ struct GetBitContext {
         gb.bits_valid += 32;                                      \
     }
 
-void init_get_bits(inout GetBitContext gb, u8buf data, uint64_t len)
+void init_get_bits(inout GetBitContext gb, u8buf data, int len)
 {
     gb.buf = gb.buf_start = uint64_t(data);
     gb.buf_end = uint64_t(data) + len;
-    gb.size_in_bits = uint(len) * 8;
+    gb.size_in_bits = len * 8;
 
     /* Preload */
     LOAD64()
@@ -237,7 +237,7 @@ bool get_bit(inout GetBitContext gb)
     return val;
 }
 
-uint get_bits(inout GetBitContext gb, uint n)
+uint get_bits(inout GetBitContext gb, int n)
 {
     if (n == 0)
         return 0;
@@ -251,7 +251,7 @@ uint get_bits(inout GetBitContext gb, uint n)
     return val;
 }
 
-uint show_bits(inout GetBitContext gb, uint n)
+uint show_bits(inout GetBitContext gb, int n)
 {
     if (n > gb.bits_valid)
         RELOAD32()
@@ -259,7 +259,7 @@ uint show_bits(inout GetBitContext gb, uint n)
     return uint(gb.bits >> (64 - n));
 }
 
-void skip_bits(inout GetBitContext gb, uint n)
+void skip_bits(inout GetBitContext gb, int n)
 {
     if (n > gb.bits_valid)
         RELOAD32()
@@ -268,12 +268,12 @@ void skip_bits(inout GetBitContext gb, uint n)
     gb.bits_valid -= n;
 }
 
-uint tell_bits(in GetBitContext gb)
+int tell_bits(in GetBitContext gb)
 {
-    return uint(gb.buf - gb.buf_start) * 8 - gb.bits_valid;
+    return int(gb.buf - gb.buf_start) * 8 - gb.bits_valid;
 }
 
-uint left_bits(in GetBitContext gb)
+int left_bits(in GetBitContext gb)
 {
-    return gb.size_in_bits - uint(gb.buf - gb.buf_start) * 8 + gb.bits_valid;
+    return gb.size_in_bits - int(gb.buf - gb.buf_start) * 8 + gb.bits_valid;
 }
-- 
2.49.0.395.g12beb8f557c
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2025-07-10 15:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-10 15:13 [FFmpeg-devel] [PATCH 1/7] vf_libplacebo: add support for specifying a LUT for the input Lynne
2025-07-10 15:13 ` [FFmpeg-devel] [PATCH 2/7] hwcontext_vulkan: temporarily disable host_image_copy Lynne
2025-07-10 15:13 ` [FFmpeg-devel] [PATCH 3/7] vulkan: add support for 16-bit RGGB Bayer pixfmt Lynne
2025-07-10 15:13 ` Lynne [this message]
2025-07-10 15:13 ` [FFmpeg-devel] [PATCH 5/7] lavc: add codec ID and profiles for ProRes RAW Lynne
2025-07-10 15:13 ` [FFmpeg-devel] [PATCH 6/7] lavc: add a ProRes RAW decoder Lynne
2025-07-10 15:13 ` [FFmpeg-devel] [PATCH 7/7] lavc: add a ProRes RAW Vulkan hwaccel Lynne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250710151349.1157547-4-dev@lynne.ee \
    --to=dev@lynne.ee \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git