FFmpeg  4.3
Macros | Functions | Variables
mpeg12enc.c File Reference
#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"
#include "profiles.h"

Go to the source code of this file.

Macros

#define A53_MAX_CC_COUNT   0x1f
 
#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

◆ A53_MAX_CC_COUNT

#define A53_MAX_CC_COUNT   0x1f

Definition at line 65 of file mpeg12enc.c.

◆ OFFSET

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

Definition at line 1135 of file mpeg12enc.c.

◆ VE

Definition at line 1136 of file mpeg12enc.c.

◆ COMMON_OPTS

#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}, 0, 0, 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}, \

Definition at line 1137 of file mpeg12enc.c.

◆ mpeg12_class

#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 1175 of file mpeg12enc.c.

Function Documentation

◆ init_uni_ac_vlc()

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

Definition at line 67 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

◆ find_frame_rate_index()

static int find_frame_rate_index ( MpegEncContext s)
static

Definition at line 102 of file mpeg12enc.c.

Referenced by encode_init().

◆ encode_init()

static av_cold int encode_init ( AVCodecContext avctx)
static

Definition at line 141 of file mpeg12enc.c.

Referenced by mpeg12_class().

◆ put_header()

static void put_header ( MpegEncContext s,
int  header 
)
static

◆ mpeg1_encode_sequence_header()

static void mpeg1_encode_sequence_header ( MpegEncContext s)
static

Definition at line 242 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_picture_header().

◆ encode_mb_skip_run()

static void encode_mb_skip_run ( MpegEncContext s,
int  run 
)
inlinestatic

Definition at line 397 of file mpeg12enc.c.

Referenced by mpeg1_encode_mb_internal().

◆ put_qscale()

static av_always_inline void put_qscale ( MpegEncContext s)
static

Definition at line 407 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_slice_header(), and mpeg1_encode_mb_internal().

◆ ff_mpeg1_encode_slice_header()

void ff_mpeg1_encode_slice_header ( MpegEncContext s)

Definition at line 412 of file mpeg12enc.c.

Referenced by encode_thread(), and ff_mpeg1_encode_picture_header().

◆ ff_mpeg1_encode_picture_header()

void ff_mpeg1_encode_picture_header ( MpegEncContext s,
int  picture_number 
)

Definition at line 426 of file mpeg12enc.c.

Referenced by encode_picture().

◆ put_mb_modes()

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

Definition at line 585 of file mpeg12enc.c.

Referenced by mpeg1_encode_mb_internal().

◆ mpeg1_encode_motion()

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

Definition at line 598 of file mpeg12enc.c.

Referenced by mpeg1_encode_mb_internal().

◆ encode_dc()

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

Definition at line 637 of file mpeg12enc.c.

Referenced by mpeg1_encode_block().

◆ mpeg1_encode_block()

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

Definition at line 671 of file mpeg12enc.c.

Referenced by mpeg1_encode_mb_internal().

◆ 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 750 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_mb().

◆ 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 1028 of file mpeg12enc.c.

Referenced by encode_mb_internal().

◆ ff_mpeg1_encode_init()

av_cold void ff_mpeg1_encode_init ( MpegEncContext s)

Definition at line 1037 of file mpeg12enc.c.

Referenced by ff_mpv_encode_init().

◆ mpeg12_class()

mpeg12_class ( )

Definition at line 1183 of file mpeg12enc.c.

Variable Documentation

◆ svcd_scan_offset_placeholder

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 46 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_picture_header().

◆ mv_penalty

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

Definition at line 51 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

◆ fcode_tab

uint8_t fcode_tab[MAX_MV *2+1]
static

Definition at line 52 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

◆ uni_mpeg1_ac_vlc_len

uint8_t uni_mpeg1_ac_vlc_len[64 *64 *2]
static

Definition at line 54 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

◆ uni_mpeg2_ac_vlc_len

uint8_t uni_mpeg2_ac_vlc_len[64 *64 *2]
static

Definition at line 55 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init().

◆ mpeg1_lum_dc_uni

uint32_t mpeg1_lum_dc_uni[512]
static

Definition at line 59 of file mpeg12enc.c.

