Created
November 29, 2021 11:41
-
-
Save BigRedEye/0dcf9a7417c8d4c9d493b6bcaf1c0ba4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "huffman.h" | |
#include "quantization.h" | |
#include "dct.h" | |
#include "mcu.h" | |
#include "octet.h" | |
#include "block.h" | |
#include <cstddef> | |
#include <optional> | |
#include <unordered_map> | |
namespace jpeg::decoder { | |
enum class EEncodingType : Octet { | |
Baseline = 0, | |
Progressive = 1, | |
Unknown = 2, | |
}; | |
struct ChannelConfig { | |
Octet id = 0; | |
Octet horisontal_sampling = 0; | |
Octet vertical_sampling = 0; | |
Octet quantization_table = 0; | |
}; | |
struct Context { | |
size_t num_sections = 0; | |
std::optional<size_t> start_section = std::nullopt; | |
std::optional<size_t> end_section = std::nullopt; | |
std::string comment; | |
EEncodingType type = EEncodingType::Unknown; | |
Vec2<size_t> size; | |
Vec2<size_t> extended_size; | |
std::unordered_map<Octet, ChannelConfig> channels_; | |
mcu::McuConfig mcu_; | |
std::array<std::optional<quantization::QuantizationTable>, 4> quantization_tables_; | |
std::array<std::array<std::optional<huffman::HuffmanTable>, 4>, 2> huffman_tables_; | |
std::unordered_map<Octet, std::vector<block::Block>> coefficients_; | |
public: | |
huffman::HuffmanTable& GetHuffmanTable(dct::CoefficientType clazz, size_t id); | |
huffman::HuffmanTable& GetHuffmanTable(PackedTuple<4, 4> spec); | |
quantization::QuantizationTable& GetQuantizationTable(size_t id); | |
}; | |
} // namespace jpeg::decoder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment