<div dir="ltr"><font color="#cc0000"><font face="comic sans ms,sans-serif">Hello folks,<br><br>I am decoding a video with an PIX_FMT_YUV420P pixel format, and then saving it as a BMP file.<br><br>The decoding is successful and i have a raw YUV frame and then i convert it to PIX_FMT_RGB24:<br>
<br><span style="color:rgb(51,51,255)"><b>swsctx = sws_getCachedContext(swsctx,<br> codecctx->width,<br> codecctx->height,<br> codecctx->pix_fmt,<br>
codecctx->width,<br> codecctx->height,<br> PIX_FMT_RGB24,<br> SWS_BICUBIC,<br> NULL,<br>
NULL,<br> NULL);<br><br>sws_scale(swsctx, frame->data, frame->linesize, 0, codecctx->height,<br> framergb->data, framergb->linesize);</b></span><br>
<br><br>And finally i save it on disk with the appropriate BMP header and then the RGB24 frame.<br><br><span style="color:rgb(51,51,255)"><b>for (y = 0; y < codecctx->height; y++) {<br> fwrite(framergb->data[0] + y * framergb->linesize[0], 1, (codecctx->width * BYTESPERPIXEL), pFile);<br>
}</b></span><br><br>The strange thing is that the image, when opened (e.g. viewnior or gimp) is shown upside down. I started to<br>write on disk from the beginning of the buffer til the end.<br><br>If i do the opposite:<br>
<br><b><span style="color:rgb(51,51,255)">uint8_t *end = framergb->data[0] + (codecctx->height * framergb->linesize[0]);<br> <br>for (y = 0; y < codecctx->height; y++) {<br> fwrite(end - (y * framergb->linesize[0]), 1, (codecctx->width * BYTESPERPIXEL), pFile);<br>
}</span><br></b><br>The BMP image is shown correctly. I really don't know if i made some mistake in this proccess,<br>or this is the way the ffmpeg library actually works. relevant infos:<br><br>ffmpeg 0.10.4 <br>Linux (Fedora 17)<br>
gcc 4.7.0 20120507<br><br><br>Thanks in advance.<br><br><br>Regards,<br>Rafael.<br><br clear="all"></font></font><div dir="ltr"><br><br><b style="color:rgb(204,0,0);font-family:comic sans ms,sans-serif">"<span>If you can't explain it simply, you don't understand it well enough.</span>"<br>
--Albert Einstein</b><br></div><br>
</div>