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)); to: 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 = (byte*)FFmpegInvoke.av_malloc((uint)convertedFrameAspectBufferSize); FFmpegInvoke.avpicture_fill((AVPicture*)_pConvertedFrame, _pConvertedFrameBuffer, convertToPixFmt, 1280, 720); FFmpegInvoke.sws_scale( _pConvertContext, &_pDecodedFrame->data_0, _pDecodedFrame->linesize, 0, _pDecodedFrame->height, &_pConvertedFrame->data_0, _pConvertedFrame->linesize); 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 <[email protected]> wrote: > With this code <https://pastebin.com/hpFUjRtG> I get this image > <https://imgur.com/a/uWmBzQE>. What's wrong? >
_______________________________________________ Libav-user mailing list [email protected] https://ffmpeg.org/mailman/listinfo/libav-user To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
