libmimic
1.0.4
|
00001 /* Copyright (C) 2005 Ole André Vadla Ravnås <oleavr@gmail.com> 00002 * 00003 * This library is free software; you can redistribute it and/or 00004 * modify it under the terms of the GNU Lesser General Public 00005 * License as published by the Free Software Foundation; either 00006 * version 2.1 of the License, or (at your option) any later version. 00007 * 00008 * This library is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Lesser General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public 00014 * License along with this library; if not, write to the Free Software 00015 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 */ 00017 00018 #ifndef MIMIC_PRIVATE_H 00019 #define MIMIC_PRIVATE_H 00020 00021 #include "mimic.h" 00022 00023 #define ENCODER_BUFFER_SIZE 16384 00024 #define ENCODER_QUALITY_DEFAULT 0 00025 #define ENCODER_QUALITY_MIN 0 00026 #define ENCODER_QUALITY_MAX 10000 00027 00028 struct _MimCtx { 00029 gboolean encoder_initialized; 00030 gboolean decoder_initialized; 00031 00032 gint frame_width; 00033 gint frame_height; 00034 gint quality; 00035 gint num_coeffs; 00036 00037 gint y_stride; 00038 gint y_row_count; 00039 gint y_size; 00040 00041 gint crcb_stride; 00042 gint crcb_row_count; 00043 gint crcb_size; 00044 00045 gint num_vblocks_y; 00046 gint num_hblocks_y; 00047 00048 gint num_vblocks_cbcr; 00049 gint num_hblocks_cbcr; 00050 00051 guchar *cur_frame_buf; 00052 guchar *prev_frame_buf; 00053 00054 gchar vlcdec_lookup[2296]; 00055 00056 gchar *data_buffer; 00057 guint data_index; 00058 00059 guint32 cur_chunk; 00060 gint cur_chunk_len; 00061 00062 guint32 *chunk_ptr; 00063 gboolean read_odd; 00064 00065 gint frame_num; 00066 00067 gint ptr_index; 00068 guchar *buf_ptrs[16]; 00069 }; 00070 00071 typedef struct { 00072 guchar length1; 00073 guint32 part1; 00074 00075 guchar length2; 00076 guint32 part2; 00077 } VlcSymbol; 00078 00079 typedef struct { 00080 guint32 magic; 00081 guchar pos_add; 00082 guchar num_bits; 00083 } VlcMagic; 00084 00085 void _mimic_init(MimCtx *ctx, gint width, gint height); 00086 guchar _clamp_value(gint value); 00087 00088 guint32 _read_bits(MimCtx *ctx, gint num_bits); 00089 void _write_bits(MimCtx *ctx, guint32 bits, gint length); 00090 00091 void _vlc_encode_block(MimCtx *ctx, const gint *block, gint num_coeffs); 00092 gboolean _vlc_decode_block(MimCtx *ctx, gint *block, gint num_coeffs); 00093 00094 void _fdct_quant_block(MimCtx *ctx, gint *block, const guchar *src, 00095 gint stride, gboolean is_chrom, gint num_coeffs); 00096 void _idct_dequant_block(MimCtx *ctx, gint *block, gboolean is_chrom); 00097 00098 VlcMagic *_find_magic(guint magic); 00099 void _initialize_vlcdec_lookup(gchar *lookup_tbl); 00100 00101 void _rgb_to_yuv(const guchar *input_rgb, 00102 guchar *output_y, 00103 guchar *output_cb, 00104 guchar *output_cr, 00105 gint width, 00106 gint height); 00107 void _yuv_to_rgb(const guchar *input_y, 00108 const guchar *input_cb, 00109 const guchar *input_cr, 00110 guchar *output_rgb, 00111 guint width, 00112 guint height); 00113 00114 void _deblock(guchar *blocks, guint stride, guint row_count); 00115 00116 #endif // MIMIC_PRIVATE_H 00117