[FFmpeg-devel] [PATCH] lavfi/crop: support more pixel formats

Paul B Mahol onemda at gmail.com
Wed Jul 3 23:38:19 CEST 2013


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavfilter/vf_crop.c              | 37 ++++++--------------
 tests/ref/fate/filter-pixfmts-crop | 69 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 27 deletions(-)

diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
index 7ba99d1..e112c23 100644
--- a/libavfilter/vf_crop.c
+++ b/libavfilter/vf_crop.c
@@ -92,34 +92,17 @@ typedef struct {
 
 static int query_formats(AVFilterContext *ctx)
 {
-    static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_RGB48BE,      AV_PIX_FMT_RGB48LE,
-        AV_PIX_FMT_BGR48BE,      AV_PIX_FMT_BGR48LE,
-        AV_PIX_FMT_ARGB,         AV_PIX_FMT_RGBA,
-        AV_PIX_FMT_ABGR,         AV_PIX_FMT_BGRA,
-        AV_PIX_FMT_RGB24,        AV_PIX_FMT_BGR24,
-        AV_PIX_FMT_RGB565BE,     AV_PIX_FMT_RGB565LE,
-        AV_PIX_FMT_RGB555BE,     AV_PIX_FMT_RGB555LE,
-        AV_PIX_FMT_BGR565BE,     AV_PIX_FMT_BGR565LE,
-        AV_PIX_FMT_BGR555BE,     AV_PIX_FMT_BGR555LE,
-        AV_PIX_FMT_GRAY16BE,     AV_PIX_FMT_GRAY16LE,
-        AV_PIX_FMT_YUV420P16LE,  AV_PIX_FMT_YUV420P16BE,
-        AV_PIX_FMT_YUV422P16LE,  AV_PIX_FMT_YUV422P16BE,
-        AV_PIX_FMT_YUV444P16LE,  AV_PIX_FMT_YUV444P16BE,
-        AV_PIX_FMT_YUV444P,      AV_PIX_FMT_YUV422P,
-        AV_PIX_FMT_YUV420P,      AV_PIX_FMT_YUV411P,
-        AV_PIX_FMT_YUV410P,      AV_PIX_FMT_YUV440P,
-        AV_PIX_FMT_YUVJ444P,     AV_PIX_FMT_YUVJ422P,
-        AV_PIX_FMT_YUVJ420P,     AV_PIX_FMT_YUVJ440P,
-        AV_PIX_FMT_YUVA420P,
-        AV_PIX_FMT_RGB8,         AV_PIX_FMT_BGR8,
-        AV_PIX_FMT_RGB4_BYTE,    AV_PIX_FMT_BGR4_BYTE,
-        AV_PIX_FMT_PAL8,         AV_PIX_FMT_GRAY8,
-        AV_PIX_FMT_NONE
-    };
-
-    ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
+    AVFilterFormats *formats = NULL;
+    int fmt;
+
+    for (fmt = 0; fmt < AV_PIX_FMT_NB; fmt++) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+        if (!(desc->flags & (AV_PIX_FMT_FLAG_HWACCEL | AV_PIX_FMT_FLAG_BITSTREAM)) &&
+            !((desc->log2_chroma_w || desc->log2_chroma_h) && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR)))
+            ff_add_format(&formats, fmt);
+    }
 
+    ff_set_common_formats(ctx, formats);
     return 0;
 }
 
diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop
index 797aedc..1060bd1 100644
--- a/tests/ref/fate/filter-pixfmts-crop
+++ b/tests/ref/fate/filter-pixfmts-crop
@@ -1,6 +1,11 @@
+0bgr                ba367adf7943b91cf7f98aefe3f7f9ea
+0rgb                c83c555fe20def126bf1b8967442aa97
 abgr                ef31d9057f6e65a7c3308a1b1daa98fa
 argb                5e5e261c4870e0de05d56ff640b9550a
