61 #define QUANT_BIAS_SHIFT 8
63 #define QMAT_SHIFT_MMX 16
81 uint16_t (*qmat16)[2][64],
82 const uint16_t *quant_matrix,
83 int bias,
int qmin,
int qmax,
int intra)
89 for (qscale = qmin; qscale <= qmax; qscale++) {
94 for (i = 0; i < 64; i++) {
103 (qscale * quant_matrix[j]));
106 for (i = 0; i < 64; i++) {
119 for (i = 0; i < 64; i++) {
127 (qscale * quant_matrix[j]));
131 (qscale * quant_matrix[j]);
133 if (qmat16[qscale][0][i] == 0 ||
134 qmat16[qscale][0][i] == 128 * 256)
135 qmat16[
qscale][0][i] = 128 * 256 - 1;
138 qmat16[qscale][0][i]);
142 for (i = intra; i < 64; i++) {
147 while (((max * qmat[qscale][i]) >> shift) > INT_MAX) {
154 "Warning, QMAT_SHIFT is larger than %d, overflows possible\n",
175 for (i = 0; i < 64; i++) {
190 for (i = 0; i < s->
mb_num; i++) {
201 #define COPY(a) dst->a= src->a
226 for (i = -16; i < 16; i++) {
240 int i, ret, format_supported;
249 "only YUV420 and YUV422 are supported\n");
254 format_supported = 0;
261 format_supported = 1;
266 format_supported = 1;
268 if (!format_supported) {
298 "Warning keyframe interval too large! reducing it ...\n");
343 "a vbv buffer size is needed, "
344 "for encoding with a maximum bitrate\n");
350 "Warning min_rate > 0 but min_rate != max_rate isn't recommended!\n");
367 "impossible bitrate constraints, this will fail\n");
381 "bitrate tolerance too small for bitrate\n");
392 "Warning vbv_delay will be set to 0xFFFF (=VBR) as the "
393 "specified vbv buffer is too large for the given bitrate!\n");
405 "OBMC is only supported with simple mb decision\n");
428 "Invalid pixel aspect ratio %i/%i, limit is 255/255\n",
442 "mpeg2 style quantization not supported by codec\n");
460 "closed gop with scene change detection are not supported yet, "
461 "set threshold to 1000000000\n");
468 "low delay forcing is only available for mpeg2\n");
473 "b frames cannot be used with low delay\n");
479 if (avctx->
qmax > 12) {
481 "non linear quant only supports qmax <= 12 currently\n");
492 "multi threaded encoding not supported by codec\n");
498 "automatic thread number detection not supported by codec,"
511 i = (INT_MAX / 2 + 128) >> 8;
520 "notice: b_frame_strategy only affects the first pass\n");
551 "timebase %d/%d not supported by MPEG 4 standard, "
552 "the maximum admitted value for the timebase denominator "
585 "The specified picture size of %dx%d is not valid for the "
586 "H.261 codec.\nValid sizes are 176x144, 352x288\n",
600 "The specified picture size of %dx%d is not valid for "
601 "the H.263 codec.\nValid sizes are 128x96, 176x144, "
602 "352x288, 704x576, and 1408x1152."
721 (
MAX_RUN + 1) * 2 *
sizeof(
int), fail);
736 2 * 64 *
sizeof(uint16_t), fail);
768 for (i = 0; i < 64; i++) {
802 #if FF_API_ERROR_RATE
809 #if FF_API_NORMALIZE_AQP
884 for (y = 0; y < 16; y++) {
885 for (x = 0; x < 16; x++) {
886 acc +=
FFABS(src[x + y * stride] - ref);
902 for (y = 0; y < h; y += 16) {
903 for (x = 0; x < w; x += 16) {
904 int offset = x + y *
stride;
905 int sad = s->
mecc.
sad[0](
NULL, src + offset, ref + offset,
908 int sae =
get_sae(src + offset, mean, stride);
910 acc += sae + 500 < sad;
921 int i, display_picture_number = 0, ret;
937 "Error, Invalid timestamp=%"PRId64
", "
942 if (!s->
low_delay && display_picture_number == 1)
951 "Warning: AVFrame.pts=? trying to guess (%"PRId64
")\n",
954 pts = display_picture_number;
960 if (!pic_arg->
buf[0]);
1002 int h_chroma_shift, v_chroma_shift;
1007 for (i = 0; i < 3; i++) {
1008 int src_stride = pic_arg->
linesize[i];
1010 int h_shift = i ? h_chroma_shift : 0;
1011 int v_shift = i ? v_chroma_shift : 0;
1012 int w = s->
width >> h_shift;
1013 int h = s->
height >> v_shift;
1020 if (src_stride == dst_stride)
1021 memcpy(dst, src, src_stride * h);
1024 memcpy(dst, src, w);
1053 int64_t score64 = 0;
1055 for (plane = 0; plane < 3; plane++) {
1057 const int bw = plane ? 1 : 2;
1058 for (y = 0; y < s->
mb_height * bw; y++) {
1059 for (x = 0; x < s->
mb_width * bw; x++) {
1060 int off = p->
shared ? 0 : 16;
1066 case 0: score =
FFMAX(score, v);
break;
1067 case 1: score +=
FFABS(v);
break;
1068 case 2: score += v * v;
break;
1069 case 3: score64 +=
FFABS(v * v * (int64_t)v);
break;
1070 case 4: score64 += v * v * (int64_t)(v * v);
break;
1089 int ret, got_output;
1106 int i, j, out_size, p_lambda, b_lambda,
lambda2;
1107 int64_t best_rd = INT64_MAX;
1108 int best_b_count = -1;
1110 assert(scale >= 0 && scale <= 3);
1118 b_lambda = p_lambda;
1142 pre_input = *pre_input_ptr;
1144 if (!pre_input.
shared && i) {
1152 pre_input.
f->
data[0],
1157 pre_input.
f->
data[1],
1162 pre_input.
f->
data[2],
1212 return best_b_count;
1285 b_frames =
FFMAX(0, i - 1);
1288 for (i = 0; i < b_frames + 1; i++) {
1300 for (i = b_frames - 1; i >= 0; i--) {
1308 "warning, too many b frames in a row\n");
1331 for (i = 0; i < b_frames; i++) {
1377 for (i = 0; i < 4; i++) {
1444 for (intra = 0; intra < 2; intra++) {
1446 for (i = 0; i < 64; i++) {
1452 for (i = 0; i < 64; i++) {
1503 for (i = 0; i < 4; i++) {
1534 const AVFrame *pic_arg,
int *got_packet)
1537 int i, stuffing_count, ret;
1561 for (i = 0; i < context_count; i++) {
1565 uint8_t *start = pkt->
data + (size_t)(((int64_t) pkt->
size) * start_y / h);
1566 uint8_t *end = pkt->
data + (size_t)(((int64_t) pkt->
size) * end_y / h);
1623 for (i = 0; i < context_count; i++) {
1636 for (i = 0; i < 4; i++) {
1649 if (stuffing_count) {
1651 stuffing_count + 50) {
1659 while (stuffing_count--) {
1666 stuffing_count -= 4;
1667 while (stuffing_count--) {
1684 int vbv_delay, min_delay;
1693 "Internal error, negative bits\n");
1701 vbv_delay =
FFMAX(vbv_delay, min_delay);
1703 assert(vbv_delay < 0xFFFF);
1734 *got_packet = !!pkt->
size;
1739 int n,
int threshold)
1741 static const char tab[64] = {
1742 3, 2, 2, 1, 1, 1, 1, 1,
1743 1, 1, 1, 1, 1, 1, 1, 1,
1744 1, 1, 1, 1, 1, 1, 1, 1,
1745 0, 0, 0, 0, 0, 0, 0, 0,
1746 0, 0, 0, 0, 0, 0, 0, 0,
1747 0, 0, 0, 0, 0, 0, 0, 0,
1748 0, 0, 0, 0, 0, 0, 0, 0,
1749 0, 0, 0, 0, 0, 0, 0, 0
1758 if (threshold < 0) {
1760 threshold = -threshold;
1765 if (last_index <= skip_dc - 1)
1768 for (i = 0; i <= last_index; i++) {
1772 if (skip_dc && i == 0)
1776 }
else if (level > 1) {
1782 if (score >= threshold)
1784 for (i = skip_dc; i <= last_index; i++) {
1807 for (; i <= last_index; i++) {
1809 int level = block[j];
1811 if (level > maxlevel) {
1814 }
else if (level < minlevel) {
1824 "warning, clipping %d dct coefficients to %d..%d\n",
1825 overflow, minlevel, maxlevel);
1832 for (y = 0; y < 8; y++) {
1833 for (x = 0; x < 8; x++) {
1839 for (y2 =
FFMAX(y - 1, 0); y2 <
FFMIN(8, y + 2); y2++) {
1840 for (x2=
FFMAX(x - 1, 0); x2 <
FFMIN(8, x + 2); x2++) {
1841 int v = ptr[x2 + y2 *
stride];
1847 weight[x + 8 * y]= (36 *
ff_sqrt(count * sqr - sum * sum)) / count;
1853 int motion_x,
int motion_y,
1854 int mb_block_height,
1857 int16_t weight[8][64];
1858 int16_t orig[8][64];
1864 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
1865 ptrdiff_t wrap_y, wrap_c;
1867 for (i = 0; i < mb_block_count; i++)
1871 const int last_qp = s->
qscale;
1872 const int mb_xy = mb_x + mb_y * s->
mb_stride;
1903 (mb_y * 16 * wrap_y) + mb_x * 16;
1905 (mb_y * mb_block_height * wrap_c) + mb_x * 8;
1907 (mb_y * mb_block_height * wrap_c) + mb_x * 8;
1909 if (mb_x * 16 + 16 > s->
width || mb_y * 16 + 16 > s->
height) {
1913 16, 16, mb_x * 16, mb_y * 16,
1918 8, mb_block_height, mb_x * 8, mb_y * 8,
1920 ptr_cb = ebuf + 18 * wrap_y;
1923 8, mb_block_height, mb_x * 8, mb_y * 8,
1925 ptr_cr = ebuf + 18 * wrap_y + 8;
1930 int progressive_score, interlaced_score;
1935 NULL, wrap_y, 8) - 400;
1937 if (progressive_score > 0) {
1939 NULL, wrap_y * 2, 8) +
1941 NULL, wrap_y * 2, 8);
1942 if (progressive_score > interlaced_score) {
1945 dct_offset = wrap_y;
1966 ptr_cb + (dct_offset >> 1), wrap_c);
1968 ptr_cr + (dct_offset >> 1), wrap_c);
1974 uint8_t *dest_y, *dest_cb, *dest_cr;
1976 dest_y = s->
dest[0];
1977 dest_cb = s->
dest[1];
1978 dest_cr = s->
dest[2];
2002 int progressive_score, interlaced_score;
2005 progressive_score = s->
mecc.
ildct_cmp[0](s, dest_y, ptr_y, wrap_y, 8) +
2011 progressive_score -= 400;
2013 if (progressive_score > 0) {
2020 if (progressive_score > interlaced_score) {
2023 dct_offset = wrap_y;
2034 dest_y + dct_offset, wrap_y);
2036 dest_y + dct_offset + 8, wrap_y);
2046 dest_cb + (dct_offset >> 1), wrap_c);
2048 dest_cr + (dct_offset >> 1), wrap_c);
2059 if (s->
mecc.
sad[1](
NULL, ptr_y + dct_offset, dest_y + dct_offset,
2060 wrap_y, 8) < 20 * s->
qscale)
2062 if (s->
mecc.
sad[1](
NULL, ptr_y + dct_offset + 8, dest_y + dct_offset + 8,
2063 wrap_y, 8) < 20 * s->
qscale)
2070 if (s->
mecc.
sad[1](
NULL, ptr_cb + (dct_offset >> 1),
2071 dest_cb + (dct_offset >> 1),
2072 wrap_c, 8) < 20 * s->
qscale)
2074 if (s->
mecc.
sad[1](
NULL, ptr_cr + (dct_offset >> 1),
2075 dest_cr + (dct_offset >> 1),
2076 wrap_c, 8) < 20 * s->
qscale)
2103 memcpy(orig[0], s->
block[0],
sizeof(int16_t) * 64 * mb_block_count);
2109 for (i = 0; i < mb_block_count; i++) {
2124 for (i = 0; i < mb_block_count; i++) {
2134 for (i = 0; i < 4; i++)
2137 for (i = 4; i < mb_block_count; i++)
2141 for (i = 0; i < mb_block_count; i++) {
2157 for (i = 0; i < mb_block_count; i++) {
2160 for (j = 63; j > 0; j--) {
2248 memcpy(d->
mv, s->
mv, 2*4*2*
sizeof(
int));
2286 int *dmin,
int *next_block,
int motion_x,
int motion_y)
2294 s->
pb= pb[*next_block];
2296 s->
pb2 = pb2 [*next_block];
2297 s->
tex_pb= tex_pb[*next_block];
2301 memcpy(dest_backup, s->
dest,
sizeof(s->
dest));
2324 memcpy(s->
dest, dest_backup,
sizeof(s->
dest));
2342 else if(w==8 && h==8)
2428 for(mb_x=0; mb_x < s->
mb_width; mb_x++) {
2436 (((unsigned) sum * sum) >> 8) + 500 + 128) >> 8;
2473 bytestream_put_le32(&ptr, offset);
2474 bytestream_put_byte(&ptr, s->
qscale);
2475 bytestream_put_byte(&ptr, gobn);
2476 bytestream_put_le16(&ptr, mba);
2477 bytestream_put_byte(&ptr, pred_x);
2478 bytestream_put_byte(&ptr, pred_y);
2480 bytestream_put_byte(&ptr, 0);
2481 bytestream_put_byte(&ptr, 0);
2570 for(mb_x=0; mb_x < s->
mb_width; mb_x++) {
2601 int current_packet_size, is_gob_start;
2607 if(s->
start_mb_y == mb_y && mb_y > 0 && mb_x==0) is_gob_start=1;
2616 if(s->
mb_x==0 && s->
mb_y!=0) is_gob_start=1;
2638 current_packet_size=0;
2696 int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
2713 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb,
2714 &dmin, &next_block, s->
mv[0][0][0], s->
mv[0][0][1]);
2725 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb,
2726 &dmin, &next_block, 0, 0);
2734 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb,
2735 &dmin, &next_block, s->
mv[0][0][0], s->
mv[0][0][1]);
2745 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb,
2746 &dmin, &next_block, 0, 0);
2754 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb,
2755 &dmin, &next_block, s->
mv[0][0][0], s->
mv[0][0][1]);
2763 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb,
2764 &dmin, &next_block, s->
mv[1][0][0], s->
mv[1][0][1]);
2774 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb,
2775 &dmin, &next_block, 0, 0);
2786 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb,
2787 &dmin, &next_block, 0, 0);
2798 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb,
2799 &dmin, &next_block, 0, 0);
2805 for(dir=0; dir<2; dir++){
2812 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb,
2813 &dmin, &next_block, 0, 0);
2821 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb,
2822 &dmin, &next_block, 0, 0);
2833 const int last_qp= backup_s.
qscale;
2837 static const int dquant_tab[4]={-1,1,-2,2};
2839 assert(backup_s.
dquant == 0);
2845 s->
mv[0][0][0] = best_s.
mv[0][0][0];
2846 s->
mv[0][0][1] = best_s.
mv[0][0][1];
2847 s->
mv[1][0][0] = best_s.
mv[1][0][0];
2848 s->
mv[1][0][1] = best_s.
mv[1][0][1];
2851 for(; qpi<4; qpi++){
2852 int dquant= dquant_tab[qpi];
2864 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,
2865 &dmin, &next_block, s->
mv[mvdir][0][0], s->
mv[mvdir][0][1]);
2885 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
2886 &dmin, &next_block, mx, my);
2893 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
2894 &dmin, &next_block, 0, 0);
2902 memcpy(s->
mv, best_s.
mv,
sizeof(s->
mv));
2923 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,
2924 &dmin, &next_block, mx, my);
2964 int motion_x = 0, motion_y = 0;
2972 motion_x= s->
mv[0][0][0] = 0;
2973 motion_y= s->
mv[0][0][1] = 0;
3060 for(dir=0; dir<2; dir++){
3134 #define MERGE(field) dst->field += src->field; src->field=0
3161 for(i=0; i<64; i++){
3268 for(i=1; i<context_count; i++){
3298 for(i=1; i<context_count; i++){
3309 av_dlog(s,
"Scene change detected, encoding as I Frame %d %d\n",
3353 for(dir=0; dir<2; dir++){
3434 for(i=1; i<context_count; i++){
3438 for(i=1; i<context_count; i++){
3451 for(i=0; i<64; i++){
3452 int level= block[i];
3458 if(level<0) level=0;
3462 if(level>0) level=0;
3470 int16_t *
block,
int n,
3471 int qscale,
int *overflow){
3476 unsigned int threshold1, threshold2;
3488 int coeff_count[64];
3489 int qmul, qadd, start_i, last_non_zero, i,
dc;
3500 qadd= ((qscale-1)|1)*8;
3517 block[0] = (block[0] + (q >> 1)) / q;
3535 threshold2= (threshold1<<1);
3537 for(i=63; i>=start_i; i--) {
3538 const int j = scantable[i];
3539 int level = block[j] * qmat[j];
3541 if(((
unsigned)(level+threshold1))>threshold2){
3547 for(i=start_i; i<=last_non_zero; i++) {
3548 const int j = scantable[i];
3549 int level = block[j] * qmat[j];
3553 if(((
unsigned)(level+threshold1))>threshold2){
3557 coeff[1][i]= level-1;
3561 coeff[0][i]= -
level;
3562 coeff[1][i]= -level+1;
3565 coeff_count[i]=
FFMIN(level, 2);
3566 assert(coeff_count[i]);
3569 coeff[0][i]= (level>>31)|1;
3576 if(last_non_zero < start_i){
3577 memset(block + start_i, 0, (64-start_i)*
sizeof(int16_t));
3578 return last_non_zero;
3581 score_tab[start_i]= 0;
3582 survivor[0]= start_i;
3585 for(i=start_i; i<=last_non_zero; i++){
3586 int level_index, j, zero_distortion;
3587 int dct_coeff=
FFABS(block[ scantable[i] ]);
3588 int best_score=256*256*256*120;
3592 zero_distortion= dct_coeff*dct_coeff;
3594 for(level_index=0; level_index < coeff_count[i]; level_index++){
3596 int level= coeff[level_index][i];
3597 const int alevel=
FFABS(level);
3603 unquant_coeff= alevel*qmul + qadd;
3607 unquant_coeff = (int)( alevel * qscale * s->
intra_matrix[j]) >> 3;
3608 unquant_coeff = (unquant_coeff - 1) | 1;
3610 unquant_coeff = ((( alevel << 1) + 1) * qscale * ((int) s->
inter_matrix[j])) >> 4;
3611 unquant_coeff = (unquant_coeff - 1) | 1;
3616 distortion= (unquant_coeff - dct_coeff) * (unquant_coeff - dct_coeff) - zero_distortion;
3618 if((level&(~127)) == 0){
3619 for(j=survivor_count-1; j>=0; j--){
3620 int run= i - survivor[j];
3622 score += score_tab[i-
run];
3624 if(score < best_score){
3627 level_tab[i+1]= level-64;
3632 for(j=survivor_count-1; j>=0; j--){
3633 int run= i - survivor[j];
3635 score += score_tab[i-
run];
3636 if(score < last_score){
3639 last_level= level-64;
3645 distortion += esc_length*
lambda;
3646 for(j=survivor_count-1; j>=0; j--){
3647 int run= i - survivor[j];
3648 int score= distortion + score_tab[i-
run];
3650 if(score < best_score){
3653 level_tab[i+1]= level-64;
3658 for(j=survivor_count-1; j>=0; j--){
3659 int run= i - survivor[j];
3660 int score= distortion + score_tab[i-
run];
3661 if(score < last_score){
3664 last_level= level-64;
3672 score_tab[i+1]= best_score;
3675 if(last_non_zero <= 27){
3676 for(; survivor_count; survivor_count--){
3677 if(score_tab[ survivor[survivor_count-1] ] <= best_score)
3681 for(; survivor_count; survivor_count--){
3682 if(score_tab[ survivor[survivor_count-1] ] <= best_score + lambda)
3687 survivor[ survivor_count++ ]= i+1;
3691 last_score= 256*256*256*120;
3692 for(i= survivor[0]; i<=last_non_zero + 1; i++){
3693 int score= score_tab[i];
3694 if(i) score += lambda*2;
3696 if(score < last_score){
3699 last_level= level_tab[i];
3700 last_run= run_tab[i];
3707 dc=
FFABS(block[0]);
3708 last_non_zero= last_i - 1;
3709 memset(block + start_i, 0, (64-start_i)*
sizeof(int16_t));
3711 if(last_non_zero < start_i)
3712 return last_non_zero;
3714 if(last_non_zero == 0 && start_i == 0){
3716 int best_score= dc *
dc;
3718 for(i=0; i<coeff_count[0]; i++){
3719 int level= coeff[i][0];
3720 int alevel=
FFABS(level);
3721 int unquant_coeff, score, distortion;
3724 unquant_coeff= (alevel*qmul + qadd)>>3;
3726 unquant_coeff = ((( alevel << 1) + 1) * qscale * ((int) s->
inter_matrix[0])) >> 4;
3727 unquant_coeff = (unquant_coeff - 1) | 1;
3729 unquant_coeff = (unquant_coeff + 4) >> 3;
3730 unquant_coeff<<= 3 + 3;
3732 distortion= (unquant_coeff -
dc) * (unquant_coeff - dc);
3735 else score= distortion + esc_length*
lambda;
3737 if(score < best_score){
3739 best_level= level - 64;
3742 block[0]= best_level;
3744 if(best_level == 0)
return -1;
3745 else return last_non_zero;
3751 block[ perm_scantable[last_non_zero] ]= last_level;
3754 for(; i>start_i; i -= run_tab[i] + 1){
3755 block[ perm_scantable[i-1] ]= level_tab[i];
3758 return last_non_zero;
3773 int perm_index= perm[
index];
3774 if(i==0) s*= sqrt(0.5);
3775 if(j==0) s*= sqrt(0.5);
3776 basis[perm_index][8*x + y]=
lrintf(s * cos((M_PI/8.0)*i*(x+0.5)) * cos((M_PI/8.0)*j*(y+0.5)));
3784 int16_t *
block, int16_t *weight, int16_t *orig,
3795 int qmul, qadd, start_i, last_non_zero, i,
dc;
3799 int rle_index,
run, q = 1, sum;
3802 static int after_last=0;
3803 static int to_zero=0;
3804 static int from_zero=0;
3807 static int messed_sign=0;
3810 if(basis[0][0] == 0)
3847 for(i=0; i<64; i++){
3854 for(i=0; i<64; i++){
3859 w=
FFABS(weight[i]) + qns*one;
3860 w= 15 + (48*qns*one + w/2)/w;
3875 for(i=start_i; i<=last_non_zero; i++){
3876 int j= perm_scantable[i];
3877 const int level= block[j];
3881 if(level<0) coeff= qmul*level - qadd;
3882 else coeff= qmul*level + qadd;
3883 run_tab[rle_index++]=
run;
3892 if(last_non_zero>0){
3903 int run2, best_unquant_change=0, analyze_gradient;
3909 if(analyze_gradient){
3913 for(i=0; i<64; i++){
3929 const int level= block[0];
3930 int change, old_coeff;
3936 for(change=-1; change<=1; change+=2){
3937 int new_level= level + change;
3938 int score, new_coeff;
3940 new_coeff= q*new_level;
3941 if(new_coeff >= 2048 || new_coeff < 0)
3945 new_coeff - old_coeff);
3946 if(score<best_score){
3949 best_change= change;
3950 best_unquant_change= new_coeff - old_coeff;
3957 run2= run_tab[rle_index++];
3961 for(i=start_i; i<64; i++){
3962 int j= perm_scantable[i];
3963 const int level= block[j];
3964 int change, old_coeff;
3970 if(level<0) old_coeff= qmul*level - qadd;
3971 else old_coeff= qmul*level + qadd;
3972 run2= run_tab[rle_index++];
3976 assert(run2>=0 || i >= last_non_zero );
3979 for(change=-1; change<=1; change+=2){
3980 int new_level= level + change;
3981 int score, new_coeff, unquant_change;
3988 if(new_level<0) new_coeff= qmul*new_level - qadd;
3989 else new_coeff= qmul*new_level + qadd;
3990 if(new_coeff >= 2048 || new_coeff <= -2048)
3995 if(level < 63 && level > -63){
3996 if(i < last_non_zero)
4004 assert(
FFABS(new_level)==1);
4006 if(analyze_gradient){
4007 int g= d1[ scantable[i] ];
4008 if(g && (g^new_level) >= 0)
4012 if(i < last_non_zero){
4013 int next_i= i + run2 + 1;
4014 int next_level= block[ perm_scantable[next_i] ] + 64;
4016 if(next_level&(~127))
4019 if(next_i < last_non_zero)
4037 assert(
FFABS(level)==1);
4039 if(i < last_non_zero){
4040 int next_i= i + run2 + 1;
4041 int next_level= block[ perm_scantable[next_i] ] + 64;
4043 if(next_level&(~127))
4046 if(next_i < last_non_zero)
4065 unquant_change= new_coeff - old_coeff;
4066 assert((score < 100*lambda && score > -100*lambda) || lambda==0);
4070 if(score<best_score){
4073 best_change= change;
4074 best_unquant_change= unquant_change;
4078 prev_level= level + 64;
4079 if(prev_level&(~127))
4092 int j= perm_scantable[ best_coeff ];
4094 block[j] += best_change;
4096 if(best_coeff > last_non_zero){
4097 last_non_zero= best_coeff;
4105 if(block[j] - best_change){
4106 if(
FFABS(block[j]) >
FFABS(block[j] - best_change)){
4118 for(; last_non_zero>=start_i; last_non_zero--){
4119 if(block[perm_scantable[last_non_zero]])
4125 if(256*256*256*64 % count == 0){
4126 printf(
"after_last:%d to_zero:%d from_zero:%d raise:%d lower:%d sign:%d xyp:%d/%d/%d\n", after_last, to_zero, from_zero,
raise, lower, messed_sign, s->
mb_x, s->
mb_y, s->
picture_number);
4131 for(i=start_i; i<=last_non_zero; i++){
4132 int j= perm_scantable[i];
4133 const int level= block[j];
4136 run_tab[rle_index++]=
run;
4149 if(last_non_zero>0){
4155 return last_non_zero;
4159 int16_t *
block,
int n,
4160 int qscale,
int *overflow)
4162 int i, j,
level, last_non_zero, q, start_i;
4167 unsigned int threshold1, threshold2;
4186 block[0] = (block[0] + (q >> 1)) / q;
4198 threshold2= (threshold1<<1);
4199 for(i=63;i>=start_i;i--) {
4201 level = block[j] * qmat[j];
4203 if(((
unsigned)(level+threshold1))>threshold2){
4210 for(i=start_i; i<=last_non_zero; i++) {
4212 level = block[j] * qmat[j];
4216 if(((
unsigned)(level+threshold1))>threshold2){
4234 scantable, last_non_zero);
4236 return last_non_zero;
4239 #define OFFSET(x) offsetof(MpegEncContext, x)
4240 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
4244 {
"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 },
4301 .
name =
"msmpeg4v2",
4310 .priv_class = &msmpeg4v2_class,
4325 .priv_class = &msmpeg4v3_class,
4340 .priv_class = &wmv1_class,
const uint16_t ff_mpeg1_default_non_intra_matrix[64]
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx)
void ff_h261_reorder_mb_index(MpegEncContext *s)
int(* try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale)
av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
int chroma_elim_threshold
void ff_jpeg_fdct_islow_10(int16_t *data)
static const AVOption h263_options[]
int frame_bits
bits used for the current frame
int ff_mpeg_ref_picture(MpegEncContext *s, Picture *dst, Picture *src)
RateControlContext rc_context
contains stuff only accessed in ratecontrol.c
const struct AVCodec * codec
av_cold void ff_rate_control_uninit(MpegEncContext *s)
#define FF_MPV_FLAG_STRICT_GOP
void ff_init_block_index(MpegEncContext *s)
void ff_estimate_b_frame_motion(MpegEncContext *s, int mb_x, int mb_y)
qpel_mc_func avg_qpel_pixels_tab[2][16]
#define MAX_PICTURE_COUNT
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[6][64])
me_cmp_func frame_skip_cmp[6]
#define CANDIDATE_MB_TYPE_SKIPPED
void(* dct_unquantize_inter)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
void av_free_packet(AVPacket *pkt)
Free a packet.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static void get_visual_weight(int16_t *weight, uint8_t *ptr, int stride)
int time_increment_bits
< number of bits to represent the fractional part of time (encoder only)
void ff_h263_encode_picture_header(MpegEncContext *s, int picture_number)
This structure describes decoded (raw) audio or video data.
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared)
Allocate a Picture.
int16_t(* p_mv_table)[2]
MV table (1MV per MB) p-frame encoding.
int mpeg_quant
0-> h263 quant 1-> mpeg quant
uint8_t * rd_scratchpad
scratchpad for rate distortion mb decision
void ff_fdct_ifast(int16_t *data)
#define FF_MB_DECISION_BITS
chooses the one which needs the fewest bits
uint8_t * fcode_tab
smallest fcode needed for each MV
int start_mb_y
start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) ...
#define MV_TYPE_FIELD
2 vectors, one per field
void ff_estimate_p_frame_motion(MpegEncContext *s, int mb_x, int mb_y)
const uint8_t * y_dc_scale_table
qscale -> y_dc_scale table
uint8_t * mb_mean
Table for MB luminance.
uint64_t error[AV_NUM_DATA_POINTERS]
error
#define CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
int last_mv[2][2][2]
last MV, used for MV prediction in MPEG1 & B-frame MPEG4
int pre_pass
= 1 for the pre pass
op_pixels_func avg_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
#define FF_MPV_FLAG_SKIP_RD
#define FF_MPV_GENERIC_CLASS(name)
AVFrame * tmp_frames[MAX_B_FRAMES+2]
qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16]
void(* shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height)
#define CANDIDATE_MB_TYPE_INTER_I
float border_masking
Border processing masking, raises the quantizer for mbs on the borders of the picture.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
#define CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
void ff_h263_encode_init(MpegEncContext *s)
AVFrame * coded_frame
the picture in the bitstream
int end_mb_y
end mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) ...
void ff_init_qscale_tab(MpegEncContext *s)
init s->current_picture.qscale_table from s->lambda_table
uint16_t * mb_var
Table for MB variances.
void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last)
Permute an 8x8 block.
static int estimate_qp(MpegEncContext *s, int dry_run)
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
int16_t(*[3] ac_val)[16]
used for for mpeg4 AC prediction, all 3 arrays must be continuous
void(* add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale)
int v_edge_pos
horizontal / vertical position of the right/bottom edge (pixel replication)
#define FF_MPV_COMMON_OPTS
enum AVColorRange color_range
MPEG vs JPEG YUV range.
int msmpeg4_version
0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
#define CANDIDATE_MB_TYPE_BIDIR
av_cold void ff_h263dsp_init(H263DSPContext *ctx)
void(* rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb)
void ff_get_2pass_fcode(MpegEncContext *s)
void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
int obmc
overlapped block motion compensation
void avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
void ff_mpeg1_clean_buffers(MpegEncContext *s)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
void ff_msmpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
int ff_h261_get_picture_format(int width, int height)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int16_t(*[2][2] p_field_mv_table)[2]
MV table (2MV per MB) interlaced p-frame encoding.
static int select_input_picture(MpegEncContext *s)
int min_qcoeff
minimum encodable coefficient
static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride)
#define CONFIG_MPEG2VIDEO_ENCODER
int ildct_cmp
interlaced DCT comparison function
void(* qpel_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
#define FF_ARRAY_ELEMS(a)
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
int mpv_flags
flags set by private options
int intra_quant_bias
intra quantizer bias
static const AVClass h263_class
uint8_t * intra_ac_vlc_length
int padding_bug_score
used to detect the VERY common padding bug in MPEG4
const uint16_t ff_h263_format[8][2]
#define UNI_AC_ENC_INDEX(run, level)
int mb_num
number of MBs of a picture
av_cold void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx)
int lmax
maximum Lagrange multipler
int frame_skip_cmp
frame skip comparison function
static void clip_coeffs(MpegEncContext *s, int16_t *block, int last_index)
An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of structures with info about macroblo...
static void write_mb_info(MpegEncContext *s)
int time_base
time in seconds of last I,P,S Frame
int h263_aic
Advanded INTRA Coding (AIC)
int16_t(* b_back_mv_table)[2]
MV table (1MV per MB) backward mode b-frame encoding.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
int encoding
true if we are encoding (vs decoding)
uint64_t vbv_delay
VBV delay coded in the last frame (in periods of a 27 MHz clock).
void(* dct_unquantize_h263_intra)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
void(* dct_unquantize_intra)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
#define CODEC_FLAG_QPEL
Use qpel MC.
int scenechange_threshold
scene change detection threshold 0 is default, larger means fewer detected scene changes.
uint32_t ff_square_tab[512]
void ff_mpeg4_merge_partitions(MpegEncContext *s)
static int mb_var_thread(AVCodecContext *c, void *arg)
void ff_clean_intra_table_entries(MpegEncContext *s)
Clean dc, ac, coded_block for the current non-intra MB.
void(* dct_unquantize_h263_inter)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
#define FF_MPV_FLAG_CBP_RD
int skipdct
skip dct and code zero residual
void ff_mpeg4_clean_buffers(MpegEncContext *s)
#define CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define CANDIDATE_MB_TYPE_INTER
float p_masking
p block masking (0-> disabled)
int picture_in_gop_number
0-> first pic in gop, ...
int alt_inter_vlc
alternative inter vlc
int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow)
int64_t time
time of current frame
static int encode_picture(MpegEncContext *s, int picture_number)
#define CONFIG_WMV2_ENCODER
av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, AVCodecContext *avctx)
int bit_rate_tolerance
number of bits the bitstream is allowed to diverge from the reference.
#define MV_DIRECT
bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4) ...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Picture ** input_picture
next pictures on display order for encoding
#define CANDIDATE_MB_TYPE_INTER4V
void(* denoise_dct)(struct MpegEncContext *s, int16_t *block)
PutBitContext pb2
used for data partitioned VOPs
enum OutputFormat out_format
output format
#define CANDIDATE_MB_TYPE_FORWARD_I
#define CONFIG_MJPEG_ENCODER
uint16_t(* dct_offset)[64]
void ff_mpv_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t **ref_picture, op_pixels_func(*pix_op)[4], qpel_mc_func(*qpix_op)[16])
static void mpv_encode_defaults(MpegEncContext *s)
Set the given MpegEncContext to defaults for encoding.
Multithreading support functions.
int pre_dia_size
ME prepass diamond size & shape.
static const AVOption h263p_options[]
static int get_sae(uint8_t *src, int ref, int stride)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int misc_bits
cbp, mb_type
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int no_rounding
apply no rounding to motion compensation (MPEG4, msmpeg4, ...) for b-frames rounding mode is always 0...
#define CANDIDATE_MB_TYPE_BACKWARD_I
int me_cmp
motion estimation comparison function
void ff_mpv_decode_mb(MpegEncContext *s, int16_t block[12][64])
void ff_mpeg4_encode_video_packet_header(MpegEncContext *s)
Picture current_picture
copy of the current picture structure.
int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of video.
#define PICT_BOTTOM_FIELD
static double av_q2d(AVRational a)
Convert rational to double.
int16_t(* b_bidir_forw_mv_table)[2]
MV table (1MV per MB) bidir mode b-frame encoding.
static void dct_single_coeff_elimination(MpegEncContext *s, int n, int threshold)
const uint16_t ff_aanscales[64]
uint8_t(* mv_penalty)[MAX_MV *2+1]
amount of bits needed to encode a MV
#define CONFIG_RV20_ENCODER
void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number)
int mb_threshold
Macroblock threshold below which the user specified macroblock types will be used.
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
void ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number)
uint16_t pp_time
time distance between the last 2 p,s,i frames
#define CONFIG_H261_ENCODER
const uint8_t * scantable
int flags2
AVCodecContext.flags2.
av_cold void ff_mpv_idct_init(MpegEncContext *s)
int mb_height
number of MBs horizontally & vertically
float lumi_masking
luminance masking (0-> disabled)
char * stats_out
pass1 encoding statistics output buffer
int max_qcoeff
maximum encodable coefficient
high precision timer, useful to profile code
static void update_noise_reduction(MpegEncContext *s)
#define FF_MPV_FLAG_QP_RD
#define CODEC_FLAG_AC_PRED
H.263 advanced intra coding / MPEG-4 AC prediction.
void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number)
int dquant
qscale difference to prev qscale
int num_entries
number of RateControlEntries
int gop_picture_number
index of the first picture of a GOP based on fake_pic_num & mpeg1 specific
static void ff_update_block_index(MpegEncContext *s)
void ff_set_qscale(MpegEncContext *s, int qscale)
set qscale and update qscale dependent variables.
#define ROUNDED_DIV(a, b)
int(* q_inter_matrix)[64]
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int get_bits_diff(MpegEncContext *s)
#define CODEC_FLAG_LOOP_FILTER
loop filter
int(* q_intra_matrix)[64]
precomputed matrix (combine qscale and DCT renorm)
int intra_only
if true, only intra pictures are generated
av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
const uint16_t ff_mpeg1_default_intra_matrix[64]
int16_t * dc_val[3]
used for mpeg4 DC prediction, all 3 arrays must be continuous
int h263_plus
h263 plus headers
int slice_context_count
number of used thread_contexts
int last_non_b_pict_type
used for mpeg4 gmc b-frames & ratecontrol
int ff_wmv2_encode_picture_header(MpegEncContext *s, int picture_number)
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
int has_b_frames
Size of the frame reordering buffer in the decoder.
static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, int motion_y, int mb_block_height, int mb_block_count)
int last_dc[3]
last DC values for MPEG1
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
uint8_t * inter_ac_vlc_last_length
#define CODEC_FLAG_INTERLACED_ME
interlaced motion estimation
int mb_skipped
MUST BE SET only during DECODING.
int strict_std_compliance
strictly follow the std (MPEG4, ...)
int partitioned_frame
is current frame partitioned
int frame_skip_threshold
frame skip threshold
av_cold int ff_rate_control_init(MpegEncContext *s)
int me_sub_cmp
subpixel motion estimation comparison function
void(* get_pixels)(int16_t *block, const uint8_t *pixels, int line_size)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int qmax
maximum quantizer
static void update_mb_info(MpegEncContext *s, int startcode)
void ff_write_pass1_stats(MpegEncContext *s)
int unrestricted_mv
mv can point outside of the coded picture
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int last_lambda_for[5]
last lambda for a specific pict type
static int sse_mb(MpegEncContext *s)
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
static int dct_quantize_trellis_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow)
void(* dct_unquantize_mpeg2_inter)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, ScanTable *intra_scantable, uint16_t intra_matrix[64])
void(* dct_unquantize_mpeg1_intra)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
int h263_slice_structured
void ff_msmpeg4_encode_picture_header(MpegEncContext *s, int picture_number)
#define CODEC_FLAG_QSCALE
Use fixed qscale.
int rc_max_rate
maximum bitrate
int64_t av_gcd(int64_t a, int64_t b)
Return the greatest common divisor of a and b.
void av_log(void *avcl, int level, const char *fmt,...)
MpegvideoEncDSPContext mpvencdsp
const char * name
Name of the codec implementation.
int quarter_sample
1->qpel, 0->half pel ME/MC
uint16_t * mb_type
Table for candidate MB types for encoding (defines in mpegutils.h)
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Shrink the already allocated side data buffer.
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
int low_delay
no reordering needed / has no b-frames
qpel_mc_func put_qpel_pixels_tab[2][16]
void ff_mpeg_unref_picture(MpegEncContext *s, Picture *pic)
Deallocate a picture.
uint8_t *[2][2] b_field_select_table
void ff_mpv_common_end(MpegEncContext *s)
#define CODEC_FLAG_LOW_DELAY
Force low delay.
int flags
A combination of AV_PKT_FLAG values.
static int put_bits_count(PutBitContext *s)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static void frame_end(MpegEncContext *s)
int resync_mb_x
x position of last resync marker
int rc_buffer_size
decoder bitstream buffer size
void ff_clean_h263_qscales(MpegEncContext *s)
modify qscale so that encoding is acually possible in h263 (limit difference to -2..2)
int coded_picture_number
used to set pic->coded_picture_number, should not be used for/by anything else
static int estimate_best_b_count(MpegEncContext *s)
int intra_dc_precision
precision of the intra DC coefficient - 8
int me_penalty_compensation
common internal API header
uint8_t * intra_ac_vlc_last_length
void ff_h263_loop_filter(MpegEncContext *s)
void(* op_pixels_func)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
int bit_rate
the average bitrate
enum AVPictureType pict_type
Picture type of the frame.
int ff_h263_get_gob_height(MpegEncContext *s)
Get the GOB height based on picture height.
int display_picture_number
picture number in display order
uint16_t(* q_inter_matrix16)[2][64]
uint8_t * vbv_delay_ptr
pointer to vbv_delay in the bitstream
int fixed_qscale
fixed qscale if non zero
void ff_clean_mpeg4_qscales(MpegEncContext *s)
modify mb_type & qscale so that encoding is acually possible in mpeg4
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
int me_method
ME algorithm.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
int umvplus
== H263+ && unrestricted_mv
Picture new_picture
copy of the source picture structure for encoding.
int intra_quant_bias
bias for the quantizer
int width
picture width / height.
#define CONFIG_MPEG1VIDEO_ENCODER
int(* pix_sum)(uint8_t *pix, int line_size)
int16_t(*[2] motion_val)[2]
Picture * current_picture_ptr
pointer to the current picture
float rc_max_available_vbv_use
Ratecontrol attempt to use, at maximum, of what can be used without an underflow. ...
void ff_msmpeg4_encode_init(MpegEncContext *s)
float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
uint16_t(* q_intra_matrix16)[2][64]
identical to the above but for MMX & these are not permutated, second 64 entries are bias ...
static av_always_inline av_const long int lrintf(float x)
#define FF_MB_DECISION_SIMPLE
uses mb_cmp
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
int(* ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2]
[mb_intra][isChroma][level][run][last]
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
#define CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
void ff_wmv2_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
int block_last_index[12]
last non zero coefficient in block
static int dct_quantize_refine(MpegEncContext *s, int16_t *block, int16_t *weight, int16_t *orig, int n, int qscale)
uint8_t idct_permutation[64]
IDCT input permutation.
const int16_t ff_mpeg4_default_non_intra_matrix[64]
int mb_decision
macroblock decision mode
static int get_intra_count(MpegEncContext *s, uint8_t *src, uint8_t *ref, int stride)
uint8_t * mbintra_table
used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding
int ac_esc_length
num of bits needed to encode the longest esc
preferred ID for MPEG-1/2 video decoding
#define CONFIG_MPEG4_ENCODER
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
int block_index[6]
index to current MB in block based arrays with edges
the normal 2^n-1 "JPEG" YUV ranges
if(ac->has_optimized_func)
int * mb_index2xy
mb_index -> mb_x + mb_y*mb_stride
int inter_quant_bias
inter quantizer bias
static uint8_t default_fcode_tab[MAX_MV *2+1]
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
static void build_basis(uint8_t *perm)
#define MV_TYPE_16X16
1 vector for the whole mb
int frame_skip_factor
frame skip factor
int first_slice_line
used in mpeg4 too to handle resync markers
uint16_t * mc_mb_var
Table for motion compensated MB variances.
void ff_flv_encode_picture_header(MpegEncContext *s, int picture_number)
const uint8_t *const ff_mpeg2_dc_scale_table[4]
int coded_picture_number
picture number in bitstream order
#define AV_LOG_INFO
Standard information.
uint16_t inter_matrix[64]
uint64_t error[AV_NUM_DATA_POINTERS]
error
void ff_jpeg_fdct_islow_8(int16_t *data)
void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
struct MpegEncContext * thread_context[MAX_THREADS]
#define CONFIG_MSMPEG4_ENCODER
unsigned int lambda2
(lambda*lambda) >> FF_LAMBDA_SHIFT
#define CODEC_FLAG_NORMALIZE_AQP
void ff_faandct(int16_t *data)
double buffer_index
amount of bits in the video/audio buffer
Libavcodec external API header.
void ff_free_picture_tables(Picture *pic)
void ff_h263_update_motion_val(MpegEncContext *s)
int h263_flv
use flv h263 header
static const AVClass h263p_class
ptrdiff_t linesize
line size, in bytes, may be different from width
static av_const unsigned int ff_sqrt(unsigned int a)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
void ff_convert_matrix(MpegEncContext *s, int(*qmat)[64], uint16_t(*qmat16)[2][64], const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra)
const uint16_t ff_inv_aanscales[64]
void ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type)
int frame_bits
number of bits used for the previously encoded frame
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
void ff_mjpeg_encode_close(MpegEncContext *s)
void(* fdct)(int16_t *block)
main external API structure.
#define CONFIG_H263_ENCODER
static void close(AVCodecParserContext *s)
ScanTable intra_scantable
int pre_me
prepass for motion estimation
int qmin
minimum quantizer
int height
picture size. must be a multiple of 16
#define FF_DEFAULT_QUANT_BIAS
static void write_slice_end(MpegEncContext *s)
int64_t dts_delta
pts difference between the first and second input frame, used for calculating dts of the first frame ...
int64_t user_specified_pts
last non-zero pts from AVFrame which was passed into avcodec_encode_video2()
static void denoise_dct_c(MpegEncContext *s, int16_t *block)
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
static int frame_start(MpegEncContext *s)
float spatial_cplx_masking
spatial complexity masking (0-> disabled)
void ff_fix_long_p_mvs(MpegEncContext *s)
Picture * picture
main picture buffer
int data_partitioning
data partitioning flag from header
uint8_t * inter_ac_vlc_length
uint16_t * intra_matrix
custom intra quantization matrix
void ff_h263_encode_gob_header(MpegEncContext *s, int mb_line)
Encode a group of blocks header.
Describe the class of an AVClass context structure.
int16_t(*[2][2][2] b_field_mv_table)[2]
MV table (4MV per MB) interlaced b-frame encoding.
int(* pix_norm1)(uint8_t *pix, int line_size)
#define CANDIDATE_MB_TYPE_DIRECT
#define FF_MB_DECISION_RD
rate distortion
static void copy_context_after_encode(MpegEncContext *d, MpegEncContext *s, int type)
op_pixels_func put_no_rnd_pixels_tab[2][4]
Halfpel motion compensation with no rounding (a+b)>>1.
int input_picture_number
used to set pic->display_picture_number, should not be used for/by anything else
const uint8_t ff_zigzag_direct[64]
av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx)
ptrdiff_t uvlinesize
line size, for chroma in bytes, may be different from width
int mb_info
interval for outputting info about mb offsets as side data
void ff_set_mpeg4_time(MpegEncContext *s)
static void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type)
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
int frame_skip_exp
frame skip exponent
#define CANDIDATE_MB_TYPE_BIDIR_I
void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
const int16_t ff_mpeg4_default_intra_matrix[64]
int f_code
forward MV resolution
int ff_pre_estimate_p_frame_motion(MpegEncContext *s, int mb_x, int mb_y)
#define CANDIDATE_MB_TYPE_DIRECT0
int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my)
static uint8_t default_mv_penalty[MAX_FCODE+1][MAX_MV *2+1]
#define CODEC_FLAG_CLOSED_GOP
uint16_t * inter_matrix
custom inter quantization matrix
int max_b_frames
max number of b-frames for encoding
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix)
int bit_rate
wanted bit rate
static av_always_inline void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
int last_mv_dir
last mv_dir, used for b frame encoding
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
int h263_pred
use mpeg4/h263 ac/dc predictions
int16_t(* b_bidir_back_mv_table)[2]
MV table (1MV per MB) bidir mode b-frame encoding.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
float dark_masking
darkness masking (0-> disabled)
float temporal_cplx_masking
temporary complexity masking (0-> disabled)
int ff_init_me(MpegEncContext *s)
uint8_t *[2] p_field_select_table
int16_t(* b_direct_mv_table)[2]
MV table (1MV per MB) direct mode b-frame encoding.
AAN (Arai Agui Nakajima) (I)DCT tables.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const uint8_t * c_dc_scale_table
qscale -> c_dc_scale table
int mv[2][4][2]
motion vectors for a macroblock first coordinate : 0 = forward 1 = backward second " : depend...
int16_t(* b_forw_mv_table)[2]
MV table (1MV per MB) forward mode b-frame encoding.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
int noise_reduction
noise reduction strength
static int estimate_motion_thread(AVCodecContext *c, void *arg)
Picture * next_picture_ptr
pointer to the next picture (for bidir pred)
struct AVCodecContext * avctx
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
PutBitContext pb
bit output
static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
static void update_qscale(MpegEncContext *s)
int mb_cmp
macroblock comparison function (not supported yet)
int quantizer_noise_shaping
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int pre_estimate_motion_thread(AVCodecContext *c, void *arg)
#define FF_DISABLE_DEPRECATION_WARNINGS
#define CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
common internal api header.
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
#define CANDIDATE_MB_TYPE_FORWARD
#define CODEC_FLAG_GRAY
Only decode/encode grayscale.
const uint8_t ff_h263_chroma_qscale_table[32]
void ff_h263_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
int adaptive_quant
use adaptive quantization
static int16_t basis[64][64]
void ff_msmpeg4_encode_ext_header(MpegEncContext *s)
static int score_tab[256]
Picture last_picture
copy of the previous picture structure.
Picture * last_picture_ptr
pointer to the previous picture.
FF_ENABLE_DEPRECATION_WARNINGS int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
int64_t reordered_pts
reordered pts to be used as dts for the next output frame when there's a delay
int ff_vbv_update(MpegEncContext *s, int frame_size)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
#define CONFIG_H263P_ENCODER
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
const uint8_t * chroma_qscale_table
qscale -> chroma_qscale (h263)
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static av_cold int init(AVCodecParserContext *s)
AVCodec ff_msmpeg4v3_encoder
int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src)
int trellis
trellis RD quantization
void(* dct_unquantize_mpeg1_inter)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
void ff_mpeg4_stuffing(PutBitContext *pbc)
add mpeg4 stuffing bits (01...1)
#define CANDIDATE_MB_TYPE_INTRA
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet)
const AVOption ff_mpv_generic_options[]
void ff_mpeg1_encode_slice_header(MpegEncContext *s)
#define CONFIG_FLV_ENCODER
int last_bits
temp var used for calculating the above vars
void ff_mpeg4_init_partitions(MpegEncContext *s)
av_cold int ff_mpv_common_init(MpegEncContext *s)
init common structure for both encoder and decoder.
void(* diff_pixels)(int16_t *block, const uint8_t *s1, const uint8_t *s2, int stride)
int dia_size
ME diamond size & shape.
int b_sensitivity
Adjust sensitivity of b_frame_strategy 1.
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
void ff_mpv_encode_init_x86(MpegEncContext *s)
#define FF_ENABLE_DEPRECATION_WARNINGS
static void merge_context_after_me(MpegEncContext *dst, MpegEncContext *src)
void(* draw_edges)(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides)
int ff_get_best_fcode(MpegEncContext *s, int16_t(*mv_table)[2], int type)
int resync_mb_y
y position of last resync marker
int16_t(* block)[64]
points to one of the following blocks
void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number)
PutBitContext tex_pb
used for data partitioned VOPs
Picture next_picture
copy of the next picture structure.
int key_frame
1 -> keyframe, 0-> not
attribute_deprecated int error_rate
static void set_frame_distances(MpegEncContext *s)
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
void ff_fix_long_mvs(MpegEncContext *s, uint8_t *field_select_table, int field_select, int16_t(*mv_table)[2], int f_code, int type, int truncate)
Picture ** reordered_input_picture
pointer to the next pictures in codedorder for encoding
static const struct twinvq_data tab
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
void(* dct_unquantize_mpeg2_intra)(struct MpegEncContext *s, int16_t *block, int n, int qscale)
int mb_var_sum
sum of MB variance for current frame
static int encode_thread(AVCodecContext *c, void *arg)
void ff_mpv_common_defaults(MpegEncContext *s)
Set the given MpegEncContext to common defaults (same for encoding and decoding). ...
int(* fast_dct_quantize)(struct MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow)
int flags
AVCodecContext.flags (HQ, MV4, ...)
void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
int mc_mb_var_sum
motion compensated MB variance for current frame
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
#define LOCAL_ALIGNED_16(t, v,...)
static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src)
static void update_duplicate_context_after_me(MpegEncContext *dst, MpegEncContext *src)
int inter_quant_bias
bias for the quantizer
av_cold void ff_qpeldsp_init(QpelDSPContext *c)
#define CANDIDATE_MB_TYPE_BACKWARD
int me_method
Motion estimation algorithm used for video coding.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
int ff_find_unused_picture(MpegEncContext *s, int shared)
int(* dct_quantize)(struct MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow)
#define MV_TYPE_8X8
4 vectors (h263, mpeg4 4MV)
int rc_min_rate
minimum bitrate
int b_code
backward MV resolution for B Frames (mpeg4)
#define CODEC_FLAG_4MV
4 MV per MB allowed / advanced prediction for H.263.
void ff_h261_encode_init(MpegEncContext *s)
static int encode_frame(AVCodecContext *c, AVFrame *frame)
AVPixelFormat
Pixel format.
This structure stores compressed data.
void ff_mjpeg_encode_stuffing(PutBitContext *pbc)
void(* emulated_edge_mc)(uint8_t *buf, const uint8_t *src, ptrdiff_t buf_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
int strict_std_compliance
strictly follow the standard (MPEG4, ...).
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define CONFIG_RV10_ENCODER
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b)
Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegEncContext *best, int type, PutBitContext pb[2], PutBitContext pb2[2], PutBitContext tex_pb[2], int *dmin, int *next_block, int motion_x, int motion_y)
unsigned int lambda
lagrange multipler used in rate distortion
AVCodec ff_msmpeg4v2_encoder
uint16_t pb_time
time distance between the last b and p,s,i frame
enum idct_permutation_type perm_type
int next_lambda
next lambda used for retrying to encode a frame