comparison libmpcodecs/mp_image.h @ 5609:25882b51e65f

mp_image moved to libmpcodecs
author arpi
date Sat, 13 Apr 2002 19:17:34 +0000
parents mp_image.h@9651a7bb874d
children de47aebf654c
comparison
equal deleted inserted replaced
5608:6f21be35b6cd 5609:25882b51e65f
1 #ifndef __MP_IMAGE_H
2 #define __MP_IMAGE_H 1
3
4 // set if buffer content shouldn't be modified:
5 #define MP_IMGFLAG_PRESERVE 0x01
6 // set if buffer content will be READED for next frame's MC: (I/P mpeg frames)
7 #define MP_IMGFLAG_READABLE 0x02
8 // set if buffer is allocated (used in destination images):
9 #define MP_IMGFLAG_ALLOCATED 0x04
10 // set if it's in video buffer/memory:
11 #define MP_IMGFLAG_DIRECT 0x08
12 // codec accept any stride (>=width):
13 #define MP_IMGFLAG_ACCEPT_STRIDE 0x10
14 // codec accept any width (width*bpp=stride) (>=width):
15 #define MP_IMGFLAG_ACCEPT_WIDTH 0x20
16 // stride should be aligned to 16-byte (MB) boundary:
17 #define MP_IMGFLAG_ALIGNED_STRIDE 0x40
18 // codec uses drawing/rendering callbacks (draw_slice()-like thing, DR method 2)
19 #define MP_IMGFLAG_DRAW_CALLBACK 0x80
20
21 // set if number of planes > 1
22 #define MP_IMGFLAG_PLANAR 0x100
23 // set if it's YUV colorspace
24 #define MP_IMGFLAG_YUV 0x200
25 // set if it's swapped plane/byteorder
26 #define MP_IMGFLAG_SWAPPED 0x400
27 // type displayed (do not set this flag - it's for internal use!)
28 #define MP_IMGFLAG_TYPE_DISPLAYED 0x800
29
30 // codec doesn't support any form of direct rendering - it has own buffer
31 // allocation. so we just export its buffer pointers:
32 #define MP_IMGTYPE_EXPORT 0
33 // codec requires a static WO buffer, but it does only partial updates later:
34 #define MP_IMGTYPE_STATIC 1
35 // codec just needs some WO memory, where it writes/copies the whole frame to:
36 #define MP_IMGTYPE_TEMP 2
37 // I+P type, requires 2+ independent static R/W buffers
38 #define MP_IMGTYPE_IP 3
39 // I+P+B type, requires 2+ independent static R/W and 1+ temp WO buffers
40 #define MP_IMGTYPE_IPB 4
41
42 typedef struct mp_image_s {
43 unsigned short flags;
44 unsigned char type;
45 unsigned char bpp; // bits/pixel. NOT depth! for RGB it will be n*8
46 unsigned int imgfmt;
47 int width,height; // stored dimensions
48 int x,y,w,h; // visible dimensions
49 unsigned char* planes[3];
50 unsigned int stride[3];
51 int* qscale;
52 int qstride;
53 } mp_image_t;
54
55 #ifdef IMGFMT_YUY2
56 static inline void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){
57 mpi->flags&=~(MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV|MP_IMGFLAG_SWAPPED);
58 mpi->imgfmt=out_fmt;
59 if( (out_fmt&IMGFMT_RGB_MASK) == IMGFMT_RGB ){
60 mpi->bpp=((out_fmt&255)+7)&(~7);
61 return;
62 }
63 if( (out_fmt&IMGFMT_BGR_MASK) == IMGFMT_BGR ){
64 mpi->bpp=((out_fmt&255)+7)&(~7);
65 mpi->flags|=MP_IMGFLAG_SWAPPED;
66 return;
67 }
68 mpi->flags|=MP_IMGFLAG_YUV;
69 switch(out_fmt){
70 case IMGFMT_I420:
71 case IMGFMT_IYUV:
72 mpi->flags|=MP_IMGFLAG_SWAPPED;
73 case IMGFMT_YV12:
74 mpi->flags|=MP_IMGFLAG_PLANAR;
75 mpi->bpp=12;
76 return;
77 case IMGFMT_UYVY:
78 mpi->flags|=MP_IMGFLAG_SWAPPED;
79 case IMGFMT_YUY2:
80 mpi->bpp=16;
81 return;
82 case IMGFMT_MPEGPES:
83 mpi->bpp=0;
84 return;
85 }
86 printf("mp_image: Unknown out_fmt: 0x%X\n",out_fmt);
87 mpi->bpp=0;
88 }
89 #endif
90
91 static inline mp_image_t* new_mp_image(int w,int h){
92 mp_image_t* mpi=malloc(sizeof(mp_image_t));
93 if(!mpi) return NULL; // error!
94 memset(mpi,0,sizeof(mp_image_t));
95 mpi->width=mpi->w=w;
96 mpi->height=mpi->h=h;
97 return mpi;
98 }
99
100 #endif