4185
|
1
|
|
2 // set if it's internal buffer of the codec, and shouldn't be modified:
|
|
3 #define MP_IMGFLAG_READONLY 0x01
|
|
4 // set if buffer is allocated (used in destination images):
|
|
5 #define MP_IMGFLAG_ALLOCATED 0x02
|
|
6 // set if it's in video buffer/memory:
|
|
7 #define MP_IMGFLAG_DIRECT 0x04
|
|
8
|
|
9 // set if number of planes > 1
|
|
10 #define MP_IMGFLAG_PLANAR 0x10
|
|
11 // set if it's YUV colorspace
|
|
12 #define MP_IMGFLAG_YUV 0x20
|
|
13 // set if it's swapped plane/byteorder
|
|
14 #define MP_IMGFLAG_SWAPPED 0x40
|
|
15
|
4186
|
16 #define MP_IMGTYPE_EXPORT 0
|
|
17 #define MP_IMGTYPE_STATIC 1
|
|
18 #define MP_IMGTYPE_TEMP 2
|
|
19
|
4185
|
20 typedef struct mp_image_s {
|
|
21 unsigned short flags;
|
4186
|
22 unsigned char type;
|
|
23 unsigned char bpp; // bits/pixel. NOT depth! for RGB it will be n*8
|
4185
|
24 unsigned int imgfmt;
|
|
25 int width,height; // stored dimensions
|
|
26 int x,y,w,h; // visible dimensions
|
|
27 unsigned char* planes[3];
|
|
28 unsigned int stride[3];
|
|
29 int* qscale;
|
|
30 int qstride;
|
|
31 } mp_image_t;
|
|
32
|
|
33 #ifdef IMGFMT_YUY2
|
|
34 static inline void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){
|
|
35 mpi->flags&=~(MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV|MP_IMGFLAG_SWAPPED);
|
4187
|
36 mpi->imgfmt=out_fmt;
|
4185
|
37 if( (out_fmt&IMGFMT_RGB_MASK) == IMGFMT_RGB ){
|
4186
|
38 mpi->bpp=((out_fmt&255)+7)&(~7);
|
4185
|
39 return;
|
|
40 }
|
|
41 if( (out_fmt&IMGFMT_BGR_MASK) == IMGFMT_BGR ){
|
4186
|
42 mpi->bpp=((out_fmt&255)+7)&(~7);
|
4185
|
43 mpi->flags|=MP_IMGFLAG_SWAPPED;
|
|
44 return;
|
|
45 }
|
|
46 mpi->flags|=MP_IMGFLAG_YUV;
|
|
47 switch(out_fmt){
|
|
48 case IMGFMT_I420:
|
|
49 case IMGFMT_IYUV:
|
|
50 mpi->flags|=MP_IMGFLAG_SWAPPED;
|
|
51 case IMGFMT_YV12:
|
|
52 mpi->flags|=MP_IMGFLAG_PLANAR;
|
|
53 mpi->bpp=12;
|
|
54 return;
|
|
55 case IMGFMT_UYVY:
|
|
56 mpi->flags|=MP_IMGFLAG_SWAPPED;
|
|
57 case IMGFMT_YUY2:
|
|
58 mpi->bpp=16;
|
|
59 return;
|
|
60 }
|
|
61 printf("mp_image: Unknown out_fmt: 0x%X\n",out_fmt);
|
|
62 mpi->bpp=0;
|
|
63 }
|
|
64 #endif
|
|
65
|
|
66 static inline mp_image_t* new_mp_image(int w,int h){
|
|
67 mp_image_t* mpi=malloc(sizeof(mp_image_t));
|
|
68 if(!mpi) return NULL; // error!
|
|
69 memset(mpi,0,sizeof(mp_image_t));
|
|
70 mpi->width=mpi->w=w;
|
|
71 mpi->height=mpi->h=h;
|
|
72 return mpi;
|
|
73 }
|