/* This file is part of jellything (https://codeberg.org/metamuffin/jellything) which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2026 metamuffin */ pub fn av1_codec_param(cp: &[u8]) -> String { let profile = (cp[1] >> 5) & 0b111; let level = cp[1] & 0b11111; let tier = (cp[2] >> 7) & 0b1; let high_bitdepth = (cp[2] >> 6) & 0b1; let twelve_bit = (cp[2] >> 5) & 0b1; let _monochrome = (cp[2] >> 4) & 0b1; let _css_x = (cp[2] >> 3) & 0b1; let _css_y = (cp[2] >> 2) & 0b1; let _css_pos = cp[2] & 0b11; let tier_char = if tier == 1 { 'H' } else { 'M' }; let bit_depth = if twelve_bit == 1 { 12 } else if high_bitdepth == 1 { 10 } else { 0 }; format!( "av01.{profile}.{level:02}{tier_char}.{bit_depth:02}" // .{monochrome}.{css_x}{css_y}{css_pos} ) } #[test] fn sample1() { assert_eq!(av1_codec_param(&[0x81, 0x04, 0x4E]), "av01.0.04M.10"); } #[test] fn sample2() { assert_eq!(av1_codec_param(&[0x81, 0x35, 0xF4]), "av01.1.21H.12"); }