Merge commit '8769113accf1f3b78634dec60b37f7354ed6d88d'
* commit '8769113accf1f3b78634dec60b37f7354ed6d88d': mpeg4videoenc: K&R formatting cosmetics Conflicts: libavcodec/mpeg4videoenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
18df75fa2f
@ -27,40 +27,42 @@
|
||||
#include "h263.h"
|
||||
#include "mpeg4video.h"
|
||||
|
||||
//The uni_DCtab_* tables below contain unified bits+length tables to encode DC
|
||||
//differences in mpeg4. Unified in the sense that the specification specifies
|
||||
//this encoding in several steps.
|
||||
/* The uni_DCtab_* tables below contain unified bits+length tables to encode DC
|
||||
* differences in mpeg4. Unified in the sense that the specification specifies
|
||||
* this encoding in several steps. */
|
||||
static uint8_t uni_DCtab_lum_len[512];
|
||||
static uint8_t uni_DCtab_chrom_len[512];
|
||||
static uint16_t uni_DCtab_lum_bits[512];
|
||||
static uint16_t uni_DCtab_chrom_bits[512];
|
||||
|
||||
//unified encoding tables for run length encoding of coefficients
|
||||
//unified in the sense that the specification specifies the encoding in several steps.
|
||||
/* Unified encoding tables for run length encoding of coefficients.
|
||||
* Unified in the sense that the specification specifies the encoding in several steps. */
|
||||
static uint32_t uni_mpeg4_intra_rl_bits[64 * 64 * 2 * 2];
|
||||
static uint8_t uni_mpeg4_intra_rl_len[64 * 64 * 2 * 2];
|
||||
static uint32_t uni_mpeg4_inter_rl_bits[64 * 64 * 2 * 2];
|
||||
static uint8_t uni_mpeg4_inter_rl_len[64 * 64 * 2 * 2];
|
||||
|
||||
//#define UNI_MPEG4_ENC_INDEX(last, run, level) ((last) * 128 + (run) * 256 + (level))
|
||||
//#define UNI_MPEG4_ENC_INDEX(last, run, level) ((last) * 128 * 64 + (run) + (level) * 64)
|
||||
#define UNI_MPEG4_ENC_INDEX(last, run, level) ((last) * 128 * 64 + (run) * 128 + (level))
|
||||
|
||||
/* mpeg4
|
||||
inter
|
||||
max level: 24/6
|
||||
max run: 53/63
|
||||
|
||||
intra
|
||||
max level: 53/16
|
||||
max run: 29/41
|
||||
* inter
|
||||
* max level: 24/6
|
||||
* max run: 53/63
|
||||
*
|
||||
* intra
|
||||
* max level: 53/16
|
||||
* max run: 29/41
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of bits that encoding the 8x8 block in block would need.
|
||||
* @param[in] block_last_index last index in scantable order that refers to a non zero element in block.
|
||||
*/
|
||||
static inline int get_block_rate(MpegEncContext * s, int16_t block[64], int block_last_index, uint8_t scantable[64]){
|
||||
static inline int get_block_rate(MpegEncContext *s, int16_t block[64],
|
||||
int block_last_index, uint8_t scantable[64])
|
||||
{
|
||||
int last = 0;
|
||||
int j;
|
||||
int rate = 0;
|
||||
@ -71,8 +73,10 @@ static inline int get_block_rate(MpegEncContext * s, int16_t block[64], int bloc
|
||||
if (level) {
|
||||
level += 64;
|
||||
if ((level & (~127)) == 0) {
|
||||
if(j<block_last_index) rate+= s->intra_ac_vlc_length [UNI_AC_ENC_INDEX(j-last-1, level)];
|
||||
else rate+= s->intra_ac_vlc_last_length[UNI_AC_ENC_INDEX(j-last-1, level)];
|
||||
if (j < block_last_index)
|
||||
rate += s->intra_ac_vlc_length[UNI_AC_ENC_INDEX(j - last - 1, level)];
|
||||
else
|
||||
rate += s->intra_ac_vlc_last_length[UNI_AC_ENC_INDEX(j - last - 1, level)];
|
||||
} else
|
||||
rate += s->ac_esc_length;
|
||||
|
||||
@ -83,7 +87,6 @@ static inline int get_block_rate(MpegEncContext * s, int16_t block[64], int bloc
|
||||
return rate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restore the ac coefficients in block that have been changed by decide_ac_pred().
|
||||
* This function also restores s->block_last_index.
|
||||
@ -92,7 +95,9 @@ static inline int get_block_rate(MpegEncContext * s, int16_t block[64], int bloc
|
||||
* @param[out] st scantable for each 8x8 block
|
||||
* @param[in] zigzag_last_index index referring to the last non zero coefficient in zigzag order
|
||||
*/
|
||||
static inline void restore_ac_coeffs(MpegEncContext * s, int16_t block[6][64], const int dir[6], uint8_t *st[6], const int zigzag_last_index[6])
|
||||
static inline void restore_ac_coeffs(MpegEncContext *s, int16_t block[6][64],
|
||||
const int dir[6], uint8_t *st[6],
|
||||
const int zigzag_last_index[6])
|
||||
{
|
||||
int i, n;
|
||||
memcpy(s->block_last_index, zigzag_last_index, sizeof(int) * 6);
|
||||
@ -103,17 +108,15 @@ static inline void restore_ac_coeffs(MpegEncContext * s, int16_t block[6][64], c
|
||||
st[n] = s->intra_scantable.permutated;
|
||||
if (dir[n]) {
|
||||
/* top prediction */
|
||||
for(i=1; i<8; i++){
|
||||
for (i = 1; i < 8; i++)
|
||||
block[n][s->dsp.idct_permutation[i]] = ac_val[i + 8];
|
||||
}
|
||||
} else {
|
||||
/* left prediction */
|
||||
for(i=1; i<8; i++){
|
||||
for (i = 1; i < 8; i++)
|
||||
block[n][s->dsp.idct_permutation[i << 3]] = ac_val[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the optimal value (0 or 1) for the ac_pred element for the given MB in mpeg4.
|
||||
@ -123,7 +126,9 @@ static inline void restore_ac_coeffs(MpegEncContext * s, int16_t block[6][64], c
|
||||
* @param[out] st scantable for each 8x8 block
|
||||
* @param[out] zigzag_last_index index referring to the last non zero coefficient in zigzag order
|
||||
*/
|
||||
static inline int decide_ac_pred(MpegEncContext * s, int16_t block[6][64], const int dir[6], uint8_t *st[6], int zigzag_last_index[6])
|
||||
static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64],
|
||||
const int dir[6], uint8_t *st[6],
|
||||
int zigzag_last_index[6])
|
||||
{
|
||||
int score = 0;
|
||||
int i, n;
|
||||
@ -134,7 +139,8 @@ static inline int decide_ac_pred(MpegEncContext * s, int16_t block[6][64], const
|
||||
for (n = 0; n < 6; n++) {
|
||||
int16_t *ac_val, *ac_val1;
|
||||
|
||||
score -= get_block_rate(s, block[n], s->block_last_index[n], s->intra_scantable.permutated);
|
||||
score -= get_block_rate(s, block[n], s->block_last_index[n],
|
||||
s->intra_scantable.permutated);
|
||||
|
||||
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
|
||||
ac_val1 = ac_val;
|
||||
@ -185,7 +191,8 @@ static inline int decide_ac_pred(MpegEncContext * s, int16_t block[6][64], const
|
||||
}
|
||||
|
||||
for (i = 63; i > 0; i--) // FIXME optimize
|
||||
if(block[n][ st[n][i] ]) break;
|
||||
if (block[n][st[n][i]])
|
||||
break;
|
||||
s->block_last_index[n] = i;
|
||||
|
||||
score += get_block_rate(s, block[n], s->block_last_index[n], st[n]);
|
||||
@ -202,7 +209,8 @@ static inline int decide_ac_pred(MpegEncContext * s, int16_t block[6][64], const
|
||||
/**
|
||||
* modify mb_type & qscale so that encoding is actually possible in mpeg4
|
||||
*/
|
||||
void ff_clean_mpeg4_qscales(MpegEncContext *s){
|
||||
void ff_clean_mpeg4_qscales(MpegEncContext *s)
|
||||
{
|
||||
int i;
|
||||
int8_t *const qscale_table = s->current_picture.qscale_table;
|
||||
|
||||
@ -210,15 +218,18 @@ void ff_clean_mpeg4_qscales(MpegEncContext *s){
|
||||
|
||||
if (s->pict_type == AV_PICTURE_TYPE_B) {
|
||||
int odd = 0;
|
||||
/* ok, come on, this isn't funny anymore, there's more code for handling this mpeg4 mess than for the actual adaptive quantization */
|
||||
/* ok, come on, this isn't funny anymore, there's more code for
|
||||
* handling this mpeg4 mess than for the actual adaptive quantization */
|
||||
|
||||
for (i = 0; i < s->mb_num; i++) {
|
||||
int mb_xy = s->mb_index2xy[i];
|
||||
odd += qscale_table[mb_xy] & 1;
|
||||
}
|
||||
|
||||
if(2*odd > s->mb_num) odd=1;
|
||||
else odd=0;
|
||||
if (2 * odd > s->mb_num)
|
||||
odd = 1;
|
||||
else
|
||||
odd = 0;
|
||||
|
||||
for (i = 0; i < s->mb_num; i++) {
|
||||
int mb_xy = s->mb_index2xy[i];
|
||||
@ -230,14 +241,14 @@ void ff_clean_mpeg4_qscales(MpegEncContext *s){
|
||||
|
||||
for (i = 1; i < s->mb_num; i++) {
|
||||
int mb_xy = s->mb_index2xy[i];
|
||||
if(qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i-1]] && (s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_DIRECT)){
|
||||
if (qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i - 1]] &&
|
||||
(s->mb_type[mb_xy] & CANDIDATE_MB_TYPE_DIRECT)) {
|
||||
s->mb_type[mb_xy] |= CANDIDATE_MB_TYPE_BIDIR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode the dc value.
|
||||
* @param n block index (0-3 are luma, 4-5 are chroma)
|
||||
@ -283,20 +294,22 @@ static inline void mpeg4_encode_dc(PutBitContext * s, int level, int n)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int mpeg4_get_dc_length(int level, int n){
|
||||
if (n < 4) {
|
||||
static inline int mpeg4_get_dc_length(int level, int n)
|
||||
{
|
||||
if (n < 4)
|
||||
return uni_DCtab_lum_len[level + 256];
|
||||
} else {
|
||||
else
|
||||
return uni_DCtab_chrom_len[level + 256];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode an 8x8 block.
|
||||
* @param n block index (0-3 are luma, 4-5 are chroma)
|
||||
*/
|
||||
static inline void mpeg4_encode_block(MpegEncContext * s, int16_t * block, int n, int intra_dc,
|
||||
uint8_t *scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb)
|
||||
static inline void mpeg4_encode_block(MpegEncContext *s,
|
||||
int16_t *block, int n, int intra_dc,
|
||||
uint8_t *scan_table, PutBitContext *dc_pb,
|
||||
PutBitContext *ac_pb)
|
||||
{
|
||||
int i, last_non_zero;
|
||||
uint32_t *bits_tab;
|
||||
@ -306,12 +319,14 @@ static inline void mpeg4_encode_block(MpegEncContext * s, int16_t * block, int n
|
||||
if (s->mb_intra) { // Note gcc (3.2.1 at least) will optimize this away
|
||||
/* mpeg4 based DC predictor */
|
||||
mpeg4_encode_dc(dc_pb, intra_dc, n);
|
||||
if(last_index<1) return;
|
||||
if (last_index < 1)
|
||||
return;
|
||||
i = 1;
|
||||
bits_tab = uni_mpeg4_intra_rl_bits;
|
||||
len_tab = uni_mpeg4_intra_rl_len;
|
||||
} else {
|
||||
if(last_index<0) return;
|
||||
if (last_index < 0)
|
||||
return;
|
||||
i = 0;
|
||||
bits_tab = uni_mpeg4_inter_rl_bits;
|
||||
len_tab = uni_mpeg4_inter_rl_len;
|
||||
@ -328,7 +343,10 @@ static inline void mpeg4_encode_block(MpegEncContext * s, int16_t * block, int n
|
||||
const int index = UNI_MPEG4_ENC_INDEX(0, run, level);
|
||||
put_bits(ac_pb, len_tab[index], bits_tab[index]);
|
||||
} else { // ESC3
|
||||
put_bits(ac_pb, 7+2+1+6+1+12+1, (3<<23)+(3<<21)+(0<<20)+(run<<14)+(1<<13)+(((level-64)&0xfff)<<1)+1);
|
||||
put_bits(ac_pb,
|
||||
7 + 2 + 1 + 6 + 1 + 12 + 1,
|
||||
(3 << 23) + (3 << 21) + (0 << 20) + (run << 14) +
|
||||
(1 << 13) + (((level - 64) & 0xfff) << 1) + 1);
|
||||
}
|
||||
last_non_zero = i;
|
||||
}
|
||||
@ -341,13 +359,17 @@ static inline void mpeg4_encode_block(MpegEncContext * s, int16_t * block, int n
|
||||
const int index = UNI_MPEG4_ENC_INDEX(1, run, level);
|
||||
put_bits(ac_pb, len_tab[index], bits_tab[index]);
|
||||
} else { // ESC3
|
||||
put_bits(ac_pb, 7+2+1+6+1+12+1, (3<<23)+(3<<21)+(1<<20)+(run<<14)+(1<<13)+(((level-64)&0xfff)<<1)+1);
|
||||
put_bits(ac_pb,
|
||||
7 + 2 + 1 + 6 + 1 + 12 + 1,
|
||||
(3 << 23) + (3 << 21) + (1 << 20) + (run << 14) +
|
||||
(1 << 13) + (((level - 64) & 0xfff) << 1) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int mpeg4_get_block_length(MpegEncContext * s, int16_t * block, int n, int intra_dc,
|
||||
uint8_t *scan_table)
|
||||
static int mpeg4_get_block_length(MpegEncContext *s,
|
||||
int16_t *block, int n,
|
||||
int intra_dc, uint8_t *scan_table)
|
||||
{
|
||||
int i, last_non_zero;
|
||||
uint8_t *len_tab;
|
||||
@ -357,11 +379,13 @@ static int mpeg4_get_block_length(MpegEncContext * s, int16_t * block, int n, in
|
||||
if (s->mb_intra) { // Note gcc (3.2.1 at least) will optimize this away
|
||||
/* mpeg4 based DC predictor */
|
||||
len += mpeg4_get_dc_length(intra_dc, n);
|
||||
if(last_index<1) return len;
|
||||
if (last_index < 1)
|
||||
return len;
|
||||
i = 1;
|
||||
len_tab = uni_mpeg4_intra_rl_len;
|
||||
} else {
|
||||
if(last_index<0) return 0;
|
||||
if (last_index < 0)
|
||||
return 0;
|
||||
i = 0;
|
||||
len_tab = uni_mpeg4_inter_rl_len;
|
||||
}
|
||||
@ -397,31 +421,36 @@ static int mpeg4_get_block_length(MpegEncContext * s, int16_t * block, int n, in
|
||||
return len;
|
||||
}
|
||||
|
||||
static inline void mpeg4_encode_blocks(MpegEncContext * s, int16_t block[6][64], int intra_dc[6],
|
||||
uint8_t **scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb){
|
||||
static inline void mpeg4_encode_blocks(MpegEncContext *s, int16_t block[6][64],
|
||||
int intra_dc[6], uint8_t **scan_table,
|
||||
PutBitContext *dc_pb,
|
||||
PutBitContext *ac_pb)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (scan_table) {
|
||||
if (s->flags2 & CODEC_FLAG2_NO_OUTPUT) {
|
||||
for (i = 0; i < 6; i++) {
|
||||
skip_put_bits(&s->pb, mpeg4_get_block_length(s, block[i], i, intra_dc[i], scan_table[i]));
|
||||
}
|
||||
for (i = 0; i < 6; i++)
|
||||
skip_put_bits(&s->pb,
|
||||
mpeg4_get_block_length(s, block[i], i,
|
||||
intra_dc[i], scan_table[i]));
|
||||
} else {
|
||||
/* encode each block */
|
||||
for (i = 0; i < 6; i++) {
|
||||
mpeg4_encode_block(s, block[i], i, intra_dc[i], scan_table[i], dc_pb, ac_pb);
|
||||
}
|
||||
for (i = 0; i < 6; i++)
|
||||
mpeg4_encode_block(s, block[i], i,
|
||||
intra_dc[i], scan_table[i], dc_pb, ac_pb);
|
||||
}
|
||||
} else {
|
||||
if (s->flags2 & CODEC_FLAG2_NO_OUTPUT) {
|
||||
for (i = 0; i < 6; i++) {
|
||||
skip_put_bits(&s->pb, mpeg4_get_block_length(s, block[i], i, 0, s->intra_scantable.permutated));
|
||||
}
|
||||
for (i = 0; i < 6; i++)
|
||||
skip_put_bits(&s->pb,
|
||||
mpeg4_get_block_length(s, block[i], i, 0,
|
||||
s->intra_scantable.permutated));
|
||||
} else {
|
||||
/* encode each block */
|
||||
for (i = 0; i < 6; i++) {
|
||||
mpeg4_encode_block(s, block[i], i, 0, s->intra_scantable.permutated, dc_pb, ac_pb);
|
||||
}
|
||||
for (i = 0; i < 6; i++)
|
||||
mpeg4_encode_block(s, block[i], i, 0,
|
||||
s->intra_scantable.permutated, dc_pb, ac_pb);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -435,11 +464,12 @@ static inline int get_b_cbp(MpegEncContext * s, int16_t block[6][64],
|
||||
int score = 0;
|
||||
const int lambda = s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (s->coded_score[i] < 0) {
|
||||
score += s->coded_score[i];
|
||||
cbp |= 1 << (5 - i);
|
||||
}
|
||||
}
|
||||
|
||||
if (cbp) {
|
||||
int zero_score = -6;
|
||||
@ -469,8 +499,7 @@ static inline int get_b_cbp(MpegEncContext * s, int16_t block[6][64],
|
||||
// FIXME this is duplicated to h263.c
|
||||
static const int dquant_code[5] = { 1, 0, 9, 2, 3 };
|
||||
|
||||
void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
int16_t block[6][64],
|
||||
void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
|
||||
int motion_x, int motion_y)
|
||||
{
|
||||
int cbpc, cbpy, pred_x, pred_y;
|
||||
@ -483,17 +512,17 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
int i, cbp;
|
||||
|
||||
if (s->pict_type == AV_PICTURE_TYPE_B) {
|
||||
static const int mb_type_table[8]= {-1, 3, 2, 1,-1,-1,-1, 0}; /* convert from mv_dir to type */
|
||||
/* convert from mv_dir to type */
|
||||
static const int mb_type_table[8] = { -1, 3, 2, 1, -1, -1, -1, 0 };
|
||||
int mb_type = mb_type_table[s->mv_dir];
|
||||
|
||||
if (s->mb_x == 0) {
|
||||
for(i=0; i<2; i++){
|
||||
for (i = 0; i < 2; i++)
|
||||
s->last_mv[i][0][0] =
|
||||
s->last_mv[i][0][1] =
|
||||
s->last_mv[i][1][0] =
|
||||
s->last_mv[i][1][1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
av_assert2(s->dquant >= -2 && s->dquant <= 2);
|
||||
av_assert2((s->dquant & 1) == 0);
|
||||
@ -532,7 +561,8 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
put_bits(&s->pb, 1, 0); /* mb coded modb1=0 */
|
||||
put_bits(&s->pb, 1, cbp ? 0 : 1); /* modb2 */ // FIXME merge
|
||||
put_bits(&s->pb, mb_type + 1, 1); // this table is so simple that we don't need it :)
|
||||
if(cbp) put_bits(&s->pb, 6, cbp);
|
||||
if (cbp)
|
||||
put_bits(&s->pb, 6, cbp);
|
||||
|
||||
if (cbp && mb_type) {
|
||||
if (s->dquant)
|
||||
@ -549,11 +579,10 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
put_bits(&s->pb, 1, s->mv_type == MV_TYPE_FIELD);
|
||||
}
|
||||
|
||||
if(interleaved_stats){
|
||||
if (interleaved_stats)
|
||||
s->misc_bits += get_bits_diff(s);
|
||||
}
|
||||
|
||||
if(mb_type == 0){
|
||||
if (!mb_type) {
|
||||
av_assert2(s->mv_dir & MV_DIRECT);
|
||||
ff_h263_encode_motion_vector(s, motion_x, motion_y, 1);
|
||||
s->b_count++;
|
||||
@ -562,17 +591,25 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
av_assert2(mb_type > 0 && mb_type < 4);
|
||||
if (s->mv_type != MV_TYPE_FIELD) {
|
||||
if (s->mv_dir & MV_DIR_FORWARD) {
|
||||
ff_h263_encode_motion_vector(s, s->mv[0][0][0] - s->last_mv[0][0][0],
|
||||
s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code);
|
||||
s->last_mv[0][0][0]= s->last_mv[0][1][0]= s->mv[0][0][0];
|
||||
s->last_mv[0][0][1]= s->last_mv[0][1][1]= s->mv[0][0][1];
|
||||
ff_h263_encode_motion_vector(s,
|
||||
s->mv[0][0][0] - s->last_mv[0][0][0],
|
||||
s->mv[0][0][1] - s->last_mv[0][0][1],
|
||||
s->f_code);
|
||||
s->last_mv[0][0][0] =
|
||||
s->last_mv[0][1][0] = s->mv[0][0][0];
|
||||
s->last_mv[0][0][1] =
|
||||
s->last_mv[0][1][1] = s->mv[0][0][1];
|
||||
s->f_count++;
|
||||
}
|
||||
if (s->mv_dir & MV_DIR_BACKWARD) {
|
||||
ff_h263_encode_motion_vector(s, s->mv[1][0][0] - s->last_mv[1][0][0],
|
||||
s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code);
|
||||
s->last_mv[1][0][0]= s->last_mv[1][1][0]= s->mv[1][0][0];
|
||||
s->last_mv[1][0][1]= s->last_mv[1][1][1]= s->mv[1][0][1];
|
||||
ff_h263_encode_motion_vector(s,
|
||||
s->mv[1][0][0] - s->last_mv[1][0][0],
|
||||
s->mv[1][0][1] - s->last_mv[1][0][1],
|
||||
s->b_code);
|
||||
s->last_mv[1][0][0] =
|
||||
s->last_mv[1][1][0] = s->mv[1][0][0];
|
||||
s->last_mv[1][0][1] =
|
||||
s->last_mv[1][1][1] = s->mv[1][0][1];
|
||||
s->b_count++;
|
||||
}
|
||||
} else {
|
||||
@ -586,8 +623,10 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
}
|
||||
if (s->mv_dir & MV_DIR_FORWARD) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
ff_h263_encode_motion_vector(s, s->mv[0][i][0] - s->last_mv[0][i][0] ,
|
||||
s->mv[0][i][1] - s->last_mv[0][i][1]/2, s->f_code);
|
||||
ff_h263_encode_motion_vector(s,
|
||||
s->mv[0][i][0] - s->last_mv[0][i][0],
|
||||
s->mv[0][i][1] - s->last_mv[0][i][1] / 2,
|
||||
s->f_code);
|
||||
s->last_mv[0][i][0] = s->mv[0][i][0];
|
||||
s->last_mv[0][i][1] = s->mv[0][i][1] * 2;
|
||||
}
|
||||
@ -595,8 +634,10 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
}
|
||||
if (s->mv_dir & MV_DIR_BACKWARD) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
ff_h263_encode_motion_vector(s, s->mv[1][i][0] - s->last_mv[1][i][0] ,
|
||||
s->mv[1][i][1] - s->last_mv[1][i][1]/2, s->b_code);
|
||||
ff_h263_encode_motion_vector(s,
|
||||
s->mv[1][i][0] - s->last_mv[1][i][0],
|
||||
s->mv[1][i][1] - s->last_mv[1][i][1] / 2,
|
||||
s->b_code);
|
||||
s->last_mv[1][i][0] = s->mv[1][i][0];
|
||||
s->last_mv[1][i][1] = s->mv[1][i][1] * 2;
|
||||
}
|
||||
@ -605,22 +646,21 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
}
|
||||
}
|
||||
|
||||
if(interleaved_stats){
|
||||
if (interleaved_stats)
|
||||
s->mv_bits += get_bits_diff(s);
|
||||
}
|
||||
|
||||
mpeg4_encode_blocks(s, block, NULL, NULL, NULL, &s->pb);
|
||||
|
||||
if(interleaved_stats){
|
||||
if (interleaved_stats)
|
||||
s->p_tex_bits += get_bits_diff(s);
|
||||
}
|
||||
|
||||
} else { /* s->pict_type==AV_PICTURE_TYPE_B */
|
||||
cbp = get_p_cbp(s, block, motion_x, motion_y);
|
||||
|
||||
if ((cbp | motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16) {
|
||||
/* check if the B frames can skip it too, as we must skip it if we skip here
|
||||
why didn't they just compress the skip-mb bits instead of reusing them ?! */
|
||||
if ((cbp | motion_x | motion_y | s->dquant) == 0 &&
|
||||
s->mv_type == MV_TYPE_16X16) {
|
||||
/* check if the B frames can skip it too, as we must skip it
|
||||
* if we skip here why didn't they just compress
|
||||
* the skip-mb bits instead of reusing them ?! */
|
||||
if (s->max_b_frames > 0) {
|
||||
int i;
|
||||
int x, y, offset;
|
||||
@ -638,7 +678,7 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
int diff;
|
||||
Picture *pic = s->reordered_input_picture[i + 1];
|
||||
|
||||
if (pic == NULL || pic->f.pict_type != AV_PICTURE_TYPE_B)
|
||||
if (!pic || pic->f.pict_type != AV_PICTURE_TYPE_B)
|
||||
break;
|
||||
|
||||
b_pic = pic->f.data[0] + offset;
|
||||
@ -686,7 +726,8 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
cbpy = cbp >> 2;
|
||||
cbpy ^= 0xf;
|
||||
if (s->mv_type == MV_TYPE_16X16) {
|
||||
if(s->dquant) cbpc+= 8;
|
||||
if (s->dquant)
|
||||
cbpc += 8;
|
||||
put_bits(&s->pb,
|
||||
ff_h263_inter_MCBPC_bits[cbpc],
|
||||
ff_h263_inter_MCBPC_code[cbpc]);
|
||||
@ -701,17 +742,19 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
put_bits(pb2, 1, 0);
|
||||
}
|
||||
|
||||
if(interleaved_stats){
|
||||
if (interleaved_stats)
|
||||
s->misc_bits += get_bits_diff(s);
|
||||
}
|
||||
|
||||
/* motion vectors: 16x16 mode */
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
|
||||
ff_h263_encode_motion_vector(s, motion_x - pred_x,
|
||||
motion_y - pred_y, s->f_code);
|
||||
ff_h263_encode_motion_vector(s,
|
||||
motion_x - pred_x,
|
||||
motion_y - pred_y,
|
||||
s->f_code);
|
||||
} else if (s->mv_type == MV_TYPE_FIELD) {
|
||||
if(s->dquant) cbpc+= 8;
|
||||
if (s->dquant)
|
||||
cbpc += 8;
|
||||
put_bits(&s->pb,
|
||||
ff_h263_inter_MCBPC_bits[cbpc],
|
||||
ff_h263_inter_MCBPC_code[cbpc]);
|
||||
@ -725,9 +768,8 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
put_bits(pb2, 1, s->interlaced_dct);
|
||||
put_bits(pb2, 1, 1);
|
||||
|
||||
if(interleaved_stats){
|
||||
if (interleaved_stats)
|
||||
s->misc_bits += get_bits_diff(s);
|
||||
}
|
||||
|
||||
/* motion vectors: 16x8 interlaced mode */
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
@ -736,10 +778,14 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
put_bits(&s->pb, 1, s->field_select[0][0]);
|
||||
put_bits(&s->pb, 1, s->field_select[0][1]);
|
||||
|
||||
ff_h263_encode_motion_vector(s, s->mv[0][0][0] - pred_x,
|
||||
s->mv[0][0][1] - pred_y, s->f_code);
|
||||
ff_h263_encode_motion_vector(s, s->mv[0][1][0] - pred_x,
|
||||
s->mv[0][1][1] - pred_y, s->f_code);
|
||||
ff_h263_encode_motion_vector(s,
|
||||
s->mv[0][0][0] - pred_x,
|
||||
s->mv[0][0][1] - pred_y,
|
||||
s->f_code);
|
||||
ff_h263_encode_motion_vector(s,
|
||||
s->mv[0][1][0] - pred_x,
|
||||
s->mv[0][1][1] - pred_y,
|
||||
s->f_code);
|
||||
} else {
|
||||
av_assert2(s->mv_type == MV_TYPE_8X8);
|
||||
put_bits(&s->pb,
|
||||
@ -747,33 +793,31 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
ff_h263_inter_MCBPC_code[cbpc + 16]);
|
||||
put_bits(pb2, ff_h263_cbpy_tab[cbpy][1], ff_h263_cbpy_tab[cbpy][0]);
|
||||
|
||||
if(!s->progressive_sequence){
|
||||
if(cbp)
|
||||
if (!s->progressive_sequence && cbp)
|
||||
put_bits(pb2, 1, s->interlaced_dct);
|
||||
}
|
||||
|
||||
if(interleaved_stats){
|
||||
if (interleaved_stats)
|
||||
s->misc_bits += get_bits_diff(s);
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
/* motion vectors: 8x8 mode*/
|
||||
ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
|
||||
ff_h263_encode_motion_vector(s, s->current_picture.motion_val[0][ s->block_index[i] ][0] - pred_x,
|
||||
s->current_picture.motion_val[0][ s->block_index[i] ][1] - pred_y, s->f_code);
|
||||
ff_h263_encode_motion_vector(s,
|
||||
s->current_picture.motion_val[0][s->block_index[i]][0] - pred_x,
|
||||
s->current_picture.motion_val[0][s->block_index[i]][1] - pred_y,
|
||||
s->f_code);
|
||||
}
|
||||
}
|
||||
|
||||
if(interleaved_stats){
|
||||
if (interleaved_stats)
|
||||
s->mv_bits += get_bits_diff(s);
|
||||
}
|
||||
|
||||
mpeg4_encode_blocks(s, block, NULL, NULL, NULL, tex_pb);
|
||||
|
||||
if(interleaved_stats){
|
||||
if (interleaved_stats)
|
||||
s->p_tex_bits += get_bits_diff(s);
|
||||
}
|
||||
|
||||
s->f_count++;
|
||||
}
|
||||
} else {
|
||||
@ -784,9 +828,8 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
uint8_t *scan_table[6];
|
||||
int i;
|
||||
|
||||
for(i=0; i<6; i++){
|
||||
for (i = 0; i < 6; i++)
|
||||
dc_diff[i] = ff_mpeg4_pred_dc(s, i, block[i][0], &dir[i], 1);
|
||||
}
|
||||
|
||||
if (s->flags & CODEC_FLAG_AC_PRED) {
|
||||
s->ac_pred = decide_ac_pred(s, block, dir, scan_table, zigzag_last_index);
|
||||
@ -797,19 +840,20 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
|
||||
/* compute cbp */
|
||||
cbp = 0;
|
||||
for (i = 0; i < 6; i++) {
|
||||
for (i = 0; i < 6; i++)
|
||||
if (s->block_last_index[i] >= 1)
|
||||
cbp |= 1 << (5 - i);
|
||||
}
|
||||
|
||||
cbpc = cbp & 3;
|
||||
if (s->pict_type == AV_PICTURE_TYPE_I) {
|
||||
if(s->dquant) cbpc+=4;
|
||||
if (s->dquant)
|
||||
cbpc += 4;
|
||||
put_bits(&s->pb,
|
||||
ff_h263_intra_MCBPC_bits[cbpc],
|
||||
ff_h263_intra_MCBPC_code[cbpc]);
|
||||
} else {
|
||||
if(s->dquant) cbpc+=8;
|
||||
if (s->dquant)
|
||||
cbpc += 8;
|
||||
put_bits(&s->pb, 1, 0); /* mb coded */
|
||||
put_bits(&s->pb,
|
||||
ff_h263_inter_MCBPC_bits[cbpc + 4],
|
||||
@ -821,22 +865,20 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
|
||||
if (s->dquant)
|
||||
put_bits(dc_pb, 2, dquant_code[s->dquant + 2]);
|
||||
|
||||
if(!s->progressive_sequence){
|
||||
if (!s->progressive_sequence)
|
||||
put_bits(dc_pb, 1, s->interlaced_dct);
|
||||
}
|
||||
|
||||
if(interleaved_stats){
|
||||
if (interleaved_stats)
|
||||
s->misc_bits += get_bits_diff(s);
|
||||
}
|
||||
|
||||
mpeg4_encode_blocks(s, block, dc_diff, scan_table, dc_pb, tex_pb);
|
||||
|
||||
if(interleaved_stats){
|
||||
if (interleaved_stats)
|
||||
s->i_tex_bits += get_bits_diff(s);
|
||||
}
|
||||
s->i_count++;
|
||||
|
||||
/* restore ac coeffs & last_index stuff if we messed them up with the prediction */
|
||||
/* restore ac coeffs & last_index stuff
|
||||
* if we messed them up with the prediction */
|
||||
if (s->ac_pred)
|
||||
restore_ac_coeffs(s, block, dir, scan_table, zigzag_last_index);
|
||||
}
|
||||
@ -850,11 +892,13 @@ void ff_mpeg4_stuffing(PutBitContext * pbc)
|
||||
int length;
|
||||
put_bits(pbc, 1, 0);
|
||||
length = (-put_bits_count(pbc)) & 7;
|
||||
if(length) put_bits(pbc, length, (1<<length)-1);
|
||||
if (length)
|
||||
put_bits(pbc, length, (1 << length) - 1);
|
||||
}
|
||||
|
||||
/* must be called before writing the header */
|
||||
void ff_set_mpeg4_time(MpegEncContext * s){
|
||||
void ff_set_mpeg4_time(MpegEncContext *s)
|
||||
{
|
||||
if (s->pict_type == AV_PICTURE_TYPE_B) {
|
||||
ff_mpeg4_init_direct_mv(s);
|
||||
} else {
|
||||
@ -863,7 +907,8 @@ void ff_set_mpeg4_time(MpegEncContext * s){
|
||||
}
|
||||
}
|
||||
|
||||
static void mpeg4_encode_gop_header(MpegEncContext * s){
|
||||
static void mpeg4_encode_gop_header(MpegEncContext *s)
|
||||
{
|
||||
int hours, minutes, seconds;
|
||||
int64_t time;
|
||||
|
||||
@ -892,7 +937,8 @@ static void mpeg4_encode_gop_header(MpegEncContext * s){
|
||||
ff_mpeg4_stuffing(&s->pb);
|
||||
}
|
||||
|
||||
static void mpeg4_encode_visual_object_header(MpegEncContext * s){
|
||||
static void mpeg4_encode_visual_object_header(MpegEncContext *s)
|
||||
{
|
||||
int profile_and_level_indication;
|
||||
int vo_ver_id;
|
||||
|
||||
@ -904,17 +950,15 @@ static void mpeg4_encode_visual_object_header(MpegEncContext * s){
|
||||
profile_and_level_indication = 0x00; // simple
|
||||
}
|
||||
|
||||
if(s->avctx->level != FF_LEVEL_UNKNOWN){
|
||||
if (s->avctx->level != FF_LEVEL_UNKNOWN)
|
||||
profile_and_level_indication |= s->avctx->level;
|
||||
}else{
|
||||
else
|
||||
profile_and_level_indication |= 1; // level 1
|
||||
}
|
||||
|
||||
if(profile_and_level_indication>>4 == 0xF){
|
||||
if (profile_and_level_indication >> 4 == 0xF)
|
||||
vo_ver_id = 5;
|
||||
}else{
|
||||
else
|
||||
vo_ver_id = 1;
|
||||
}
|
||||
|
||||
// FIXME levels
|
||||
|
||||
@ -937,11 +981,14 @@ static void mpeg4_encode_visual_object_header(MpegEncContext * s){
|
||||
ff_mpeg4_stuffing(&s->pb);
|
||||
}
|
||||
|
||||
static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_number)
|
||||
static void mpeg4_encode_vol_header(MpegEncContext *s,
|
||||
int vo_number,
|
||||
int vol_number)
|
||||
{
|
||||
int vo_ver_id;
|
||||
|
||||
if (!CONFIG_MPEG4_ENCODER) return;
|
||||
if (!CONFIG_MPEG4_ENCODER)
|
||||
return;
|
||||
|
||||
if (s->max_b_frames || s->quarter_sample) {
|
||||
vo_ver_id = 5;
|
||||
@ -976,7 +1023,7 @@ static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_n
|
||||
put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
|
||||
}
|
||||
|
||||
if(s->workaround_bugs & FF_BUG_MS) { //
|
||||
if (s->workaround_bugs & FF_BUG_MS) {
|
||||
put_bits(&s->pb, 1, 0); /* vol control parameters= no @@@ */
|
||||
} else {
|
||||
put_bits(&s->pb, 1, 1); /* vol control parameters= yes */
|
||||
@ -1000,11 +1047,10 @@ static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_n
|
||||
put_bits(&s->pb, 1, 1); /* marker bit */
|
||||
put_bits(&s->pb, 1, s->progressive_sequence ? 0 : 1);
|
||||
put_bits(&s->pb, 1, 1); /* obmc disable */
|
||||
if (vo_ver_id == 1) {
|
||||
if (vo_ver_id == 1)
|
||||
put_bits(&s->pb, 1, s->vol_sprite_usage); /* sprite enable */
|
||||
}else{
|
||||
else
|
||||
put_bits(&s->pb, 2, s->vol_sprite_usage); /* sprite enable */
|
||||
}
|
||||
|
||||
put_bits(&s->pb, 1, 0); /* not 8 bit == false */
|
||||
put_bits(&s->pb, 1, s->mpeg_quant); /* quant type= (0=h263 style)*/
|
||||
@ -1020,9 +1066,8 @@ static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_n
|
||||
s->resync_marker = s->rtp_mode;
|
||||
put_bits(&s->pb, 1, s->resync_marker ? 0 : 1); /* resync marker disable */
|
||||
put_bits(&s->pb, 1, s->data_partitioning ? 1 : 0);
|
||||
if(s->data_partitioning){
|
||||
if (s->data_partitioning)
|
||||
put_bits(&s->pb, 1, 0); /* no rvlc */
|
||||
}
|
||||
|
||||
if (vo_ver_id != 1) {
|
||||
put_bits(&s->pb, 1, 0); /* newpred */
|
||||
@ -1076,8 +1121,8 @@ void ff_mpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
|
||||
put_bits(&s->pb, s->time_increment_bits, time_mod); /* time increment */
|
||||
put_bits(&s->pb, 1, 1); /* marker */
|
||||
put_bits(&s->pb, 1, 1); /* vop coded */
|
||||
if ( s->pict_type == AV_PICTURE_TYPE_P
|
||||
|| (s->pict_type == AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE)) {
|
||||
if (s->pict_type == AV_PICTURE_TYPE_P ||
|
||||
(s->pict_type == AV_PICTURE_TYPE_S && s->vol_sprite_usage == GMC_SPRITE)) {
|
||||
put_bits(&s->pb, 1, s->no_rounding); /* rounding type */
|
||||
}
|
||||
put_bits(&s->pb, 3, 0); /* intra dc VLC threshold */
|
||||
@ -1095,7 +1140,6 @@ void ff_mpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
|
||||
put_bits(&s->pb, 3, s->b_code); /* fcode_back */
|
||||
}
|
||||
|
||||
|
||||
static av_cold void init_uni_dc_tab(void)
|
||||
{
|
||||
int level, uni_code, uni_len;
|
||||
@ -1120,10 +1164,12 @@ static av_cold void init_uni_dc_tab(void)
|
||||
uni_len = ff_mpeg4_DCtab_lum[size][1];
|
||||
|
||||
if (size > 0) {
|
||||
uni_code<<=size; uni_code|=l;
|
||||
uni_code <<= size;
|
||||
uni_code |= l;
|
||||
uni_len += size;
|
||||
if (size > 8) {
|
||||
uni_code<<=1; uni_code|=1;
|
||||
uni_code <<= 1;
|
||||
uni_code |= 1;
|
||||
uni_len++;
|
||||
}
|
||||
}
|
||||
@ -1135,16 +1181,17 @@ static av_cold void init_uni_dc_tab(void)
|
||||
uni_len = ff_mpeg4_DCtab_chrom[size][1];
|
||||
|
||||
if (size > 0) {
|
||||
uni_code<<=size; uni_code|=l;
|
||||
uni_code <<= size;
|
||||
uni_code |= l;
|
||||
uni_len += size;
|
||||
if (size > 8) {
|
||||
uni_code<<=1; uni_code|=1;
|
||||
uni_code <<= 1;
|
||||
uni_code |= 1;
|
||||
uni_len++;
|
||||
}
|
||||
}
|
||||
uni_DCtab_chrom_bits[level + 256] = uni_code;
|
||||
uni_DCtab_chrom_len[level + 256] = uni_len;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1157,7 +1204,8 @@ static av_cold void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab,
|
||||
av_assert0(MAX_RUN >= 63);
|
||||
|
||||
for (slevel = -64; slevel < 64; slevel++) {
|
||||
if(slevel==0) continue;
|
||||
if (slevel == 0)
|
||||
continue;
|
||||
for (run = 0; run < 64; run++) {
|
||||
for (last = 0; last <= 1; last++) {
|
||||
const int index = UNI_MPEG4_ENC_INDEX(last, run, slevel + 64);
|
||||
@ -1172,7 +1220,8 @@ static av_cold void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab,
|
||||
code = get_rl_index(rl, last, run, level);
|
||||
bits = rl->table_vlc[code][0];
|
||||
len = rl->table_vlc[code][1];
|
||||
bits=bits*2+sign; len++;
|
||||
bits = bits * 2 + sign;
|
||||
len++;
|
||||
|
||||
if (code != rl->n && len < len_tab[index]) {
|
||||
bits_tab[index] = bits;
|
||||
@ -1181,14 +1230,16 @@ static av_cold void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab,
|
||||
/* ESC1 */
|
||||
bits = rl->table_vlc[rl->n][0];
|
||||
len = rl->table_vlc[rl->n][1];
|
||||
bits=bits*2; len++; //esc1
|
||||
bits = bits * 2;
|
||||
len++; // esc1
|
||||
level1 = level - rl->max_level[last][run];
|
||||
if (level1 > 0) {
|
||||
code = get_rl_index(rl, last, run, level1);
|
||||
bits <<= rl->table_vlc[code][1];
|
||||
len += rl->table_vlc[code][1];
|
||||
bits += rl->table_vlc[code][0];
|
||||
bits=bits*2+sign; len++;
|
||||
bits = bits * 2 + sign;
|
||||
len++;
|
||||
|
||||
if (code != rl->n && len < len_tab[index]) {
|
||||
bits_tab[index] = bits;
|
||||
@ -1198,14 +1249,16 @@ static av_cold void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab,
|
||||
/* ESC2 */
|
||||
bits = rl->table_vlc[rl->n][0];
|
||||
len = rl->table_vlc[rl->n][1];
|
||||
bits=bits*4+2; len+=2; //esc2
|
||||
bits = bits * 4 + 2;
|
||||
len += 2; // esc2
|
||||
run1 = run - rl->max_run[last][level] - 1;
|
||||
if (run1 >= 0) {
|
||||
code = get_rl_index(rl, last, run1, level);
|
||||
bits <<= rl->table_vlc[code][1];
|
||||
len += rl->table_vlc[code][1];
|
||||
bits += rl->table_vlc[code][0];
|
||||
bits=bits*2+sign; len++;
|
||||
bits = bits * 2 + sign;
|
||||
len++;
|
||||
|
||||
if (code != rl->n && len < len_tab[index]) {
|
||||
bits_tab[index] = bits;
|
||||
@ -1215,12 +1268,18 @@ static av_cold void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab,
|
||||
/* ESC3 */
|
||||
bits = rl->table_vlc[rl->n][0];
|
||||
len = rl->table_vlc[rl->n][1];
|
||||
bits=bits*4+3; len+=2; //esc3
|
||||
bits=bits*2+last; len++;
|
||||
bits=bits*64+run; len+=6;
|
||||
bits=bits*2+1; len++; //marker
|
||||
bits=bits*4096+(slevel&0xfff); len+=12;
|
||||
bits=bits*2+1; len++; //marker
|
||||
bits = bits * 4 + 3;
|
||||
len += 2; // esc3
|
||||
bits = bits * 2 + last;
|
||||
len++;
|
||||
bits = bits * 64 + run;
|
||||
len += 6;
|
||||
bits = bits * 2 + 1;
|
||||
len++; // marker
|
||||
bits = bits * 4096 + (slevel & 0xfff);
|
||||
len += 12;
|
||||
bits = bits * 2 + 1;
|
||||
len++; // marker
|
||||
|
||||
if (len < len_tab[index]) {
|
||||
bits_tab[index] = bits;
|
||||
@ -1268,7 +1327,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
||||
s->c_dc_scale_table = ff_mpeg4_c_dc_scale_table;
|
||||
|
||||
if (s->flags & CODEC_FLAG_GLOBAL_HEADER) {
|
||||
|
||||
s->avctx->extradata = av_malloc(1024);
|
||||
init_put_bits(&s->pb, s->avctx->extradata, 1024);
|
||||
|
||||
@ -1322,7 +1380,6 @@ void ff_mpeg4_merge_partitions(MpegEncContext *s)
|
||||
s->last_bits = put_bits_count(&s->pb);
|
||||
}
|
||||
|
||||
|
||||
void ff_mpeg4_encode_video_packet_header(MpegEncContext *s)
|
||||
{
|
||||
int mb_num_bits = av_log2(s->mb_num - 1) + 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user