FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Functions | Variables
mjpegenc.c File Reference
#include "config_components.h"
#include "libavutil/mem.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "jpegtables.h"
#include "mjpegenc_common.h"
#include "mjpegenc_huffman.h"
#include "mpegvideo.h"
#include "mjpeg.h"
#include "mjpegenc.h"
#include "mpegvideoenc.h"
#include "profiles.h"

Go to the source code of this file.

Data Structures

struct  MJpegHuffmanCode
 Buffer of JPEG frame data. More...
 
struct  MJPEGEncContext
 

Macros

#define OFFSET(x)   offsetof(MJPEGEncContext, mjpeg.x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
#define AMV_OPTIONS_OFFSET   4
 

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_header (MPVEncContext *const s)
 
static int mjpeg_amv_encode_picture_header (MPVMainEncContext *const m)
 
int ff_mjpeg_encode_stuffing (MPVEncContext *const s)
 Writes the complete JPEG frame when optimal huffman tables are enabled, otherwise writes the stuffing. More...
 
static int alloc_huffman (MJPEGEncContext *const m2)
 
static av_cold int mjpeg_encode_close (AVCodecContext *avctx)
 
static void mjpeg_encode_code (MJpegContext *s, uint8_t table_id, int code)
 Add code and table_id to the JPEG buffer. More...
 
static void 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 (MPVEncContext *const s, int16_t block[], int n)
 Add the block's data into the JPEG buffer. More...
 
static void encode_block (MPVEncContext *const s, int16_t block[], int n)
 
static void mjpeg_record_mb (MPVEncContext *const s, int16_t block[][64], int unused_x, int unused_y)
 
static void mjpeg_encode_mb (MPVEncContext *const s, int16_t block[][64], int unused_x, int unused_y)
 
static av_cold int mjpeg_encode_init (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 

Detailed Description

MJPEG encoder.

Definition in file mjpegenc.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(MJPEGEncContext, mjpeg.x)

Definition at line 646 of file mjpegenc.c.

◆ VE

Definition at line 647 of file mjpegenc.c.

◆ AMV_OPTIONS_OFFSET

#define AMV_OPTIONS_OFFSET   4

Function Documentation

◆ init_uni_ac_vlc()

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 71 of file mjpegenc.c.

Referenced by ff_mjpeg_encode_stuffing(), and mjpeg_encode_init().

◆ mjpeg_encode_picture_header()

static void mjpeg_encode_picture_header ( MPVEncContext *const  s)
static

Definition at line 95 of file mjpegenc.c.

Referenced by ff_mjpeg_encode_stuffing(), and mjpeg_amv_encode_picture_header().

◆ mjpeg_amv_encode_picture_header()

static int mjpeg_amv_encode_picture_header ( MPVMainEncContext *const  m)
static

Definition at line 107 of file mjpegenc.c.

Referenced by mjpeg_encode_init().

◆ ff_mjpeg_encode_stuffing()

int ff_mjpeg_encode_stuffing ( MPVEncContext *const  s)

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

Header + values + stuffing.

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

Definition at line 238 of file mjpegenc.c.

Referenced by write_slice_end().

◆ alloc_huffman()

static int alloc_huffman ( MJPEGEncContext *const  m2)
static

Definition at line 287 of file mjpegenc.c.

Referenced by mjpeg_encode_init().

◆ mjpeg_encode_close()

static av_cold int mjpeg_encode_close ( AVCodecContext avctx)
static

Definition at line 306 of file mjpegenc.c.

◆ mjpeg_encode_code()

static void 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 321 of file mjpegenc.c.

Referenced by mjpeg_encode_coef(), and record_block().

◆ mjpeg_encode_coef()

static void 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 336 of file mjpegenc.c.

Referenced by record_block().

◆ record_block()

static void record_block ( MPVEncContext *const  s,
int16_t  block[],
int  n 
)
static

Add the block's data into the JPEG buffer.

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

Definition at line 364 of file mjpegenc.c.

Referenced by mjpeg_record_mb().

◆ encode_block()

static void encode_block ( MPVEncContext *const  s,
int16_t  block[],
int  n 
)
static

Definition at line 407 of file mjpegenc.c.

Referenced by mjpeg_encode_mb().

◆ mjpeg_record_mb()

static void mjpeg_record_mb ( MPVEncContext *const  s,
int16_t  block[][64],
int  unused_x,
int  unused_y 
)
static

Definition at line 465 of file mjpegenc.c.

Referenced by mjpeg_encode_init().

◆ mjpeg_encode_mb()

static void mjpeg_encode_mb ( MPVEncContext *const  s,
int16_t  block[][64],
int  unused_x,
int  unused_y 
)
static

Definition at line 497 of file mjpegenc.c.

Referenced by mjpeg_encode_init().

◆ mjpeg_encode_init()

static av_cold int mjpeg_encode_init ( AVCodecContext avctx)
static

Definition at line 531 of file mjpegenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
#define AMV_OPTIONS_OFFSET
{ "huffman", "Huffman table strategy", OFFSET(huffman), AV_OPT_TYPE_INT, { .i64 = HUFFMAN_TABLE_OPTIMAL }, 0, NB_HUFFMAN_TABLE_OPTION - 1, VE, .unit = "huffman" },
{ "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_DEFAULT }, INT_MIN, INT_MAX, VE, .unit = "huffman" },
{ "optimal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_OPTIMAL }, INT_MIN, INT_MAX, VE, .unit = "huffman" },
{ "force_duplicated_matrix", "Always write luma and chroma matrix for mjpeg, useful for rtp streaming.", OFFSET(force_duplicated_matrix), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, VE },
{ NULL},
}

Definition at line 648 of file mjpegenc.c.

FF_MPV_COMMON_OPTS
#define FF_MPV_COMMON_OPTS
Definition: mpegvideoenc.h:309
HUFFMAN_TABLE_OPTIMAL
@ HUFFMAN_TABLE_OPTIMAL
Compute and use optimal Huffman tables.
Definition: mjpegenc.h:85
NB_HUFFMAN_TABLE_OPTION
@ NB_HUFFMAN_TABLE_OPTION
Definition: mjpegenc.h:86
NULL
#define NULL
Definition: coverity.c:32
HUFFMAN_TABLE_DEFAULT
@ HUFFMAN_TABLE_DEFAULT
Use the default Huffman tables.
Definition: mjpegenc.h:84
OFFSET
#define OFFSET(x)
Definition: mjpegenc.c:646
VE
#define VE
Definition: mjpegenc.c:647
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299