mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
videoscale: Remove interlaced scaling again
This behaviour was not preferred and caused visible image quality degradations. The real solution would be, to apply a real deinterlacing filter before scaling the frames. Fixes bug #615471.
This commit is contained in:
parent
9fe51a4a50
commit
58c77eb1b4
2 changed files with 169 additions and 222 deletions
|
@ -338,7 +338,6 @@ gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
|
|||
ret &=
|
||||
gst_video_format_parse_caps (out, NULL, &videoscale->to_width,
|
||||
&videoscale->to_height);
|
||||
ret &= gst_video_format_parse_caps_interlaced (in, &videoscale->interlaced);
|
||||
if (!ret)
|
||||
goto done;
|
||||
|
||||
|
@ -355,8 +354,7 @@ gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
|
|||
|
||||
if (videoscale->tmp_buf)
|
||||
g_free (videoscale->tmp_buf);
|
||||
videoscale->tmp_buf =
|
||||
g_malloc (videoscale->dest.stride * 4 * (videoscale->interlaced ? 2 : 1));
|
||||
videoscale->tmp_buf = g_malloc (videoscale->dest.stride * 4);
|
||||
|
||||
if (!gst_video_parse_caps_pixel_aspect_ratio (in, &from_par_n, &from_par_d))
|
||||
from_par_n = from_par_d = 1;
|
||||
|
@ -816,8 +814,7 @@ done:
|
|||
|
||||
static gboolean
|
||||
gst_video_scale_prepare_image (gint format, GstBuffer * buf,
|
||||
VSImage * img, VSImage * img_u, VSImage * img_v, gint step,
|
||||
gboolean interlaced)
|
||||
VSImage * img, VSImage * img_u, VSImage * img_v)
|
||||
{
|
||||
gboolean res = TRUE;
|
||||
|
||||
|
@ -837,21 +834,6 @@ gst_video_scale_prepare_image (gint format, GstBuffer * buf,
|
|||
img_v->pixels =
|
||||
GST_BUFFER_DATA (buf) + gst_video_format_get_component_offset (format,
|
||||
2, img->width, img->height);
|
||||
|
||||
if (interlaced && step == 1) {
|
||||
img_v->pixels += img_v->stride;
|
||||
img_u->pixels += img_u->stride;
|
||||
}
|
||||
|
||||
if (interlaced) {
|
||||
img_u->height = (img_u->height / 2) + ((step == 0
|
||||
&& img_u->height % 2 == 1) ? 1 : 0);
|
||||
img_u->stride *= 2;
|
||||
img_v->height = (img_v->height / 2) + ((step == 0
|
||||
&& img_v->height % 2 == 1) ? 1 : 0);
|
||||
img_v->stride *= 2;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -872,8 +854,6 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
|
|||
VSImage src_u = { NULL, };
|
||||
VSImage src_v = { NULL, };
|
||||
gint method;
|
||||
gint step;
|
||||
gboolean interlaced = videoscale->interlaced;
|
||||
|
||||
GST_OBJECT_LOCK (videoscale);
|
||||
method = videoscale->method;
|
||||
|
@ -882,43 +862,13 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
|
|||
src.pixels = GST_BUFFER_DATA (in);
|
||||
dest.pixels = GST_BUFFER_DATA (out);
|
||||
|
||||
/* For interlaced content we have to run two times with half height
|
||||
* and doubled stride */
|
||||
if (interlaced) {
|
||||
dest.height /= 2;
|
||||
src.height /= 2;
|
||||
dest.stride *= 2;
|
||||
src.stride *= 2;
|
||||
}
|
||||
|
||||
if (src.height < 4 && method == GST_VIDEO_SCALE_4TAP)
|
||||
method = GST_VIDEO_SCALE_BILINEAR;
|
||||
|
||||
for (step = 0; step < (interlaced ? 2 : 1); step++) {
|
||||
gst_video_scale_prepare_image (videoscale->format, in, &videoscale->src,
|
||||
&src_u, &src_v, step, interlaced);
|
||||
&src_u, &src_v);
|
||||
gst_video_scale_prepare_image (videoscale->format, out, &videoscale->dest,
|
||||
&dest_u, &dest_v, step, interlaced);
|
||||
|
||||
if (step == 0 && interlaced) {
|
||||
if (videoscale->from_height % 2 == 1) {
|
||||
src.height += 1;
|
||||
}
|
||||
|
||||
if (videoscale->to_height % 2 == 1) {
|
||||
dest.height += 1;
|
||||
}
|
||||
} else if (step == 1 && interlaced) {
|
||||
if (videoscale->from_height % 2 == 1) {
|
||||
src.height -= 1;
|
||||
}
|
||||
|
||||
if (videoscale->to_height % 2 == 1) {
|
||||
dest.height -= 1;
|
||||
}
|
||||
src.pixels += (src.stride / 2);
|
||||
dest.pixels += (dest.stride / 2);
|
||||
}
|
||||
&dest_u, &dest_v);
|
||||
|
||||
switch (method) {
|
||||
case GST_VIDEO_SCALE_NEAREST:
|
||||
|
@ -1088,8 +1038,6 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
|
|||
goto unknown_mode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GST_LOG_OBJECT (videoscale, "pushing buffer of %d bytes",
|
||||
GST_BUFFER_SIZE (out));
|
||||
|
||||
|
|
|
@ -77,7 +77,6 @@ struct _GstVideoScale {
|
|||
gint from_height;
|
||||
guint src_size;
|
||||
guint dest_size;
|
||||
gboolean interlaced;
|
||||
|
||||
VSImage src;
|
||||
VSImage dest;
|
||||
|
|
Loading…
Reference in a new issue