void decode_start(int* out_data_image_width, int* out_data_image_height, int* out_data_comp_vpos, int* out_data_comp_hpos) { int i; int CurrentMCU = 0; int HuffBuff[NUM_COMPONENT][DCTSIZE2]; int IDCTBuff[6][DCTSIZE2]; /* Read buffer */ CurHuffReadBuf = p_jinfo_jpeg_data; /* * Initial value of DC element is 0 */ for(i = 0; i < NUM_COMPONENT; i++){ HuffBuff[i][0] = 0; } /* * Set the size of image to output buffer */ *out_data_image_width = p_jinfo_image_width; *out_data_image_height = p_jinfo_image_height; /* * Initialize output buffer */ for(i = 0; i < RGB_NUM; i++){ out_data_comp_vpos[i] = 0; out_data_comp_hpos[i] = 0; } if(p_jinfo_smp_fact == SF1_1_1){ // printf("Decode 1:1:1 NumMCU = %d\n",p_jinfo_NumMCU); /* * 1_1_1 */ while(CurrentMCU < p_jinfo_NumMCU){ for(i = 0; i < NUM_COMPONENT; i++){ decode_block(i, IDCTBuff[i], HuffBuff[i]); } YuvToRgb(0,IDCTBuff[0],IDCTBuff[1],IDCTBuff[2]); /* * Write */ for(i = 0; i < RGB_NUM; i++){ WriteBlock(&rgb_buf[0][i][0], &out_data_comp_vpos[i], &out_data_comp_hpos[i], &OutData_comp_buf[i][0]); } CurrentMCU++; } }else{ // printf("Decode 4:1:1 NumMCU = %d\n",p_jinfo_NumMCU); /* * 4_1_1 */ while(CurrentMCU < p_jinfo_NumMCU){ /* * Decode Y element * Decoding Y, U and V elements should be sequentially conducted for the use of Huffman table */ for(i = 0; i < 4; i++){ decode_block(0, IDCTBuff[i], HuffBuff[0]); } /* Decode U */ decode_block(1, IDCTBuff[4], HuffBuff[1]); /* Decode V */ decode_block(2, IDCTBuff[5], HuffBuff[2]); /* Transform from Yuv into RGB */ for(i = 0; i < 4; i++){ YuvToRgb(i,IDCTBuff[i],IDCTBuff[4],IDCTBuff[5]); } for(i = 0; i < RGB_NUM; i++){ Write4Blocks(&rgb_buf[0][i][0], &rgb_buf[1][i][0], &rgb_buf[2][i][0], &rgb_buf[3][i][0], &out_data_comp_vpos[i], &out_data_comp_hpos[i], &OutData_comp_buf[i][0]); } CurrentMCU += 4; } } }
int decode_start (int x[4000],int m, int y[4000],int n) { data_in(x,m); //data1(); int i; int CurrentMCU = 0; int HuffBuff[NUM_COMPONENT][DCTSIZE2]; int IDCTBuff[6][DCTSIZE2]; /* Read buffer */ CurHuffReadBuf = p_jinfo_jpeg_data_; /* * Initial value of DC element is 0 */ for (i = 0; i < NUM_COMPONENT; i++) { HuffBuff[i][0] = 0; } /* * Set the size of image to output buffer */ OutData_image_width_ = p_jinfo_image_width_; OutData_image_height_ = p_jinfo_image_height_; /* * Initialize output buffer */ for (i = 0; i < RGB_NUM; i++) { OutData_comp_vpos_[i] = 0; OutData_comp_hpos_[i] = 0; } if (p_jinfo_smp_fact_ == SF1_1_1) { printf ("Decode 1:1:1 NumMCU = %d\n", p_jinfo_NumMCU_); /* * 1_1_1 */ while (CurrentMCU < p_jinfo_NumMCU_) { for (i = 0; i < NUM_COMPONENT; i++) { decode_block (i, IDCTBuff[i], HuffBuff[i]); } YuvToRgb (0, IDCTBuff[0], IDCTBuff[1], IDCTBuff[2]); /* * Write */ for (i = 0; i < RGB_NUM; i++) { WriteBlock (&rgb_buf[0][i][0], &OutData_comp_vpos_[i], &OutData_comp_hpos_[i], &OutData_comp_buf_[i][0]); } CurrentMCU++; } } else { printf ("Decode 4:1:1 NumMCU = %d\n", p_jinfo_NumMCU_); /* * 4_1_1 */ while (CurrentMCU < p_jinfo_NumMCU_) { /* * Decode Y element * Decoding Y, U and V elements should be sequentially conducted for the use of Huffman table */ for (i = 0; i < 4; i++) { decode_block (0, IDCTBuff[i], HuffBuff[0]); } /* Decode U */ decode_block (1, IDCTBuff[4], HuffBuff[1]); /* Decode V */ decode_block (2, IDCTBuff[5], HuffBuff[2]); /* Transform from Yuv into RGB */ for (i = 0; i < 4; i++) { YuvToRgb (i, IDCTBuff[i], IDCTBuff[4], IDCTBuff[5]); } for (i = 0; i < RGB_NUM; i++) { Write4Blocks (&rgb_buf[0][i][0], &rgb_buf[1][i][0], &rgb_buf[2][i][0], &rgb_buf[3][i][0], &OutData_comp_vpos_[i], &OutData_comp_hpos_[i], &OutData_comp_buf_[i][0]); } CurrentMCU += 4; } } //data2(); data_out(x,n); return m+n+*y; }