Go to the documentation of this file.
63 #define UNI_MPEG4_ENC_INDEX(last, run, level) ((last) * 128 * 64 + (run) * 128 + (level))
91 int block_last_index,
const uint8_t scantable[64])
97 for (j = 1; j <= block_last_index; j++) {
98 const int index = scantable[j];
102 if ((
level & (~127)) == 0) {
103 if (j < block_last_index)
108 rate +=
s->ac_esc_length;
126 const int dir[6],
const uint8_t *st[6],
127 const int zigzag_last_index[6])
130 memcpy(
s->c.block_last_index, zigzag_last_index,
sizeof(
int) * 6);
132 for (n = 0; n < 6; n++) {
133 int16_t *ac_val = &
s->c.ac_val[0][0] +
s->c.block_index[n] * 16;
135 st[n] =
s->c.intra_scantable.permutated;
138 for (
i = 1;
i < 8;
i++)
139 block[n][
s->c.idsp.idct_permutation[
i]] = ac_val[
i + 8];
142 for (
i = 1;
i < 8;
i++)
143 block[n][
s->c.idsp.idct_permutation[
i << 3]] = ac_val[
i];
155 const int16_t *
const dc_val =
s->dc_val +
s->block_index[n];
156 const int wrap =
s->block_wrap[n];
161 const int a = dc_val[-1];
162 const int b = dc_val[-1 -
wrap];
163 const int c = dc_val[-
wrap];
187 const int dir[6],
const uint8_t *st[6],
188 int zigzag_last_index[6])
192 const int8_t *
const qscale_table =
s->c.cur_pic.qscale_table;
194 memcpy(zigzag_last_index,
s->c.block_last_index,
sizeof(
int) * 6);
196 for (n = 0; n < 6; n++) {
197 int16_t *ac_val, *ac_val1;
200 s->c.intra_scantable.permutated);
202 ac_val = &
s->c.ac_val[0][0] +
s->c.block_index[n] * 16;
205 const int xy =
s->c.mb_x +
s->c.mb_y *
s->c.mb_stride -
s->c.mb_stride;
207 ac_val -=
s->c.block_wrap[n] * 16;
208 if (
s->c.first_slice_line ||
s->c.qscale == qscale_table[xy] || n == 2 || n == 3) {
210 for (
i = 1;
i < 8;
i++) {
211 const int level =
block[n][
s->c.idsp.idct_permutation[
i]];
212 block[n][
s->c.idsp.idct_permutation[
i]] =
level - ac_val[
i + 8];
213 ac_val1[
i] =
block[n][
s->c.idsp.idct_permutation[
i << 3]];
218 for (
i = 1;
i < 8;
i++) {
219 const int level =
block[n][
s->c.idsp.idct_permutation[
i]];
221 ac_val1[
i] =
block[n][
s->c.idsp.idct_permutation[
i << 3]];
225 st[n] =
s->c.permutated_intra_h_scantable;
227 const int xy =
s->c.mb_x - 1 +
s->c.mb_y *
s->c.mb_stride;
230 if (
s->c.mb_x == 0 ||
s->c.qscale == qscale_table[xy] || n == 1 || n == 3) {
232 for (
i = 1;
i < 8;
i++) {
233 const int level =
block[n][
s->c.idsp.idct_permutation[
i << 3]];
234 block[n][
s->c.idsp.idct_permutation[
i << 3]] =
level - ac_val[
i];
236 ac_val1[
i + 8] =
block[n][
s->c.idsp.idct_permutation[
i]];
240 for (
i = 1;
i < 8;
i++) {
241 const int level =
block[n][
s->c.idsp.idct_permutation[
i << 3]];
244 ac_val1[
i + 8] =
block[n][
s->c.idsp.idct_permutation[
i]];
247 st[n] =
s->c.permutated_intra_v_scantable;
250 for (
i = 63;
i > 0;
i--)
253 s->c.block_last_index[n] =
i;
274 int8_t *
const qscale_table =
s->c.cur_pic.qscale_table;
279 for (
int i = 0;
i <
s->c.mb_num;
i++) {
280 int mb_xy =
s->c.mb_index2xy[
i];
281 odd += qscale_table[mb_xy] & 1;
284 if (2 * odd >
s->c.mb_num)
289 for (
int i = 0;
i <
s->c.mb_num;
i++) {
290 int mb_xy =
s->c.mb_index2xy[
i];
291 if ((qscale_table[mb_xy] & 1) != odd)
292 qscale_table[mb_xy]++;
293 if (qscale_table[mb_xy] > 31)
294 qscale_table[mb_xy] = 31;
297 for (
int i = 1;
i <
s->c.mb_num;
i++) {
298 int mb_xy =
s->c.mb_index2xy[
i];
299 if (qscale_table[mb_xy] != qscale_table[
s->c.mb_index2xy[
i - 1]] &&
328 const int last_index,
int i,
329 const uint8_t *
const scan_table,
331 const uint32_t *
const bits_tab,
332 const uint8_t *
const len_tab)
334 int last_non_zero =
i - 1;
337 for (;
i < last_index;
i++) {
340 int run =
i - last_non_zero - 1;
342 if ((
level & (~127)) == 0) {
347 7 + 2 + 1 + 6 + 1 + 12 + 1,
348 (3 << 23) + (3 << 21) + (0 << 20) + (
run << 14) +
349 (1 << 13) + (((
level - 64) & 0xfff) << 1) + 1);
356 int run =
i - last_non_zero - 1;
358 if ((
level & (~127)) == 0) {
363 7 + 2 + 1 + 6 + 1 + 12 + 1,
364 (3 << 23) + (3 << 21) + (1 << 20) + (
run << 14) +
365 (1 << 13) + (((
level - 64) & 0xfff) << 1) + 1);
371 const int16_t
block[6][64],
375 for (
int n = 0; n < 6; ++n) {
376 const int last_index =
s->c.block_last_index[n];
381 s->c.intra_scantable.permutated, ac_pb,
387 const int16_t
block[6][64],
388 const int intra_dc[6],
389 const uint8_t *
const *scan_table,
394 for (
int n = 0; n < 6; ++n) {
397 const int last_index =
s->c.block_last_index[n];
402 scan_table[n], ac_pb,
408 int motion_x,
int motion_y,
int mb_type)
416 for (
i = 0;
i < 6;
i++) {
417 if (
s->coded_score[
i] < 0) {
418 score +=
s->coded_score[
i];
425 if ((motion_x | motion_y |
s->dquant | mb_type) == 0)
428 zero_score *= lambda;
429 if (zero_score <= score)
433 for (
i = 0;
i < 6;
i++) {
434 if (
s->c.block_last_index[
i] >= 0 && ((cbp >> (5 -
i)) & 1) == 0) {
435 s->c.block_last_index[
i] = -1;
436 s->c.bdsp.clear_block(
s->c.block[
i]);
440 for (
i = 0;
i < 6;
i++) {
441 if (
s->c.block_last_index[
i] >= 0)
452 int motion_x,
int motion_y)
454 int cbpc, cbpy, pred_x, pred_y;
458 const int interleaved_stats = (
s->c.avctx->flags &
AV_CODEC_FLAG_PASS1) && !
s->c.data_partitioning ? 1 : 0;
460 if (!
s->c.mb_intra) {
465 static const int mb_type_table[8] = { -1, 3, 2, 1, -1, -1, -1, 0 };
466 int mb_type = mb_type_table[
s->c.mv_dir];
468 if (
s->c.mb_x == 0) {
469 for (
i = 0;
i < 2;
i++)
470 s->c.last_mv[
i][0][0] =
471 s->c.last_mv[
i][0][1] =
472 s->c.last_mv[
i][1][0] =
473 s->c.last_mv[
i][1][1] = 0;
481 if (
s->c.next_pic.mbskip_table[
s->c.mb_y *
s->c.mb_stride +
s->c.mb_x]) {
485 s->c.mv[1][0][1] = 0;
487 s->c.qscale -=
s->dquant;
495 if ((cbp | motion_x | motion_y | mb_type) == 0) {
501 if (interleaved_stats) {
514 if (cbp && mb_type) {
520 s->c.qscale -=
s->dquant;
522 if (!
s->c.progressive_sequence) {
529 if (interleaved_stats)
540 s->c.mv[0][0][0] -
s->c.last_mv[0][0][0],
541 s->c.mv[0][0][1] -
s->c.last_mv[0][0][1],
543 s->c.last_mv[0][0][0] =
544 s->c.last_mv[0][1][0] =
s->c.mv[0][0][0];
545 s->c.last_mv[0][0][1] =
546 s->c.last_mv[0][1][1] =
s->c.mv[0][0][1];
550 s->c.mv[1][0][0] -
s->c.last_mv[1][0][0],
551 s->c.mv[1][0][1] -
s->c.last_mv[1][0][1],
553 s->c.last_mv[1][0][0] =
554 s->c.last_mv[1][1][0] =
s->c.mv[1][0][0];
555 s->c.last_mv[1][0][1] =
556 s->c.last_mv[1][1][1] =
s->c.mv[1][0][1];
568 for (
i = 0;
i < 2;
i++) {
570 s->c.mv[0][
i][0] -
s->c.last_mv[0][
i][0],
571 s->c.mv[0][
i][1] -
s->c.last_mv[0][
i][1] / 2,
573 s->c.last_mv[0][
i][0] =
s->c.mv[0][
i][0];
574 s->c.last_mv[0][
i][1] =
s->c.mv[0][
i][1] * 2;
578 for (
i = 0;
i < 2;
i++) {
580 s->c.mv[1][
i][0] -
s->c.last_mv[1][
i][0],
581 s->c.mv[1][
i][1] -
s->c.last_mv[1][
i][1] / 2,
583 s->c.last_mv[1][
i][0] =
s->c.mv[1][
i][0];
584 s->c.last_mv[1][
i][1] =
s->c.mv[1][
i][1] * 2;
590 if (interleaved_stats)
595 if (interleaved_stats)
600 if ((cbp | motion_x | motion_y |
s->dquant) == 0 &&
608 const uint8_t *p_pic;
613 offset = x + y *
s->c.linesize;
614 p_pic =
s->new_pic->data[0] +
offset;
618 const uint8_t *b_pic;
629 if (x + 16 >
s->c.width || y + 16 >
s->c.height) {
631 int xe =
FFMIN(16,
s->c.width - x);
632 int ye =
FFMIN(16,
s->c.height - y);
634 for (y1 = 0; y1 < ye; y1++) {
635 for (x1 = 0; x1 < xe; x1++) {
636 diff +=
FFABS(p_pic[x1 + y1 *
s->c.linesize] - b_pic[x1 + y1 *
s->c.linesize]);
641 diff =
s->sad_cmp[0](
NULL, p_pic, b_pic,
s->c.linesize, 16);
643 if (
diff >
s->c.qscale * 70) {
651 if (
s->c.mb_skipped == 1) {
655 if (interleaved_stats) {
679 if (!
s->c.progressive_sequence) {
685 if (interleaved_stats)
711 if (interleaved_stats)
722 s->c.mv[0][0][0] - pred_x,
723 s->c.mv[0][0][1] - pred_y,
726 s->c.mv[0][1][0] - pred_x,
727 s->c.mv[0][1][1] - pred_y,
736 if (!
s->c.progressive_sequence && cbp)
739 if (interleaved_stats)
742 for (
i = 0;
i < 4;
i++) {
747 s->c.cur_pic.motion_val[0][
s->c.block_index[
i]][0] - pred_x,
748 s->c.cur_pic.motion_val[0][
s->c.block_index[
i]][1] - pred_y,
753 if (interleaved_stats)
758 if (interleaved_stats)
765 int zigzag_last_index[6];
766 const uint8_t *scan_table[6];
769 for (
int i = 0;
i < 6;
i++) {
771 int scale =
i < 4 ?
s->c.y_dc_scale :
s->c.c_dc_scale;
781 for (
i = 0;
i < 6;
i++)
782 scan_table[
i] =
s->c.intra_scantable.permutated;
787 for (
i = 0;
i < 6;
i++)
788 if (
s->c.block_last_index[
i] >= 1)
812 if (!
s->c.progressive_sequence)
815 if (interleaved_stats)
820 if (interleaved_stats)
838 put_bits(pbc, length, (1 << (length - 1)) - 1);
847 s->c.last_time_base =
s->c.time_base;
848 s->c.time_base =
FFUDIV(
s->c.time,
s->c.avctx->time_base.den);
855 int64_t hours, minutes, seconds;
860 time =
s->c.cur_pic.ptr->f->pts;
863 time = time *
s->c.avctx->time_base.num;
864 s->c.last_time_base =
FFUDIV(time,
s->c.avctx->time_base.den);
866 seconds =
FFUDIV(time,
s->c.avctx->time_base.den);
867 minutes =
FFUDIV(seconds, 60); seconds =
FFUMOD(seconds, 60);
868 hours =
FFUDIV(minutes, 60); minutes =
FFUMOD(minutes, 60);
869 hours =
FFUMOD(hours , 24);
885 int profile_and_level_indication;
889 profile_and_level_indication =
s->c.avctx->profile << 4;
891 profile_and_level_indication = 0xF0;
893 profile_and_level_indication = 0x00;
897 profile_and_level_indication |=
s->c.avctx->level;
899 profile_and_level_indication |= 1;
901 if (profile_and_level_indication >> 4 == 0xF)
910 put_bits(&
s->pb, 8, profile_and_level_indication);
930 int vo_ver_id, vo_type, aspect_ratio_info;
953 av_reduce(&
s->c.avctx->sample_aspect_ratio.num, &
s->c.avctx->sample_aspect_ratio.den,
954 s->c.avctx->sample_aspect_ratio.num,
s->c.avctx->sample_aspect_ratio.den, 255);
955 put_bits(&
s->pb, 8,
s->c.avctx->sample_aspect_ratio.num);
956 put_bits(&
s->pb, 8,
s->c.avctx->sample_aspect_ratio.den);
967 put_bits(&
s->pb, 16,
s->c.avctx->time_base.den);
977 put_bits(&
s->pb, 1,
s->c.progressive_sequence ? 0 : 1);
996 put_bits(&
s->pb, 1,
s->c.data_partitioning ? 1 : 0);
997 if (
s->c.data_partitioning)
1000 if (vo_ver_id != 1) {
1040 time_div =
FFUDIV(
s->c.time,
s->c.avctx->time_base.den);
1041 time_mod =
FFUMOD(
s->c.time,
s->c.avctx->time_base.den);
1042 time_incr = time_div -
s->c.last_time_base;
1045 if (time_incr > 3600*24) {
1062 if (!
s->c.progressive_sequence) {
1080 int level, uni_code, uni_len;
1138 memset(len_tab, 30, 2 * 2 * 64 * 64);
1144 unsigned code = (3 << 23) | (3 << 21) | (0 << 20) | (
run << 14) | (1 << 13) | 1;
1161 uint8_t max_run[2][32] = { 0 };
1163 #define VLC_NUM_CODES 102 // excluding the escape
1167 int last =
i >= rl->
last;
1176 if (!max_run[last][
level])
1180 int run3 =
run + max_run[last][
level];
1181 int len3 =
len + 7 + 2;
1184 unsigned code3 =
code | (0x3 << 2 | 0x2) <<
len;
1194 if (
run != cur_run) {
1218 for (
int f_code =
MAX_FCODE; f_code > 0; f_code--) {
1219 for (
int mv = -(16 << f_code);
mv < (16 << f_code);
mv++)
1232 if (avctx->
width >= (1<<13) || avctx->
height >= (1<<13)) {
1242 s->min_qcoeff = -2048;
1243 s->max_qcoeff = 2047;
1249 s->ac_esc_length = 7 + 2 + 1 + 6 + 1 + 12 + 1;
1261 "timebase %d/%d not supported by MPEG 4 standard, "
1262 "the maximum admitted value for the timebase denominator "
1289 uint8_t *end =
s->pb.buf_end;
1290 int size = end - start;
1291 int pb_size = (((intptr_t)start +
size / 3) & (~3)) - (intptr_t)start;
1292 int tex_size = (
size - 2 * pb_size) & (~3);
1307 s->misc_bits += 19 + pb2_len +
bits -
s->last_bits;
1308 s->i_tex_bits += tex_pb_len;
1311 s->misc_bits += 17 + pb2_len;
1312 s->mv_bits +=
bits -
s->last_bits;
1313 s->p_tex_bits += tex_pb_len;
1327 int mb_num_bits =
av_log2(
s->c.mb_num - 1) + 1;
1332 put_bits(&
s->pb, mb_num_bits,
s->c.mb_x +
s->c.mb_y *
s->c.mb_width);
1337 #define OFFSET(x) offsetof(MPVEncContext, x)
1338 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1340 {
"data_partitioning",
"Use data partitioning.",
OFFSET(
c.data_partitioning),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
VE },
1341 {
"alternate_scan",
"Enable alternate scantable.",
OFFSET(
c.alternate_scan),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
VE },
1342 {
"mpeg_quant",
"Use MPEG quantizers instead of H.263",
static av_cold void mpeg4_encode_init_static(void)
const uint8_t * fcode_tab
smallest fcode needed for each MV
#define CODEC_PIXFMTS(...)
#define CANDIDATE_MB_TYPE_BIDIR
#define MV_TYPE_16X16
1 vector for the whole mb
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.
#define FF_ASPECT_EXTENDED
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static void av_unused put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
static int put_bytes_output(const PutBitContext *s)
static const int8_t mv[256][2]
static void mpeg4_encode_gop_header(MPVMainEncContext *const m)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
av_cold void ff_qpeldsp_init(QpelDSPContext *c)
void ff_clean_h263_qscales(MPVEncContext *s)
#define MV_DIRECT
bidirectional mode where the difference equals the MV of the last P/S/I-Frame (MPEG-4)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static av_cold void init_uni_dc_tab(void)
int time_increment_bits
number of bits to represent the fractional part of time
int ff_mpeg4_get_video_packet_prefix_length(enum AVPictureType pict_type, int f_code, int b_code)
static void mpeg4_encode_mb(MPVEncContext *const s, int16_t block[][64], int motion_x, int motion_y)
int(* encode_picture_header)(struct MPVMainEncContext *m)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
static uint32_t uni_mpeg4_intra_rl_bits[64 *64 *2 *2]
#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 FF_MPV_COMMON_MOTION_EST_OPTS
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet)
#define FF_MPV_COMMON_OPTS
void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
static uint8_t uni_mpeg4_intra_rl_len[64 *64 *2 *2]
const uint8_t ff_mpeg4_DCtab_chrom[13][2]
AVCodec p
The public AVCodec.
static Mpeg4EncContext * mainctx_to_mpeg4(MPVMainEncContext *m)
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
static void mpeg4_encode_visual_object_header(MPVMainEncContext *const m)
static uint32_t uni_mpeg4_inter_rl_bits[64 *64 *2 *2]
int flags
AV_CODEC_FLAG_*.
static uint8_t uni_DCtab_chrom_len[512]
#define FF_MPV_FLAG_CBP_RD
void ff_mpeg4_init_partitions(MPVEncContext *const s)
#define FF_CODEC_ENCODE_CB(func)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static const int dquant_code[5]
#define CANDIDATE_MB_TYPE_DIRECT
int n
number of entries of table_vlc minus 1
static int ff_thread_once(char *control, void(*routine)(void))
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PROFILE_UNKNOWN
static uint8_t uni_mpeg4_inter_rl_len[64 *64 *2 *2]
MPVPicture * reordered_input_picture[MPVENC_MAX_B_FRAMES+1]
next pictures in coded order
void ff_mpeg4_stuffing(PutBitContext *pbc)
add MPEG-4 stuffing bits (01...1)
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
RLTable ff_mpeg4_rl_intra
static uint16_t uni_DCtab_chrom_bits[512]
#define UNI_MPEG4_ENC_INDEX(last, run, level)
static uint16_t uni_DCtab_lum_bits[512]
void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix)
int max_b_frames
max number of B-frames
void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
void ff_clean_mpeg4_qscales(MPVEncContext *const s)
modify mb_type & qscale so that encoding is actually possible in MPEG-4
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void mpeg4_encode_vol_header(Mpeg4EncContext *const m4, int vo_number, int vol_number)
static av_cold void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_tab)
#define CODEC_LONG_NAME(str)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
const uint8_t ff_mpeg4_DCtab_lum[13][2]
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.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
#define FF_COMPLIANCE_VERY_STRICT
Strictly conform to an older more strict version of the spec or reference software.
const uint16_t(* table_vlc)[2]
#define ROUNDED_DIV(a, b)
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_PICTURE_TYPE_I
Intra.
#define AV_CODEC_FLAG_AC_PRED
H.263 advanced intra coding / MPEG-4 AC prediction.
av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
void ff_mpeg4_encode_video_packet_header(MPVEncContext *const s)
static int get_p_cbp(MPVEncContext *const s, int16_t block[6][64], int motion_x, int motion_y)
static int mpeg4_encode_picture_header(MPVMainEncContext *const m)
#define VISUAL_OBJ_STARTCODE
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define MV_TYPE_8X8
4 vectors (H.263, MPEG-4 4MV)
static void set_put_bits_buffer_size(PutBitContext *s, int size)
Change the end of the buffer.
void ff_set_mpeg4_time(MPVEncContext *const s)
#define ADV_SIMPLE_VO_TYPE
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
const int8_t * table_level
enum AVPictureType pict_type
Picture type of the frame.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
const uint8_t ff_mpeg4_y_dc_scale_table[32]
static void put_bits_assume_flushed(const PutBitContext *s)
Inform the compiler that a PutBitContext is flushed (i.e.
const uint8_t ff_h263_cbpy_tab[16][2]
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
static uint8_t fcode_tab[MAX_MV *2+1]
Minimal fcode that a motion vector component would need.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
#define MV_TYPE_FIELD
2 vectors, one per field
const uint8_t ff_h263_inter_MCBPC_bits[28]
#define UNI_AC_ENC_INDEX(run, level)
#define FF_MPEG4_PROFILE_OPTS
static int get_bits_diff(MPVEncContext *s)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
static int put_bits_count(PutBitContext *s)
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
static uint8_t uni_DCtab_lum_len[512]
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 const AVClass mpeg4enc_class
static const AVOption options[]
const FFCodec ff_mpeg4_encoder
const char * name
Name of the codec implementation.
av_const int ff_h263_aspect_to_info(AVRational aspect)
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
#define AV_CODEC_FLAG_CLOSED_GOP
static const float pred[4]
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static av_cold int encode_init(AVCodecContext *avctx)
void ff_mpeg4_init_direct_mv(MpegEncContext *s)
const uint8_t ff_h263_intra_MCBPC_bits[9]
main external API structure.
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
const uint8_t ff_h263_intra_MCBPC_code[9]
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
static void mpeg4_encode_dc(PutBitContext *s, int level, int n)
Encode the dc value.
@ AV_OPT_TYPE_INT
Underlying C type is int.
int last
number of values for last = 0
#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 FF_MPV_COMMON_BFRAME_OPTS
#define USER_DATA_STARTCODE
const uint8_t ff_h263_inter_MCBPC_code[28]
@ AV_PICTURE_TYPE_P
Predicted.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
void ff_mpeg4_merge_partitions(MPVEncContext *const s)
const uint8_t ff_mpeg4_c_dc_scale_table[32]
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 scale(int *out, const int *in, const int w, const int h, const int shift)
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)
static const MPVMainEncContext * slice_to_mainenc(const MPVEncContext *s)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
static void ff_h263_encode_motion_vector(MPVEncContext *s, int x, int y, int f_code)
int width
picture width / height.
The exact code depends on how similar the blocks are and how related they are to the block
static int get_b_cbp(MPVEncContext *const s, int16_t block[6][64], int motion_x, int motion_y, int mb_type)
static int mpeg4_pred_dc(MpegEncContext *s, int n, int *dir_ptr)
Predict the dc.
MPVEncContext s
The main slicecontext.
static void mpeg4_encode_blocks_inter(MPVEncContext *const s, const int16_t block[6][64], PutBitContext *ac_pb)
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.