Commit a9ed56b1 authored by Sebastian Dröge's avatar Sebastian Dröge
Browse files

deinterlace: Add support for UYVY

parent 50f26c67
......@@ -157,6 +157,7 @@ static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" GST_VIDEO_CAPS_YUV ("Y444")
";" GST_VIDEO_CAPS_YUV ("YUY2") ";" GST_VIDEO_CAPS_YUV ("YVYU") ";"
GST_VIDEO_CAPS_YUV ("UYVY") ";"
GST_VIDEO_CAPS_YUV ("Y42B") ";" GST_VIDEO_CAPS_YUV ("I420") ";"
GST_VIDEO_CAPS_YUV ("YV12") ";" GST_VIDEO_CAPS_YUV ("Y41B") ";"
GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_ABGR ";"
......@@ -171,6 +172,7 @@ static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" GST_VIDEO_CAPS_YUV ("Y444")
";" GST_VIDEO_CAPS_YUV ("YUY2") ";" GST_VIDEO_CAPS_YUV ("YVYU") ";"
GST_VIDEO_CAPS_YUV ("UYVY") ";"
GST_VIDEO_CAPS_YUV ("Y42B") ";" GST_VIDEO_CAPS_YUV ("I420") ";"
GST_VIDEO_CAPS_YUV ("YV12") ";" GST_VIDEO_CAPS_YUV ("Y41B") ";"
GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_ABGR ";"
......
......@@ -58,6 +58,8 @@ gst_deinterlace_method_supported_impl (GstDeinterlaceMethodClass * klass,
return (klass->deinterlace_frame_yuy2 != NULL);
case GST_VIDEO_FORMAT_YVYU:
return (klass->deinterlace_frame_yvyu != NULL);
case GST_VIDEO_FORMAT_UYVY:
return (klass->deinterlace_frame_uyvy != NULL);
case GST_VIDEO_FORMAT_I420:
return (klass->deinterlace_frame_i420 != NULL);
case GST_VIDEO_FORMAT_YV12:
......@@ -132,6 +134,9 @@ gst_deinterlace_method_setup_impl (GstDeinterlaceMethod * self,
case GST_VIDEO_FORMAT_YVYU:
self->deinterlace_frame = klass->deinterlace_frame_yvyu;
break;
case GST_VIDEO_FORMAT_UYVY:
self->deinterlace_frame = klass->deinterlace_frame_uyvy;
break;
case GST_VIDEO_FORMAT_I420:
self->deinterlace_frame = klass->deinterlace_frame_i420;
break;
......@@ -260,6 +265,9 @@ gst_deinterlace_simple_method_supported (GstDeinterlaceMethodClass * mklass,
case GST_VIDEO_FORMAT_YVYU:
return (klass->interpolate_scanline_yvyu != NULL
&& klass->copy_scanline_yvyu != NULL);
case GST_VIDEO_FORMAT_UYVY:
return (klass->interpolate_scanline_uyvy != NULL
&& klass->copy_scanline_uyvy != NULL);
case GST_VIDEO_FORMAT_AYUV:
return (klass->interpolate_scanline_ayuv != NULL
&& klass->copy_scanline_ayuv != NULL);
......@@ -680,6 +688,10 @@ gst_deinterlace_simple_method_setup (GstDeinterlaceMethod * method,
self->interpolate_scanline_packed = klass->interpolate_scanline_yvyu;
self->copy_scanline_packed = klass->copy_scanline_yvyu;
break;
case GST_VIDEO_FORMAT_UYVY:
self->interpolate_scanline_packed = klass->interpolate_scanline_uyvy;
self->copy_scanline_packed = klass->copy_scanline_uyvy;
break;
case GST_VIDEO_FORMAT_AYUV:
self->interpolate_scanline_packed = klass->interpolate_scanline_ayuv;
self->copy_scanline_packed = klass->copy_scanline_ayuv;
......
......@@ -92,6 +92,7 @@ struct _GstDeinterlaceMethodClass {
GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yuy2;
GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yvyu;
GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_uyvy;
GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_i420;
GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yv12;
GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_y444;
......@@ -185,6 +186,8 @@ struct _GstDeinterlaceSimpleMethodClass {
GstDeinterlaceSimpleMethodFunction copy_scanline_yuy2;
GstDeinterlaceSimpleMethodFunction interpolate_scanline_yvyu;
GstDeinterlaceSimpleMethodFunction copy_scanline_yvyu;
GstDeinterlaceSimpleMethodFunction interpolate_scanline_uyvy;
GstDeinterlaceSimpleMethodFunction copy_scanline_uyvy;
GstDeinterlaceSimpleMethodFunction interpolate_scanline_ayuv;
GstDeinterlaceSimpleMethodFunction copy_scanline_ayuv;
GstDeinterlaceSimpleMethodFunction interpolate_scanline_argb;
......
......@@ -568,6 +568,7 @@ gst_deinterlace_method_greedy_l_class_init (GstDeinterlaceMethodGreedyLClass *
dim_class->deinterlace_frame_yuy2 = deinterlace_frame_di_greedy_packed;
dim_class->deinterlace_frame_yvyu = deinterlace_frame_di_greedy_packed;
dim_class->deinterlace_frame_uyvy = deinterlace_frame_di_greedy_packed;
dim_class->deinterlace_frame_y444 = deinterlace_frame_di_greedy_planar;
dim_class->deinterlace_frame_y42b = deinterlace_frame_di_greedy_planar;
dim_class->deinterlace_frame_i420 = deinterlace_frame_di_greedy_planar;
......
......@@ -61,6 +61,7 @@ typedef struct
{
GstDeinterlaceMethodClass parent_class;
ScanlineFunction scanline_yuy2; /* This is for YVYU too */
ScanlineFunction scanline_uyvy;
ScanlineFunction scanline_ayuv;
ScanlineFunction scanline_planar_y;
ScanlineFunction scanline_planar_uv;
......@@ -321,6 +322,150 @@ greedyh_scanline_C_yuy2 (GstDeinterlaceMethodGreedyH * self, const guint8 * L1,
}
}
static void
greedyh_scanline_C_uyvy (GstDeinterlaceMethodGreedyH * self, const guint8 * L1,
const guint8 * L2, const guint8 * L3, const guint8 * L2P, guint8 * Dest,
gint width)
{
gint Pos;
guint8 l1_l, l1_1_l, l3_l, l3_1_l;
guint8 l1_c, l1_1_c, l3_c, l3_1_c;
guint8 avg_l, avg_c, avg_l_1, avg_c_1;
guint8 avg_l__1 = 0, avg_c__1 = 0;
guint8 avg_s_l, avg_s_c;
guint8 avg_sc_l, avg_sc_c;
guint8 best_l, best_c;
guint16 mov_l;
guint8 out_l, out_c;
guint8 l2_l, l2_c, lp2_l, lp2_c;
guint8 l2_l_diff, l2_c_diff, lp2_l_diff, lp2_c_diff;
guint8 min_l, min_c, max_l, max_c;
guint max_comb = self->max_comb;
guint motion_sense = self->motion_sense;
guint motion_threshold = self->motion_threshold;
width /= 2;
for (Pos = 0; Pos < width; Pos++) {
l1_l = L1[1];
l1_c = L1[0];
l3_l = L3[1];
l3_c = L3[0];
if (Pos == width - 1) {
l1_1_l = l1_l;
l1_1_c = l1_c;
l3_1_l = l3_l;
l3_1_c = l3_c;
} else {
l1_1_l = L1[3];
l1_1_c = L1[2];
l3_1_l = L3[3];
l3_1_c = L3[2];
}
/* Average of L1 and L3 */
avg_l = (l1_l + l3_l) / 2;
avg_c = (l1_c + l3_c) / 2;
if (Pos == 0) {
avg_l__1 = avg_l;
avg_c__1 = avg_c;
}
/* Average of next L1 and next L3 */
avg_l_1 = (l1_1_l + l3_1_l) / 2;
avg_c_1 = (l1_1_c + l3_1_c) / 2;
/* Calculate average of one pixel forward and previous */
avg_s_l = (avg_l__1 + avg_l_1) / 2;
avg_s_c = (avg_c__1 + avg_c_1) / 2;
/* Calculate average of center and surrounding pixels */
avg_sc_l = (avg_l + avg_s_l) / 2;
avg_sc_c = (avg_c + avg_s_c) / 2;
/* move forward */
avg_l__1 = avg_l;
avg_c__1 = avg_c;
/* Get best L2/L2P, i.e. least diff from above average */
l2_l = L2[1];
l2_c = L2[0];
lp2_l = L2P[1];
lp2_c = L2P[0];
l2_l_diff = ABS (l2_l - avg_sc_l);
l2_c_diff = ABS (l2_c - avg_sc_c);
lp2_l_diff = ABS (lp2_l - avg_sc_l);
lp2_c_diff = ABS (lp2_c - avg_sc_c);
if (l2_l_diff > lp2_l_diff)
best_l = lp2_l;
else
best_l = l2_l;
if (l2_c_diff > lp2_c_diff)
best_c = lp2_c;
else
best_c = l2_c;
/* Clip this best L2/L2P by L1/L3 and allow to differ by GreedyMaxComb */
max_l = MAX (l1_l, l3_l);
min_l = MIN (l1_l, l3_l);
if (max_l < 256 - max_comb)
max_l += max_comb;
else
max_l = 255;
if (min_l > max_comb)
min_l -= max_comb;
else
min_l = 0;
max_c = MAX (l1_c, l3_c);
min_c = MIN (l1_c, l3_c);
if (max_c < 256 - max_comb)
max_c += max_comb;
else
max_c = 255;
if (min_c > max_comb)
min_c -= max_comb;
else
min_c = 0;
out_l = CLAMP (best_l, min_l, max_l);
out_c = CLAMP (best_c, min_c, max_c);
/* Do motion compensation for luma, i.e. how much
* the weave pixel differs */
mov_l = ABS (l2_l - lp2_l);
if (mov_l > motion_threshold)
mov_l -= motion_threshold;
else
mov_l = 0;
mov_l = mov_l * motion_sense;
if (mov_l > 256)
mov_l = 256;
/* Weighted sum on clipped weave pixel and average */
out_l = (out_l * (256 - mov_l) + avg_sc_l * mov_l) / 256;
Dest[1] = out_l;
Dest[0] = out_c;
Dest += 2;
L1 += 2;
L2 += 2;
L3 += 2;
L2P += 2;
}
}
static void
greedyh_scanline_C_planar_y (GstDeinterlaceMethodGreedyH * self,
const guint8 * L1, const guint8 * L2, const guint8 * L3, const guint8 * L2P,
......@@ -866,6 +1011,7 @@ gst_deinterlace_method_greedy_h_class_init (GstDeinterlaceMethodGreedyHClass *
#endif
/* TODO: MMX implementation of these two */
klass->scanline_ayuv = greedyh_scanline_C_ayuv;
klass->scanline_uyvy = greedyh_scanline_C_uyvy;
klass->scanline_planar_y = greedyh_scanline_C_planar_y;
klass->scanline_planar_uv = greedyh_scanline_C_planar_uv;
}
......
......@@ -292,6 +292,7 @@ gst_deinterlace_method_linear_class_init (GstDeinterlaceMethodLinearClass *
dism_class->interpolate_scanline_yuy2 = deinterlace_scanline_linear_packed_c;
dism_class->interpolate_scanline_yvyu = deinterlace_scanline_linear_packed_c;
dism_class->interpolate_scanline_uyvy = deinterlace_scanline_linear_packed_c;
dism_class->interpolate_scanline_ayuv = deinterlace_scanline_linear_packed_c;
dism_class->interpolate_scanline_argb = deinterlace_scanline_linear_packed_c;
dism_class->interpolate_scanline_abgr = deinterlace_scanline_linear_packed_c;
......@@ -314,6 +315,8 @@ gst_deinterlace_method_linear_class_init (GstDeinterlaceMethodLinearClass *
deinterlace_scanline_linear_packed_mmxext;
dism_class->interpolate_scanline_yvyu =
deinterlace_scanline_linear_packed_mmxext;
dism_class->interpolate_scanline_uyvy =
deinterlace_scanline_linear_packed_mmxext;
dism_class->interpolate_scanline_argb =
deinterlace_scanline_linear_packed_mmxext;
dism_class->interpolate_scanline_abgr =
......@@ -339,6 +342,8 @@ gst_deinterlace_method_linear_class_init (GstDeinterlaceMethodLinearClass *
deinterlace_scanline_linear_packed_mmx;
dism_class->interpolate_scanline_yvyu =
deinterlace_scanline_linear_packed_mmx;
dism_class->interpolate_scanline_uyvy =
deinterlace_scanline_linear_packed_mmx;
dism_class->interpolate_scanline_argb =
deinterlace_scanline_linear_packed_mmx;
dism_class->interpolate_scanline_abgr =
......
......@@ -326,6 +326,8 @@ static void
deinterlace_scanline_linear_blend_packed_c;
dism_class->interpolate_scanline_yvyu =
deinterlace_scanline_linear_blend_packed_c;
dism_class->interpolate_scanline_uyvy =
deinterlace_scanline_linear_blend_packed_c;
dism_class->interpolate_scanline_ayuv =
deinterlace_scanline_linear_blend_packed_c;
dism_class->interpolate_scanline_argb =
......@@ -350,6 +352,7 @@ static void
dism_class->copy_scanline_yuy2 = deinterlace_scanline_linear_blend2_packed_c;
dism_class->copy_scanline_yvyu = deinterlace_scanline_linear_blend2_packed_c;
dism_class->copy_scanline_uyvy = deinterlace_scanline_linear_blend2_packed_c;
dism_class->copy_scanline_ayuv = deinterlace_scanline_linear_blend2_packed_c;
dism_class->copy_scanline_argb = deinterlace_scanline_linear_blend2_packed_c;
dism_class->copy_scanline_abgr = deinterlace_scanline_linear_blend2_packed_c;
......@@ -371,6 +374,8 @@ static void
deinterlace_scanline_linear_blend_packed_mmx;
dism_class->interpolate_scanline_yvyu =
deinterlace_scanline_linear_blend_packed_mmx;
dism_class->interpolate_scanline_uyvy =
deinterlace_scanline_linear_blend_packed_mmx;
dism_class->interpolate_scanline_ayuv =
deinterlace_scanline_linear_blend_packed_mmx;
dism_class->interpolate_scanline_argb =
......@@ -400,6 +405,8 @@ static void
deinterlace_scanline_linear_blend2_packed_mmx;
dism_class->copy_scanline_yvyu =
deinterlace_scanline_linear_blend2_packed_mmx;
dism_class->copy_scanline_uyvy =
deinterlace_scanline_linear_blend2_packed_mmx;
dism_class->copy_scanline_argb =
deinterlace_scanline_linear_blend2_packed_mmx;
dism_class->copy_scanline_abgr =
......
......@@ -88,6 +88,8 @@ gst_deinterlace_method_scaler_bob_class_init (GstDeinterlaceMethodScalerBobClass
deinterlace_scanline_scaler_bob_packed;
dism_class->interpolate_scanline_yvyu =
deinterlace_scanline_scaler_bob_packed;
dism_class->interpolate_scanline_uyvy =
deinterlace_scanline_scaler_bob_packed;
dism_class->interpolate_scanline_argb =
deinterlace_scanline_scaler_bob_packed;
dism_class->interpolate_scanline_abgr =
......
......@@ -268,6 +268,7 @@ gst_deinterlace_method_vfir_class_init (GstDeinterlaceMethodVFIRClass * klass)
dism_class->interpolate_scanline_ayuv = deinterlace_line_packed_mmx;
dism_class->interpolate_scanline_yuy2 = deinterlace_line_packed_mmx;
dism_class->interpolate_scanline_yvyu = deinterlace_line_packed_mmx;
dism_class->interpolate_scanline_uyvy = deinterlace_line_packed_mmx;
dism_class->interpolate_scanline_argb = deinterlace_line_packed_mmx;
dism_class->interpolate_scanline_abgr = deinterlace_line_packed_mmx;
dism_class->interpolate_scanline_rgba = deinterlace_line_packed_mmx;
......@@ -280,6 +281,7 @@ gst_deinterlace_method_vfir_class_init (GstDeinterlaceMethodVFIRClass * klass)
} else {
dism_class->interpolate_scanline_yuy2 = deinterlace_line_packed_c;
dism_class->interpolate_scanline_yvyu = deinterlace_line_packed_c;
dism_class->interpolate_scanline_uyvy = deinterlace_line_packed_c;
dism_class->interpolate_scanline_ayuv = deinterlace_line_packed_c;
dism_class->interpolate_scanline_argb = deinterlace_line_packed_c;
dism_class->interpolate_scanline_abgr = deinterlace_line_packed_c;
......@@ -295,6 +297,7 @@ gst_deinterlace_method_vfir_class_init (GstDeinterlaceMethodVFIRClass * klass)
dism_class->interpolate_scanline_ayuv = deinterlace_line_packed_c;
dism_class->interpolate_scanline_yuy2 = deinterlace_line_packed_c;
dism_class->interpolate_scanline_yvyu = deinterlace_line_packed_c;
dism_class->interpolate_scanline_uyvy = deinterlace_line_packed_c;
dism_class->interpolate_scanline_argb = deinterlace_line_packed_c;
dism_class->interpolate_scanline_abgr = deinterlace_line_packed_c;
dism_class->interpolate_scanline_rgba = deinterlace_line_packed_c;
......
......@@ -118,6 +118,7 @@ gst_deinterlace_method_weave_class_init (GstDeinterlaceMethodWeaveClass * klass)
dism_class->interpolate_scanline_ayuv = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_yuy2 = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_yvyu = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_uyvy = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_argb = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_abgr = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_rgba = deinterlace_scanline_weave_packed;
......@@ -134,6 +135,7 @@ gst_deinterlace_method_weave_class_init (GstDeinterlaceMethodWeaveClass * klass)
dism_class->copy_scanline_ayuv = copy_scanline_packed;
dism_class->copy_scanline_yuy2 = copy_scanline_packed;
dism_class->copy_scanline_yvyu = copy_scanline_packed;
dism_class->copy_scanline_uyvy = copy_scanline_packed;
dism_class->copy_scanline_argb = copy_scanline_packed;
dism_class->copy_scanline_abgr = copy_scanline_packed;
dism_class->copy_scanline_rgba = copy_scanline_packed;
......
......@@ -139,6 +139,7 @@ gst_deinterlace_method_weave_bff_class_init (GstDeinterlaceMethodWeaveBFFClass *
dism_class->interpolate_scanline_ayuv = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_yuy2 = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_yvyu = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_uyvy = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_argb = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_abgr = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_rgba = deinterlace_scanline_weave_packed;
......@@ -155,6 +156,7 @@ gst_deinterlace_method_weave_bff_class_init (GstDeinterlaceMethodWeaveBFFClass *
dism_class->copy_scanline_ayuv = copy_scanline_packed;
dism_class->copy_scanline_yuy2 = copy_scanline_packed;
dism_class->copy_scanline_yvyu = copy_scanline_packed;
dism_class->copy_scanline_uyvy = copy_scanline_packed;
dism_class->copy_scanline_argb = copy_scanline_packed;
dism_class->copy_scanline_abgr = copy_scanline_packed;
dism_class->copy_scanline_rgba = copy_scanline_packed;
......
......@@ -140,6 +140,7 @@ gst_deinterlace_method_weave_tff_class_init (GstDeinterlaceMethodWeaveTFFClass *
dism_class->interpolate_scanline_ayuv = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_yuy2 = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_yvyu = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_uyvy = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_argb = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_abgr = deinterlace_scanline_weave_packed;
dism_class->interpolate_scanline_rgba = deinterlace_scanline_weave_packed;
......@@ -156,6 +157,7 @@ gst_deinterlace_method_weave_tff_class_init (GstDeinterlaceMethodWeaveTFFClass *
dism_class->copy_scanline_ayuv = copy_scanline_packed;
dism_class->copy_scanline_yuy2 = copy_scanline_packed;
dism_class->copy_scanline_yvyu = copy_scanline_packed;
dism_class->copy_scanline_uyvy = copy_scanline_packed;
dism_class->copy_scanline_argb = copy_scanline_packed;
dism_class->copy_scanline_abgr = copy_scanline_packed;
dism_class->copy_scanline_rgba = copy_scanline_packed;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment