Initial commit - from Precise source
[freerdp-ubuntu-pcb-backport.git] / include / freerdp / codec / nsc.h
1 /**
2  * FreeRDP: A Remote Desktop Protocol client.
3  * NSCodec Codec
4  *
5  * Copyright 2011 Samsung, Author Jiten Pathy
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *       http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 #ifndef __NSC_H
21 #define __NSC_H
22
23 #include <freerdp/api.h>
24 #include <freerdp/types.h>
25 #include <freerdp/utils/stream.h>
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #define BYTESUM(_bs) (_bs[0] + _bs[1] + _bs[2] + _bs[3])
32 #define ROUND_UP_TO(_b, _n) (_b + ((~(_b & (_n-1)) + 0x1) & (_n-1)));
33
34 /* NSCODEC_BITMAP_STREAM */
35 struct _NSC_STREAM
36 {
37         uint32 PlaneByteCount[4];
38         uint8 colorLossLevel;
39         uint8 ChromaSubSamplingLevel;
40         uint16 Reserved;
41         STREAM* pdata;
42 };
43 typedef struct _NSC_STREAM NSC_STREAM;
44
45 struct _NSC_CONTEXT
46 {
47         uint32 OrgByteCount[4]; /* original byte length of luma, chroma orange, chroma green, alpha variable in order */
48         NSC_STREAM* nsc_stream;
49         uint16 width;
50         uint16 height;
51         uint8* bmpdata;     /* final argb values in little endian order */
52         STREAM* org_buf[4];     /* Decompressed Plane Buffers in the respective order */
53 };
54 typedef struct _NSC_CONTEXT NSC_CONTEXT;
55
56 FREERDP_API NSC_CONTEXT* nsc_context_new(void);
57 FREERDP_API void nsc_process_message(NSC_CONTEXT* context, uint8* data, uint32 length);
58 FREERDP_API void nsc_context_initialize(NSC_CONTEXT* context, STREAM* s);
59 FREERDP_API void nsc_stream_initialize(NSC_CONTEXT* context, STREAM* s);
60 FREERDP_API void nsc_rle_decompress_data(NSC_CONTEXT* context);
61 FREERDP_API void nsc_ycocg_rgb_convert(NSC_CONTEXT* context);
62 FREERDP_API void nsc_rle_decode(STREAM* in, STREAM* out, uint32 origsz);
63 FREERDP_API void nsc_chroma_supersample(NSC_CONTEXT* context);
64 FREERDP_API void nsc_cl_expand(STREAM* stream, uint8 shiftcount, uint32 origsz);
65 FREERDP_API void nsc_colorloss_recover(NSC_CONTEXT* context);
66 FREERDP_API void nsc_ycocg_rgb(NSC_CONTEXT* context);
67 FREERDP_API void nsc_context_destroy(NSC_CONTEXT* context);
68
69 #ifdef __cplusplus
70 }
71 #endif
72
73 #endif /* __NSC_H */