• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavfilter/libmpcodecs/mp_image.h

Go to the documentation of this file.
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 #undef strncpy
00037 #define ASMALIGN(ZEROBITS) ".p2align " #ZEROBITS "\n\t"
00038 
00039 
00040 //--------- codec's requirements (filled by the codec/vf) ---------
00041 
00042 //--- buffer content restrictions:
00043 // set if buffer content shouldn't be modified:
00044 #define MP_IMGFLAG_PRESERVE 0x01
00045 // set if buffer content will be READ for next frame's MC: (I/P mpeg frames)
00046 #define MP_IMGFLAG_READABLE 0x02
00047 
00048 //--- buffer width/stride/plane restrictions: (used for direct rendering)
00049 // stride _have_to_ be aligned to MB boundary:  [for DR restrictions]
00050 #define MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE 0x4
00051 // stride should be aligned to MB boundary:     [for buffer allocation]
00052 #define MP_IMGFLAG_PREFER_ALIGNED_STRIDE 0x8
00053 // codec accept any stride (>=width):
00054 #define MP_IMGFLAG_ACCEPT_STRIDE 0x10
00055 // codec accept any width (width*bpp=stride -> stride%bpp==0) (>=width):
00056 #define MP_IMGFLAG_ACCEPT_WIDTH 0x20
00057 //--- for planar formats only:
00058 // uses only stride[0], and stride[1]=stride[2]=stride[0]>>mpi->chroma_x_shift
00059 #define MP_IMGFLAG_COMMON_STRIDE 0x40
00060 // uses only planes[0], and calculates planes[1,2] from width,height,imgfmt
00061 #define MP_IMGFLAG_COMMON_PLANE 0x80
00062 
00063 #define MP_IMGFLAGMASK_RESTRICTIONS 0xFF
00064 
00065 //--------- color info (filled by mp_image_setfmt() ) -----------
00066 // set if number of planes > 1
00067 #define MP_IMGFLAG_PLANAR 0x100
00068 // set if it's YUV colorspace
00069 #define MP_IMGFLAG_YUV 0x200
00070 // set if it's swapped (BGR or YVU) plane/byteorder
00071 #define MP_IMGFLAG_SWAPPED 0x400
00072 // set if you want memory for palette allocated and managed by vf_get_image etc.
00073 #define MP_IMGFLAG_RGB_PALETTE 0x800
00074 
00075 #define MP_IMGFLAGMASK_COLORS 0xF00
00076 
00077 // codec uses drawing/rendering callbacks (draw_slice()-like thing, DR method 2)
00078 // [the codec will set this flag if it supports callbacks, and the vo _may_
00079 //  clear it in get_image() if draw_slice() not implemented]
00080 #define MP_IMGFLAG_DRAW_CALLBACK 0x1000
00081 // set if it's in video buffer/memory: [set by vo/vf's get_image() !!!]
00082 #define MP_IMGFLAG_DIRECT 0x2000
00083 // set if buffer is allocated (used in destination images):
00084 #define MP_IMGFLAG_ALLOCATED 0x4000
00085 
00086 // buffer type was printed (do NOT set this flag - it's for INTERNAL USE!!!)
00087 #define MP_IMGFLAG_TYPE_DISPLAYED 0x8000
00088 
00089 // codec doesn't support any form of direct rendering - it has own buffer
00090 // allocation. so we just export its buffer pointers:
00091 #define MP_IMGTYPE_EXPORT 0
00092 // codec requires a static WO buffer, but it does only partial updates later:
00093 #define MP_IMGTYPE_STATIC 1
00094 // codec just needs some WO memory, where it writes/copies the whole frame to:
00095 #define MP_IMGTYPE_TEMP 2
00096 // I+P type, requires 2+ independent static R/W buffers
00097 #define MP_IMGTYPE_IP 3
00098 // I+P+B type, requires 2+ independent static R/W and 1+ temp WO buffers
00099 #define MP_IMGTYPE_IPB 4
00100 // Upper 16 bits give desired buffer number, -1 means get next available
00101 #define MP_IMGTYPE_NUMBERED 5
00102 // Doesn't need any buffer, incomplete image (probably a first field only)
00103 // we need this type to be able to differentiate between half frames and
00104 // all other cases
00105 #define MP_IMGTYPE_INCOMPLETE 6
00106 
00107 #define MP_MAX_PLANES 4
00108 
00109 #define MP_IMGFIELD_ORDERED 0x01
00110 #define MP_IMGFIELD_TOP_FIRST 0x02
00111 #define MP_IMGFIELD_REPEAT_FIRST 0x04
00112 #define MP_IMGFIELD_TOP 0x08
00113 #define MP_IMGFIELD_BOTTOM 0x10
00114 #define MP_IMGFIELD_INTERLACED 0x20
00115 
00116 typedef struct mp_image {
00117     unsigned int flags;
00118     unsigned char type;
00119     int number;
00120     unsigned char bpp;  // bits/pixel. NOT depth! for RGB it will be n*8
00121     unsigned int imgfmt;
00122     int width,height;  // stored dimensions
00123     int x,y,w,h;  // visible dimensions
00124     unsigned char* planes[MP_MAX_PLANES];
00125     int stride[MP_MAX_PLANES];
00126     char * qscale;
00127     int qstride;
00128     int pict_type; // 0->unknown, 1->I, 2->P, 3->B
00129     int fields;
00130     int qscale_type; // 0->mpeg1/4/h263, 1->mpeg2
00131     int num_planes;
00132     /* these are only used by planar formats Y,U(Cb),V(Cr) */
00133     int chroma_width;
00134     int chroma_height;
00135     int chroma_x_shift; // horizontal
00136     int chroma_y_shift; // vertical
00137     int usage_count;
00138     /* for private use by filter or vo driver (to store buffer id or dmpi) */
00139     void* priv;
00140 } mp_image_t;
00141 
00142 void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt);
00143 mp_image_t* new_mp_image(int w,int h);
00144 void free_mp_image(mp_image_t* mpi);
00145 
00146 mp_image_t* alloc_mpi(int w, int h, unsigned long int fmt);
00147 void mp_image_alloc_planes(mp_image_t *mpi);
00148 void copy_mpi(mp_image_t *dmpi, mp_image_t *mpi);
00149 
00150 #endif /* MPLAYER_MP_IMAGE_H */

Generated on Wed Apr 11 2012 07:31:35 for FFmpeg by  doxygen 1.7.1