NV12 pixel format conversion to RGB24 issue
I use gpu decoding from ffmpeg. The AVFrames I get I have to converted to rgb24 (Bitmap). When I use sw_scale (nv12->bgr24) all colors are ok, but the left border show the following disterbunce.
Is this issue familiar to anyone? Anything for suggestion?
When I use custom conversion taken from project "PixelFormatConverter"
I get the following result (border distortion, and color misalignment):
Is these issues familiar to anyone? Anything for suggestion?
After the conversion I create the bitmap and display it. For Bitmap creation I use the following:
frame is AVFrame (NV12) taken from FFMPEG
int image_size = av_image_get_buffer_size(AV_PIX_FMT_BGR24, frame->width, frame->height, 32);
size_t sizeof_file_header = sizeof(BITMAPFILEHEADER);
size_t sizeof_info_header = sizeof(BITMAPINFOHEADER);
bmpheader.bfType = 0x4d42;
bmpheader.bfReserved1 = 0;
bmpheader.bfReserved2 = 0;
bmpheader.bfOffBits = sizeof_file_header + sizeof_info_header;
bmpheader.bfSize = bmpheader.bfOffBits + image_size;
bmpinfo.biSize = sizeof_info_header;
bmpinfo.biWidth = frame->width;
bmpinfo.biHeight = frame->height;
bmpinfo.biPlanes = 1;
bmpinfo.biBitCount = 24;
bmpinfo.biCompression = BI_RGB;
bmpinfo.biSizeImage = 0;
bmpinfo.biXPelsPerMeter = 0;
bmpinfo.biYPelsPerMeter = 0;
bmpinfo.biClrUsed = 0;
bmpinfo.biClrImportant = 0;
uint8_t* buffer = new uint8_t[bmpheader.bfSize];
memcpy(buffer, &bmpheader, sizeof_file_header);
memcpy(buffer + sizeof_file_header, &bmpinfo, sizeof_info_header);
NV12_TO_BGR24(frame->data[0], (buffer + (bmpheader.bfOffBits)), frame->width, frame->height);
Can anyone spot the issue?