Video image coding method and device, storage medium and terminal equipment
By converting the video image format to YUV420 and dividing it into MCU lines, and writing and reading alternately in the two buffer spaces, parallel processing of the video image encoding process is achieved, solving the problems of large buffer space consumption and low processing efficiency, and improving Improve data processing efficiency and system stability.
Patent Information
- Application Number
- CN202410688159.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-09-06
AI Technical Summary
The existing video image compression and encoding process consumes a lot of buffer space and has low processing efficiency, resulting in high peak bandwidth and large delay.
Convert the format of the video image from YUV422 to YUV420, and divide the converted video image into multiple MCU lines, using an alternate use strategy to write and read MCU lines in the two buffer spaces to achieve data writing and encoding of parallel processing.
It significantly improves the data processing efficiency of the video encoding process, optimizes resource utilization, reduces latency, and improves system stability. It is suitable for scenarios such as real-time video processing and streaming media transmission.
Smart Images

Figure CN118612450A
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to a method, apparatus, storage medium and terminal device for encoding video images. Background Art
[0002] The video image is a static video frame. It needs to be compressed and encoded before it is displayed. The compression encoding process is as follows: first, the original video image is saved to the frame buffer space. After the video image is saved, the video image is read from the frame buffer space, and then the video image is compressed and encoded. The problems with the above compression encoding process are: the buffer space consumed is too large; the encoding data bandwidth is relatively concentrated, that is, after the video image is ready, the encoding and reading of data begins in a concentrated manner, resulting in high peak bandwidth and large delay. Summary of the invention
[0003] The embodiments of the present application provide a video image encoding method, apparatus, storage medium and terminal device, which can solve the problems of large buffer space consumption and low processing efficiency in the video image compression encoding process in the prior art. The technical solution is as follows:
[0004] In a first aspect, an embodiment of the present application provides a method for encoding a video image, the method comprising:
[0005] Obtain a video image to be encoded; the height of the video image is L, the width is W, L and W are integer multiples of 16, and the format of the video image is YUV422;
[0006] Convert the format of the video image from YUV422 to YUV420;
[0007] Divide the converted video image into multiple MCU rows; the height of each MCU row is 16, the width is W, and the size of each MCU is 16×16;
[0008] Selecting one MCU row from the plurality of MCU rows at a time;
[0009] Determine a target buffer space in the first buffer space and the second buffer space according to the alternating use strategy, and write the selected MCU row into the target buffer space;
[0010] During the process of writing the selected MCU row into the target buffer space, an MCU row is read from another buffer space, and encoding and compression processing is performed on the read MCU row.
[0011] In a second aspect, an embodiment of the present application provides a video image encoding device, the device comprising:
[0012] An acquisition unit, used for acquiring a video image to be encoded; the height of the video image is L, the width is W, L and W are integer multiples of 16, and the format of the video image is YUV422;
[0013] A conversion unit, used for converting the format of the video image from YUV422 to YUV420;
[0014] A division unit, used for dividing the converted video image into a plurality of MCU rows; the height of each MCU row is 16, the width is W, and the size of each MCU is 16×16;
[0015] A selection unit, configured to select one MCU row from the plurality of MCU rows at a time;
[0016] a writing unit, configured to determine a target buffer space in the first buffer space and the second buffer space according to an alternating use strategy, and to write the selected MCU row into the target buffer space;
[0017] The encoding unit is used to read an MCU row from another buffer space and perform encoding compression processing on the read MCU row during the process of writing the selected MCU row into the target buffer space.
[0018] In a third aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.
[0019] In a fourth aspect, an embodiment of the present application provides a terminal device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.
[0020] The beneficial effects brought about by the technical solutions provided by some embodiments of the present application include at least:
[0021] The parallel processing of data writing and data encoding significantly improves the data processing efficiency in the video encoding process. At the same time, through the design of optimizing resource utilization, reducing latency and improving system stability, this technical solution has broad application prospects in application scenarios such as real-time video processing and streaming media transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 It is a flowchart of a method for encoding a video image provided by an embodiment of the present application;
[0024] Figure 2 It is a schematic diagram of the structure of the MCU row provided in the embodiment of the present application;
[0025] Figure 3 It is a schematic diagram of the principle of video encoding provided by an embodiment of the present application;
[0026] Figure 4 It is a structural schematic diagram of a video image encoding device provided by the present application;
[0027] Figure 5 It is a structural diagram of a terminal device provided by this application. DETAILED DESCRIPTION
[0028] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0029] It should be noted that the video image encoding method provided in the present application is generally executed by a video image encoding device, and accordingly, the video image encoding device is generally arranged in a terminal device.
[0030] See also Figure 1 , is a flow chart of a method for encoding a video image provided by an embodiment of the present application. Figure 2 As shown, the method of the embodiment of the present application may include the following steps:
[0031] S101: Obtain a video image to be encoded.
[0032] The height of the video image is L, the width is W, and L and W are integer multiples of 16. When the encoding device needs to obtain video images to be encoded, and the height (L) and width (W) of these images must be integer multiples of 16, it is usually to meet the requirements of certain video encoding standards (such as H.264, H.265, etc.). The following are the specific steps and principles of the encoding device to perform this operation:
[0033] The encoding device first determines the video source, which may be a video file stored locally or remotely, or a real-time video stream (such as captured from a camera).
[0034] The encoding device uses a video processing library (such as FFmpeg, OpenCV, etc.) to read video frames (ie, static video images) from a video source.
[0035] After reading, the encoding device checks whether the width (W) and height (L) of the video frame are integer multiples of 16, which usually involves performing simple mathematical operations on the frame size, that is, determining whether the height and width of the video frame are divisible by 16.
[0036] If the size of the video frame is not an integer multiple of 16, the encoding device needs to adjust the size of the video frame to meet this requirement. This usually involves an image scaling operation. The encoding device uses the scaling function in the video processing library to adjust the size of the video frame to a size that is closest to and greater than or equal to the original size and is an integer multiple of 16.
[0037] After adjusting the size of the video frame, the encoding device may save the video frame to a file for subsequent encoding or other processing.
[0038] For example: Assume that the encoding device is processing a video file, and the original size of the video frame is 1910×1075. The encoding device needs to obtain each video frame and adjust the size of the video frame to an integer multiple of 16. The encoding device uses OpenCV to read a frame from the video file. Check the size of the frame and find that it is not an integer multiple of 16. Calculate the size that is closest to and greater than or equal to the original size and is also an integer multiple of 16. In this example, the encoding device adjusts the width to 1920 (the number closest to 1910 and an integer multiple of 16) and the height to 1088 (the number closest to 1075 and an integer multiple of 16). The encoding device uses OpenCV's resize function to adjust the frame size to 1920×1088. Save the adjusted frame to a file or perform subsequent encoding processing.
[0039] S102, converting the format of the video image from YUV422 to YUV420.
[0040] Among them, in the YUV422 format, for every two Y (luminance) components, there are two corresponding U and V (chrominance) components. This means that in the horizontal and vertical directions, the sampling rates of U and V are the same as Y. Since the YUV420 format has only two U components and two V components for every four Y components, the encoding device needs to perform a subsampling operation to reduce the number of U and V components. This means that: in the horizontal direction, the encoding device can retain the original U and V component sequence because their sampling rates have been matched with the Y component (at least for the semi-planar format of YUV422). In the vertical direction, the encoding device needs to discard some rows of U and V components. Specifically, for every two rows of Y components, the encoding device only needs to retain one row of U and V components, thereby achieving the effect of halving the U and V components in the vertical direction. According to the requirements of the YUV420 format, the encoding device needs to reorganize the data to ensure that the Y component remains unchanged, while the U and V components are correctly reduced and arranged. This usually involves rearranging or copying the image data. After completing the conversion, the encoding device can save the video frame in the YUV420 format to a file, perform subsequent processing or transmission.
[0041] It should be noted that the format conversion process does not change the size of the video frame (i.e. width and height), but only reduces the amount of pixel data by reducing the sampling rate of the chrominance components (U and V). This usually leads to a certain loss of image quality, but in many applications, this loss is acceptable because the human eye is usually more sensitive to brightness than chrominance.
[0042] S103, dividing the converted video image into a plurality of MCU rows.
[0043] Among them, the height of each MCU row is 16, the width is W, and the size of each MCU is 16×16. The encoding device first reads the width W and height H of the converted video image. Make sure that the width W is an integer multiple of 16, because the width of each MCU is 16 pixels. Since the size of each MCU is 16×16, the width of the MCU row (that is, the width of the image) is W, so the number of MCUs in each MCU row is W / 16. The encoding device initializes a counter variable (such as mcu_row_count) to track the row number of the MCU row currently being processed (starting from 0). Starting from the upper left corner of the video image, the encoding device traverses the video image line by line. For each row, the encoding device divides an MCU row at every 16-bit height and marks its position. Repeat this process until all rows of the image are traversed. In the process of dividing the MCU row, the encoding device records the position (serial number) of each MCU row.
[0044] See also Figure 2As shown, it is a structural diagram of an MCU row. The MCU row includes W / 16 MCU minimum coding units, and the arrangement order of each component of each MCU is: 4 Y components, 1 U component and 1 V component.
[0045] S104. Select an MCU row from multiple MCU rows in sequence.
[0046] Among them, the encoding device selects an MCU row from the divided multiple MCU rows in sequence until the last MCU row is selected. First, initialize a variable (such as mcu_row_index) to track the index of the current MCU row to be selected. Since we want to select in sequence, we usually start from the first row, that is, mcu_row_index = 0. Before selecting an MCU row each time, check whether mcu_row_index is less than or equal to the total number of MCU rows (this is usually equal to the height H of the video image divided by 16, because the height of each MCU is 16 pixels). If mcu_row_index is out of this range, it means that all MCU rows have been processed and the selection process can be ended. Use mcu_row_index as an index to select the corresponding MCU row from the divided MCU row set. This usually means accessing an array or list that stores MCU row information and taking out the element with index mcu_row_index. Perform the required processing on the selected MCU row. This may include traversing all MCUs in the MCU row and encoding, analyzing or other operations on each MCU. After processing the current MCU row, increase mcu_row_index by 1 so that the next MCU can be selected in the next iteration. Until mcu_row_index exceeds the total number of MCU rows, all MCU rows are processed.
[0047] S105 , determining a target buffer space in the first buffer space and the second buffer space, and writing the selected MCU row into the target buffer space.
[0048] Among them, when the encoding device needs to determine a target buffer space from two buffer spaces (the first buffer space and the second buffer space) and write the selected MCU row into the target buffer space, the specific implementation steps can be described as follows:
[0049] The encoding device first initializes two pointers (eg, buffer1_ptr and buffer2_ptr) to point to the start positions of the first buffer space and the second buffer space, respectively. The two buffer spaces should have been pre-allocated and ready for storing data.
[0050] The buffer space to be used as the target buffer space is determined according to the alternating use strategy. For example, if the buffer space used last time is the first buffer space, then the second buffer space is currently determined to be the target buffer space.
[0051] In some embodiments of the present application, the sizes of the Y component, the U component, and the V component are 1 byte, and the sizes of the first buffer unit and the second buffer unit are 16×W×1.5 bytes.
[0052] Before writing the MCU row to the target buffer space, the encoding device should check the status of the buffer space to ensure that it has enough space to store the entire MCU row. If the target buffer space is full or insufficient, some measures may need to be taken, such as waiting for space to be released, selecting another buffer space, or performing error handling.
[0053] Writing the selected MCU row data to the current pointer position of the target buffer space involves copying the data from the MCU row's data structure to the memory area of the buffer space. Ensure that the integrity and accuracy of the data is maintained during the writing process.
[0054] After writing is complete, update the pointer of the target buffer space to point to the next location available for writing. This usually means increasing the pointer by the size of the MCU row data (for example, for a 16x16 MCU, increase by 256 bytes or other values determined by the data format and encoding method). If you need to continue processing other MCU rows, you can repeat steps 2 to 6 until all MCU rows are written to the buffer space. In addition, according to the alternating use strategy, you need to switch the target buffer space after each write so that the two buffer spaces are used alternately.
[0055] S106. In the process of writing the selected MCU row into the target buffer space, an MCU row is read from another buffer space, and encoding and compressing the read MCU row is performed.
[0056] Among them, the target buffer space is the first buffer space or the second buffer space, and the other buffer space is a buffer space outside the target buffer space. For example, when the target buffer space is the first buffer space, the other buffer space is the second buffer space, so that the data writing to the first buffer space and the data reading from the second buffer space for encoding and compression processing are realized in parallel, which can significantly improve the data processing efficiency. The following are the specific matters and steps to achieve such parallel processing and bring efficiency improvement: Design a system architecture that supports parallel processing to ensure that data writing and encoding processing can be carried out simultaneously without interfering with each other. Use multi-core processors, hardware acceleration or distributed computing and other technologies to support parallel processing. Set up two independent buffer spaces: the first buffer space is used for data writing, and the second buffer space is used for data reading and encoding. Ensure that there is sufficient capacity and appropriate read and write speed between the two buffer spaces to support continuous data stream processing. The data source continuously writes data into the first buffer space in units of MCU rows. At the same time, the prepared MCU row data is read from the second buffer space for encoding processing. The two operations are executed by different processing units or threads respectively, and do not block each other. The encoding processing unit reads the MCU row data from the second buffer space. Apply appropriate video encoding algorithms to compress and encode the data, such as H.264, HEVC, etc. The encoded data can be immediately output or stored in another buffer for subsequent processing or transmission. When the data in the first buffer space is processed, the data can be moved to the second buffer space in preparation for encoding processing. Ensure that data transmission between the two buffer spaces is efficient and reliable to avoid data loss or delay. Use appropriate concurrency control mechanisms to ensure coordination and consistency between data writing and reading operations. Manage the system's CPU, memory and other hardware resources to ensure that both parallel operations have sufficient resource support.
[0057] For an example, see Figure 3 As shown in the principle diagram, when the double buffer preprocessing prepares buffer buff0, buff_rdy is triggered and mjpeg encoding compresses buff0; generally, mjpeg encoding compression is faster than sensor data input. When buffer buff1 is prepared, mjpeg has completed encoding 16 lines of buffer buff0; double buffering and mjpeg encoding are triggered in conjunction, and image encoding is not completed until the last 16-line buffer buff is encoded. The encoding delay is the time for reading and encoding 16 lines of data, thereby realizing parallel processing of data writing and data encoding compression.
[0058] Implementing the embodiments of the present application can bring the following beneficial effects:
[0059] Parallel processing improves efficiency: This technical solution significantly improves data processing efficiency by processing data writing and video encoding operations in parallel. While writing the selected MCU row to the target buffer space, the MCU row can be read from another buffer space and encoded. This parallel processing method reduces waiting time and makes the entire video encoding process more efficient.
[0060] Optimize resource utilization: This technical solution optimizes the utilization of system resources by converting the YUV422 format of video images to the YUV420 format and dividing the MCU rows reasonably. The YUV420 format has a lower chromaticity resolution than YUV422, but the human eye is relatively less sensitive to chromaticity information, so this conversion reduces the amount of data and processing requirements while maintaining video quality. In addition, by dividing the video image into multiple MCU rows, parallel processing can be performed more conveniently, further improving resource utilization.
[0061] Reduced latency: Due to the parallel processing of data writing and encoding operations, this technical solution reduces the latency in the video encoding process. Traditional serial processing requires waiting for the previous operation to complete before the next operation can be performed, while parallel processing can perform multiple operations at the same time, thereby reducing the overall processing time. This low latency feature makes this technical solution have obvious advantages in application scenarios such as real-time video processing and streaming media transmission.
[0062] Improve system stability: Through reasonable buffer space management and concurrency control mechanism, this technical solution ensures the coordination and consistency of data writing and encoding operations. This design avoids data conflicts or loss problems and improves the stability and reliability of the system. At the same time, the setting of buffer space also enables the system to cope with processing requirements under different loads, further enhancing the robustness of the system.
[0063] The following are device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0064] See also Figure 4 , which shows a schematic diagram of the structure of a video image encoding device provided by an exemplary embodiment of the present application, hereinafter referred to as device 4. The device 4 can be implemented as all or part of a terminal device through software, hardware, or a combination of both. The device 4 includes: an acquisition unit 401, a conversion unit 402, a division unit 403, a selection unit 404, a writing unit 405, and an encoding unit 406.
[0065] The acquisition unit 401 is used to acquire a video image to be encoded; the height of the video image is L, the width is W, L and W are integer multiples of 16, and the format of the video image is YUV422;
[0066] A conversion unit 402, configured to convert the format of the video image from YUV422 to YUV420;
[0067] A division unit 403 is used to divide the converted video image into a plurality of MCU rows; the height of each MCU row is 16, the width is W, and the size of each MCU is 16×16;
[0068] A selection unit 404, configured to select one MCU row from the plurality of MCU rows at a time;
[0069] A writing unit 405, configured to determine a target buffer space in the first buffer space and the second buffer space according to an alternating use strategy, and write the selected MCU row into the target buffer space;
[0070] The encoding unit 406 is used to read an MCU row from another buffer space and perform encoding compression processing on the read MCU row during the process of writing the selected MCU row into the target buffer space.
[0071] In one or more possible embodiments, obtaining the video image to be encoded includes:
[0072] Read a video image from a video file;
[0073] Obtaining the original height and original width of the video image;
[0074] If the original height is not an integer multiple of 16, calculate the size L that is closest to and greater than or equal to the original height and is an integer multiple of 16, and adjust the original height to L;
[0075] If the original width is not an integer multiple of 16, calculate the size W that is closest to and greater than or equal to the original width and is an integer multiple of 16, and adjust the original width to W.
[0076] In one or more possible embodiments, the sizes of the first buffer unit and the second buffer unit are 16×W×1.5 bytes.
[0077] In one or more possible embodiments, determining the target buffer space in the first buffer space and the second buffer space according to the alternating use strategy includes:
[0078] Get the serial number of the selected MCU row;
[0079] When the sequence number is an odd number, the first buffer space is used as the target buffer space;
[0080] When the sequence number is an even number, the second buffer space is used as the target buffer space.
[0081] In one or more possible embodiments, the MCUs in the MCU row are arranged in the order of: 4 Y components, 1 U component and 1 V component.
[0082] It should be noted that, when the device 4 provided in the above embodiment executes the video image encoding method, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above functions. In addition, the video image encoding device provided in the above embodiment and the video image encoding method embodiment belong to the same concept, and the embodiment and implementation process thereof are detailed in the method embodiment, which will not be repeated here.
[0083] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0084] The present application also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor as described above. Figure 2 The method steps of the embodiment shown in the figure can be found in the specific execution process. Figure 2 The specific description of the illustrated embodiment will not be repeated here.
[0085] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the video image encoding method described in the above embodiments.
[0086] See also Figure 5 , which is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application. Figure 5 As shown, the terminal device 500 may include: at least one processor 501 , at least one network interface 504 , a user interface 503 , a memory 505 , and at least one communication bus 502 .
[0087] The communication bus 502 is used to realize the connection and communication between these components.
[0088] The user interface 503 may include a display screen (Display) and a camera (Camera), and the optional user interface 503 may also include a standard wired interface and a wireless interface.
[0089] The network interface 504 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0090] Among them, the processor 501 may include one or more processing cores. The processor 501 uses various interfaces and lines to connect various parts within the entire terminal device 500, and executes various functions and processes data of the terminal device 500 by running or executing instructions, programs, code sets or instruction sets stored in the memory 505, and calling data stored in the memory 505. Optionally, the processor 501 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 501 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 501, and it can be implemented separately through a chip.
[0091] Among them, the memory 505 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 505 includes a non-transitory computer-readable storage medium. The memory 505 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 505 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 505 may also be optionally at least one storage device located away from the aforementioned processor 501. As Figure 5 As shown, the memory 505 as a computer storage medium may include an operating system, a network communication module, a user interface module and an application program.
[0092] exist Figure 5In the terminal device 500 shown in FIG. 1 , the user interface 503 is mainly used to provide an input interface for the user and obtain the data input by the user; and the processor 501 can be used to call the application stored in the memory 505 and specifically execute the following steps: Figure 2 The specific process can be referred to Figure 2 As shown, no further description is given here.
[0093] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0094] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A method for encoding a video image, characterized in that: include: Obtain a video image to be encoded; the height of the video image is L, the width is W, L and W are integer multiples of 16, and the format of the video image is YUV422; Convert the format of the video image from YUV422 to YUV420; Divide the converted video image into multiple MCU rows; the height of each MCU row is 16, the width is W, and the size of each MCU is 16×16; Selecting one MCU row from the plurality of MCU rows at a time; Determine a target buffer space in the first buffer space and the second buffer space according to the alternating use strategy, and write the selected MCU row into the target buffer space; During the process of writing the selected MCU row into the target buffer space, an MCU row is read from another buffer space, and encoding and compression processing is performed on the read MCU row.
2. The method according to claim 1, characterized in that The step of obtaining a video image to be encoded comprises: Read a video image from a video file; Obtaining the original height and original width of the video image; If the original height is not an integer multiple of 16, calculate the size L that is closest to and greater than or equal to the original height and is an integer multiple of 16, and adjust the original height to L; If the original width is not an integer multiple of 16, calculate the size W that is closest to and greater than or equal to the original width and is an integer multiple of 16, and adjust the original width to W.
3. The method according to claim 1 or 2, characterized in that: The sizes of the first buffer unit and the second buffer unit are 16×W×1.5 bytes.
4. The method according to claim 3, characterized in that The step of determining the target buffer space in the first buffer space and the second buffer space according to the alternating use strategy includes: Get the serial number of the selected MCU row; When the sequence number is an odd number, the first buffer space is used as the target buffer space; When the sequence number is an even number, the second buffer space is used as the target buffer space.
5. The method according to claim 1, 2 or 4, characterized in that: The MCUs in the MCU row are arranged in the order of: 4 8×8 Y components, 1 8×8 U component and 1 8×8 V component.
6. A video image encoding device, characterized in that: include: An acquisition unit, used for acquiring a video image to be encoded; the height of the video image is L, the width is W, L and W are integer multiples of 16, and the format of the video image is YUV422; A conversion unit, used for converting the format of the video image from YUV422 to YUV420; A division unit, used for dividing the converted video image into a plurality of MCU rows; the height of each MCU row is 16, the width is W, and the size of each MCU is 16×16; A selection unit, configured to select one MCU row from the plurality of MCU rows at a time; a writing unit, configured to determine a target buffer space in the first buffer space and the second buffer space according to an alternating use strategy, and to write the selected MCU row into the target buffer space; The encoding unit is used to read an MCU row from another buffer space and perform encoding and compression processing on the read MCU row during the process of writing the selected MCU row into the target buffer space.
7. A computer storage medium, characterized in that: The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 5.
8. A terminal device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 5.
Citation Information
Cited By
Method and device for carrying out H.264 coding on image based on wavefront parallel processing, storage medium and computer equipment
CN120639991A
Method, device, storage medium and computer device for H.264 encoding of an image based on wavefront parallel processing
CN120639991B
