00001 /* 00002 * This file is part of MPlayer. 00003 * 00004 * MPlayer is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * MPlayer is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License along 00015 * with MPlayer; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00017 */ 00018 00019 #ifndef MPLAYER_MP_IMAGE_H 00020 #define MPLAYER_MP_IMAGE_H 00021 00022 #include <stdio.h> 00023 #include <stdlib.h> 00024 #include <string.h> 00025 #undef printf //FIXME 00026 #undef fprintf //FIXME 00027 #include "mp_msg.h" 00028 #include "libavutil/avutil.h" 00029 #include "libavutil/avassert.h" 00030 #undef realloc 00031 #undef malloc 00032 #undef free 00033 #undef rand 00034 #undef srand 00035 #undef printf 00036 #define ASMALIGN(ZEROBITS) ".p2align " #ZEROBITS "\n\t" 00037 00038 00039 //--------- codec's requirements (filled by the codec/vf) --------- 00040 00041 //--- buffer content restrictions: 00042 // set if buffer content shouldn't be modified: 00043 #define MP_IMGFLAG_PRESERVE 0x01 00044 // set if buffer content will be READ for next frame's MC: (I/P mpeg frames) 00045 #define MP_IMGFLAG_READABLE 0x02 00046 00047 //--- buffer width/stride/plane restrictions: (used for direct rendering) 00048 // stride _have_to_ be aligned to MB boundary: [for DR restrictions] 00049 #define MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE 0x4 00050 // stride should be aligned to MB boundary: [for buffer allocation] 00051 #define MP_IMGFLAG_PREFER_ALIGNED_STRIDE 0x8 00052 // codec accept any stride (>=width): 00053 #define MP_IMGFLAG_ACCEPT_STRIDE 0x10 00054 // codec accept any width (width*bpp=stride -> stride%bpp==0) (>=width): 00055 #define MP_IMGFLAG_ACCEPT_WIDTH 0x20 00056 //--- for planar formats only: 00057 // uses only stride[0], and stride[1]=stride[2]=stride[0]>>mpi->chroma_x_shift 00058 #define MP_IMGFLAG_COMMON_STRIDE 0x40 00059 // uses only planes[0], and calculates planes[1,2] from width,height,imgfmt 00060 #define MP_IMGFLAG_COMMON_PLANE 0x80 00061 00062 #define MP_IMGFLAGMASK_RESTRICTIONS 0xFF 00063 00064 //--------- color info (filled by mp_image_setfmt() ) ----------- 00065 // set if number of planes > 1 00066 #define MP_IMGFLAG_PLANAR 0x100 00067 // set if it's YUV colorspace 00068 #define MP_IMGFLAG_YUV 0x200 00069 // set if it's swapped (BGR or YVU) plane/byteorder 00070 #define MP_IMGFLAG_SWAPPED 0x400 00071 // set if you want memory for palette allocated and managed by vf_get_image etc. 00072 #define MP_IMGFLAG_RGB_PALETTE 0x800 00073 00074 #define MP_IMGFLAGMASK_COLORS 0xF00 00075 00076 // codec uses drawing/rendering callbacks (draw_slice()-like thing, DR method 2) 00077 // [the codec will set this flag if it supports callbacks, and the vo _may_ 00078 // clear it in get_image() if draw_slice() not implemented] 00079 #define MP_IMGFLAG_DRAW_CALLBACK 0x1000 00080 // set if it's in video buffer/memory: [set by vo/vf's get_image() !!!] 00081 #define MP_IMGFLAG_DIRECT 0x2000 00082 // set if buffer is allocated (used in destination images): 00083 #define MP_IMGFLAG_ALLOCATED 0x4000 00084 00085 // buffer type was printed (do NOT set this flag - it's for INTERNAL USE!!!) 00086 #define MP_IMGFLAG_TYPE_DISPLAYED 0x8000 00087 00088 // codec doesn't support any form of direct rendering - it has own buffer 00089 // allocation. so we just export its buffer pointers: 00090 #define MP_IMGTYPE_EXPORT 0 00091 // codec requires a static WO buffer, but it does only partial updates later: 00092 #define MP_IMGTYPE_STATIC 1 00093 // codec just needs some WO memory, where it writes/copies the whole frame to: 00094 #define MP_IMGTYPE_TEMP 2 00095 // I+P type, requires 2+ independent static R/W buffers 00096 #define MP_IMGTYPE_IP 3 00097 // I+P+B type, requires 2+ independent static R/W and 1+ temp WO buffers 00098 #define MP_IMGTYPE_IPB 4 00099 // Upper 16 bits give desired buffer number, -1 means get next available 00100 #define MP_IMGTYPE_NUMBERED 5 00101 // Doesn't need any buffer, incomplete image (probably a first field only) 00102 // we need this type to be able to differentiate between half frames and 00103 // all other cases 00104 #define MP_IMGTYPE_INCOMPLETE 6 00105 00106 #define MP_MAX_PLANES 4 00107 00108 #define MP_IMGFIELD_ORDERED 0x01 00109 #define MP_IMGFIELD_TOP_FIRST 0x02 00110 #define MP_IMGFIELD_REPEAT_FIRST 0x04 00111 #define MP_IMGFIELD_TOP 0x08 00112 #define MP_IMGFIELD_BOTTOM 0x10 00113 #define MP_IMGFIELD_INTERLACED 0x20 00114 00115 typedef struct mp_image { 00116 unsigned int flags; 00117 unsigned char type; 00118 int number; 00119 unsigned char bpp; // bits/pixel. NOT depth! for RGB it will be n*8 00120 unsigned int imgfmt; 00121 int width,height; // stored dimensions 00122 int x,y,w,h; // visible dimensions 00123 unsigned char* planes[MP_MAX_PLANES]; 00124 int stride[MP_MAX_PLANES]; 00125 char * qscale; 00126 int qstride; 00127 int pict_type; // 0->unknown, 1->I, 2->P, 3->B 00128 int fields; 00129 int qscale_type; // 0->mpeg1/4/h263, 1->mpeg2 00130 int num_planes; 00131 /* these are only used by planar formats Y,U(Cb),V(Cr) */ 00132 int chroma_width; 00133 int chroma_height; 00134 int chroma_x_shift; // horizontal 00135 int chroma_y_shift; // vertical 00136 int usage_count; 00137 /* for private use by filter or vo driver (to store buffer id or dmpi) */ 00138 void* priv; 00139 } mp_image_t; 00140 00141 void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt); 00142 mp_image_t* new_mp_image(int w,int h); 00143 void free_mp_image(mp_image_t* mpi); 00144 00145 mp_image_t* alloc_mpi(int w, int h, unsigned long int fmt); 00146 void mp_image_alloc_planes(mp_image_t *mpi); 00147 void copy_mpi(mp_image_t *dmpi, mp_image_t *mpi); 00148 00149 #endif /* MPLAYER_MP_IMAGE_H */
1.5.6