diff options
author | Johns <johns98@gmx.net> | 2012-01-23 20:04:15 +0100 |
---|---|---|
committer | Johns <johns98@gmx.net> | 2012-01-23 20:04:15 +0100 |
commit | 5f43803236e9ce08dba301bbdea67fb88c208950 (patch) | |
tree | ebce861b8847f0127f8d9367a617e387e265a52d | |
parent | 993d831190cce6d8582300f74a2ce3acedc40b20 (diff) | |
download | vdr-plugin-softhddevice-5f43803236e9ce08dba301bbdea67fb88c208950.tar.gz vdr-plugin-softhddevice-5f43803236e9ce08dba301bbdea67fb88c208950.tar.bz2 |
VDPAU: Add primitive software scaler to grab image
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | Todo | 3 | ||||
-rw-r--r-- | softhddev.c | 3 | ||||
-rw-r--r-- | video.c | 61 |
4 files changed, 65 insertions, 3 deletions
@@ -1,6 +1,7 @@ User johns Date: + VDPAU: Add very primitive software scaler for grab image. VA-API: Add auto-crop support. Suspend can close/open X11 window, connection and audio device. @@ -45,6 +45,9 @@ libva: can associate ony displayed part of osd ready(not intel checked) auto crop for va-api grab image for va-api + still many: + [drm:i915_hangcheck_elapsed] *ERROR* Hangcheck timer elapsed... GPU hung + [drm:i915_wait_request] *ERROR* i915_wait_request returns -11 ... libva: branch vaapi-ext add support for vaapi-ext diff --git a/softhddev.c b/softhddev.c index 102f9f1..758ef0d 100644 --- a/softhddev.c +++ b/softhddev.c @@ -830,8 +830,7 @@ uint8_t *GrabImage(int *size, int jpeg, int quality, int width, int height) return NULL; } if (width != -1 && height != -1) { - Error(_("softhddev: scaling not supported\n")); - return NULL; + Warning(_("softhddev: scaling unsupported\n")); } return VideoGrab(size, &width, &height); } @@ -7768,8 +7768,66 @@ uint8_t *VideoGrab(int *size, int *width, int *height) char buf[64]; int i; int n; - + int scale_width; + int scale_height; + int x; + int y; + double src_x; + double src_y; + double scale_x; + double scale_y; + + scale_width = *width; + scale_height = *height; data = VdpauGrabOutputSurface(size, width, height); + +#if 1 + if (scale_width <= 0) { + scale_width = *width; + } + if (scale_height <= 0) { + scale_height = *height; + } + + n = snprintf(buf, sizeof(buf), "P6\n%d\n%d\n255\n", scale_width, + scale_height); + rgb = malloc(scale_width * scale_height * 3 + n); + if (!rgb) { + Error(_("video: out of memory\n")); + free(data); + return NULL; + } + *size = scale_width * scale_height * 3 + n; + memcpy(rgb, buf, n); // header + + scale_x = (double)*width / scale_width; + scale_y = (double)*height / scale_height; + + src_y = 0.0; + for (y = 0; y < scale_height; y++) { + int o; + + src_x = 0.0; + o = (int)src_y **width; + + for (x = 0; x < scale_width; x++) { + i = 4 * (o + (int)src_x); + + rgb[n + (x + y * scale_width) * 3 + 0] = data[i + 2]; + rgb[n + (x + y * scale_width) * 3 + 1] = data[i + 1]; + rgb[n + (x + y * scale_width) * 3 + 2] = data[i + 0]; + + src_x += scale_x; + } + + src_y += scale_y; + } + + *width = scale_width; + *height = scale_height; + + free(data); +#else n = snprintf(buf, sizeof(buf), "P6\n%d\n%d\n255\n", *width, *height); rgb = malloc(*width * *height * 3 + n); if (!rgb) { @@ -7787,6 +7845,7 @@ uint8_t *VideoGrab(int *size, int *width, int *height) free(data); *size = *width * *height * 3 + n; +#endif return rgb; } |