FFmpeg
Macros | Functions
mjpegdec.c File Reference

MJPEG decoder. More...

#include "libavutil/imgutils.h"
#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "blockdsp.h"
#include "copy_block.h"
#include "hwaccel.h"
#include "idctdsp.h"
#include "internal.h"
#include "jpegtables.h"
#include "mjpeg.h"
#include "mjpegdec.h"
#include "jpeglsdec.h"
#include "profiles.h"
#include "put_bits.h"
#include "tiff.h"
#include "exif.h"
#include "bytestream.h"

Go to the source code of this file.

Macros

#define REFINE_BIT(j)
 
#define ZERO_RUN
 
#define copy_data_segment(skip)
 

Functions

static int build_vlc (VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table, int nb_codes, int use_static, int is_ac)
 
static int init_default_huffman_tables (MJpegDecodeContext *s)
 
static void parse_avid (MJpegDecodeContext *s, uint8_t *buf, int len)
 
static void init_idct (AVCodecContext *avctx)
 
av_cold int ff_mjpeg_decode_init (AVCodecContext *avctx)
 
int ff_mjpeg_decode_dqt (MJpegDecodeContext *s)
 
int ff_mjpeg_decode_dht (MJpegDecodeContext *s)
 
int ff_mjpeg_decode_sof (MJpegDecodeContext *s)
 
static int mjpeg_decode_dc (MJpegDecodeContext *s, int dc_index)
 
static int decode_block (MJpegDecodeContext *s, int16_t *block, int component, int dc_index, int ac_index, uint16_t *quant_matrix)
 
static int decode_dc_progressive (MJpegDecodeContext *s, int16_t *block, int component, int dc_index, uint16_t *quant_matrix, int Al)
 
static int decode_block_progressive (MJpegDecodeContext *s, int16_t *block, uint8_t *last_nnz, int ac_index, uint16_t *quant_matrix, int ss, int se, int Al, int *EOBRUN)
 
static int decode_block_refinement (MJpegDecodeContext *s, int16_t *block, uint8_t *last_nnz, int ac_index, uint16_t *quant_matrix, int ss, int se, int Al, int *EOBRUN)
 
static int handle_rstn (MJpegDecodeContext *s, int nb_components)
 
static int ljpeg_decode_rgb_scan (MJpegDecodeContext *s, int nb_components, int predictor, int point_transform)
 
static int ljpeg_decode_yuv_scan (MJpegDecodeContext *s, int predictor, int point_transform, int nb_components)
 
static av_always_inline void mjpeg_copy_block (MJpegDecodeContext *s, uint8_t *dst, const uint8_t *src, int linesize, int lowres)
 
static void shift_output (MJpegDecodeContext *s, uint8_t *ptr, int linesize)
 
static int mjpeg_decode_scan (MJpegDecodeContext *s, int nb_components, int Ah, int Al, const uint8_t *mb_bitmask, int mb_bitmask_size, const AVFrame *reference)
 
static int mjpeg_decode_scan_progressive_ac (MJpegDecodeContext *s, int ss, int se, int Ah, int Al)
 
static void mjpeg_idct_scan_progressive_ac (MJpegDecodeContext *s)
 
int ff_mjpeg_decode_sos (MJpegDecodeContext *s, const uint8_t *mb_bitmask, int mb_bitmask_size, const AVFrame *reference)
 
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 (const uint8_t **pbuf_ptr, const uint8_t *buf_end)
 
int ff_mjpeg_find_marker (MJpegDecodeContext *s, const uint8_t **buf_ptr, const uint8_t *buf_end, const uint8_t **unescaped_buf_ptr, int *unescaped_buf_size)
 
static void reset_icc_profile (MJpegDecodeContext *s)
 
int ff_mjpeg_decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 
av_cold int ff_mjpeg_decode_end (AVCodecContext *avctx)
 
static void decode_flush (AVCodecContext *avctx)
 

Detailed Description

MJPEG decoder.

Definition in file mjpegdec.c.

Macro Definition Documentation

