diff --git a/video/mp_image.c b/video/mp_image.c index 25b84641a7..7cfceca1c2 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -33,23 +33,6 @@ #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+ @@ -95,8 +78,11 @@ void mp_image_alloc_planes(mp_image_t *mpi) { mp_image_t* alloc_mpi(int w, int h, unsigned long int fmt) { mp_image_t* mpi = new_mp_image(w,h); + mpi->width=FFALIGN(w, MP_STRIDE_ALIGNMENT); mp_image_setfmt(mpi,fmt); mp_image_alloc_planes(mpi); + mpi->width=w; + mp_image_setfmt(mpi,fmt); // reset chroma size return mpi; } diff --git a/video/mp_image.h b/video/mp_image.h index 8ce0b98edc..d2c7d38f50 100644 --- a/video/mp_image.h +++ b/video/mp_image.h @@ -26,6 +26,9 @@ #include "core/mp_msg.h" #include "csputils.h" +// Minimum stride alignment in pixels +#define MP_STRIDE_ALIGNMENT 32 + //--------- codec's requirements (filled by the codec/vf) --------- //--- buffer content restrictions: