* h263 bitstream encoder.
*/
-//#define DEBUG
#include <limits.h>
-#include "dsputil.h"
+#include "libavutil/attributes.h"
#include "avcodec.h"
#include "mpegvideo.h"
#include "h263.h"
#include "mathops.h"
+#include "mpegutils.h"
#include "unary.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.
*/
*/
void ff_clean_h263_qscales(MpegEncContext *s){
int i;
- int8_t * const qscale_table = s->current_picture.f.qscale_table;
+ int8_t * const qscale_table = s->current_picture.qscale_table;
ff_init_qscale_tab(s);
qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i+1] ]+2;
}
- if(s->codec_id != CODEC_ID_H263P){
+ if(s->codec_id != AV_CODEC_ID_H263P){
for(i=1; i<s->mb_num; i++){
int mb_xy= s->mb_index2xy[i];
* @param block the 8x8 block
* @param n block index (0-3 are luma, 4-5 are chroma)
*/
-static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
+static void h263_encode_block(MpegEncContext * s, int16_t * block, int n)
{
int level, run, last, i, j, last_index, last_non_zero, sign, slevel, code;
RLTable *rl;
}
void ff_h263_encode_mb(MpegEncContext * s,
- DCTELEM block[6][64],
+ int16_t block[6][64],
int motion_x, int motion_y)
{
int cbpc, cbpy, i, cbp, pred_x, pred_y;
/* motion vectors: 8x8 mode*/
ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
- motion_x = s->current_picture.f.motion_val[0][s->block_index[i]][0];
- motion_y = s->current_picture.f.motion_val[0][s->block_index[i]][1];
+ motion_x = s->current_picture.motion_val[0][s->block_index[i]][0];
+ motion_y = s->current_picture.motion_val[0][s->block_index[i]][1];
if (!s->umvplus) {
ff_h263_encode_motion_vector(s, motion_x - pred_x,
motion_y - pred_y, 1);
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{
}
}
-static void init_mv_penalty_and_fcode(MpegEncContext *s)
+static av_cold void init_mv_penalty_and_fcode(MpegEncContext *s)
{
int f_code;
int mv;
}
}
-static void init_uni_h263_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_tab){
+static av_cold void init_uni_h263_rl_tab(RLTable *rl, uint32_t *bits_tab,
+ uint8_t *len_tab)
+{
int slevel, run, last;
assert(MAX_LEVEL >= 64);
}
}
-void ff_h263_encode_init(MpegEncContext *s)
+av_cold void ff_h263_encode_init(MpegEncContext *s)
{
static int done = 0;
if (!done) {
done = 1;
- init_rl(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
- init_rl(&ff_rl_intra_aic, ff_h263_static_rl_table_store[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]);
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);
// use fcodes >1 only for mpeg4 & h263 & h263p FIXME
switch(s->codec_id){
- case CODEC_ID_MPEG4:
+ case AV_CODEC_ID_MPEG4:
s->fcode_tab= fcode_tab;
break;
- case CODEC_ID_H263P:
+ case AV_CODEC_ID_H263P:
if(s->umvplus)
s->fcode_tab= umv_fcode_tab;
if(s->modified_quant){
}
break;
//Note for mpeg4 & h263 the dc-scale table will be set per frame as needed later
- case CODEC_ID_FLV1:
+ case AV_CODEC_ID_FLV1:
if (s->h263_flv > 1) {
s->min_qcoeff= -1023;
s->max_qcoeff= 1023;