Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: third_party/lzma_sdk/Delta.c

Issue 1700453002: Update lzma_sdk sources to 15.14. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium modifications Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/lzma_sdk/Delta.h ('k') | third_party/lzma_sdk/LzFind.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* Delta.c -- Delta converter
2 2009-05-26 : Igor Pavlov : Public domain */
3
4 #include "Precomp.h"
5
6 #include "Delta.h"
7
8 void Delta_Init(Byte *state)
9 {
10 unsigned i;
11 for (i = 0; i < DELTA_STATE_SIZE; i++)
12 state[i] = 0;
13 }
14
15 static void MyMemCpy(Byte *dest, const Byte *src, unsigned size)
16 {
17 unsigned i;
18 for (i = 0; i < size; i++)
19 dest[i] = src[i];
20 }
21
22 void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size)
23 {
24 Byte buf[DELTA_STATE_SIZE];
25 unsigned j = 0;
26 MyMemCpy(buf, state, delta);
27 {
28 SizeT i;
29 for (i = 0; i < size;)
30 {
31 for (j = 0; j < delta && i < size; i++, j++)
32 {
33 Byte b = data[i];
34 data[i] = (Byte)(b - buf[j]);
35 buf[j] = b;
36 }
37 }
38 }
39 if (j == delta)
40 j = 0;
41 MyMemCpy(state, buf + j, delta - j);
42 MyMemCpy(state + delta - j, buf, j);
43 }
44
45 void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size)
46 {
47 Byte buf[DELTA_STATE_SIZE];
48 unsigned j = 0;
49 MyMemCpy(buf, state, delta);
50 {
51 SizeT i;
52 for (i = 0; i < size;)
53 {
54 for (j = 0; j < delta && i < size; i++, j++)
55 {
56 buf[j] = data[i] = (Byte)(buf[j] + data[i]);
57 }
58 }
59 }
60 if (j == delta)
61 j = 0;
62 MyMemCpy(state, buf + j, delta - j);
63 MyMemCpy(state + delta - j, buf, j);
64 }
OLDNEW
« no previous file with comments | « third_party/lzma_sdk/Delta.h ('k') | third_party/lzma_sdk/LzFind.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698