From: Kostya Shishkov Date: Tue, 16 May 2017 16:47:38 +0000 (+0200) Subject: use codec name in info X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=ccae5343c71a92519937b9eafd9af0fe0ce3d799;p=nihav.git use codec name in info --- diff --git a/src/demuxers/avi.rs b/src/demuxers/avi.rs index 99c7305..0b8ade0 100644 --- a/src/demuxers/avi.rs +++ b/src/demuxers/avi.rs @@ -1,4 +1,5 @@ use super::*; +use register; use super::DemuxerError::*; use io::byteio::*; use frame::*; @@ -269,7 +270,8 @@ fn parse_strf_vids(dmx: &mut AVIDemuxer, size: usize) -> DemuxerResult { let height = dmx.src.read_u32le()? as i32; let planes = dmx.src.read_u16le()?; let bitcount = dmx.src.read_u16le()?; - let compression = dmx.src.read_u32be()?; + let mut compression: [u8; 4] = [0; 4]; + dmx.src.read_buf(&mut compression)?; let img_size = dmx.src.read_u32le()?; let xdpi = dmx.src.read_u32le()?; let ydpi = dmx.src.read_u32le()?; @@ -281,7 +283,11 @@ fn parse_strf_vids(dmx: &mut AVIDemuxer, size: usize) -> DemuxerResult { let vhdr = NAVideoInfo::new(width, if flip { -height as u32 } else { height as u32}, flip, PAL8_FORMAT); let vci = NACodecTypeInfo::Video(vhdr); let edata = dmx.read_extradata(size - 40)?; - let vinfo = NACodecInfo::new(vci, edata); + let cname = match register::find_codec_from_avi_fourcc(&compression) { + None => "unknown", + Some(name) => name, + }; + let vinfo = NACodecInfo::new(cname, vci, edata); let res = dmx.dmx.add_stream(NAStream::new(StreamType::Video, dmx.sstate.strm_no as u32, vinfo)); if let None = res { return Err(MemoryError); } dmx.sstate.reset(); @@ -301,7 +307,11 @@ fn parse_strf_auds(dmx: &mut AVIDemuxer, size: usize) -> DemuxerResult { let soniton = NASoniton::new(bits_per_sample as u8, SONITON_FLAG_SIGNED); let ahdr = NAAudioInfo::new(samplespersec, channels as u8, soniton, block_align as usize); let edata = dmx.read_extradata(size - 16)?; - let ainfo = NACodecInfo::new(NACodecTypeInfo::Audio(ahdr), edata); + let cname = match register::find_codec_from_wav_twocc(w_format_tag) { + None => "unknown", + Some(name) => name, + }; + let ainfo = NACodecInfo::new(cname, NACodecTypeInfo::Audio(ahdr), edata); let res = dmx.dmx.add_stream(NAStream::new(StreamType::Audio, dmx.sstate.strm_no as u32, ainfo)); if let None = res { return Err(MemoryError); } dmx.sstate.reset(); @@ -310,7 +320,7 @@ fn parse_strf_auds(dmx: &mut AVIDemuxer, size: usize) -> DemuxerResult { fn parse_strf_xxxx(dmx: &mut AVIDemuxer, size: usize) -> DemuxerResult { let edata = dmx.read_extradata(size)?; - let info = NACodecInfo::new(NACodecTypeInfo::None, edata); + let info = NACodecInfo::new("unknown", NACodecTypeInfo::None, edata); let res = dmx.dmx.add_stream(NAStream::new(StreamType::Data, dmx.sstate.strm_no as u32, info)); if let None = res { return Err(MemoryError); } dmx.sstate.reset(); diff --git a/src/demuxers/gdv.rs b/src/demuxers/gdv.rs index afdc4f6..57b6792 100644 --- a/src/demuxers/gdv.rs +++ b/src/demuxers/gdv.rs @@ -43,13 +43,13 @@ impl<'a> Demux<'a> for GremlinVideoDemuxer<'a> { if max_fs > 0 { let vhdr = NAVideoInfo::new(width as u32, height as u32, false, PAL8_FORMAT); let vci = NACodecTypeInfo::Video(vhdr); - let vinfo = NACodecInfo::new(vci, None); + let vinfo = NACodecInfo::new("video-gdv", vci, None); self.v_id = self.dmx.add_stream(NAStream::new(StreamType::Video, 0, vinfo)); } if (aflags & 1) != 0 { let channels = if (aflags & 2) != 0 { 2 } else { 1 }; let ahdr = NAAudioInfo::new(rate as u32, channels as u8, if (aflags & 4) != 0 { SND_S16_FORMAT } else { SND_U8_FORMAT }, 2); - let ainfo = NACodecInfo::new(NACodecTypeInfo::Audio(ahdr), None); + let ainfo = NACodecInfo::new("audio-gdv", NACodecTypeInfo::Audio(ahdr), None); self.a_id = self.dmx.add_stream(NAStream::new(StreamType::Audio, 1, ainfo)); let packed = if (aflags & 8) != 0 { 1 } else { 0 }; diff --git a/src/frame.rs b/src/frame.rs index 962198e..7455b72 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -73,17 +73,18 @@ pub struct NABuffer<'a> { #[allow(dead_code)] #[derive(Clone)] pub struct NACodecInfo { + name: &'static str, properties: NACodecTypeInfo, extradata: Option>>, } impl NACodecInfo { - pub fn new(p: NACodecTypeInfo, edata: Option>) -> Self { + pub fn new(name: &'static str, p: NACodecTypeInfo, edata: Option>) -> Self { let extradata = match edata { None => None, Some(vec) => Some(Rc::new(vec)), }; - NACodecInfo { properties: p, extradata: extradata } + NACodecInfo { name: name, properties: p, extradata: extradata } } pub fn get_properties(&self) -> NACodecTypeInfo { self.properties } pub fn get_extradata(&self) -> Option>> {