#define REFINE_BIT (   j)
Value:
{ \
UPDATE_CACHE(re, &s->gb); \
sign = block[j] >> 15; \
block[j] += SHOW_UBITS(re, &s->gb, 1) * \
((quant_matrix[i] ^ sign) - sign) << Al; \
LAST_SKIP_BITS(re, &s->gb, 1); \
}
float re
Definition: fft.c:82
The exact code depends on how similar the blocks are and how related they are to the block
#define UPDATE_CACHE(name, gb)
Definition: get_bits.h:178
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
#define s(width, name)
Definition: cbs_vp9.c:257
#define LAST_SKIP_BITS(name, gb, num)
Definition: get_bits.h:199
#define SHOW_UBITS(name, gb, num)
Definition: get_bits.h:211

Definition at line 919 of file mjpegdec.c.

Referenced by decode_block_refinement().

#define ZERO_RUN
Value:
for (; ; i++) { \
if (i > last) { \
i += run; \
if (i > se) { \
av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i); \
return -1; \
} \
break; \
} \
j = s->scantable.permutated[i]; \
if (block[j]) \
else if (run-- == 0) \
break; \
}
#define se(name, range_min, range_max)
Definition: cbs_h2645.c:263
uint8_t run
Definition: svq3.c:206
The exact code depends on how similar the blocks are and how related they are to the block
#define av_log(a,...)
else
Definition: snow.txt:125
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define s(width, name)
Definition: cbs_vp9.c:257
if(ret)
#define REFINE_BIT(j)
Definition: mjpegdec.c:919
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a it should return

Definition at line 927 of file mjpegdec.c.

Referenced by decode_block_refinement().

#define copy_data_segment (   skip)
Value:
do { \
ptrdiff_t length = (ptr - src) - (skip); \
if (length > 0) { \
memcpy(dst, src, length); \
dst += length; \
src = ptr; \
} \
} while (0)
#define src
Definition: vp8dsp.c:254
GLsizei GLsizei * length
Definition: opengl_enc.c:114
if(ret)

Referenced by ff_mjpeg_find_marker().

Function Documentation

static int build_vlc ( VLC vlc,
const uint8_t bits_table,
const uint8_t val_table,
int  nb_codes,
int  use_static,
int  is_ac 
)
static

Definition at line 53 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_dht(), and init_default_huffman_tables().

static int init_default_huffman_tables ( MJpegDecodeContext s)
static

Definition at line 76 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_init().

static void parse_avid ( MJpegDecodeContext s,
uint8_t buf,
int  len 
)
static

Definition at line 119 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_init(), and mjpeg_decode_com().

static void init_idct ( AVCodecContext avctx)
static

Definition at line 130 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_init(), and ff_mjpeg_decode_sof().

av_cold int ff_mjpeg_decode_init ( AVCodecContext avctx)

Definition at line 139 of file mjpegdec.c.

Referenced by decode_flush(), mxpeg_decode_init(), and sp5x_decode_frame().

int ff_mjpeg_decode_dqt ( MJpegDecodeContext s)

Definition at line 200 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_frame(), mjpegb_decode_frame(), and mxpeg_decode_frame().

int ff_mjpeg_decode_dht ( MJpegDecodeContext s)
int ff_mjpeg_decode_sof ( MJpegDecodeContext s)

Definition at line 305 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_frame(), mjpegb_decode_frame(), and mxpeg_decode_frame().

static int mjpeg_decode_dc ( MJpegDecodeContext s,
int  dc_index 
)
inlinestatic
static int decode_block ( MJpegDecodeContext s,
int16_t *  block,
int  component,
int  dc_index,
int  ac_index,
uint16_t *  quant_matrix 
)
static

Definition at line 779 of file mjpegdec.c.

Referenced by mjpeg_decode_scan().

static int decode_dc_progressive ( MJpegDecodeContext s,
int16_t *  block,
int  component,
int  dc_index,
uint16_t *  quant_matrix,
int  Al 
)
static

Definition at line 828 of file mjpegdec.c.

Referenced by mjpeg_decode_scan().

static int decode_block_progressive ( MJpegDecodeContext s,
int16_t *  block,
uint8_t last_nnz,
int  ac_index,
uint16_t *  quant_matrix,
int  ss,
int  se,
int  Al,
int EOBRUN 
)
static

