diff options
author | wm4 <wm4@nowhere> | 2012-10-17 13:46:46 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-24 21:56:33 +0200 |
commit | 73f18ace91fb040f7016df28e66ebe5ce7177e66 (patch) | |
tree | 10fa05120a6e316517028543686e3bdb1e97a0b2 | |
parent | f6197249a783f00ae583e67d113ed737d677f12c (diff) | |
download | mpv-73f18ace91fb040f7016df28e66ebe5ce7177e66.tar.bz2 mpv-73f18ace91fb040f7016df28e66ebe5ce7177e66.tar.xz |
mp_image: hack to fix alignment for certain image formats
This is to get rid of swscale alignment warnings with the new OSD code.
Only image formats used by it are fixed.
Solving this generally would require some more effort. (Possibly by
using libav's allocation functions plus lots of testing.)
-rw-r--r-- | libmpcodecs/mp_image.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libmpcodecs/mp_image.c b/libmpcodecs/mp_image.c index 28472d092c..1ba9e8e753 100644 --- a/libmpcodecs/mp_image.c +++ b/libmpcodecs/mp_image.c @@ -26,11 +26,30 @@ #include "libmpcodecs/img_format.h" #include "libmpcodecs/mp_image.h" +#include "libmpcodecs/sws_utils.h" #include "libvo/fastmemcpy.h" #include "libavutil/mem.h" +#include "libavutil/common.h" void mp_image_alloc_planes(mp_image_t *mpi) { + if (mpi->imgfmt == IMGFMT_BGRA) { + mpi->stride[0]=FFALIGN(mpi->width*4,SWS_MIN_BYTE_ALIGN); + mpi->planes[0]=av_malloc(mpi->stride[0]*mpi->height); + mpi->flags|=MP_IMGFLAG_ALLOCATED; + return; + } + if (mpi->imgfmt == IMGFMT_444P16 || mpi->imgfmt == IMGFMT_444P) { + int bp = mpi->imgfmt == IMGFMT_444P16 ? 2 : 1; + mpi->stride[0]=FFALIGN(mpi->width*bp,SWS_MIN_BYTE_ALIGN); + mpi->stride[1]=mpi->stride[2]=mpi->stride[0]; + int imgsize = mpi->stride[0] * mpi->height; + mpi->planes[0]=av_malloc(imgsize*3); + mpi->planes[1]=mpi->planes[0]+imgsize; + mpi->planes[2]=mpi->planes[1]+imgsize; + mpi->flags|=MP_IMGFLAG_ALLOCATED; + return; + } // IF09 - allocate space for 4. plane delta info - unused if (mpi->imgfmt == IMGFMT_IF09) { mpi->planes[0]=av_malloc(mpi->bpp*mpi->width*(mpi->height+2)/8+ |