Referenced by encode_dc(), and ff_mpeg1_encode_init().

◆ mpeg1_chr_dc_uni

uint32_t mpeg1_chr_dc_uni[512]
static

Definition at line 60 of file mpeg12enc.c.

Referenced by encode_dc(), and ff_mpeg1_encode_init().

◆ mpeg1_index_run

uint8_t mpeg1_index_run[2][64]
static

Definition at line 62 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init(), and mpeg1_encode_block().

◆ mpeg1_max_level

int8_t mpeg1_max_level[2][64]
static

Definition at line 63 of file mpeg12enc.c.

Referenced by ff_mpeg1_encode_init(), and mpeg1_encode_block().

◆ mpeg1_options

const AVOption mpeg1_options[]
static
Initial value:

Definition at line 1149 of file mpeg12enc.c.

◆ mpeg2_options

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" },
{ "video_format", "Video_format in the sequence_display_extension indicating the source of the video.", OFFSET(video_format), AV_OPT_TYPE_INT, { .i64 = VIDEO_FORMAT_UNSPECIFIED }, 0, 7, VE, "video_format" },
{ "component", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VIDEO_FORMAT_COMPONENT }, 0, 0, VE, "video_format" },
{ "pal", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VIDEO_FORMAT_PAL }, 0, 0, VE, "video_format" },
{ "ntsc", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VIDEO_FORMAT_NTSC }, 0, 0, VE, "video_format" },
{ "secam", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VIDEO_FORMAT_SECAM }, 0, 0, VE, "video_format" },
{ "mac", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VIDEO_FORMAT_MAC }, 0, 0, VE, "video_format" },
{ "unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = VIDEO_FORMAT_UNSPECIFIED}, 0, 0, VE, "video_format" },
{ NULL },
}

Definition at line 1155 of file mpeg12enc.c.

◆ ff_mpeg2video_encoder

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,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.priv_class = &mpeg2_class,
}

Definition at line 1203 of file mpeg12enc.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
VIDEO_FORMAT_SECAM
#define VIDEO_FORMAT_SECAM
Definition: mpegvideo.h:477
ff_mpeg2_frame_rate_tab
const AVRational ff_mpeg2_frame_rate_tab[]
Definition: mpeg12data.c:308
x
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo x
Definition: fate.txt:150
COMMON_OPTS
#define COMMON_OPTS
Definition: mpeg12enc.c:1137
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:224
ff_mpv_encode_picture
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: mpegvideo_enc.c:1819
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
NULL
#define NULL
Definition: coverity.c:32
VIDEO_FORMAT_MAC
#define VIDEO_FORMAT_MAC
Definition: mpegvideo.h:478
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
VE
#define VE
Definition: mpeg12enc.c:1136
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:186
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:110
VIDEO_FORMAT_PAL
#define VIDEO_FORMAT_PAL
Definition: mpegvideo.h:475
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
ff_mpv_encode_end
int ff_mpv_encode_end(AVCodecContext *avctx)
Definition: mpegvideo_enc.c:1067
FF_MPEG2_PROFILE_OPTS
#define FF_MPEG2_PROFILE_OPTS
Definition: profiles.h:46
VIDEO_FORMAT_COMPONENT
#define VIDEO_FORMAT_COMPONENT
Definition: mpegvideo.h:474
OFFSET
#define OFFSET(x)
Definition: mpeg12enc.c:1135
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
AV_CODEC_CAP_DELAY
#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: codec.h:75
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
encode_init
static av_cold int encode_init(AVCodecContext *avctx)
Definition: mpeg12enc.c:141
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:227
AV_CODEC_ID_MPEG2VIDEO
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition: codec_id.h:51
FF_MPV_COMMON_OPTS
#define FF_MPV_COMMON_OPTS
Definition: mpegvideo.h:616
VIDEO_FORMAT_UNSPECIFIED
#define VIDEO_FORMAT_UNSPECIFIED
Definition: mpegvideo.h:479
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:81
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232
VIDEO_FORMAT_NTSC
#define VIDEO_FORMAT_NTSC
Definition: mpegvideo.h:476