[Libav-user] Help : YUV value for a macroblock in a yuv240p frame

Boris ndjoreboris at gmail.com
Tue Apr 9 18:03:56 EEST 2019

```Le mar. 9 avr. 2019 à 15:54, Simon Brown <simon.k.brown at gmail.com> a écrit :

>
> On Tue, 9 Apr 2019 at 14:43, NDJORE BORIS <ndjoreboris at gmail.com> wrote:
>
>>
>> Thank you simon.
>>
>> You probably right. The first loop is to obten all macroblock in the
>> frame and the second is to optain each pixel in the macroblock, I thinked.
>> But in what you gave if I do this for two different block, I think that I
>> will obtain the same value for "y".
>> Can you explain me  how can I do to obtain different "y" value for each
>> macroblock if I'm wrong , please?
>>
>> Regards
>>
>>>
>>> So the first loop needs to be:
> for (int mby=0 ; mby< mb_height ; mby++) {
>
> and similarly for mbx.
> Then you can declare outside of the loop an array for yval, uval and vval
> (I notice now that you also use variable y for the y pixel value, rather
> than just the inner loop counter!):
> uint16_t yval[mb_height * mb_width][256];
> and then set:
> yval[mby*mb_width + mbx][y*16+x] = data[0][.....];
> etc.
> Then yval[0] would have an array of 256 values for Y for the first
> macroblock, and yval[1] would have 256 values for Y for the second
> macroblock.
> If you want an average Y, U and V value then you can always sum inside the
> loop and divide by 256, and then just store one value for yval[0] rather
> than 256.
>
> Regards,
> Simon
>

Thanks,
If I understand what you said, I have to proccess like this :

//Declaration of yuv arrays
uint16_t yval[mb_height * mb_width][256];
uint16_t uval[mb_height * mb_width][256];
uint16_t vval[mb_height * mb_width][256];

for(int mby=0;  mby<mb_height; mby++)
{
for(int mbx=0; mbx <mb_width ;mbx++)
{
//Now for this 16x16 macroblock
for(int y=0; y<16;y++)
{
for(int x=0; x<16;x++)
{
yval[mby*mb_width + mbx][y*16+x] =
data[0][linesize[0]*y*16+x]; or yval[mby*mb_width + mbx][y*16+x] =
data[0][y*16+x]???
uval[mby*mb_width + mbx][(y/2)*16+x/2] =
data[1][linesize[1]*(y/2)*16+x/2];
uval[mby*mb_width + mbx][(y/2)*16+x/2] =
data[2][linesize[2]*(y/2)*16+x/2];
//Setting of Yuv arrays

}
}
//Let's go to  an other macroblock
}
}

Regards

> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190409/72e8a9b7/attachment.html>
```

More information about the Libav-user mailing list