[FFmpeg-devel] [PATCH v2 1/4] avcodec/tiff: correct unpacking of border YUV pixels
Michael Niedermayer
michael at niedermayer.cc
Fri Oct 11 22:55:54 EEST 2019
On Thu, Oct 10, 2019 at 03:05:11AM +0300, Skakov Pavel wrote:
> Corrected handling of border pixels when unpacking YUV. Example (bottom line): https://github.com/BitMiracle/libtiff.net/blob/master/TestCase/ycbcr-cat.tif
> tiff.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
> 3959d6f0fc427fce64684a2768d3ac154ff49993 0001-avcodec-tiff-correct-unpacking-of-border-YUV-pixels.patch
> From 09f9822d8d38f26ff386df3d01794fcafe3f3869 Mon Sep 17 00:00:00 2001
> From: Pavel Skakov <pavelsx at gmail.com>
> Date: Thu, 10 Oct 2019 02:21:06 +0300
> Subject: [PATCH 1/4] avcodec/tiff: correct unpacking of border YUV pixels
>
> Signed-off-by: Pavel Skakov <pavelsx at gmail.com>
> ---
> libavcodec/tiff.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> index 069792b4c3..70c49f7d44 100644
> --- a/libavcodec/tiff.c
> +++ b/libavcodec/tiff.c
> @@ -369,8 +369,11 @@ static void unpack_yuv(TiffContext *s, AVFrame *p,
> for (i = 0; i < w; i++) {
> for (j = 0; j < s->subsampling[1]; j++)
> for (k = 0; k < s->subsampling[0]; k++)
> - p->data[0][FFMIN(lnum + j, s->height-1) * p->linesize[0] +
> - FFMIN(i * s->subsampling[0] + k, s->width-1)] = *src++;
> + if (j < s->height - lnum && i * s->subsampling[0] + k < s->width) {
> + p->data[0][(lnum + j) * p->linesize[0] + i * s->subsampling[0] + k] = *src++;
> + } else {
> + src++;
> + }
> *pu++ = *src++;
> *pv++ = *src++;
> }
Its probably better to ensure the buffer is large enough instead of using
special cases
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20191011/240cf258/attachment.sig>
More information about the ffmpeg-devel
mailing list