#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/parsers/jpeg_parser.h"
#include <cstring>
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/containers/span_reader.h"
#include "base/logging.h"
#define READ_U8_OR_RETURN_FALSE(out) …
#define READ_U16_OR_RETURN_FALSE(out) …
namespace media {
const JpegHuffmanTable kDefaultDcTable[kJpegMaxHuffmanTableNumBaseline] = …;
const JpegHuffmanTable kDefaultAcTable[kJpegMaxHuffmanTableNumBaseline] = …;
constexpr uint8_t kZigZag8x8[64] = …;
constexpr JpegQuantizationTable kDefaultQuantTable[2] = …;
static bool InRange(int value, int a, int b) { … }
static int RoundUp(int value, int mul) { … }
static bool ParseSOF(base::span<const uint8_t> buffer,
JpegFrameHeader* frame_header) { … }
static bool ParseDQT(base::span<const uint8_t> buffer,
JpegQuantizationTable* q_table) { … }
static bool ParseDHT(base::span<const uint8_t> buffer,
JpegHuffmanTable* dc_table,
JpegHuffmanTable* ac_table) { … }
static bool ParseDRI(base::span<const uint8_t> buffer,
uint16_t* restart_interval) { … }
static bool ParseSOS(base::span<const uint8_t> buffer,
const JpegFrameHeader& frame_header,
JpegScanHeader* scan) { … }
static bool SearchEOI(base::span<const uint8_t> buffer,
const char** eoi_begin_ptr,
const char** eoi_end_ptr) { … }
static bool ParseSOI(base::span<const uint8_t> buffer,
JpegParseResult* result) { … }
bool ParseJpegPicture(base::span<const uint8_t> buffer,
JpegParseResult* result) { … }
bool ParseJpegStream(base::span<const uint8_t> buffer,
JpegParseResult* result) { … }
}