Commit graph

974 commits

Author SHA1 Message Date
Laurent Fasnacht 9112cbb58c Generate and use static tables 2014-04-16 09:49:09 +02:00
Ari Koivula a982800e1b Merge remote-tracking branch 'remotes/lfasnacht/const' 2014-04-16 10:28:31 +03:00
Ari Koivula df5af669f9 Merge remote-tracking branch 'remotes/lfasnacht/makefile_deps' 2014-04-16 10:28:04 +03:00
Ari Koivula 33b9594fec Take into account the coding cost of not using SAO. 2014-04-15 21:32:24 +03:00
Ari Koivula 880d09b27a Add sao_type_idx to SAO mode cost estimation. 2014-04-15 21:29:09 +03:00
Ari Koivula 280a946269 Apply bit cost fixes to edge band band sao search.
- Increases bdrate slightly. It's still a cleaner solution though and further
  improvements to bit cost estimation might improve things.
2014-04-15 21:28:16 +03:00
Ari Koivula c968253eb3 Estimate SAO merge coding costs better.
- This doesn't seem to have very much of an effect. I guess the difference
  between 1 and 2 bits isn't that important.
2014-04-15 21:27:16 +03:00
Ari Koivula ef7840c623 Add SAO coding costs for sao_eo_class, band position and offset sign.
- This reduces bdrate a little bit.

- It seems like increasing the bit cost of using SAO in general
  increases bdrate.
2014-04-15 21:24:44 +03:00
Ari Koivula 9ff32c566c Adjust SAO mode coding cost for zero offsets.
- Coding zero with TR only takes one bit.

- Even though offset 0 should be fairly common, this doesn't seem to help very
  much and actually increases bdrate on some sequences.
2014-04-15 21:21:31 +03:00
Ari Koivula 67a3d5542c Add better delta distortion calculation to sao. 2014-04-15 21:17:29 +03:00
Ari Koivula 8c4796e56e Calculate edge and band sao separately. 2014-04-15 21:16:55 +03:00
Ari Koivula 1017c6639c Move band and edge sao to their own functions. 2014-04-15 21:14:59 +03:00
Laurent Fasnacht 960f2cb4b0 g_sig_last_scan -> const uint32_t* 2014-04-15 16:09:52 +02:00
Laurent Fasnacht 288a4537ba const bit_table for exp_golomb 2014-04-15 16:09:52 +02:00
Laurent Fasnacht 763b775d3e encoder_control->cfg is const 2014-04-15 16:09:52 +02:00
Laurent Fasnacht ae2d79c954 Remove encoder_control.cqmfile 2014-04-15 16:09:51 +02:00
Laurent Fasnacht 86c1cf339f Add Makefile to dependencies 2014-04-15 15:47:40 +02:00
Laurent Fasnacht e135a88fb5 Remove encoder_control.cqmfile 2014-04-15 14:21:25 +02:00
Laurent Fasnacht 29c93d8f3f Automatic generation of build dependencies 2014-04-15 13:52:31 +02:00
Laurent Fasnacht 7897f7d5cd Remove counter from debug version of WRITE_*
It's not very useful, and create unneeded noise when trying to make diffs
2014-04-15 11:37:45 +02:00
Laurent Fasnacht f47e23cd24 Allow FREE_POINTER to free const xxx * ptr without warning 2014-04-15 11:37:44 +02:00
Laurent Fasnacht 52ae027b3a Avoid undefined behavior in memcpy calls
"The memcpy() function shall copy n bytes from the object pointed to by s2 into the object pointed to by s1. If copying takes place between objects that overlap, the behavior is undefined."
2014-04-15 06:30:21 +02:00
Laurent Fasnacht 317a3f87a4 Initialize scaling_list_dc (avoids branching on uninitialized value) 2014-04-15 06:19:12 +02:00
Laurent Fasnacht 9f3aeed6be Fix pixel access in sao 2014-04-14 15:40:06 +02:00
Laurent Fasnacht 486768fc79 scalinglist privatization 2014-04-14 13:39:28 +02:00
Laurent Fasnacht 78c579053a encoder_control should be const in nearly all the code 2014-04-14 10:56:06 +02:00
Marko Viitanen 0e7a5057d1 Merge pull request #26 from lfasnacht/warnings_fix
Fix warnings and compile with -Werror
2014-04-14 11:30:37 +03:00
Marko Viitanen 04f09a2bc8 Merge pull request #25 from lfasnacht/memory_bitstream
Changed bitstream handling to allow in-memory bitstream.
2014-04-14 11:29:25 +03:00
Laurent Fasnacht 13398e011b Fix create_bitstream() 2014-04-14 10:23:09 +02:00
Laurent Fasnacht 64f3f57af3 Compile with -Werror 2014-04-14 09:38:37 +02:00
Laurent Fasnacht 89ef1161c4 Fix warnings 2014-04-14 09:37:39 +02:00
Laurent Fasnacht baba299bb8 Obviously a void function cannot return NULL 2014-04-14 09:11:15 +02:00
Laurent Fasnacht 418e6eae51 Changed bitstream handling to allow in-memory bitstream. 2014-04-14 08:13:00 +02:00
Laurent Fasnacht 520dbdd86d Change return type of free_exp_golomb to be void, and add it to bitstream.h 2014-04-14 06:41:27 +02:00
Ari Koivula 29787efbbc Fix whitespace.
Fix some whitespace issues from a merge.
2014-04-11 17:06:21 +03:00
Ari Koivula 83d5a4753d Move input resolution to the same line as internal resolution.
The \n must have been left there by accident.
2014-04-11 16:55:08 +03:00
Ari Koivula 0b5c357795 Move all output to stderr.
It has to be in stderr to allow piping bitstream from stdout.
2014-04-11 16:50:59 +03:00
Ari Koivula 115872b300 Add total running time to output. 2014-04-11 12:42:37 +03:00
Marko Viitanen de1c0b7e8d Fixed intra RDO to include mode bitcost 2014-04-10 16:28:41 +03:00
Marko Viitanen a657cf84d9 Insert most probable (predicted) intra modes to RDO search 2014-04-10 15:59:36 +03:00
Marko Viitanen 05169d9476 Added more modes to RDO mode selection in intra search
Now 8 best modes for sizes 4x4 and 8x8 are added to RDO checking and 3 for other block sizes as before, only applies when --rd 2
2014-04-10 15:20:49 +03:00
Ari Koivula 5fa5e01e05 Merge branch 'intra-cleanup'
Conflicts:
	src/intra.c
	src/intra.h
	src/search.c
2014-04-10 13:51:14 +03:00
Ari Koivula 40c2fa4d46 Change intra reconstruction to use the same prediction function as search.
- This fixes a bug with intra search. It sometimes used filtered reference
  pixels for 4x4 blocks leading to inaccurate cost estimate.
2014-04-10 12:09:19 +03:00
Ari Koivula d5c3ad7a2b Move intra prediction generation to its own function. 2014-04-10 11:27:15 +03:00
Ari Koivula 088dd9ab96 Clean up intra mode search.
- This changes the bitstream a little bit, because it changes the order in
  which the modes are tried and when two modes have the same cost the first
  one is chosen.

- Dst buffer was removes as it was no longer used.
2014-04-10 10:25:57 +03:00
Marko Viitanen 43ae0a3b9a Implemented RDO cost calculation to Intra modes 2014-04-10 10:25:20 +03:00
Marko Viitanen c38ec1aa10 Added commandline option for RDO (--rd) 2014-04-09 12:29:15 +03:00
Marko Viitanen 6558c92020 Clean up get_coeff_cost()
Since contexts were moved to cabac struct, there's no need to store contexts one by one
2014-04-09 11:50:17 +03:00
Ari Koivula 92ac5025f9 Take intra mode based coeff scan mode into account for coeff bit cost.
- Previously only diagonal scan mode, the most common one, would be used.

- This improved bdrate by 0.1-0.5 % for p0 and 0-0.2 % for p60.
2014-04-09 10:44:44 +03:00
Ari Koivula c5dfcdf3aa Simplify scan mode selection.
- The scan mode selection for chroma was a bit complicated so I checked it
  and it was all unnecessary. The mode selection is the same as for luma.
