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
1168 if (frame_rate.num > 0 && frame_rate.den > 0)1168 if (frame_rate.num > 0 && frame_rate.den > 0)
1169 duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base));1169 duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base));
1170 1170
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)
1172 duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base)));1172 duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base)));
1173 1173
1174 if (!ost->filters_script &&1174 if (!ost->filters_script &&
@@ -2625,9 +2625,11 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 1450 unmodified lines
2625 avpkt = ist->pkt;2625 avpkt = ist->pkt;
2626 2626
2627 if (!ist->saw_first_ts) {2627 if (!ist->saw_first_ts) {
2628 ist->first_dts =
2628 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;2629 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;
2629 ist->pts = 0;2630 ist->pts = 0;
2630 if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) {2631 if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) {
2632 ist->first_dts =
2631 ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);2633 ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
2632 ist->pts = ist->dts; //unused but better to set it to a value thats not totally wrong2634 ist->pts = ist->dts; //unused but better to set it to a value thats not totally wrong
2633 }2635 }
@@ -3949,10 +3951,10 @@ static OutputStream *choose_output(void) · 1315 unmodified lines
3949 3951
3950 for (i = 0; i < nb_output_streams; i++) {3952 for (i = 0; i < nb_output_streams; i++) {
3951 OutputStream *ost = output_streams[i];3953 OutputStream *ost = output_streams[i];
3952 int64_t opts = ost->st->cur_dts == AV_NOPTS_VALUE ? INT64_MIN :3954 int64_t opts = ost->last_mux_dts == AV_NOPTS_VALUE ? INT64_MIN :
3953 av_rescale_q(ost->st->cur_dts, ost->st->time_base,3955 av_rescale_q(ost->last_mux_dts, ost->st->time_base,
3954 AV_TIME_BASE_Q);3956 AV_TIME_BASE_Q);
3955 if (ost->st->cur_dts == AV_NOPTS_VALUE)3957 if (ost->last_mux_dts == AV_NOPTS_VALUE)
3956 av_log(NULL, AV_LOG_DEBUG,3958 av_log(NULL, AV_LOG_DEBUG,
3957 "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",3959 "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",
3958 ost->st->index, ost->st->id, ost->initialized, ost->inputs_done, ost->finished);3960 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
316 /* predicted dts of the next packet read for this stream or (when there are316 /* predicted dts of the next packet read for this stream or (when there are
317 * several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */317 * several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
318 int64_t next_dts;318 int64_t next_dts;
319 int64_t first_dts; ///< dts of the first packet read for this stream (in AV_TIME_BASE units)
319 int64_t dts; ///< dts of the last packet read for this stream (in AV_TIME_BASE units)320 int64_t dts; ///< dts of the last packet read for this stream (in AV_TIME_BASE units)
320 321
321 int64_t next_pts; ///< synthetic pts for the next decode frame (in AV_TIME_BASE units)322 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
809 ist->discard = 1;809 ist->discard = 1;
810 st->discard = AVDISCARD_ALL;810 st->discard = AVDISCARD_ALL;
811 ist->nb_samples = 0;811 ist->nb_samples = 0;
812 ist->first_dts = AV_NOPTS_VALUE;
812 ist->min_pts = INT64_MAX;813 ist->min_pts = INT64_MAX;
813 ist->max_pts = INT64_MIN;814 ist->max_pts = INT64_MIN;
814 815

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