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:
wm4 2012-10-17 13:46:46 +02:00
parent f6197249a7
commit 73f18ace91
1 changed files with 19 additions and 0 deletions

View File

@ -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+