r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / guicast / vframe.h
blob2632bb067033f8f90cbaa295327f692fd9d50fbb
1 #ifndef VFRAME_H
2 #define VFRAME_H
4 #include "colormodels.h"
5 #include "vframe.inc"
7 class PngReadFunction;
9 class VFrame
11 public:
12 // Create new frame with shared data if *data is nonzero.
13 // Pass 0 to *data if private data is desired.
14 VFrame(unsigned char *data,
15 int w,
16 int h,
17 int color_model = BC_RGBA8888,
18 long bytes_per_line = -1);
19 VFrame(unsigned char *data,
20 long y_offset,
21 long u_offset,
22 long v_offset,
23 int w,
24 int h,
25 int color_model = BC_RGBA8888,
26 long bytes_per_line = -1);
27 // Create a frame with the png image
28 VFrame(unsigned char *png_data);
29 VFrame(VFrame &vframe);
30 // Create new frame for compressed data.
31 // Can't share data because the data is dynamically allocated.
32 VFrame();
33 ~VFrame();
35 friend class PngReadFunction;
37 // Reallocate a frame without deleting the class
38 int reallocate(unsigned char *data,
39 long y_offset,
40 long u_offset,
41 long v_offset,
42 int w,
43 int h,
44 int color_model,
45 long bytes_per_line);
47 void set_memory(unsigned char *data,
48 long y_offset,
49 long u_offset,
50 long v_offset);
52 // Read a PNG into the frame with alpha
53 int read_png(unsigned char *data);
55 // if frame points to the same data as this return 1
56 int equals(VFrame *frame);
57 // Test if frame already matches parameters
58 int params_match(int w, int h, int color_model);
60 long set_shm_offset(long offset);
61 long get_shm_offset();
63 // direct copy with no alpha
64 int copy_from(VFrame *frame);
65 // Direct copy with alpha from 0 to 1.
66 int replace_from(VFrame *frame, float alpha);
68 int apply_fade(float alpha);
69 // Required for YUV
70 int clear_frame();
71 int allocate_compressed_data(long bytes);
73 // Sequence number. -1 means invalid. Passing frames to the encoder is
74 // asynchronous. The sequence number must be preserved in the image itself
75 // to encode discontinuous frames.
76 long get_number();
77 void set_number(long number);
79 long get_compressed_allocated();
80 long get_compressed_size();
81 long set_compressed_size(long size);
82 int get_color_model();
83 // Get the data pointer
84 unsigned char* get_data();
85 // return an array of pointers to rows
86 unsigned char** get_rows();
87 // return yuv planes
88 unsigned char* get_y();
89 unsigned char* get_u();
90 unsigned char* get_v();
91 int get_w();
92 int get_h();
93 int get_w_fixed();
94 int get_h_fixed();
95 static int get_scale_tables(int *column_table, int *row_table,
96 int in_x1, int in_y1, int in_x2, int in_y2,
97 int out_x1, int out_y1, int out_x2, int out_y2);
98 int get_bytes_per_pixel();
99 long get_bytes_per_line();
100 static int calculate_bytes_per_pixel(int colormodel);
101 static long calculate_data_size(int w,
102 int h,
103 int bytes_per_line = -1,
104 int color_model = BC_RGB888);
105 long get_data_size();
106 void rotate270();
107 void rotate90();
108 void flip_vert();
110 // Convenience storage.
111 // Returns -1 if not set.
112 int get_field2_offset();
113 int set_field2_offset(int value);
114 // Overlay src onto this with blending and translation of input.
115 // Source and this must have alpha
116 void overlay(VFrame *src,
117 int out_x1,
118 int out_y1);
120 private:
121 int clear_objects();
122 int reset_parameters();
123 void create_row_pointers();
124 int allocate_data(unsigned char *data,
125 long y_offset,
126 long u_offset,
127 long v_offset,
128 int w,
129 int h,
130 int color_model,
131 long bytes_per_line);
133 // Convenience storage
134 int field2_offset;
135 // Data is pointing to someone else's buffer.
136 int shared;
137 long shm_offset;
138 // If not set by user, is calculated from color_model
139 long bytes_per_line;
140 int bytes_per_pixel;
141 // Image data
142 unsigned char *data;
143 // Pointers to the start of each row
144 unsigned char **rows;
145 // One of the #defines
146 int color_model;
147 // Allocated space for compressed data
148 long compressed_allocated;
149 // Size of stored compressed image
150 long compressed_size;
151 // Pointers to yuv planes
152 unsigned char *y, *u, *v;
153 long y_offset;
154 long u_offset;
155 long v_offset;
156 // Dimensions of frame
157 int w, h;
158 // Info for reading png images
159 unsigned char *image;
160 long image_offset;
161 long image_size;
162 // For writing discontinuous frames in background rendering
163 long sequence_number;
167 #endif