FFmpeg
Macros | Functions | Variables
ituh263enc.c File Reference
#include "config_components.h"
#include <limits.h>
#include "libavutil/attributes.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "mpegvideo.h"
#include "mpegvideodata.h"
#include "flvenc.h"
#include "mpegvideoenc.h"
#include "h263.h"
#include "h263enc.h"
#include "h263data.h"
#include "mathops.h"
#include "mpegutils.h"
#include "internal.h"

Go to the source code of this file.

Macros

#define UNI_MPEG4_ENC_INDEX(last, run, level)   ((last)*128*64 + (run)*128 + (level))
 
#define OFFSET(x)   offsetof(MpegEncContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

av_const int ff_h263_aspect_to_info (AVRational aspect)
 Return the 4 bit value that specifies the given aspect ratio. More...
 
void ff_h263_encode_picture_header (MpegEncContext *s)
 
void ff_h263_encode_gob_header (MpegEncContext *s, int mb_line)
 Encode a group of blocks header. More...
 
void ff_clean_h263_qscales (MpegEncContext *s)
 modify qscale so that encoding is actually possible in H.263 (limit difference to -2..2) More...
 
static void h263_encode_block (MpegEncContext *s, int16_t *block, int n)
 Encode an 8x8 block. More...
 
static void h263p_encode_umotion (PutBitContext *pb, int val)
 
static int h263_pred_dc (MpegEncContext *s, int n, int16_t **dc_val_ptr)
 
void ff_h263_encode_mb (MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
 
void ff_h263_encode_motion (PutBitContext *pb, int val, int f_code)
 
static av_cold void init_mv_penalty_and_fcode (void)
 
static av_cold void init_uni_h263_rl_tab (const RLTable *rl, uint8_t *len_tab)
 
static av_cold void h263_encode_init_static (void)
 
av_cold void ff_h263_encode_init (MpegEncContext *s)
 
void ff_h263_encode_mba (MpegEncContext *s)
 

Variables

static uint8_t mv_penalty [MAX_FCODE+1][MAX_DMV *2+1]
 Table of number of bits a motion vector component needs. More...
 
static uint8_t fcode_tab [MAX_MV *2+1]
 Minimal fcode that a motion vector component would need. More...
 
static uint8_t umv_fcode_tab [MAX_MV *2+1]
 Minimal fcode that a motion vector component would need in umv. More...
 
static uint8_t uni_h263_intra_aic_rl_len [64 *64 *2 *2]
 
static uint8_t uni_h263_inter_rl_len [64 *64 *2 *2]
 
static const uint8_t wrong_run [102]
 
static const int dquant_code [5] = {1,0,9,2,3}
 
static const AVOption h263_options []
 
static const AVClass h263_class
 
const FFCodec ff_h263_encoder
 
static const AVOption h263p_options []
 
static const AVClass h263p_class
 
const FFCodec ff_h263p_encoder
 

Detailed Description

H.263 bitstream encoder.

Definition in file ituh263enc.c.

Macro Definition Documentation

◆ UNI_MPEG4_ENC_INDEX

#define UNI_MPEG4_ENC_INDEX (   last,
  run,
  level 
)    ((last)*128*64 + (run)*128 + (level))

Definition at line 71 of file ituh263enc.c.

◆ OFFSET

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

Definition at line 887 of file ituh263enc.c.

◆ VE

Definition at line 888 of file ituh263enc.c.

Function Documentation

◆ ff_h263_aspect_to_info()

av_const int ff_h263_aspect_to_info ( AVRational  aspect)

Return the 4 bit value that specifies the given aspect ratio.

This may be one of the standard aspect ratios or it specifies that the aspect will be stored explicitly later.

Definition at line 94 of file ituh263enc.c.

Referenced by ff_h263_encode_picture_header(), and mpeg4_encode_vol_header().

◆ ff_h263_encode_picture_header()

void ff_h263_encode_picture_header ( MpegEncContext s)

Definition at line 108 of file ituh263enc.c.

Referenced by encode_picture().

◆ ff_h263_encode_gob_header()

