annotate mp_image.h @ 4373:4f36681c95f8

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