2014-04-09 10:36:39 +03:00
Ari Koivula 3764688f84 Fix lambda initialization.
- Lambda was initialized before slice type was set in encoder_control.
2014-04-08 16:58:36 +03:00
Ari Koivula 0251bf5a1a Improve calculation of chroma coding cost for 4x4 blocks.
- Adds calculation of chroma coefficient cost for 4x4 blocks.

- Previously there was no cost. Now the cost is added to the first prediction
  block for NxN.

- This fix should improve bdrate by about 1%.
2014-04-08 12:43:26 +03:00
Ari Koivula 3c0977c7f3 Fix buffer overflow on copying of reference pixels.
- Valgrind noticed this.

- Shouldn't affect anything as the buffer overflowed to pixel buffers which
  were initialized later.
2014-04-04 17:28:56 +03:00
Ari Koivula 6e0bc655e2 Resolve unused variable warning.
- This unexpectedly changes bitstream, but as that makes no sense, it must be
  because some part of the program uses uninitialized memory.
2014-04-04 17:28:50 +03:00
Marko Viitanen e15a86268d Clean up tabs and whitespaces 2014-04-04 16:04:44 +03:00
Laurent Fasnacht 816ae13b1d Moved context information inside cabac_data.
This is required in order to be able to work on parallelism.
2014-04-04 14:28:50 +02:00
Laurent Fasnacht 8a14bd3b7b Remove cabac global variable 2014-04-04 14:26:40 +02:00
Laurent Fasnacht 946c815932 init_context directly has a QP parameter, instead of passing an encoder_control*
This makes context less tightly coupled with encoder.
2014-04-04 14:26:39 +02:00
Laurent Fasnacht 1e03cf8ac1 Add a function to free g_exp_table.
Even though g_exp_table has to be global (used in #define), it's better to avoid requiring other module to directly access it.
2014-04-04 14:26:39 +02:00
Marko Viitanen 7484dafd82 Fix for get_coeff_cost() scan mode selection
Small BD-rate improvement with this fix
2014-04-04 15:16:04 +03:00
Marko Viitanen c5ba5eb3c8 Use RDO in final_cost 2014-04-04 14:10:49 +03:00
Marko Viitanen b83559d3f3 Use RDO to check for transform skip mode 2014-04-04 13:09:42 +03:00
Marko Viitanen b09854d964 Implemented RDO function to calculate bits used for coefficient coding 2014-04-04 13:09:42 +03:00
Ari Koivula 61256fc31a Enable -Wall by default. 2014-04-04 13:02:08 +03:00
Ari Koivula 69ac9176a5 Disable warnings for extras/getopt.
- This isn't our code so we don't care about these warnings.
2014-04-04 13:02:08 +03:00
Ari Koivula 7239b59e94 Resolve constant conditional expression warning.
- Working towards issue #11.

- I felt that the macro was a little bit too clever in hiding the if-else
  statements so I removed that aspect, which also has the minor benefit of not
  requiring the starting if (0) statement.
2014-04-04 13:02:07 +03:00
Ari Koivula b19e4f3f2d Resolve possible uninitialized variable warnings.
- Working towards issue #11.

- Neither variable was actually used as uninitialized.
2014-04-04 13:02:06 +03:00
Ari Koivula 61ae195af7 Resolve warnings about assignments within conditions.
- Working towards issue #11.
2014-04-04 13:02:06 +03:00
Ari Koivula d44d1837bb Remove unreferenced parameters.
- Working towards issue #11.
2014-04-04 12:56:24 +03:00
Ari Koivula 46d33d3945 Resolve unsigned/signed mismatch warnings.
- Working towards issue #11.
2014-04-04 12:56:23 +03:00
Ari Koivula c142cbba21 Fix typo.
- Obvious typo. This g_bitdepth - 8 used to be g_bitincrement. Doesn't affect
  anything yet as we don't actually support bitdepth > 8 yet.
2014-04-04 12:56:22 +03:00
Laurent Fasnacht b371a8bb59 Use realloc correctly
Quote from MALLOC(3) manpage:

The realloc() function returns a pointer to the newly allocated memory, which is suitably aligned for  any  kind  of
variable and may be different from ptr, or NULL if the request fails.
2014-04-04 06:37:35 +02:00
Ari Koivula 0074cd1a98 Add extra parenthesis to suppress compiler warnings. 2014-04-03 15:38:18 +03:00
Ari Koivula 27a3329dfb Remove unreferenced_parameter macro.
- It was a silly hack to selectively silence compiler warnings from VS, but
  there is no point as it causes compiler warnings in GCC.
2014-04-03 15:38:17 +03:00
Ari Koivula f380e7d4b0 Check for malloc failure. 2014-04-03 15:38:17 +03:00
Ari Koivula 313466fdff Remove unused variables.
- Working towards issue #11.

- Either removed or redefined variables to not cause a warning.
2014-04-03 15:37:59 +03:00
Marko Viitanen 0da8071300 Changed final cost (and transform skip) error function from SAD to SSD 2014-04-02 14:51:39 +03:00
Marko Viitanen a14fb14e33 Added new commandline parameter --no-transform-skip 2014-04-02 14:49:48 +03:00
Marko Viitanen 21e02e2d7d Added 4x4 SATD (Hadamard)
Taken from HM 13.0
2014-04-02 11:12:42 +03:00
Marko Viitanen cfb21c0e4c Implemented transform skipping (for 4x4 blocks)
transform skip vs. normal transform selection criteria might need more work, currently both are calculated for each 4x4 block and SAD+coeff_SSE is compared.
2014-04-02 10:54:03 +03:00
Laurent Fasnacht ae5c573843 Global defines are now documented with references the specification when possible. Removes some redundancy. 2014-04-01 13:48:17 +02:00
Panu Sjövall c8f629495d Remove unnecessary buffer from bitstream.
- Writing encoded data to file is done in bitstream_put one byte at a time and nal_write only writes the packet headers
2014-03-25 11:46:56 +02:00
Ari Koivula 953aef0379 Move rest of LCU encoding inside the LCU loop.
- Move SAO search inside the LCU loop.

- Move CU coding inside the LCU loop.

- Move SAO frame reconstruction loop to sao module.
2014-03-21 12:41:44 +02:00
Ari Koivula 746eaa3671 Move deblocking code to filter module. 2014-03-21 11:57:12 +02:00
Ari Koivula 4d34377c42 Clean up deblocking code a bit.
- Change guards to use the same method of checking for coordinate alignment.

- Move variables to reduce their scope.
2014-03-21 10:50:47 +02:00
Ari Koivula 0f492c7680 Fix deblocking of transform boundaries.
This fixes issues with inter. Deblocking works now.
2014-03-21 10:42:41 +02:00
Ari Koivula c42b25054a Modify deblocking to be done per-LCU in the encoding loop.
- Intra works. There is still something wrong in inter.

- Avoid horizontal deblocking of the rightmost 4 pixels in the LCU.
  This is because vertical deblocking must be done for all pixels
  before horizontal, but vertical deblocking can't be done for those
  pixels before the next LCU is finished.

- Add separate deblocking of the rightmost pixels of the last LCU
  after the LCU edge has been deblocked.

- This is a pretty ugly hack but will have to do for now.
2014-03-20 18:14:43 +02:00
Ari Koivula bbd1202f90 Replace old LCU reference pixels initialization with new ones.
In the future we might even have just a const pointer to reference pixels.
2014-03-19 16:01:31 +02:00
Ari Koivula 7328fc2897 Add special handling for bottom right LCU pixel.
I didn't take into account that the reference pixel on the top-left of the
LCU gets over written if we just replace the top reference pixels for
current LCU with the bottom reference pixels after doing the search.
To handle this I copy the pixel that gets overwritten to the vertical
reference pixels.
2014-03-19 16:01:31 +02:00
Ari Koivula 57ce7e990b Add new reference pixel buffer management to encoding loop.
- This is necessary because after we add in-loop filters to be done per LCU,
  the reconstruction buffer will have the deblocked pixels. We only need the
  edge-pixels for intra prediction though so we just save those.

- Right now it only copies the pixels and passes them on to search, where
  the copied pixels are asserted to be the same ones we copy from
  reconstruction buffer.

- New yuv_t struct added for arrays of dynamic length. We might want to change
  other buffers to use it or something like it in the future.
2014-03-19 16:01:30 +02:00
Ari Koivula eacad83ff9 Fix encoder reconstruction output for non multiple of 8 sized input.
Output changed so that only pixels within the conformance window are output.
2014-03-19 13:24:01 +02:00
Ari Koivula 34e453c880 Clean up encode_one_frame.
There is a lot of duplicated code due to handling random access and trailing
pictures separately. I merged the code for these two branches so it would be
easier to modify.
2014-03-17 18:04:41 +02:00
Ari Koivula b1596eb76c Refactor coding of end_of_slice_segment_flag.
According to spec the end_of_slice_segment_flag is always coded, but in the
code it looked like it was not coded for the last LCU in picture. This was
due to the end_of_slice_segment_flag being coded inside cabac_flush, like it
is in HM. This is a bit silly so I moved it out of cabac_flush.
2014-03-17 18:04:41 +02:00
Ari Koivula 6a384112cc Remove old unnecessary functions from search module.
- As we move to per-LCU encoding only search_lcu will be necessary.

- Function search_best_mode is no longer used.
2014-03-17 18:04:41 +02:00
Marko Viitanen c7ee176480 Removed unused function search_best_mode() 2014-03-17 12:56:04 +02:00
Ari Koivula 9563b50a34 Refactor coefficient group scan mapping lists.
The relation between coefficients positions and coefficient group positions
was a big confusing due to the use of 16x16 diagonal coefficient mappings
also as coefficient group mappings.

- Moved all coefficient group mappings to their own const arrays and added
  a new array the select the correct coefficient group mapping. This removes
  special cases for 8x8 and 32x32 transform sizes.

- Removed all coefficient group mapping initialization from init_sig_last_scan.

- Removed 128x128 and 64x64 from regular coefficient group array as those
  transform sizes don't exist anymore in HEVC.
2014-03-14 16:56:49 +02:00
Ari Koivula 319174258b Increment version number and update usage information. 2014-03-12 18:06:41 +02:00
Ari Koivula 34d4e74cd6 Fix selection of bitcost for NxN mode intra CUs. 2014-03-12 18:05:42 +02:00
Marko Viitanen 17b9c9d0b7 Unified all uses of --input-res to use 'x' as delimiter
Addresses issue #20
2014-03-12 15:20:57 +02:00
Ari Koivula 462b75f0f3 Merge branch 'intra-NxN'
Conflicts:
	src/search.c
2014-03-12 15:08:39 +02:00
Ari Koivula e93ae54e70 Fix bug with selecting wrong coeff scan mode for 4x4 blocks. 2014-03-12 14:56:05 +02:00
Marko Viitanen e6985eeb08 Terminate search when any block is found with no coefficients to code 2014-03-12 14:14:42 +02:00
Marko Viitanen 362fc6c5a5 Reduced bit cost when skip mode is selected 2014-03-12 14:13:38 +02:00
Ari Koivula aa59605392 Set correct max depth for search work-tree copying.
The copy up and down functions had wrong max depth so they didn't work with
4x4 blocks.
2014-03-12 14:02:13 +02:00
Marko Viitanen b5756821dd Tuned cost calculations for "final cost"
By adding chroma cost and using 1.5x coeff cost instead of 0.5x, additional 3% (LP) and 1.8% (AI) drop in BD-rate noticed.
2014-03-12 10:35:56 +02:00
Ari Koivula 409b094acf Try and get NxN to work again.
- Moved NxN search to be done on the same level as other searches, as it's
  really not any different from 2Nx2N.
- Produces working bitstream but reconstruction is different.
2014-03-11 19:19:20 +02:00
Marko Viitanen 75dd1f48ef Bugfix: calculate "final cost" only when block is inter or intra 2014-03-11 17:09:08 +02:00
Marko Viitanen 3b59d7c3a3 Implemented "final cost" calculation for best CU on each depth in search
Take SAD between reconstruction and original and add cost from coding and cost for coding coefficients.
2014-03-11 15:01:50 +02:00
Marko Viitanen aa0fb6ccad Store intra coding bit costs to CU structure 2014-03-11 12:15:50 +02:00
Marko Viitanen bdf8166e5c Store inter coding bit costs to CU structure
To be used for calculating better coding cost later
2014-03-11 11:40:39 +02:00
Marko Viitanen d2d877933a bugfix: only fclose recout if it was opened 2014-03-11 09:09:43 +02:00
Marko Viitanen eaf4434ae9 Removed unused parameter cur_cu from inter_get_merge_cand() 2014-03-11 09:04:17 +02:00
Marko Viitanen f2e722fed8 Implemented early search termination when skip mode is used 2014-03-11 08:55:38 +02:00
Ari Koivula 1b2705a042 Add video dimensions to the filename of encoder reconstruction. 2014-03-10 18:10:50 +02:00
Ari Koivula 965d8c377a Make encoder reconstruction obey --debug. 2014-03-10 18:10:49 +02:00
Ari Koivula 7e507fd615 Add --input-res CLI parameter.
- Also set default width and height to 0 because it makes no sense to assume
  dimensions. It's kind of like defaulting to the most common altitude when
  the altimeter is broken.
- Add config_validate to have a place for checks on overall cfg state.
2014-03-10 16:09:33 +02:00
Ari Koivula a644848b36 Add --seek CLI parameter.
Related to issue #12.

Motivation for adding this is that the syntax for frame accurate seeking in
ffmpeg is a little cumbersome. Also it's kind of a standard feature I guess.
2014-03-10 15:14:56 +02:00
Marko Viitanen a935aa5d96 Untabified encmain.c and nal.c 2014-03-10 12:10:40 +02:00
Marko Viitanen a7dade5069 Tuned inter MV coding costs to achieve BD-rate reduction
Compared to version with no inter costs, around -2% BD-rate in LP configuration
2014-03-10 12:08:09 +02:00
Marko Viitanen 1bd79c719e Fixed MV candidate derivation in search 2014-03-10 10:16:30 +02:00
Marko Viitanen 9a4b0d2cc7 Added newline after printing of real video frame size 2014-03-10 10:16:30 +02:00
Marko Viitanen c7e4861dbf Added coding cost calculations to MV search 2014-03-10 10:16:30 +02:00
Ari Koivula 9dde96f25e Refactor search_cu_intra.
- Formatted.
- Renamed and consolidated variables.
- Removed unused x and y pos from intra_prediction function.
2014-03-07 16:25:25 +02:00
Ari Koivula 470f36ce34 Remove left-over commented out code. 2014-03-07 12:44:45 +02:00
Ari Koivula 5d9aa3409b Merge branch 'new-search-wip'
Conflicts:
	src/encoder.c
	src/intra.c
	src/intra.h
	src/search.c
2014-03-06 19:00:53 +02:00
Ari Koivula 47af5207c5 Remove dead code and fix white space. 2014-03-06 18:35:17 +02:00
Marko Viitanen 877e156cb8 Fixed the case where transform split is used (always on depth 0)
After this fix, inter coding should be working.
2014-03-06 14:52:58 +02:00
Marko Viitanen c9d35aeacf Removed unused block data setting functions from picture.c/.h 2014-03-05 17:22:36 +02:00
Marko Viitanen c3e47c6a8d Removed redundant coeff_y/u/v variables from CU 2014-03-05 17:18:03 +02:00
Marko Viitanen b00f4c8dbf Fixed transform offset value and set tr_depth to correct value when depth 0 2014-03-05 17:10:17 +02:00
Ari Koivula 1cf03cfb37 Add --no-rdoq parameter. 2014-03-05 17:02:21 +02:00
Ari Koivula ca51f660d5 Fix fluctuation of coefficients on identical frames when RDOQ is on.
Moves CABAC context initialization to take place before search. This fixes
an issue with RDOQ returning different coefficients for identical adjacent
frames.

- This actually probably worsens BD-rate a little for all frames except the
  first one because we were using last frames final CABAC context for every
  LCU and now we are using initialized CABAC contexts. The fix is to encode
  the LCU before we start compressing the next LCU so we can update CABAC
  contexts.
2014-03-05 17:02:13 +02:00
Ari Koivula 8f3d5045b0 Add --no-rdoq parameter. 2014-03-05 17:00:08 +02:00
Ari Koivula 139e00f064 Fix fluctuation of coefficients on identical frames when RDOQ is on.
Moves CABAC context initialization to take place before search. This fixes
an issue with RDOQ returning different coefficients for identical adjacent
frames.

- This actually probably worsens BD-rate a little for all frames except the
  first one because we were using last frames final CABAC context for every
  LCU and now we are using initialized CABAC contexts. The fix is to encode
  the LCU before we start compressing the next LCU so we can update CABAC
  contexts.
2014-03-05 17:00:08 +02:00
Marko Viitanen c5842e1769 More fixes to B0 mv candidate selection
After this fix, inter coding works in depth != 0
2014-03-05 12:53:35 +02:00
Marko Viitanen 278042aaac Fixed top-right CU copy to lcu structure 2014-03-04 16:32:31 +02:00
Marko Viitanen 91e83db3c6 Bugfix for inter_get_spatial_merge_candidates() b2 block checking
Wrong variable was used to check for x-border
2014-03-04 15:34:32 +02:00
Marko Viitanen df669ca7df Added skip mode checking to the new lcu search 2014-03-04 12:48:19 +02:00
Marko Viitanen bddadbb4ed Inter coding fixed and added call to encode_transform_tree() 2014-03-03 17:42:44 +02:00
Marko Viitanen 09d4b47395 Fixed CU array calculations in inter_get_spatial_merge_candidates() 2014-03-03 16:25:33 +02:00
Marko Viitanen 17b256b5e3 Converted inter mv candidate functions to use lcu structure
Implemented merge and mvd candidate search
Added initialization of the whole work_tree
2014-03-03 16:08:35 +02:00
Marko Viitanen 1f82239367 Implemented inter search and reconstruction with lcu structure 2014-03-03 14:51:36 +02:00
Marko Viitanen b5fca8b206 Added missing chroma ref pixel init and fixed pic width/height in intra ref border
intra_build_reference_border() was given wrong picture width and height on chroma.
Chroma top-left reference pixels were not copied on init_lcu_t()
2014-03-03 12:21:55 +02:00
Ari Koivula 448285a56a Fix bug in intra mode coding. 2014-02-28 17:36:04 +02:00
Marko Viitanen f1882a0d82 Fixed CU type initialization and PU index calculations 2014-02-28 15:56:27 +02:00
Ari Koivula c05e91472d Fix intra reference border construction on LCU boundary. 2014-02-28 15:43:59 +02:00
Marko Viitanen 83e2079587 Fixed chroma stride in intra_build_reference_border() 2014-02-28 15:24:47 +02:00
Ari Koivula 19f67d4466 Fix LCU reference pixel indexing in reference border construction. 2014-02-28 14:22:13 +02:00
Ari Koivula 768d54ff4c Fix wrong array offset in intra search. 2014-02-28 14:22:13 +02:00
Marko Viitanen 0a6d9bda41 Fixed stride values in transform_chroma() 2014-02-27 17:47:00 +02:00
Marko Viitanen 4027de6e1f Fixed reconstruct_chroma() stride values 2014-02-27 16:48:51 +02:00
Ari Koivula 6e11eda133 Fix coeff flag initialization.
They should be initialized, even if none exist.
2014-02-27 16:43:20 +02:00
Marko Viitanen 9968fd46b0 Fixed chroma array index calculations in transform_tree() and intra_recon_lcu() 2014-02-27 16:42:32 +02:00
Ari Koivula 71d9ab7e26 Fix copying-up of coefficients during search. 2014-02-27 15:58:47 +02:00
Ari Koivula 526fdfc078 Fix erroneous indexing of pixel arrays. 2014-02-27 15:51:21 +02:00
Ari Koivula 5f75753f85 Set coeff flags correctly.
The coeff flags are no longer propagated upwards because encode_transform_tree
is being called from depth > 0. The fix is to initialize the whole coeff flag
array when the coeff flag is set.
2014-02-27 15:45:07 +02:00
Ari Koivula eda5ade06d Add missing offsets for lcu_t.cu pointers.
Also changes alternate ways of doing the offset to use LCU_CU_OFFSET macro.
2014-02-27 14:22:01 +02:00
Ari Koivula a8237bcb1e Remove duplicated defines. 2014-02-27 14:03:33 +02:00
Marko Viitanen b58c5b872a Fixed cu coordinate derivation in lcu_set_intra_mode() 2014-02-27 13:53:26 +02:00
Ari Koivula f6c97712b2 Add lcu_set_intra_mode. 2014-02-27 13:02:24 +02:00
Ari Koivula faea7caaf4 Remove unnecessary copying of reconstructed pixels from init_lcu_t.
The reconstructed pixels don't exist yet.
2014-02-27 11:58:32 +02:00
Ari Koivula 869ca5aa58 Add copying of LCU coefficients to search. 2014-02-27 11:56:16 +02:00
Marko Viitanen 117f74b481 Fixed allocated size for coefficient arrays 2014-02-27 11:05:21 +02:00
Marko Viitanen 7a1bf6b17d Intra fix: encode_transform_tree() call was missing and depth was not set 2014-02-27 10:53:01 +02:00
Marko Viitanen 8ae453551d Fixed cu type definition and reconstruction function calling
reconstruction could have been called when no search was done
2014-02-26 17:50:09 +02:00
Ari Koivula 879c355d9d Add work_tree_copy_down. 2014-02-26 17:31:26 +02:00
Marko Viitanen f788661a54 Fixed coeff flag derivation from NxN blocks 2014-02-26 16:54:49 +02:00
Ari Koivula 9faecd375a Add work_tree_copy_up. 2014-02-26 16:08:43 +02:00
Ari Koivula 1450d0edf8 Add lcu_t copying to main CU array. 2014-02-26 16:08:43 +02:00
Ari Koivula e651078e78 Fix compilation for rebase.
Conflicts:
	src/search.c
2014-02-26 16:08:15 +02:00
Marko Viitanen b4181dd398 Fixed problems with the new structure and commented out old search 2014-02-26 14:57:57 +02:00
Marko Viitanen bf21e4d019 Modified encode_transform_tree() to use new structure 2014-02-26 14:28:02 +02:00
Marko Viitanen 43abe296d0 Fixed intra headers and implemented intra search in the new structure 2014-02-26 12:45:43 +02:00
Marko Viitanen 40138f082e Modified intra_get_dir_luma_predictor() to use the new structure
Also fixed intra_pred_ratecost() parameters and usage of intra_build_reference_border()
2014-02-26 12:38:30 +02:00
Marko Viitanen 1197e24b3f Modified intra_prediction() to use new structure and renamed intra_merge_cost() 2014-02-26 12:34:22 +02:00
Marko Viitanen 68b4e9e3db Modified intra_build_reference_border() to work on the new structure 2014-02-26 12:30:12 +02:00
Marko Viitanen d0a9c5e83b Implemented intra_recon_lcu() to reconstruct intra in the new structure 2014-02-26 12:28:24 +02:00
Marko Viitanen fb9e3ad1d2 Implemented proper intra mode cost calculation
This does not currently affect the search primary search defining the used block sizes, only the refining second intra search. Gain 1.9% BD-rate on All Intra 600f of BQMall QP 22,27,32,37.
2014-02-26 12:26:54 +02:00
Ari Koivula b067b2f802 Add lcu_t initialization. 2014-02-26 10:58:20 +02:00
Ari Koivula 7e520a85c4 Add skeleton/plan for LCU based search.
The plan is to replace the dumb search we are doing now with proper sequential
search that is encapsulated inside data structure that holds all temporary
search data for the LCU.
2014-02-25 13:06:22 +02:00
Marko Viitanen d2b8f50351 Merge branch 'master' of https://github.com/lu-zero/kvazaar 2014-02-25 10:53:51 +02:00
Marko Viitanen 565be069b9 Implemented proper intra mode cost calculation
This does not currently affect the search primary search defining the used block sizes, only the refining second intra search. Gain 1.9% BD-rate on All Intra 600f of BQMall QP 22,27,32,37.
2014-02-24 15:28:37 +02:00
Luca Barbato a6dfe79d16 encoder: Export g_convert_to_bit correctly
It is a global table initialized in encoder.c and used all over the
codebase.
2014-02-22 18:02:09 +01:00
Ari Koivula db4402e8d6 Fix for SAO band offset merge cost calculation.
Gives a tiny improvement to both bit rate and psnr.
2014-02-22 16:08:39 +02:00
Marko Viitanen 34f558ddd7 Fixed SAO cost checking, disabling SAO when RD-cost is 0
Decreases overall BD-rate a bit more, this fix prevents coding zero offsets to the bitstream
2014-02-21 17:43:15 +02:00
Ari Koivula 73f5c3b80e Fix compiler warnings for VS2010 /W4 in config.c and encmain.c.
- Working towards issue #11.
- Widened datatypes for cfg struct members that take values from atoi to full
  ints so that bounds checking can be done after parsing without overflow.
2014-02-21 17:28:11 +02:00
Ari Koivula db3b96b90b Fix compiler warnings for VS2010 /W4 in bitstream.c and cabac.c.
- Working towards issue #11.
2014-02-21 17:28:11 +02:00
Marko Viitanen 8768f2bb22 Revert "build: Add more cflags to the Makefile"
This reverts commit 4c6e7e086a.
2014-02-21 17:18:23 +02:00
Luca Barbato d07e12dbf0 sao: Add correct header
abs is part of stdlib.h
2014-02-21 15:07:56 +01:00
Luca Barbato 47677af690 Drop remaining unused variables 2014-02-21 15:07:16 +01:00
Luca Barbato 77da143089 picture: Comment out unused-for-now functions 2014-02-21 15:07:15 +01:00
Luca Barbato 0e67f6ffa5 intra: Do not use ambiguous - position
Clang warns about it.
2014-02-21 15:07:15 +01:00
Luca Barbato 6fec5ff25e rdo: Drop now unused variables 2014-02-21 15:07:15 +01:00
Luca Barbato 5e585cc2bd transform: Drop now-unused variables 2014-02-21 15:07:15 +01:00
Luca Barbato 0cafa8105f search: Conditionally compile conditionally used functions 2014-02-21 15:07:15 +01:00
Luca Barbato 3441ff831e Drop clang-compatible flag 2014-02-21 15:07:15 +01:00
Luca Barbato 35ff5113a6 transform: Staticize 2014-02-21 15:07:15 +01:00
Luca Barbato d6095ff283 transform: Fix function prototypes 2014-02-21 15:07:15 +01:00
Luca Barbato e03049782c search: Staticize functions 2014-02-21 15:07:15 +01:00
Luca Barbato ba494e19c5 sao: Constantize *_list 2014-02-21 15:07:15 +01:00
Luca Barbato 8fbb26975e sao: Drop unused variable 2014-02-21 15:07:15 +01:00
Luca Barbato 4796675731 rdo: Staticize 2014-02-21 15:07:15 +01:00
Luca Barbato f314c9b8c0 sao: Staticize 2014-02-21 15:07:11 +01:00
Luca Barbato 974a409387 picture: Staticize 2014-02-21 15:03:35 +01:00
Luca Barbato 350826bc00 encoder: Staticize functions 2014-02-21 15:03:35 +01:00
Luca Barbato 934a4e3b88 whitespace: Drop trailing spaces 2014-02-21 15:03:35 +01:00
Luca Barbato b99a25ca89 global: Use defined() in macro checks 2014-02-21 14:59:50 +01:00
Luca Barbato 4c6e7e086a build: Add more cflags to the Makefile 2014-02-21 14:59:50 +01:00
Luca Barbato 0cdaf6bf2a config: Set static copy_string
It is used only within the file.
2014-02-21 14:59:50 +01:00
Luca Barbato f43240794f config: Fix config_alloc prototype 2014-02-21 14:59:50 +01:00
Luca Barbato ae59116945 bitstream: Add correct header for htonl 2014-02-21 14:59:50 +01:00
Luca Barbato 20063f418d lib: Add a public version include 2014-02-21 14:59:50 +01:00
Marko Viitanen e3a528df2e Added rate cost to SAO mode selection calculations
Decreased BD-rate 1% on LP configuration with 600 frames of BQMall, QP 22,27,32,37
Merge check is now performed in a function to ease the checking
2014-02-21 15:54:56 +02:00
Marko Viitanen 11bf11f33a Changed duplicate scaled QP calculations to use a function 2014-02-21 15:41:55 +02:00
Marko Viitanen f1f293ae0c Implemented SAO merging 2014-02-21 13:20:54 +02:00
Ari Koivula 5760c79272 Fix crash with dimensions that are not multiples of 8.
The clean up of input parsing and encoder initialization code had caused the
real source input dimensions to be used for array initialization, instead of
the dimensions modified to be multiples of the smallest coding unit.
2014-02-21 12:48:33 +02:00
Marko Viitanen 13dc95a164 Implemented band SAO reconstruction 2014-02-21 11:52:41 +02:00
Marko Viitanen e4880aa4b7 Fixed SAO bitstream generation and band offset a bit 2014-02-20 17:22:33 +02:00
Marko Viitanen 5d946c774a Implemented draft SAO band offset functions 2014-02-20 16:08:09 +02:00
Marko Viitanen bb1ae0da62 Limited maximum number of reference frames to 15
This now complies with the specification (when using only L0 reference list)
2014-02-20 11:09:09 +02:00
Ari Koivula 18c3d9c72d Add scons build script.
We will also maintain the Makefile for basic building. This is for more
complicated stuff, like building the project on command line with
Visual Studio.
2014-02-19 16:58:52 +02:00
Marko Viitanen db689227f4 Increased maximum ref frame count to 16 and set default to 3 2014-02-19 15:09:17 +02:00
Marko Viitanen c230a73155 Added number of reference frames to prefix SEI user data 2014-02-19 14:45:18 +02:00
Marko Viitanen 8490ff1a9d Disabled NxN mode
Something must be done to enable better selection of NxN blocks in order to gain BD-rate with this mode.
2014-02-19 14:36:17 +02:00
Marko Viitanen 3618eab72a Added lambda cost when using reference frames with refIdx > 0
Because selecting references "far away" costs bits, this should help with the issue that multiple reference frames actually increases coded bits with no quality gain.
2014-02-19 14:34:36 +02:00
Marko Viitanen 478552ea00 Added commandline parameter for reference frame number
Also updated README and usage with the new parameter
2014-02-18 17:45:54 +02:00
Marko Viitanen 7fb03049b8 Fixed mvd candidate selection 2014-02-18 17:27:45 +02:00
Marko Viitanen 54e68378dc Fixed merge candidate selection on multiref 2014-02-18 16:59:45 +02:00
Marko Viitanen a2424d9476 Fixed deblocking filter when using multiple reference frames 2014-02-18 15:22:20 +02:00
Marko Viitanen f85e0e4ad6 Fix for MV candidate derivation 2014-02-17 17:39:40 +02:00
Marko Viitanen cda60897e1 Fixed inter mv_ref propagation and merge candidate mv_ref matching 2014-02-17 11:13:12 +02:00
Marko Viitanen e6212110a1 Simplified MV scaling calculations 2014-02-17 09:58:10 +02:00
Marko Viitanen 7dee412cb0 Fixed some of the motion vector scaling problems
motion vector candidates are not yet scaled or selected correctly
2014-02-17 09:58:10 +02:00
Marko Viitanen 28aa20df12 Basic search for multiple reference frames 2014-02-17 09:58:10 +02:00
Ari Koivula 8e63dd29bb Fix compiler warnings for VS2010 /W4 in intra.c.
- Working towards issue #11.
- Removed intra_get_block_mode as unused.
- Removed unused parameters from functions. Many of them were remnants from
  earlier data structures and earlier features of HEVC that have been removed.
- Lots of implicit conversions from larger types to smaller ones. I tried to
  avoid turning all of them to explicit ones this time and opted for changing
  the original data type instead. Had to do it in few cases though to stop the
  changes from propagating too widely.
2014-02-14 17:15:54 +02:00
Marko Viitanen a6e8373349 Fixed crash issue on windows when cqmfile was not specified
fclose(cqmfile) crashed on windows when cqmfile was NULL
2014-02-14 14:38:53 +02:00
Yusuke Nakamura a860bbc7f9 config: Add --cqmfile to use custom quantization matrices from a file.
The coefficients in a matrix are stored in up-right diagonal order.

The following indicates the default matrices specified in the spec.

INTRA4X4_LUMA
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16

INTRA4X4_CHROMAU
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16

INTRA4X4_CHROMAV
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16

INTER4X4_LUMA
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16

INTER4X4_CHROMAU
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16

INTER4X4_CHROMAV
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16

INTRA8X8_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115

INTRA8X8_CHROMAU
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115

INTRA8X8_CHROMAV
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115

INTER8X8_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91

INTER8X8_CHROMAU
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91

INTER8X8_CHROMAV
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91

INTRA16X16_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115

INTRA16X16_CHROMAU
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115

INTRA16X16_CHROMAV
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115

INTER16X16_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91

INTER16X16_CHROMAU
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91

INTER16X16_CHROMAV
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91

INTRA32X32_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115

INTER32X32_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91

INTRA16X16_LUMA_DC
16

INTRA16X16_CHROMAU_DC
16

INTRA16X16_CHROMAV_DC
16

INTER16X16_LUMA_DC
16

INTER16X16_CHROMAU_DC
16

INTER16X16_CHROMAV_DC
16

INTRA32X32_LUMA_DC
16

INTER32X32_LUMA_DC
16
2014-02-13 17:47:21 +09:00
Marko Viitanen 96d62e1bec Fixed general_profile_compatibility_flag value
Might help with issue #5
2014-02-12 16:01:02 +02:00
Marko Viitanen 5c4c47b07a Fixed and enabled Intra NxN
NxN block needs reference border from previous NxN blocks and to do this, the structure was changed a bit.
2014-02-11 18:31:41 +02:00
Ari Koivula 9b993de79b Increase version number.
- Also removes VERSION macro that wasn't used for anything.
2014-02-11 17:01:18 +02:00
Ari Koivula c7d236c8ed Update usage information.
- Removed tabs from the README.
2014-02-11 16:33:50 +02:00
Yusuke Nakamura af25c36ac4 config: Fix fullrange option parsing and so that it matches what x264 CLI does. 2014-02-11 19:12:04 +09:00
Ari Koivula c18b6f53e1 Fix regression that disabled intra prediction in inter frames.
The intent was to remove the flag that enabled intra in inter frames, as that
is not really that usefull anymore, but it ended up disabling intra instead.
2014-02-11 11:57:54 +02:00
Marko Viitanen c202c8caac Fixed motion vector cost calculation a bit
Cost was calculated a bit wrong causing non-zero motion vectors on totally black video.
2014-02-10 20:30:55 +02:00
Marko Viitanen 0ac12e72f6 Added init value for encoder->ref_list to fix valgrind warnings
This might help with issue #16
Thanks again to ps-auxw for pointing this out ;)
2014-02-10 20:06:54 +02:00
Marko Viitanen 4bd6131499 Fixed array overflow causing segfault, fixes #17
Should also solve issue #16
Thanks to ps-auxw @ IRC for finding this stupid bug!
2014-02-10 19:40:43 +02:00
Ari Koivula 75f3ba5b2f Fix compiler warnings for VS2010 /W4 in nal.c.
- Working towards issue #11.
- Leaving this as a separate commit in case there is a regression.
2014-02-10 17:46:38 +02:00
Ari Koivula ea600ec980 Fix some compiler warnings for VS2010 /W4 in encoder.c.
- Working towards issue #11.
- There is a lot in this module so I'm fixing only ~half in this commit.
2014-02-10 17:31:52 +02:00
Ari Koivula e0cf09bc6b Fix compiler warnings for VS2010 /W4 in nal.c.
- Working towards issue #11.
- Removed todo about luma margin. The code should work even with margin.
2014-02-10 17:07:22 +02:00
Ari Koivula e66fe65f8b Fix compiler warnings for VS2010 /W4 in picture.c.
- Working towards issue #11.
2014-02-10 16:50:53 +02:00
Ari Koivula 6dbae48268 Remove debug module.
- It hasn't been very useful lately and I don't want to maintain it.
2014-02-10 16:50:53 +02:00
Ari Koivula bc3b80b9e4 Fix compiler warnings for VS2010 /W4 in intra.c.
- Working towards issue #11.
2014-02-10 16:50:10 +02:00
Ari Koivula 09b742796f Simplify intra reference border construction.
Doesn't change anything but makes the control flow more clear.
2014-02-10 16:19:17 +02:00
Ari Koivula b440c48d07 Fix intra reconstruction on the bottom of the frame.
When the CU was both at the bottom of frame and at the bottom of LCU,
uninitialized pixels were being used as reference.
2014-02-10 14:31:47 +02:00
Marko Viitanen 5f79f30b8c Added preliminary support for multiple reference frames
L0 reference list is being updated and sent to bitstream but actual usage of other than default reference might break something.
2014-02-10 11:32:48 +02:00
Marko Viitanen 241aa9155c Fixed crash-bug when using NxN Intra mode (array index overflow)
In NxN mode, chroma predictions were pushed to buffer when chroma should not have been used at all. (Because it is processed only on first of the four NxN luma blocks)
2014-02-07 17:24:58 +02:00
Marko Viitanen d106b21954 Removed redundant function call from encode_block_residual()
intra_set_block_mode() was called twice with the same parameters.
2014-02-07 15:33:58 +02:00
Marko Viitanen 27ffb98d08 Fixed an issue with NxN using uninitialized y_recdata
NxN is still disabled by default as it's being fixed.
2014-02-07 15:33:58 +02:00
Ari Koivula 526e3f9790 Fix interpolated_sad not working with vectors pointing far outside the frame. 2014-02-07 14:24:18 +02:00
Ari Koivula b48d1c9ca2 Fixes to version sei message.
- Fixed the last 16 characters of the url string being cut of.
- Added some guards against the message overwriting the stack.
2014-02-07 11:43:38 +02:00
Yusuke Nakamura 3e96df2a81 Write Kvazaar's version and encoding options in an user data unregistered SEI. 2014-02-07 10:53:18 +09:00
Yusuke Nakamura 430e475954 config: Add --aud to use access unit delimiters. 2014-02-07 07:35:15 +09:00
Yusuke Nakamura a29b6f7c92 Add some options to specify VUI parameters. 2014-02-07 06:50:43 +09:00
Ari Koivula f4d5370e8b Fix compiler warnings for VS2010 /W4 in context.c and rdo.c.
- Working towards issue #11.
- Moved all const arrays from .h to the .c. These are not used anywhere else.
- Moved entropy_bits array and its helper macro to rdo.c. They are not used
  anywhere else.
