FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
mpeg12enc.c File Reference

MPEG1/2 encoder. More...

#include "avcodec.h"
#include "mathops.h"
#include "mpegvideo.h"
#include "mpeg12.h"
#include "mpeg12data.h"
#include "bytestream.h"
#include "libavutil/attributes.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/avassert.h"
#include "libavutil/timecode.h"

Go to the source code of this file.

Macros

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

Functions

static void mpeg1_encode_block (MpegEncContext *s, int16_t *block, int component)
 
static void mpeg1_encode_motion (MpegEncContext *s, int val, int f_or_b_code)
 
static av_cold void init_uni_ac_vlc (RLTable *rl, uint8_t *uni_ac_vlc_len)
 
static int find_frame_rate_index (MpegEncContext *s)
 
static av_cold int encode_init (AVCodecContext *avctx)
 
static void put_header (MpegEncContext *s, int header)
 
static void mpeg1_encode_sequence_header (MpegEncContext *s)
 
static void encode_mb_skip_run (MpegEncContext *s, int run)
 
static av_always_inline void put_qscale (MpegEncContext *s)
 
void ff_mpeg1_encode_slice_header (MpegEncContext *s)
 
void ff_mpeg1_encode_picture_header (MpegEncContext *s, int picture_number)
 
static void put_mb_modes (MpegEncContext *s, int n, int bits, int has_mv, int field_motion)
 
static av_always_inline void mpeg1_encode_mb_internal (MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y, int mb_block_count)
 
