64#define UNI_MPEG4_ENC_INDEX(last, run, level) ((last) * 128 * 64 + (run) * 128 + (level))
92 int block_last_index,
const uint8_t scantable[64])
98 for (j = 1; j <= block_last_index; j++) {
99 const int index = scantable[j];
103 if ((
level & (~127)) == 0) {
104 if (j < block_last_index)
109 rate +=
s->ac_esc_length;
127 const int dir[6],
const uint8_t *st[6],
128 const int zigzag_last_index[6])
131 memcpy(
s->c.block_last_index, zigzag_last_index,
sizeof(
int) * 6);
133 for (n = 0; n < 6; n++) {
134 int16_t *ac_val = &
s->c.ac_val[0][0] +
s->c.block_index[n] * 16;
136 st[n] =
s->c.intra_scantable.permutated;
139 for (
i = 1;
i < 8;
i++)
140 block[n][
s->c.idsp.idct_permutation[
i]] = ac_val[
i + 8];
143 for (
i = 1;
i < 8;
i++)
144 block[n][
s->c.idsp.idct_permutation[
i << 3]] = ac_val[
i];
156 const int16_t *
const dc_val =
s->dc_val +
s->block_index[n];
157 const int wrap =
s->block_wrap[n];
162 const int a = dc_val[-1];
163 const int b = dc_val[-1 -
wrap];
164 const int c = dc_val[-
wrap];
188 const int dir[6],
const uint8_t *st[6],
189 int zigzag_last_index[6])
193 const int8_t *
const qscale_table =
s->c.cur_pic.qscale_table;
195 memcpy(zigzag_last_index,
s->c.block_last_index,
sizeof(
int) * 6);
197 for (n = 0; n < 6; n++) {
198 int16_t *ac_val, *ac_val1;
201 s->c.intra_scantable.permutated);
203 ac_val = &
s->c.ac_val[0][0] +
s->c.block_index[n] * 16;
206 const int xy =
s->c.mb_x +
s->c.mb_y *
s->c.mb_stride -
s->c.mb_stride;
208 ac_val -=
s->c.block_wrap[n] * 16;
209 if (
s->c.first_slice_line ||
s->c.qscale == qscale_table[xy] || n == 2 || n == 3) {
211 for (
i = 1;
i < 8;
i++) {
212 const int level =
block[n][
s->c.idsp.idct_permutation[
i]];
213 block[n][
s->c.idsp.idct_permutation[
i]] =
level - ac_val[
i + 8];
214 ac_val1[
i] =
block[n][
s->c.idsp.idct_permutation[
i << 3]];
219 for (
i = 1;
i < 8;
i++) {
220 const int level =
block[n][
s->c.idsp.idct_permutation[
i]];
222 ac_val1[
i] =
block[n][
s->c.idsp.idct_permutation[
i << 3]];
226 st[n] =
s->permutated_intra_h_scantable;
228 const int xy =
s->c.mb_x - 1 +
s->c.mb_y *
s->c.mb_stride;
231 if (
s->c.mb_x == 0 ||
s->c.qscale == qscale_table[xy] || n == 1 || n == 3) {
233 for (
i = 1;
i < 8;
i++) {
234 const int level =
block[n][
s->c.idsp.idct_permutation[
i << 3]];
235 block[n][
s->c.idsp.idct_permutation[
i << 3]] =
level - ac_val[
i];
237 ac_val1[
i + 8] =
block[n][
s->c.idsp.idct_permutation[
i]];
241 for (
i = 1;
i < 8;
i++) {
242 const int level =
block[n][
s->c.idsp.idct_permutation[
i << 3]];
245 ac_val1[
i + 8] =
block[n][
s->c.idsp.idct_permutation[
i]];
248 st[n] =
s->permutated_intra_v_scantable;
251 for (
i = 63;
i > 0;
i--)
254 s->c.block_last_index[n] =
i;
275 int8_t *
const qscale_table =
s->c.cur_pic.qscale_table;
280 for (
int i = 0;
i <
s->c.mb_num;
i++) {
281 int mb_xy =
s->c.mb_index2xy[
i];
282 odd += qscale_table[mb_xy] & 1;
285 if (2 * odd >
s->c.mb_num)
290 for (
int i = 0;
i <
s->c.mb_num;
i++) {
291 int mb_xy =
s->c.mb_index2xy[
i];
292 if ((qscale_table[mb_xy] & 1) != odd)
293 qscale_table[mb_xy]++;
294 if (qscale_table[mb_xy] > 31)
295 qscale_table[mb_xy] = 31;
298 for (
int i = 1;
i <
s->c.mb_num;
i++) {
299 int mb_xy =
s->c.mb_index2xy[
i];
300 if (qscale_table[mb_xy] != qscale_table[
s->c.mb_index2xy[
i - 1]] &&
329 const int last_index,
int i,
330 const uint8_t *
const scan_table,
332 const uint32_t *
const bits_tab,
333 const uint8_t *
const len_tab)
335 int last_non_zero =
i - 1;
338 for (;
i < last_index;
i++) {
341 int run =
i - last_non_zero - 1;
343 if ((
level & (~127)) == 0) {
348 7 + 2 + 1 + 6 + 1 + 12 + 1,
349 (3 << 23) + (3 << 21) + (0 << 20) + (
run << 14) +
350 (1 << 13) + (((
level - 64) & 0xfff) << 1) + 1);
357 int run =
i - last_non_zero - 1;
359 if ((
level & (~127)) == 0) {
364 7 + 2 + 1 + 6 + 1 + 12 + 1,
365 (3 << 23) + (3 << 21) + (1 << 20) + (
run << 14) +
366 (1 << 13) + (((
level - 64) & 0xfff) << 1) + 1);
372 const int16_t
block[6][64],
376 for (
int n = 0; n < 6; ++n) {
377 const int last_index =
s->c.block_last_index[n];
382 s->c.intra_scantable.permutated, ac_pb,
388 const int16_t
block[6][64],
389 const int intra_dc[6],
390 const uint8_t *
const *scan_table,
395 for (
int n = 0; n < 6; ++n) {
398 const int last_index =
s->c.block_last_index[n];
403 scan_table[n], ac_pb,
409 int motion_x,
int motion_y,
int mb_type)
417 for (
i = 0;
i < 6;
i++) {
418 if (
s->coded_score[
i] < 0) {
419 score +=
s->coded_score[
i];
426 if ((motion_x | motion_y |
s->dquant | mb_type) == 0)
429 zero_score *= lambda;
430 if (zero_score <= score)
434 for (
i = 0;
i < 6;
i++) {
435 if (
s->c.block_last_index[
i] >= 0 && ((cbp >> (5 -
i)) & 1) == 0) {
436 s->c.block_last_index[
i] = -1;
437 s->c.bdsp.clear_block(
s->block[
i]);
441 for (
i = 0;
i < 6;
i++) {
442 if (
s->c.block_last_index[
i] >= 0)
453 int motion_x,
int motion_y)
455 int cbpc, cbpy, pred_x, pred_y;
461 if (!
s->c.mb_intra) {
466 static const int mb_type_table[8] = { -1, 3, 2, 1, -1, -1, -1, 0 };
467 int mb_type = mb_type_table[
s->c.mv_dir];
469 if (
s->c.mb_x == 0) {
470 for (
i = 0;
i < 2;
i++)
471 s->c.last_mv[
i][0][0] =
472 s->c.last_mv[
i][0][1] =
473 s->c.last_mv[
i][1][0] =
474 s->c.last_mv[
i][1][1] = 0;
482 if (
s->c.next_pic.mbskip_table[
s->c.mb_y *
s->c.mb_stride +
s->c.mb_x]) {
486 s->c.mv[1][0][1] = 0;
488 s->c.qscale -=
s->dquant;
496 if ((cbp | motion_x | motion_y | mb_type) == 0) {
502 if (interleaved_stats) {
515 if (cbp && mb_type) {
521 s->c.qscale -=
s->dquant;
523 if (!
s->c.progressive_sequence) {
530 if (interleaved_stats)
541 s->c.mv[0][0][0] -
s->c.last_mv[0][0][0],
542 s->c.mv[0][0][1] -
s->c.last_mv[0][0][1],
544 s->c.last_mv[0][0][0] =
545 s->c.last_mv[0][1][0] =
s->c.mv[0][0][0];
546 s->c.last_mv[0][0][1] =
547 s->c.last_mv[0][1][1] =
s->c.mv[0][0][1];
551 s->c.mv[1][0][0] -
s->c.last_mv[1][0][0],
552 s->c.mv[1][0][1] -
s->c.last_mv[1][0][1],
554 s->c.last_mv[1][0][0] =
555 s->c.last_mv[1][1][0] =
s->c.mv[1][0][0];
556 s->c.last_mv[1][0][1] =
557 s->c.last_mv[1][1][1] =
s->c.mv[1][0][1];
569 for (
i = 0;
i < 2;
i++) {
571 s->c.mv[0][
i][0] -
s->c.last_mv[0][
i][0],
572 s->c.mv[0][
i][1] -
s->c.last_mv[0][
i][1] / 2,
574 s->c.last_mv[0][
i][0] =
s->c.mv[0][
i][0];
575 s->c.last_mv[0][
i][1] =
s->c.mv[0][
i][1] * 2;
579 for (
i = 0;
i < 2;
i++) {
581 s->c.mv[1][
i][0] -
s->c.last_mv[1][
i][0],
582 s->c.mv[1][
i][1] -
s->c.last_mv[1][
i][1] / 2,
584 s->c.last_mv[1][
i][0] =
s->c.mv[1][
i][0];
585 s->c.last_mv[1][
i][1] =
s->c.mv[1][
i][1] * 2;
591 if (interleaved_stats)
596 if (interleaved_stats)
601 if ((cbp | motion_x | motion_y |
s->dquant) == 0 &&
609 const uint8_t *p_pic;
614 offset = x + y *
s->c.linesize;
615 p_pic =
s->new_pic->data[0] +
offset;
619 const uint8_t *b_pic;
630 if (x + 16 >
s->c.width || y + 16 >
s->c.height) {
632 int xe =
FFMIN(16,
s->c.width - x);
633 int ye =
FFMIN(16,
s->c.height - y);
635 for (y1 = 0; y1 < ye; y1++) {
636 for (x1 = 0; x1 < xe; x1++) {
637 diff +=
FFABS(p_pic[x1 + y1 *
s->c.linesize] - b_pic[x1 + y1 *
s->c.linesize]);
642 diff =
s->sad_cmp[0](
NULL, p_pic, b_pic,
s->c.linesize, 16);
644 if (
diff >
s->c.qscale * 70) {
652 if (
s->c.mb_skipped == 1) {
656 if (interleaved_stats) {
680 if (!
s->c.progressive_sequence) {
686 if (interleaved_stats)
712 if (interleaved_stats)
723 s->c.mv[0][0][0] - pred_x,
724 s->c.mv[0][0][1] - pred_y,
727 s->c.mv[0][1][0] - pred_x,
728 s->c.mv[0][1][1] - pred_y,
737 if (!
s->c.progressive_sequence && cbp)
740 if (interleaved_stats)
743 for (
i = 0;
i < 4;
i++) {
748 s->c.cur_pic.motion_val[0][
s->c.block_index[
i]][0] - pred_x,
749 s->c.cur_pic.motion_val[0][
s->c.block_index[
i]][1] - pred_y,
754 if (interleaved_stats)
759 if (interleaved_stats)
766 int zigzag_last_index[6];
767 const uint8_t *scan_table[6];
770 for (
int i = 0;
i < 6;
i++) {
772 int scale =
i < 4 ?
s->c.y_dc_scale :
s->c.c_dc_scale;
782 for (
i = 0;
i < 6;
i++)
783 scan_table[
i] =
s->c.intra_scantable.permutated;
788 for (
i = 0;
i < 6;
i++)
789 if (
s->c.block_last_index[
i] >= 1)
813 if (!
s->c.progressive_sequence)
816 if (interleaved_stats)
821 if (interleaved_stats)
839 put_bits(pbc, length, (1 << (length - 1)) - 1);
848 s->c.last_time_base =
s->c.time_base;
849 s->c.time_base =
FFUDIV(
s->c.time,
s->c.avctx->time_base.den);
856 int64_t hours, minutes, seconds;
861 time =
s->c.cur_pic.ptr->f->pts;
864 time = time *
s->c.avctx->time_base.num;
865 s->c.last_time_base =
FFUDIV(time,
s->c.avctx->time_base.den);
867 seconds =
FFUDIV(time,
s->c.avctx->time_base.den);
868 minutes =
FFUDIV(seconds, 60); seconds =
FFUMOD(seconds, 60);
869 hours =
FFUDIV(minutes, 60); minutes =
FFUMOD(minutes, 60);
870 hours =
FFUMOD(hours , 24);
886 int profile_and_level_indication;
890 profile_and_level_indication =
s->c.avctx->profile << 4;
892 profile_and_level_indication = 0xF0;
894 profile_and_level_indication = 0x00;
898 profile_and_level_indication |=
s->c.avctx->level;
900 profile_and_level_indication |= 1;
902 if (profile_and_level_indication >> 4 == 0xF)
911 put_bits(&
s->pb, 8, profile_and_level_indication);
931 int vo_ver_id, vo_type, aspect_ratio_info;
954 av_reduce(&
s->c.avctx->sample_aspect_ratio.num, &
s->c.avctx->sample_aspect_ratio.den,
955 s->c.avctx->sample_aspect_ratio.num,
s->c.avctx->sample_aspect_ratio.den, 255);
956 put_bits(&
s->pb, 8,
s->c.avctx->sample_aspect_ratio.num);
957 put_bits(&
s->pb, 8,
s->c.avctx->sample_aspect_ratio.den);
968 put_bits(&
s->pb, 16,
s->c.avctx->time_base.den);
978 put_bits(&
s->pb, 1,
s->c.progressive_sequence ? 0 : 1);
998 if (
s->data_partitioning)
1001 if (vo_ver_id != 1) {
1041 time_div =
FFUDIV(
s->c.time,
s->c.avctx->time_base.den);
1042 time_mod =
FFUMOD(
s->c.time,
s->c.avctx->time_base.den);
1043 time_incr = time_div -
s->c.last_time_base;
1046 if (time_incr > 3600*24) {
1063 if (!
s->c.progressive_sequence) {
1081 int level, uni_code, uni_len;
1139 memset(len_tab, 30, 2 * 2 * 64 * 64);
1145 unsigned code = (3 << 23) | (3 << 21) | (0 << 20) | (
run << 14) | (1 << 13) | 1;
1162 uint8_t max_run[2][32] = { 0 };
1164#define VLC_NUM_CODES 102
1168 int last =
i >= rl->
last;
1177 if (!max_run[last][
level])
1181 int run3 =
run + max_run[last][
level];
1182 int len3 =
len + 7 + 2;
1185 unsigned code3 =
code | (0x3 << 2 | 0x2) <<
len;
1195 if (
run != cur_run) {
1219 for (
int f_code =
MAX_FCODE; f_code > 0; f_code--) {
1220 for (
int mv = -(16 << f_code);
mv < (16 << f_code);
mv++)
1233 if (avctx->
width >= (1<<13) || avctx->
height >= (1<<13)) {
1243 s->min_qcoeff = -2048;
1244 s->max_qcoeff = 2047;
1250 s->ac_esc_length = 7 + 2 + 1 + 6 + 1 + 12 + 1;
1262 "timebase %d/%d not supported by MPEG 4 standard, "
1263 "the maximum admitted value for the timebase denominator "
1290 uint8_t *end =
s->pb.buf_end;
1291 int size = end - start;
1292 int pb_size = (((intptr_t)start +
size / 3) & (~3)) - (intptr_t)start;
1293 int tex_size = (
size - 2 * pb_size) & (~3);
1308 s->misc_bits += 19 + pb2_len +
bits -
s->last_bits;
1309 s->i_tex_bits += tex_pb_len;
1312 s->misc_bits += 17 + pb2_len;
1313 s->mv_bits +=
bits -
s->last_bits;
1314 s->p_tex_bits += tex_pb_len;
1328 int mb_num_bits =
av_log2(
s->c.mb_num - 1) + 1;
1333 put_bits(&
s->pb, mb_num_bits,
s->c.mb_x +
s->c.mb_y *
s->c.mb_width);
1338#define OFFSET(x) offsetof(MPVEncContext, x)
1339#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1342 {
"alternate_scan",
"Enable alternate scantable.",
OFFSET(
c.alternate_scan),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
VE },
1343 {
"mpeg_quant",
"Use MPEG quantizers instead of H.263",
1353 .class_name =
"MPEG4 encoder",
const FFCodec ff_mpeg4_encoder
static av_cold int encode_init(AVCodecContext *avctx)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
#define i(width, name, range_min, range_max)
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define ROUNDED_DIV(a, b)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define AV_PROFILE_UNKNOWN
#define FF_COMPLIANCE_VERY_STRICT
Strictly conform to an older more strict version of the spec or reference software.
int(* init)(AVBSFContext *ctx)
static const uint8_t bits[8]
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_FLAG_CLOSED_GOP
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_FLAG_AC_PRED
H.263 advanced intra coding / MPEG-4 AC prediction.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
#define LIBAVUTIL_VERSION_INT
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
#define FF_ASPECT_EXTENDED
av_const int ff_h263_aspect_to_info(AVRational aspect)
const uint8_t ff_h263_intra_MCBPC_bits[9]
const uint8_t ff_h263_inter_MCBPC_code[28]
const uint8_t ff_h263_inter_MCBPC_bits[28]
const uint8_t ff_h263_intra_MCBPC_code[9]
const uint8_t ff_h263_cbpy_tab[16][2]
static void ff_h263_encode_motion_vector(MPVEncContext *s, int x, int y, int f_code)
static int get_p_cbp(MPVEncContext *const s, int16_t block[6][64], int motion_x, int motion_y)
void ff_clean_h263_qscales(MPVEncContext *s)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static const int8_t mv[256][2]
av_cold void ff_qpeldsp_init(QpelDSPContext *c)
Libavcodec version macros.
Macro definitions for various function/variable attributes.
static int ff_thread_once(char *control, void(*routine)(void))
Memory handling functions.
const uint8_t ff_mpeg4_DCtab_lum[13][2]
RLTable ff_mpeg4_rl_intra
const uint8_t ff_mpeg4_c_dc_scale_table[32]
const uint8_t ff_mpeg4_y_dc_scale_table[32]
const uint8_t ff_mpeg4_DCtab_chrom[13][2]
void ff_mpeg4_init_direct_mv(MpegEncContext *s)
int ff_mpeg4_get_video_packet_prefix_length(enum AVPictureType pict_type, int f_code, int b_code)
#define ADV_SIMPLE_VO_TYPE
#define USER_DATA_STARTCODE
#define VISUAL_OBJ_STARTCODE
static void mpeg4_encode_gop_header(MPVMainEncContext *const m)
static uint8_t fcode_tab[MAX_MV *2+1]
Minimal fcode that a motion vector component would need.
void ff_mpeg4_stuffing(PutBitContext *pbc)
add MPEG-4 stuffing bits (01...1)
static Mpeg4EncContext * mainctx_to_mpeg4(MPVMainEncContext *m)
static uint8_t uni_DCtab_lum_len[512]
static const AVClass mpeg4enc_class
static uint16_t uni_DCtab_chrom_bits[512]
static uint8_t uni_mpeg4_intra_rl_len[64 *64 *2 *2]
static void mpeg4_encode_mb(MPVEncContext *const s, int16_t block[][64], int motion_x, int motion_y)
static av_cold void init_uni_dc_tab(void)
static void mpeg4_encode_ac_coeffs(const int16_t block[64], const int last_index, int i, const uint8_t *const scan_table, PutBitContext *const ac_pb, const uint32_t *const bits_tab, const uint8_t *const len_tab)
Encode the AC coefficients of an 8x8 block.
static void mpeg4_encode_dc(PutBitContext *s, int level, int n)
Encode the dc value.
static uint16_t uni_DCtab_lum_bits[512]
void ff_mpeg4_init_partitions(MPVEncContext *const s)
static av_cold int encode_init(AVCodecContext *avctx)
static av_cold void mpeg4_encode_init_static(void)
static int mpeg4_encode_picture_header(MPVMainEncContext *const m)
static int get_b_cbp(MPVEncContext *const s, int16_t block[6][64], int motion_x, int motion_y, int mb_type)
static void restore_ac_coeffs(MPVEncContext *const s, int16_t block[6][64], const int dir[6], const uint8_t *st[6], const int zigzag_last_index[6])
Restore the ac coefficients in block that have been changed by decide_ac_pred().
static void mpeg4_encode_blocks_intra(MPVEncContext *const s, const int16_t block[6][64], const int intra_dc[6], const uint8_t *const *scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb)
#define UNI_MPEG4_ENC_INDEX(last, run, level)
static uint32_t uni_mpeg4_inter_rl_bits[64 *64 *2 *2]
static int mpeg4_pred_dc(MpegEncContext *s, int n, int *dir_ptr)
Predict the dc.
static int decide_ac_pred(MPVEncContext *const s, int16_t block[6][64], const int dir[6], const uint8_t *st[6], int zigzag_last_index[6])
Return the optimal value (0 or 1) for the ac_pred element for the given MB in MPEG-4.
static void mpeg4_encode_visual_object_header(MPVMainEncContext *const m)
void ff_clean_mpeg4_qscales(MPVEncContext *const s)
modify mb_type & qscale so that encoding is actually possible in MPEG-4
static int get_block_rate(MPVEncContext *const s, int16_t block[64], int block_last_index, const uint8_t scantable[64])
Return the number of bits that encoding the 8x8 block in block would need.
void ff_mpeg4_merge_partitions(MPVEncContext *const s)
static const int dquant_code[5]
static uint32_t uni_mpeg4_intra_rl_bits[64 *64 *2 *2]
static void mpeg4_encode_blocks_inter(MPVEncContext *const s, const int16_t block[6][64], PutBitContext *ac_pb)
static uint8_t uni_mpeg4_inter_rl_len[64 *64 *2 *2]
void ff_set_mpeg4_time(MPVEncContext *const s)
void ff_mpeg4_encode_video_packet_header(MPVEncContext *const s)
static av_cold void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_tab)
static void mpeg4_encode_vol_header(Mpeg4EncContext *const m4, int vo_number, int vol_number)
static uint8_t uni_DCtab_chrom_len[512]
#define MV_TYPE_FIELD
2 vectors, one per field
#define MV_TYPE_8X8
4 vectors (H.263, MPEG-4 4MV)
#define MV_DIRECT
bidirectional mode where the difference equals the MV of the last P/S/I-Frame (MPEG-4)
#define MV_TYPE_16X16
1 vector for the whole mb
av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet)
void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix)
av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
static int get_bits_diff(MPVEncContext *s)
#define FF_MPV_FLAG_CBP_RD
#define CANDIDATE_MB_TYPE_DIRECT
#define CANDIDATE_MB_TYPE_BIDIR
#define UNI_AC_ENC_INDEX(run, level)
#define FF_MPV_COMMON_OPTS
#define FF_MPV_COMMON_BFRAME_OPTS
#define FF_MPV_COMMON_MOTION_EST_OPTS
static const MPVMainEncContext * slice_to_mainenc(const MPVEncContext *s)
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_MPEG4_PROFILE_OPTS
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static void set_put_bits_buffer_size(PutBitContext *s, int size)
Change the end of the buffer.
static int put_bits_count(PutBitContext *s)
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static int put_bytes_output(const PutBitContext *s)
static av_unused void put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
static void put_bits_assume_flushed(const PutBitContext *s)
Inform the compiler that a PutBitContext is flushed (i.e.
static const float pred[4]
Describe the class of an AVClass context structure.
main external API structure.
int width
picture width / height.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int flags
AV_CODEC_FLAG_*.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
enum AVPictureType pict_type
Picture type of the frame.
int max_b_frames
max number of B-frames
MPVEncContext s
The main slicecontext.
const uint8_t * fcode_tab
smallest fcode needed for each MV
MPVPicture * reordered_input_picture[MPVENC_MAX_B_FRAMES+1]
next pictures in coded order
int(* encode_picture_header)(struct MPVMainEncContext *m)
int time_increment_bits
number of bits to represent the fractional part of time
int n
number of entries of table_vlc minus 1
int last
number of values for last = 0
const uint16_t(* table_vlc)[2]
const int8_t * table_level
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)