- Implicit conversions to explicit ones.
2014-02-06 17:57:41 +02:00
Ari Koivula 40ed25de7e Fix compiler warnings for VS2010 /W4 in sao.c.
- Working towards issue #11.
2014-02-06 16:06:24 +02:00
Ari Koivula 0188aa8631 Fix compiler warnings for VS2010 /W4 in search.c.
- Working towards issue #11.
- Implicit conversions to explicit ones.
2014-02-06 14:40:18 +02:00
Marko Viitanen 4704a6adf4 Added deblock beta/tc checking and allowed range to usage, closes issue #13 2014-02-06 14:33:13 +02:00
Ari Koivula 4184818322 Fix compiler warnings for VS2010 /W4 in tranform.c.
- Working towards issue #11.
- Lots of implicit conversions to explicit ones.
2014-02-06 14:02:56 +02:00
Ari Koivula 2614aa0fe4 Fix compiler warnings for VS2010 /W3.
- Working towards issue #11.
- Change lambda cost multiplier for intra NxN to from 256 to 4.
- Add 0.5 to the lambda multipliers so it's rounded instead of truncated.
2014-02-06 11:04:23 +02:00
Ari Koivula 1d730bd248 Update usage information and version string.
- Change stderr back to text mode. Can't see what harm it should allow us to print
  correct newlines for different platforms.