void ff_h263_encode_gob_header ( MpegEncContext s,
int  mb_line 
)

Encode a group of blocks header.

Definition at line 246 of file ituh263enc.c.

Referenced by encode_thread().

◆ ff_clean_h263_qscales()

void ff_clean_h263_qscales ( MpegEncContext s)

modify qscale so that encoding is actually possible in H.263 (limit difference to -2..2)

Definition at line 272 of file ituh263enc.c.

Referenced by estimate_qp(), and ff_clean_mpeg4_qscales().

◆ h263_encode_block()

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

Encode an 8x8 block.

Parameters
blockthe 8x8 block
nblock index (0-3 are luma, 4-5 are chroma)

Definition at line 305 of file ituh263enc.c.

Referenced by ff_h263_encode_mb().

◆ h263p_encode_umotion()

static void h263p_encode_umotion ( PutBitContext pb,
int  val 
)
static

Definition at line 416 of file ituh263enc.c.

Referenced by ff_h263_encode_mb().

◆ h263_pred_dc()

static int h263_pred_dc ( MpegEncContext s,
int  n,
int16_t **  dc_val_ptr 
)
static

Definition at line 453 of file ituh263enc.c.

Referenced by ff_h263_encode_mb().

◆ ff_h263_encode_mb()

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

Definition at line 494 of file ituh263enc.c.

Referenced by encode_mb_internal().

◆ ff_h263_encode_motion()

void ff_h263_encode_motion ( PutBitContext pb,
int  val,
int  f_code 
)

Definition at line 692 of file ituh263enc.c.

Referenced by ff_h263_encode_motion_vector(), and svq1_encode_plane().

◆ init_mv_penalty_and_fcode()

static av_cold void init_mv_penalty_and_fcode ( void  )
static

Definition at line 720 of file ituh263enc.c.

Referenced by h263_encode_init_static().

◆ init_uni_h263_rl_tab()

static av_cold void init_uni_h263_rl_tab ( const RLTable rl,
uint8_t *  len_tab 
)
static

Definition at line 762 of file ituh263enc.c.

Referenced by h263_encode_init_static().

◆ h263_encode_init_static()

static av_cold void h263_encode_init_static ( void  )
static

Definition at line 803 of file ituh263enc.c.

Referenced by ff_h263_encode_init().

◆ ff_h263_encode_init()

av_cold void ff_h263_encode_init ( MpegEncContext s)

Definition at line 816 of file ituh263enc.c.

Referenced by encode_init(), ff_mpv_encode_init(), and svq1_encode_init().

◆ ff_h263_encode_mba()

void ff_h263_encode_mba ( MpegEncContext s)

Variable Documentation

◆ mv_penalty

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

◆ fcode_tab

uint8_t fcode_tab[MAX_MV *2+1]
static

Minimal fcode that a motion vector component would need.

Definition at line 57 of file ituh263enc.c.

Referenced by ff_get_best_fcode(), ff_h263_encode_init(), and init_mv_penalty_and_fcode().

◆ umv_fcode_tab

uint8_t umv_fcode_tab[MAX_MV *2+1]
static

Minimal fcode that a motion vector component would need in umv.

All entries in this table are 1.

Definition at line 63 of file ituh263enc.c.

Referenced by ff_h263_encode_init(), and init_mv_penalty_and_fcode().

◆ uni_h263_intra_aic_rl_len

uint8_t uni_h263_intra_aic_rl_len[64 *64 *2 *2]
static

Definition at line 67 of file ituh263enc.c.

Referenced by ff_h263_encode_init(), and h263_encode_init_static().

◆ uni_h263_inter_rl_len

uint8_t uni_h263_inter_rl_len[64 *64 *2 *2]
static

Definition at line 68 of file ituh263enc.c.

Referenced by ff_h263_encode_init(), and h263_encode_init_static().

◆ wrong_run

