revert changes
diff --git a/include/ast_jpeg_decoder.hpp b/include/ast_jpeg_decoder.hpp
index 2e0a9b6..2bf5cf6 100644
--- a/include/ast_jpeg_decoder.hpp
+++ b/include/ast_jpeg_decoder.hpp
@@ -757,16 +757,16 @@
void MoveBlockIndex(void) {
if (yuvmode == YuvMode::YUV444) {
txb++;
- if (txb >= (int)(WIDTH / 8)) {
+ if (txb >= (int)(tmp_WIDTH / 8)) {
tyb++;
- if (tyb >= (int)(HEIGHT / 8)) tyb = 0;
+ if (tyb >= (int)(tmp_HEIGHT / 8)) tyb = 0;
txb = 0;
}
} else {
txb++;
- if (txb >= (int)(WIDTH / 16)) {
+ if (txb >= (int)(tmp_WIDTH / 16)) {
tyb++;
- if (tyb >= (int)(HEIGHT / 16)) tyb = 0;
+ if (tyb >= (int)(tmp_HEIGHT / 16)) tyb = 0;
txb = 0;
}
}
@@ -1042,44 +1042,87 @@
int uv_selector) {
COLOR_CACHE Decode_Color;
- // If any of our parameters have changed, we need to reinit the jpeg
- // Tables
- if (width != USER_WIDTH || height != USER_HEIGHT || yuvmode_in != yuvmode ||
- y_selector != Y_selector || uv_selector != UV_selector) {
- LOG(DEBUG) << "Reinitializing\n";
- init_JPG_decoding();
- USER_WIDTH = width;
- USER_HEIGHT = height;
+ // TODO(ed) use the enum everywhere, not just externally
+ yuvmode = yuvmode_in; // 0 = YUV444, 1 = YUV420
+ Y_selector = y_selector; // 0-7
+ UV_selector = uv_selector; // 0-7
- yuvmode = yuvmode_in; // 0 = YUV444, 1 = YUV420
+ // TODO(ed) Magic number section. Document appropriately
+ advance_selector = 0; // 0-7
+ First_Frame = 1; // 0 or 1
+ Mapping = 0; // 0 or 1
+ /*
+ if (yuvmode == YuvMode::YUV420) {
+ Y_selector = 4;
+ UV_selector = 7;
+ Mapping = 0;
+ } else { // YUV444
+ Y_selector = 7;
+ UV_selector = 7;
+ Mapping = 0;
+ }
+ */
+ auto test = static_cast<int>(yuvmode);
+ std::cout << "YUVmode " << test << " " << static_cast<int>(Y_selector) << static_cast<int>(UV_selector) << "\n";
- // TODO(ed) Magic number section. Document appropriately
- Y_selector = y_selector; // 0-7
- UV_selector = uv_selector; // 0-7
+ tmp_WIDTH = width;
+ tmp_HEIGHT = height;
+ WIDTH = width;
+ HEIGHT = height;
- advance_selector = 0; // 0-7
- Mapping = 0; // 0 or 1
-
- WIDTH = width;
- HEIGHT = height;
-
- int block_size = 8; /// YUV444 has a block size of 8
- if (yuvmode == YuvMode::YUV420) {
- block_size = 16;
+ //VQ_Initialize(&Decode_Color);
+ // OutputDebugString ("In decode\n");
+ // GetINFData (VideoEngineInfo);
+ // WIDTH = VideoEngineInfo->SourceModeInfo.X = 640;
+ // HEIGHT = VideoEngineInfo->SourceModeInfo.Y = 480;
+ // AST2000 JPEG block is 16x16(pixels) base
+ if (yuvmode == YuvMode::YUV420) {
+ if (WIDTH % 16) {
+ WIDTH = WIDTH + 16 - (WIDTH % 16);
}
-
- auto remainder = WIDTH % block_size;
- if (WIDTH % block_size) {
- WIDTH = WIDTH + block_size - remainder;
+ if (HEIGHT % 16) {
+ HEIGHT = HEIGHT + 16 - (HEIGHT % 16);
}
- remainder = HEIGHT % block_size;
- if (remainder) {
- HEIGHT = HEIGHT + block_size - remainder;
+ } else {
+ if (WIDTH % 8) {
+ WIDTH = WIDTH + 8 - (WIDTH % 8);
+ }
+ if (HEIGHT % 8) {
+ HEIGHT = HEIGHT + 8 - (HEIGHT % 8);
}
}
- LOG(DEBUG) << "Height" << HEIGHT << " WIDTH " << WIDTH << "\n";
- // TODO(ed) cleanup cruft. THis global buffer pointer is ugly and error prone
+ // tmp_WDITH, tmp_HEIGHT are for block position
+ // tmp_WIDTH = VideoEngineInfo->DestinationModeInfo.X;
+ // tmp_HEIGHT = VideoEngineInfo->DestinationModeInfo.Y;
+ if (yuvmode == YuvMode::YUV420) {
+ if (tmp_WIDTH % 16) {
+ tmp_WIDTH = tmp_WIDTH + 16 - (tmp_WIDTH % 16);
+ }
+ if (tmp_HEIGHT % 16) {
+ tmp_HEIGHT = tmp_HEIGHT + 16 - (tmp_HEIGHT % 16);
+ }
+ } else {
+ if (tmp_WIDTH % 8) {
+ tmp_WIDTH = tmp_WIDTH + 8 - (tmp_WIDTH % 8);
+ }
+ if (tmp_HEIGHT % 8) {
+ tmp_HEIGHT = tmp_HEIGHT + 8 - (tmp_HEIGHT % 8);
+ }
+ }
+
+ int qfactor = 16;
+
+ SCALEFACTOR = qfactor;
+ SCALEFACTORUV = qfactor;
+ ADVANCESCALEFACTOR = 16;
+ ADVANCESCALEFACTORUV = 16;
+
+ if (First_Frame == 1) {
+ //init_jpg_table();
+ init_JPG_decoding();
+ }
+ // TODO(ed) cleanup cruft
Buffer = buffer.data();
codebuf = buffer[0];
@@ -1290,8 +1333,8 @@
// WIDTH and HEIGHT are the modes your display used
unsigned long WIDTH;
unsigned long HEIGHT;
- unsigned long USER_WIDTH;
- unsigned long USER_HEIGHT;
+ unsigned long tmp_HEIGHT;
+ unsigned long tmp_WIDTH;
unsigned char Y_selector;
int SCALEFACTOR;
int SCALEFACTORUV;
@@ -1300,6 +1343,7 @@
int Mapping;
unsigned char UV_selector;
unsigned char advance_selector;
+ unsigned char First_Frame;
int byte_pos; // current byte position
// quantization tables, no more than 4 quantization tables