Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupt bitstream: multi-pass encoding #2311

Closed
mikoim opened this issue May 17, 2020 · 8 comments
Closed

Corrupt bitstream: multi-pass encoding #2311

mikoim opened this issue May 17, 2020 · 8 comments
Assignees
Labels
BLOCKER Blocking major path of the project. bug desync

Comments

@mikoim
Copy link

mikoim commented May 17, 2020

I encoded video with target bitrate mode to compare quality and performance. rav1e seems to output corrupt bitstream in specific parameters.

for TILE in 1 2 4 8 16 32 64
do
    for SPEED in 0 1 2 3 4 5 6 7 8 9 10
    do
        echo "--speed $SPEED --tiles $TILE"
        rav1e --output /dev/null --bitrate 3000 --first-pass $SPEED-$TILE.stat --speed $SPEED --tiles $TILE input.y4m
        rav1e --output $SPEED-$TILE.ivf --bitrate 3000 --second-pass $SPEED-$TILE.stat --speed $SPEED --tiles $TILE input.y4m
    done
done

Playable?

tiles/speed 0 1 2 3 4 5 6 7 8 9 10
1
2 not tested not tested not tested not tested
4
8
16
32
64 not tested not tested not tested not tested not tested not tested

Environment

  • Intel(R) Core(TM) i9-7980XE CPU @ 2.60GHz
  • aom 9c38f3b0f18a0d64cbfbf4d28c283c9a44c69667
  • rav1e c6bf0bf
    • rustc 1.43.1 (8d69840ab 2020-05-04)
    • RUSTFLAGS="-C target-cpu=native" cargo build --release
$ mediainfo input.y4m
General
Complete name                            : input.y4m
Format                                   : YUV4MPEG2
File size                                : 451 MiB
Duration                                 : 7 s 958 ms
Overall bit rate                         : 475 Mb/s

Video
Format                                   : YUV
Duration                                 : 7 s 958 ms
Bit rate                                 : 475 Mb/s
Width                                    : 1 718 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 2.40:1
Frame rate                               : 24.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:2
Scan type                                : Progressive
Compression mode                         : Lossless
Bits/(Pixel*Frame)                       : 16.000
Stream size                              : 451 MiB (100%)

Artifacts

Logs

$ aomdec --verbose -o /dev/null 0-2.ivf
AOMedia Project AV1 Decoder 1.0.0-errata1-avif-893-g9c38f3b0f
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Corrupted segment_ids
$ aomdec --verbose -o /dev/null 1-2.ivf
AOMedia Project AV1 Decoder 1.0.0-errata1-avif-893-g9c38f3b0f
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 8x16 invalid with this subsampling mode
$ aomdec --verbose -o /dev/null 2-2.ivf
AOMedia Project AV1 Decoder 1.0.0-errata1-avif-893-g9c38f3b0f
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 8x32 invalid with this subsampling mode
$ aomdec --verbose -o /dev/null 3-2.ivf
AOMedia Project AV1 Decoder 1.0.0-errata1-avif-893-g9c38f3b0f
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 8x16 invalid with this subsampling mode
$ aomdec --verbose -o /dev/null 4-2.ivf
AOMedia Project AV1 Decoder 1.0.0-errata1-avif-893-g9c38f3b0f
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 16x32 invalid with this subsampling mode
$ aomdec --verbose -o /dev/null 5-2.ivf
AOMedia Project AV1 Decoder 1.0.0-errata1-avif-893-g9c38f3b0f
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 4x16 invalid with this subsampling mode
$ aomdec --verbose -o /dev/null 6-64.ivf
AOMedia Project AV1 Decoder 1.0.0-errata1-avif-893-g9c38f3b0f
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 16x32 invalid with this subsampling mode
$ aomdec --verbose -o /dev/null 7-64.ivf
AOMedia Project AV1 Decoder 1.0.0-errata1-avif-893-g9c38f3b0f
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 16x32 invalid with this subsampling mode
$ aomdec --verbose -o /dev/null 8-64.ivf
AOMedia Project AV1 Decoder 1.0.0-errata1-avif-893-g9c38f3b0f
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 16x32 invalid with this subsampling mode
$ aomdec --verbose -o /dev/null 9-64.ivf
AOMedia Project AV1 Decoder 1.0.0-errata1-avif-893-g9c38f3b0f
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 32x64 invalid with this subsampling mode
@barrbrain
Copy link
Collaborator

Thank you for this detailed report. Which revision of rav1e was used in these tests?

@mikoim
Copy link
Author

mikoim commented May 17, 2020

rav1e c6bf0bf is used in these tests.

@barrbrain
Copy link
Collaborator

I reproduced the 2-tile failures in a test case and added an assertion for the block size error condition. The assertion didn't fail although the decode did, so I hypothesise that the preceding symbols are where the desync occurs. To test this, I tried disabling loop restoration filters (LRF) and the test case then passed. The cause is likely in the writing of LRF coefficients. Given that there is no desync for most resolutions/tiles/subsamplings, it might be that in this case the wrong number of symbols are written.

@barrbrain
Copy link
Collaborator

I can reproduce in single-pass with quantizers >= 161.

@dwbuiten dwbuiten added the BLOCKER Blocking major path of the project. label May 19, 2020
@mikoim
Copy link
Author

mikoim commented May 19, 2020

  • --speed 9 --tiles 64 --quantizer 176
aomdec -o /dev/null s9-t64-q176.ivf
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Failed to decode tile data
  • --speed 9 --tiles 64 --quantizer 192
aomdec -o /dev/null s9-t64-q192.ivf
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 16x32 invalid with this subsampling mode
  • --speed 9 --tiles 64 --quantizer 208
aomdec -o /dev/null s9-t64-q208.ivf
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 16x32 invalid with this subsampling mode
  • --speed 9 --tiles 64 --quantizer 224
aomdec -o /dev/null s9-t64-q224.ivf
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 16x32 invalid with this subsampling mode
  • --speed 9 --tiles 64 --quantizer 240
aomdec -o /dev/null s9-t64-q240.ivf
Warning: Failed to decode frame 1: Corrupt frame detected
Warning: Additional information: Block size 32x64 invalid with this subsampling mode

rav1e 02018bf
corrupt.tar: https://gofile.io/d/EGd91F

@xiphmont
Copy link
Contributor

I think I know what this is; I missed a necessary tile/LRU alignment restriction case for 4:2:2 when fixing #2212.

@xiphmont
Copy link
Contributor

xiphmont commented Jun 5, 2020

Proposed fix in PR #2371, please test. Our CI coverage is very light on 4:2:2 content right now.

@mikoim
Copy link
Author

mikoim commented Jun 10, 2020

@xiphmont It seems to work well. Thank you!

@mikoim mikoim closed this as completed Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLOCKER Blocking major path of the project. bug desync
Projects
None yet
Development

No branches or pull requests

5 participants