diff options
author | Søren Sandmann Pedersen <sandmann@redhat.com> | 2009-06-04 05:11:12 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <sandmann@redhat.com> | 2009-06-19 13:21:28 -0400 |
commit | 55c4b9d8a7e11ba8cba35c8b036b23d9027dab88 (patch) | |
tree | 805c2d697b4a11090bd41ff2cd61638e9bab242d | |
parent | 7d77f7a68ddccec1bb128c10bf516149e904997a (diff) |
Fix prepare_access() and finish_access() for yv12 images.
The yv12 format consists of height lines of Y data followed by height
more lines of U and V data.
-rw-r--r-- | pixman/pixman-utils.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c index 48a1aafe..54f52467 100644 --- a/pixman/pixman-utils.c +++ b/pixman/pixman-utils.c @@ -855,6 +855,7 @@ prepare_access (pixman_image_t *img) { uint32_t *copy; size_t i; + int height; if (!img) return TRUE; @@ -864,13 +865,24 @@ prepare_access (pixman_image_t *img) if (!img->bits.read_func) return TRUE; + + if (img->bits.orig_data) + return TRUE; + + height = img->bits.height; + + /* yv12 is height rows of Y data followed by height + * more rows of U and V data + */ + if (img->bits.format == PIXMAN_yv12) + height *= 2; - copy = pixman_malloc_abc (img->bits.height, img->bits.rowstride, sizeof (uint32_t)); + copy = pixman_malloc_abc (height, img->bits.rowstride, sizeof (uint32_t)); if (!copy) return FALSE; - for (i = 0; i < img->bits.rowstride * img->bits.height; ++i) + for (i = 0; i < img->bits.rowstride * height; ++i) copy[i] = img->bits.read_func (img->bits.bits + i, sizeof (uint32_t *)); img->bits.orig_data = img->bits.bits; @@ -882,8 +894,9 @@ prepare_access (pixman_image_t *img) static void finish_access (pixman_image_t *img) { - int i; uint32_t *orig; + size_t i; + int height; if (!img) return; @@ -896,7 +909,15 @@ finish_access (pixman_image_t *img) orig = img->bits.orig_data; - for (i = 0; i < img->bits.rowstride * img->bits.height; ++i) + height = img->bits.height; + + /* yv12 is height rows of Y data followed by height + * more rows of U and V data + */ + if (img->bits.format == PIXMAN_yv12) + height *= 2; + + for (i = 0; i < img->bits.rowstride * height; ++i) img->bits.write_func (orig + i, img->bits.bits[i], sizeof (uint32_t *)); free (img->bits.bits); |