Commit 569a9d3d authored by Anton Khirnov's avatar Anton Khirnov Committed by James Almer

pthread_frame: change the way delay is set

It is a constant known at codec init, so set it in
ff_frame_thread_init(). Also, only set it for video, since the meaning
of this field is not well-defined for audio with frame threading.

Fixes availability of delay in callbacks invoked from the per-thread
contexts after 1f4cf92c.

(cherry picked from commit 6943ab688d0c75dbab3222b5b80457ab72a0615f)
parent 52dc21a6
...@@ -310,7 +310,6 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, ...@@ -310,7 +310,6 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
} }
if (for_user) { if (for_user) {
dst->delay = src->thread_count - 1;
#if FF_API_CODED_FRAME #if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS FF_DISABLE_DEPRECATION_WARNINGS
dst->coded_frame = src->coded_frame; dst->coded_frame = src->coded_frame;
...@@ -790,6 +789,9 @@ int ff_frame_thread_init(AVCodecContext *avctx) ...@@ -790,6 +789,9 @@ int ff_frame_thread_init(AVCodecContext *avctx)
fctx->async_lock = 1; fctx->async_lock = 1;
fctx->delaying = 1; fctx->delaying = 1;
if (codec->type == AVMEDIA_TYPE_VIDEO)
avctx->delay = src->thread_count - 1;
for (i = 0; i < thread_count; i++) { for (i = 0; i < thread_count; i++) {
AVCodecContext *copy = av_malloc(sizeof(AVCodecContext)); AVCodecContext *copy = av_malloc(sizeof(AVCodecContext));
PerThreadContext *p = &fctx->threads[i]; PerThreadContext *p = &fctx->threads[i];
...@@ -827,6 +829,8 @@ int ff_frame_thread_init(AVCodecContext *avctx) ...@@ -827,6 +829,8 @@ int ff_frame_thread_init(AVCodecContext *avctx)
copy->internal->thread_ctx = p; copy->internal->thread_ctx = p;
copy->internal->last_pkt_props = &p->avpkt; copy->internal->last_pkt_props = &p->avpkt;
copy->delay = avctx->delay;
if (codec->priv_data_size) { if (codec->priv_data_size) {
copy->priv_data = av_mallocz(codec->priv_data_size); copy->priv_data = av_mallocz(codec->priv_data_size);
if (!copy->priv_data) { if (!copy->priv_data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment