<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mar. 9 avr. 2019 à 17:44, Simon Brown <<a href="mailto:simon.k.brown@gmail.com">simon.k.brown@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div><br>Thanks,</div><div>If I understand what you said, I have to proccess like this :</div><div><br></div><div>//Declaration of yuv arrays</div><div>uint16_t yval[mb_height * mb_width][256]; </div><div>uint16_t uval[mb_height * mb_width][256];</div><div>uint16_t vval[mb_height * mb_width][256]; <br></div><div><br></div><div>for(int mby=0;  mby<mb_height; mby++)</div><div>{</div><div>         for(int mbx=0; mbx <mb_width ;mbx++)</div><div>         {</div><div>             //Now for this 16x16 macroblock</div><div>            for(int y=0; y<16;y++)</div><div>            {</div><div>               for(int x=0; x<16;x++)</div><div>               {</div><div>                 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]???</div><div>                 uval[mby*mb_width + mbx][(y/2)*16+x/2] = data[1][linesize[1]*(y/2)*16+x/2];</div><div>                 uval[mby*mb_width + mbx][(y/2)*16+x/2] = data[2][linesize[2]*(y/2)*16+x/2];</div><div>               //Setting of Yuv arrays</div><div>           </div><div>             }</div><div>}</div><div>//Let's go to  an other macroblock</div><div>}</div><div>} </div><div><br></div><div>Regards</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br></blockquote></div></div></blockquote><div>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:</div><div>yval[mby*mb_width + mbx][y*16+x] = data[0][ linesize[0]*(mby*16 + y) + (mbx*16 + x) ]</div><div>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".</div><div><br></div><div>I hope that makes sense.</div><div><br></div><div>Regards,</div><div>Simon</div></div></div></blockquote><div><br></div><div>Hello Simon,</div><div><br></div><div>Not quite.Excuse me if I ask you the same question but it is because I'm new in ffmpeg and color format manipulation.</div><div>In my above code. mbx and mby are not (x, y) coordinate for the macroblock but only integers used to run through the "for" loop. It is also the case for x and y. mb_width is the number of macroblock</div><div>horizontally and mb_height is the number of macroblock vertically in the frame.</div><div>Now let's suppose I want to have yuv value for only one 16X16  macroblock located at (MBx, MBy) in the frame . Where MBx and MBy are the coordinate of this macroblock in the frame.</div><div>Can I obtain yuv value for this macroblock like this :</div><div><br></div><div><div>for(int y=0; y<16;y++) // run through the heigh of the 16X16 macroblock</div><div>            {</div><div>               for(int x=0; x<16;x++)  // run through the width of the 16X16 macroblock</div><div>               {</div></div><div>                        y+=data[0][ linesize[0]*(MBy*16 + y) + (MBx*16 + x) ]; //sum of all y pixel's value of the macroblock </div><div>                       // for u and v I must do only x/2 and y/2 or (MBx*16 + x)/2 and (MBy*16 + y)/2)</div><div>                        u+=data[1][ linesize[1]*(MBy*16 + y/2) + (MBx*16 + x/2) ]  or  u+=data[1][ linesize[1]*((MBy*16 + y)/2) + (MBx*16 + x)/2 ]     //sum of all y pixel's value of the macroblock </div><div>                        v+=data[2][ linesize[2]*(MBy*16 + y/2) + (MBx*16 + x/2) ]   or  v+=data[2][ linesize[2]*((MBy*16 + y)/2) + (MBx*16 + x)/2 ]     //sum of all y pixel's value of the macroblock </div><div><br></div><div>               }</div><div>}</div><div><br></div><div>Apologize me if I asked you what you already said. </div><div><br></div><div>Regards</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".</blockquote></div></div>