Commit graph

59 commits

Author SHA1 Message Date
Joose Sainio 0e8815a3d8 test clipping qp to previous frame instead of previous ctus 2019-11-19 14:32:31 +02:00
Joose Sainio ddb4e5a131 move the intra bit calculation so that it is used also with lambda rc 2019-11-19 14:16:48 +02:00
Joose Sainio a07833f3e6 check that mallocs in rc initialization were successful
only call kvz_update_after_picture when using the OBA rc
2019-11-19 13:59:44 +02:00
Joose Sainio 57e5615ece Fix incorrect intra rc calculation skipping 2019-11-19 13:25:31 +02:00
Joose Sainio 6cc3bcd87e Command line parameters for oba rc and implementation of the usage of the intra parameter 2019-11-19 09:29:06 +02:00
Joose Sainio eb73548af5 Encode first frame completely before starting others to enable owf 2019-11-18 09:51:37 +02:00
Joose Sainio c759c138ed Prepare the rc data structure to be shared among all frame encoders 2019-11-13 11:56:25 +02:00
Joose Sainio cdb7c851a4 Fix weight calculation 2019-11-13 08:55:31 +02:00
Joose Sainio b9b01f8036 WPP with threading 2019-11-12 12:12:57 +02:00
Joose Sainio 615973adca should enable threading with wpp when owf is not used 2019-11-12 09:03:00 +02:00
Joose Sainio d353f7dd1a Disable debug prints, fix multiple bugs in the calculation 2019-11-07 15:08:57 +02:00
Joose Sainio 408fd4ccb6 Fix lambda and qp calcualtion for intra frames
also fixes a bug with selecting the clip neighbor lambda and clip neighbor qp
selection for inter frames
2019-11-05 10:51:39 +02:00
Joose Sainio 372934c7db Fix division by zero 2019-10-10 16:35:56 +03:00
Joose Sainio 9bdfdeaf5c Rest of the owl 2019-10-09 15:48:58 +03:00
Joose Sainio 1ba8525faf WIP 2019-10-09 10:35:07 +03:00
Joose Sainio 19496d2692 ? 2019-10-03 14:50:11 +03:00
Joose Sainio 4b111e339e fix couple of bugs in the implementation, bit calculation seems still bit off 2019-10-01 15:08:39 +03:00
Joose Sainio 84615e406a fix compiler warnings 2019-09-27 14:20:08 +03:00
Joose Sainio 14b7a75713 Call the new functions and fix bugs 2019-09-27 14:14:24 +03:00
Joose Sainio ef74bfb182 unify naming 2019-09-27 10:16:21 +03:00
Joose Sainio e36f481bda qp calculation for frame 2019-09-27 09:05:40 +03:00
Joose Sainio 47019ca1cd intra ck update 2019-09-26 16:04:53 +03:00
Joose Sainio 7c8f4da7cb Update c and k except after first intra 2019-09-26 13:09:28 +03:00
Joose Sainio 0577d481c1 CTU level code 2019-09-25 12:12:21 +03:00
Joose Sainio 7d2737bdf6 WIP picture lambda calculation 2019-09-03 11:03:35 +03:00
Joose Sainio 131c04f65c Fix incorrect weight for intra frame 2019-08-29 12:01:13 +03:00
Joose Sainio 8f96678d13 Fix issue with intra frames being part of gop when they shouldn't 2019-08-29 09:28:10 +03:00
Ari Lemmetti c6da839002 Set lcu sqrt lambda according to lcu lambda instead of frame lambda when ROI is used 2019-05-29 18:32:10 +03:00
Joose Sainio 1c8a1f24e2 Don't assume anything about bits spent 2018-11-07 16:03:38 +02:00
Joose Sainio 3471e2470d Fix using uninitialized value for the first frame 2018-11-07 08:17:39 +02:00
Joose Sainio d95ac11a3b Fix rate_control for other LP-GOPS 2018-11-06 14:20:44 +02:00
Arttu Ylä-Outinen 382636de55 Fix handling too large QPs
Changes kvz_config_validate to output an error if the given QP is out of
range and changes kvz_set_picture_lambda_and_qp to clip the QP to the
valid range if is too large after applying QP offset from GOP structure.
2017-05-17 12:41:51 +03:00
Arttu Ylä-Outinen 79cb3a2fd3 Permit negative QP deltas in ROI
Delta QPs should not be arbitrarily restricted to positive values.
2017-05-11 12:13:47 +03:00
Arttu Ylä-Outinen 51786eda67 Drop redundant fields in encoder_control_t
Some of the fields in encoder_control_t were simply copies of the
corresponding fields in kvz_config. This commit drops the copied fields
in favor of using the fields in encoder_control_t.cfg directly.
2017-02-09 14:05:28 +09:00
Arttu Ylä-Outinen e78a8dfcf5 Copy the kvz_config passed to encoder_open
The kvz_config struct is created by the user but kvazaar keeps a pointer
to it. It is easy to break things by modifying the configuration outside
kvazaar. In addition, kvazaar modifies the struct even though it is has
a const modifier.

