Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate
@ 2024-02-17 19:54 Andreas Rheinhardt
  2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 2/4] avcodec/jpeg2000dec: Avoid using GetByteContext.buffer directly Andreas Rheinhardt
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Andreas Rheinhardt @ 2024-02-17 19:54 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/j2kenc.c      |  2 +-
 libavcodec/jpeg2000dec.c | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 789791f529..ebf21f6e7a 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -781,7 +781,7 @@ static void putnumpasses(Jpeg2000EncoderContext *s, int n)
 
 
 static int encode_packet(Jpeg2000EncoderContext *s, Jpeg2000ResLevel *rlevel, int layno,
-                         int precno, uint8_t *expn, int numgbits, int packetno,
+                         int precno, const uint8_t *expn, int numgbits, int packetno,
                          int nlayers)
 {
     int bandno, empty = 1;
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 691cfbd891..3d18d48e7c 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -489,7 +489,7 @@ static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)
 
 /* get coding parameters for a particular tile or whole image*/
 static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
-                   uint8_t *properties)
+                   const uint8_t *properties)
 {
     Jpeg2000CodingStyle tmp;
     int compno, ret;
@@ -639,7 +639,7 @@ static int get_qcx(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q)
 
 /* Get quantization parameters for a particular tile or a whole image. */
 static int get_qcd(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q,
-                   uint8_t *properties)
+                   const uint8_t *properties)
 {
     Jpeg2000QuantStyle tmp;
     int compno, ret;
@@ -1004,7 +1004,7 @@ static int getlblockinc(Jpeg2000DecoderContext *s)
     return res;
 }
 
-static inline void select_header(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
+static inline void select_header(Jpeg2000DecoderContext *s, const Jpeg2000Tile *tile,
                                  int *tp_index)
 {
     s->g = tile->tile_part[*tp_index].header_tpg;
@@ -1015,8 +1015,8 @@ static inline void select_header(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
     }
 }
 
-static inline void select_stream(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
-                                 int *tp_index, Jpeg2000CodingStyle *codsty)
+static inline void select_stream(Jpeg2000DecoderContext *s, const Jpeg2000Tile *tile,
+                                 int *tp_index, const Jpeg2000CodingStyle *codsty)
 {
     s->g = tile->tile_part[*tp_index].tpg;
     if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
@@ -1033,9 +1033,9 @@ static inline void select_stream(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
 }
 
 static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, int *tp_index,
-                                  Jpeg2000CodingStyle *codsty,
+                                  const Jpeg2000CodingStyle *codsty,
                                   Jpeg2000ResLevel *rlevel, int precno,
-                                  int layno, uint8_t *expn, int numgbits)
+                                  int layno, const uint8_t *expn, int numgbits)
 {
     int bandno, cblkno, ret, nb_code_blocks;
     int cwsno;
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [FFmpeg-devel] [PATCH 2/4] avcodec/jpeg2000dec: Avoid using GetByteContext.buffer directly
  2024-02-17 19:54 [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate Andreas Rheinhardt
@ 2024-02-17 20:05 ` Andreas Rheinhardt
  2024-02-19 14:00   ` Tomas Härdin
  2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 3/4] avcodec/jpeg2000: Simplify exp2fi for numbers used here Andreas Rheinhardt
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Andreas Rheinhardt @ 2024-02-17 20:05 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/jpeg2000dec.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 3d18d48e7c..1afc6b1e2d 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -886,8 +886,8 @@ static int get_ppm(Jpeg2000DecoderContext *s, int n)
         return AVERROR(ENOMEM);
     s->has_ppm = 1;
     memset(&s->packed_headers_stream, 0, sizeof(s->packed_headers_stream));
-    bytestream_get_buffer(&s->g.buffer, s->packed_headers + s->packed_headers_size,
-                          n - 3);
+    bytestream2_get_bufferu(&s->g, s->packed_headers + s->packed_headers_size,
+                            n - 3);
     s->packed_headers_size += n - 3;
 
     return 0;
@@ -921,10 +921,8 @@ static int get_ppt(Jpeg2000DecoderContext *s, int n)
     } else
         return AVERROR(ENOMEM);
     memset(&tile->packed_headers_stream, 0, sizeof(tile->packed_headers_stream));
