[FFmpeg-devel] [PATCH v3 2/2] swscale/swscale: various cosmetics for the code style

lance.lmwang at gmail.com lance.lmwang at gmail.com
Sun Sep 8 16:12:15 EEST 2019


From: Limin Wang <lance.lmwang at gmail.com>

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
 libswscale/swscale.c | 66 +++++++++++++++++++---------------------------------
 1 file changed, 24 insertions(+), 42 deletions(-)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index b4f958a..5212317 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,20 +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[1] =
-        src[2] =
-        src[3] = src[0];
-        srcStride[1] =
-        srcStride[2] =
-        srcStride[3] = srcStride[0];
+        for (int i = 1; i < 4; i++) {
+            src[i] = src[0];
+            srcStride[i] = srcStride[0];
+        }
     }
     srcStride[1] <<= c->vChrDrop;
     srcStride[2] <<= c->vChrDrop;
@@ -322,11 +315,10 @@ 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
-        || (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
-    ) {
+    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) {
         static int warnedAlready=0;
         int cpu_flags = av_get_cpu_flags();
         if (HAVE_MMXEXT && (cpu_flags & AV_CPU_FLAG_SSE2) && !warnedAlready){
@@ -339,11 +331,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) {
@@ -366,16 +356,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]);
@@ -394,7 +382,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;
@@ -406,7 +393,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;
@@ -438,7 +424,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);
@@ -501,10 +486,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;
@@ -570,7 +553,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;
@@ -628,7 +610,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])
@@ -788,8 +769,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);
@@ -798,16 +777,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;
@@ -820,8 +803,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;
     }
 
@@ -983,7 +966,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