- Remove copy-pasted function calls from usage printing.
2014-02-05 19:16:44 +02:00
Ari Koivula 355340067f Modify search_tree to take a pixel coordinate instead of CU coordinate.
I need at least 4x4 resolution for NxN. It's simpler to just use pixel
coordinates.
2014-02-05 18:43:34 +02:00
Ari Koivula ea312082a4 Simplify the prediction mode search recursion.
No need to be so clever for something this simple.

I moved the cost initialization outside the recursing function because it
relied on the clever recursion to work. It should eventually be moved to its
own function that also initializes all the other fields just to be safe. I
didn't do that yet because I want to do it per-LCU and these functions are
still working on per-frame basis.
2014-02-05 18:43:34 +02:00
Marko Viitanen 337a565232 Better lambda cost implementation (from HM12)
- Lambda array changed to double as in HM
 - Needs updating when GOP / B-pictures are used
2014-02-05 15:57:16 +02:00
Marko Viitanen 2438386f4b Merge pull request #10 from VFR-maniac/fix
Avoid reading one extra frame at the end of the input file.
2014-02-04 07:35:47 -08:00
Marko Viitanen a4cd709fc7 Fixed missing includes in MSVC caused by the deletion of stdint.h 2014-02-04 17:23:50 +02:00
Yusuke Nakamura 42908076c2 config: Add --no-sao to disable sample adaptive offset filter. 2014-02-04 23:19:17 +09:00
Yusuke Nakamura f40d9a3e2f config: Add --deblock to specify deblocking parameter offsets divided by
2.
2014-02-04 23:19:17 +09:00
Yusuke Nakamura 89800d3690 config: Add --no-deblock to disable deblocking filter. 2014-02-04 23:19:16 +09:00
Yusuke Nakamura 4286c0f988 Support long option names by getopt_long(). 2014-02-04 23:19:16 +09:00
Yusuke Nakamura de2c4ab78e Avoid reading one extra frame at the end of the input file. 2014-02-04 21:55:08 +09:00
Marko Viitanen 39a45936a6 Fixed crash bug on QP < 15 caused by division with zero lambda cost 2014-02-04 09:39:27 +02:00
Ari Koivula 7bb9c25447 Remove duplicate implementation of intra_build_reference_border.
The search_buildReferenceBorder was an ugly hack and a place for bugs to hide
that should never have existed. Now it doesn't.

