History

avcodec/mpegvideoencdsp: convert stride parameters from int to ptrdiff_t

Ramiro Polla committed 2 years ago

Commit 6aafe611 parent 7753a9d12 files · +53 −49Browse files

Unified · Split

12 files
  1. libavcodec/aarch64/mpegvideoencdsp_init.c +3 −3
  2. libavcodec/aarch64/mpegvideoencdsp_neon.S +3 −6
  3. libavcodec/arm/mpegvideoencdsp_init_arm.c +2 −2
  4. libavcodec/mips/h263dsp_mips.h +1 −1
  5. libavcodec/mips/mpegvideoencdsp_msa.c +1 −1
  6. libavcodec/mpegvideoencdsp.c +20 −11
  7. libavcodec/mpegvideoencdsp.h +5 −5
  8. libavcodec/ppc/mpegvideoencdsp.c +4 −4
  9. libavcodec/riscv/mpegvideoencdsp_init.c +2 −2
  10. libavcodec/x86/mpegvideoencdsp.asm +2 −4
  11. libavcodec/x86/mpegvideoencdsp_init.c +4 −4
  12. tests/checkasm/mpegvideoencdsp.c +6 −6
libavcodec/aarch64/mpegvideoencdsp_init.c+3−3
@@ -24,11 +24,11 @@ · 23 unmodified lines
2424 #include "libavcodec/mpegvideoencdsp.h"
2525 #include "config.h"
2626
27−int ff_pix_sum16_neon(const uint8_t *pix, int line_size);
28−int ff_pix_norm1_neon(const uint8_t *pix, int line_size);
27+int ff_pix_sum16_neon(const uint8_t *pix, ptrdiff_t line_size);
28+int ff_pix_norm1_neon(const uint8_t *pix, ptrdiff_t line_size);
2929
3030 #if HAVE_DOTPROD
31−int ff_pix_norm1_neon_dotprod(const uint8_t *pix, int line_size);
31+int ff_pix_norm1_neon_dotprod(const uint8_t *pix, ptrdiff_t line_size);
3232 #endif
3333
3434 av_cold void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c,
libavcodec/aarch64/mpegvideoencdsp_neon.S+3−6
@@ -22,9 +22,8 @@ · 21 unmodified lines
2222
2323 function ff_pix_sum16_neon, export=1
2424 // x0 const uint8_t *pix
25−// x1 int line_size
25+// x1 ptrdiff_t line_size
2626
27− sxtw x1, w1
2827 add x2, x0, x1
2928 lsl x1, x1, #1
3029 movi v0.16b, #0
@@ -46,9 +45,8 @@ endfunc · 15 unmodified lines
4645
4746 function ff_pix_norm1_neon, export=1
4847 // x0 const uint8_t *pix
49−// x1 int line_size
48+// x1 ptrdiff_t line_size
5049
51− sxtw x1, w1
5250 movi v0.16b, #0
5351 mov w2, #16
5452
@@ -72,9 +70,8 @@ ENABLE_DOTPROD · 17 unmodified lines
7270
7371 function ff_pix_norm1_neon_dotprod, export=1
7472 // x0 const uint8_t *pix
75−// x1 int line_size
73+// x1 ptrdiff_t line_size
7674
77− sxtw x1, w1
7875 movi v0.16b, #0
7976 mov w2, #16
8077
libavcodec/arm/mpegvideoencdsp_init_arm.c+2−2
@@ -24,8 +24,8 @@ · 23 unmodified lines
2424 #include "libavcodec/avcodec.h"
2525 #include "libavcodec/mpegvideoencdsp.h"
2626
27−int ff_pix_norm1_armv6(const uint8_t *pix, int line_size);
28−int ff_pix_sum_armv6(const uint8_t *pix, int line_size);
27+int ff_pix_norm1_armv6(const uint8_t *pix, ptrdiff_t line_size);
28+int ff_pix_sum_armv6(const uint8_t *pix, ptrdiff_t line_size);
2929
3030 av_cold void ff_mpegvideoencdsp_init_arm(MpegvideoEncDSPContext *c,
3131 AVCodecContext *avctx)
libavcodec/mips/h263dsp_mips.h+1−1
@@ -31,6 +31,6 @@ void ff_dct_unquantize_h263_inter_msa(MpegEncContext *s, int16_t *block, · 30 unmodified lines
3131 int32_t index, int32_t q_scale);
3232 void ff_dct_unquantize_h263_intra_msa(MpegEncContext *s, int16_t *block,
3333 int32_t index, int32_t q_scale);
34−int ff_pix_sum_msa(const uint8_t *pix, int line_size);
34+int ff_pix_sum_msa(const uint8_t *pix, ptrdiff_t line_size);
3535
3636 #endif // #ifndef AVCODEC_MIPS_H263DSP_MIPS_H
libavcodec/mips/mpegvideoencdsp_msa.c+1−1
@@ -56,7 +56,7 @@ static int32_t sum_u8src_16width_msa(const uint8_t *src, int32_t stride) · 55 unmodified lines
5656 return sum;
5757 }
5858
59−int ff_pix_sum_msa(const uint8_t *pix, int line_size)
59+int ff_pix_sum_msa(const uint8_t *pix, ptrdiff_t line_size)
6060 {
6161 return sum_u8src_16width_msa(pix, line_size);
6262 }
libavcodec/mpegvideoencdsp.c+20−11
@@ -57,7 +57,7 @@ static void add_8x8basis_c(int16_t rem[64], const int16_t basis[64], int scale) · 56 unmodified lines
5757 (BASIS_SHIFT - RECON_SHIFT);
5858 }
5959
60−static int pix_sum_c(const uint8_t *pix, int line_size)
60+static int pix_sum_c(const uint8_t *pix, ptrdiff_t line_size)
6161 {
6262 int s = 0, i, j;
6363
@@ -78,7 +78,7 @@ static int pix_sum_c(const uint8_t *pix, int line_size) · 14 unmodified lines
7878 return s;
7979 }
8080
81−static int pix_norm1_c(const uint8_t *pix, int line_size)
81+static int pix_norm1_c(const uint8_t *pix, ptrdiff_t line_size)
8282 {
8383 int s = 0, i, j;
8484 const uint32_t *sq = ff_square_tab + 256;
@@ -114,7 +114,7 @@ static int pix_norm1_c(const uint8_t *pix, int line_size) · 29 unmodified lines
114114 return s;
115115 }
116116
117−static av_always_inline void draw_edges_lr(uint8_t *ptr, int wrap, int width, int height, int w)
117+static av_always_inline void draw_edges_lr(uint8_t *ptr, ptrdiff_t wrap, int width, int height, int w)
118118 {
119119 for (int i = 0; i < height; i++) {
120120 memset(ptr - w, ptr[0], w);
@@ -125,7 +125,7 @@ static av_always_inline void draw_edges_lr(uint8_t *ptr, int wrap, int width, in · 4 unmodified lines
125125
126126 /* draw the edges of width 'w' of an image of size width, height */
127127 // FIXME: Check that this is OK for MPEG-4 interlaced.
128−static void draw_edges_8_c(uint8_t *buf, int wrap, int width, int height,
128+static void draw_edges_8_c(uint8_t *buf, ptrdiff_t wrap, int width, int height,
129129 int w, int h, int sides)
130130 {
131131 uint8_t *last_line;
@@ -154,9 +154,18 @@ static void draw_edges_8_c(uint8_t *buf, int wrap, int width, int height, · 22 unmodified lines
154154 memcpy(last_line + (i + 1) * wrap, last_line, width + w + w);
155155 }
156156
157+/* This wrapper function only serves to convert the stride parameters
158+ * from ptrdiff_t to int for av_image_copy_plane(). */
159+static void copy_plane_wrapper(uint8_t *dst, ptrdiff_t dst_wrap,
160+ const uint8_t *src, ptrdiff_t src_wrap,
161+ int width, int height)
162+{
163+ av_image_copy_plane(dst, dst_wrap, src, src_wrap, width, height);
164+}
165+
157166 /* 2x2 -> 1x1 */
158−static void shrink22(uint8_t *dst, int dst_wrap,
159− const uint8_t *src, int src_wrap,
167+static void shrink22(uint8_t *dst, ptrdiff_t dst_wrap,
168+ const uint8_t *src, ptrdiff_t src_wrap,
160169 int width, int height)
161170 {
162171 int w;
@@ -188,8 +197,8 @@ static void shrink22(uint8_t *dst, int dst_wrap, · 25 unmodified lines
188197 }
189198
190199 /* 4x4 -> 1x1 */
191−static void shrink44(uint8_t *dst, int dst_wrap,
192− const uint8_t *src, int src_wrap,
200+static void shrink44(uint8_t *dst, ptrdiff_t dst_wrap,
201+ const uint8_t *src, ptrdiff_t src_wrap,
193202 int width, int height)
194203 {
195204 int w;
@@ -219,8 +228,8 @@ static void shrink44(uint8_t *dst, int dst_wrap, · 23 unmodified lines
219228 }
220229
221230 /* 8x8 -> 1x1 */
222−static void shrink88(uint8_t *dst, int dst_wrap,
223− const uint8_t *src, int src_wrap,
231+static void shrink88(uint8_t *dst, ptrdiff_t dst_wrap,
232+ const uint8_t *src, ptrdiff_t src_wrap,
224233 int width, int height)
225234 {
226235 int w, i;
@@ -247,7 +256,7 @@ av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, · 20 unmodified lines
247256 c->try_8x8basis = try_8x8basis_c;
248257 c->add_8x8basis = add_8x8basis_c;
249258
250− c->shrink[0] = av_image_copy_plane;
259+ c->shrink[0] = copy_plane_wrapper;
251260 c->shrink[1] = shrink22;
252261 c->shrink[2] = shrink44;
253262 c->shrink[3] = shrink88;
libavcodec/mpegvideoencdsp.h+5−5
@@ -34,13 +34,13 @@ typedef struct MpegvideoEncDSPContext { · 33 unmodified lines
3434 const int16_t basis[64], int scale);
3535 void (*add_8x8basis)(int16_t rem[64], const int16_t basis[64], int scale);
3636
37− int (*pix_sum)(const uint8_t *pix, int line_size);
38− int (*pix_norm1)(const uint8_t *pix, int line_size);
37+ int (*pix_sum)(const uint8_t *pix, ptrdiff_t line_size);
38+ int (*pix_norm1)(const uint8_t *pix, ptrdiff_t line_size);
3939
40− void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src,
41− int src_wrap, int width, int height);
40+ void (*shrink[4])(uint8_t *dst, ptrdiff_t dst_wrap, const uint8_t *src,
41+ ptrdiff_t src_wrap, int width, int height);
4242
43− void (*draw_edges)(uint8_t *buf, int wrap, int width, int height,
43+ void (*draw_edges)(uint8_t *buf, ptrdiff_t wrap, int width, int height,
4444 int w, int h, int sides);
4545 } MpegvideoEncDSPContext;
4646
libavcodec/ppc/mpegvideoencdsp.c+4−4
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030 #if HAVE_ALTIVEC
3131
3232 #if HAVE_VSX
33−static int pix_norm1_altivec(const uint8_t *pix, int line_size)
33+static int pix_norm1_altivec(const uint8_t *pix, ptrdiff_t line_size)
3434 {
3535 int i, s = 0;
3636 const vector unsigned int zero =
@@ -57,7 +57,7 @@ static int pix_norm1_altivec(const uint8_t *pix, int line_size) · 20 unmodified lines
5757 return s;
5858 }
5959 #else
60−static int pix_norm1_altivec(const uint8_t *pix, int line_size)
60+static int pix_norm1_altivec(const uint8_t *pix, ptrdiff_t line_size)
6161 {
6262 int i, s = 0;
6363 const vector unsigned int zero =
@@ -87,7 +87,7 @@ static int pix_norm1_altivec(const uint8_t *pix, int line_size) · 23 unmodified lines
8787 #endif /* HAVE_VSX */
8888
8989 #if HAVE_VSX
90−static int pix_sum_altivec(const uint8_t *pix, int line_size)
90+static int pix_sum_altivec(const uint8_t *pix, ptrdiff_t line_size)
9191 {
9292 int i, s;
9393 const vector unsigned int zero =
@@ -115,7 +115,7 @@ static int pix_sum_altivec(const uint8_t *pix, int line_size) · 21 unmodified lines
115115 return s;
116116 }
117117 #else
118−static int pix_sum_altivec(const uint8_t *pix, int line_size)
118+static int pix_sum_altivec(const uint8_t *pix, ptrdiff_t line_size)
119119 {
120120 int i, s;
121121 const vector unsigned int zero =
libavcodec/riscv/mpegvideoencdsp_init.c+2−2
@@ -26,8 +26,8 @@ · 25 unmodified lines
2626 int ff_try_8x8basis_rvv(const int16_t rem[64], const int16_t weight[64],
2727 const int16_t basis[16], int scale);
2828 void ff_add_8x8basis_rvv(int16_t rem[64], const int16_t basis[16], int scale);
29−int ff_pix_sum_rvv(const uint8_t *pix, int line_size);
30−int ff_pix_norm1_rvv(const uint8_t *pix, int line_size);
29+int ff_pix_sum_rvv(const uint8_t *pix, ptrdiff_t line_size);
30+int ff_pix_norm1_rvv(const uint8_t *pix, ptrdiff_t line_size);
3131
3232 av_cold void ff_mpegvideoencdsp_init_riscv(MpegvideoEncDSPContext *c,
3333 AVCodecContext *avctx)
libavcodec/x86/mpegvideoencdsp.asm+2−4
@@ -24,12 +24,11 @@ · 23 unmodified lines
2424 %include "libavutil/x86/x86util.asm"
2525
2626 SECTION .text
27−; int ff_pix_sum16(const uint8_t *pix, int line_size)
27+; int ff_pix_sum16(const uint8_t *pix, ptrdiff_t line_size)
2828 ; %1 = number of loops
2929 ; %2 = number of GPRs used
3030 %macro PIX_SUM16 3
3131 cglobal pix_sum16, 2, %2, 6
32− movsxdifnidn r1, r1d
3332 mov r2, %1
3433 lea r3, [r1*3]
3534 %if notcpuflag(xop)
@@ -72,12 +71,11 @@ INIT_XMM xop · 36 unmodified lines
7271 PIX_SUM16 4, 4, 4
7372 %endif
7473
75−; int ff_pix_norm1(const uint8_t *pix, int line_size)
74+; int ff_pix_norm1(const uint8_t *pix, ptrdiff_t line_size)
7675 ; %1 = number of xmm registers used
7776 ; %2 = number of loops
7877 %macro PIX_NORM1 2
7978 cglobal pix_norm1, 2, 3, %1
80− movsxdifnidn r1, r1d
8179 mov r2, %2
8280 pxor m0, m0
8381 pxor m5, m5
libavcodec/x86/mpegvideoencdsp_init.c+4−4
@@ -23,9 +23,9 @@ · 22 unmodified lines
2323 #include "libavcodec/avcodec.h"
2424 #include "libavcodec/mpegvideoencdsp.h"
2525
26−int ff_pix_sum16_sse2(const uint8_t *pix, int line_size);
27−int ff_pix_sum16_xop(const uint8_t *pix, int line_size);
28−int ff_pix_norm1_sse2(const uint8_t *pix, int line_size);
26+int ff_pix_sum16_sse2(const uint8_t *pix, ptrdiff_t line_size);
27+int ff_pix_sum16_xop(const uint8_t *pix, ptrdiff_t line_size);
28+int ff_pix_norm1_sse2(const uint8_t *pix, ptrdiff_t line_size);
2929
3030 #if HAVE_INLINE_ASM
3131
@@ -96,7 +96,7 @@ int ff_pix_norm1_sse2(const uint8_t *pix, int line_size); · 64 unmodified lines
9696 #endif /* HAVE_SSSE3_INLINE */
9797
9898 /* Draw the edges of width 'w' of an image of size width, height */
99−static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
99+static void draw_edges_mmx(uint8_t *buf, ptrdiff_t wrap, int width, int height,
100100 int w, int h, int sides)
101101 {
102102 uint8_t *ptr, *last_line;
tests/checkasm/mpegvideoencdsp.c+6−6
@@ -34,7 +34,7 @@ static void check_pix_sum(MpegvideoEncDSPContext *c) · 33 unmodified lines
3434 {
3535 LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]);
3636
37− declare_func(int, const uint8_t *pix, int line_size);
37+ declare_func(int, const uint8_t *pix, ptrdiff_t line_size);
3838
3939 randomize_buffers(src, 16 * 16);
4040
@@ -43,7 +43,7 @@ static void check_pix_sum(MpegvideoEncDSPContext *c) · 2 unmodified lines
4343 if (check_func(c->pix_sum, "pix_sum%s", negstride_str)) {
4444 int sum0, sum1;
4545 const uint8_t *pix = src + (n ? (15 * 16) : 0);
46− int line_size = 16 * (n ? -1 : 1);
46+ ptrdiff_t line_size = 16 * (n ? -1 : 1);
4747 sum0 = call_ref(pix, line_size);
4848 sum1 = call_new(pix, line_size);
4949 if (sum0 != sum1)
@@ -57,7 +57,7 @@ static void check_pix_norm1(MpegvideoEncDSPContext *c) · 7 unmodified lines
5757 {
5858 LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]);
5959
60− declare_func(int, const uint8_t *pix, int line_size);
60+ declare_func(int, const uint8_t *pix, ptrdiff_t line_size);
6161
6262 randomize_buffers(src, 16 * 16);
6363
@@ -66,7 +66,7 @@ static void check_pix_norm1(MpegvideoEncDSPContext *c) · 2 unmodified lines
6666 if (check_func(c->pix_norm1, "pix_norm1%s", negstride_str)) {
6767 int sum0, sum1;
6868 const uint8_t *pix = src + (n ? (15 * 16) : 0);
69− int line_size = 16 * (n ? -1 : 1);
69+ ptrdiff_t line_size = 16 * (n ? -1 : 1);
7070 sum0 = call_ref(pix, line_size);
7171 sum1 = call_new(pix, line_size);
7272 if (sum0 != sum1)
@@ -88,7 +88,7 @@ static void check_draw_edges(MpegvideoEncDSPContext *c) · 15 unmodified lines
8888 LOCAL_ALIGNED_16(uint8_t, buf0, [BUFSIZE]);
8989 LOCAL_ALIGNED_16(uint8_t, buf1, [BUFSIZE]);
9090
91− declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *buf, int wrap, int width, int height,
91+ declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *buf, ptrdiff_t wrap, int width, int height,
9292 int w, int h, int sides);
9393
9494 for (int isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++) {
@@ -96,7 +96,7 @@ static void check_draw_edges(MpegvideoEncDSPContext *c) · 1 unmodified line
9696 int negstride = input_size < 0;
9797 const char *negstride_str = negstride ? "_negstride" : "";
9898 int width = FFABS(input_size);
99− int linesize = EDGE_WIDTH + width + EDGE_WIDTH;
99+ ptrdiff_t linesize = EDGE_WIDTH + width + EDGE_WIDTH;
100100 /* calculate height based on specified width to use the entire buffer. */
101101 int height = (BUFSIZE / linesize) - (2 * EDGE_WIDTH);
102102 uint8_t *dst0 = buf0 + EDGE_WIDTH * linesize + EDGE_WIDTH;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t