I try to decode produced by xdelta3 address with this lua functions:
local decode = function(copy_mode, copy_size)
local address, mode_name, address_value, cache_value = decode_address(address_stream, copy_mode, address_cache)
update_target( address_cache, copy_size )
local source_address = ( address_cache.segment_length + address ) % address_cache.segment_length
source_address = address_cache.segment_position + source_address
return source_address, mode_name, copy_mode, address_value, address, cache_value
end
function decode_address(address_stream, copy_mode, address_cache)
local address
local mode_name
local same_index
local address_value
local cache_value
if copy_mode == 0 then
mode_name = "self"
address = read_int( address_stream )
elseif copy_mode == 1 then
mode_name = "here"
address_value = read_int( address_stream )
address = address_cache.target_address - address_value
elseif copy_mode < 2 + address_cache.near_size then
mode_name = "near"
local near_index = copy_mode - 2
address_value = read_int( address_stream )
cache_value = address_cache.near[near_index]
address = cache_value + address_value
elseif copy_mode < 2 + address_cache.near_size + address_cache.same_size then
mode_name = "same"
local same_mode = copy_mode - (2 + address_cache.near_size)
address_value = read_byte( address_stream )
same_index = same_mode * 256 + address_value
address = address_cache.same[same_index]
if not address then
debug_values()
assert(address)
end
end
return cache_update( address_cache, address), mode_name, address_value, cache_value
end
In output below:
RA - result address (result of self, here, near or same parts)
CV - cache value (value from near or same cache)
AV - address value (value from address stream)
I try to decode produced by xdelta3 address with this lua functions:
In output below: RA - result address (result of self, here, near or same parts) CV - cache value (value from near or same cache) AV - address value (value from address stream)
First problem negative address (RA: -10049)
my code decode:
147733 035 CPY_1 159 S@1066732 here RA: -10049 AV: 157782
Is it right to fix it with this code?:
% - mod
Second problem wrong address
VCDIFF copy window offset: 124004297
xdelta3 decode:134227622 035 CPY_1 162 S@284037645
my code decode:134227622 035 CPY_1 162 S@258221863 here RA: 134217566 AV: 10056
If i try to encode back address that give xdelta3 than in address stream will be negative value.