[FFmpeg-devel] [PATCH] avfilter/vf_fieldorder: support subsampled chroma

Paul B Mahol onemda at gmail.com
Wed Oct 23 18:21:12 CEST 2013


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---

Should fix fate failures.

---
 libavfilter/vf_fieldorder.c              | 13 ++++++---
 tests/ref/fate/filter-fieldorder         | 50 ++++++++++++++++----------------
 tests/ref/fate/filter-pixfmts-fieldorder | 24 +++++++++++++++
 3 files changed, 58 insertions(+), 29 deletions(-)

diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index eb5e189..2bbed11 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -36,6 +36,7 @@ typedef struct {
     const AVClass *class;
     int dst_tff;               ///< output bff/tff
     int          line_size[4]; ///< bytes of pixel data per line for each plane
+    int height[4];             ///< height of each plane
 } FieldOrderContext;
 
 static int query_formats(AVFilterContext *ctx)
@@ -45,7 +46,7 @@ static int query_formats(AVFilterContext *ctx)
     int              ret;
 
     /** accept any input pixel format that is not hardware accelerated, not
-     *  a bitstream format, and does not have vertically sub-sampled chroma */
+     *  a bitstream format */
     if (ctx->inputs[0]) {
         formats = NULL;
         for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++) {
@@ -53,7 +54,7 @@ static int query_formats(AVFilterContext *ctx)
             if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL ||
                   desc->flags & AV_PIX_FMT_FLAG_PAL     ||
                   desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) &&
-                desc->nb_components && !desc->log2_chroma_h &&
+                desc->nb_components &&
                 (ret = ff_add_format(&formats, pix_fmt)) < 0) {
                 ff_formats_unref(&formats);
                 return ret;
@@ -70,6 +71,10 @@ static int config_input(AVFilterLink *inlink)
 {
     AVFilterContext   *ctx = inlink->dst;
     FieldOrderContext *s   = ctx->priv;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
+
+    s->height[1] = s->height[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
+    s->height[0] = s->height[3] = inlink->h;
 
     return av_image_fill_linesizes(s->line_size, inlink->format, inlink->w);
 }
@@ -106,8 +111,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     av_dlog(ctx,
             "picture will move %s one line\n",
             s->dst_tff ? "up" : "down");
-    h = frame->height;
     for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++) {
+        h = s->height[plane];
         dst_line_step = out->linesize[plane];
         src_line_step = frame->linesize[plane];
         line_size = s->line_size[plane];
@@ -120,7 +125,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
              *  The new last line is created as a copy of the
              *  penultimate line from that field. */
             for (line = 0; line < h; line++) {
-                if (1 + line < frame->height) {
+                if (1 + line < h) {
                     memcpy(dst, src + src_line_step, line_size);
                 } else {
                     memcpy(dst, src - 2 * src_line_step, line_size);
diff --git a/tests/ref/fate/filter-fieldorder b/tests/ref/fate/filter-fieldorder
index 14807d7..bf760ce 100644
--- a/tests/ref/fate/filter-fieldorder
+++ b/tests/ref/fate/filter-fieldorder
@@ -1,26 +1,26 @@
 #tb 0: 2/25
-0,          0,          0,        1,   202752, 0xe857d963
-0,          1,          1,        1,   202752, 0xaf7503d8
-0,          2,          2,        1,   202752, 0x99f04d65
-0,          3,          3,        1,   202752, 0x95a4f5c7
-0,          4,          4,        1,   202752, 0xb6858cd1
-0,          5,          5,        1,   202752, 0x2cd15050
-0,          6,          6,        1,   202752, 0xe90350bd
-0,          7,          7,        1,   202752, 0x040e1405
-0,          8,          8,        1,   202752, 0x6b68c254
-0,          9,          9,        1,   202752, 0x252ed792
-0,         10,         10,        1,   202752, 0x9e80ccce
-0,         11,         11,        1,   202752, 0x45759807
-0,         12,         12,        1,   202752, 0x2cacebb2
-0,         13,         13,        1,   202752, 0x94de13e4
-0,         14,         14,        1,   202752, 0xcbdd3b6d
-0,         15,         15,        1,   202752, 0x93ee3f19
-0,         16,         16,        1,   202752, 0xa9ff0798
-0,         17,         17,        1,   202752, 0x4dce02e7
-0,         18,         18,        1,   202752, 0x3da977c6
-0,         19,         19,        1,   202752, 0x11aeb220
-0,         20,         20,        1,   202752, 0x3d831198
-0,         21,         21,        1,   202752, 0x335bcd4e
-0,         22,         22,        1,   202752, 0x755a6589
-0,         23,         23,        1,   202752, 0xbbf5ec97
-0,         24,         24,        1,   202752, 0x9aa4bb3b
+0,          0,          0,        1,   152064, 0x0a890511
+0,          1,          1,        1,   152064, 0xbb403ecd
+0,          2,          2,        1,   152064, 0x5f79b008
+0,          3,          3,        1,   152064, 0xc4c927ec
+0,          4,          4,        1,   152064, 0xca13f43d
+0,          5,          5,        1,   152064, 0xb77931c3
+0,          6,          6,        1,   152064, 0x37e8afac
+0,          7,          7,        1,   152064, 0xfe954ec2
+0,          8,          8,        1,   152064, 0xc7f03982
+0,          9,          9,        1,   152064, 0x6dfd197e
+0,         10,         10,        1,   152064, 0x46bb0593
+0,         11,         11,        1,   152064, 0x98d5c266
+0,         12,         12,        1,   152064, 0x1e1f4945
+0,         13,         13,        1,   152064, 0x584eb921
+0,         14,         14,        1,   152064, 0xcfd10e9b
+0,         15,         15,        1,   152064, 0xe9302b01
+0,         16,         16,        1,   152064, 0xa2f3dbb1
+0,         17,         17,        1,   152064, 0xa2527c90
+0,         18,         18,        1,   152064, 0x0e91a107
+0,         19,         19,        1,   152064, 0x8519de0a
+0,         20,         20,        1,   152064, 0x9eba8ded
+0,         21,         21,        1,   152064, 0xb1ec05c1
+0,         22,         22,        1,   152064, 0x3bc8e0f6
+0,         23,         23,        1,   152064, 0xa72fa803
+0,         24,         24,        1,   152064, 0x8be7d341
diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder
index d743caa..17a1cad 100644
--- a/tests/ref/fate/filter-pixfmts-fieldorder
+++ b/tests/ref/fate/filter-pixfmts-fieldorder
@@ -28,6 +28,8 @@ gbrp9le             1b6d228b97a370ec76707ed2dcc15a66
 gray                3258910ef8c6f0c4a331368e7af87507
 gray16be            50cc8a29e8e81e174676542347804a4f
 gray16le            fb93e8aa2deed734dfd1ca6a5c48cf18
+nv12                3eea4cc17fddc9ea73499cd484987948
+nv21                2c4a742b4fa9bf085b16ff4423107083
 rgb0                5f8f8076e2b9a2422cac25a4f0459d79
 rgb24               66ca89ced3ade4c239ad6c5a79a6b8cd
 rgb444be            7197a09137ab5630a26226396bb7e313
@@ -46,7 +48,19 @@ rgba64le            86997e62f62d2a5351b5ca9c9c93c2d1
 uyvy422             a07829fe630b59855c80d87d0e8f0dbb
 xyz12be             5785613045b051cee508625dde3357df
 xyz12le             3645601dc8bfbdff68cc823a0fc85b27
+yuv410p             0db484fcff3056237b23e71d37ff7955
 yuv411p             3d3d427999863945aa5ec03edf98c19a
+yuv420p             48102f42b9cc6cf783fafc2ac25be29c
+yuv420p10be         e136e4cee4151274370c6638a609b859
+yuv420p10le         1829061302326d234163a05decd137be
+yuv420p12be         6f9cd14ec204030f273f57a3df7b5b23
+yuv420p12le         833a9905b0a681084cf26cf94a27c3d1
+yuv420p14be         f32bdd339068ecb54615fbe6844a480a
+yuv420p14le         72c3f2871471387973240b368278935d
+yuv420p16be         0c7d657449ce81c42b57ee8328550dfe
+yuv420p16le         255d920c10db1e015d81c5a4128aca77
+yuv420p9be          4dc1adaa302220cc5616cfcef3ca9895
+yuv420p9le          f4765d7f4331d3b6455aae5f754ec3e0
 yuv422p             961d8a22bfe8868eb3c743b4241a3c99
 yuv422p10be         845e80406c880f33a384b5ebdd21796d
 yuv422p10le         0dbf5d1eb94f10cc4413976fa175fa90
@@ -58,6 +72,7 @@ yuv422p16be         09d09b64aa4b6ae8479a833622bf27e8
 yuv422p16le         03dbbf3394ba66cda54ef53772258dae
 yuv422p9be          7c59e15cb5e6eac9cd090c6ecab4c6b8
 yuv422p9le          98b6b1fbacdfd4c25dbda89b675b660b
+yuv440p             31aab987fa7eaa7abacf2e9dc543ed8e
 yuv444p             709ffd0e95a9438b14d9ba59c0237a61
 yuv444p10be         5ae7571651faebac6dca2ee4fd24610c
 yuv444p10le         eb3acb92448d8b0e6f145e9d8af43378
@@ -69,6 +84,13 @@ yuv444p16be         2a19a8ca44198d0e90c02fd4db24d0c6
 yuv444p16le         5cb12916afef8c82d1796fdc39b97174
 yuv444p9be          fc731b5b0afe0a9de6bd46179c692efa
 yuv444p9le          7449c543e528067afed5d3c96f7b8da2
+yuva420p            9eef4d551cecc533aee266341bdff6ab
+yuva420p10be        3b6bbb7139169007aa8f2cbf24435097
+yuva420p10le        006313535bf0b7d38cbd00bf8622746c
+yuva420p16be        f8d2d5d23a6ef707ccfaff7204498417
+yuva420p16le        fa740e5b6af5657baa43434d0d97289b
+yuva420p9be         c8ab2d8c8ca571386757e74c64285106
+yuva420p9le         7518091094e2f19ed1f46685664ab1d2
 yuva422p            d07e0ed0cb20eee67007b154f02cf37c
 yuva422p10be        56bfd0af50b9450f72061c605f6537dd
 yuva422p10le        bfe1df3aae3e02f0a2ddbd404199e6ac
@@ -84,6 +106,8 @@ yuva444p16le        c2cfda36aa173be3a4a5c9a8fd66d8db
 yuva444p9be         e047805a8f9552a6e0b6d4f772126808
 yuva444p9le         28336905569a55e935d708527a3c9d9d
 yuvj411p            09f79c56109a13eefb68ee729d9a624b
+yuvj420p            b9e480238641385925fa915a008dcbe7
 yuvj422p            942043a34ac7d0f65edced1f6361259c
+yuvj440p            f8f8a7962e49a11d551bf72c494c9b92
 yuvj444p            7e4758df8eb9b18ad60e1b69a913f8c8
 yuyv422             6b0c70d5ebf1685857b65456c547ea1c
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list