This commit changes the field cfg in encoder_control_t to be a copy of
the kvz_config struct instead of a pointer, removing modifications to
the const struct and allowing users to do whatever they want with it
after opening the encoder.
2017-02-09 13:23:54 +09:00
Ari Koivula 4a0121ac42 Add --roi parameter
Adds region of interest coding capability.

Works by reading a file of delta QP values which will then be applied
to each frame at LCU level.
2017-01-26 09:14:14 +02:00
Arttu Ylä-Outinen 05794c3548 Add missing static to function lambda_to_qp 2017-01-11 15:53:55 +09:00
Arttu Ylä-Outinen ee518e8ac4 Take header bits into account in rate control 2017-01-11 15:53:55 +09:00
Arttu Ylä-Outinen 82a98180e4 Clip LCU lambda to reduce quality fluctuation
Limits lambdas for each LCU based on the computed lambda from the
previous frame and the frame-level lambda.
2017-01-09 01:24:23 +09:00
Arttu Ylä-Outinen 93172fd251 Use separate alpha, beta and lambda for each LCU
Changes rate control to use the alpha and beta values stored in
lcu_stats_t instead of the frame-level values when selecting lambda and
QP for an LCU.
2017-01-09 01:24:23 +09:00
Arttu Ylä-Outinen 3af4e9cc8a Allocate bits separately for each LCU
Bits are allocated based on the costs of the LCUs in the previous
completely coded frame.

Breaks deblock when rate control is used.
2017-01-09 01:24:23 +09:00
Arttu Ylä-Outinen ff5e5ec6d4 Record info about coded LCUs
Adds field lcu_stats to encoder_state_config_frame_t. The following data
is recorded for each LCU:
    - number of bits
    - squared cost
    - used lambda value
    - alpha parameter used for rate control
    - beta parameter used for rate control
2017-01-09 01:24:23 +09:00
Arttu Ylä-Outinen 2a4243acbe Refactor rate control
Moves all code related to setting QP and lambda values to rate_control
module.
2017-01-09 01:24:23 +09:00
Arttu Ylä-Outinen 640ff94ecd Use separate lambda and QP for each LCU
Adds fields lambda, lambda_sqrt and qp to encoder_state_t. Drops field
cur_lambda_cost_sqrt from encoder_state_config_frame_t and renames
cur_lambda_cost to lambda.
2017-01-09 01:24:23 +09:00
Arttu Ylä-Outinen 435c387357 Refactor rate control
- Defines MIN_LAMBDA and MAX_LAMBDA constants.
- Moves resetting state->frame->cur_gop_bits_coded to rate_control.c.
- Changes gop_allocate_bits to return the number of bits allocated like
  pic_allocate_bits does.
2017-01-09 01:24:23 +09:00
Arttu Ylä-Outinen 2a946bd88e Rename encoder_state_t.global to frame
"Frame" is more accurate than "global" since when OWF is used, encoder
states for each frame have their own struct.
2016-08-10 13:22:36 +09:00
Ari Koivula 4eaacbe23e Fix bug with lp-gop and ratecontrol
The first frame was always qp51 due to gop_offset being -1 for the
first frame. This fix makes it so that bits are allocated as if it was
the last (high quality) frame from the previous GOP.
2016-05-27 15:53:55 +03:00
Ari Koivula 61fc3e87ba Run include-what-you-use fix_includes.py fix_includes.py
The includes should make more sense now and not just happen to compile
due to headers included from other headers.

Used a modified version of IWYU. Modifications were to attribute int8_t
and so on to stdint.h instead of sys/types.h and immintrin.h instead of
more specific headers.

include-what-you-use 0.7 (git:b70df35)
based on clang version 3.9.0 (trunk 264728)
2016-04-01 17:46:55 +03:00
Ari Koivula d23a5a15f1 Fix overflow in rate control
A 32 bit int overflowed after 2^31 bits (2Gb). It will still overflow
eventually, after 500 years of outputting 1Gb/s, but by that time,
I recon we will have fixed this properly and it's time to upgrade.
2016-02-18 16:48:21 +02:00
Ari Koivula 8d9e8aad73 Fix lambda calculation to match HM
The lambda was not being increased for non-key frames and was different
in other ways too. The new implementation matches HM.
2015-11-03 16:49:42 +02:00