diff options
author | hans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain> | 2009-04-14 23:11:39 +0200 |
---|---|---|
committer | hans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain> | 2009-04-14 23:11:39 +0200 |
commit | 18d8f58054d630d7f1c80f5586aaa7331d4f46e7 (patch) | |
tree | 9fd36fd08fba9e518d8bd8006acef79da83a5d31 /v4l2-apps/libv4l/libv4lconvert | |
parent | 67f9c69681d56764910ae950b367bc99dfc51d4f (diff) | |
download | mediapointer-dvb-s2-18d8f58054d630d7f1c80f5586aaa7331d4f46e7.tar.gz mediapointer-dvb-s2-18d8f58054d630d7f1c80f5586aaa7331d4f46e7.tar.bz2 |
libv4l: crop widths to the nearest multiple of 8 when converting to YUV420
From: Hans de Goede <hdegoede@redhat.com>
Some applications / libs (*cough* gstreamer *cough*) will not work
correctly with planar YUV formats when the width is not a multiple of 8,
so crop widths which are not a multiple of 8 to the nearest multiple of 8
when converting to planar YUV
Priority: normal
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'v4l2-apps/libv4l/libv4lconvert')
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c index 2e029a81c..39e9d8669 100644 --- a/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c +++ b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c @@ -398,6 +398,21 @@ int v4lconvert_try_format(struct v4lconvert_data *data, } } + /* Some applications / libs (*cough* gstreamer *cough*) will not work + correctly with planar YUV formats when the width is not a multiple of 8 + or the height is not a multiple of 2 */ + if (try_dest.fmt.pix.pixelformat == V4L2_PIX_FMT_YUV420 || + try_dest.fmt.pix.pixelformat == V4L2_PIX_FMT_YVU420) { + try_dest.fmt.pix.width &= ~7; + try_dest.fmt.pix.height &= ~1; + } + + /* Likewise the width needs to be a multiple of 4 for RGB formats + (although I've never seen a device with a width not a multiple of 4) */ + if (try_dest.fmt.pix.pixelformat == V4L2_PIX_FMT_RGB24 || + try_dest.fmt.pix.pixelformat == V4L2_PIX_FMT_BGR24) + try_dest.fmt.pix.width &= ~3; + /* Are we converting? */ if(try_src.fmt.pix.width != try_dest.fmt.pix.width || try_src.fmt.pix.height != try_dest.fmt.pix.height || @@ -1083,6 +1098,13 @@ int v4lconvert_enum_framesizes(struct v4lconvert_data *data, switch(frmsize->type) { case V4L2_FRMSIZE_TYPE_DISCRETE: frmsize->discrete = data->framesizes[frmsize->index].discrete; + /* Apply the same rounding algorithm as v4lconvert_try_format */ + if (frmsize->pixel_format == V4L2_PIX_FMT_YUV420 || + frmsize->pixel_format == V4L2_PIX_FMT_YVU420) { + frmsize->discrete.width &= ~7; + frmsize->discrete.height &= ~1; + } else + frmsize->discrete.width &= ~3; break; case V4L2_FRMSIZE_TYPE_CONTINUOUS: case V4L2_FRMSIZE_TYPE_STEPWISE: |