Skip to content

Commit 018afc2

Browse files
committed
Set chroma_sample_position only for YUV 4:2:0
The chroma_sample_position syntax element is only used for YUV 4:2:0 in the AV1 bitstream. So set chroma_sample_position to ChromaSamplePosition::Unknown for all other YUV formats, including monochrome (YUV 4:0:0). Note: For still images, the most common chroma sample position in practice is the "center" position. Unfortunately the AV1 specification does not have a value for the "center" chroma sample position. See AOMediaCodec/av1-avif#88 and AOMediaCodec/av1-spec#308. This pull request preserves the ChromaSamplePosition::Colocated value that is currently used, but it is likely to be incorrect when YUV 4:2:0 is supported.
1 parent 0f5daab commit 018afc2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ravif/src/av1encoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,10 @@ fn encode_to_av1(p: &Av1EncodeConfig<'_>) -> Result<Vec<u8>, Box<dyn std::error:
351351
sample_aspect_ratio: Rational::new(1, 1),
352352
bit_depth,
353353
chroma_sampling: p.chroma_sampling,
354-
chroma_sample_position: if p.chroma_sampling == ChromaSampling::Cs400 {
355-
ChromaSamplePosition::Unknown
356-
} else {
354+
chroma_sample_position: if p.chroma_sampling == ChromaSampling::Cs420 {
357355
ChromaSamplePosition::Colocated
356+
} else {
357+
ChromaSamplePosition::Unknown
358358
},
359359
pixel_range: p.pixel_range,
360360
color_description: p.color_description,

0 commit comments

Comments
 (0)