|
@@ -15,6 +15,7 @@ VideoRenderImpl::VideoRenderImpl(IRenderCallback* pCallback)
|
|
|
m_height = 0;
|
|
|
m_videoformat = VIDEO_FORMAT_RGB24;
|
|
|
m_flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR;
|
|
|
+ m_convertbuffer = NULL;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -34,6 +35,11 @@ VideoRenderImpl::~VideoRenderImpl()
|
|
|
SDL_DestroyWindow(m_sdl_window);
|
|
|
m_sdl_window = NULL;
|
|
|
}
|
|
|
+
|
|
|
+ if (NULL != m_convertbuffer){
|
|
|
+ delete []m_convertbuffer;
|
|
|
+ m_convertbuffer = NULL;
|
|
|
+ }
|
|
|
|
|
|
SDL_Quit();
|
|
|
}
|
|
@@ -63,6 +69,10 @@ int VideoRenderImpl::SetWindowProperty(videorender_param_t* tparam)
|
|
|
|
|
|
m_videoformat = tparam->ivideoformat;
|
|
|
|
|
|
+ if (VIDEO_FORMAT_RGB24 == m_videoformat){
|
|
|
+ m_convertbuffer = new unsigned char[m_videowidth* m_videoheight*4];
|
|
|
+ }
|
|
|
+
|
|
|
iRet = 0;
|
|
|
|
|
|
return iRet;
|
|
@@ -71,6 +81,7 @@ int VideoRenderImpl::SetWindowProperty(videorender_param_t* tparam)
|
|
|
SDL_PixelFormatEnum VideoRenderImpl::GetPixelFormat()
|
|
|
{
|
|
|
SDL_PixelFormatEnum eType = SDL_PIXELFORMAT_BGR24;
|
|
|
+ //SDL_PixelFormatEnum eType = SDL_PIXELFORMAT_BGR888;
|
|
|
if (VIDEO_FORMAT_I420 == m_videoformat){
|
|
|
eType = SDL_PIXELFORMAT_IYUV;
|
|
|
}
|
|
@@ -273,10 +284,14 @@ int VideoRenderImpl::RenderVideoFrame(video_frame* pframe)
|
|
|
//SDL_QueryTexture()
|
|
|
|
|
|
if (VIDEO_FORMAT_RGB24 == pframe->format){
|
|
|
+ //ConVert24to32(pframe->data[0], m_convertbuffer, pframe->width, pframe->height);
|
|
|
SDL_UpdateTexture(m_rending_texture, NULL, pframe->data[0], pframe->width*3);
|
|
|
+ SDL_Point point = {m_videowidth/2, m_videoheight/2};
|
|
|
+ SDL_RenderCopyEx(m_renderer, m_rending_texture, NULL, NULL, 0, &point, SDL_FLIP_VERTICAL);
|
|
|
}
|
|
|
else if(VIDEO_FORMAT_I420 == pframe->format){
|
|
|
SDL_UpdateTexture(m_rending_texture, NULL, pframe->data[0], pframe->width);
|
|
|
+ SDL_RenderCopy(m_renderer, m_rending_texture, NULL, NULL);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -285,11 +300,35 @@ int VideoRenderImpl::RenderVideoFrame(video_frame* pframe)
|
|
|
}
|
|
|
|
|
|
|
|
|
- SDL_RenderCopy(m_renderer, m_rending_texture, NULL, NULL);
|
|
|
+
|
|
|
|
|
|
SDL_RenderPresent(m_renderer);
|
|
|
|
|
|
iret = 0;
|
|
|
|
|
|
return iret;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void VideoRenderImpl::ConVert24to32(unsigned char* image_in, unsigned char* image_out, int w, int h)
|
|
|
+{
|
|
|
+ for (int i = 0; i < h; i++)
|
|
|
+ for (int j = 0; j < w; j++) {
|
|
|
+ //Big Endian or Small Endian?
|
|
|
+ //"ARGB" order:high bit -> low bit.
|
|
|
+ //ARGB Format Big Endian (low address save high MSB, here is A) in memory : A|R|G|B
|
|
|
+ //ARGB Format Little Endian (low address save low MSB, here is B) in memory : B|G|R|A
|
|
|
+ if (SDL_BYTEORDER == SDL_LIL_ENDIAN) {
|
|
|
+ //Little Endian (x86): R|G|B --> B|G|R|A
|
|
|
+ image_out[(i * w + j) * 4 + 0] = image_in[(i * w + j) * 3 + 2];
|
|
|
+ image_out[(i * w + j) * 4 + 1] = image_in[(i * w + j) * 3 + 1];
|
|
|
+ image_out[(i * w + j) * 4 + 2] = image_in[(i * w + j) * 3];
|
|
|
+ image_out[(i * w + j) * 4 + 3] = '0';
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //Big Endian: R|G|B --> A|R|G|B
|
|
|
+ image_out[(i * w + j) * 4] = '0';
|
|
|
+ memcpy(image_out + (i * w + j) * 4 + 1, image_in + (i * w + j) * 3, 3);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|