The change reduces PSNR a little, but also reduces the bitrate, when the
expected result was to have no change in either. I'm guessing there was still
some bug in the search_buildReferenceBorder, but the bug could also be in
intra_build_reference_border. Will have to do more testing to be sure, but
having one place to look at will be better than having two.
2014-02-03 18:35:11 +02:00
Marko Viitanen d1b093c2ee Merge branch 'master' of https://github.com/ultravideo/kvazaar 2014-02-03 17:20:36 +02:00
Ari Koivula 91ff5ff086 Merge branch 'jeeb-cleanup'
Conflicts:
	src/encoder.c
	src/encoder.h
2014-02-03 17:13:13 +02:00
Yusuke Nakamura 4ffdb358ed nal: Add the writing of an additional zero_byte before the start code.
Enables the output of spec-compliant byte streams, as the specification
notes that an additional zero_byte has to be added under certain
circuimstances.
2014-02-03 17:00:55 +02:00
Ari Koivula 478740cf21 Add missing new lines to ends of files. 2014-02-03 16:54:03 +02:00
Jan Ekström ac8fbc0519 Move initialization away from main() 2014-02-03 16:53:51 +02:00
Marko Viitanen d69f97cb90 Fixed level and profile sent to bitstream, for issue #5 b 2014-02-03 16:08:25 +02:00
Marko Viitanen 57d5f2fb93 Changes in Makefile for better 32/64bit detection
- Addresses issue #6
- Added -m64/-m32 flags for linker to allow 32bit compiling on 64bit platform
2014-02-03 15:53:21 +02:00
Marko Viitanen 47d85f8cd5 Modified Makefile to allow building on windows and defaulting to elf-binary
- Addresses issues #3 and #6
- Included make clean option
2014-02-03 14:27:19 +02:00
Marko Viitanen ffd00695c7 Better cleanup of allocated memory at exit
Using valgrind all the leaks were tracked and fixed.
2014-02-03 11:52:43 +02:00
Jan Ekström 007986974a config: Make config_alloc() no longer crash if allocation fails 2014-01-31 17:30:27 +02:00
Jan Ekström 7db28fad84 encmain: Make the main function more resilient to allocation failures
Application will no longer crash if config or encoder_control
allocation fails.
2014-01-31 17:26:09 +02:00
Jan Ekström 271c08f963 config: Add a string copying helper function
Removes the need to add the same code into multiple places
2014-01-31 17:24:04 +02:00
Jan Ekström d8d44e5bcd encoder: Remove a non-UTF-8 symbol from the code
Silences a Visual Studio warning on systems where the symbol is not
in the local code page
2014-01-31 17:17:44 +02:00
Marko Viitanen ac8141b328 Fixed a bug in intra search and some memory leaks, changed version to 0.2.1
Intra search was using faulty border data and selected modes were a bit random. Around -0.5% (LP) and -2% (AI) change in BD-rate was seen in limited testing conditions.
2014-01-31 16:54:43 +02:00
Jan Ekström f1ff6a8274 encmain: Add rudimentary support for input via stdin 2014-01-31 14:32:41 +02:00
Marko Viitanen 80da15df4d Adjusted cost calculation of CU split
Quick testing shows BD-rate change of -14% (LP) and -4% (AI) with 600 frames of BQMall using QP 22,27,32,37.
2014-01-31 12:31:51 +02:00
Marko Viitanen 5d5fbb8704 Added commandline configuration of intra period (-p <intra_period>) 2014-01-31 10:23:56 +02:00
Marko Viitanen 76f24408b6 Included x264asm abstraction layer -library and fixed Makefile
Name mangling is causing problems on different platforms (issues #2 and #3) and some of it was solved modifying the Makefile. Separate 32bit and 64bit assembly functions were also causing problems and since we were going to move to x264asm abstraction layer anyway, we decided to do it now before spending time on the old implementation.
2014-01-30 17:59:50 +02:00
Ari Koivula b93629f26e Re-enable P frames.
It was inadvertently disabled due to an aborted merge.
2014-01-29 17:56:38 +02:00
Gareth Andrew Lloyd 3805483595 Linker's objects/libraries order changed
gcc linker needs to parse objects before linking the necessary libraries
2014-01-29 15:34:31 +00:00
Ari Koivula 5d12706510 Merge branch 'intra_NxN'
Conflicts:
	src/encoder.c

- Chroma RDOQ changes conflicted because I had moved the chroma
  quantization/dequantization to it's own function.
- Merged to master because I want my code to show up in github. =)
  All the old stuff still works, even though NxN doesn't work, so there
  is no reason not to merge anyway.
