hvirtual/quicktime/ffmpeg/libavcodec/mjpeg.c File Reference

#include <assert.h>
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
#include "sp5x.h"

Include dependency graph for mjpeg.c:

Go to the source code of this file.

Data Structures

struct  MJpegContext
struct  MJpegDecodeContext

Defines

#define PREDICT(ret, topleft, top, left, predictor)
#define MAX_COMPONENTS   4

Enumerations

enum  JPEG_MARKER {
  SOF0 = 0xc0, SOF1 = 0xc1, SOF2 = 0xc2, SOF3 = 0xc3,
  SOF5 = 0xc5, SOF6 = 0xc6, SOF7 = 0xc7, JPG = 0xc8,
  SOF9 = 0xc9, SOF10 = 0xca, SOF11 = 0xcb, SOF13 = 0xcd,
  SOF14 = 0xce, SOF15 = 0xcf, DHT = 0xc4, DAC = 0xcc,
  RST0 = 0xd0, RST1 = 0xd1, RST2 = 0xd2, RST3 = 0xd3,
  RST4 = 0xd4, RST5 = 0xd5, RST6 = 0xd6, RST7 = 0xd7,
  SOI = 0xd8, EOI = 0xd9, SOS = 0xda, DQT = 0xdb,
  DNL = 0xdc, DRI = 0xdd, DHP = 0xde, EXP = 0xdf,
  APP0 = 0xe0, APP1 = 0xe1, APP2 = 0xe2, APP3 = 0xe3,
  APP4 = 0xe4, APP5 = 0xe5, APP6 = 0xe6, APP7 = 0xe7,
  APP8 = 0xe8, APP9 = 0xe9, APP10 = 0xea, APP11 = 0xeb,
  APP12 = 0xec, APP13 = 0xed, APP14 = 0xee, APP15 = 0xef,
  JPG0 = 0xf0, JPG1 = 0xf1, JPG2 = 0xf2, JPG3 = 0xf3,
  JPG4 = 0xf4, JPG5 = 0xf5, JPG6 = 0xf6, JPG7 = 0xf7,
  JPG8 = 0xf8, JPG9 = 0xf9, JPG10 = 0xfa, JPG11 = 0xfb,
  JPG12 = 0xfc, JPG13 = 0xfd, COM = 0xfe, TEM = 0x01
}

Functions

static void build_huffman_codes (uint8_t *huff_size, uint16_t *huff_code, const uint8_t *bits_table, const uint8_t *val_table)
static int mjpeg_decode_dht (MJpegDecodeContext *s)
static int build_vlc (VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table, int nb_codes, int use_static)
static int mjpeg_decode_init (AVCodecContext *avctx)
static int find_frame_end (ParseContext *pc, const uint8_t *buf, int buf_size)
static int jpeg_parse (AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
static int mjpeg_decode_dqt (MJpegDecodeContext *s)
static int mjpeg_decode_sof (MJpegDecodeContext *s)
static int mjpeg_decode_dc (MJpegDecodeContext *s, int dc_index)
static int decode_block (MJpegDecodeContext *s, DCTELEM *block, int component, int dc_index, int ac_index, int quant_index)
static int ljpeg_decode_rgb_scan (MJpegDecodeContext *s, int predictor, int point_transform)
static int ljpeg_decode_yuv_scan (MJpegDecodeContext *s, int predictor, int point_transform)
static int mjpeg_decode_scan (MJpegDecodeContext *s)
static int mjpeg_decode_sos (MJpegDecodeContext *s)
static int mjpeg_decode_dri (MJpegDecodeContext *s)
static int mjpeg_decode_app (MJpegDecodeContext *s)
static int mjpeg_decode_com (MJpegDecodeContext *s)
static int find_marker (uint8_t **pbuf_ptr, uint8_t *buf_end)
static int mjpeg_decode_frame (AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size)
static int mjpegb_decode_frame (AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size)
static int sp5x_decode_frame (AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size)
static int mjpeg_decode_end (AVCodecContext *avctx)

Variables

static const uint8_t bits_dc_luminance [17]
static const uint8_t val_dc_luminance []
static const uint8_t bits_dc_chrominance [17]
static const uint8_t val_dc_chrominance []
static const uint8_t bits_ac_luminance [17]
static const uint8_t val_ac_luminance []
static const uint8_t bits_ac_chrominance [17]
static const uint8_t val_ac_chrominance []
AVCodec mjpeg_decoder
AVCodec mjpegb_decoder
AVCodec sp5x_decoder
AVCodecParser mjpeg_parser


Detailed Description

MJPEG encoder and decoder.

Definition in file mjpeg.c.


Define Documentation

#define MAX_COMPONENTS   4

Definition at line 810 of file mjpeg.c.

Referenced by mjpeg_decode_sof().

#define PREDICT ( ret,
topleft,
top,
left,
predictor   ) 

