use codec name in info
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 16 May 2017 16:47:38 +0000 (18:47 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 16 May 2017 16:47:38 +0000 (18:47 +0200)
src/demuxers/avi.rs
src/demuxers/gdv.rs
src/frame.rs

index 99c730522c21221b4a364fc9d35387d0899ccdff..0b8ade0d5dc4b60114ca706105ffaddfdc6e019d 100644 (file)
@@ -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<usize> {
     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<usize> {
     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<usize> {
     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<usize> {
 
 fn parse_strf_xxxx(dmx: &mut AVIDemuxer, size: usize) -> DemuxerResult<usize> {
     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();
index afdc4f6ac591ce1b37541b3fa2caa14c70048bc1..57b67921dc2c09580a89d9e24a68e02865e2738c 100644 (file)
@@ -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 };
index 962198e84df7afba64412a1a179d2bf9c64dc326..7455b72a393bd298819b054a680a2d0187f60fc3 100644 (file)
@@ -73,17 +73,18 @@ pub struct NABuffer<'a> {
 #[allow(dead_code)]
 #[derive(Clone)]
 pub struct NACodecInfo {
+    name:       &'static str,
     properties: NACodecTypeInfo,
     extradata:  Option<Rc<Vec<u8>>>,
 }
 
 impl NACodecInfo {
-    pub fn new(p: NACodecTypeInfo, edata: Option<Vec<u8>>) -> Self {
+    pub fn new(name: &'static str, p: NACodecTypeInfo, edata: Option<Vec<u8>>) -> 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<Rc<Vec<u8>>> {