Mercurial > mplayer.hg
annotate libmpcodecs/mp_image.h @ 6858:21186a5514b4
initial window size (-xy) fixed - patch by Kazunori Ueno <jagarl@creator.club.ne.jp>
author | arpi |
---|---|
date | Wed, 31 Jul 2002 19:40:33 +0000 |
parents | 415be01747ae |
children | 713182435a76 |
rev | line source |
---|---|
4933 | 1 #ifndef __MP_IMAGE_H |
2 #define __MP_IMAGE_H 1 | |
4185 | 3 |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
4 // set if buffer content shouldn't be modified: |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
5 #define MP_IMGFLAG_PRESERVE 0x01 |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
6 // set if buffer content will be READ for next frame's MC: (I/P mpeg frames) |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
7 #define MP_IMGFLAG_READABLE 0x02 |
4185 | 8 // set if buffer is allocated (used in destination images): |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
9 #define MP_IMGFLAG_ALLOCATED 0x04 |
4185 | 10 // set if it's in video buffer/memory: |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
11 #define MP_IMGFLAG_DIRECT 0x08 |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
12 // codec accept any stride (>=width): |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
13 #define MP_IMGFLAG_ACCEPT_STRIDE 0x10 |
4962 | 14 // codec accept any width (width*bpp=stride) (>=width): |
15 #define MP_IMGFLAG_ACCEPT_WIDTH 0x20 | |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
16 // stride should be aligned to 16-byte (MB) boundary: |
4962 | 17 #define MP_IMGFLAG_ALIGNED_STRIDE 0x40 |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
18 // codec uses drawing/rendering callbacks (draw_slice()-like thing, DR method 2) |
4962 | 19 #define MP_IMGFLAG_DRAW_CALLBACK 0x80 |
4185 | 20 |
21 // set if number of planes > 1 | |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
22 #define MP_IMGFLAG_PLANAR 0x100 |
4185 | 23 // set if it's YUV colorspace |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
24 #define MP_IMGFLAG_YUV 0x200 |
4185 | 25 // set if it's swapped plane/byteorder |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
26 #define MP_IMGFLAG_SWAPPED 0x400 |
4972 | 27 // type displayed (do not set this flag - it's for internal use!) |
28 #define MP_IMGFLAG_TYPE_DISPLAYED 0x800 | |
6478 | 29 // using palette for RGB data |
30 #define MP_IMGFLAG_TYPE_RGB_PALETTE 0x1000 | |
4185 | 31 |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
32 // codec doesn't support any form of direct rendering - it has own buffer |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
33 // allocation. so we just export its buffer pointers: |
4186 | 34 #define MP_IMGTYPE_EXPORT 0 |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
35 // codec requires a static WO buffer, but it does only partial updates later: |
4186 | 36 #define MP_IMGTYPE_STATIC 1 |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
37 // codec just needs some WO memory, where it writes/copies the whole frame to: |
4186 | 38 #define MP_IMGTYPE_TEMP 2 |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
39 // I+P type, requires 2+ independent static R/W buffers |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
40 #define MP_IMGTYPE_IP 3 |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
41 // I+P+B type, requires 2+ independent static R/W and 1+ temp WO buffers |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
42 #define MP_IMGTYPE_IPB 4 |
4186 | 43 |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
44 #define MP_MAX_PLANES 4 |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
45 |
4185 | 46 typedef struct mp_image_s { |
47 unsigned short flags; | |
4186 | 48 unsigned char type; |
49 unsigned char bpp; // bits/pixel. NOT depth! for RGB it will be n*8 | |
4185 | 50 unsigned int imgfmt; |
51 int width,height; // stored dimensions | |
52 int x,y,w,h; // visible dimensions | |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
53 unsigned char* planes[MP_MAX_PLANES]; |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
54 unsigned int stride[MP_MAX_PLANES]; |
4185 | 55 int* qscale; |
56 int qstride; | |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
57 int num_planes; |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
58 /* these are only used by planar formats Y,U(Cb),V(Cr) */ |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
59 int chroma_width; |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
60 int chroma_height; |
6539
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6538
diff
changeset
|
61 int chroma_x_shift; // horizontal |
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6538
diff
changeset
|
62 int chroma_y_shift; // vertical |
6759
415be01747ae
added 'priv' field to mpi - requires for tracking frames with different
arpi
parents:
6707
diff
changeset
|
63 /* for private use by filter or vo driver (to store buffer id or dmpi) */ |
415be01747ae
added 'priv' field to mpi - requires for tracking frames with different
arpi
parents:
6707
diff
changeset
|
64 void* priv; |
4185 | 65 } mp_image_t; |
66 | |
67 #ifdef IMGFMT_YUY2 | |
68 static inline void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ | |
69 mpi->flags&=~(MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV|MP_IMGFLAG_SWAPPED); | |
4187 | 70 mpi->imgfmt=out_fmt; |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
71 if(out_fmt == IMGFMT_MPEGPES){ |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
72 mpi->bpp=0; |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
73 return; |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
74 } |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
75 mpi->num_planes=1; |
6707 | 76 if (IMGFMT_IS_RGB(out_fmt)) { |
77 if (IMGFMT_RGB_DEPTH(out_fmt) < 8) | |
78 mpi->bpp = IMGFMT_RGB_DEPTH(out_fmt); | |
79 else | |
80 mpi->bpp=(IMGFMT_RGB_DEPTH(out_fmt)+7)&(~7); | |
4185 | 81 return; |
82 } | |
6707 | 83 if (IMGFMT_IS_BGR(out_fmt)) { |
84 if (IMGFMT_BGR_DEPTH(out_fmt) < 8) | |
85 mpi->bpp = IMGFMT_BGR_DEPTH(out_fmt); | |
86 else | |
87 mpi->bpp=(IMGFMT_BGR_DEPTH(out_fmt)+7)&(~7); | |
4185 | 88 mpi->flags|=MP_IMGFLAG_SWAPPED; |
89 return; | |
90 } | |
91 mpi->flags|=MP_IMGFLAG_YUV; | |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
92 mpi->num_planes=3; |
4185 | 93 switch(out_fmt){ |
94 case IMGFMT_I420: | |
95 case IMGFMT_IYUV: | |
96 mpi->flags|=MP_IMGFLAG_SWAPPED; | |
97 case IMGFMT_YV12: | |
98 mpi->flags|=MP_IMGFLAG_PLANAR; | |
99 mpi->bpp=12; | |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
100 mpi->chroma_width=(mpi->width>>1); |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
101 mpi->chroma_height=(mpi->height>>1); |
6539
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6538
diff
changeset
|
102 mpi->chroma_x_shift=1; |
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6538
diff
changeset
|
103 mpi->chroma_y_shift=1; |
4185 | 104 return; |
6525 | 105 case IMGFMT_IF09: |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
106 mpi->num_planes=4; |
6478 | 107 case IMGFMT_YVU9: |
108 mpi->flags|=MP_IMGFLAG_PLANAR; | |
109 mpi->bpp=9; | |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
110 mpi->chroma_width=(mpi->width>>2); |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
111 mpi->chroma_height=(mpi->height>>2); |
6539
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6538
diff
changeset
|
112 mpi->chroma_x_shift=2; |
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6538
diff
changeset
|
113 mpi->chroma_y_shift=2; |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
114 return; |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
115 case IMGFMT_Y800: |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
116 case IMGFMT_Y8: |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
117 /* they're planar ones, but for easier handling use them as packed */ |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
118 // mpi->flags|=MP_IMGFLAG_PLANAR; |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
119 mpi->bpp=8; |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
120 mpi->num_planes=1; |
6478 | 121 return; |
4185 | 122 case IMGFMT_UYVY: |
123 mpi->flags|=MP_IMGFLAG_SWAPPED; | |
124 case IMGFMT_YUY2: | |
125 mpi->bpp=16; | |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
126 mpi->num_planes=1; |
5144 | 127 return; |
4185 | 128 } |
129 printf("mp_image: Unknown out_fmt: 0x%X\n",out_fmt); | |
130 mpi->bpp=0; | |
131 } | |
132 #endif | |
133 | |
134 static inline mp_image_t* new_mp_image(int w,int h){ | |
135 mp_image_t* mpi=malloc(sizeof(mp_image_t)); | |
136 if(!mpi) return NULL; // error! | |
137 memset(mpi,0,sizeof(mp_image_t)); | |
138 mpi->width=mpi->w=w; | |
139 mpi->height=mpi->h=h; | |
140 return mpi; | |
141 } | |
4933 | 142 |
5737 | 143 static inline void free_mp_image(mp_image_t* mpi){ |
144 if(!mpi) return; | |
145 if(mpi->flags&MP_IMGFLAG_ALLOCATED){ | |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
146 /* becouse we allocate the whole image in once */ |
5737 | 147 if(mpi->planes[0]) free(mpi->planes[0]); |
148 } | |
149 free(mpi); | |
150 } | |
151 | |
4933 | 152 #endif |