CN116400998A - Video hardware acceleration device and method suitable for virtual display card - Google Patents

Video hardware acceleration device and method suitable for virtual display card Download PDF

Info

Publication number
CN116400998A
CN116400998A CN202211100537.6A CN202211100537A CN116400998A CN 116400998 A CN116400998 A CN 116400998A CN 202211100537 A CN202211100537 A CN 202211100537A CN 116400998 A CN116400998 A CN 116400998A
Authority
CN
China
Prior art keywords
video
virtual
display card
card
gpu
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211100537.6A
Other languages
Chinese (zh)
Inventor
江锋
谢明
孙立明
张铎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kirin Software Co Ltd
Original Assignee
Kirin Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kirin Software Co Ltd filed Critical Kirin Software Co Ltd
Priority to CN202211100537.6A priority Critical patent/CN116400998A/en
Publication of CN116400998A publication Critical patent/CN116400998A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
    • H04N21/2343Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
    • H04N21/234309Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4 or from Quicktime to Realvideo
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • G06F9/5077Logical partitioning of resources; Management or configuration of virtualized resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/20Processor architectures; Processor configuration, e.g. pipelining
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • H04N21/440218Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45562Creating, deleting, cloning virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

The invention relates to a video hardware acceleration device and a method suitable for a virtual display card, wherein the device comprises a virtual display card video driver, a video processing module of the virtual display card, a virtual display card video protocol and a virtual display card video service program, and the virtual display card is a virtual graphics processing unit (Virtio GPU); the method uses the accelerating device to forward the video processing request of the virtual machine to the physical display card of the host machine side, and uses the video processing module in the physical display card to encode and decode the video of the hardware. The invention realizes the video hardware acceleration function of the virtual display card, can support hardware decoding, encoding, processing and the like of the video, and obviously reduces the occupation of CPU resources while improving the video processing performance of the virtual machine.

Description