Definition at line 846 of file mjpegdec.c.

Referenced by mjpeg_decode_scan_progressive_ac().

static int decode_block_refinement ( MJpegDecodeContext s,
int16_t *  block,
uint8_t last_nnz,
int  ac_index,
uint16_t *  quant_matrix,
int  ss,
int  se,
int  Al,
int EOBRUN 
)
static

Definition at line 945 of file mjpegdec.c.

Referenced by mjpeg_decode_scan_progressive_ac().

static int handle_rstn ( MJpegDecodeContext s,
int  nb_components 
)
static

Definition at line 1010 of file mjpegdec.c.

Referenced by mjpeg_decode_scan(), and mjpeg_decode_scan_progressive_ac().

static int ljpeg_decode_rgb_scan ( MJpegDecodeContext s,
int  nb_components,
int  predictor,
int  point_transform 
)
static

Definition at line 1044 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_sos().

static int ljpeg_decode_yuv_scan ( MJpegDecodeContext s,
int  predictor,
int  point_transform,
int  nb_components 
)
static

Definition at line 1174 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_sos().

static av_always_inline void mjpeg_copy_block ( MJpegDecodeContext s,
uint8_t dst,
const uint8_t src,
int  linesize,
int  lowres 
)
static

Definition at line 1328 of file mjpegdec.c.

Referenced by mjpeg_decode_scan().

static void shift_output ( MJpegDecodeContext s,
uint8_t ptr,
int  linesize 
)
static

Definition at line 1344 of file mjpegdec.c.

Referenced by mjpeg_decode_scan(), and mjpeg_idct_scan_progressive_ac().

static int mjpeg_decode_scan ( MJpegDecodeContext s,
int  nb_components,
int  Ah,
int  Al,
const uint8_t mb_bitmask,
int  mb_bitmask_size,
const AVFrame reference 
)
static

Definition at line 1359 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_sos().

static int mjpeg_decode_scan_progressive_ac ( MJpegDecodeContext s,
int  ss,
int  se,
int  Ah,
int  Al 
)
static

Definition at line 1480 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_sos().

static void mjpeg_idct_scan_progressive_ac ( MJpegDecodeContext s)
static

Definition at line 1532 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_frame().

int ff_mjpeg_decode_sos ( MJpegDecodeContext s,
const uint8_t mb_bitmask,
int  mb_bitmask_size,
const AVFrame reference 
)

Definition at line 1567 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_frame(), mjpegb_decode_frame(), and mxpeg_decode_frame().

static int mjpeg_decode_dri ( MJpegDecodeContext s)
static

Definition at line 1745 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_frame().

static int mjpeg_decode_app ( MJpegDecodeContext s)
static

Definition at line 1757 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_frame().

static int mjpeg_decode_com ( MJpegDecodeContext s)
static

Definition at line 2067 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_frame().

static int find_marker ( const uint8_t **  pbuf_ptr,
const uint8_t buf_end 
)
static

Definition at line 2107 of file mjpegdec.c.

Referenced by ff_mjpeg_find_marker().

int ff_mjpeg_find_marker ( MJpegDecodeContext s,
const uint8_t **  buf_ptr,
const uint8_t buf_end,
const uint8_t **  unescaped_buf_ptr,
int unescaped_buf_size 
)

Definition at line 2132 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_frame(), and mxpeg_decode_frame().

static void reset_icc_profile ( MJpegDecodeContext s)
static

Definition at line 2252 of file mjpegdec.c.

Referenced by ff_mjpeg_decode_end(), and ff_mjpeg_decode_frame().

int ff_mjpeg_decode_frame ( AVCodecContext avctx,
void data,
int got_frame,
AVPacket avpkt 
)

Definition at line 2266 of file mjpegdec.c.

Referenced by decode_flush(), and sp5x_decode_frame().

av_cold int ff_mjpeg_decode_end ( AVCodecContext avctx)

Definition at line 2745 of file mjpegdec.c.

Referenced by decode_flush(), mxpeg_decode_end(), and sp5x_decode_frame().

static void decode_flush ( AVCodecContext avctx)
static

Definition at line 2782 of file mjpegdec.c.