Skip to content

File picojpeg.c

FileList > jpeg-decoder > picojpeg.c

Go to the source code of this file

  • #include "picojpeg.h"

Classes

Type Name
struct HuffTableT

Public Types

Type Name
typedef struct HuffTableT HuffTable
enum JPEG_MARKER
typedef signed short int16
typedef signed char int8
typedef unsigned short uint16
typedef unsigned char uint8

Public Attributes

Type Name
const uint8 gWinogradQuant = = {
128, 178, 178, 167, 246, 167, 151, 232, 232, 151, 128, 209, 219, 209, 128, 101,
178, 197, 197, 178, 101, 69, 139, 167, 177, 167, 139, 69, 35, 96, 131, 151,
151, 131, 96, 35, 49, 91, 118, 128, 118, 91, 49, 46, 81, 101, 101, 81,
46, 42, 69, 79, 69, 42, 35, 54, 54, 35, 28, 37, 28, 19, 19, 10,
}

Public Static Attributes

Type Name
const int8 ZAG = = {
0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48,
41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23,
30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63,
}
uint16 gBitBuf
uint8 gBitsLeft
uint8 gCallbackStatus
int16 gCoeffBuf
uint8 gCompACTab
uint8 gCompDCTab
uint8 gCompHSamp
uint8 gCompIdent
uint8 gCompList
uint8 gCompQuant
uint8 gCompVSamp
uint8 gCompsInFrame
uint8 gCompsInScan
HuffTable gHuffTab0
HuffTable gHuffTab1
HuffTable gHuffTab2
HuffTable gHuffTab3
uint8 gHuffVal0
uint8 gHuffVal1
uint8 gHuffVal2
uint8 gHuffVal3
uint16 gImageXSize
uint16 gImageYSize
uint8 gInBuf
uint8 gInBufLeft
uint8 gInBufOfs
int16 gLastDC
uint8 gMCUBufB
uint8 gMCUBufG
uint8 gMCUBufR
uint8 gMCUOrg
uint8 gMaxBlocksPerMCU
uint16 gMaxMCUSPerCol
uint16 gMaxMCUSPerRow
uint8 gMaxMCUXSize
uint8 gMaxMCUYSize
uint16 gNextRestartNum
uint16 gNumMCUSRemainingX
uint16 gNumMCUSRemainingY
int16 gQuant0
int16 gQuant1
uint8 gReduce
uint16 gRestartInterval
uint16 gRestartsLeft
pjpeg_scan_type_t gScanType
uint8 gTemFlag
uint8 gValidHuffTables
uint8 gValidQuantTables
void * g_pCallback_data
pjpeg_need_bytes_callback_t g_pNeedBytesCallback

Public Functions

Type Name
unsigned char pjpeg_decode_init (pjpeg_image_info_t * pInfo, pjpeg_need_bytes_callback_t pNeed_bytes_callback, void * pCallback_data, unsigned char reduce)
unsigned char pjpeg_decode_mcu (void)

Public Static Functions

