From: Kostya Shishkov Date: Tue, 22 Jan 2019 15:26:53 +0000 (+0100) Subject: use chromaton offsets when writing paletted image X-Git-Url: https://git.nihav.org/?p=nihav.git;a=commitdiff_plain;h=ccc30e3991dfb6905347b6276ada399667513037 use chromaton offsets when writing paletted image --- diff --git a/nihav-core/src/test/dec_video.rs b/nihav-core/src/test/dec_video.rs index 01cc42b..21c3f1a 100644 --- a/nihav-core/src/test/dec_video.rs +++ b/nihav-core/src/test/dec_video.rs @@ -77,6 +77,11 @@ fn write_palppm(pfx: &str, strno: usize, num: u64, frmref: NAFrameRef) { ofile.write_all(hdr.as_bytes()).unwrap(); let dta = buf.get_data(); let ls = buf.get_stride(0); + let offs: [usize; 3] = [ + buf.get_info().get_format().get_chromaton(0).unwrap().get_offset() as usize, + buf.get_info().get_format().get_chromaton(1).unwrap().get_offset() as usize, + buf.get_info().get_format().get_chromaton(2).unwrap().get_offset() as usize + ]; let mut idx = 0; let mut line: Vec = Vec::with_capacity(w * 3); line.resize(w * 3, 0); @@ -84,9 +89,9 @@ fn write_palppm(pfx: &str, strno: usize, num: u64, frmref: NAFrameRef) { let src = &dta[idx..(idx+w)]; for x in 0..w { let pix = src[x] as usize; - line[x * 3 + 0] = dta[paloff + pix * 3 + 2]; - line[x * 3 + 1] = dta[paloff + pix * 3 + 1]; - line[x * 3 + 2] = dta[paloff + pix * 3 + 0]; + line[x * 3 + 0] = dta[paloff + pix * 3 + offs[0]]; + line[x * 3 + 1] = dta[paloff + pix * 3 + offs[1]]; + line[x * 3 + 2] = dta[paloff + pix * 3 + offs[2]]; } ofile.write_all(line.as_slice()).unwrap(); idx += ls;