mirror of https://github.com/mpv-player/mpv
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.)
This commit is contained in:
parent
f6197249a7
commit
73f18ace91
|
@ -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+
|
||||
|
|
Loading…
Reference in New Issue