Skip to content

Commit

Permalink
Add API for ChromaLocation information retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
philn committed Apr 6, 2024
1 parent 06d002c commit 8469229
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,18 @@ impl Picture {
}
}
}

/// Sample position for subsampled chroma.
pub fn chroma_location(&self) -> pixel::ChromaLocation {
// According to y4m mapping declared in dav1d's output/y4m2.c and applied from FFmpeg's yuv4mpegdec.c
unsafe {
match (*self.inner.pic.seq_hdr).chr {
DAV1D_CHR_UNKNOWN | DAV1D_CHR_COLOCATED => pixel::ChromaLocation::Center,
DAV1D_CHR_VERTICAL => pixel::ChromaLocation::Left,
_ => unreachable!(),
}
}
}
}

static_assertions::assert_impl_all!(Picture: Send, Sync);
Expand Down

0 comments on commit 8469229

Please sign in to comment.