2014-01-29 17:04:41 +02:00
Ari Koivula e33655fde5 Remove debug stuff and disable intra NxN in preparation for a merge.
- Re-enable intra search based on reconstructed image.
  - This didn't have as much of an effect as I thought it would.
- Re-enable SAO and deblocking.
- Disable NxN searching. (4x4 luma coding is still broken)
2014-01-29 16:45:37 +02:00
Ari Koivula bf80007270 Try to fix 4x4 luma coding.
Still doesn't work. I have no idea what the problem is. Probably somehow related to the coefficient coding, since the bitstream seems to work, the prediction is correct and the error is not very severe.

- Change scan order selection to be more verbose and based on the correct mode for 4x4. Didn't affect the problem with 4x4 luma in any way although it should have.
- Re-enable residual coding as everything seems to work now besides 4x4 luma.
2014-01-29 15:09:41 +02:00
Ari Koivula de3c58862a Fix intra NxN chroma coefficients.
- The NxN coefficients were being saved to the bottom right PU offset instead of
  the parent CU offset.
- Re-enable coefficient coding for chroma NxN.
2014-01-29 14:22:31 +02:00
Ari Koivula f1b2e9f603 Fix buggy chroma when NxN is present.
- NxN intra prediction seems to work fully now.
- Coefficients still don't work for NxN.
2014-01-29 14:22:31 +02:00
Ari Koivula 9f855c16db Fix building of reference border in the bottom of the frame.
- Don't write to the top-left corner during construction of left border,
  because that is handled later that is handled later.
