Video playing method and device, electronic equipment and medium
By decoding the video stream into RGBA format and storing it in the display memory, and data transmission is carried out using the synchronization buffer area and frame buffer memory, the problem of low video playback efficiency in the prior art is solved, and more efficient video playback processing is achieved.
Patent Information
- Application Number
- CN202411181609.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2024-12-03
AI Technical Summary
In the existing video playback method, multiple copies of data between the display memory and the main memory lead to low video playback efficiency, especially when the GPU performance is limited and the video resolution is high, frame drops and stuttering are prone to occur.
By decoding the video stream into an RGBA format image frame and storing it to the display memory, data transmission is performed using the synchronization buffer area and frame buffer memory, data copying is reduced, data processing is ensured, and video playback efficiency is improved.
It effectively reduces data copy operations, improves the processing efficiency of video playback, avoids frame drops and lags in video playback, and improves user experience.
Smart Images

Figure CN119071558A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of video playback, and in particular to a video playback method, device, electronic device and medium. Background Art
[0002] With the advent of the 5G era, the demand for high-definition video playback is increasing day by day. Relying solely on the CPU (Central Processing Unit) to undertake video playback tasks is not only inefficient, but also occupies a large amount of CPU resources. When the CPU is performing other tasks at the same time, it is easy to cause system lag and affect user experience. At present, using GPU (Graphics Processing Unit) for video playback has become an effective solution and is widely used.
[0003] However, the existing data processing flow of video playback involves multiple data copies between the display memory and the main memory. For example, in a multimedia platform, the YUV image data decoded by the GPU is stored in the display memory. It needs to be copied to the main memory first, and then the data in the main memory is transferred to the display memory through the server. The GPU will scale and convert the YUV image data in the display memory before displaying it, which will greatly affect the video playback performance. Therefore, when the GPU performance is limited and the video resolution is large, it will affect the video processing efficiency, and it is easy to cause frame drops and freezes in video playback.
[0004] Therefore, how to improve the processing efficiency of video playback is a technical problem that needs to be solved urgently. Summary of the invention
[0005] The present invention provides a video playback method, device, electronic equipment and medium, which improve the processing efficiency of video playback.
[0006] The embodiment of the present invention provides the following solution:
[0007] In a first aspect, an embodiment of the present invention provides a method for playing a video, comprising:
[0008] Get the video stream to be played;
[0009] Decoding the video stream into multiple image frames in RGBA format and storing them in a display memory;
[0010] storing the current frame data to be outputted among the plurality of image frames in a synchronous buffer area of the display memory;
[0011] Outputting the cache information of the synchronization cache area to the frame buffer memory of the main memory, wherein the cache information at least includes the current frame data;
[0012] When the current frame data in the synchronization buffer area is the same as the current frame data in the frame buffer memory, the current frame data in the synchronization buffer area is output to play the video stream.
[0013] In an optional embodiment, decoding the video stream into multiple image frames in RGBA format and storing them in a display memory includes:
[0014] The multimedia platform reads the video stream;
[0015] According to the output mode configured by the multimedia platform, hard decoding processes the video stream;
[0016] According to the hard decoding result of the multimedia platform, a plurality of image frames in RGBA format are obtained;
[0017] A plurality of the image frames are stored in the display memory.
[0018] In an optional embodiment, storing the plurality of image frames in the display memory comprises:
[0019] Generate a video memory request instruction according to the image format and resolution of the image frame;
[0020] Obtaining video memory space of the display memory according to the video memory request instruction;
[0021] According to the decoding order of the multiple image frames, the multiple image frames are sequentially stored in the video memory space.
[0022] In an optional embodiment, the output frame for playing the video stream is xvideo, and before storing the current frame data to be output among the plurality of image frames into the synchronization buffer area of the display memory, the method further includes:
[0023] Initialize the hardware abstraction layer of the xorg server and the display memory, and make the xvideo output framework active.
[0024] In an optional embodiment, the output frame for playing the video stream is xvideo, and when the current frame data in the synchronization buffer area is the same as the current frame data in the frame buffer memory, the current frame data in the synchronization buffer area is output, including:
[0025] Configure the xorg server to transmit the current frame data in the synchronization buffer area to the transmission interface of the xvideo output framework;
[0026] The xorg server reads the cache information through the transmission interface and stores the cache information in the frame buffer memory;
[0027] Determining whether the current frame data of the synchronization buffer area is the same as the current frame data of the frame buffer memory;
[0028] If so, the current frame data of the synchronization buffer area is scaled and processed, and output to a preset playback window for fusion display.
[0029] In an optional embodiment, the scaling process of the current frame data of the synchronization buffer area and outputting the current frame data to a preset playback window for fusion display includes:
[0030] Obtaining display specifications of the current frame data;
[0031] Scaling the current frame data according to the display specification, and outputting the scaling result to a preset display area of the display memory;
[0032] The current frame data of the preset display area is played and displayed in the play window.
[0033] In an optional embodiment, scaling the current frame data according to the display specification and outputting the scaling result to a preset display area of the display memory includes:
[0034] Reading the display specification and the current frame data;
[0035] The current frame data is scaled and processed according to the display specification, and stored in the preset display area.
[0036] In a second aspect, an embodiment of the present invention further provides a video playback device, including:
[0037] An acquisition module is used to acquire the video stream to be played;
[0038] A decoding module, used for decoding the video stream into a plurality of image frames in RGBA format and storing the frames in a display memory;
[0039] A storage module, used for storing the current frame data to be output among the plurality of image frames into the synchronization buffer area of the display memory;
[0040] A first output module, configured to output the cache information of the synchronization cache area to a frame buffer memory of a main memory, wherein the cache information at least includes the current frame data;
[0041] The second output module is used to output the current frame data in the synchronization buffer area when the current frame data in the synchronization buffer area is the same as the current frame data in the frame buffer memory, so as to play the video stream.
[0042] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a processor and a memory, wherein the memory is coupled to the processor, and the memory stores instructions, which, when executed by the processor, enable the electronic device to perform the steps of any one of the methods described in the first aspect.
[0043] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any one of the methods described in the first aspect.
[0044] Compared with the prior art, the video playback method, device, electronic device and medium provided by the present invention have the following advantages:
[0045] The playback method of the present invention obtains a video stream to be played, directly decodes the video stream into multiple image frames in RGBA format and stores them in a display memory, so that the image frame is directly decoded into RGBA image data instead of traditional YUV image data, omitting the process of converting the YUV format to RGBA format in the traditional processing method, storing the current frame data to be output in the multiple image frames in the synchronization buffer area of the display memory, and outputting the cache information including at least the image data information of the current frame data to the frame buffer memory of the main memory. When the current frame data in the synchronization buffer area and the current frame data in the frame buffer memory are the same, it can be determined that the data transmission is correct, and then the current frame data in the synchronization buffer area is output to play the video stream. The processing flow of the playback method ensures that the video stream data is always in the display memory. Compared with the traditional solution of setting up a cache area in the main memory, the copying of data from the display memory to the main memory is reduced, thereby improving the processing efficiency of video playback. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 A schematic diagram of an existing xvideo output framework provided by an embodiment of the present invention;
[0048] Figure 2 A flowchart of a video playback method provided by an embodiment of the present invention;
[0049] Figure 3 A flowchart of storing an image frame into a display memory provided by an embodiment of the present invention;
[0050] Figure 4A flowchart of activating an xvideo output framework provided by an embodiment of the present invention;
[0051] Figure 5 A flowchart of outputting current frame data to a main memory provided by an embodiment of the present invention;
[0052] Figure 6 A flowchart of playing current frame data provided by an embodiment of the present invention;
[0053] Figure 7 A schematic diagram of an xvideo output framework provided by an embodiment of the present invention;
[0054] Figure 8 A data flow diagram of video output provided by an embodiment of the present invention;
[0055] Fig. 9 A schematic diagram of the structure of a video playback device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0056] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention belong to the scope of protection of the embodiments of the present invention.
[0057] The video playback task consists of two main parts: video decoding and video rendering output. Compared with the two, video rendering output has a higher CPU usage rate and has a more direct impact on the video playback effect. In the Linux system, the main interfaces of the GPU-based video framework include VDPAU (Video Decode and Presentation API video decoding display interface) and VAAPI (Video Acceleration API video acceleration interface), but these two interfaces are complex to implement, have a long processing flow, and have relatively slow processing efficiency for video playback.
[0058] The video playback method of the embodiment of the present invention can be applied to xvideo, VAAPI or VDPAU based on the GPU to output video images. Those skilled in the art will understand that the output schemes of VAAPI and VDPAU require 3D and underlying driver support, and the implementation process is relatively complex. Xvideo is a control that outputs images before a video is played. Its output application is a lightweight framework, which is easy to implement and has lower development difficulty. It is suitable for low-power chip solutions. The following embodiment of the present invention will take the application of the xvideo output framework as an example to specifically explain how to implement the playback method proposed in the embodiment of the present invention.
[0059] The output diagram of the existing xvideo output framework is as follows Figure 1 As shown, specifically, the steps of video output are as follows:
[0060] S1. The video stream is first decapsulated and decoded by the multimedia platform, and the YUV image data of the image frame is obtained after processing. At this time, the YUV image data is stored in the display memory (or video memory), and the data in the display memory needs to be transferred to the main memory (or main memory). It can be understood that because the main memory needs to be used to transfer the YUV image data in the xvideo transmission, the data needs to be transferred from the display memory to the main memory.
[0061] S2. The YUV image data in the main memory is transferred to the xvideo output frame through the xserver interface, and the YUV image data in the main memory is transferred to the display memory. The GPU needs to operate the display memory to complete subsequent processing.
[0062] S3, GPU enlarges or reduces the original YUV image frame according to the display specifications of the target video, that is, the scaling function.
[0063] S4. GPU converts the scaled YUV image into an RGBA image.
[0064] S5. The GPU displays the RGBA image to be displayed and merges it with the display window for playback.
[0065] The above data processing process involves multiple data copies between the display memory and the main memory, which affects the video processing efficiency. The following will specifically explain the technical solution of the embodiment of the present invention. Please refer to the following for how to improve the processing efficiency of video playback. Figure 2 , Figure 2 A flowchart of a video playback method provided by an embodiment of the present invention includes:
[0066] S11. Obtain the video stream to be played.
[0067] Specifically, the video stream is a data stream of a video to be played, which includes video data continuously transmitted in chronological order on a data network. The video data is processed in a prescribed encoding method and then transmitted. After the video stream is obtained, step S12 is entered.
[0068] S12: Decode the video stream into multiple image frames in RGBA format and store them in a display memory.
[0069] Specifically, the video needs to be decoded before it is played. After the image frame is decoded into RGBA format, no further format conversion is required. Decoding can be hard decoding or soft decoding, and it is sufficient to decode the video stream into an image frame in RGBA format. During decoding, the video stream data is first read, the GPU decoding component is initialized, the output mode of the GPU decoding is set, and the image frame obtained after GPU decoding is in RGBA format, and then stored in the display memory. It can be understood that the RGBA format is the format required for the display screen to directly play the video.
[0070] In a specific implementation, decoding a video stream into a plurality of image frames in RGBA format and storing the frames in a display memory includes:
[0071] The multimedia platform reads the video stream; according to the output mode configured by the multimedia platform, the video stream is processed by hard decoding; according to the hard decoding result of the multimedia platform, a plurality of image frames in RGBA format are obtained; and the plurality of image frames are stored in the display memory.
[0072] Specifically, the multimedia platform is software that configures the decoding components in the GPU, such as ffmpeg, gstreamer, etc. Through the multimedia platform, the hard decoding output format of the image frame can be configured to obtain the image frame in RGBA format, and the image frame is stored in the display memory accordingly. It can be understood that the hard decoding processing rate is faster, which can release the CPU from the heavy video decoding operation, so that the player has the ability to smoothly play high-definition video.
[0073] In a specific implementation, storing a plurality of image frames into a display memory includes:
[0074] Generate a video memory request instruction according to the image format and resolution of the image frame; obtain video memory space of the display memory according to the video memory request instruction; and store the image frames in the video memory space in sequence according to the decoding order of the multiple image frames.
[0075] Specifically, the resolution represents the clarity of the current frame data playback. The higher the resolution, the better the corresponding playback clarity. Conversely, the lower the resolution, the worse the corresponding playback clarity. Different image frame formats also correspond to different video memory spaces allocated in the display memory. The video memory request instruction is generated based on the resolution of the current frame data and the allocation specification of the RGBA format. The corresponding video memory space is applied for in the display memory based on the video memory request instruction, and the image frames are sequentially stored in the video memory space according to the decoding order of multiple image frames.
[0076] See also Figure 3 , Figure 3 A flowchart for storing an image frame into a display memory, comprising:
[0077] S101, initializing GPU hard decoding component.
[0078] S102: Decapsulate the video to obtain data including but not limited to the encoding format, resolution size, and timestamp of the video.
[0079] S103, setting the video decoding output format of the GPU to RGBA.
[0080] S104, allocate corresponding video memory space according to the RGBA format and the video resolution, and store it in the display memory. After the image frame is stored in the display memory, the process proceeds to step S13.
[0081] S13, storing the current frame data to be output among the multiple image frames into the synchronization buffer area of the display memory.
[0082] Specifically, multiple image frames are decoded in the display order of video stream playback, and the current frame data is the image frame data to be output and displayed in the display order. The synchronization buffer is used to store the current frame data. The synchronization buffer can preset a video memory space in its video memory capacity according to the capacity of the current frame data through the display memory. The synchronization buffer is used to cache the current frame data. The current frame data represents the image data to be output, so as to achieve the purpose of video playback synchronization. When the GPU is operating, the decoded current frame data is stored in the requested video memory space to complete the caching operation of the current frame data in the synchronization buffer.
[0083] In a specific implementation, the output frame for playing the video stream is xvideo, and before inputting the current frame data belonging to the image frame into the synchronization buffer area of the display memory, it also includes:
[0084] Initializes the xorg server and the hardware abstraction layer for display memory, and makes the xvideo output framework active.
[0085] Specifically, the xorg server is used for data transmission of the xvideo output framework. The hardware abstraction layer is an interface layer between the operating system kernel and the hardware circuit. Its purpose is to abstract the hardware to establish corresponding processing functions. Figure 4 , activating the xvideo output framework includes the following process:
[0086] S201, start the xorg server, initialize the xorg driver of the GPU, including initialization of the xvideo interface.
[0087] S202, initialize the hardware abstraction layer of the GPU, and establish the 2D scaling function and video memory read and write function in the xvideo output framework.
[0088] S203, setting the state of the xvideo output framework to an activated state, and waiting for a system call.
[0089] When the xvideo output framework is used for video playback, the xvideo output framework can be activated through the above steps to establish the corresponding processing function. After the current frame data is input into the synchronization buffer area, step S14 is entered.
[0090] S14. Outputting the cache information of the synchronization cache area to the frame buffer memory of the main memory, wherein the cache information at least includes the current frame data.
[0091] Specifically, the main memory is used for temporary storage of data during CPU operation and processing. The main memory is needed to transfer data during video playback. Therefore, the cache information needs to be transferred to the frame buffer memory (or frame buffer). Other data other than the current frame data can also be synchronously transferred to the frame buffer memory according to needs, such as the size of the current frame data. Please refer to Figure 5 , the current frame data transmission process includes:
[0092] S301, the GPU completes video decoding on the multimedia platform and obtains a corresponding image frame (or video frame data) in RGBA format.
[0093] S302, storing the decoded image frame data into the requested video memory space, and moving (or transferring storage) the image frame in the video memory to the synchronization buffer area through the GPU.
[0094] S303, transferring the cache information to the frame buffer memory in the main memory. After the cache information is output to the frame buffer memory, the process proceeds to step S15.
[0095] S15. When the current frame data in the synchronization buffer area is the same as the current frame data in the frame buffer memory, output the current frame data in the synchronization buffer area to play the video stream.
[0096] Specifically, in the output frame, when the current frame data in the synchronization cache area and the current frame data in the frame buffer memory are the same, it can be said that the data transmission is correct (that is, it is determined that the data transmission is correct), and the current frame data is output; on the contrary, if they are different, it means that there may be an abnormality in the data transmission, and the current frame data is exited from the playback sequence. Since the current frame data is in RGBA format, it can be played and displayed directly on the display.
[0097] In a specific implementation, the output frame of the video stream is xvideo, and when the current frame data of the synchronization buffer is the same as the current frame data of the frame buffer memory, the current frame data of the synchronization buffer is output, including:
[0098] Configure the xorg server to transmit the current frame data in the synchronization buffer to the transmission interface of the xvideo output framework; the xorg server reads the cache information through the transmission interface and stores the cache information in the frame buffer memory; determine whether the current frame data in the synchronization buffer and the current frame data in the frame buffer memory are the same; if so, scale the current frame data in the synchronization buffer and output it to the preset playback window for fusion display.
[0099] Specifically, when the output frame of the video stream is xvideo, the current frame data of the frame buffer memory can be obtained in xvideo. When the video decoding is completed, the decoded current frame data is stored in the synchronization buffer area, and the current frame data is transferred to the frame buffer memory, and the current frame data (or frame information) in the frame buffer memory is transferred to the xorg server through the transmission interface (or client interface) of xvideo. The cache information represents the relevant parameters corresponding to the synchronization buffer area, such as the current frame data stored in the synchronization buffer area and the size of the current frame data. The cache information is stored in the frame buffer memory through the transmission interface, so that the cache information is transferred to the xorg server through the xvideo output frame, and the xvideo output frame reads the transferred cache information to judge the correctness of the current frame data transmission, and determine whether the current frame data in the synchronization buffer area and the current frame data in the frame buffer memory are the same. If so, it means that the data transmission is correct, then the current frame data in the synchronization buffer area is scaled and processed, and output to the preset playback window for fusion display to play the video; if not consistent, then exit the playback sequence. It can be understood that the current frame data is represented in binary form. To confirm whether the data is the same, the binary codes corresponding to the data can be compared one by one. If they are completely consistent, the data is the same. When fused with the playback window, the 2D module of the GPU scales the current frame data in the synchronization buffer area according to the read current frame data and the width and height of the current frame data to be displayed, and displays it in the desktop playback window to achieve the purpose of fusion display.
[0100] In a specific implementation, scaling the current frame data of the synchronization buffer area and outputting it to a preset playback window for fusion display includes:
[0101] Obtain the display specifications of the current frame data; scale the current frame data according to the display specifications, and output the scaling result to a preset display area of the display memory; and play and display the current frame data in the preset display area in the playback window.
[0102] Specifically, the display specification represents the display width and height of the current frame data playback, which can be determined according to the decoding result of the current frame data, and usually has a standard width and height, such as 1920×1080, 800×480, etc. The display specification may be different from the image output by the xvideo output framework. The current frame data is scaled and processed according to the display specification and output to the preset display area for playback and display in the player's playback window.
[0103] In a specific implementation, scaling the current frame data according to the display specification and outputting the scaling result to a preset display area of the display memory includes:
[0104] Read the display specifications and current frame data; scale and process the current frame data according to the display specifications and store it in the preset display area.
[0105] Specifically, the preset display area is a preset storage area in the display memory. After the current frame data is scaled and stored in the preset display area, it can be displayed on the desktop for video playback. Figure 6 , the playing steps include:
[0106] S401, reading the display width and height of the current frame data and the image data of the current frame data;
[0107] S402, transmitting display width, height and image data to the 2D module of the GPU;
[0108] S403, the GPU scales the image frames in the synchronization buffer area according to the video display width and height, and then stores the scaled image frames in a preset display area, and directly displays them on the desktop.
[0109] The following embodiments of the present invention will be combined with Figure 7 , describing the video playback process, which specifically includes the following steps:
[0110] S71, in the multimedia platform, read the video stream, complete the initialization of the GPU decoding component, set the output mode of the GPU decoding component, so that after the GPU decodes the video stream, the format of the image frame obtained is RGBA, and apply for the video memory space of the image frame through the GPU;
[0111] S72, initialize the xvideo driver, including establishing GPU video memory read and write functions, 2D scaling functions, etc.;
[0112] S73, the GPU completes the video hard decoding, stores the image frame into the requested video memory space, and transfers the image frame into the synchronization buffer area of the GPU for video synchronization;
[0113] S74, transferring the cache information of the synchronization cache area to the frame cache in the main memory;
[0114] S75, transmitting the cache information stored in the frame buffer through the XV interface of the player, so that the cache information is transmitted to the xvideo output frame through the xorg server;
[0115] S76, reading the transmitted cache information in the xvideo output frame, judging the correctness of the current frame data, if the current frame data in the synchronization cache area is the same as the current frame data in the frame buffer memory, then reading the current frame data, if not consistent, then exiting the play sequence;
[0116] S77. The 2D module of the GPU scales the current frame data in the synchronization buffer area according to the read current frame data and the width and height of the current frame data to be displayed, stores the scaled current frame data in RGBA format into the preset display area, and displays it on the desktop.
[0117] S78, merging the current frame data with the window for display.
[0118] See also Figure 8 , steps S71-S78 can be implemented in the GPU by configuring corresponding modules, specifically including:
[0119] Decoding module: used to implement steps S71-S73;
[0120] Transmission module: used to implement steps S74-S75;
[0121] Output module: used to implement steps S76-S78;
[0122] Hardware abstraction module: provides the decoding module and the output module with the underlying driver calling interface. The decoding module uses this module to complete the video memory management, and the output module uses this module to complete the video memory management, video scaling, output display and other functions;
[0123] Bottom-level driver module: provides bottom-level interface support for the decoding module and hardware abstraction module, and calls the GPU to complete video processing.
[0124] Based on the same inventive concept as the playback method, the embodiment of the present invention also provides a video playback device, see Fig. 9 ,include:
[0125] The acquisition module 901 is used to acquire the video stream to be played;
[0126] A decoding module 902, configured to decode the video stream into a plurality of image frames in RGBA format and store the frames in a display memory;
[0127] A storage module 903 is used to store the current frame data to be output among the multiple image frames into the synchronization buffer area of the display memory;
[0128] A first output module 904, configured to output the cache information of the synchronization cache area to the frame buffer memory of the main memory, wherein the cache information at least includes the current frame data;
[0129] The second output module 905 is used to output the current frame data in the synchronization buffer area when the current frame data in the synchronization buffer area is the same as the current frame data in the frame buffer memory, so as to play the video stream.
[0130] In an optional embodiment, the decoding module includes:
[0131] A reading submodule, used for a multimedia platform to read the video stream;
[0132] A processing submodule, configured to perform hard decoding processing on the video stream according to an output mode configured on the multimedia platform;
[0133] A first obtaining submodule, configured to obtain a plurality of image frames in RGBA format according to a hard decoding result of the multimedia platform;
[0134] The first storage submodule is used to store the plurality of image frames into the display memory.
[0135] In an optional embodiment, the first storage submodule includes:
[0136] A generating unit, used for generating a video memory request instruction according to the image format and resolution of the image frame;
[0137] An obtaining unit, configured to obtain a video memory space of the display memory according to the video memory request instruction;
[0138] The storage unit is used to store the multiple image frames in the video memory space in sequence according to the decoding order of the multiple image frames.
[0139] In an optional embodiment, the output framework for playing the video stream is xvideo, and the device further includes:
[0140] The initialization module is used to initialize the hardware abstraction layer of the xorg server and the display memory, so that the xvideo output framework is in an activated state.
[0141] In an optional embodiment, the output framework for playing the video stream is xvideo, and the second output module includes:
[0142] A transmission submodule, used for configuring the xorg server to transmit the current frame data in the synchronization buffer area to the transmission interface of the xvideo output framework;
[0143] A second storage submodule is used for the xorg server to read the cache information through the transmission interface and store the cache information in the frame buffer memory;
[0144] A determination submodule, used to determine whether the current frame data in the synchronization buffer area is the same as the current frame data in the frame buffer memory;
[0145] The first output submodule is used to scale the current frame data in the synchronization buffer area and output it to a preset playback window for fusion display when the current frame data in the synchronization buffer area is the same as the current frame data in the frame buffer memory.
[0146] In an optional embodiment, the first output submodule includes:
[0147] An acquisition unit, used for acquiring display specifications of the current frame data;
[0148] An output unit, configured to scale the current frame data according to the display specification and output the scaling result to a preset display area of the display memory;
[0149] A display unit is used to play and display the current frame data of the preset display area in the play window.
[0150] In an optional embodiment, the output unit includes:
[0151] A reading subunit, used for reading the display specification and the current frame data;
[0152] The processing subunit is used to scale the current frame data according to the display specification and store it in the preset display area.
[0153] Based on the same inventive concept as the playback method, an embodiment of the present invention also provides an electronic device, including a processor and a memory, wherein the memory is coupled to the processor, and the memory stores instructions, which, when executed by the processor, enable the electronic device to perform any step of the playback method.
[0154] Based on the same inventive concept as the playback method, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of any one of the methods described in the playback method are implemented.
[0155] The technical solution provided in the embodiments of the present invention has at least the following technical effects or advantages:
[0156] 1. The playback method obtains the video stream to be played, directly decodes the video stream into multiple image frames in RGBA format and stores them in the display memory, so that the image frame is directly decoded into RGBA image data instead of traditional YUV image data, omitting the process of converting the YUV format to RGBA format in the traditional processing method, and stores the current frame data to be output in the multiple image frames in the synchronization buffer area of the display memory, and outputs the cache information including at least the current frame data image data information to the frame buffer memory of the main memory. When the current frame data in the synchronization buffer area and the current frame data in the frame buffer memory are the same, it can be determined that the data transmission is correct, and then the current frame data in the synchronization buffer area is output to play the video stream. The processing flow of the playback method ensures that the video stream data is always in the display memory. Compared with the traditional solution of setting up a cache area in the main memory, it reduces the copy of data from the display memory to the main memory, thereby improving the processing efficiency of video playback.
[0157] 2. When processing output based on the xvideo output framework, the current frame data is transmitted to the xvideo output framework through the xorg server, so that the GPU can be directly used to complete the scaling of the image frame, further improving the processing efficiency of video playback.
[0158] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0159] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (modules, systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0160] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0161] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0162] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0163] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for playing a video, It is characterized in that include: Get the video stream to be played; Decoding the video stream into multiple image frames in RGBA format and storing them in a display memory; storing the current frame data to be outputted among the plurality of image frames in a synchronous buffer area of the display memory; Outputting the cache information of the synchronization cache area to the frame buffer memory of the main memory, wherein the cache information at least includes the current frame data; When the current frame data in the synchronization buffer area is the same as the current frame data in the frame buffer memory, the current frame data in the synchronization buffer area is output to play the video stream.
2. The video playback method according to claim 1, It is characterized in that Decoding the video stream into a plurality of image frames in RGBA format and storing the frames in a display memory comprises: The multimedia platform reads the video stream; According to the output mode configured by the multimedia platform, hard decoding processes the video stream; According to the hard decoding result of the multimedia platform, a plurality of image frames in RGBA format are obtained; A plurality of the image frames are stored in the display memory.
3. The video playback method according to claim 2, It is characterized in that The storing the plurality of image frames into the display memory comprises: Generate a video memory request instruction according to the image format and resolution of the image frame; Obtaining video memory space of the display memory according to the video memory request instruction; According to the decoding order of the multiple image frames, the multiple image frames are sequentially stored in the video memory space.
4. The video playback method according to claim 1, It is characterized in that The output frame for playing the video stream is xvideo, and before storing the current frame data to be output among the plurality of image frames into the synchronization buffer area of the display memory, it also includes: Initialize the hardware abstraction layer of the xorg server and the display memory, and make the xvideo output framework active.
5. The video playback method according to claim 1, It is characterized in that The output frame for playing the video stream is xvideo, and when the current frame data in the synchronization buffer area is the same as the current frame data in the frame buffer memory, the current frame data in the synchronization buffer area is output, including: Configure the xorg server to transmit the current frame data in the synchronization buffer area to the transmission interface of the xvideo output framework; The xorg server reads the cache information through the transmission interface and stores the cache information in the frame buffer memory; Determining whether the current frame data of the synchronization buffer area is the same as the current frame data of the frame buffer memory; If so, the current frame data of the synchronization buffer area is scaled and processed, and output to a preset playback window for fusion display.
6. The video playback method according to claim 5, It is characterized in that The scaling process of the current frame data in the synchronization buffer area and outputting the current frame data to a preset playback window for fusion display includes: Obtaining display specifications of the current frame data; Scaling the current frame data according to the display specification, and outputting the scaling result to a preset display area of the display memory; The current frame data of the preset display area is played and displayed in the play window.
7. The video playback method according to claim 6, It is characterized in that The scaling process of the current frame data according to the display specification and outputting the scaling process result to a preset display area of the display memory includes: Reading the display specification and the current frame data; The current frame data is scaled and processed according to the display specification, and stored in the preset display area.
8. A video playback device, It is characterized in that include: An acquisition module is used to acquire the video stream to be played; A decoding module, used for decoding the video stream into a plurality of image frames in RGBA format and storing the frames in a display memory; A storage module, used for storing the current frame data to be output among the plurality of image frames into the synchronization buffer area of the display memory; A first output module, configured to output the cache information of the synchronization cache area to a frame buffer memory of a main memory, wherein the cache information at least includes the current frame data; The second output module is used to output the current frame data in the synchronization buffer area when the current frame data in the synchronization buffer area is the same as the current frame data in the frame buffer memory, so as to play the video stream.
9. An electronic device, It is characterized in that The electronic device comprises a processor and a memory, wherein the memory is coupled to the processor and stores instructions, and when the instructions are executed by the processor, the electronic device executes the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the steps of the method described in any one of claims 1 to 7 are implemented.