Type Name
PJPG_INLINE uint8 addAndClamp (uint8 a, int16 b)
uint8 checkHuffTables (void)
uint8 checkQuantTables (void)
PJPG_INLINE uint8 clamp (int16 s)
void convertCb (uint8 dstOfs)
void convertCr (uint8 dstOfs)
void copyY (uint8 dstOfs)
void createWinogradQuant (int16 * pQuant)
uint8 decodeNextMCU (void)
void fillInBuf (void)
uint8 findEOI (void)
void fixInBuffer (void)
PJPG_INLINE uint8 getBit (void)
uint16 getBits (uint8 numBits, uint8 FFCheck)
PJPG_INLINE uint16 getBits1 (uint8 numBits)
PJPG_INLINE uint16 getBits2 (uint8 numBits)
PJPG_INLINE uint8 getChar (void)
int16 getExtendOffset (uint8 i)
uint16 getExtendTest (uint8 i)
HuffTable * getHuffTable (uint8 index)
uint8 * getHuffVal (uint8 index)
uint16 getMaxHuffCodes (uint8 index)
PJPG_INLINE uint8 getOctet (uint8 FFCheck)
void huffCreate (const uint8 * pBits, HuffTable * pHuffTable)
PJPG_INLINE uint8 huffDecode (const HuffTable * pHuffTable, const uint8 * pHuffVal)
PJPG_INLINE int16 huffExtend (uint16 x, uint8 s)
void idctCols (void)
void idctRows (void)
PJPG_INLINE int16 imul_b1_b3 (int16 w)
PJPG_INLINE int16 imul_b2 (int16 w)
PJPG_INLINE int16 imul_b4 (int16 w)
PJPG_INLINE int16 imul_b5 (int16 w)
uint8 init (void)
uint8 initFrame (void)
uint8 initScan (void)
uint8 locateSOFMarker (void)
uint8 locateSOIMarker (void)
uint8 locateSOSMarker (uint8 * pFoundEOI)
uint8 nextMarker (void)
uint8 processMarkers (uint8 * pMarker)
uint8 processRestart (void)
uint8 readDHTMarker (void)
uint8 readDQTMarker (void)
uint8 readDRIMarker (void)
uint8 readSOFMarker (void)
uint8 readSOSMarker (void)
uint8 skipVariableMarker (void)
PJPG_INLINE void stuffChar (uint8 i)
PJPG_INLINE uint8 subAndClamp (uint8 a, int16 b)
void transformBlock (uint8 mcuBlock)
void transformBlockReduce (uint8 mcuBlock)
void upsampleCb (uint8 srcOfs, uint8 dstOfs)
void upsampleCbH (uint8 srcOfs, uint8 dstOfs)
void upsampleCbV (uint8 srcOfs, uint8 dstOfs)
void upsampleCr (uint8 srcOfs, uint8 dstOfs)
void upsampleCrH (uint8 srcOfs, uint8 dstOfs)
void upsampleCrV (uint8 srcOfs, uint8 dstOfs)

Macros

Type Name
define PJPG_ARITH_SHIFT_RIGHT_8_L (x) ((x) >> 8)
define PJPG_ARITH_SHIFT_RIGHT_N_16 (x, n) ((x) >> (n))
define PJPG_DCT_SCALE (1U << PJPG_DCT_SCALE_BITS)
define PJPG_DCT_SCALE_BITS 7
define PJPG_DESCALE (x) PJPG_ARITH_SHIFT_RIGHT_N_16(((x) + (1 << (PJPG_DCT_SCALE_BITS - 1))), PJPG_DCT_SCALE_BITS)
define PJPG_INLINE
define PJPG_MAXCOMPSINSCAN 3
define PJPG_MAX_HEIGHT 16384
define PJPG_MAX_IN_BUF_SIZE 256
define PJPG_MAX_WIDTH 16384
define PJPG_RIGHT_SHIFT_IS_ALWAYS_UNSIGNED 0
define PJPG_WFIX (x) ((x)*PJPG_DCT_SCALE + 0.5f)
define PJPG_WINOGRAD_QUANT_SCALE_BITS 10

Public Types Documentation

typedef HuffTable

typedef struct HuffTableT HuffTable;

enum JPEG_MARKER