+bgr0                c8729ca08c5d29ecd5ca21c0ea8c54ce
 bgr24               44bec15f35513de7e957b3d59b53cb7b
+bgr444be            d56f795721020fc7a598e3b07f3fba1e
+bgr444le            53224fc7360806c19fbd873e13fd0c68
 bgr48be             0b5ebce3c48eb8614d79e204b5268603
 bgr48le             c4ab61a8b9d502132730c6abb6ffd84c
 bgr4_byte           cab930dbe1fe77d58b41837ecdcb8460
@@ -10,11 +15,26 @@ bgr565be            ee9a1debb896d41c53a026f9e6ce006b
 bgr565le            ab7b6055bc3b6b7edc9a5e4de43ec90d
 bgr8                f85ff16e21d922ad6d32648ef3acfbfb
 bgra                9f2e37d73ad3b759fc9d6b12ee668c38
+gbrap               32c0326859b41ae1fee015648162c6a0
+gbrp                b59909dd28f16bbe0e3c474523471b3c
+gbrp10be            c7ebd8966a6dda5858366094f7f1c08c
+gbrp10le            6624c0deb9f3a966b15485aa54e8e927
+gbrp12be            ca6978c75aa0e68fe9bfe51525103c91
+gbrp12le            2cada0b4a7b4edcb823b7eddd7c82420
+gbrp14be            160084920ca0c108ae6fd3bbd1882c54
+gbrp14le            7549f7f56affecf6bd412e97719a6fb5
+gbrp9be             c9a0aa01e46a55a70943b5b94be1a190
+gbrp9le             da35c8294af5806bbc44b9d83cad903d
 gray                3266b99065a17cbd647f2339addc5303
 gray16be            02ac848ad4e28c06938599563ba81ff7
 gray16le            672aebfeb8a0f4067b3c6064340056e4
+nv12                923a313a7013fb0e87608155ef6aa9a4
+nv21                21e6b9273bb74203beabeb9edb9cf95c
 pal8                e1fd50b8a8a67fb5abd8b44abc778bbb
+rgb0                8bd7785a8421b3f60e5eae2d2968a546
 rgb24               d044123f1fe50f656f2101dd3f091ead
+rgb444be            6a076e84d0cdbae2ba29412a28587e81
+rgb444le            f82d127ca2a40ec822171b79a11df65d
 rgb48be             ef5507f88948b54218911d12e1dbef36
 rgb48le             6d045d5990d6ada64a112e3b581a7b38
 rgb4_byte           0f0f9ee31c65dc60da49bf98a1b06dcf
@@ -24,19 +44,68 @@ rgb565be            0dd6f6a5a8713bd1c3d9826bb7a88eab
 rgb565le            6afd85faa8c6f0f330969539178eb9a2
 rgb8                87cf541b110e35a6f9a983e9cde85e15
 rgba                7abe1af7b97f5b9a7aa5ad3e4bf32f76
+rgba64be            2eed28b61af25790c02cc658e5f86b9b
+rgba64le            de8bc34c6d573488d87e87ce8c7ad07f
+xyz12be             1de64f52c6e2e7ff0b5da20c78910304
+xyz12le             f7b79cf87ad69dfc24056468e6dffaea
 yuv410p             126e0da1da4fd89be28087b8367bbb36
 yuv411p             b94f0af107fc4796aca70c0a36d374c5
 yuv420p             74c6b331bd30f005e6c75a192423ad90
+yuv420p10be         1321772e0586e9b89386e792ed9f5277
+yuv420p10le         726b637741fe28c26d57a1dd814ef14b
+yuv420p12be         5c3bf63a61fe41acb958614d4a7c8923
+yuv420p12le         073c6fa32443c1df26243b598fb5a34e
+yuv420p14be         9460b8507137516ae437d00380921cb9
+yuv420p14le         fd162a79436a9585ed44814fa3dc02fd
 yuv420p16be         2d3c84ebff77479e8c5b6e3e59ec4e45
 yuv420p16le         e2c906f2751609bf8cbcbeb2f629319a
