TwiceAsNice  2019-02-18
Macros | Functions
Functions to encode and decode JPEG

jpeg_data: buffer with input / output jpeg
len: Length of jpeg buffer
itype: Y4M_ILACE_NONE: Not interlaced
Y4M_ILACE_TOP_FIRST: Interlaced, top-field-first
Y4M_ILACE_BOTTOM_FIRST: Interlaced, bottom-field-first
ctype Chroma format for decompression. More...

Macros

#define Y4M_ILACE_NONE   0 /** non-interlaced, progressive frame */
 
#define Y4M_ILACE_TOP_FIRST   1 /** interlaced, top-field first */
 
#define Y4M_ILACE_BOTTOM_FIRST   2 /** interlaced, bottom-field first */
 
#define Y4M_ILACE_MIXED   3 /** mixed, "refer to frame header" */
 
#define Y4M_CHROMA_420JPEG   0 /** 4:2:0, H/V centered, for JPEG/MPEG-1 */
 
#define Y4M_CHROMA_420MPEG2   1 /** 4:2:0, H cosited, for MPEG-2 */
 
#define Y4M_CHROMA_420PALDV   2 /** 4:2:0, alternating Cb/Cr, for PAL-DV */
 
#define Y4M_CHROMA_444   3 /** 4:4:4, no subsampling, phew. */
 
#define Y4M_CHROMA_422   4 /** 4:2:2, H cosited */
 
#define Y4M_CHROMA_411   5 /** 4:1:1, H cosited */
 
#define Y4M_CHROMA_MONO   6 /** luma plane only */
 
#define Y4M_CHROMA_444ALPHA   7 /** 4:4:4 with an alpha channel */
 

Functions

int decode_jpeg_raw (unsigned char *jpeg_data, int len, int itype, int ctype, unsigned int width, unsigned int height, unsigned char *raw0, unsigned char *raw1, unsigned char *raw2)
 decode JPEG buffer More...
 
int decode_jpeg_rgb (unsigned char *inBuffer, unsigned long inSize, uint8_t **memptr, size_t *memsize, int *naxis, int *w, int *h)
 decode_jpeg_rgb Read jpeg in memory buffer and produce RGB image More...
 
int decode_jpeg_gray_raw (unsigned char *jpeg_data, int len, int itype, int ctype, unsigned int width, unsigned int height, unsigned char *raw0, unsigned char *raw1, unsigned char *raw2)
 decode JPEG raw gray buffer More...
 
int encode_jpeg_raw (unsigned char *jpeg_data, int len, int quality, int itype, int ctype, unsigned int width, unsigned int height, unsigned char *raw0, unsigned char *raw1, unsigned char *raw2)
 encode raw JPEG buffer More...
 

Detailed Description

jpeg_data: buffer with input / output jpeg
len: Length of jpeg buffer
itype: Y4M_ILACE_NONE: Not interlaced
Y4M_ILACE_TOP_FIRST: Interlaced, top-field-first
Y4M_ILACE_BOTTOM_FIRST: Interlaced, bottom-field-first
ctype Chroma format for decompression.


Currently always 420 and hence ignored.
raw0 buffer with input / output raw Y channel
raw1 buffer with input / output raw U/Cb channel
raw2 buffer with input / output raw V/Cr channel
width width of Y channel (width of U/V is width/2)
height height of Y channel (height of U/V is height/2)

Macro Definition Documentation

◆ Y4M_CHROMA_411

#define Y4M_CHROMA_411   5 /** 4:1:1, H cosited */

◆ Y4M_CHROMA_420JPEG

#define Y4M_CHROMA_420JPEG   0 /** 4:2:0, H/V centered, for JPEG/MPEG-1 */

◆ Y4M_CHROMA_420MPEG2

#define Y4M_CHROMA_420MPEG2   1 /** 4:2:0, H cosited, for MPEG-2 */

◆ Y4M_CHROMA_420PALDV

#define Y4M_CHROMA_420PALDV   2 /** 4:2:0, alternating Cb/Cr, for PAL-DV */

◆ Y4M_CHROMA_422

#define Y4M_CHROMA_422   4 /** 4:2:2, H cosited */

◆ Y4M_CHROMA_444

#define Y4M_CHROMA_444   3 /** 4:4:4, no subsampling, phew. */

◆ Y4M_CHROMA_444ALPHA

#define Y4M_CHROMA_444ALPHA   7 /** 4:4:4 with an alpha channel */

◆ Y4M_CHROMA_MONO

#define Y4M_CHROMA_MONO   6 /** luma plane only */

◆ Y4M_ILACE_BOTTOM_FIRST

#define Y4M_ILACE_BOTTOM_FIRST   2 /** interlaced, bottom-field first */

◆ Y4M_ILACE_MIXED

#define Y4M_ILACE_MIXED   3 /** mixed, "refer to frame header" */

◆ Y4M_ILACE_NONE

#define Y4M_ILACE_NONE   0 /** non-interlaced, progressive frame */

◆ Y4M_ILACE_TOP_FIRST

#define Y4M_ILACE_TOP_FIRST   1 /** interlaced, top-field first */

Function Documentation

◆ decode_jpeg_gray_raw()

int decode_jpeg_gray_raw ( unsigned char *  jpeg_data,
int  len,
int  itype,
int  ctype,
unsigned int  width,
unsigned int  height,
unsigned char *  raw0,
unsigned char *  raw1,
unsigned char *  raw2 
)

decode JPEG raw gray buffer

◆ decode_jpeg_raw()

int decode_jpeg_raw ( unsigned char *  jpeg_data,
int  len,
int  itype,
int  ctype,
unsigned int  width,
unsigned int  height,
unsigned char *  raw0,
unsigned char *  raw1,
unsigned char *  raw2 
)

decode JPEG buffer

◆ decode_jpeg_rgb()

int decode_jpeg_rgb ( unsigned char *  inBuffer,
unsigned long  inSize,
uint8_t **  memptr,
size_t *  memsize,
int *  naxis,
int *  w,
int *  h 
)

decode_jpeg_rgb Read jpeg in memory buffer and produce RGB image

Parameters
inBufferpointer to jpeg file in memory
inSizefile of jpeg file in bytes
memptrpointer to store RGB data. To enhance performance, the memory must be allocated at least byte. memptr = malloc(1) since subsequent calls will use realloc to allocate memory. The caller is responsible for free(*memptr) eventually.
memsizesize of RGB data as determined after jpeg decompression
naxis1 for mono, 3 for color
wwidth of image in pixels
hheight image in pixels
Returns
0 if decoding sucseeds, -1 otherwise.

◆ encode_jpeg_raw()

int encode_jpeg_raw ( unsigned char *  jpeg_data,
int  len,
int  quality,
int  itype,
int  ctype,
unsigned int  width,
unsigned int  height,
unsigned char *  raw0,
unsigned char *  raw1,
unsigned char *  raw2 
)

encode raw JPEG buffer