Video hardware acceleration device and method suitable for virtual display card
Technical Field
The patent application belongs to the technical field of virtualization, and particularly relates to a video hardware acceleration device and method suitable for a virtual display card.
Background
Currently, in the virtualization technology, the technical solutions for displaying the virtualization aspect mainly include two main categories:
a hardware virtualization scheme represented by the technology such as an English-Weida GRID vGPU divides a physical display card into a plurality of virtual display cards from a hardware level, and then distributes the virtual display cards to a virtual machine in a transparent transmission mode. The method is mainly realized based on hardware, so that the method has excellent performance, is often applied to professional scenes such as deep learning, scientific calculation and the like, but also has the problems of high cost, need of authorization, inflexibility of division and the like.
The other is a software virtualization scheme represented by a virtual display card such as QXL and Virtio GPU, and the scheme simulates display card equipment through software, so that the method has low cost, good compatibility and easy deployment, and is widely used in cloud desktop, remote office and other scenes.
The virtual display card has a very remarkable disadvantage although the application is wide. For the QXL, the pure software simulation virtual display card completely depends on a CPU to perform image rendering and video processing, so that the performance is quite low. Compared with QXL, the Virtio GPU supports 3D hardware acceleration, and can forward a graphics rendering request of a virtual machine to a physical display card of a host side for processing, so that the graphics performance of the virtual machine is greatly enhanced, but in the aspect of video processing, the Virtio GPU is still the same as the QXL, and a software coding and decoding mode is adopted, so that the video processing performance is still seriously insufficient, and a large amount of CPU resources are consumed.
The disadvantages of the prior art are:
chinese patent invention 'a hardware decoding method, decoding device and storage medium based on virtualization' (patent number: CN 107911700B). The invention discloses a hardware decoding method, decoding equipment and a storage medium based on virtualization. The method comprises the steps of obtaining video data to be decoded in a first operating system, wherein the first operating system is an operating system of a virtual machine, intercepting the video data to be decoded in the first operating system through a preset hook program, sending the video data to be decoded to a second operating system, and decoding the video data to be decoded in the second operating system to obtain corresponding decoded video data, wherein the second operating system is an operating system of a host machine. According to the method and the device, the video data to be decoded in the first operating system is forwarded to the second operating system to call the GPU to decode, so that the problem of overlarge CPU load caused by decoding through the CPU is solved, and the technical problem of overlarge operation load of physical equipment in video decoding of the virtual machine in the prior art is solved. However, this invention also has significant disadvantages: (1) The invention only supports the hardware decoding function, but does not support the functions of hardware coding, video processing and the like; (2) Because the invention adopts the API hijacking technology based on the hook program, only a specific decoding API can be supported at the same time, and other APIs can not be supported. In specific implementation, the hijacked API is DXVA (DirectX Video Acceleration) interface of Microsoft corporation, so it is only suitable for Windows operating system; (3) After the version of the hijacked API is updated, the method needs synchronous modification and re-adaptation, and compatibility problems are easy to generate.
At present, part of virtual graphics cards (such as a virtual graphics processing unit (Virtio) GPU) already support a 3D hardware acceleration function, and can transfer a graphics rendering request of a virtual machine to a physical graphics card on a host machine (i.e. a physical machine) side for processing, so that the graphics performance of the virtual machine is greatly improved, and user experience in scenes such as games, 3D drawing and modeling is remarkably improved.
Although virtual graphics cards have greatly improved graphics rendering, there are still significant shortboards in video processing. Because the virtual video card has no video hardware acceleration function, a user can only use the CPU to decode or encode the software when playing the high-definition video by using the media player or editing the video by using the video editing software. This obviously results in performance inefficiency and consumes significant CPU resources, which in turn affects the proper operation of other applications and even the operating system. Through testing, under the spread-spectrum 920 processor and the AMD Radeon RX550 display card, when the MPV player is used for playing 4K/60fps H.264 video in the virtual machine (matched with the Virtio GPU display card), the CPU occupancy rate of the player can reach about 321%, and the use experience of a user is greatly influenced.
On the other hand, the mainstream physical display card at present generally includes a graphics rendering module, and a video processing module is usually built in the physical display card, which is specially used for hardware encoding and decoding of video. At present, the virtual display card still adopts a software coding and decoding mode, and the powerful calculation power of the host side physical display card is also idle while a large amount of CPU resources are consumed.
In summary, it is highly desirable to provide a video hardware acceleration mechanism, which adds a video hardware acceleration function to a virtual video card, so that the virtual video card can utilize a physical video card of a host side to perform hardware encoding and decoding of video, thereby improving video processing performance of the virtual machine, reducing occupation of CPU resources, and improving user experience.
Disclosure of Invention
Aiming at the technical problems, the invention creates a new video hardware acceleration device and method suitable for the virtual display card, can realize the video hardware acceleration function of the virtual display card, improves the video performance of the virtual machine, reduces the occupation of CPU resources and improves the user experience.
In order to solve the problems, the invention adopts the following technical scheme:
the video hardware accelerating device is positioned in a host machine or a virtual machine, wherein the virtual machine comprises an application program and a first video accelerating library which are connected with each other in information, the host machine comprises a second video accelerating library, a physical display card video driver and a physical display card which are connected with each other in sequence in information, the host machine distributes a virtual display card for the virtual machine, and a function realization module of the virtual display card is distributed in the virtual machine and the host machine, and is characterized in that the function realization module of the virtual display card comprises a virtual display card video driver distributed in the virtual machine, a video processing module of the virtual display card distributed in the host machine and a virtual display card video service program, and the video processing modules of the virtual display card video driver and the virtual display card realize information connection through a virtual display card video protocol;
the virtual display card video driver is in information connection with the first video acceleration library and the video processing module of the virtual display card, is responsible for managing and controlling the video processing module of the virtual display card, and provides an access interface for the first video acceleration library or the application program on the upper layer;
the virtual video card video protocol realizes a communication protocol between a virtual video card video driver and a video processing module of the virtual video card by defining a plurality of commands and an affiliated data structure thereof;
the video processing module of the virtual video card is in information connection with the input end of the video service program of the virtual video card and is responsible for receiving and analyzing the command of the video protocol of the virtual video card, extracting the request data and forwarding the request data to the video service program of the virtual video card for processing;
the virtual display card video service program is connected with the input end of the second video acceleration library in an information way and is responsible for receiving and analyzing the request data, and then an interface of the second video acceleration library on the host side is called to process by using a physical display card.
The technical scheme of the invention is further improved as follows: a plurality of commands defined by a virtual graphics card video protocol and its accompanying data structures, comprising: querying one or more of video functional characteristics, creating a codec, destroying a codec, creating a video buffer, destroying a video buffer, starting a codec frame, decoding a macroblock, decoding a bitstream, encoding a bitstream, and ending a codec frame.
The technical scheme of the invention is further improved as follows: the virtual display card is a virtual GPU, and the corresponding virtual display card video driver is a virtual GPU video driver; the virtual video card video protocol is a virtual GPU video protocol; the virtual video card video service program is a virtual GPU video service program; the first video acceleration library and the second video acceleration library are libva video acceleration libraries.
The video hardware acceleration method suitable for the virtual display card forwards a video processing request of a virtual machine to a physical display card of a host side, and video encoding and decoding of hardware are performed by utilizing a video processing module in the physical display card, so that the acceleration device is utilized, and the method comprises the following steps of:
s1, creating a virtual machine in a host machine, and distributing a virtual display card for the virtual machine;
s2, starting a virtual machine, and simultaneously starting a virtual video card video service program in a host;
s3, an application program in the virtual machine calls a first video acceleration library to encode, decode or process video;
s4, the first video acceleration library calls an interface of a virtual display card video driver to encode, decode or process the video;
s5, converting the call from the first video acceleration library into a virtual video card video protocol command by a virtual video card video driver, and sending the command to a video processing module of a virtual video card;
s6, a video processing module of the virtual display card receives and analyzes a command of a video protocol of the virtual display card, extracts request data and forwards the request data to a video service program of the virtual display card;
s7, receiving and analyzing request data by a virtual display card video service program, and then calling an interface of a second video acceleration library of a host side, and completing request processing by means of a physical display card video driver and a related module of a physical display card;
s8, the 'virtual display card video service program' in the host machine encapsulates the processing result into response data and returns the response data to the application program of the virtual machine side according to the original path;
s9, receiving and processing response data by an application program in the virtual machine;
and S10, ending the video encoding, decoding or processing.
The technical scheme of the invention is further improved as follows: in step S7, the request is processed by means of the video driver of the physical display card, and the video processing module and the graphics rendering module of the physical display card.
The video hardware acceleration method suitable for the virtual display card forwards a video processing request of a virtual machine to a physical display card of a host side, and the acceleration device comprises the following steps:
v1, creating a virtual machine in a host machine, and distributing a virtual GPU display card for the virtual machine;
v2, starting a virtual machine, and simultaneously starting a Virtio GPU video service program in a host;
v3, an application program in the virtual machine calls a first libva video acceleration library to encode, decode or process the video;
v4, calling a video acceleration library interface of Virtio GPU video drive to encode, decode or process video;
v5, converting the call from the first libva video acceleration library into a Virtio GPU video protocol command by a Virtio GPU video driver, and sending the Virtio GPU video protocol command to a Virtio GPU video processing module of a virtual display card;
v6, a 'Virtio GPU video processing module' of the virtual display card receives and analyzes a 'Virtio GPU video protocol' command, extracts request data and forwards the request data to a 'Virtio GPU video service program';
v7, receiving and analyzing request data by a Virtio GPU video service program, calling an interface of a second libva video acceleration library of the host side, and completing request processing by means of a physical display card video driver and a related module of the physical display card;
v8, a 'Virtio GPU video service program' in the host machine encapsulates the processing result into response data, and returns the response data to an application program of the virtual machine side according to a primary path;
v9, receiving and processing response data by an application program in the virtual machine;
v10, video encoding, decoding or processing ends.
Due to the adoption of the technical scheme, the beneficial effects obtained by the invention are as follows:
1. the video hardware acceleration mechanism realizes the video hardware acceleration function of the virtual display card, can support hardware decoding, encoding, processing and the like of the video, improves the video processing performance of the virtual machine, and simultaneously obviously reduces the occupation of CPU resources. Through testing, under the spread-spectrum 920 processor and the AMD Radeon RX550 display card, when the 4K/60fps H.264 video is played in the virtual machine (matched with the Virtio GPU display card) by using the MPV player, the CPU occupation rate of the player is greatly reduced from the original 321% to about 8.4%, and the user experience is remarkably improved.
2. The invention not only supports the hardware decoding of the video, but also simultaneously supports hardware coding, hardware video processing and the like;
3. the invention realizes the video hardware acceleration function of the virtual display card from the equipment layer and the driving layer, so that the virtual display card is not bound with a specific video acceleration library or a coding/decoding API of an upper layer, can simultaneously support various coding/decoding interfaces such as VA-API, VDPAU, NVDEC, NVENC and the like, and is not influenced by version changes of the virtual display card.
4. The invention can support various encoding and decoding specifications, including but not limited to H.264/AVC, H.265/HEVC, MPEG-2, VC1, VP9, etc., and the specific supporting condition is determined by the hardware encoding and decoding environment of the host side, and has the characteristics of strong applicability and flexible use.
Drawings
FIG. 1 is a functional block diagram of video hardware acceleration of a virtual graphics card according to the present invention;
FIG. 2 is a functional block diagram of video hardware acceleration of a Virtio GPU in accordance with the present invention.
Detailed Description
The present invention will be described in further detail with reference to examples.
Abbreviations and key term definitions to which the present invention relates are first described:
cloud desktop: cloud desktop, also known as desktop virtualization, is a typical application of virtualization and the cloud computing era. The cloud desktop builds a server cluster in a cloud data center through a cloud computing technology, creates a plurality of virtual machines to provide remote services of remote computing, storage, application programs and other personalized contents, and a user is connected into the remote cloud desktop through various cloud terminal equipment through a network to obtain computing, storage, personalized application and data contents belonging to the user, so that the user experience consistent with a local PC is realized.
QXL: a virtual display card for software simulation.
Virtio GPU: the Virtual I/O GPU is also written as Virtual I/O GPU, and is a Virtual graphics card based on the Virtual I/O technology. The Virtio and related device specifications are maintained by the OASIS organization and are intended to provide a generic, efficient virtual device mechanism for virtual environments. Currently, both QEMU and Linux kernels already support Virtio GPU devices. Compared with a virtual display card simulated by pure software such as QXL, the virtual GPU can accelerate 3D hardware by using a physical display card of a host side by means of tools such as VirGL, so that the graphic performance of the virtual machine is greatly improved.
libva: a video acceleration library is an open source implementation of VA-API (Video Acceleration API) video acceleration interface specification, and is developed by Intel corporation.
libdpau: a video decoding library is an open source implementation of VDPAU (Video Decode and Presentation API for Unix) video acceleration interface specification, and is developed by Inlet.
NVDEC: a video decoding interface specification and library was developed by Injeida.
NVENC: a video coding interface specification and library was developed by Injeida.
In the above embodiment, although the libva library is used as the video acceleration library, the present embodiment is not limited to the libva library, and may support a plurality of video acceleration libraries such as libvdpau, NVENC, NVDEC.
The invention provides a video hardware accelerating device suitable for a virtual display card, which is positioned in a host machine or a virtual machine, wherein the virtual machine comprises an application program and a first video accelerating library which are connected by information, the host machine comprises a second video accelerating library, a physical display card video driver and a physical display card which are connected by information in sequence, the host machine distributes the virtual display card for the virtual machine, and a function realization module of the virtual display card is distributed in the virtual machine and the host machine, and is characterized in that the function realization module of the virtual display card comprises a video driver of the virtual display card distributed in the virtual machine, a video processing module of the virtual display card distributed in the host machine and a video service program of the virtual display card, and the video processing module of the virtual display card video driver and the video processing module of the virtual display card realize information connection through a video protocol of the virtual display card;
the virtual display card video driver is in information connection with the first video acceleration library and the video processing module of the virtual display card, is responsible for managing and controlling the video processing module of the virtual display card, and provides an access interface for the first video acceleration library or the application program on the upper layer;
the virtual video card video protocol realizes a communication protocol between a virtual video card video driver and a video processing module of the virtual video card by defining a plurality of commands and an affiliated data structure thereof;
the video processing module of the virtual video card is in information connection with the input end of the video service program of the virtual video card and is responsible for receiving and analyzing the command of the video protocol of the virtual video card, extracting the request data and forwarding the request data to the video service program of the virtual video card for processing;
the virtual display card video service program is connected with the input end of the second video acceleration library in an information way and is responsible for receiving and analyzing the request data, and then an interface of the second video acceleration library on the host side is called to process by using a physical display card.
A plurality of commands defined by a virtual graphics card video protocol and its accompanying data structures, comprising: querying one or more of video functional characteristics, creating a codec, destroying a codec, creating a video buffer, destroying a video buffer, starting a codec frame, decoding a macroblock, decoding a bitstream, encoding a bitstream, and ending a codec frame. For example, the virtual graphics card is a virtual GPU, and the corresponding virtual graphics card video driver is a virtual GPU video driver; the virtual video card video protocol is a virtual GPU video protocol; the virtual video card video service program is a virtual GPU video service program; the first video acceleration library and the second video acceleration library are libva video acceleration libraries.
In addition, the present invention also provides a method for accelerating video hardware suitable for a virtual display card, as shown in fig. 1, by forwarding a video processing request of a virtual machine to a physical display card on a host side, and using a video processing module in the physical display card to perform video encoding and decoding of hardware, the method for accelerating video hardware comprises the following steps:
1) Creating a virtual machine in the host machine and distributing a virtual display card for the virtual machine;
2) Starting a virtual machine and simultaneously starting a virtual video card video service program in a host;
3) An application program in the virtual machine calls a first video acceleration library to encode, decode or process video;
4) The first video acceleration library calls an interface of a virtual display card video driver to encode, decode or process the video;
5) The virtual display card video driver converts the call from the first video acceleration library into a virtual display card video protocol command and sends the command to a video processing module of the virtual display card;
6) The video processing module of the virtual display card receives and analyzes the command of the video protocol of the virtual display card, extracts the request data and forwards the request data to the video service program of the virtual display card;
7) Receiving and analyzing request data by a virtual display card video service program, then calling an interface of a second video acceleration library of a host side, and completing the processing of the request by means of a physical display card video driver and a related module of a physical display card;
8) The processing result is encapsulated into response data by a virtual video card video service program in the host machine, and the response data is returned to an application program of the virtual machine side according to the original path;
9) Receiving and processing the response data by an application program in the virtual machine;
10 Video encoding, decoding, or processing ends).
In the step 7), the request processing is completed by means of the video driver of the physical display card, and the video processing module and the graphic rendering module of the physical display card.
In addition to the above method for accelerating video hardware, as shown in fig. 2, when the virtual video card is a Virtio GPU video card, the present invention also provides a method for accelerating video hardware suitable for a virtual video card, which also uses the above accelerating device by forwarding a video processing request of a virtual machine to a physical video card on a host side, and includes the following steps:
11 Creating a virtual machine in the host machine, and distributing a virtual GPU display card for the virtual machine;
12 Starting a virtual machine, and simultaneously starting a 'virtual GPU video service program' in a host;
13 An application program in the virtual machine calls a first libva video acceleration library to encode, decode or process the video;
14 The first libva video acceleration library calls a video driver interface of a video GPU to encode, decode or process the video;
15 The Virtio GPU video driver converts the call from the first libva video acceleration library into a Virtio GPU video protocol command and sends the Virtio GPU video protocol command to a Virtio GPU video processing module of the virtual display card;
16 The virtual video card 'Virtio GPU video processing module' receives and analyzes the 'Virtio GPU video protocol' command, extracts request data and forwards the request data to the 'Virtio GPU video service program';
7) The Virtio GPU video service program receives and analyzes the request data, then invokes an interface of a second libva video acceleration library of the host side, and completes the request processing by means of a physical display card video driver and a related module of the physical display card;
18 The 'Virtio GPU video service program' in the host machine encapsulates the processing result into response data and returns the response data to the application program of the virtual machine side according to the original path;
19 Receiving and processing the response data by an application program in the virtual machine;
10 Video encoding, decoding, or processing ends).
The details are developed below.
For example, in the above embodiment, commands defined by the "Virtio GPU video protocol" are:
Figure BDA0003838238330000101
taking the codec process as an example, the interaction flow of the "Virtio GPU video protocol" is as follows:
the video function characteristics of the virtual video card of the Virtio GPU are queried by a 'Virtio GPU video driver' sending 'GET_CAPSET' command, and the video function characteristics are recorded and stored;
the "Virtio GPU VIDEO driver" send "create_video_buffer" command CREATEs a VIDEO BUFFER for storing image data to be encoded or decoded;
the "VIDEO GPU VIDEO driver" sends a "create_video_codec" command, CREATEs a CODEC corresponding to the CODEC specification, and binds the VIDEO buffer to the CODEC;
the "Virtio GPU video driver" send "begin_frame" command, indicating the start of a codec FRAME;
the video GPU video driver sends a command of DECODE_MACROCK, DECODE_BITSTREAM or ENCODE_BITSTREAM to ENCODE and DECODE the image;
the "Virtio GPU video driver" send "end_frame" command, indicating ending the codec FRAME;
reading and processing the encoded or decoded data by a Virtio GPU video driver to finish the processing of a frame of image;
8. step 4 is again entered until all image frames have been processed.
The Virtio GPU VIDEO driver sends a DESTROY_VIDEO_CODEC command to DESTROY the VIDEO CODEC;
the VIDEO BUFFER is destroyed by the Virtio GPU VIDEO driver sending a destroy_video_buffer command;
11. the codec ends.
The protocol basically embodies the entire flow, so the protocol will be described in detail. The Virtio GPU video driver is generally equivalent to a request party (front end) of a protocol, and the Virtio GPU video processing module is equivalent to a transfer agent of a protocol message; the "Virtio GPU video service program" is equivalent to the processing and responding party (backend) of protocol messages.
Since each module is an integral unit as an important component of the whole process, interfaces and functions of other modules are listed in the following supplementary, and then described in an integral codec process:
"Virtio GPU video driver" provides an interface for the virtual machine side's libva video acceleration library:
Figure BDA0003838238330000111
Figure BDA0003838238330000121
the "Virtio GPU video service program" is an interface provided by the "Virtio GPU video processing module":
interface name Description of the invention
vrend_video_init Initializing a "Virtio GPU video service program"
vrend_video_fini Inverse initialization "Virtio GPU video service program"
vrend_video_fill_caps Filling in supported video functionality features
vrend_video_create_codec Creating video codecs
vrend_video_destroy_codec Destroying video codecs
vrend_video_create_buffer Creating video buffers
vrend_video_destroy_buffer Destroying video buffers
vrend_video_begin_frame Beginning a codec frame
vrend_video_decode_macroblock Decoding macro blocks
vrend_video_decode_bitstream Decoding a bitstream
vrend_video_encode_bitstream Encoding a bitstream
vrend_video_end_frame Ending a codec frame
The interface provided by the "Virtio GPU video processing module" for the "Virtio GPU video driver" is the "Virtio GPU video protocol", and will not be described here again.
The libva video acceleration library belongs to the existing module, is not created by the invention, but for the sake of document completeness, key interfaces are briefly described here:
interface name Description of the invention
vaInitialize Initializing libva video acceleration library
vaTerminate Destroying libva video acceleration library
vaQueryConfigProfiles Query support specification
vaQueryConfigEntrypoints Inlet Point for query support
vaCreateConfig Creating a configuration
vaDestroyConfig Destruction arrangement
vaCreateContext Creating a codec context
vaDestroyContext Destroying codec context
vaCreateSurfaces Creating canvas
vaDestroySurfaces Destroying canvas
vaCreateBuffer Creating buffers
vaDestroyBuffer Destruction buffer
vaBeginPicture Beginning a codec frame
vaRenderPicture Encoding and decoding frame
vaEndPicture Ending a codec frame
Taking the codec process as an example, the specific steps of this embodiment are as follows (complex details inside each module are omitted for convenience of description):
1. creating a virtual machine in a host machine, and distributing a virtual video card of a virtual io GPU for the virtual machine;
2. starting a virtual machine;
3. the initialization of the Virtio GPU video processing module and the Virtio GPU video service program of the host side comprises the following steps:
(1) The 'video GPU video processing module' calls a 'vrend_video_init' interface to start and initialize a 'video GPU video service program';
(2) The Virtio GPU video service program calls a 'vaInitialize' interface of a libva video acceleration library on the host side to initialize the libva video acceleration library;
(3) The libva video acceleration library on the host side calls the interface driven by the physical display card to initialize the video function.
4. The virtual machine side 'Virtio GPU video driver' is initialized, and specifically comprises the following sub-steps:
(1) The Virtio GPU video driver sends a GET_CAPSET command to a Virtio GPU video processing module of the host side, and inquires the supported video function characteristics;
(2) The video GPU video processing module receives the command and performs validity check, extracts the command parameter and invokes the video functional characteristics supported by the video GPU video service program interface inquiry;
(3) The Virtio GPU video service program calls interfaces such as 'VaQueryConfigProfiles' and 'VaQueryConfigEntry points' of a Libva video acceleration library on a host side to inquire video characteristics supported by a physical display card, and then returns to a Virtio GPU video processing module;
(4) The Virtio GPU video processing module fills a response message according to the returned information of the Virtio GPU video service program and sends the response message to the Virtio GPU video driver;
(5) The Virtio GPU video driver analyzes the response message, records and stores video characteristic information.
5. The application program of the virtual machine side calls a 'vaInitialize' interface of the virtual machine side libva video acceleration library, and initializes the virtual machine side libva video acceleration library;
6. the application program of the virtual machine side queries the video characteristics of a virtual video card of a virtual video GPU, and specifically comprises the following sub-steps:
(1) The application program of the virtual machine side calls interfaces such as 'vaQueryConfigProfiles' and 'vaQueryConfigEntry points' of the virtual machine side libva video acceleration library to inquire the video characteristics;
(2) The libva video acceleration library of the virtual machine side calls the get_video_param of the Virtio GPU video driver and the is_video_format_supported interface to inquire the video characteristics and formats supported by the Virtio GPU virtual display card;
(3) The Virtio GPU video driver returns a query result according to the stored video characteristic information.
(4) The application program judges whether the Virtio GPU virtual display card supports the required coding and decoding specifications according to the query result, if so, the application program enters the step 7, and if not, the application program reports errors and exits;
7. the method for creating the video buffer area specifically comprises the following sub-steps:
(1) An application program of the virtual machine side calls a 'vareateSturface' interface of the libva video acceleration library to create a canvas;
(2) The libva video acceleration library of the virtual machine side calls a "create_video_buffer" interface of the "video GPU video driver" to create a video buffer;
(3) The Virtio GPU VIDEO driver constructs a CREATE_VIDEO_BUFFER command message according to the request and forwards the command message to the Virtio GPU VIDEO processing module;
(4) The video GPU video processing module receives the command and performs validity check, extracts the command parameter and calls the video buffer area created by the video_video_create_buffer interface of the video GPU video service program;
(5) The Virtio GPU video service program calls interfaces such as a host side libva video acceleration library, such as a VaCreateStourface, to create a canvas;
(6) The libva video acceleration library at the host side calls an interface driven by a physical display card to complete the creation of a video buffer;
8. the method for creating the video codec specifically comprises the following sub-steps:
(1) The application program of the virtual machine side calls the 'vaceateConfig' and 'vaceateContext' interfaces of the libva video acceleration library to create a video codec context;
(2) The libva video acceleration library of the virtual machine side calls a "create_video_codec" interface of "video GPU video driver" to create a video codec;
(3) The "Virtio GPU VIDEO driver" constructs a "create_video_codec" command message on request and forwards it to the "Virtio GPU VIDEO processing module".
(4) The video GPU video processing module receives the command and performs validity check, extracts the command parameter and calls the video codec created by the video codec interface of the video GPU video service program;
(5) The Virtio GPU video service program calls interfaces such as 'vareateConfig' and 'vareateContext' of a host side libva video acceleration library to create video codec contexts;
(6) The libva video acceleration library at the host side calls the interface driven by the physical display card to finish the creation of the video coder-decoder;
9. the method for starting encoding and decoding the frame specifically comprises the following substeps:
(1) An application program of the virtual machine side calls a 'VaBeginPictures' interface of the libva video acceleration library to start encoding and decoding frames, and binds canvas to a video encoding and decoding context;
(2) The libva video acceleration library of the virtual machine side calls a codec.begin_frame interface of Virtio GPU video drive to start encoding and decoding frames, and binds a video buffer zone to a codec;
(3) The "Virtio GPU video driver" constructs a "begin_frame" command message upon request and forwards it to the "Virtio GPU video processing module".
(4) The video GPU video processing module receives the command and performs validity check, extracts the command parameter and calls the video frame of the video GPU video service program;
(5) The Virtio GPU video service program invokes interfaces such as a host side libva video acceleration library, such as a VaBeginPictures interface, to start encoding and decoding frames, and binds canvas to a video encoding and decoding context;
(6) The libva video acceleration library at the host side calls an interface driven by a physical display card to start encoding and decoding frames;
10. the encoding and decoding frame specifically comprises the following substeps:
(1) An application program of the virtual machine side calls a 'vaRenderPicture' interface codec frame of the libva video acceleration library;
(2) The libva video acceleration library at the virtual machine side calls the corresponding codec.decode_macroloc of the video GPU video driver according to the current created codec context,
A "codec_bitstream" or "codec_bitstream" interface to decode a macroblock, decode a bitstream, or encode a bitstream;
(3) The video driver of the video GPU constructs a corresponding command message of the DECODE_MACROCK, the DECODE_BITSTREAM or the ENCODE_BITSTREAM according to the request, and forwards the command message to the video GPU video processing module.
(4) The video GPU video processing module receives the command and performs validity check, extracts the command parameter and calls the corresponding 'virend_video_begin_frame', 'virend_video_decode_bitstream' or 'virend_video_encode_bitstream' interface of the video GPU video service program to decode the macro block, decode the bitstream or encode the bitstream;
(5) The Virtio GPU video service program calls interfaces such as 'vareateBuffer' and 'varrenderPictures' of a host side libva video acceleration library to encode and decode frames;
(6) The libva video acceleration library at the host side calls the physical display card drive interface coding and decoding frames;
11. ending the encoding and decoding frame, comprising the following steps:
(1) The application program of the virtual machine side calls a 'VaEndPictures' interface of the libva video acceleration library to finish encoding and decoding frames;
(2) The libva video acceleration library of the virtual machine side calls a codec. End_frame interface of Virtio GPU video drive to finish the encoding and decoding frame;
(3) The Virtio GPU video driver constructs an END_FRAME command message according to the request and forwards the END_FRAME command message to the Virtio GPU video processing module;
(4) The video GPU video processing module receives the command and performs validity check, extracts the command parameter and calls the video end frame of the video GPU video service program;
(5) The Virtio GPU video service program calls interfaces such as a host side libva video acceleration library and ends the encoding and decoding frames;
(6) The libva video acceleration library at the host side calls a physical display card driving interface to finish encoding and decoding frames, and stores encoded and decoded data into a video buffer area or other appointed buffer areas;
12. the application program of the virtual machine side reads the encoded and decoded data from the video buffer area or other appointed buffer areas, and forwards, displays or stores the encoded and decoded data according to the requirements of users, so as to finish the processing of one frame of image;
13. step 9 is again entered until all image frames have been processed.
14. Destroying the video buffer area, the video codec, etc., and ending the codec.
The new video hardware acceleration mechanism provided by the invention realizes the video hardware acceleration function of the virtual display card, can support hardware decoding, encoding, processing and the like of video, and obviously reduces the occupation of CPU resources while improving the video processing performance of the virtual machine. Through testing, under the spread-spectrum 920 processor and the AMD Radeon RX550 display card, when the 4K/60fps H.264 video is played in a virtual machine (matched with a Virtio GPU display card) by using an MPV player, the CPU occupancy rate of the player is greatly reduced from the original 321% to about 8.4%, the user experience is obviously improved, and the method has extremely high popularization and application values.

