avi: take into account the original orientation for raw video
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 5 Oct 2021 13:58:47 +0000 (15:58 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 5 Oct 2021 13:58:47 +0000 (15:58 +0200)
nihav-commonfmt/src/demuxers/avi.rs

index 3e372e0d4c0ed9f4ab90ba9d070b27b832599e3b..3e49be0e17fb7862f4eaaa80a4f720c6234ffe19 100644 (file)
@@ -424,7 +424,7 @@ fn parse_strf_vids(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize
     let format = if bitcount > 8 { RGB24_FORMAT } else { PAL8_FORMAT };
     let mut vhdr = NAVideoInfo::new(width as usize, if flip { -height as usize } else { height as usize}, flip, format);
     vhdr.bits = (planes as u8) * (bitcount as u8);
-    let cname = if find_raw_fmt(&compression, planes, bitcount, &mut vhdr) {
+    let cname = if find_raw_fmt(&compression, planes, bitcount, flip, &mut vhdr) {
             "rawvideo-ms"
         } else {
             match register::find_codec_from_avi_fourcc(&compression) {
@@ -454,7 +454,7 @@ fn parse_strf_vids(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize
     Ok(size)
 }
 
-fn find_raw_fmt(compr: &[u8; 4], planes: u16, bitcount: u16, vhdr: &mut NAVideoInfo) -> bool {
+fn find_raw_fmt(compr: &[u8; 4], planes: u16, bitcount: u16, flip: bool, vhdr: &mut NAVideoInfo) -> bool {
     match compr {
         &[0, 0, 0, 0] | b"DIB " => {
             if planes != 1 {
@@ -469,7 +469,7 @@ fn find_raw_fmt(compr: &[u8; 4], planes: u16, bitcount: u16, vhdr: &mut NAVideoI
                 };
             if let Ok(fmt) = NAPixelFormaton::from_str(fmt_name) {
                 vhdr.format = fmt;
-                vhdr.flipped = true;
+                vhdr.flipped = !flip;
                 true
             } else {
                 false