<commit_before>
#include "jpeg.hpp"
#include <stdint.h>

// Assumed for 8x8 matrixes
const uint_fast8_t zigzag_level_baseline[] = {0, 1, 3, 6, 10, 15, 21, 28, 36, 43, 49, 54, 58, 61, 63};

uint_fast8_t zigzag_position(uint_fast8_t x, uint_fast8_t y)
{
	const uint_fast8_t level = x + y;
	const bool odd_level = level & 1;
	const uint_fast8_t level_baseline = zigzag_level_baseline[level];
	return level_baseline + (odd_level? y : x);
}

quantization_table::quantization_table(std::istream &stream)
{
	unsigned char zigzag[WIDTH * HEIGHT];
	stream.read(reinterpret_cast<char *>(zigzag), sizeof(zigzag));

	uint_fast8_t k = 0;
	for (uint_fast8_t y = 0; y < HEIGHT; y++)<commit_msg>Fix a bug in the zigzag algorithm<commit_after>
#include "jpeg.hpp"
#include <stdint.h>

// Assumed for 8x8 matrixes
const uint_fast8_t zigzag_level_baseline[] = {0, 1, 3, 6, 10, 15, 21, 28, 35, 41, 46, 50, 53, 55, 56};

uint_fast8_t zigzag_position(uint_fast8_t x, uint_fast8_t y)
{
	const uint_fast8_t level = x + y;
	const bool odd_level = level & 1;
	const uint_fast8_t level_baseline = zigzag_level_baseline[level];
	return level_baseline + (odd_level? y : x);
}

quantization_table::quantization_table(std::istream &stream)
{
	unsigned char zigzag[WIDTH * HEIGHT];
	stream.read(reinterpret_cast<char *>(zigzag), sizeof(zigzag));

	uint_fast8_t k = 0;
	for (uint_fast8_t y = 0; y < HEIGHT; y++)
{'fraction_non_alphanumeric': 0.12772133526850507, 'fraction_numerical': 0.05660377358490566, 'mean_word_length': 5.535545023696683, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3457722', 'n_tokens_mistral': 638, 'n_tokens_neox': 545, 'n_words': 145}