11use dav1d_sys:: * ;
22
3+ pub use av_data:: pixel;
34use std:: ffi:: c_void;
45use std:: fmt;
56use std:: i64;
@@ -640,6 +641,97 @@ impl Picture {
640641 pub fn offset ( & self ) -> i64 {
641642 self . inner . pic . m . offset
642643 }
644+
645+ /// Chromaticity coordinates of the source colour primaries.
646+ pub fn color_primaries ( & self ) -> pixel:: ColorPrimaries {
647+ unsafe {
648+ #[ allow( non_upper_case_globals) ]
649+ match ( * self . inner . pic . seq_hdr ) . pri {
650+ DAV1D_COLOR_PRI_BT709 => pixel:: ColorPrimaries :: BT709 ,
651+ DAV1D_COLOR_PRI_UNKNOWN => pixel:: ColorPrimaries :: Unspecified ,
652+ DAV1D_COLOR_PRI_BT470M => pixel:: ColorPrimaries :: BT470M ,
653+ DAV1D_COLOR_PRI_BT470BG => pixel:: ColorPrimaries :: BT470BG ,
654+ DAV1D_COLOR_PRI_BT601 => pixel:: ColorPrimaries :: BT470BG ,
655+ DAV1D_COLOR_PRI_SMPTE240 => pixel:: ColorPrimaries :: ST240M ,
656+ DAV1D_COLOR_PRI_FILM => pixel:: ColorPrimaries :: Film ,
657+ DAV1D_COLOR_PRI_BT2020 => pixel:: ColorPrimaries :: BT2020 ,
658+ DAV1D_COLOR_PRI_XYZ => pixel:: ColorPrimaries :: ST428 ,
659+ DAV1D_COLOR_PRI_SMPTE431 => pixel:: ColorPrimaries :: P3DCI ,
660+ DAV1D_COLOR_PRI_SMPTE432 => pixel:: ColorPrimaries :: P3Display ,
661+ DAV1D_COLOR_PRI_EBU3213 => pixel:: ColorPrimaries :: Tech3213 ,
662+ 23 ..=DAV1D_COLOR_PRI_RESERVED => pixel:: ColorPrimaries :: Unspecified ,
663+ _ => unreachable ! ( ) ,
664+ }
665+ }
666+ }
667+
668+ /// Transfer characteristics function.
669+ pub fn transfer_characteristic ( & self ) -> pixel:: TransferCharacteristic {
670+ unsafe {
671+ #[ allow( non_upper_case_globals) ]
672+ match ( * self . inner . pic . seq_hdr ) . trc {
673+ DAV1D_TRC_BT709 => pixel:: TransferCharacteristic :: BT1886 ,
674+ DAV1D_TRC_UNKNOWN => pixel:: TransferCharacteristic :: Unspecified ,
675+ DAV1D_TRC_BT470M => pixel:: TransferCharacteristic :: BT470M ,
676+ DAV1D_TRC_BT470BG => pixel:: TransferCharacteristic :: BT470BG ,
677+ DAV1D_TRC_BT601 => pixel:: TransferCharacteristic :: ST170M ,
678+ DAV1D_TRC_SMPTE240 => pixel:: TransferCharacteristic :: ST240M ,
679+ DAV1D_TRC_LINEAR => pixel:: TransferCharacteristic :: Linear ,
680+ DAV1D_TRC_LOG100 => pixel:: TransferCharacteristic :: Logarithmic100 ,
681+ DAV1D_TRC_LOG100_SQRT10 => pixel:: TransferCharacteristic :: Logarithmic316 ,
682+ DAV1D_TRC_IEC61966 => pixel:: TransferCharacteristic :: SRGB ,
683+ DAV1D_TRC_BT1361 => pixel:: TransferCharacteristic :: BT1886 ,
684+ DAV1D_TRC_SRGB => pixel:: TransferCharacteristic :: SRGB ,
685+ DAV1D_TRC_BT2020_10BIT => pixel:: TransferCharacteristic :: BT2020Ten ,
686+ DAV1D_TRC_BT2020_12BIT => pixel:: TransferCharacteristic :: BT2020Twelve ,
687+ DAV1D_TRC_SMPTE2084 => pixel:: TransferCharacteristic :: PerceptualQuantizer ,
688+ DAV1D_TRC_SMPTE428 => pixel:: TransferCharacteristic :: ST428 ,
689+ DAV1D_TRC_HLG => pixel:: TransferCharacteristic :: HybridLogGamma ,
690+ 19 ..=DAV1D_TRC_RESERVED => pixel:: TransferCharacteristic :: Unspecified ,
691+ _ => unreachable ! ( ) ,
692+ }
693+ }
694+ }
695+
696+ /// Matrix coefficients used in deriving luma and chroma signals from the
697+ /// green, blue and red or X, Y and Z primaries.
698+ pub fn matrix_coefficients ( & self ) -> pixel:: MatrixCoefficients {
699+ unsafe {
700+ #[ allow( non_upper_case_globals) ]
701+ match ( * self . inner . pic . seq_hdr ) . mtrx {
702+ DAV1D_MC_IDENTITY => pixel:: MatrixCoefficients :: Identity ,
703+ DAV1D_MC_BT709 => pixel:: MatrixCoefficients :: BT709 ,
704+ DAV1D_MC_UNKNOWN => pixel:: MatrixCoefficients :: Unspecified ,
705+ DAV1D_MC_FCC => pixel:: MatrixCoefficients :: BT470M ,
706+ DAV1D_MC_BT470BG => pixel:: MatrixCoefficients :: BT470BG ,
707+ DAV1D_MC_BT601 => pixel:: MatrixCoefficients :: BT470BG ,
708+ DAV1D_MC_SMPTE240 => pixel:: MatrixCoefficients :: ST240M ,
709+ DAV1D_MC_SMPTE_YCGCO => pixel:: MatrixCoefficients :: YCgCo ,
710+ DAV1D_MC_BT2020_NCL => pixel:: MatrixCoefficients :: BT2020NonConstantLuminance ,
711+ DAV1D_MC_BT2020_CL => pixel:: MatrixCoefficients :: BT2020ConstantLuminance ,
712+ DAV1D_MC_SMPTE2085 => pixel:: MatrixCoefficients :: ST2085 ,
713+ DAV1D_MC_CHROMAT_NCL => {
714+ pixel:: MatrixCoefficients :: ChromaticityDerivedNonConstantLuminance
715+ }
716+ DAV1D_MC_CHROMAT_CL => {
717+ pixel:: MatrixCoefficients :: ChromaticityDerivedConstantLuminance
718+ }
719+ DAV1D_MC_ICTCP => pixel:: MatrixCoefficients :: ICtCp ,
720+ 15 ..=DAV1D_MC_RESERVED => pixel:: MatrixCoefficients :: Unspecified ,
721+ _ => unreachable ! ( ) ,
722+ }
723+ }
724+ }
725+
726+ /// YUV color range.
727+ pub fn color_range ( & self ) -> pixel:: YUVRange {
728+ unsafe {
729+ match ( * self . inner . pic . seq_hdr ) . color_range {
730+ 0 => pixel:: YUVRange :: Limited ,
731+ _ => pixel:: YUVRange :: Full ,
732+ }
733+ }
734+ }
643735}
644736
645737unsafe impl Send for Picture { }
0 commit comments