The loopfilter thread from the previous frame can be running while
starting the current frame. cpi->Source will change during this time causing
the wrong data to be copied. The refresh_x_frame flags also change, which
will cause incorrect updates of the denoised buffers.
Change-Id: I7d982b4fcb40a0610801332aa85f3b792c64e4c3
The denoiser was writing to LAST_FRAME buffer. If LAST_FRAME isn't being
updated, the reference frame buffers were out of sync between the encoder and the
denoised raw buffers. This patch resolves the discrepancy by always writing to a work
buffer (INTRA_FRAME) and then copying from that buffer to any buffers that needs to
be updated.
Change-Id: I6dd855b9749978b542bc3d515914d5f16faf25df
Multi-threaded code was not updated to disable background
refresh for non base-layer frames at the time it was
disabled in the main C-code.
Change-Id: Id6cc376130b7def046942121cfd0526b4f0a71d4
Don't use the switch to gf_rate_correction factor when
temporal layers is used (i.e., cpi->oxcf.number_of_layers > 1).
In temporal layers, we prefer to avoid this as any frame
(e.g., base layer frame at anchor of pattern) may update
both last and golden (and possibly alt-ref), and so we would get
different rate correction factors within the same layer.
This change will make sure one rate correction factor exists for each layer.
Also, made some other code in qp-regulate that depends on
alt/golden update specific to the 1 layer case.
Change-Id: I41a6d085bd477f9307ef3b3c311695214273892c
If the threshold(limits) <= 0, skipped filtering and copied the
frame directly. Also, fixed memory allocation checking.
Change-Id: If3d79d5b2bcb71b9777e6eb5cba1384585131e22
If a reference frame is forced because of low dissimilarity, then
shut off the search of intra modes. This change has mixed results. On
one clip (QVGA), it hurt quality by ~1.5% with negligible speed impact.
On another (VGA) it had negligible affect on quality, but a ~0.2% speed
impact.
Change-Id: Ic8b07648979d732f489de5f094957e140f84d2eb
Rather than overloading the parent_ref_frame value to shut off the
search in some cases, add a new validity flag. This cleans up some
of the duplicated mr_encoder_id && mr_low_res_mv_avail checks as
well, for readability.
Change-Id: Iddad93a27066c3d85ff2f25a361ac113b288ab7b
1. Algorithm modification:
Instead of having same filter threshold for a whole frame, now we
allow the thresholds to be adjusted for each macroblock. In current
implementation, to avoid excessive blur on background as reported
in issue480(http://code.google.com/p/webm/issues/detail?id=480), we
reduce the thresholds for skipped macroblocks.
2. SSE2 optimization:
As started in issue479(http://code.google.com/p/webm/issues/detail?id=479),
the filter calculation was adjusted for better performance. The c
code was also modified accordingly. This made the deblock filter
2x faster, and the decoder was 1.2x faster overall.
Next, the demacroblock filter will be modified similarly.
Change-Id: I05e54c3f580ccd427487d085096b3174f2ab7e86
In some situations, believed to be an interaction between temporal
scalability and dropped frames, the references available to an
encoder may not be the same references available to its parent.
Previously, the code tried to force the reference frame chosen by
the parent to be used on this frame, even if it was disabled. This
was preventing the pick mode loop from running even once, which led
to a crash.
Attempts to reproduce this bug locally were unsuccessful, so it is
still undetermined what the underlying cause of this issue is. In
the specific case that was failing, the application did not set
any flags which influenced the reference selection on that frame.
ref_frame_flags indicated that the golden frame was disabled,
believed to be because the last frame updated the last and golden
frames, so golden was shut off by default. It's not clear why this
wouldn't have also been true in the lower res encoder, ie, why the
lower res encoder decided to use and/or was allowed to use the
golden frame. We weren't able to debug into the non-crashing
lower res encoder as the crash couldn't be reproduced locally.
Change-Id: Ifb265253d26963ac2afde0e20cf6792788be6af7
If a parent mb is available but is intra coded, then parent_ref_mv is
invalid. Check that the parent is inter coded before trying to access
the parent_ref_mv. Previously the parent_ref_mv was being read from
an uninitialized stack allocation, causing potential OOB reads and
other undefined behavior.
Change-Id: I0c93cd412a19c3a184bcf6decaa145b3a036a6c0
The codec as it stood placed a keyframe one frame after a
real cut scene - and ignored datarate and other considerations.
TODO: Its possible that we should detect a keyframe and recode
the frame ( in certain circumstances) to improve quality.
Change-Id: Ia1fd6d90103f4da4d21ca5ab62897d22e0b888a8
Reset the cyclie refresh mode index in alloc_compressor_data().
This is needed to handle both cases of internal and
external spatial resizing.
Change-Id: I2697e12d45135eae2e8f0d45161811f24722312a
On an internal spatial resize, this mode index was not reset to 0,
and therefore could exceed dimensions of seg_map or cyclic_refresh_map.
Change-Id: I6fe85dbd2765eb0207a9d9f71fda8d8b8c34f075
This should avoid problems with blocks gettings high quality
improvement despite having recently moved:
Change-Id: Ic0af0de2d6577807fa3c553f47b55d547ef36359
Set the seg map to 0 for key frame.
In previous commit on cyclic refresh, the seg map for key frame
was not reset, and instead used the seg map from last frame.
Change-Id: I848eb2face420dfcd2f7daca6f070b9127ca938b
-Increase the amount of mbs to be refreshed.
-Replace the delta qp with a fixed and reduced delta.
-Change to the mb update loop to try to always update same amount of mbs.
Change-Id: I93ac88002fd8dc677d2337f77998ff93f64e4ff9
The denoiser function was modified to reduce the computational
complexity.
1. The denoiser c function modification:
The original implementation calculated pixel's filter_coefficient
based on the pixel value difference between current raw frame and last
denoised raw frame, and stored them in lookup tables. For each pixel c,
find its coefficient using
filter_coefficient[c] = LUT[abs_diff[c]];
and then apply filtering operation for the pixel.
The denoising filter costed about 12% of encoding time when it was
turned on, and half of the time was spent on finding coefficients in
lookup tables. In order to simplify the process, a short cut was taken.
The pixel adjustments vs. pixel diff value were calculated ahead of time.
adjustment = filtered_value - current_raw
= (filter_coefficient * diff + 128) >> 8
The adjustment vs. diff curve becomes flat very quick when diff increases.
This allowed us to use only several levels to get a close approximation
of the curve. Following the denoiser algorithm, the adjustments are
further modified according to how big the motion magnitude is.
2. The sse2 function was rewritten.
This change made denoiser filter function 3x faster, and improved the
encoder performance by 7% ~ 10% with the denoiser on.
Change-Id: I93a4308963b8e80c7307f96ffa8b8c667425bf50
For videos with big static background(such as video conferencing
clips), the mode decision was biased to ZEROMV in order to
obtain a stable background. The percentage of ZEROMV on last
frame was used to predict if there is static area in current frame,
and checking already-encoded neighboring macroblocks' motion
vectors to make sure the local area has low motion.
Change-Id: I05b3241d3a56a0bda88b6681e5646c1c8baf2e57
The current way of counting inter_zz_count doesn't work correctly
in multi-threaded encoding. Calculating it after the frame is
encoded fixed the problem.
Change-Id: Ifcb1972cde950b8cc194f75c6d7b6af09e8b0e65
Loop filter producing wierd artifacts when
repeatedly applied in noisy video. This
mitigates the effect.
Change-Id: If4b1a8543912d186a486f84e11d8b01f7436fa5f