rivet-codec 0.2.0

GPU video decode/encode dispatch (NVDEC/NVENC, AMF, QSV) plus colorspace, tonemap, audio, and probe for the rivet transcoder. Imported as `codec`.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! `invert` (alias `negate`) — photo-negative the frame. 8-bit `Yuv420p` only.

use anyhow::Result;

use super::{assemble, planes_8bit};
use crate::frame::VideoFrame;

/// Negate every sample (`out = 255 − in`) on luma **and** chroma. Requires
/// 8-bit SDR output — `planes_8bit` errors on a 10-bit frame.
pub(super) fn apply(frame: &VideoFrame) -> Result<VideoFrame> {
    let (mut y, mut u, mut v) = planes_8bit(frame, "invert")?;
    for b in y.iter_mut().chain(u.iter_mut()).chain(v.iter_mut()) {
        *b = 255 - *b;
    }
    Ok(assemble(frame, frame.width, frame.height, y, u, v))
}