diff options
author | Mark Thompson <sw@jkqxz.net> | 2024-02-25 11:13:24 +0000 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2024-03-19 22:56:56 +0000 |
commit | 7f4b8d2f5e1a780eaefff528b1dd5070c42f496f (patch) | |
tree | 42fe99eaa495873e5d85b813e4128c16d2fb27f3 /fftools/ffmpeg_sched.c | |
parent | 7251f909721a570726775acf61b2b9c28a950c76 (diff) | |
download | ffmpeg-7f4b8d2f5e1a780eaefff528b1dd5070c42f496f.tar.gz |
ffmpeg: set extra_hw_frames to account for frames held in queues
Since e0da916b8f5b079a4865eef7f64863f50785463d the ffmpeg utility has
held multiple frames output by the decoder in internal queues without
telling the decoder that it is going to do so. When the decoder has a
fixed-size pool of frames (common in some hardware APIs where the output
frames must be stored as an array texture) this could lead to the pool
being exhausted and the decoder getting stuck. Fix this by telling the
decoder to allocate additional frames according to the queue size.
Diffstat (limited to 'fftools/ffmpeg_sched.c')
-rw-r--r-- | fftools/ffmpeg_sched.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index f739066921..ec88017e21 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -365,7 +365,21 @@ static int queue_alloc(ThreadQueue **ptq, unsigned nb_streams, unsigned queue_si ThreadQueue *tq; ObjPool *op; - queue_size = queue_size > 0 ? queue_size : 8; + if (queue_size <= 0) { + if (type == QUEUE_FRAMES) + queue_size = DEFAULT_FRAME_THREAD_QUEUE_SIZE; + else + queue_size = DEFAULT_PACKET_THREAD_QUEUE_SIZE; + } + + if (type == QUEUE_FRAMES) { + // This queue length is used in the decoder code to ensure that + // there are enough entries in fixed-size frame pools to account + // for frames held in queues inside the ffmpeg utility. If this + // can ever dynamically change then the corresponding decode + // code needs to be updated as well. + av_assert0(queue_size == DEFAULT_FRAME_THREAD_QUEUE_SIZE); + } op = (type == QUEUE_PACKETS) ? objpool_alloc_packets() : objpool_alloc_frames(); |