diff options
author | Rudolf Polzer <divverent@xonotic.org> | 2012-10-24 19:05:49 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-24 21:56:15 +0200 |
commit | 1282f9d79e09160af67ec13c05c0eed1ae02bd46 (patch) | |
tree | dcba92d684a8d689eecc5ba0592e0f5b56bc341b /libmpcodecs/mp_image.h | |
parent | 64ac38c4d30e30783032a4b65f34f4fb50761c7b (diff) | |
download | mpv-1282f9d79e09160af67ec13c05c0eed1ae02bd46.tar.bz2 mpv-1282f9d79e09160af67ec13c05c0eed1ae02bd46.tar.xz |
mp_image: fix copy_mpi() with 16 bit formats, add helper macros
Merged by wm4.
copy_mpi() assumed that planar YUV formats always used 1 byte per
component, which is not true for 9/10/16 bit YUV formats.
Diffstat (limited to 'libmpcodecs/mp_image.h')
-rw-r--r-- | libmpcodecs/mp_image.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libmpcodecs/mp_image.h b/libmpcodecs/mp_image.h index 6dbe3bfe02..e1cbe7d2cf 100644 --- a/libmpcodecs/mp_image.h +++ b/libmpcodecs/mp_image.h @@ -130,4 +130,14 @@ mp_image_t* alloc_mpi(int w, int h, unsigned long int fmt); void mp_image_alloc_planes(mp_image_t *mpi); void copy_mpi(mp_image_t *dmpi, mp_image_t *mpi); +// this macro requires img_format.h to be included too: +#define MP_IMAGE_PLANAR_BITS_PER_PIXEL_ON_PLANE(mpi, p) \ + (IMGFMT_IS_YUVP16((mpi)->imgfmt) ? 16 : 8) +#define MP_IMAGE_BITS_PER_PIXEL_ON_PLANE(mpi, p) \ + (((mpi)->flags & MP_IMGFLAG_PLANAR) \ + ? MP_IMAGE_PLANAR_BITS_PER_PIXEL_ON_PLANE(mpi, p) \ + : (mpi)->bpp) +#define MP_IMAGE_BYTES_PER_ROW_ON_PLANE(mpi, p) \ + ((MP_IMAGE_BITS_PER_PIXEL_ON_PLANE(mpi, p) * ((mpi)->w >> (p ? mpi->chroma_x_shift : 0)) + 7) / 8) + #endif /* MPLAYER_MP_IMAGE_H */ |