qiqian / webp

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

Why WEBP_REFERENCE_IMPLEMENTATION was introduced #215

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I have very very strange bug and it redroduces only in one my project (other in 
the same environemnt works fine)

In function
static WEBP_INLINE void Put8x8uv(uint8_t value, uint8_t* dst) {
  int j;
#ifndef WEBP_REFERENCE_IMPLEMENTATION
  const uint64_t v = (uint64_t)value * 0x0101010101010101ULL;
  for (j = 0; j < 8; ++j) {
    *(uint64_t*)(dst + j * BPS) = v;
  }
#else
  for (j = 0; j < 8; ++j) memset(dst + j * BPS, value, 8);
#endif
}

v stores value as 32 bit unsigned integer but not 64 bit.
i.e. v == (unsigned int)((uint64_t)value * 0x0101010101010101ULL);
I wonder why WEBP_REFERENCE_IMPLEMENTATION preprocessor definition was 
introduced. Where I should define it to avoid such strange bug?

Original issue reported on code.google.com by SergeySo...@gmail.com on 23 Jul 2014 at 11:54

GoogleCodeExporter commented 8 years ago
I'm using Visual Srudio 2013 update 2

Original comment by SergeySo...@gmail.com on 23 Jul 2014 at 12:01

GoogleCodeExporter commented 8 years ago
Can you describe the bug you're observing? On which platform?
Does it disappear when WEBP_REFERENCE_IMPLEMENTATION is defined?

WEBP_REFERENCE_IMPLEMENTATION was introduced to have a safe fallback
for part of the code that is deemed 'tricky'. It also helps with enscripten
translation to Javascript, etc.
By defining WEBP_REFERENCE_IMPLEMENTATION, you trade some speed against
code safety.

Original comment by pascal.m...@gmail.com on 23 Jul 2014 at 12:02

GoogleCodeExporter commented 8 years ago
I'm working on windows 7 sp1. My project is SDL game. And yes bug dissappear 
when I define WEBP_REFERENCE_IMPLEMENTATION.

Original comment by SergeySo...@gmail.com on 23 Jul 2014 at 12:07

GoogleCodeExporter commented 8 years ago
It appears on windows platform

Original comment by SergeySo...@gmail.com on 23 Jul 2014 at 12:07

GoogleCodeExporter commented 8 years ago
I found the reason of issue. It is because of sdl. It include assmbler code 
that does not work correctly for multiplying uint64 x uint64. And this code is 
used over the project

Original comment by SergeySo...@gmail.com on 23 Jul 2014 at 12:47

GoogleCodeExporter commented 8 years ago
alright, i think we should just remove this tweak altogether then,
since there's no speed diff.

Original comment by pascal.m...@gmail.com on 23 Jul 2014 at 6:35

GoogleCodeExporter commented 8 years ago
merged in 0.4.1 branch thanks to https://gerrit.chromium.org/gerrit/#/c/70969/

Will be merged back in HEAD later.

Original comment by pascal.m...@gmail.com on 23 Jul 2014 at 9:36