enum JPEG_MARKER {
    M_SOF0 = 0xC0,
    M_SOF1 = 0xC1,
    M_SOF2 = 0xC2,
    M_SOF3 = 0xC3,
    M_SOF5 = 0xC5,
    M_SOF6 = 0xC6,
    M_SOF7 = 0xC7,
    M_JPG = 0xC8,
    M_SOF9 = 0xC9,
    M_SOF10 = 0xCA,
    M_SOF11 = 0xCB,
    M_SOF13 = 0xCD,
    M_SOF14 = 0xCE,
    M_SOF15 = 0xCF,
    M_DHT = 0xC4,
    M_DAC = 0xCC,
    M_RST0 = 0xD0,
    M_RST1 = 0xD1,
    M_RST2 = 0xD2,
    M_RST3 = 0xD3,
    M_RST4 = 0xD4,
    M_RST5 = 0xD5,
    M_RST6 = 0xD6,
    M_RST7 = 0xD7,
    M_SOI = 0xD8,
    M_EOI = 0xD9,
    M_SOS = 0xDA,
    M_DQT = 0xDB,
    M_DNL = 0xDC,
    M_DRI = 0xDD,
    M_DHP = 0xDE,
    M_EXP = 0xDF,
    M_APP0 = 0xE0,
    M_APP15 = 0xEF,
    M_JPG0 = 0xF0,
    M_JPG13 = 0xFD,
    M_COM = 0xFE,
    M_TEM = 0x01,
    M_ERROR = 0x100,
    RST0 = 0xD0
};

typedef int16

typedef signed short int16;

typedef int8

typedef signed char int8;

typedef uint16

typedef unsigned short uint16;

typedef uint8

typedef unsigned char uint8;

Public Attributes Documentation

variable gWinogradQuant

const uint8 gWinogradQuant[];

Public Static Attributes Documentation

variable ZAG

const int8 ZAG[];

variable gBitBuf

uint16 gBitBuf;

variable gBitsLeft

uint8 gBitsLeft;

variable gCallbackStatus

uint8 gCallbackStatus;

variable gCoeffBuf

int16 gCoeffBuf[8 *8];

variable gCompACTab

uint8 gCompACTab[3];

variable gCompDCTab

uint8 gCompDCTab[3];

variable gCompHSamp

uint8 gCompHSamp[3];

variable gCompIdent

uint8 gCompIdent[3];

variable gCompList

uint8 gCompList[3];

variable gCompQuant

uint8 gCompQuant[3];

variable gCompVSamp

uint8 gCompVSamp[3];

variable gCompsInFrame

uint8 gCompsInFrame;

variable gCompsInScan

uint8 gCompsInScan;

variable gHuffTab0

HuffTable gHuffTab0;

variable gHuffTab1

HuffTable gHuffTab1;

variable gHuffTab2

HuffTable gHuffTab2;

variable gHuffTab3

HuffTable gHuffTab3;

variable gHuffVal0

uint8 gHuffVal0[16];

variable gHuffVal1

uint8 gHuffVal1[16];

variable gHuffVal2

uint8 gHuffVal2[256];

variable gHuffVal3

uint8 gHuffVal3[256];

variable gImageXSize

uint16 gImageXSize;

variable gImageYSize

uint16 gImageYSize;

variable gInBuf

uint8 gInBuf[PJPG_MAX_IN_BUF_SIZE];

variable gInBufLeft

uint8 gInBufLeft;

variable gInBufOfs

uint8 gInBufOfs;

variable gLastDC

int16 gLastDC[3];

variable gMCUBufB

uint8 gMCUBufB[256];

variable gMCUBufG

uint8 gMCUBufG[256];

variable gMCUBufR

uint8 gMCUBufR[256];

variable gMCUOrg

uint8 gMCUOrg[6];

variable gMaxBlocksPerMCU

uint8 gMaxBlocksPerMCU;

variable gMaxMCUSPerCol

uint16 gMaxMCUSPerCol;

variable gMaxMCUSPerRow

uint16 gMaxMCUSPerRow;

variable gMaxMCUXSize

uint8 gMaxMCUXSize;

variable gMaxMCUYSize

uint8 gMaxMCUYSize;

variable gNextRestartNum

uint16 gNextRestartNum;

variable gNumMCUSRemainingX

uint16 gNumMCUSRemainingX;

variable gNumMCUSRemainingY

uint16 gNumMCUSRemainingY;

variable gQuant0

int16 gQuant0[8 *8];

variable gQuant1

int16 gQuant1[8 *8];

