Re: [libav-devel] [RFC] [PATCH] Set video strides to a custom type in preparation of a change to ptrdiff_t

2018-01-16 Thread Luca Barbato

On 16/01/2018 12:41, wm4 wrote:

So, do we want this or not?


I like it a lot.

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [RFC] [PATCH] Set video strides to a custom type in preparation of a change to ptrdiff_t

2018-01-16 Thread wm4
On Fri,  5 Jan 2018 22:06:42 +0100
Vittorio Giovara  wrote:

> This patch introduces a new type, av_stride, which is set for any
> representation of strides or linesize, including AVFrame and av_image_*
> APIs. This is done in preparation of a future switch to ptrdiff_t, a
> better suited type to represent this type of data, in a way that it is
> atomically changed at the version bump.
> ---
> 
> This is a work in progress change that I was preparing and briefly discussed
> on IRC today, based on suggestion by wm4. I wanted to share this early to
> thread waters, as well as gather feedback on this approach. As a matter of
> fact I haven't fully tested this yet, but if the idea is welcome, I will
> extensively test it on Oracle.
> 
> The rationale of introducing this "temporary" type is to minimize impact on
> downstream, allowing a long enough transition time to API users to change
> their code. I say temporary because it is possible that in the very distant
> future it would be nice to be able to just the standard type instead of a
> custom one.
> 
> We considered other ideas, such as deprecating the current APIs and frame
> fields and introducing setters and getters but they seemed less elegant and
> more likely to induce annoying code breaks to our users.

I like this (at least more than the other alternatives). In addition to
being cleaner, this would allow us to support images with higher
resolutions, without having to fear to overflow stride calculations.

So, do we want this or not?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [RFC] [PATCH] Set video strides to a custom type in preparation of a change to ptrdiff_t

2018-01-05 Thread Vittorio Giovara
This patch introduces a new type, av_stride, which is set for any
representation of strides or linesize, including AVFrame and av_image_*
APIs. This is done in preparation of a future switch to ptrdiff_t, a
better suited type to represent this type of data, in a way that it is
atomically changed at the version bump.
---

This is a work in progress change that I was preparing and briefly discussed
on IRC today, based on suggestion by wm4. I wanted to share this early to
thread waters, as well as gather feedback on this approach. As a matter of
fact I haven't fully tested this yet, but if the idea is welcome, I will
extensively test it on Oracle.

The rationale of introducing this "temporary" type is to minimize impact on
downstream, allowing a long enough transition time to API users to change
their code. I say temporary because it is possible that in the very distant
future it would be nice to be able to just the standard type instead of a
custom one.

We considered other ideas, such as deprecating the current APIs and frame
fields and introducing setters and getters but they seemed less elegant and
more likely to induce annoying code breaks to our users.

Vittorio

 avtools/avconv_vda.c  |   2 +-
 avtools/avplay.c  |   2 +-
 libavcodec/avcodec.h  |   2 +-
 libavcodec/cinepakenc.c   |  42 +++---
 libavcodec/decode.c   |   6 +-
 libavcodec/error_resilience.c |   8 +--
 libavcodec/ffv1dec.c  |   2 +-
 libavcodec/ffv1enc.c  |   2 +-
 libavcodec/internal.h |   2 +-
 libavcodec/libvpxdec.c|   7 ++-
 libavcodec/mmaldec.c  |   2 +-
 libavcodec/mpegvideoencdsp.c  |  12 ++--
 libavcodec/mpegvideoencdsp.h  |   4 +-
 libavcodec/nuv.c  |   2 +-
 libavcodec/omx.c  |   4 +-
 libavcodec/roqvideoenc.c  |   8 +--
 libavcodec/utils.c|   2 +-
 libavfilter/drawutils.c   |   6 +-
 libavfilter/drawutils.h   |   7 ++-
 libavfilter/vf_framepack.c|   2 +-
 libavfilter/vf_interlace.c|   4 +-
 libavfilter/vf_showinfo.c |   2 +-
 libavutil/avutil.h|  13 -
 libavutil/frame.c |   4 +-
 libavutil/frame.h |   2 +-
 libavutil/hwcontext_d3d11va.c |   4 +-
 libavutil/imgutils.c  |  27 -
 libavutil/imgutils.h  |  22 +++
 libavutil/pixdesc.c   |   4 +-
 libavutil/pixdesc.h   |   5 +-
 libavutil/version.h   |   3 +
 libswscale/swscale.h  |   4 +-
 libswscale/swscale_internal.h |   4 +-
 libswscale/swscale_unscaled.c | 130 --
 libswscale/tests/swscale.c|   6 +-
 libswscale/yuv2rgb.c  |   4 +-
 36 files changed, 191 insertions(+), 171 deletions(-)

diff --git a/avtools/avconv_vda.c b/avtools/avconv_vda.c
index d86076e79e..3f3156dbbc 100644
--- a/avtools/avconv_vda.c
+++ b/avtools/avconv_vda.c
@@ -34,7 +34,7 @@ static int vda_retrieve_data(AVCodecContext *s, AVFrame 
*frame)
 OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf);
 CVReturn err;
 uint8_t *data[4] = { 0 };
-int linesize[4] = { 0 };
+av_stride linesize[4] = { 0 };
 int planes, ret, i;
 
 av_frame_unref(vda->tmp_frame);
diff --git a/avtools/avplay.c b/avtools/avplay.c
index b6dbc52cf7..3392bd34c2 100644
--- a/avtools/avplay.c
+++ b/avtools/avplay.c
@@ -1312,7 +1312,7 @@ static int queue_picture(PlayerState *is, AVFrame 
*src_frame, double pts, int64_
 /* if the frame is not skipped, then display it */
 if (vp->bmp) {
 uint8_t *data[4];
-int linesize[4];
+av_stride linesize[4];
 
 /* get a pointer on the bitmap */
 SDL_LockYUVOverlay (vp->bmp);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7eaa0c9277..c4f5168676 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3203,7 +3203,7 @@ typedef struct AVSubtitleRect {
  * Can be set for text/ass as well once they are rendered.
  */
 uint8_t *data[4];
-int linesize[4];
+av_stride linesize[4];
 
 enum AVSubtitleType type;
 
diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c
index c323bde30f..f8d5f0cbe6 100644
--- a/libavcodec/cinepakenc.c
+++ b/libavcodec/cinepakenc.c
@@ -444,8 +444,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], av_stride  in_linesize[4],
+uint8_t *out_data[4], av_stride out_linesize[4])
 {
 out_data[0] = in_data[0] + x + y * in_linesize[0];
 out_linesize[0] = in_linesize[0];
@@ -461,7 +461,7 @@ static void get_sub_picture(CinepakEncContext *s, int x, 
int y,
 
 // decodes the V1 vector in mb into