~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/lib/lib7z/Delta.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Emmanuel Kasper, Jordi Mallach
  • Date: 2012-06-05 20:02:23 UTC
  • mfrom: (0.3.1) (0.1.4)
  • Revision ID: package-import@ubuntu.com-20120605200223-gnlpogjrg6oqe9md
Tags: 0.146-1
[ Emmanuel Kasper ]
* New upstream release
* Drop patch to fix man pages section and patches to link with flac 
  and jpeg system lib: all this has been pushed upstream by Cesare Falco
* Add DM-Upload-Allowed: yes field.

[ Jordi Mallach ]
* Create a "gnu" TARGETOS stanza that defines NO_AFFINITY_NP.
* Stop setting TARGETOS to "unix" in d/rules. It should be autodetected,
  and set to the appropriate value.
* mame_manpage_section.patch: Change mame's manpage section to 6 (games),
  in the TH declaration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Delta.c -- Delta converter
 
2
2009-05-26 : Igor Pavlov : Public domain */
 
3
 
 
4
#include "Delta.h"
 
5
 
 
6
void Delta_Init(Byte *state)
 
7
{
 
8
  unsigned i;
 
9
  for (i = 0; i < DELTA_STATE_SIZE; i++)
 
10
    state[i] = 0;
 
11
}
 
12
 
 
13
static void MyMemCpy(Byte *dest, const Byte *src, unsigned size)
 
14
{
 
15
  unsigned i;
 
16
  for (i = 0; i < size; i++)
 
17
    dest[i] = src[i];
 
18
}
 
19
 
 
20
void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size)
 
21
{
 
22
  Byte buf[DELTA_STATE_SIZE];
 
23
  unsigned j = 0;
 
24
  MyMemCpy(buf, state, delta);
 
25
  {
 
26
    SizeT i;
 
27
    for (i = 0; i < size;)
 
28
    {
 
29
      for (j = 0; j < delta && i < size; i++, j++)
 
30
      {
 
31
        Byte b = data[i];
 
32
        data[i] = (Byte)(b - buf[j]);
 
33
        buf[j] = b;
 
34
      }
 
35
    }
 
36
  }
 
37
  if (j == delta)
 
38
    j = 0;
 
39
  MyMemCpy(state, buf + j, delta - j);
 
40
  MyMemCpy(state + delta - j, buf, j);
 
41
}
 
42
 
 
43
void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size)
 
44
{
 
45
  Byte buf[DELTA_STATE_SIZE];
 
46
  unsigned j = 0;
 
47
  MyMemCpy(buf, state, delta);
 
48
  {
 
49
    SizeT i;
 
50
    for (i = 0; i < size;)
 
51
    {
 
52
      for (j = 0; j < delta && i < size; i++, j++)
 
53
      {
 
54
        buf[j] = data[i] = (Byte)(buf[j] + data[i]);
 
55
      }
 
56
    }
 
57
  }
 
58
  if (j == delta)
 
59
    j = 0;
 
60
  MyMemCpy(state, buf + j, delta - j);
 
61
  MyMemCpy(state + delta - j, buf, j);
 
62
}