Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: IndecisiveTurtle <geoster3d@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com>
Subject: [FFmpeg-devel] [PATCH 2/4] libavcodec/vulkan: Add modifications to common shader for VC2 vulkan encoder
Date: Sat,  8 Mar 2025 14:21:39 +0200
Message-ID: <20250308122140.59850-3-47210458+raphaelthegreat@users.noreply.github.com> (raw)
In-Reply-To: <20250308122140.59850-2-47210458+raphaelthegreat@users.noreply.github.com>

---
 libavcodec/vulkan/common.comp | 58 +++++++++++++++++++++++++++--------
 1 file changed, 46 insertions(+), 12 deletions(-)

diff --git a/libavcodec/vulkan/common.comp b/libavcodec/vulkan/common.comp
index e4e983b3e2..3dc1527529 100644
--- a/libavcodec/vulkan/common.comp
+++ b/libavcodec/vulkan/common.comp
@@ -18,6 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#extension GL_EXT_buffer_reference : require
+#extension GL_EXT_buffer_reference2 : require
+
 layout(buffer_reference, buffer_reference_align = 1) buffer u8buf {
     uint8_t v;
 };
@@ -57,22 +60,20 @@ layout(buffer_reference, buffer_reference_align = 8) buffer u64buf {
 #define mid_pred(a, b, c) \
     max(min((a), (b)), min(max((a), (b)), (c)))
 
-/* TODO: optimize */
+
 uint align(uint src, uint a)
 {
-    uint res = src % a;
-    if (res == 0)
-        return src;
-    return src + a - res;
+    return (src + a - 1) & ~(a - 1);
+}
+
+int align(int src, int a)
+{
+    return (src + a - 1) & ~(a - 1);
 }
 
-/* TODO: optimize */
 uint64_t align64(uint64_t src, uint64_t a)
 {
-    uint64_t res = src % a;
-    if (res == 0)
-        return src;
-    return src + a - res;
+    return (src + a - 1) & ~(a - 1);
 }
 
 #define reverse4(src) \
@@ -163,6 +164,39 @@ uint32_t flush_put_bits(inout PutBitContext pb)
     return uint32_t(pb.buf - pb.buf_start);
 }
 
+void skip_put_bytes(inout PutBitContext pb, int n)
+{
+    int bytes_left = pb.bit_left >> 3;
+    if (n < bytes_left)
+    {
+        int n_bits = n << 3;
+        int mask = (1 << n_bits) - 1;
+        pb.bit_buf <<= n_bits;
+        pb.bit_buf |= mask;
+        pb.bit_left -= uint8_t(n_bits);
+        return;
+    }
+    if (pb.bit_left < BUF_BITS)
+    {
+        int mask = (1 << pb.bit_left) - 1;
+        pb.bit_buf <<= pb.bit_left;
+        pb.bit_buf |= mask;
+        u32vec2buf(pb.buf).v = BUF_REVERSE(pb.bit_buf);
+        pb.buf += BUF_BYTES;
+        n -= pb.bit_left >> 3;
+    }
+    int skip_dwords = n >> 2;
+    while (skip_dwords > 0)
+    {
+        u32buf(pb.buf).v = 0xFFFFFFFF;
+        pb.buf += 4;
+        skip_dwords--;
+    }
+    int skip_bits = (n & 3) << 3;
+    pb.bit_buf = (1 << skip_bits) - 1;
+    pb.bit_left = uint8_t(BUF_BITS - skip_bits);
+}
+
 void init_put_bits(out PutBitContext pb, u8buf data, uint64_t len)
 {
     pb.buf_start = uint64_t(data);
@@ -177,8 +211,8 @@ uint64_t put_bits_count(in PutBitContext pb)
     return (pb.buf - pb.buf_start)*8 + BUF_BITS - pb.bit_left;
 }
 
-uint32_t put_bytes_count(in PutBitContext pb)
+int32_t put_bytes_count(in PutBitContext pb)
 {
     uint64_t num_bytes = (pb.buf - pb.buf_start) + ((BUF_BITS - pb.bit_left) >> 3);
-    return uint32_t(num_bytes);
+    return int32_t(num_bytes);
 }
-- 
2.48.1

_______________________________________________
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".

  reply	other threads:[~2025-03-08 12:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-08 12:21 [FFmpeg-devel] [PATCH 1/4] libavcodec/vc2enc: Split out common functions between software and hardware encoders IndecisiveTurtle
2025-03-08 12:21 ` IndecisiveTurtle [this message]
2025-03-08 12:21 ` [FFmpeg-devel] [PATCH 3/4] libavcodec/vulkan: Add vulkan vc2 shaders IndecisiveTurtle
2025-03-08 12:21 ` [FFmpeg-devel] [PATCH 4/4] avcodec/vc2enc: Initial vulkan VC2 encoder Implements a Vulkan based dirac encoder. Supports Haar and Legall wavelets and should work with all wavelet depths IndecisiveTurtle
2025-03-08 13:13 ` [FFmpeg-devel] [PATCH 1/4] libavcodec/vc2enc: Split out common functions between software and hardware encoders Andreas Rheinhardt
2025-03-08 13:52   ` IndecisiveTurtle
2025-03-08 14:05     ` Andreas Rheinhardt
2025-03-08 14:22       ` IndecisiveTurtle

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=20250308122140.59850-3-47210458+raphaelthegreat@users.noreply.github.com \
    --to=geoster3d@gmail.com \
    --cc=47210458+raphaelthegreat@users.noreply.github.com \
    --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