From 29b2437e04d6af1c5093efcaac6f8bc852525d78 Mon Sep 17 00:00:00 2001
From: Pavel Skakov <pavelsx@gmail.com>
Date: Thu, 10 Oct 2019 02:43:34 +0300
Subject: [PATCH 4/4] avcodec/tiff: small compiling optimization
Signed-off-by: Pavel Skakov <pavelsx@gmail.com>
---
libavcodec/tiff.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
@@ -358,11 +358,12 @@ static void unpack_gray(TiffContext *s, AVFrame *p,
}
}
-static void unpack_yuv(TiffContext *s, AVFrame *p,
+static void unpack_yuv(TiffContext *av_restrict s, AVFrame *av_restrict p,
const uint8_t *src, int lnum)
{
- int i, j, k;
- int w = (s->width - 1) / s->subsampling[0] + 1;
+ size_t i, j, k;
+ size_t w = (s->width - 1) / s->subsampling[0] + 1;
+ uint8_t *py = &p->data[0][lnum * p->linesize[0]];
uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]];
uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]];
if (s->width % s->subsampling[0] || s->height % s->subsampling[1]) {
@@ -371,7 +372,7 @@ static void unpack_yuv(TiffContext *s, AVFrame *p,
for (j = 0; j < s->subsampling[1]; j++)
for (k = 0; k < s->subsampling[0]; k++)
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++;
+ py[j * p->linesize[0] + i * s->subsampling[0] + k] = *src++;
} else {
src++;
}
@@ -383,8 +384,8 @@ static void unpack_yuv(TiffContext *s, AVFrame *p,
for (j = 0; j < s->subsampling[1]; j++)
for (k = 0; k < s->subsampling[0]; k++)
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)*2 ] = *src++;
- p->data[0][(lnum + j) * p->linesize[0] + (i * s->subsampling[0] + k)*2 + 1] = *src++;
+ py[j * p->linesize[0] + (i * s->subsampling[0] + k)*2 ] = *src++;
+ py[j * p->linesize[0] + (i * s->subsampling[0] + k)*2 + 1] = *src++;
} else {
src += 2;
}
@@ -399,7 +400,7 @@ 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][(lnum + j) * p->linesize[0] + i * s->subsampling[0] + k] = *src++;
+ py[j * p->linesize[0] + i * s->subsampling[0] + k] = *src++;
*pu++ = *src++;
*pv++ = *src++;
}
@@ -407,8 +408,8 @@ 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][(lnum + j) * p->linesize[0] + (i * s->subsampling[0] + k)*2 ] = *src++;
- p->data[0][(lnum + j) * p->linesize[0] + (i * s->subsampling[0] + k)*2 + 1] = *src++;
+ py[j * p->linesize[0] + (i * s->subsampling[0] + k)*2 ] = *src++;
+ py[j * p->linesize[0] + (i * s->subsampling[0] + k)*2 + 1] = *src++;
}
*pu++ = *src++;
*pu++ = *src++;
--
2.13.2.windows.1