diff options
author | Petri Hintukainen <phintuka@users.sourceforge.net> | 2012-06-15 10:25:46 +0300 |
---|---|---|
committer | Petri Hintukainen <phintuka@users.sourceforge.net> | 2012-06-15 10:25:46 +0300 |
commit | 6eca0da170fd8d83bb3b611ea579b27a7c84b12a (patch) | |
tree | dbf0f05630678cad2c6c53aad7733eea5c2f53e0 /src | |
parent | 52732e443424511ffc285b009f999cf00fbfa090 (diff) | |
download | xine-lib-6eca0da170fd8d83bb3b611ea579b27a7c84b12a.tar.gz xine-lib-6eca0da170fd8d83bb3b611ea579b27a7c84b12a.tar.bz2 |
image decoders: crop image if allocated frame is smaller than requested
Diffstat (limited to 'src')
-rw-r--r-- | src/libxinevdec/gdkpixbuf.c | 22 | ||||
-rw-r--r-- | src/libxinevdec/image.c | 20 |
2 files changed, 32 insertions, 10 deletions
diff --git a/src/libxinevdec/gdkpixbuf.c b/src/libxinevdec/gdkpixbuf.c index 8815edabe..7ec2069ea 100644 --- a/src/libxinevdec/gdkpixbuf.c +++ b/src/libxinevdec/gdkpixbuf.c @@ -133,8 +133,24 @@ static void image_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { lprintf("image loaded successfully\n"); /* + * alloc video frame + */ + img = this->stream->video_out->get_frame (this->stream->video_out, width, height, + (double)width / (double)height, + XINE_IMGFMT_YUY2, + VO_BOTH_FIELDS); + + /* crop if allocated frame is smaller than requested */ + if (width > img->width) + width = img->width; + if (height > img->height) + height = img->height; + img->ratio = (double)width / (double)height; + + /* * rgb data -> yuv_planes */ + width &= ~1; /* must be even for init_yuv_planes */ init_yuv_planes(&yuv_planes, width, height); n_channels = gdk_pixbuf_get_n_channels (pixbuf); @@ -155,12 +171,8 @@ static void image_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { gdk_pixbuf_unref (pixbuf); /* - * alloc and draw video frame + * draw video frame */ - img = this->stream->video_out->get_frame (this->stream->video_out, width, - height, (double)width/(double)height, - XINE_IMGFMT_YUY2, - VO_BOTH_FIELDS); img->pts = buf->pts; img->duration = 3600; img->bad_frame = 0; diff --git a/src/libxinevdec/image.c b/src/libxinevdec/image.c index b63cfa265..4a872655e 100644 --- a/src/libxinevdec/image.c +++ b/src/libxinevdec/image.c @@ -153,6 +153,20 @@ static void image_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { lprintf("image loaded successfully\n"); /* + * alloc video frame and set cropping + */ + img = this->stream->video_out->get_frame (this->stream->video_out, width, height, + (double)width / (double)height, + XINE_IMGFMT_YUY2, + VO_BOTH_FIELDS); + + if (width > img->width) + width = img->width; + if (height > img->height) + height = img->height; + img->ratio = (double)width / (double)height; + + /* * rgb data -> yuv_planes */ width &= ~1; /* must be even for init_yuv_planes */ @@ -176,12 +190,8 @@ static void image_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { free(img_buf); /* - * alloc and draw video frame + * draw video frame */ - img = this->stream->video_out->get_frame (this->stream->video_out, width, - height, (double)width/(double)height, - XINE_IMGFMT_YUY2, - VO_BOTH_FIELDS); img->pts = buf->pts; img->duration = 3600; img->bad_frame = 0; |