Skip to content

Commit 4916e35

Browse files
fixup! Implement a decoder
Consistent use of av_image_get_linesize
1 parent 3e6ec7e commit 4916e35

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/decoder.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,18 @@ impl FrameRef for DecodedFrame {
293293
assert!(i < sys::AV_NUM_DATA_POINTERS as usize);
294294

295295
// SAFETY: The pointer is valid while self is alive.
296-
unsafe { (*self.0).linesize[i] as usize }
296+
unsafe {
297+
assert_eq!(
298+
(*self.0).format,
299+
PixelFormat::AV_PIX_FMT_YUV420P as i32,
300+
"Only YUV420P is supported"
301+
);
302+
sys::av_image_get_linesize(
303+
PixelFormat::AV_PIX_FMT_YUV420P,
304+
self.width() as i32,
305+
i as i32,
306+
) as usize
307+
}
297308
}
298309
}
299310

0 commit comments

Comments
 (0)