diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-06-23 19:30:15 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2011-07-08 19:58:23 +0200 |
commit | 27e91f37f58d122f94d9d9b30c6355d2dd2b0e49 (patch) | |
tree | 492f189984d5e20d0005c0a17c9e053092387358 /ffmpeg.c | |
parent | 9e253c13d0f019359bdddc75aa5adba59e2a793d (diff) | |
download | ffmpeg-27e91f37f58d122f94d9d9b30c6355d2dd2b0e49.tar.gz |
ffmpeg: merge input_files_ts_offset into input_files.
Diffstat (limited to 'ffmpeg.c')
-rw-r--r-- | ffmpeg.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -107,7 +107,6 @@ static const OptionDef options[]; #define FFM_PACKET_SIZE 4096 //XXX a duplicate of the line in ffm.h static const char *last_asked_format = NULL; -static int64_t input_files_ts_offset[MAX_FILES]; static double *input_files_ts_scale[MAX_FILES] = {NULL}; static int nb_input_files_ts_scale[MAX_FILES] = {0}; @@ -329,6 +328,7 @@ typedef struct InputFile { int eof_reached; /* true if eof reached */ int ist_index; /* index of first stream in ist_table */ int buffer_size; /* current total buffer size */ + int64_t ts_offset; } InputFile; static InputStream *input_streams = NULL; @@ -1671,7 +1671,7 @@ static int output_packet(InputStream *ist, int ist_index, os = output_files[ost->file_index]; /* set the input output pts pairs */ - //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index] - start_time)/ AV_TIME_BASE; + //ost->sync_ipts = (double)(ist->pts + input_files[ist->file_index].ts_offset - start_time)/ AV_TIME_BASE; if (ost->encoding_needed) { av_assert0(ist->decoding_needed); @@ -1882,7 +1882,7 @@ static int copy_chapters(int infile, int outfile) for (i = 0; i < is->nb_chapters; i++) { AVChapter *in_ch = is->chapters[i], *out_ch; - int64_t ts_off = av_rescale_q(start_time - input_files_ts_offset[infile], + int64_t ts_off = av_rescale_q(start_time - input_files[infile].ts_offset, AV_TIME_BASE_Q, in_ch->time_base); int64_t rt = (recording_time == INT64_MAX) ? INT64_MAX : av_rescale_q(recording_time, AV_TIME_BASE_Q, in_ch->time_base); @@ -2613,9 +2613,9 @@ static int transcode(AVFormatContext **output_files, goto discard_packet; if (pkt.dts != AV_NOPTS_VALUE) - pkt.dts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base); + pkt.dts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) - pkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base); + pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.stream_index < nb_input_files_ts_scale[file_index] && input_files_ts_scale[file_index][pkt.stream_index]){ @@ -2625,15 +2625,16 @@ static int transcode(AVFormatContext **output_files, pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index]; } -// fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type); +// fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files[ist->file_index].ts_offset, ist->st->codec->codec_type); if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE && (is->iformat->flags & AVFMT_TS_DISCONT)) { int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta= pkt_dts - ist->next_pts; if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){ - input_files_ts_offset[ist->file_index]-= delta; + input_files[ist->file_index].ts_offset -= delta; if (verbose > 2) - fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]); + fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", + delta, input_files[ist->file_index].ts_offset); pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); if(pkt.pts != AV_NOPTS_VALUE) pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); @@ -3357,7 +3358,6 @@ static int opt_input_file(const char *opt, const char *filename) } } - input_files_ts_offset[nb_input_files] = input_ts_offset - (copy_ts ? 0 : timestamp); /* dump the file content */ if (verbose >= 0) av_dump_format(ic, nb_input_files, filename, 0); @@ -3365,6 +3365,7 @@ static int opt_input_file(const char *opt, const char *filename) input_files = grow_array(input_files, sizeof(*input_files), &nb_input_files, nb_input_files + 1); input_files[nb_input_files - 1].ctx = ic; input_files[nb_input_files - 1].ist_index = nb_input_streams - ic->nb_streams; + input_files[nb_input_files - 1].ts_offset = input_ts_offset - (copy_ts ? 0 : timestamp); frame_rate = (AVRational){0, 0}; frame_pix_fmt = PIX_FMT_NONE; |