-    memcpy(tile->packed_headers + tile->packed_headers_size,
-           s->g.buffer, n - 3);
+    bytestream2_get_bufferu(&s->g, tile->packed_headers + tile->packed_headers_size, n - 3);
     tile->packed_headers_size += n - 3;
-    bytestream2_skip(&s->g, n - 3);
 
     return 0;
 }
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [FFmpeg-devel] [PATCH 3/4] avcodec/jpeg2000: Simplify exp2fi for numbers used here
  2024-02-17 19:54 [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate Andreas Rheinhardt
  2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 2/4] avcodec/jpeg2000dec: Avoid using GetByteContext.buffer directly Andreas Rheinhardt
@ 2024-02-17 20:05 ` Andreas Rheinhardt
  2024-02-19 14:09   ` Tomas Härdin
  2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 4/4] avcodec/internal: Move ff_exp2fi() to aacsbr.c Andreas Rheinhardt
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Andreas Rheinhardt @ 2024-02-17 20:05 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The call to ff_exp2fi() here always uses arguments in the normal
range, so that the branches in ff_exp2fi() are unnecessary.
This is so because JPEG2000 itself only supports up to
128 bits per component per pixel (we only support far less);
furthermore, expn is always 0..31 for the decoder and also
sane for the encoder, so that the difference between these
two values is always in the normal range of -126..128.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/jpeg2000.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 0aa984bc53..d6ffb02319 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -32,7 +32,6 @@
 #include "libavutil/mem.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
-#include "internal.h"
 #include "jpeg2000.h"
 
 #define SHL(a, n) ((n) >= 0 ? (a) << (n) : (a) >> -(n))
@@ -201,6 +200,17 @@ void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1, int x, int y,
 
 // static const uint8_t lut_gain[2][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 2 } }; (unused)
 
