Video coding method and apparatus, and electronic device, storage medium and program product
By partitioning the image into multiple coding tree units CTU and processing the encoding tasks in the CTU rows in parallel, the problem of low resource utilization in the existing technology is solved, and the efficiency and resource utilization of video encoding are improved.
Patent Information
- Application Number
- PCT/CN2024/079845
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-06
- Filing Date
- 2024-03-04
- Publication Date
- 2024-09-12
AI Technical Summary
In the process of high-efficiency video encoding, the resource utilization rate in the mode decision process in the existing technology is low, resulting in long data processing time and waste of computing and storage resources.
By partitioning the image into multiple coding tree units CTU and allocating the encoding tasks in the CTU rows into multiple task sequences, parallel processing is adopted to improve resource utilization.
It improves the encoding speed, saves hardware resources, solves the problem of hardware encoder speed and resource bottlenecks in mode decision, and improves encoding efficiency.
Smart Images

Figure CN2024079845_12092024_PF_FP_ABST
Abstract
Description
Video encoding method, device, electronic device, storage medium and program product
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 6, 2023, with application number 2023102544023 and application name “Mode Judgment Scheduling Method and Related Devices”. The entire contents of the application are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of image processing technology and provides a video encoding method, device, electronic device, storage medium and program product. Background Art
[0003] In High Efficient Video Coding (HEVC), Mode Decision (MD) is the most important core module, determining both coding quality and efficiency. During MD, the image is encoded through operations such as prediction (Prediction), transform and quantization (TQ), and rate distortion optimization (RDO).
[0004] In related technologies, the largest coding unit (LCU) is usually used as the coding unit, and each LCU in the processed image is encoded in sequence according to the raster coding order. For example, referring to Figure 1, each space represents an LCU, and for each row of LCUs, the LCUs are encoded in sequence from left to right.
[0005] An LCU may contain one or more coding units (CUs). During the encoding process of each LCU, each CU is processed in the order of Pred → TQ → RDO. For example, as shown in Figure 2, the luminance component and chrominance components of CU0 are processed in the order of Pred, TQ, and RDO. After CU0 is encoded, CU1 is processed in the order of Pred, TQ, and RDO.
[0006] However, if encoding is performed in raster coding order, only one LCU is started at a time, and the processing of the next CU must be performed after the Pred, TQ, and RDO processing of the previous CU are completed, resulting in low resource utilization and long data processing time, which in turn leads to a waste of computing and storage resources.
[0007] Summary of the Invention
[0008] The embodiments of the present application provide a mode decision scheduling method and related devices to improve resource utilization in the mode decision process.
[0009] In a first aspect, an embodiment of the present application provides a video encoding method, which is executed in an electronic device, and the method includes:
[0010] Acquire images;
[0011] Partitioning the image into a plurality of coding tree units (CTUs), wherein each CTU includes one or more coding units (CUs);
[0012] Allocating encoding tasks of encoding blocks of CUs in multiple CTU rows in the image into multiple task sequences, wherein each task sequence is a sequence composed of encoding tasks of multiple encoding blocks;
[0013] The multiple task sequences are executed in parallel to obtain encoding results of the encoding blocks of the CUs in the multiple CTU rows.
[0014] In a second aspect, an embodiment of the present application provides a video encoding device, including:
[0015] an acquisition unit, configured to acquire an image;
[0016] a partitioning unit, configured to partition the image into a plurality of coding tree units (CTUs), wherein each CTU includes one or more coding units (CUs);
[0017] a scheduling unit, configured to allocate encoding tasks of encoding blocks of CUs in multiple CTU rows in the image into multiple task sequences, wherein each task sequence is a sequence consisting of encoding tasks of multiple encoding blocks;
[0018] The encoding unit is configured to execute the multiple task sequences in parallel to obtain encoding results of the encoding blocks of the CUs in the multiple CTU rows.
[0019] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the above-mentioned video encoding method.
[0020] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the above-mentioned video encoding method.
[0021] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program stored in a computer-readable storage medium. The processor of an electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device performs the above-mentioned video encoding method. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0023] Figure 1 is a schematic diagram of the grating encoding sequence;
[0024] FIG2 is a schematic diagram of a task execution sequence;
[0025] FIG3A is a schematic diagram of the structure of a CTU provided in an embodiment of the present application;
[0026] FIG3B is a schematic diagram of the structure of a quadtree corresponding to a CTU provided in an embodiment of the present application;
[0027] FIG4 is a schematic diagram of an application scenario provided in an embodiment of the present application;
[0028] FIG5 is a schematic diagram of a flow chart of a video encoding method provided in an embodiment of the present application;
[0029] FIG6 is a schematic diagram of a first row of LCUs provided in an embodiment of the present application;
[0030] FIG7 is a schematic diagram of various WPP threads provided in an embodiment of the present application;
[0031] FIG8 is a schematic diagram of an assembly line provided in an embodiment of the present application;
[0032] FIG9 is a schematic diagram of determining processing resources corresponding to a task provided in an embodiment of the present application;
[0033] FIG10 is a schematic diagram of a WPP thread scheduling sequence provided in an embodiment of the present application;
[0034] FIG11 is a schematic diagram of a scheduling relationship provided in an embodiment of the present application;
[0035] FIG12A is a schematic diagram of dependency relationship 1 provided in an embodiment of the present application;
[0036] FIG12B is a schematic diagram of dependency relationship 2 provided in an embodiment of the present application;
[0037] FIG12C is a schematic diagram of dependency relationship 3 provided in an embodiment of the present application;
[0038] FIG13 is a schematic diagram of a WPP thread startup sequence provided in an embodiment of the present application;
[0039] FIG14 is a schematic diagram of another scheduling relationship provided in an embodiment of the present application;
[0040] FIG15 is a schematic diagram of the structure of the mode determination provided in an embodiment of the present application;
[0041] FIG16 is a schematic diagram of a flow chart of a video encoding method provided in an embodiment of the present application;
[0042] FIG17 is a schematic structural diagram of a video encoding device provided in an embodiment of the present application;
[0043] FIG18 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of the technical solutions of this application, but not all of them. Based on the embodiments described in this application document, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the technical solutions of this application.
[0045] It should be noted that the terms "first" and "second" in the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or modules is not limited to the listed steps or modules, but may optionally include steps or modules that are not listed, or may optionally include other steps or modules inherent to these processes, methods, products, or devices.
[0046] In this application, "multiple" can mean at least two, for example, two, three, or more, and this is not a limitation in the embodiments of this application. "And / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exists simultaneously, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0047] It is understandable that in the embodiments of the present application, the collection, use and processing of map data comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0048] Below, some concepts involved in this application are explained.
[0049] Coding Tree Unit (CTU): In HEVC, each frame can be divided into one or more CTUs of fixed size. Each CTU can be further divided into one or more Coding Units (CU) through a recursive quadtree. Each leaf node of the quadtree is called a CU. A CU is the basic unit block for intra-frame or inter-frame coding.
[0050] For example, as shown in Figure 3A, each space represents a CU, and the CTU is further divided into two 32×32 pixel CUs, five 16×16 pixel CUs, and twelve 8×8 pixel CUs. As shown in Figure 3B, in the quadtree corresponding to the CTU, the root node represents the CTU, "1" indicates that the current node has child nodes, and "0" indicates that the current node does not have child nodes. The quadtree contains 19 leaf nodes, each of which represents a CU.
[0051] Largest Coding Unit (LCU): In HEVC encoders, LCUs are used as coding units for encoding. The size of an LCU is usually the same as that of a CTU, such as 64×64 pixels.
[0052] Mode Decision (MD): In order to obtain the final optimal partitioning mode among the many partitioning modes for each size, the MD module is introduced. This module is generally the core processing unit of each video encoder. This implementation selects the partitioning mode and prediction mode of the coding unit with the best coding performance through the RDO process for multiple candidate modes within and between frames, thereby achieving the best coding quality and performance. The MD module is usually the most complex and data structure-dependent module in the encoder. In the standard HEVC encoder, it is necessary to recursively detect all possible partitioning combinations and select the combination with the lowest rate-distortion cost as the optimal solution to achieve RDO.
[0053] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.
[0054] Cloud technology is a general term for network technologies, information technologies, integration technologies, management platform technologies, and application technologies based on the cloud computing business model. It can form a resource pool that can be used flexibly and conveniently on demand. Cloud computing technology will become a crucial support. Backend services for technical network systems, such as video websites, image websites, and more portals, require extensive computing and storage resources. With the rapid development and application of the internet industry, every item will likely have its own unique identifier, requiring transmission to backend systems for logical processing. Different levels of data will be processed separately, and data from various industries will require a strong system backend, which can only be achieved through cloud computing.
[0055] Cloud computing is a computing model that distributes computing tasks across a resource pool consisting of a large number of computers, enabling various application systems to access computing power, storage space, and information services as needed. The network that provides these resources is called the "cloud." To users, these resources appear infinitely scalable and can be accessed at any time, used on demand, expanded at any time, and paid for on a per-use basis.
[0056] As a provider of cloud computing infrastructure, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an Infrastructure as a Service (IaaS) platform) is established. Various types of virtual resources are deployed in the resource pool for external customers to choose and use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.
[0057] Based on logical functional divisions, the Platform as a Service (PaaS) layer can be deployed on top of the IaaS layer, and the Software as a Service (SaaS) layer can be deployed on top of the PaaS layer. SaaS can also be deployed directly on top of IaaS. PaaS is a platform for software execution, such as databases and web containers. SaaS is a variety of business software, such as web portals and text messaging apps. Generally speaking, SaaS and PaaS are layers above IaaS.
[0058] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.
[0059] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0060] Computer vision (CV) is the science of making machines "see." Specifically, it refers to machine vision, where cameras and computers replace the human eye in identifying, detecting, and measuring objects. This involves further processing the images, transforming them into images more suitable for human observation or transmission to instruments. As a scientific discipline, computer vision studies related theories and technologies, aiming to build artificial intelligence systems capable of extracting information from images or multidimensional data. Computer vision technologies typically include image processing, image recognition, image semantic understanding, image retrieval, optical character recognition (OCR), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping, and common biometric recognition technologies such as facial recognition and fingerprint recognition.
[0061] In related art, each LCU in the image to be processed is encoded in sequence according to the raster coding order. For example, referring to FIG1 , for each row of LCUs, the LCUs are encoded in sequence from left to right. An LCU may contain one or more CUs. During the encoding process of each LCU, each CU is processed in the order of Pred → TQ → RDO. For example, referring to FIG2 , CU0 is processed in sequence of Pred, TQ, and RDO. After CU0 is encoded, CU1 is processed in sequence of Pred, TQ, and RDO.
[0062] However, if encoding is performed in raster coding order, only one LCU is started at a time, and the processing of the next CU must be performed after the Pred, TQ, and RDO processing of the previous CU are completed, resulting in low resource utilization and long data processing time, which in turn leads to a waste of computing and storage resources.
[0063] In some embodiments, the present application can first determine the CU set associated with each WPP thread, and the task subset corresponding to each CU contains N types of tasks, so that the total set of tasks to be executed by the corresponding WPP thread can be obtained. Then, based on the processing resources allocated to each of the N types, the processing resources corresponding to each task are determined respectively. After that, based on the dependency between the encoding results of each CU, the scheduling order between the tasks in the total task set is obtained. The scheduling order supports parallel processing of at least two WPP threads. Finally, based on the processing resources corresponding to each task, the corresponding WPP thread is called in sequence according to the scheduling order to process the corresponding task to obtain the encoding result of the image to be processed.
[0064] In this way, through WPP parallel processing, various tasks involved in the mode decision process are scheduled while satisfying the coding data dependencies. This allows full utilization of computing resources, improved coding speed, and saved hardware resources, while ensuring hardware coding quality and efficiency. This solves the speed and resource bottleneck issues of hardware encoders in mode decision.
[0065] In some embodiments, the present application may first acquire an image; then partition the image into multiple coding tree units (CTUs), where each CTU includes one or more coding units (CUs); on this basis, the encoding tasks of the coding blocks of the CUs in multiple CTU rows in the image are allocated into multiple task sequences, where each task sequence is a sequence composed of encoding tasks of multiple coding blocks; and the multiple task sequences are executed in parallel to obtain encoding results of the coding blocks of the CUs in the multiple CTU rows. In this way, the embodiments of the present application can process the tasks of the coding blocks of the CUs in multiple CTU rows (or multiple LCU rows) in parallel, making full use of computing resources and improving encoding efficiency.
[0066] The application scenario of the technical solution of the embodiment of the present application is described below with reference to FIG4 . Referring to FIG4 , it is a schematic diagram of an application scenario provided in the embodiment of the present application, which includes: a terminal device 401 and a server 402 .
[0067] In one embodiment, the terminal device 401 is installed with an application that requires image encoding, such as video on demand, live broadcast, cloud gaming, cloud phone, and cloud desktop, etc. The application can be a software client, or a client such as a web page or a mini-program.
[0068] The terminal device 401 may be a device owned by the user, such as a mobile phone, tablet computer, laptop computer, desktop computer, smart TV, smart wearable device, smart voice interaction device, smart home appliance, vehicle-mounted terminal, aircraft, etc.
[0069] Server 402 may be a backend server corresponding to an application installed on terminal device 401, and may provide encoding functionality. Server 402 may be, for example, an independent physical server, or a server cluster or distributed system consisting of multiple physical servers. It may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Networks (CDNs), and big data and artificial intelligence platforms, but is not limited thereto.
[0070] The terminal device 401 and the server 402 can be directly or indirectly connected to each other through one or more networks. The network can be a wired network or a wireless network. For example, the wireless network can be a mobile cellular network or a Wireless Fidelity (WIFI) network. Of course, other possible networks are also possible, and the embodiments of the present application are not limited thereto.
[0071] It should be noted that in the embodiment of the present application, the number of terminal devices 401 can be one or more, and similarly, the number of servers 402 can be one or more, that is, there is no restriction on the number of terminal devices 401 or servers 402.
[0072] In some embodiments, after acquiring an image to be processed, server 402 determines the CU sets associated with each created wavefront parallel processing (WPP) thread based on the location information of each coding unit (CU) in the image to be processed. For each WPP thread, the following operations are performed: based on the task subsets corresponding to each CU in the CU set associated with the WPP thread, a total set of tasks to be executed by the WPP thread is obtained, where each task subset includes N types of tasks; and based on the processing resources allocated to each of the N types, processing resources corresponding to each task in each task set are determined; based on the dependencies between the encoding results of each CU in the image to be processed, a scheduling order between the tasks in each task set is obtained, where the scheduling order supports parallel processing by at least two WPP threads; and based on the processing resources corresponding to each task in the task set, the corresponding WPP thread is sequentially called to process the corresponding task in accordance with the scheduling order to obtain the encoding result of the image to be processed. After encoding the data to be processed, server 402 transmits the encoded data to terminal device 401.
[0073] It should be noted that in the embodiments of the present application, the mode decision scheduling method can be implemented by a terminal device, can be implemented by a server, or can be implemented by both a terminal device and a server, without limitation.
[0074] In the embodiments of the present application, it can be applied to various application scenarios such as on-demand, ultra-high-definition real-time live broadcast, cloud gaming low-latency scenarios, cloud phones and cloud desktops. By transcoding or rendering and then encoding and transmitting on the cloud, edge or device side, CDN bandwidth is reduced, latency is reduced, and encoding speed is increased. For image data that needs to be rendered (such as game streams), the image data can be rendered and then encoded and transmitted after high-definition video processing. For image data that does not need to be rendered (such as live broadcasts and short videos), the image data can be decoded and processed after high-definition video processing and then encoded and transmitted.
[0075] In some implementations, to meet the needs of different applications, encoding schemes can be selected based on product business requirements. For example, if the product business focuses on low latency, the encoding scheme can be set to low latency mode, with each encoding core outputting at the LCU row level, thereby converting WPP LCU row-level encoding to raster LCU row-level output. For another example, if the product business focuses on encoding speed, the priority of each pipeline in 3WPP can be controlled based on the business, and the encoding speed can be optimized by adjusting pipeline utilization.
[0076] 5 is a flow chart of a possible video encoding method provided in an embodiment of the present application. The method is applied to an electronic device, which may be a terminal device or a server. The specific process is as follows:
[0077] S501: Based on the position information of each CU in the image to be processed, determine the CU sets associated with each created wavefront parallel processing (WPP) thread, where each CU contained in each CU set is located in the same image region. For example, each CU in each CU set belongs to the same row of LCUs.
[0078] In an embodiment of the present application, the image to be processed includes but is not limited to a game image, a video image, and the like. The image to be processed can be divided into one or more CTUs, each CTU containing one CU (without further division), or multiple CUs (with further division). Exemplarily, the size of a CU ranges from the smallest CU to the CTU. Generally, the size of a CTU is 64×64 pixels, and the smallest CU is 8×8 pixels. Therefore, the size of a CU can be 8×8 pixels, 16×16 pixels, 32×32 pixels, or 64×64 pixels.
[0079] The location information of each CU is used to represent the LCU to which the corresponding CU belongs in the image to be processed. The LCU is the basic unit for encoding the image to be processed. In HEVC, the size of an LCU is typically 64×64 pixels. Therefore, in some embodiments, the LCU can be equivalent to the CTU.
[0080] For the image to be processed, the image to be processed can be divided into a number of non-overlapping LCUs according to the set LCU size. Each LCU can be further divided to obtain CUs.
[0081] WPP parallel technology is implemented in units of a row of LCUs. As shown in Figure 6, the created WPP threads include: WPP0 thread to WPP5 thread. Each WPP thread corresponds to a row of LCUs, with one square representing one LCU. Each WPP thread encodes a corresponding row of LCUs. In this embodiment of the present application, based on the LCU to which each CU belongs in the image to be processed, the CUs contained in the row of LCUs corresponding to a WPP thread are used as the CU set associated with the WPP thread.
[0082] In the embodiment of the present application, first, multiple WPP threads need to be created before parallel encoding of the WPP threads can be performed. Referring to FIG. 7 , it is assumed that multiple WPP threads are created, namely, WPP0 thread, WPP1 thread, WPP2 thread, WPP3 thread, WPP4 thread, and WPP5 thread. It should be noted that in the embodiment of the present application, the number of threads created can be 3. Each thread can be used for cyclic encoding. In this case, the WPP0 thread can be understood as the WPP0-1 thread, and the WPP3 can be understood as the WPP0-2 thread. Similarly, the WPP4 thread is the WPP1-2 thread, and the WPP5 thread is the WPP2-2 thread.
[0083] The image to be processed is divided into 6 rows of LCUs, each row of LCUs contains 6 LCUs, and the size of each LCU is 64×64 pixels. Among them, the first row of LCUs corresponds to the WPP0 thread, the second row of LCUs corresponds to the WPP1 thread, the third row of LCUs corresponds to the WPP2 thread, the fourth row of LCUs corresponds to the WPP3 thread, the fifth row of LCUs corresponds to the WPP4 thread, and the sixth row of LCUs corresponds to the WPP5 thread.
[0084] Referring to Figure 7, taking the first row of LCUs as an example, the first row of LCUs includes LCU0, LCU1, LCU2, LCU3, LCU4, and LCU5. Assume that LCU0 includes CU0 to CU3, LCU1 includes CU4, LCU2 includes CU5 to CU11, LCU3 includes CU12 to CU18, LCU4 includes CU19 to CU28, and LCU5 includes CU29 to CU32. Obviously, CU0 to CU32 are all located in the first row of LCUs. Therefore, the CUs associated with the WPP0 thread are concentrated to include: CU0 to CU32.
[0085] S502 : For each WPP thread, perform the following operations: based on the task subsets corresponding to each CU in the CU set associated with the WPP thread, obtain a total set of tasks to be executed by the WPP thread, where each task subset includes N types of tasks, where N is a positive integer.
[0086] In the embodiment of the present application, during the encoding process, each CU needs to undergo operations such as prediction, transformation and quantization, and rate-distortion optimization. The prediction process is regarded as a prediction task, the transformation and quantization process is regarded as a transformation and quantization task, and the rate-distortion optimization process is regarded as a rate-distortion optimization task. In other words, the N types of tasks include: at least one of the prediction task, the transformation and quantization task, and the rate-distortion optimization task.
[0087] After obtaining the task subsets corresponding to each CU in a CU set associated with a WPP thread, each task subset corresponding to a CU includes N types of tasks. The N types of tasks corresponding to each CU in the CU set are taken as tasks in the total task set to be executed by a WPP thread.
[0088] Taking the WPP0 thread as an example, as shown in Figure 7, the CU set associated with the WPP0 thread includes: CU0 to CU32. For each CU in CU0 to CU32, there are three corresponding tasks: Pred, TQ, and RDO. Taking CU0 as an example, the task subset corresponding to CU0 includes: Pred tasks, TQ tasks, and RDO tasks for CU0. Based on the task subsets corresponding to CU0 to CU32, the total set of tasks to be executed by the WPP0 thread is obtained. The total set of tasks to be executed by the WPP0 thread includes: each task in the task subsets corresponding to CU0 to CU32.
[0089] Furthermore, since a CU includes a luminance component and two chrominance components (ie, one luminance coding block and two chrominance coding blocks), for each CU in each CU, each type of task includes one luminance coding task and two chrominance coding tasks.
[0090] Still referring to FIG. 7 , taking CU0 as an example, the task subset corresponding to CU0 includes the following nine tasks: a Pred task for the luma component of CU0 (CU0-Y Pred task), a Pred task for one chroma component of CU0 (CU0-U Pred task), a Pred task for another chroma component of CU0 (CU0-V Pred task), a TQ task for the luma component of CU0 (CU0-Y TQ task), a TQ task for one chroma component of CU0 (CU0-U TQ task), a TQ task for another chroma component of CU0 (CU0-V TQ task), an RDO task for the luma component of CU0 (CU0-Y RDO task), an RDO task for one chroma component of CU0 (CU0-U RDO task), and an RDO task for another chroma component of CU0 (CU0-V RDO task).
[0091] S503 : Based on the processing resources allocated to each of the N types, determine the processing resources corresponding to each task included in each task set.
[0092] In an embodiment of the present application, corresponding processing resources are pre-allocated for N types of tasks. For example, corresponding Pred processing resources are allocated to Pred tasks, corresponding TQ processing resources are allocated to TQ tasks, and corresponding RDO processing resources are allocated to RDO tasks.
[0093] In some embodiments, since the processing speeds of CUs (or coding blocks) of different sizes are different, in order to further improve processing efficiency, corresponding processing resources are allocated to different CU sizes (or coding block sizes), that is, the processing resources allocated to each of the N types include: a set of processing resources allocated for various CU sizes (or coding block sizes), and each processing resource corresponds to a block size.
[0094] For example, referring to FIG8 , since the size of a CU can be 8×8 pixels, 16×16 pixels, 32×32 pixels, and 64×64 pixels, different processing resources can be allocated to 8×8 pixels, 16×16 pixels, 32×32 pixels, and 64×64 pixels. That is, the Pred processing resources include: Pred processing resources corresponding to 8×8 pixels, 16×16 pixels, 32×32 pixels, and 64×64 pixels, respectively; the TQ processing resources include: TQ processing resources corresponding to 8×8 pixels, 16×16 pixels, 32×32 pixels, and 64×64 pixels, respectively; and the RDO processing resources include: RDO processing resources corresponding to 8×8 pixels, 16×16 pixels, 32×32 pixels, and 64×64 pixels, respectively.
[0095] It should be noted that, in the embodiment of the present application, N types of processing resources corresponding to the same CU size can be referred to as a pipeline. For example, the pipeline corresponding to 16×16 pixels includes: Pred processing resources of 16×16 pixels, TQ processing resources of 16×16 pixels, and RDO processing resources of 16×16 pixels.
[0096] In an embodiment of the present application, a pipeline corresponding to a CU size can also be used to process tasks of other CU sizes. For example, a pipeline corresponding to 16×16 pixels can also be used to process tasks of 8×8 pixel CUs, that is, a pipeline corresponding to 16×16 pixels can also correspond to tasks of 8×8 pixel CUs. Furthermore, based on the size of each CU and the number of CUs, combined with the processing resource sets allocated to each of the N types, the processing resources corresponding to each CU in the image to be processed can be determined respectively. In this way, when the resources of one pipeline are too occupied, other pipelines can be used for processing, thereby improving encoding efficiency.
[0097] Specifically, based on the processing resources allocated to each of the N types, the processing resources corresponding to each task in each task set are determined, including:
[0098] Based on the size of each CU in the image to be processed and the processing resource sets allocated to each of the N types, respectively determine the processing resources corresponding to each CU in the image to be processed;
[0099] Based on the processing resources corresponding to each CU in the image to be processed, the processing resources corresponding to each task included in each task set are determined respectively.
[0100] For each of the N types, each processing resource in the allocated processing resource set is used to process tasks corresponding to a CU of the corresponding CU size. In the embodiment of the present application, for each of the N types of processing resources, the processing resources are subdivided into a plurality of processing resources according to various CU sizes, and then a processing resource set allocated to the type is obtained based on the plurality of processing resources.
[0101] Processing resources include, but are not limited to, resources required to perform tasks of the corresponding type during the encoding process, such as processor resources, memory resources, etc.
[0102] As a possible implementation method, the tasks corresponding to the luminance component and chrominance component of a CU can be processed in the pipeline corresponding to the size of the CU, that is, directly based on the corresponding size of the CU, combined with the processing resource sets allocated to each of the N types, the processing resources corresponding to each CU in the image to be processed are determined respectively, and then based on the processing resources corresponding to each CU in the image to be processed, the processing resources corresponding to each task contained in each task set are determined respectively.
[0103] Taking CU0 as an example, the size of CU0 is 32×32 pixels. Combined with the Pred processing resource set, TQ processing resource set, and RDO processing resource set, the processing resources corresponding to CU0 include: Pred processing resources corresponding to 32×32 pixels, TQ processing resources corresponding to 32×32 pixels, and RDO processing resources corresponding to 32×32 pixels. The task subset corresponding to CU0 includes: Pred tasks for CU0, TQ tasks for CU0, and RDO tasks for CU0. Among them, the Pred tasks for CU0 include Pred tasks for the luminance component and two chrominance components of CU0. The TQ task for CU0 includes TQ tasks for the luminance component and two chrominance components of CU0, and the RDO task for CU0 includes RDO tasks for the luminance component and two chrominance components of CU0. Then, based on the processing resources corresponding to CU0, it is determined that the processing resources corresponding to the Pred task for CU0 are the Pred processing resources corresponding to 32×32 pixels, the processing resources corresponding to the TQ task for CU0 are the TQ processing resources corresponding to 32×32 pixels, and the processing resources corresponding to the RDO task for CU0 are the RDO processing resources corresponding to 32×32 pixels.
[0104] As another possible implementation, each CU includes one luminance component and two chrominance components. Since the coding block sizes of the luminance component and the chrominance component are different, in order to further improve the coding efficiency, based on the size of each CU in the image to be processed and in combination with the processing resource sets allocated to each of the N types, the processing resources corresponding to each CU in the image to be processed are determined respectively, including:
[0105] Based on the size of each luminance CU in the image to be processed and the processing resource sets allocated to each of the N types, the processing resources corresponding to each luminance component in the image to be processed are determined respectively;
[0106] Based on the size of each chroma CU in the image to be processed and in combination with the processing resource sets allocated to each of the N types, the processing resources corresponding to each chroma component in the image to be processed are determined respectively.
[0107] Still taking CU0 as an example, referring to Figure 9, CU0 includes a luminance component and two chrominance components. The luminance component of CU0 is called CU0-Y, and the two chrominance components of CU0 are called CU0-U and CU0-V. Since the size of CU0 is 32×32 pixels, the coding block size of CU0-Y is 32×32 pixels, and the coding block sizes of CU0-U and CU0-V are both 16×16 pixels. According to the respective sizes of CU0-Y, CU0-U, and CU0-V, combined with the processing resources allocated to each of the three types, the processing corresponding to CU0-Y is determined. The resources include: Pred processing resources corresponding to 32×32 pixels, TQ processing resources corresponding to 32×32 pixels, and RDO processing resources corresponding to 32×32 pixels. The processing resources corresponding to CU0-U include: Pred processing resources corresponding to 16×16 pixels, TQ processing resources corresponding to 16×16 pixels, and RDO processing resources corresponding to 16×16 pixels. The processing resources corresponding to CU0-V include: Pred processing resources corresponding to 16×16 pixels, TQ processing resources corresponding to 16×16 pixels, and RDO processing resources corresponding to 16×16 pixels.
[0108] The task subset corresponding to CU0 includes the following 9 tasks: CU0-Y Pred task, CU0-U Pred task, CU0-V Pred task, CU0-Y TQ task, CU0-U TQ task, CU0-V TQ task, CU0-Y RDO task, CU0-U RDO task, and CU0-V RDO task. Based on the processing resources corresponding to CU0-U, the processing resources corresponding to each of the 9 tasks are determined. Among them, the processing resources corresponding to the CU0-Y Pred task are: Pred processing resources corresponding to 32×32 pixels, the processing resources corresponding to the CU0-Y TQ task are: TQ processing resources corresponding to 32×32 pixels, the processing resources corresponding to the CU0-Y RDO task are: RDO processing resources corresponding to 32×32 pixels, the processing resources corresponding to the CU0-U Pred task and the CU0-V Pred task are both: Pred processing resources corresponding to 16×16 pixels, the processing resources corresponding to the CU0-U TQ task and the CU0-V TQ task are both: TQ processing resources corresponding to 16×16 pixels, and the processing resources corresponding to the CU0-U The processing resources corresponding to the RDO task and the CU0-V RDO task are both: RDO processing resources corresponding to 16×16 pixels.
[0109] By placing luminance coding blocks and chrominance coding blocks of the same size in the same pipeline for processing, it helps to save computing and storage resources, thereby increasing processing speed, reducing resource consumption, and improving encoding performance.
[0110] It should be noted that in the embodiments of the present application, only YUV sampling is used as an example for description, but it is not limited to this.
[0111] S504 : Based on the dependency relationship between the encoding results of each CU in the image to be processed, obtain a scheduling order between each task in each task set, where the scheduling order supports parallel processing of at least two WPP threads.
[0112] In an embodiment of the present application, 3WPP parallel processing is adopted, and when the encoder data dependency is met, 3 LCU rows are started simultaneously for encoding.
[0113] Referring to Figure 10, the shaded part represents the encoded LCU, and the direction of the arrow represents the LCU encoding order. The startup of the WPP1 thread is subject to the completion of encoding of the upper adjacent and upper right adjacent LCUs of the WPP0 row (i.e., encoding of LCU0 and LCU1 of the first row is completed), the startup of the WPP2 thread is subject to the completion of encoding of the upper adjacent and upper right adjacent LCUs of the WPP1 row (i.e., encoding of LCU0 and LCU1 of the second row is completed), and the startup of the WPP3 thread is subject to the completion of encoding of the upper adjacent and upper right adjacent LCUs of the WPP2 row. Similarly, the startup of other WPP threads will not be repeated.
[0114] In Figure 10, when the encoding of LCU0 and LCU1 of the WPP0 row is completed, the encoding of LCU0 of the WPP1 row starts, that is, LCU2 of the WPP0 row and LCU0 of the WPP1 row are processed in parallel. When the encoding of LCU0 and LCU1 of the WPP1 row is completed, the encoding of LCU0 of the WPP2 row starts, that is, LCU3 of the WPP0 row, LCU2 of the WPP1 row, and LCU0 of the WPP2 row are processed in parallel.
[0115] Specifically, in the embodiment of the present application, the dependency relationship includes but is not limited to at least one of the following relationships:
[0116] Dependency 1: For every two CUs that are adjacent in the horizontal direction (ie, adjacent left and right) in the image to be processed, the encoding of the luminance coding block of the right CU depends on the encoding result of the luminance coding block of the left CU.
[0117] Referring to FIG3A , in the embodiment of the present application, CU encoding is performed within a CTU (or LCU) in a Z-scan order. Taking FIG3A as an example, Z-scan encoding is performed in the order of 0->1->2->3, ensuring that the CUs to the left and above the coded CU have already been encoded. This allows the encoding results of the coded CUs to be used for intra-frame prediction and inter-frame prediction.
[0118] Refer to Figure 11, which is a schematic diagram of a scheduling sequence provided in an embodiment of the present application. In Figure 11, the grid area represents the CU of the WPP0 thread, the dotted area represents the CU of the WPP1 thread, the diagonal area represents the CU of the WPP2 thread, and "×" represents no task. The CU can also be called Blk. Taking Blk0-Y as an example, Blk0-Y represents the brightness component of the first CU (that is, the brightness coding block). In this scheduling sequence, for each pipeline, three WPPs are supported to process tasks simultaneously. For example, the WPP2 thread processes the Blk0-Y Pred task, the WPP1 thread processes the Blk0-Y TQ task, and the WPP0 thread processes the Blk0-Y RDO task in parallel. In addition, Blk0-0, Blk0-1, Blk0-2, and Blk0-3 represent the four CUs divided from Blk0.
[0119] Referring to FIG12A , since the luminance coding of CU1 depends on the luminance coding result of CU0, the Blk1-Y task is executed after the Blk0-Y task is executed. Taking the WPP0 thread as an example, whether in the pipeline corresponding to 32×32 pixels or in the pipeline corresponding to 16×16 pixels, for the Pred task, the Blk0-0-Y Pred task is executed first, and then the Blk0-1-Y Pred task is executed. For the TQ task, the Blk0-0-Y TQ task is executed first, and then the Blk0-1-Y TQ task is executed. For the RDO task, the Blk0-0-Y RDO task is executed first, and then the Blk0-1-Y RDO task is executed.
[0120] Dependency 2: The chroma encoding of each CU in the image to be processed depends on the corresponding luminance encoding result.
[0121] In the embodiment of the present application, for each CU, the chroma encoding of a CU depends on the luma encoding result of the CU. Considering that the luma component and chroma components contained in a CU are processed by different processing resources, for the luma component and two chroma components contained in a CU, the tasks of the luma component in one pipeline are executed first, and the tasks of the chroma components in the other pipeline are executed later.
[0122] As shown in Figure 12B, since the chroma encoding of each CU depends on the corresponding luma encoding result, after the Blk0-Y task is executed, the Blk0-U task and the Blk0-V task are executed. Taking the WPP0 thread as an example, the Blk0-Y task includes: Blk0-Y Pred task, Blk0-Y TQ task and Blk0-Y RDO task. In the pipeline corresponding to 32×32 pixels, the Blk0-Y Pred task, Blk0-Y TQ task and Blk0-Y RDO task are executed in sequence, and then the Blk0-U task and the Blk0-V task are executed in sequence. Among them, the Blk0-U task includes: Blk0-U Pred task, Blk0-U TQ task and Blk0-U RDO task, and the Blk0-V task includes: Blk0-V Pred task, Blk0-V TQ task and Blk0-V RDO task.
[0123] Dependency 3: For every two adjacent CUs in the object to be processed, the luminance coding of the right CU depends on the chrominance coding result of the left CU.
[0124] It should be noted that in the embodiment of the present application, there is also a data dependency relationship between the Pred task, the TQ task, and the RDO task. After the Pred task is executed, the TQ task is executed first, and then the RDO task is executed.
[0125] Still taking WPP0 as an example, referring to FIG12C , since for every two adjacent CUs, the luminance coding of the right CU depends on the chrominance coding result of the left CU, the luminance task of the right CU is executed after the chrominance task of the left CU is completed. That is, after the Blk0-U task and the Blk0-V task are executed, the Blk1-Y task is executed. Specifically, the Blk0-U task includes: Blk0-U Pred task, Blk0-U TQ task, and Blk0-U RDO task. The Blk0-V task includes: Blk0-V Pred task, Blk0-V TQ task, and Blk0-V RDO task. Therefore, after the Blk0-U task and the Blk0-V task are executed, the Blk1-Y task is executed. The Blk1-Y task includes: Blk1-Y Pred task, Blk1-Y TQ task, and Blk1-Y RDO task. It is understandable that, since the latest task executed between the Blk0-U task and the Blk0-V task is the Blk0-V RDO task, the Blk1-Y task may also be executed after the Blk0-V RDO task is executed.
[0126] S505 : Based on the processing resources corresponding to each task in the task set, the corresponding WPP threads are called in sequence to process the corresponding tasks in accordance with the scheduling order, so as to obtain the encoding result of the image to be processed.
[0127] In the embodiment of the present application, a first WPP thread is started, and based on the processing resources corresponding to each task in the task set of the first WPP thread, the first WPP thread is used to process the corresponding tasks in sequence according to the scheduling order, and generate corresponding encoding information;
[0128] Starting from the second WPP thread, perform the following operations on each WPP thread in turn:
[0129] When the previous WPP thread completes encoding of each CU in the set area, the current WPP thread is started;
[0130] Based on the encoding information corresponding to each CU in the set area and the processing resources corresponding to each task in the task set of the current WPP thread, the current WPP thread is used to process the corresponding tasks in the scheduling order and generate the corresponding encoding information.
[0131] The set area may refer to the upper adjacent LCU and the upper right adjacent LCU, that is, LCU0 and LCU1 in the previous row of LCUs.
[0132] For example, referring to FIG13 , the first WPP thread is the WPP0 thread, the WPP0 thread corresponds to the first row of LCUs, the WPP1 thread corresponds to the second row of LCUs, the WPP2 thread corresponds to the third row of LCUs, the WPP3 thread corresponds to the fourth row of LCUs, the WPP4 thread corresponds to the fifth row of LCUs, and the WPP5 thread corresponds to the sixth row of LCUs.
[0133] First, the first WPP thread is the WPP0 thread. The WPP0 thread is started and based on the processing resources corresponding to each task in the WPP0 task set, the WPP0 thread is used to process LCU0 to LCU1 in the first row in the scheduling order.
[0134] Specifically, taking any CU in the first row of LCUs as an example, assuming that the size of the CU is 16×16 pixels, the Pred resources, TQ resources, and RDO resources for 16×16 pixels are used to sequentially process the Pred task, TQ task, and RDO task corresponding to the luminance component of the CU to obtain a luminance coding result. Then, the Pred resources, TQ resources, and RDO resources for 8×8 pixels are used to respectively process the Pred task, TQ task, and RDO task corresponding to the chrominance component of CU0 to obtain a chrominance coding result. Similarly, the other LCUs in the first row of LCUs are encoded in sequence.
[0135] When LCU0 and LCU1 in the first row of LCUs are encoded, the WPP1 thread is started. That is, when the WPP0 thread processes LCU2 in the first row of LCUs, the WPP1 thread processes LCU0 in the second row. Then, based on the processing resources corresponding to each task in the task set of the WPP1 thread, the WPP1 thread is used to process LCU0 to LCU5 in the second row in sequence according to the scheduling order.
[0136] When LCU0 and LCU1 in the second row of LCUs complete encoding, WPP2 is started. That is, when WPP0 processes LCU4 in the first row of LCUs, WPP1 processes LCU3 in the second row, and WPP2 processes LCU0 in the third row. Then, based on the processing resources corresponding to each task in the task set of the WPP2 thread, the WPP2 thread is used to process LCU0 to LCU5 in the third row in sequence according to the scheduling order.
[0137] Similarly, the WPP3 thread, the WPP4 thread, and the WPP5 thread are all started after the second LCU of the previous row completes encoding, and based on the corresponding processing resources, process LCU0 to LCU5 in the corresponding row in sequence according to the scheduling order.
[0138] In some embodiments, the processing priority corresponding to each processing resource can also be obtained in response to the processing priority configuration operation triggered by the target object for each processing resource. Based on the processing resources corresponding to each task in the task set, the corresponding WPP threads are called in sequence according to the scheduling order to process the corresponding tasks, and the encoding result of the image to be processed can be obtained in the following manner, but not limited to:
[0139] Based on the processing priority corresponding to each processing resource, the scheduling order is adjusted, and based on the processing resources corresponding to each task in the total task set, the corresponding WPP threads are called in sequence to process the corresponding tasks in accordance with the adjusted scheduling order to obtain the encoding results of the image to be processed.
[0140] The processing priorities corresponding to the respective processing resources may be the same or different. It should be noted that, in the embodiment of the present application, the adjusted scheduling order still satisfies the dependency condition.
[0141] If the processing priorities corresponding to the processing resources are the same, then based on the dependency between the encoding results of each CU in the image to be processed, after obtaining the scheduling order between the tasks in the task set, as an implementation method, the scheduling order may not be adjusted, that is, directly based on the processing resources corresponding to each task in the task set, according to the scheduling order, the corresponding WPP threads are called in sequence to process the corresponding tasks to obtain the encoding result of the image to be processed.
[0142] As another implementation, based on the number of tasks corresponding to each processing resource, for a processing resource whose corresponding number of tasks exceeds a set task number threshold, the portion of the tasks corresponding to the processing resource exceeding the set task number threshold may be adjusted to tasks corresponding to other processing resources other than the processing resource, where the other processing resources refer to processing resources that support processing of some of the tasks. Then, based on the adjusted correspondence between tasks and processing resources, the scheduling order is adjusted. Furthermore, based on the processing resources corresponding to each task in the total task set, the corresponding WPP threads are sequentially called to process the corresponding tasks in accordance with the adjusted scheduling order, thereby obtaining the encoding result of the image to be processed.
[0143] The tasks to be adjusted may be randomly selected from the tasks corresponding to the processing resource, or may be selected according to the scheduling order, without limitation. A processing resource supporting task processing refers to a processing resource whose corresponding CU size is not smaller than the CU size corresponding to the task.
[0144] It should be noted that, since the Pred task, TQ task, and RDO task need to be executed in sequence, when performing task adjustment, the Pred task, TQ task, and RDO task are adjusted simultaneously.
[0145] For example, taking the Pred resource as an example, assuming that the task number threshold is set to 15, and the number of tasks corresponding to the 16×16 pixel Pred resource is 16, then the number of tasks corresponding to the 16×16 pixel Pred resource exceeds the set task number threshold. Therefore, the Blk0-U Pred task in the tasks corresponding to the 16×16 pixel Pred resource is adjusted to the task corresponding to the 32×32 pixel Pred resource, the Blk0-U TQ task in the tasks corresponding to the 16×16 pixel TQ resource is adjusted to the task corresponding to the 32×32 pixel TQ resource, and the Blk0-U RDO task in the tasks corresponding to the 16×16 pixel RDO resource is adjusted to the task corresponding to the 32×32 pixel RDO resource.
[0146] Referring to Figure 14, based on the adjusted correspondence between tasks and processing resources, the scheduling order is adjusted. In the adjusted scheduling order, after the 32×32 pixel Pred resources, TQ resources, and RDO resources respectively process the Blk0-U Pred task, Blk0-U TQ task, and Blk0-U RDO task, the 16×16 pixel Pred resources, TQ resources, and RDO resources respectively process the Blk0-V Pred task, Blk0-V TQ task, and Blk0-V RDO task.
[0147] If the processing priorities corresponding to the processing resources are different, the scheduling relationship is adjusted based on the processing priorities corresponding to the processing resources. Specifically, when adjusting the scheduling relationship based on the processing priorities corresponding to the processing resources, if the processing priority of one processing resource is higher than the processing priority of another processing resource, then in the adjusted scheduling order, the execution order of the task corresponding to the processing resource with the higher processing priority is earlier than the execution order of the task corresponding to the processing resource with the lower processing priority.
[0148] For example, the processing priority of the 16×16 pixel pipeline is higher than that of the 8×8 pixel pipeline. Therefore, when processing a 16×16 pixel task and an 8×8 pixel task, the execution order of the 16×16 pixel task is earlier than that of the 8×8 pixel task.
[0149] Through the above implementation, priority control is used to enable N types of tasks to be processed in parallel while fully utilizing the corresponding N types of resources, so that resource utilization is optimized, thereby improving coding efficiency and coding quality.
[0150] In some embodiments, when tasks of different CUs are processed in different pipelines, and different pipelines process tasks of different CUs, the task completion times of the associated CUs are matched at the synchronization node, where matching can mean that the task completion times of the CUs are the same, or that the difference between the task completion times of the CUs is within a preset range.
[0151] In HEVC, since the minimum partitioning unit is 8×8 pixels, the optimal partitioning mode of an LCU is selected. When the size of the LCU is 64×64 pixels and the maximum coding depth is 3, it is necessary to traverse the partitioning from 64×64 pixels to 8×8 pixels, that is, 85 CUs. The optimal partitioning method of the LCU is determined by calculating the rate-distortion cost. Among them, the 85 CUs include: one CU of 64×64 pixels, four CUs of 32×32 pixels, 16 CUs of 16×16 pixels, and 64 CUs of 8×8 pixels.
[0152] In the process of selecting the optimal partitioning mode of the LCU, for each CU, each intra-frame prediction mode and each inter-frame prediction mode are traversed, and the optimal prediction mode, that is, the optimal prediction unit (PU), is determined through the rate-distortion cost.
[0153] Among them, for intra-frame prediction mode, the luminance component has 35 intra-frame prediction modes, including: planar mode (Planar mode), direct current mode (DC mode) and 33 angle modes, and the chrominance component has 5 intra-frame prediction modes, including: planar mode, DC mode, horizontal direction mode, vertical direction mode and intra-frame prediction mode corresponding to the luminance component. For inter-frame prediction mode, the inter-frame prediction mode mainly includes: inter-frame mode (Inter mode), merge mode (Merge mode) and skip mode (Skip mode).
[0154] The process of determining the optimal LCU partitioning mode and the optimal prediction mode can be divided into the following steps:
[0155] In the first step, for a coding unit a with a size of 64×64 pixels and a depth of 0, each intra prediction mode and each inter prediction mode are traversed to obtain the optimal prediction mode and rate-distortion cost Ra when the depth is 0.
[0156] In the second step, a is further divided to obtain four 32×32 pixel CUs: b0, b1, b2, b3, and the coding depth is 1.
[0157] First, each intra-frame prediction mode and each inter-frame prediction mode are traversed for the coding unit b0 to obtain the optimal prediction method and rate-distortion cost Rb0 of b0.
[0158] In the third step, b0 is further divided to obtain four 16×16 pixel CUs: c0, c1, c2, and c3. At this time, the coding depth is 2.
[0159] For c0, each intra-frame prediction mode and each inter-frame prediction mode are traversed to obtain the optimal prediction mode and rate-distortion cost Rc0 of c0.
[0160] In the fourth step, c0 is further partitioned to obtain four 8×8 pixel CUs: d0, d1, d2, and d3. At this point, the coding depth is 3, which has reached the maximum coding depth and cannot be partitioned. For d0, d1, d2, and d3, each intra-frame prediction mode and each inter-frame prediction mode are traversed to obtain the corresponding optimal prediction method and rate-distortion cost Rd0, Rd1, Rd2, and Rd3. The sum of the rate-distortion costs of d0, d1, d2, and d3 is calculated and compared with Rc0. The smaller value between the sum of the rate-distortion costs of d0, d1, d2, and d3 and Rc0 is selected as the optimal rate-distortion cost Min-Rc0 for c0. The corresponding prediction mode and partitioning method are then used as the optimal prediction mode and partitioning method for c0.
[0161] In the fifth step, referring to the fourth step, c1, c2 and c3 are divided and the prediction mode is selected in turn, and the corresponding optimal prediction mode and rate-distortion cost Min-Rc1, Min-Rc2, Min-Rc3 are obtained respectively, and the sum of the rate-distortion costs of c0, c1, c2 and c3 (the sum of Min-Rc0, Min-Rc1, Min-Rc2, Min-Rc3) is calculated. Then, the sum of the rate-distortion costs of c0, c1, c2 and c3 is compared with Rb0. From the sum of the rate-distortion costs of c0, c1, c2 and c3 and Rb0, the smaller value is selected as the optimal rate-distortion cost Min-Rb0 of b0, and the corresponding prediction mode and segmentation method are used as the optimal prediction mode and segmentation method of b0.
[0162] In the sixth step, referring to steps 2 to 5, b1, b2, and b3 are divided and prediction modes are selected in turn to obtain the corresponding optimal prediction mode and rate-distortion cost Min-Rb1, Min-Rb2, and Min-Rb3, and the sum of Min-Rb0, Min-Rb1, Min-Rb2, and Min-Rb3 is calculated. Then, by comparing the sum of Min-Rb0, Min-Rb1, Min-Rb2, and Min-Rb3 with Ra, the optimal prediction mode and segmentation method of the LCU are determined.
[0163] The synchronization node refers to the comparison of the encoding results of the associated CUs before performing a mode comparison. For example, before comparing the sum of the rate-distortion costs of d0, d1, d2, and d3 with Rc0, d0, d1, d2, d3, and c0 are required to complete the task. Therefore, d0, d1, d2, d3, and c0 are associated CUs, and the synchronization node compares the sum of the rate-distortion costs of d0, d1, d2, and d3 with Rc0. For example, before comparing the sum of the rate-distortion costs of c0, c1, c2, and c3 with Rb0, c0, c1, c2, c3, and b0 are required to complete the task. Therefore, c0, c1, c2, c3, and b0 are associated CUs, and the synchronization node compares the sum of the rate-distortion costs of c0, c1, c2, and c3 with Rb0.
[0164] For example, the task completion time of four 8x8 pixel CUs is synchronized with the task completion time of one 16x16 pixel CU, so that after the encoding of the four 8x8 CU blocks is completed, they are compared with the encoded 16x16 CU block to obtain the optimal mode.
[0165] The following describes the method in conjunction with a specific embodiment.
[0166] Refer to Figure 15, which is a schematic diagram of the architecture of a mode judgment provided in an embodiment of the present application. In this architecture, an MD configuration module, a WPP control module and each pipeline scheduling module are included. Each process line scheduling module corresponds to a pipeline, and each pipeline contains an independent set of Pred processing resources, TQ processing resources, and RDO processing resources.
[0167] The MD control module is used to configure the processing priorities corresponding to each processing resource. The WPP control module may include a WPP priority scheduling module and a WPP dependency scheduling module. The WPP priority scheduling module is used to sequentially use each WPP thread to execute corresponding tasks based on the calling relationship, and the WPP dependency scheduling module is used to configure dependency relationships. Each pipeline scheduling module is used to execute corresponding tasks based on the Pred processing resources, TQ processing resources, and RDO processing resources in the corresponding pipeline.
[0168] After acquiring the image to be processed, the image is first divided into blocks based on the CTU structure to obtain the CUs in the image to be processed. Then, each CU in the image to be processed is pipelined according to CU size and number of CU blocks, so that chroma components and luminance components of the same CU size are divided into the same pipeline. Each pipeline has an independent set of Pred, Time Query, and Response Time (RDO) resources for mode decision calculation. Each CU block is processed in a different pipeline, and the CU blocks in different pipelines are time-matched at the synchronization node.
[0169] Referring to FIG11 , each pipeline is a three-stage pipeline including Pred, TQ, and RDO. In an embodiment of the present application, after determining the CU set associated with each WPP thread, a corresponding set of tasks to be executed is obtained for each WPP thread, wherein each task subset includes a Pred task, a TQ task, and an RDO task. Then, based on the Pred resources, the TQ task resources, and the RDO task resources, the processing resources corresponding to each task included in each task set are determined respectively. Then, based on the dependency between the encoding results of each CU in the image to be processed, the scheduling order between the tasks in each task set is obtained. The scheduling order supports parallel processing of three WPP threads. Finally, based on the processing resources corresponding to each task in the task set, the corresponding WPP threads are called in sequence according to the scheduling order to process the corresponding tasks, thereby obtaining the encoding result of the image to be processed.
[0170] In the embodiment of the present application, 3WPP is started simultaneously to encode each CU. During the encoding process, tasks corresponding to independent CUs that have no dependency relationship can be interleaved and executed between dependent CUs.
[0171] In the embodiments of the present application, this efficient video coding method was used to perform encoding tests on 1080P 2Mbps bitrate point video. Statistics show that the encoding speed of a single MD LCU is twice that of a single-stage pipeline solution in the prior art that only processes Pred, TQ, or RDO at the same time. The utilization of the three-stage Pred, TQ, and RDO pipelines using this efficient video coding method was also tested. The test results showed that Pred utilization reached 84.47%, TQ utilization reached 75.56%, and RDO utilization reached 82.94%, indicating that all three stages of Pred, TQ, and RDO have high pipeline utilization.
[0172] 16 shows a flow chart of a video encoding method 1600 according to an embodiment of the present application. The video encoding method 1600 is executed in an electronic device.
[0173] Step S1601, acquiring an image.
[0174] Step S1602: Partition the image into multiple coding tree units (CTUs), each of which includes one or more coding units (CUs). In some embodiments, the size of a CTU is 64×64 pixels, and the smallest CU is 8×8 pixels. Therefore, the size of a CU can be 8×8 pixels, 16×16 pixels, 32×32 pixels, or 64×64 pixels. In HEVC, the size of an LCU is typically 64×64 pixels. Therefore, in some embodiments, an LCU can be equivalent to a CTU.
[0175] Step S1603 allocates the coding tasks of the coding blocks of the CUs in the multiple CTU rows in the image into multiple task sequences, where each task sequence is a sequence of coding tasks for multiple coding blocks. Here, each task sequence can represent the execution order of the coding tasks in the task sequence. In addition, the multiple task sequences can represent the execution order of all coding tasks in the multiple task sequences. At the same time point, different coding tasks in different task sequences can be executed in parallel.
[0176] Step S1604 : Execute the multiple task sequences in parallel to obtain encoding results of the encoding blocks of the CUs in the multiple CTU rows.
[0177] In summary, the embodiments of the present application can divide the overall encoding tasks corresponding to multiple CTU rows (or multiple LCU rows) into multiple task sequences that are executed in parallel, rather than encoding only a single CTU at a time, thereby improving encoding efficiency.
[0178] In some embodiments, the size of a CTU (or LCU) is 64×64 pixels, the maximum coding depth is 3, and the minimum partition unit is 8×8 pixels. In order to determine the optimal partitioning mode of a CTU (or LCU), it is necessary to traverse the partitioning from 64×64 pixels to 8×8 pixels and determine the optimal partitioning method of the LCU by calculating the rate-distortion cost. Therefore, a CTU can include 85 CUs. Among them, the 85 CUs include: one 64×64 pixel CU, four 32×32 pixel CUs, 16 16×16 pixel CUs, and 64 8×8 pixel CUs.
[0179] In some embodiments, allocating the encoding tasks of the coding blocks of the CUs in the plurality of CTU rows in the image into a plurality of task sequences comprises:
[0180] Based on the coding dependencies between the coding blocks of the CUs in the multiple CTU rows, the coding tasks of the coding blocks of the CUs in the multiple CTU rows are allocated into the multiple task sequences. In this way, the embodiment of the present application determines each task sequence based on the coding dependencies, so that the process of executing the coding tasks in parallel in the embodiment of the present application can satisfy the coding dependencies between the coding tasks to ensure the normal progress of the coding. In some embodiments, the multiple coding blocks corresponding to each task sequence have the same coding block size or correspond to the same CU size.
[0181] The allocating the encoding tasks of the encoding blocks of the CUs in the multiple CTU rows in the image into multiple task sequences includes:
[0182] According to the coding block size or CU size, the coding tasks of the coding blocks of the CUs in the multiple CTU rows in the image are allocated into multiple task sequences. For example, for a coding block size of 32×32, the present application can divide the luminance coding blocks and chrominance coding blocks of 32×32 pixels in the CUs in multiple CTU rows into the same task sequence. For example, for a CU size of 32×32, the present application can divide the luminance coding blocks (size of 32×32) and chrominance coding blocks (size of 16×16) of the CUs of 32×32 pixels in the CUs in multiple CTU rows into the same task sequence.
[0183] In some embodiments, allocating the coding tasks of the coding blocks of the CUs in the multiple CTU rows in the image into multiple task sequences according to the coding block size or the CU size includes:
[0184] Allocating, for the image, encoding tasks of encoding blocks of CUs in a plurality of CTU rows in the image into a plurality of groups according to a coding block size or a CU size;
[0185] Based on the coding dependencies between the coding blocks of the CUs in the multiple CTU rows, the coding tasks in each of the multiple groups are sorted into corresponding task sequences. For example, the coding tasks of the coding blocks with the same coding block size in multiple CTU rows in the image are assigned to the same task sequence to obtain the multiple task sequences; or the tasks of the coding blocks of the CUs with the same CU size in multiple CTU rows in the image are assigned to the same task sequence to obtain the multiple task sequences.
[0186] In some embodiments, at the CTU (LCU) level, the embodiment of the present application can process multiple CTU rows in the image in parallel according to the WPP method of the embodiment of Figure 13 above, that is, the processing progress of any two adjacent CTU rows differs by two CTUs. More specifically, the processing progress of the upper CTU row in the two adjacent CTU rows is two CTUs ahead of the lower CTU row. In addition, for multiple CTUs processed in parallel (for example, multiple CTUs processed in parallel come from different CTU rows), the embodiment of the present application can allocate the encoding tasks of the coding blocks of all CUs corresponding to the multiple CTUs into multiple task sequences at the CU level. In this way, at the CTU level, the embodiment of the present application can process multiple CTU rows in a WPP manner. At the CU level, the encoding tasks of the coding blocks of the CUs in multiple CTUs executed in parallel are processed according to multiple parallel task sequences.
[0187] In some embodiments, the coding blocks of each CU include one luma coding block and two chroma coding blocks, and the size of each of the two chroma coding blocks is smaller than the size of the luma coding block.
[0188] The coding dependency relationship between the coding blocks of the CUs in the multiple CTUs includes at least one of the following:
[0189] A first dependency relationship is used to indicate that, for two adjacent CUs in the image, encoding of the luminance coding block of the right CU depends on the encoding result of the luminance coding block of the left CU;
[0190] The second dependency relationship is used to indicate that, for two adjacent CUs in the image, the encoding of the luminance coding block of the right CU depends on the encoding result of the chrominance coding block of the left CU;
[0191] The third dependency relationship is used to indicate that the encoding of the chrominance coding block of each CU in the image depends on the encoding result of the respective luminance coding block. For details of the first, second and third dependency relationships, please refer to the embodiments of Figures 12A to 12C above.
[0192] In some embodiments, sorting the coding tasks in each of the plurality of groups into a corresponding task sequence based on the coding dependencies between the coding blocks of the CUs in the plurality of CTU rows includes at least one of the following:
[0193] For two adjacent CUs in the image, according to the first dependency relationship, assigning an execution order of the coding task of the luma coding block of the right CU to be later than an execution order of the coding task of the luma coding block of the left CU;
[0194] For two adjacent CUs in the image, according to the second dependency, assigning execution order of the coding task of the luma coding block of the right CU to be later than the coding task of the chroma coding block of the left CU;
[0195] Based on the third dependency, the execution order of the coding tasks of the chrominance coding blocks of each CU in the image is assigned to be later than the coding tasks of the respective luminance coding blocks. In this way, the embodiment of the present application can arrange the coding tasks corresponding to multiple CTU rows in an overall manner, and can execute the coding tasks corresponding to multiple CTU rows in parallel while ensuring the coding dependency, thereby improving coding efficiency.
[0196] In some embodiments, the embodiments of the present application further include: obtaining a plurality of pipelines, wherein each pipeline includes at least one level of processing resources for encoding, wherein different levels of processing resources are used to process different types of encoding tasks;
[0197] The step of allocating the encoding tasks of the encoding blocks of the CUs in the multiple CTU rows in the image into multiple task sequences includes:
[0198] The encoding tasks of the encoding blocks of the CUs in the multiple CTU rows in the image are distributed to the multiple pipelines to obtain a task sequence of each pipeline.
[0199] In some embodiments, each pipeline includes three levels of processing resources, wherein the first level of processing resources is used to perform prediction processing regarding the coding mode, the second level of processing resources is used to perform transform and quantization processing, and the third level of processing resources is used to perform rate-distortion optimization processing. The encoding task of each coding block of each CU includes a prediction processing task (i.e., the Pred task mentioned above), a transform and quantization processing task (i.e., a TQ task), and a rate-distortion optimization processing task (i.e., an RDO task) for the corresponding coding block. Each coding block in the embodiment of the present application will be processed in sequence by the processing resources at each level in the pipeline, that is, each coding block performs prediction processing, transform and quantization processing, and rate-distortion optimization processing in sequence. In addition, in the embodiment of the present application, different levels of processing resources in the pipeline can process the encoding tasks of different coding blocks at the same time point respectively, without having to wait for the three encoding tasks of the same coding block to be completed before executing the encoding task corresponding to another coding block. In this way, the embodiment of the present application can improve the utilization of processing resources and improve coding efficiency.
[0200] In some embodiments, obtaining multiple pipelines includes:
[0201] Generate a corresponding pipeline for each of the multiple CU sizes; or
[0202] A corresponding pipeline is generated for each of the multiple encoding block sizes.
[0203] Therefore, embodiments of the present application can establish pipelines based on CU size or coding block size. That is, CU size is associated with pipeline selection. It should be understood that CU size (coding block size) is proportional to the processing resources (e.g., memory, CPU, etc.) of the pipeline classification.
[0204] In some embodiments, different pipelines in the plurality of pipelines correspond to different CU sizes; and allocating encoding tasks for coding blocks of CUs in a plurality of CTU rows in the image to the plurality of pipelines to obtain a task sequence for each pipeline includes:
[0205] Based on the sizes of the CUs in the plurality of CTU rows, assigning coding tasks for the coding blocks of the CUs in the plurality of CTU rows to pipelines corresponding to the sizes of the corresponding CUs;
[0206] Based on the coding dependencies between the coding blocks of the CUs in multiple CTU rows, the execution order of the coding tasks assigned to each pipeline is determined to obtain the task sequence of each pipeline.
[0207] In this way, the present application can divide the coding blocks of CUs into pipelines that match the CU sizes according to the different CU sizes, so that the coding tasks of the coding blocks of CUs of different CU sizes can be processed in parallel while satisfying the coding dependencies, thereby improving the coding efficiency.
[0208] In some embodiments, different pipelines in the plurality of pipelines correspond to different coding block sizes; and allocating the coding tasks for the coding blocks of the CUs in the plurality of CTU rows in the image to the plurality of pipelines to obtain a task sequence for each pipeline includes:
[0209] Allocating, based on sizes of coding blocks of CUs in the plurality of CTU rows, coding tasks of the coding blocks of the CUs in the plurality of CTU rows to pipelines corresponding to the corresponding coding block sizes;
[0210] Based on the coding dependencies between the coding blocks of the CUs in multiple CTU rows, the execution order of the coding tasks assigned to each pipeline is determined to obtain the task sequence of each pipeline.
[0211] Since coding blocks are assigned to corresponding pipelines based on their size, the luma and chroma coding blocks of the same CU are assigned to different pipelines. In this way, the encoding tasks of the luma coding block and the chroma coding block of the same CU can be processed in parallel in different pipelines in the embodiment of the present application, thereby improving the encoding efficiency of the CU.
[0212] In some embodiments, the embodiments of the present application may further include: creating multiple threads; associating a thread with each CTU row;
[0213] Each encoding task in each task sequence is executed by a thread associated with the CTU row where the corresponding encoding block is located.
[0214] Here, the thread is, for example, a WPP thread. When executing an encoding task of an encoding block, the thread can utilize processing resources in a pipeline associated with a task sequence in which the encoding task is located to execute the encoding task.
[0215] Based on the same inventive concept, an embodiment of the present application provides a video encoding device. As shown in FIG16 , it is a schematic structural diagram of a video encoding device 1700 , which may include:
[0216] An acquisition unit 1701 is used to acquire an image;
[0217] A partitioning unit 1702 is configured to partition the image into a plurality of coding tree units (CTUs), where each CTU includes one or more coding units (CUs);
[0218] a scheduling unit 1703, configured to allocate coding tasks of coding blocks of CUs in multiple CTU rows in the image into multiple task sequences, wherein each task sequence is a sequence consisting of coding tasks of multiple coding blocks;
[0219] The encoding unit 1704 is configured to execute the multiple task sequences in parallel to obtain encoding results of the encoding blocks of the CUs in the multiple CTU rows.
[0220] For more specific implementation of device 1700, please refer to method 1600, which will not be repeated here.
[0221] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.
[0222] Regarding the apparatus in the above embodiment, the specific manner in which each unit executes the request has been described in detail in the embodiment of the method, and will not be elaborated on here.
[0223] Those skilled in the art will appreciate that various aspects of the present application can be implemented as systems, methods, or program products. Therefore, various aspects of the present application can be specifically implemented in the following forms: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation that combines hardware and software aspects, which may be collectively referred to herein as a "circuit," "module," or "system."
[0224] Based on the same inventive concept, an embodiment of the present application further provides an electronic device. In one embodiment, the electronic device can be a server or a terminal device. Referring to FIG. 18 , which is a schematic diagram of the structure of a possible electronic device provided in an embodiment of the present application, electronic device 1800 includes a processor 1810 and a memory 1820.
[0225] The memory 1820 stores a computer program that can be executed by the processor 1810 . The processor 1810 can execute the steps of the above-mentioned video encoding method by executing the instructions stored in the memory 1820 .
[0226] Memory 1820 can be a volatile memory, such as random-access memory (RAM); a non-volatile memory, such as read-only memory (ROM), flash memory, a hard disk drive (HDD), or a solid-state drive (SSD); or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1820 can also be a combination of the above memories.
[0227] The processor 1810 may include one or more central processing units (CPUs) or digital processing units, etc. The processor 1810 is configured to implement the above-mentioned video encoding method when executing the computer program stored in the memory 1820 .
[0228] In some embodiments, the processor 1810 and the memory 1820 may be implemented on the same chip. In some embodiments, they may also be implemented on separate chips.
[0229] The specific connection medium between the processor 1810 and the memory 1820 is not limited in the embodiments of the present application. In the embodiments of the present application, the bus connection between the processor 1810 and the memory 1820 is used as an example. The bus is depicted as a bold line in FIG18 . The connection methods between other components are merely illustrative and are not intended to be limiting. Buses can be divided into address buses, data buses, control buses, etc. For ease of description, FIG18 depicts only a single bold line, but this does not imply that there is only one bus or only one type of bus.
[0230] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium, which includes a computer program. When the computer program is executed on an electronic device, the computer program is used to cause the electronic device to perform the steps of the above-mentioned video encoding method. In some possible implementations, various aspects of the video encoding method provided by the present application can also be implemented in the form of a program product, which includes a computer program. When the program product is executed on an electronic device, the computer program is used to cause the electronic device to perform the steps of the above-mentioned video encoding method. For example, the electronic device can perform the steps shown in Figures 5 or 16.
[0231] The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, RAM, ROM, an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0232] The program product of the embodiments of the present application may be a CD-ROM and include a computer program, and may be run on an electronic device. However, the program product of the present application is not limited thereto. In this document, a readable storage medium may be any tangible medium that contains or stores a computer program that can be used by or in conjunction with a command execution system, apparatus, or device.
[0233] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries a readable computer program. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a computer program for use by or in conjunction with a command execution system, apparatus, or device.
[0234] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional 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 application.
[0235] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
[0236] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
Claims
1. A video encoding method, performed in an electronic device, the method comprising: Get the image; Partitioning the image into a plurality of coding tree units (CTUs), wherein each CTU includes one or more coding units (CUs); Allocating the encoding tasks of the encoding blocks of the CUs in the multiple CTU rows in the image into multiple task sequences, wherein each task sequence is a sequence composed of the encoding tasks of the multiple encoding blocks; The multiple task sequences are executed in parallel to obtain encoding results of the encoding blocks of the CUs in the multiple CTU rows.
2. The method of claim 1, wherein: The multiple coding blocks corresponding to each task sequence have the same coding block size or correspond to the same CU size; The allocating the encoding tasks of the encoding blocks of the CUs in the multiple CTU rows in the image into multiple task sequences includes: According to the coding block size or the CU size, the coding tasks of the coding blocks of the CUs in the multiple CTU rows in the image are allocated into multiple task sequences.
3. The method according to claim 2, wherein the encoding tasks of the encoding blocks of the CUs in the plurality of CTU rows in the image are allocated into a plurality of task sequences according to the encoding block size or the CU size, comprising: Allocating, according to a coding block size or a CU size, coding tasks of coding blocks of CUs in a plurality of CTU rows in the image into a plurality of groups; Based on the coding dependencies between the coding blocks of the CUs in the multiple CTU rows, the coding tasks in each of the multiple groups are sorted into a corresponding task sequence.
4. The method of claim 3, wherein: The coding block of each CU includes a luminance coding block and two chrominance coding blocks, and the size of each of the two chrominance coding blocks is smaller than the size of the luminance coding block; The coding dependency relationship between the coding blocks of the CUs in the multiple CTUs includes at least one of the following: The first dependency relationship is used to indicate that, for two adjacent CUs in the image, the encoding of the luminance coding block of the right CU depends on the encoding result of the luminance coding block of the left CU; The second dependency relationship is used to indicate that, for two adjacent CUs in the image, the encoding of the luminance coding block of the right CU depends on the encoding result of the chrominance coding block of the left CU; The third dependency is used to indicate that the encoding of the chrominance coding block of each CU in the image depends on the encoding result of the respective luminance coding block.
5. The method of claim 4, wherein: The sorting of the encoding tasks in each of the plurality of groups into a corresponding task sequence based on the encoding dependencies between the encoding blocks of the CUs in the plurality of CTU rows includes at least one of the following: For two CUs adjacent to each other in the image, according to the first dependency relationship, the execution order of the coding task of the luminance coding block of the right CU is assigned to be later than the coding task of the luminance coding block of the left CU; for two CUs adjacent to each other in the image, according to the second dependency relationship, the execution order of the coding task of the luminance coding block of the right CU is assigned to be later than the coding task of the chrominance coding block of the left CU; According to the third dependency, the execution order of the coding tasks of the chrominance coding blocks of each CU in the image is assigned to be later than the coding tasks of the respective luminance coding blocks.
6. The method of claim 1, further comprising: Acquire a plurality of pipelines, wherein each pipeline comprises at least one level of processing resources for encoding, wherein different levels of processing resources are used to process different types of encoding tasks; The step of allocating the encoding tasks of the encoding blocks of the CUs in the plurality of CTU rows in the image into a plurality of task sequences includes: The encoding tasks for the encoding blocks of the CUs in the multiple CTU rows in the image are allocated to the multiple pipelines to obtain a task sequence for each pipeline.
7. The method of claim 6, wherein: Each pipeline includes three levels of processing resources, wherein the first level of processing resources is used to perform prediction processing regarding the coding mode, the second level of processing resources is used to perform transform and quantization processing, and the third level of processing resources is used to perform rate-distortion optimization processing, and the encoding task of each coding block of each CU includes a prediction processing task, a transform and quantization processing task, and a rate-distortion optimization processing task for the corresponding coding block.
8. The method of claim 6, wherein: The obtaining of multiple pipelines includes: Generate a corresponding pipeline for each of the multiple CU sizes; or A corresponding pipeline is generated for each of the plurality of encoding block sizes.
9. The method according to any one of claims 6 to 8, wherein different pipelines in the plurality of pipelines correspond to different CU sizes; The allocating the encoding tasks of the encoding blocks of the CUs in the multiple CTU rows in the image to the multiple pipelines to obtain a task sequence of each pipeline includes: Based on the sizes of the CUs in the multiple CTU rows, assigning encoding tasks of the encoding blocks of the CUs in the multiple CTU rows to pipelines corresponding to the sizes of the corresponding CUs; Based on the coding dependencies between the coding blocks of the CUs in the multiple CTU rows, the execution order of the coding tasks assigned to each pipeline is determined to obtain the task sequence of each pipeline.
10. The method according to any one of claims 6 to 8, wherein different pipelines in the plurality of pipelines correspond to different encoding block sizes; The allocating the encoding tasks of the encoding blocks of the CUs in the multiple CTU rows in the image to the multiple pipelines to obtain a task sequence of each pipeline includes: Based on the sizes of the coding blocks of the CUs in the multiple CTU rows, assigning the coding tasks of the coding blocks of the CUs in the multiple CTU rows to pipelines corresponding to the corresponding coding block sizes; Based on the coding dependencies between the coding blocks of the CUs in the multiple CTU rows, the execution order of the coding tasks assigned to each pipeline is determined to obtain the task sequence of each pipeline.
11. The method of any one of claims 1 to 9, further comprising: Create multiple threads; Associate a thread with each CTU row; Each encoding task in each task sequence is executed by a thread associated with the CTU row where the corresponding encoding block is located.
12. A video encoding device, characterized in that: include: An acquisition unit, used for acquiring an image; A partitioning unit, configured to partition the image into a plurality of coding tree units CTU, wherein each CTU includes one or more coding units CU; A scheduling unit, used to allocate the encoding tasks of the encoding blocks of the CUs in the multiple CTU rows in the image into multiple task sequences, wherein each task sequence is a sequence composed of the encoding tasks of the multiple encoding blocks; The encoding unit is used to execute the multiple task sequences in parallel to obtain encoding results of the encoding blocks of the CUs in the multiple CTU rows.
13. An electronic device comprising a processor and a memory, wherein: The memory stores a computer program, and when the computer program is executed by the processor, the processor is enabled to perform the method according to any one of claims 1 to 11.
14. A computer-readable storage medium comprising a computer program, wherein when the computer program is executed on an electronic device, the computer program is used to cause the electronic device to execute the method according to any one of claims 1 to 11.
15. A computer program product, comprising a computer program, wherein the computer program is stored in a computer-readable storage medium, and a processor of an electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device executes any one of the methods of claims 1 to 11.
Citation Information
Patent Citations
Enhanced data processing apparatus employing multiple-block based pipeline and operation method thereof
CN106686380A
Intra-frame coding prediction method based on CPU + GPU hybrid coding
CN110677646A
Ultrahigh-definition video image parallel processing method
CN113259675A
Mode decision scheduling method and related device
CN116980616A
Block mapping in high efficiency video coding compliant encoders and decoders
US10127624B1
