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

Boris ndjoreboris at gmail.com
Wed Apr 10 13:21:06 EEST 2019


Le mer. 10 avr. 2019 à 12:16, Paul B Mahol <onemda at gmail.com> a écrit :

> On 4/10/19, Boris <ndjoreboris at gmail.com> wrote:
> > Le mer. 10 avr. 2019 à 11:57, Paul B Mahol <onemda at gmail.com> a écrit :
> >
> >> On 4/10/19, Boris <ndjoreboris at gmail.com> wrote:
> >> > Le mar. 9 avr. 2019 à 17:44, Simon Brown <simon.k.brown at gmail.com> a
> >> écrit
> >> > :
> >> >
> >> >>
> >> >>> 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
> >> >>>
> >> >>>>
> >> >>>> Not quite - the data in data[0] is arranged by pixels, so your
> >> >> coordinate into that array must include all the pixels, not just the
> >> >> current macroblock.  So you need:
> >> >> yval[mby*mb_width + mbx][y*16+x] = data[0][ linesize[0]*(mby*16 + y)
> +
> >> >> (mbx*16 + x) ]
> >> >> so you skip all lines up to the one you're processing, including all
> >> >> previous macroblocks and all lines already processed in the current
> >> >> macroblock using "linesize[0]*(mby*16 + y)" and then all the pixels
> in
> >> >> the
> >> >> current line up to the macroblock you're interested in, and any
> pixels
> >> >> already processed in that macroblock with "mbx*16 + x".
> >> >>
> >> >> I hope that makes sense.
> >> >>
> >> >> Regards,
> >> >> Simon
> >> >>
> >> >
> >> > Hello Simon,
> >> >
> >> > I do like you tell me but data[0][ linesize[0]*(mby*16 + y) + (mbx*16
> +
> >> x)
> >> > ] gives me some negatives pixel's values.
> >> > Is it normal ?
> >> > For exemple data[0][ linesize[0]*(mby*16 + y) + (mbx*16 + x) ] =
> >> >  -62
> >> > -65
> >> > -72
> >> > My question is to know if it is normal to have negatives pixel's value
> >> > (
> >> y
> >> > = -a; u=-b; v=-c) where a, b and c are integers.
> >>
> >> Doesn't make sense, post full code.
> >>
> >
> > Hello Paul,
> > The code is the following :
> > mbx and mby are x,y coordinate (position) of the macroblock in the frame
> ,
> > data is AVFrame frame->data and linesize is AVFrame frame->linesize
> > Then :
> >  for(int y=0; y<16;y++) //run through the length of the 16x16 macroblock
> >             {
> >                for(int x=0; x<16;x++) ////run through the width of the
> > 16x16 macroblock
> >                 {
> >  cout<<data[0][ linesize[0]*(mby*16 + y) + (mbx*16 + x) ] <<endl;
> >
> > }
> > }
> >
> > So I still getting some negatives values. My question is to know if it's
> > normal.
>
> It is not normal. Make sure you are not reading past end of data[0].
>

Ok Thanks,
But can you tell me if the above formula is correct, please?
To remember you it's based one the x,y position  (mbx, mby) of the
macroblock in the frame and the size 16x16 of the 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/20190410/e5d47f3d/attachment.html>


More information about the Libav-user mailing list