Macros | Functions
rtjpeg.c File Reference
#include "libavutil/common.h"
#include "get_bits.h"
#include "rtjpeg.h"

Go to the source code of this file.


#define PUT_COEFF(c)
#define ALIGN(a)
 aligns the bitstream to the given power of two More...
#define BLOCK(quant, dst, stride)


static int get_block (GetBitContext *gb, int16_t *block, const uint8_t *scan, const uint32_t *quant)
 read one block from stream More...
int ff_rtjpeg_decode_frame_yuv420 (RTJpegContext *c, AVFrame *f, const uint8_t *buf, int buf_size)
 decode one rtjpeg YUV420 frame More...
void ff_rtjpeg_decode_init (RTJpegContext *c, int width, int height, const uint32_t *lquant, const uint32_t *cquant)
 initialize an RTJpegContext, may be called multiple times More...
void ff_rtjpeg_init (RTJpegContext *c, AVCodecContext *avctx)

Macro Definition Documentation


#define PUT_COEFF (   c)
i = scan[coeff--]; \
block[i] = (c) * quant[i];

Definition at line 25 of file rtjpeg.c.


#define ALIGN (   a)
n = (-get_bits_count(gb)) & (a - 1); \
if (n) {skip_bits(gb, n);}

aligns the bitstream to the given power of two

Definition at line 30 of file rtjpeg.c.


#define BLOCK (   quant,
do { \
int res = get_block(&gb, block, c->scan, quant); \
if (res < 0) \
return res; \
if (res > 0) \
c->idsp.idct_put(dst, stride, block); \
} while (0)

Function Documentation

◆ get_block()

static int get_block ( GetBitContext gb,
int16_t *  block,
const uint8_t scan,
const uint32_t *  quant 

read one block from stream

gbcontains stream data
blockwhere data is written to
scanarray containing the mapping stream address -> block position
quantquantization factors
0 means the block is not coded, < 0 means an error occurred.

Note: GetBitContext is used to make the code simpler, since all data is aligned this could be done faster in a different way, e.g. as it is done in MPlayer libmpcodecs/native/rtjpegn.c.

Definition at line 46 of file rtjpeg.c.

◆ ff_rtjpeg_decode_frame_yuv420()

int ff_rtjpeg_decode_frame_yuv420 ( RTJpegContext c,
AVFrame f,
const uint8_t buf,
int  buf_size 

decode one rtjpeg YUV420 frame

ccontext, must be initialized via ff_rtjpeg_decode_init
fAVFrame to place decoded frame into. If parts of the frame are not coded they are left unchanged, so consider initializing it
bufbuffer containing input data
buf_sizelength of input data in bytes
number of bytes consumed from the input buffer

Definition at line 106 of file rtjpeg.c.

Referenced by decode_frame().

◆ ff_rtjpeg_decode_init()

void ff_rtjpeg_decode_init ( RTJpegContext c,
int  width,
int  height,
const uint32_t *  lquant,
const uint32_t *  cquant 

initialize an RTJpegContext, may be called multiple times

ccontext to initialize
widthwidth of image, will be rounded down to the nearest multiple of 16 for decoding
heightheight of image, will be rounded down to the nearest multiple of 16 for decoding
lquantluma quantization table to use
cquantchroma quantization table to use

Definition at line 158 of file rtjpeg.c.

Referenced by codec_reinit(), and decode_frame().

◆ ff_rtjpeg_init()

void ff_rtjpeg_init ( RTJpegContext c,
AVCodecContext avctx 

Definition at line 170 of file rtjpeg.c.

Referenced by decode_init().

int stride
Definition: mace.c:144
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:219
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:467
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
int i
Definition: input.c:407
const uint8_t * quant
Definition: vorbis_enc_data.h:458
static int get_block(GetBitContext *gb, int16_t *block, const uint8_t *scan, const uint32_t *quant)
read one block from stream
Definition: rtjpeg.c:46
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
static const double coeff[2][5]
Definition: vf_owdenoise.c:73