[FFmpeg-devel] [PATCH] Missing emms_c() calls causing weird Windows crashes with deshake

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Jan 7 12:07:03 CET 2012


On Fri, Jan 06, 2012 at 11:17:12PM -0800, Ray Simard wrote:
> diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
> index 7013f6c..16e0c77 100644
> --- a/libavfilter/vf_deshake.c
> +++ b/libavfilter/vf_deshake.c
> @@ -145,6 +145,7 @@ static void find_block_motion(DeshakeContext *deshake, uint8_t *src1,
>          for (y = -deshake->ry; y <= deshake->ry; y++) {
>              for (x = -deshake->rx; x <= deshake->rx; x++) {
>                  diff = CMP(cx - x, cy - y);
> +                emms_c();
>                  if (diff < smallest) {
>                      smallest = diff;
>                      mv->x = x;
> @@ -157,6 +158,7 @@ static void find_block_motion(DeshakeContext *deshake, uint8_t *src1,
>          for (y = -deshake->ry + 1; y < deshake->ry - 2; y += 2) {
>              for (x = -deshake->rx + 1; x < deshake->rx - 2; x += 2) {
>                  diff = CMP(cx - x, cy - y);
> +                emms_c();
>                  if (diff < smallest) {
>                      smallest = diff;
>                      mv->x = x;
> @@ -175,6 +177,7 @@ static void find_block_motion(DeshakeContext *deshake, uint8_t *src1,
>                      continue;
>  
>                  diff = CMP(cx - x, cy - y);
> +                emms_c();
>                  if (diff < smallest) {
>                      smallest = diff;
>                      mv->x = x;

Doing emms_c in the inner loop will (at least on some processors) be
far, far slower than not using MMX at all.
An obvious approach is to do the conversion to double only after the
emms_c.
Of course I couldn't really figure out why the motion values are float
anyway, it seems to me that they only ever get assigned ints anyway
(and none of the video codecs use floating point for motion vectors,
so IMHO the filter must be doing something wrong if it needs doubles)...


More information about the ffmpeg-devel mailing list