summaryrefslogtreecommitdiff
path: root/libavcodec/pthread_frame.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2021-02-03 15:24:58 -0300
committerJames Almer <jamrial@gmail.com>2021-03-17 15:06:47 -0300
commitb0de31e2784fa02aeafb1d892dc0e9d0f9662369 (patch)
treeb61addaecca27e0ba724c34bfa176af31e301133 /libavcodec/pthread_frame.c
parentca966af4977efa74cf30979561d025a5df528d49 (diff)
avcodec/pthread_frame: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/pthread_frame.c')
-rw-r--r--libavcodec/pthread_frame.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 4429a4d59c..7bcb9a7bcc 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -81,7 +81,7 @@ typedef struct PerThreadContext {
AVCodecContext *avctx; ///< Context used to decode packets passed to this thread.
- AVPacket avpkt; ///< Input packet (for decoding) or output (for encoding).
+ AVPacket *avpkt; ///< Input packet (for decoding) or output (for encoding).
AVFrame *frame; ///< Output frame (for decoding) or input (for encoding).
int got_frame; ///< The output of got_picture_ptr from the last avcodec_decode_video() call.
@@ -208,7 +208,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_frame_unref(p->frame);
p->got_frame = 0;
- p->result = codec->decode(avctx, p->frame, &p->got_frame, &p->avpkt);
+ p->result = codec->decode(avctx, p->frame, &p->got_frame, p->avpkt);
if ((p->result < 0 || !p->got_frame) && p->frame->buf[0]) {
if (avctx->codec->caps_internal & FF_CODEC_CAP_ALLOCATE_PROGRESS)
@@ -438,8 +438,8 @@ static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx,
}
}
- av_packet_unref(&p->avpkt);
- ret = av_packet_ref(&p->avpkt, avpkt);
+ av_packet_unref(p->avpkt);
+ ret = av_packet_ref(p->avpkt, avpkt);
if (ret < 0) {
pthread_mutex_unlock(&p->mutex);
av_log(p->avctx, AV_LOG_ERROR, "av_packet_ref() failed in submit_packet()\n");
@@ -550,7 +550,7 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
av_frame_move_ref(picture, p->frame);
*got_picture_ptr = p->got_frame;
- picture->pkt_dts = p->avpkt.dts;
+ picture->pkt_dts = p->avpkt->dts;
err = p->result;
/*
@@ -725,7 +725,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
pthread_cond_destroy(&p->input_cond);
pthread_cond_destroy(&p->progress_cond);
pthread_cond_destroy(&p->output_cond);
- av_packet_unref(&p->avpkt);
+ av_packet_free(&p->avpkt);
#if FF_API_THREAD_SAFE_CALLBACKS
for (int j = 0; j < p->released_buffers_allocated; j++)
@@ -822,6 +822,12 @@ int ff_frame_thread_init(AVCodecContext *avctx)
err = AVERROR(ENOMEM);
goto error;
}
+ p->avpkt = av_packet_alloc();
+ if (!p->avpkt) {
+ av_freep(&copy);
+ err = AVERROR(ENOMEM);
+ goto error;
+ }
p->parent = fctx;
p->avctx = copy;
@@ -841,7 +847,7 @@ int ff_frame_thread_init(AVCodecContext *avctx)
}
*copy->internal = *src->internal;
copy->internal->thread_ctx = p;
- copy->internal->last_pkt_props = &p->avpkt;
+ copy->internal->last_pkt_props = p->avpkt;
copy->delay = avctx->delay;