|
简单的jpeg转成avi的类(11) if (NULL == fdest) { cerr << "Can't create a new file to write (" << this->avi_name_ << ")!" << endl; return -2; } //fwrite (&list_hdrl.avih.max_bytes_per_sec, 4, 1, fdest); long nbr; long nbw; long tnbw = 0; long mfsz; long remnant; char buff[512]; //write file header fwrite ("RIFF", 4, 1, fdest); print_quartet (fdest, riff_sz); fwrite ("AVI ", 4, 1, fdest); fwrite (&list_hdrl, sizeof (struct AVI_list_hdrl), 1, fdest); //sort the list by file name sort (this->jpeg_list.begin (), this->jpeg_list.end (), AviGenerator::Jpeg_Data::lestthan); // list movi size_t offset = 4; fwrite ("LIST", 4, 1, fdest); print_quartet (fdest, jpg_sz + 8 * frames + 4); fwrite ("movi", 4, 1, fdest); //write video data for (vector <Jpeg_Data*>::iterator iter = this->jpeg_list.begin (); iter != jpeg_list.end (); ++iter) { #ifdef DEBUG_VERSION cout << "dealing with " << (*iter)->name << endl; #endif fwrite ("00db", 4, 1, fdest); mfsz = (*iter)->size; remnant = (4 - (mfsz % 4)) % 4; print_quartet (fdest, mfsz + remnant); (*iter)->size += remnant; (*iter)->offset = offset; offset += (*iter)->size + 8; int fd; #ifdef _WIN32 fd = open ((*iter)->name.c_str (), O_RDONLY O_BINARY); #else fd = open ((*iter)->name.c_str (), O_RDONLY); #endif if (fd < 0) { cerr << "couldn't open file (" << (*iter)->name << ")!" << endl; fclose (fdest); return -3;
|