Value:

switch(predictor){\
        case 1: ret= left; break;\
        case 2: ret= top; break;\
        case 3: ret= topleft; break;\
        case 4: ret= left   +   top - topleft; break;\
        case 5: ret= left   + ((top - topleft)>>1); break;\
        case 6: ret= top + ((left   - topleft)>>1); break;\
        default:\
        case 7: ret= (left + top)>>1; break;\
    }

Definition at line 288 of file mjpeg.c.

Referenced by ljpeg_decode_rgb_scan(), and ljpeg_decode_yuv_scan().


Enumeration Type Documentation

Enumerator:
SOF0 
SOF1 
SOF2 
SOF3 
SOF5 
SOF6 
SOF7 
JPG 
SOF9 
SOF10 
SOF11 
SOF13 
SOF14 
SOF15 
DHT 
DAC 
RST0 
RST1 
RST2 
RST3 
RST4 
RST5 
RST6 
RST7 
SOI 
EOI 
SOS 
DQT 
DNL 
DRI 
DHP 
EXP 
APP0 
APP1 
APP2 
APP3 
APP4 
APP5 
APP6 
APP7 
APP8 
APP9 
APP10 
APP11 
APP12 
APP13 
APP14 
APP15 
JPG0 
JPG1 
JPG2 
JPG3 
JPG4 
JPG5 
JPG6 
JPG7 
JPG8 
JPG9 
JPG10 
JPG11 
JPG12 
JPG13 
COM 
TEM 

Definition at line 55 of file mjpeg.c.


Function Documentation

static void build_huffman_codes ( uint8_t *  huff_size,
uint16_t *  huff_code,
const uint8_t *  bits_table,
const uint8_t *  val_table 
) [static]

Definition at line 229 of file mjpeg.c.

References nb.

Referenced by build_vlc().

static int build_vlc ( VLC vlc,
const uint8_t *  bits_table,
const uint8_t *  val_table,
int  nb_codes,
int  use_static 
) [static]

Definition at line 869 of file mjpeg.c.

References build_huffman_codes(), and init_vlc().

Referenced by mjpeg_decode_dht(), and mjpeg_decode_init().

Here is the call graph for this function:

static int decode_block ( MJpegDecodeContext s,
DCTELEM block,
int  component,
int  dc_index,
int  ac_index,
int  quant_index 
) [static]

static int find_frame_end ( ParseContext pc,
const uint8_t *  buf,
int  buf_size 
) [static]

finds the end of the current frame in the bitstream.

Returns:
the position of the first byte of the next frame, or -1

Definition at line 927 of file mjpeg.c.

References END_NOT_FOUND, ParseContext::frame_start_found, and ParseContext::state.

static int find_marker ( uint8_t **  pbuf_ptr,
uint8_t *  buf_end 
) [static]

static int jpeg_parse ( AVCodecParserContext s,
AVCodecContext avctx,
uint8_t **  poutbuf,
int *  poutbuf_size,
const uint8_t *  buf,
int  buf_size 
) [static]

Definition at line 964 of file mjpeg.c.

References ff_combine_frame(), find_frame_end(), NULL, and AVCodecParserContext::priv_data.

Here is the call graph for this function:

static int ljpeg_decode_rgb_scan ( MJpegDecodeContext s,
int  predictor,
int  point_transform 
) [static]

static int ljpeg_decode_yuv_scan ( MJpegDecodeContext s,
int  predictor,
int  point_transform 
) [static]

static int mjpeg_decode_app ( MJpegDecodeContext s  )  [static]

static int mjpeg_decode_com ( MJpegDecodeContext s  )  [static]

static int mjpeg_decode_dc ( MJpegDecodeContext s,
int  dc_index 
) [inline, static]

Definition at line 1186 of file mjpeg.c.