const uint8_t wrong_run[102]
static
Initial value:
= {
1, 2, 3, 5, 4, 10, 9, 8,
11, 15, 17, 16, 23, 22, 21, 20,
19, 18, 25, 24, 27, 26, 11, 7,
6, 1, 2, 13, 2, 2, 2, 2,
6, 12, 3, 9, 1, 3, 4, 3,
7, 4, 1, 1, 5, 5, 14, 6,
1, 7, 1, 8, 1, 1, 1, 1,
10, 1, 1, 5, 9, 17, 25, 24,
29, 33, 32, 41, 2, 23, 28, 31,
3, 22, 30, 4, 27, 40, 8, 26,
6, 39, 7, 38, 16, 37, 15, 10,
11, 12, 13, 14, 1, 21, 20, 18,
19, 2, 1, 34, 35, 36
}

Definition at line 73 of file ituh263enc.c.

Referenced by h263_encode_block().

◆ dquant_code

const int dquant_code[5] = {1,0,9,2,3}
static

Definition at line 298 of file ituh263enc.c.

Referenced by ff_h263_encode_mb().

◆ h263_options

const AVOption h263_options[]
static
Initial value:
= {
{ "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "mb_info", "emit macroblock info for RFC 2190 packetization, the parameter value is the maximum payload size", OFFSET(mb_info), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ NULL },
}

Definition at line 889 of file ituh263enc.c.

◆ h263_class

const AVClass h263_class
static
Initial value:
= {
.class_name = "H.263 encoder",
.item_name = av_default_item_name,
.option = h263_options,
}

Definition at line 897 of file ituh263enc.c.

◆ ff_h263_encoder

const FFCodec ff_h263_encoder
Initial value:
= {
.p.name = "h263",
CODEC_LONG_NAME("H.263 / H.263-1996"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE},
.p.priv_class = &h263_class,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.priv_data_size = sizeof(MpegEncContext),
}

Definition at line 904 of file ituh263enc.c.

◆ h263p_options

const AVOption h263p_options[]
static
Initial value:
= {
{ "umv", "Use unlimited motion vectors.", OFFSET(umvplus), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "structured_slices", "Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE},
{ NULL },
}

Definition at line 919 of file ituh263enc.c.

◆ h263p_class

const AVClass h263p_class
static
Initial value:
= {
.class_name = "H.263p encoder",
.item_name = av_default_item_name,
.option = h263p_options,
}

Definition at line 928 of file ituh263enc.c.

◆ ff_h263p_encoder

const FFCodec ff_h263p_encoder
Initial value:
= {
.p.name = "h263p",
CODEC_LONG_NAME("H.263+ / H.263-1998 / H.263 version 2"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
.p.priv_class = &h263p_class,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.priv_data_size = sizeof(MpegEncContext),
}

Definition at line 935 of file ituh263enc.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
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: codec_internal.h:42
h263p_options
static const AVOption h263p_options[]
Definition: ituh263enc.c:919
VE
#define VE
Definition: ituh263enc.c:888
OFFSET
#define OFFSET(x)
Definition: ituh263enc.c:887
FF_MPV_COMMON_MOTION_EST_OPTS
#define FF_MPV_COMMON_MOTION_EST_OPTS
Definition: mpegvideoenc.h:108
ff_mpv_encode_picture
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet)
Definition: mpegvideo_enc.c:1756
FF_MPV_COMMON_OPTS
#define FF_MPV_COMMON_OPTS
Definition: mpegvideoenc.h:65
h263p_class
static const AVClass h263p_class
Definition: ituh263enc.c:928
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:296
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
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:73
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
ff_mpv_encode_end
av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
Definition: mpegvideo_enc.c:987
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
AV_CODEC_ID_H263
@ AV_CODEC_ID_H263
Definition: codec_id.h:56
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:114
h263_options
static const AVOption h263_options[]
Definition: ituh263enc.c:889
AV_CODEC_ID_H263P
@ AV_CODEC_ID_H263P
Definition: codec_id.h:71
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ff_mpv_encode_init
av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
Definition: mpegvideo_enc.c:310
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:67
h263_class
static const AVClass h263_class
Definition: ituh263enc.c:897
mb_info
Definition: cinepakenc.c:88