Data processing method and device, electronic equipment and computer readable storage medium
By grouping and configuring parameters of the data stream to be encoded, the problem of incompatibility between different types of graphics cards on the same terminal is solved, realizing unified parameter configuration and group encoding of graphics cards, and improving encoding speed and efficiency.
Patent Information
- Application Number
- CN202310960516.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-01
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2043-08-01
AI Technical Summary
In the current technology, different types of graphics cards are not compatible on the same terminal, resulting in slow encoding speed and high encoding pressure on a single graphics card.
By grouping the data stream to be encoded into multiple sub-data streams, and configuring the parameters of at least two graphics cards with different type identifiers according to the encoding parameters, encoding is performed using these graphics cards, and finally the encoded data is reassembled to achieve unified parameter configuration and group encoding for different types of graphics cards.
It improves encoding speed and efficiency, is compatible with different types of graphics cards, balances the encoding load on the graphics card, and enhances overall encoding performance.
Smart Images

Figure CN117221608B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to computer technology, and particularly relates to a data processing method and device, electronic equipment and computer readable storage medium. BACKGROUND
[0002] The current hard coding technology is usually that a terminal encodes data through the same type of graphics card, different types of graphics cards cannot be compatible on the same terminal, the graphics card that can be used by the terminal is very limited, the coding speed is not fast enough, and the coding pressure of a single graphics card is large. SUMMARY
[0003] Embodiments of the present application provide a data processing method and device, electronic equipment and computer readable storage medium, which improves the coding speed by grouping and coding different types of graphics cards.
[0004] The technical scheme of the embodiments of the present application is as follows:
[0005] The embodiments of the present application provide a data processing method, comprising:
[0006] Grouping the to-be-coded data stream to obtain a plurality of groups of sub-data streams;
[0007] According to the obtained coding parameters, the at least two graphics cards are configured with parameters, and the at least two graphics cards are graphics cards with different types of identifiers;
[0008] The plurality of groups of sub-data streams are encoded by the at least two graphics cards configured with parameters respectively, to obtain corresponding coded data;
[0009] The plurality of groups of coded data are recombined to obtain a coded data stream corresponding to the to-be-coded data stream.
[0010] In the above scheme, the grouping of the to-be-coded data stream comprises:
[0011] A grouping length is obtained, and the grouping length represents the number of frames of the sub-data stream;
[0012] The to-be-coded data stream is grouped according to the grouping length.
[0013] In the above scheme, the encoding of the plurality of groups of sub-data streams by the at least two graphics cards based on the coding parameters comprises:
[0014] The plurality of groups of sub-data streams are distributed to the at least two graphics cards;
[0015] The distributed sub-data streams are encoded by the at least two graphics cards based on the coding parameters respectively.
[0016] In the scheme, the assigning the multiple groups of sub-data streams to the at least two display cards comprises:
[0017] obtaining an assignment parameter;
[0018] according to the assignment parameter, assigning the multiple groups of sub-data streams to the at least two display cards through multiple rounds of assignment in a grouping order of the multiple groups of sub-data streams, the assignment parameter comprising a quantity ratio of sub-data streams assigned to each display card in each round of assignment in the multiple rounds of assignment.
[0019] In the scheme, the method further comprises:
[0020] obtaining an encoding capability parameter of each display card in the at least two display cards;
[0021] determining the quantity ratio according to the encoding capability parameter of each display card.
[0022] In the scheme, the encoding parameter comprises an encoding format, and before the assigning the encoding parameter to the at least two display cards respectively, the method further comprises:
[0023] determining the at least two display cards capable of supporting the encoding format from at least two alternative display cards according to the encoding format.
[0024] In the scheme, the method further comprises:
[0025] adding a group of pictures sequence number to the multiple groups of sub-data streams respectively according to a grouping order of the multiple groups of sub-data streams, the group of pictures sequence number corresponding to the grouping order;
[0026] wherein the encoded data carries a group of pictures sequence number of a corresponding sub-data stream, and the data recombining the multiple groups of encoded data comprises:
[0027] recombining the multiple groups of encoded data according to the grouping order corresponding to the group of pictures sequence number carried by each encoded data.
[0028] In the scheme, the assigning the encoding parameter to the at least two display cards respectively according to the encoding parameter comprises:
[0029] assigning the encoding parameter to the at least two display cards respectively;
[0030] determining a corresponding sequence parameter set and a picture parameter set according to the encoding parameter through the at least two display cards respectively, and assigning the sequence parameter set and the picture parameter set to the corresponding display card;
[0031] wherein the sequence parameter set and the picture parameter set are used for adding the corresponding sequence parameter set and the picture parameter set to corresponding encoded data in the process of encoding by the corresponding display card.
[0032] In the above solution, before the data recombination on the multiple groups of the encoded data, the method further comprises:
[0033] In response to a change instruction of the encoding parameter, obtaining a new encoding parameter;
[0034] Respective new parameter configurations are determined according to the new encoding parameter through the at least two graphic cards, and the new parameter configurations are distributed to the corresponding graphic cards.
[0035] In the above solution, the method further comprises:
[0036] The encoded data stream is divided into multiple groups of to-be-decoded data packets;
[0037] The multiple groups of to-be-decoded data packets are decoded through the at least two graphic cards to obtain corresponding decoded data;
[0038] The multiple groups of the decoded data are recombined to obtain a corresponding decoded data stream.
[0039] An embodiment of the present application provides a data processing apparatus, comprising:
[0040] A grouping module is configured to group a to-be-encoded data stream to obtain multiple groups of sub-data streams;
[0041] A configuration module is configured to perform parameter configuration on at least two graphic cards according to the obtained encoding parameter, wherein the at least two graphic cards are graphic cards with different types of identification;
[0042] An encoding module is configured to encode the multiple groups of sub-data streams through the at least two graphic cards after the parameter configuration to obtain corresponding encoded data;
[0043] A recombination module is configured to recombine the multiple groups of the encoded data to obtain an encoded data stream corresponding to the to-be-encoded data stream.
[0044] An embodiment of the present application provides an electronic device, comprising:
[0045] A memory is configured to store executable instructions;
[0046] A processor is configured to execute the executable instructions stored in the memory to implement the data processing method provided in the embodiments of the present application.
[0047] An embodiment of the present application provides a computer readable storage medium storing executable instructions, which are used to cause a processor to execute the data processing method provided in the embodiments of the present application.
[0048] The embodiment of the present application groups the to-be-encoded data stream to obtain multiple groups of sub-data streams, configures parameters for at least two graphic cards with different types of identifiers respectively according to the obtained encoding parameters, encodes the multiple groups of sub-data streams through the at least two graphic cards configured with parameters respectively to obtain corresponding encoded data, and recombines the multiple groups of encoded data to obtain an encoded data stream corresponding to the to-be-encoded data stream, thereby completing encoding. The multiple graphic cards are configured with parameters based on the same encoding parameters, so that the graphic cards of different types have unified parameter configuration, and then the grouping and encoding are performed based on this, thereby improving the encoding efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0049] Figure 1 is an optional structural schematic diagram of an electronic device 100 provided by the embodiment of the present application;
[0050] Figure 2 is an optional flow schematic diagram of a data processing method provided by the embodiment of the present application;
[0051] Figure 3 is an optional detailed flow schematic diagram of step 201 provided by the embodiment of the present application;
[0052] Figure 4 is an optional detailed flow schematic diagram of step 203 provided by the embodiment of the present application;
[0053] Figure 5 is an optional detailed flow schematic diagram of step 202 provided by the embodiment of the present application;
[0054] Figure 6 is an optional flow schematic diagram after step 204 provided by the embodiment of the present application. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical scheme and advantages of the present application more clear, the present application will be further described in detail below with reference to the drawings, and the described embodiments should not be regarded as limiting the present application. All other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0056] In the following description, "some embodiments" are related to a subset of all possible embodiments, but it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments, and can be combined with each other without conflict.
[0057] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0059] This application provides a data processing method, apparatus, electronic device, and computer-readable storage medium that are compatible with different types of graphics cards and improve encoding speed.
[0060] First, the electronic device for implementing the above-described data processing method, as provided in the embodiments of this application, will be described. See also... Figure 1 , Figure 1 This is an optional structural diagram of the electronic device 100 provided in this application embodiment. In practical applications, the electronic device 100 can be implemented as a terminal. The terminal can be a laptop, tablet, desktop computer, smartphone, portable gaming device, etc., but is not limited to these. Figure 1 The illustrated electronic device 100 includes at least one processor 101, a memory 105, at least one network interface 102, and a user interface 103. The various components of the electronic device 100 are coupled together via a bus system 104. It is understood that the bus system 104 is used to implement communication between these components. In addition to a data bus, the bus system 104 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 1 The general labeled all buses as Bus System 104.
[0061] The processor 101 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0062] The user interface 103 includes one or more output devices 1031 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 103 also includes one or more input devices 1032 that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0063] The memory 105 can be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard drives, optical drives, and the like. The memory 105 optionally includes one or more storage devices remotely located from the processor 101 in a physical location.
[0064] The memory 105 includes volatile memory or nonvolatile memory, and can also include both volatile and nonvolatile memory. Nonvolatile memory can be read only memory (ROM), volatile memory can be random access memory (RAM). The memory 105 described in embodiments of the present application is intended to include any suitable type of memory.
[0065] In some embodiments, the memory 105 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or a subset or superset thereof. In embodiments of the present application, the memory 105 stores an operating system 1051, a network communication module 1052, a presentation module 1053, an input processing module 1054, and a data processing device 1055. Specifically,
[0066] The operating system 1051 includes system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, and the like, for implementing various basic services and processing hardware-based tasks;
[0067] The network communication module 1052 is used to communicate with other computing devices via one or more (wired or wireless) network interfaces 102, examples of which include Bluetooth, wireless compatibility certification (WiFi), and universal serial bus (USB), and the like;
[0068] The presentation module 1053 is used to enable presentation of information via one or more output devices 1031 associated with the user interface 103 (e.g., display screens, speakers, and the like) (e.g., user interfaces for operating peripheral devices and displaying content and information);
[0069] The input processing module 1054 is configured to detect one or more user inputs or interactions from one or more input devices 1032 and translate the detected inputs or interactions.
[0070] In some embodiments, the data processing apparatus provided by the embodiments of the present application can be implemented in software, Figure 1 The data processing apparatus 1055 stored in the memory 105 is shown, which can be software in the form of programs and plug-ins, etc., including the following software modules: grouping module 10551, configuration module 10552, encoding module 10553 and re-grouping module 10554. These modules are logical, and thus can be combined or further split according to the implemented functions. The functions of each module will be described below.
[0071] In some other embodiments, the data processing apparatus provided by the embodiments of the present application can be implemented in hardware, for example, the data processing apparatus provided by the embodiments of the present application can be a processor in the form of hardware decoding processor, which is programmed to execute the data processing method provided by the embodiments of the present application. For example, the processor in the form of hardware decoding processor can use one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field programmable gate array (FPGA) or other electronic elements.
[0072] The data processing method provided by the embodiments of the present application will be described below in combination with exemplary applications and implementations of the terminal provided by the embodiments of the present application.
[0073] Referring to Figure 2 , Figure 2 is an optional flowchart of the data processing method provided by the embodiments of the present application, which will be described in combination with the steps shown. Figure 2
[0074] Step 201, grouping the to-be-encoded data stream to obtain a plurality of groups of sub-data streams;
[0075] Step 202, according to the obtained encoding parameters, respectively configuring parameters for at least two graphics cards, the at least two graphics cards being graphics cards with different types of identification;
[0076] At step 203, the multiple groups of sub-data streams are encoded by the at least two graphics cards with the configured parameters respectively to obtain corresponding encoded data.
[0077] At step 204, the multiple groups of encoded data are recombined to obtain an encoded data stream corresponding to the to-be-encoded data stream.
[0078] Here, the type identifier can be used to include at least one of the vendor information, the brand information and the model of the graphics card. Different type identifiers can represent that the graphics cards come from different vendors or different brands, or represent different models of graphics cards. For example, the brand of the graphics card can be Intel, AMD, NVIDIA, etc. The model of the graphics card can be NVIDIA QuadroRTX 6000, AMD Radeon Pro VII, NVIDIA Quadro P4000 and AMD Radeon Pro WX 7100, etc. The terminal of the embodiment of the present application can identify graphics cards of multiple different type identifiers and configure parameters for the graphics cards of different type identifiers to enable the graphics cards of different type identifiers to perform combined encoding. In a possible implementation, the hardware basic input output system (BIOS, Basic Input Output System) and the general driver of the terminal can identify graphics cards of different type identifiers and perform grouped encoding using the graphics cards of different type identifiers.
[0079] In actual implementation, the to-be-encoded data stream can be a data stream composed of multiple image frames. The format of the image frame can be ycbcr format. The terminal groups the to-be-encoded data stream into multiple groups of sub-data streams. Here, each group of sub-data streams includes at least one image frame. The terminal obtains encoding parameters and configures parameters for the at least two graphics cards according to the obtained encoding parameters. Here, the terminal configures parameters for the graphics cards each time the to-be-encoded data stream is encoded to perform encoding using the graphics cards with the configured parameters. Specifically, the encoding parameters include at least one of the following multiple types: encoding format, resolution of the image, length and width of the image, frame rate, bit rate, quantization parameter (QP, Quantizer Parameter) and input data type, etc. The encoding format can be H264, H265, avi, JPEG or MPEG, etc. The input data type is the type of the to-be-encoded data stream, which can be YUV format, RGB format or ycbcr format, for example. It should be understood that the type of the sub-data stream is the same as the type of the to-be-encoded data stream. In the embodiment of the present application, the encoding parameters can be pre-set, and the terminal can obtain the corresponding encoding parameters in response to a parameter input operation. The encoding parameters can also be updated based on a user parameter input operation before each encoding. Specifically, the terminal initializes the at least two graphics cards respectively according to the encoding parameters to configure parameters for the at least two graphics cards.
[0080] In actual implementation, after the parameter configuration of the graphics cards, the corresponding graphics cards after parameter configuration are obtained. Then, the terminal encodes the multiple groups of sub-data streams by using the at least two graphics cards after parameter configuration, to obtain corresponding encoding data. It should be understood that the encoding in the embodiments of the present application is hardware encoding. In the embodiments of the present application, the graphics cards can perform the encoding operation in parallel, that is, the at least two graphics cards can simultaneously perform the encoding of the corresponding sub-data streams, so as to improve the encoding efficiency. After the encoding is completed, the multiple groups of encoding data are obtained. The terminal then recombines the multiple groups of encoding data to obtain the encoding data stream corresponding to the encoding data stream. Here, the terminal recombines the multiple groups of encoding data according to the grouping order of the multiple groups of sub-data streams, to obtain the encoding data stream. Exemplarily, if the data stream to be encoded is grouped into sub-data stream 1, sub-data stream 2 and sub-data stream 3 in order, and the corresponding encoding data is encoding data 1, encoding data 2 and encoding data 3, then the three groups of encoding data are recombined in order to obtain the encoding data stream.
[0081] The embodiments of the present application group the data stream to be encoded into multiple groups of sub-data streams, parameter configure at least two graphics cards with different types of identification respectively according to the obtained encoding parameters, encode the multiple groups of sub-data streams by using the at least two graphics cards after parameter configuration respectively, obtain corresponding encoding data, and recombine the multiple groups of encoding data to obtain the encoding data stream corresponding to the data stream to be encoded, so as to complete the encoding. By parameter configuring the multiple graphics cards based on the same encoding parameters, the graphics cards with different types have unified parameter configuration, and then the grouping encoding is performed based on this, so that the encoding efficiency is improved.
[0082] In some embodiments, referring to Figure 3 , Figure 3 is an optional detailed flowchart of step 201 provided by the embodiments of the present application, and the step 201 includes:
[0083] Step 2011, obtaining a grouping length, the grouping length representing the number of frames of the sub-data stream;
[0084] Step 2012, grouping the data stream to be encoded according to the grouping length.
[0085] Here, the packet length can be set before step 201, which represents the number of frames of the sub-data stream. The terminal groups the to-be-encoded data stream according to the packet length. In actual implementation, the terminal divides the to-be-encoded data stream according to the order of image frames in the to-be-encoded data stream according to the packet length, until the number of frames of the remaining to-be-encoded data stream is less than or equal to the packet length. Exemplarily, the packet length can be 240 frames. If the to-be-encoded data stream is 2100 frames, the to-be-encoded data stream can be grouped into 9 groups of sub-data streams, and the lengths of the first 8 groups of sub-data streams are all 240 frames, and the length of the last group of sub-data streams is 180 frames. In some embodiments, the packet length can also be set after step 201. The terminal obtains the packet length set by the user in response to the setting operation of the packet length. In actual scenarios, the user can determine a suitable packet length according to the length of the to-be-encoded data stream. The embodiments of the present application can make the to-be-encoded data stream be more evenly grouped by grouping the to-be-encoded data stream according to the packet length, so that the grouping can be allocated based on the grouping when performing grouped encoding, thereby improving the encoding efficiency.
[0086] In some embodiments, referring to Figure 4 , Figure 4 is an optional detailed flowchart of step 203 provided by the embodiments of the present application, and the step 203 comprises:
[0087] Step 2031, allocating the plurality of groups of sub-data streams to the at least two GPUs.
[0088] Step 2032, respectively encoding the allocated sub-data streams based on the encoding parameters by the at least two GPUs.
[0089] In actual implementation, the terminal allocates the plurality of groups of sub-data streams to the at least two GPUs, and the GPU encodes the corresponding sub-data stream based on the encoding parameters after obtaining the allocated sub-data stream. Here, the terminal can allocate the plurality of groups of sub-data streams to the at least two GPUs in order. Specifically, the terminal randomly selects a GPU as the first allocated GPU, allocates the first group of sub-data streams to the selected GPU, then selects a second GPU from the remaining GPUs to allocate the second group of sub-data streams, and sequentially allocates until there is no idle GPU. After waiting for the GPU to be idle after the encoding of the GPU is completed, the terminal continues to allocate the unallocated sub-data stream to the idle GPU in order until all the sub-data streams are allocated. In the embodiments of the present application, each GPU only encodes the allocated sub-data stream, and the division of labor of the at least two GPUs improves the encoding efficiency.
[0090] In some embodiments, the step 2031 comprises: obtaining an allocation parameter; and allocating the plurality of groups of sub-data streams to the at least two display cards in multiple rounds according to the allocation parameter, wherein the allocation parameter comprises a proportion of the number of sub-data streams allocated to each display card in each round of the multiple rounds.
[0091] Here, the allocation parameter can be pre-set. In actual implementation, the terminal allocates the plurality of groups of sub-data streams to the at least two display cards in multiple rounds according to the allocation parameter. Here, the allocation parameter can comprise a proportion of the number of sub-data streams allocated to each display card in each round. It should be understood that the data of the sub-data streams allocated to each display card can be different in each round. For example, if the number of display cards is 2 and the proportion of the number of sub-data streams allocated to each display card in each round is a:b, then the number of sub-data streams allocated in each round can be a groups and b groups, respectively. Here, the total number of sub-data streams is greater than a+b. By allocating sub-data streams in proportion, different display cards can be allocated sub-data streams in proportion to adapt to the capabilities of different display cards in actual scenarios and improve coding efficiency. In some embodiments, the allocation parameter can further comprise an allocation sequence of each display card in each round. Here, the allocation sequence of each display card in each round can be the same. For example, if there are display card A and display card B, the allocation sequence of each round can be set as display card A first and then display card B. By setting a fixed allocation sequence in each round, each display card can be regularly allocated and can be used relatively evenly.
[0092] In some embodiments, the method further comprises: obtaining an encoding capability parameter of each display card in the at least two display cards; and determining the proportion according to the encoding capability parameter of each display card.
[0093] In actual implementation, the proportion of the number of sub-data streams allocated to each display card in each round can be determined before step 203. Specifically, the terminal obtains an encoding capability parameter of each display card and determines the proportion according to the encoding capability parameter. Here, the encoding capability parameter can be the encoding speed and the determined proportion can be positively correlated with the encoding speed. For example, if the encoding speed of display card A is 60 FS and the encoding speed of display card B is 30 FS, then the proportion is 60 FS:30 FS=2:1. Embodiments of the present application determine the proportion of the number of sub-data streams allocated to each display card in each round according to the encoding capability parameter of each display card, so that each display card can complete the same round of encoding at the same time as much as possible, use the display card to the greatest extent, and improve coding efficiency.
[0094] In some embodiments, the encoding parameter comprises an encoding format, and before the configuring the at least two graphic cards with the encoding parameter respectively, the method further comprises: determining the at least two graphic cards capable of supporting the encoding format from at least two alternative graphic cards according to the encoding format.
[0095] Here, the encoding format can be, but is not limited to, H264, H265, avi, JPEG, MPEG, etc. In actual implementation, the terminal further selects the at least two graphic cards capable of supporting the corresponding encoding format from the at least two alternative graphic cards according to the encoding format, and performs group encoding based on the selected at least two graphic cards. Here, the at least two alternative graphic cards are graphic cards installed in the terminal, each graphic card has a different type of identification, and each graphic card supports one or more encoding formats. The types of encoding formats supported by different graphic cards can be all the same, partially the same, or completely different. After obtaining the encoding parameter, the terminal can select the at least two graphic cards according to the encoding parameter, and then configure the selected at least two graphic cards with the corresponding parameters. That is, the step of selecting the graphic cards can be performed after obtaining the encoding parameter. The embodiments of the present application can make the terminal compatible with multiple different graphic cards for corresponding group encoding by selecting the at least two graphic cards according to the encoding format.
[0096] In some embodiments, after step 201, the method further comprises: adding a group of picture sequence number to each of the plurality of groups of sub-data streams according to a grouping order of the plurality of groups of sub-data streams, the group of picture sequence number corresponding to the grouping order; wherein the encoded data carries the group of picture sequence number of the corresponding sub-data stream, and step 204 comprises: reorganizing the plurality of groups of encoded data according to the grouping order corresponding to the group of picture sequence number carried by each encoded data.
[0097] In actual implementation, after the terminal obtains the multiple groups of sub-data streams from the packet, the terminal adds a group of pictures (GOP) sequence number to each group of sub-data streams according to the packet order, so that each group of sub-data streams has a unique identifier representing the packet data. For example, for the data stream to be encoded, the following group of pictures sequence numbers can be added to the multiple groups of sub-data streams according to the packet order: GOP raw data 1, GOP raw data 2, …, GOP raw data n. Wherein, n is a positive integer greater than or equal to 2. In actual implementation, each word data stream takes a key instantaneous decoding refresh (IDR) frame as a starting frame, and the IDR frame can be encoded independently in the graphics card as an intra-frame encoding. After packet encoding, each encoded data carries the group of pictures sequence number of the corresponding sub-data stream. When the data is reorganized, the terminal can use the group of pictures sequence number of each encoded data to reorganize the multiple groups of encoded data according to the packet order corresponding to the group of pictures sequence number, so that the reorganized encoded data stream is consistent with the picture order of the original data stream to be encoded.
[0098] In some embodiments, referring to Figure 5 , Figure 5 is an optional detailed flowchart of step 202 provided by the embodiments of the present application, and the step 202 includes:
[0099] Step 2021, respectively configuring the encoding parameters to the at least two graphics cards;
[0100] Step 2022, respectively determining the corresponding sequence parameter set and image parameter set through the at least two graphics cards according to the encoding parameters, and configuring the sequence parameter set and image parameter set to the corresponding graphics card;
[0101] Wherein, the sequence parameter set and image parameter set are used to add the corresponding sequence parameter set and image parameter set to the corresponding encoded data in the process of encoding by the corresponding graphics card.
[0102] In actual implementation, the terminal configures the encoding parameters to the at least two GPUs, so that each GPU sets the corresponding encoding parameters. After configuring the encoding parameters, each GPU determines the corresponding sequence parameter set (SPS) and picture parameter set (PPS) according to the encoding parameters. Specifically, each GPU calculates its own SPS and PPS. The GPU adds the SPS and PPS in the corresponding encoded data during encoding. Specifically, the GPU can write the SPS and PPS in the header file of the encoded data. In the embodiments of the present application, since the encoding parameters configured by each GPU are the same, the SPS and PPS calculated by each GPU will also be the same in theory, and the error generated in the actual application scenario can be ignored. It should be understood that if the encoding format is H264, the SPS and PPS will also be the standard output of H264. The SPS and PPS will be used for decoding the encoded data stream. Since the SPS and PPS corresponding to each sub-data stream are relatively small, when the data is recombined, the SPS and PPS carried by one set of sub-data streams can be selected as the SPS and PPS of the encoded data stream, and only the SPS and PPS can be used to realize the decoding of the entire encoded data stream. In the embodiments of the present application, by configuring the encoding parameters, each GPU also calculates its own SPS and PPS using the encoding parameters when configuring the parameters, so that the GPU can add the corresponding SPS and PPS to the sub-data stream, thereby realizing the complete encoding process and facilitating the subsequent decoding of the encoded data stream.
[0103] In some embodiments, before the step 204, the method further includes: in response to the change instruction of the encoding parameters, obtaining new encoding parameters; and respectively through the at least two GPUs, re-determining the corresponding new parameter configurations according to the new encoding parameters, and distributing the new parameter configurations to the corresponding GPUs.
[0104] Here, the change instruction can be generated in response to a user's parameter update operation, and can also be generated based on a change condition. Here, the change condition can be, for example, network changes. In an actual scenario, the to-be-encoded data stream can be data obtained by video live streaming software. The recombined encoded data stream after encoding by the graphics card needs to be sent to the video live streaming software for playing. The video live streaming software is affected by the network of the terminal and automatically adjusts the video parameters of the video live streaming, and then adjusts the encoding parameters to generate a change instruction of the encoding parameters and determine new encoding parameters. For example, if the network becomes poor, the resolution of the video will be automatically reduced, and the new encoding parameters will correspond to a smaller resolution. After obtaining the new encoding parameters, the terminal reconfigures the parameters of the graphics cards according to the new encoding parameters, obtains new parameter configurations, and allocates the new parameter configurations to the corresponding graphics cards. Here, because the encoding parameters are changed, the graphics cards will recalculate the SPS and PPS based on the new encoding parameters. In actual implementation, the graphics cards will encode the sub-data streams based on the new parameter configurations. For the encoded data that has not been recombined, the terminal will update the SPS and PPS carried by the data. The embodiments of the present application reconfigure the parameters of the graphics cards when the encoding parameters change, so that the encoded data stream can adapt to the new encoding requirements in real time.
[0105] In some embodiments, referring to Figure 6 , Figure 6 is an optional flowchart provided by the embodiments of the present application after step 204. After step 204, the method further includes:
[0106] Step 301: The encoded data stream is divided into multiple groups of to-be-decoded data packets.
[0107] Step 302: The multiple groups of to-be-decoded data packets are decoded by the at least two graphics cards to obtain corresponding decoded data.
[0108] Step 303: The multiple groups of decoded data are recombined to obtain a corresponding decoded data stream.
[0109] In actual implementation, when the encoded data stream needs to be decoded and output, the terminal can split the encoded data stream into multiple groups of to-be-decoded data packets for grouped decoding. Here, the grouping can be performed according to the grouping manner of the to-be-encoded data, or can be performed according to the decoding requirement in an actual scenario. For example, the encoded data stream can be grouped into multiple groups of to-be-decoded data packets with small grouping length. Specifically, the terminal can obtain decoding capability parameters of each graphics card, and distribute the multiple groups of to-be-decoded data packets to at least two graphics cards for decoding based on the decoding capability parameters. Here, the number of to-be-decoded data packets allocated to each graphics card is positively correlated with the decoding capability. After obtaining the decoded data, the multiple groups of decoded data are recombined based on the grouping order, to obtain a corresponding decoded data stream. Here, after obtaining the decoded data stream, the decoded data stream can be input to a target playback application for output. The embodiment of the present application utilizes a graphics card to perform grouped decoding, and improves decoding efficiency through grouped hardware decoding.
[0110] In some embodiments, the encoded data stream can also be directly input to software for soft decoding. Specifically, step 204 further includes: sending the encoded data stream to a target playback application; decoding the encoded data stream by the target playback application to obtain a decoded data stream; and displaying the decoded data stream.
[0111] Here, the encoded data stream is directly input to the target playback application, and the target playback application performs soft decoding and displays the decoded data stream obtained by decoding, thereby reducing the pressure on the graphics card and facilitating the output and use of the decoded data stream.
[0112] The following continues to describe an exemplary structure of the data processing apparatus 1055 provided by the embodiment of the present application, which is implemented as a software module. In some embodiments, as shown in FIG. 10, the software module stored in the data processing apparatus 1055 of the memory 105 can include: Figure 1
[0113] A grouping module 10551 configured to group to-be-encoded data streams to obtain multiple groups of sub-data streams;
[0114] A configuration module 10552 configured to respectively configure parameters of at least two graphics cards according to the obtained encoding parameters, the at least two graphics cards being graphics cards with different types of identifiers;
[0115] An encoding module 10553 configured to respectively encode the multiple groups of sub-data streams by the at least two graphics cards configured with parameters to obtain corresponding encoded data;
[0116] A recombination module 10554 configured to recombine the multiple groups of encoded data to obtain an encoded data stream corresponding to the to-be-encoded data stream.
[0117] In some embodiments, the grouping module 10551 is further configured to obtain a grouping length, the grouping length representing a number of frames of the sub-data stream; and group the to-be-encoded data stream according to the grouping length.
[0118] In some embodiments, the encoding module 10553 is further configured to distribute the multiple groups of sub-data streams to the at least two GPUs; and respectively encode the distributed sub-data streams based on the encoding parameters by the at least two GPUs.
[0119] In some embodiments, the encoding module 10553 is further configured to obtain a distribution parameter; and distribute the multiple groups of sub-data streams to the at least two GPUs in multiple rounds according to a grouping order of the multiple groups of sub-data streams based on the distribution parameter, the distribution parameter including a quantity ratio of sub-data streams corresponding to each GPU in each round of distribution.
[0120] In some embodiments, the method further includes obtaining an encoding capability parameter of each GPU in the at least two GPUs; and determining the quantity ratio based on the encoding capability parameter of each GPU.
[0121] In some embodiments, the encoding parameter includes an encoding format, and the encoding module 10553 is further configured to determine the at least two GPUs capable of supporting the encoding format from at least two alternative GPUs based on the encoding format.
[0122] In some embodiments, the apparatus further includes a sequence number adding module configured to add a group of pictures sequence number to the multiple groups of sub-data streams respectively according to a grouping order of the multiple groups of sub-data streams, the group of pictures sequence number corresponding to the grouping order; and the reorganizing module 10554 is further configured to reorganize the multiple groups of encoded data according to the group of pictures sequence number corresponding to the grouping order by using the group of pictures sequence number carried by each encoded data.
[0123] In some embodiments, the configuration module 10552 is further configured to respectively configure the encoding parameters to the at least two GPUs; respectively determine corresponding sequence parameter sets and picture parameter sets based on the encoding parameters by the at least two GPUs, and configure the sequence parameter sets and the picture parameter sets to the corresponding GPUs; and the sequence parameter sets and the picture parameter sets are used to add the corresponding sequence parameter sets and the picture parameter sets to the corresponding encoded data in the process of encoding by the corresponding GPUs.
[0124] In some embodiments, the configuration module 10552 is further configured to obtain new encoding parameters in response to a change instruction of the encoding parameters; respectively determine new parameter configurations based on the new encoding parameters by the at least two GPUs, and distribute the new parameter configurations to the corresponding GPUs.
[0125] The apparatus further comprises a decoding module configured to split the encoded data stream into a plurality of groups of data packets to be decoded; decode, by the at least two graphics cards, the plurality of groups of data packets to be decoded to obtain corresponding decoded data; and recombine the plurality of groups of decoded data to obtain a corresponding decoded data stream.
[0126] It should be noted that the description of the apparatus of the embodiments of the present application is similar to the description of the method embodiments, and has similar beneficial effects as the method embodiments, and thus is not described herein.
[0127] The embodiments of the present application provide a computer program product or a computer program, which comprises computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to perform the data processing method described above.
[0128] The embodiments of the present application provide a computer readable storage medium storing executable instructions, wherein the executable instructions, when executed by a processor, cause the processor to perform the data processing method provided by the embodiments of the present application.
[0129] In some embodiments, the computer readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disc, or CD-ROM; or various devices comprising one or any combination of the above memories.
[0130] In some embodiments, the executable instructions can be in the form of a program, software, software module, script or code, written in any form of programming language (including a compiled or interpreted language, or a declarative or procedural language), and can be deployed in any form, including being deployed as a standalone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0131] As an example, the executable instructions can but need not correspond to a file in a file system, can be stored in a part of a file that holds other programs or data, for example, in one or more scripts stored in a HyperText Markup Language (HTML, HyperText Markup Language) document, in a single file dedicated to the program in question, or in multiple coordinated files (for example, files that store one or more modules, subprograms or code portions).
[0132] As an example, the executable instructions can be deployed to execute on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected via a communication network.
[0133] In summary, the embodiment of the present application can be compatible with different types of display cards, and improve the encoding speed.
[0134] The above merely illustrates the embodiments of the present application, but is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, and improvement within the spirit and scope of the present application shall be included in the protection scope of the present application.
Claims
1. A data processing method, characterized by, The method comprises: grouping the to-be-encoded data stream to obtain a plurality of groups of sub-data streams; obtaining preset encoding parameters; the encoding parameters comprise an encoding format and an input data type; the input data type represents a type of the to-be-encoded data stream, and the types of the plurality of groups of sub-data streams are the same as the type of the to-be-encoded data stream; determining, according to the encoding format, at least two graphics cards capable of supporting the encoding format from at least two candidate graphics cards installed in the terminal; the at least two graphics cards are graphics cards with different type identifiers, and the type identifiers are used to represent at least one of supplier information, brand information and a model of the graphics cards; performing parameter configuration on the at least two graphics cards in the terminal based on the same encoding parameters according to the obtained encoding parameters; obtaining an allocation parameter; allocating, according to the allocation parameter, the plurality of groups of sub-data streams to the at least two graphics cards after parameter configuration through a plurality of rounds of allocation in a grouping order of the plurality of groups of sub-data streams; the allocation parameter comprises a quantity ratio of sub-data streams allocated to each graphics card in each round of allocation in the plurality of rounds of allocation, and the quantity ratio is positively correlated with an encoding speed of the graphics card; wherein, in the process of allocating the sub-data streams, encoding, by the at least two graphics cards respectively, the allocated sub-data streams based on the encoding parameters to obtain corresponding encoded data; reorganizing the plurality of groups of encoded data to obtain an encoded data stream corresponding to the to-be-encoded data stream.
2. The method of claim 1, wherein, The grouping of the to-be-encoded data stream comprises: obtaining a grouping length, the grouping length representing a number of frames of the sub-data stream; grouping the to-be-encoded data stream according to the grouping length.
3. The method of claim 1, wherein, The method further comprises: obtaining an encoding capability parameter of each graphics card in the at least two graphics cards; determining the quantity ratio according to the encoding capability parameter of each graphics card.
4. The method of claim 1, wherein, The method further comprises: adding, according to the grouping order of the plurality of groups of sub-data streams, a picture group sequence number to each group of sub-data streams respectively, the picture group sequence number corresponding to the grouping order; wherein, the encoded data carries the picture group sequence number of the corresponding sub-data stream, and the reorganizing of the plurality of groups of encoded data comprises: reorganizing, according to the grouping order corresponding to the picture group sequence number, the plurality of groups of encoded data by using the picture group sequence number carried by each encoded data.
5. The method of claim 1, wherein, The parameter configuration on the at least two graphics cards according to the encoding parameters comprises: configuring the encoding parameters to the at least two graphics cards respectively; determining, by the at least two graphics cards respectively, a corresponding sequence parameter set and a picture parameter set according to the encoding parameters, and configuring the sequence parameter set and the picture parameter set to the corresponding graphics card; wherein, the sequence parameter set and the picture parameter set are used to add the corresponding sequence parameter set and the picture parameter set to the corresponding encoded data in the process of encoding by the corresponding graphics card.
6. The method of claim 1, wherein, Before the reorganizing of the plurality of groups of encoded data, the method further comprises: obtaining new encoding parameters in response to a change instruction of the encoding parameters; redetermining, by the at least two graphics cards respectively, a new parameter configuration according to the new encoding parameters, and allocating the new parameter configuration to the corresponding graphics card.
7. The method of claim 1, wherein, The method further comprises: dividing the encoded data stream into multiple groups of to-be-decoded data packets; decoding, by the at least two display cards, the multiple groups of to-be-decoded data packets to obtain corresponding decoded data; recombining the multiple groups of decoded data to obtain a corresponding decoded data stream.
Citation Information
Patent Citations
Control method and electronic equipment
CN110286869A
Method for realizing 8K HEVC real-time coding based on GPU cluster
CN110493604A
KR20200097499A