This is a constant codec property, so a capability flag is more appropriate.
speed gain at this point but it should work.
If there are inter-frame dependencies, so the codec calls
-ff_thread_report/await_progress(), set AVCodecInternal.allocate_progress. The
+ff_thread_report/await_progress(), set FF_CODEC_CAP_ALLOCATE_PROGRESS in
+AVCodec.caps_internal and use ff_thread_get_buffer() to allocate frames. The
frames must then be freed with ff_thread_release_buffer().
-Otherwise leave it at zero and decode directly into the user-supplied frames.
+Otherwise decode directly into the user-supplied frames.
Call ff_thread_report_progress() after some part of the current picture has decoded.
A good place to put this is where draw_horiz_band() is called - add this if it isn't
if ((ret = ff_ffv1_init_slice_contexts(f)) < 0)
return ret;
- avctx->internal->allocate_progress = 1;
-
return 0;
}
.update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context),
.capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/ |
AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS,
- .caps_internal = FF_CODEC_CAP_INIT_CLEANUP
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ALLOCATE_PROGRESS,
};
h->avctx->has_b_frames = h->ps.sps->num_reorder_frames;
}
- avctx->internal->allocate_progress = 1;
-
ff_h264_flush_change(h);
if (h->enable_er < 0 && (avctx->active_thread_type & FF_THREAD_SLICE))
#endif
NULL
},
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING |
+ FF_CODEC_CAP_ALLOCATE_PROGRESS,
.flush = flush_dpb,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
HEVCContext *s = avctx->priv_data;
int ret;
- avctx->internal->allocate_progress = 1;
-
ret = hevc_init_context(avctx);
if (ret < 0)
return ret;
.init_thread_copy = ONLY_IF_THREADS_ENABLED(hevc_init_thread_copy),
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS,
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING |
+ FF_CODEC_CAP_ALLOCATE_PROGRESS,
.profiles = NULL_IF_CONFIG_SMALL(ff_hevc_profiles),
.hw_configs = (const AVCodecHWConfigInternal*[]) {
#if CONFIG_HEVC_DXVA2_HWACCEL
* Codec initializes slice-based threading with a main function
*/
#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF (1 << 5)
+/*
+ * The codec supports frame threading and has inter-frame dependencies, so it
+ * uses ff_thread_report/await_progress().
+ */
+#define FF_CODEC_CAP_ALLOCATE_PROGRESS (1 << 6)
/**
* AVCodec.codec_tags termination value
*/
int is_copy;
- /**
- * Whether to allocate progress for frame threading.
- *
- * The codec must set it to 1 if it uses ff_thread_await/report_progress(),
- * then progress will be allocated in ff_thread_get_buffer(). The frames
- * then MUST be freed with ff_thread_release_buffer().
- *
- * If the codec does not need to call the progress functions (there are no
- * dependencies between the frames), it should leave this at 0. Then it can
- * decode straight to the user-provided frames (which the user will then
- * free with av_frame_unref()), there is no need to call
- * ff_thread_release_buffer().
- */
- int allocate_progress;
-
/**
* An audio frame with less than required samples has been submitted and
* padded with silence. Reject all subsequent frames.
MimicContext *ctx = avctx->priv_data;
int ret, i;
- avctx->internal->allocate_progress = 1;
-
ctx->prev_index = 0;
ctx->cur_index = 15;
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
.update_thread_context = ONLY_IF_THREADS_ENABLED(mimic_decode_update_thread_context),
.init_thread_copy = ONLY_IF_THREADS_ENABLED(mimic_init_thread_copy),
+ .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS,
};
ctx->time_increment_bits = 4; /* default value for broken headers */
avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
- avctx->internal->allocate_progress = 1;
return 0;
}
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
AV_CODEC_CAP_FRAME_THREADS,
- .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+ .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
+ FF_CODEC_CAP_ALLOCATE_PROGRESS,
.flush = ff_mpeg_flush,
.max_lowres = 3,
.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,
}
if (!avctx->internal->is_copy) {
- avctx->internal->allocate_progress = 1;
ff_pngdsp_init(&s->dsp);
}
.init_thread_copy = ONLY_IF_THREADS_ENABLED(png_dec_init),
.update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context),
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/,
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
+ FF_CODEC_CAP_ALLOCATE_PROGRESS,
};
#endif
.init_thread_copy = ONLY_IF_THREADS_ENABLED(png_dec_init),
.update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context),
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/,
- .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_THREADSAFE,
+ .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_THREADSAFE |
+ FF_CODEC_CAP_ALLOCATE_PROGRESS,
};
#endif
.decode = decode_frame_lscr,
.flush = decode_flush,
.capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/,
- .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_THREADSAFE,
+ .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_THREADSAFE |
+ FF_CODEC_CAP_ALLOCATE_PROGRESS,
};
#endif
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->internal->allocate_progress)
+ if (avctx->codec->caps_internal & FF_CODEC_CAP_ALLOCATE_PROGRESS)
av_log(avctx, AV_LOG_ERROR, "A frame threaded decoder did not "
"free the frame on failure. This is a bug, please report it.\n");
av_frame_unref(p->frame);
return -1;
}
- if (avctx->internal->allocate_progress) {
+ if (avctx->codec->caps_internal & FF_CODEC_CAP_ALLOCATE_PROGRESS) {
atomic_int *progress;
f->progress = av_buffer_alloc(2 * sizeof(*progress));
if (!f->progress) {
},
.init_thread_copy = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context),
+ .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS,
};
if(!intra_vlcs[0].cbppattern[0].bits)
rv34_init_tables();
- avctx->internal->allocate_progress = 1;
-
return 0;
}
},
.init_thread_copy = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context),
+ .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS,
};
if (ret < 0)
return ret;
- avctx->internal->allocate_progress = 1;
-
if (avctx->codec_tag == MKTAG('V', 'P', '4', '0'))
s->version = 3;
else if (avctx->codec_tag == MKTAG('V', 'P', '3', '0'))
.flush = vp3_decode_flush,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context),
- .caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING,
+ .caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING | FF_CODEC_CAP_ALLOCATE_PROGRESS,
};
#endif
.flush = vp3_decode_flush,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context),
+ .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS,
};
#if CONFIG_VP4_DECODER
.flush = vp3_decode_flush,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context),
+ .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS,
};
#endif
s->vp7 = avctx->codec->id == AV_CODEC_ID_VP7;
s->pix_fmt = AV_PIX_FMT_NONE;
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
- avctx->internal->allocate_progress = 1;
ff_videodsp_init(&s->vdsp, 8);
#endif
NULL
},
+ .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS,
};
#endif /* CONFIG_VP7_DECODER */
{
VP9Context *s = avctx->priv_data;
- avctx->internal->allocate_progress = 1;
s->last_bpp = 0;
s->s.h.filter.sharpness = -1;
.close = vp9_decode_free,
.decode = vp9_decode_frame,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS,
- .caps_internal = FF_CODEC_CAP_SLICE_THREAD_HAS_MF,
+ .caps_internal = FF_CODEC_CAP_SLICE_THREAD_HAS_MF |
+ FF_CODEC_CAP_ALLOCATE_PROGRESS,
.flush = vp9_decode_flush,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(vp9_decode_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(vp9_decode_update_thread_context),
s->fdec_num = 0;
- avctx->internal->allocate_progress = 1;
-
s->curr_frame.f = av_frame_alloc();
s->prev_frame.f = av_frame_alloc();
.init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context),
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
- AV_CODEC_CAP_SLICE_THREADS
+ AV_CODEC_CAP_SLICE_THREADS,
+ .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS,
};