---
 libavfilter/vf_fieldorder.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index cd8040d..bc17894 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -55,7 +55,6 @@ static int query_formats(AVFilterContext *ctx)
             const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
             if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL ||
                   desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) &&
-                desc->nb_components && !desc->log2_chroma_h &&
                 (ret = ff_add_format(&formats, pix_fmt)) < 0) {
                 ff_formats_unref(&formats);
                 return ret;
@@ -91,6 +90,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     AVFilterLink      *outlink = ctx->outputs[0];
     int h, plane, line_step, line_size, line;
     uint8_t *data;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
+
+    if (!desc)
+        return AVERROR_INVALIDDATA;
 
     if (!frame->interlaced_frame ||
         frame->top_field_first == s->dst_tff) {
@@ -104,11 +107,12 @@ 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]; plane++) {
         line_step = frame->linesize[plane];
         line_size = s->line_size[plane];
         data = frame->data[plane];
+        h = frame->height << (plane == 1 || plane == 2) ? desc->log2_chroma_h 
: 0;
         if (s->dst_tff) {
             /** Move every line up one line, working from
              *  the top to the bottom of the frame.
@@ -116,7 +120,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(data, data + line_step, line_size);
                 } else {
                     memcpy(data, data - line_step - line_step, line_size);
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to