summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohns <johns98@gmx.net>2012-01-23 20:04:15 +0100
committerJohns <johns98@gmx.net>2012-01-23 20:04:15 +0100
commit5f43803236e9ce08dba301bbdea67fb88c208950 (patch)
treeebce861b8847f0127f8d9367a617e387e265a52d
parent993d831190cce6d8582300f74a2ce3acedc40b20 (diff)
downloadvdr-plugin-softhddevice-5f43803236e9ce08dba301bbdea67fb88c208950.tar.gz
vdr-plugin-softhddevice-5f43803236e9ce08dba301bbdea67fb88c208950.tar.bz2
VDPAU: Add primitive software scaler to grab image
-rw-r--r--ChangeLog1
-rw-r--r--Todo3
-rw-r--r--softhddev.c3
-rw-r--r--video.c61
4 files changed, 65 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 1a13d6a..74809b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/Todo b/Todo
index f9ad9ad..6aaacc4 100644
--- a/Todo
+++ b/Todo
@@ -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);
}
diff --git a/video.c b/video.c
index 01c1b09..19753b5 100644
--- a/video.c
+++ b/video.c
@@ -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;
}