+/**
+ * 2^(x) for integer x in the range -126..128.
+ * @return correctly rounded float
+ */
+static av_always_inline float exp2fi(int x)
+{
+    av_assert2(-126 <= x && x <= 128);
+    /* Normal range */
+    return av_int2float((x+127) << 23);
+}
+
 static void init_band_stepsize(AVCodecContext *avctx,
                                Jpeg2000Band *band,
                                Jpeg2000CodingStyle *codsty,
@@ -230,7 +240,7 @@ static void init_band_stepsize(AVCodecContext *avctx,
          * R_b = R_I + log2 (gain_b )
          * see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */
         gain            = cbps;
-        band->f_stepsize  = ff_exp2fi(gain - qntsty->expn[gbandno]);
+        band->f_stepsize  = exp2fi(gain - qntsty->expn[gbandno]);
         band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0;
         break;
     default:
@@ -391,7 +401,7 @@ static int init_band(AVCodecContext *avctx,
                      Jpeg2000CodingStyle *codsty,
                      Jpeg2000QuantStyle *qntsty,
                      int bandno, int gbandno, int reslevelno,
-                     int cbps, int dx, int dy)
+                     const int cbps, int dx, int dy)
 {
     Jpeg2000Band *band = reslevel->band + bandno;
     uint8_t log2_band_prec_width, log2_band_prec_height;
@@ -466,7 +476,7 @@ static int init_band(AVCodecContext *avctx,
 int ff_jpeg2000_init_component(Jpeg2000Component *comp,
                                Jpeg2000CodingStyle *codsty,
                                Jpeg2000QuantStyle *qntsty,
-                               int cbps, int dx, int dy,
+                               const int cbps, int dx, int dy,
                                AVCodecContext *avctx)
 {
     int reslevelno, bandno, gbandno = 0, ret, i, j;
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [FFmpeg-devel] [PATCH 4/4] avcodec/internal: Move ff_exp2fi() to aacsbr.c
  2024-02-17 19:54 [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate Andreas Rheinhardt
  2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 2/4] avcodec/jpeg2000dec: Avoid using GetByteContext.buffer directly Andreas Rheinhardt
  2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 3/4] avcodec/jpeg2000: Simplify exp2fi for numbers used here Andreas Rheinhardt
@ 2024-02-17 20:05 ` Andreas Rheinhardt
  2024-02-19 11:30 ` [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate Andreas Rheinhardt
  2024-02-19 13:58 ` Tomas Härdin
  4 siblings, 0 replies; 10+ messages in thread
From: Andreas Rheinhardt @ 2024-02-17 20:05 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Only used there.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aacsbr.c   | 39 +++++++++++++++++++++++++++++----------
 libavcodec/internal.h | 22 ----------------------
 2 files changed, 29 insertions(+), 32 deletions(-)

diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c
index 683c079b91..da9e160a57 100644
--- a/libavcodec/aacsbr.c
+++ b/libavcodec/aacsbr.c
@@ -31,10 +31,10 @@
 #include "sbr.h"
 #include "aacsbr.h"
 #include "aacsbrdata.h"
-#include "internal.h"
 #include "aacps.h"
 #include "sbrdsp.h"
 #include "libavutil/internal.h"
+#include "libavutil/intfloat.h"
 #include "libavutil/libm.h"
 #include "libavutil/avassert.h"
 #include "libavutil/mem_internal.h"
@@ -47,6 +47,25 @@
 #include "mips/aacsbr_mips.h"
 #endif /* ARCH_MIPS */
 
+/**
+ * 2^(x) for integer x
+ * @return correctly rounded float
+ */
+static av_always_inline float exp2fi(int x) {
+    /* Normal range */
+    if (-126 <= x && x <= 128)
+        return av_int2float((x+127) << 23);
+    /* Too large */
+    else if (x > 128)
+        return INFINITY;
+    /* Subnormal numbers */
+    else if (x > -150)
+        return av_int2float(1 << (x+149));
+    /* Negligibly small */
+    else
+        return 0;
+}
+
 static void aacsbr_func_ptr_init(AACSBRContext *c);
 
 static void make_bands(int16_t* bands, int start, int stop, int num_bands)
@@ -79,13 +98,13 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
             for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) {
                 float temp1, temp2, fac;
                 if (sbr->data[0].bs_amp_res) {
-                    temp1 = ff_exp2fi(sbr->data[0].env_facs_q[e][k] + 7);
-                    temp2 = ff_exp2fi(pan_offset - sbr->data[1].env_facs_q[e][k]);
+                    temp1 = exp2fi(sbr->data[0].env_facs_q[e][k] + 7);
+                    temp2 = exp2fi(pan_offset - sbr->data[1].env_facs_q[e][k]);
                 }
                 else {
-                    temp1 = ff_exp2fi((sbr->data[0].env_facs_q[e][k]>>1) + 7) *
+                    temp1 = exp2fi((sbr->data[0].env_facs_q[e][k]>>1) + 7) *
                             exp2_tab[sbr->data[0].env_facs_q[e][k] & 1];
-                    temp2 = ff_exp2fi((pan_offset - sbr->data[1].env_facs_q[e][k])>>1) *
+                    temp2 = exp2fi((pan_offset - sbr->data[1].env_facs_q[e][k])>>1) *
                             exp2_tab[(pan_offset - sbr->data[1].env_facs_q[e][k]) & 1];
                 }
                 if (temp1 > 1E20) {
@@ -99,8 +118,8 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
         }
         for (e = 1; e <= sbr->data[0].bs_num_noise; e++) {
             for (k = 0; k < sbr->n_q; k++) {
-                float temp1 = ff_exp2fi(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs_q[e][k] + 1);
-                float temp2 = ff_exp2fi(12 - sbr->data[1].noise_facs_q[e][k]);
+                float temp1 = exp2fi(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs_q[e][k] + 1);
+                float temp2 = exp2fi(12 - sbr->data[1].noise_facs_q[e][k]);
                 float fac;
                 av_assert0(temp1 <= 1E20);
                 fac = temp1 / (1.0f + temp2);
@@ -113,9 +132,9 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
             for (e = 1; e <= sbr->data[ch].bs_num_env; e++)
                 for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++){
                     if (sbr->data[ch].bs_amp_res)
-                        sbr->data[ch].env_facs[e][k] = ff_exp2fi(sbr->data[ch].env_facs_q[e][k] + 6);
+                        sbr->data[ch].env_facs[e][k] = exp2fi(sbr->data[ch].env_facs_q[e][k] + 6);
                     else
-                        sbr->data[ch].env_facs[e][k] = ff_exp2fi((sbr->data[ch].env_facs_q[e][k]>>1) + 6)
+                        sbr->data[ch].env_facs[e][k] = exp2fi((sbr->data[ch].env_facs_q[e][k]>>1) + 6)
                                                        * exp2_tab[sbr->data[ch].env_facs_q[e][k] & 1];
                     if (sbr->data[ch].env_facs[e][k] > 1E20) {
                         av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n");
@@ -126,7 +145,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
             for (e = 1; e <= sbr->data[ch].bs_num_noise; e++)
                 for (k = 0; k < sbr->n_q; k++)
                     sbr->data[ch].noise_facs[e][k] =
-                        ff_exp2fi(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs_q[e][k]);
+                        exp2fi(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs_q[e][k]);
         }
     }
 }
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index eb9e0d707c..04f7cebdcb 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -26,10 +26,7 @@
 
 #include <stdint.h>
 
-#include "libavutil/buffer.h"
 #include "libavutil/channel_layout.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/pixfmt.h"
 #include "avcodec.h"
 #include "config.h"
 
@@ -157,25 +154,6 @@ int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b);
 
 unsigned int ff_toupper4(unsigned int x);
 
-/**
- * 2^(x) for integer x
- * @return correctly rounded float
- */
-static av_always_inline float ff_exp2fi(int x) {
-    /* Normal range */
-    if (-126 <= x && x <= 128)
-        return av_int2float((x+127) << 23);
-    /* Too large */
-    else if (x > 128)
-        return INFINITY;
-    /* Subnormal numbers */
-    else if (x > -150)
-        return av_int2float(1 << (x+149));
-    /* Negligibly small */
-    else
-        return 0;
-}
-
 int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx);
 
 int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec);
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate
  2024-02-17 19:54 [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate Andreas Rheinhardt
                   ` (2 preceding siblings ...)
  2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 4/4] avcodec/internal: Move ff_exp2fi() to aacsbr.c Andreas Rheinhardt
@ 2024-02-19 11:30 ` Andreas Rheinhardt
  2024-02-19 13:58 ` Tomas Härdin
  4 siblings, 0 replies; 10+ messages in thread
From: Andreas Rheinhardt @ 2024-02-19 11:30 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/j2kenc.c      |  2 +-
>  libavcodec/jpeg2000dec.c | 14 +++++++-------
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
> index 789791f529..ebf21f6e7a 100644
> --- a/libavcodec/j2kenc.c
> +++ b/libavcodec/j2kenc.c
> @@ -781,7 +781,7 @@ static void putnumpasses(Jpeg2000EncoderContext *s, int n)
>  
>  
>  static int encode_packet(Jpeg2000EncoderContext *s, Jpeg2000ResLevel *rlevel, int layno,
> -                         int precno, uint8_t *expn, int numgbits, int packetno,
> +                         int precno, const uint8_t *expn, int numgbits, int packetno,
>                           int nlayers)
>  {
>      int bandno, empty = 1;
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index 691cfbd891..3d18d48e7c 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -489,7 +489,7 @@ static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)
>  
>  /* get coding parameters for a particular tile or whole image*/
>  static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
> -                   uint8_t *properties)
> +                   const uint8_t *properties)
>  {
>      Jpeg2000CodingStyle tmp;
>      int compno, ret;
> @@ -639,7 +639,7 @@ static int get_qcx(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q)
>  
>  /* Get quantization parameters for a particular tile or a whole image. */
>  static int get_qcd(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q,
> -                   uint8_t *properties)
> +                   const uint8_t *properties)
>  {
>      Jpeg2000QuantStyle tmp;
>      int compno, ret;
> @@ -1004,7 +1004,7 @@ static int getlblockinc(Jpeg2000DecoderContext *s)
>      return res;
>  }
>  
> -static inline void select_header(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
> +static inline void select_header(Jpeg2000DecoderContext *s, const Jpeg2000Tile *tile,
>                                   int *tp_index)
>  {
>      s->g = tile->tile_part[*tp_index].header_tpg;
> @@ -1015,8 +1015,8 @@ static inline void select_header(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
>      }
>  }
>  
> -static inline void select_stream(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
> -                                 int *tp_index, Jpeg2000CodingStyle *codsty)
> +static inline void select_stream(Jpeg2000DecoderContext *s, const Jpeg2000Tile *tile,
> +                                 int *tp_index, const Jpeg2000CodingStyle *codsty)
>  {
>      s->g = tile->tile_part[*tp_index].tpg;
>      if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
> @@ -1033,9 +1033,9 @@ static inline void select_stream(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
>  }
>  
>  static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, int *tp_index,
> -                                  Jpeg2000CodingStyle *codsty,
> +                                  const Jpeg2000CodingStyle *codsty,
>                                    Jpeg2000ResLevel *rlevel, int precno,
> -                                  int layno, uint8_t *expn, int numgbits)
> +                                  int layno, const uint8_t *expn, int numgbits)
>  {
>      int bandno, cblkno, ret, nb_code_blocks;
>      int cwsno;

Will apply this patchset tomorrow unless there are objections.

- Andreas

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate
  2024-02-17 19:54 [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate Andreas Rheinhardt
                   ` (3 preceding siblings ...)
  2024-02-19 11:30 ` [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate Andreas Rheinhardt
@ 2024-02-19 13:58 ` Tomas Härdin
  4 siblings, 0 replies; 10+ messages in thread
From: Tomas Härdin @ 2024-02-19 13:58 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

lör 2024-02-17 klockan 20:54 +0100 skrev Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/j2kenc.c      |  2 +-
>  libavcodec/jpeg2000dec.c | 14 +++++++-------
>  2 files changed, 8 insertions(+), 8 deletions(-)

Should be fine

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/4] avcodec/jpeg2000dec: Avoid using GetByteContext.buffer directly
  2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 2/4] avcodec/jpeg2000dec: Avoid using GetByteContext.buffer directly Andreas Rheinhardt
@ 2024-02-19 14:00   ` Tomas Härdin
  0 siblings, 0 replies; 10+ messages in thread
From: Tomas Härdin @ 2024-02-19 14:00 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

lör 2024-02-17 klockan 21:05 +0100 skrev Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/jpeg2000dec.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index 3d18d48e7c..1afc6b1e2d 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -886,8 +886,8 @@ static int get_ppm(Jpeg2000DecoderContext *s, int
> n)
>          return AVERROR(ENOMEM);
>      s->has_ppm = 1;
>      memset(&s->packed_headers_stream, 0, sizeof(s-
> >packed_headers_stream));
> -    bytestream_get_buffer(&s->g.buffer, s->packed_headers + s-
> >packed_headers_size,
> -                          n - 3);
> +    bytestream2_get_bufferu(&s->g, s->packed_headers + s-
> >packed_headers_size,
> +                            n - 3);
>      s->packed_headers_size += n - 3;
>  
>      return 0;
> @@ -921,10 +921,8 @@ static int get_ppt(Jpeg2000DecoderContext *s,
> int n)
>      } else
>          return AVERROR(ENOMEM);
>      memset(&tile->packed_headers_stream, 0, sizeof(tile-
> >packed_headers_stream));
> -    memcpy(tile->packed_headers + tile->packed_headers_size,
> -           s->g.buffer, n - 3);
> +    bytestream2_get_bufferu(&s->g, tile->packed_headers + tile-
> >packed_headers_size, n - 3);
>      tile->packed_headers_size += n - 3;
> -    bytestream2_skip(&s->g, n - 3);

Looks OK. bytestream2_get_bufferu() seems to do the skipping for us.

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [FFmpeg-devel] [PATCH 3/4] avcodec/jpeg2000: Simplify exp2fi for numbers used here
  2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 3/4] avcodec/jpeg2000: Simplify exp2fi for numbers used here Andreas Rheinhardt
@ 2024-02-19 14:09   ` Tomas Härdin
  2024-02-19 14:14     ` Andreas Rheinhardt
  0 siblings, 1 reply; 10+ messages in thread
From: Tomas Härdin @ 2024-02-19 14:09 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

lör 2024-02-17 klockan 21:05 +0100 skrev Andreas Rheinhardt:
> The call to ff_exp2fi() here always uses arguments in the normal
> range, so that the branches in ff_exp2fi() are unnecessary.
> This is so because JPEG2000 itself only supports up to
> 128 bits per component per pixel (we only support far less);
> furthermore, expn is always 0..31 for the decoder and also
> sane for the encoder, so that the difference between these
> two values is always in the normal range of -126..128.

Any measurable improvement in decode speed?

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [FFmpeg-devel] [PATCH 3/4] avcodec/jpeg2000: Simplify exp2fi for numbers used here
  2024-02-19 14:09   ` Tomas Härdin
@ 2024-02-19 14:14     ` Andreas Rheinhardt
  2024-02-19 14:51       ` Tomas Härdin
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Rheinhardt @ 2024-02-19 14:14 UTC (permalink / raw)
  To: ffmpeg-devel

Tomas Härdin:
> lör 2024-02-17 klockan 21:05 +0100 skrev Andreas Rheinhardt:
>> The call to ff_exp2fi() here always uses arguments in the normal
>> range, so that the branches in ff_exp2fi() are unnecessary.
>> This is so because JPEG2000 itself only supports up to
>> 128 bits per component per pixel (we only support far less);
>> furthermore, expn is always 0..31 for the decoder and also
>> sane for the encoder, so that the difference between these
>> two values is always in the normal range of -126..128.
> 
> Any measurable improvement in decode speed?
> 

I don't think it is measurable; my aim was to move ff_exp2fi() out of
internal.h (where it does not belong).

- Andreas

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [FFmpeg-devel] [PATCH 3/4] avcodec/jpeg2000: Simplify exp2fi for numbers used here
  2024-02-19 14:14     ` Andreas Rheinhardt
@ 2024-02-19 14:51       ` Tomas Härdin
  0 siblings, 0 replies; 10+ messages in thread
From: Tomas Härdin @ 2024-02-19 14:51 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

mån 2024-02-19 klockan 15:14 +0100 skrev Andreas Rheinhardt:
> Tomas Härdin:
> > lör 2024-02-17 klockan 21:05 +0100 skrev Andreas Rheinhardt:
> > > The call to ff_exp2fi() here always uses arguments in the normal
> > > range, so that the branches in ff_exp2fi() are unnecessary.
> > > This is so because JPEG2000 itself only supports up to
> > > 128 bits per component per pixel (we only support far less);
> > > furthermore, expn is always 0..31 for the decoder and also
> > > sane for the encoder, so that the difference between these
> > > two values is always in the normal range of -126..128.
> > 
> > Any measurable improvement in decode speed?
> > 
> 
> I don't think it is measurable; my aim was to move ff_exp2fi() out of
> internal.h (where it does not belong).

Ah. Well, fewer branches is almost always good so, looks good to me.
Maybe pal has an opinion?

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-02-19 14:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-17 19:54 [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate Andreas Rheinhardt
2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 2/4] avcodec/jpeg2000dec: Avoid using GetByteContext.buffer directly Andreas Rheinhardt
2024-02-19 14:00   ` Tomas Härdin
2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 3/4] avcodec/jpeg2000: Simplify exp2fi for numbers used here Andreas Rheinhardt
2024-02-19 14:09   ` Tomas Härdin
2024-02-19 14:14     ` Andreas Rheinhardt
2024-02-19 14:51       ` Tomas Härdin
2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 4/4] avcodec/internal: Move ff_exp2fi() to aacsbr.c Andreas Rheinhardt
2024-02-19 11:30 ` [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate Andreas Rheinhardt
2024-02-19 13:58 ` Tomas Härdin

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