1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/* Copyright (C) 2005 Ole André Vadla Ravnås <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MIMIC_PRIVATE_H
#define MIMIC_PRIVATE_H
#include "mimic.h"
#define ENCODER_BUFFER_SIZE 16384
#define ENCODER_QUALITY_DEFAULT 0
#define ENCODER_QUALITY_MIN 0
#define ENCODER_QUALITY_MAX 10000
struct _MimCtx {
gboolean encoder_initialized;
gboolean decoder_initialized;
gint frame_width;
gint frame_height;
gint quality;
gint num_coeffs;
gint y_stride;
gint y_row_count;
gint y_size;
gint crcb_stride;
gint crcb_row_count;
gint crcb_size;
gint num_vblocks_y;
gint num_hblocks_y;
gint num_vblocks_cbcr;
gint num_hblocks_cbcr;
guchar *cur_frame_buf;
guchar *prev_frame_buf;
gint8 vlcdec_lookup[2296];
gchar *data_buffer;
guint data_index;
guint32 cur_chunk;
gint cur_chunk_len;
guint32 *chunk_ptr;
gboolean read_odd;
gint frame_num;
gint ptr_index;
guchar *buf_ptrs[16];
};
typedef struct {
guchar length1;
guint32 part1;
guchar length2;
guint32 part2;
} VlcSymbol;
typedef struct {
guint32 magic;
guchar pos_add;
guchar num_bits;
} VlcMagic;
void _mimic_init(MimCtx *ctx, gint width, gint height);
guchar _clamp_value(gint value);
guint32 _read_bits(MimCtx *ctx, gint num_bits);
void _write_bits(MimCtx *ctx, guint32 bits, gint length);
void _vlc_encode_block(MimCtx *ctx, const gint *block, gint num_coeffs);
gboolean _vlc_decode_block(MimCtx *ctx, gint *block, gint num_coeffs);
void _fdct_quant_block(MimCtx *ctx, gint *block, const guchar *src,
gint stride, gboolean is_chrom, gint num_coeffs);
void _idct_dequant_block(MimCtx *ctx, gint *block, gboolean is_chrom);
VlcMagic *_find_magic(guint magic);
void _initialize_vlcdec_lookup(gint8 *lookup_tbl);
void _rgb_to_yuv(const guchar *input_rgb,
guchar *output_y,
guchar *output_cb,
guchar *output_cr,
gint width,
gint height);
void _yuv_to_rgb(const guchar *input_y,
const guchar *input_cb,
const guchar *input_cr,
guchar *output_rgb,
guint width,
guint height);
void _deblock(guchar *blocks, guint stride, guint row_count);
#endif
|