1 |
/* |
2 |
ROHC Project 2003 at Lulea University of Technology, Sweden. |
3 |
Authors: Andreas Vernersson <andver-8@student.luth.se> |
4 |
Daniel Pettersson <danpet-7@student.luth.se> |
5 |
Erik Soderstrom <soderstrom@yahoo.com> |
6 |
Fredrik Lindstrom <frelin-9@student.luth.se> |
7 |
Johan Stenmark <johste-8@student.luth.se> |
8 |
Martin Juhlin <juhlin@users.sourceforge.net> |
9 |
Mikael Larsson <larmik-9@student.luth.se> |
10 |
Robert Maxe <robmax-1@student.luth.se> |
11 |
|
12 |
Copyright (C) 2003 Andreas Vernersson, Daniel Pettersson, |
13 |
Erik Soderström, Fredrik Lindström, Johan Stenmark, |
14 |
Martin Juhlin, Mikael Larsson, Robert Maxe. |
15 |
|
16 |
This program is free software; you can redistribute it and/or modify |
17 |
it under the terms of the GNU General Public License as published by |
18 |
the Free Software Foundation; either version 2 of the License, or |
19 |
(at your option) any later version. |
20 |
|
21 |
This program is distributed in the hope that it will be useful, |
22 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24 |
GNU General Public License for more details. |
25 |
|
26 |
You should have received a copy of the GNU General Public License |
27 |
along with this program; if not, write to the Free Software |
28 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
29 |
*/ |
30 |
|
31 |
// The Uncompressed profile in decompressor |
32 |
|
33 |
#include "rohc.h" |
34 |
#include "decomp.h" |
35 |
|
36 |
#include "d_uncompressed.h" |
37 |
|
38 |
// Allocate profile-data, nothing to allocate |
39 |
void * uncompressed_allocate_decode_data(void) |
40 |
{ |
41 |
return (void*)1; |
42 |
} |
43 |
|
44 |
// To deallocate profile data, no data to free |
45 |
void uncompressed_free_decode_data(void * p) |
46 |
{ |
47 |
} |
48 |
|
49 |
// Decode an IR-package and initalize context |
50 |
int uncompressed_decode_ir( |
51 |
struct sd_rohc * state, |
52 |
struct sd_context * context, |
53 |
unsigned char * src, |
54 |
int copy_size, |
55 |
int dynamic_present, |
56 |
unsigned char * dest |
57 |
) |
58 |
{ |
59 |
unsigned char * s = src; |
60 |
unsigned char * d = dest; |
61 |
|
62 |
context->state = ROHC_FULL_CONTEXT; |
63 |
|
64 |
if (copy_size == 0) return ROHC_OK_NO_DATA; |
65 |
|
66 |
memcpy(d, s, copy_size); |
67 |
return copy_size; |
68 |
} |
69 |
|
70 |
// Calculate the size of data in an IR-package. |
71 |
// return : size or zero. |
72 |
int uncompressed_detect_ir_size(unsigned char * first_byte, int second_byte_add) |
73 |
{ |
74 |
int ret = 10; |
75 |
int d = GET_BIT_0(first_byte); |
76 |
if (d) ret += 5 + 2; |
77 |
if (first_byte[second_byte_add + 2] != 0x40) return 0; |
78 |
|
79 |
return ret; |
80 |
} |
81 |
|
82 |
// Calculate the size of data in an IR-package. |
83 |
// return : size or zero. |
84 |
int uncompressed_detect_ir_dyn_size(unsigned char * first_byte, struct sd_context *c) |
85 |
{ |
86 |
return 7; |
87 |
} |
88 |
|
89 |
// Decode all package except IR-package. |
90 |
int uncompressed_decode( |
91 |
struct sd_rohc * state, |
92 |
struct sd_context * context, |
93 |
unsigned char * src, |
94 |
int size, |
95 |
int second_byte, |
96 |
unsigned char * dest |
97 |
) |
98 |
{ |
99 |
unsigned char * s = src; |
100 |
unsigned char * d = dest; |
101 |
|
102 |
if (context->state == ROHC_NO_CONTEXT) return ROHC_ERROR; |
103 |
|
104 |
*d = GET_BIT_0_7(src); |
105 |
d += 1; |
106 |
s += second_byte; |
107 |
|
108 |
memcpy(d, s, size - second_byte); |
109 |
return (size - second_byte + 1); |
110 |
} |
111 |
|
112 |
static int uncompressed_get_sn(struct sd_context * dummy) |
113 |
{ |
114 |
return 0; |
115 |
} |
116 |
|
117 |
static struct s_profile d_uncomp_profile = {0,"1.0", "Uncompressed / Decompressor", |
118 |
uncompressed_decode, |
119 |
uncompressed_decode_ir, |
120 |
uncompressed_allocate_decode_data, |
121 |
uncompressed_free_decode_data, |
122 |
uncompressed_detect_ir_size, |
123 |
uncompressed_detect_ir_dyn_size, |
124 |
uncompressed_get_sn |
125 |
}; |
126 |
|
127 |
struct s_profile * uncompressed_profile_create() |
128 |
{ |
129 |
return &d_uncomp_profile; |
130 |
} |
131 |
|
132 |
|
133 |
|