diff mbox

[FFmpeg-devel,02/13] avcodec: Clear MMX state in ff_thread_report_progress(INT_MAX)

Message ID 20161022190211.16526-2-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Oct. 22, 2016, 7:02 p.m. UTC
This decreases the number of FPU state violations in fate on x86-64 from 309 to 79

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/pthread_frame.c | 3 +++
 libavcodec/utils.c         | 2 ++
 2 files changed, 5 insertions(+)

Comments

wm4 Oct. 24, 2016, 7:26 a.m. UTC | #1
On Sat, 22 Oct 2016 22:06:22 -0400
"Ronald S. Bultje" <rsbultje@gmail.com> wrote:

> Hi,
> 
> On Sat, Oct 22, 2016 at 3:02 PM, Michael Niedermayer <michael@niedermayer.cc
> > wrote:  
> 
> > This decreases the number of FPU state violations in fate on x86-64 from
> > 309 to 79
> >
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/pthread_frame.c | 3 +++
> >  libavcodec/utils.c         | 2 ++
> >  2 files changed, 5 insertions(+)
> >
> > diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
> > index 7ef5e9f..b6c6027 100644
> > --- a/libavcodec/pthread_frame.c
> > +++ b/libavcodec/pthread_frame.c
> > @@ -473,6 +473,9 @@ void ff_thread_report_progress(ThreadFrame *f, int n,
> > int field)
> >      PerThreadContext *p;
> >      volatile int *progress = f->progress ? (int*)f->progress->data : NULL;
> >
> > +    if (n >= INT_MAX)
> > +        emms_c();  
> 
> 
> I don't like how INT_MAX is becoming more and more like a magic number.
> This should probably be a new function that is called upon frame (or field)
> decoding completion (or abort), where part of what it does is to set
> progress to INT_MAX.

Indeed, this looks very strange.

Also the ">" in the ">=" is redundant, why isn't it "=="?
diff mbox

Patch

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 7ef5e9f..b6c6027 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -473,6 +473,9 @@  void ff_thread_report_progress(ThreadFrame *f, int n, int field)
     PerThreadContext *p;
     volatile int *progress = f->progress ? (int*)f->progress->data : NULL;
 
+    if (n >= INT_MAX)
+        emms_c();
+
     if (!progress || progress[field] >= n) return;
 
     p = f->owner->internal->thread_ctx;
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 7c26485..bc28cf9 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -3959,6 +3959,8 @@  void ff_thread_finish_setup(AVCodecContext *avctx)
 
 void ff_thread_report_progress(ThreadFrame *f, int progress, int field)
 {
+    if (progress >= INT_MAX)
+        emms_c();
 }
 
 void ff_thread_await_progress(ThreadFrame *f, int progress, int field)