]> git.sesse.net Git - ffmpeg/blobdiff - libswscale/utils.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libswscale / utils.c
index bdc7005280712d0473cff6c4546714433a2caf78..a6bb7320248e60a77ebf9e2f917242ffa0623719 100644 (file)
@@ -22,7 +22,6 @@
 
 #define _SVID_SOURCE // needed for MAP_ANONYMOUS
 #define _DARWIN_C_SOURCE // needed for MAP_ANON
-#include <assert.h>
 #include <inttypes.h>
 #include <math.h>
 #include <stdio.h>
@@ -113,6 +112,7 @@ static const FormatEntry format_entries[PIX_FMT_NB] = {
     [PIX_FMT_YUV440P]     = { 1, 1 },
     [PIX_FMT_YUVJ440P]    = { 1, 1 },
     [PIX_FMT_YUVA420P]    = { 1, 1 },
+    [PIX_FMT_YUVA422P]    = { 1, 1 },
     [PIX_FMT_YUVA444P]    = { 1, 1 },
     [PIX_FMT_RGB48BE]     = { 1, 1 },
     [PIX_FMT_RGB48LE]     = { 1, 1 },
@@ -145,19 +145,35 @@ static const FormatEntry format_entries[PIX_FMT_NB] = {
     [PIX_FMT_YUV420P9LE]  = { 1, 1 },
     [PIX_FMT_YUV420P10BE] = { 1, 1 },
     [PIX_FMT_YUV420P10LE] = { 1, 1 },
+    [PIX_FMT_YUV420P12BE] = { 1, 1 },
+    [PIX_FMT_YUV420P12LE] = { 1, 1 },
+    [PIX_FMT_YUV420P14BE] = { 1, 1 },
+    [PIX_FMT_YUV420P14LE] = { 1, 1 },
     [PIX_FMT_YUV422P9BE]  = { 1, 1 },
     [PIX_FMT_YUV422P9LE]  = { 1, 1 },
     [PIX_FMT_YUV422P10BE] = { 1, 1 },
     [PIX_FMT_YUV422P10LE] = { 1, 1 },
+    [PIX_FMT_YUV422P12BE] = { 1, 1 },
+    [PIX_FMT_YUV422P12LE] = { 1, 1 },
+    [PIX_FMT_YUV422P14BE] = { 1, 1 },
+    [PIX_FMT_YUV422P14LE] = { 1, 1 },
     [PIX_FMT_YUV444P9BE]  = { 1, 1 },
     [PIX_FMT_YUV444P9LE]  = { 1, 1 },
     [PIX_FMT_YUV444P10BE] = { 1, 1 },
     [PIX_FMT_YUV444P10LE] = { 1, 1 },
+    [PIX_FMT_YUV444P12BE] = { 1, 1 },
+    [PIX_FMT_YUV444P12LE] = { 1, 1 },
+    [PIX_FMT_YUV444P14BE] = { 1, 1 },
+    [PIX_FMT_YUV444P14LE] = { 1, 1 },
     [PIX_FMT_GBRP]        = { 1, 0 },
     [PIX_FMT_GBRP9LE]     = { 1, 0 },
     [PIX_FMT_GBRP9BE]     = { 1, 0 },
     [PIX_FMT_GBRP10LE]    = { 1, 0 },
     [PIX_FMT_GBRP10BE]    = { 1, 0 },
+    [PIX_FMT_GBRP12LE]    = { 1, 0 },
+    [PIX_FMT_GBRP12BE]    = { 1, 0 },
+    [PIX_FMT_GBRP14LE]    = { 1, 0 },
+    [PIX_FMT_GBRP14BE]    = { 1, 0 },
     [PIX_FMT_GBRP16LE]    = { 1, 0 },
     [PIX_FMT_GBRP16BE]    = { 1, 0 },
 };
@@ -286,8 +302,7 @@ static int initFilter(int16_t **outFilter, int32_t **filterPos,
         else if (flags & SWS_BILINEAR)
             sizeFactor = 2;
         else {
-            sizeFactor = 0;     // GCC warning killer
-            assert(0);
+            av_assert0(0);
         }
 
         if (xInc <= 1 << 16)
@@ -386,8 +401,7 @@ static int initFilter(int16_t **outFilter, int32_t **filterPos,
                     double p = -2.196152422706632;
                     coeff = getSplineCoeff(1.0, 0.0, p, -p - 1.0, floatd) * fone;
                 } else {
-                    coeff = 0.0; // GCC warning killer
-                    assert(0);
+                    av_assert0(0);
                 }
 
                 filter[i * filterSize + j] = coeff;
@@ -400,13 +414,13 @@ static int initFilter(int16_t **outFilter, int32_t **filterPos,
     /* apply src & dst Filter to filter -> filter2
      * av_free(filter);
      */
-    assert(filterSize > 0);
+    av_assert0(filterSize > 0);
     filter2Size = filterSize;
     if (srcFilter)
         filter2Size += srcFilter->length - 1;
     if (dstFilter)
         filter2Size += dstFilter->length - 1;
-    assert(filter2Size > 0);
+    av_assert0(filter2Size > 0);
     FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size * dstW * sizeof(*filter2), fail);
 
     for (i = 0; i < dstW; i++) {
@@ -488,9 +502,9 @@ static int initFilter(int16_t **outFilter, int32_t **filterPos,
             filterAlign = 1;
     }
 
-    assert(minFilterSize > 0);
+    av_assert0(minFilterSize > 0);
     filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1));
-    assert(filterSize > 0);
+    av_assert0(filterSize > 0);
     filter = av_malloc(filterSize * dstW * sizeof(*filter));
     if (filterSize >= MAX_FILTER_SIZE * 16 /
                       ((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter)
@@ -982,6 +996,8 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter)
     c->chrDstW = -((-dstW) >> c->chrDstHSubSample);
     c->chrDstH = -((-dstH) >> c->chrDstVSubSample);
 
+    FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW*2+78, 16) * 2, fail);
+
     /* unscaled special cases */
     if (unscaled && !usesHFilter && !usesVFilter &&
         (c->srcRange == c->dstRange || isAnyRGB(dstFormat))) {
@@ -1006,9 +1022,8 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter)
         c->srcBpc = 16;
     if (c->dstBpc == 16)
         dst_stride <<= 1;
