summaryrefslogtreecommitdiff
path: root/str-util.cpp
diff options
context:
space:
mode:
authorPixel <Pixel>2002-06-20 16:34:46 +0000
committerPixel <Pixel>2002-06-20 16:34:46 +0000
commit026e1c60db7b6596a50f325f05fdd54d4a404127 (patch)
treeafbfcfbbb513d2dbdd9c42a92acf9a5d306f6a41 /str-util.cpp
parenta4aa1f93479eb03a6bb462342f9a74c31c8f9d8b (diff)
Still working on it.
Diffstat (limited to 'str-util.cpp')
-rw-r--r--str-util.cpp134
1 files changed, 69 insertions, 65 deletions
diff --git a/str-util.cpp b/str-util.cpp
index aa2c9d6..cf3f6ff 100644
--- a/str-util.cpp
+++ b/str-util.cpp
@@ -58,14 +58,14 @@ int zscan[] = {
};
int izscan[] = {
- 0, 17, 12, 27, 35, 29, 58, 53,
- 1, 24, 19, 20, 42, 22, 59, 60,
- 8, 32, 26, 13, 49, 15, 52, 61,
- 16, 25, 35, 6, 56, 23, 45, 54,
- 9, 18, 40, 7, 57, 30, 38, 47,
- 2, 11, 48, 14, 50, 37, 31, 55,
- 3, 4, 41, 21, 43, 44, 39, 62,
- 10, 5, 34, 28, 36, 51, 46, 63,
+ 0, 1, 5, 6, 14, 15, 27, 28,
+ 2, 4, 7, 13, 16, 26, 29, 42,
+ 3, 8, 12, 17, 25, 30, 41, 43,
+ 9, 11, 18, 24, 31, 40, 44, 53,
+ 10, 19, 23, 32, 39, 45, 52, 54,
+ 20, 22, 33, 38, 46, 51, 55, 60,
+ 21, 34, 37, 47, 50, 56, 59, 61,
+ 35, 36, 48, 49, 57, 58, 62, 63,
};
int iqtab[] = {
@@ -107,25 +107,27 @@ struct STR_Header {
Byte * video = 0, * audio = 0;
-void print_bits(Uint16 w) {
+void print_bits(Uint16 w, int size = 16) {
int i;
- for (i = 0; i < 16; i++) {
+ for (i = size - 1; i >= 0; i--) {
printm(M_BARE, "%c", w & (1 << i) ? '1' : '0');
}
}
-Uint32 get_bits(Uint16 * datas, int size, int * pointer) {
- static internal = 0;
+Uint32 get_bits(Byte * datas, int size, Uint32 * pointer) {
+ static int internal = 0;
static Uint16 w = 0;
- Uint16 r = 0;
+ Uint32 r = 0;
+ int os = size;
- if (internal <= size) {
+ if (internal < size) {
r = w;
size -= internal;
- w = *((Uint16 *) (video + pointer));
- pointer += 2;
- w = swap_word(w);
+ w = *((Uint16 *) (video + *pointer));
+ printm(M_BARE, "get_bits: needs food, got 0x%04x\n", w);
+ *pointer += 2;
+// w = swap_word(w);
internal = 16;
}
@@ -134,6 +136,14 @@ Uint32 get_bits(Uint16 * datas, int size, int * pointer) {
w <<= size;
+ printm(M_BARE, "Read bits: ");
+ print_bits(r, os);
+ printm(M_BARE, "\n");
+
+ internal -= size;
+
+ r &= ((1 << size) - 1);
+
return r;
}
@@ -176,74 +186,68 @@ void process_one_sector(FILE * f) {
// fwrite(video, 1, h->StSECTOR_SIZE * 2016, stdout);
- while (pointer <= h->StFRAME_SIZE) {
- Uint16 rl_size = *((Uint16 *) (video + pointer));
- pointer += 2;
- if (*((Uint16 *) (video + pointer)) != 0x3800) {
- printm(M_ERROR, "Broken frame\n");
- break;
- }
- pointer += 2;
+ Uint16 rl_size = *((Uint16 *) (video + pointer));
+ pointer += 2;
+ if (*((Uint16 *) (video + pointer)) != 0x3800) {
+ printm(M_ERROR, "Broken frame\n");
+// break;
+ }
+ pointer += 2;
- Uint16 quant = *((Uint16 *) (video + pointer));
- pointer += 2;
- Uint16 ver = *((Uint16 *) (video + pointer));
+ Uint16 quant = *((Uint16 *) (video + pointer));
+ pointer += 2;
+ Uint16 ver = *((Uint16 *) (video + pointer));
+ pointer += 2;
+ int rls = 0;
+ while (rls <= rl_size) {
printm(M_BARE, "Processing macrobloc %i, rlsize = %i, quant = %i, ver = %i, pointer = 0x%08x\n", macrobloc, rl_size, quant, ver, pointer);
- for (int i = 0; i < 32; i++) {
- }
-
- printm(M_BARE, "\n");
-
-// int16 Cb[64], Cr[64], Y0[64], Y1[64], Y2[64], Y3[64];
-// int16 * blocs[6] = {Cb, Cr, Y0, Y1, Y2, Y3};
-// int bloc;
+ int16 Cb[64], Cr[64], Y0[64], Y1[64], Y2[64], Y3[64];
+ int16 * blocs[6] = {Cb, Cr, Y0, Y1, Y2, Y3};
+ int bloc;
- exit(-1);
-
-/* for (bloc = 0; bloc < 6; bloc++) {
- Uint16 QSP = *((Uint16 *) (video + pointer));
- pointer += 2;
- int16 DC = QSP & 0x3f;
- Uint8 Quant = QSP >> 10;
-
+ for (bloc = 0; bloc < 6; bloc++) {
int i;
for (i = 0; i < 64; i++) {
blocs[bloc][i] = 0;
}
-
- if (DC & 0x20) {
- DC |= 0xc0;
- }
- printm(M_BARE, "Processing subbloc %i, DC = %i, Quant = %i, pointer = 0x%08x\n", bloc, DC, Quant, pointer);
+ int16 DC = get_bits(video, 10, &pointer);
+ if (DC & 0x20)
+ DC |= 0xc0;
+
+ printm(M_BARE, "Processing subbloc %i, DC = %i, Quant = %i, pointer = 0x%08x\n", bloc, DC, quant, pointer);
- int inblock = 1;
+ int inbloc = 1;
blocs[bloc][0] = DC;
- while (1) {
- Uint16 RCF = *((Uint16 *) (video + pointer));
- pointer += 2;
+ while (inbloc < 64) {
+ Uint8 run = get_bits(video, 6, &pointer);
+ int16 level;
- if (RCF == 0xfe00) {
+ level = get_bits(video, 8, &pointer);
- break;
+ if (level == 0) {
+ level = get_bits(video, 8, &pointer);
+ } else if (level & 0x80) {
+ if (level == 0x80)
+ level = get_bits(video, 8, &pointer);
+ level |= 0xff00;
}
- printm(M_BARE, "Read a RCF: 0x%04x\n", RCF);
-
- int16 Level = RCF & 0x3f;
- Uint8 Run = RCF >> 10;
- if (Level & 0x20) {
- Level |= 0xc0;
- }
+ printm(M_BARE, "Read a runlevel: (%i, %i) = (%x %x), inbloc = %i, (pointer is %i)\n", run, level, run, level, inbloc, pointer);
+ rls++;
- blocs[bloc][inblock] = Level;
- inblock += Run + 1;
+ blocs[bloc][inbloc] = level;
+ inbloc += run + 1;
}
- } */
+
+ printm(M_BARE, "Finished the bloc with inbloc = %i\n", inbloc);
+ }
+ macrobloc++;
}
+ exit(-1);
free(video);
}