Unified · Split
| @@ -56,20 +56,25 @@ void ff_write_pass1_stats(MpegEncContext *s) · 55 unmodified lines | |||
| 56 | s->header_bits); | 56 | s->header_bits); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | static double get_fps(AVCodecContext *avctx) | 59 | static AVRational get_fpsQ(AVCodecContext *avctx) |
| 60 | { | 60 | { |
| 61 | if (avctx->framerate.num > 0 && avctx->framerate.den > 0) | 61 | if (avctx->framerate.num > 0 && avctx->framerate.den > 0) |
| 62 | return av_q2d(avctx->framerate); | 62 | return avctx->framerate; |
| 63 | 63 | ||
| 64 | FF_DISABLE_DEPRECATION_WARNINGS | 64 | FF_DISABLE_DEPRECATION_WARNINGS |
| 65 | return 1.0 / av_q2d(avctx->time_base) | ||
| 66 | #if FF_API_TICKS_PER_FRAME | 65 | #if FF_API_TICKS_PER_FRAME |
| 67 | / FFMAX(avctx->ticks_per_frame, 1) | 66 | return av_div_q((AVRational){1, FFMAX(avctx->ticks_per_frame, 1)}, avctx->time_base); |
| 67 | #else | ||
| 68 | return av_inv_q(avctx->time_base); | ||
| 68 | #endif | 69 | #endif |
| 69 | ; | ||
| 70 | FF_ENABLE_DEPRECATION_WARNINGS | 70 | FF_ENABLE_DEPRECATION_WARNINGS |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | static double get_fps(AVCodecContext *avctx) | ||
| 74 | { | ||
| 75 | return av_q2d(get_fpsQ(avctx)); | ||
| 76 | } | ||
| 77 | |||
| 73 | static inline double qp2bits(const RateControlEntry *rce, double qp) | 78 | static inline double qp2bits(const RateControlEntry *rce, double qp) |
| 74 | { | 79 | { |
| 75 | if (qp <= 0.0) { | 80 | if (qp <= 0.0) { |
| @@ -332,12 +337,13 @@ static int init_pass2(MpegEncContext *s) · 256 unmodified lines | |||
| 332 | RateControlContext *rcc = &s->rc_context; | 337 | RateControlContext *rcc = &s->rc_context; |
| 333 | AVCodecContext *a = s->avctx; | 338 | AVCodecContext *a = s->avctx; |
| 334 | int i, toobig; | 339 | int i, toobig; |
| 335 | double fps = get_fps(s->avctx); | 340 | AVRational fps = get_fpsQ(s->avctx); |
| 336 | double complexity[5] = { 0 }; // approximate bits at quant=1 | 341 | double complexity[5] = { 0 }; // approximate bits at quant=1 |
| 337 | uint64_t const_bits[5] = { 0 }; // quantizer independent bits | 342 | uint64_t const_bits[5] = { 0 }; // quantizer independent bits |
| 338 | uint64_t all_const_bits; | 343 | uint64_t all_const_bits; |
| 339 | uint64_t all_available_bits = (uint64_t)(s->bit_rate * | 344 | uint64_t all_available_bits = av_rescale_q(s->bit_rate, |
| 340 | (double)rcc->num_entries / fps); | 345 | (AVRational){rcc->num_entries,1}, |
| 346 | fps); | ||
| 341 | double rate_factor = 0; | 347 | double rate_factor = 0; |
| 342 | double step; | 348 | double step; |
| 343 | const int filter_size = (int)(a->qblur * 4) | 1; | 349 | const int filter_size = (int)(a->qblur * 4) | 1; |