[FFmpeg-cvslog] avfilter/vf_v360: make more stuff const

Paul B Mahol git at videolan.org
Sun Jan 19 20:56:21 EET 2020


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Jan 18 18:48:02 2020 +0100| [fdc61267b471d5243cab21affb767868eafc1bc7] | committer: Paul B Mahol

avfilter/vf_v360: make more stuff const

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fdc61267b471d5243cab21affb767868eafc1bc7
---

 libavfilter/v360.h    |  4 +--
 libavfilter/vf_v360.c | 83 ++++++++++++++++++++++++++-------------------------
 2 files changed, 45 insertions(+), 42 deletions(-)

diff --git a/libavfilter/v360.h b/libavfilter/v360.h
index 88de9cbd7c..82bc37ef48 100644
--- a/libavfilter/v360.h
+++ b/libavfilter/v360.h
@@ -169,8 +169,8 @@ typedef struct V360Context {
 
     int (*remap_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
 
-    void (*remap_line)(uint8_t *dst, int width, const uint8_t *src, ptrdiff_t in_linesize,
-                       const uint16_t *u, const uint16_t *v, const int16_t *ker);
+    void (*remap_line)(uint8_t *dst, int width, const uint8_t *const src, ptrdiff_t in_linesize,
+                       const uint16_t *const u, const uint16_t *const v, const int16_t *const ker);
 } V360Context;
 
 void ff_v360_init(V360Context *s, int depth);
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index bc10ced55d..fcbb969aef 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -208,18 +208,19 @@ static int query_formats(AVFilterContext *ctx)
     return ff_set_common_formats(ctx, fmts_list);
 }
 
-#define DEFINE_REMAP1_LINE(bits, div)                                                           \
-static void remap1_##bits##bit_line_c(uint8_t *dst, int width, const uint8_t *src,              \
-                                      ptrdiff_t in_linesize,                                    \
-                                      const uint16_t *u, const uint16_t *v, const int16_t *ker) \
-{                                                                                               \
-    const uint##bits##_t *s = (const uint##bits##_t *)src;                                      \
-    uint##bits##_t *d = (uint##bits##_t *)dst;                                                  \
-                                                                                                \
-    in_linesize /= div;                                                                         \
-                                                                                                \
-    for (int x = 0; x < width; x++)                                                             \
-        d[x] = s[v[x] * in_linesize + u[x]];                                                    \
+#define DEFINE_REMAP1_LINE(bits, div)                                                    \
+static void remap1_##bits##bit_line_c(uint8_t *dst, int width, const uint8_t *const src, \
+                                      ptrdiff_t in_linesize,                             \
+                                      const uint16_t *const u, const uint16_t *const v,  \
+                                      const int16_t *const ker)                          \
+{                                                                                        \
+    const uint##bits##_t *const s = (const uint##bits##_t *const)src;                    \
+    uint##bits##_t *d = (uint##bits##_t *)dst;                                           \
+                                                                                         \
+    in_linesize /= div;                                                                  \
+                                                                                         \
+    for (int x = 0; x < width; x++)                                                      \
+        d[x] = s[v[x] * in_linesize + u[x]];                                             \
 }
 
 DEFINE_REMAP1_LINE( 8, 1)
@@ -248,7 +249,8 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jo
             const int in_offset_h = stereo ? s->in_offset_h[plane] : 0;                                    \
             const int out_offset_w = stereo ? s->out_offset_w[plane] : 0;                                  \
             const int out_offset_h = stereo ? s->out_offset_h[plane] : 0;                                  \
-            const uint8_t *src = in->data[plane] + in_offset_h * in_linesize + in_offset_w * (bits >> 3);  \
+            const uint8_t *const src = in->data[plane] +                                                   \
+                                                   in_offset_h * in_linesize + in_offset_w * (bits >> 3);  \
             uint8_t *dst = out->data[plane] + out_offset_h * out_linesize + out_offset_w * (bits >> 3);    \
             const int width = s->pr_width[plane];                                                          \
             const int height = s->pr_height[plane];                                                        \
