#include "SSD1926_JPEG.h"
#include "SSD1928_JPEGENC.h"

#define SSD_REG_DEFINE_END	0xffff

const INT32 reg_init[][2]={
      {SSD_REG_FRC_FRAME_CTL                ,0x00},   // Reg   334h
      {SSD_REG_FRC_ENABLE                   ,0x00},   // Reg   336h
      {SSD_JPEG_REG_RESIZER_CTL             ,0x00},   // Reg   360h
      {SSD_JPEG_REG_CTRL                    ,0x00},   // Reg   380h
      {SSD_JPEG_REG_RAW_STATUS              ,0x00},   // Reg   384h
      {SSD_JPEG_REG_START_STOP              ,0x00},   // Reg   38ah
      {SSD_JPEG_REG_FIFO_SIZE               ,0x00},   // Reg   3a4h
      {SSD_JPEG_REG_ENCODE_SIZE_LIMIT_0     ,0x00},   // Reg   3b0h
      {SSD_JPEG_REG_ENCODE_SIZE_LIMIT_1     ,0x00},   // Reg   3b1h
      {SSD_JPEG_REG_ENCODE_SIZE_LIMIT_2     ,0x00},   // Reg   3b2h

      {SSD_JPEG_REG_FILE_SIZE_0             ,0x00},   // Reg   3b8h
      {SSD_JPEG_REG_FILE_SIZE_1             ,0x00},   // Reg   3b9h
      {SSD_JPEG_REG_FILE_SIZE_2             ,0x00},   // Reg   3bah

      {SSD_JPEG_REG_OP_MODE_ENC             ,0x00},   // Reg   400h

      {SSD_JPEG_REG_CMD                     ,0x80},   // Reg   402h

      {SSD_JPEG_REG_DECODE_VALUE            ,0x00},   // Reg   404h

      {SSD_JPEG_REG_Y_PIXEL_SIZE_0          ,0x00},   // Reg   40ch
      {SSD_JPEG_REG_Y_PIXEL_SIZE_1          ,0x00},   // Reg   40dh
      {SSD_JPEG_REG_X_PIXEL_SIZE_0          ,0x00},   // Reg   40eh
      {SSD_JPEG_REG_X_PIXEL_SIZE_1          ,0x00},   // Reg   40fh

      {SSD_JPEG_REG_SRC_START_ADDR_0        ,0x00},   // Reg   410h
      {SSD_JPEG_REG_SRC_START_ADDR_1        ,0x00},   // Reg   411h
      {SSD_JPEG_REG_SRC_START_ADDR_2        ,0x00},   // Reg   412h
      {0x413						        ,0x00},   // Reg   413h

      {SSD_JPEG_REG_DEST_START_ADDR_0       ,0x00},   // Reg   414h
      {SSD_JPEG_REG_DEST_START_ADDR_1       ,0x00},   // Reg   415h
      {SSD_JPEG_REG_DEST_START_ADDR_2       ,0x00},   // Reg   416h
      {SSD_JPEG_REG_DEST_START_ADDR_3       ,0x00},   // Reg   417h

      {SSD_JPEG_REG_RST_MARKER_STATUS       ,0x00},   // Reg   41eh

      {SSD_JPEG_REG_INSERT_MARKER00         ,0xff},   // Reg   420
      {SSD_JPEG_REG_INSERT_MARKER01         ,0xfe},   // Reg   422

      {SSD_JPEG_REG_MARKER_LENGTH00         ,0x00},   // Reg   424
      {SSD_JPEG_REG_MARKER_LENGTH01         ,0x22},   // Reg   426

      {SSD_JPEG_REG_MARKER_DATA_00          ,0x05},   // Reg   428
      {SSD_JPEG_REG_MARKER_DATA_01          ,0x06},   // Reg   42a
      {SSD_JPEG_REG_MARKER_DATA_02          ,0xff},   // Reg   42c
      {SSD_JPEG_REG_MARKER_DATA_03          ,0xff},   // Reg   42e
      {SSD_JPEG_REG_MARKER_DATA_04          ,0xff},   // Reg   430
      {SSD_JPEG_REG_MARKER_DATA_05          ,0xff},   // Reg   432
      {SSD_JPEG_REG_MARKER_DATA_06          ,0xff},   // Reg   434
      {SSD_JPEG_REG_MARKER_DATA_07          ,0xff},   // Reg   436
      {SSD_JPEG_REG_MARKER_DATA_08          ,0xff},   // Reg   438
      {SSD_JPEG_REG_MARKER_DATA_09          ,0xff},   // Reg   43a
      {SSD_JPEG_REG_MARKER_DATA_10          ,0xff},   // Reg   43c
      {SSD_JPEG_REG_MARKER_DATA_11          ,0xff},   // Reg   43e
      {SSD_JPEG_REG_MARKER_DATA_12          ,0xff},   // Reg   440
      {SSD_JPEG_REG_MARKER_DATA_13          ,0xff},   // Reg   442
      {SSD_JPEG_REG_MARKER_DATA_14          ,0xff},   // Reg   444
      {SSD_JPEG_REG_MARKER_DATA_15          ,0xff},   // Reg   446
      {SSD_JPEG_REG_MARKER_DATA_16          ,0xff},   // Reg   448
      {SSD_JPEG_REG_MARKER_DATA_17          ,0xff},   // Reg   44a
      {SSD_JPEG_REG_MARKER_DATA_18          ,0xff},   // Reg   44c
      {SSD_JPEG_REG_MARKER_DATA_19          ,0xff},   // Reg   44e
      {SSD_JPEG_REG_MARKER_DATA_20          ,0xff},   // Reg   450
      {SSD_JPEG_REG_MARKER_DATA_21          ,0xff},   // Reg   452
      {SSD_JPEG_REG_MARKER_DATA_22          ,0xff},   // Reg   454
      {SSD_JPEG_REG_MARKER_DATA_23          ,0xff},   // Reg   456
      {SSD_JPEG_REG_MARKER_DATA_24          ,0xff},   // Reg   458
      {SSD_JPEG_REG_MARKER_DATA_25          ,0xff},   // Reg   45a
      {SSD_JPEG_REG_MARKER_DATA_26          ,0xff},   // Reg   45c
      {SSD_JPEG_REG_MARKER_DATA_27          ,0xff},   // Reg   45e
      {SSD_JPEG_REG_MARKER_DATA_28          ,0xff},   // Reg   460
      {SSD_JPEG_REG_MARKER_DATA_29          ,0xff},   // Reg   462
      {SSD_JPEG_REG_MARKER_DATA_30          ,0x30},   // Reg   464
      {SSD_JPEG_REG_MARKER_DATA_31          ,0x31},   // Reg   466

      {SSD_JPEG_REG_SOI_CONST_00            ,0xff},   // Reg   468
      {SSD_JPEG_REG_SOI_CONST_01            ,0xd8},   // Reg   46a

      {SSD_JPEG_REG_JFIF_CONST_00           ,0xff},   // Reg   46c
      {SSD_JPEG_REG_JFIF_CONST_01           ,0xe0},   // Reg   46e
      {SSD_JPEG_REG_JFIF_CONST_02           ,0x00},   // Reg   470
      {SSD_JPEG_REG_JFIF_CONST_03           ,0x10},   // Reg   472
      {SSD_JPEG_REG_JFIF_CONST_04           ,0x4a},   // Reg   474
      {SSD_JPEG_REG_JFIF_CONST_05           ,0x46},   // Reg   476
      {SSD_JPEG_REG_JFIF_CONST_06           ,0x49},   // Reg   478
      {SSD_JPEG_REG_JFIF_CONST_07           ,0x46},   // Reg   47a
      {SSD_JPEG_REG_JFIF_CONST_08           ,0x00},   // Reg   47c
      {SSD_JPEG_REG_JFIF_CONST_09           ,0x01},   // Reg   47e
      {SSD_JPEG_REG_JFIF_CONST_10           ,0x02},   // Reg   480
      {SSD_JPEG_REG_JFIF_CONST_11           ,0x00},   // Reg   482
      {SSD_JPEG_REG_JFIF_CONST_12           ,0x00},   // Reg   484
      {SSD_JPEG_REG_JFIF_CONST_13           ,0x01},   // Reg   486
      {SSD_JPEG_REG_JFIF_CONST_14           ,0x00},   // Reg   488
      {SSD_JPEG_REG_JFIF_CONST_15           ,0x01},   // Reg   48a
      {SSD_JPEG_REG_JFIF_CONST_16           ,0x00},   // Reg   48c
      {SSD_JPEG_REG_JFIF_CONST_17           ,0x00},   // Reg   48e

      {SSD_JPEG_REG_LUM_DC_HT_CONST_00      ,0xff},   // Reg   490
      {SSD_JPEG_REG_LUM_DC_HT_CONST_01      ,0xc4},   // Reg   492
      {SSD_JPEG_REG_LUM_DC_HT_CONST_02      ,0x00},   // Reg   494
      {SSD_JPEG_REG_LUM_DC_HT_CONST_03      ,0x1f},   // Reg   496
      {SSD_JPEG_REG_LUM_DC_HT_CONST_04      ,0x00},   // Reg   498

      {SSD_JPEG_REG_CHR_DC_HT_CONST_00      ,0xff},   // Reg   4a0
      {SSD_JPEG_REG_CHR_DC_HT_CONST_01      ,0xc4},   // Reg   4a2
      {SSD_JPEG_REG_CHR_DC_HT_CONST_02      ,0x00},   // Reg   4a4
      {SSD_JPEG_REG_CHR_DC_HT_CONST_03      ,0x1f},   // Reg   4a6
      {SSD_JPEG_REG_CHR_DC_HT_CONST_04      ,0x01},   // Reg   4a8

      {SSD_JPEG_REG_LUM_AC_HT_CONST_00      ,0xff},   // Reg   4b0
      {SSD_JPEG_REG_LUM_AC_HT_CONST_01      ,0xc4},   // Reg   4b2
      {SSD_JPEG_REG_LUM_AC_HT_CONST_02      ,0x00},   // Reg   4b4
      {SSD_JPEG_REG_LUM_AC_HT_CONST_03      ,0xb5},   // Reg   4b6
      {SSD_JPEG_REG_LUM_AC_HT_CONST_04      ,0x10},   // Reg   4b8

      {SSD_JPEG_REG_CHR_AC_HT_CONST_00      ,0xff},   // Reg   4c0
      {SSD_JPEG_REG_CHR_AC_HT_CONST_01      ,0xc4},   // Reg   4c2
      {SSD_JPEG_REG_CHR_AC_HT_CONST_02      ,0x00},   // Reg   4c4
      {SSD_JPEG_REG_CHR_AC_HT_CONST_03      ,0xb5},   // Reg   4c6
      {SSD_JPEG_REG_CHR_AC_HT_CONST_04      ,0x11},   // Reg   4c8

      {SSD_JPEG_REG_LUM_QT_CONST_00         ,0xff},   // Reg   4d0
      {SSD_JPEG_REG_LUM_QT_CONST_01         ,0xdb},   // Reg   4d2
      {SSD_JPEG_REG_LUM_QT_CONST_02         ,0x00},   // Reg   4d4
      {SSD_JPEG_REG_LUM_QT_CONST_03         ,0x43},   // Reg   4d6
      {SSD_JPEG_REG_LUM_QT_CONST_04         ,0x00},   // Reg   4d8

      {SSD_JPEG_REG_CHR_QT_CONST_00         ,0xff},   // Reg   4e0
      {SSD_JPEG_REG_CHR_QT_CONST_01         ,0xdb},   // Reg   4e2
      {SSD_JPEG_REG_CHR_QT_CONST_02         ,0x00},   // Reg   4e4
      {SSD_JPEG_REG_CHR_QT_CONST_03         ,0x43},   // Reg   4e6
      {SSD_JPEG_REG_CHR_QT_CONST_04         ,0x01},   // Reg   4e8

      {SSD_JPEG_REG_SOF_CONST_00            ,0xff},   // Reg   4f0
      {SSD_JPEG_REG_SOF_CONST_01            ,0xc0},   // Reg   4f2
      {SSD_JPEG_REG_SOF_CONST_02            ,0x00},   // Reg   4f4
      {SSD_JPEG_REG_SOF_CONST_03            ,0x11},   // Reg   4f6
      {SSD_JPEG_REG_SOF_CONST_04            ,0x08},   // Reg   4f8

      {SSD_JPEG_REG_QUANT_T0_00             ,0x10},   // Reg   500
      {SSD_JPEG_REG_QUANT_T0_01             ,0x0b},   // Reg   502
      {SSD_JPEG_REG_QUANT_T0_02             ,0x0c},   // Reg   504
      {SSD_JPEG_REG_QUANT_T0_03             ,0x0e},   // Reg   506
      {SSD_JPEG_REG_QUANT_T0_04             ,0x0c},   // Reg   508
      {SSD_JPEG_REG_QUANT_T0_05             ,0x0a},   // Reg   50a
      {SSD_JPEG_REG_QUANT_T0_06             ,0x10},   // Reg   50c
      {SSD_JPEG_REG_QUANT_T0_07             ,0x0e},   // Reg   50e
      {SSD_JPEG_REG_QUANT_T0_08             ,0x0d},   // Reg   510
      {SSD_JPEG_REG_QUANT_T0_09             ,0x0e},   // Reg   512
      {SSD_JPEG_REG_QUANT_T0_10             ,0x12},   // Reg   514
      {SSD_JPEG_REG_QUANT_T0_11             ,0x11},   // Reg   516
      {SSD_JPEG_REG_QUANT_T0_12             ,0x10},   // Reg   518
      {SSD_JPEG_REG_QUANT_T0_13             ,0x13},   // Reg   51a
      {SSD_JPEG_REG_QUANT_T0_14             ,0x18},   // Reg   51c
      {SSD_JPEG_REG_QUANT_T0_15             ,0x28},   // Reg   51e
      {SSD_JPEG_REG_QUANT_T0_16             ,0x1a},   // Reg   520
      {SSD_JPEG_REG_QUANT_T0_17             ,0x18},   // Reg   522
      {SSD_JPEG_REG_QUANT_T0_18             ,0x16},   // Reg   524
      {SSD_JPEG_REG_QUANT_T0_19             ,0x16},   // Reg   526
      {SSD_JPEG_REG_QUANT_T0_20             ,0x18},   // Reg   528
      {SSD_JPEG_REG_QUANT_T0_21             ,0x31},   // Reg   52a
      {SSD_JPEG_REG_QUANT_T0_22             ,0x23},   // Reg   52c
      {SSD_JPEG_REG_QUANT_T0_23             ,0x25},   // Reg   52e
      {SSD_JPEG_REG_QUANT_T0_24             ,0x1d},   // Reg   530
      {SSD_JPEG_REG_QUANT_T0_25             ,0x28},   // Reg   532
      {SSD_JPEG_REG_QUANT_T0_26             ,0x3a},   // Reg   534
      {SSD_JPEG_REG_QUANT_T0_27             ,0x33},   // Reg   536
      {SSD_JPEG_REG_QUANT_T0_28             ,0x3d},   // Reg   538
      {SSD_JPEG_REG_QUANT_T0_29             ,0x3c},   // Reg   53a
      {SSD_JPEG_REG_QUANT_T0_30             ,0x39},   // Reg   53c
      {SSD_JPEG_REG_QUANT_T0_31             ,0x33},   // Reg   53e
      {SSD_JPEG_REG_QUANT_T0_32             ,0x38},   // Reg   540
      {SSD_JPEG_REG_QUANT_T0_33             ,0x37},   // Reg   542
      {SSD_JPEG_REG_QUANT_T0_34             ,0x40},   // Reg   544
      {SSD_JPEG_REG_QUANT_T0_35             ,0x48},   // Reg   546
      {SSD_JPEG_REG_QUANT_T0_36             ,0x5c},   // Reg   548
      {SSD_JPEG_REG_QUANT_T0_37             ,0x4e},   // Reg   54a
      {SSD_JPEG_REG_QUANT_T0_38             ,0x40},   // Reg   54c
      {SSD_JPEG_REG_QUANT_T0_39             ,0x44},   // Reg   54e
      {SSD_JPEG_REG_QUANT_T0_40             ,0x57},   // Reg   550
      {SSD_JPEG_REG_QUANT_T0_41             ,0x45},   // Reg   552
      {SSD_JPEG_REG_QUANT_T0_42             ,0x37},   // Reg   554
      {SSD_JPEG_REG_QUANT_T0_43             ,0x38},   // Reg   556
      {SSD_JPEG_REG_QUANT_T0_44             ,0x50},   // Reg   558
      {SSD_JPEG_REG_QUANT_T0_45             ,0x6d},   // Reg   55a
      {SSD_JPEG_REG_QUANT_T0_46             ,0x51},   // Reg   55c
      {SSD_JPEG_REG_QUANT_T0_47             ,0x57},   // Reg   55e
      {SSD_JPEG_REG_QUANT_T0_48             ,0x5f},   // Reg   560
      {SSD_JPEG_REG_QUANT_T0_49             ,0x62},   // Reg   562
      {SSD_JPEG_REG_QUANT_T0_50             ,0x67},   // Reg   564
      {SSD_JPEG_REG_QUANT_T0_51             ,0x68},   // Reg   566
      {SSD_JPEG_REG_QUANT_T0_52             ,0x67},   // Reg   568
      {SSD_JPEG_REG_QUANT_T0_53             ,0x3e},   // Reg   56a
      {SSD_JPEG_REG_QUANT_T0_54             ,0x4d},   // Reg   56c
      {SSD_JPEG_REG_QUANT_T0_55             ,0x71},   // Reg   56e
      {SSD_JPEG_REG_QUANT_T0_56             ,0x79},   // Reg   570
      {SSD_JPEG_REG_QUANT_T0_57             ,0x70},   // Reg   572
      {SSD_JPEG_REG_QUANT_T0_58             ,0x64},   // Reg   574
      {SSD_JPEG_REG_QUANT_T0_59             ,0x78},   // Reg   576
      {SSD_JPEG_REG_QUANT_T0_60             ,0x5c},   // Reg   578
      {SSD_JPEG_REG_QUANT_T0_61             ,0x65},   // Reg   57a
      {SSD_JPEG_REG_QUANT_T0_62             ,0x67},   // Reg   57c
      {SSD_JPEG_REG_QUANT_T0_63             ,0x63},   // Reg   57e

      //64 elements for Quantization table
      {SSD_JPEG_REG_QUANT_T1_00             ,0x11},   // Reg   580
      {SSD_JPEG_REG_QUANT_T1_01             ,0x12},   // Reg   582
      {SSD_JPEG_REG_QUANT_T1_02             ,0x12},   // Reg   584
      {SSD_JPEG_REG_QUANT_T1_03             ,0x18},   // Reg   586
      {SSD_JPEG_REG_QUANT_T1_04             ,0x15},   // Reg   588
      {SSD_JPEG_REG_QUANT_T1_05             ,0x18},   // Reg   58a
      {SSD_JPEG_REG_QUANT_T1_06             ,0x2f},   // Reg   58c
      {SSD_JPEG_REG_QUANT_T1_07             ,0x1a},   // Reg   58e
      {SSD_JPEG_REG_QUANT_T1_08             ,0x1a},   // Reg   590
      {SSD_JPEG_REG_QUANT_T1_09             ,0x2f},   // Reg   592
      {SSD_JPEG_REG_QUANT_T1_10             ,0x63},   // Reg   594
      {SSD_JPEG_REG_QUANT_T1_11             ,0x42},   // Reg   596
      {SSD_JPEG_REG_QUANT_T1_12             ,0x38},   // Reg   598
      {SSD_JPEG_REG_QUANT_T1_13             ,0x42},   // Reg   59a
      {SSD_JPEG_REG_QUANT_T1_14             ,0x63},   // Reg   59c
      {SSD_JPEG_REG_QUANT_T1_15             ,0x63},   // Reg   59e
      {SSD_JPEG_REG_QUANT_T1_16             ,0x63},   // Reg   5a0
      {SSD_JPEG_REG_QUANT_T1_17             ,0x63},   // Reg   5a2
      {SSD_JPEG_REG_QUANT_T1_18             ,0x63},   // Reg   5a4
      {SSD_JPEG_REG_QUANT_T1_19             ,0x63},   // Reg   5a6
      {SSD_JPEG_REG_QUANT_T1_20             ,0x63},   // Reg   5a8
      {SSD_JPEG_REG_QUANT_T1_21             ,0x63},   // Reg   5aa
      {SSD_JPEG_REG_QUANT_T1_22             ,0x63},   // Reg   5ac
      {SSD_JPEG_REG_QUANT_T1_23             ,0x63},   // Reg   5ae
      {SSD_JPEG_REG_QUANT_T1_24             ,0x63},   // Reg   5b0
      {SSD_JPEG_REG_QUANT_T1_25             ,0x63},   // Reg   5b2
      {SSD_JPEG_REG_QUANT_T1_26             ,0x63},   // Reg   5b4
      {SSD_JPEG_REG_QUANT_T1_27             ,0x63},   // Reg   5b6
      {SSD_JPEG_REG_QUANT_T1_28             ,0x63},   // Reg   5b8
      {SSD_JPEG_REG_QUANT_T1_29             ,0x63},   // Reg   5ba
      {SSD_JPEG_REG_QUANT_T1_30             ,0x63},   // Reg   5bc
      {SSD_JPEG_REG_QUANT_T1_31             ,0x63},   // Reg   5be
      {SSD_JPEG_REG_QUANT_T1_32             ,0x63},   // Reg   5c0
      {SSD_JPEG_REG_QUANT_T1_33             ,0x63},   // Reg   5c2
      {SSD_JPEG_REG_QUANT_T1_34             ,0x63},   // Reg   5c4
      {SSD_JPEG_REG_QUANT_T1_35             ,0x63},   // Reg   5c6
      {SSD_JPEG_REG_QUANT_T1_36             ,0x63},   // Reg   5c8
      {SSD_JPEG_REG_QUANT_T1_37             ,0x63},   // Reg   5ca
      {SSD_JPEG_REG_QUANT_T1_38             ,0x63},   // Reg   5cc
      {SSD_JPEG_REG_QUANT_T1_39             ,0x63},   // Reg   5ce
      {SSD_JPEG_REG_QUANT_T1_40             ,0x63},   // Reg   5d0
      {SSD_JPEG_REG_QUANT_T1_41             ,0x63},   // Reg   5d2
      {SSD_JPEG_REG_QUANT_T1_42             ,0x63},   // Reg   5d4
      {SSD_JPEG_REG_QUANT_T1_43             ,0x63},   // Reg   5d6
      {SSD_JPEG_REG_QUANT_T1_44             ,0x63},   // Reg   5d8
      {SSD_JPEG_REG_QUANT_T1_45             ,0x63},   // Reg   5da
      {SSD_JPEG_REG_QUANT_T1_46             ,0x63},   // Reg   5dc
      {SSD_JPEG_REG_QUANT_T1_47             ,0x63},   // Reg   5de
      {SSD_JPEG_REG_QUANT_T1_48             ,0x63},   // Reg   5e0
      {SSD_JPEG_REG_QUANT_T1_49             ,0x63},   // Reg   5e2
      {SSD_JPEG_REG_QUANT_T1_50             ,0x63},   // Reg   5e4
      {SSD_JPEG_REG_QUANT_T1_51             ,0x63},   // Reg   5e6
      {SSD_JPEG_REG_QUANT_T1_52             ,0x63},   // Reg   5e8
      {SSD_JPEG_REG_QUANT_T1_53             ,0x63},   // Reg   5ea
      {SSD_JPEG_REG_QUANT_T1_54             ,0x63},   // Reg   5ec
      {SSD_JPEG_REG_QUANT_T1_55             ,0x63},   // Reg   5ee
      {SSD_JPEG_REG_QUANT_T1_56             ,0x63},   // Reg   5f0
      {SSD_JPEG_REG_QUANT_T1_57             ,0x63},   // Reg   5f2
      {SSD_JPEG_REG_QUANT_T1_58             ,0x63},   // Reg   5f4
      {SSD_JPEG_REG_QUANT_T1_59             ,0x63},   // Reg   5f6
      {SSD_JPEG_REG_QUANT_T1_60             ,0x63},   // Reg   5f8
      {SSD_JPEG_REG_QUANT_T1_61             ,0x63},   // Reg   5fa
      {SSD_JPEG_REG_QUANT_T1_62             ,0x63},   // Reg   5fc
      {SSD_JPEG_REG_QUANT_T1_63             ,0x63},   // Reg   5fe

      {SSD_JPEG_REG_DC_T0_R0_00             ,0x00},   // Reg   600
      {SSD_JPEG_REG_DC_T0_R0_01             ,0x01},   // Reg   602
      {SSD_JPEG_REG_DC_T0_R0_02             ,0x05},   // Reg   604
      {SSD_JPEG_REG_DC_T0_R0_03             ,0x01},   // Reg   606
      {SSD_JPEG_REG_DC_T0_R0_04             ,0x01},   // Reg   608
      {SSD_JPEG_REG_DC_T0_R0_05             ,0x01},   // Reg   60a
      {SSD_JPEG_REG_DC_T0_R0_06             ,0x01},   // Reg   60c
      {SSD_JPEG_REG_DC_T0_R0_07             ,0x01},   // Reg   60e
      {SSD_JPEG_REG_DC_T0_R0_08             ,0x01},   // Reg   610
      {SSD_JPEG_REG_DC_T0_R0_09             ,0x00},   // Reg   612
      {SSD_JPEG_REG_DC_T0_R0_10             ,0x00},   // Reg   614
      {SSD_JPEG_REG_DC_T0_R0_11             ,0x00},   // Reg   616
      {SSD_JPEG_REG_DC_T0_R0_12             ,0x00},   // Reg   618
      {SSD_JPEG_REG_DC_T0_R0_13             ,0x00},   // Reg   61a
      {SSD_JPEG_REG_DC_T0_R0_14             ,0x00},   // Reg   61c
      {SSD_JPEG_REG_DC_T0_R0_15             ,0x00},   // Reg   61e

      {SSD_JPEG_REG_DC_T0_R1_00             ,0x00},   // Reg   620
      {SSD_JPEG_REG_DC_T0_R1_01             ,0x01},   // Reg   622
      {SSD_JPEG_REG_DC_T0_R1_02             ,0x02},   // Reg   624
      {SSD_JPEG_REG_DC_T0_R1_03             ,0x03},   // Reg   626
      {SSD_JPEG_REG_DC_T0_R1_04             ,0x04},   // Reg   628
      {SSD_JPEG_REG_DC_T0_R1_05             ,0x05},   // Reg   62a
      {SSD_JPEG_REG_DC_T0_R1_06             ,0x06},   // Reg   62c
      {SSD_JPEG_REG_DC_T0_R1_07             ,0x07},   // Reg   62e
      {SSD_JPEG_REG_DC_T0_R1_08             ,0x08},   // Reg   630
      {SSD_JPEG_REG_DC_T0_R1_09             ,0x09},   // Reg   632
      {SSD_JPEG_REG_DC_T0_R1_10             ,0x0a},   // Reg   634
      {SSD_JPEG_REG_DC_T0_R1_11             ,0x0b},   // Reg   636

      {SSD_JPEG_REG_AC_T0_R0_00             ,0x00},   // Reg   640
      {SSD_JPEG_REG_AC_T0_R0_01             ,0x02},   // Reg   642
      {SSD_JPEG_REG_AC_T0_R0_02             ,0x01},   // Reg   644
      {SSD_JPEG_REG_AC_T0_R0_03             ,0x03},   // Reg   646
      {SSD_JPEG_REG_AC_T0_R0_04             ,0x03},   // Reg   648
      {SSD_JPEG_REG_AC_T0_R0_05             ,0x02},   // Reg   64a
      {SSD_JPEG_REG_AC_T0_R0_06             ,0x04},   // Reg   64c
      {SSD_JPEG_REG_AC_T0_R0_07             ,0x03},   // Reg   64e
      {SSD_JPEG_REG_AC_T0_R0_08             ,0x05},   // Reg   650
      {SSD_JPEG_REG_AC_T0_R0_09             ,0x05},   // Reg   652
      {SSD_JPEG_REG_AC_T0_R0_10             ,0x04},   // Reg   654
      {SSD_JPEG_REG_AC_T0_R0_11             ,0x04},   // Reg   656
      {SSD_JPEG_REG_AC_T0_R0_12             ,0x00},   // Reg   658
      {SSD_JPEG_REG_AC_T0_R0_13             ,0x00},   // Reg   65a
      {SSD_JPEG_REG_AC_T0_R0_14             ,0x01},   // Reg   65c
      {SSD_JPEG_REG_AC_T0_R0_15             ,0x7d},   // Reg   65e

      {SSD_JPEG_REG_AC_T0_R1_00             ,0x01},   // Reg   660
      {SSD_JPEG_REG_AC_T0_R1_01             ,0x02},   // Reg   662
      {SSD_JPEG_REG_AC_T0_R1_02             ,0x03},   // Reg   664
      {SSD_JPEG_REG_AC_T0_R1_03             ,0x00},   // Reg   666
      {SSD_JPEG_REG_AC_T0_R1_04             ,0x04},   // Reg   668
      {SSD_JPEG_REG_AC_T0_R1_05             ,0x11},   // Reg   66a
      {SSD_JPEG_REG_AC_T0_R1_06             ,0x05},   // Reg   66c
      {SSD_JPEG_REG_AC_T0_R1_07             ,0x12},   // Reg   66e
      {SSD_JPEG_REG_AC_T0_R1_08             ,0x21},   // Reg   670
      {SSD_JPEG_REG_AC_T0_R1_09             ,0x31},   // Reg   672
      {SSD_JPEG_REG_AC_T0_R1_10             ,0x41},   // Reg   674
      {SSD_JPEG_REG_AC_T0_R1_11             ,0x06},   // Reg   676
      {SSD_JPEG_REG_AC_T0_R1_12             ,0x13},   // Reg   678
      {SSD_JPEG_REG_AC_T0_R1_13             ,0x51},   // Reg   67a
      {SSD_JPEG_REG_AC_T0_R1_14             ,0x61},   // Reg   67c
      {SSD_JPEG_REG_AC_T0_R1_15             ,0x07},   // Reg   67e
      {SSD_JPEG_REG_AC_T0_R1_16             ,0x22},   // Reg   680
      {SSD_JPEG_REG_AC_T0_R1_17             ,0x71},   // Reg   682
      {SSD_JPEG_REG_AC_T0_R1_18             ,0x14},   // Reg   684
      {SSD_JPEG_REG_AC_T0_R1_19             ,0x32},   // Reg   686
      {SSD_JPEG_REG_AC_T0_R1_20             ,0x81},   // Reg   688
      {SSD_JPEG_REG_AC_T0_R1_21             ,0x91},   // Reg   68a
      {SSD_JPEG_REG_AC_T0_R1_22             ,0xa1},   // Reg   68c
      {SSD_JPEG_REG_AC_T0_R1_23             ,0x08},   // Reg   68e
      {SSD_JPEG_REG_AC_T0_R1_24             ,0x23},   // Reg   690
      {SSD_JPEG_REG_AC_T0_R1_25             ,0x42},   // Reg   692
      {SSD_JPEG_REG_AC_T0_R1_26             ,0xb1},   // Reg   694
      {SSD_JPEG_REG_AC_T0_R1_27             ,0xc1},   // Reg   696
      {SSD_JPEG_REG_AC_T0_R1_28             ,0x15},   // Reg   698
      {SSD_JPEG_REG_AC_T0_R1_29             ,0x52},   // Reg   69a
      {SSD_JPEG_REG_AC_T0_R1_30             ,0xd1},   // Reg   69c
      {SSD_JPEG_REG_AC_T0_R1_31             ,0xf0},   // Reg   69e
      {SSD_JPEG_REG_AC_T0_R1_32             ,0x24},   // Reg   6a0
      {SSD_JPEG_REG_AC_T0_R1_33             ,0x33},   // Reg   6a2
      {SSD_JPEG_REG_AC_T0_R1_34             ,0x62},   // Reg   6a4
      {SSD_JPEG_REG_AC_T0_R1_35             ,0x72},   // Reg   6a6
      {SSD_JPEG_REG_AC_T0_R1_36             ,0x82},   // Reg   6a8
      {SSD_JPEG_REG_AC_T0_R1_37             ,0x09},   // Reg   6aa
      {SSD_JPEG_REG_AC_T0_R1_38             ,0x0a},   // Reg   6ac
      {SSD_JPEG_REG_AC_T0_R1_39             ,0x16},   // Reg   6ae
      {SSD_JPEG_REG_AC_T0_R1_40             ,0x17},   // Reg   6b0
      {SSD_JPEG_REG_AC_T0_R1_41             ,0x18},   // Reg   6b2
      {SSD_JPEG_REG_AC_T0_R1_42             ,0x19},   // Reg   6b4
      {SSD_JPEG_REG_AC_T0_R1_43             ,0x1a},   // Reg   6b6
      {SSD_JPEG_REG_AC_T0_R1_44             ,0x25},   // Reg   6b8
      {SSD_JPEG_REG_AC_T0_R1_45             ,0x26},   // Reg   6ba
      {SSD_JPEG_REG_AC_T0_R1_46             ,0x27},   // Reg   6bc
      {SSD_JPEG_REG_AC_T0_R1_47             ,0x28},   // Reg   6be
      {SSD_JPEG_REG_AC_T0_R1_48             ,0x29},   // Reg   6c0
      {SSD_JPEG_REG_AC_T0_R1_49             ,0x2a},   // Reg   6c2
      {SSD_JPEG_REG_AC_T0_R1_50             ,0x34},   // Reg   6c4
      {SSD_JPEG_REG_AC_T0_R1_51             ,0x35},   // Reg   6c6
      {SSD_JPEG_REG_AC_T0_R1_52             ,0x36},   // Reg   6c8
      {SSD_JPEG_REG_AC_T0_R1_53             ,0x37},   // Reg   6ca
      {SSD_JPEG_REG_AC_T0_R1_54             ,0x38},   // Reg   6cc
      {SSD_JPEG_REG_AC_T0_R1_55             ,0x39},   // Reg   6ce
      {SSD_JPEG_REG_AC_T0_R1_56             ,0x3a},   // Reg   6d0
      {SSD_JPEG_REG_AC_T0_R1_57             ,0x43},   // Reg   6d2
      {SSD_JPEG_REG_AC_T0_R1_58             ,0x44},   // Reg   6d4
      {SSD_JPEG_REG_AC_T0_R1_59             ,0x45},   // Reg   6d6
      {SSD_JPEG_REG_AC_T0_R1_60             ,0x46},   // Reg   6d8
      {SSD_JPEG_REG_AC_T0_R1_61             ,0x47},   // Reg   6da
      {SSD_JPEG_REG_AC_T0_R1_62             ,0x48},   // Reg   6dc
      {SSD_JPEG_REG_AC_T0_R1_63             ,0x49},   // Reg   6de
      {SSD_JPEG_REG_AC_T0_R1_64             ,0x4a},   // Reg   6e0
      {SSD_JPEG_REG_AC_T0_R1_65             ,0x53},   // Reg   6e2
      {SSD_JPEG_REG_AC_T0_R1_66             ,0x54},   // Reg   6e4
      {SSD_JPEG_REG_AC_T0_R1_67             ,0x55},   // Reg   6e6
      {SSD_JPEG_REG_AC_T0_R1_68             ,0x56},   // Reg   6e8
      {SSD_JPEG_REG_AC_T0_R1_69             ,0x57},   // Reg   6ea
      {SSD_JPEG_REG_AC_T0_R1_70             ,0x58},   // Reg   6ec
      {SSD_JPEG_REG_AC_T0_R1_71             ,0x59},   // Reg   6ee
      {SSD_JPEG_REG_AC_T0_R1_72             ,0x5a},   // Reg   6f0
      {SSD_JPEG_REG_AC_T0_R1_73             ,0x63},   // Reg   6f2
      {SSD_JPEG_REG_AC_T0_R1_74             ,0x64},   // Reg   6f4
      {SSD_JPEG_REG_AC_T0_R1_75             ,0x65},   // Reg   6f6
      {SSD_JPEG_REG_AC_T0_R1_76             ,0x66},   // Reg   6f8
      {SSD_JPEG_REG_AC_T0_R1_77             ,0x67},   // Reg   6fa
      {SSD_JPEG_REG_AC_T0_R1_78             ,0x68},   // Reg   6fc
      {SSD_JPEG_REG_AC_T0_R1_79             ,0x69},   // Reg   6fe
      {SSD_JPEG_REG_AC_T0_R1_80             ,0x6a},   // Reg   700
      {SSD_JPEG_REG_AC_T0_R1_81             ,0x73},   // Reg   702
      {SSD_JPEG_REG_AC_T0_R1_82             ,0x74},   // Reg   704
      {SSD_JPEG_REG_AC_T0_R1_83             ,0x75},   // Reg   706
      {SSD_JPEG_REG_AC_T0_R1_84             ,0x76},   // Reg   708
      {SSD_JPEG_REG_AC_T0_R1_85             ,0x77},   // Reg   70a
      {SSD_JPEG_REG_AC_T0_R1_86             ,0x78},   // Reg   70c
      {SSD_JPEG_REG_AC_T0_R1_87             ,0x79},   // Reg   70e
      {SSD_JPEG_REG_AC_T0_R1_88             ,0x7a},   // Reg   710
      {SSD_JPEG_REG_AC_T0_R1_89             ,0x83},   // Reg   712
      {SSD_JPEG_REG_AC_T0_R1_90             ,0x84},   // Reg   714
      {SSD_JPEG_REG_AC_T0_R1_91             ,0x85},   // Reg   716
      {SSD_JPEG_REG_AC_T0_R1_92             ,0x86},   // Reg   718
      {SSD_JPEG_REG_AC_T0_R1_93             ,0x87},   // Reg   71a
      {SSD_JPEG_REG_AC_T0_R1_94             ,0x88},   // Reg   71c
      {SSD_JPEG_REG_AC_T0_R1_95             ,0x89},   // Reg   71e
      {SSD_JPEG_REG_AC_T0_R1_96             ,0x8a},   // Reg   720
      {SSD_JPEG_REG_AC_T0_R1_97             ,0x92},   // Reg   722
      {SSD_JPEG_REG_AC_T0_R1_98             ,0x93},   // Reg   724
      {SSD_JPEG_REG_AC_T0_R1_99             ,0x94},   // Reg   726
      {SSD_JPEG_REG_AC_T0_R1_100            ,0x95},   // Reg   728
      {SSD_JPEG_REG_AC_T0_R1_101            ,0x96},   // Reg   72a
      {SSD_JPEG_REG_AC_T0_R1_102            ,0x97},   // Reg   72c
      {SSD_JPEG_REG_AC_T0_R1_103            ,0x98},   // Reg   72e
      {SSD_JPEG_REG_AC_T0_R1_104            ,0x99},   // Reg   730
      {SSD_JPEG_REG_AC_T0_R1_105            ,0x9a},   // Reg   732
      {SSD_JPEG_REG_AC_T0_R1_106            ,0xa2},   // Reg   734
      {SSD_JPEG_REG_AC_T0_R1_107            ,0xa3},   // Reg   736
      {SSD_JPEG_REG_AC_T0_R1_108            ,0xa4},   // Reg   738
      {SSD_JPEG_REG_AC_T0_R1_109            ,0xa5},   // Reg   73a
      {SSD_JPEG_REG_AC_T0_R1_110            ,0xa6},   // Reg   73c
      {SSD_JPEG_REG_AC_T0_R1_111            ,0xa7},   // Reg   73e
      {SSD_JPEG_REG_AC_T0_R1_112            ,0xa8},   // Reg   740
      {SSD_JPEG_REG_AC_T0_R1_113            ,0xa9},   // Reg   742
      {SSD_JPEG_REG_AC_T0_R1_114            ,0xaa},   // Reg   744
      {SSD_JPEG_REG_AC_T0_R1_115            ,0xb2},   // Reg   746
      {SSD_JPEG_REG_AC_T0_R1_116            ,0xb3},   // Reg   748
      {SSD_JPEG_REG_AC_T0_R1_117            ,0xb4},   // Reg   74a
      {SSD_JPEG_REG_AC_T0_R1_118            ,0xb5},   // Reg   74c
      {SSD_JPEG_REG_AC_T0_R1_119            ,0xb6},   // Reg   75e
      {SSD_JPEG_REG_AC_T0_R1_120            ,0xb7},   // Reg   750
      {SSD_JPEG_REG_AC_T0_R1_121            ,0xb8},   // Reg   752
      {SSD_JPEG_REG_AC_T0_R1_122            ,0xb9},   // Reg   754
      {SSD_JPEG_REG_AC_T0_R1_123            ,0xba},   // Reg   756
      {SSD_JPEG_REG_AC_T0_R1_124            ,0xc2},   // Reg   758
      {SSD_JPEG_REG_AC_T0_R1_125            ,0xc3},   // Reg   75a
      {SSD_JPEG_REG_AC_T0_R1_126            ,0xc4},   // Reg   75c
      {SSD_JPEG_REG_AC_T0_R1_127            ,0xc5},   // Reg   75e
      {SSD_JPEG_REG_AC_T0_R1_128            ,0xc6},   // Reg   760
      {SSD_JPEG_REG_AC_T0_R1_129            ,0xc7},   // Reg   762
      {SSD_JPEG_REG_AC_T0_R1_130            ,0xc8},   // Reg   764
      {SSD_JPEG_REG_AC_T0_R1_131            ,0xc9},   // Reg   766
      {SSD_JPEG_REG_AC_T0_R1_132            ,0xca},   // Reg   768
      {SSD_JPEG_REG_AC_T0_R1_133            ,0xd2},   // Reg   76a
      {SSD_JPEG_REG_AC_T0_R1_134            ,0xd3},   // Reg   76c
      {SSD_JPEG_REG_AC_T0_R1_135            ,0xd4},   // Reg   76e
      {SSD_JPEG_REG_AC_T0_R1_136            ,0xd5},   // Reg   770
      {SSD_JPEG_REG_AC_T0_R1_137            ,0xd6},   // Reg   772
      {SSD_JPEG_REG_AC_T0_R1_138            ,0xd7},   // Reg   774
      {SSD_JPEG_REG_AC_T0_R1_139            ,0xd8},   // Reg   776
      {SSD_JPEG_REG_AC_T0_R1_140            ,0xd9},   // Reg   778
      {SSD_JPEG_REG_AC_T0_R1_141            ,0xda},   // Reg   77a
      {SSD_JPEG_REG_AC_T0_R1_142            ,0xe1},   // Reg   77c
      {SSD_JPEG_REG_AC_T0_R1_143            ,0xe2},   // Reg   77e
      {SSD_JPEG_REG_AC_T0_R1_144            ,0xe3},   // Reg   780
      {SSD_JPEG_REG_AC_T0_R1_145            ,0xe4},   // Reg   782
      {SSD_JPEG_REG_AC_T0_R1_146            ,0xe5},   // Reg   784
      {SSD_JPEG_REG_AC_T0_R1_147            ,0xe6},   // Reg   786
      {SSD_JPEG_REG_AC_T0_R1_148            ,0xe7},   // Reg   788
      {SSD_JPEG_REG_AC_T0_R1_149            ,0xe8},   // Reg   78a
      {SSD_JPEG_REG_AC_T0_R1_150            ,0xe9},   // Reg   78c
      {SSD_JPEG_REG_AC_T0_R1_151            ,0xea},   // Reg   78e
      {SSD_JPEG_REG_AC_T0_R1_152            ,0xf1},   // Reg   790
      {SSD_JPEG_REG_AC_T0_R1_153            ,0xf2},   // Reg   792
      {SSD_JPEG_REG_AC_T0_R1_154            ,0xf3},   // Reg   794
      {SSD_JPEG_REG_AC_T0_R1_155            ,0xf4},   // Reg   796
      {SSD_JPEG_REG_AC_T0_R1_156            ,0xf5},   // Reg   798
      {SSD_JPEG_REG_AC_T0_R1_157            ,0xf6},   // Reg   79a
      {SSD_JPEG_REG_AC_T0_R1_158            ,0xf7},   // Reg   79c
      {SSD_JPEG_REG_AC_T0_R1_159            ,0xf8},   // Reg   79e
      {SSD_JPEG_REG_AC_T0_R1_160            ,0xf9},   // Reg   7a0
      {SSD_JPEG_REG_AC_T0_R1_161            ,0xfa},   // Reg   7a2

      {SSD_JPEG_REG_DC_T1_R0_00             ,0x00},   // Reg   800
      {SSD_JPEG_REG_DC_T1_R0_01             ,0x03},   // Reg   802
      {SSD_JPEG_REG_DC_T1_R0_02             ,0x01},   // Reg   804
      {SSD_JPEG_REG_DC_T1_R0_03             ,0x01},   // Reg   806
      {SSD_JPEG_REG_DC_T1_R0_04             ,0x01},   // Reg   808
      {SSD_JPEG_REG_DC_T1_R0_05             ,0x01},   // Reg   80a
      {SSD_JPEG_REG_DC_T1_R0_06             ,0x01},   // Reg   80c
      {SSD_JPEG_REG_DC_T1_R0_07             ,0x01},   // Reg   80e
      {SSD_JPEG_REG_DC_T1_R0_08             ,0x01},   // Reg   810
      {SSD_JPEG_REG_DC_T1_R0_09             ,0x01},   // Reg   812
      {SSD_JPEG_REG_DC_T1_R0_10             ,0x01},   // Reg   814
      {SSD_JPEG_REG_DC_T1_R0_11             ,0x00},   // Reg   816
      {SSD_JPEG_REG_DC_T1_R0_12             ,0x00},   // Reg   818
      {SSD_JPEG_REG_DC_T1_R0_13             ,0x00},   // Reg   81a
      {SSD_JPEG_REG_DC_T1_R0_14             ,0x00},   // Reg   81c
      {SSD_JPEG_REG_DC_T1_R0_15             ,0x00},   // Reg   81e

      {SSD_JPEG_REG_DC_T1_R1_00             ,0x00},   // Reg   820
      {SSD_JPEG_REG_DC_T1_R1_01             ,0x01},   // Reg   822
      {SSD_JPEG_REG_DC_T1_R1_02             ,0x02},   // Reg   824
      {SSD_JPEG_REG_DC_T1_R1_03             ,0x03},   // Reg   826
      {SSD_JPEG_REG_DC_T1_R1_04             ,0x04},   // Reg   828
      {SSD_JPEG_REG_DC_T1_R1_05             ,0x05},   // Reg   82a
      {SSD_JPEG_REG_DC_T1_R1_06             ,0x06},   // Reg   82c
      {SSD_JPEG_REG_DC_T1_R1_07             ,0x07},   // Reg   82e
      {SSD_JPEG_REG_DC_T1_R1_08             ,0x08},   // Reg   830
      {SSD_JPEG_REG_DC_T1_R1_09             ,0x09},   // Reg   832
      {SSD_JPEG_REG_DC_T1_R1_10             ,0x0a},   // Reg   834
      {SSD_JPEG_REG_DC_T1_R1_11             ,0x0b},   // Reg   836

      {SSD_JPEG_REG_AC_T1_R0_00             ,0x00},   // Reg   840
      {SSD_JPEG_REG_AC_T1_R0_01             ,0x02},   // Reg   842
      {SSD_JPEG_REG_AC_T1_R0_02             ,0x01},   // Reg   844
      {SSD_JPEG_REG_AC_T1_R0_03             ,0x02},   // Reg   846
      {SSD_JPEG_REG_AC_T1_R0_04             ,0x04},   // Reg   848
      {SSD_JPEG_REG_AC_T1_R0_05             ,0x04},   // Reg   84a
      {SSD_JPEG_REG_AC_T1_R0_06             ,0x03},   // Reg   84c
      {SSD_JPEG_REG_AC_T1_R0_07             ,0x04},   // Reg   84e
      {SSD_JPEG_REG_AC_T1_R0_08             ,0x07},   // Reg   850
      {SSD_JPEG_REG_AC_T1_R0_09             ,0x05},   // Reg   852
      {SSD_JPEG_REG_AC_T1_R0_10             ,0x04},   // Reg   854
      {SSD_JPEG_REG_AC_T1_R0_11             ,0x04},   // Reg   856
      {SSD_JPEG_REG_AC_T1_R0_12             ,0x00},   // Reg   858
      {SSD_JPEG_REG_AC_T1_R0_13             ,0x01},   // Reg   85a
      {SSD_JPEG_REG_AC_T1_R0_14             ,0x02},   // Reg   85c
      {SSD_JPEG_REG_AC_T1_R0_15             ,0x77},   // Reg   85e

      {SSD_JPEG_REG_AC_T1_R1_00             ,0x00},   // Reg   860
      {SSD_JPEG_REG_AC_T1_R1_01             ,0x01},   // Reg   862
      {SSD_JPEG_REG_AC_T1_R1_02             ,0x02},   // Reg   864
      {SSD_JPEG_REG_AC_T1_R1_03             ,0x03},   // Reg   866
      {SSD_JPEG_REG_AC_T1_R1_04             ,0x11},   // Reg   868
      {SSD_JPEG_REG_AC_T1_R1_05             ,0x04},   // Reg   86a
      {SSD_JPEG_REG_AC_T1_R1_06             ,0x05},   // Reg   86c
      {SSD_JPEG_REG_AC_T1_R1_07             ,0x21},   // Reg   86e
      {SSD_JPEG_REG_AC_T1_R1_08             ,0x31},   // Reg   870
      {SSD_JPEG_REG_AC_T1_R1_09             ,0x06},   // Reg   872
      {SSD_JPEG_REG_AC_T1_R1_10             ,0x12},   // Reg   874
      {SSD_JPEG_REG_AC_T1_R1_11             ,0x41},   // Reg   876
      {SSD_JPEG_REG_AC_T1_R1_12             ,0x51},   // Reg   878
      {SSD_JPEG_REG_AC_T1_R1_13             ,0x07},   // Reg   87a
      {SSD_JPEG_REG_AC_T1_R1_14             ,0x61},   // Reg   87c
      {SSD_JPEG_REG_AC_T1_R1_15             ,0x71},   // Reg   87e
      {SSD_JPEG_REG_AC_T1_R1_16             ,0x13},   // Reg   880
      {SSD_JPEG_REG_AC_T1_R1_17             ,0x22},   // Reg   882
      {SSD_JPEG_REG_AC_T1_R1_18             ,0x32},   // Reg   884
      {SSD_JPEG_REG_AC_T1_R1_19             ,0x81},   // Reg   886
      {SSD_JPEG_REG_AC_T1_R1_20             ,0x08},   // Reg   888
      {SSD_JPEG_REG_AC_T1_R1_21             ,0x14},   // Reg   88a
      {SSD_JPEG_REG_AC_T1_R1_22             ,0x42},   // Reg   88c
      {SSD_JPEG_REG_AC_T1_R1_23             ,0x91},   // Reg   88e
      {SSD_JPEG_REG_AC_T1_R1_24             ,0xa1},   // Reg   890
      {SSD_JPEG_REG_AC_T1_R1_25             ,0xb1},   // Reg   892
      {SSD_JPEG_REG_AC_T1_R1_26             ,0xc1},   // Reg   894
      {SSD_JPEG_REG_AC_T1_R1_27             ,0x09},   // Reg   896
      {SSD_JPEG_REG_AC_T1_R1_28             ,0x23},   // Reg   898
      {SSD_JPEG_REG_AC_T1_R1_29             ,0x33},   // Reg   89a
      {SSD_JPEG_REG_AC_T1_R1_30             ,0x52},   // Reg   89c
      {SSD_JPEG_REG_AC_T1_R1_31             ,0xf0},   // Reg   89e
      {SSD_JPEG_REG_AC_T1_R1_32             ,0x15},   // Reg   8a0
      {SSD_JPEG_REG_AC_T1_R1_33             ,0x62},   // Reg   8a2
      {SSD_JPEG_REG_AC_T1_R1_34             ,0x72},   // Reg   8a4
      {SSD_JPEG_REG_AC_T1_R1_35             ,0xd1},   // Reg   8a6
      {SSD_JPEG_REG_AC_T1_R1_36             ,0x0a},   // Reg   8a8
      {SSD_JPEG_REG_AC_T1_R1_37             ,0x16},   // Reg   8aa
      {SSD_JPEG_REG_AC_T1_R1_38             ,0x24},   // Reg   8ac
      {SSD_JPEG_REG_AC_T1_R1_39             ,0x34},   // Reg   8ae
      {SSD_JPEG_REG_AC_T1_R1_40             ,0xe1},   // Reg   8b0
      {SSD_JPEG_REG_AC_T1_R1_41             ,0x25},   // Reg   8b2
      {SSD_JPEG_REG_AC_T1_R1_42             ,0xf1},   // Reg   8b4
      {SSD_JPEG_REG_AC_T1_R1_43             ,0x17},   // Reg   8b6
      {SSD_JPEG_REG_AC_T1_R1_44             ,0x18},   // Reg   8b8
      {SSD_JPEG_REG_AC_T1_R1_45             ,0x19},   // Reg   8ba
      {SSD_JPEG_REG_AC_T1_R1_46             ,0x1a},   // Reg   8bc
      {SSD_JPEG_REG_AC_T1_R1_47             ,0x26},   // Reg   8be
      {SSD_JPEG_REG_AC_T1_R1_48             ,0x27},   // Reg   8c0
      {SSD_JPEG_REG_AC_T1_R1_49             ,0x28},   // Reg   8c2
      {SSD_JPEG_REG_AC_T1_R1_50             ,0x29},   // Reg   8c4
      {SSD_JPEG_REG_AC_T1_R1_51             ,0x2a},   // Reg   8c6
      {SSD_JPEG_REG_AC_T1_R1_52             ,0x35},   // Reg   8c8
      {SSD_JPEG_REG_AC_T1_R1_53             ,0x36},   // Reg   8ca
      {SSD_JPEG_REG_AC_T1_R1_54             ,0x37},   // Reg   8cc
      {SSD_JPEG_REG_AC_T1_R1_55             ,0x38},   // Reg   8ce
      {SSD_JPEG_REG_AC_T1_R1_56             ,0x39},   // Reg   8d0
      {SSD_JPEG_REG_AC_T1_R1_57             ,0x3a},   // Reg   8d2
      {SSD_JPEG_REG_AC_T1_R1_58             ,0x43},   // Reg   8d4
      {SSD_JPEG_REG_AC_T1_R1_59             ,0x44},   // Reg   8d6
      {SSD_JPEG_REG_AC_T1_R1_60             ,0x45},   // Reg   8d8
      {SSD_JPEG_REG_AC_T1_R1_61             ,0x46},   // Reg   8da
      {SSD_JPEG_REG_AC_T1_R1_62             ,0x47},   // Reg   8dc
      {SSD_JPEG_REG_AC_T1_R1_63             ,0x48},   // Reg   8de
      {SSD_JPEG_REG_AC_T1_R1_64             ,0x49},   // Reg   8e0
      {SSD_JPEG_REG_AC_T1_R1_65             ,0x4a},   // Reg   8e2
      {SSD_JPEG_REG_AC_T1_R1_66             ,0x53},   // Reg   8e4
      {SSD_JPEG_REG_AC_T1_R1_67             ,0x54},   // Reg   8e6
      {SSD_JPEG_REG_AC_T1_R1_68             ,0x55},   // Reg   8e8
      {SSD_JPEG_REG_AC_T1_R1_69             ,0x56},   // Reg   8ea
      {SSD_JPEG_REG_AC_T1_R1_70             ,0x57},   // Reg   8ec
      {SSD_JPEG_REG_AC_T1_R1_71             ,0x58},   // Reg   8ee
      {SSD_JPEG_REG_AC_T1_R1_72             ,0x59},   // Reg   8f0
      {SSD_JPEG_REG_AC_T1_R1_73             ,0x5a},   // Reg   8f2
      {SSD_JPEG_REG_AC_T1_R1_74             ,0x63},   // Reg   8f4
      {SSD_JPEG_REG_AC_T1_R1_75             ,0x64},   // Reg   8f6
      {SSD_JPEG_REG_AC_T1_R1_76             ,0x65},   // Reg   8f8
      {SSD_JPEG_REG_AC_T1_R1_77             ,0x66},   // Reg   8fa
      {SSD_JPEG_REG_AC_T1_R1_78             ,0x67},   // Reg   8fc
      {SSD_JPEG_REG_AC_T1_R1_79             ,0x68},   // Reg   8fe
      {SSD_JPEG_REG_AC_T1_R1_80             ,0x69},   // Reg   900
      {SSD_JPEG_REG_AC_T1_R1_81             ,0x6a},   // Reg   902
      {SSD_JPEG_REG_AC_T1_R1_82             ,0x73},   // Reg   904
      {SSD_JPEG_REG_AC_T1_R1_83             ,0x74},   // Reg   906
      {SSD_JPEG_REG_AC_T1_R1_84             ,0x75},   // Reg   908
      {SSD_JPEG_REG_AC_T1_R1_85             ,0x76},   // Reg   90a
      {SSD_JPEG_REG_AC_T1_R1_86             ,0x77},   // Reg   90c
      {SSD_JPEG_REG_AC_T1_R1_87             ,0x78},   // Reg   90e
      {SSD_JPEG_REG_AC_T1_R1_88             ,0x79},   // Reg   910
      {SSD_JPEG_REG_AC_T1_R1_89             ,0x7a},   // Reg   912
      {SSD_JPEG_REG_AC_T1_R1_90             ,0x82},   // Reg   914
      {SSD_JPEG_REG_AC_T1_R1_91             ,0x83},   // Reg   916
      {SSD_JPEG_REG_AC_T1_R1_92             ,0x84},   // Reg   918
      {SSD_JPEG_REG_AC_T1_R1_93             ,0x85},   // Reg   91a
      {SSD_JPEG_REG_AC_T1_R1_94             ,0x86},   // Reg   91c
      {SSD_JPEG_REG_AC_T1_R1_95             ,0x87},   // Reg   91e
      {SSD_JPEG_REG_AC_T1_R1_96             ,0x88},   // Reg   920
      {SSD_JPEG_REG_AC_T1_R1_97             ,0x89},   // Reg   922
      {SSD_JPEG_REG_AC_T1_R1_98             ,0x8a},   // Reg   924
      {SSD_JPEG_REG_AC_T1_R1_99             ,0x92},   // Reg   926
      {SSD_JPEG_REG_AC_T1_R1_100            ,0x93},   // Reg   928
      {SSD_JPEG_REG_AC_T1_R1_101            ,0x94},   // Reg   92a
      {SSD_JPEG_REG_AC_T1_R1_102            ,0x95},   // Reg   92c
      {SSD_JPEG_REG_AC_T1_R1_103            ,0x96},   // Reg   92e
      {SSD_JPEG_REG_AC_T1_R1_104            ,0x97},   // Reg   930
      {SSD_JPEG_REG_AC_T1_R1_105            ,0x98},   // Reg   932
      {SSD_JPEG_REG_AC_T1_R1_106            ,0x99},   // Reg   934
      {SSD_JPEG_REG_AC_T1_R1_107            ,0x9a},   // Reg   936
      {SSD_JPEG_REG_AC_T1_R1_108            ,0xa2},   // Reg   938
      {SSD_JPEG_REG_AC_T1_R1_109            ,0xa3},   // Reg   93a
      {SSD_JPEG_REG_AC_T1_R1_110            ,0xa4},   // Reg   93c
      {SSD_JPEG_REG_AC_T1_R1_111            ,0xa5},   // Reg   93e
      {SSD_JPEG_REG_AC_T1_R1_112            ,0xa6},   // Reg   940
      {SSD_JPEG_REG_AC_T1_R1_113            ,0xa7},   // Reg   942
      {SSD_JPEG_REG_AC_T1_R1_114            ,0xa8},   // Reg   944
      {SSD_JPEG_REG_AC_T1_R1_115            ,0xa9},   // Reg   946
      {SSD_JPEG_REG_AC_T1_R1_116            ,0xaa},   // Reg   948
      {SSD_JPEG_REG_AC_T1_R1_117            ,0xb2},   // Reg   94a
      {SSD_JPEG_REG_AC_T1_R1_118            ,0xb3},   // Reg   94c
      {SSD_JPEG_REG_AC_T1_R1_119            ,0xb4},   // Reg   95e
      {SSD_JPEG_REG_AC_T1_R1_120            ,0xb5},   // Reg   950
      {SSD_JPEG_REG_AC_T1_R1_121            ,0xb6},   // Reg   952
      {SSD_JPEG_REG_AC_T1_R1_122            ,0xb7},   // Reg   954
      {SSD_JPEG_REG_AC_T1_R1_123            ,0xb8},   // Reg   956
      {SSD_JPEG_REG_AC_T1_R1_124            ,0xb9},   // Reg   958
      {SSD_JPEG_REG_AC_T1_R1_125            ,0xba},   // Reg   95a
      {SSD_JPEG_REG_AC_T1_R1_126            ,0xc2},   // Reg   95c
      {SSD_JPEG_REG_AC_T1_R1_127            ,0xc3},   // Reg   95e
      {SSD_JPEG_REG_AC_T1_R1_128            ,0xc4},   // Reg   960
      {SSD_JPEG_REG_AC_T1_R1_129            ,0xc5},   // Reg   962
      {SSD_JPEG_REG_AC_T1_R1_130            ,0xc6},   // Reg   964
      {SSD_JPEG_REG_AC_T1_R1_131            ,0xc7},   // Reg   966
      {SSD_JPEG_REG_AC_T1_R1_132            ,0xc8},   // Reg   968
      {SSD_JPEG_REG_AC_T1_R1_133            ,0xc9},   // Reg   96a
      {SSD_JPEG_REG_AC_T1_R1_134            ,0xca},   // Reg   96c
      {SSD_JPEG_REG_AC_T1_R1_135            ,0xd2},   // Reg   96e
      {SSD_JPEG_REG_AC_T1_R1_136            ,0xd3},   // Reg   970
      {SSD_JPEG_REG_AC_T1_R1_137            ,0xd4},   // Reg   972
      {SSD_JPEG_REG_AC_T1_R1_138            ,0xd5},   // Reg   974
      {SSD_JPEG_REG_AC_T1_R1_139            ,0xd6},   // Reg   976
      {SSD_JPEG_REG_AC_T1_R1_140            ,0xd7},   // Reg   978
      {SSD_JPEG_REG_AC_T1_R1_141            ,0xd8},   // Reg   97a
      {SSD_JPEG_REG_AC_T1_R1_142            ,0xd9},   // Reg   97c
      {SSD_JPEG_REG_AC_T1_R1_143            ,0xda},   // Reg   97e
      {SSD_JPEG_REG_AC_T1_R1_144            ,0xe2},   // Reg   980
      {SSD_JPEG_REG_AC_T1_R1_145            ,0xe3},   // Reg   982
      {SSD_JPEG_REG_AC_T1_R1_146            ,0xe4},   // Reg   984
      {SSD_JPEG_REG_AC_T1_R1_147            ,0xe5},   // Reg   986
      {SSD_JPEG_REG_AC_T1_R1_148            ,0xe6},   // Reg   988
      {SSD_JPEG_REG_AC_T1_R1_149            ,0xe7},   // Reg   98a
      {SSD_JPEG_REG_AC_T1_R1_150            ,0xe8},   // Reg   98c
      {SSD_JPEG_REG_AC_T1_R1_151            ,0xe9},   // Reg   98e
      {SSD_JPEG_REG_AC_T1_R1_152            ,0xea},   // Reg   990
      {SSD_JPEG_REG_AC_T1_R1_153            ,0xf2},   // Reg   992
      {SSD_JPEG_REG_AC_T1_R1_154            ,0xf3},   // Reg   994
      {SSD_JPEG_REG_AC_T1_R1_155            ,0xf4},   // Reg   996
      {SSD_JPEG_REG_AC_T1_R1_156            ,0xf5},   // Reg   998
      {SSD_JPEG_REG_AC_T1_R1_157            ,0xf6},   // Reg   99a
      {SSD_JPEG_REG_AC_T1_R1_158            ,0xf7},   // Reg   99c
      {SSD_JPEG_REG_AC_T1_R1_159            ,0xf8},   // Reg   99e
      {SSD_JPEG_REG_AC_T1_R1_160            ,0xf9},   // Reg   9a0
      {SSD_JPEG_REG_AC_T1_R1_161            ,0xfa},   // Reg   9a2

      {SSD_JPEG_REG_QTABLE_CONST_0          ,0x03},   // Reg   9b0
      {SSD_JPEG_REG_QTABLE_CONST_1          ,0x01},   // Reg   9b2
      {SSD_JPEG_REG_QTABLE_CONST_2          ,0x02},   // Reg   9b4
      {SSD_JPEG_REG_QTABLE_CONST_3          ,0x03},   // Reg   9b6

      {SSD_JPEG_REG_QTABLE0_SAMPLE          ,0x21},   // Reg   9b8
      {0x9ba                            ,0x00},
      {SSD_JPEG_REG_QTABLE1_SAMPLE          ,0x11},   // Reg   9bc
      {0x9be                            ,0x01},
      {SSD_JPEG_REG_QTABLE2_SAMPLE          ,0x11},   // Reg   9c0
      {0x9c2                            ,0x01},

      {SSD_JPEG_REG_DRI_CONST_0             ,0xff},   // Reg   9c4
      {SSD_JPEG_REG_DRI_CONST_1             ,0xdd},   // Reg   9c6
      {SSD_JPEG_REG_DRI_CONST_2             ,0x00},   // Reg   9c8
      {SSD_JPEG_REG_DRI_CONST_3             ,0x04},   // Reg   9ca

      {SSD_JPEG_REG_SOS_CONST_0             ,0xff},   // Reg   9cc
      {SSD_JPEG_REG_SOS_CONST_1             ,0xda},   // Reg   9ce
      {SSD_JPEG_REG_SOS_CONST_2             ,0x00},   // Reg   9d0
      {SSD_JPEG_REG_SOS_CONST_3             ,0x0c},   // Reg   9d2
      {SSD_JPEG_REG_SOS_CONST_4             ,0x03},   // Reg   9d4
      {0x9d8                            ,0x01},
      {0x9da                            ,0x00},
      {0x9dc                            ,0x02},
      {0x9de                            ,0x11},
      {0x9e0                            ,0x03},
      {0x9e2                            ,0x11},

      {SSD_JPEG_REG_EOI_CONST_0             ,0x00},   // Reg   9e4
      {SSD_JPEG_REG_EOI_CONST_1             ,0x3f},   // Reg   9e6
      {SSD_JPEG_REG_EOI_CONST_2             ,0x00},   // Reg   9e8
      {SSD_JPEG_REG_EOI_CONST_3             ,0xff},   // Reg   9ea
      {SSD_JPEG_REG_EOI_CONST_4             ,0xd9},   // Reg   9ec
      {SSD_REG_DEFINE_END                   ,0x00},
    };

