[theora-dev] dead DCSearchPoints code
melanson at pcisys.net
Wed Jun 18 13:18:05 PDT 2003
On Wed, 18 Jun 2003, Dan Miller wrote:
> The HIGHBITDUPPED thing looks like a hack to use shift instead of divide -- basically if the value is negative, you add
> 2^shift-1 before shifting. This forces the shift to round towards zero, rather than always rounding down (which would increase the absolute value of a negative number). For example, without the correction 7>>1 = 3, and -7>>1 = -4. But if we add 1 to -7 we get -6, and -6>>1 = -3.
My original analysis was similar, which is why I replaced it with
a straight divide. I figured that maybe the macro existed for paranoia
that a naive compiler would not optimize a div-by-power-of-2 with a shift.
But I quickly figured out that the macro did more so I had to copy it.
I figure that hopeful optimization was the rationale behind some
other code, like the token decoder. There is a series of if-else
statements instead of a more intuitive (IMO) switch-case. Maybe the
programmer was counting on certain token values occurring more frequently,
thus certain execution paths should be shorter. Though, a switch-case
should be constant time to jump to any path.
> I'll get to the part of the code with the bug eventually. I'm recalling a bit more -- this programmer said that for some reason they decided late in the game to tie chroma motion vectors to Y vectors -- is it possible that while the decoder has logic to unpack these unused bits, the encoder never generates them? The explanation would be that for a while they had old bitstreams lying around they didn't want to break...
I had it wrong-- there are no extra bits allocated to indicate
macroblock coding. Which macroblocks are coded is implied by which Y-plane
fragments are coded. Memory is allocated in the decoder for which C-plane
"macroblocks" are coded. The memory is written to during the decode, but
never read back. Maybe it made the decoder code a little more
straightforward to write.
> I can always try to get some help from On2, but they're on to VP6 and tend not to remember what was going on 4 years ago. And of course they're always on deadline and basically have no allowance to give me any time on VP3 anymore.
> I still have faith everything will make sense eventually...
We multimedia hackers are quite used to reverse engineering code,
from either binary or source code implementations, and trying to get at
the underlying concepts. So this is no big deal. See some of the other
documents on my site for more details. Come to think of it, some of your
other work is already on my site...:) Duck's DK* ADPCM codecs. One day, I
will get Duck Truemotion v1 written up, too (a.k.a., VP1?).
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'theora-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Theora-dev