Claims (6)

1. The video hardware accelerating device is positioned in a host machine or a virtual machine, wherein the virtual machine comprises an application program and a first video accelerating library which are connected with each other in information, the host machine comprises a second video accelerating library, a physical display card video driver and a physical display card which are connected with each other in sequence in information, the host machine distributes a virtual display card for the virtual machine, and a function realization module of the virtual display card is distributed in the virtual machine and the host machine, and is characterized in that the function realization module of the virtual display card comprises a virtual display card video driver distributed in the virtual machine, a video processing module of the virtual display card distributed in the host machine and a virtual display card video service program, and the video processing modules of the virtual display card video driver and the virtual display card realize information connection through a virtual display card video protocol;
the virtual display card video driver is in information connection with the first video acceleration library and the video processing module of the virtual display card, is responsible for managing and controlling the video processing module of the virtual display card, and provides an access interface for the first video acceleration library or the application program on the upper layer;
the virtual video card video protocol realizes a communication protocol between a virtual video card video driver and a video processing module of the virtual video card by defining a plurality of commands and an affiliated data structure thereof;
the video processing module of the virtual video card is in information connection with the input end of the video service program of the virtual video card and is responsible for receiving and analyzing the command of the video protocol of the virtual video card, extracting the request data and forwarding the request data to the video service program of the virtual video card for processing;
the virtual display card video service program is connected with the input end of the second video acceleration library in an information way and is responsible for receiving and analyzing the request data, and then an interface of the second video acceleration library on the host side is called to process by using a physical display card.
2. The video hardware acceleration apparatus and method of claim 1, wherein the plurality of commands defined by the video protocol of the virtual graphics card and their accompanying data structures, comprise: querying one or more of video functional characteristics, creating a codec, destroying a codec, creating a video buffer, destroying a video buffer, starting a codec frame, decoding a macroblock, decoding a bitstream, encoding a bitstream, and ending a codec frame.
3. The video hardware acceleration device of claim 2, wherein the virtual graphics card is a Virtio GPU, and the corresponding virtual graphics card video driver is a Virtio GPU video driver; the virtual video card video protocol is a virtual GPU video protocol; the virtual video card video service program is a virtual GPU video service program; the first video acceleration library and the second video acceleration library are libva video acceleration libraries.
4. The video hardware acceleration method suitable for the virtual display card is characterized in that the acceleration device of claim 1 is utilized by forwarding a video processing request of a virtual machine to a physical display card of a host side and utilizing a video processing module in the physical display card to carry out video encoding and decoding of hardware, and the method comprises the following steps:
s1, creating a virtual machine in a host machine, and distributing a virtual display card for the virtual machine;
s2, starting a virtual machine, and simultaneously starting a virtual video card video service program in a host;
s3, an application program in the virtual machine calls a first video acceleration library to encode, decode or process video;
s4, the first video acceleration library calls an interface of a virtual display card video driver to encode, decode or process the video;
s5, converting the call from the first video acceleration library into a virtual video card video protocol command by a virtual video card video driver, and sending the command to a video processing module of a virtual video card;
s6, a video processing module of the virtual display card receives and analyzes a command of a video protocol of the virtual display card, extracts request data and forwards the request data to a video service program of the virtual display card;
s7, receiving and analyzing request data by a virtual display card video service program, and then calling an interface of a second video acceleration library of a host side, and completing request processing by means of a physical display card video driver and a related module of a physical display card;
s8, the 'virtual display card video service program' in the host machine encapsulates the processing result into response data and returns the response data to the application program of the virtual machine side according to the original path;
s9, receiving and processing response data by an application program in the virtual machine;
and S10, ending the video encoding, decoding or processing.
5. The method according to claim 4, wherein in step S7, the request processing is performed by means of a physical video card video driver, and a video processing module and a graphics rendering module of the physical video card.
6. A video hardware acceleration method suitable for a virtual display card, by forwarding a video processing request of a virtual machine to a physical display card on a host side, characterized in that the acceleration device of claim 3 is utilized, comprising the steps of:
v1, creating a virtual machine in a host machine, and distributing a virtual GPU display card for the virtual machine;
v2, starting a virtual machine, and simultaneously starting a Virtio GPU video service program in a host;
v3, an application program in the virtual machine calls a first libva video acceleration library to encode, decode or process the video;
v4, calling a video acceleration library interface of Virtio GPU video drive to encode, decode or process video;
v5, converting the call from the first libva video acceleration library into a Virtio GPU video protocol command by a Virtio GPU video driver, and sending the Virtio GPU video protocol command to a Virtio GPU video processing module of a virtual display card;
v6, a 'Virtio GPU video processing module' of the virtual display card receives and analyzes a 'Virtio GPU video protocol' command, extracts request data and forwards the request data to a 'Virtio GPU video service program';
v7, receiving and analyzing request data by a Virtio GPU video service program, calling an interface of a second libva video acceleration library of the host side, and completing request processing by means of a physical display card video driver and a related module of the physical display card;
v8, a 'Virtio GPU video service program' in the host machine encapsulates the processing result into response data, and returns the response data to an application program of the virtual machine side according to a primary path;
v9, receiving and processing response data by an application program in the virtual machine;
v10, video encoding, decoding or processing ends.
CN202211100537.6A 2022-09-08 2022-09-08 Video hardware acceleration device and method suitable for virtual display card Pending CN116400998A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211100537.6A CN116400998A (en) 2022-09-08 2022-09-08 Video hardware acceleration device and method suitable for virtual display card

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211100537.6A CN116400998A (en) 2022-09-08 2022-09-08 Video hardware acceleration device and method suitable for virtual display card