void ssd192x_jpeg_init(void)
{
	WORD i=0;

  	while(reg_init[i][0]!=SSD_REG_DEFINE_END) //SSD_REG_DEFINE_END==0xffff.
  	{
    	SetReg(reg_init[i][0],reg_init[i][1]);
    	i++;
  	}
}

//Should call SSD1928CamInit() prior to calling this.
void Set_JPEG_Encode_Registers(UINT32 jpeg_width,UINT32 jpeg_height)
{
	UINT32 vpixel, hpixel;
	UINT8 vpixel_8, hpixel_8;
	UINT32 exp_jpeg_width, exp_jpeg_height;
	UINT32 line_buf, vert_buf;

	UINT32 raw_jpeg_addr = 0;
	UINT32 encoded_jpeg_addr = (UINT32)DISP_HOR_RESOLUTION * DISP_VER_RESOLUTION*2;

	// count_h & v are for the decimation ratio, if 1, means divide 2 from the input of CMOS sensor
	char count_h =0;
	char count_v =0;

	exp_jpeg_width = jpeg_width;
	exp_jpeg_height = jpeg_height;

	//myprintf("lcdw = %d, lcdh = %d, jpeg_width =%d, jpeg_height =%d,SET_CAM_WIDTH =%d, SET_CAM_HEIGHT =%d\r\n",
	//		LCD_WIDTH, LCD_HEIGHT, jpeg_width, jpeg_height,SET_CAM_WIDTH, SET_CAM_HEIGHT );

	SetReg(0x402, 0x80);	// Reset the JPEG codec

	// Disable the interrupt so as to be able to clear the status
	SetReg(0x386, 0x00);	// JPEG interrupt control register 0
	SetReg(0x387, 0x00);	// JPEG interrupt control register 1 -> Reflect status at 383h

	SetReg(0x382, 0x8F);	// Clear the status register
	SetReg(0x383, 0x30);	// Clear the status register

	// clear the JPEG control registers
	SetReg(0x386, 0x87);	// JPEG interrupt control register 0
	SetReg(0x387, 0x36);	// JPEG interrupt control register 1 -> Reflect status at 383h
	SetReg(0x3A0, 0x12);	// Trigger when more than 4 bytes in FIFO & configure as output

	// Initialize the JPEG Codec registers
	SetReg(0x400, 0x09);	// still JPEG encode, bit 5 determine MJPEG(1) or still JPEG(0)
							// YUV format is 4:2:2

	while(_param.previewCropHSize >= (jpeg_width*=2))
	{
		count_h++;
	}

	while(_param.previewCropVSize >= (jpeg_height*=2))
	{
		count_v++;
	}

	SetReg(REG_DV_JHDEC_RATIO, count_h);
	SetReg(REG_DV_JVDEC_RATIO, count_v);

	// since we encode as YUV 422, the horizontal must be multiple of 16, vertical multiple of 8
	if(exp_jpeg_width%16 !=0)
		exp_jpeg_width = ((exp_jpeg_width/16)*16)*(1<<count_h);
	else
		exp_jpeg_width = exp_jpeg_width*(1<<count_h);

	if(exp_jpeg_height%8 !=0)
		exp_jpeg_height = ((exp_jpeg_height/8)*8)*(1<<count_v);
	else
		exp_jpeg_height = exp_jpeg_height*(1<<count_v);

	// Set horizontal buffer
	line_buf = exp_jpeg_width/(1<<(GetReg(REG_DV_JHDEC_RATIO)+2)) -1;
	SetRegW(REG_DV_JHORI_SIZE_0, line_buf);

	// Set Vertical buffer
	vert_buf = exp_jpeg_height/(1<<(GetReg(REG_DV_JVDEC_RATIO))) -1;
	SetRegW(REG_DV_JVERT_SIZE_0, vert_buf);

	hpixel = exp_jpeg_width;
	vpixel = exp_jpeg_height;

	// Input resolution of image
	hpixel_8 = hpixel & 0x00FF;
	SetReg(REG_JPEG_HORI_PIX_SIZE1, hpixel_8);		// size of image before encoding - horizontal, lower byte

	hpixel_8 = (hpixel>>8) & 0x00FF;
	SetReg(REG_JPEG_HORI_PIX_SIZE0, hpixel_8);		// size of image before encoding - horizontal, higher byte

	vpixel_8 = vpixel & 0x00FF;
	SetReg(REG_JPEG_VERT_PIX_SIZE1, vpixel_8);		// size of image before encoding - vertical, lower byte

	vpixel_8 = (vpixel>>8) & 0x00FF;
	SetReg(REG_JPEG_VERT_PIX_SIZE0, vpixel_8);		// size of image before encoding - vertical, higher byte

	UINT32 max_size = 0x40000L - encoded_jpeg_addr;

	// Initi JPEG module registers
	SetRegL(0x410, raw_jpeg_addr>>2);		// source address
	SetRegL(0x414, encoded_jpeg_addr>>2);	// destination address
	SetReg (0x3A4, 0x0F);					// 0 = 4K F = 64K for JPEG FIFO
	SetRegL(0x3B0, max_size);				// set max encode size in byte - max is 256*1024 due to 256K RAM
	SetReg (0x380, 0x11);					// turn on the YUV output data range 1, and turn on module
}

