From 7a4c5c18dc78fcbbfb44d52f84ed4ffaf6c498c3 Mon Sep 17 00:00:00 2001 From: Torsten Jager Date: Thu, 12 Jun 2014 15:31:40 +0200 Subject: ff_video_decoder: fix multithreading #4. Avoid H.265 image size pumping on x86, for example. This really is a workaround for an ff bug. They should issue emms when done with a frame instead. --- src/combined/ffmpeg/ff_video_decoder.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') diff --git a/src/combined/ffmpeg/ff_video_decoder.c b/src/combined/ffmpeg/ff_video_decoder.c index 95e40abe0..19fe681a1 100644 --- a/src/combined/ffmpeg/ff_video_decoder.c +++ b/src/combined/ffmpeg/ff_video_decoder.c @@ -59,6 +59,11 @@ #include "ffmpeg_compat.h" +#if (defined(ARCH_X86) || defined(ARCH_X86_64)) && defined(HAVE_MMX) +#include "xine_mmx.h" +#define ENABLE_EMMS +#endif + #define VIDEOBUFSIZE (128*1024) #define SLICE_BUFFER_SIZE (1194*1024) @@ -170,6 +175,11 @@ struct ff_video_decoder_s { #define STATE_FRAME_SENT 3 #define STATE_FLUSHED 4 int state; + +#ifdef ENABLE_EMMS + /* see get_buffer () */ + int emms; +#endif }; /* import color matrix names */ @@ -281,6 +291,14 @@ static int get_buffer (AVCodecContext *context, AVFrame *av_frame) int top_edge; int guarded_render = 0; +#ifdef ENABLE_EMMS + /* some background thread may call this while still in mmx mode. + this will trash "double" aspect ratio values, even when only + passing them to vo_get_frame () verbatim. */ + if (this->emms) + emms (); +#endif + /* multiple threads have individual contexts !! */ #ifdef AVCODEC_HAS_COLORSPACE if (context != this->context) { @@ -2519,6 +2537,10 @@ static video_decoder_t *ff_video_open_plugin (video_decoder_class_t *class_gen, this->pix_fmt = -1; this->rgb2yuy2 = NULL; +#ifdef ENABLE_EMMS + this->emms = !!(xine_mm_accel () & (MM_ACCEL_X86_MMX | MM_ACCEL_X86_MMXEXT)); +#endif + #ifdef LOG this->debug_fmt = -1; #endif -- cgit v1.2.3