X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fvframe.h;h=dc907821efca0fb90f721cb444b6c9127bc21994;hp=dbf4dab0a30d0c2f1e1860cbf41223ecee071394;hb=eb9df615719cf3afe2bc08035900e5d3451034e1;hpb=3b2c7c9370c55deb546f76895d6829fbc9476a18 diff --git a/cinelerra-5.1/guicast/vframe.h b/cinelerra-5.1/guicast/vframe.h index dbf4dab0..dc907821 100644 --- a/cinelerra-5.1/guicast/vframe.h +++ b/cinelerra-5.1/guicast/vframe.h @@ -29,13 +29,19 @@ #include "bctexture.inc" #include "bcwindowbase.inc" #include "bccmodels.h" -#include "bccmodels.h" #include "vframe.inc" // Maximum number of prev or next effects to be pushed onto the stacks. #define MAX_STACK_ELEMENTS 255 #define SHM_MIN_SIZE 2048 +#define ALIAS_OFF 0 +#define ALIAS_TOP 1 +#define ALIAS_CTR 2 +#define ALIAS_BOT 4 +#define ALIAS_DBL 5 +#define ALIAS_NRM 6 + // Scene graph for 3D models // Defined by the subclass class VFrameScene @@ -50,6 +56,7 @@ public: class VFrame { friend class VFramePng; + friend class VFrameJpeg; friend class PngReadFunction; public: // Create new frame with shared data if *data is nonzero. @@ -112,8 +119,11 @@ public: int data_size, int data_allocated); -// Write a PNG for debugging +// Write a PNG/PPM for debugging int write_png(const char *path); + static void write_ppm(VFrame *vfrm, const char *fmt, ...); + void write_ppm(const char *path) { write_ppm(this, "%s", path); } +//static int n = 0; write_ppm(vframe, "/tmp/data/f%05d", ++n); // if frame points to the same data as this return 1 int equals(VFrame *frame); @@ -137,7 +147,8 @@ public: return transfer_from(frame, bg_color, 0,0, frame->get_w(),frame->get_h()); } // Required for YUV - int clear_frame(); + void black_frame(); + void clear_frame(); int allocate_compressed_data(long bytes); // Sequence number. -1 means invalid. Passing frames to the encoder is @@ -280,12 +291,7 @@ public: BC_PBuffer* get_pbuffer(); // Bind the frame's texture to GL_TEXTURE_2D and enable it. -// If a texture_unit is supplied, the texture unit is made active -// and the commands are run in the right sequence to -// initialize it to our preferred specifications. - void bind_texture(int texture_unit = -1); - - + void bind_texture(int texture_unit, int nearest=0); // Create a frustum with 0,0 in the upper left and w,-h in the bottom right. // Set preferred opengl settings. @@ -293,6 +299,11 @@ public: // Calls init_screen with the current frame's dimensions. void init_screen(); +// color used by clear_frame, default -1 (unset) which clears to BLACK + void set_clear_color(int color, int alpha); + int get_clear_color(); + int get_clear_alpha(); + // Compiles and links the shaders into a program. // Adds the program with put_shader. // Returns the program handle. @@ -339,16 +350,20 @@ public: void copy_stacks(VFrame *src); // Updates the params with values from src void copy_params(VFrame *src); - // This clears the stacks and the param table void clear_stacks(); - virtual int draw_pixel(int x, int y); - int pixel_rgb, pixel_yuv, stipple; +// pixel drawing + virtual int draw_pixel(float x, float y, float a=1.f); + virtual int draw_pixel(float x, float y, float frac, int axis); + void set_draw_alpha(float a); + void set_draw_flags(int flags); + int pixel_rgb, pixel_yuv, stipple, draw_flags; + float draw_alpha; void set_pixel_color(int rgb, int a=0xff); void set_stiple(int mask); - void draw_line(int x1, int y1, int x2, int y2); + void draw_line(float x1, float y1, float x2, float y2); void draw_smooth(int x1, int y1, int x2, int y2, int x3, int y3); void smooth_draw(int x1, int y1, int x2, int y2, int x3, int y3); void draw_rect(int x1, int y1, int x2, int y2); @@ -402,7 +417,7 @@ private: { PRIVATE, SHARED, - SHMGET + SHM_GET }; // Data pointer is pointing to someone else's buffer. @@ -434,6 +449,8 @@ private: unsigned char *a; // Dimensions of frame int w, h; +// color used by clear_frame + int clear_color, clear_alpha; // Info for reading png images const unsigned char *image; long image_offset; @@ -470,4 +487,21 @@ public: static VFrame *vframe_png(const char *png_path, double xs=1, double ys=1); }; +// Create a frame with the jpeg image +// jpeg_model must be BC_RGB888, BC_YUV888, or BC_GREY8 +class VFrameJpeg : public VFrame +{ +// Read a JPEG into the frame (no alpha) + int read_jpeg(const unsigned char *data, long sz, + double xscale, double yscale, int jpeg_model); +public: + VFrameJpeg(const unsigned char *jpeg_data, double s=0); + VFrameJpeg(const unsigned char *jpeg_data, long image_size, double xs=0, double ys=0); + virtual ~VFrameJpeg(); + static VFrame *vframe_jpeg(int fd, + double xs=1, double ys=1, int jpeg_model=BC_RGB888); + static VFrame *vframe_jpeg(const char *jpeg_path, + double xs=1, double ys=1, int jpeg_model=BC_RGB888); +}; + #endif