2014-01-29 14:22:31 +02:00
Ari Koivula ca454b67df Fix intra filtering for 4x4 luma blocks. 2014-01-29 14:22:31 +02:00
Ari Koivula acbe656c6d Fix intra prediction mode list generation. 2014-01-29 14:22:30 +02:00
Ari Koivula 81b51f17d8 Reimplement intra_build_reference_border to support NxN.
New implementation uses precalculated tables to look up number of reference
pixels available in coded CUs. Otherwise it works just like the previous
version.

- NxN mostly works. Prediction appears to be almost correct but there is a
  slight error in the exact values, probably related to filtering.
2014-01-29 14:22:30 +02:00
Ari Koivula 71a996f50f Work on reconstruction and searching.
- Set part-size for Inter.
- Change to Intra Only mode for testing.
- Many small changes here and there. Should have been separate commits probably, but too late.
- Disable SAO and deblocking to be able to see problems with reconstruction better.
2014-01-29 14:18:01 +02:00
Ari Koivula 5e2f22f447 Try to fix intra prediction mode coding for NxN.
- Adjust predictor list to take modes from PUs in addition to 2Nx2N CUs.
- Change intra_get_dir_luma_predictor to take PU index instead of CU index.
- Comment prediction encoding now that I've had to look it up.
2014-01-29 13:52:17 +02:00
Marko Viitanen 3a95d49484 Removed __cdecl from asm header files and corrected parameters printed by the program 2014-01-28 16:40:38 +02:00
Marko Viitanen 23427a72cf Merge branch 'rdoq' 2014-01-28 12:29:21 +02:00
Marko Viitanen 7a21b9b769 Changed lambda calculation to fix RDOQ issues, RDOQ is now in use by default. 2014-01-28 12:14:43 +02:00
Marko Viitanen 5e759b8e1d Fix for RDOQ, added missing cost function 2014-01-28 11:01:46 +02:00
Marko Viitanen 13927f777f Fix for Makefile to allow 32bit compiling of assembly test 2014-01-27 15:34:02 +02:00
Marko Viitanen cbd4d16f25 Added commandline configuration of QP 2014-01-27 15:02:07 +02:00
Marko Viitanen 0cdd9d032f Added GPLv2 headers to rdo.c/.h 2014-01-27 14:39:56 +02:00
Marko Viitanen 83a1e9a555 Added rdo to Makefile 2014-01-27 14:36:10 +02:00
Marko Viitanen 80b3b4a6e0 Added missing lambda parameter to some RDOQ costs and moved go_rice arrays from header file 2014-01-27 14:34:58 +02:00
Marko Viitanen 144d5293b1 Implemented RDOQ function get_rate_last() 2014-01-27 14:34:58 +02:00
Marko Viitanen f447b92755 Added error scaling list calculation from HM 12.0 2014-01-27 14:34:58 +02:00
Marko Viitanen 9f70bf74f0 Imported and converted RDOQ from HM 12.0, NOT WORKING YET 2014-01-27 14:34:58 +02:00
Marko Viitanen de6faf623d Imported entropy bits array from HM and added macro to access it 2014-01-27 14:34:57 +02:00
Marko Viitanen f5c2292e06 Added simple Makefile and header files needed to compile on linux 2014-01-27 14:34:09 +02:00
Ari Koivula 77339efa57 Add COPYING file and add boilerplate for copyright and GPLv2 to every file. 2014-01-24 12:48:48 +02:00
Ari Koivula c889e20e4c Fix debug to work for intra and show CU part_mode. 2014-01-15 18:15:42 +02:00
Ari Koivula 7a7110ff7a Move chroma transformation and reconstruction to it's own functions.
Just a simple copy and paste with minimal changes.
2014-01-15 16:55:05 +02:00
Ari Koivula 35ba873abc Move transform unit coding to its own function. 2014-01-14 18:47:02 +02:00
Ari Koivula a38a5fd647 Improve transform tree coding.
- Clean up code and comment.
- Change terminology to match H.265 specification where possible.
- Move transform splitting for depth==0 out of the coding part. It's not
  possible to do it here anyway because intra reconstruction is different
  if the transform is split.
