Log in

View Full Version : Bad macro block when using cavlc encoding


dvbrain
18th January 2021, 11:31
When using x264 do intra encoding with tune fastdecode, we found some frames got wrong outputs.

When using command line:
x264 -o x264_test_sample_2.264 --input-fmt raw --input-res 3840x2160 --fps 50 --input-depth 10 --input-csp i422 --output-depth 10 --output-csp i422 --preset ultrafast --tune fastdecode --qp 12 --keyint 1 --slices 8 --no-cabac --threads 1 x264_test_sample_2.yuv
We got this:
https://i.postimg.cc/mg48861F/x264-test-sample-2-qp-12-480x270.jpg

When using command line:
x264 -o x264_test_sample_2.264 --input-fmt raw --input-res 3840x2160 --fps 50 --input-depth 10 --input-csp i422 --output-depth 10 --output-csp i422 --preset ultrafast --tune fastdecode --qp 11 --keyint 1 --slices 8 --no-cabac --threads 1 x264_test_sample_2.yuv
We got this:
https://i.postimg.cc/vByYBy4Z/x264-test-sample-2-qp-11-480x270.jpg

It seems the first micro block of slice 6 is corrupt encoded. The gray bar will disappear if we modify the Y value of pixel (0, 1344) from 721 to 711.

The source YUV file:
https://drive.google.com/file/d/1Wx3jLreE4vDTnPMU6FYB0F3fcu3PQIOH/view?usp=sharing

Hope somebody can help us to fix this problem.
Thanks.

dvbrain
21st January 2021, 11:34
Below is the differences between qp 11 and qp 12:

Dequantized for qp 11:
https://i.postimg.cc/s2P6ZMsL/qp-11-dequantized.jpg

Dequantized for qp 12:
https://i.postimg.cc/rphh9vRG/qp-12-dequantized.jpg

Transform for qp 11:
https://i.postimg.cc/dtq4zsRR/qp-11-transform.jpg

Transform for qp 12:
https://i.postimg.cc/rsqNXj4y/qp-12-transform.jpg

Residual for qp 11:
https://i.postimg.cc/nVdDhnbG/qp-11-residual.jpg

Residual for qp 12:
https://i.postimg.cc/j2Wd50PM/qp-12-residual.jpg

Decoded for qp 11:
https://i.postimg.cc/FK9rSJ0d/qp-11-decoded.jpg

Decoded for qp 12:
https://i.postimg.cc/QVGsdBXM/qp-12-decoded.jpg

Hope these can help to solve the problem.

jpsdr
21st January 2021, 17:18
I suggest you post here (https://code.videolan.org/videolan/x264/-/issues) the issue, if it's not allready posted.

dvbrain
22nd January 2021, 07:33
The bug has been fixed with patch BugMaster/x264@133c700b (https://code.videolan.org/BugMaster/x264/-/commit/133c700b38fd4274d2a4fd567a30be8d49e75a6b).

Thanks.

Emulgator
23rd January 2021, 23:34
Good find !

jpsdr
24th January 2021, 11:25
Not merged yet, probably in the next official release.