]> granicus.if.org Git - handbrake/commitdiff
deinterlace: add conditional deinterlacing of interlaced frames
authorJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 25 Jan 2016 19:24:03 +0000 (12:24 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 15 Feb 2016 19:38:13 +0000 (12:38 -0700)
Only deinterlace frames that are marked as interlaced when mode
HB_YADIF_AUTO is set in the filter settings.

Currently, this would cause no frames to be deinterlaced since all
frames are marked non-interlaced.  This option will become useful in a
subsequent patch that splits comb detection into it's own filter.

libhb/avfilter.c
libhb/internal.h
libhb/param.c

index 4c1f1d1650ccf0fd102ee9e39e4b5a5a214779c0..a865d6305fe8a0b05de80136d4b32afbcbf0f2e9 100644 (file)
@@ -335,11 +335,12 @@ static void fill_frame(hb_filter_private_t * pv,
     frame->linesize[1] = buf->plane[1].stride;
     frame->linesize[2] = buf->plane[2].stride;
 
-    frame->pts = buf->s.start;
+    frame->pts              = buf->s.start;
     frame->reordered_opaque = buf->s.start;
-    frame->width = buf->f.width;
-    frame->height = buf->f.height;
-    frame->format = buf->f.fmt;
+    frame->width            = buf->f.width;
+    frame->height           = buf->f.height;
+    frame->format           = buf->f.fmt;
+    frame->interlaced_frame = !!buf->s.combed;
 }
 
 static hb_buffer_t* avframe_to_buffer(hb_filter_private_t * pv, AVFrame *frame)
index a4c0eb5b04b865e0e608928ecc69c76d09eb48d4..9ad22507f526fff5d25c86d5fcc32c92d2c123e0 100644 (file)
@@ -102,6 +102,11 @@ struct hb_buffer_settings_s
 #define PIC_FLAG_REPEAT_FRAME       0x0200
 #define HB_BUF_FLAG_EOF             0x0400
     uint16_t      flags;
+
+#define HB_COMB_NONE  0
+#define HB_COMB_LIGHT 1
+#define HB_COMB_HEAVY 2
+    uint8_t       combed;
 };
 
 struct hb_image_format_s
index 3a9402021d97030cb84e824af03a6859d388ee30..f9ec820928f9aa70888c93e66ab530c3cf190dc7 100644 (file)
@@ -108,6 +108,7 @@ static filter_param_map_t param_map[] =
 #define MODE_YADIF_ENABLE       1
 #define MODE_YADIF_SPATIAL      2
 #define MODE_YADIF_BOB          4
+#define MODE_YADIF_AUTO         8
 
 /* Deinterlace Settings
  *  mode:parity
@@ -119,6 +120,7 @@ static filter_param_map_t param_map[] =
  *      1 = Enabled
  *      2 = Spatial
  *      4 = Bob
+ *      8 = Auto
  *
  *  Parity:
  *      0  = Top Field First
@@ -149,11 +151,13 @@ generate_deinterlace_settings(const char * settings)
     {
         return (char*)hb_filter_off;
     }
+    int automatic  = !!(mode & MODE_YADIF_AUTO);
     int bob        = !!(mode & MODE_YADIF_BOB);
     int no_spatial = !(mode & MODE_YADIF_SPATIAL);
     mode = bob | (no_spatial << 1);
 
-    return hb_strdup_printf("yadif='mode=%d:parity=%d'", mode, parity);
+    return hb_strdup_printf("yadif='mode=%d:auto=%d:parity=%d'",
+                            mode, automatic, parity);
 }
 
 /* Rotate Settings: