diff options
author | Petri Hintukainen <phintuka@users.sourceforge.net> | 2012-06-15 10:22:46 +0300 |
---|---|---|
committer | Petri Hintukainen <phintuka@users.sourceforge.net> | 2012-06-15 10:22:46 +0300 |
commit | 52732e443424511ffc285b009f999cf00fbfa090 (patch) | |
tree | 7dcf55175b9202a068ff466b76f7cea47f04bea9 /src | |
parent | dc4e6262caacbdb7c36b82ba28b0157d00e466f1 (diff) | |
download | xine-lib-52732e443424511ffc285b009f999cf00fbfa090.tar.gz xine-lib-52732e443424511ffc285b009f999cf00fbfa090.tar.bz2 |
image: fix decoding images with odd width
Diffstat (limited to 'src')
-rw-r--r-- | src/libxinevdec/image.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libxinevdec/image.c b/src/libxinevdec/image.c index 5e166382b..b63cfa265 100644 --- a/src/libxinevdec/image.c +++ b/src/libxinevdec/image.c @@ -102,7 +102,7 @@ static void image_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { this->index += buf->size; if (buf->decoder_flags & BUF_FLAG_FRAME_END) { - int width, height, i; + int width, height, i, x, y, img_stride; int status; MagickWand *wand; uint8_t *img_buf, *img_buf_ptr; @@ -133,9 +133,10 @@ static void image_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { return; } - width = MagickGetImageWidth(wand) & ~1; /* must be even for init_yuv_planes */ + width = MagickGetImageWidth(wand); height = MagickGetImageHeight(wand); img_buf = malloc(width * height * 3); + img_stride = 3 * width; #if MAGICK_VERSION < 0x671 MagickGetImagePixels(wand, 0, 0, width, height, "RGB", CharPixel, img_buf); DestroyMagickWand(wand); @@ -154,10 +155,13 @@ static void image_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { /* * rgb data -> yuv_planes */ + width &= ~1; /* must be even for init_yuv_planes */ init_yuv_planes(&yuv_planes, width, height); img_buf_ptr = img_buf; - for (i=0; i < width*height; i++) { + i = 0; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { uint8_t r = *(img_buf_ptr++); uint8_t g = *(img_buf_ptr++); uint8_t b = *(img_buf_ptr++); @@ -165,6 +169,9 @@ static void image_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { yuv_planes.y[i] = COMPUTE_Y(r, g, b); yuv_planes.u[i] = COMPUTE_U(r, g, b); yuv_planes.v[i] = COMPUTE_V(r, g, b); + i++; + } + img_buf_ptr += img_stride - 3 * width; } free(img_buf); |