/* 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 */ use crate::codec_param::{av1::av1_codec_param, hevc::hevc_codec_param, vp9::vp9_codec_param}; use winter_matroska::TrackEntry; mod av1; mod hevc; mod vp9; #[derive(Debug, PartialEq, Eq)] struct CodecParam { bit_depth: Option, string: String, } pub fn codec_param(te: &TrackEntry) -> String { let empty_cp = vec![]; let cp = te.codec_private.as_ref().unwrap_or(&empty_cp); match te.codec_id.as_str() { "A_AAC" => "mp4a.40.2".to_string(), "A_FLAC" => "flac".to_string(), "A_OPUS" => "opus".to_string(), "A_VORBIS" => "vorbis".to_string(), "V_AV1" => av1_codec_param(cp).string, "V_MPEG4/ISO/AVC" => format!("avc1.{:02x}{:02x}{:02x}", cp[1], cp[2], cp[3]), "V_MPEGH/ISO/HEVC" => hevc_codec_param(cp).string, "V_VP9" => vp9_codec_param(te), "D_WEBVTT/SUBTITLES" => "webvtt".to_string(), "S_TEXT/ASS" => "ass".to_string(), x => todo!("{x:?}"), } } pub fn codec_param_bit_depth(te: &TrackEntry) -> Option { let empty_cp = vec![]; let cp = te.codec_private.as_ref().unwrap_or(&empty_cp); match te.codec_id.as_str() { "V_AV1" => av1_codec_param(cp).bit_depth, "V_MPEGH/ISO/HEVC" => hevc_codec_param(cp).bit_depth, _ => None, } }