[FFmpeg-devel] [PATCH v2] swscale/swscale: various cosmetics for the code style
lance.lmwang at gmail.com
lance.lmwang at gmail.com
Sun Sep 8 13:00:26 EEST 2019
From: Limin Wang <lance.lmwang at gmail.com>
Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
libswscale/swscale.c | 61 ++++++++++++++++++----------------------------------
1 file changed, 21 insertions(+), 40 deletions(-)
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 4069550..1aa23c6 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -242,12 +242,10 @@ static int swscale(SwsContext *c, const uint8_t *src[],
* and faster */
const int dstW = c->dstW;
const int dstH = c->dstH;
-
const enum AVPixelFormat dstFormat = c->dstFormat;
const int flags = c->flags;
int32_t *vLumFilterPos = c->vLumFilterPos;
int32_t *vChrFilterPos = c->vChrFilterPos;
-
const int vLumFilterSize = c->vLumFilterSize;
const int vChrFilterSize = c->vChrFilterSize;
@@ -271,7 +269,6 @@ static int swscale(SwsContext *c, const uint8_t *src[],
int lastInLumBuf = c->lastInLumBuf;
int lastInChrBuf = c->lastInChrBuf;
-
int lumStart = 0;
int lumEnd = c->descIndex[0];
int chrStart = lumEnd;
@@ -283,22 +280,16 @@ static int swscale(SwsContext *c, const uint8_t *src[],
SwsSlice *vout_slice = &c->slice[c->numSlice-1];
SwsFilterDescriptor *desc = c->desc;
-
int needAlpha = c->needAlpha;
int hasLumHoles = 1;
int hasChrHoles = 1;
-
if (isPacked(c->srcFormat)) {
- src[0] =
- src[1] =
- src[2] =
- src[3] = src[0];
- srcStride[0] =
- srcStride[1] =
- srcStride[2] =
- srcStride[3] = srcStride[0];
+ for (int i = 0; i < 4; i++) {
+ src[i] = src[0];
+ srcStride[i] = srcStride[0];
+ }
}
srcStride[1] <<= c->vChrDrop;
srcStride[2] <<= c->vChrDrop;
@@ -324,7 +315,7 @@ static int swscale(SwsContext *c, const uint8_t *src[],
}
}
- if ( (uintptr_t)dst[0]&15 || (uintptr_t)dst[1]&15 || (uintptr_t)dst[2]&15
+ if ((uintptr_t)dst[0]&15 || (uintptr_t)dst[1]&15 || (uintptr_t)dst[2]&15
|| (uintptr_t)src[0]&15 || (uintptr_t)src[1]&15 || (uintptr_t)src[2]&15
|| dstStride[0]&15 || dstStride[1]&15 || dstStride[2]&15 || dstStride[3]&15
|| srcStride[0]&15 || srcStride[1]&15 || srcStride[2]&15 || srcStride[3]&15
@@ -341,11 +332,9 @@ static int swscale(SwsContext *c, const uint8_t *src[],
* will not get executed. This is not really intended but works
* currently, so people might do it. */
if (srcSliceY == 0) {
- lumBufIndex = -1;
- chrBufIndex = -1;
+ lumBufIndex = chrBufIndex = -1;
dstY = 0;
- lastInLumBuf = -1;
- lastInChrBuf = -1;
+ lastInLumBuf = lastInChrBuf = -1;
}
if (!should_dither) {
@@ -368,16 +357,14 @@ static int swscale(SwsContext *c, const uint8_t *src[],
hout_slice->plane[2].sliceY = lastInChrBuf + 1;
hout_slice->plane[3].sliceY = lastInLumBuf + 1;
- hout_slice->plane[0].sliceH =
- hout_slice->plane[1].sliceH =
- hout_slice->plane[2].sliceH =
- hout_slice->plane[3].sliceH = 0;
+ for(int i = 0; i < 4; i++)
+ hout_slice->plane[i].sliceH = 0;
hout_slice->width = dstW;
}
for (; dstY < dstH; dstY++) {
const int chrDstY = dstY >> c->chrDstVSubSample;
- int use_mmx_vfilter= c->use_mmx_vfilter;
+ int use_mmx_vfilter = c->use_mmx_vfilter;
// First line needed as input
const int firstLumSrcY = FFMAX(1 - vLumFilterSize, vLumFilterPos[dstY]);
@@ -396,7 +383,6 @@ static int swscale(SwsContext *c, const uint8_t *src[],
// handle holes (FAST_BILINEAR & weird filters)
if (firstLumSrcY > lastInLumBuf) {
-
hasLumHoles = lastInLumBuf != firstLumSrcY - 1;
if (hasLumHoles) {
hout_slice->plane[0].sliceY = firstLumSrcY;
@@ -408,7 +394,6 @@ static int swscale(SwsContext *c, const uint8_t *src[],
lastInLumBuf = firstLumSrcY - 1;
}
if (firstChrSrcY > lastInChrBuf) {
-
hasChrHoles = lastInChrBuf != firstChrSrcY - 1;
if (hasChrHoles) {
hout_slice->plane[1].sliceY = firstChrSrcY;
@@ -440,7 +425,6 @@ static int swscale(SwsContext *c, const uint8_t *src[],
av_assert0((lastLumSrcY - firstLumSrcY + 1) <= hout_slice->plane[0].available_lines);
av_assert0((lastChrSrcY - firstChrSrcY + 1) <= hout_slice->plane[1].available_lines);
-
posY = hout_slice->plane[0].sliceY + hout_slice->plane[0].sliceH;
if (posY <= lastLumSrcY && !hasLumHoles) {
firstPosY = FFMAX(firstLumSrcY, posY);
@@ -503,10 +487,8 @@ static int swscale(SwsContext *c, const uint8_t *src[],
yuv2packed1, yuv2packed2, yuv2packedX, yuv2anyX, use_mmx_vfilter);
}
- {
- for (i = vStart; i < vEnd; ++i)
- desc[i].process(c, &desc[i], dstY, 1);
- }
+ for (i = vStart; i < vEnd; i++)
+ desc[i].process(c, &desc[i], dstY, 1);
}
if (isPlanar(dstFormat) && isALPHA(dstFormat) && !needAlpha) {
int length = dstW;
@@ -572,7 +554,6 @@ static av_cold void sws_init_swscale(SwsContext *c)
ff_sws_init_input_funcs(c);
-
if (c->srcBpc == 8) {
if (c->dstBpc <= 14) {
c->hyScale = c->hcScale = hScale8To15_c;
@@ -630,7 +611,6 @@ static int check_image_pointers(const uint8_t * const data[4], enum AVPixelForma
int i;
av_assert2(desc);
-
for (i = 0; i < 4; i++) {
int plane = desc->comp[i].plane;
if (!data[plane] || !linesizes[plane])
@@ -790,8 +770,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
}
if (c->gamma_flag && c->cascaded_context[0]) {
-
-
ret = sws_scale(c->cascaded_context[0],
srcSlice, srcStride, srcSliceY, srcSliceH,
c->cascaded_tmp, c->cascaded_tmpStride);
@@ -800,16 +778,20 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
return ret;
if (c->cascaded_context[2])
- ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, c->cascaded1_tmp, c->cascaded1_tmpStride);
+ ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp,
+ c->cascaded_tmpStride, srcSliceY, srcSliceH, c->cascaded1_tmp,
+ c->cascaded1_tmpStride);
else
- ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, dst, dstStride);
+ ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp,
+ c->cascaded_tmpStride, srcSliceY, srcSliceH, dst, dstStride);
if (ret < 0)
return ret;
if (c->cascaded_context[2]) {
ret = sws_scale(c->cascaded_context[2],
- (const uint8_t * const *)c->cascaded1_tmp, c->cascaded1_tmpStride, c->cascaded_context[1]->dstY - ret, c->cascaded_context[1]->dstY,
+ (const uint8_t * const *)c->cascaded1_tmp, c->cascaded1_tmpStride,
+ c->cascaded_context[1]->dstY - ret, c->cascaded_context[1]->dstY,
dst, dstStride);
}
return ret;
@@ -822,8 +804,8 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
if (ret < 0)
return ret;
ret = sws_scale(c->cascaded_context[1],
- (const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride, 0, c->cascaded_context[0]->dstH,
- dst, dstStride);
+ (const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride, 0,
+ c->cascaded_context[0]->dstH, dst, dstStride);
return ret;
}
@@ -985,7 +967,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
c->sliceDir = 0;
ret = c->swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2);
-
if (c->dstXYZ && !(c->srcXYZ && c->srcW==c->dstW && c->srcH==c->dstH)) {
int dstY = c->dstY ? c->dstY : srcSliceY + srcSliceH;
uint16_t *dst16 = (uint16_t*)(dst2[0] + (dstY - ret) * dstStride2[0]);
--
2.6.4
More information about the ffmpeg-devel
mailing list