X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.0%2Fcinelerra%2Ffilempeg.C;h=e14b657ed92a3d1d38b97039362298eb600ac84c;hp=3791322508215d9a70d44add9a174c7b2e123c41;hb=52fcc46226f9df46f9ce9d0566dc568455a7db0b;hpb=2d99bb8ce591f05a31464b517d85dc2bc35b2abe diff --git a/cinelerra-5.0/cinelerra/filempeg.C b/cinelerra-5.0/cinelerra/filempeg.C index 37913225..e14b657e 100644 --- a/cinelerra-5.0/cinelerra/filempeg.C +++ b/cinelerra-5.0/cinelerra/filempeg.C @@ -50,8 +50,8 @@ #include -#define HVPEG_EXE "/hveg2enc.plugin" -#define MJPEG_EXE "/mpeg2enc.plugin" +#define HVPEG_EXE "/hveg2enc" +#define MJPEG_EXE "/mpeg2enc" // M JPEG dependancies @@ -134,7 +134,7 @@ int FileMPEG::check_sig(Asset *asset) return mpeg3_check_sig(asset->path); } -void FileMPEG::get_info(char *title_path, char *path, char *text) +void FileMPEG::get_info(char *title_path, char *path, char *text, int len) { mpeg3_t *fd; *text = 0; @@ -145,32 +145,32 @@ void FileMPEG::get_info(char *title_path, char *path, char *text) if( !result ) result = mpeg3_create_title(fd, 0); if( result ) return; - char *cp = text; + char *cp = text, *ep = text + len-1; if( mpeg3_has_toc(fd) ) { - cp += sprintf(cp, "toc path:%s\n", path); - cp += sprintf(cp, "title path:\n"); + cp += snprintf(cp,ep-cp, _("toc path:%s\n"), path); + cp += snprintf(cp,ep-cp, _("title path:\n")); for( int i=0; i<100; ++i ) { char *title_path = mpeg3_title_path(fd,i); if( !title_path ) break; - cp += sprintf(cp, " %2d. %s\n", i+1, title_path); + cp += snprintf(cp,ep-cp, " %2d. %s\n", i+1, title_path); } } else - cp += sprintf(cp, "file path:%s\n", path); + cp += snprintf(cp,ep-cp, _("file path:%s\n"), path); int64_t bytes = mpeg3_get_bytes(fd); char string[BCTEXTLEN]; sprintf(string,"%ld",bytes); Units::punctuate(string); - cp += sprintf(cp, "size: %s", string); + cp += snprintf(cp,ep-cp, _("size: %s"), string); if( mpeg3_is_program_stream(fd) ) - cp += sprintf(cp, " program stream\n"); + cp += snprintf(cp,ep-cp, _(" program stream\n")); else if( mpeg3_is_transport_stream(fd) ) - cp += sprintf(cp, " transport stream\n"); + cp += snprintf(cp,ep-cp, _(" transport stream\n")); else if( mpeg3_is_video_stream(fd) ) - cp += sprintf(cp, " video stream\n"); + cp += snprintf(cp,ep-cp, _(" video stream\n")); else if( mpeg3_is_audio_stream(fd) ) - cp += sprintf(cp, " audio stream\n"); + cp += snprintf(cp,ep-cp, _(" audio stream\n")); int64_t sdate = mpeg3_get_source_date(fd); if( !sdate ) { @@ -179,60 +179,60 @@ void FileMPEG::get_info(char *title_path, char *path, char *text) sdate = stat64(path, &ostat) < 0 ? 0 : ostat.st_mtime; } time_t tm = (time_t)sdate; - cp += sprintf(cp, "date: %s\n", ctime(&tm)); + cp += snprintf(cp,ep-cp, _("date: %s\n"), ctime(&tm)); int vtrks = mpeg3_total_vstreams(fd); - cp += sprintf(cp, "%d video tracks\n", vtrks); + cp += snprintf(cp,ep-cp, _("%d video tracks\n"), vtrks); for( int vtrk=0; vtrk 0 ) { double secs = (double)frames / frame_rate; - cp += sprintf(cp, " (%0.3f secs)",secs); + cp += snprintf(cp,ep-cp, _(" (%0.3f secs)"),secs); } *cp++ = '\n'; } int atrks = mpeg3_total_astreams(fd); - cp += sprintf(cp, "%d audio tracks\n", atrks); + cp += snprintf(cp,ep-cp, _("%d audio tracks\n"), atrks); for( int atrk=0; atrk= 0 ? '+' : (nudge=-nudge, '-'); - cp += sprintf(cp, "%ld samples",nudge); + cp += snprintf(cp,ep-cp, _("%ld samples"),nudge); if( sample_rate > 0 ) { double secs = (double)(samples+nudge) / sample_rate; - cp += sprintf(cp, " (%0.3f secs)",secs); + cp += snprintf(cp,ep-cp, _(" (%0.3f secs)"),secs); } *cp++ = '\n'; } int stracks = mpeg3_subtitle_tracks(fd); if( stracks > 0 ) { - cp += sprintf(cp, "%d subtitles\n", stracks); + cp += snprintf(cp,ep-cp, _("%d subtitles\n"), stracks); } int vts_titles = mpeg3_get_total_vts_titles(fd); if( vts_titles > 0 ) - cp += sprintf(cp, "%d title sets, ", vts_titles); + cp += snprintf(cp,ep-cp, _("%d title sets, "), vts_titles); int interleaves = mpeg3_get_total_interleaves(fd); if( interleaves > 0 ) - cp += sprintf(cp, "%d interleaves\n", interleaves); + cp += snprintf(cp,ep-cp, _("%d interleaves\n"), interleaves); int vts_title = mpeg3_set_vts_title(fd, -1); int angle = mpeg3_set_angle(fd, -1); int interleave = mpeg3_set_interleave(fd, -1); int program = mpeg3_set_program(fd, -1); - cp += sprintf(cp, "current program %d = title %d, angle %d, interleave %d\n\n", + cp += snprintf(cp,ep-cp, _("current program %d = title %d, angle %d, interleave %d\n\n"), program, vts_title, angle, interleave); ArrayList cell_times; @@ -241,21 +241,21 @@ void FileMPEG::get_info(char *title_path, char *path, char *text) cell_times.append(cell_time); } if( cell_times.size() > 1 ) { - cp += sprintf(cp, "cell times:"); + cp += snprintf(cp,ep-cp, _("cell times:")); for( int i=0; i= 0; ++i ) { @@ -306,6 +306,7 @@ void FileMPEG::get_info(char *title_path, char *path, char *text) } } + *cp = 0; mpeg3_close(fd); return; } @@ -391,16 +392,16 @@ int FileMPEG::open_file(int rd, int wr) if( !fd ) { result = 1; if(error == zmpeg3_t::ERR_INVALID_TOC_VERSION) { - eprintf("Couldn't open %s: invalid table of contents version.\n" - "Rebuilding the table of contents.", asset->path); + eprintf(_("Couldn't open %s: invalid table of contents version.\n" + "Rebuilding the table of contents."), asset->path); } else if(error == zmpeg3_t::ERR_TOC_DATE_MISMATCH) { - eprintf("Couldn't open %s: table of contents out of date.\n" - "Rebuilding the table of contents.", asset->path); + eprintf(_("Couldn't open %s: table of contents out of date.\n" + "Rebuilding the table of contents."), asset->path); } else { - eprintf("Couldn't open %s: table of contents corrupt.\n" - "Rebuilding the table of contents.", asset->path); + eprintf(_("Couldn't open %s: table of contents corrupt.\n" + "Rebuilding the table of contents."), asset->path); } char filename[BCTEXTLEN]; strcpy(filename, toc_name); @@ -414,7 +415,7 @@ int FileMPEG::open_file(int rd, int wr) if( fd ) result = 0; } if( result ) - eprintf("Couldn't open %s: rebuild failed.\n", asset->path); + eprintf(_("Couldn't open %s: rebuild failed.\n"), asset->path); } if(!result) { // Determine if the file needs a table of contents and create one if needed. @@ -483,10 +484,9 @@ int FileMPEG::open_file(int rd, int wr) // Construct command line if(!result) { - char string[BCTEXTLEN]; string[0] = 0; - sprintf(mjpeg_command, "%s%s", - file->preferences->plugin_dir, HVPEG_EXE); - append_vcommand_line(string); + char string[BCTEXTLEN]; + get_exe_path(string); + sprintf(mjpeg_command, "%s/%s", string, HVPEG_EXE); if(asset->aspect_ratio > 0) { @@ -518,7 +518,6 @@ int FileMPEG::open_file(int rd, int wr) append_vcommand_line("-q"); append_vcommand_line(quant_string); } - append_vcommand_line(!asset->vmpeg_fix_bitrate ? quant_string : ""); append_vcommand_line("-n"); append_vcommand_line(iframe_string); append_vcommand_line(asset->vmpeg_progressive ? "-p" : ""); @@ -535,8 +534,9 @@ int FileMPEG::open_file(int rd, int wr) // mjpegtools encoder // this one is cinelerra-x.x.x/thirdparty/mjpegtools/mpeg2enc { - sprintf(mjpeg_command, "%s%s -v 0 ", - file->preferences->plugin_dir, MJPEG_EXE); + char string[BCTEXTLEN]; + get_exe_path(string); + sprintf(mjpeg_command, "%s/%s -v 0 ", string, MJPEG_EXE); // Must disable interlacing if MPEG-1 switch (asset->vmpeg_preset) @@ -550,7 +550,6 @@ int FileMPEG::open_file(int rd, int wr) // The current usage of mpeg2enc requires bitrate of 0 when quantization is fixed and // quantization of 1 when bitrate is fixed. Perfectly intuitive. - char string[BCTEXTLEN]; if(asset->vmpeg_fix_bitrate) { sprintf(string, " -b %d -q 1", asset->vmpeg_bitrate / 1000); @@ -588,7 +587,7 @@ int FileMPEG::open_file(int rd, int wr) if(aspect_ratio_code < 0) { - eprintf("Unsupported aspect ratio %f\n", asset->aspect_ratio); + eprintf(_("Unsupported aspect ratio %f\n"), asset->aspect_ratio); aspect_ratio_code = 2; } sprintf(string, " -a %d", aspect_ratio_code); @@ -613,7 +612,7 @@ int FileMPEG::open_file(int rd, int wr) if(frame_rate_code < 0) { frame_rate_code = 4; - eprintf("Unsupported frame rate %f\n", asset->frame_rate); + eprintf(_("Unsupported frame rate %f\n"), asset->frame_rate); } sprintf(string, " -F %d", frame_rate_code); strcat(mjpeg_command, string); @@ -660,7 +659,7 @@ int FileMPEG::open_file(int rd, int wr) if(!(mjpeg_out = popen(mjpeg_command, "w"))) { perror("FileMPEG::open_file"); - eprintf("Error while opening \"%s\" for writing\n%m\n", mjpeg_command); + eprintf(_("Error while opening \"%s\" for writing\n%m\n"), mjpeg_command); return 1; } @@ -708,7 +707,7 @@ int FileMPEG::open_file(int rd, int wr) if(!(lame_fd = fopen(asset->path, "w"))) { perror("FileMPEG::open_file"); - eprintf("Error while opening \"%s\" for writing\n%m\n", asset->path); + eprintf(_("Error while opening \"%s\" for writing\n%m\n"), asset->path); lame_close(lame_global); lame_global = 0; result = 1; @@ -716,7 +715,7 @@ int FileMPEG::open_file(int rd, int wr) } else { - eprintf("ampeg_derivative=%d\n", asset->ampeg_derivative); + eprintf(_("ampeg_derivative=%d\n"), asset->ampeg_derivative); result = 1; } } @@ -728,7 +727,7 @@ int FileMPEG::open_file(int rd, int wr) S_IRUSR+S_IWUSR + S_IRGRP+S_IWGRP)) < 0 ) { perror("FileMPEG::open_file"); - eprintf("Error while opening \"%s\" for writing\n%m\n", asset->path); + eprintf(_("Error while opening \"%s\" for writing\n%m\n"), asset->path); result = 1; } } @@ -822,7 +821,7 @@ int FileMPEG::create_index() fd = mpeg3_start_toc( asset->path, index_filename, file->current_program, &total_bytes); if( !fd ) { - eprintf("cant init toc index\n"); + eprintf(_("cant init toc index\n")); result = 1; } @@ -832,13 +831,13 @@ int FileMPEG::create_index() if( !result && file->preferences->scan_commercials ) { set_skimming(-1, 1, toc_nail, file); if( (result=MWindow::commercials->resetDb() ) != 0 ) - eprintf("cant access commercials database"); + eprintf(_("cant access commercials database")); } char progress_title[BCTEXTLEN]; progress_title[0] = 0; BC_ProgressBox *progress = 0; if( !result ) { - sprintf(progress_title, "Creating %s\n", index_filename); + sprintf(progress_title, _("Creating %s\n"), index_filename); progress = new BC_ProgressBox(-1, -1, progress_title, total_bytes); progress->start(); @@ -870,7 +869,7 @@ int FileMPEG::create_index() if(bytes_processed >= total_bytes) break; if(progress->is_cancelled()) result = 1; if( bytes_processed == last_bytes ) { - eprintf("toc scan stopped before eof"); + eprintf(_("toc scan stopped before eof")); break; } last_bytes = bytes_processed; @@ -944,7 +943,7 @@ int FileMPEG::close_file() if( ret > 0 ) fwrite(opkt, 1, ret, twofp); else if( ret < 0 ) - fprintf(stderr, "twolame error encoding audio: %d\n", ret); + fprintf(stderr, _("twolame error encoding audio: %d\n"), ret); fclose(twofp); twofp = 0; } if( twopts ) { twolame_close(&twopts); twopts = 0; } @@ -1012,7 +1011,7 @@ int FileMPEG::get_best_colormodel(Asset *asset, int driver) case CAPTURE_IEC61883: return BC_YUV422P; } - eprintf("unknown driver %d\n",driver); + eprintf(_("unknown driver %d\n"),driver); return BC_RGB888; } @@ -1027,56 +1026,23 @@ int FileMPEG::get_index(char *index_path) // Convert the index tables from tracks to channels. - if(mpeg3_index_tracks(fd)) - { -// Calculate size of buffer needed for all channels - int buffer_size = 0; - for(int i = 0; i < mpeg3_index_tracks(fd); i++) - { - buffer_size += mpeg3_index_size(fd, i) * - mpeg3_index_channels(fd, i) * - 2; - } - + if(mpeg3_index_tracks(fd)) { IndexState *index_state = asset->index_state; - index_state->index_buffer = new float[buffer_size]; - - int index_channels = 0; - for(int i = 0; i < mpeg3_index_tracks(fd); i++) - index_channels += mpeg3_index_channels(fd, i); -// Size of index buffer in floats - int current_offset = 0; -// Current asset channel - int current_channel = 0; - index_state->channels = index_channels; - index_state->index_zoom = mpeg3_index_zoom(fd); - index_state->index_offsets = new int64_t[index_channels]; - index_state->index_sizes = new int64_t[index_channels]; - for(int i = 0; i < mpeg3_index_tracks(fd); i++) - { - for(int j = 0; j < mpeg3_index_channels(fd, i); j++) - { - index_state->index_offsets[current_channel] = current_offset; - index_state->index_sizes[current_channel] = mpeg3_index_size(fd, i) * 2; - memcpy(index_state->index_buffer + current_offset, - mpeg3_index_data(fd, i, j), - mpeg3_index_size(fd, i) * sizeof(float) * 2); - - current_offset += mpeg3_index_size(fd, i) * 2; - current_channel++; + int index_zoom = mpeg3_index_zoom(fd); + int ntracks = mpeg3_index_tracks(fd); + int64_t offset = 0; + for(int i = 0; i < ntracks; i++) { + int nch = mpeg3_index_channels(fd, i); + for(int j = 0; j < nch; j++) { + float *bfr = (float *)mpeg3_index_data(fd, i, j); + int64_t size = 2*mpeg3_index_size(fd, i); + index_state->add_index_entry(bfr, offset, size); + offset += size; } } - FileSystem fs; - index_state->index_bytes = fs.get_size(asset->path); - - index_state->write_index(index_path, - buffer_size * sizeof(float), - asset, - asset->audio_length); - delete [] index_state->index_buffer; - - return 0; + int64_t file_bytes = fs.get_size(asset->path); + return index_state->write_index(index_path, asset, index_zoom, file_bytes); } return 1; @@ -1190,7 +1156,6 @@ int FileMPEG::select_video_stream(Asset *asset, int vstream) int FileMPEG::select_audio_stream(Asset *asset, int astream) { if( !fd ) return -1; - asset->channels = mpeg3_audio_channels(fd, astream); asset->sample_rate = mpeg3_sample_rate(fd, astream); asset->audio_length = mpeg3_audio_samples(fd, astream); return 0; @@ -1236,7 +1201,7 @@ int FileMPEG::write_samples(double **buffer, int64_t len) if( ret > 0 ) fwrite(twolame_out, 1, ret, twofp); else if( ret < 0 ) - fprintf(stderr, "twolame error encoding audio: %d\n", ret); + fprintf(stderr, _("twolame error encoding audio: %d\n"), ret); } else if(asset->ampeg_derivative == 3) @@ -1297,7 +1262,7 @@ int FileMPEG::write_samples(double **buffer, int64_t len) result = !fwrite(real_output, 1, bytes, lame_fd); if(result) { perror("FileMPEG::write_samples"); - eprintf("write failed: %m"); + eprintf(_("write failed: %m")); } } else @@ -1682,17 +1647,6 @@ int FileMPEG::read_samples(double *buffer, int64_t len) return 0; } -const char* FileMPEG::strtocompression(char *string) -{ - return ""; -} - -const char* FileMPEG::compressiontostr(char *string) -{ - return ""; -} - - @@ -1808,7 +1762,7 @@ void FileMPEGVideo::run() MPEGConfigAudio::MPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset) - : BC_Window(PROGRAM_NAME ": Audio Compression", + : BC_Window(_(PROGRAM_NAME ": Audio Compression"), parent_window->get_abs_cursor_x(1), parent_window->get_abs_cursor_y(1), 310, @@ -2003,7 +1957,7 @@ char* MPEGABitrate::bitrate_to_string(char *string, int bitrate) MPEGConfigVideo::MPEGConfigVideo(BC_WindowBase *parent_window, Asset *asset) - : BC_Window(PROGRAM_NAME ": Video Compression", + : BC_Window(_(PROGRAM_NAME ": Video Compression"), parent_window->get_abs_cursor_x(1), parent_window->get_abs_cursor_y(1), 500,