History

fftools/ffmpeg: remove usage of internal timestamp AVStream fields

They should not be accessed outside of libavformat.

James Almer committed 5 years ago

Commit ab4f2991 parent 57de8063 files · +8 −4Browse files

Unified · Split

3 files
  1. fftools/ffmpeg.c +6 −4
  2. fftools/ffmpeg.h +1 −0
  3. fftools/ffmpeg_opt.c +1 −0
fftools/ffmpeg.c+6−4
@@ -1168,7 +1168,7 @@ static void do_video_out(OutputFile *of, · 1167 unmodified lines
11681168 if (frame_rate.num > 0 && frame_rate.den > 0)
11691169 duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base));
11701170
1171− if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num)
1171+ if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num)
11721172 duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base)));
11731173
11741174 if (!ost->filters_script &&
@@ -2625,9 +2625,11 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 1450 unmodified lines
26252625 avpkt = ist->pkt;
26262626
26272627 if (!ist->saw_first_ts) {
2628+ ist->first_dts =
26282629 ist->dts = ist->st->avg_frame_rate.num ? - ist->dec_ctx->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
26292630 ist->pts = 0;
26302631 if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) {
2632+ ist->first_dts =
26312633 ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
26322634 ist->pts = ist->dts; //unused but better to set it to a value thats not totally wrong
26332635 }
@@ -3949,10 +3951,10 @@ static OutputStream *choose_output(void) · 1315 unmodified lines
39493951
39503952 for (i = 0; i < nb_output_streams; i++) {
39513953 OutputStream *ost = output_streams[i];
3952− int64_t opts = ost->st->cur_dts == AV_NOPTS_VALUE ? INT64_MIN :
3953− av_rescale_q(ost->st->cur_dts, ost->st->time_base,
3954+ int64_t opts = ost->last_mux_dts == AV_NOPTS_VALUE ? INT64_MIN :
3955+ av_rescale_q(ost->last_mux_dts, ost->st->time_base,
39543956 AV_TIME_BASE_Q);
3955− if (ost->st->cur_dts == AV_NOPTS_VALUE)
3957+ if (ost->last_mux_dts == AV_NOPTS_VALUE)
39563958 av_log(NULL, AV_LOG_DEBUG,
39573959 "cur_dts is invalid st:%d (%d) [init:%d i_done:%d finish:%d] (this is harmless if it occurs once at the start per stream)\n",
39583960 ost->st->index, ost->st->id, ost->initialized, ost->inputs_done, ost->finished);
fftools/ffmpeg.h+1−0
@@ -316,6 +316,7 @@ typedef struct InputStream { · 315 unmodified lines
316316 /* predicted dts of the next packet read for this stream or (when there are
317317 * several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
318318 int64_t next_dts;
319+ int64_t first_dts; ///< dts of the first packet read for this stream (in AV_TIME_BASE units)
319320 int64_t dts; ///< dts of the last packet read for this stream (in AV_TIME_BASE units)
320321
321322 int64_t next_pts; ///< synthetic pts for the next decode frame (in AV_TIME_BASE units)
fftools/ffmpeg_opt.c+1−0
@@ -809,6 +809,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) · 808 unmodified lines
809809 ist->discard = 1;
810810 st->discard = AVDISCARD_ALL;
811811 ist->nb_samples = 0;
812+ ist->first_dts = AV_NOPTS_VALUE;
812813 ist->min_pts = INT64_MAX;
813814 ist->max_pts = INT64_MIN;
814815

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t