@ -486,6 +486,20 @@ static inline void restore_ac_coeffs(MpegEncContext * s, DCTELEM block[6][64], i
}
}
}
}
/**
* init s - > current_picture . qscale_table from s - > lambda_table
*/
static void ff_init_qscale_tab ( MpegEncContext * s ) {
int8_t * const qscale_table = s - > current_picture . qscale_table ;
int i ;
for ( i = 0 ; i < s - > mb_num ; i + + ) {
unsigned int lam = s - > lambda_table [ s - > mb_index2xy [ i ] ] ;
int qp = ( lam * 139 + FF_LAMBDA_SCALE * 64 ) > > ( FF_LAMBDA_SHIFT + 7 ) ;
qscale_table [ s - > mb_index2xy [ i ] ] = clip ( qp , s - > avctx - > qmin , s - > avctx - > qmax ) ;
}
}
/**
/**
* modify qscale so that encoding is acually possible in h263 ( limit difference to - 2. .2 )
* modify qscale so that encoding is acually possible in h263 ( limit difference to - 2. .2 )
*/
*/
@ -493,6 +507,8 @@ void ff_clean_h263_qscales(MpegEncContext *s){
int i ;
int i ;
int8_t * const qscale_table = s - > current_picture . qscale_table ;
int8_t * const qscale_table = s - > current_picture . qscale_table ;
ff_init_qscale_tab ( s ) ;
for ( i = 1 ; i < s - > mb_num ; i + + ) {
for ( i = 1 ; i < s - > mb_num ; i + + ) {
if ( qscale_table [ s - > mb_index2xy [ i ] ] - qscale_table [ s - > mb_index2xy [ i - 1 ] ] > 2 )
if ( qscale_table [ s - > mb_index2xy [ i ] ] - qscale_table [ s - > mb_index2xy [ i - 1 ] ] > 2 )
qscale_table [ s - > mb_index2xy [ i ] ] = qscale_table [ s - > mb_index2xy [ i - 1 ] ] + 2 ;
qscale_table [ s - > mb_index2xy [ i ] ] = qscale_table [ s - > mb_index2xy [ i - 1 ] ] + 2 ;
@ -507,7 +523,6 @@ void ff_clean_h263_qscales(MpegEncContext *s){
int mb_xy = s - > mb_index2xy [ 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_INTER4V ) ) {
if ( qscale_table [ mb_xy ] ! = qscale_table [ s - > mb_index2xy [ i - 1 ] ] & & ( s - > mb_type [ mb_xy ] & CANDIDATE_MB_TYPE_INTER4V ) ) {
s - > mb_type [ mb_xy ] & = ~ CANDIDATE_MB_TYPE_INTER4V ;
s - > mb_type [ mb_xy ] | = CANDIDATE_MB_TYPE_INTER ;
s - > mb_type [ mb_xy ] | = CANDIDATE_MB_TYPE_INTER ;
}
}
}
}