SDL2 Source Analysis 8: Video Display summary

Source: Internet
Author: User

=====================================================

SDL Source Analysis Series Articles list:

SDL2 Source Analysis 1: Initialization (Sdl_init ())

SDL2 Source Analysis 2: Form (Sdl_window)

SDL2 Source Analysis 3: Renderer (Sdl_renderer)

SDL2 Source Analysis 4: Textures (sdl_texture)

SDL2 Source Analysis 5: Update textures (sdl_updatetexture ())

SDL2 Source Analysis 6: Copy to Renderer (Sdl_rendercopy ())

SDL2 Source Analysis 7: Display (Sdl_renderpresent ())

SDL2 Source Analysis 8: Video Display summary

=====================================================


This article briefly summarizes the source code of the SDL display video.

The structure of SDL display video SDL display video involves the following structures:
Sdl_window: Represents the form
Sdl_renderer: Represents the Renderer
Sdl_texture: Represents the texture
Sdl_rect: a rectangular box. Used to determine the location of the texture display.
The relationships between the above several structures are, for example, seen.

PS: This image is derived from the article "simplest FFMPEG+SDL-based video player Ver2 (SDL2.0)"


Visible from the diagram. Yuv/rgb pixel data is first loaded into sdl_texture and then rendered to Sdl_window through Sdl_render. The sdl_rect can specify the location of the display.

SDL shows the process of video

SDL shows the process of video for example as seen in.


Clearer picture links (right-click to save): http://my.csdn.net/leixiaohua1020/album/detail/1795751 can see. The overall process can be summarized as the following steps:
1.Initialization: Sdl_init ()
2.Create Sdl_window:sdl_createwindow ()
3.Create Sdl_render:sdl_createrenderer ()
4.Create Sdl_texture:sdl_createtexture ()
5.Update Sdl_texture:sdl_updatetexture ()
6.Render Sdl_texture:sdl_rendercopy ()
7.Display: Sdl_renderpresent ()
8.Return to step 4 to continue running
The call flow for the API when the SDL plays the video is shown in.

The following summarizes the invocation relationships between these SDL APIs and the system's underlying API under different systems and rendering techniques.

SDL-WINDOWS-DIRECT3DSDL in Windows systems, the function call relationships that use Direct3D to render video, for example, are seen.

PS: The white background function is the SDL API; The blue background function is the Win32 API. The purple background of the function Direct3D API.


Clearer picture link (right-click): http://my.csdn.net/leixiaohua1020/album/detail/1795753

It can be seen that SDL uses Direct3D to render video under Windows. The call relationships between functions are listed as follows:
Sdl_createwindow () invokes an API such as the following Win32:
CreateWindow ()
SetWindowText ()
ShowWindow ()
SetWindowPos ()

Sdl_createrenderer () invokes an API such as the following direc3d:
Direct3dcreate9 ()
Idirect3d9_getdevicecaps ()
Idirect3d9_createdevice ()
IDIRECT3DDEVICE9_SETFVF ()
Idirect3ddevice9_setrenderstate ()
Idirect3ddevice9_settexturestagestate ()
Idirect3ddevice9_settransform ()
Idirect3ddevice9_createpixelshader ()

Sdl_createtexture () invokes an API such as the following direc3d:
idirect3ddevice9_createtexture ()

Sdl_updatetexture () invokes an API such as the following direc3d:
Idirect3dtexture9_lockrect ()
memcpy (): This is not D3D. Used to copy pixel data.
Idirect3dtexture9_unlockrect ()

Sdl_rendercopy () invokes an API such as the following direc3d:
Idirect3ddevice9_beginscene ()
Idirect3ddevice9_setrenderstate ()
Idirect3ddevice9_setsamplerstate ()
Idirect3ddevice9_settexture ()
Idirect3ddevice9_setpixelshader ()
Idirect3ddevice9_drawprimitiveup ()

Sdl_renderpresent () invokes an API such as the following direc3d:
Idirect3ddevice9_endscene ()
Idirect3ddevice9_present ()

SDL-WINDOWS-OPENGLSDL in the Windows system, use OpenGL to render the video when the function calls the relationship for example as seen.


PS: The white background function is the SDL API, the blue background function is the Win32 API, and the purple background function OpenGL API.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbgvpeglhb2h1ytewmja=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/southeast "/>

Clearer picture link (right-click): http://my.csdn.net/leixiaohua1020/album/detail/1795755


Can see the time when SDL renders video using OpenGL under Windows. The call relationships between functions are listed as follows:
Sdl_createwindow () invokes an API such as the following Win32:
CreateWindow ()
SetWindowText ()
ShowWindow ()
SetWindowPos ()

Sdl_createrenderer () invokes an API such as the following OpenGL:
Glcreateprogramobject ()
Glcreateshaderobject ()
Glshadersource ()
Glcompileshader ()
Getobjectparameteriv ()
Attachobject ()
Linkprogram ()
Useprogramobject ()

Sdl_createtexture () invokes an API such as the following OpenGL:
Glgentextures ()
Glbindtexture ()
Gltexparameteri ()
Glteximage2d ()

Sdl_updatetexture () invokes an API such as the following OpenGL:
Glbindtexture ()
Gltexsubimage2d ()

Sdl_rendercopy () invokes an API such as the following OpenGL:
Glactivetexture ()
Glbindtexture ()

Sdl_renderpresent () invokes an API such as the following OpenGL:
swapbuffers ()


SDL-WINDOWS-SOFTWARESDL in Windows systems, the function call relationships that use software to render video, for example, are seen.


PS1: The white background function is the SDL API, and the blue background function is the Win32 API.
Ps2:software rendering is not yet thoroughly analyzed.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbgvpeglhb2h1ytewmja=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/southeast "/> clearer picture link (right-click): Http://my.csdn.net/leixiaohua1020/album/detail /1795757

It can be seen that SDL uses software to render video under Windows. The call relationships between functions are listed as follows:
Sdl_createwindow () invokes an API such as the following Win32:

CreateWindow ()
SetWindowText ()
ShowWindow ()
SetWindowPos ()

Sdl_createrenderer () invokes an API such as the following Win32:
CreateCompatibleBitmap ()
GetDIBits ()
CreateCompatibleDC ()
CreateDIBSection ()
SelectObject ()

Sdl_updatetexture () calls memcpy () to populate the pixel data.

Sdl_renderpresent () invokes an API such as the following Win32:
BitBlt ()

SDL2 Source Analysis 8: Video Display summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.