X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.0%2Fcinelerra%2Ffilempeg.C;h=dfd271818a19008edae83f06d9dc3de9aa3060ac;hb=e3c81d537528ce9e4300d54fc5c89e20c21070a0;hp=584dc1891041f9ab029acb91086ecf049afe72e8;hpb=f9d0d999e813ae19965e07ae2f7da690b4e6fe45;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.0/cinelerra/filempeg.C b/cinelerra-5.0/cinelerra/filempeg.C index 584dc189..dfd27181 100644 --- a/cinelerra-5.0/cinelerra/filempeg.C +++ b/cinelerra-5.0/cinelerra/filempeg.C @@ -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; } @@ -1189,7 +1190,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;