You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	pixblockdsp: Change type of stride parameters to ptrdiff_t
This avoids SIMD-optimized functions having to sign-extend their line size argument manually to be able to do pointer arithmetic. Also adjust parameter names to be "stride" everywhere.
This commit is contained in:
		| @@ -24,9 +24,10 @@ | |||||||
| #include "libavcodec/avcodec.h" | #include "libavcodec/avcodec.h" | ||||||
| #include "libavcodec/pixblockdsp.h" | #include "libavcodec/pixblockdsp.h" | ||||||
|  |  | ||||||
| void ff_get_pixels_armv6(int16_t *block, const uint8_t *pixels, int stride); | void ff_get_pixels_armv6(int16_t *block, const uint8_t *pixels, | ||||||
|  |                          ptrdiff_t stride); | ||||||
| void ff_diff_pixels_armv6(int16_t *block, const uint8_t *s1, | void ff_diff_pixels_armv6(int16_t *block, const uint8_t *s1, | ||||||
|                           const uint8_t *s2, int stride); |                           const uint8_t *s2, ptrdiff_t stride); | ||||||
|  |  | ||||||
| av_cold void ff_pixblockdsp_init_arm(PixblockDSPContext *c, | av_cold void ff_pixblockdsp_init_arm(PixblockDSPContext *c, | ||||||
|                                      AVCodecContext *avctx, |                                      AVCodecContext *avctx, | ||||||
|   | |||||||
| @@ -45,7 +45,7 @@ typedef struct DVVideoContext { | |||||||
|  |  | ||||||
|     uint8_t dv_zigzag[2][64]; |     uint8_t dv_zigzag[2][64]; | ||||||
|  |  | ||||||
|     void (*get_pixels)(int16_t *block, const uint8_t *pixels, int line_size); |     void (*get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t linesize); | ||||||
|     void (*fdct[2])(int16_t *block); |     void (*fdct[2])(int16_t *block); | ||||||
|     void (*idct_put[2])(uint8_t *dest, int line_size, int16_t *block); |     void (*idct_put[2])(uint8_t *dest, int line_size, int16_t *block); | ||||||
|     me_cmp_func ildct_cmp; |     me_cmp_func ildct_cmp; | ||||||
|   | |||||||
| @@ -197,7 +197,7 @@ static av_always_inline PutBitContext *dv_encode_ac(EncBlockInfo *bi, | |||||||
| } | } | ||||||
|  |  | ||||||
| static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, uint8_t *data, | static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, uint8_t *data, | ||||||
|                                               int linesize) |                                               ptrdiff_t linesize) | ||||||
| { | { | ||||||
|     if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { |     if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { | ||||||
|         int ps = s->ildct_cmp(NULL, data, NULL, linesize, 8) - 400; |         int ps = s->ildct_cmp(NULL, data, NULL, linesize, 8) - 400; | ||||||
| @@ -234,8 +234,8 @@ static const int dv_weight_248[64] = { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| static av_always_inline int dv_init_enc_block(EncBlockInfo *bi, uint8_t *data, | static av_always_inline int dv_init_enc_block(EncBlockInfo *bi, uint8_t *data, | ||||||
|                                               int linesize, DVVideoContext *s, |                                               ptrdiff_t linesize, | ||||||
|                                               int bias) |                                               DVVideoContext *s, int bias) | ||||||
| { | { | ||||||
|     const int *weight; |     const int *weight; | ||||||
|     const uint8_t *zigzag_scan; |     const uint8_t *zigzag_scan; | ||||||
| @@ -413,7 +413,8 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg) | |||||||
|     DVVideoContext *s = avctx->priv_data; |     DVVideoContext *s = avctx->priv_data; | ||||||
|     DVwork_chunk *work_chunk = arg; |     DVwork_chunk *work_chunk = arg; | ||||||
|     int mb_index, i, j; |     int mb_index, i, j; | ||||||
|     int mb_x, mb_y, c_offset, linesize, y_stride; |     int mb_x, mb_y, c_offset; | ||||||
|  |     ptrdiff_t linesize, y_stride; | ||||||
|     uint8_t *y_ptr; |     uint8_t *y_ptr; | ||||||
|     uint8_t *dif; |     uint8_t *dif; | ||||||
|     LOCAL_ALIGNED_8(uint8_t, scratch, [128]); |     LOCAL_ALIGNED_8(uint8_t, scratch, [128]); | ||||||
|   | |||||||
| @@ -31,7 +31,7 @@ | |||||||
| #include "pixblockdsp_template.c" | #include "pixblockdsp_template.c" | ||||||
|  |  | ||||||
| static void diff_pixels_c(int16_t *restrict block, const uint8_t *s1, | static void diff_pixels_c(int16_t *restrict block, const uint8_t *s1, | ||||||
|                           const uint8_t *s2, int stride) |                           const uint8_t *s2, ptrdiff_t stride) | ||||||
| { | { | ||||||
|     int i; |     int i; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -26,11 +26,11 @@ | |||||||
| typedef struct PixblockDSPContext { | typedef struct PixblockDSPContext { | ||||||
|     void (*get_pixels)(int16_t *block /* align 16 */, |     void (*get_pixels)(int16_t *block /* align 16 */, | ||||||
|                        const uint8_t *pixels /* align 8 */, |                        const uint8_t *pixels /* align 8 */, | ||||||
|                        int line_size); |                        ptrdiff_t stride); | ||||||
|     void (*diff_pixels)(int16_t *block /* align 16 */, |     void (*diff_pixels)(int16_t *block /* align 16 */, | ||||||
|                         const uint8_t *s1 /* align 8 */, |                         const uint8_t *s1 /* align 8 */, | ||||||
|                         const uint8_t *s2 /* align 8 */, |                         const uint8_t *s2 /* align 8 */, | ||||||
|                         int stride); |                         ptrdiff_t stride); | ||||||
| } PixblockDSPContext; | } PixblockDSPContext; | ||||||
|  |  | ||||||
| void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx); | void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx); | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ | |||||||
| #include "bit_depth_template.c" | #include "bit_depth_template.c" | ||||||
|  |  | ||||||
| static void FUNCC(get_pixels)(int16_t *restrict block, const uint8_t *_pixels, | static void FUNCC(get_pixels)(int16_t *restrict block, const uint8_t *_pixels, | ||||||
|                               int line_size) |                               ptrdiff_t stride) | ||||||
| { | { | ||||||
|     const pixel *pixels = (const pixel *) _pixels; |     const pixel *pixels = (const pixel *) _pixels; | ||||||
|     int i; |     int i; | ||||||
| @@ -34,7 +34,7 @@ static void FUNCC(get_pixels)(int16_t *restrict block, const uint8_t *_pixels, | |||||||
|         block[5] = pixels[5]; |         block[5] = pixels[5]; | ||||||
|         block[6] = pixels[6]; |         block[6] = pixels[6]; | ||||||
|         block[7] = pixels[7]; |         block[7] = pixels[7]; | ||||||
|         pixels  += line_size / sizeof(pixel); |         pixels  += stride / sizeof(pixel); | ||||||
|         block   += 8; |         block   += 8; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ | |||||||
| #if HAVE_ALTIVEC && HAVE_BIGENDIAN | #if HAVE_ALTIVEC && HAVE_BIGENDIAN | ||||||
|  |  | ||||||
| static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, | static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, | ||||||
|                                int line_size) |                                ptrdiff_t stride) | ||||||
| { | { | ||||||
|     int i; |     int i; | ||||||
|     vec_u8 perm = vec_lvsl(0, pixels); |     vec_u8 perm = vec_lvsl(0, pixels); | ||||||
| @@ -56,12 +56,12 @@ static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, | |||||||
|         // Save the data to the block, we assume the block is 16-byte aligned. |         // Save the data to the block, we assume the block is 16-byte aligned. | ||||||
|         vec_st(shorts, i * 16, (vec_s16 *)block); |         vec_st(shorts, i * 16, (vec_s16 *)block); | ||||||
|  |  | ||||||
|         pixels += line_size; |         pixels += stride; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1, | static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1, | ||||||
|                                 const uint8_t *s2, int stride) |                                 const uint8_t *s2, ptrdiff_t stride) | ||||||
| { | { | ||||||
|     int i; |     int i; | ||||||
|     vec_u8 perm1 = vec_lvsl(0, s1); |     vec_u8 perm1 = vec_lvsl(0, s1); | ||||||
| @@ -135,7 +135,7 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1, | |||||||
|  |  | ||||||
| #if HAVE_VSX | #if HAVE_VSX | ||||||
| static void get_pixels_vsx(int16_t *restrict block, const uint8_t *pixels, | static void get_pixels_vsx(int16_t *restrict block, const uint8_t *pixels, | ||||||
|                            int line_size) |                            ptrdiff_t stride) | ||||||
| { | { | ||||||
|     int i; |     int i; | ||||||
|     for (i = 0; i < 8; i++) { |     for (i = 0; i < 8; i++) { | ||||||
| @@ -143,12 +143,12 @@ static void get_pixels_vsx(int16_t *restrict block, const uint8_t *pixels, | |||||||
|  |  | ||||||
|         vec_vsx_st(shorts, i * 16, block); |         vec_vsx_st(shorts, i * 16, block); | ||||||
|  |  | ||||||
|         pixels += line_size; |         pixels += stride; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void diff_pixels_vsx(int16_t *restrict block, const uint8_t *s1, | static void diff_pixels_vsx(int16_t *restrict block, const uint8_t *s1, | ||||||
|                             const uint8_t *s2, int stride) |                             const uint8_t *s2, ptrdiff_t stride) | ||||||
| { | { | ||||||
|     int i; |     int i; | ||||||
|     vec_s16 shorts1, shorts2; |     vec_s16 shorts1, shorts2; | ||||||
|   | |||||||
| @@ -26,9 +26,8 @@ | |||||||
| SECTION .text | SECTION .text | ||||||
|  |  | ||||||
| INIT_MMX mmx | INIT_MMX mmx | ||||||
| ; void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size) | ; void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, ptrdiff_t stride) | ||||||
| cglobal get_pixels, 3,4 | cglobal get_pixels, 3,4 | ||||||
|     movsxdifnidn r2, r2d |  | ||||||
|     add          r0, 128 |     add          r0, 128 | ||||||
|     mov          r3, -128 |     mov          r3, -128 | ||||||
|     pxor         m7, m7 |     pxor         m7, m7 | ||||||
| @@ -52,7 +51,6 @@ cglobal get_pixels, 3,4 | |||||||
|  |  | ||||||
| INIT_XMM sse2 | INIT_XMM sse2 | ||||||
| cglobal get_pixels, 3, 4 | cglobal get_pixels, 3, 4 | ||||||
|     movsxdifnidn r2, r2d |  | ||||||
|     lea          r3, [r2*3] |     lea          r3, [r2*3] | ||||||
|     pxor         m4, m4 |     pxor         m4, m4 | ||||||
|     movh         m0, [r1] |     movh         m0, [r1] | ||||||
| @@ -84,9 +82,8 @@ cglobal get_pixels, 3, 4 | |||||||
|  |  | ||||||
| INIT_MMX mmx | INIT_MMX mmx | ||||||
| ; void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2, | ; void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2, | ||||||
| ;                         int stride); | ;                         ptrdiff_t stride); | ||||||
| cglobal diff_pixels, 4,5 | cglobal diff_pixels, 4,5 | ||||||
|     movsxdifnidn r3, r3d |  | ||||||
|     pxor         m7, m7 |     pxor         m7, m7 | ||||||
|     add          r0,  128 |     add          r0,  128 | ||||||
|     mov          r4, -128 |     mov          r4, -128 | ||||||
|   | |||||||
| @@ -23,10 +23,10 @@ | |||||||
| #include "libavutil/x86/cpu.h" | #include "libavutil/x86/cpu.h" | ||||||
| #include "libavcodec/pixblockdsp.h" | #include "libavcodec/pixblockdsp.h" | ||||||
|  |  | ||||||
| void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size); | void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, ptrdiff_t stride); | ||||||
| void ff_get_pixels_sse2(int16_t *block, const uint8_t *pixels, int line_size); | void ff_get_pixels_sse2(int16_t *block, const uint8_t *pixels, ptrdiff_t stride); | ||||||
| void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2, | void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2, | ||||||
|                         int stride); |                         ptrdiff_t stride); | ||||||
|  |  | ||||||
| av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c, | av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c, | ||||||
|                                      AVCodecContext *avctx, |                                      AVCodecContext *avctx, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user