avfilter/vf_cropdetect: support 9-16bit planar formats
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 30 Dec 2014 04:29:27 +0000 (05:29 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 30 Dec 2014 04:31:24 +0000 (05:31 +0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavfilter/vf_cropdetect.c

index abfbd1d..592eb15 100644 (file)
@@ -51,6 +51,11 @@ static int query_formats(AVFilterContext *ctx)
         AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P,
         AV_PIX_FMT_YUV411P, AV_PIX_FMT_GRAY8,
         AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV410P,
+        AV_PIX_FMT_YUV420P9 , AV_PIX_FMT_YUV422P9 , AV_PIX_FMT_YUV444P9,
+        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
+        AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12,
+        AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14,
+        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
         AV_PIX_FMT_NV12,    AV_PIX_FMT_NV21,
         AV_PIX_FMT_RGB24,   AV_PIX_FMT_BGR24,
         AV_PIX_FMT_RGBA,    AV_PIX_FMT_BGRA,
@@ -65,6 +70,7 @@ static int checkline(void *ctx, const unsigned char *src, int stride, int len, i
 {
     int total = 0;
     int div = len;
+    const uint16_t *src16 = (const uint16_t *)src;
 
     switch (bpp) {
     case 1:
@@ -79,6 +85,19 @@ static int checkline(void *ctx, const unsigned char *src, int stride, int len, i
             src += stride;
         }
         break;
+    case 2:
+        stride >>= 1;
+        while (len >= 8) {
+            total += src16[       0] + src16[  stride] + src16[2*stride] + src16[3*stride]
+                  +  src16[4*stride] + src16[5*stride] + src16[6*stride] + src16[7*stride];
+            src += 8*stride;
+            len -= 8;
+        }
+        while (--len >= 0) {
+            total += src16[0];
+            src += stride;
+        }
+        break;
     case 3:
     case 4:
         while (len >= 4) {