diff mbox series

[FFmpeg-devel,25/60] avcodec/mjpegdec: fix variable shadowing

Message ID D41CE2FHWXFC.2FVPBNNR8HHCV@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,01/60] fftools/ffmpeg_opt: fix variable shadowing | expand

Commit Message

Marvin Scholz Sept. 8, 2024, 9:03 p.m. UTC
---
 libavcodec/mjpegdec.c        | 15 +++++++--------
 libavcodec/mjpegenc_common.c | 13 ++++++-------
 2 files changed, 13 insertions(+), 15 deletions(-)

Comments

Anton Khirnov Sept. 13, 2024, 10:03 a.m. UTC | #1
Quoting Marvin Scholz (2024-09-08 23:03:35)
> ---
>  libavcodec/mjpegdec.c        | 15 +++++++--------
>  libavcodec/mjpegenc_common.c | 13 ++++++-------
>  2 files changed, 13 insertions(+), 15 deletions(-)

Looks ok
diff mbox series

Patch

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 7daec649bc..86ec58713c 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2377,7 +2377,7 @@  int ff_mjpeg_decode_frame_from_buf(AVCodecContext *avctx, AVFrame *frame,
     int hshift, vshift;
     int unescaped_buf_size;
     int start_code;
-    int i, index;
+    int index;
     int ret = 0;
     int is16bit;
     AVDictionaryEntry *e = NULL;
@@ -2657,7 +2657,7 @@  the_end:
             if (s->upscale_v[p] == 1)
                 h = (h+1)>>1;
             av_assert0(w > 0);
-            for (i = 0; i < h; i++) {
+            for (int i = 0; i < h; i++) {
                 if (s->upscale_h[p] == 1) {
                     if (is16bit) ((uint16_t*)line)[w - 1] = ((uint16_t*)line)[(w - 1) / 2];
                     else                      line[w - 1] = line[(w - 1) / 2];
@@ -2735,7 +2735,7 @@  the_end:
                 h = AV_CEIL_RSHIFT(h, vshift);
             }
             dst = &((uint8_t *)s->picture_ptr->data[p])[(h - 1) * s->linesize[p]];
-            for (i = h - 1; i; i--) {
+            for (int i = h - 1; i; i--) {
                 uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[p])[i * s->upscale_v[p] / (s->upscale_v[p] + 1) * s->linesize[p]];
                 uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[p])[(i + 1) * s->upscale_v[p] / (s->upscale_v[p] + 1) * s->linesize[p]];
                 if (s->upscale_v[p] != 2 && (src1 == src2 || i == h - 1)) {
@@ -2777,7 +2777,7 @@  the_end:
         int w = s->picture_ptr->width;
         int h = s->picture_ptr->height;
         av_assert0(s->nb_components == 4);
-        for (i=0; i<h; i++) {
+        for (int i = 0; i < h; i++) {
             int j;
             uint8_t *dst[4];
             for (index=0; index<4; index++) {
@@ -2800,7 +2800,7 @@  the_end:
         int w = s->picture_ptr->width;
         int h = s->picture_ptr->height;
         av_assert0(s->nb_components == 4);
-        for (i=0; i<h; i++) {
+        for (int i = 0; i < h; i++) {
             int j;
             uint8_t *dst[4];
             for (index=0; index<4; index++) {
@@ -2833,10 +2833,9 @@  the_end:
         AVFrameSideData *sd;
         size_t offset = 0;
         int total_size = 0;
-        int i;
 
         /* Sum size of all parts. */
-        for (i = 0; i < s->iccnum; i++)
+        for (int i = 0; i < s->iccnum; i++)
             total_size += s->iccentries[i].length;
 
         ret = ff_frame_new_side_data(avctx, frame, AV_FRAME_DATA_ICC_PROFILE, total_size, &sd);
@@ -2847,7 +2846,7 @@  the_end:
 
         if (sd) {
             /* Reassemble the parts, which are now in-order. */
-            for (i = 0; i < s->iccnum; i++) {
+            for (int i = 0; i < s->iccnum; i++) {
                 memcpy(sd->data + offset, s->iccentries[i].data, s->iccentries[i].length);
                 offset += s->iccentries[i].length;
             }
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 049ae3d929..751e43fd3b 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -39,18 +39,17 @@ 
 static int put_huffman_table(PutBitContext *p, int table_class, int table_id,
                              const uint8_t *bits_table, const uint8_t *value_table)
 {
-    int n, i;
+    int n = 0;
 
     put_bits(p, 4, table_class);
     put_bits(p, 4, table_id);
 
-    n = 0;
-    for(i=1;i<=16;i++) {
+    for (int i = 1; i <= 16; i++) {
         n += bits_table[i];
         put_bits(p, 8, bits_table[i]);
     }
 
-    for(i=0;i<n;i++)
+    for (int i = 0; i < n; i++)
         put_bits(p, 8, value_table[i]);
 
     return n + 17;
@@ -63,7 +62,7 @@  static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
                               uint16_t chroma_intra_matrix[64],
                               int hsample[3], int use_slices, int matrices_differ)
 {
-    int i, j, size;
+    int size;
     uint8_t *ptr;
 
     if (m) {
@@ -83,8 +82,8 @@  static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
         if (matrix_count > 1) {
             put_bits(p, 4, 0); /* 8 bit precision */
             put_bits(p, 4, 1); /* table 1 */
-            for(i=0;i<64;i++) {
-                j = intra_matrix_permutation[i];
+            for (int i = 0; i < 64; i++) {
+                uint8_t j = intra_matrix_permutation[i];
                 put_bits(p, 8, chroma_intra_matrix[j]);
             }
         }