Use proper length specifiers in mp_msg calls, fixes the warnings:
[mplayer/greg.git] / libmpcodecs / mp_image.c
blob809acce2210b79fd04ea16291169fce04771c6f0
2 #include "config.h"
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
8 #ifdef HAVE_MALLOC_H
9 #include <malloc.h>
10 #endif
12 #include "libmpcodecs/img_format.h"
13 #include "libmpcodecs/mp_image.h"
15 #include "libvo/fastmemcpy.h"
17 mp_image_t* alloc_mpi(int w, int h, unsigned long int fmt) {
18 mp_image_t* mpi = new_mp_image(w,h);
20 mp_image_setfmt(mpi,fmt);
21 // IF09 - allocate space for 4. plane delta info - unused
22 if (mpi->imgfmt == IMGFMT_IF09)
24 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+
25 mpi->chroma_width*mpi->chroma_height);
26 /* delta table, just for fun ;) */
27 mpi->planes[3]=mpi->planes[0]+2*(mpi->chroma_width*mpi->chroma_height);
29 else
30 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8);
31 if(mpi->flags&MP_IMGFLAG_PLANAR){
32 // YV12/I420/YVU9/IF09. feel free to add other planar formats here...
33 if(!mpi->stride[0]) mpi->stride[0]=mpi->width;
34 if(!mpi->stride[1]) mpi->stride[1]=mpi->stride[2]=mpi->chroma_width;
35 if(mpi->flags&MP_IMGFLAG_SWAPPED){
36 // I420/IYUV (Y,U,V)
37 mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height;
38 mpi->planes[2]=mpi->planes[1]+mpi->chroma_width*mpi->chroma_height;
39 } else {
40 // YV12,YVU9,IF09 (Y,V,U)
41 mpi->planes[2]=mpi->planes[0]+mpi->width*mpi->height;
42 mpi->planes[1]=mpi->planes[2]+mpi->chroma_width*mpi->chroma_height;
44 } else {
45 if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8;
47 mpi->flags|=MP_IMGFLAG_ALLOCATED;
49 return mpi;
52 void copy_mpi(mp_image_t *dmpi, mp_image_t *mpi) {
53 if(mpi->flags&MP_IMGFLAG_PLANAR){
54 memcpy_pic(dmpi->planes[0],mpi->planes[0], mpi->w, mpi->h,
55 dmpi->stride[0],mpi->stride[0]);
56 memcpy_pic(dmpi->planes[1],mpi->planes[1], mpi->chroma_width, mpi->chroma_height,
57 dmpi->stride[1],mpi->stride[1]);
58 memcpy_pic(dmpi->planes[2], mpi->planes[2], mpi->chroma_width, mpi->chroma_height,
59 dmpi->stride[2],mpi->stride[2]);
60 } else {
61 memcpy_pic(dmpi->planes[0],mpi->planes[0],
62 mpi->w*(dmpi->bpp/8), mpi->h,
63 dmpi->stride[0],mpi->stride[0]);