[Libav-user] 971221 - ffmpeg incorrect decoding

hamidi hamidi at gmail.com
Tue Mar 12 18:21:06 EET 2019

I found that it was my mistake. I made the bitmap from the original YUV420P
decoded frame. Maybe Bitmap constructor tiles the image when it sees that
the data belongs to a bitmap with less width, because when I changed the
bitmap size, I saw no distortion in the made bitmap. Anyway, now I changed
the line:

var _frameBitmap = new Bitmap(1280, 720, _pDecodedFrame->linesize[0],
PixelFormat.Format32bppPArgb, new IntPtr(_pDecodedFrame->data_0));


var convertToPixFmt = AVPixelFormat.PIX_FMT_RGBA;
SwsContext* _pConvertContext = FFmpegInvoke.sws_getContext(1280, 720, 0,
1280, 720, convertToPixFmt,
FFmpegInvoke.SWS_FAST_BILINEAR, null, null, null);
AVFrame* _pConvertedFrame = FFmpegInvoke.av_frame_alloc();
int convertedFrameAspectBufferSize =
FFmpegInvoke.avpicture_get_size(convertToPixFmt, 1280, 720);
byte* _pConvertedFrameBuffer =
_pConvertedFrameBuffer, convertToPixFmt, 1280, 720);
var _frameBitmap = new Bitmap(1280, 720, _pConvertedFrame->linesize[0],
PixelFormat.Format32bppPArgb, new IntPtr(_pConvertedFrame->data_0));

and now the Bitmap is made properly.
The next step is that how can I make all of these be done by the graphics
card? I can decode the original H264 video by hardware based on what we may
find in hw_decode.c, but the other problems like rendering the video on
screen and omitting the decoded video move to physical memory for scaling
and changing its format to RGB is my other problems.
Can you rewrite the above code so that no CPU gets involved and no move or
copy in physical memory be necessary?

On Tue, Mar 12, 2019 at 3:11 PM hamidi <hamidi at gmail.com> wrote:

> With this code <https://pastebin.com/hpFUjRtG> I get this image
> <https://imgur.com/a/uWmBzQE>. What's wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190312/79066c28/attachment.html>

More information about the Libav-user mailing list