FFmpeg
Macros | Functions | Variables
mjpegenc.c File Reference

MJPEG encoder. More...

#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "jpegtables.h"
#include "mjpegenc_common.h"
#include "mjpegenc_huffman.h"
#include "mpegvideo.h"
#include "mjpeg.h"
#include "mjpegenc.h"
#include "profiles.h"

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(MpegEncContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static av_cold void init_uni_ac_vlc (const uint8_t huff_size_ac[256], uint8_t *uni_ac_vlc_len)
 
static void mjpeg_encode_picture_frame (MpegEncContext *s)
 Encodes and outputs the entire frame in the JPEG format. More...
 
static void mjpeg_build_optimal_huffman (MJpegContext *m)
 Builds all 4 optimal Huffman tables. More...
 
int ff_mjpeg_encode_stuffing (MpegEncContext *s)
 Writes the complete JPEG frame when optimal huffman tables are enabled, otherwise writes the stuffing. More...
 
static int alloc_huffman (MpegEncContext *s)
 
av_cold int ff_mjpeg_encode_init (MpegEncContext *s)
 
av_cold void ff_mjpeg_encode_close (MpegEncContext *s)
 
static void ff_mjpeg_encode_code (MJpegContext *s, uint8_t table_id, int code)
 Add code and table_id to the JPEG buffer. More...
 
static void ff_mjpeg_encode_coef (MJpegContext *s, uint8_t table_id, int val, int run)
 Add the coefficient's data to the JPEG buffer. More...
 
static void record_block (MpegEncContext *s, int16_t *block, int n)
 Add the block's data into the JPEG buffer. More...
 
static void encode_block (MpegEncContext *s, int16_t *block, int n)
 
void ff_mjpeg_encode_mb (MpegEncContext *s, int16_t block[12][64])
 

Variables

static const AVOption options []
 

Detailed Description

MJPEG encoder.

Definition in file mjpegenc.c.

Macro Definition Documentation

#define OFFSET (   x)    offsetof(MpegEncContext, x)

Definition at line 573 of file mjpegenc.c.

Definition at line 574 of file mjpegenc.c.

Function Documentation

static av_cold void init_uni_ac_vlc ( const uint8_t  huff_size_ac[256],
uint8_t uni_ac_vlc_len 
)
static

Definition at line 44 of file mjpegenc.c.

Referenced by ff_mjpeg_encode_init(), and ff_mjpeg_encode_stuffing().

static void mjpeg_encode_picture_frame ( MpegEncContext s)
static

Encodes and outputs the entire frame in the JPEG format.

Parameters
sThe MpegEncContext.

Definition at line 73 of file mjpegenc.c.

Referenced by ff_mjpeg_encode_stuffing().

static void mjpeg_build_optimal_huffman ( MJpegContext m)
static

Builds all 4 optimal Huffman tables.

Uses the data stored in the JPEG buffer to compute the tables. Stores the Huffman tables in the bits_* and val_* arrays in the MJpegContext.

Parameters
mMJpegContext containing the JPEG buffer.

Definition at line 124 of file mjpegenc.c.

Referenced by ff_mjpeg_encode_stuffing().

int ff_mjpeg_encode_stuffing ( MpegEncContext s)

Writes the complete JPEG frame when optimal huffman tables are enabled, otherwise writes the stuffing.

Header + values + stuffing.

Parameters
sThe MpegEncContext.
Returns
int Error code, 0 if successful.

Definition at line 184 of file mjpegenc.c.

Referenced by put_marker(), and write_slice_end().

static int alloc_huffman ( MpegEncContext s)
static

Definition at line 230 of file mjpegenc.c.

Referenced by ff_mjpeg_encode_init().

av_cold int ff_mjpeg_encode_init ( MpegEncContext s)

Definition at line 258 of file mjpegenc.c.

Referenced by ff_mpv_encode_init(), and put_marker().

av_cold void ff_mjpeg_encode_close ( MpegEncContext s)

Definition at line 313 of file mjpegenc.c.

Referenced by ff_mpv_encode_end(), and put_marker().

static void ff_mjpeg_encode_code ( MJpegContext s,
uint8_t  table_id,
int  code 
)
inlinestatic

Add code and table_id to the JPEG buffer.

Parameters
sThe MJpegContext which contains the JPEG buffer.
table_idWhich Huffman table the code belongs to.
codeThe encoded exponent of the coefficients and the run-bits.

Definition at line 326 of file mjpegenc.c.

Referenced by ff_mjpeg_encode_coef(), and record_block().

static void ff_mjpeg_encode_coef ( MJpegContext s,
uint8_t  table_id,
int  val,
int  run 
)
static

Add the coefficient's data to the JPEG buffer.

Parameters
sThe MJpegContext which contains the JPEG buffer.
table_idWhich Huffman table the code belongs to.
valThe coefficient.
runThe run-bits.

Definition at line 341 of file mjpegenc.c.

Referenced by record_block().

static void record_block ( MpegEncContext s,
int16_t *  block,
int  n 
)
static

Add the block's data into the JPEG buffer.

Parameters
sThe MJpegEncContext that contains the JPEG buffer.
blockThe block.
nThe block's index or number.

Definition at line 369 of file mjpegenc.c.

Referenced by ff_mjpeg_encode_mb().

static void encode_block ( MpegEncContext s,
int16_t *  block,
int  n 
)
static

Definition at line 412 of file mjpegenc.c.

Referenced by ff_mjpeg_encode_mb().

void ff_mjpeg_encode_mb ( MpegEncContext s,
int16_t  block[12][64] 
)

Definition at line 470 of file mjpegenc.c.

Referenced by encode_mb_internal(), and put_marker().

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{ "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 3, VE, "pred" },
{ "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
{ "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "pred" },
{ "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, INT_MIN, INT_MAX, VE, "pred" },
{ "huffman", "Huffman table strategy", OFFSET(huffman), AV_OPT_TYPE_INT, { .i64 = HUFFMAN_TABLE_OPTIMAL }, 0, NB_HUFFMAN_TABLE_OPTION - 1, VE, "huffman" },
{ "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_DEFAULT }, INT_MIN, INT_MAX, VE, "huffman" },
{ "optimal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_OPTIMAL }, INT_MIN, INT_MAX, VE, "huffman" },
{ NULL},
}
#define NULL
Definition: coverity.c:32
#define FF_MPV_COMMON_OPTS
Definition: mpegvideo.h:619
Use the default Huffman tables.
Definition: mjpegenc.h:96
Compute and use optimal Huffman tables.
Definition: mjpegenc.h:97
static const float pred[4]
Definition: siprdata.h:259
#define OFFSET(x)
Definition: mjpegenc.c:573
#define VE
Definition: mjpegenc.c:574

Definition at line 575 of file mjpegenc.c.