- Add checking for transform hierarchy depth when coding split flag.
- Fixes bug with cu_data.tr_depth being set. The CU struct was being reused
  for inter coded CUs, which did not initialize the tr_depth.
2014-01-14 18:39:24 +02:00
Ari Koivula d5745aa31a Fix encode_transform_tree to handle 4x4 luma.
- Add room to cu_data.coeff_top_yuv arrays for the 4x4 PUs data. Will probably have to do the same to other coeff flags. The flags could also probably be combined as they are a bit redundant.
2014-01-13 18:37:47 +02:00
Ari Koivula 73fdc35c4f Try to implement 4x4 luma transform coding.
- Doesn't work yet so it's disabled.
- Change encode_transform_coeff to accept PU (Prediction Unit) coordinates
  instead of CU coordinates because CUs are 8x8.
2014-01-09 19:30:54 +02:00
Ari Koivula c3f4a628af Try to fix stuff related to NxN intra transform splitting. 2014-01-03 16:47:27 +02:00
Ari Koivula b897562ef8 Enable NxN. 2014-01-03 16:46:02 +02:00
Ari Koivula 00ece94613 Change the default encoder reconstruction file name.
YUV Toolkit parses the file name for frame size.
2014-01-03 13:03:46 +02:00
Ari Koivula 1b7e44c4d4 Add NxN to intra reconstruction. 2014-01-03 13:01:54 +02:00
Ari Koivula 4c84a35391 Add part size to intra_set_block_mode. 2014-01-03 13:01:13 +02:00
Ari Koivula d9cdab052b Add NxN mode selection to search_intra. 2014-01-03 10:21:59 +02:00
Ari Koivula 5083e6db10 Change cu_info.intra into an array to support NxN split. 2014-01-02 15:13:20 +02:00
Ari Koivula 80cd172f75 Clean up SAO encoding.
- Fixes a bug when pic->slice_sao_chroma == false.
2014-01-02 15:10:07 +02:00
Ari Koivula f1d8aae5b4 Clean up SAO encoding.
- Fixes a bug when pic->slice_sao_chroma == false.
2013-12-19 13:54:32 +02:00
Ari Koivula 8e2a7ef6ed Start implementing NxN prediction coding. 2013-12-18 14:55:05 +02:00
Ari Koivula 553bcdc324 Rewrite intra prediction mode coding to be simpler.
Should work exactly the same, but with the prediction mode selection done
separately from the binarization it's easier to see that the implementation
is correct.
2013-12-18 14:16:04 +02:00
Ari Koivula cf0d314d03 Clean up prediction mode coding.
This was done as preparation for adding NxN intra.

- Monochrome coding was removed as it's not part of the standard.
- No other functional changes.
2013-12-18 11:25:44 +02:00
Ari Koivula 8f610176d8 Add NxN part_mode coding. 2013-12-18 10:50:24 +02:00
Ari Koivula ee92fc341c Move intra and inter search into their own functions. 2013-12-17 11:32:28 +02:00
Ari Koivula 80064d3834 Streamline SAO to have less duplicated code. 2013-11-14 15:38:19 +02:00
Ari Koivula 21678930b1 Add an alternate way of accessing pixel buffers. 2013-11-14 15:38:10 +02:00