comparison mp_image.h @ 4185:85c90bb8729a

initial stuff. comments welcomed...
author arpi
date Wed, 16 Jan 2002 00:14:59 +0000
parents
children f5c38da17b59
comparison
equal deleted inserted replaced
4184:f648f699eda6 4185:85c90bb8729a
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
16 typedef struct mp_image_s {
17 unsigned short flags;
18 unsigned short bpp;
19 unsigned int imgfmt;
20 int width,height; // stored dimensions
21 int x,y,w,h; // visible dimensions
22 unsigned char* planes[3];
23 unsigned int stride[3];
24 int* qscale;
25 int qstride;
26 } mp_image_t;
27
28 #ifdef IMGFMT_YUY2
29 static inline void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){
30 mpi->flags&=~(MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV|MP_IMGFLAG_SWAPPED);
31 mpi->out_fmt=out_fmt;
32 if( (out_fmt&IMGFMT_RGB_MASK) == IMGFMT_RGB ){
33 mpi->bpp=out_fmt&255;
34 return;
35 }
36 if( (out_fmt&IMGFMT_BGR_MASK) == IMGFMT_BGR ){
37 mpi->bpp=out_fmt&255;
38 mpi->flags|=MP_IMGFLAG_SWAPPED;
39 return;
40 }
41 mpi->flags|=MP_IMGFLAG_YUV;
42 switch(out_fmt){
43 case IMGFMT_I420:
44 case IMGFMT_IYUV:
45 mpi->flags|=MP_IMGFLAG_SWAPPED;
46 case IMGFMT_YV12:
47 mpi->flags|=MP_IMGFLAG_PLANAR;
48 mpi->bpp=12;
49 return;
50 case IMGFMT_UYVY:
51 mpi->flags|=MP_IMGFLAG_SWAPPED;
52 case IMGFMT_YUY2:
53 mpi->bpp=16;
54 return;
55 }
56 printf("mp_image: Unknown out_fmt: 0x%X\n",out_fmt);
57 mpi->bpp=0;
58 }
59 #endif
60
61 static inline mp_image_t* new_mp_image(int w,int h){
62 mp_image_t* mpi=malloc(sizeof(mp_image_t));
63 if(!mpi) return NULL; // error!
64 memset(mpi,0,sizeof(mp_image_t));
65 mpi->width=mpi->w=w;
66 mpi->height=mpi->h=h;
67 return mpi;
68 }