History

fftools/sync_queue: use timebase from input frames/packets

They are always properly set now. Avoid a separate timebase-setting call, which duplicates the knowledge of the timebase being used.

Anton Khirnov committed 3 years ago

Commit 090950f1 parent 87e9f5a4 files · +22 −29Browse files

Showing the changes to fftools/sync_queue.c (1 of 4 files). Show all

Unified · Split

fftools/sync_queue.c+22−17
@@ -84,6 +84,26 @@ static int frame_null(const SyncQueue *sq, SyncQueueFrame frame) · 83 unmodified lines
8484 return (sq->type == SYNC_QUEUE_PACKETS) ? (frame.p == NULL) : (frame.f == NULL);
8585 }
8686
87+static void tb_update(const SyncQueue *sq, SyncQueueStream *st,
88+ const SyncQueueFrame frame)
89+{
90+ AVRational tb = (sq->type == SYNC_QUEUE_PACKETS) ?
91+ frame.p->time_base : frame.f->time_base;
92+
93+ av_assert0(tb.num > 0 && tb.den > 0);
94+
95+ if (tb.num == st->tb.num && tb.den == st->tb.den)
96+ return;
97+
98+ // timebase should not change after the first frame
99+ av_assert0(!av_fifo_can_read(st->fifo));
100+
101+ if (st->head_ts != AV_NOPTS_VALUE)
102+ st->head_ts = av_rescale_q(st->head_ts, st->tb, tb);
103+
104+ st->tb = tb;
105+}
106+
87107 static void finish_stream(SyncQueue *sq, unsigned int stream_idx)
88108 {
89109 SyncQueueStream *st = &sq->streams[stream_idx];
@@ -241,8 +261,6 @@ int sq_send(SyncQueue *sq, unsigned int stream_idx, SyncQueueFrame frame) · 151 unmodified lines
241261 av_assert0(stream_idx < sq->nb_streams);
242262 st = &sq->streams[stream_idx];
243263
244− av_assert0(st->tb.num > 0 && st->tb.den > 0);
245−
246264 if (frame_null(sq, frame)) {
247265 finish_stream(sq, stream_idx);
248266 return 0;
@@ -250,6 +268,8 @@ int sq_send(SyncQueue *sq, unsigned int stream_idx, SyncQueueFrame frame) · 1 unmodified line
250268 if (st->finished)
251269 return AVERROR_EOF;
252270
271+ tb_update(sq, st, frame);
272+
253273 ret = objpool_get(sq->pool, (void**)&dst);
254274 if (ret < 0)
255275 return ret;
@@ -375,21 +395,6 @@ int sq_add_stream(SyncQueue *sq, int limiting) · 119 unmodified lines
375395 return sq->nb_streams++;
376396 }
377397
378−void sq_set_tb(SyncQueue *sq, unsigned int stream_idx, AVRational tb)
379−{
380− SyncQueueStream *st;
381−
382− av_assert0(stream_idx < sq->nb_streams);
383− st = &sq->streams[stream_idx];
384−
385− av_assert0(!av_fifo_can_read(st->fifo));
386−
387− if (st->head_ts != AV_NOPTS_VALUE)
388− st->head_ts = av_rescale_q(st->head_ts, st->tb, tb);
389−
390− st->tb = tb;
391−}
392−
393398 void sq_limit_frames(SyncQueue *sq, unsigned int stream_idx, uint64_t frames)
394399 {
395400 SyncQueueStream *st;

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