@@ -258,9 +260,9 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jo
                                                                                                            \
             for (int y = slice_start; y < slice_end; y++) {                                                \
                 const unsigned map = s->map[plane];                                                        \
-                const uint16_t *u = s->u[map] + y * uv_linesize * ws * ws;                                 \
-                const uint16_t *v = s->v[map] + y * uv_linesize * ws * ws;                                 \
-                const int16_t *ker = s->ker[map] + y * uv_linesize * ws * ws;                              \
+                const uint16_t *const u = s->u[map] + y * uv_linesize * ws * ws;                           \
+                const uint16_t *const v = s->v[map] + y * uv_linesize * ws * ws;                           \
+                const int16_t *const ker = s->ker[map] + y * uv_linesize * ws * ws;                        \
                                                                                                            \
                 s->remap_line(dst + y * out_linesize, width, src, in_linesize, u, v, ker);                 \
             }                                                                                              \
@@ -277,30 +279,31 @@ DEFINE_REMAP(1, 16)
 DEFINE_REMAP(2, 16)
 DEFINE_REMAP(4, 16)
 
-#define DEFINE_REMAP_LINE(ws, bits, div)                                                                   \
-static void remap##ws##_##bits##bit_line_c(uint8_t *dst, int width, const uint8_t *src,                    \
-                                           ptrdiff_t in_linesize,                                          \
-                                           const uint16_t *u, const uint16_t *v, const int16_t *ker)       \
-{                                                                                                          \
-    const uint##bits##_t *s = (const uint##bits##_t *)src;                                                 \
-    uint##bits##_t *d = (uint##bits##_t *)dst;                                                             \
-                                                                                                           \
-    in_linesize /= div;                                                                                    \
-                                                                                                           \
-    for (int x = 0; x < width; x++) {                                                                      \
-        const uint16_t *uu = u + x * ws * ws;                                                              \
-        const uint16_t *vv = v + x * ws * ws;                                                              \
-        const int16_t *kker = ker + x * ws * ws;                                                           \
-        int tmp = 0;                                                                                       \
-                                                                                                           \
-        for (int i = 0; i < ws; i++) {                                                                     \
-            for (int j = 0; j < ws; j++) {                                                                 \
-                tmp += kker[i * ws + j] * s[vv[i * ws + j] * in_linesize + uu[i * ws + j]];                \
-            }                                                                                              \
-        }                                                                                                  \
-                                                                                                           \
-        d[x] = av_clip_uint##bits(tmp >> 14);                                                              \
-    }                                                                                                      \
+#define DEFINE_REMAP_LINE(ws, bits, div)                                                      \
+static void remap##ws##_##bits##bit_line_c(uint8_t *dst, int width, const uint8_t *const src, \
+                                           ptrdiff_t in_linesize,                             \
+                                           const uint16_t *const u, const uint16_t *const v,  \
+                                           const int16_t *const ker)                          \
+{                                                                                             \
+    const uint##bits##_t *const s = (const uint##bits##_t *const)src;                         \
+    uint##bits##_t *d = (uint##bits##_t *)dst;                                                \
+                                                                                              \
+    in_linesize /= div;                                                                       \
+                                                                                              \
+    for (int x = 0; x < width; x++) {                                                         \
+        const uint16_t *const uu = u + x * ws * ws;                                           \
+        const uint16_t *const vv = v + x * ws * ws;                                           \
+        const int16_t *const kker = ker + x * ws * ws;                                        \
+        int tmp = 0;                                                                          \
+                                                                                              \
+        for (int i = 0; i < ws; i++) {                                                        \
+            for (int j = 0; j < ws; j++) {                                                    \
+                tmp += kker[i * ws + j] * s[vv[i * ws + j] * in_linesize + uu[i * ws + j]];   \
+            }                                                                                 \
+        }                                                                                     \
+                                                                                              \
+        d[x] = av_clip_uint##bits(tmp >> 14);                                                 \
+    }                                                                                         \
 }
 
 DEFINE_REMAP_LINE(2,  8, 1)



More information about the ffmpeg-cvslog mailing list