|
简单的jpeg转成avi的类(8) void set_avi_size (int w, int h); int generate_avi (); private: int file_size (string const& file); int files_size (); int initalize_header (); void print_quartet (FILE* file, DWORD i); public: static DWORD const MAX_RIFF_SZ = 2147483648LL; /*Max avi file size, 2 GB limit*/ static DWORD const JPEG_DATA_SZ = sizeof(DWORD) * 2; struct Jpeg_Data { DWORD size; DWORD offset; string name; /* i.e. variable length structure */ Jpeg_Data () {} ~Jpeg_Data () {} friend bool operator< (Jpeg_Data const& a, Jpeg_Data const& o) { return a.name < o.name; } static bool lestthan (Jpeg_Data const* a, Jpeg_Data const* o) { return a->name < o->name; } }; protected: string avi_name_; WORD fps_; WORD frames_; WORD usec_per_frame; //file structure AVI_list_hdrl list_hdrl; //file list vector <Jpeg_Data*> jpeg_list; //option DWORD width; DWORD height; DWORD frames; unsigned int fps; long jpg_sz; size_t jpg_sz_64; size_t riff_sz_64; DWORD riff_sz; }; #endif
//AviGenerator.cpp
#include "AviGenerator.h" #include <iostream> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <algorithm> #ifdef _WIN32 #include <io.h> #include <errno.h> #else #include <sys/param.h> #include <unistd.h> #endif using namespace std; AviGenerator::AviGenerator(void) :fps (15) ,frames (1), jpg_sz (1), width (320), height (240) { usec_per_frame = 1000000 / fps;
|