summaryrefslogtreecommitdiff
path: root/src/libffmpeg/libavcodec/h263.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libffmpeg/libavcodec/h263.c')
-rw-r--r--src/libffmpeg/libavcodec/h263.c193
1 files changed, 102 insertions, 91 deletions
diff --git a/src/libffmpeg/libavcodec/h263.c b/src/libffmpeg/libavcodec/h263.c
index 81c3648f1..80a283bb5 100644
--- a/src/libffmpeg/libavcodec/h263.c
+++ b/src/libffmpeg/libavcodec/h263.c
@@ -110,7 +110,7 @@ max run: 29/41
*/
#endif
-#if 0 //3IV1 is quite rare and tis slows things down a tiny bit
+#if 0 //3IV1 is quite rare and it slows things down a tiny bit
#define IS_3IV1 s->avctx->codec_tag == ff_get_fourcc("3IV1")
#else
#define IS_3IV1 0
@@ -160,8 +160,8 @@ void ff_flv_encode_picture_header(MpegEncContext * s, int picture_number)
put_bits(&s->pb, 17, 1);
put_bits(&s->pb, 5, (s->h263_flv-1)); /* 0: h263 escape codes 1: 11-bit escape codes */
- put_bits(&s->pb, 8, (((int64_t)s->picture_number * 30 * s->avctx->frame_rate_base) /
- s->avctx->frame_rate) & 0xff); /* TemporalReference */
+ put_bits(&s->pb, 8, (((int64_t)s->picture_number * 30 * s->avctx->time_base.num) / //FIXME use timestamp
+ s->avctx->time_base.den) & 0xff); /* TemporalReference */
if (s->width == 352 && s->height == 288)
format = 2;
else if (s->width == 176 && s->height == 144)
@@ -208,9 +208,9 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
if(s->h263_plus){
for(i=0; i<2; i++){
int div, error;
- div= (s->avctx->frame_rate_base*1800000LL + 500LL*s->avctx->frame_rate) / ((1000LL+i)*s->avctx->frame_rate);
+ div= (s->avctx->time_base.num*1800000LL + 500LL*s->avctx->time_base.den) / ((1000LL+i)*s->avctx->time_base.den);
div= clip(1, div, 127);
- error= ABS(s->avctx->frame_rate_base*1800000LL - (1000LL+i)*s->avctx->frame_rate*div);
+ error= ABS(s->avctx->time_base.num*1800000LL - (1000LL+i)*s->avctx->time_base.den*div);
if(error < best_error){
best_error= error;
best_divisor= div;
@@ -227,8 +227,8 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
/* Update the pointer to last GOB */
s->ptr_lastgob = pbBufPtr(&s->pb);
put_bits(&s->pb, 22, 0x20); /* PSC */
- temp_ref= s->picture_number * (int64_t)coded_frame_rate * s->avctx->frame_rate_base /
- (coded_frame_rate_base * (int64_t)s->avctx->frame_rate);
+ temp_ref= s->picture_number * (int64_t)coded_frame_rate * s->avctx->time_base.num / //FIXME use timestamp
+ (coded_frame_rate_base * (int64_t)s->avctx->time_base.den);
put_bits(&s->pb, 8, temp_ref & 0xff); /* TemporalReference */
put_bits(&s->pb, 1, 1); /* marker */
@@ -523,8 +523,7 @@ void ff_clean_mpeg4_qscales(MpegEncContext *s){
if(s->pict_type== B_TYPE){
int odd=0;
- /* ok, come on, this isnt funny anymore, theres 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];
@@ -615,11 +614,11 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){
void ff_h263_update_motion_val(MpegEncContext * s){
const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
- //FIXME a lot of thet is only needed for !low_delay
+ //FIXME a lot of that is only needed for !low_delay
const int wrap = s->b8_stride;
const int xy = s->block_index[0];
- s->current_picture.mbskip_table[mb_xy]= s->mb_skiped;
+ s->current_picture.mbskip_table[mb_xy]= s->mb_skipped;
if(s->mv_type != MV_TYPE_8X8){
int motion_x, motion_y;
@@ -855,16 +854,16 @@ void mpeg4_encode_mb(MpegEncContext * s,
assert((s->dquant&1)==0);
assert(mb_type>=0);
- /* nothing to do if this MB was skiped in the next P Frame */
+ /* nothing to do if this MB was skipped in the next P Frame */
if(s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]){ //FIXME avoid DCT & ...
s->skip_count++;
s->mv[0][0][0]=
s->mv[0][0][1]=
s->mv[1][0][0]=
s->mv[1][0][1]= 0;
- s->mv_dir= MV_DIR_FORWARD; //doesnt matter
+ s->mv_dir= MV_DIR_FORWARD; //doesn't matter
s->qscale -= s->dquant;
-// s->mb_skiped=1;
+// s->mb_skipped=1;
return;
}
@@ -887,7 +886,7 @@ void 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 dont need it :)
+ 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 && mb_type){
@@ -901,7 +900,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
if(!s->progressive_sequence){
if(cbp)
put_bits(&s->pb, 1, s->interlaced_dct);
- if(mb_type) // not diect mode
+ if(mb_type) // not direct mode
put_bits(&s->pb, 1, s->mv_type == MV_TYPE_FIELD);
}
@@ -976,7 +975,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
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 didnt they just compress the skip-mb bits instead of reusing them ?! */
+ 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;
@@ -990,7 +989,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
offset= x + y*s->linesize;
p_pic= s->new_picture.data[0] + offset;
- s->mb_skiped=1;
+ s->mb_skipped=1;
for(i=0; i<s->max_b_frames; i++){
uint8_t *b_pic;
int diff;
@@ -1001,14 +1000,14 @@ void mpeg4_encode_mb(MpegEncContext * s,
b_pic= pic->data[0] + offset + 16; //FIXME +16
diff= s->dsp.sad[0](NULL, p_pic, b_pic, s->linesize, 16);
if(diff>s->qscale*70){ //FIXME check that 70 is optimal
- s->mb_skiped=0;
+ s->mb_skipped=0;
break;
}
}
}else
- s->mb_skiped=1;
+ s->mb_skipped=1;
- if(s->mb_skiped==1){
+ if(s->mb_skipped==1){
/* skip macroblock */
put_bits(&s->pb, 1, 1);
@@ -1623,7 +1622,7 @@ int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir,
A = mot_val[ - 1];
/* special case for first (slice) line */
if (s->first_slice_line && block<3) {
- // we cant just change some MVs to simulate that as we need them for the B frames (and ME)
+ // we can't just change some MVs to simulate that as we need them for the B frames (and ME)
// and if we ever support non rectangular objects than we need to do a few ifs here anyway :(
if(block==0){ //most common case
if(s->mb_x == s->resync_mb_x){ //rare
@@ -2054,7 +2053,7 @@ void h263_encode_init(MpegEncContext *s)
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
break;
- default: //nothing needed default table allready set in mpegvideo.c
+ default: //nothing needed - default table already set in mpegvideo.c
s->min_qcoeff= -127;
s->max_qcoeff= 127;
s->y_dc_scale_table=
@@ -2210,10 +2209,10 @@ void ff_set_mpeg4_time(MpegEncContext * s, int picture_number){
int time_div, time_mod;
assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE);
- s->time= (s->current_picture_ptr->pts*s->time_increment_resolution + AV_TIME_BASE/2)/AV_TIME_BASE;
+ s->time= s->current_picture_ptr->pts*s->avctx->time_base.num;
- time_div= s->time/s->time_increment_resolution;
- time_mod= s->time%s->time_increment_resolution;
+ time_div= s->time/s->avctx->time_base.den;
+ time_mod= s->time%s->avctx->time_base.den;
if(s->pict_type==B_TYPE){
s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
@@ -2237,9 +2236,9 @@ static void mpeg4_encode_gop_header(MpegEncContext * s){
time= s->current_picture_ptr->pts;
if(s->reordered_input_picture[1])
time= FFMIN(time, s->reordered_input_picture[1]->pts);
- time= (time*s->time_increment_resolution + AV_TIME_BASE/2)/AV_TIME_BASE;
+ time= time*s->avctx->time_base.num;
- seconds= time/s->time_increment_resolution;
+ seconds= time/s->avctx->time_base.den;
minutes= seconds/60; seconds %= 60;
hours= minutes/60; minutes %= 60;
hours%=24;
@@ -2252,7 +2251,7 @@ static void mpeg4_encode_gop_header(MpegEncContext * s){
put_bits(&s->pb, 1, !!(s->flags&CODEC_FLAG_CLOSED_GOP));
put_bits(&s->pb, 1, 0); //broken link == NO
- s->last_time_base= time / s->time_increment_resolution;
+ s->last_time_base= time / s->avctx->time_base.den;
ff_mpeg4_stuffing(&s->pb);
}
@@ -2349,7 +2348,7 @@ static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_n
put_bits(&s->pb, 2, RECT_SHAPE); /* vol shape= rectangle */
put_bits(&s->pb, 1, 1); /* marker bit */
- put_bits(&s->pb, 16, s->time_increment_resolution);
+ put_bits(&s->pb, 16, s->avctx->time_base.den);
if (s->time_increment_bits < 1)
s->time_increment_bits = 1;
put_bits(&s->pb, 1, 1); /* marker bit */
@@ -2420,14 +2419,14 @@ void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
s->partitioned_frame= s->data_partitioning && s->pict_type!=B_TYPE;
-//printf("num:%d rate:%d base:%d\n", s->picture_number, s->frame_rate, FRAME_RATE_BASE);
+//printf("num:%d rate:%d base:%d\n", s->picture_number, s->time_base.den, FRAME_RATE_BASE);
put_bits(&s->pb, 16, 0); /* vop header */
put_bits(&s->pb, 16, VOP_STARTCODE); /* vop header */
put_bits(&s->pb, 2, s->pict_type - 1); /* pict type: I = 0 , P = 1 */
- time_div= s->time/s->time_increment_resolution;
- time_mod= s->time%s->time_increment_resolution;
+ time_div= s->time/s->avctx->time_base.den;
+ time_mod= s->time%s->avctx->time_base.den;
time_incr= time_div - s->last_time_base;
assert(time_incr >= 0);
while(time_incr--)
@@ -2509,7 +2508,7 @@ static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, int level, int *di
b = dc_val[ - 1 - wrap];
c = dc_val[ - wrap];
- /* outside slice handling (we cant do that by memset as we need the dc for error resilience) */
+ /* outside slice handling (we can't do that by memset as we need the dc for error resilience) */
if(s->first_slice_line && n!=3){
if(n!=2) b=c= 1024;
if(n!=1 && s->mb_x == s->resync_mb_x) b=a= 1024;
@@ -3211,7 +3210,7 @@ static int mpeg4_decode_video_packet_header(MpegEncContext *s)
}
if(s->pict_type == B_TYPE){
while(s->next_picture.mbskip_table[ s->mb_index2xy[ mb_num ] ]) mb_num++;
- if(mb_num >= s->mb_num) return -1; // slice contains just skiped MBs which where allready decoded
+ if(mb_num >= s->mb_num) return -1; // slice contains just skipped MBs which where allready decoded
}
s->mb_x= mb_num % s->mb_width;
@@ -3242,7 +3241,7 @@ static int mpeg4_decode_video_packet_header(MpegEncContext *s)
if(s->shape != BIN_ONLY_SHAPE){
skip_bits(&s->gb, 3); /* intra dc vlc threshold */
-//FIXME dont just ignore everything
+//FIXME don't just ignore everything
if(s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE){
mpeg4_decode_sprite_trajectory(s, &s->gb);
av_log(s->avctx, AV_LOG_ERROR, "untested\n");
@@ -3293,7 +3292,7 @@ void ff_mpeg4_clean_buffers(MpegEncContext *s)
memset(s->ac_val[2] + c_xy, 0, (c_wrap +1)*16*sizeof(int16_t));
/* clean MV */
- // we cant clear the MVs as they might be needed by a b frame
+ // we can't clear the MVs as they might be needed by a b frame
// memset(s->motion_val + l_xy, 0, (l_wrap*2+1)*2*sizeof(int16_t));
// memset(s->motion_val, 0, 2*sizeof(int16_t)*(2 + s->mb_width*2)*(2 + s->mb_height*2));
s->last_mv[0][0][0]=
@@ -3322,7 +3321,7 @@ int ff_h263_resync(MpegEncContext *s){
if(ret>=0)
return 0;
}
- //ok, its not where its supposed to be ...
+ //ok, it's not where its supposed to be ...
s->gb= s->last_resync_gb;
align_get_bits(&s->gb);
left= s->gb.size_in_bits - get_bits_count(&s->gb);
@@ -3729,10 +3728,10 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64])
s->mv_type = MV_TYPE_16X16;
if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE){
s->mcsel=1;
- s->mb_skiped = 0;
+ s->mb_skipped = 0;
}else{
s->mcsel=0;
- s->mb_skiped = 1;
+ s->mb_skipped = 1;
}
}else if(s->mb_intra){
s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]);
@@ -3753,6 +3752,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64])
if (!IS_SKIP(mb_type)) {
int i;
+ s->dsp.clear_blocks(s->block[0]);
/* decode each block */
for (i = 0; i < 6; i++) {
if(mpeg4_decode_block(s, block[i], i, cbp&32, s->mb_intra, s->rvlc) < 0){
@@ -3910,7 +3910,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
- s->mb_skiped = !(s->obmc | s->loop_filter);
+ s->mb_skipped = !(s->obmc | s->loop_filter);
goto end;
}
cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
@@ -3921,6 +3921,8 @@ int ff_h263_decode_mb(MpegEncContext *s,
}
}while(cbpc == 20);
+ s->dsp.clear_blocks(s->block[0]);
+
dquant = cbpc & 8;
s->mb_intra = ((cbpc & 4) != 0);
if (s->mb_intra) goto intra;
@@ -4024,6 +4026,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
s->mb_intra = IS_INTRA(mb_type);
if(HAS_CBP(mb_type)){
+ s->dsp.clear_blocks(s->block[0]);
cbpc = get_vlc2(&s->gb, cbpc_b_vlc.table, CBPC_B_VLC_BITS, 1);
if(s->mb_intra){
dquant = IS_QUANT(mb_type);
@@ -4102,6 +4105,8 @@ int ff_h263_decode_mb(MpegEncContext *s,
}
}while(cbpc == 8);
+ s->dsp.clear_blocks(s->block[0]);
+
dquant = cbpc & 4;
s->mb_intra = 1;
intra:
@@ -4175,13 +4180,13 @@ int ff_mpeg4_decode_mb(MpegEncContext *s,
s->mv[0][0][0]= get_amv(s, 0);
s->mv[0][0][1]= get_amv(s, 1);
- s->mb_skiped = 0;
+ s->mb_skipped = 0;
}else{
s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
s->mcsel=0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
- s->mb_skiped = 1;
+ s->mb_skipped = 1;
}
goto end;
}
@@ -4193,6 +4198,7 @@ int ff_mpeg4_decode_mb(MpegEncContext *s,
}
}while(cbpc == 20);
+ s->dsp.clear_blocks(s->block[0]);
dquant = cbpc & 8;
s->mb_intra = ((cbpc & 4) != 0);
if (s->mb_intra) goto intra;
@@ -4294,9 +4300,9 @@ int ff_mpeg4_decode_mb(MpegEncContext *s,
}
/* if we skipped it in the future P Frame than skip it now too */
- s->mb_skiped= s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC
+ s->mb_skipped= s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC
- if(s->mb_skiped){
+ if(s->mb_skipped){
/* skip mb */
for(i=0;i<6;i++)
s->block_last_index[i] = -1;
@@ -4324,7 +4330,10 @@ int ff_mpeg4_decode_mb(MpegEncContext *s,
}
mb_type= mb_type_b_map[ mb_type ];
if(modb2) cbp= 0;
- else cbp= get_bits(&s->gb, 6);
+ else{
+ s->dsp.clear_blocks(s->block[0]);
+ cbp= get_bits(&s->gb, 6);
+ }
if ((!IS_DIRECT(mb_type)) && cbp) {
if(get_bits1(&s->gb)){
@@ -4442,6 +4451,7 @@ intra:
if(!s->progressive_sequence)
s->interlaced_dct= get_bits1(&s->gb);
+ s->dsp.clear_blocks(s->block[0]);
/* decode each block */
for (i = 0; i < 6; i++) {
if (mpeg4_decode_block(s, block[i], i, cbp&32, 1, 0) < 0)
@@ -4556,6 +4566,7 @@ static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
} else if (s->mb_intra) {
/* DC coef */
if(s->codec_id == CODEC_ID_RV10){
+#ifdef CONFIG_RV10_DECODER
if (s->rv10_version == 3 && s->pict_type == I_TYPE) {
int component, diff;
component = (n <= 3 ? 0 : n - 4 + 1);
@@ -4575,6 +4586,7 @@ static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
if (level == 255)
level = 128;
}
+#endif
}else{
level = get_bits(&s->gb, 8);
if((level&0x7F) == 0){
@@ -4638,7 +4650,7 @@ retry:
i += run;
if (i >= 64){
if(s->alt_inter_vlc && rl == &rl_inter && !s->mb_intra){
- //looks like a hack but no, its the way its supposed to work ...
+ //looks like a hack but no, it's the way its supposed to work ...
rl = &rl_intra_aic;
i = 0;
s->gb= gb;
@@ -5043,8 +5055,7 @@ int h263_decode_picture_header(MpegEncContext *s)
s->width = width;
s->height = height;
s->avctx->sample_aspect_ratio= (AVRational){12,11};
- s->avctx->frame_rate = 30000;
- s->avctx->frame_rate_base= 1001;
+ s->avctx->time_base= (AVRational){1001, 30000};
} else {
int ufep;
@@ -5139,20 +5150,19 @@ int h263_decode_picture_header(MpegEncContext *s)
if(s->custom_pcf){
int gcd;
- s->avctx->frame_rate= 1800000;
- s->avctx->frame_rate_base= 1000 + get_bits1(&s->gb);
- s->avctx->frame_rate_base*= get_bits(&s->gb, 7);
- if(s->avctx->frame_rate_base == 0){
+ s->avctx->time_base.den= 1800000;
+ s->avctx->time_base.num= 1000 + get_bits1(&s->gb);
+ s->avctx->time_base.num*= get_bits(&s->gb, 7);
+ if(s->avctx->time_base.num == 0){
av_log(s, AV_LOG_ERROR, "zero framerate\n");
return -1;
}
- gcd= ff_gcd(s->avctx->frame_rate, s->avctx->frame_rate_base);
- s->avctx->frame_rate /= gcd;
- s->avctx->frame_rate_base /= gcd;
-// av_log(s->avctx, AV_LOG_DEBUG, "%d/%d\n", s->avctx->frame_rate, s->avctx->frame_rate_base);
+ gcd= ff_gcd(s->avctx->time_base.den, s->avctx->time_base.num);
+ s->avctx->time_base.den /= gcd;
+ s->avctx->time_base.num /= gcd;
+// av_log(s->avctx, AV_LOG_DEBUG, "%d/%d\n", s->avctx->time_base.den, s->avctx->time_base.num);
}else{
- s->avctx->frame_rate = 30000;
- s->avctx->frame_rate_base= 1001;
+ s->avctx->time_base= (AVRational){1001, 30000};
}
}
@@ -5223,7 +5233,7 @@ int h263_decode_picture_header(MpegEncContext *s)
s->modified_quant ? " MQ" : "",
s->loop_filter ? " LOOP" : "",
s->h263_slice_structured ? " SS" : "",
- s->avctx->frame_rate, s->avctx->frame_rate_base
+ s->avctx->time_base.den, s->avctx->time_base.num
);
}
#if 1
@@ -5287,7 +5297,7 @@ static void mpeg4_decode_sprite_trajectory(MpegEncContext * s, GetBitContext *gb
w2= 1<<alpha;
h2= 1<<beta;
-// Note, the 4th point isnt used for GMC
+// Note, the 4th point isn't used for GMC
if(s->divx_version==500 && s->divx_build==413){
sprite_ref[0][0]= a*vop_ref[0][0] + d[0][0];
sprite_ref[0][1]= a*vop_ref[0][1] + d[0][1];
@@ -5512,7 +5522,7 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
skip_bits1(gb); /* marker */
}
}else{
- // set low delay flag only once so the smart? low delay detection wont be overriden
+ // set low delay flag only once the smartest? low delay detection won't be overriden
if(s->picture_number==0)
s->low_delay=0;
}
@@ -5526,18 +5536,19 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
check_marker(gb, "before time_increment_resolution");
- s->time_increment_resolution = get_bits(gb, 16);
+ s->avctx->time_base.den = get_bits(gb, 16);
- s->time_increment_bits = av_log2(s->time_increment_resolution - 1) + 1;
+ s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
if (s->time_increment_bits < 1)
s->time_increment_bits = 1;
check_marker(gb, "before fixed_vop_rate");
if (get_bits1(gb) != 0) { /* fixed_vop_rate */
- skip_bits(gb, s->time_increment_bits);
- }
-
+ s->avctx->time_base.num = get_bits(gb, s->time_increment_bits);
+ }else
+ s->avctx->time_base.num = 1;
+
s->t_frame=0;
if (s->shape != BIN_ONLY_SHAPE) {
@@ -5586,7 +5597,7 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
if (get_bits1(gb) == 1) { /* not_8_bit */
s->quant_precision = get_bits(gb, 4); /* quant_precision */
if(get_bits(gb, 4)!=8) av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n"); /* bits_per_pixel */
- if(s->quant_precision!=5) av_log(s->avctx, AV_LOG_ERROR, "quant precission %d\n", s->quant_precision);
+ if(s->quant_precision!=5) av_log(s->avctx, AV_LOG_ERROR, "quant precision %d\n", s->quant_precision);
} else {
s->quant_precision = 5;
}
@@ -5778,7 +5789,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
s->pict_type = get_bits(gb, 2) + I_TYPE; /* pict type: I = 0 , P = 1 */
if(s->pict_type==B_TYPE && s->low_delay && s->vol_control_parameters==0 && !(s->flags & CODEC_FLAG_LOW_DELAY)){
- av_log(s->avctx, AV_LOG_ERROR, "low_delay flag set, but shouldnt, clearing it\n");
+ av_log(s->avctx, AV_LOG_ERROR, "low_delay flag incorrectly, clearing it\n");
s->low_delay=0;
}
@@ -5788,8 +5799,8 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
else
s->decode_mb= ff_mpeg4_decode_mb;
- if(s->time_increment_resolution==0){
- s->time_increment_resolution=1;
+ if(s->avctx->time_base.den==0){
+ s->avctx->time_base.den=1;
// fprintf(stderr, "time_increment_resolution is illegal\n");
}
time_incr=0;
@@ -5799,7 +5810,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
check_marker(gb, "before time_increment");
if(s->time_increment_bits==0){
- av_log(s->avctx, AV_LOG_ERROR, "hmm, seems the headers arnt complete, trying to guess time_increment_bits\n");
+ av_log(s->avctx, AV_LOG_ERROR, "hmm, seems the headers are not complete, trying to guess time_increment_bits\n");
for(s->time_increment_bits=1 ;s->time_increment_bits<16; s->time_increment_bits++){
if(show_bits(gb, s->time_increment_bits+1)&1) break;
@@ -5816,22 +5827,22 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
if(s->pict_type!=B_TYPE){
s->last_time_base= s->time_base;
s->time_base+= time_incr;
- s->time= s->time_base*s->time_increment_resolution + time_increment;
+ s->time= s->time_base*s->avctx->time_base.den + time_increment;
if(s->workaround_bugs&FF_BUG_UMP4){
if(s->time < s->last_non_b_time){
// fprintf(stderr, "header is not mpeg4 compatible, broken encoder, trying to workaround\n");
s->time_base++;
- s->time+= s->time_increment_resolution;
+ s->time+= s->avctx->time_base.den;
}
}
s->pp_time= s->time - s->last_non_b_time;
s->last_non_b_time= s->time;
}else{
- s->time= (s->last_time_base + time_incr)*s->time_increment_resolution + time_increment;
+ s->time= (s->last_time_base + time_incr)*s->avctx->time_base.den + time_increment;
s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){
-// printf("messed up order, seeking?, skiping current b frame\n");
- return FRAME_SKIPED;
+// printf("messed up order, maybe after seeking? skipping current b frame\n");
+ return FRAME_SKIPPED;
}
if(s->t_frame==0) s->t_frame= s->pb_time;
@@ -5843,9 +5854,9 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
}
//av_log(s->avctx, AV_LOG_DEBUG, "last nonb %Ld last_base %d time %Ld pp %d pb %d t %d ppf %d pbf %d\n", s->last_non_b_time, s->last_time_base, s->time, s->pp_time, s->pb_time, s->t_frame, s->pp_field_time, s->pb_field_time);
- s->current_picture_ptr->pts= s->time*(int64_t)AV_TIME_BASE / s->time_increment_resolution;
+ s->current_picture_ptr->pts= (s->time + s->avctx->time_base.num/2) / s->avctx->time_base.num;
if(s->avctx->debug&FF_DEBUG_PTS)
- av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %f\n", s->current_picture_ptr->pts/(float)AV_TIME_BASE);
+ av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %f\n", s->current_picture_ptr->pts);
check_marker(gb, "before vop_coded");
@@ -5853,9 +5864,9 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
if (get_bits1(gb) != 1){
if(s->avctx->debug&FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_ERROR, "vop not coded\n");
- return FRAME_SKIPED;
+ return FRAME_SKIPPED;
}
-//printf("time %d %d %d || %Ld %Ld %Ld\n", s->time_increment_bits, s->time_increment_resolution, s->time_base,
+//printf("time %d %d %d || %Ld %Ld %Ld\n", s->time_increment_bits, s->avctx->time_base.den, s->time_base,
//s->time, s->last_non_b_time, s->last_non_b_time - s->pp_time);
if (s->shape != BIN_ONLY_SHAPE && ( s->pict_type == P_TYPE
|| (s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE))) {
@@ -5951,20 +5962,20 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
if(s->enhancement_type){
int load_backward_shape= get_bits1(gb);
if(load_backward_shape){
- av_log(s->avctx, AV_LOG_ERROR, "load backward shape isnt supported\n");
+ av_log(s->avctx, AV_LOG_ERROR, "load backward shape isn't supported\n");
}
}
skip_bits(gb, 2); //ref_select_code
}
}
- /* detect buggy encoders which dont set the low_delay flag (divx4/xvid/opendivx)*/
- // note we cannot detect divx5 without b-frames easyly (allthough its buggy too)
+ /* detect buggy encoders which don't set the low_delay flag (divx4/xvid/opendivx)*/
+ // note we cannot detect divx5 without b-frames easily (although it's buggy too)
if(s->vo_type==0 && s->vol_control_parameters==0 && s->divx_version==0 && s->picture_number==0){
av_log(s->avctx, AV_LOG_ERROR, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
s->low_delay=1;
}
- s->picture_number++; // better than pic number==0 allways ;)
+ s->picture_number++; // better than pic number==0 always ;)
s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table; //FIXME add short header support
s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
@@ -6003,7 +6014,7 @@ int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb)
if(get_bits_count(gb) >= gb->size_in_bits){
if(gb->size_in_bits==8 && (s->divx_version || s->xvid_build)){
av_log(s->avctx, AV_LOG_ERROR, "frame skip %d\n", gb->size_in_bits);
- return FRAME_SKIPED; //divx bug
+ return FRAME_SKIPPED; //divx bug
}else
return -1; //end of stream
}
@@ -6032,11 +6043,11 @@ int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb)
else if(startcode==0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start");
else if(startcode==0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start");
else if(startcode==0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start");
- else if(startcode==0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Textutre Object start");
- else if(startcode==0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Textutre Spatial Layer start");
- else if(startcode==0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Textutre SNR Layer start");
- else if(startcode==0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Textutre Tile start");
- else if(startcode==0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Textutre Shape Layer start");
+ else if(startcode==0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Texture Object start");
+ else if(startcode==0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Texture Spatial Layer start");
+ else if(startcode==0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Texture SNR Layer start");
+ else if(startcode==0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Texture Tile start");
+ else if(startcode==0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Texture Shape Layer start");
else if(startcode==0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start");
else if(startcode<=0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved");
else if(startcode<=0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start");