#include <GL/gl.h>
#include "texture.h"
#include "MotionFrameDCT.h"
#include "Bmp2jpg.h"
#pragma once
typedef signed char INT8, *PINT8;
typedef signed short INT16, *PINT16;
typedef signed int INT32, *PINT32;
//typedef signed __int64 INT64, *PINT64;
typedef unsigned char UINT8, *PUINT8;
typedef unsigned short UINT16, *PUINT16;
typedef unsigned int UINT32, *PUINT32;
//typedef unsigned __int64 UINT64, *PUINT64;
typedef unsigned long ULONG;
typedef unsigned char* PUCHAR;
typedef unsigned char UCHAR;
//typedef signed __int64 int64_t;
//typedef unsigned __int64 u_int64_t;
#define NULL 0
#define DCTSIZE 8
#define DCTSIZE2 64
#define MAXJSAMPLE 255
#define CENTERJSAMPLE 128
#define JSAMPLE unsigned char
#define SCALEBITS 16
#define ONE_HALF ((long) 1 << (SCALEBITS-1))
#define CBCR_OFFSET ((INT32) CENTERJSAMPLE << SCALEBITS)
#define FIX(x) ((long) ((x) * (1L<<SCALEBITS) + 0.5))
#define R_Y_OFF 0 /* offset to R => Y section */
#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */
#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */
#define R_CB_OFF (3*(MAXJSAMPLE+1))
#define G_CB_OFF (4*(MAXJSAMPLE+1))
#define B_CB_OFF (5*(MAXJSAMPLE+1))
#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */
#define G_CR_OFF (6*(MAXJSAMPLE+1))
#define B_CR_OFF (7*(MAXJSAMPLE+1))
#define TABLE_SIZE (8*(MAXJSAMPLE+1))
typedef short DCTELEM;
#define FIX_0_382683433 ((INT32) 98) /* FIX(0.382683433) */
#define FIX_0_541196100 ((INT32) 139) /* FIX(0.541196100) */
#define FIX_0_707106781 ((INT32) 181) /* FIX(0.707106781) */
#define FIX_1_306562965 ((INT32) 334)
#define ONE ((INT32) 1)
#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
#define DESCALE_IDCT(x,n) RIGHT_SHIFT(x, n)
#define CONST_BITS_FDCT 8
#define MULTIPLY_F(var,const) ((DCTELEM) DESCALE_IDCT((var) * (const), CONST_BITS_FDCT))
#define MULTIPLY16V16(var1,var2) ((var1) * (var2))
struct quantval
{
UINT16 quantval_luminance[DCTSIZE2];
UINT16 quantval_chrominance[DCTSIZE2];
UINT16 quantval_luminance2[DCTSIZE2];
UINT16 quantval_chrominance2[DCTSIZE2];
UINT16 quantval_luminance2m[DCTSIZE2];
UINT16 quantval_chrominance2m[DCTSIZE2];
UINT16 quantval_luminance2mz[DCTSIZE2];
UINT16 quantval_chrominance2mz[DCTSIZE2];
UINT16 iquantval_luminance2[DCTSIZE2];
UINT16 iquantval_chrominance2[DCTSIZE2];
};
class CBmp2jpg
{
public:
CBmp2jpg(void);
~CBmp2jpg(void);
int compress_24bmp2jpg(unsigned char* pbmp, int width, int height, unsigned char* pbuffer, int buffer_size);
int compress_32bmp2jpg(unsigned char* pbmp, int width, int height, unsigned char* pbuffer, int buffer_size);
void init_quantization(int quality);
void rgb_ycc_convertor_init();
void get_dct_blocks_color24(unsigned char* pPixelInBitmap, int BmpStride, short* pYDctBlock, short* pCbDctBlock, short* pCrDctBlock);
void get_dct_blocks_color32(unsigned char* pPixelInBitmap, int BmpStride, short* pYDctBlock, short* pCbDctBlock, short* pCrDctBlock);
void jpeg_fdct_ifast (DCTELEM * data);
ULONG emit_bits(ULONG code, ULONG size, PUCHAR pOutputBuffer, ULONG BitIndex);
ULONG emit_bits_2(ULONG code, ULONG size, PUCHAR pOutputBuffer, ULONG BitIndex);
int encode_block(short *pBlock8x8, PUCHAR pDst, short* punused, int bit_idx, int last_dc, const unsigned int* phtable);
void quantization(DCTELEM *workspace, UINT16 *divisors);
void descale_iqunt (UINT16 *quantval, UINT16 *ifmtbl);
void descale_qunt( UINT16 *quantval, UINT16 *dtbl);
void jpeg_set_linear_quality (quantval* stQuantval, int scale_factor, bool force_baseline);
int jpeg_quality_scaling (int quality);
void jpeg_set_quality (quantval* stQuantval, int quality, bool force_baseline);
void jpeg_add_quant_table (UINT16 *quantval, int which_tbl,
const unsigned int *basic_table,
int scale_factor, bool force_baseline);
void prepare_range_limit_table();
static bool m_rgb_ycc_tab_initialized;
static long m_rgb_ycc_tab[TABLE_SIZE];
static const unsigned int huf_tbl_Y[256*4];
static const unsigned int huf_tbl_CbCr[256*4];
static const unsigned int masktbl[9];
static const unsigned int zigzag_order[64];
JSAMPLE range_limit_table_data[(5 * (MAXJSAMPLE+1) + CENTERJSAMPLE)];
JSAMPLE* range_limit_table;
quantval m_quantval;
};
extern CBmp2jpg* G_pbmp2jpg;
extern unsigned char G_jpghdr[];
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
<File name="texture.cpp" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="2751" topLine="82" />
</Cursor>
</File>
<File name="sglplayerMain.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="5" zoom_2="0">
<Cursor>
<Cursor1 position="667" topLine="19" />
</Cursor>
</File>
<File name="Basicglplane.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0">
<Cursor>
<Cursor1 position="914" topLine="36" />
</Cursor>
</File>
<File name="src/MotionFrame.cpp" open="0" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="88" topLine="0" />
</Cursor>
</File>
<File name="global.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="803" topLine="3" />
</Cursor>
</File>
<File name="Bmp2jpg.cpp" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="21399" topLine="120" />
</Cursor>
<Folding>
<Collapse line="7" />
<Collapse line="143" />
<Collapse line="377" />
<Collapse line="459" />
<Collapse line="562" />
<Collapse line="632" />
<Collapse line="741" />
</Folding>
</File>
<File name="Bmp2jpg.h" open="1" top="1" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2432" topLine="0" />
</Cursor>
</File>
<File name="texture.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="809" topLine="1" />
</Cursor>
</File>
<File name="sglplayerMain.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0">
<Cursor>
<Cursor1 position="4386" topLine="119" />
</Cursor>
<Folding>
<Collapse line="145" />
<Collapse line="162" />
</Folding>
</File>
<File name="Basicglplane.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="4" zoom_2="0">
<Cursor>
<Cursor1 position="2646" topLine="32" />
</Cursor>
<Folding>
<Collapse line="21" />
<Collapse line="105" />
<Collapse line="128" />
<Collapse line="270" />
<Collapse line="382" />
</Folding>
</File>
<File name="src/RenderTimer.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="262" topLine="0" />
</Cursor>
</File>
<File name="SettingsDialog.cpp" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0">
<Cursor>
<Cursor1 position="2226" topLine="0" />
</Cursor>
</File>
<File name="src/MotionFrameDCT.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="609" topLine="3" />
</Cursor>
</File>
<File name="include/IPcameraRTSP.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="442" topLine="5" />
</Cursor>
</File>
<File name="SettingsDialog.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0">
<Cursor>
<Cursor1 position="138" topLine="0" />
</Cursor>
</File>
<File name="src/IPcameraRTSP.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="15327" topLine="334" />
</Cursor>
<Folding>
<Collapse line="249" />
</Folding>
</File>
<File name="sglplayerApp.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="320" topLine="0" />
</Cursor>
</File>
<File name="include/RenderTimer.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="63" topLine="0" />
</Cursor>
</File>
<File name="sglplayerApp.cpp" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="435" topLine="0" />
</Cursor>
</File>
<File name="include/MotionFrame.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="373" topLine="8" />
</Cursor>
</File>
</CodeBlocks_layout_file>
layout