UINT32 Start_JPEG_Encode(void)
{
	UINT8 status, temp;
	UINT8 JRStatus0, JStatus1, JStatus0;
	UINT32 filesize=0;


	//Enable jpeg capture in camera interface, it is 0x80
 	SetReg(REG_DV_OP_MODE, (GetReg(REG_DV_OP_MODE)|0x80));    
	SetReg(0x402, 0x01);		// 	Start JPEG operation
	SetReg(0x38A, 0x01);		//  Start the frame capturing

	UINT32 i =0;
	while(i<0xFFFF)
	{
		status = GetReg(0x404);

		if ( status == 0 )	//JPEG codec engine is idle
		{
			filesize = GetRegL(0x3B4);
			JStatus0 = GetReg(0x382);
			JStatus1 = GetReg(0x383)& 0x02;
			JRStatus0 = GetReg(0x385)& 0x02;
	
			if ( filesize == 0 || JStatus1 != 0x02 || JRStatus0 != 0x02)
			{
				// still in encoding process
				i++;
				if(i == 0xFFFF)
				return 0;
			}
			else
			{
				//myprintf("Encode completed\r\n");
				return filesize;
			}
		}
		i++;
		if(i == 0xFFFF)
			return 0;		
	}
}

/*
void Write_JPEG_data_to_192x(UINT32 filesize)
{
	UINT32 i=0;
	UINT32 encoded_jpeg_address;

	UINT8 t;

	encoded_jpeg_address = (GetRegL(0x414))<<2;
	//myprintf("encoded_jpeg_address is 0x%x\r\n", encoded_jpeg_address);

	for(i = 0 ; i < filesize; i++)
	{
		t = jpeg_encode[i] = GetMem(encoded_jpeg_address+i);
	}

	jfilesize = filesize;

	// to be remove
	//print_encode();

	//myprintf("file size is 0x%x & had written to external Flash\r\n", filesize);
}
*/

UINT8 Write_JPEG_data_to_SD(UINT32 fsize, UINT8 index)
{
	FSFILE *pFile=NULL;

	UINT8 jpeg_encode_byte;
	UINT8 file_ext[5] = ".jpg";
	UINT8 file_name[9] = "JPEG";
	UINT8 file_index[3];

	UINT32 i = 0;
 	UINT32 en_jpeg_address = GetRegL(0x414)<<2;

	sprintf(file_index, "%d", index);
	strcat(file_name, file_index);
	strcat(file_name, file_ext);

	//jfilesize = fsize;

	if(FSInit())
	{
		pFile = FSfopen(file_name, FS_WRITE);	//create a new file or replace an existing file
		if(pFile!=NULL)
		{
			for(i = 0 ; i < fsize; i++)
			{
				jpeg_encode_byte = GetMem(en_jpeg_address+i);
				if(FSfwrite(&jpeg_encode_byte, 1, 1, pFile)!=1)
					return 0;
			}
			FSfclose(pFile);
				return 1;
		}
	}
	else
	{
		return 0;//error
	}

}