Publications (1)

Publication Number Publication Date
CN116400998A true CN116400998A (en) 2023-07-07

Family

ID=87006297

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211100537.6A Pending CN116400998A (en) 2022-09-08 2022-09-08 Video hardware acceleration device and method suitable for virtual display card

Country Status (1)

Country Link
CN (1) CN116400998A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116828198A (en) * 2023-08-29 2023-09-29 麒麟软件有限公司 Method for supporting VA-API hardware video acceleration interface on NVIDIA GPU
CN117992237A (en) * 2024-03-18 2024-05-07 麒麟软件有限公司 Rendering API forwarding method based on virgl graphic technology stack

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116828198A (en) * 2023-08-29 2023-09-29 麒麟软件有限公司 Method for supporting VA-API hardware video acceleration interface on NVIDIA GPU
CN116828198B (en) * 2023-08-29 2023-11-28 麒麟软件有限公司 Method for supporting VA-API hardware video acceleration interface on NVIDIA GPU
CN117992237A (en) * 2024-03-18 2024-05-07 麒麟软件有限公司 Rendering API forwarding method based on virgl graphic technology stack

Similar Documents

Publication Publication Date Title
US10542301B2 (en) Multimedia redirection method, device, and system
CN116400998A (en) Video hardware acceleration device and method suitable for virtual display card
CN1856819B (en) System and method for network transmission of graphical data through a distributed application
US9235452B2 (en) Graphics remoting using augmentation data
CN108881916A (en) The video optimized processing method and processing device of remote desktop
CN104660687A (en) Realization method and system for virtual desktop display
AU2011314228B2 (en) Entropy coder for image compression
CN102447901B (en) Adaptive grid generation for improved caching and image classification
WO2022257699A1 (en) Image picture display method and apparatus, device, storage medium and program product
CN108366288A (en) A kind of efficient decoding and playback method and system for HD video
CN113542757A (en) Image transmission method and device for cloud application, server and storage medium
CN113946402A (en) Cloud mobile phone acceleration method, system, equipment and storage medium based on rendering separation
CN106797398A (en) Method and system for providing from virtual desktop serve to client
WO2023011033A1 (en) Image processing method and apparatus, computer device and storage medium
CN114567784B (en) VPU video decoding output method and system for Feiteng display card
KR20030077374A (en) Apparatus and method for processing image in thin-client environment, apparatus and method for receiving processed image
CN113411660A (en) Video data processing method and device and electronic equipment
US20170289547A1 (en) Video decoding using point sprites
CN107809671A (en) Video is redirected to the method and system of server decoding under a kind of virtualized environment
CN114820660A (en) Image processing method, image processing apparatus, electronic device, storage medium, and program product
CN116700943A (en) Video playing system and method and electronic equipment
US6621490B1 (en) Method and apparatus for motion compensation using hardware-assisted abstraction layer
CN104737225A (en) System and method for memory-bandwidth efficient display composition
CN115801747B (en) Cloud server based on ARM architecture and audio/video data transmission method
CN116828198B (en) Method for supporting VA-API hardware video acceleration interface on NVIDIA GPU

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination