/*
- * ITU H263 bitstream encoder
+ * ITU H.263 bitstream encoder
* Copyright (c) 2000,2001 Fabrice Bellard
- * H263+ support.
+ * H.263+ support.
* Copyright (c) 2001 Juan J. Sierralta P
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
*
/**
* @file
- * h263 bitstream encoder.
+ * H.263 bitstream encoder.
*/
-//#define DEBUG
#include <limits.h>
#include "libavutil/attributes.h"
#include "avcodec.h"
#include "mpegvideo.h"
+#include "mpegvideodata.h"
#include "h263.h"
+#include "h263data.h"
#include "mathops.h"
-#include "unary.h"
+#include "mpegutils.h"
#include "flv.h"
#include "mpeg4video.h"
#include "internal.h"
-//#undef NDEBUG
-//#include <assert.h>
-
/**
* Table of number of bits a motion vector component needs.
*/
put_sbits(&s->pb, 8, temp_ref); /* TemporalReference */
put_bits(&s->pb, 1, 1); /* marker */
- put_bits(&s->pb, 1, 0); /* h263 id */
+ put_bits(&s->pb, 1, 0); /* H.263 id */
put_bits(&s->pb, 1, 0); /* split screen off */
put_bits(&s->pb, 1, 0); /* camera off */
put_bits(&s->pb, 1, 0); /* freeze picture release off */
put_bits(&s->pb, 1, 0); /* Unrestricted Motion Vector: off */
put_bits(&s->pb, 1, 0); /* SAC: off */
put_bits(&s->pb, 1, s->obmc); /* Advanced Prediction */
- put_bits(&s->pb, 1, 0); /* only I/P frames, no PB frame */
+ put_bits(&s->pb, 1, 0); /* only I/P-frames, no PB-frame */
put_bits(&s->pb, 5, s->qscale);
put_bits(&s->pb, 1, 0); /* Continuous Presence Multipoint mode: off */
} else {
}
/**
- * modify qscale so that encoding is acually possible in h263 (limit difference to -2..2)
+ * modify qscale so that encoding is actually possible in H.263 (limit difference to -2..2)
*/
void ff_clean_h263_qscales(MpegEncContext *s){
int i;
int16_t pred_dc;
int16_t rec_intradc[6];
int16_t *dc_ptr[6];
- const int interleaved_stats= (s->flags&CODEC_FLAG_PASS1);
+ const int interleaved_stats = s->avctx->flags & AV_CODEC_FLAG_PASS1;
if (!s->mb_intra) {
/* compute cbp */
else
level = (level - (scale>>1))/scale;
- /* AIC can change CBP */
- if (level == 0 && s->block_last_index[i] == 0)
- s->block_last_index[i] = -1;
-
if(!s->modified_quant){
if (level < -127)
level = -127;
/* Update AC/DC tables */
*dc_ptr[i] = rec_intradc[i];
- if (s->block_last_index[i] >= 0)
+ /* AIC can change CBP */
+ if (s->block_last_index[i] > 0 ||
+ (s->block_last_index[i] == 0 && level !=0))
cbp |= 1 << (5 - i);
}
}else{
if (!done) {
done = 1;
- ff_init_rl(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
- ff_init_rl(&ff_rl_intra_aic, ff_h263_static_rl_table_store[1]);
+ ff_rl_init(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
+ ff_rl_init(&ff_rl_intra_aic, ff_h263_static_rl_table_store[1]);
init_uni_h263_rl_tab(&ff_rl_intra_aic, NULL, uni_h263_intra_aic_rl_len);
init_uni_h263_rl_tab(&ff_h263_rl_inter , NULL, uni_h263_inter_rl_len);
init_mv_penalty_and_fcode(s);
}
- s->me.mv_penalty= mv_penalty; //FIXME exact table for msmpeg4 & h263p
+ s->me.mv_penalty= mv_penalty; // FIXME exact table for MSMPEG4 & H.263+
s->intra_ac_vlc_length =s->inter_ac_vlc_length = uni_h263_inter_rl_len;
s->intra_ac_vlc_last_length=s->inter_ac_vlc_last_length= uni_h263_inter_rl_len + 128*64;
}
s->ac_esc_length= 7+1+6+8;
- // use fcodes >1 only for mpeg4 & h263 & h263p FIXME
+ // use fcodes >1 only for MPEG-4 & H.263 & H.263+ FIXME
switch(s->codec_id){
case AV_CODEC_ID_MPEG4:
s->fcode_tab= fcode_tab;
s->max_qcoeff= 127;
}
break;
- //Note for mpeg4 & h263 the dc-scale table will be set per frame as needed later
+ // Note for MPEG-4 & H.263 the dc-scale table will be set per frame as needed later
case AV_CODEC_ID_FLV1:
if (s->h263_flv > 1) {
s->min_qcoeff= -1023;