Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

vframe.h

Go to the documentation of this file.
00001 #ifndef VFRAME_H
00002 #define VFRAME_H
00003 
00004 #include "colormodels.h"
00005 #include "vframe.inc"
00006 
00007 class PngReadFunction;
00008 
00009 struct PngData
00010 {
00011         unsigned char* data;
00012         long size;
00013 };
00014 
00015 class VFrame
00016 {
00017 public:
00018 // Create new frame with shared data if *data is nonzero.
00019 // Pass 0 to *data if private data is desired.
00020         VFrame(unsigned char *data, 
00021                 int w, 
00022                 int h, 
00023                 int color_model = BC_RGBA8888, 
00024                 long bytes_per_line = -1);
00025         VFrame(unsigned char *data, 
00026                 long y_offset,
00027                 long u_offset,
00028                 long v_offset,
00029                 int w, 
00030                 int h, 
00031                 int color_model = BC_RGBA8888, 
00032                 long bytes_per_line = -1);
00033 // Create a frame with the png image
00034         VFrame(unsigned char *png_data);
00035         VFrame(const PngData& png_data);
00036         VFrame(VFrame &vframe);
00037 // Create new frame for compressed data.
00038         VFrame();
00039         ~VFrame();
00040 
00041         friend class PngReadFunction;
00042 
00043 // Return 1 if the colormodel and dimensions are the same
00044 // Used by FrameCache
00045         int equivalent(VFrame *src);
00046 
00047 // Reallocate a frame without deleting the class
00048         int reallocate(unsigned char *data, 
00049                 long y_offset,
00050                 long u_offset,
00051                 long v_offset,
00052                 int w, 
00053                 int h, 
00054                 int color_model, 
00055                 long bytes_per_line);
00056 
00057         void set_memory(unsigned char *data, 
00058                 long y_offset,
00059                 long u_offset,
00060                 long v_offset);
00061 
00062         void set_compressed_memory(unsigned char *data,
00063                 int data_size,
00064                 int data_allocated);
00065 
00066 // Read a PNG into the frame with alpha
00067         int read_png(unsigned char *data);
00068         int read_png(const PngData& png_data);
00069 
00070 // if frame points to the same data as this return 1
00071         int equals(VFrame *frame);
00072 // Test if frame already matches parameters
00073         int params_match(int w, int h, int color_model);
00074 
00075         long set_shm_offset(long offset);
00076         long get_shm_offset();
00077 
00078 // direct copy with no alpha
00079         int copy_from(VFrame *frame);
00080 // Required for YUV
00081         int clear_frame();
00082         int allocate_compressed_data(long bytes);
00083 
00084 // Sequence number. -1 means invalid.  Passing frames to the encoder is
00085 // asynchronous.  The sequence number must be preserved in the image itself
00086 // to encode discontinuous frames.
00087         long get_number();
00088         void set_number(long number);
00089 
00090         long get_compressed_allocated();
00091         long get_compressed_size();
00092         long set_compressed_size(long size);
00093         int get_color_model();
00094 // Get the data pointer
00095         unsigned char* get_data();
00096 // return an array of pointers to rows
00097         unsigned char** get_rows();       
00098 // return yuv planes
00099         unsigned char* get_y();
00100         unsigned char* get_u();
00101         unsigned char* get_v();
00102         int get_w();
00103         int get_h();
00104         int get_w_fixed();
00105         int get_h_fixed();
00106         static int get_scale_tables(int *column_table, int *row_table, 
00107                         int in_x1, int in_y1, int in_x2, int in_y2,
00108                         int out_x1, int out_y1, int out_x2, int out_y2);
00109         int get_bytes_per_pixel();
00110         long get_bytes_per_line();
00111         static int calculate_bytes_per_pixel(int colormodel);
00112         static long calculate_data_size(int w, 
00113                 int h, 
00114                 int bytes_per_line = -1, 
00115                 int color_model = BC_RGB888);
00116 // Get size of uncompressed frame buffer
00117         long get_data_size();
00118         void rotate270();
00119         void rotate90();
00120         void flip_vert();
00121 
00122 // Convenience storage.
00123 // Returns -1 if not set.
00124         int get_field2_offset();
00125         int set_field2_offset(int value);
00126 // Set keyframe status
00127         void set_keyframe(int value);
00128         int get_keyframe();
00129 // Overlay src onto this with blending and translation of input.
00130 // Source and this must have alpha
00131         void overlay(VFrame *src, 
00132                 int out_x1, 
00133                 int out_y1);
00134 
00135 private:
00136         int clear_objects();
00137         int reset_parameters();
00138         void create_row_pointers();
00139         int allocate_data(unsigned char *data, 
00140                 long y_offset,
00141                 long u_offset,
00142                 long v_offset,
00143                 int w, 
00144                 int h, 
00145                 int color_model, 
00146                 long bytes_per_line);
00147 
00148 // Convenience storage
00149         int field2_offset;
00150 // Data is pointing to someone else's buffer.
00151         int shared; 
00152         long shm_offset;
00153 // If not set by user, is calculated from color_model
00154         long bytes_per_line;
00155         int bytes_per_pixel;
00156 // Image data
00157         unsigned char *data;
00158 // Pointers to the start of each row
00159         unsigned char **rows;
00160 // One of the #defines
00161         int color_model;
00162 // Allocated space for compressed data
00163         long compressed_allocated;
00164 // Size of stored compressed image
00165         long compressed_size;   
00166 // Pointers to yuv planes
00167         unsigned char *y, *u, *v;
00168         long y_offset;
00169         long u_offset;
00170         long v_offset;
00171 // Dimensions of frame
00172         int w, h;
00173 // Info for reading png images
00174         unsigned char *image;
00175         long image_offset;
00176         long image_size;
00177 // For writing discontinuous frames in background rendering
00178         long sequence_number;
00179         int is_keyframe;
00180 };
00181 
00182 
00183 #endif

Generated on Sun Jan 8 13:26:35 2006 for Guicast-svn by  doxygen 1.4.4