variable gReduce

uint8 gReduce;

variable gRestartInterval

uint16 gRestartInterval;

variable gRestartsLeft

uint16 gRestartsLeft;

variable gScanType

pjpeg_scan_type_t gScanType;

variable gTemFlag

uint8 gTemFlag;

variable gValidHuffTables

uint8 gValidHuffTables;

variable gValidQuantTables

uint8 gValidQuantTables;

variable g_pCallback_data

void* g_pCallback_data;

variable g_pNeedBytesCallback

pjpeg_need_bytes_callback_t g_pNeedBytesCallback;

Public Functions Documentation

function pjpeg_decode_init

unsigned char pjpeg_decode_init (
    pjpeg_image_info_t * pInfo,
    pjpeg_need_bytes_callback_t pNeed_bytes_callback,
    void * pCallback_data,
    unsigned char reduce
) 

function pjpeg_decode_mcu

unsigned char pjpeg_decode_mcu (
    void
) 

Public Static Functions Documentation

function addAndClamp

static PJPG_INLINE uint8 addAndClamp (
    uint8 a,
    int16 b
) 

function checkHuffTables

static uint8 checkHuffTables (
    void
) 

function checkQuantTables

static uint8 checkQuantTables (
    void
) 

function clamp

static PJPG_INLINE uint8 clamp (
    int16 s
) 

function convertCb

static void convertCb (
    uint8 dstOfs
) 

function convertCr

static void convertCr (
    uint8 dstOfs
) 

function copyY

static void copyY (
    uint8 dstOfs
) 

function createWinogradQuant

static void createWinogradQuant (
    int16 * pQuant
) 

function decodeNextMCU

static uint8 decodeNextMCU (
    void
) 

function fillInBuf

static void fillInBuf (
    void
) 

function findEOI

static uint8 findEOI (
    void
) 

function fixInBuffer

static void fixInBuffer (
    void
) 

function getBit

static PJPG_INLINE uint8 getBit (
    void
) 

function getBits

static uint16 getBits (
    uint8 numBits,
    uint8 FFCheck
) 

function getBits1

static PJPG_INLINE uint16 getBits1 (
    uint8 numBits
) 

function getBits2

static PJPG_INLINE uint16 getBits2 (
    uint8 numBits
) 

function getChar

static PJPG_INLINE uint8 getChar (
    void
) 

function getExtendOffset

static int16 getExtendOffset (
    uint8 i
) 

function getExtendTest

static uint16 getExtendTest (
    uint8 i
) 

function getHuffTable

static HuffTable * getHuffTable (
    uint8 index
) 

function getHuffVal

static uint8 * getHuffVal (
    uint8 index
) 

function getMaxHuffCodes

static uint16 getMaxHuffCodes (
    uint8 index
) 

function getOctet

static PJPG_INLINE uint8 getOctet (
    uint8 FFCheck
) 

function huffCreate

static void huffCreate (
    const uint8 * pBits,
    HuffTable * pHuffTable
) 

function huffDecode

static PJPG_INLINE uint8 huffDecode (
    const HuffTable * pHuffTable,
    const uint8 * pHuffVal
) 

function huffExtend

static PJPG_INLINE int16 huffExtend (
    uint16 x,
    uint8 s
) 

function idctCols

static void idctCols (
    void
) 

function idctRows

static void idctRows (
    void
) 

function imul_b1_b3

static PJPG_INLINE int16 imul_b1_b3 (
    int16 w
) 

function imul_b2

static PJPG_INLINE int16 imul_b2 (
    int16 w
) 

function imul_b4

static PJPG_INLINE int16 imul_b4 (
    int16 w
) 

function imul_b5

static PJPG_INLINE int16 imul_b5 (
    int16 w
) 

function init

static uint8 init (
    void
) 

function initFrame

static uint8 initFrame (
    void
) 

function initScan

static uint8 initScan (
    void
) 

function locateSOFMarker

