Commit graph

132 commits

Author SHA1 Message Date
Ari Koivula 1d5cfbdcc2 Remove unused variable. 2015-09-16 18:39:46 +03:00
Ari Koivula 513e80bcca Fix bug causing unnecessary copying of memory
This bug caused a single tiles worth of lcu_info_t structs to be copied
unnecessarily for every LCU in the frame. This obviously caused huge
memory bandwidth issues when coding large frames without tiles. The
effect was minimized somewhat with a large number of tiles, because
only the current tile was copied.

From context it is clear that this piece of code was supposed to copy
a single tile or frame, once the frame was done, but because it was
placed in a function which is called for every LCU, it copied the data
for the LCU, but also lots of extra stuff.

The fix is to copy only the current LCU instead of the whole tile.
2015-09-16 18:23:44 +03:00
Ari Koivula f1ac0e6bc2 Rename _DEBUG to KVZ_DEBUG 2015-09-15 13:04:03 +03:00
Ari Koivula ec2d8d6ad7 Rename _DEBUG_PERF macros to KVZ_PERF
And move them to threadqueue.h, where the things that use them are.
2015-09-15 13:03:32 +03:00
Marko Viitanen 3217e70f99 Revert "Revert "Fix keeping of reference frames over IDR boundary.""
This reverts commit 87936eb99f.

Conflicts:
	src/encoderstate.c
2015-09-14 14:31:58 +03:00
Arttu Ylä-Outinen 1d2a398197 Move function kvz_encoder_feed_frame to a separate module.
Adds module input_frame_buffer.
2015-09-14 14:12:18 +03:00
Arttu Ylä-Outinen 97913cee40 Add pts field to kvz_picture.
The pts field can be used to set the presentation timestamp of the input
frames. The timestamps are copied to the reconstructed frames.
2015-09-14 14:12:00 +03:00
Ari Koivula 24618c90ce Fix wrong type in debug code.
- This type is expected by outside debug scripts. It does not have to
  match the function name.
2015-09-10 16:07:18 +03:00
Arttu Ylä-Outinen 70b3e10e27 Fix a crash with owf=4, gop=8, frames=10.
A call to kvz_threadqueue_waitfor caused the tqj_bitstream_written field
of the previous encoder state to become a dangling pointer, subsequently
causing an assertion to fail. This would only occur when the encoder
state used for a new frame was not the last finished one.

Fixed by setting tqj_bitstream_written to NULL after the job is done and
removing unnecessary calls to kvz_threadqueue_waitfor.
2015-09-07 15:37:04 +03:00
Ari Koivula b2fb1b6d4a Rename kvz_bitstream_align to kvz_bitstream_rbsp_trailing_bits.
- The syntax is called rbsp_trailing_bits in spec and 1 byte is added
  even when the bitstream is already aligned, so align is a bad name.
2015-08-27 14:33:30 +03:00
Arttu Ylä-Outinen 3a10e9e3e0 Prefix all non-static symbols with "kvz_". 2015-08-26 13:02:28 +03:00
Arttu Ylä-Outinen dd874a0a4a Move writing of reconstructed picture to encmain.
- Removes parameter recout of function encoder_compute_stats.
- Now only encmain uses the yuv_io module.
2015-08-20 16:42:28 +03:00
Marko Viitanen 8409317bd9 Fixed rebasing errors for 10bit branch 2015-08-11 14:56:45 +03:00
Marko Viitanen 58f12bd530 Changed frame 8bit to 10bit conversion to be done without memory allocation 2015-08-11 08:18:14 +03:00
Marko Viitanen 57ab46f110 Small fixes all around to enable 10bit encoding
Conflicts:
	src/encmain.c
	src/encoder.c
	src/encoderstate.c
	src/global.h
2015-08-11 07:59:20 +03:00
Arttu Ylä-Outinen b715ae9767 Return length of the data from encoder_encode.
Adds parameter len_out returning the length of the encoded data in bytes
to function encoder_encode.
2015-07-02 16:58:29 +03:00
Arttu Ylä-Outinen f7f17a060c Rename pixel_t to kvz_pixel. 2015-07-02 16:58:28 +03:00
Arttu Ylä-Outinen cecea44d37 Rename config_t to kvz_config. 2015-07-02 16:58:28 +03:00
Arttu Ylä-Outinen 17d720363a Rename struct image_t to kvz_picture. 2015-07-02 16:55:48 +03:00
Arttu Ylä-Outinen 7b6178f6e0 Rename macro MAX_GOP to KVZ_MAX_GOP_LENGTH. 2015-07-02 16:55:47 +03:00
Arttu Ylä-Outinen 398f0c823b Replace memory bitstreams with linked lists.
- Removes all bitstream types.
- Changes encoder_encode to return the encoded data as list of chunks.
- Moves writing of the encoded data to the main function.
2015-07-02 16:35:46 +03:00
Arttu Ylä-Outinen 7e20e62cc7 Make kvazaar_encode consume one frame on each call.
- Replaces read_one_frame by encoder_feed_frame.
- Adds field "prepared" to encoderstate_t to indicate that
  encoder_next_frame has been called.
- Input frames are read in the main function and passed to
  encoder_encode.
