Commit graph

238 commits

Author SHA1 Message Date
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
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 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 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
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
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 f1f293ae0c Implemented SAO merging 2014-02-21 13:20:54 +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 c230a73155 Added number of reference frames to prefix SEI user data 2014-02-19 14:45:18 +02:00
Marko Viitanen 54e68378dc Fixed merge candidate selection on multiref 2014-02-18 16:59:45 +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 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
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
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
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
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
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
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
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
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 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 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 5d5fbb8704 Added commandline configuration of intra period (-p <intra_period>) 2014-01-31 10:23:56 +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
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 acbe656c6d Fix intra prediction mode list generation. 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