annotate libmpcodecs/mp_image.h @ 5694:8031d86f1839

fixes, updates
author arpi
date Fri, 19 Apr 2002 01:08:00 +0000
parents 25882b51e65f
children de47aebf654c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4933
429994672d8c 're-include' possibility
nick
parents: 4877
diff changeset
1 #ifndef __MP_IMAGE_H
429994672d8c 're-include' possibility
nick
parents: 4877
diff changeset
2 #define __MP_IMAGE_H 1
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
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
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
6 // set if buffer content will be READED for next frame's MC: (I/P mpeg frames)
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
7 #define MP_IMGFLAG_READABLE 0x02
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
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
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
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
993f274191ff ACCEPT_WIDTH flag added
arpi
parents: 4933
diff changeset
14 // codec accept any width (width*bpp=stride) (>=width):
993f274191ff ACCEPT_WIDTH flag added
arpi
parents: 4933
diff changeset
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
993f274191ff ACCEPT_WIDTH flag added
arpi
parents: 4933
diff changeset
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
993f274191ff ACCEPT_WIDTH flag added
arpi
parents: 4933
diff changeset
19 #define MP_IMGFLAG_DRAW_CALLBACK 0x80
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
20
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
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
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
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
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
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
643da7f45219 MP_IMGFLAG_TYPE_DISPLAYED added
arpi
parents: 4962
diff changeset
27 // type displayed (do not set this flag - it's for internal use!)
643da7f45219 MP_IMGFLAG_TYPE_DISPLAYED added
arpi
parents: 4962
diff changeset
28 #define MP_IMGFLAG_TYPE_DISPLAYED 0x800
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
29
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
30 // 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
31 // allocation. so we just export its buffer pointers:
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
32 #define MP_IMGTYPE_EXPORT 0
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
33 // codec requires a static WO buffer, but it does only partial updates later:
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
34 #define MP_IMGTYPE_STATIC 1
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
35 // codec just needs some WO memory, where it writes/copies the whole frame to:
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
36 #define MP_IMGTYPE_TEMP 2
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
37 // I+P type, requires 2+ independent static R/W buffers
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
38 #define MP_IMGTYPE_IP 3
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
39 // 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
40 #define MP_IMGTYPE_IPB 4
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
41
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
42 typedef struct mp_image_s {
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
43 unsigned short flags;
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
44 unsigned char type;
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
45 unsigned char bpp; // bits/pixel. NOT depth! for RGB it will be n*8
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
46 unsigned int imgfmt;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
47 int width,height; // stored dimensions
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
48 int x,y,w,h; // visible dimensions
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
49 unsigned char* planes[3];
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
50 unsigned int stride[3];
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
51 int* qscale;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
52 int qstride;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
53 } mp_image_t;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
54
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
55 #ifdef IMGFMT_YUY2
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
56 static inline void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
57 mpi->flags&=~(MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV|MP_IMGFLAG_SWAPPED);
4187
arpi
parents: 4186
diff changeset
58 mpi->imgfmt=out_fmt;
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
59 if( (out_fmt&IMGFMT_RGB_MASK) == IMGFMT_RGB ){
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
60 mpi->bpp=((out_fmt&255)+7)&(~7);
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
61 return;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
62 }
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
63 if( (out_fmt&IMGFMT_BGR_MASK) == IMGFMT_BGR ){
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
64 mpi->bpp=((out_fmt&255)+7)&(~7);
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
65 mpi->flags|=MP_IMGFLAG_SWAPPED;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
66 return;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
67 }
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
68 mpi->flags|=MP_IMGFLAG_YUV;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
69 switch(out_fmt){
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
70 case IMGFMT_I420:
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
71 case IMGFMT_IYUV:
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
72 mpi->flags|=MP_IMGFLAG_SWAPPED;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
73 case IMGFMT_YV12:
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
74 mpi->flags|=MP_IMGFLAG_PLANAR;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
75 mpi->bpp=12;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
76 return;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
77 case IMGFMT_UYVY:
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
78 mpi->flags|=MP_IMGFLAG_SWAPPED;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
79 case IMGFMT_YUY2:
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
80 mpi->bpp=16;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
81 return;
5144
9651a7bb874d accept IMGFMT_MPEGPES
arpi
parents: 4972
diff changeset
82 case IMGFMT_MPEGPES:
9651a7bb874d accept IMGFMT_MPEGPES
arpi
parents: 4972
diff changeset
83 mpi->bpp=0;
9651a7bb874d accept IMGFMT_MPEGPES
arpi
parents: 4972
diff changeset
84 return;
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
85 }
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
86 printf("mp_image: Unknown out_fmt: 0x%X\n",out_fmt);
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
87 mpi->bpp=0;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
88 }
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
89 #endif
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
90
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
91 static inline mp_image_t* new_mp_image(int w,int h){
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
92 mp_image_t* mpi=malloc(sizeof(mp_image_t));
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
93 if(!mpi) return NULL; // error!
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
94 memset(mpi,0,sizeof(mp_image_t));
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
95 mpi->width=mpi->w=w;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
96 mpi->height=mpi->h=h;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
97 return mpi;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
98 }
4933
429994672d8c 're-include' possibility
nick
parents: 4877
diff changeset
99
429994672d8c 're-include' possibility
nick
parents: 4877
diff changeset
100 #endif