[Ffmpeg-devel] [PATCH] Ratecontrol 2nd pass bug
Mark Williams MWP
mwp
Wed Sep 7 10:31:29 CEST 2005
Greetings all,
My first patch submission, so be nice :)
This stops the assertion that occours if the 2nd pass encoding has more frames
than in the 1st pass log.
I have this problem frequently when encoding TS/TP files.
Its probably a bit of a hack, but it works.
Mark Williams.
-------------- next part --------------
--- libavcodec/ratecontrol.c 2005-09-07 17:52:55.000000000 +0930
+++ libavcodec/ratecontrol.c 2005-09-07 17:54:23.000000000 +0930
@@ -639,12 +639,15 @@
update_predictor(&rcc->pred[s->last_pict_type], rcc->last_qscale, sqrt(last_var), s->frame_bits);
}
- if(s->flags&CODEC_FLAG_PASS2){
- assert(picture_number>=0);
- assert(picture_number<rcc->num_entries);
- rce= &rcc->entry[picture_number];
- wanted_bits= rce->expected_bits;
- }else{
+ if ((s->flags & CODEC_FLAG_PASS2) && (picture_number >= 0) && (picture_number < rcc->num_entries))
+ {
+ rce= &rcc->entry[picture_number];
+ wanted_bits= rce->expected_bits;
+ }
+ else
+ {
+ if (s->flags & CODEC_FLAG_PASS2)
+ av_log(s->avctx, AV_LOG_ERROR, "Using CBR rates due to picture_number >= rcc->num_entries!\n");
rce= &local_rce;
wanted_bits= (uint64_t)(s->bit_rate*(double)picture_number/fps);
}
More information about the ffmpeg-devel
mailing list