diff mbox

[FFmpeg-devel,4/7] avcodec/mpegvideo_enc: Add missing emms_c() to clear MMX state after SIMD use

Message ID 20161021133146.11956-4-michael@niedermayer.cc
State Accepted
Headers show

Commit Message

Michael Niedermayer Oct. 21, 2016, 1:31 p.m. UTC
Fixes undefined behavior due to calling libc allocation with unclean FPU state

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/mpegvideo_enc.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Michael Niedermayer Oct. 21, 2016, 1:42 p.m. UTC | #1
On Fri, Oct 21, 2016 at 03:31:43PM +0200, Michael Niedermayer wrote:
> Fixes undefined behavior due to calling libc allocation with unclean FPU state
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/mpegvideo_enc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
> index f34003e..b2c5eab 100644
> --- a/libavcodec/mpegvideo_enc.c
> +++ b/libavcodec/mpegvideo_enc.c
> @@ -1320,6 +1320,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
>                                                  EDGE_BOTTOM);
>                      }
>                  }
> +                emms_c();
>              }
>          }
>          ret = av_frame_copy_props(pic->f, pic_arg);

> @@ -1890,6 +1891,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
>              return ret;
>  vbv_retry:
>          ret = encode_picture(s, s->picture_number);
> +//         emms_c();

this was not intended to be here ...

[...]
Sven C. Dack Oct. 21, 2016, 2:26 p.m. UTC | #2
On 21/10/16 14:42, Michael Niedermayer wrote:
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Modern terrorism, a quick summary: Need oil, start war with country that
> has oil, kill hundread thousand in war. Let country fall into chaos,
> be surprised about raise of fundamantalists. Drop more bombs, kill more
> people, be surprised about them taking revenge and drop even more bombs
> and strip your own citizens of their rights and freedoms. to be continued
Modern trolling, an even quicker summary: Forgets who started it, blames 
everyone and doesn't know where to stop.
Michael Niedermayer Oct. 22, 2016, 12:19 p.m. UTC | #3
On Fri, Oct 21, 2016 at 03:42:09PM +0200, Michael Niedermayer wrote:
> On Fri, Oct 21, 2016 at 03:31:43PM +0200, Michael Niedermayer wrote:
> > Fixes undefined behavior due to calling libc allocation with unclean FPU state
> > 
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/mpegvideo_enc.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
> > index f34003e..b2c5eab 100644
> > --- a/libavcodec/mpegvideo_enc.c
> > +++ b/libavcodec/mpegvideo_enc.c
> > @@ -1320,6 +1320,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
> >                                                  EDGE_BOTTOM);
> >                      }
> >                  }
> > +                emms_c();
> >              }
> >          }
> >          ret = av_frame_copy_props(pic->f, pic_arg);
> 
> > @@ -1890,6 +1891,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
> >              return ret;
> >  vbv_retry:
> >          ret = encode_picture(s, s->picture_number);
> > +//         emms_c();
> 
> this was not intended to be here ...

applied without this hunk

[...]
diff mbox

Patch

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index f34003e..b2c5eab 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1320,6 +1320,7 @@  static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
                                                 EDGE_BOTTOM);
                     }
                 }
+                emms_c();
             }
         }
         ret = av_frame_copy_props(pic->f, pic_arg);
@@ -1890,6 +1891,7 @@  int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
             return ret;
 vbv_retry:
         ret = encode_picture(s, s->picture_number);
+//         emms_c();
         if (growing_buffer) {
             av_assert0(s->pb.buf == avctx->internal->byte_buffer);
             pkt->data = s->pb.buf;