Finished explantion comments
This commit is contained in:
parent
7d905adf10
commit
0f3c3453ac
22
src/out.rs
22
src/out.rs
@ -46,25 +46,27 @@ pub fn print_square(frame: &ffmpeg::frame::Video, lines_format: LinesFormat, vid
|
|||||||
let mut stdout = stdout();
|
let mut stdout = stdout();
|
||||||
let mut lock = stdout.lock();
|
let mut lock = stdout.lock();
|
||||||
|
|
||||||
// Entire frame, as rgb data
|
// EXPLANATION: (12x12 image)
|
||||||
let buf = frame.data(video_index);
|
|
||||||
|
|
||||||
// How many bytes per line
|
|
||||||
let step = buf.len() / frame.height() as usize;
|
|
||||||
|
|
||||||
// Explanation?: (12x12 image:)
|
|
||||||
// The full buffer will be 1152 bytes.
|
// The full buffer will be 1152 bytes.
|
||||||
|
//
|
||||||
// 1152/12=96 Buffer length / Pixels high = 96 Bytes per line.
|
// 1152/12=96 Buffer length / Pixels high = 96 Bytes per line.
|
||||||
// 96/12=8 Bytes per line / Pixels per line = 8 Bytes per pixel.
|
// 96/12=8 Bytes per line / Pixels per line = 8 Bytes per pixel.
|
||||||
//
|
//
|
||||||
// But RGB24 should only use 3 bytes per pixel.
|
// But RGB24 should only use 3 bytes per pixel. The other 5 we just discard.
|
||||||
// The other 5 we just discard.
|
// They might be alpha, or grayscale overlay, I'm not really sure.
|
||||||
//
|
//
|
||||||
|
// 8-5=3 Bytes per pixel - Discarded bytes = Used bytes
|
||||||
|
// 3*12=36 Used bytes * Pixels per line = Slice length
|
||||||
|
//
|
||||||
|
// This is because all the extra data (the 5 extra bytes) are at the end
|
||||||
|
// of each line. So we just take the first (Pixel width)*3 bytes.
|
||||||
|
|
||||||
|
let buf = frame.data(video_index);
|
||||||
|
let step = buf.len() / frame.height() as usize;
|
||||||
|
|
||||||
// (Assuming square) Step thru buffer.
|
// (Assuming square) Step thru buffer.
|
||||||
for i in 0..pixels_wide {
|
for i in 0..pixels_wide {
|
||||||
let j = i*step;
|
let j = i*step;
|
||||||
// Only take the size*3 of bytes, ignoring alpha(?) values which are stored after.
|
|
||||||
// Have to take ownership, by implicilty Cloning the data. (Copying?)
|
// Have to take ownership, by implicilty Cloning the data. (Copying?)
|
||||||
let mut slice = Vec::from(&buf[j..j+pixels_wide*3]);
|
let mut slice = Vec::from(&buf[j..j+pixels_wide*3]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user