summaryrefslogtreecommitdiff
path: root/libavcodec/encode.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2020-05-15 20:24:19 -0300
committerJames Almer <jamrial@gmail.com>2020-05-25 12:46:22 -0300
commitcde7818d9f1774e2114b4fa3f051546fbed603f6 (patch)
tree0b51812b40d9cc0f9519dba1dd991c70e5c2c290 /libavcodec/encode.c
parent82bf41f3abce4a13e7c6ad1606eb708f371de87f (diff)
avcodec/frame_thread_encoder: remove usage of avcodec_encode_video2()
Call the encoder's internal AVCodec.encode2() function instead. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/encode.c')
-rw-r--r--libavcodec/encode.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 03d579fd4e..b850f86d0c 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -277,14 +277,12 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
return AVERROR(ENOSYS);
}
- if(CONFIG_FRAME_THREAD_ENCODER &&
- avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))
- return ff_thread_video_encode_frame(avctx, avpkt, frame, got_packet_ptr);
-
if ((avctx->flags&AV_CODEC_FLAG_PASS1) && avctx->stats_out)
avctx->stats_out[0] = '\0';
- if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
+ if (!frame &&
+ !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY ||
+ (avctx->internal->frame_thread_encoder && avctx->active_thread_type & FF_THREAD_FRAME))) {
av_packet_unref(avpkt);
return 0;
}
@@ -299,7 +297,15 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
av_assert0(avctx->codec->encode2);
- ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
+
+ if (CONFIG_FRAME_THREAD_ENCODER &&
+ avctx->internal->frame_thread_encoder && (avctx->active_thread_type & FF_THREAD_FRAME))
+ ret = ff_thread_video_encode_frame(avctx, avpkt, frame, got_packet_ptr);
+ else {
+ ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
+ if (*got_packet_ptr && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))
+ avpkt->pts = avpkt->dts = frame->pts;
+ }
av_assert0(ret <= 0);
emms_c();
@@ -326,8 +332,6 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
if (!ret) {
if (!*got_packet_ptr)
avpkt->size = 0;
- else if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))
- avpkt->pts = avpkt->dts = frame->pts;
if (needs_realloc && avpkt->data) {
ret = av_buffer_realloc(&avpkt->buf, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE);