aboutsummaryrefslogtreecommitdiffstats
path: root/nihav-core/src
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2019-12-18 17:55:42 +0100
committerKostya Shishkov <kostya.shishkov@gmail.com>2019-12-18 17:55:42 +0100
commitd55185ccf5f25cafabd57d12b0ba96dc36b61327 (patch)
tree0a8da86ef44fcbb8404f5c95493825d9132e591b /nihav-core/src
parented4165117e3348e3b2b8484733469012b7b4c182 (diff)
downloadnihav-d55185ccf5f25cafabd57d12b0ba96dc36b61327.tar.gz
core/test: flip output PGMYUV if needed
Diffstat (limited to 'nihav-core/src')
-rw-r--r--nihav-core/src/test/dec_video.rs63
1 files changed, 55 insertions, 8 deletions
diff --git a/nihav-core/src/test/dec_video.rs b/nihav-core/src/test/dec_video.rs
index 7db25b8..9db9a02 100644
--- a/nihav-core/src/test/dec_video.rs
+++ b/nihav-core/src/test/dec_video.rs
@@ -32,11 +32,22 @@ fn write_pgmyuv(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) {
let ls = buf.get_stride(0);
let mut idx = 0;
let mut idx2 = w;
+ let is_flipped = buf.get_info().is_flipped();
+ if is_flipped {
+ idx += h * ls;
+ idx2 += h * ls;
+ }
for _ in 0..h {
+ if is_flipped {
+ idx -= ls;
+ idx2 -= ls;
+ }
let line = &dta[idx..idx2];
ofile.write_all(line).unwrap();
- idx += ls;
- idx2 += ls;
+ if !is_flipped {
+ idx += ls;
+ idx2 += ls;
+ }
}
if w2 <= w/2 {
let pad: Vec<u8> = vec![0xFF; (w - w2 * 2) / 2];
@@ -44,7 +55,15 @@ fn write_pgmyuv(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) {
let stride1 = buf.get_stride(1);
let mut base2 = buf.get_offset(2);
let stride2 = buf.get_stride(2);
+ if is_flipped {
+ base1 += h2 * stride1;
+ base2 += h2 * stride2;
+ }
for _ in 0..h2 {
+ if is_flipped {
+ base1 -= stride1;
+ base2 -= stride2;
+ }
let bend1 = base1 + w2;
let line = &dta[base1..bend1];
ofile.write_all(line).unwrap();
@@ -55,39 +74,67 @@ fn write_pgmyuv(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) {
ofile.write_all(line).unwrap();
ofile.write_all(pad.as_slice()).unwrap();
- base1 += stride1;
- base2 += stride2;
+ if !is_flipped {
+ base1 += stride1;
+ base2 += stride2;
+ }
}
} else {
let pad: Vec<u8> = vec![0xFF; w - w2];
let mut base1 = buf.get_offset(1);
let stride1 = buf.get_stride(1);
+ if is_flipped {
+ base1 += h2 * stride1;
+ }
for _ in 0..h2 {
+ if is_flipped {
+ base1 -= stride1;
+ }
let bend1 = base1 + w2;
let line = &dta[base1..bend1];
ofile.write_all(line).unwrap();
ofile.write_all(pad.as_slice()).unwrap();
- base1 += stride1;
+ if !is_flipped {
+ base1 += stride1;
+ }
}
let mut base2 = buf.get_offset(2);
let stride2 = buf.get_stride(2);
+ if is_flipped {
+ base2 += h2 * stride2;
+ }
for _ in 0..h2 {
+ if is_flipped {
+ base2 -= stride2;
+ }
let bend2 = base2 + w2;
let line = &dta[base2..bend2];
ofile.write_all(line).unwrap();
ofile.write_all(pad.as_slice()).unwrap();
- base2 += stride2;
+ if !is_flipped {
+ base2 += stride2;
+ }
}
}
if has_alpha {
let ls = buf.get_stride(3);
let mut idx = buf.get_offset(3);
let mut idx2 = idx + w;
+ if is_flipped {
+ idx += h * ls;
+ idx2 += h * ls;
+ }
for _ in 0..h {
+ if is_flipped {
+ idx -= ls;
+ idx2 -= ls;
+ }
let line = &dta[idx..idx2];
ofile.write_all(line).unwrap();
- idx += ls;
- idx2 += ls;
+ if !is_flipped {
+ idx += ls;
+ idx2 += ls;
+ }
}
}
}