quicktime_t* quicktime_open(char *filename, int rd, int wr) { quicktime_t *new_file = calloc(1, sizeof(quicktime_t)); int result = 0; //printf("quicktime_open 1\n"); quicktime_init(new_file); new_file->wr = wr; new_file->rd = rd; new_file->mdat.atom.start = 0; result = quicktime_file_open(new_file, filename, rd, wr); if(!result) { if(rd) { if(quicktime_read_info(new_file)) { quicktime_close(new_file); fprintf(stderr, "quicktime_open: error in header\n"); new_file = 0; } } /* start the data atom */ /* also don't want to do this if making a streamable file */ if(wr) { quicktime_set_presave(new_file, 1); // android requires the ftyp header const unsigned char ftyp_data[] = { 0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70, 0x6d, 0x70, 0x34, 0x32, 0x00, 0x00, 0x00, 0x01, 0x6d, 0x70, 0x34, 0x32, 0x61, 0x76, 0x63, 0x31 }; quicktime_write_data(new_file, (char*)ftyp_data, sizeof(ftyp_data)); quicktime_atom_write_header64(new_file, &new_file->mdat.atom, "mdat"); quicktime_set_presave(new_file, 0); } } else { //printf("quicktime_open 10\n"); quicktime_close(new_file); //printf("quicktime_open 100\n"); new_file = 0; } return new_file; }
void imb_filetypes_init(void) { ImFileType *type; for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) if (type->init) type->init(); #ifdef WITH_QUICKTIME quicktime_init(); #endif }
void GLView::initializeGL() { #ifdef HAVE_QUICKTIME m_haveQuickTime = quicktime_init(); if (!m_haveQuickTime) { QMessageBox::warning(NULL, "Warning", "<a href='http://www.apple.com/quicktime/download'>QuickTime 7 Pro</a> not found!<br>"); } #endif if (!GLEE_VERSION_2_0 || !GLEE_EXT_framebuffer_object || !GLEE_ARB_texture_float || !GLEE_ARB_texture_rectangle || !GLEE_EXT_bgra) { QMessageBox::critical(this, "Error", "OpenGL 2.0 Graphics Card with EXT_framebuffer_object, ARB_texture_rectangle, ARB_texture_float and EXT_bgra required"); } bool status = true; QDir glsl_dir(":/glsl"); QFileInfoList glsl_list = glsl_dir.entryInfoList(); for (int i = 0; i < glsl_list.size(); ++i) { QFileInfo fi = glsl_list[i]; std::string fn = fi.fileName().toStdString(); QFile f(fi.filePath()); if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox::critical(NULL, "Error", QString("Can't open %1").arg(fi.filePath())); exit(1); } #ifdef WIN32 OutputDebugStringA(fn.c_str()); OutputDebugStringA("\n"); #else fprintf(stderr, "%s\n", fn.c_str()); #endif QByteArray src = f.readAll(); glsl_program glsl(fn.c_str(), true); glsl.attach_shader(GL_FRAGMENT_SHADER, src.constData()); status &= glsl.link(); } if (!status) { QMessageBox::critical(this, "Error", "Compiling/Linking shader failed!"); qApp->quit(); } glGenFramebuffersEXT(1, &m_fbo); glEnable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); }
quicktime_t* quicktime_open(char *filename, int rd, int wr) { quicktime_t *new_file = calloc(1, sizeof(quicktime_t)); char flags[10]; int result = 0; //printf("quicktime_open 1\n"); quicktime_init(new_file); new_file->wr = wr; new_file->rd = rd; new_file->mdat.atom.start = 0; result = quicktime_file_open(new_file, filename, rd, wr); if(!result) { if(rd) { if(quicktime_read_info(new_file)) { quicktime_close(new_file); fprintf(stderr, "quicktime_open: error in header\n"); new_file = 0; } } /* start the data atom */ /* also don't want to do this if making a streamable file */ if(wr) { quicktime_set_presave(new_file, 1); quicktime_atom_write_header64(new_file, &new_file->mdat.atom, "mdat"); quicktime_set_presave(new_file, 0); } } else { //printf("quicktime_open 10\n"); quicktime_close(new_file); //printf("quicktime_open 100\n"); new_file = 0; } return new_file; }
int quicktime_check_sig(char *path) { quicktime_t file; quicktime_atom_t leaf_atom; int result = 0, result1 = 0, result2 = 0; char avi_test[12]; quicktime_init(&file); result = quicktime_file_open(&file, path, 1, 0); if(!result) { // Check for Microsoft AVI quicktime_read_data(&file, avi_test, 12); quicktime_set_position(&file, 0); if(quicktime_match_32(avi_test, "RIFF") && quicktime_match_32(avi_test + 8, "AVI ")) { result2 = 1; } else { do { result1 = quicktime_atom_read_header(&file, &leaf_atom); if(!result1) { /* just want the "moov" atom */ if(quicktime_atom_is(&leaf_atom, "moov")) { result2 = 1; } else quicktime_atom_skip(&file, &leaf_atom); } }while(!result1 && !result2 && quicktime_position(&file) < file.total_length); } } //printf(__FUNCTION__ " 2 %d\n", result2); quicktime_file_close(&file); quicktime_delete(&file); return result2; }
int quicktime_check_sig(const char *path) { quicktime_t file; quicktime_atom_t leaf_atom; int result1 = 0, result2 = 0; quicktime_init(&file); if(!(file.stream = fopen(path, "rb"))) { perror("quicktime_check_sig"); return 0; } fseek(file.stream, 0, SEEK_END); file.total_length = ftell(file.stream); fseek(file.stream, 0, SEEK_SET); do { result1 = quicktime_atom_read_header(&file, &leaf_atom); if(!result1) { /* just want the "moov" atom */ if(quicktime_atom_is(&leaf_atom, "moov")) { result2 = 1; } else quicktime_atom_skip(&file, &leaf_atom); } }while(!result1 && !result2 && quicktime_position(&file) < file.total_length); fclose(file.stream); quicktime_delete(&file); return result2; }
int quicktime_make_streamable(char *in_path, char *out_path) { quicktime_t file, *old_file, new_file; int moov_exists = 0, mdat_exists = 0, result, atoms = 1; int64_t mdat_start, mdat_size; quicktime_atom_t leaf_atom; int64_t moov_length; quicktime_init(&file); /* find the moov atom in the old file */ if(!(file.stream = fopen(in_path, "rb"))) { perror("quicktime_make_streamable"); return 1; } file.total_length = quicktime_get_file_length(in_path); /* get the locations of moov and mdat atoms */ do { /*printf("%x\n", quicktime_position(&file)); */ result = quicktime_atom_read_header(&file, &leaf_atom); if(!result) { if(quicktime_atom_is(&leaf_atom, "moov")) { moov_exists = atoms; moov_length = leaf_atom.size; } else if(quicktime_atom_is(&leaf_atom, "mdat")) { mdat_start = quicktime_position(&file) - HEADER_LENGTH; mdat_size = leaf_atom.size; mdat_exists = atoms; } quicktime_atom_skip(&file, &leaf_atom); atoms++; } }while(!result && quicktime_position(&file) < file.total_length); fclose(file.stream); if(!moov_exists) { printf("quicktime_make_streamable: no moov atom\n"); return 1; } if(!mdat_exists) { printf("quicktime_make_streamable: no mdat atom\n"); return 1; } /* copy the old file to the new file */ if(moov_exists && mdat_exists) { /* moov wasn't the first atom */ if(moov_exists > 1) { char *buffer; int64_t buf_size = 1000000; result = 0; /* read the header proper */ if(!(old_file = quicktime_open(in_path, 1, 0))) { return 1; } quicktime_shift_offsets(&(old_file->moov), moov_length); /* open the output file */ if(!(new_file.stream = fopen(out_path, "wb"))) { perror("quicktime_make_streamable"); result = 1; } else { /* set up some flags */ new_file.wr = 1; new_file.rd = 0; quicktime_write_moov(&new_file, &(old_file->moov)); quicktime_set_position(old_file, mdat_start); if(!(buffer = calloc(1, buf_size))) { result = 1; printf("quicktime_make_streamable: out of memory\n"); } else { while(quicktime_position(old_file) < mdat_start + mdat_size && !result) { if(quicktime_position(old_file) + buf_size > mdat_start + mdat_size) buf_size = mdat_start + mdat_size - quicktime_position(old_file); if(!quicktime_read_data(old_file, buffer, buf_size)) result = 1; if(!result) { if(!quicktime_write_data(&new_file, buffer, buf_size)) result = 1; } } free(buffer); } fclose(new_file.stream); } quicktime_close(old_file); } else { printf("quicktime_make_streamable: header already at 0 offset\n"); return 0; } } return 0; }
quicktime_t* quicktime_open(char *filename, int rd, int wr, int append) { quicktime_t *new_file = malloc(sizeof(quicktime_t)); char flags[10]; int exists = 0; quicktime_init(new_file); new_file->wr = wr; new_file->rd = rd; new_file->mdat.start = 0; if (!strcmp(&filename[strlen(filename)-4], ".mp4")) { new_file->use_mp4 = TRUE; } else { new_file->use_mp4 = FALSE; } if(rd && (new_file->stream = fopen(filename, "rb"))) { exists = 1; fclose(new_file->stream); new_file->stream = NULL; } if(rd && !wr) sprintf(flags, "rb"); else if(!rd && wr) sprintf(flags, "wb"); else if(rd && wr) { if(exists) sprintf(flags, "rb+"); else sprintf(flags, "wb+"); } if(!(new_file->stream = fopen(filename, flags))) { perror("quicktime_open"); free(new_file); return 0; } if(rd && exists) { fseek(new_file->stream, 0, SEEK_END); new_file->total_length = ftell(new_file->stream); fseek(new_file->stream, 0, SEEK_SET); if(quicktime_read_info(new_file)) { quicktime_close(new_file); new_file = 0; } } if(wr) { if(!exists || !append) { /* start the data atom */ quicktime_write_int32(new_file, 0); quicktime_write_char32(new_file, "mdat"); } else { quicktime_set_position(new_file, new_file->mdat.start + new_file->mdat.size); fseek(new_file->stream, new_file->mdat.start + new_file->mdat.size, SEEK_SET); } } return new_file; }
void Load::init() throw (Error) { quicktime_init(); }
int quicktime_make_streamable(char *in_path, char *out_path) { quicktime_t file, *old_file, new_file; int moov_exists = 0, mdat_exists = 0, result, atoms = 1; int64_t mdat_start, mdat_size; quicktime_atom_t leaf_atom; int64_t moov_start, moov_end; int ftyp_exists = 0; int ftyp_size = 0; unsigned char *ftyp_data = 0; quicktime_init(&file); /* find the moov atom in the old file */ if(!(file.stream = fopen(in_path, "rb"))) { perror("quicktime_make_streamable"); return 1; } file.total_length = quicktime_get_file_length(in_path); /* get the locations of moov and mdat atoms */ do { result = quicktime_atom_read_header(&file, &leaf_atom); //printf("0x%llx %s\n", quicktime_position(&file), leaf_atom.type); if(!result) { if(quicktime_atom_is(&leaf_atom, "ftyp")) { ftyp_exists = 1; ftyp_data = calloc(1, leaf_atom.size); ftyp_size = leaf_atom.size; quicktime_set_position(&file, quicktime_position(&file) - HEADER_LENGTH); quicktime_read_data(&file, (char*)ftyp_data, ftyp_size); } else if(quicktime_atom_is(&leaf_atom, "moov")) { moov_exists = atoms; } else if(quicktime_atom_is(&leaf_atom, "mdat")) { mdat_start = quicktime_position(&file) - HEADER_LENGTH; mdat_size = leaf_atom.size; mdat_exists = atoms; } quicktime_atom_skip(&file, &leaf_atom); atoms++; } }while(!result && quicktime_position(&file) < file.total_length); fclose(file.stream); if(!moov_exists) { printf("quicktime_make_streamable: no moov atom\n"); if(ftyp_data) free(ftyp_data); return 1; } if(!mdat_exists) { printf("quicktime_make_streamable: no mdat atom\n"); if(ftyp_data) free(ftyp_data); return 1; } /* copy the old file to the new file */ if(moov_exists && mdat_exists) { /* moov wasn't the first atom */ if(moov_exists > 1) { char *buffer; int64_t buf_size = 1000000; result = 0; /* read the header proper */ if(!(old_file = quicktime_open(in_path, 1, 0))) { if(ftyp_data) free(ftyp_data); return 1; } /* open the output file */ if(!(new_file.stream = fopen(out_path, "wb"))) { perror("quicktime_make_streamable"); result = 1; } else { /* set up some flags */ new_file.wr = 1; new_file.rd = 0; /* Write ftyp header */ if(ftyp_exists) { quicktime_write_data(&new_file, (char*)ftyp_data, ftyp_size); } /* Write moov once to get final size with our substituted headers */ moov_start = quicktime_position(&new_file); quicktime_write_moov(&new_file, &(old_file->moov), 0); moov_end = quicktime_position(&new_file); printf("make_streamable 0x%llx 0x%llx\n", (long long)moov_end - moov_start, (long long)mdat_start); quicktime_shift_offsets(&(old_file->moov), moov_end - moov_start - mdat_start + ftyp_size); /* Write again with shifted offsets */ quicktime_set_position(&new_file, moov_start); quicktime_write_moov(&new_file, &(old_file->moov), 0); quicktime_set_position(old_file, mdat_start); if(!(buffer = calloc(1, buf_size))) { result = 1; printf("quicktime_make_streamable: out of memory\n"); } else { while(quicktime_position(old_file) < mdat_start + mdat_size && !result) { if(quicktime_position(old_file) + buf_size > mdat_start + mdat_size) buf_size = mdat_start + mdat_size - quicktime_position(old_file); if(!quicktime_read_data(old_file, buffer, buf_size)) result = 1; if(!result) { if(!quicktime_write_data(&new_file, buffer, buf_size)) result = 1; } } free(buffer); } fclose(new_file.stream); } quicktime_close(old_file); } else { printf("quicktime_make_streamable: header already at 0 offset\n"); if(ftyp_data) free(ftyp_data); return 0; } } if(ftyp_data) free(ftyp_data); return 0; }