mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-02-04 14:30:55 +08:00
avcodec/frame_thread_encoder: Stop serializing unreferencing AVFrames
Currently, the frame-threaded decoding API still supports thread-unsafe callbacks. If one uses a thread-unsafe get_buffer2() callback, calls to av_frame_unref() by the decoder are serialized, because it is presumed that the underlying deallocator is thread-unsafe. The frame-threaded encoder seems to have been written with this restriction in mind: It always serializes unreferencing its AVFrames, although no documentation forces it to do so. This commit schedules to change this behaviour as soon as thread-unsafe callbacks are removed. For this reason, the FF_API_THREAD_SAFE_CALLBACKS define is reused. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -190,7 +190,7 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
|
||||
}
|
||||
|
||||
int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
const AVFrame *frame, int *got_packet)
|
||||
AVFrame *frame, int *got_packet)
|
||||
{
|
||||
const FFCodec *const codec = ffcodec(avctx->codec);
|
||||
int ret;
|
||||
@@ -227,6 +227,10 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
unref:
|
||||
av_packet_unref(avpkt);
|
||||
}
|
||||
#if !FF_API_THREAD_SAFE_CALLBACKS
|
||||
if (frame)
|
||||
av_frame_unref(frame);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -267,8 +271,10 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
|
||||
ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet);
|
||||
else {
|
||||
ret = ff_encode_encode_cb(avctx, avpkt, frame, &got_packet);
|
||||
#if FF_API_THREAD_SAFE_CALLBACKS
|
||||
if (frame)
|
||||
av_frame_unref(frame);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (avci->draining && !got_packet)
|
||||
|
||||
Reference in New Issue
Block a user