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

MPEG-1/2 encoder. More...

#include <stdint.h>
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/timecode.h"
#include "libavutil/stereo3d.h"
#include "avcodec.h"
#include "bytestream.h"
#include "mathops.h"
#include "mpeg12.h"
#include "mpeg12data.h"
#include "mpegutils.h"
#include "mpegvideo.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 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 void mpeg1_encode_motion (MpegEncContext *s, int val, int f_or_b_code)
 
static void encode_dc (MpegEncContext *s, int diff, int component)
 
static void mpeg1_encode_block (MpegEncContext *s, int16_t *block, int n)
 
static av_always_inline void mpeg1_encode_mb_internal (MpegEncContext *s, int16_t block[8][64], int motion_x, int motion_y, int mb_block_count)
 
void ff_mpeg1_encode_mb (MpegEncContext *s, int16_t block[8][64], int motion_x, int motion_y)
 
av_cold void ff_mpeg1_encode_init (MpegEncContext *s)
 
 mpeg12_class (1)
 

Variables

static const uint8_t svcd_scan_offset_placeholder []
 
static uint8_t mv_penalty [MAX_FCODE+1][MAX_DMV *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

MPEG-1/2 encoder.

Definition in file mpeg12enc.c.

Macro Definition Documentation

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

Definition at line 1100 of file mpeg12enc.c.

Definition at line 1101 of file mpeg12enc.c.

#define COMMON_OPTS
Value:
{ "gop_timecode", "MPEG GOP Timecode in hh:mm:ss[:;.]ff format. Overrides timecode_frame_start.", \
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_BOOL, { .i64 = 0 }, 0, 1, VE }, \
{ "drop_frame_timecode", "Timecode is in drop frame format.", \
OFFSET(drop_frame_timecode), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, \
{ "scan_offset", "Reserve space for SVCD scan offset user data.", \
OFFSET(scan_offset), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, \
{ "timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", \
OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = -1 }, -1, INT64_MAX, VE}, \
#define NULL
Definition: coverity.c:32
#define VE
Definition: mpeg12enc.c:1101
#define OFFSET(x)
Definition: mpeg12enc.c:1100

Definition at line 1102 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, \
};
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
av_default_item_name
Describe the class of an AVClass context structure.
Definition: log.h:67

Definition at line 1132 of file mpeg12enc.c.

Function Documentation

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

Definition at line 64 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

static int find_frame_rate_index ( MpegEncContext s)
static

Definition at line 99 of file mpeg12enc.c.

Referenced by encode_init().

static av_cold int encode_init ( AVCodecContext avctx)
static

Definition at line 138 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 238 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 392 of file mpeg12enc.c.

Referenced by mpeg1_encode_mb_internal().

static av_always_inline void put_qscale ( MpegEncContext s)
static

Definition at line 402 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 407 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 421 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 550 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 563 of file mpeg12enc.c.

Referenced by mpeg1_encode_mb_internal().

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

Definition at line 602 of file mpeg12enc.c.

Referenced by mpeg1_encode_block().

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

Definition at line 636 of file mpeg12enc.c.

Referenced by mpeg1_encode_mb_internal().

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

Definition at line 715 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_mb().

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

Definition at line 993 of file mpeg12enc.c.

Referenced by encode_mb_internal().

av_cold void ff_mpeg1_encode_init ( MpegEncContext s)

Definition at line 1002 of file mpeg12enc.c.

Referenced by ff_mpv_encode_init().

mpeg12_class ( )

Definition at line 1140 of file mpeg12enc.c.

Variable Documentation

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

Definition at line 45 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_picture_header().

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

Definition at line 50 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

uint8_t fcode_tab[MAX_MV *2+1]
static

Definition at line 51 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

uint8_t uni_mpeg1_ac_vlc_len[64 *64 *2]
static

Definition at line 53 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

uint8_t uni_mpeg2_ac_vlc_len[64 *64 *2]
static

Definition at line 54 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

uint32_t mpeg1_lum_dc_uni[512]
static

Definition at line 58 of file mpeg12enc.c.

Referenced by encode_dc(), and ff_mpeg1_encode_init().

uint32_t mpeg1_chr_dc_uni[512]
static

Definition at line 59 of file mpeg12enc.c.

Referenced by encode_dc(), and ff_mpeg1_encode_init().

uint8_t mpeg1_index_run[2][64]
static

Definition at line 61 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 62 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init(), and mpeg1_encode_block().

const AVOption mpeg1_options[]
static
Initial value:
= {
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define FF_MPV_COMMON_OPTS
Definition: mpegvideo.h:605
#define COMMON_OPTS
Definition: mpeg12enc.c:1102

Definition at line 1114 of file mpeg12enc.c.

const AVOption mpeg2_options[]
static
Initial value:
= {
{ "non_linear_quant", "Use nonlinear quantizer.", OFFSET(q_scale_type), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "seq_disp_ext", "Write sequence_display_extension blocks.", OFFSET(seq_disp_ext), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE, "seq_disp_ext" },
{ "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, VE, "seq_disp_ext" },
{ "never", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, VE, "seq_disp_ext" },
{ "always", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, VE, "seq_disp_ext" },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define FF_MPV_COMMON_OPTS
Definition: mpegvideo.h:605
#define VE
Definition: mpeg12enc.c:1101
#define COMMON_OPTS
Definition: mpeg12enc.c:1102
#define OFFSET(x)
Definition: mpeg12enc.c:1100

Definition at line 1120 of file mpeg12enc.c.

AVCodec ff_mpeg2video_encoder
Initial value:
= {
.name = "mpeg2video",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video"),
.priv_data_size = sizeof(MpegEncContext),
.supported_framerates = ff_mpeg2_frame_rate_tab,
.priv_class = &mpeg2_class,
}
const AVRational ff_mpeg2_frame_rate_tab[]
Definition: mpeg12data.c:308
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: avcodec.h:1019
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:219
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: avcodec.h:1061
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
static av_cold int encode_init(AVCodecContext *avctx)
Definition: mpeg12enc.c:138
MpegEncContext.
Definition: mpegvideo.h:78
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
int ff_mpv_encode_end(AVCodecContext *avctx)
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60

Definition at line 1159 of file mpeg12enc.c.