# NvBufSurface attributes don't add up

**URL:** <https://forums.developer.nvidia.com/t/nvbufsurface-attributes-dont-add-up/186675>\
**Category:** Jetson Nano\
**Tags:** camera\
**Created:** [August 16, 2021, 1:00pm UTC](https://forums.developer.nvidia.com/t/nvbufsurface-attributes-dont-add-up/186675 "2021-08-16T13:00:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![elhe](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@elhe](https://forums.developer.nvidia.com/u/elhe)\
**Post date:** [August 16, 2021, 1:00pm UTC](https://forums.developer.nvidia.com/t/nvbufsurface-attributes-dont-add-up/186675/1 "2021-08-16T13:00:16Z")

</div>

I am reading the buffer of a frame of a nvarguscamerasrc into an NvBufSurface in order to work with it, but I cannot explain some of the values that are set in the object attributes.  
The are the attributes I read from the object

```auto
Batch Size: 1
Num Filled: 1
Is contiguous: 0
Mem type: 4
Buffer descriptor 1063
Width: 3264, Height: 2464
Data size: 12451840
Color format: 6 (NV12)
Number of planes: 2
Width plane 0: 3264, Height plane 0: 2464
Width plane 1: 1632, Height plane 1: 1232
Byte per pixel plane 0: 1, Byte per pixel plane 1: 2
pitch plane 0: 3328 bytes, pitch plane 1 : 3328 bytes
offset plane 0 (Y): 0 bytes, offset plane 1 (UV): 8257536 bytes
size plane 0 (Y): 8257536, size plane 1 (UV): 4194304

```

How is the size of the planes calculated?  
For plane 0 (Y) with one byte per pixel I would have calculated it with:

```auto
size = Width * pitch + Height = 3264 * 3328 + 2464 = 10865056

```

Which is neither the size of plane 0 nor the total size.

Where does the pitch come into play?  
How is total size and plane size calculated?

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [August 17, 2021, 6:48am UTC](https://forums.developer.nvidia.com/t/nvbufsurface-attributes-dont-add-up/186675/3 "2021-08-17T06:48:36Z")

</div>

Hi,  
There is constraint in data alignment. Please refer to this post:  
[Memory for NvMap - #10 by DaneLLL](https://forums.developer.nvidia.com/t/memory-for-nvmap/178239/10)

---

<div class="post-metadata">

**Author:** ![elhe](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@elhe](https://forums.developer.nvidia.com/u/elhe)\
**Post date:** [August 17, 2021, 11:25am UTC](https://forums.developer.nvidia.com/t/nvbufsurface-attributes-dont-add-up/186675/4 "2021-08-17T11:25:13Z")

</div>

Hi,  
Yes I understand that the DMA memory buffer is constrained in that regard. The size of my plane 0 is 8257536 bytes and with a pitch of every row of 3328 bytes I would expect to be the size of plane 0 to be

```auto
pitch * number_of_columns = 3328*2464 = 8200192 bytes

```

But it isn’t. Where are the extra bytes coming from? If I wanted to iterate over every byte of my buffer, how would I do that?

---

<div class="post-metadata">

**Author:** ![ShaneCCC](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/shaneccc/32/14043_2.png) [@ShaneCCC](https://forums.developer.nvidia.com/u/ShaneCCC)\
**Post date:** [August 17, 2021, 6:10pm UTC](https://forums.developer.nvidia.com/t/nvbufsurface-attributes-dont-add-up/186675/5 "2021-08-17T18:10:13Z")

</div>

@elhe  
Each plane aligns to 128K(131072 bytes)  
8200192/131072=62.5625  
63\*131072=8257536

---

<div class="post-metadata">

**Author:** ![elhe](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@elhe](https://forums.developer.nvidia.com/u/elhe)\
**Post date:** [August 18, 2021, 4:47am UTC](https://forums.developer.nvidia.com/t/nvbufsurface-attributes-dont-add-up/186675/6 "2021-08-18T04:47:35Z")

</div>

Ah very good thanks.

---

<div class="post-metadata">

**Author:** ![nadeemm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nadeemm/32/367020_2.png) [@nadeemm](https://forums.developer.nvidia.com/u/nadeemm)\
**Post date:** [October 15, 2021, 3:20am UTC](https://forums.developer.nvidia.com/t/nvbufsurface-attributes-dont-add-up/186675/8 "2021-10-15T03:20:10Z")

</div>

Closed on October 15, 2021, 3:20am UTC


