Chen-tao / webm

Automatically exported from code.google.com/p/webm
0 stars 0 forks source link

VPX codec executes emms instruction without checking CPU capabilities #532

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
As stated in a summary, subroutine that executes emms instruction in:
vpx_ports/emms.asm

is called despite of CPU capabilities.

Call to this subroutine is always made on x86 and x64, as stated by definition 
of vp8_clear_system_state() macro in:
vp8/common/systemdependent.h

If MMX registers are not used at all (when CPU has SSE2 or newer extension - 
but that's my suspicion, I haven't checked, whether MMX registers are actually 
used when newer extension is present), it is redundant and each call takes many 
CPU cycles (even on modern CPUs).

On CPUs that do not support MMX it crashes with invalid instruction exception.

No patch this time, as I'm not sure how to deal with it exactly.

I think that the best way will be not to use a macro such as that in:
vp8/common/systemdependent.h

but rather an assignment like the ones in setup_rtcd_internal function
(file: vpx_rtcd.h).

Then this instruction could be called only when MMX registers are actually used 
(check, whether vp8_clear_system_state is NULL would cost much less than 
executing emms instruction)
--
Best regards,
Krzysztof Kaspruk

Original issue reported on code.google.com by ohcy...@gmail.com on 18 Jan 2013 at 5:14

GoogleCodeExporter commented 8 years ago
I agree that calling emms unconditionally is bad.
But I'd suggest dropping MMX - rely on SSE2 for optimization.

Original comment by fbarch...@google.com on 21 Jan 2013 at 4:47

GoogleCodeExporter commented 8 years ago

Original comment by fgalli...@google.com on 14 Mar 2013 at 10:08

GoogleCodeExporter commented 8 years ago
Fixed in https://gerrit.chromium.org/gerrit/45624

Original comment by jkoles...@google.com on 29 Mar 2013 at 3:46