From: Kostya Shishkov Date: Thu, 21 May 2020 09:00:47 +0000 (+0200) Subject: registry: allow searching for FOURCC/TWOCC by codec name X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=9a3ce86c69889682eba3fa640475b86598f6120b;p=nihav.git registry: allow searching for FOURCC/TWOCC by codec name --- diff --git a/nihav-registry/src/register.rs b/nihav-registry/src/register.rs index 6ae8528..1665b67 100644 --- a/nihav-registry/src/register.rs +++ b/nihav-registry/src/register.rs @@ -317,6 +317,14 @@ pub fn find_codec_from_avi_fourcc(fcc: &[u8;4]) -> Option<&'static str> { None } +/// Returns FOURCC (used in AVI format) for provided codec name. +pub fn find_avi_fourcc(codecname: &str) -> Option<[u8; 4]> { + for (fourcc, name) in AVI_VIDEO_CODEC_REGISTER.iter() { + if *name == codecname { return Some(**fourcc); } + } + None +} + /// Returns known audio codec short name for provided TWOCC (used in WAV and AVI format). pub fn find_codec_from_wav_twocc(tcc: u16) -> Option<&'static str> { for (twocc, name) in WAV_CODEC_REGISTER.iter() { @@ -325,6 +333,14 @@ pub fn find_codec_from_wav_twocc(tcc: u16) -> Option<&'static str> { None } +/// Returns TWOCC (used in WAV and AVI format for provided codec name. +pub fn find_wav_twocc(codecname: &str) -> Option { + for (twocc, name) in WAV_CODEC_REGISTER.iter() { + if *name == codecname { return Some(*twocc); } + } + None +} + /// Returns video codec short name for provided FOURCC (used in MOV format). pub fn find_codec_from_mov_video_fourcc(fcc: &[u8;4]) -> Option<&'static str> { for (fourcc, name) in MOV_VIDEO_CODEC_REGISTER.iter() {