void ff_mpeg1_encode_mb (MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
 
av_cold void ff_mpeg1_encode_init (MpegEncContext *s)
 
static void encode_dc (MpegEncContext *s, int diff, int component)
 
 mpeg12_class (1)
 

Variables

static const uint8_t inv_non_linear_qscale [13]
 
static const uint8_t svcd_scan_offset_placeholder [14]
 
static uint8_t mv_penalty [MAX_FCODE+1][MAX_MV *2+1]
 
static uint8_t fcode_tab [MAX_MV *2+1]
 
static uint8_t uni_mpeg1_ac_vlc_len [64 *64 *2]
 
static uint8_t uni_mpeg2_ac_vlc_len [64 *64 *2]
 
static uint32_t mpeg1_lum_dc_uni [512]
 
static uint32_t mpeg1_chr_dc_uni [512]
 
static uint8_t mpeg1_index_run [2][64]
 
static int8_t mpeg1_max_level [2][64]
 
static const AVOption mpeg1_options []
 
static const AVOption mpeg2_options []
 
AVCodec ff_mpeg2video_encoder
 

Detailed Description

MPEG1/2 encoder.

Definition in file mpeg12enc.c.

Macro Definition Documentation

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

Definition at line 962 of file mpeg12enc.c.

Definition at line 963 of file mpeg12enc.c.

#define COMMON_OPTS
Value:
{ "gop_timecode", "MPEG GOP Timecode in hh:mm:ss[:;.]ff format", OFFSET(tc_opt_str), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, VE },\
{ "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },\
{ "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE}, \
{ "scan_offset", "Reserve space for SVCD scan offset user data.", OFFSET(scan_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },

Definition at line 964 of file mpeg12enc.c.

#define mpeg12_class (   x)
Value:
static const AVClass mpeg## x ##_class = {\
.class_name = "mpeg" #x "video encoder",\
.item_name = av_default_item_name,\
.option = mpeg## x ##_options,\
.version = LIBAVUTIL_VERSION_INT,\
};

Definition at line 984 of file mpeg12enc.c.

Function Documentation

static void mpeg1_encode_block ( MpegEncContext s,
int16_t *  block,
int  component 
)
static

Definition at line 882 of file mpeg12enc.c.

Referenced by mpeg1_encode_mb_internal().

static void mpeg1_encode_motion ( MpegEncContext s,
int  val,
int  f_or_b_code 
)
static

Definition at line 707 of file mpeg12enc.c.

Referenced by mpeg1_encode_mb_internal().

static av_cold void init_uni_ac_vlc ( RLTable rl,
uint8_t uni_ac_vlc_len 
)
static

Definition at line 73 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

static int find_frame_rate_index ( MpegEncContext s)
static

Definition at line 111 of file mpeg12enc.c.

Referenced by encode_init().

static av_cold int encode_init ( AVCodecContext avctx)
static

Definition at line 146 of file mpeg12enc.c.

Referenced by mpeg12_class().

static void put_header ( MpegEncContext s,
int  header 
)
static
static void mpeg1_encode_sequence_header ( MpegEncContext s)
static

Definition at line 230 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_picture_header().

static void encode_mb_skip_run ( MpegEncContext s,
int  run 
)
inlinestatic

Definition at line 345 of file mpeg12enc.c.

Referenced by mpeg1_encode_mb_internal().

static av_always_inline void put_qscale ( MpegEncContext s)
static

Definition at line 354 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_slice_header(), and mpeg1_encode_mb_internal().

void ff_mpeg1_encode_slice_header ( MpegEncContext s)

Definition at line 364 of file mpeg12enc.c.

Referenced by encode_thread(), and ff_mpeg1_encode_picture_header().

void ff_mpeg1_encode_picture_header ( MpegEncContext s,
int  picture_number 
)

Definition at line 375 of file mpeg12enc.c.

Referenced by encode_picture().

static void put_mb_modes ( MpegEncContext s,
int  n,
int  bits,
int  has_mv,
int  field_motion 
)
inlinestatic

Definition at line 464 of file mpeg12enc.c.

Referenced by mpeg1_encode_mb_internal().

static av_always_inline void mpeg1_encode_mb_internal ( MpegEncContext s,
int16_t  block[6][64],
int  motion_x,
int  motion_y,
int  mb_block_count 
)
static

Definition at line 475 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_mb().

void ff_mpeg1_encode_mb ( MpegEncContext s,
int16_t  block[6][64],
int  motion_x,
int  motion_y 
)

Definition at line 700 of file mpeg12enc.c.

Referenced by encode_mb_internal().

av_cold void ff_mpeg1_encode_init ( MpegEncContext s)

Definition at line 747 of file mpeg12enc.c.

Referenced by ff_MPV_encode_init().

static void encode_dc ( MpegEncContext s,
int  diff,
int  component 
)
inlinestatic

Definition at line 845 of file mpeg12enc.c.

Referenced by mpeg1_encode_block().

mpeg12_class ( )

Definition at line 992 of file mpeg12enc.c.

Variable Documentation

const uint8_t inv_non_linear_qscale[13]
static
Initial value:
= {
0, 2, 4, 6, 8,
9,10,11,12,13,14,15,16,
}

Definition at line 42 of file mpeg12enc.c.

Referenced by put_qscale().

const uint8_t svcd_scan_offset_placeholder[14]
static
Initial value:
= {
0x10, 0x0E,
0x00, 0x80, 0x81,
0x00, 0x80, 0x81,
0xff, 0xff, 0xff,
0xff, 0xff, 0xff,
}

Definition at line 47 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_picture_header().

uint8_t mv_penalty[MAX_FCODE+1][MAX_MV *2+1]
static

Definition at line 60 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

uint8_t fcode_tab[MAX_MV *2+1]
static

Definition at line 61 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

uint8_t uni_mpeg1_ac_vlc_len[64 *64 *2]
static

Definition at line 63 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

uint8_t uni_mpeg2_ac_vlc_len[64 *64 *2]
static

Definition at line 64 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

uint32_t mpeg1_lum_dc_uni[512]
static

Definition at line 67 of file mpeg12enc.c.

Referenced by encode_dc(), and ff_mpeg1_encode_init().

uint32_t mpeg1_chr_dc_uni[512]
static

Definition at line 68 of file mpeg12enc.c.

Referenced by encode_dc(), and ff_mpeg1_encode_init().

uint8_t mpeg1_index_run[2][64]
static

Definition at line 70 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init(), and mpeg1_encode_block().

int8_t mpeg1_max_level[2][64]
static

Definition at line 71 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init(), and mpeg1_encode_block().

const AVOption mpeg1_options[]
static
Initial value:

Definition at line 970 of file mpeg12enc.c.

const AVOption mpeg2_options[]
static
Initial value:
= {
{ "non_linear_quant", "Use nonlinear quantizer.", OFFSET(q_scale_type), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ NULL },
}

Definition at line 976 of file mpeg12enc.c.

AVCodec ff_mpeg2video_encoder
Initial value:
= {
.name = "mpeg2video",
.priv_data_size = sizeof(MpegEncContext),
.supported_framerates = ff_mpeg2_frame_rate_tab,
.pix_fmts = (const enum AVPixelFormat[]){
},
.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video"),
.priv_class = &mpeg2_class,
}

Definition at line 1011 of file mpeg12enc.c.