+yuv420p9be          d40531645b7ddecf4778f652549c121c
+yuv420p9le          fbffd583dd189a546cf4df144a735f66
 yuv422p             124bc8d668072de1bb3b894cc4bae859
+yuv422p10be         3d6195bb0c4cc9498ef42227839db9d5
+yuv422p10le         d19bdc9ba4e76b38c076ac93e99e6ef4
+yuv422p12be         f2c2f23269fa969e3e3f0ba5e065bc98
+yuv422p12le         6d07ba50dcdaf43bd8b73233ed11e4d9
+yuv422p14be         3115c4c01f6a8b9930b32ec8a12f52ac
+yuv422p14le         00ba7302e4e4db2c70ba0712f2fc8574
 yuv422p16be         3ec47e2709107fcc388b5e0abebf7eaf
 yuv422p16le         a4183a62917bf8568fe11ff446dd18f9
+yuv422p9be          05c2d9a95f329133a9fa03c46eaaf0cd
+yuv422p9le          ea559e7009aef6c36de0daa8061740f7
 yuv440p             15c81c685fa5b9db95150caff14ff83f
 yuv444p             12b752f78af72666627cea2d0c274cdb
+yuv444p10be         6a5d1574657bdadd435c59227b6772d0
+yuv444p10le         cc6e8453e6ffeeca98055722f9833fb0
+yuv444p12be         39086bcf3ad336391c2a378b32d9cd1b
+yuv444p12le         ccc98011edecb7c643e6250c34ae9b3d
+yuv444p14be         b05b5999610b1369d0873212543697f8
+yuv444p14le         a4ae35bb8a377d593635126671d1af30
 yuv444p16be         f2bf0e22a1d184e37eaa199a76cf22ba
 yuv444p16le         c11b151dced5c8854d385373fa4dcc8f
+yuv444p9be          0b4e2a096a7ada2d6fab3f7d5160326c
+yuv444p9le          04b00046c0409849f89bca191298257b
 yuva420p            920c5d1b965eeb72e3a0e343696face3
+yuva420p10be        c2d580dee6da641c176c6357e74d14bd
+yuva420p10le        51781f8328a0ad69466e729cfc31bbc6
+yuva420p16be        1855e36526638e5d364b1d29bd49141b
+yuva420p16le        2476b93493a30cce3c8fe07ea3ce3761
+yuva420p9be         7c9d877f0c06529d60beb5fcbe5a6f47
+yuva420p9le         392387fc9b414576e003abed4f8bf389
+yuva422p            1bc930cf64afc7cc99362fee5d8e08d8
+yuva422p10be        3382c54dd78aec916210edef29aa268f
+yuva422p10le        93862b68e0dc6ea812fa36fbb1641b48
+yuva422p16be        a44509ccee5dd71a67f8138a8dca7620
+yuva422p16le        4a0b4f7cb3fda825acd6eeef7efa4aae
+yuva422p9be         f3d9d423699ccf369b50ea7dfefb16da
+yuva422p9le         f65115fd89e0cbabc975a15e764b4d30
+yuva444p            1cf9c2dddb0e2f082eca981b2226bdb1
+yuva444p10be        e60f55491f67bb69962e4c2a29868da2
+yuva444p10le        6a7a95f6af4ef3ce47e2b20bc2453746
+yuva444p16be        0caa51254006811d244e150fa34f2e90
+yuva444p16le        5f073f7771254bace1d07279c56c9613
+yuva444p9be         3d64778ebee876c77e77066fd57336b9
+yuva444p9le         85a80221022b5de7cb3233845392d8c6
+yuvj411p            55f4d5f22146e7771ec4e5729a438f48
 yuvj420p            f9183e49f42bae31d7d85b92161fa82f
 yuvj422p            aabeed60a6e1b2cf88665ac627bf531f
 yuvj440p            5ae4f404b42f3167f978473d9a3737fc
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list