2015-07-02 16:28:40 +03:00
Arttu Ylä-Outinen 012c0580df Move writing reconstructed image to yuv_io module.
Adds function yuv_io_write.
2015-07-02 16:28:39 +03:00
Arttu Ylä-Outinen 7bd23f5dbb Rename yuv_input module to yuv_io. 2015-07-02 16:28:39 +03:00
Arttu Ylä-Outinen 1f41717351 Rename stats_done to frame_done in encoderstate.
The new field frame_done is set to zero when starting to encode a new
frame and reset to one when the encoded data has been written.
2015-07-02 16:24:26 +03:00
Arttu Ylä-Outinen 50a5d5faa5 Let subimages have multiple references.
Adds function image_copy_ref to image module for getting a new reference
to an image. It can be used instead of image_make_subimage when the
sizes of the original and the subimage are same.
2015-07-02 16:24:26 +03:00
Arttu Ylä-Outinen fe3b629905 Move poc from image_t to image_list_t. 2015-07-02 16:24:25 +03:00
Arttu Ylä-Outinen 5d524c0290 Move seeking to yuv_input module. 2015-07-02 16:24:24 +03:00
Arttu Ylä-Outinen 970d0ec182 Move input reading functions to yuv_input module.
Adds function read_yuv_frame and moves functions fill_after_frame and
read_and_fill_frame_data from encoderstate to yuv_input.
2015-07-02 16:24:23 +03:00
Arttu Ylä-Outinen b130ecc9bb Fix "reference not found" when GOP is enabled.
The encoder state must be cleared by calling encoder_next_frame before
calling read_one_frame.
2015-07-02 16:14:51 +03:00
Ari Koivula fc58748ae8 Output bitstream through API.
- Use the existing bitstream_t type to give access to the bitstream.
  We can extend it later to make it a linked list like I was planning
  to do with the payload type.
- The main encoder now also stores the bitstream in memory.
2015-07-02 16:10:51 +03:00
Ari Koivula 9a3edce3fc Separate input and output from encoding.
- Move image_t and pixel_t to the kvazaar.h API.
- Try and arrange things such that image_t can be used as input and
  output for encoding.

Conflicts:
	src/encmain.c
2015-07-02 15:52:23 +03:00
Ari Koivula 4f4b62b13c Fix owf. 2015-07-02 15:45:34 +03:00
Ari Koivula 5c28745457 Move OWF logic and CLI stuff out of encoder_compute_stats.
- CLI stuff is moved to either cli-module or to main function.
- OWF stuff is made more explicit by counting the frames instead of
  communicating through encoder_state_t.stats_done.
2015-07-02 15:45:33 +03:00
Ari Koivula 80ec1fda3a Remove unnecessary dependency between I-frames.
- Inter OWF dependency was being added to non-IDR I-frames.
2015-06-01 16:26:30 +03:00
Arttu Ylä-Outinen 984e7cb4e0 Fix setting QP when rate control is disabled.
When rate control is disabled, QP and lambda are now selected like they
were before rate control was implemented.
2015-06-01 13:57:11 +03:00
Arttu Ylä-Outinen 93d2a95ddc Implement rate control in lambda domain.
- Rate control adjusts the lambda value.
- QP is selected according to lambda.
- Bits are allocated for GOPs and individual pictures.
2015-05-19 11:40:51 +03:00
Arttu Ylä-Outinen 4a5698a6ba Implement basic rate control. 2015-05-19 10:42:17 +03:00
Ari Koivula 56bb8e75ba Fix non-deterministic behavior with tiles.
- Depend on the whole previous frame.
- We should really go through all these FIXME's sometime.
2015-05-12 12:00:32 +03:00
Ari Koivula a48d91dacd Fix WPP not working when SAO is off and OWF is on.
- Every wavefront row was being set to done when the first wavefront
  row got done.
- Looks like I didn't understand how the data structure worked when I
  "cleaned this up", and it didn't get caught in tests because it
  needs OWF to be on to affect anything.
2015-05-11 12:01:17 +03:00
Ari Koivula 87936eb99f Revert "Fix keeping of reference frames over IDR boundary."
This reverts commit b43f1cb9eb.

- This change resulted in use of uninitialized memory with owf != 0.

Conflicts:
	src/encoderstate.c
2015-05-05 17:07:49 +03:00
Ari Koivula c3b42291e1 Merge branches 'coverity-fix-5', 'coverity-fix-6', 'coverity-fix-7', 'coverity-fix-8', 'coverity-fix-9', 'coverity-fix-10', 'coverity-fix-11', 'coverity-fix-12', 'coverity-fix-13' and 'coverity-fix-14' into coverity-fixes2 2015-05-05 12:27:02 +03:00
Ari Koivula 2276e0028f Fix coverity warning.
- False positive about use of an uninitialized value. Actually just
  copying uninitialized data from one struct to another.
2015-05-05 10:39:29 +03:00
Ari Koivula 41d9889e28 Fix coverity warning.
- False positive about coeff_y being uninitialized when width == 0.
2015-05-05 10:23:52 +03:00
Ari Koivula 9015aab996 Clean up IDR handling code.
- IDR was called RADL, probably because the NAL type is IDR_W_RADL.
- Move things around to make it clearer what is happening.
2015-04-30 20:46:07 +03:00
Ari Koivula b43f1cb9eb Fix keeping of reference frames over IDR boundary.
-
2015-04-30 15:42:16 +03:00
Ari Koivula c0c9bc619a Fix valgrind warning.
- Attribute state->global->slicetype was used before being initialized.
- The reference frame lists should be updated based on current frame,
  not on previous frame (or uninitialized data).
2015-04-30 13:18:28 +03:00
Marko Viitanen 8ed5d06ebe Fixed compiler warnings caused by the bipred branch merge 2015-04-23 15:12:48 +03:00
Marko Viitanen 3c694a8f6e Fixed bipred mv candidate selection 2015-04-23 12:18:05 +03:00
Marko Viitanen 06bc4f3d5e Fixed duplicate checking for merge cand and some cleanup 2015-03-31 12:23:46 +03:00