@@ -54,21 +54,20 @@ std::size_t computeBufferSize(int width, int height, VideoBufferType type) {
5454 return w * h * 3 ;
5555
5656 case VideoBufferType::I420:
57- case VideoBufferType::NV12:
57+ // Y (1 byte) + U (1 byte) + V (1 byte)
58+ case VideoBufferType::NV12: {
59+ // Y (1 byte) + UV interleaved (2 bytes per chroma sample)
60+ const std::size_t chroma_w = (w + 1 ) / 2 ;
61+ const std::size_t chroma_h = (h + 1 ) / 2 ;
62+ return w * h + chroma_w * chroma_h * 2 ;
63+ }
64+
5865 case VideoBufferType::I010: {
59- // Y full, U and V subsampled 2x2
66+ // 16 bits per sample in memory
67+ // Y: 2 bytes per sample, U & V: 2 bytes per sample
6068 const std::size_t chroma_w = (w + 1 ) / 2 ;
6169 const std::size_t chroma_h = (h + 1 ) / 2 ;
62- if (type == VideoBufferType::I420) {
63- // Y (1 byte) + U (1 byte) + V (1 byte)
64- return w * h + chroma_w * chroma_h * 2 ;
65- } else if (type == VideoBufferType::NV12) {
66- // Y (1 byte), UV interleaved (2 bytes per chroma sample)
67- return w * h + chroma_w * chroma_h * 2 ;
68- } else { // I010, 16 bits per sample in memory
69- // Y: 2 bytes per sample, U & V: 2 bytes per sample
70- return w * h * 2 + chroma_w * chroma_h * 4 ;
71- }
70+ return w * h * 2 + chroma_w * chroma_h * 4 ;
7271 }
7372
7473 case VideoBufferType::I420A: {
0 commit comments