mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-06-16 04:32:47 +02:00
avcodec: allow bypassing frame threading with an optional flag
Normally, this function tries to make sure all threads are saturated with work to do before returning any frames; and will continue requesting packets until that is the case. However, this significantly slows down initial decoding latency when only requesting a single frame (to e.g. configure the filter graph), and also wastes a lot of unnecessary memory in the event that the user does not intend to decode more frames until later. By introducing a new `flags` paramater and a new flag `AV_CODEC_RECEIVE_FRAME_FLAG_SYNCHRONOUS` to go along with it, we can allow users to temporarily bypass this logic.
This commit is contained in:
@@ -705,7 +705,8 @@ int avcodec_is_open(AVCodecContext *s)
|
||||
return !!s->internal;
|
||||
}
|
||||
|
||||
int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
|
||||
int attribute_align_arg avcodec_receive_frame2(AVCodecContext *avctx,
|
||||
AVFrame *frame, unsigned flags)
|
||||
{
|
||||
av_frame_unref(frame);
|
||||
|
||||
@@ -713,10 +714,15 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
if (ff_codec_is_decoder(avctx->codec))
|
||||
return ff_decode_receive_frame(avctx, frame);
|
||||
return ff_decode_receive_frame(avctx, frame, flags);
|
||||
return ff_encode_receive_frame(avctx, frame);
|
||||
}
|
||||
|
||||
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
|
||||
{
|
||||
return avcodec_receive_frame2(avctx, frame, 0);
|
||||
}
|
||||
|
||||
#define WRAP_CONFIG(allowed_type, field, var, field_type, sentinel_check) \
|
||||
do { \
|
||||
if (codec->type != (allowed_type)) \
|
||||
|
||||
Reference in New Issue
Block a user