static uint8 locateSOFMarker (
    void
) 

function locateSOIMarker

static uint8 locateSOIMarker (
    void
) 

function locateSOSMarker

static uint8 locateSOSMarker (
    uint8 * pFoundEOI
) 

function nextMarker

static uint8 nextMarker (
    void
) 

function processMarkers

static uint8 processMarkers (
    uint8 * pMarker
) 

function processRestart

static uint8 processRestart (
    void
) 

function readDHTMarker

static uint8 readDHTMarker (
    void
) 

function readDQTMarker

static uint8 readDQTMarker (
    void
) 

function readDRIMarker

static uint8 readDRIMarker (
    void
) 

function readSOFMarker

static uint8 readSOFMarker (
    void
) 

function readSOSMarker

static uint8 readSOSMarker (
    void
) 

function skipVariableMarker

static uint8 skipVariableMarker (
    void
) 

function stuffChar

static PJPG_INLINE void stuffChar (
    uint8 i
) 

function subAndClamp

static PJPG_INLINE uint8 subAndClamp (
    uint8 a,
    int16 b
) 

function transformBlock

static void transformBlock (
    uint8 mcuBlock
) 

function transformBlockReduce

static void transformBlockReduce (
    uint8 mcuBlock
) 

function upsampleCb

static void upsampleCb (
    uint8 srcOfs,
    uint8 dstOfs
) 

function upsampleCbH

static void upsampleCbH (
    uint8 srcOfs,
    uint8 dstOfs
) 

function upsampleCbV

static void upsampleCbV (
    uint8 srcOfs,
    uint8 dstOfs
) 

function upsampleCr

static void upsampleCr (
    uint8 srcOfs,
    uint8 dstOfs
) 

function upsampleCrH

static void upsampleCrH (
    uint8 srcOfs,
    uint8 dstOfs
) 

function upsampleCrV

static void upsampleCrV (
    uint8 srcOfs,
    uint8 dstOfs
) 

Macro Definition Documentation

define PJPG_ARITH_SHIFT_RIGHT_8_L

#define PJPG_ARITH_SHIFT_RIGHT_8_L (
    x
) ((x) >> 8)

define PJPG_ARITH_SHIFT_RIGHT_N_16

#define PJPG_ARITH_SHIFT_RIGHT_N_16 (
    x,
    n
) ((x) >> (n))

define PJPG_DCT_SCALE

#define PJPG_DCT_SCALE (1U << PJPG_DCT_SCALE_BITS)

define PJPG_DCT_SCALE_BITS

#define PJPG_DCT_SCALE_BITS 7

define PJPG_DESCALE

#define PJPG_DESCALE (
    x
) PJPG_ARITH_SHIFT_RIGHT_N_16(((x) + (1 << (PJPG_DCT_SCALE_BITS - 1))), PJPG_DCT_SCALE_BITS)

define PJPG_INLINE

#define PJPG_INLINE 

define PJPG_MAXCOMPSINSCAN

#define PJPG_MAXCOMPSINSCAN 3

define PJPG_MAX_HEIGHT

#define PJPG_MAX_HEIGHT 16384

define PJPG_MAX_IN_BUF_SIZE

#define PJPG_MAX_IN_BUF_SIZE 256

define PJPG_MAX_WIDTH

#define PJPG_MAX_WIDTH 16384

define PJPG_RIGHT_SHIFT_IS_ALWAYS_UNSIGNED

#define PJPG_RIGHT_SHIFT_IS_ALWAYS_UNSIGNED 0

define PJPG_WFIX

#define PJPG_WFIX (
    x
) ((x)*PJPG_DCT_SCALE + 0.5f)

define PJPG_WINOGRAD_QUANT_SCALE_BITS

#define PJPG_WINOGRAD_QUANT_SCALE_BITS 10

The documentation for this class was generated from the following file neuralSPOT/neuralspot/ns-camera/src/jpeg-decoder/picojpeg.c