kornelski / avif-serialize

Minimal pure Rust AVIF writer (bring your own AV1 payload)
https://lib.rs/avif-serialize
BSD 3-Clause "New" or "Revised" License
20 stars 3 forks source link

Fix the encoding of av1C properties #6

Closed wantehchang closed 2 years ago

wantehchang commented 2 years ago

Change the type of the seq_profile field of struct Av1CBox from bool to u8 because it needs to represents 3 bits: unsigned int (3) seq_profile;

Reverse the order of serializing the components of 'flags1'. The first field, seq_tier_0, should occupy the most significant bit of the byte.

Ideally the fields of the av1C property should be set to values obtained by parsing the sequence header OBU in the AV1 bitstream. For simplicity we set them to values that we predict rav1e will use.

In the av1C property for the color image, YUV 4:4:4 requires seq_profile=1 for bit depth 8 or 10 and seq_profile=2 for bit depth 12.

In the av1C property for the alpha image, monochrome requires seq_profile=0 for bit depth 8 or 10 and seq_profile=2 for bit depth 12. chroma_subsampling_x and chroma_subsampling_y are both equal to 1 for monochrome.

In both av1C properties, set seq_level_idx_0 to 31, which is the "Maximum parameters" level. Empirically this level appears to be used by rav1e.

wantehchang commented 2 years ago

@kornelski Please review. Thanks!

kornelski commented 2 years ago

Thank you