X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fituh263enc.c;h=313f5f3e5977b8a8974fb966aa7d7b0884284e00;hb=5b145290df2998a9836a93eb925289c6c8b63af0;hp=07277bbeda1368b69ce96a453a81090df61d7e70;hpb=88bd7fdc821aaa0cbcf44cf075c62aaa42121e3f;p=ffmpeg diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 07277bbeda1..313f5f3e597 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -1,7 +1,7 @@ /* - * 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 * @@ -24,25 +24,23 @@ /** * @file - * h263 bitstream encoder. + * H.263 bitstream encoder. */ -//#define DEBUG #include -#include "dsputil.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 - /** * Table of number of bits a motion vector component needs. */ @@ -136,7 +134,7 @@ void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number) 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 */ @@ -152,7 +150,7 @@ void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number) 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 { @@ -271,11 +269,11 @@ void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line) } /** - * 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; - 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); @@ -462,7 +460,7 @@ void ff_h263_encode_mb(MpegEncContext * s, 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 */ @@ -529,8 +527,8 @@ void ff_h263_encode_mb(MpegEncContext * s, /* 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); @@ -569,10 +567,6 @@ void ff_h263_encode_mb(MpegEncContext * s, 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; @@ -595,7 +589,9 @@ void ff_h263_encode_mb(MpegEncContext * s, /* 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{ @@ -683,7 +679,7 @@ void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code) } } -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; @@ -725,7 +721,9 @@ static void init_mv_penalty_and_fcode(MpegEncContext *s) } } -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); @@ -768,22 +766,22 @@ static void init_uni_h263_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_t } } -void ff_h263_encode_init(MpegEncContext *s) +av_cold void ff_h263_encode_init(MpegEncContext *s) { static int done = 0; 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; @@ -793,7 +791,7 @@ void ff_h263_encode_init(MpegEncContext *s) } 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; @@ -809,7 +807,7 @@ void ff_h263_encode_init(MpegEncContext *s) 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;