From: IndecisiveTurtle <geoster3d@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: IndecisiveTurtle <geoster3d@gmail.com> Subject: [FFmpeg-devel] [PATCH v6 3/4] libavcodec/vulkan: Add modifications to common shader for VC2 vulkan encoder Date: Mon, 2 Jun 2025 22:12:50 +0300 Message-ID: <20250602191313.906527-3-47210458+raphaelthegreat@users.noreply.github.com> (raw) In-Reply-To: <20250602191313.906527-1-47210458+raphaelthegreat@users.noreply.github.com> From: IndecisiveTurtle <geoster3d@gmail.com> --- libavcodec/vulkan/common.comp | 51 ++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/libavcodec/vulkan/common.comp b/libavcodec/vulkan/common.comp index 10af9c0623..59a4a4b1a8 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; }; @@ -61,22 +64,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) \ @@ -146,6 +147,36 @@ void put_bits(inout PutBitContext pb, const uint32_t n, uint32_t value) } } +void put_bits63(inout PutBitContext pb, const uint32_t n, uint64_t value) +{ + if (n < pb.bit_left) { + pb.bit_buf = (pb.bit_buf << n) | value; + pb.bit_left -= uint8_t(n); + } else { + pb.bit_buf <<= pb.bit_left; + pb.bit_buf |= (value >> (n - pb.bit_left)); + +#ifdef PB_UNALIGNED + u8buf bs = u8buf(pb.buf); + [[unroll]] + for (uint8_t i = uint8_t(0); i < BUF_BYTES; i++) + bs[i].v = BYTE_EXTRACT(pb.bit_buf, BUF_BYTES - uint8_t(1) - i); +#else +#ifdef DEBUG + if ((pb.buf % BUF_BYTES) != 0) + debugPrintfEXT("put_bits buffer is not aligned!"); +#endif + + BUF_TYPE bs = BUF_TYPE(pb.buf); + bs.v = BUF_REVERSE(pb.bit_buf); +#endif + pb.buf = uint64_t(bs) + BUF_BYTES; + + pb.bit_left += BUF_BITS - uint8_t(n); + pb.bit_buf = value; + } +} + uint32_t flush_put_bits(inout PutBitContext pb) { /* Align bits to MSBs */ -- 2.49.0 _______________________________________________ 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".
next prev parent reply other threads:[~2025-06-02 19:13 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-06-02 19:12 [FFmpeg-devel] [PATCH v6 1/4] libavcodec/vc2enc: Split out common functions between software and hardware encoders IndecisiveTurtle 2025-06-02 19:12 ` [FFmpeg-devel] [PATCH v6 2/4] libavcodec/vc2enc: Switch quant to int IndecisiveTurtle 2025-06-02 19:12 ` IndecisiveTurtle [this message] 2025-06-02 19:12 ` [FFmpeg-devel] [PATCH v6 4/4] lavc: implement a Vulkan-based VC-2 encoder Implements a Vulkan based dirac encoder. Supports Haar and Legall wavelets and should work with all wavelet depths IndecisiveTurtle 2025-06-02 19:16 ` IndecisiveTurtle 2025-06-08 19:57 ` Michael Niedermayer
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=20250602191313.906527-3-47210458+raphaelthegreat@users.noreply.github.com \ --to=geoster3d@gmail.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