From 6c8ce504a5a8d14bf33c3046f4ab356ac477a1d5 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 8 Oct 2017 15:05:37 +0200 Subject: [PATCH] Update qdd with newer DC coefficient predictions. --- qdd.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/qdd.cpp b/qdd.cpp index 522957d..d9b788c 100644 --- a/qdd.cpp +++ b/qdd.cpp @@ -6,8 +6,15 @@ #define WIDTH 1280 #define HEIGHT 720 +#define WIDTH_BLOCKS (WIDTH/8) +#define WIDTH_BLOCKS_CHROMA (WIDTH/16) +#define HEIGHT_BLOCKS (HEIGHT/8) +#define NUM_BLOCKS (WIDTH_BLOCKS * HEIGHT_BLOCKS) +#define NUM_BLOCKS_CHROMA (WIDTH_BLOCKS_CHROMA * HEIGHT_BLOCKS) + #define NUM_SYMS 256 #define ESCAPE_LIMIT (NUM_SYMS - 1) +#define BLOCKS_PER_STREAM 320 #include "ryg_rans/rans_byte.h" @@ -208,10 +215,17 @@ int main(void) } fclose(fp); - // DC coefficient pred from the right to left - for (unsigned yb = 0; yb < HEIGHT; yb += 8) { - for (int xb = WIDTH - 16; xb >= 0; xb -= 8) { - coeff[yb * WIDTH + xb] += coeff[yb * WIDTH + (xb + 8)]; + // DC coefficient pred from the right to left (within each slice) + for (unsigned block_idx = 0; block_idx < NUM_BLOCKS; block_idx += BLOCKS_PER_STREAM) { + int prev_k = 128; + + for (unsigned subblock_idx = BLOCKS_PER_STREAM; subblock_idx --> 0; ) { + unsigned yb = (block_idx + subblock_idx) / WIDTH_BLOCKS; + unsigned xb = (block_idx + subblock_idx) % WIDTH_BLOCKS; + int k = coeff[(yb * 8) * WIDTH + (xb * 8)]; + + prev_k += k; + coeff[(yb * 8) * WIDTH + (xb * 8)] = prev_k; } } -- 2.39.2