References MJpegDecodeContext::gb, get_vlc2(), get_xbits(), VLC::table, and MJpegDecodeContext::vlcs.

Referenced by decode_block(), ljpeg_decode_rgb_scan(), and ljpeg_decode_yuv_scan().

Here is the call graph for this function:

static int mjpeg_decode_dht ( MJpegDecodeContext s  )  [static]

Definition at line 1021 of file mjpeg.c.

References build_vlc(), free_vlc(), MJpegDecodeContext::gb, get_bits(), and MJpegDecodeContext::vlcs.

Referenced by mjpeg_decode_frame(), mjpeg_decode_init(), and mjpegb_decode_frame().

Here is the call graph for this function:

static int mjpeg_decode_dqt ( MJpegDecodeContext s  )  [static]

static int mjpeg_decode_dri ( MJpegDecodeContext s  )  [static]

Definition at line 1572 of file mjpeg.c.

References MJpegDecodeContext::gb, get_bits(), MJpegDecodeContext::restart_count, and MJpegDecodeContext::restart_interval.

Referenced by mjpeg_decode_frame().

Here is the call graph for this function:

static int mjpeg_decode_end ( AVCodecContext avctx  )  [static]

Definition at line 2253 of file mjpeg.c.

References av_free(), MJpegDecodeContext::buffer, free_vlc(), AVCodecContext::priv_data, MJpegDecodeContext::qscale_table, and MJpegDecodeContext::vlcs.

Here is the call graph for this function:

static int mjpeg_decode_frame ( AVCodecContext avctx,
void *  data,
int *  data_size,
uint8_t *  buf,
int  buf_size 
) [static]

static int mjpeg_decode_init ( AVCodecContext avctx  )  [static]

static int mjpeg_decode_scan ( MJpegDecodeContext s  )  [static]

static int mjpeg_decode_sof ( MJpegDecodeContext s  )  [static]

static int mjpeg_decode_sos ( MJpegDecodeContext s  )  [static]

static int mjpegb_decode_frame ( AVCodecContext avctx,
void *  data,
int *  data_size,
uint8_t *  buf,
int  buf_size 
) [static]

static int sp5x_decode_frame ( AVCodecContext avctx,
void *  data,
int *  data_size,
uint8_t *  buf,
int  buf_size 
) [static]


Variable Documentation

const uint8_t bits_ac_chrominance[17] [static]

Initial value:

{  0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }

Definition at line 201 of file mjpeg.c.

Referenced by mjpeg_decode_init().

const uint8_t bits_ac_luminance[17] [static]

Initial value:

{  0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }

Definition at line 175 of file mjpeg.c.

Referenced by mjpeg_decode_init().

const uint8_t bits_dc_chrominance[17] [static]

Initial value:

{  0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }

Definition at line 170 of file mjpeg.c.

Referenced by mjpeg_decode_init().

const uint8_t bits_dc_luminance[17] [static]

Initial value:

{  0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }

Definition at line 165 of file mjpeg.c.

Referenced by mjpeg_decode_init().

Initial value:

Definition at line 2319 of file mjpeg.c.

Referenced by avcodec_register_all().

const uint8_t val_ac_chrominance[] [static]

Initial value:

{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
  0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
  0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
  0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
  0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
  0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
  0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
  0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
  0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
  0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
  0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
  0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
  0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
  0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
  0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
  0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
  0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
  0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
  0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
  0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
  0xf9, 0xfa 
}

Definition at line 204 of file mjpeg.c.

Referenced by mjpeg_decode_init().

const uint8_t val_ac_luminance[] [static]

Initial value:

{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
  0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
  0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
  0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
  0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
  0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
  0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
  0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
  0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
  0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
  0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
  0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
  0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
  0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
  0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
  0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
  0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
  0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
  0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
  0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
  0xf9, 0xfa 
}

Definition at line 177 of file mjpeg.c.

Referenced by mjpeg_decode_init().

const uint8_t val_dc_chrominance[] [static]

Initial value:

{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }

Definition at line 172 of file mjpeg.c.

Referenced by mjpeg_decode_init().

const uint8_t val_dc_luminance[] [static]

Initial value:

{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }

Definition at line 167 of file mjpeg.c.

Referenced by mjpeg_decode_init().


Generated on Mon Apr 28 14:05:05 2008 for Cinelerra by  doxygen 1.5.5