This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new a1050d48b0 avcodec/j2kenc: Compute division only once, preshift bit
a1050d48b0 is described below

commit a1050d48b0df3f7c3fa1c631ec8e82528b3f7c85
Author:     Zsolt Vadasz <[email protected]>
AuthorDate: Fri Jul 3 19:07:04 2026 +0200
Commit:     michaelni <[email protected]>
CommitDate: Tue Aug 25 16:10:16 2026 +0000

    avcodec/j2kenc: Compute division only once, preshift bit
    
    Pre-shift n to the highest bit in put_bits(), and compute a division
    outside of a hot loop in encode_tile().
---
 libavcodec/j2kenc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index cba4d18adf..ac18c66b99 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -153,13 +153,14 @@ typedef struct {
 /** put n times val bit */
 static void put_bits(Jpeg2000EncoderContext *s, int val, int n) // TODO: 
optimize
 {
+    val <<= 7;
     while (n-- > 0){
         if (s->bit_index == 8)
         {
             s->bit_index = *s->buf == 0xff;
             *(++s->buf) = 0;
         }
-        *s->buf |= val << (7 - s->bit_index++);
+        *s->buf |= val >> s->bit_index++;
     }
 }
 
@@ -1384,11 +1385,12 @@ static int encode_tile(Jpeg2000EncoderContext *s, 
Jpeg2000Tile *tile, int tileno
                                 }
                             }
                         } else{
+                            int64_t multiplier = (int64_t)(16384 * 65536 / 
band->i_stepsize);
                             for (y = yy0; y < yy1; y++){
                                 int *ptr = t1.data + (y-yy0)*t1.stride;
                                 for (x = xx0; x < xx1; x++){
                                     *ptr = (comp->i_data[(comp->coord[0][1] - 
comp->coord[0][0]) * y + x]);
-                                    *ptr = (int64_t)*ptr * (int64_t)(16384 * 
65536 / band->i_stepsize) >> 15 - NMSEDEC_FRACBITS;
+                                    *ptr = (int64_t)*ptr * multiplier >> 15 - 
NMSEDEC_FRACBITS;
                                     ptr++;
                                 }
                             }

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to