[FFmpeg-devel,RFC] Use ptrdiff_t for linesize and stride

Submitted by Carl Eugen Hoyos on Jan. 13, 2018, 1:46 a.m.

Details

Message ID CAB0OVGrAYZuwjLULi5He6DtQSsF6m16PwmjdCdB9nDBW=QsAzA@mail.gmail.com
State New
Headers show

Commit Message

Carl Eugen Hoyos Jan. 13, 2018, 1:46 a.m.
Hi!

Seeing 6e80079a it appears that the unstable period is not over yet.
Vittorio posted a patch that introduces a temporary type to avoid
breaking API, but that may not be relevant if the api currently
unstable.

Attached patch (inspired by Vittorio's RFC) passes fate with
--disable-asm and does not introduce new warnings with gcc 6.3.
Do we generally need this change?
Do we generally want it?

If yes, I will likely need help for the asm changes.

I would like to avoid a temporary type and I would like to avoid a
future version bump only because this change suddenly becomes
necessary.

Please comment, Carl Eugen

Comments

wm4 Jan. 13, 2018, 2:19 a.m.
On Sat, 13 Jan 2018 02:46:51 +0100
Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> Hi!
> 
> Seeing 6e80079a it appears that the unstable period is not over yet.
> Vittorio posted a patch that introduces a temporary type to avoid
> breaking API, but that may not be relevant if the api currently
> unstable.
> 
> Attached patch (inspired by Vittorio's RFC) passes fate with
> --disable-asm and does not introduce new warnings with gcc 6.3.
> Do we generally need this change?
> Do we generally want it?
> 
> If yes, I will likely need help for the asm changes.
> 
> I would like to avoid a temporary type and I would like to avoid a
> future version bump only because this change suddenly becomes
> necessary.
> 
> Please comment, Carl Eugen

Doing that now would break EVERY API user.
Carl Eugen Hoyos Jan. 13, 2018, 2:47 a.m.
2018-01-13 3:19 GMT+01:00 wm4 <nfxjfg@googlemail.com>:
> On Sat, 13 Jan 2018 02:46:51 +0100
> Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
>> Hi!
>>
>> Seeing 6e80079a it appears that the unstable period is not over yet.
>> Vittorio posted a patch that introduces a temporary type to avoid
>> breaking API, but that may not be relevant if the api currently
>> unstable.
>>
>> Attached patch (inspired by Vittorio's RFC) passes fate with
>> --disable-asm and does not introduce new warnings with gcc 6.3.
>> Do we generally need this change?
>> Do we generally want it?
>>
>> If yes, I will likely need help for the asm changes.
>>
>> I would like to avoid a temporary type and I would like to avoid a
>> future version bump only because this change suddenly becomes
>> necessary.
>>
>> Please comment, Carl Eugen
>
> Doing that now would break EVERY API user.

As opposed to causing trouble only to those users who happen
to run libavcodec on a new Intel cpu? We seem to disagree
which is worse...
Anyway, since we had no release since the last bump, we
could simply bump again if this change has any advantage.

Carl Eugen
wm4 Jan. 13, 2018, 3:06 a.m.
On Sat, 13 Jan 2018 03:47:31 +0100
Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> 2018-01-13 3:19 GMT+01:00 wm4 <nfxjfg@googlemail.com>:
> > On Sat, 13 Jan 2018 02:46:51 +0100
> > Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >  
> >> Hi!
> >>
> >> Seeing 6e80079a it appears that the unstable period is not over yet.
> >> Vittorio posted a patch that introduces a temporary type to avoid
> >> breaking API, but that may not be relevant if the api currently
> >> unstable.
> >>
> >> Attached patch (inspired by Vittorio's RFC) passes fate with
> >> --disable-asm and does not introduce new warnings with gcc 6.3.
> >> Do we generally need this change?
> >> Do we generally want it?
> >>
> >> If yes, I will likely need help for the asm changes.
> >>
> >> I would like to avoid a temporary type and I would like to avoid a
> >> future version bump only because this change suddenly becomes
> >> necessary.
> >>
> >> Please comment, Carl Eugen  
> >
> > Doing that now would break EVERY API user.  
> 
> As opposed to causing trouble only to those users who happen
> to run libavcodec on a new Intel cpu? We seem to disagree
> which is worse...
> Anyway, since we had no release since the last bump, we
> could simply bump again if this change has any advantage.

What does this have to do with new Intel CPUs?

Also you can't be serious about breaking the API this badly. Also,
we're in an ABI unstable period - we never have API unstable periods.
The suggested change does not only change the ABI, but it breaks the
API as well, because the change is not source compatible.
James Almer Jan. 13, 2018, 3:41 a.m.
On 1/12/2018 10:46 PM, Carl Eugen Hoyos wrote:
> Hi!
> 
> Seeing 6e80079a it appears that the unstable period is not over yet.
> Vittorio posted a patch that introduces a temporary type to avoid
> breaking API, but that may not be relevant if the api currently
> unstable.

The ABI is what is in the unstable post bump period (Although that
should end soon), but the API never goes through such thing.
It's why the two years deprecation periods exist every time a public
symbol needs to be removed or some behavior changed, and why Vittorio's
patch implemented this by starting one.

> 
> Attached patch (inspired by Vittorio's RFC) passes fate with
> --disable-asm and does not introduce new warnings with gcc 6.3.
> Do we generally need this change?
> Do we generally want it?
> 
> If yes, I will likely need help for the asm changes.
> 
> I would like to avoid a temporary type and I would like to avoid a
> future version bump only because this change suddenly becomes
> necessary.
> 
> Please comment, Carl Eugen
> 
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Patch hide | download patch | download mbox

From 8846f6e0a773937c441834ccaf7774fd2415d8b7 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Sat, 13 Jan 2018 02:32:45 +0100
Subject: [PATCH] Use ptrdiff_t for linesize.

---
 libavcodec/avcodec.h              |    4 +-
 libavcodec/cinepakenc.c           |   42 ++++++------
 libavcodec/decode.c               |    2 +-
 libavcodec/error_resilience.c     |    8 +--
 libavcodec/ffv1dec_template.c     |    2 +-
 libavcodec/ffv1enc.c              |    2 +-
 libavcodec/ffv1enc_template.c     |    2 +-
 libavcodec/h264_loopfilter.c      |    6 +-
 libavcodec/h264dec.c              |    2 +-
 libavcodec/h264dec.h              |    6 +-
 libavcodec/internal.h             |    2 +-
 libavcodec/mpegvideo_enc.c        |    3 +-
 libavcodec/mpegvideoencdsp.c      |   12 ++--
 libavcodec/mpegvideoencdsp.h      |    4 +-
 libavcodec/nuv.c                  |    2 +-
 libavcodec/nvenc.c                |    2 +-
 libavcodec/roqvideoenc.c          |    4 +-
 libavcodec/smvjpegdec.c           |    4 +-
 libavcodec/utvideoenc.c           |    2 +-
 libavdevice/sdl2.c                |    2 +-
 libavdevice/xv.c                  |    6 +-
 libavfilter/avf_showcqt.c         |    2 +-
 libavfilter/drawutils.c           |   14 ++--
 libavfilter/drawutils.h           |   12 ++--
 libavfilter/framepool.c           |    2 +-
 libavfilter/lavfutils.c           |    2 +-
 libavfilter/lavfutils.h           |    2 +-
 libavfilter/lswsutils.c           |    4 +-
 libavfilter/lswsutils.h           |    4 +-
 libavfilter/maskedmerge.h         |    2 +-
 libavfilter/tinterlace.h          |    2 +-
 libavfilter/vf_detelecine.c       |    2 +-
 libavfilter/vf_extractplanes.c    |    2 +-
 libavfilter/vf_fieldhint.c        |    2 +-
 libavfilter/vf_fieldmatch.c       |    4 +-
 libavfilter/vf_fieldorder.c       |    2 +-
 libavfilter/vf_framepack.c        |    2 +-
 libavfilter/vf_il.c               |    2 +-
 libavfilter/vf_kerndeint.c        |    4 +-
 libavfilter/vf_limiter.c          |    2 +-
 libavfilter/vf_maskedclamp.c      |    2 +-
 libavfilter/vf_mix.c              |    2 +-
 libavfilter/vf_neighbor.c         |    2 +-
 libavfilter/vf_nnedi.c            |    4 +-
 libavfilter/vf_noise.h            |    2 +-
 libavfilter/vf_perspective.c      |    2 +-
 libavfilter/vf_phase.c            |    2 +-
 libavfilter/vf_premultiply.c      |    2 +-
 libavfilter/vf_pseudocolor.c      |    2 +-
 libavfilter/vf_psnr.c             |    4 +-
 libavfilter/vf_pullup.h           |    2 +-
 libavfilter/vf_removelogo.c       |    2 +-
 libavfilter/vf_repeatfields.c     |    2 +-
 libavfilter/vf_sab.c              |    8 +--
 libavfilter/vf_scale.c            |    2 +-
 libavfilter/vf_shuffleplanes.c    |    2 +-
 libavfilter/vf_smartblur.c        |    8 +--
 libavfilter/vf_stack.c            |    2 +-
 libavfilter/vf_stereo3d.c         |    2 +-
 libavfilter/vf_telecine.c         |    2 +-
 libavfilter/vf_tinterlace.c       |    4 +-
 libavfilter/vf_uspp.c             |    2 +-
 libavfilter/vf_w3fdif.c           |    2 +-
 libavfilter/vf_weave.c            |    2 +-
 libavfilter/vsrc_mptestsrc.c      |    4 +-
 libavformat/uncodedframecrcenc.c  |    2 +-
 libavutil/attributes.h            |    2 +
 libavutil/audio_fifo.c            |    5 +-
 libavutil/frame.h                 |    2 +-
 libavutil/hwcontext_vdpau.c       |    4 +-
 libavutil/imgutils.c              |   25 +++----
 libavutil/imgutils.h              |   18 ++---
 libavutil/pixdesc.c               |    6 +-
 libavutil/pixdesc.h               |    5 +-
 libavutil/samplefmt.c             |   11 +--
 libavutil/samplefmt.h             |    8 +--
 libpostproc/postprocess.c         |    4 +-
 libpostproc/postprocess.h         |    4 +-
 libswscale/alphablend.c           |    4 +-
 libswscale/slice.c                |    2 +-
 libswscale/swscale.c              |   17 ++---
 libswscale/swscale.h              |    4 +-
 libswscale/swscale_internal.h     |   14 ++--
 libswscale/swscale_unscaled.c     |  136 ++++++++++++++++++-------------------
 libswscale/x86/yuv2rgb_template.c |   32 ++++-----
 libswscale/yuv2rgb.c              |    4 +-
 tests/api/api-band-test.c         |    2 +-
 tests/api/api-h264-test.c         |    2 +-
 tests/api/api-seek-test.c         |    2 +-
 89 files changed, 290 insertions(+), 282 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8fbbc79..41a94f0 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3748,7 +3748,7 @@  typedef struct AVPicture {
     attribute_deprecated
     uint8_t *data[AV_NUM_DATA_POINTERS];    ///< pointers to the image data planes
     attribute_deprecated
-    int linesize[AV_NUM_DATA_POINTERS];     ///< number of bytes per line
+    ptrdiff_t linesize[AV_NUM_DATA_POINTERS];     ///< number of bytes per line
 } AVPicture;
 
 /**
@@ -3795,7 +3795,7 @@  typedef struct AVSubtitleRect {
      * Can be set for text/ass as well once they are rendered.
      */
     uint8_t *data[4];
-    int linesize[4];
+    ptrdiff_t linesize[4];
 
     enum AVSubtitleType type;
 
diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c
index 93917fa..463834b 100644
--- a/libavcodec/cinepakenc.c
+++ b/libavcodec/cinepakenc.c
@@ -445,8 +445,8 @@  static int encode_codebook(CinepakEncContext *s, int *codebook, int size,
 
 // sets out to the sub picture starting at (x,y) in in
 static void get_sub_picture(CinepakEncContext *s, int x, int y,
-                            uint8_t * in_data[4], int  in_linesize[4],
-                            uint8_t *out_data[4], int out_linesize[4])
+                            uint8_t * in_data[4], const ptrdiff_t  in_linesize[4],
+                            uint8_t *out_data[4], ptrdiff_t out_linesize[4])
 {
     out_data[0]     = in_data[0] + x + y * in_linesize[0];
     out_linesize[0] = in_linesize[0];
@@ -462,7 +462,7 @@  static void get_sub_picture(CinepakEncContext *s, int x, int y,
 
 // decodes the V1 vector in mb into the 4x4 MB pointed to by data
 static void decode_v1_vector(CinepakEncContext *s, uint8_t *data[4],
-                             int linesize[4], int v1_vector, strip_info *info)
+                             ptrdiff_t linesize[4], int v1_vector, strip_info *info)
 {
     int entry_size = s->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4;
 
@@ -501,7 +501,7 @@  static void decode_v1_vector(CinepakEncContext *s, uint8_t *data[4],
 
 // decodes the V4 vectors in mb into the 4x4 MB pointed to by data
 static void decode_v4_vector(CinepakEncContext *s, uint8_t *data[4],
-                             int linesize[4], int *v4_vector, strip_info *info)
+                             ptrdiff_t linesize[4], int *v4_vector, strip_info *info)
 {
     int i, x, y, entry_size = s->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4;
 
@@ -521,8 +521,8 @@  static void decode_v4_vector(CinepakEncContext *s, uint8_t *data[4],
 }
 
 static void copy_mb(CinepakEncContext *s,
-                    uint8_t *a_data[4], int a_linesize[4],
-                    uint8_t *b_data[4], int b_linesize[4])
+                    uint8_t *a_data[4], ptrdiff_t a_linesize[4],
+                    uint8_t *b_data[4], ptrdiff_t b_linesize[4])
 {
     int y, p;
 
@@ -540,8 +540,8 @@  static void copy_mb(CinepakEncContext *s,
 }
 
 static int encode_mode(CinepakEncContext *s, int h,
-                       uint8_t *scratch_data[4], int scratch_linesize[4],
-                       uint8_t *last_data[4], int last_linesize[4],
+                       uint8_t *scratch_data[4], ptrdiff_t scratch_linesize[4],
+                       uint8_t *last_data[4], ptrdiff_t last_linesize[4],
                        strip_info *info, unsigned char *buf)
 {
     int x, y, z, flags, bits, temp_size, header_ofs, ret = 0, mb_count = s->w * h / MB_AREA;
@@ -549,7 +549,7 @@  static int encode_mode(CinepakEncContext *s, int h,
     unsigned char temp[64]; // 32/2 = 16 V4 blocks at 4 B each -> 64 B
     mb_info *mb;
     uint8_t *sub_scratch_data[4] = { 0 }, *sub_last_data[4] = { 0 };
-    int sub_scratch_linesize[4] = { 0 }, sub_last_linesize[4] = { 0 };
+    ptrdiff_t sub_scratch_linesize[4] = { 0 }, sub_last_linesize[4] = { 0 };
 
     // encode codebooks
     ////// MacOS vintage decoder compatibility dictates the presence of
@@ -685,8 +685,8 @@  static int encode_mode(CinepakEncContext *s, int h,
 
 // computes distortion of 4x4 MB in b compared to a
 static int compute_mb_distortion(CinepakEncContext *s,
-                                 uint8_t *a_data[4], int a_linesize[4],
-                                 uint8_t *b_data[4], int b_linesize[4])
+                                 uint8_t *a_data[4], ptrdiff_t a_linesize[4],
+                                 uint8_t *b_data[4], ptrdiff_t b_linesize[4])
 {
     int x, y, p, d, ret = 0;
 
@@ -712,7 +712,7 @@  static int compute_mb_distortion(CinepakEncContext *s,
 // return the possibly adjusted size of the codebook
 #define CERTAIN(x) ((x) != ENC_UNCERTAIN)
 static int quantize(CinepakEncContext *s, int h, uint8_t *data[4],
-                    int linesize[4], int v1mode, strip_info *info,
+                    ptrdiff_t linesize[4], int v1mode, strip_info *info,
                     mb_encoding encoding)
 {
     int x, y, i, j, k, x2, y2, x3, y3, plane, shift, mbn;
@@ -722,7 +722,7 @@  static int quantize(CinepakEncContext *s, int h, uint8_t *data[4],
     int64_t total_error = 0;
     uint8_t vq_pict_buf[(MB_AREA * 3) / 2];
     uint8_t     *sub_data[4],     *vq_data[4];
-    int      sub_linesize[4],  vq_linesize[4];
+    ptrdiff_t sub_linesize[4],  vq_linesize[4];
 
     for (mbn = i = y = 0; y < h; y += MB_SIZE) {
         for (x = 0; x < s->w; x += MB_SIZE, ++mbn) {
@@ -827,13 +827,13 @@  static int quantize(CinepakEncContext *s, int h, uint8_t *data[4],
 }
 
 static void calculate_skip_errors(CinepakEncContext *s, int h,
-                                  uint8_t *last_data[4], int last_linesize[4],
-                                  uint8_t *data[4], int linesize[4],
+                                  uint8_t *last_data[4], ptrdiff_t last_linesize[4],
+                                  uint8_t *data[4], ptrdiff_t linesize[4],
                                   strip_info *info)
 {
     int x, y, i;
     uint8_t *sub_last_data    [4], *sub_pict_data    [4];
-    int      sub_last_linesize[4],  sub_pict_linesize[4];
+    ptrdiff_t sub_last_linesize[4],  sub_pict_linesize[4];
 
     for (i = y = 0; y < h; y += MB_SIZE)
         for (x = 0; x < s->w; x += MB_SIZE, i++) {
@@ -868,9 +868,9 @@  static void write_strip_header(CinepakEncContext *s, int y, int h, int keyframe,
 }
 
 static int rd_strip(CinepakEncContext *s, int y, int h, int keyframe,
-                    uint8_t *last_data[4], int last_linesize[4],
-                    uint8_t *data[4], int linesize[4],
-                    uint8_t *scratch_data[4], int scratch_linesize[4],
+                    uint8_t *last_data[4], ptrdiff_t last_linesize[4],
+                    uint8_t *data[4], ptrdiff_t linesize[4],
+                    uint8_t *scratch_data[4], ptrdiff_t scratch_linesize[4],
                     unsigned char *buf, int64_t *best_score)
 {
     int64_t score = 0;
@@ -1004,7 +1004,7 @@  static int rd_frame(CinepakEncContext *s, const AVFrame *frame,
 {
     int num_strips, strip, i, y, nexty, size, temp_size, best_size;
     uint8_t *last_data    [4], *data    [4], *scratch_data    [4];
-    int      last_linesize[4],  linesize[4],  scratch_linesize[4];
+    ptrdiff_t last_linesize[4],  linesize[4],  scratch_linesize[4];
     int64_t best_score = 0, score, score_temp;
     int best_nstrips;
 
@@ -1088,7 +1088,7 @@  static int rd_frame(CinepakEncContext *s, const AVFrame *frame,
                                 data, linesize);
             else
                 get_sub_picture(s, 0, y,
-                                (uint8_t **)frame->data, (int *)frame->linesize,
+                                (uint8_t **)frame->data, frame->linesize,
                                 data, linesize);
             get_sub_picture(s, 0, y,
                             s->last_frame->data, s->last_frame->linesize,
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index f67b214..fa1b15c 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1429,7 +1429,7 @@  static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
     switch (avctx->codec_type) {
     case AVMEDIA_TYPE_VIDEO: {
         uint8_t *data[4];
-        int linesize[4];
+        ptrdiff_t linesize[4];
         int size[4] = { 0 };
         int w = frame->width;
         int h = frame->height;
diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 55f7796..f41ac47 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -59,7 +59,7 @@  static void set_mv_strides(ERContext *s, ptrdiff_t *mv_step, ptrdiff_t *stride)
 static void put_dc(ERContext *s, uint8_t *dest_y, uint8_t *dest_cb,
                    uint8_t *dest_cr, int mb_x, int mb_y)
 {
-    int *linesize = s->cur_pic.f->linesize;
+    ptrdiff_t *linesize = s->cur_pic.f->linesize;
     int dc, dcu, dcv, y, i;
     for (i = 0; i < 4; i++) {
         dc = s->dc_val[0][mb_x * 2 + (i &  1) + (mb_y * 2 + (i >> 1)) * s->b8_stride];
@@ -623,7 +623,7 @@  skip_mean_and_median:
                 best_pred = 0;
                 best_score = 256 * 256 * 256 * 64;
                 for (j = 0; j < pred_count; j++) {
-                    int *linesize = s->cur_pic.f->linesize;
+                    ptrdiff_t *linesize = s->cur_pic.f->linesize;
                     int score = 0;
                     uint8_t *src = s->cur_pic.f->data[0] +
                                    mb_x * 16 + mb_y * 16 * linesize[0];
@@ -765,7 +765,7 @@  static int is_intra_more_likely(ERContext *s)
                 continue;
 
             if (s->cur_pic.f->pict_type == AV_PICTURE_TYPE_I) {
-                int *linesize = s->cur_pic.f->linesize;
+                ptrdiff_t *linesize = s->cur_pic.f->linesize;
                 uint8_t *mb_ptr      = s->cur_pic.f->data[0] +
                                        mb_x * 16 + mb_y * 16 * linesize[0];
                 uint8_t *last_mb_ptr = s->last_pic.f->data[0] +
@@ -899,7 +899,7 @@  void ff_er_add_slice(ERContext *s, int startx, int starty,
 
 void ff_er_frame_end(ERContext *s)
 {
-    int *linesize = NULL;
+    ptrdiff_t *linesize = NULL;
     int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error;
     int distance;
     int threshold_part[4] = { 100, 100, 100 };
diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c
index 37df766..6e284fa 100644
--- a/libavcodec/ffv1dec_template.c
+++ b/libavcodec/ffv1dec_template.c
@@ -107,7 +107,7 @@  static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w,
     return 0;
 }
 
-static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3])
+static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[3], int w, int h, ptrdiff_t stride[3])
 {
     int x, y, p;
     TYPE *sample[4][2];
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index c0c1558..4f6e0a2 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -934,7 +934,7 @@  static void encode_slice_header(FFV1Context *f, FFV1Context *fs)
     }
 }
 
-static void choose_rct_params(FFV1Context *fs, const uint8_t *src[3], const int stride[3], int w, int h)
+static void choose_rct_params(FFV1Context *fs, const uint8_t *src[3], const ptrdiff_t stride[3], int w, int h)
 {
 #define NB_Y_COEFF 15
     static const int rct_y_coeff[15][2] = {
diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c
index b7eea0d..c0da5e2 100644
--- a/libavcodec/ffv1enc_template.c
+++ b/libavcodec/ffv1enc_template.c
@@ -123,7 +123,7 @@  static av_always_inline int RENAME(encode_line)(FFV1Context *s, int w,
 }
 
 static int RENAME(encode_rgb_frame)(FFV1Context *s, const uint8_t *src[3],
-                                    int w, int h, const int stride[3])
+                                    int w, int h, const ptrdiff_t stride[3])
 {
     int x, y, p, i;
     const int ring_size = s->context_model ? 3 : 2;
diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c
index 0924f32..b0faa75 100644
--- a/libavcodec/h264_loopfilter.c
+++ b/libavcodec/h264_loopfilter.c
@@ -144,7 +144,7 @@  static av_always_inline void filter_mb_edgecv(uint8_t *pix, int stride,
 }
 
 static av_always_inline void filter_mb_mbaff_edgev(const H264Context *h, uint8_t *pix,
-                                                   int stride,
+                                                   ptrdiff_t stride,
                                                    const int16_t bS[7], int bsi,
                                                    int qp, int a, int b,
                                                    int intra)
@@ -418,7 +418,7 @@  static av_always_inline void h264_filter_mb_fast_internal(const H264Context *h,
 void ff_h264_filter_mb_fast(const H264Context *h, H264SliceContext *sl,
                             int mb_x, int mb_y, uint8_t *img_y,
                             uint8_t *img_cb, uint8_t *img_cr,
-                            unsigned int linesize, unsigned int uvlinesize)
+                            ptrdiff_t linesize, ptrdiff_t uvlinesize)
 {
     av_assert2(!FRAME_MBAFF(h));
     if(!h->h264dsp.h264_loop_filter_strength || h->ps.pps->chroma_qp_diff) {
@@ -718,7 +718,7 @@  static av_always_inline void filter_mb_dir(const H264Context *h, H264SliceContex
 void ff_h264_filter_mb(const H264Context *h, H264SliceContext *sl,
                        int mb_x, int mb_y,
                        uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
-                       unsigned int linesize, unsigned int uvlinesize)
+                       ptrdiff_t linesize, ptrdiff_t uvlinesize)
 {
     const int mb_xy= mb_x + mb_y*h->mb_stride;
     const int mb_type = h->cur_pic.mb_type[mb_xy];
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 8c9c6d9..ea8ccb2 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -891,7 +891,7 @@  static int finalize_frame(H264Context *h, AVFrame *dst, H264Picture *out, int *g
             AVFrame *f = out->f;
             int field = out->field_poc[0] == INT_MAX;
             uint8_t *dst_data[4];
-            int linesizes[4];
+            ptrdiff_t linesizes[4];
             const uint8_t *src_data[4];
 
             av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to fill missing\n", field);
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index 1d97232..db8e968 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -165,7 +165,7 @@  typedef struct H264Picture {
 
 typedef struct H264Ref {
     uint8_t *data[3];
-    int linesize[3];
+    ptrdiff_t linesize[3];
 
     int reference;
     int poc;
@@ -602,10 +602,10 @@  void ff_h264_pred_direct_motion(const H264Context *const h, H264SliceContext *sl
 
 void ff_h264_filter_mb_fast(const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y,
                             uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
-                            unsigned int linesize, unsigned int uvlinesize);
+                            ptrdiff_t linesize, ptrdiff_t uvlinesize);
 void ff_h264_filter_mb(const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y,
                        uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
-                       unsigned int linesize, unsigned int uvlinesize);
+                       ptrdiff_t linesize, ptrdiff_t uvlinesize);
 
 /*
  * o-o o-o
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 16bd101..4b68eec 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -110,7 +110,7 @@  typedef struct FramePool {
     int format;
     int width, height;
     int stride_align[AV_NUM_DATA_POINTERS];
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int planes;
     int channels;
     int samples;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index f1f4989..422ecae 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1216,7 +1216,8 @@  static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
         if (s->linesize & (STRIDE_ALIGN-1))
             direct = 0;
 
-        ff_dlog(s->avctx, "%d %d %"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER"\n", pic_arg->linesize[0],
+        ff_dlog(s->avctx, "%"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER"\n",
+                pic_arg->linesize[0],
                 pic_arg->linesize[1], s->linesize, s->uvlinesize);
 
         i = ff_find_unused_picture(s->avctx, s->picture, direct);
diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c
index 0af3d8b..b43f5f9 100644
--- a/libavcodec/mpegvideoencdsp.c
+++ b/libavcodec/mpegvideoencdsp.c
@@ -143,8 +143,8 @@  static void draw_edges_8_c(uint8_t *buf, int wrap, int width, int height,
 }
 
 /* 2x2 -> 1x1 */
-static void shrink22(uint8_t *dst, int dst_wrap,
-                     const uint8_t *src, int src_wrap,
+static void shrink22(uint8_t *dst, ptrdiff_t dst_wrap,
+                     const uint8_t *src, ptrdiff_t src_wrap,
                      int width, int height)
 {
     int w;
@@ -176,8 +176,8 @@  static void shrink22(uint8_t *dst, int dst_wrap,
 }
 
 /* 4x4 -> 1x1 */
-static void shrink44(uint8_t *dst, int dst_wrap,
-                     const uint8_t *src, int src_wrap,
+static void shrink44(uint8_t *dst, ptrdiff_t dst_wrap,
+                     const uint8_t *src, ptrdiff_t src_wrap,
                      int width, int height)
 {
     int w;
@@ -207,8 +207,8 @@  static void shrink44(uint8_t *dst, int dst_wrap,
 }
 
 /* 8x8 -> 1x1 */
-static void shrink88(uint8_t *dst, int dst_wrap,
-                     const uint8_t *src, int src_wrap,
+static void shrink88(uint8_t *dst, ptrdiff_t dst_wrap,
+                     const uint8_t *src, ptrdiff_t src_wrap,
                      int width, int height)
 {
     int w, i;
diff --git a/libavcodec/mpegvideoencdsp.h b/libavcodec/mpegvideoencdsp.h
index 33f0282..71a7a0e 100644
--- a/libavcodec/mpegvideoencdsp.h
+++ b/libavcodec/mpegvideoencdsp.h
@@ -37,8 +37,8 @@  typedef struct MpegvideoEncDSPContext {
     int (*pix_sum)(uint8_t *pix, int line_size);
     int (*pix_norm1)(uint8_t *pix, int line_size);
 
-    void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src,
-                      int src_wrap, int width, int height);
+    void (*shrink[4])(uint8_t *dst, ptrdiff_t dst_wrap, const uint8_t *src,
+                      ptrdiff_t src_wrap, int width, int height);
 
     void (*draw_edges)(uint8_t *buf, int wrap, int width, int height,
                        int w, int h, int sides);
diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c
index ad6c029..4374ae4 100644
--- a/libavcodec/nuv.c
+++ b/libavcodec/nuv.c
@@ -76,7 +76,7 @@  static const uint8_t fallback_cquant[] = {
 static void copy_frame(AVFrame *f, const uint8_t *src, int width, int height)
 {
     uint8_t *src_data[4];
-    int src_linesize[4];
+    ptrdiff_t src_linesize[4];
     av_image_fill_arrays(src_data, src_linesize, src,
                          f->format, width, height, 1);
     av_image_copy(f->data, f->linesize, (const uint8_t **)src_data, src_linesize,
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 4a91d99..9f65fb9 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1500,7 +1500,7 @@  static NvencSurface *get_free_frame(NvencContext *ctx)
 static int nvenc_copy_frame(AVCodecContext *avctx, NvencSurface *nv_surface,
             NV_ENC_LOCK_INPUT_BUFFER *lock_buffer_params, const AVFrame *frame)
 {
-    int dst_linesize[4] = {
+    ptrdiff_t dst_linesize[4] = {
         lock_buffer_params->pitch,
         lock_buffer_params->pitch,
         lock_buffer_params->pitch,
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index ac05123..1a76b9e 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -128,7 +128,7 @@  static inline int eval_sse(const uint8_t *a, const uint8_t *b, int count)
 // FIXME Could use DSPContext.sse, but it is not so speed critical (used
 // just for motion estimation).
 static int block_sse(uint8_t * const *buf1, uint8_t * const *buf2, int x1, int y1,
-                     int x2, int y2, const int *stride1, const int *stride2, int size)
+                     int x2, int y2, const ptrdiff_t *stride1, const ptrdiff_t *stride2, int size)
 {
     int i, k;
     int sse=0;
@@ -743,7 +743,7 @@  static void reconstruct_and_encode_image(RoqContext *enc, RoqTempdata *tempData,
  * Create a single YUV cell from a 2x2 section of the image
  */
 static inline void frame_block_to_cell(uint8_t *block, uint8_t * const *data,
-                                       int top, int left, const int *stride)
+                                       int top, int left, const ptrdiff_t *stride)
 {
     int i, j, u=0, v=0;
 
diff --git a/libavcodec/smvjpegdec.c b/libavcodec/smvjpegdec.c
index 018e135..a2cef7c 100644
--- a/libavcodec/smvjpegdec.c
+++ b/libavcodec/smvjpegdec.c
@@ -40,7 +40,7 @@  typedef struct SMVJpegDecodeContext {
 } SMVJpegDecodeContext;
 
 static inline void smv_img_pnt_plane(uint8_t      **dst, uint8_t *src,
-                                     int src_linesize, int height, int nlines)
+                                     ptrdiff_t src_linesize, int height, int nlines)
 {
     if (!dst || !src)
         return;
@@ -49,7 +49,7 @@  static inline void smv_img_pnt_plane(uint8_t      **dst, uint8_t *src,
 }
 
 static inline void smv_img_pnt(uint8_t *dst_data[4], uint8_t *src_data[4],
-                               const int src_linesizes[4],
+                               const ptrdiff_t src_linesizes[4],
                                enum AVPixelFormat pix_fmt, int width, int height,
                                int nlines)
 {
diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index a829b7a..3e7e5b6 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -243,7 +243,7 @@  FF_ENABLE_DEPRECATION_WARNINGS
 }
 
 static void mangle_rgb_planes(uint8_t *dst[4], ptrdiff_t dst_stride,
-                              uint8_t *const src[4], int planes, const int stride[4],
+                              uint8_t *const src[4], int planes, const ptrdiff_t stride[4],
                               int width, int height)
 {
     int i, j;
diff --git a/libavdevice/sdl2.c b/libavdevice/sdl2.c
index 5d9e91e..3b16101 100644
--- a/libavdevice/sdl2.c
+++ b/libavdevice/sdl2.c
@@ -244,7 +244,7 @@  static int sdl2_write_packet(AVFormatContext *s, AVPacket *pkt)
     SDLContext *sdl = s->priv_data;
     AVCodecParameters *codecpar = s->streams[0]->codecpar;
     uint8_t *data[4];
-    int linesize[4];
+    ptrdiff_t linesize[4];
 
     SDL_Event event;
     if (SDL_PollEvent(&event)){
diff --git a/libavdevice/xv.c b/libavdevice/xv.c
index 185de75..a9a38f4 100644
--- a/libavdevice/xv.c
+++ b/libavdevice/xv.c
@@ -292,7 +292,7 @@  static int xv_repaint(AVFormatContext *s)
 }
 
 static int write_picture(AVFormatContext *s, uint8_t *input_data[4],
-                         int linesize[4])
+                         ptrdiff_t linesize[4])
 {
     XVContext *xv = s->priv_data;
     XvImage *img = xv->yuv_image;
@@ -314,7 +314,7 @@  static int write_picture(AVFormatContext *s, uint8_t *input_data[4],
         }
     }
 
-    av_image_copy(data, img->pitches, (const uint8_t **)input_data, linesize,
+    av_image_copy(data, (ptrdiff_t *)img->pitches, (const uint8_t **)input_data, linesize,
                   xv->image_format, img->width, img->height);
     return xv_repaint(s);
 }
@@ -323,7 +323,7 @@  static int xv_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
     AVCodecParameters *par = s->streams[0]->codecpar;
     uint8_t *data[4];
-    int linesize[4];
+    ptrdiff_t linesize[4];
 
     av_image_fill_arrays(data, linesize, pkt->data, par->format,
                          par->width, par->height, 1);
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index 875ba48..58ec8d1 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -403,7 +403,7 @@  static int init_axis_empty(ShowCQTContext *s)
 static int init_axis_from_file(ShowCQTContext *s)
 {
     uint8_t *tmp_data[4] = { NULL };
-    int tmp_linesize[4];
+    ptrdiff_t tmp_linesize[4];
     enum AVPixelFormat tmp_format;
     int tmp_w, tmp_h, ret;
 
diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c
index 77ab86b..cd2acdc 100644
--- a/libavfilter/drawutils.c
+++ b/libavfilter/drawutils.c
@@ -279,7 +279,7 @@  void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4
     }
 }
 
-static uint8_t *pointer_at(FFDrawContext *draw, uint8_t *data[], int linesize[],
+static uint8_t *pointer_at(FFDrawContext *draw, uint8_t *data[], ptrdiff_t linesize[],
                            int plane, int x, int y)
 {
     return data[plane] +
@@ -288,8 +288,8 @@  static uint8_t *pointer_at(FFDrawContext *draw, uint8_t *data[], int linesize[],
 }
 
 void ff_copy_rectangle2(FFDrawContext *draw,
-                        uint8_t *dst[], int dst_linesize[],
-                        uint8_t *src[], int src_linesize[],
+                        uint8_t *dst[], ptrdiff_t dst_linesize[],
+                        uint8_t *src[], ptrdiff_t src_linesize[],
                         int dst_x, int dst_y, int src_x, int src_y,
                         int w, int h)
 {
@@ -310,7 +310,7 @@  void ff_copy_rectangle2(FFDrawContext *draw,
 }
 
 void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color,
-                       uint8_t *dst[], int dst_linesize[],
+                       uint8_t *dst[], ptrdiff_t dst_linesize[],
                        int dst_x, int dst_y, int w, int h)
 {
     int plane, x, y, wp, hp;
@@ -437,7 +437,7 @@  static void blend_line16(uint8_t *dst, unsigned src, unsigned alpha,
 }
 
 void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color,
-                        uint8_t *dst[], int dst_linesize[],
+                        uint8_t *dst[], ptrdiff_t dst_linesize[],
                         int dst_w, int dst_h,
                         int x0, int y0, int w, int h)
 {
@@ -614,8 +614,8 @@  static void blend_line_hv(uint8_t *dst, int dst_delta,
 }
 
 void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color,
-                   uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h,
-                   const uint8_t *mask,  int mask_linesize, int mask_w, int mask_h,
+                   uint8_t *dst[], ptrdiff_t dst_linesize[], int dst_w, int dst_h,
+                   const uint8_t *mask,  ptrdiff_t mask_linesize, int mask_w, int mask_h,
                    int l2depth, unsigned endianness, int x0, int y0)
 {
     unsigned alpha, nb_planes, nb_comp, plane, comp;
diff --git a/libavfilter/drawutils.h b/libavfilter/drawutils.h
index cf53635..09dc491 100644
--- a/libavfilter/drawutils.h
+++ b/libavfilter/drawutils.h
@@ -93,8 +93,8 @@  void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4
  * The coordinates must be as even as the subsampling requires.
  */
 void ff_copy_rectangle2(FFDrawContext *draw,
-                        uint8_t *dst[], int dst_linesize[],
-                        uint8_t *src[], int src_linesize[],
+                        uint8_t *dst[], ptrdiff_t dst_linesize[],
+                        uint8_t *src[], ptrdiff_t src_linesize[],
                         int dst_x, int dst_y, int src_x, int src_y,
                         int w, int h);
 
@@ -105,14 +105,14 @@  void ff_copy_rectangle2(FFDrawContext *draw,
  * The color needs to be inited with ff_draw_color.
  */
 void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color,
-                       uint8_t *dst[], int dst_linesize[],
+                       uint8_t *dst[], ptrdiff_t dst_linesize[],
                        int dst_x, int dst_y, int w, int h);
 
 /**
  * Blend a rectangle with an uniform color.
  */
 void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color,
-                        uint8_t *dst[], int dst_linesize[],
+                        uint8_t *dst[], ptrdiff_t dst_linesize[],
                         int dst_w, int dst_h,
                         int x0, int y0, int w, int h);
 
@@ -135,8 +135,8 @@  void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color,
  * @param y0             vertical position of the overlay
  */
 void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color,
-                   uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h,
-                   const uint8_t *mask, int mask_linesize, int mask_w, int mask_h,
+                   uint8_t *dst[], ptrdiff_t dst_linesize[], int dst_w, int dst_h,
+                   const uint8_t *mask, ptrdiff_t mask_linesize, int mask_w, int mask_h,
                    int l2depth, unsigned endianness, int x0, int y0);
 
 /**
diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index da2ac5c..98b4c72 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -43,7 +43,7 @@  struct FFFramePool {
     /* common */
     int format;
     int align;
-    int linesize[4];
+    ptrdiff_t linesize[4];
     AVBufferPool *pools[4];
 
 };
diff --git a/libavfilter/lavfutils.c b/libavfilter/lavfutils.c
index b6319cf..ae2f64b 100644
--- a/libavfilter/lavfutils.c
+++ b/libavfilter/lavfutils.c
@@ -21,7 +21,7 @@ 
 #include "libavutil/imgutils.h"
 #include "lavfutils.h"
 
-int ff_load_image(uint8_t *data[4], int linesize[4],
+int ff_load_image(uint8_t *data[4], ptrdiff_t linesize[4],
                   int *w, int *h, enum AVPixelFormat *pix_fmt,
                   const char *filename, void *log_ctx)
 {
diff --git a/libavfilter/lavfutils.h b/libavfilter/lavfutils.h
index 2d5308f..3b0c293 100644
--- a/libavfilter/lavfutils.h
+++ b/libavfilter/lavfutils.h
@@ -36,7 +36,7 @@ 
  * @param log_ctx log context
  * @return >= 0 in case of success, a negative error code otherwise.
  */
-int ff_load_image(uint8_t *data[4], int linesize[4],
+int ff_load_image(uint8_t *data[4], ptrdiff_t linesize[4],
                   int *w, int *h, enum AVPixelFormat *pix_fmt,
                   const char *filename, void *log_ctx);
 
diff --git a/libavfilter/lswsutils.c b/libavfilter/lswsutils.c
index ebb4f93..c9873c4 100644
--- a/libavfilter/lswsutils.c
+++ b/libavfilter/lswsutils.c
@@ -19,9 +19,9 @@ 
 #include "libavutil/imgutils.h"
 #include "lswsutils.h"
 
-int ff_scale_image(uint8_t *dst_data[4], int dst_linesize[4],
+int ff_scale_image(uint8_t *dst_data[4], ptrdiff_t dst_linesize[4],
                    int dst_w, int dst_h, enum AVPixelFormat dst_pix_fmt,
-                   uint8_t * const src_data[4], int src_linesize[4],
+                   uint8_t * const src_data[4], ptrdiff_t src_linesize[4],
                    int src_w, int src_h, enum AVPixelFormat src_pix_fmt,
                    void *log_ctx)
 {
diff --git a/libavfilter/lswsutils.h b/libavfilter/lswsutils.h
index f5f5320..3293157 100644
--- a/libavfilter/lswsutils.h
+++ b/libavfilter/lswsutils.h
@@ -29,9 +29,9 @@ 
 /**
  * Scale image using libswscale.
  */
-int ff_scale_image(uint8_t *dst_data[4], int dst_linesize[4],
+int ff_scale_image(uint8_t *dst_data[4], ptrdiff_t dst_linesize[4],
                    int dst_w, int dst_h, enum AVPixelFormat dst_pix_fmt,
-                   uint8_t *const src_data[4], int src_linesize[4],
+                   uint8_t *const src_data[4], ptrdiff_t src_linesize[4],
                    int src_w, int src_h, enum AVPixelFormat src_pix_fmt,
                    void *log_ctx);
 
diff --git a/libavfilter/maskedmerge.h b/libavfilter/maskedmerge.h
index 8e2b1cf..4c8e26f 100644
--- a/libavfilter/maskedmerge.h
+++ b/libavfilter/maskedmerge.h
@@ -27,7 +27,7 @@ 
 typedef struct MaskedMergeContext {
     const AVClass *class;
     int width[4], height[4];
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int nb_planes;
     int planes;
     int half, depth;
diff --git a/libavfilter/tinterlace.h b/libavfilter/tinterlace.h
index b5c39aa..c3a39d6 100644
--- a/libavfilter/tinterlace.h
+++ b/libavfilter/tinterlace.h
@@ -59,7 +59,7 @@  typedef struct TInterlaceContext {
     AVFrame *cur;
     AVFrame *next;
     uint8_t *black_data[4];     ///< buffer used to fill padded lines
-    int black_linesize[4];
+    ptrdiff_t black_linesize[4];
     FFDrawContext draw;
     FFDrawColor color;
     const AVPixFmtDescriptor *csp;
diff --git a/libavfilter/vf_detelecine.c b/libavfilter/vf_detelecine.c
index 0d1e2f2..713a987 100644
--- a/libavfilter/vf_detelecine.c
+++ b/libavfilter/vf_detelecine.c
@@ -48,7 +48,7 @@  typedef struct DetelecineContext {
 
     int nb_planes;
     int planeheight[4];
-    int stride[4];
+    ptrdiff_t stride[4];
 
     AVFrame *frame[2];
     AVFrame *temp;
diff --git a/libavfilter/vf_extractplanes.c b/libavfilter/vf_extractplanes.c
index fc676a2..43e40f1 100644
--- a/libavfilter/vf_extractplanes.c
+++ b/libavfilter/vf_extractplanes.c
@@ -42,7 +42,7 @@  typedef struct ExtractPlanesContext {
     const AVClass *class;
     int requested_planes;
     int map[4];
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int is_packed;
     int depth;
     int step;
diff --git a/libavfilter/vf_fieldhint.c b/libavfilter/vf_fieldhint.c
index 3cfeb20..6cf8ce8 100644
--- a/libavfilter/vf_fieldhint.c
+++ b/libavfilter/vf_fieldhint.c
@@ -39,7 +39,7 @@  typedef struct FieldHintContext {
     int64_t line;
     int nb_planes;
     int eof;
-    int planewidth[4];
+    ptrdiff_t planewidth[4];
     int planeheight[4];
 } FieldHintContext;
 
diff --git a/libavfilter/vf_fieldmatch.c b/libavfilter/vf_fieldmatch.c
index 3694f26..3bd9306 100644
--- a/libavfilter/vf_fieldmatch.c
+++ b/libavfilter/vf_fieldmatch.c
@@ -101,9 +101,9 @@  typedef struct FieldMatchContext {
 
     /* misc buffers */
     uint8_t *map_data[4];
-    int map_linesize[4];
+    ptrdiff_t map_linesize[4];
     uint8_t *cmask_data[4];
-    int cmask_linesize[4];
+    ptrdiff_t cmask_linesize[4];
     int *c_array;
     int tpitchy, tpitchuv;
     uint8_t *tbuffer;
diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index ca55ff1..478a1ec 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -35,7 +35,7 @@ 
 typedef struct FieldOrderContext {
     const AVClass *class;
     int dst_tff;               ///< output bff/tff
-    int          line_size[4]; ///< bytes of pixel data per line for each plane
+    ptrdiff_t line_size[4]; ///< bytes of pixel data per line for each plane
 } FieldOrderContext;
 
 static int query_formats(AVFilterContext *ctx)
diff --git a/libavfilter/vf_framepack.c b/libavfilter/vf_framepack.c
index 12a2996..0e83505 100644
--- a/libavfilter/vf_framepack.c
+++ b/libavfilter/vf_framepack.c
@@ -220,7 +220,7 @@  static void vertical_frame_pack(AVFilterLink *outlink,
     for (i = 0; i < 2; i++) {
         const uint8_t *src[4];
         uint8_t *dst[4];
-        int linesizes[4];
+        ptrdiff_t linesizes[4];
         int sub_h = s->input_views[i]->height >> s->pix_desc->log2_chroma_h;
 
         src[0] = s->input_views[i]->data[0];
diff --git a/libavfilter/vf_il.c b/libavfilter/vf_il.c
index ae0cc19..fc314f2 100644
--- a/libavfilter/vf_il.c
+++ b/libavfilter/vf_il.c
@@ -41,7 +41,7 @@  typedef struct IlContext {
     int luma_mode, chroma_mode, alpha_mode; ///<FilterMode
     int luma_swap, chroma_swap, alpha_swap;
     int nb_planes;
-    int linesize[4], chroma_height;
+    ptrdiff_t linesize[4], chroma_height;
     int has_alpha;
 } IlContext;
 
diff --git a/libavfilter/vf_kerndeint.c b/libavfilter/vf_kerndeint.c
index 057d15f..fa6f168 100644
--- a/libavfilter/vf_kerndeint.c
+++ b/libavfilter/vf_kerndeint.c
@@ -42,8 +42,8 @@  typedef struct KerndeintContext {
     int           vsub;
     int           is_packed_rgb;
     uint8_t       *tmp_data    [4];  ///< temporary plane data buffer
-    int            tmp_linesize[4];  ///< temporary plane byte linesize
-    int            tmp_bwidth  [4];  ///< temporary plane byte width
+    ptrdiff_t      tmp_linesize[4];  ///< temporary plane byte linesize
+    ptrdiff_t      tmp_bwidth  [4];  ///< temporary plane byte width
 } KerndeintContext;
 
 #define OFFSET(x) offsetof(KerndeintContext, x)
diff --git a/libavfilter/vf_limiter.c b/libavfilter/vf_limiter.c
index 9c62b11..9f8dbbf 100644
--- a/libavfilter/vf_limiter.c
+++ b/libavfilter/vf_limiter.c
@@ -34,7 +34,7 @@  typedef struct LimiterContext {
     int max;
     int planes;
     int nb_planes;
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int width[4];
     int height[4];
 
diff --git a/libavfilter/vf_maskedclamp.c b/libavfilter/vf_maskedclamp.c
index 9812e08..d2304b7 100644
--- a/libavfilter/vf_maskedclamp.c
+++ b/libavfilter/vf_maskedclamp.c
@@ -37,7 +37,7 @@  typedef struct MaskedClampContext {
     int undershoot;
     int overshoot;
 
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int width[4], height[4];
     int nb_planes;
     int depth;
diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c
index 261ab06..b4f7747 100644
--- a/libavfilter/vf_mix.c
+++ b/libavfilter/vf_mix.c
@@ -41,7 +41,7 @@  typedef struct MixContext {
 
     int depth;
     int nb_planes;
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int height[4];
 
     AVFrame **frames;
diff --git a/libavfilter/vf_neighbor.c b/libavfilter/vf_neighbor.c
index de4a12f..4f9b395 100644
--- a/libavfilter/vf_neighbor.c
+++ b/libavfilter/vf_neighbor.c
@@ -30,7 +30,7 @@ 
 typedef struct NContext {
     const AVClass *class;
     int planeheight[4];
-    int planewidth[4];
+    ptrdiff_t planewidth[4];
     int nb_planes;
     int threshold[4];
     int coordinates;
diff --git a/libavfilter/vf_nnedi.c b/libavfilter/vf_nnedi.c
index b14aa64..65e0061 100644
--- a/libavfilter/vf_nnedi.c
+++ b/libavfilter/vf_nnedi.c
@@ -38,7 +38,7 @@  typedef struct FrameData {
     int padded_height[3];
 
     uint8_t *dstp[3];
-    int dst_stride[3];
+    ptrdiff_t dst_stride[3];
 
     int field[3];
 
@@ -60,7 +60,7 @@  typedef struct NNEDIContext {
 
     AVFloatDSPContext *fdsp;
     int nb_planes;
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int planeheight[4];
 
     float *weights0;
diff --git a/libavfilter/vf_noise.h b/libavfilter/vf_noise.h
index 92998e5..bffdf66 100644
--- a/libavfilter/vf_noise.h
+++ b/libavfilter/vf_noise.h
@@ -48,7 +48,7 @@  typedef struct FilterParams {
 typedef struct NoiseContext {
     const AVClass *class;
     int nb_planes;
-    int bytewidth[4];
+    ptrdiff_t bytewidth[4];
     int height[4];
     FilterParams all;
     FilterParams param[4];
diff --git a/libavfilter/vf_perspective.c b/libavfilter/vf_perspective.c
index 9249509..d6d5675 100644
--- a/libavfilter/vf_perspective.c
+++ b/libavfilter/vf_perspective.c
@@ -43,7 +43,7 @@  typedef struct PerspectiveContext {
     int32_t (*pv)[2];
     int32_t coeff[SUB_PIXELS][4];
     int interpolation;
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int height[4];
     int hsub, vsub;
     int nb_planes;
diff --git a/libavfilter/vf_phase.c b/libavfilter/vf_phase.c
index fadeb62..f1f91bf 100644
--- a/libavfilter/vf_phase.c
+++ b/libavfilter/vf_phase.c
@@ -45,7 +45,7 @@  typedef struct PhaseContext {
     AVFrame *frame; /* previous frame */
     int nb_planes;
     int planeheight[4];
-    int linesize[4];
+    ptrdiff_t linesize[4];
 } PhaseContext;
 
 #define OFFSET(x) offsetof(PhaseContext, x)
diff --git a/libavfilter/vf_premultiply.c b/libavfilter/vf_premultiply.c
index df4f265..61c654c 100644
--- a/libavfilter/vf_premultiply.c
+++ b/libavfilter/vf_premultiply.c
@@ -31,7 +31,7 @@ 
 typedef struct PreMultiplyContext {
     const AVClass *class;
     int width[4], height[4];
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int nb_planes;
     int planes;
     int inverse;
diff --git a/libavfilter/vf_pseudocolor.c b/libavfilter/vf_pseudocolor.c
index 2e7a3a9..f5c5b14 100644
--- a/libavfilter/vf_pseudocolor.c
+++ b/libavfilter/vf_pseudocolor.c
@@ -65,7 +65,7 @@  typedef struct PseudoColorContext {
     int index;
     int nb_planes;
     int color;
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int width[4], height[4];
     double var_values[VAR_VARS_NB];
     char   *comp_expr_str[4];
diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 153d694..7c5f3d3 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -106,8 +106,8 @@  static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t *_ref_li
 
 static inline
 void compute_images_mse(PSNRContext *s,
-                        const uint8_t *main_data[4], const int main_linesizes[4],
-                        const uint8_t *ref_data[4], const int ref_linesizes[4],
+                        const uint8_t *main_data[4], const ptrdiff_t main_linesizes[4],
+                        const uint8_t *ref_data[4], const ptrdiff_t ref_linesizes[4],
                         int w, int h, double mse[4])
 {
     int i, c;
diff --git a/libavfilter/vf_pullup.h b/libavfilter/vf_pullup.h
index 8f59335..5c3e51b 100644
--- a/libavfilter/vf_pullup.h
+++ b/libavfilter/vf_pullup.h
@@ -55,7 +55,7 @@  typedef struct PullupContext {
     int metric_w, metric_h, metric_length;
     int metric_offset;
     int nb_planes;
-    int planewidth[4];
+    ptrdiff_t planewidth[4];
     int planeheight[4];
     PullupField *first, *last, *head;
     PullupBuffer buffers[10];
diff --git a/libavfilter/vf_removelogo.c b/libavfilter/vf_removelogo.c
index aff2d12..748f1e2 100644
--- a/libavfilter/vf_removelogo.c
+++ b/libavfilter/vf_removelogo.c
@@ -218,7 +218,7 @@  static int load_mask(uint8_t **mask, int *w, int *h,
     int ret;
     enum AVPixelFormat pix_fmt;
     uint8_t *src_data[4], *gray_data[4];
-    int src_linesize[4], gray_linesize[4];
+    ptrdiff_t src_linesize[4], gray_linesize[4];
 
     /* load image from file */
     if ((ret = ff_load_image(src_data, src_linesize, w, h, &pix_fmt, filename, log_ctx)) < 0)
diff --git a/libavfilter/vf_repeatfields.c b/libavfilter/vf_repeatfields.c
index 3ac432b..5358ffc 100644
--- a/libavfilter/vf_repeatfields.c
+++ b/libavfilter/vf_repeatfields.c
@@ -26,7 +26,7 @@  typedef struct RepeatFieldsContext {
     const AVClass *class;
     int state;
     int nb_planes;
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int planeheight[4];
     AVFrame *frame;
 } RepeatFieldsContext;
diff --git a/libavfilter/vf_sab.c b/libavfilter/vf_sab.c
index 6f63654..49a7279 100644
--- a/libavfilter/vf_sab.c
+++ b/libavfilter/vf_sab.c
@@ -221,8 +221,8 @@  static int config_props(AVFilterLink *inlink)
 
 #define NB_PLANES 4
 
-static void blur(uint8_t       *dst, const int dst_linesize,
-                 const uint8_t *src, const int src_linesize,
+static void blur(uint8_t       *dst, const ptrdiff_t dst_linesize,
+                 const uint8_t *src, const ptrdiff_t src_linesize,
                  const int w, const int h, FilterParam *fp)
 {
     int x, y;
@@ -230,9 +230,9 @@  static void blur(uint8_t       *dst, const int dst_linesize,
     const int radius = f.dist_width/2;
 
     const uint8_t * const src2[NB_PLANES] = { src };
-    int          src2_linesize[NB_PLANES] = { src_linesize };
+    ptrdiff_t src2_linesize[NB_PLANES] = { src_linesize };
     uint8_t     *dst2[NB_PLANES] = { f.pre_filter_buf };
-    int dst2_linesize[NB_PLANES] = { f.pre_filter_linesize };
+    ptrdiff_t dst2_linesize[NB_PLANES] = { f.pre_filter_linesize };
 
     sws_scale(f.pre_filter_context, src2, src2_linesize, 0, h, dst2, dst2_linesize);
 
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 9f45032..1f5d693 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -382,7 +382,7 @@  static int scale_slice(AVFilterLink *link, AVFrame *out_buf, AVFrame *cur_pic, s
     ScaleContext *scale = link->dst->priv;
     const uint8_t *in[4];
     uint8_t *out[4];
-    int in_stride[4],out_stride[4];
+    ptrdiff_t in_stride[4],out_stride[4];
     int i;
 
     for(i=0; i<4; i++){
diff --git a/libavfilter/vf_shuffleplanes.c b/libavfilter/vf_shuffleplanes.c
index 4bc7b79..8e20a84 100644
--- a/libavfilter/vf_shuffleplanes.c
+++ b/libavfilter/vf_shuffleplanes.c
@@ -88,7 +88,7 @@  static int shuffleplanes_filter_frame(AVFilterLink *inlink, AVFrame *frame)
     AVFilterContext          *ctx = inlink->dst;
     ShufflePlanesContext       *s = ctx->priv;
     uint8_t *shuffled_data[4]     = { NULL };
-    int      shuffled_linesize[4] = { 0 };
+    ptrdiff_t shuffled_linesize[4] = { 0 };
     int i, ret;
 
     for (i = 0; i < s->planes; i++) {
diff --git a/libavfilter/vf_smartblur.c b/libavfilter/vf_smartblur.c
index 1955ac4..bffac38 100644
--- a/libavfilter/vf_smartblur.c
+++ b/libavfilter/vf_smartblur.c
@@ -174,8 +174,8 @@  static int config_props(AVFilterLink *inlink)
     return 0;
 }
 
-static void blur(uint8_t       *dst, const int dst_linesize,
-                 const uint8_t *src, const int src_linesize,
+static void blur(uint8_t       *dst, const ptrdiff_t dst_linesize,
+                 const uint8_t *src, const ptrdiff_t src_linesize,
                  const int w, const int h, const int threshold,
                  struct SwsContext *filter_context)
 {
@@ -185,8 +185,8 @@  static void blur(uint8_t       *dst, const int dst_linesize,
     /* Declare arrays of 4 to get aligned data */
     const uint8_t* const src_array[4] = {src};
     uint8_t *dst_array[4]             = {dst};
-    int src_linesize_array[4] = {src_linesize};
-    int dst_linesize_array[4] = {dst_linesize};
+    ptrdiff_t src_linesize_array[4] = {src_linesize};
+    ptrdiff_t dst_linesize_array[4] = {dst_linesize};
 
     sws_scale(filter_context, src_array, src_linesize_array,
               0, h, dst_array, dst_linesize_array);
diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c
index b2b8c68..1056ac8 100644
--- a/libavfilter/vf_stack.c
+++ b/libavfilter/vf_stack.c
@@ -109,7 +109,7 @@  static int process_frame(FFFrameSync *fs)
 
     for (i = 0; i < s->nb_inputs; i++) {
         AVFilterLink *inlink = ctx->inputs[i];
-        int linesize[4];
+        ptrdiff_t linesize[4];
         int height[4];
 
         if ((ret = av_image_fill_linesizes(linesize, inlink->format, inlink->w)) < 0) {
diff --git a/libavfilter/vf_stereo3d.c b/libavfilter/vf_stereo3d.c
index 8b22f88..edec674 100644
--- a/libavfilter/vf_stereo3d.c
+++ b/libavfilter/vf_stereo3d.c
@@ -143,7 +143,7 @@  typedef struct Stereo3DContext {
     int width, height;
     const int *ana_matrix[3];
     int nb_planes;
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int pheight[4];
     int hsub, vsub;
     int pixstep[4];
diff --git a/libavfilter/vf_telecine.c b/libavfilter/vf_telecine.c
index 62599a7..2b5220d 100644
--- a/libavfilter/vf_telecine.c
+++ b/libavfilter/vf_telecine.c
@@ -47,7 +47,7 @@  typedef struct TelecineContext {
 
     int nb_planes;
     int planeheight[4];
-    int stride[4];
+    ptrdiff_t stride[4];
 
     AVFrame *frame[5];
     AVFrame *temp;
diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c
index f13791d..c09b395 100644
--- a/libavfilter/vf_tinterlace.c
+++ b/libavfilter/vf_tinterlace.c
@@ -296,8 +296,8 @@  static int config_out_props(AVFilterLink *outlink)
  */
 static inline
 void copy_picture_field(TInterlaceContext *tinterlace,
-                        uint8_t *dst[4], int dst_linesize[4],
-                        const uint8_t *src[4], int src_linesize[4],
+                        uint8_t *dst[4], ptrdiff_t dst_linesize[4],
+                        const uint8_t *src[4], ptrdiff_t src_linesize[4],
                         enum AVPixelFormat format, int w, int src_h,
                         int src_field, int interleave, int dst_field,
                         int flags)
diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
index da4029f..a6c377b 100644
--- a/libavfilter/vf_uspp.c
+++ b/libavfilter/vf_uspp.c
@@ -181,7 +181,7 @@  static void store_slice_c(uint8_t *dst, const uint16_t *src,
 }
 
 static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3],
-                   int dst_stride[3], int src_stride[3], int width,
+                   ptrdiff_t dst_stride[3], ptrdiff_t src_stride[3], int width,
                    int height, uint8_t *qp_store, int qp_stride)
 {
     int x, y, i, j;
diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c
index c6a6550..9c91134 100644
--- a/libavfilter/vf_w3fdif.c
+++ b/libavfilter/vf_w3fdif.c
@@ -35,7 +35,7 @@  typedef struct W3FDIFContext {
     const AVClass *class;
     int filter;           ///< 0 is simple, 1 is more complex
     int deint;            ///< which frames to deinterlace
-    int linesize[4];      ///< bytes of pixel data per line for each plane
+    ptrdiff_t linesize[4];///< bytes of pixel data per line for each plane
     int planeheight[4];   ///< height of each plane
     int field;            ///< which field are we on, 0 or 1
     int eof;
diff --git a/libavfilter/vf_weave.c b/libavfilter/vf_weave.c
index 037f5d1..08428fe 100644
--- a/libavfilter/vf_weave.c
+++ b/libavfilter/vf_weave.c
@@ -30,7 +30,7 @@  typedef struct WeaveContext {
     int double_weave;
     int nb_planes;
     int planeheight[4];
-    int linesize[4];
+    ptrdiff_t linesize[4];
 
     AVFrame *prev;
 } WeaveContext;
diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
index c5fdea7..ac2f16b 100644
--- a/libavfilter/vsrc_mptestsrc.c
+++ b/libavfilter/vsrc_mptestsrc.c
@@ -146,7 +146,7 @@  static void draw_basis(uint8_t *dst, int dst_linesize, int amp, int freq, int dc
     idct(dst, dst_linesize, src);
 }
 
-static void draw_cbp(uint8_t *dst[3], int dst_linesize[3], int cbp, int amp, int dc)
+static void draw_cbp(uint8_t *dst[3], ptrdiff_t dst_linesize[3], int cbp, int amp, int dc)
 {
     if (cbp&1)  draw_basis(dst[0]                    , dst_linesize[0], amp, 1, dc);
     if (cbp&2)  draw_basis(dst[0]+8                  , dst_linesize[0], amp, 1, dc);
@@ -193,7 +193,7 @@  static void amp_test(uint8_t *dst, int dst_linesize, int off)
     }
 }
 
-static void cbp_test(uint8_t *dst[3], int dst_linesize[3], int off)
+static void cbp_test(uint8_t *dst[3], ptrdiff_t dst_linesize[3], int off)
 {
     int x, y, cbp = 0;
 
diff --git a/libavformat/uncodedframecrcenc.c b/libavformat/uncodedframecrcenc.c
index 2f1a14c..5cec062 100644
--- a/libavformat/uncodedframecrcenc.c
+++ b/libavformat/uncodedframecrcenc.c
@@ -50,7 +50,7 @@  static void video_frame_cksum(AVBPrint *bp, AVFrame *frame)
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
     int i, y;
     uint8_t *data;
-    int linesize[5] = { 0 };
+    ptrdiff_t linesize[5] = { 0 };
 
     av_bprintf(bp, ", %d x %d", frame->width, frame->height);
     if (!desc) {
diff --git a/libavutil/attributes.h b/libavutil/attributes.h
index ced108a..8072291 100644
--- a/libavutil/attributes.h
+++ b/libavutil/attributes.h
@@ -97,6 +97,8 @@ 
 #else
 #    define attribute_deprecated
 #endif
+#undef attribute_deprecated
+#define attribute_deprecated
 
 /**
  * Disable warnings about deprecated features
diff --git a/libavutil/audio_fifo.c b/libavutil/audio_fifo.c
index 1bf75ce..049d4ef 100644
--- a/libavutil/audio_fifo.c
+++ b/libavutil/audio_fifo.c
@@ -60,7 +60,7 @@  AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
                                  int nb_samples)
 {
     AVAudioFifo *af;
-    int buf_size, i;
+    ptrdiff_t buf_size, i;
 
     /* get channel buffer size (also validates parameters) */
     if (av_samples_get_buffer_size(&buf_size, channels, nb_samples, sample_fmt, 1) < 0)
@@ -95,7 +95,8 @@  error:
 
 int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples)
 {
-    int i, ret, buf_size;
+    int i, ret;
+    ptrdiff_t buf_size;
 
     if ((ret = av_samples_get_buffer_size(&buf_size, af->channels, nb_samples,
                                           af->sample_fmt, 1)) < 0)
diff --git a/libavutil/frame.h b/libavutil/frame.h
index d54bd9a..104f48c 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -229,7 +229,7 @@  typedef struct AVFrame {
      * @note The linesize may be larger than the size of usable data -- there
      * may be extra padding present for performance reasons.
      */
-    int linesize[AV_NUM_DATA_POINTERS];
+    ptrdiff_t linesize[AV_NUM_DATA_POINTERS];
 
     /**
      * pointers to the data planes/channels.
diff --git a/libavutil/hwcontext_vdpau.c b/libavutil/hwcontext_vdpau.c
index 9b8f839..10ad57f 100644
--- a/libavutil/hwcontext_vdpau.c
+++ b/libavutil/hwcontext_vdpau.c
@@ -306,7 +306,7 @@  static int vdpau_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,
         data[i] = dst->data[i];
         if (dst->linesize[i] < 0 || dst->linesize[i] > UINT32_MAX) {
             av_log(ctx, AV_LOG_ERROR,
-                   "The linesize %d cannot be represented as uint32\n",
+                   "The linesize %"PTRDIFF_SPECIFIER" cannot be represented as uint32\n",
                    dst->linesize[i]);
             return AVERROR(ERANGE);
         }
@@ -357,7 +357,7 @@  static int vdpau_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
         data[i] = src->data[i];
         if (src->linesize[i] < 0 || src->linesize[i] > UINT32_MAX) {
             av_log(ctx, AV_LOG_ERROR,
-                   "The linesize %d cannot be represented as uint32\n",
+                   "The linesize %"PTRDIFF_SPECIFIER" cannot be represented as uint32\n",
                    src->linesize[i]);
             return AVERROR(ERANGE);
         }
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 5af4fc2..805019d 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -86,7 +86,7 @@  int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
     return image_get_linesize(width, plane, max_step[plane], max_step_comp[plane], desc);
 }
 
-int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
+int av_image_fill_linesizes(ptrdiff_t linesizes[4], enum AVPixelFormat pix_fmt, int width)
 {
     int i, ret;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
@@ -109,7 +109,7 @@  int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int wi
 }
 
 int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height,
-                           uint8_t *ptr, const int linesizes[4])
+                           uint8_t *ptr, const ptrdiff_t linesizes[4])
 {
     int i, total_size, size[4] = { 0 }, has_plane[4] = { 0 };
 
@@ -189,7 +189,7 @@  int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
     return 0;
 }
 
-int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
+int av_image_alloc(uint8_t *pointers[4], ptrdiff_t linesizes[4],
                    int w, int h, enum AVPixelFormat pix_fmt, int align)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
@@ -335,8 +335,8 @@  static void image_copy_plane_uc_from(uint8_t       *dst, ptrdiff_t dst_linesize,
         image_copy_plane(dst, dst_linesize, src, src_linesize, bytewidth, height);
 }
 
-void av_image_copy_plane(uint8_t       *dst, int dst_linesize,
-                         const uint8_t *src, int src_linesize,
+void av_image_copy_plane(uint8_t       *dst, ptrdiff_t dst_linesize,
+                         const uint8_t *src, ptrdiff_t src_linesize,
                          int bytewidth, int height)
 {
     image_copy_plane(dst, dst_linesize, src, src_linesize, bytewidth, height);
@@ -383,8 +383,8 @@  static void image_copy(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
     }
 }
 
-void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
-                   const uint8_t *src_data[4], const int src_linesizes[4],
+void av_image_copy(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
+                   const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4],
                    enum AVPixelFormat pix_fmt, int width, int height)
 {
     ptrdiff_t dst_linesizes1[4], src_linesizes1[4];
@@ -407,7 +407,7 @@  void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4
                width, height, image_copy_plane_uc_from);
 }
 
-int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
+int av_image_fill_arrays(uint8_t *dst_data[4], ptrdiff_t dst_linesize[4],
                          const uint8_t *src, enum AVPixelFormat pix_fmt,
                          int width, int height, int align)
 {
@@ -431,7 +431,7 @@  int av_image_get_buffer_size(enum AVPixelFormat pix_fmt,
                              int width, int height, int align)
 {
     uint8_t *data[4];
-    int linesize[4];
+    ptrdiff_t linesize[4];
     int ret;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
     if (!desc)
@@ -451,11 +451,12 @@  int av_image_get_buffer_size(enum AVPixelFormat pix_fmt,
 
 int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
                             const uint8_t * const src_data[4],
-                            const int src_linesize[4],
+                            const ptrdiff_t src_linesize[4],
                             enum AVPixelFormat pix_fmt,
                             int width, int height, int align)
 {
-    int i, j, nb_planes = 0, linesize[4];
+    int i, j, nb_planes = 0;
+    ptrdiff_t linesize[4];
     int size = av_image_get_buffer_size(pix_fmt, width, height, align);
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
     int ret;
@@ -606,7 +607,7 @@  int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4],
         // (Multiple pixels happen e.g. with AV_PIX_FMT_UYVY422.)
         int w = clear_block_size[comp.plane] / comp.step;
         uint8_t *c_data[4];
-        const int c_linesize[4] = {0};
+        const ptrdiff_t c_linesize[4] = {0};
         uint16_t src_array[MAX_BLOCK_SIZE];
         uint16_t src = 0;
         int x;
diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h
index 5b790ec..a52af57 100644
--- a/libavutil/imgutils.h
+++ b/libavutil/imgutils.h
@@ -65,7 +65,7 @@  int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane);
  * @param linesizes array to be filled with the linesize for each plane
  * @return >= 0 in case of success, a negative error code otherwise
  */
-int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width);
+int av_image_fill_linesizes(ptrdiff_t linesizes[4], enum AVPixelFormat pix_fmt, int width);
 
 /**
  * Fill plane data pointers for an image with pixel format pix_fmt and
@@ -79,7 +79,7 @@  int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int wi
  * error code in case of failure
  */
 int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height,
-                           uint8_t *ptr, const int linesizes[4]);
+                           uint8_t *ptr, const ptrdiff_t linesizes[4]);
 
 /**
  * Allocate an image with size w and h and pixel format pix_fmt, and
@@ -91,7 +91,7 @@  int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int hei
  * @return the size in bytes required for the image buffer, a negative
  * error code in case of failure
  */
-int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
+int av_image_alloc(uint8_t *pointers[4], ptrdiff_t linesizes[4],
                    int w, int h, enum AVPixelFormat pix_fmt, int align);
 
 /**
@@ -106,8 +106,8 @@  int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
  * @param dst_linesize linesize for the image plane in dst
  * @param src_linesize linesize for the image plane in src
  */
-void av_image_copy_plane(uint8_t       *dst, int dst_linesize,
-                         const uint8_t *src, int src_linesize,
+void av_image_copy_plane(uint8_t       *dst, ptrdiff_t dst_linesize,
+                         const uint8_t *src, ptrdiff_t src_linesize,
                          int bytewidth, int height);
 
 /**
@@ -116,8 +116,8 @@  void av_image_copy_plane(uint8_t       *dst, int dst_linesize,
  * @param dst_linesizes linesizes for the image in dst_data
  * @param src_linesizes linesizes for the image in src_data
  */
-void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
-                   const uint8_t *src_data[4], const int src_linesizes[4],
+void av_image_copy(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
+                   const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4],
                    enum AVPixelFormat pix_fmt, int width, int height);
 
 /**
@@ -164,7 +164,7 @@  void av_image_copy_uc_from(uint8_t *dst_data[4],       const ptrdiff_t dst_lines
  * @return the size in bytes required for src, a negative error code
  * in case of failure
  */
-int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
+int av_image_fill_arrays(uint8_t *dst_data[4], ptrdiff_t dst_linesize[4],
                          const uint8_t *src,
                          enum AVPixelFormat pix_fmt, int width, int height, int align);
 
@@ -198,7 +198,7 @@  int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height,
  * (error code) on error
  */
 int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
-                            const uint8_t * const src_data[4], const int src_linesize[4],
+                            const uint8_t * const src_data[4], const ptrdiff_t src_linesize[4],
                             enum AVPixelFormat pix_fmt, int width, int height, int align);
 
 /**
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index e77d5f4..41eeff3 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -32,7 +32,7 @@ 
 #include "version.h"
 
 void av_read_image_line(uint16_t *dst,
-                        const uint8_t *data[4], const int linesize[4],
+                        const uint8_t *data[4], const ptrdiff_t linesize[4],
                         const AVPixFmtDescriptor *desc,
                         int x, int y, int c, int w,
                         int read_pal_component)
@@ -80,7 +80,7 @@  void av_read_image_line(uint16_t *dst,
 }
 
 void av_write_image_line(const uint16_t *src,
-                         uint8_t *data[4], const int linesize[4],
+                         uint8_t *data[4], const ptrdiff_t linesize[4],
                          const AVPixFmtDescriptor *desc,
                          int x, int y, int c, int w)
 {
@@ -2422,7 +2422,7 @@  void ff_check_pixfmt_descriptors(void){
         const AVPixFmtDescriptor *d = &av_pix_fmt_descriptors[i];
         uint8_t fill[4][8+6+3] = {{0}};
         uint8_t *data[4] = {fill[0], fill[1], fill[2], fill[3]};
-        int linesize[4] = {0,0,0,0};
+        ptrdiff_t linesize[4] = {0,0,0,0};
         uint16_t tmp[2];
 
         if (!d->name && !d->nb_components && !d->log2_chroma_w && !d->log2_chroma_h && !d->flags)
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index ea04603..db418fa 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -23,6 +23,7 @@ 
 #define AVUTIL_PIXDESC_H
 
 #include <inttypes.h>
+#include <stddef.h>
 
 #include "attributes.h"
 #include "pixfmt.h"
@@ -341,7 +342,7 @@  char *av_get_pix_fmt_string(char *buf, int buf_size,
  * data[0]. The behavior is undefined if the format is not paletted.
  */
 void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
-                        const int linesize[4], const AVPixFmtDescriptor *desc,
+                        const ptrdiff_t linesize[4], const AVPixFmtDescriptor *desc,
                         int x, int y, int c, int w, int read_pal_component);
 
 /**
@@ -359,7 +360,7 @@  void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
  * values to write to the image line
  */
 void av_write_image_line(const uint16_t *src, uint8_t *data[4],
-                         const int linesize[4], const AVPixFmtDescriptor *desc,
+                         const ptrdiff_t linesize[4], const AVPixFmtDescriptor *desc,
                          int x, int y, int c, int w);
 
 /**
diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c
index fc077f6..fe0d398 100644
--- a/libavutil/samplefmt.c
+++ b/libavutil/samplefmt.c
@@ -116,7 +116,7 @@  int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
      return sample_fmt_info[sample_fmt].planar;
 }
 
-int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
+int av_samples_get_buffer_size(ptrdiff_t *linesize, int nb_channels, int nb_samples,
                                enum AVSampleFormat sample_fmt, int align)
 {
     int line_size;
@@ -148,11 +148,12 @@  int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
     return planar ? line_size * nb_channels : line_size;
 }
 
-int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
+int av_samples_fill_arrays(uint8_t **audio_data, ptrdiff_t *linesize,
                            const uint8_t *buf, int nb_channels, int nb_samples,
                            enum AVSampleFormat sample_fmt, int align)
 {
-    int ch, planar, buf_size, line_size;
+    int ch, planar, buf_size;
+    ptrdiff_t line_size;
 
     planar   = av_sample_fmt_is_planar(sample_fmt);
     buf_size = av_samples_get_buffer_size(&line_size, nb_channels, nb_samples,
@@ -170,7 +171,7 @@  int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
     return buf_size;
 }
 
-int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
+int av_samples_alloc(uint8_t **audio_data, ptrdiff_t *linesize, int nb_channels,
                      int nb_samples, enum AVSampleFormat sample_fmt, int align)
 {
     uint8_t *buf;
@@ -195,7 +196,7 @@  int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
     return size;
 }
 
-int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int nb_channels,
+int av_samples_alloc_array_and_samples(uint8_t ***audio_data, ptrdiff_t *linesize, int nb_channels,
                                        int nb_samples, enum AVSampleFormat sample_fmt, int align)
 {
     int ret, nb_planes = av_sample_fmt_is_planar(sample_fmt) ? nb_channels : 1;
diff --git a/libavutil/samplefmt.h b/libavutil/samplefmt.h
index 8cd43ae..40874f8 100644
--- a/libavutil/samplefmt.h
+++ b/libavutil/samplefmt.h
@@ -157,7 +157,7 @@  int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt);
  * @param align         buffer size alignment (0 = default, 1 = no alignment)
  * @return              required buffer size, or negative error code on failure
  */
-int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
+int av_samples_get_buffer_size(ptrdiff_t *linesize, int nb_channels, int nb_samples,
                                enum AVSampleFormat sample_fmt, int align);
 
 /**
@@ -199,7 +199,7 @@  int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
  * @todo return minimum size in bytes required for the buffer in case
  * of success at the next bump
  */
-int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
+int av_samples_fill_arrays(uint8_t **audio_data, ptrdiff_t *linesize,
                            const uint8_t *buf,
                            int nb_channels, int nb_samples,
                            enum AVSampleFormat sample_fmt, int align);
@@ -223,7 +223,7 @@  int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
  * @see av_samples_fill_arrays()
  * @see av_samples_alloc_array_and_samples()
  */
-int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
+int av_samples_alloc(uint8_t **audio_data, ptrdiff_t *linesize, int nb_channels,
                      int nb_samples, enum AVSampleFormat sample_fmt, int align);
 
 /**
@@ -235,7 +235,7 @@  int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
  *
  * @see av_samples_alloc()
  */
-int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int nb_channels,
+int av_samples_alloc_array_and_samples(uint8_t ***audio_data, ptrdiff_t *linesize, int nb_channels,
                                        int nb_samples, enum AVSampleFormat sample_fmt, int align);
 
 /**
diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c
index 1fef874..044713f 100644
--- a/libpostproc/postprocess.c
+++ b/libpostproc/postprocess.c
@@ -937,8 +937,8 @@  av_cold void pp_free_context(void *vc){
     av_free(c);
 }
 
-void  pp_postprocess(const uint8_t * src[3], const int srcStride[3],
-                     uint8_t * dst[3], const int dstStride[3],
+void  pp_postprocess(const uint8_t * src[3], const ptrdiff_t srcStride[3],
+                     uint8_t * dst[3], const ptrdiff_t dstStride[3],
                      int width, int height,
                      const int8_t *QP_store,  int QPStride,
                      pp_mode *vm,  void *vc, int pict_type)
diff --git a/libpostproc/postprocess.h b/libpostproc/postprocess.h
index 348ee7c..f9df272 100644
--- a/libpostproc/postprocess.h
+++ b/libpostproc/postprocess.h
@@ -66,8 +66,8 @@  extern const char *const pp_help; ///< a simple help text
 extern const char pp_help[]; ///< a simple help text
 #endif
 
-void  pp_postprocess(const uint8_t * src[3], const int srcStride[3],
-                     uint8_t * dst[3], const int dstStride[3],
+void  pp_postprocess(const uint8_t * src[3], const ptrdiff_t srcStride[3],
+                     uint8_t * dst[3], const ptrdiff_t dstStride[3],
                      int horizontalSize, int verticalSize,
                      const int8_t *QP_store,  int QP_stride,
                      pp_mode *mode, pp_context *ppContext, int pict_type);
diff --git a/libswscale/alphablend.c b/libswscale/alphablend.c
index b568659..eeea579 100644
--- a/libswscale/alphablend.c
+++ b/libswscale/alphablend.c
@@ -21,8 +21,8 @@ 
 #include "swscale_internal.h"
 
 int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
-                          int srcStride[], int srcSliceY, int srcSliceH,
-                          uint8_t *dst[], int dstStride[])
+                          ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                          uint8_t *dst[], ptrdiff_t dstStride[])
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
     int nb_components = desc->nb_components;
diff --git a/libswscale/slice.c b/libswscale/slice.c
index db4fa87..d646cb1 100644
--- a/libswscale/slice.c
+++ b/libswscale/slice.c
@@ -144,7 +144,7 @@  int ff_rotate_slice(SwsSlice *s, int lum, int chr)
     return 0;
 }
 
-int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int srcW, int lumY, int lumH, int chrY, int chrH, int relative)
+int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], ptrdiff_t stride[4], int srcW, int lumY, int lumH, int chrY, int chrH, int relative)
 {
     int i = 0;
 
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 7f3e223..c4575d3 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -229,8 +229,8 @@  static void lumRangeFromJpeg16_c(int16_t *_dst, int width)
         av_log(c, AV_LOG_DEBUG, __VA_ARGS__)
 
 static int swscale(SwsContext *c, const uint8_t *src[],
-                   int srcStride[], int srcSliceY,
-                   int srcSliceH, uint8_t *dst[], int dstStride[])
+                   ptrdiff_t srcStride[], int srcSliceY,
+                   int srcSliceH, uint8_t *dst[], ptrdiff_t dstStride[])
 {
     /* load a few things into local vars to make the code more readable?
      * and faster */
@@ -297,7 +297,8 @@  static int swscale(SwsContext *c, const uint8_t *src[],
     srcStride[1] <<= c->vChrDrop;
     srcStride[2] <<= c->vChrDrop;
 
-    DEBUG_BUFFERS("swscale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
+    DEBUG_BUFFERS("swscale() %p[%"PTRDIFF_SPECIFIER"] %p[%"PTRDIFF_SPECIFIER"] %p[%"PTRDIFF_SPECIFIER"] %p[%"PTRDIFF_SPECIFIER"]"
+                  " -> %p[%"PTRDIFF_SPECIFIER"] %p[%"PTRDIFF_SPECIFIER"] %p[%"PTRDIFF_SPECIFIER"] %p[%"PTRDIFF_SPECIFIER"]\n",
                   src[0], srcStride[0], src[1], srcStride[1],
                   src[2], srcStride[2], src[3], srcStride[3],
                   dst[0], dstStride[0], dst[1], dstStride[1],
@@ -618,7 +619,7 @@  static void reset_ptr(const uint8_t *src[], enum AVPixelFormat format)
 }
 
 static int check_image_pointers(const uint8_t * const data[4], enum AVPixelFormat pix_fmt,
-                                const int linesizes[4])
+                                const ptrdiff_t linesizes[4])
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
     int i;
@@ -752,9 +753,9 @@  static void rgb48Toxyz12(struct SwsContext *c, uint16_t *dst,
  */
 int attribute_align_arg sws_scale(struct SwsContext *c,
                                   const uint8_t * const srcSlice[],
-                                  const int srcStride[], int srcSliceY,
+                                  const ptrdiff_t srcStride[], int srcSliceY,
                                   int srcSliceH, uint8_t *const dst[],
-                                  const int dstStride[])
+                                  const ptrdiff_t dstStride[])
 {
     int i, ret;
     const uint8_t *src2[4];
@@ -762,8 +763,8 @@  int attribute_align_arg sws_scale(struct SwsContext *c,
     uint8_t *rgb0_tmp = NULL;
     int macro_height = isBayer(c->srcFormat) ? 2 : (1 << c->chrSrcVSubSample);
     // copy strides, so they can safely be modified
-    int srcStride2[4];
-    int dstStride2[4];
+    ptrdiff_t srcStride2[4];
+    ptrdiff_t dstStride2[4];
     int srcSliceY_internal = srcSliceY;
 
     if (!srcStride || !dstStride || !dst || !srcSlice) {
diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index 7713f51..cac2975 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -215,8 +215,8 @@  struct SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcForm
  * @return          the height of the output slice
  */
 int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
-              const int srcStride[], int srcSliceY, int srcSliceH,
-              uint8_t *const dst[], const int dstStride[]);
+              const ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+              uint8_t *const dst[], const ptrdiff_t dstStride[]);
 
 /**
  * @param dstRange flag indicating the while-black range of the output (1=jpeg / 0=mpeg)
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 0f51df9..2b71b34 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -80,8 +80,8 @@  typedef enum SwsAlphaBlend {
 } SwsAlphaBlend;
 
 typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t *src[],
-                       int srcStride[], int srcSliceY, int srcSliceH,
-                       uint8_t *dst[], int dstStride[]);
+                       ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                       uint8_t *dst[], ptrdiff_t dstStride[]);
 
 /**
  * Write one line of horizontally scaled data to planar output
@@ -315,9 +315,9 @@  typedef struct SwsContext {
      * downscaling factor that needs to be supported in one scaler.
      */
     struct SwsContext *cascaded_context[3];
-    int cascaded_tmpStride[4];
+    ptrdiff_t cascaded_tmpStride[4];
     uint8_t *cascaded_tmp[4];
-    int cascaded1_tmpStride[4];
+    ptrdiff_t cascaded1_tmpStride[4];
     uint8_t *cascaded1_tmp[4];
     int cascaded_mainindex;
 
@@ -871,8 +871,8 @@  struct SwsContext *sws_alloc_set_opts(int srcW, int srcH, enum AVPixelFormat src
                                       int flags, const double *param);
 
 int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
-                          int srcStride[], int srcSliceY, int srcSliceH,
-                          uint8_t *dst[], int dstStride[]);
+                          ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                          uint8_t *dst[], ptrdiff_t dstStride[]);
 
 static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y,
                                int alpha, int bits, const int big_endian)
@@ -940,7 +940,7 @@  typedef struct SwsFilterDescriptor
 
 // warp input lines in the form (src + width*i + j) to slice format (line[i][j])
 // relative=true means first line src[x][0] otherwise first line is src[x][lum/crh Y]
-int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int srcW, int lumY, int lumH, int chrY, int chrH, int relative);
+int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], ptrdiff_t stride[4], int srcW, int lumY, int lumH, int chrY, int chrH, int relative);
 
 // Initialize scaler filter descriptor chain
 int ff_init_filters(SwsContext *c);
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 5ec2116..47b006e 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -122,9 +122,9 @@  static void fillPlane(uint8_t *plane, int stride, int width, int height, int y,
     }
 }
 
-static void copyPlane(const uint8_t *src, int srcStride,
+static void copyPlane(const uint8_t *src, ptrdiff_t srcStride,
                       int srcSliceY, int srcSliceH, int width,
-                      uint8_t *dst, int dstStride)
+                      uint8_t *dst, ptrdiff_t dstStride)
 {
     dst += dstStride * srcSliceY;
     if (dstStride == srcStride && srcStride > 0) {
@@ -140,9 +140,9 @@  static void copyPlane(const uint8_t *src, int srcStride,
 }
 
 static int planarToNv12Wrapper(SwsContext *c, const uint8_t *src[],
-                               int srcStride[], int srcSliceY,
+                               ptrdiff_t srcStride[], int srcSliceY,
                                int srcSliceH, uint8_t *dstParam[],
-                               int dstStride[])
+                               ptrdiff_t dstStride[])
 {
     uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY / 2;
 
@@ -160,9 +160,9 @@  static int planarToNv12Wrapper(SwsContext *c, const uint8_t *src[],
 }
 
 static int nv12ToPlanarWrapper(SwsContext *c, const uint8_t *src[],
-                               int srcStride[], int srcSliceY,
+                               ptrdiff_t srcStride[], int srcSliceY,
                                int srcSliceH, uint8_t *dstParam[],
-                               int dstStride[])
+                               ptrdiff_t dstStride[])
 {
     uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2;
     uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2;
@@ -181,9 +181,9 @@  static int nv12ToPlanarWrapper(SwsContext *c, const uint8_t *src[],
 }
 
 static int planarToP010Wrapper(SwsContext *c, const uint8_t *src8[],
-                               int srcStride[], int srcSliceY,
+                               ptrdiff_t srcStride[], int srcSliceY,
                                int srcSliceH, uint8_t *dstParam8[],
-                               int dstStride[])
+                               ptrdiff_t dstStride[])
 {
     const uint16_t **src = (const uint16_t**)src8;
     uint16_t *dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
@@ -229,9 +229,9 @@  static int planarToP010Wrapper(SwsContext *c, const uint8_t *src8[],
 #endif
 
 static int planar8ToP01xleWrapper(SwsContext *c, const uint8_t *src[],
-                                  int srcStride[], int srcSliceY,
+                                  ptrdiff_t srcStride[], int srcSliceY,
                                   int srcSliceH, uint8_t *dstParam8[],
-                                  int dstStride[])
+                                  ptrdiff_t dstStride[])
 {
     uint16_t *dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
     uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
@@ -271,8 +271,8 @@  static int planar8ToP01xleWrapper(SwsContext *c, const uint8_t *src[],
 #undef output_pixel
 
 static int planarToYuy2Wrapper(SwsContext *c, const uint8_t *src[],
-                               int srcStride[], int srcSliceY, int srcSliceH,
-                               uint8_t *dstParam[], int dstStride[])
+                               ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                               uint8_t *dstParam[], ptrdiff_t dstStride[])
 {
     uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
 
@@ -283,8 +283,8 @@  static int planarToYuy2Wrapper(SwsContext *c, const uint8_t *src[],
 }
 
 static int planarToUyvyWrapper(SwsContext *c, const uint8_t *src[],
-                               int srcStride[], int srcSliceY, int srcSliceH,
-                               uint8_t *dstParam[], int dstStride[])
+                               ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                               uint8_t *dstParam[], ptrdiff_t dstStride[])
 {
     uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
 
@@ -295,8 +295,8 @@  static int planarToUyvyWrapper(SwsContext *c, const uint8_t *src[],
 }
 
 static int yuv422pToYuy2Wrapper(SwsContext *c, const uint8_t *src[],
-                                int srcStride[], int srcSliceY, int srcSliceH,
-                                uint8_t *dstParam[], int dstStride[])
+                                ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                                uint8_t *dstParam[], ptrdiff_t dstStride[])
 {
     uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
 
@@ -307,8 +307,8 @@  static int yuv422pToYuy2Wrapper(SwsContext *c, const uint8_t *src[],
 }
 
 static int yuv422pToUyvyWrapper(SwsContext *c, const uint8_t *src[],
-                                int srcStride[], int srcSliceY, int srcSliceH,
-                                uint8_t *dstParam[], int dstStride[])
+                                ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                                uint8_t *dstParam[], ptrdiff_t dstStride[])
 {
     uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
 
@@ -319,8 +319,8 @@  static int yuv422pToUyvyWrapper(SwsContext *c, const uint8_t *src[],
 }
 
 static int yuyvToYuv420Wrapper(SwsContext *c, const uint8_t *src[],
-                               int srcStride[], int srcSliceY, int srcSliceH,
-                               uint8_t *dstParam[], int dstStride[])
+                               ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                               uint8_t *dstParam[], ptrdiff_t dstStride[])
 {
     uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
     uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
@@ -336,8 +336,8 @@  static int yuyvToYuv420Wrapper(SwsContext *c, const uint8_t *src[],
 }
 
 static int yuyvToYuv422Wrapper(SwsContext *c, const uint8_t *src[],
-                               int srcStride[], int srcSliceY, int srcSliceH,
-                               uint8_t *dstParam[], int dstStride[])
+                               ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                               uint8_t *dstParam[], ptrdiff_t dstStride[])
 {
     uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
     uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
@@ -350,8 +350,8 @@  static int yuyvToYuv422Wrapper(SwsContext *c, const uint8_t *src[],
 }
 
 static int uyvyToYuv420Wrapper(SwsContext *c, const uint8_t *src[],
-                               int srcStride[], int srcSliceY, int srcSliceH,
-                               uint8_t *dstParam[], int dstStride[])
+                               ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                               uint8_t *dstParam[], ptrdiff_t dstStride[])
 {
     uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
     uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
@@ -367,8 +367,8 @@  static int uyvyToYuv420Wrapper(SwsContext *c, const uint8_t *src[],
 }
 
 static int uyvyToYuv422Wrapper(SwsContext *c, const uint8_t *src[],
-                               int srcStride[], int srcSliceY, int srcSliceH,
-                               uint8_t *dstParam[], int dstStride[])
+                               ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                               uint8_t *dstParam[], ptrdiff_t dstStride[])
 {
     uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
     uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
@@ -412,8 +412,8 @@  static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels,
 }
 
 static int packed_16bpc_bswap(SwsContext *c, const uint8_t *src[],
-                              int srcStride[], int srcSliceY, int srcSliceH,
-                              uint8_t *dst[], int dstStride[])
+                              ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                              uint8_t *dst[], ptrdiff_t dstStride[])
 {
     int i, j, p;
 
@@ -438,9 +438,9 @@  static int packed_16bpc_bswap(SwsContext *c, const uint8_t *src[],
     return srcSliceH;
 }
 
-static int palToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
+static int palToRgbWrapper(SwsContext *c, const uint8_t *src[], ptrdiff_t srcStride[],
                            int srcSliceY, int srcSliceH, uint8_t *dst[],
-                           int dstStride[])
+                           ptrdiff_t dstStride[])
 {
     const enum AVPixelFormat srcFormat = c->srcFormat;
     const enum AVPixelFormat dstFormat = c->dstFormat;
@@ -484,8 +484,8 @@  static int palToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
     return srcSliceH;
 }
 
-static void packed16togbra16(const uint8_t *src, int srcStride,
-                             uint16_t *dst[], int dstStride[], int srcSliceH,
+static void packed16togbra16(const uint8_t *src, ptrdiff_t srcStride,
+                             uint16_t *dst[], ptrdiff_t dstStride[], int srcSliceH,
                              int src_alpha, int swap, int shift, int width)
 {
     int x, h, i;
@@ -619,13 +619,13 @@  static void packed16togbra16(const uint8_t *src, int srcStride,
 }
 
 static int Rgb16ToPlanarRgb16Wrapper(SwsContext *c, const uint8_t *src[],
-                                     int srcStride[], int srcSliceY, int srcSliceH,
-                                     uint8_t *dst[], int dstStride[])
+                                     ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                                     uint8_t *dst[], ptrdiff_t dstStride[])
 {
     uint16_t *dst2013[] = { (uint16_t *)dst[2], (uint16_t *)dst[0], (uint16_t *)dst[1], (uint16_t *)dst[3] };
     uint16_t *dst1023[] = { (uint16_t *)dst[1], (uint16_t *)dst[0], (uint16_t *)dst[2], (uint16_t *)dst[3] };
-    int stride2013[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
-    int stride1023[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
+    ptrdiff_t stride2013[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
+    ptrdiff_t stride1023[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
     const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->srcFormat);
     const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->dstFormat);
     int bpc = dst_format->comp[0].depth;
@@ -798,8 +798,8 @@  static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
 }
 
 static int planarRgb16ToRgb16Wrapper(SwsContext *c, const uint8_t *src[],
-                                     int srcStride[], int srcSliceY, int srcSliceH,
-                                     uint8_t *dst[], int dstStride[])
+                                     ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                                     uint8_t *dst[], ptrdiff_t dstStride[])
 {
     const uint16_t *src102[] = { (uint16_t *)src[1], (uint16_t *)src[0], (uint16_t *)src[2], (uint16_t *)src[3] };
     const uint16_t *src201[] = { (uint16_t *)src[2], (uint16_t *)src[0], (uint16_t *)src[1], (uint16_t *)src[3] };
@@ -857,8 +857,8 @@  static int planarRgb16ToRgb16Wrapper(SwsContext *c, const uint8_t *src[],
     return srcSliceH;
 }
 
-static void gbr24ptopacked24(const uint8_t *src[], int srcStride[],
-                             uint8_t *dst, int dstStride, int srcSliceH,
+static void gbr24ptopacked24(const uint8_t *src[], ptrdiff_t srcStride[],
+                             uint8_t *dst, ptrdiff_t dstStride, int srcSliceH,
                              int width)
 {
     int x, h, i;
@@ -875,8 +875,8 @@  static void gbr24ptopacked24(const uint8_t *src[], int srcStride[],
     }
 }
 
-static void gbr24ptopacked32(const uint8_t *src[], int srcStride[],
-                             uint8_t *dst, int dstStride, int srcSliceH,
+static void gbr24ptopacked32(const uint8_t *src[], ptrdiff_t srcStride[],
+                             uint8_t *dst, ptrdiff_t dstStride, int srcSliceH,
                              int alpha_first, int width)
 {
     int x, h, i;
@@ -905,14 +905,14 @@  static void gbr24ptopacked32(const uint8_t *src[], int srcStride[],
 }
 
 static int planarRgbToRgbWrapper(SwsContext *c, const uint8_t *src[],
-                                 int srcStride[], int srcSliceY, int srcSliceH,
-                                 uint8_t *dst[], int dstStride[])
+                                 ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                                 uint8_t *dst[], ptrdiff_t dstStride[])
 {
     int alpha_first = 0;
     const uint8_t *src102[] = { src[1], src[0], src[2] };
     const uint8_t *src201[] = { src[2], src[0], src[1] };
-    int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
-    int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
+    ptrdiff_t stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
+    ptrdiff_t stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
 
     if (c->srcFormat != AV_PIX_FMT_GBRP) {
         av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
@@ -961,9 +961,9 @@  static int planarRgbToRgbWrapper(SwsContext *c, const uint8_t *src[],
 }
 
 static int planarRgbToplanarRgbWrapper(SwsContext *c,
-                                       const uint8_t *src[], int srcStride[],
+                                       const uint8_t *src[], ptrdiff_t srcStride[],
                                        int srcSliceY, int srcSliceH,
-                                       uint8_t *dst[], int dstStride[])
+                                       uint8_t *dst[], ptrdiff_t dstStride[])
 {
     copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
               dst[0], dstStride[0]);
@@ -977,8 +977,8 @@  static int planarRgbToplanarRgbWrapper(SwsContext *c,
     return srcSliceH;
 }
 
-static void packedtogbr24p(const uint8_t *src, int srcStride,
-                           uint8_t *dst[], int dstStride[], int srcSliceH,
+static void packedtogbr24p(const uint8_t *src, ptrdiff_t srcStride,
+                           uint8_t *dst[], ptrdiff_t dstStride[], int srcSliceH,
                            int alpha_first, int inc_size, int width)
 {
     uint8_t *dest[3];
@@ -1007,12 +1007,12 @@  static void packedtogbr24p(const uint8_t *src, int srcStride,
 }
 
 static int rgbToPlanarRgbWrapper(SwsContext *c, const uint8_t *src[],
-                                 int srcStride[], int srcSliceY, int srcSliceH,
-                                 uint8_t *dst[], int dstStride[])
+                                 ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                                 uint8_t *dst[], ptrdiff_t dstStride[])
 {
     int alpha_first = 0;
-    int stride102[] = { dstStride[1], dstStride[0], dstStride[2] };
-    int stride201[] = { dstStride[2], dstStride[0], dstStride[1] };
+    ptrdiff_t stride102[] = { dstStride[1], dstStride[0], dstStride[2] };
+    ptrdiff_t stride201[] = { dstStride[2], dstStride[0], dstStride[1] };
     uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
                           dst[0] + srcSliceY * dstStride[0],
                           dst[2] + srcSliceY * dstStride[2] };
@@ -1111,8 +1111,8 @@  static int rgbToPlanarRgbWrapper(SwsContext *c, const uint8_t *src[],
 #define BAYER_RENAME(x) bayer_rggb16be_to_##x
 #include "bayer_template.c"
 
-static int bayer_to_rgb24_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
-                                  int srcSliceH, uint8_t* dst[], int dstStride[])
+static int bayer_to_rgb24_wrapper(SwsContext *c, const uint8_t* src[], ptrdiff_t srcStride[], int srcSliceY,
+                                  int srcSliceH, uint8_t* dst[], ptrdiff_t dstStride[])
 {
     uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
     const uint8_t *srcPtr= src[0];
@@ -1160,8 +1160,8 @@  static int bayer_to_rgb24_wrapper(SwsContext *c, const uint8_t* src[], int srcSt
     return srcSliceH;
 }
 
-static int bayer_to_yv12_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
-                                 int srcSliceH, uint8_t* dst[], int dstStride[])
+static int bayer_to_yv12_wrapper(SwsContext *c, const uint8_t* src[], ptrdiff_t srcStride[], int srcSliceY,
+                                 int srcSliceH, uint8_t* dst[], ptrdiff_t dstStride[])
 {
     const uint8_t *srcPtr= src[0];
     uint8_t *dstY= dst[0] + srcSliceY * dstStride[0];
@@ -1361,9 +1361,9 @@  static rgbConvFn findRgbConvFn(SwsContext *c)
 }
 
 /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
-static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
+static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], ptrdiff_t srcStride[],
                            int srcSliceY, int srcSliceH, uint8_t *dst[],
-                           int dstStride[])
+                           ptrdiff_t dstStride[])
 
 {
     const enum AVPixelFormat srcFormat = c->srcFormat;
@@ -1423,8 +1423,8 @@  static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
 }
 
 static int bgr24ToYv12Wrapper(SwsContext *c, const uint8_t *src[],
-                              int srcStride[], int srcSliceY, int srcSliceH,
-                              uint8_t *dst[], int dstStride[])
+                              ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                              uint8_t *dst[], ptrdiff_t dstStride[])
 {
     ff_rgb24toyv12(
         src[0],
@@ -1440,8 +1440,8 @@  static int bgr24ToYv12Wrapper(SwsContext *c, const uint8_t *src[],
 }
 
 static int yvu9ToYv12Wrapper(SwsContext *c, const uint8_t *src[],
-                             int srcStride[], int srcSliceY, int srcSliceH,
-                             uint8_t *dst[], int dstStride[])
+                             ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                             uint8_t *dst[], ptrdiff_t dstStride[])
 {
     copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
               dst[0], dstStride[0]);
@@ -1457,8 +1457,8 @@  static int yvu9ToYv12Wrapper(SwsContext *c, const uint8_t *src[],
 
 /* unscaled copy like stuff (assumes nearly identical formats) */
 static int packedCopyWrapper(SwsContext *c, const uint8_t *src[],
-                             int srcStride[], int srcSliceY, int srcSliceH,
-                             uint8_t *dst[], int dstStride[])
+                             ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                             uint8_t *dst[], ptrdiff_t dstStride[])
 {
     if (dstStride[0] == srcStride[0] && srcStride[0] > 0)
         memcpy(dst[0] + dstStride[0] * srcSliceY, src[0], srcSliceH * dstStride[0]);
@@ -1544,8 +1544,8 @@  static int packedCopyWrapper(SwsContext *c, const uint8_t *src[],
     }
 
 static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
-                             int srcStride[], int srcSliceY, int srcSliceH,
-                             uint8_t *dst[], int dstStride[])
+                             ptrdiff_t srcStride[], int srcSliceY, int srcSliceH,
+                             uint8_t *dst[], ptrdiff_t dstStride[])
 {
     const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
     const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
diff --git a/libswscale/x86/yuv2rgb_template.c b/libswscale/x86/yuv2rgb_template.c
index acb78f5..e222c8e 100644
--- a/libswscale/x86/yuv2rgb_template.c
+++ b/libswscale/x86/yuv2rgb_template.c
@@ -199,9 +199,9 @@ 
 
 #if !COMPILE_TEMPLATE_MMXEXT
 static inline int RENAME(yuv420_rgb15)(SwsContext *c, const uint8_t *src[],
-                                       int srcStride[],
+                                       ptrdiff_t srcStride[],
                                        int srcSliceY, int srcSliceH,
-                                       uint8_t *dst[], int dstStride[])
+                                       uint8_t *dst[], ptrdiff_t dstStride[])
 {
     int y, h_size, vshift;
 
@@ -227,9 +227,9 @@  static inline int RENAME(yuv420_rgb15)(SwsContext *c, const uint8_t *src[],
 }
 
 static inline int RENAME(yuv420_rgb16)(SwsContext *c, const uint8_t *src[],
-                                       int srcStride[],
+                                       ptrdiff_t srcStride[],
                                        int srcSliceY, int srcSliceH,
-                                       uint8_t *dst[], int dstStride[])
+                                       uint8_t *dst[], ptrdiff_t dstStride[])
 {
     int y, h_size, vshift;
 
@@ -317,9 +317,9 @@  DECLARE_ASM_CONST(8, int16_t, mask0100[4]) = { 0,-1, 0, 0};
 #endif
 
 static inline int RENAME(yuv420_rgb24)(SwsContext *c, const uint8_t *src[],
-                                       int srcStride[],
+                                       ptrdiff_t srcStride[],
                                        int srcSliceY, int srcSliceH,
-                                       uint8_t *dst[], int dstStride[])
+                                       uint8_t *dst[], ptrdiff_t dstStride[])
 {
     int y, h_size, vshift;
 
@@ -335,9 +335,9 @@  static inline int RENAME(yuv420_rgb24)(SwsContext *c, const uint8_t *src[],
 }
 
 static inline int RENAME(yuv420_bgr24)(SwsContext *c, const uint8_t *src[],
-                                       int srcStride[],
+                                       ptrdiff_t srcStride[],
                                        int srcSliceY, int srcSliceH,
-                                       uint8_t *dst[], int dstStride[])
+                                       uint8_t *dst[], ptrdiff_t dstStride[])
 {
     int y, h_size, vshift;
 
@@ -379,9 +379,9 @@  static inline int RENAME(yuv420_bgr24)(SwsContext *c, const uint8_t *src[],
 
 #if !COMPILE_TEMPLATE_MMXEXT
 static inline int RENAME(yuv420_rgb32)(SwsContext *c, const uint8_t *src[],
-                                       int srcStride[],
+                                       ptrdiff_t srcStride[],
                                        int srcSliceY, int srcSliceH,
-                                       uint8_t *dst[], int dstStride[])
+                                       uint8_t *dst[], ptrdiff_t dstStride[])
 {
     int y, h_size, vshift;
 
@@ -400,9 +400,9 @@  static inline int RENAME(yuv420_rgb32)(SwsContext *c, const uint8_t *src[],
 
 #if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
 static inline int RENAME(yuva420_rgb32)(SwsContext *c, const uint8_t *src[],
-                                        int srcStride[],
+                                        ptrdiff_t srcStride[],
                                         int srcSliceY, int srcSliceH,
-                                        uint8_t *dst[], int dstStride[])
+                                        uint8_t *dst[], ptrdiff_t dstStride[])
 {
     int y, h_size, vshift;
 
@@ -422,9 +422,9 @@  static inline int RENAME(yuva420_rgb32)(SwsContext *c, const uint8_t *src[],
 #endif
 
 static inline int RENAME(yuv420_bgr32)(SwsContext *c, const uint8_t *src[],
-                                       int srcStride[],
+                                       ptrdiff_t srcStride[],
                                        int srcSliceY, int srcSliceH,
-                                       uint8_t *dst[], int dstStride[])
+                                       uint8_t *dst[], ptrdiff_t dstStride[])
 {
     int y, h_size, vshift;
 
@@ -443,9 +443,9 @@  static inline int RENAME(yuv420_bgr32)(SwsContext *c, const uint8_t *src[],
 
 #if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
 static inline int RENAME(yuva420_bgr32)(SwsContext *c, const uint8_t *src[],
-                                        int srcStride[],
+                                        ptrdiff_t srcStride[],
                                         int srcSliceY, int srcSliceH,
-                                        uint8_t *dst[], int dstStride[])
+                                        uint8_t *dst[], ptrdiff_t dstStride[])
 {
     int y, h_size, vshift;
 
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index 737cbb0..9df24bf 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -128,8 +128,8 @@  const int *sws_getCoefficients(int colorspace)
 
 #define YUV2RGBFUNC(func_name, dst_type, alpha)                             \
     static int func_name(SwsContext *c, const uint8_t *src[],               \
-                         int srcStride[], int srcSliceY, int srcSliceH,     \
-                         uint8_t *dst[], int dstStride[])                   \
+                         ptrdiff_t srcStride[], int srcSliceY, int srcSliceH, \
+                         uint8_t *dst[], ptrdiff_t dstStride[])             \
     {                                                                       \
         int y;                                                              \
                                                                             \
diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c
index 5ccba4f..597d1cc 100644
--- a/tests/api/api-band-test.c
+++ b/tests/api/api-band-test.c
@@ -175,7 +175,7 @@  static int video_decode(const char *input_filename)
             }
             if (got_frame) {
                 number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size,
-                                        (const uint8_t* const *)fr->data, (const int*) fr->linesize,
+                                        (const uint8_t* const *)fr->data, fr->linesize,
                                         ctx->pix_fmt, ctx->width, ctx->height, 1);
                 if (number_of_written_bytes < 0) {
                     av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n");
diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c
index 52282e0..837dc28 100644
--- a/tests/api/api-h264-test.c
+++ b/tests/api/api-h264-test.c
@@ -125,7 +125,7 @@  static int video_decode_example(const char *input_filename)
             }
             if (got_frame) {
                 number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size,
-                                        (const uint8_t* const *)fr->data, (const int*) fr->linesize,
+                                        (const uint8_t* const *)fr->data, fr->linesize,
                                         ctx->pix_fmt, ctx->width, ctx->height, 1);
                 if (number_of_written_bytes < 0) {
                     av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n");
diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c
index 2b32cb9..dcac473 100644
--- a/tests/api/api-seek-test.c
+++ b/tests/api/api-seek-test.c
@@ -123,7 +123,7 @@  static int compute_crc_of_packets(AVFormatContext *fmt_ctx, int video_stream,
             }
             if (got_frame) {
                 number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size,
-                                        (const uint8_t* const *)fr->data, (const int*) fr->linesize,
+                                        (const uint8_t* const *)fr->data, fr->linesize,
                                         ctx->pix_fmt, ctx->width, ctx->height, 1);
                 if (number_of_written_bytes < 0) {
                     av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n");
-- 
1.7.10.4