-    FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW*2+78, 16) * 2, fail);
     if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2 &&
-        c->srcBpc == 8 && c->dstBpc <= 10) {
+        c->srcBpc == 8 && c->dstBpc <= 14) {
         c->canMMX2BeUsed = (dstW >= srcW && (dstW & 31) == 0 &&
                             (srcW & 15) == 0) ? 1 : 0;
         if (!c->canMMX2BeUsed && dstW >= srcW && (srcW & 15) == 0
@@ -1038,7 +1053,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter)
             c->chrXInc += 20;
         }
         // we don't use the x86 asm scaler if MMX is available
-        else if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX && c->dstBpc <= 10) {
+        else if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX && c->dstBpc <= 14) {
             c->lumXInc = ((int64_t)(srcW       - 2) << 16) / (dstW       - 2) - 20;
             c->chrXInc = ((int64_t)(c->chrSrcW - 2) << 16) / (c->chrDstW - 2) - 20;
         }
@@ -1209,14 +1224,14 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter)
     // try to avoid drawing green stuff between the right end and the stride end
     for (i = 0; i < c->vChrBufSize; i++)
         if(av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 == 15){
-            av_assert0(c->dstBpc > 10);
+            av_assert0(c->dstBpc > 14);
             for(j=0; j<dst_stride/2+1; j++)
                 ((int32_t*)(c->chrUPixBuf[i]))[j] = 1<<18;
         } else
             for(j=0; j<dst_stride+1; j++)
                 ((int16_t*)(c->chrUPixBuf[i]))[j] = 1<<14;
 
-    assert(c->chrDstH <= dstH);
+    av_assert0(c->chrDstH <= dstH);
 
     if (flags & SWS_PRINT_INFO) {
         if (flags & SWS_FAST_BILINEAR)