videoscale: Fix interlaced scaling for I420

...and some other minor mistakes in the previous change.
This commit is contained in:
Sebastian Dröge 2009-07-28 15:18:56 +02:00
parent 164b90f9d0
commit c51d2febd3

View file

@ -709,25 +709,28 @@ gst_video_scale_prepare_image (gint format, GstBuffer * buf,
{ {
gboolean res = TRUE; gboolean res = TRUE;
img->pixels = GST_BUFFER_DATA (buf);
switch (format) { switch (format) {
case GST_VIDEO_SCALE_I420: case GST_VIDEO_SCALE_I420:
case GST_VIDEO_SCALE_YV12: case GST_VIDEO_SCALE_YV12:
img_u->pixels = img->pixels + GST_ROUND_UP_2 (img->height) * img->stride; img_u->pixels =
GST_BUFFER_DATA (buf) + GST_ROUND_UP_2 (img->height) * img->stride;
img_u->height = GST_ROUND_UP_2 (img->height) / 2; img_u->height = GST_ROUND_UP_2 (img->height) / 2;
if (interlaced) {
img_u->height = (img_u->height / 2) + ((step == 0
&& img_u->height % 2 == 1) ? 1 : 0);
img_u->stride *= 2;
}
img_u->width = GST_ROUND_UP_2 (img->width) / 2; img_u->width = GST_ROUND_UP_2 (img->width) / 2;
img_u->stride = GST_ROUND_UP_4 (img_u->width); img_u->stride = GST_ROUND_UP_4 (img_u->width);
if (interlaced) {
}
memcpy (img_v, img_u, sizeof (*img_v)); memcpy (img_v, img_u, sizeof (*img_v));
img_v->pixels = img_u->pixels + img_u->height * img_u->stride; img_v->pixels = img_u->pixels + img_u->height * img_u->stride;
if (interlaced && step == 1) { if (interlaced && step == 1) {
img_v->pixels += (img_v->stride / 2); img_v->pixels += img_v->stride;
img_u->pixels += (img_u->stride / 2); img_u->pixels += img_u->stride;
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; break;
default: default:
@ -756,23 +759,26 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
method = videoscale->method; method = videoscale->method;
GST_OBJECT_UNLOCK (videoscale); GST_OBJECT_UNLOCK (videoscale);
if (src.height < 4 && method == GST_VIDEO_SCALE_4TAP) src.pixels = GST_BUFFER_DATA (in);
method = GST_VIDEO_SCALE_BILINEAR; dest.pixels = GST_BUFFER_DATA (out);
/* For interlaced content we have to run two times with half height /* For interlaced content we have to run two times with half height
* and doubled stride */ * and doubled stride */
if (videoscale->interlaced) { if (interlaced) {
dest.height /= 2; dest.height /= 2;
src.height /= 2; src.height /= 2;
dest.stride *= 2; dest.stride *= 2;
src.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++) { for (step = 0; step < (interlaced ? 2 : 1); step++) {
gst_video_scale_prepare_image (videoscale->format, in, &src, &src_u, &src_v, gst_video_scale_prepare_image (videoscale->format, in, &videoscale->src,
step, interlaced); &src_u, &src_v, step, interlaced);
gst_video_scale_prepare_image (videoscale->format, out, &dest, &dest_u, gst_video_scale_prepare_image (videoscale->format, out, &videoscale->dest,
&dest_v, step, interlaced); &dest_u, &dest_v, step, interlaced);
if (step == 0 && interlaced) { if (step == 0 && interlaced) {
if (videoscale->from_height % 2 == 1) { if (videoscale->from_height % 2 == 1) {