Commit 05fa79b8 authored by Janne Grunau's avatar Janne Grunau

hwaccel: fix use with frame based multithreading

Allows use of AVHWAccel based decoders with frame based multithreading.
The decoders will be forced into an non-concurrent mode by delaying
ff_thread_finish_setup() calls after decoding of the current frame
is finished.

This wastes memory by unnecessarily using multiple threads and thus
copies of the decoder context but allows seamless switching between
hardware accelerated and frame threaded software decoding when the
hardware decoder does not support the stream.
parent c24469e8
...@@ -627,7 +627,8 @@ retry: ...@@ -627,7 +627,8 @@ retry:
if(ff_MPV_frame_start(s, avctx) < 0) if(ff_MPV_frame_start(s, avctx) < 0)
return -1; return -1;
if (!s->divx_packed) ff_thread_finish_setup(avctx); if (!s->divx_packed && !avctx->hwaccel)
ff_thread_finish_setup(avctx);
if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) { if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {
ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer); ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
...@@ -720,6 +721,9 @@ intrax8_decoded: ...@@ -720,6 +721,9 @@ intrax8_decoded:
ff_MPV_frame_end(s); ff_MPV_frame_end(s);
if (!s->divx_packed && avctx->hwaccel)
ff_thread_finish_setup(avctx);
assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type); assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
assert(s->current_picture.f.pict_type == s->pict_type); assert(s->current_picture.f.pict_type == s->pict_type);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
......
...@@ -2032,7 +2032,7 @@ static void decode_postinit(H264Context *h, int setup_finished) ...@@ -2032,7 +2032,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
av_log(h->avctx, AV_LOG_DEBUG, "no picture\n"); av_log(h->avctx, AV_LOG_DEBUG, "no picture\n");
} }
if (setup_finished) if (setup_finished && !h->avctx->hwaccel)
ff_thread_finish_setup(h->avctx); ff_thread_finish_setup(h->avctx);
} }
......
...@@ -428,6 +428,9 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, ...@@ -428,6 +428,9 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
dst->colorspace = src->colorspace; dst->colorspace = src->colorspace;
dst->color_range = src->color_range; dst->color_range = src->color_range;
dst->chroma_sample_location = src->chroma_sample_location; dst->chroma_sample_location = src->chroma_sample_location;
dst->hwaccel = src->hwaccel;
dst->hwaccel_context = src->hwaccel_context;
} }
if (for_user) { if (for_user) {
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
*/ */
#define LIBAVCODEC_VERSION_MAJOR 55 #define LIBAVCODEC_VERSION_MAJOR 55
#define LIBAVCODEC_VERSION_MINOR 0 #define LIBAVCODEC_VERSION_MINOR 1
#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
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