Re: [FFmpeg-devel] Patch for vf_fillborders.c – Bug?

2019-03-08 Thread Ulf Zibis

Am 08.03.19 um 00:53 schrieb Michael Niedermayer:
> On Thu, Mar 07, 2019 at 12:52:32AM +0100, Ulf Zibis wrote:
>> Hi,
>>
>> I think there is a bug in vf_fillborders.c 16 bit routines.
>>
>> When using memset or memcopy, I think, correct linesize instead
>> s->planewidth[p] should be used.
>> When using arrray syntax, I think, correct s->planewidth[p] instead
>> linesize should be used.
>>
>> See my proposed patch.
>>
>> -Ulf

Please ignore the patch.
In the meantime I've found a misunderstanding from my side.

-Ulf



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Patch for vf_fillborders.c – Bug?

2019-03-07 Thread Michael Niedermayer
On Thu, Mar 07, 2019 at 12:52:32AM +0100, Ulf Zibis wrote:
> Hi,
> 
> I think there is a bug in vf_fillborders.c 16 bit routines.
> 
> When using memset or memcopy, I think, correct linesize instead
> s->planewidth[p] should be used.
> When using arrray syntax, I think, correct s->planewidth[p] instead
> linesize should be used.
> 
> See my proposed patch.
> 
> -Ulf
> 

>  .gitignore   |2 
>  libavfilter/vf_fillborders.c |  125 
> ---
>  2 files changed, 63 insertions(+), 64 deletions(-)
> c9197f5c0215e05633f5a09071cc6ba87e74a757  
> vf_fillborders_linesize_in_16-bit.patch
> From f3513f992e0b5595f2644257b92fdea6189592de Mon Sep 17 00:00:00 2001
> From: Ulf Zibis 
> Date: 07.03.2019, 00:34:51
> 
> Correct usage of linesize and width in 16 bit depth routines.
> 

> diff --git a/.gitignore b/.gitignore
> index 0e57cb0..7819c84 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -36,3 +36,5 @@
>  /lcov/
>  /src
>  /mapfile
> +/nbproject
> +/debug

this shouldnt be in the patch


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] Patch for vf_fillborders.c – Bug?

2019-03-06 Thread Ulf Zibis
Hi,

I think there is a bug in vf_fillborders.c 16 bit routines.

When using memset or memcopy, I think, correct linesize instead
s->planewidth[p] should be used.
When using arrray syntax, I think, correct s->planewidth[p] instead
linesize should be used.

See my proposed patch.

-Ulf

>From f3513f992e0b5595f2644257b92fdea6189592de Mon Sep 17 00:00:00 2001
From: Ulf Zibis 
Date: 07.03.2019, 00:34:51

Correct usage of linesize and width in 16 bit depth routines.

diff --git a/.gitignore b/.gitignore
index 0e57cb0..7819c84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,3 +36,5 @@
 /lcov/
 /src
 /mapfile
+/nbproject
+/debug
diff --git a/libavfilter/vf_fillborders.c b/libavfilter/vf_fillborders.c
index 1344587..019cdff 100644
--- a/libavfilter/vf_fillborders.c
+++ b/libavfilter/vf_fillborders.c
@@ -89,25 +89,27 @@
 for (p = 0; p < s->nb_planes; p++) {
 uint8_t *ptr = frame->data[p];
 int linesize = frame->linesize[p];
+int nb_leftbytes = s->borders[p].left * linesize / s->planewidth[p];
+int nb_rightbytes = s->borders[p].right * linesize / s->planewidth[p];
 
 for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
 memset(ptr + y * linesize,
-   *(ptr + y * linesize + s->borders[p].left),
-   s->borders[p].left);
-memset(ptr + y * linesize + s->planewidth[p] - s->borders[p].right,
-   *(ptr + y * linesize + s->planewidth[p] - s->borders[p].right - 1),
-   s->borders[p].right);
+   *(ptr + y * linesize + nb_leftbytes),
+   nb_leftbytes);
+memset(ptr + y * linesize + linesize - nb_rightbytes,
+   *(ptr + y * linesize + linesize - nb_rightbytes - 1),
+   nb_rightbytes);
 }
 
 for (y = 0; y < s->borders[p].top; y++) {
 memcpy(ptr + y * linesize,
-   ptr + s->borders[p].top * linesize, s->planewidth[p]);
+   ptr + s->borders[p].top * linesize, linesize);
 }
 
 for (y = s->planeheight[p] - s->borders[p].bottom; y < s->planeheight[p]; y++) {
 memcpy(ptr + y * linesize,
ptr + (s->planeheight[p] - s->borders[p].bottom - 1) * linesize,
-   s->planewidth[p]);
+   linesize);
 }
 }
 }
@@ -118,28 +120,28 @@
 
 for (p = 0; p < s->nb_planes; p++) {
 uint16_t *ptr = (uint16_t *)frame->data[p];
-int linesize = frame->linesize[p] / 2;
+int linesize = frame->linesize[p];
 
 for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
 for (x = 0; x < s->borders[p].left; x++) {
-ptr[y * linesize + x] =  *(ptr + y * linesize + s->borders[p].left);
+ptr[y * s->planewidth[p] + x] =  *(ptr + y * s->planewidth[p] + s->borders[p].left);
 }
 
 for (x = 0; x < s->borders[p].right; x++) {
-ptr[y * linesize + s->planewidth[p] - s->borders[p].right + x] =
-   *(ptr + y * linesize + s->planewidth[p] - s->borders[p].right - 1);
+ptr[y * s->planewidth[p] + s->planewidth[p] - s->borders[p].right + x] =
+   *(ptr + y * s->planewidth[p] + s->planewidth[p] - s->borders[p].right - 1);
 }
 }
 
 for (y = 0; y < s->borders[p].top; y++) {
 memcpy(ptr + y * linesize,
-   ptr + s->borders[p].top * linesize, s->planewidth[p] * 2);
+   ptr + s->borders[p].top * linesize, linesize);
 }
 
 for (y = s->planeheight[p] - s->borders[p].bottom; y < s->planeheight[p]; y++) {
 memcpy(ptr + y * linesize,
ptr + (s->planeheight[p] - s->borders[p].bottom - 1) * linesize,
-   s->planewidth[p] * 2);
+   linesize);
 }
 }
 }
@@ -154,25 +156,25 @@
 
 for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
 for (x = 0; x < s->borders[p].left; x++) {
-ptr[y * linesize + x] = ptr[y * linesize + s->borders[p].left * 2 - 1 - x];
+ptr[y * s->planewidth[p] + x] = ptr[y * s->planewidth[p] + s->borders[p].left * 2 - 1 - x];
 }
 
 for (x = 0; x < s->borders[p].right; x++) {
-ptr[y * linesize + s->planewidth[p] - s->borders[p].right + x] =
-ptr[y * linesize + s->planewidth[p] - s->borders[p].right - 1 - x];
+ptr[y * s->planewidth[p] + s->planewidth[p] - s->borders[p].right + x] =
+ptr[y * s->planewidth[p] + s->planewidth[p] - s->borders[p].right - 1 - x];
 }
 }
 
 for (y = 0; y < s->borders[p].top; y++) {
 memcpy(ptr + y * linesize,
ptr + (s->borders[p].top * 2 - 1 - y) * linesize,
-   s->planewidth[p]);
+