Data processing method and device for video coding and decoding, equipment and storage medium
Through the parallel processing method of the assembly instruction set, the data statistical efficiency of band compensation in video encoding and decoding is improved, the problem of high computing resource usage in the existing technology is solved, and a more efficient video encoding and decoding process is realized.
Patent Information
- Application Number
- CN202310295889.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-23
- Publication Date
- 2024-09-24
AI Technical Summary
In existing video encoding and decoding technology, the statistical efficiency of strip compensation data is low, which causes the video encoding and decoding process to occupy more computing resources and affects efficiency.
Through a method based on the assembly instruction set, the reconstructed pixel group and pixel difference group are obtained, parallel processing is performed using vector operations, concurrent processing vectors are constructed, band compensation information is collected, and the traversal processing requirements of each pixel are reduced.
It improves the efficiency of video encoding and decoding, reduces the occupation of computing resources, and reduces the computational cost of obtaining strip compensation information during the encoding and decoding process.
Smart Images

Figure CN118694955A
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of video coding and decoding technology, and in particular, to a data processing method, device, equipment and storage medium for video coding and decoding. Background Art
[0002] In video coding technology, the Sample Adaptive Offset (SAO) technology can be used to reduce the deviation between the reconstructed image and the original image. Band Offset (BO) is one of the SAO technologies.
[0003] In the video encoding and decoding process, for a group of pixels, band compensation needs to count the number of pixels belonging to each pixel classification in each reconstructed pixel of the group of pixels, and the sum of the pixel value differences belonging to each pixel classification, so that the decoder can correct the reconstructed image. In the related art, the reconstructed pixel value and pixel value difference of each pixel are usually traversed, and the above two pieces of information are obtained according to the traversal results.
[0004] However, the above solution requires traversing and processing each pixel separately, which occupies more computing resources, thereby affecting the efficiency of video encoding and decoding. Summary of the invention
[0005] The embodiments of the present application provide a data processing method, device, equipment and storage medium for video encoding and decoding, which can reduce the computing resources required for obtaining information required for band compensation during the encoding and decoding process and improve the efficiency of video encoding and decoding. The technical solution is as follows:
[0006] According to one aspect of an embodiment of the present application, a data processing method for video encoding and decoding is provided, the method being implemented by a computer device based on an assembly instruction set, the method comprising:
[0007] Obtain a reconstructed pixel group and a pixel difference group corresponding to the reconstructed pixel group; the reconstructed pixel group includes pixel values of N reconstructed pixels in a video frame; the pixel difference group includes pixel value differences of the N reconstructed pixels; the pixel value difference is a difference between a pixel value of the reconstructed pixel and a pixel value of an original pixel corresponding to the reconstructed pixel; the pixel value is represented by 8 bits, and the pixel value difference is represented by 16 bits;
[0008] The following steps are executed in a loop until the data in the reconstructed pixel group and the pixel difference group are processed: the pixel values of M pixels are read from the reconstructed pixel group to obtain a first vector, and the pixel value differences corresponding to the M pixels are read from the pixel difference group to obtain a second vector and a third vector; M is the bit width / 8 of the assembly instruction set; the first vector is composed of the pixel values of the M pixels connected end to end; the second vector is composed of the pixel value differences corresponding to the first M / 2 pixels of the M pixels connected end to end; the third vector is composed of the pixel value differences corresponding to the last M / 2 pixels of the M pixels connected end to end; based on the first vector, the second vector and the third vector, the number of pixel values belonging to each pixel classification in the pixel values of the M pixels and the pixel value differences belonging to each pixel classification in the pixel value differences corresponding to the M pixels are obtained;
[0009] In response to the data in the reconstructed pixel group and the pixel difference group being processed, the band compensation statistical information of the reconstructed pixel group is obtained; the band compensation statistical information includes a first array and a second array; the first array is used to record the number of pixel values belonging to each pixel classification in the reconstructed pixel group; the second array is used to indicate the sum of the pixel value differences belonging to each pixel classification in the pixel difference group.
[0010] According to one aspect of an embodiment of the present application, a data processing device for video encoding and decoding is provided, the device is operated based on an assembly instruction set, and the device includes:
[0011] A first acquisition module is used to acquire a reconstructed pixel group and a pixel difference group corresponding to the reconstructed pixel group; the reconstructed pixel group includes pixel values of N reconstructed pixels in a video frame; the pixel difference group includes pixel value differences of the N reconstructed pixels; the pixel value difference is a difference between a pixel value of the reconstructed pixel and a pixel value of an original pixel corresponding to the reconstructed pixel; the pixel value is represented by 8 bits, and the pixel value difference is represented by 16 bits;
[0012] A loop module, for looping the following steps until the data in the reconstructed pixel group and the pixel difference group are processed: reading pixel values of M pixels from the reconstructed pixel group to obtain a first vector, and reading pixel value differences corresponding to the M pixels from the pixel difference group to obtain a second vector and a third vector; M is the bit width / 8 of the assembly instruction set; the first vector is composed of the pixel values of the M pixels connected end to end; the second vector is composed of the pixel value differences corresponding to the first M / 2 pixels of the M pixels connected end to end; the third vector is composed of the pixel value differences corresponding to the last M / 2 pixels of the M pixels connected end to end; based on the first vector, the second vector and the third vector, obtaining the number of pixel values belonging to each pixel classification in the pixel values of the M pixels, and the pixel value differences belonging to each pixel classification in the pixel value differences corresponding to the M pixels;
[0013] A second acquisition module is used to acquire the band compensation statistical information of the reconstructed pixel group in response to the data in the reconstructed pixel group and the pixel difference group being processed; the band compensation statistical information includes a first array and a second array; the first array is used to record the number of pixel values belonging to each pixel classification in the reconstructed pixel group; the second array is used to indicate the sum of the pixel value differences belonging to each pixel classification in the pixel difference group.
[0014] On the other hand, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the above-mentioned data processing method for video encoding and decoding.
[0015] On the other hand, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, and the computer program is loaded and executed by a processor to implement the above-mentioned data processing method for video encoding and decoding.
[0016] On the other hand, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the data processing method for video encoding and decoding provided in the above-mentioned various optional implementations.
[0017] The technical solution provided by the embodiments of the present application may have the following beneficial effects:
[0018] The acquisition of band compensation statistical information is realized based on an assembly instruction set. Specifically, when the pixel value of the reconstructed pixel is represented by 8 bits and the pixel value difference of the reconstructed pixel is represented by 16 bits, three vectors are respectively formed for the pixel value and the pixel value difference of each M reconstructed pixel. Based on the above three vectors, the number of pixel values belonging to each pixel classification in the pixel values of the M pixels and the pixel value difference belonging to each pixel classification in the pixel value difference corresponding to the M pixels are obtained. Finally, a first array recording the number of pixel values belonging to each pixel classification in the reconstructed pixel group and a second array recording the sum of the pixel value difference belonging to each pixel classification in the pixel value difference corresponding to the M pixels are obtained. In the above scheme, since the value of M is the bit width of the assembly instruction set / 8, the length of the three vectors used in the operation process is equal to the bit width of the assembly instruction set. The above three vectors can be operated and processed by the assembly instruction set, thereby realizing concurrent processing of M pixels without traversing each pixel, which can reduce the operation resources required for obtaining the information required for band compensation in the encoding and decoding process and improve the efficiency of video encoding and decoding. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 is a basic flow chart of a video encoding process exemplarily shown in this application;
[0020] Figure 2 is a simplified block diagram of a communication system provided by one embodiment of the present application;
[0021] Figure 3 is a schematic diagram of the placement of a video encoder and a video decoder in a streaming transmission environment exemplarily shown in the present application;
[0022] Figure 4 It is a process diagram of SAO BO data statistics;
[0023] Figure 5 is a flow chart of a data processing method for video encoding and decoding provided by an embodiment of the present application;
[0024] Figure 6 yes Figure 5 A schematic diagram of a bit structure involved in the illustrated embodiment;
[0025] Figure 7 is a flow chart of a data processing method for video encoding and decoding provided by an embodiment of the present application;
[0026] Figure 8 yes Figure 7 A schematic diagram of a vector operation for pixel classification involved in the illustrated embodiment;
[0027] Fig. 9 yes Figure 7A schematic diagram of obtaining a comparison result vector involved in the illustrated embodiment;
[0028] Fig.10 yes Figure 7 A schematic diagram of pixel value statistics involved in the illustrated embodiment;
[0029] Fig.11 yes Figure 7 A schematic diagram of obtaining pixel value difference involved in the illustrated embodiment;
[0030] Fig.12 yes Figure 7 A schematic diagram of pixel classification processing involved in the illustrated embodiment;
[0031] Fig.13 yes Figure 7 A schematic diagram of pixel classification processing involved in the illustrated embodiment;
[0032] Fig.14 It is a schematic diagram of similar pixel processing involved in this application;
[0033] Fig.15 It is a schematic diagram of mask calculation involved in this application;
[0034] Fig.16 This is a schematic diagram of remain_mask update involved in this application;
[0035] Fig.17 This is a schematic diagram of pixel classification query involved in this application;
[0036] Fig.18 It is a data schematic diagram of the unit test involved in this application;
[0037] Fig.19 is a block diagram of a data processing device for video encoding and decoding provided by an embodiment of the present application;
[0038] Fig. 20 It is a structural block diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0040] 1) High Efficiency Video Coding (HEVC), also known as H.265, is a video codec standard.
[0041] 2) SAO, the main idea is to reduce the deviation from the original image by correcting the reconstructed image. SAO is processed in Coding Tree Units (CTU). For all pixels in a CTU, they are divided into several groups according to certain standards. A correction value is calculated for each group, and this value is used to correct the reconstructed pixels to reduce the error with the original image. SAO in HEVC is divided into edge offset (EO) and band offset (BO). In experimental data, SAO can increase the compression rate by 5%. SAO has two characteristics related to video conferencing scenarios: 1. It is more effective for images of computer graphics and screen content; 2. In the case of low-latency single-frame inter-frame prediction coding, SAO can provide relatively high coding gain.
[0042] 3) BO, band offset, is a category of SAO. BO groups pixels only based on the pixels themselves. For pixel values of 0 to 255, they are divided into 32 bands, each covering 8 values. These 32 bands are 32 groups. However, in order to reduce the required bits, SAO is performed on only 4 of the groups. The rate-distortion optimization (RDO) method is used to select 4 consecutive groups from the 32 groups, and the position of the first group and the deviation values of the four groups are written into the bitstream and passed to the decoder.
[0043] 4) BO data statistics: count the number of pixels in each group in the entire CTU, classified into 32 groups. In the process of SAO rate-distortion optimization (or mode selection), it is necessary to rely on BO data statistics to estimate the distortion and bit rate consumption, so as to select the best solution from the three modes (BO / EO / disable SAO).
[0044] 5) Advanced Vector Extensions 2 (AVX2) assembly, bit width 256 bits. If the unit width is 8 bits, then 32 units can be processed in parallel, which is called a 32×8 vector (the unit is bits, and the units involved in m×n below are also bits). It is agreed that if the unit width is n, m units (m=256 / n) can be processed concurrently, which is called an m×n vector.
[0045] 6) Streaming Single Instruction Multiple Data Extensions 41 (SSE41), bit width 128 bits, if the unit bit width is 8 bits, then 16 units can be processed in parallel, which is called a 32×8 vector in this article. It is agreed that if the unit bit width is n, m units (m=128 / n) can be processed concurrently, which is called an m×n vector.
[0046] 7)POPCOUNT, assembly instruction, finds the number of 1s in a 32-bit integer. The specific instruction under Windows is __popcnt, and the specific instruction under Linux is __builtin_popcount.
[0047] 8) CTZ, assembly instruction, finds the position of the first 1 from low to high in a 32-bit integer. The specific instruction under window is _BitScanForward, and the specific instruction under Linux is __builtin_ctz.
[0048] Before introducing the embodiments of the present application, Figure 1 A brief introduction to video encoding technology. Figure 1 A basic flow chart of a video encoding process is exemplarily shown.
[0049] Video signal refers to an image sequence consisting of multiple frames. A frame is a representation of the spatial information of a video signal. Taking the YUV (brightness-chrominance-saturation) mode as an example, a frame includes a brightness sample matrix (Y) and two chrominance sample matrices (Cb and Cr). From the perspective of how the video signal is acquired, it can be divided into two methods: captured by a camera and generated by a computer. Due to different statistical characteristics, the corresponding compression encoding methods may also be different.
[0050] In some mainstream video coding technologies, such as H.265 / HEVC, H.266 / VVC (Versatile Video Coding) standards, AVS (Audio Video Coding Standard) (such as AVS3), a hybrid coding framework is used to perform the following series of operations and processing on the input original video signal:
[0051] 1. Block Partition Structure: The input image is divided into several non-overlapping processing units, each of which will perform similar compression operations. This processing unit is called CTU, or Large Coding Unit (LCU). Below CTU, we can continue to divide it more finely to obtain one or more basic coding units, called Coding Unit (CU). Each CU is the most basic element in the coding process. The following describes the various coding methods that may be used for each CU.
[0052] 2. Predictive Coding: It includes intra-frame prediction and inter-frame prediction. The original video signal is predicted by the selected reconstructed video signal to obtain the residual video signal. The encoder needs to choose the most suitable one among many possible predictive coding modes for the current CU and inform the decoder. Intra-frame prediction means that the predicted signal comes from the area that has been encoded and reconstructed in the same image. Inter-frame prediction means that the predicted signal comes from other images that have been encoded and are different from the current image (called reference images).
[0053] 3. Transform coding and quantization (Transform & Quantization): The residual video signal is transformed into the transform domain through discrete Fourier transform (DFT), discrete cosine transform (DCT) and other transform operations, which are called transform coefficients. The signal in the transform domain is further subjected to lossy quantization operations, which loses certain information, making the quantized signal conducive to compression expression. In some video coding standards, there may be more than one transform method to choose from, so the encoder also needs to select one of the transforms for the current CU and inform the decoder. The degree of quantization is usually determined by the quantization parameter. A larger value of the quantization parameter (Quantization Parameter, QP) means that coefficients with a larger value range will be quantized to the same output, which usually results in greater distortion and lower bit rate; on the contrary, a smaller value of QP means that coefficients with a smaller value range will be quantized to the same output, which usually results in less distortion and a higher bit rate.
[0054] 4. Entropy Coding or Statistical Coding: The quantized transform domain signal will be statistically compressed and encoded according to the frequency of occurrence of each value, and finally output as a binary (0 or 1) compressed bit stream. At the same time, the encoding generates other information, such as the selected mode, motion vector, etc., which also needs to be entropy encoded to reduce the bit rate. Statistical coding is a lossless coding method that can effectively reduce the bit rate required to express the same signal. Common statistical coding methods include variable length coding (VLC) or context-based binary arithmetic coding (CABAC).
[0055] 5. Loop Filtering: The encoded image can be reconstructed into a decoded image after undergoing inverse quantization, inverse transformation and prediction compensation (the reverse operation of 2 to 4 above). Compared with the original image, the reconstructed image has some information that is different from the original image due to the influence of quantization, resulting in distortion. Filtering the reconstructed image, such as deblocking, SAO or adaptive lattice filter (ALF), can effectively reduce the distortion caused by quantization. Since these filtered reconstructed images will be used as a reference for subsequent encoded images and used to predict future signals, the above filtering operation is also called loop filtering, and the filtering operation within the encoding loop.
[0056] like Figure 2 , which shows a simplified block diagram of a communication system provided by an embodiment of the present application. The communication system 200 includes a plurality of devices, which can communicate with each other through, for example, a network 250. For example, the communication system 200 includes a first device 210 and a second device 220 interconnected through the network 250. Figure 2 In an embodiment, the first device 210 and the second device 220 perform unidirectional data transmission. For example, the first device 210 may encode video data, such as a video picture stream captured by the first device 210, for transmission to the second device 220 via the network 250. The encoded video data is transmitted in the form of one or more encoded video code streams. The second device 220 may receive the encoded video data from the network 250, decode the encoded video data to recover the video data, and display the video picture based on the recovered video data. Unidirectional data transmission is more common in applications such as media services.
[0057] In another embodiment, the communication system 200 includes a third device 230 and a fourth device 240 that perform bidirectional transmission of encoded video data, which may occur, for example, during a video conference. For bidirectional data transmission, each of the third device 230 and the fourth device 240 may encode video data (e.g., a video picture stream collected by the device) for transmission to the other of the third device 230 and the fourth device 240 via the network 250. Each of the third device 230 and the fourth device 240 may also receive encoded video data transmitted by the other of the third device 230 and the fourth device 240, and may decode the encoded video data to recover the video data, and may display the video picture on an accessible display device based on the recovered video data.
[0058] exist Figure 2In the embodiment of, the first device 210, the second device 220, the third device 230 and the fourth device 240 may be computer devices such as servers, personal computers and smart phones, but the principles disclosed in the present application may not be limited thereto. The present application embodiment is applicable to personal computers (PCs), mobile phones, tablet computers, media players and / or dedicated video conferencing equipment. The network 250 represents any number of networks that transmit encoded video data between the first device 210, the second device 220, the third device 230 and the fourth device 240, including, for example, wired and / or wireless communication networks. The communication network 250 may exchange data in circuit switching and / or packet switching channels. The network may include a telecommunications network, a local area network, a wide area network and / or the Internet. For the purpose of the present application, unless explained below, the architecture and topology of the network 250 may be irrelevant to the operation disclosed in the present application.
[0059] As an example, Figure 3 The video encoder and the video decoder are shown in a streaming environment. The subject matter disclosed in the present application is equally applicable to other video-supported applications, including, for example, video conferencing, digital TV, storing compressed video on digital media including compact discs (CDs), digital versatile discs (DVDs), memory sticks, etc.
[0060] The streaming system may include an acquisition subsystem 313, which may include a video source 301 such as a digital camera, which creates an uncompressed video picture stream 302. In an embodiment, the video picture stream 302 includes samples taken by a digital camera. The video picture stream 302 is depicted as a thick line to emphasize the high data volume of the video picture stream compared to the encoded video data 304 (or the encoded video code stream), and the video picture stream 302 can be processed by an electronic device 320, which includes a video encoder 303 coupled to the video source 301. The video encoder 303 may include hardware, software, or a combination of hardware and software to implement or implement various aspects of the disclosed subject matter as described in more detail below. Compared to the video picture stream 302, the encoded video data 304 (or the encoded video code stream 304) is depicted as a thin line to emphasize the lower data volume of the encoded video data 304 (or the encoded video code stream 304), which can be stored on the streaming server 305 for future use. One or more streaming client subsystems, such as Figure 3, can access the streaming server 305 to retrieve the copies 307 and 309 of the encoded video data 304. The client subsystem 306 can include, for example, a video decoder 310 in an electronic device 330. The video decoder 310 decodes the incoming copy 307 of the encoded video data and produces an output video picture stream 311 that can be presented on a display 312 (e.g., a display screen) or another presentation device (not depicted). In some streaming systems, the encoded video data 304, video data 307, and video data 309 (e.g., video bitstreams) can be encoded according to certain video encoding / compression standards.
[0061] It should be noted that the electronic device 320 and the electronic device 330 may include other components (not shown). For example, the electronic device 320 may include a video decoder (not shown), and the electronic device 330 may also include a video encoder (not shown). The video decoder is used to decode the received encoded video data; the video encoder is used to encode the video data.
[0062] It should be noted that the technical solution provided in the embodiments of the present application can be applied to the H.266 / VVC standard, the H.265 / HEVC standard, AVS (such as AVS3) or the next-generation video coding and decoding standard, and the embodiments of the present application are not limited to this.
[0063] A schematic diagram of the data statistics process of SAO BO is as follows: Figure 4 As shown in the figure, n is the index of a pixel of a 64x64 CTU, rec represents the pixel cache of the reconstructed CTU, diff is the cache of the difference between the reconstructed pixel and the original pixel of the CTU, boCount records the number of pixels in 32 groups, and boStat accumulates the difference between the original pixel and the reconstructed pixel in each group. At initialization, n is set to 0, and boCount and boStat are cleared. During execution, traverse each pixel of the entire CTU, find the group boType to which the pixel belongs, and then accumulate the number in boCount and the pixel difference in boStat. At the end, return boCount and boStat to the upper layer.
[0064] Above Figure 4 The main drawback of the solution shown is low efficiency, which requires more than 5% increase in encoding time, and the user perception of online video conferencing is that the probability of video freezes will increase. The reason for the low efficiency is that for each 64x64 CTU, it is necessary to traverse each pixel to reconstruct the pixel, and then classify and accumulate the two eigenvalues of boCount and boStat. At the same time, if the pixel classification is relatively discrete, the process of accumulating eigenvalues will be even slower.
[0065] Please refer to Figure 5 , which shows a flow chart of a data processing method for video encoding and decoding provided by an embodiment of the present application. For the sake of convenience, only the subject of each step execution is a computer device for introduction and description. The method can be implemented by a computer device based on an assembly instruction set; the method may include the following steps:
[0066] Step 501: Obtain a reconstructed pixel group and a pixel difference group corresponding to the reconstructed pixel group; the reconstructed pixel group includes pixel values of N reconstructed pixels in the video frame; the pixel difference group includes pixel value differences of N reconstructed pixels; the pixel value difference is the difference between the pixel value of the reconstructed pixel and the pixel value of the original pixel corresponding to the reconstructed pixel; the pixel value is represented by 8 bits, and the pixel value difference is represented by 16 bits.
[0067] In the video encoding and decoding process supporting SAO BO, a reconstructed image corresponding to the original image and a pixel difference corresponding to each pixel in the reconstructed image and the original image can be generated, wherein the pixels in the reconstructed image are divided in units of reconstructed pixel groups, and similarly, the pixel differences are also divided in units of pixel difference groups according to the pixel division method.
[0068] That is, one reconstructed pixel group corresponds to one pixel difference value group, and the pixel values in the reconstructed pixel group correspond one to one with the pixel value differences in the pixel difference value group.
[0069] In the embodiment of the present application, the above pixel value is represented by 8 bits, and the above pixel value difference is represented by 16 bits.
[0070] Wherein, N is an integer greater than or equal to 2. For example, each of the above-mentioned reconstructed pixel groups may be a CTU, that is, a reconstructed pixel group includes 64×64 pixel values. Optionally, the number of pixels corresponding to a reconstructed pixel group may also be greater than the number of pixels included in a CTU or less than the number of pixels included in a CTU.
[0071] For example, take CTU as the unit for BO data statistics. Figure 6 , which shows a bit structure diagram involved in the embodiment of the present application. Figure 6 As shown, the reconstructed pixel group 61 includes 64×64 pixel values, each pixel value is represented by 8 bits; the pixel difference value group 62 corresponding to the reconstructed pixel group 61 includes 64×64 pixel value differences, each pixel value difference is represented by 16 bits. The pixel value 0 in the reconstructed pixel group 61 and the pixel value difference 0 in the pixel difference value group 62 respectively represent the pixel value and the pixel value difference of pixel 0 in the image; the pixel value 1 in the reconstructed pixel group 61 and the pixel value difference 1 in the pixel difference value group 62 respectively represent the pixel value and the pixel value difference of pixel 1 in the image, and so on.
[0072] Step 502: Execute the following steps in a loop until the data in the reconstructed pixel group and the pixel difference group are processed completely:
[0073] Step 502a: Read the pixel values of M pixels from the reconstructed pixel group to obtain a first vector, and read the pixel value differences corresponding to the M pixels from the pixel difference group to obtain a second vector and a third vector; M is the bit width of the assembly instruction set / 8; the first vector is composed of the pixel values of the M pixels connected end to end; the second vector is composed of the pixel value differences corresponding to the first M / 2 pixels of the M pixels connected end to end; the third vector is composed of the pixel value differences corresponding to the last M / 2 pixels of the M pixels connected end to end.
[0074] For example, when the bit width of the assembly instruction set is 256, the value of M is 256 / 8=32; when the bit width of the assembly instruction set is 128, the value of M is 128 / 8=16.
[0075] In a possible implementation, the first vector includes M vector elements, each vector element includes 8 bits, corresponding to a pixel value of a pixel, and the M pixel elements are connected end to end.
[0076] Correspondingly, the second vector includes M / 2 vector elements, each of which includes 16 bits, corresponding to a pixel value difference of a pixel, and the M / 2 vector elements are connected end to end.
[0077] Similar to the second vector, the third vector includes M / 2 vector elements, each of which includes 16 bits corresponding to a pixel value difference of a pixel, and the M / 2 vector elements are connected end to end.
[0078] The order of pixels corresponding to the first M / 2 vector elements of the M vector elements in the above-mentioned first vector is the same as the order of pixels corresponding to the M / 2 vector elements in the first vector; the order of pixels corresponding to the last M / 2 vector elements of the M vector elements in the second vector is the same as the order of pixels corresponding to the M / 2 vector elements in the third vector.
[0079] Or Figure 6 For example, assuming that the bit width of the assembly instruction set is 256, the value of M is 32, the first vector 63 is a vector formed by connecting the first 32 pixel values in the reconstructed pixel group end to end, the second vector 64 is a vector formed by connecting the first 16 pixel value differences in the pixel difference group end to end, and the third vector 65 is a vector formed by connecting the 17th to 32nd pixel value differences in the pixel difference group end to end. Each pixel value in the first vector occupies 8 bits, and the total length is 256 bits; each pixel value in the second vector and the third vector occupies 16 bits, and the total length is 256 bits.
[0080] Step 502b: Based on the first vector, the second vector and the third vector, obtain the number of pixel values belonging to each pixel category among the pixel values of the M pixels and the pixel value difference belonging to each pixel category among the pixel value differences corresponding to the M pixels.
[0081] In an embodiment of the present application, the lengths of the first vector, the second vector and the third vector are all the bit widths of the assembly instruction set, that is, the first vector, the second vector and the third vector can be uniformly processed by assembly instructions in the assembly instruction set, so that the statistical task of BO statistical data of M pixels can be processed concurrently through assembly instructions.
[0082] Step 503: In response to the data in the reconstructed pixel group and the pixel difference group being processed, obtain the band compensation statistical information of the reconstructed pixel group; the band compensation statistical information includes a first array and a second array; the first array is used to record the number of pixel values belonging to each pixel category in the reconstructed pixel group; the second array is used to indicate the sum of the pixel value differences belonging to each pixel category in the pixel difference group.
[0083] In an embodiment of the present application, the computer device executes step 502 in a loop, concurrently processing the pixel values and pixel value differences corresponding to M pixels in the reconstructed pixel group and the pixel difference group each time, until all data in the reconstructed pixel group and the pixel difference group are processed, after which the BO statistical data corresponding to the reconstructed pixel group can be obtained.
[0084] Since the above scheme takes M pixels as a batch, a vector with the same length as the bit width of the assembly instruction set is constructed by the pixel values and pixel value differences of the M pixels, so that the pixel values and pixel value differences of the M pixels can be processed concurrently through the instructions in the assembly instruction set.
[0085] In summary, the scheme shown in the embodiment of the present application realizes the acquisition of band compensation statistical information based on the assembly instruction set. Specifically, when the pixel value of the reconstructed pixel is represented by 8 bits and the pixel value difference of the reconstructed pixel is represented by 16 bits, for the pixel value and pixel value difference of each M reconstructed pixel, three vectors are respectively formed, and the number of pixel values belonging to each pixel classification in the pixel values of the M pixels and the pixel value difference belonging to each pixel classification in the pixel value difference corresponding to the M pixels are obtained based on the above three vectors. Finally, a first array recording the number of pixel values belonging to each pixel classification in the reconstructed pixel group and a second array recording the sum of the pixel value difference belonging to each pixel classification in the pixel value difference corresponding to the M pixels are obtained; in the above scheme, since the value of M is the bit width of the assembly instruction set / 8, the length of the three vectors used in the operation process is equal to the bit width of the assembly instruction set. The above three vectors can be operated and processed by the assembly instruction set, thereby realizing concurrent processing of M pixels, without traversing each pixel, which can reduce the computing resources required for obtaining the information required for band compensation in the encoding and decoding process, and improve the efficiency of video encoding and decoding.
[0086] based on Figure 5 For the examples shown, please refer to Figure 7 , which shows a flow chart of a data processing method for video encoding and decoding provided by an embodiment of the present application. For the sake of convenience, only the subject of each step execution is a computer device for introduction and description. The method can be implemented by a computer device based on an assembly instruction set; Figure 7 As shown above Figure 5 Step 502b in the illustrated embodiment may be implemented as step 502b1 and step 502b2:
[0087] Step 502b1: Obtain a classification result indication vector by left-shifting the vector elements corresponding to each pixel value in the first vector; the vector element at the position corresponding to each pixel value in the classification result indication vector is used to indicate the pixel classification to which the corresponding pixel value belongs.
[0088] The above-mentioned left shifting of the vector elements refers to shifting the values of the bits in the vector elements in order from low to high.
[0089] In an embodiment of the present application, 256 pixel values from 0 to 255 can be grouped into groups of 8 pixel values to obtain 32 pixel categories, and the 32 pixel categories are represented by 32 numerical values from 0 to 31 respectively. Therefore, for each 8-bit pixel value, the pixel value is shifted left by 3 bits (that is, the numerical value of each bit in the 8 bits is shifted left by 3 bits, wherein the numerical value of the first bit after the left shift is the numerical value of the fourth bit before the left shift, the numerical value of the second bit after the left shift is the numerical value of the fifth bit before the left shift, and so on, and the numerical values of the last three bits after the left shift are set to 0), and the obtained numerical value can represent the pixel category of the pixel value.
[0090] In a possible implementation, the above step 503b1 may include:
[0091] 1) Using 16 bits as the shift unit, the vector elements corresponding to each pixel value in the first vector are shifted left by 3 bits to obtain a shift result vector;
[0092] Among them, the step of shifting the vector elements corresponding to each pixel value in the first vector left by 3 bits with 16 bits as the displacement unit to obtain the shift result vector can be executed by the computer device through the first assembly instruction, and the first assembly instruction is used to shift each bit in a vector left with 16 bits as a unit; for example, taking the above-mentioned assembly instruction set as the AVX2 assembly instruction set as an example, the above-mentioned first assembly instruction can be _mm256_srli_epi16.
[0093] 2) performing an AND operation on the shift result vector and the first template vector to obtain a classification result indication vector;
[0094] The above process of performing an AND operation on the shift result vector and the first template vector to obtain a classification result indication vector can be executed by a computer device through a second assembly instruction, where the second assembly instruction is used to perform a bitwise AND operation on the two vectors; for example, taking the above assembly instruction set as the AVX2 assembly instruction set as an example, the above second assembly instruction can be _mm256_and_si256.
[0095] The first template vector is composed of M 8-bit vector elements; the value of each 8-bit vector element in the first template vector is 31.
[0096] Among them, since there may be no instructions for shifting in units of 8 bits in the assembly instruction set, in the scheme shown in the embodiment of the present application, every 16 bits (that is, every two pixel values) in the first vector can be shifted left by 3 bits by supporting instructions for shifting in units of 16 bits, and then combined with a pre-set template vector, the invalid data of the lower 3 bits of the upper 8 bits of every two pixel values are set to 0, thereby realizing the operation of shifting each pixel value left by 3 bits through the assembly instruction set.
[0097] For example, please refer to Figure 8 , which shows a vector operation schematic diagram of a pixel classification involved in an embodiment of the present application. Figure 8 As shown, taking the vector element 81 and the vector element 82 in the first vector as an example to form a 16-bit displacement unit, the 16 bits are arranged from the low bit to the high bit of the first vector; when shifting left, the value of the first 3 bits of the vector element 81 is discarded, the last 5 bits of the vector element 81 and the values of the 8 bits in the vector element 82 are shifted left by 3 bits in sequence, and then the value of the last 3 bits of the vector element 82 is set to 0; the above operation is performed on each displacement unit in the first vector to obtain a shift result vector; in the shift result vector, the values of the last 3 bits of the 8 bits corresponding to the vector element 82 (that is, the upper 3 bits of the 16 bits) are set to 0 during the left shift process, so the above 8 bits corresponding to the vector element 82 can indicate the pixel classification of the pixel value corresponding to the vector element 82; and the 8 bits corresponding to the vector element 81 (that is, Figure 8 The value of the last 3 bits of the 8 bits in the vector element 83 (that is, the upper 3 bits of the lower 8 bits of 16 bits) is the value of the first 3 bits of the vector element 82, which is not set to 0. Therefore, the 8 bits corresponding to the vector element 81 cannot accurately indicate the pixel classification of the pixel value corresponding to the vector element 81, and further processing is required. Afterwards, when the displacement result vector and the first template vector are ANDed to obtain the classification result indication vector, the 8 bits corresponding to the vector element 81 in the displacement result vector are ANDed with the corresponding 8 bits in the first template vector (that is, Figure 88 bits of the vector element 84 in the shift result vector are ANDed to obtain 8 bits of the corresponding vector element 81 in the classification result indication vector, wherein the value of the vector element 84 is 31. When expressed in binary, the values of the 8 bits are arranged from low to high as 11111000. In this way, after the vector element 83 is ANDed, the last 3 bits of the vector element 83 can be set to 0. At this time, the 8 bits of the corresponding vector element 81 in the classification result indication vector can indicate the pixel classification of the pixel value corresponding to the vector element 81; and for the 8 bits of the corresponding vector element 82 in the displacement result vector, since the last 3 bits have been set to 0, the ANDed operation with 11111000 will not affect the 8 bits; after the vector element consisting of each 8 bits in the shift result vector is ANDed with the corresponding 8 bits in the first template vector, the classification result indication vector can be obtained, and each 8 bits in the classification result indication vector indicates the pixel classification of a pixel value.
[0098] Step 502b2: Based on the classification result indication vector, the second vector and the third vector, for each pixel category in at least one pixel category included in the pixel values of the M pixels, obtain the number of pixel values belonging to each pixel category in the pixel values of the M pixels, and the pixel value difference belonging to each pixel category in the pixel value difference corresponding to the M pixels.
[0099] After obtaining the classification result indication vector indicating the pixel category to which the pixel value corresponding to each pixel in the M pixels belongs, the second vector and the third vector representing the pixel value difference corresponding to each pixel in the M pixels can be combined to determine the number of pixel values belonging to each pixel category in the pixel values of the M pixels, as well as the pixel value difference belonging to each pixel category in the pixel value difference corresponding to the M pixels.
[0100] Among them, since the classification result indication vector is obtained by shifting the first vector, the length of the classification result indication vector is also equal to the bandwidth of the assembly instruction set. Therefore, the operation process based on the classification result indication vector, the second vector and the third vector can also be implemented by the assembly instruction set, thereby realizing concurrent processing of M pixels.
[0101] In a possible implementation, the above step 503b2 may include:
[0102] S1, obtaining an 8-bit pixel value of a target pixel; the target pixel is a pixel among M pixels for which statistical processing has not yet been completed.
[0103] The target pixel classification is a pixel classification for which SAO BO statistical processing has not yet been completed among one or more pixel classifications corresponding to the M pixels.
[0104] That is to say, in the process of performing SAO BO data statistics on pixels in the reconstructed pixel group with M pixels as a batch, any pixel in the M pixels processed in the current batch that has not completed SAO BO data can be used as the above target pixel.
[0105] S2, shift the 8-bit pixel value of the target pixel left by 3 bits to obtain a classification representation vector of the target pixel classification corresponding to the target.
[0106] In an embodiment of the present application, the computer device can shift the 8-bit pixel value of the target pixel left by 3 bits by a method other than an assembly instruction set. For example, the computer device can implement the operation of shifting the 8-bit pixel value of the target pixel left by 3 bits by C / C++ instructions.
[0107] S3, obtaining an expanded vector of the target pixel classification, where the expanded vector is formed by connecting the classification representation vectors of M target pixel classifications end to end.
[0108] In an embodiment of the present application, the computer device may generate an extended bit vector of the target pixel classification according to the classification representation vector of the target pixel classification.
[0109] For example, the computer device can obtain an extended vector through a third assembly instruction, where the third assembly instruction is used to copy an 8-bit value to a vector whose length is the bandwidth of the assembly instruction set; for example, taking the assembly instruction set as the AVX2 instruction set with a bandwidth of 256 as an example, the computer device copies the classification representation vector of the target pixel classification to a 32×8 vector (containing 32 vector elements, each vector element containing 8 bits) through the assembly instruction _mm256_set1_epi8 (i.e., the third assembly instruction mentioned above) in the AVX2 instruction set to obtain the extended vector of the target pixel classification.
[0110] Alternatively, the computer device may also copy the above-mentioned expanded bit vector according to the 8 bits corresponding to the target pixel in the classification result indication vector, which are used to indicate the pixel classification corresponding to the target pixel.
[0111] For example, the computer device can copy the 8 bits at the specified position in the classification result indication vector to obtain the above-mentioned extended bit vector through the third assembly instruction for vector bit conversion and vector copying in the assembly instruction set; for example, taking the assembly instruction set as the AVX2 instruction set with a bandwidth of 256 as an example, when the above-mentioned target pixel is the first pixel among M pixels, the 8 bits corresponding to the target pixel in the classification result indication vector can be the 8th bit of the classification result indication vector; at this time, the computer device can first convert the classification result indication vector from 256 bits to 128 bits through the assembly instruction mm256 castsi256 si128 to obtain the lower 128 bits of the classification result indication vector; then, through the assembly instruction _mm256_broadcastb_epi8, the lower 8 bits of the above-mentioned lower 128 bits of the vector are copied to a 32×8 vector to obtain the extended bit vector of the target pixel classification. The above-mentioned assembly instruction _mm256_castsi256_si128 and the assembly instruction _mm256_broadcastb_epi8 are the third assembly instructions.
[0112] S4, taking 8 bits as the comparison unit, compares the expanded bit vector of the target pixel classification with the classification result indication vector, sets the bits of the comparison units with differences in the expanded bit vector of the target pixel classification to the first value, and sets the bits of the same comparison units in the expanded bit vector of the target pixel classification to the second value, to obtain the comparison result vector of the target pixel classification; the first value is one of 0 and 1, and the second value is the other of 0 and 1 except the first value.
[0113] In one possible implementation, using 8 bits as a comparison unit, the computer device may compare the expanded bit vector of the target pixel classification with the classification result indication vector, set the bits of the comparison units that are different in the expanded bit vector of the target pixel classification to 0, and set the bits of the same comparison units in the expanded bit vector of the target pixel classification to 1, to obtain the comparison result vector of the target pixel classification.
[0114] In the above-mentioned expanded vector, each 8-bit vector element is the value of the target pixel classification, and the classification result indication vector can also be regarded as a 32×8 vector, which contains 32 first-place connected vector elements. The 8 bits in each vector element correspond to the pixel classification to which one pixel among M pixels belongs. Assuming that the first vector element in the expanded vector of the target pixel classification and the second vector element in the classification result indication vector have the same position in their respective vectors (for example, they are both the first vector element or the second vector element in their respective vectors, etc.), the first vector element and the second vector element are compared. If the first vector element and the second vector element contain the same 8 bits, it means that the pixel corresponding to the second vector element belongs to the above-mentioned target pixel classification. At this time, the second vector element in the classification result indication vector is set to 1; conversely, if the first vector element and the second vector element contain different 8 bits, it means that the pixel corresponding to the second vector element does not belong to the above-mentioned target pixel classification. At this time, the second vector element in the classification result indication vector is set to 0.
[0115] In another possible implementation, using 8 bits as the comparison unit, the computer device may compare the expanded bit vector of the target pixel classification with the classification result indication vector, set the bits of the comparison units that are different in the expanded bit vector of the target pixel classification to 1, and set the bits of the same comparison units in the expanded bit vector of the target pixel classification to 0, to obtain the comparison result vector of the target pixel classification.
[0116] In the above scheme, the computer device compares the first vector element and the second vector element. If the first vector element and the second vector element contain the same 8 bits, the second vector element in the classification result indication vector is set to 0; otherwise, if the first vector element and the second vector element contain different 8 bits, the second vector element in the classification result indication vector is set to 1.
[0117] For example, please refer to Fig. 9 , which shows a schematic diagram of obtaining a comparison result vector involved in an embodiment of the present application. Fig. 9 As shown, assuming that the target pixel is the first pixel among M pixels, the pixel value of the target pixel in the reconstructed pixel group is 67, and its 8-bit binary representation result 91 is arranged from low to high as 11000010. The binary representation result 91 is shifted left by 3 bits, and the left-shifted binary representation result 92 is arranged from low to high as 00010000. The binary representation result 92 corresponds to a decimal value of 8, that is, the pixel category to which the target pixel belongs is represented by the value "8". At this time, the computer device can determine that the target pixel category is "8".
[0118] Taking the AVX2 instruction set with a bandwidth of 256 as an example, the computer device can copy the lower 8 bits of the classification result indication vector 93 to a 32×8 vector through the assembly instructions _mm256_castsi256_si128 and _mm256_broadcastb_epi8 to obtain the extended bit vector 94; or, copy the binary representation result 92 to a 32×8 vector through the assembly instruction _mm256_set1_epi8 to obtain the extended bit vector 94; wherein the value of each 8-bit vector element in the above-mentioned extended bit vector 94 is 00010000.
[0119] Afterwards, the computer device compares every 8 bits corresponding to the position in the expanded vector 94 and the classification result indication vector 93, sets the vector elements with values of 00010000 in the expanded vector 94 to 111111111, and sets the vector elements with values not 00010000 in the expanded vector 94 to 00000000, to obtain a comparison result vector 95.
[0120] S5, based on the comparison result vector of the target pixel classification, obtaining the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels.
[0121] In an embodiment of the present application, since in the comparison result vector, the pixel elements corresponding to the target pixel classification are all set to the second value, and the other pixel elements are all set to the first value, the computer device only needs to count the number of pixel elements set to the second value in the comparison result vector, that is, the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels can be obtained.
[0122] In a possible implementation, the process of obtaining the number of pixel values of M pixels belonging to the target pixel classification based on the comparison result vector of the target pixel classification may include:
[0123] Obtain the most significant bit of each comparison unit in the comparison result vector of the target pixel classification, and concatenate them to obtain the comparison mask vector of the target pixel classification;
[0124] The number of bits whose values in the mask vector are the second value is counted and compared to obtain the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels.
[0125] Among them, after obtaining the comparison result vector, it is only necessary to extract the value of the most significant bit of every 8 bits in the comparison result, that is, to form a comparison mask vector composed of M elements, wherein each element indicates whether the pixel value at the corresponding position belongs to the above-mentioned target pixel classification. By counting the number of second values in the comparison mask vector, the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels can be obtained.
[0126] For example, when the second value is 1, the computer device only needs to count the number of 1s in the comparison mask vector, that is, the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels can be obtained.
[0127] For example, when the bit width of the above assembly instruction set is 256, the value of M is 32, and when the second value is 1, the computer device can use the assembly instruction POPCOUNT to count the number of 1s in the comparison mask vector.
[0128] Optionally, the computer device may also count the number of 1s in the comparison mask vector by other means other than assembly instructions, for example, by counting the number of 1s in the comparison mask vector by C / C++ instructions.
[0129] Alternatively, when the second value is 0, the computer device only needs to count the number of 0s in the comparison mask vector, that is, the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels can be obtained.
[0130] Among them, the process of obtaining the most significant bit of each comparison unit in the comparison result vector of the target pixel classification and splicing to obtain the comparison mask vector of the target pixel classification can be implemented by the fourth assembly instruction, wherein the fourth assembly instruction is used to extract the most significant bit of each vector element in the M×8 vector; for example, taking the assembly instruction set with a bandwidth of 256 as an example, the value of M is 32, and the fourth assembly instruction can be the assembly instruction _mm256_movemask_epi8. The above scheme realizes the statistics of the number of pixel values based on the assembly instruction by extracting the most significant bit of each comparison unit, splicing to obtain the comparison mask vector of the target pixel classification, and counting the number of second values in the comparison mask vector.
[0131] Combination Fig. 9 , please refer to Fig.10 , which shows a schematic diagram of the number of pixel values involved in the embodiment of the present application. Fig.10 As shown, the computer device uses the assembly instruction _mm256_movemask_epi8 to Fig. 9 The obtained comparison result vector 95 is processed, and the most significant bit of every 8 bits in the comparison result vector 95 is extracted to form a 32-bit comparison mask vector 96, where the value of the first bit in the comparison mask vector 96 is 1, indicating that the first pixel among the M pixels belongs to the target pixel classification "8", and the value of the second bit in the comparison mask vector 96 is 0, indicating that the second pixel among the M pixels does not belong to the target pixel classification "8", and so on.
[0132] The computer device processes the above-mentioned comparison mask vector 96 through the assembly instruction POPCOUNT to obtain the number 97 of pixel values belonging to the target pixel classification "8" among the pixel values of the M pixels processed in the current batch.
[0133] S6, based on the comparison result vector of the target pixel classification, the second vector and the third vector, obtaining the pixel value difference corresponding to the target pixel classification from the pixel value differences corresponding to the M pixels.
[0134] In an embodiment of the present application, for each pixel classification, an extended vector with the same length as the bit width of the assembly instruction set can be formed by M 8-bit representation vectors representing the pixel classification, and then the assembly instruction is used to compare the above-mentioned extended vector and the comparison unit composed of each 8 bits in the classification result indication vector. Optionally, in the above-mentioned extended vector, the 8 bits on different comparison units are set to 0, and the 8 bits on the same comparison unit are set to 1, so that a vector with a length of the bit width of the assembly instruction set can be obtained, and each 8-bit unit set to 1 in the vector indicates that the pixel classification to which the pixel value at the corresponding position belongs is the above-mentioned pixel classification. On this basis, the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels can be obtained; further, in combination with the above-mentioned comparison result vector, the second vector and the third vector, the pixel value difference corresponding to the M pixels belonging to the first pixel classification can be calculated.
[0135] Since the vector lengths involved in the calculation process of the above comparison vectors are all the bit widths of the assembly instruction set, the above process can be implemented by the assembly instruction set, thereby achieving concurrent processing of M pixels.
[0136] That is to say, based on the above scheme, the embodiment of the present application assembles an instruction set and takes pixel classification as a unit to count the number of pixel values and pixel value differences of M pixels belonging to the same specified pixel classification (i.e., the first pixel classification mentioned above) at a time. There is no need to traverse the pixel values and pixel value differences of the M pixels one by one, which can improve the efficiency of SAO BO statistical data.
[0137] In a possible implementation, the computer device may also accumulate the number of pixel values of the M pixels that belong to the target pixel category into the first array.
[0138] Among them, in the processing process of every M pixels, the number of pixel values of the M pixels belonging to the target pixel category is obtained, that is, the number of pixel values of the M pixels belonging to the target pixel category can be added to the value corresponding to the target pixel category in the first array.
[0139] In a possible implementation, the process of obtaining the pixel value difference corresponding to the target pixel classification among the pixel value differences corresponding to the M pixels based on the comparison result vector, the second vector and the third vector of the target pixel classification may include:
[0140] The comparison result vector of the target pixel classification is ANDed with the second vector and the third vector respectively to obtain the pixel value difference corresponding to the target pixel classification among the pixel value differences corresponding to the M pixels.
[0141] In the embodiment of the present application, taking the second numerical value of 1 as an example, since in the comparison result vector, the values of pixels belonging to the target pixel classification are set to 1, and the values of pixels not belonging to the target pixel classification are set to 0, therefore, as long as the comparison result vector is ANDed with the second vector and the third vector respectively, the pixel value differences of each pixel corresponding to the target pixel classification can be extracted from the second vector and the third vector separately, and then the pixel value differences of each pixel extracted separately are accumulated, so that the sum of the pixel value differences corresponding to the target pixel classification in the pixel value differences corresponding to the M pixels can be obtained.
[0142] The scheme shown in the embodiment of the present application can achieve the setting of the pixel value difference of the non-target pixel classification to 0 by comparing the AND operation between the result vector, the second vector and the third vector, thereby separately extracting the pixel value difference belonging to the target pixel classification, thereby realizing the assembly instruction execution scheme for extracting the pixel value difference of the target pixel classification.
[0143] In a possible implementation, the comparison result vector of the target pixel classification is respectively ANDed with the second vector and the third vector to obtain the pixel value difference corresponding to the M pixels. The process of the pixel value difference corresponding to the target pixel classification may include:
[0144] S1, expanding the vector elements of the first half of the comparison result vector of the target pixel classification from 8 bits to 16 bits to obtain a first comparison result expansion vector.
[0145] The computer device can use the fifth assembly instruction for extracting the first half of an M×8 vector, the sixth assembly instruction for extracting the first half of an M×8 vector, the first half of the comparison result vector of the target pixel classification, and the second half of the comparison result vector of the target pixel classification.
[0146] For example, taking the assembly instruction set having a bandwidth of 256 as an example, the fifth assembly instruction may be an assembly instruction _mm256_castsi256_si128, and the sixth assembly instruction may be an assembly instruction _mm256_extracti128_si256.
[0147] Among them, the first half of the comparison result vector contains M / 2 vector elements, each vector element contains 8 bits, and after the vector elements of the first half of the comparison result vector of the target pixel classification are expanded from 8 bits to 16 bits, the first comparison result vector obtained also contains M / 2 vector elements, but each vector element contains 16 bits.
[0148] For example, after the computer device expands the vector elements of the first half of the comparison result vector of the target pixel classification from 8 bits to 16 bits to obtain the first comparison result extended vector, assuming that a vector element in the first half of the comparison result vector is 111111111, then in the first comparison result extended vector, the corresponding vector element is 11111111111111111; accordingly, assuming that a vector element in the first half of the comparison result vector is 000000000, then in the first comparison result extended vector, the corresponding vector element is 0000000000000000.
[0149] The computer device can expand each 8-bit in the first half through the seventh assembly instruction, wherein the seventh assembly instruction is used to expand each 8-bit vector element in the (M / 2)×8 vector to a 16-bit vector element to obtain a (M / 2)×16 vector; wherein each 16-bit vector element in each of the above (M / 2)×16 vectors is obtained by copying and concatenating the corresponding 8-bit vector elements in the (M / 2)×8 vector. For example, taking the assembly instruction set as an instruction set with a bandwidth of 256 as an example, the seventh assembly instruction can be the assembly instruction _mm256_cvtepi8_epi16.
[0150] S2, performing an AND operation on the first comparison result extended vector and the second vector to obtain a first difference vector; the first difference vector includes the pixel value difference corresponding to the target pixel classification among the pixel value differences corresponding to the first M / 2 pixels among the M pixels.
[0151] The computer device may perform an AND operation on the extended vector of the first half of the comparison result vector and the second vector through a second assembly instruction.
[0152] The above-mentioned pixel value difference corresponding to the target pixel classification refers to the pixel value difference corresponding to the pixels whose pixel values belong to the target pixel classification.
[0153] Among them, when the above-mentioned second numerical value is 1, the computer device can directly perform an AND operation on the first comparison result extension vector and the second vector; when the above-mentioned second numerical value is 0, the computer device can bit-invert the first comparison result extension vector, and perform an AND operation on the bit-inverted first comparison result extension vector and the second vector.
[0154] The first comparison result extended vector obtained by the bit expansion has the same vector elements as those included in the second vector, and the number of bits included in each vector element is also the same, and the first half of the comparison result vector corresponds to the first M / 2 pixels of the M pixels, and the arrangement order of pixels corresponding to each pixel element in the first vector is consistent with the arrangement order of pixels corresponding to each pixel element in the second vector and the second vector, and the arrangement order of pixels corresponding to each pixel element in the first comparison result vector is also consistent with the arrangement order of pixels corresponding to each pixel element in the second vector; at this time, if among the pixel elements in the first comparison result extended vector, the pixel elements corresponding to the target pixel classification The bit values of all the pixels in the first comparison result extended vector are 1, and the bit values of all the pixel elements are 0, then after performing an AND operation on the first comparison result extended vector and the second vector, the pixel value difference corresponding to the target pixel classification in the second vector will be retained, and the other pixel value differences will be removed (that is, set to 0), and the first difference vector obtained is the pixel value difference corresponding to the target pixel classification among the pixel value differences corresponding to the first M / 2 pixels; conversely, if the bit values of the pixel elements corresponding to the target pixel classification in each pixel element in the first comparison result extended vector are all 0, and the bit values of the pixel elements are all 1, then the first comparison result extended vector is bitwise inverted and then performed an AND operation with the second vector to obtain the above-mentioned first difference vector.
[0155] S3, expanding the vector elements of the second half of the comparison result vector of the target pixel classification from 8 bits to 16 bits to obtain a second comparison result expansion vector.
[0156] The method for obtaining the second comparison result extension vector is similar to the method for obtaining the first comparison result extension vector, and will not be described in detail here.
[0157] S4, performing an AND operation on the second comparison result extended vector and the third vector to obtain a second difference vector; the second difference vector includes the pixel value difference corresponding to the last M / 2 pixels among the pixel values of the M pixels, and the pixel value difference corresponding to the target pixel classification.
[0158] Among them, when the above-mentioned second numerical value is 1, the computer device can directly perform an AND operation on the second comparison result extension vector and the third vector; when the above-mentioned second numerical value is 0, the computer device can bit-invert the second comparison result extension vector, and perform an AND operation on the bit-inverted second comparison result extension vector and the third vector.
[0159] The process of obtaining the second difference vector is similar to the process of obtaining the first difference vector, which will not be described in detail here.
[0160] In the embodiment of the present application, since each vector in the comparison result vector corresponds to 8 bits, and each vector in the second vector and the third vector corresponds to 16 bits, and the comparison result vector corresponds to M pixels, and the second vector and the third vector correspond to M / 2 pixels respectively, therefore, if the comparison result vector and the second vector or the third vector are directly ANDed, the pixel value difference of the corresponding pixels cannot be obtained. In this regard, in the scheme shown in the embodiment of the present application, the computer device first divides the comparison result vector into two parts, a first half corresponding to the first M / 2 pixels, and a second half corresponding to the last M / 2 pixels, wherein the first half corresponds to the second vector, and the second half corresponds to the second vector. Then, by assembling the instructions in the instruction set, each 8-bit vector element in the first half and the second half is expanded, that is, each 8 bits is converted into 16 bits, so that the two vectors obtained can be aligned with the second vector and the third vector, that is, every 16 bits in the expanded vector corresponds to a vector, and each expanded vector corresponds to M / 2 pixels. Subsequently, the expanded vector of the first half can be ANDed with the second vector to extract the pixel value difference corresponding to the target pixel classification in the first M / 2 pixels to obtain a first difference vector, and the expanded vector of the second half can be ANDed with the second vector to extract the pixel value difference corresponding to the second pixel classification in the last M / 2 pixels to obtain a second difference vector. The above-mentioned scheme involved in the present application expands the front and rear parts of the comparison result vector respectively, thereby achieving alignment with the second vector and the third vector, and ensuring the feasibility of pixel value difference extraction based on assembly instructions.
[0161] S5, adding the first difference vector and the second difference vector, with 16 bits as one pixel element, to obtain a classification difference vector for classifying the target pixel; each 16-bit vector element in the classification difference vector constitutes a pixel value difference.
[0162] In an embodiment of the present application, the computer device can obtain a classified difference vector by adding the result vector obtained by performing an AND operation on the extended vector of the first half and the second vector in a manner of adding vector elements, and adding the result vector obtained by performing an AND operation on the extended vector of the second half and the second vector, respectively, by taking two vectors whose lengths are the bit width of the assembly instruction set as an example, and the process can be implemented by the eighth assembly instruction, which is used to add the vector elements at corresponding positions in two (M / 2)×16 vectors; for example, taking the assembly instruction set as an instruction set with a bandwidth of 256 as an example, the eighth assembly instruction can be the assembly instruction _mm256_add_epi16.
[0163] Among them, a 16-bit vector element in the above-mentioned classification difference vector may be 0, or it may be a pixel value difference corresponding to the target pixel classification, or it may be the sum of the pixel value differences of two target pixel classifications, and the cumulative sum of all 16-bit vector elements in the above-mentioned classification difference vector is the sum of the pixel value differences corresponding to the target pixel classification among the above-mentioned M pixel value differences.
[0164] Combination Fig. 9 , please refer to Fig.11 , which shows a schematic diagram of obtaining pixel value difference involved in the embodiment of the present application. Fig.11 As shown, taking the second value as 1 as an example, for Fig. 9 The computer device extracts the first half 98 of the comparison result vector 95 through the assembly instruction _mm256_castsi256_si128, and then expands the first half 98 through the assembly instruction _mm256_cvtepi8_epi16 to obtain the first comparison result extended vector 99, and performs an AND operation on the first comparison result extended vector 99 and the second vector 910 through the assembly instruction _mm256_and_si256 to obtain the first difference vector 911.
[0165] The computer device also extracts the second half 912 through the assembly instruction _mm256_extracti128_si256, and then expands the second half 912 through the assembly instruction _mm256_cvtepi8_epi16 to obtain a second comparison result extended vector 913, and performs an AND operation on the second comparison result extended vector 913 and the third vector 914 through the assembly instruction _mm256_and_si256 to obtain a second difference vector 915.
[0166] Finally, the computer device adds the 16-bit vector elements at corresponding positions in the first difference vector 911 and the second difference vector 915 through the assembly instruction _mm256_add_epi16 to obtain the classification difference vector 916 of the target pixel classification.
[0167] In a possible implementation, the computer device may further accumulate pixel value differences belonging to the first pixel classification among the pixel value differences corresponding to the M pixels into a third array.
[0168] In an embodiment of the present application, the computer device may accumulate the classification difference vector of the target pixel classification, with 16 bits as one vector element, into the difference statistic vector corresponding to the target pixel classification in the third array.
[0169] Among them, the above-mentioned difference statistical vector can be a (M / 2)×16 vector, and the computer device can add the classification difference vector of the target pixel classification with the difference statistical vector corresponding to the target pixel classification in the third array through the eighth assembly instruction.
[0170] After completing the statistics of the number of pixel values and the pixel value differences of one pixel classification for the above-mentioned M pixels, the computer device can switch to the next pixel classification (that is, update the above-mentioned target pixel classification), and continue to execute the statistical process of the number of pixel values and the pixel value differences of another pixel classification among the above-mentioned M pixels until all the M pixels are processed.
[0171] In a possible implementation, the computer device may maintain a pending mark vector, which is used to mark whether each pixel in the M pixels has completed SAO BO data statistics. When updating the above-mentioned target pixel classification, the computer device may determine a new target pixel classification from the pixel classifications corresponding to pixels that have not been processed (i.e., have not completed SAO BO data statistics) through the pending mark vector, until all M pixels have completed SAO BO data statistics.
[0172] In a possible implementation, the process of the computer device performing target pixel classification may be as follows:
[0173] S1, in response to the second value being 1, inverting the above comparison mask vector bit by bit to obtain an inverted mask vector.
[0174] Among them, when the second value is 1, in the mask vector obtained by bitwise inversion of the comparison mask vector, the pixel values corresponding to the bits with a value of 0 belong to the target pixel category, while the pixel values corresponding to the bits with a value of 1 do not belong to the target pixel category.
[0175] S2, performs an AND operation on the inverted mask vector and the pending mark vector to update the pending mark vector; the value of each bit in the pending mark vector is used to indicate whether a corresponding pixel in the M pixels has been processed; the initial value of each bit in the pending mark vector is 1.
[0176] In an embodiment of the present application, a to-be-processed mark vector with an initial value of 1 can be set corresponding to the M pixels processed in this batch, the length of the to-be-processed mark vector is M, each bit position corresponds to one of the M pixels, and the above-mentioned value of each bit position indicates whether the pixel corresponding to the bit position has been processed; for example, if the value of the first bit in the to-be-processed mark vector is 0, it means that the first pixel among the M pixels has completed the SAO BO statistical processing; for another example, if the value of the second bit in the to-be-processed mark vector is 1, it means that the second pixel among the M pixels has not completed the SAO BO statistical processing, and so on.
[0177] When the above-mentioned inverted mask vector is ANDed with the mark vector to be processed, since the pixel value corresponding to the bit with a value of 0 in the inverted mask vector belongs to the target pixel classification, it is equivalent to setting the bit value corresponding to each pixel whose pixel value belongs to the target pixel classification in the mark vector to be processed among the M pixels to 0, indicating that each pixel belonging to the target pixel classification among the M pixels has been processed. At the same time, the above-mentioned AND operation can keep the other bit values in the mark vector to be processed unchanged, thereby completing the marking of the processed pixels in the mark vector to be processed.
[0178] In another possible implementation, when the second value is 0, the computer device may perform an AND operation on the comparison mask vector and the to-be-processed label vector to update the to-be-processed label vector.
[0179] S3, select a bit with a value of 1 from the updated to-be-processed mark vector, and obtain the pixel value corresponding to the selected bit as the 8-bit pixel value of the new target pixel.
[0180] In the updated pending mark vector, the pixel value corresponding to the bit with a value of 1 is the pixel value of the M pixels that has not yet completed the SAO BO statistical processing; therefore, the pixel value corresponding to any bit with a value of 1 in the updated pending mark vector can be used as the pixel value after reconstructing the new target pixel.
[0181] After determining the new target pixel, the computer device may re-execute the above step 503b2 until the bit values in the to-be-processed tag vector are all 0, that is, it can be determined that the SAO BO statistics of the above M pixels are completed.
[0182] When the computer device selects a bit with a value of 1 from the updated tag vector to be processed, it can select the first bit with a value of 1 in order from high to low, or from low to high.
[0183] In one possible implementation, when a computer device selects the first bit with a value of 1 from the updated to-be-processed mark vector in order from low to high, it can be executed through a ninth assembly instruction, wherein the ninth assembly instruction is used to select the position where the first 1 appears from low to high from a 32-bit vector; for example, the ninth assembly instruction can be the assembly instruction CTZ.
[0184] The computer device may also select a bit with a value of 1 from the updated tag vector to be processed by other methods other than the above-mentioned CTZ; for example, the computer device may select the first bit with a value of 1 in the tag vector to be processed from high to low, or from low to high, through C / C++ instructions.
[0185] The above-mentioned scheme of the present application updates the mark vector to be processed by comparing the mask vector, and determines the next target pixel to be processed based on the mark vector to be processed through assembly instructions, thereby realizing the statistics of the number of pixel classifications based on assembly instructions, avoiding the processing of unnecessary pixel classifications, and improving the statistical efficiency of the number of pixel values corresponding to each pixel classification.
[0186] In a possible implementation, when the pixel values of M pixels are read from the reconstructed pixel group to obtain the first vector, if the number of unprocessed pixel values in the reconstructed pixel group is less than M, the computer device may sequentially fill all the unprocessed pixel values in the reconstructed pixel group into the first vector, and fill other vector elements in the first vector. When filling the vector elements of the first vector, the computer device may continue to read bit data after the unprocessed pixel values in the reconstructed pixel group and fill them into the first vector; for example, taking the value of M as 32 and the number of unprocessed pixel values in the reconstructed pixel group as 30, the computer device fills the 30 unprocessed pixel values in the reconstructed pixel group into the first vector in order from low to high, and there are still two vector elements (16 bits) left in the high order of the first vector. At this time, the computer device may continue to read 16-bit values from the cache and fill them into the high 16 bits of the first vector.
[0187] Correspondingly, when the pixel value differences corresponding to M pixels are read from the pixel difference group to obtain the second vector and the third vector, if the number of unprocessed pixel value differences in the pixel difference group is less than M, all the unprocessed pixel value differences in the pixel difference group are sequentially filled into the second vector and the third vector, and other vector elements in the second vector and the third vector are filled. Wherein, when filling the vector elements in the second vector and the third vector, the computer device can continue to read bit data after the unprocessed pixel value differences in the pixel difference group and fill it into the second vector or the third vector; for example, taking the value of M as 32 and the number of unprocessed pixel value differences in the pixel difference group as 30, the computer device fills the unprocessed 30 pixel values in the pixel difference group into the second vector and the third vector in order from low to high, and there are still two vector elements (32 bits) left in the high position of the third vector. At this time, the computer device can continue to read 32-bit values from the cache and fill them into the high 32 bits of the third vector.
[0188] In the case where the number of pixel values of the above-mentioned reconstructed pixel group is not an integer multiple of 32, when the data is read from the reconstructed pixel group and the pixel value difference group for the last time, the number of unprocessed pixel values in the reconstructed pixel group and the pixel value difference group is less than 32. At this time, the insufficient part can be filled by continuing to read data from the cache to complete the M pixel values and pixel value differences required by the first vector, the second vector and the third vector. In the above scheme, in the process of constructing the first vector, the second vector and the third vector, when the number of unprocessed pixels is less than 32, no additional processing is required for the filled part, and only the step of continuing to read data from the cache is required, which reduces the complexity of the algorithm implementation and improves the construction efficiency of the first vector, the second vector and the third vector.
[0189] In the above scheme, when the number of unprocessed pixels is less than M, since there are padded vector elements in the first vector, the second vector and the third vector, and since the padded vector elements are read from the cache and are random, if the pixel number statistics and pixel value difference statistics of pixel classification are directly performed through the above first vector, the second vector and the third vector, the padded vector elements will be counted as valid pixels, resulting in errors in the statistical results. For the above problem, the embodiment of the present application is aimed at the case where the number of pixel classifications is less than or equal to 128 (that is, for each pixel classification obtained by dividing the pixel values from 0 to 255, each pixel classification must contain at least 2 pixel values), and the processing process of reading data from the reconstructed pixel group and the pixel value difference group and performing SAO BO statistics for the last time is adjusted as follows:
[0190] 1) Setting a classification result correction vector for correcting the classification result indication vector; the classification result correction vector contains M 8-bit vector elements, and the value of the vector element corresponding to the unprocessed pixel in the classification result correction vector is 0, and the value of other vector elements is 128; the above step of comparing the expanded bit vector of the target pixel classification with the classification result indication vector is modified to: performing an XOR operation on the classification result indication vector and the classification result correction vector to obtain a corrected classification result indication vector; comparing the expanded bit vector of the target pixel classification with the corrected classification result indication vector to obtain a comparison result vector of the target pixel classification;
[0191] 2) When initializing the marker vector to be processed, the bits corresponding to the unprocessed pixels in the marker vector to be processed are initialized to the second value, and the other bits are initialized to the first value.
[0192] In the above adjusted scheme, when the data is read from the reconstructed pixel group and the pixel value difference group for the last time, the number of unprocessed pixels is J as an example, J+K=M, 1≤J<M, and J and K are integers; then in the first vector, the first J vector elements are valid pixel values, and the last K vector elements are invalid pixel values; similarly, in the combination of the second vector and the third vector, the first J vector elements are valid pixel value differences, and the last K vector elements are invalid pixel value differences. At this time, when the computer device initializes the to-be-processed tag vector, it initializes the first J bits of the to-be-processed tag vector to 1 and the last K bits to 0; then, a classification result correction vector is set, in which the values of the first J 8-bit vector elements in the classification result correction vector are 0 (the bit values of each bit are 0), and the values of the last K 8-bit vector elements are 128 (the bit values of each bit are arranged from low to high as "00000001"). Based on this example, the statistics of the number of pixels corresponding to the target pixel classification and the statistical scheme of the pixel value difference corresponding to the target pixel classification are as follows:
[0193] 1. Statistics on the number of pixels corresponding to the target pixel classification:
[0194] Since the values of the first J 8-bit vector elements in the classification result correction vector are 0, and the values of the last K 8-bit vector elements are 128, and the highest bit of each vector element in the classification result indication vector is 0 after translation, therefore, when the classification result indication vector and the classification result correction vector are XORed, the first J vector elements in the classification result indication vector remain unchanged after XORing with 0, and for each of the last K vector elements in the classification result indication vector, after XORing with 0, the first 7 bits remain unchanged and the last bit is 1. After this processing, the last K vector elements in the classification result indication vector are arranged from low to high as "xxxxxxx1", where "x" is 0 or 1. In this way, in the corrected classification result indication vector, the value (decimal) of each vector element in the last K vector elements will be greater than 128, and it does not belong to any pixel classification. For example, taking the type of pixel classification as 32 as an example, the value range corresponding to the pixel classification is 0 to 31, and 128 does not belong to this range. In this way, the expanded bit vector of the target pixel classification is subsequently compared with the modified classification result indication vector to obtain the comparison result vector of the target pixel classification, and the bits of the last K vector elements of the modified classification result indication vector are set to the first value.
[0195] Among them, in the above scheme, it is necessary to ensure that the value of the target pixel classification is not 128. This requirement can be achieved by controlling the selection method of the first target pixel. For example, when selecting the first target pixel, the pixel value of the first pixel among M pixels can be directly selected and shifted left by 3 bits to obtain the value of the target pixel classification.
[0196] When updating the target pixel, the first bit with a value of 1 can be selected from the high bit to the low bit of the updated processed mark vector, and the pixel value corresponding to the selected bit can be obtained as the 8-bit pixel value of the new target pixel. Since the last K bits have been set to 0 when the above-mentioned processed mark vector is initialized, the last K vector elements in the first vector will not be selected as the 8-bit pixel value of the target pixel, thereby avoiding the statistics of erroneous pixel classification.
[0197] 2. Statistics on the pixel value difference corresponding to the target pixel classification:
[0198] Based on the introduction of the first point above, since the bits of the last K vector elements in the comparison result vector are set to the first value (for example, 0), when the first difference vector and the second difference vector are subsequently calculated, the pixel value difference of the last K pixels in the combination of the second vector and the third vector will be set to 0, which will not affect the statistics of the pixel value difference.
[0199] In an embodiment of the present application, when the computer device processes every M pixels, the pixel value difference obtained for each pixel classification can be temporarily stored in the third array. There is no need to accumulate the pixel value difference for each pixel classification into the second array, thereby improving statistical efficiency.
[0200] In a possible implementation, in response to the number of processed pixels in the pixels corresponding to the reconstructed pixel group satisfying a specified condition, the computer device accumulates the third array into the second array.
[0201] In an embodiment of the present application, the computer device may add the third array to the second array when the number of processed pixels reaches a certain condition to avoid data overflow of the third array.
[0202] In a possible implementation, the specified conditions include the following conditions:
[0203] The number of pixels processed reaches the specified value; or,
[0204] The number of processed pixels is equal to the number of pixels corresponding to the reconstructed pixel group.
[0205] In an embodiment of the present application, the computer device may add the third array to the second array when the number of processed pixels reaches a specified value and when the number of pixels corresponding to the reconstructed pixel group is processed.
[0206] In a possible implementation, when the value of M is 32 and the bit width of the assembly instruction set is 256, the process of the computer device accumulating the third array into the second array may include:
[0207] S1, obtaining the difference statistical vectors corresponding to the four unprocessed pixel categories in the third array.
[0208] The third array contains the difference statistic vectors for each pixel classification. For example, taking the case where 256 pixel values are divided into 32 pixel classifications and each pixel classification contains 8 consecutive pixel values, the third array contains 32 difference statistic vectors. Since each difference statistic vector is a (M / 2)×16 vector, the sum of the pixel value differences of a corresponding pixel classification can be obtained by accumulating the vector elements composed of each 16 bits in the (M / 2)×16 vector.
[0209] In order to improve the concurrency of the accumulation process of the vector elements in the difference statistical vector, the scheme shown in the embodiment of the present application performs the process of accumulating the vector elements by taking the difference statistical vectors corresponding to four pixel classifications as a group.
[0210] S2, multiply and add the difference statistical vectors corresponding to the four pixel categories with the second template vector respectively to obtain the first difference representation vectors corresponding to the four pixel categories; the second template vector is composed of M / 2 16-bit vector elements, and the value of each 16-bit vector element in the second template vector is 1.
[0211] Among them, when the difference statistical vector is multiplied and added with the second template vector, since the value of each 16-bit vector element in the second template vector is 1, the operation is equivalent to calculating the sum of every two adjacent pixel elements in the difference statistical vector, and the obtained first difference representation vector is a (M / 4)×32 vector, that is, the first difference representation vector contains M / 4 vector elements, and each vector element contains 32 bits; the value of each vector element in the first difference representation vector is the sum of the two vector elements at the corresponding bit position in the above difference statistical vector.
[0212] In an embodiment of the present application, the computer device can execute the above-mentioned steps of multiplying and adding the difference statistical vectors corresponding to each of the four pixel categories with the second template vector respectively, through the tenth assembly instruction for performing multiplication and addition operations, to obtain the first difference representation vectors corresponding to each of the four pixel categories.
[0213] For example, taking the assembly instruction set being the AVX2 instruction set with a bandwidth of 256 as an example, the tenth assembly instruction may be the assembly instruction _mm256_madd_epi16.
[0214] S3, taking the two first difference representation vectors as a group and 32 bits as a vector element, performing addition processing on the shaped vectors in the horizontal direction to obtain two second difference representation vectors.
[0215] Among them, the above two first difference representation vectors (assuming that they are the first difference representation vector 0 and the first difference representation vector 1) are added in the horizontal direction with 32 bits as a vector element to obtain a (M / 4)×32 second difference representation vector; wherein the first 32-bit vector element and the second 32-bit vector element of the second difference representation vector are respectively the sum of the first two 32-bit vector elements of the first difference representation vector 0, and the sum of the third and fourth 32-bit vector elements of the first difference representation vector 0; the third 32-bit vector element and the fourth 32-bit vector element of the second difference representation vector are respectively the sum of the first two 32-bit vector elements of the first difference representation vector 0, and the sum of the third and fourth 32-bit vector elements of the first difference representation vector 0. 1, and the first difference represents the sum of the third and fourth 32-bit vector elements of vector 1; the fifth 32-bit vector element and the sixth 32-bit vector element of the second difference represents the vector, which are respectively the sum of the third and fourth 32-bit vector elements of vector 0 represented by the first difference, and the first difference represents the sum of the fifth and sixth 32-bit vector elements of vector 0; the seventh and eighth 32-bit vector elements of the second difference represents the vector, which are respectively the sum of the third and fourth 32-bit vector elements of vector 1 represented by the first difference, and the first difference represents the sum of the fifth and sixth 32-bit vector elements of vector 1; and so on.
[0216] Among them, the computer device can process the two first difference representation vectors through the eleventh assembly instruction for performing addition processing on the shaping vector in the horizontal direction; for example, taking the bandwidth of the assembly instruction set as 256 as an example, the above eleventh assembly instruction can be the assembly instruction _mm256_hadd_epi32.
[0217] For example, the first difference represents vector 0 and the first difference represents vector 1. Please refer to Fig.12 , which shows a schematic diagram of pixel classification processing involved in an embodiment of the present application; Fig.12 As shown, the first difference represents vector 0 ( Fig.12 The pixel value difference corresponding to 1201) in is represented by 0, and the first difference represents vector 1 ( Fig.12 1202) is represented by 1; the computer device processes the first difference representation vector 0 and the first difference representation vector 1 through the assembly instruction _mm256_hadd_epi32 to obtain the second difference representation vector 1203, in which the first two 32-bit vector elements, each vector element is the sum of the two 32-bit vector elements in the first difference representation vector 0, and the third and fourth 32-bit vector elements in the second difference representation vector 1201, each vector element is the sum of the two 32-bit vector elements in the first difference representation vector 1, and so on.
[0218] S4, taking 32 bits as a vector element, performing a shaping vector addition process on the two second difference representation vectors in the horizontal direction to obtain a third difference representation vector.
[0219] The computer device can process the two second difference representation vectors through the eleventh assembly instruction.
[0220] For example, taking the first difference representation vectors of four pixel classifications as first difference representation vector 0 to first difference representation vector 3, please refer to Fig.13 , which shows a schematic diagram of pixel classification processing involved in an embodiment of the present application; Fig.13 As shown, the pixel value difference corresponding to the first difference representation vector 0 is represented by 0, the pixel value difference corresponding to the first difference representation vector 1 is represented by 1, the pixel value difference corresponding to the first difference representation vector 2 is represented by 2, and the pixel value difference corresponding to the first difference representation vector 3 is represented by 3; each 32-bit vector element in the second difference representation vector 1301 is respectively the sum of the two vector elements in the first difference representation vector 0 and the first difference representation vector 1, and each 32-bit vector element in the second difference representation vector 1302 is respectively the sum of the two vector elements in the first difference representation vector 2 and the first difference representation vector 3; the computer The device processes the second difference representation vector 1301 and the second difference representation vector 1302 through the assembly instruction _mm256_hadd_epi32 to obtain a third difference representation vector 1303, wherein the first four 32-bit vector elements in the third difference representation vector 1303 are the sum of the four 32-bit vector elements in the first difference representation vector 0 to the first difference representation vector 3; similarly, the last four 32-bit vector elements in the third difference representation vector 1303 are the sum of the other four 32-bit vector elements in the first difference representation vector 0 to the first difference representation vector 3.
[0221] S5, taking 32 bits as a vector element, performs integer vector addition processing on the first half and the second half of the third difference representation vector to obtain a fourth difference representation vector; the fourth difference representation vector includes four 32-bit vector elements which are the sum of the pixel value differences of the four pixel categories.
[0222] The computer device can extract the first half and the second half from the third difference representation vector through the fifth assembly instruction and the sixth assembly instruction, and then perform integer vector addition processing on the first half and the second half of the third difference representation vector through the twelfth assembly instruction that performs addition processing on the two vectors in units of 32 bits; for example, taking the bit width of the above-mentioned assembly instruction set as 256 as an example, the above-mentioned twelfth assembly instruction is the assembly instruction _mm_add_epi32.
[0223] Or Fig.13 For example, by adding the first four vector elements and the second four vector elements of the third difference representation vector 1303, a 4×32 fourth difference representation vector 1304 can be obtained. The four vector elements in the fourth difference representation vector 1304 are the sum of the vector elements in the first difference representation vector 0 to the first difference representation vector 3, that is, the sum of the pixel value differences corresponding to the four pixel classifications in the third array.
[0224] S6, accumulating the sum of the pixel value differences of the four pixel categories into the second array, corresponding to the array positions of the four pixel categories.
[0225] The second array contains array positions of respective pixel classifications, and each array position is used to store a 32-bit vector; when the sum of the pixel value differences of the four pixel classifications is accumulated to the second array, for a 32-bit vector element in the above-mentioned fourth difference representation vector, if the value of the array position of the pixel classification corresponding to the 32-bit vector element in the second array is 0 or empty, the computer device can directly write the 32-bit vector element into the corresponding array position in the second array.
[0226] If the value of the array position of the pixel classification corresponding to the 32-bit vector element in the second array is not 0 or empty, the computer device can add the 32-bit vector element to the array position of the corresponding pixel classification in the second array; for example, the computer device can extract the 32-bit vector stored in the array position of the pixel classification corresponding to the 32-bit vector element in the second array, and add the 32-bit vector to the 32-bit vector element.
[0227] Among them, the computer device can extract the four 32-bit vectors stored in the array positions of the above four pixel classifications in the second array at one time to form a 4×32 fifth difference representation vector; the array positions of the above four pixel classifications in the second array are continuous, and the arrangement order is the same as the arrangement order of the first difference representation vector 0 to the first difference representation vector 3; at this time, the computer device adds the fourth difference representation vector and the fifth difference representation vector through the assembly instruction _mm_add_epi32, and covers the obtained 4×32-bit vector to the array positions of the four pixel classifications in the second array to complete the accumulation.
[0228] Based on the above Figure 5 or Figure 7 The scheme shown takes AVX2 assembly instructions as an example to introduce the core process of BO data statistics of this application:
[0229] S1, input the reconstructed pixel group and pixel value difference group of the reconstructed image:
[0230] The input includes:
[0231] 1) Reconstructed pixel buffer (uint8_t*rec), corresponding to the above-mentioned reconstructed pixel group;
[0232] 2) The difference between the reconstructed pixel and the original pixel (int16_t*diff), corresponding to the above pixel value difference group.
[0233] S2, output the number of pixel values belonging to each pixel classification in the reconstructed pixel group, and the sum of the pixel value differences belonging to each pixel classification in the pixel difference group:
[0234] The input includes:
[0235] 1) The sum of the differences between the reconstructed pixels and the original pixels of each pixel category, boStat(int32_t*), that is, the sum of the differences in the pixel values belonging to each pixel category in the above pixel difference group;
[0236] 2) The total number of each pixel category boCount (int32_t*), that is, the number of pixel values belonging to each pixel category in the above reconstructed pixel group.
[0237] S3, initialization:
[0238] S3.1, let total be the total number of pixels to be processed;
[0239] S3.2, let n, n is the number of processed pixels, initialized to 0;
[0240] S3.3, initialize the array boCount to 0;
[0241] S3.4, initialize the array boStat to 0;
[0242] S3.5, set the 32x8 constant vector pb_31, call _mm256_set1_epi8 to initialize each of its units to 31 (0x1F);
[0243] S3.6, set the 16x16 constant vector pw_1, and call _mm256_set1_epi16 to initialize each unit of it to 1;
[0244] S3.7, set the vector array vStats to accumulate the sum of the difference values of each type of pixel. Call _mm256_setzero_si256 to initialize vStats to 0;
[0245] S3.8, let bReSet indicate whether vStats has been reset, initialized to 0.
[0246] S4, read 32 pixels and their corresponding differences:
[0247] S4.1, read 32 pixel data from rec (_mm256_lddqu_si256) into 32x8 vector pixels;
[0248] S4.2, read the 32 pixel differences corresponding to the 32 pixels just read by rec from diff into 16x16 vectors diff_p0_0 and diff_p0_1;
[0249] S4.3, let remain_mask0, the index information of the pixel to be processed, be a 32-bit bitmask used to record which pixels have not been processed. remain_mask0 is initialized to 0xFFFFFFFF, where each bit represents the processing status of a pixel, and 1 represents unprocessed.
[0250] S4.4, calculate the categories of 32 pixels. Shifting the pixel left by 3 bits can get its BO category, but since there is no shift operation in units of 8 bits in AVX2, shift and AND operations are used here to simulate it. Fig.14 A schematic diagram of similar pixel processing involved in the present application is shown, in which the calculation process of shift and operation simulation is demonstrated.
[0251] S4.4.1, first use the 16-bit shift operation (_mm256_srli_epi16) to shift the pixels in 4.1 left by 3 bits. After the shift, the upper 8 bits of each 16 bits are valid classification results, while the upper 3 bits of the lower 8 bits are invalid data;
[0252] S4.4.2, through the AND operation (_mm256_and_si256) with pb_31 in 3.4, the invalid data in the lower 8 bits are cleared. So far, the classification result classIdxs_p0 is obtained.
[0253] S5, process 32 pixels and jump to step S8;
[0254] S6, update context:
[0255] S6.1, n+=32;
[0256] S6.2, rec+=32;
[0257] S6.3, diff+=32;
[0258] S6.4, if bReset is 0 and n is equal to 64x32, then bReset=1, jump to step 10; otherwise, execute step 7.
[0259] S7, if n is less than total, jump to step 4, otherwise jump to step 11;
[0260] S8, processing of type 1 pixels:
[0261] S8.1, obtaining the first pixel category;
[0262] S8.1.1, in S4.4, the categories of all pixels are obtained, and _mm256_castsi256_si128 is called (to convert 256 bits to 128 bits) to obtain the lower 128 bits of classIdxs_p0, and then _mm256_broadcastb_epi8 is called to copy the lower 8 bits of data to the entire 32x8 vector classIdx. Fig.14 The calculation process is demonstrated;
[0263] S8.1.2, shift rec[0] left by 3 bits to obtain the category c of the pixel;
[0264] S8.2, processing pixels of the same type;
[0265] S8.2.1, find similar pixels. Call _mm256_cmpeq_epi8 to compare classIdx and classIdxs_p0 in 8-bit units. If they are the same, the 8 bits at the corresponding positions are set to 1. If they are different, the 8 bits at the corresponding positions are set to 0. The comparison result is saved in the 32x8 vector cmp_p0. Fig.14 The calculation process is demonstrated;
[0266] S8.2.2, accumulate the difference between the reconstructed and original pixels of the same type. The 32x8 vector cmp_p0 marks the position of the same type of pixels. Perform AND operations on diff_p0_0 / diff_p0_1 and cmp_p0 respectively to obtain the difference containing only the same type of pixels, and then accumulate the result into vStats[c], specific implementation;
[0267] S8.2.2.1, because the unit widths of cmp_p0 and diff_p0_0 / diff_p0_1 are different (8 bits vs 16 bits), the unit widths need to be aligned first, and _mm256_castsi256_si128 and _mm256_extracti128_si256 are called to obtain the low and high 128 bits of cmp_p0, and _mm256_cvtepi8_epi16 is called to expand them to 16x16 vectors respectively. Fig.14 The calculation process is demonstrated;
[0268] S8.2.2.2, perform AND operation (_mm256_and_si256) on the low and high parts of the expanded cmp_p0 and diff_p0_0 / diff_p0_1 respectively. Fig.14 The calculation process is demonstrated;
[0269] S8.2.2.3, add (_mm256_add_epi16) the result of 8.2.2.2;
[0270] S8.2.2.4, accumulate the result of 8.2.2.3 (_mm256_add_epi16) to vStats[c];
[0271] S8.2.3, accumulate the number of pixels of the same type;
[0272] S8.2.3.1, call _mm256_movemask_epi8 to get the most significant bit of each unit in the 32x8 vector cmp_p0, and assemble it into a 32-bit mask. Each bit of this mask represents 1 pixel, 1 means that the pixel has the same classification, and 0 means different classifications, such as Fig.15 As shown;
[0273] S8.2.3.2, use the assembly POPCOUNT to count the number of 1s in the mask. At this point, the number of pixels of the same type is obtained, and the result is accumulated to boCount[c], such as Fig.15 As shown, it shows a schematic diagram of mask calculation involved in this application;
[0274] S8.2.4, update remain_mask0:
[0275] S8.2.4.1, bitwise invert the mask in 8.2.3.1, perform an AND operation with remaining_mask0, and update it to remaining_mask. At this point, all pixels on remaining_mask0 that are of the same type as pixels in category 1 are cleared. The calculation process is as follows: Fig.16 As shown; among them, Fig.16 A schematic diagram of remain_mask update involved in the present application is shown.
[0276] S9, processing the next type of pixels:
[0277] S9.1, obtain the next pixel category:
[0278] S9.1.1, if remaining_mask0 is 0, it means that all 32 pixels have been processed, and jump to step 6; otherwise, call CTZ and find the position pos of the first 1 in remaining_mask0 from low to high. The process is as follows Fig.17 As shown, Fig.17 A schematic diagram of pixel classification query involved in the present application is shown;
[0279] S9.1.2, shift rec[pos] left by 3 bits to obtain the category c of the pixel;
[0280] S9.1.3, call _mm256_set1_epi8, copy c to 32x8 vector classIdx;
[0281] S9.2, processing pixels of the same type, the process is the same as S8.2;
[0282] S9.3, jump to step S9.1.
[0283] S10, calculate the sum of the vector elements of each type of vector in vStats and output it to boStat. To improve instruction concurrency, four pixel categories are processed at a time. Specific process:
[0284] S10.1, Initialization:
[0285] S10.1.1, set stat = boStat, back up the cache address to be output;
[0286] S10.1.2, set i=0, indicating the first pixel type to be processed;
[0287] S10.2, set the four pixel types to be processed simultaneously, idx0 / 1 / 2 / 3=i / i+1 / i+2 / i+3;
[0288] S10.3, calculate the sum of two adjacent elements in the 16x16 vector, call _mm256_madd_epi16 to perform multiplication and addition operations on vStats[idx0] and pw_1, multiply the two adjacent elements of the 16x16 vector vStats[idx0] by 1 and then add them to get the 8x32 vector result r0. Perform the same operation on vStats[idx1] / vStats[idx2] / vStats[idx3] to get r1 / r2 / r3;
[0289] S10.4, find the sum of two adjacent elements in 8x32;
[0290] S10.4.1, call _mm256_hadd_epi32 (add two integer vectors horizontally) to operate on r0 and r1, and get a new 8x32 result r0. In the new result r0, bits 0 to 63 correspond to the result of adding the original 4 32-bit elements of r0 from bits 0 to 127 in pairs; bits 64 to 127 correspond to the result of adding the original 4 elements of r1 from bits 0 to 127 in pairs; bits 128 to 191 correspond to the result of adding the original 4 32-bit elements of r0 from bits 128 to 255 in pairs; bits 192 to 255 correspond to the result of adding the original 4 elements of r1 from bits 128 to 255 in pairs;
[0291] S10.4.2, call _mm256_hadd_epi32 to operate on r2 and r3, and get the new result r2 of 8x32;
[0292] S10.4.3, call _mm256_hadd_epi32 to operate on new r0 and new r2, and get the latest result r0 of 8x32;
[0293] At this time, in the latest result r0, the 8 32-bit elements represent the cumulative sum of the lower 8 elements of vStats[idx0] / vStats[idx1] / vStats[idx2] / vStats[idx3] and the higher 8 elements of vStats[idx0] / vStats[idx1] / vStats[idx2] / vStats[idx3];
[0294] S10.4.4, call _mm256_castsi256_si128 for the latest result r0 to get its lower 128 bits, call _mm256_extracti128_si256 to get its upper 128 bits, and then _mm_add_epi32 (add two integer vectors) to sum the lower 4x32 bit vector and the upper 4x32 bit vector to get the 4x32 vector result res;
[0295] S10.5, call _mm_storeu_si128 (store 128 bits of data) and write the result to stat;
[0296] S10.6, Update context:
[0297] S10.6.1, stat+ = 4;
[0298] S10.6.2, i+=4;
[0299] S10.7, repeat steps 10.2, 10.3, 10.4, 10.5, and 10.6 eight times to process 32 pixel categories;
[0300] S10.8, jump to step 7.
[0301] S11, calculate the sum of the vector elements of each type of vector of vStats, add it to the data of boStat and output it to boStat:
[0302] S11.1, Initialization:
[0303] S11.1.1, set stat = boStat, back up the cache address to be output;
[0304] S11.1.2, set i=0, indicating the first pixel type to be processed;
[0305] S11.2, set the four pixel types to be processed simultaneously, idx0 / 1 / 2 / 3=i / i+1 / i+2 / i+3;
[0306] S11.3, calculate the sum of two adjacent elements in the 16x16 vector, call _mm256_madd_epi16 to perform multiplication and addition operations on vStats[idx0] and pw_1, multiply the two adjacent elements of the 16x16 vector vStats[idx0] by 1 and then add them to get the 8x32 vector result r0. Perform the same operation on vStats[idx1] / vStats[idx2] / vStats[idx3] to get r1 / r2 / r3;
[0307] S11.4, find the sum of two adjacent elements in 8x32;
[0308] S11.4.1, call _mm256_hadd_epi32 to operate on r0 and r1, and get the new result r0 of 8x32. In the new result r0, bits 0 to 63 correspond to the result of adding the original 4 32-bit elements of r0 from bits 0 to 127 in pairs; bits 64 to 127 correspond to the result of adding the original 4 elements of r1 from bits 0 to 127 in pairs; bits 128 to 191 correspond to the result of adding the original 4 32-bit elements of r0 from bits 128 to 255 in pairs; bits 192 to 255 correspond to the result of adding the original 4 elements of r1 from bits 128 to 255 in pairs;
[0309] S11.4.2, call _mm256_hadd_epi32 to operate on r2 and r3, and get the new result r2 of 8x32;
[0310] S11.4.3, call _mm256_hadd_epi32 to operate on new r0 and new r2, and get the latest result r0 of 8x32;
[0311] At this time, in the latest result r0, the 8 32-bit elements represent the cumulative sum of the lower 8 elements of vStats[idx0] / vStats[idx1] / vStats[idx2] / vStats[idx3] and the higher 8 elements of vStats[idx0] / vStats[idx1] / vStats[idx2] / vStats[idx3];
[0312] S11.4.4, call _mm256_castsi256_si128 for the latest result r0 to get its lower 128 bits, call _mm256_extracti128_si256 to get its upper 128 bits, and then _mm_add_epi32 to sum the lower 4x32 bit vector and the upper 4x32 bit vector. Get the 4x32 vector result res;
[0313] S11.4.5, call _mm_lddqu_si128, read 4x32 bits of data from stat into vector tmp;
[0314] S11.4.6, call _mm_add_epi32, sum res and tmp, and get 4x32 vector res;
[0315] S11.5, call _mm_storeu_si128 to write the result to stat;
[0316] S11.6, Update context:
[0317] S11.6.1, stat+ = 4;
[0318] S11.6.2, i+=4;
[0319] S11.7, repeat steps 11.2, 11.3, 11.4, 11.5, and 11.6 eight times to process 32 pixel categories;
[0320] S11.8, end.
[0321] In terms of the acceleration of a single function, the overall use of the assembly implementation method of this application can accelerate the time consumption of SAO BO statistics from more than 5% to only about 1.5%. The data diagram of the unit test is as follows Fig.18 As shown in the figure, it can be seen that when the number of pixel types is less than 4, the speed can be increased by more than 1 times. Although there is basically no acceleration effect when the number of colors exceeds 7, in the actual screen content, the number of color types is likely to be less than 5, so there is still a significant acceleration in actual application.
[0322] From the perspective of the entire encoder, since applications based on video codec, such as video conferencing, need to run on terminals with different performances (especially old devices), reducing the encoder's time consumption can, on the one hand, increase the encoder's coverage on different models, allowing old devices to use HEVC encoding and save bandwidth for video conferencing; on the other hand, it can avoid the problem of reduced SAO benefits caused by the use of fast algorithms.
[0323] The scheme shown in the above embodiment of the present application is only illustrated by taking the bandwidth of the assembly instruction set as 256 as an example. Optionally, the above scheme can also be implemented by assembly instruction sets with other bandwidths, such as the SSE41 instruction set with a bandwidth of 128. Its implementation logic is similar to the scheme in the above embodiment, except that the value of the number of pixels M to be processed concurrently is different.
[0324] 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.
[0325] Please refer to Fig.19 , which shows a block diagram of a data processing device for video encoding and decoding provided by an embodiment of the present application. The device can be operated based on an assembly instruction set. The device may include:
[0326] The first acquisition module 1901 is used to acquire a reconstructed pixel group and a pixel difference group corresponding to the reconstructed pixel group; the reconstructed pixel group includes pixel values of N reconstructed pixels in a video frame; the pixel difference group includes pixel value differences of the N reconstructed pixels; the pixel value difference is the difference between the pixel value of the reconstructed pixel and the pixel value of the original pixel corresponding to the reconstructed pixel; the pixel value is represented by 8 bits, and the pixel value difference is represented by 16 bits; N is an integer greater than or equal to 32;
[0327] The loop module 1902 is used to loop through the following steps until the data in the reconstructed pixel group and the pixel difference group are processed: the pixel values of M pixels are read from the reconstructed pixel group to obtain a first vector, and the pixel value differences corresponding to the M pixels are read from the pixel difference group to obtain a second vector and a third vector; M is the bit width / 8 of the assembly instruction set; the first vector is composed of the pixel values of the M pixels connected end to end; the second vector is composed of the pixel value differences corresponding to the first M / 2 pixels of the M pixels connected end to end; the third vector is composed of the pixel value differences corresponding to the last M / 2 pixels of the M pixels connected end to end; based on the first vector, the second vector and the third vector, the number of pixel values belonging to each pixel classification in the pixel values of the M pixels and the pixel value differences belonging to each pixel classification in the pixel value differences corresponding to the M pixels are obtained;
[0328] The second acquisition module 1903 is used to obtain the band compensation statistical information of the reconstructed pixel group in response to the data in the reconstructed pixel group and the pixel difference group being processed; the band compensation statistical information includes a first array and a second array; the first array is used to record the number of pixel values belonging to each pixel classification in the reconstructed pixel group; the second array is used to indicate the sum of the pixel value differences belonging to each pixel classification in the pixel difference group.
[0329] In a possible implementation, the loop module 1902 is used to:
[0330] A classification result indication vector is obtained by left-shifting the vector elements corresponding to each pixel value in the first vector; the vector element at the position corresponding to each pixel value in the classification result indication vector is used to indicate the pixel classification to which the corresponding pixel value belongs;
[0331] Based on the classification result indication vector, the second vector and the third vector, for each pixel classification in at least one pixel classification included in the pixel values of the M pixels, the number of pixel values belonging to each pixel classification in the pixel values of the M pixels and the pixel value differences corresponding to the M pixels belonging to each pixel classification are obtained respectively.
[0332] In a possible implementation, the loop module 1902 is used to:
[0333] Using 16 bits as a shift unit, left-shift the vector element corresponding to each pixel value in the first vector by 3 bits to obtain a shift result vector;
[0334] Performing an AND operation on the shift result vector and the first template vector to obtain the classification result indication vector;
[0335] The first template vector is composed of M 8-bit vector elements; the value of each 8-bit vector element in the first template vector is 31.
[0336] In a possible implementation, the loop module 1902 is used to:
[0337] Obtaining an 8-bit pixel value of a target pixel; the target pixel is a pixel among the M pixels for which statistical processing has not yet been completed;
[0338] Shift the 8-bit pixel value of the target pixel left by 3 bits to obtain a classification representation vector of the target pixel classification corresponding to the target pixel;
[0339] Obtaining an expansion vector of the target pixel classification, wherein the expansion vector is formed by connecting M classification representation vectors of the target pixel classification end to end;
[0340] Taking 8 bits as a comparison unit, comparing the expanded bit vector of the target pixel classification with the classification result indication vector, setting the bits of the comparison units with differences in the expanded bit vector of the target pixel classification to a first value, and setting the bits of the same comparison units in the expanded bit vector of the target pixel classification to a second value, to obtain a comparison result vector of the target pixel classification; the first value is one of 0 and 1, and the second value is the other of 0 and 1 except the first value;
[0341] Based on the comparison result vector of the target pixel classification, obtaining the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels;
[0342] Based on the comparison result vector of the target pixel classification, the second vector and the third vector, the pixel value difference corresponding to the target pixel classification is obtained among the pixel value differences corresponding to the M pixels.
[0343] In a possible implementation, the loop module 1902 is used to:
[0344] Obtaining the most significant bit of each comparison unit in the comparison result vector of the target pixel classification, and concatenating them to obtain a comparison mask vector of the target pixel classification;
[0345] The number of bits whose value is the second value in the comparison mask vector is counted to obtain the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels.
[0346] In a possible implementation, the loop module 1902 is further configured to:
[0347] In response to the second value being 1, inverting the comparison mask vector bit by bit to obtain an inverted mask vector;
[0348] Performing an AND operation on the inverted mask vector and the to-be-processed mark vector to update the to-be-processed mark vector; the value of each bit in the to-be-processed mark vector is used to indicate whether a corresponding pixel in the M pixels has been processed; the initial value of each bit in the to-be-processed mark vector is 1;
[0349] A bit with a value of 1 is selected from the updated to-be-processed mark vector, and the pixel value corresponding to the selected bit is obtained as the 8-bit pixel value of the new target pixel.
[0350] In a possible implementation, the loop module 1902 is used to:
[0351] The comparison result vector of the target pixel classification is ANDed with the second vector and the third vector respectively to obtain the pixel value difference corresponding to the target pixel classification among the pixel value differences corresponding to the M pixels.
[0352] In a possible implementation, the loop module 1902 is used to:
[0353] Expanding the vector elements of the first half of the comparison result vector of the target pixel classification from 8 bits to 16 bits to obtain a first comparison result expansion vector;
[0354] Performing an AND operation on the first comparison result extended vector and the second vector to obtain a first difference vector; the first difference vector includes the pixel value difference corresponding to the target pixel classification among the pixel value differences corresponding to the first M / 2 pixels of the M pixels;
[0355] Expanding the vector elements of the second half of the comparison result vector of the target pixel classification from 8 bits to 16 bits to obtain a second comparison result expansion vector;
[0356] Performing an AND operation on the second comparison result extended vector and the third vector to obtain a second difference vector; the second difference vector includes the pixel value difference corresponding to the target pixel classification among the pixel value differences corresponding to the last M / 2 pixels among the pixel values of the M pixels;
[0357] The first difference vector and the second difference vector are added with 16 bits as one pixel element to obtain a classification difference vector of the target pixel classification; each 16-bit vector element in the classification difference vector constitutes a pixel value difference.
[0358] In a possible implementation, the loop module 1902 is further used to accumulate the classification difference vector of the target pixel classification into the difference statistic vector corresponding to the target pixel classification in the third array, with 16 bits as one vector element.
[0359] In a possible implementation, the loop module 1902 is further configured to, in response to the number of processed pixels corresponding to the reconstructed pixel group satisfying a specified condition, accumulate the third array into the second array;
[0360] The specified conditions include the following conditions:
[0361] The number of processed pixels reaches a specified value;
[0362] Alternatively, the number of processed pixels is equal to the number of pixels corresponding to the reconstructed pixel group.
[0363] In a possible implementation, the value of M is 32, and the bit width of the assembly instruction set is 256; the loop module 1902 is used to:
[0364] Obtain the difference statistical vectors corresponding to the four unprocessed pixel categories in the third array;
[0365] The difference statistical vectors corresponding to the four pixel classifications are respectively multiplied and added with the second template vector to obtain first difference representation vectors corresponding to the four pixel classifications; the second template vector is composed of M / 2 16-bit vector elements, and the value of each 16-bit vector element in the second template vector is 1;
[0366] Taking the two first difference representation vectors as a group, taking 32 bits as a vector element, performing addition processing on the shaping vectors in the horizontal direction, and obtaining two second difference representation vectors;
[0367] Taking 32 bits as one vector element, performing a shaping vector addition process on two second difference representation vectors in a horizontal direction to obtain a third difference representation vector;
[0368] Taking 32 bits as one vector element, performing an addition process of the first half and the second half of the third difference representation vector as the shaping vector, to obtain a fourth difference representation vector; the four 32-bit vector elements included in the fourth difference representation vector are respectively the sums of the pixel value differences of the four pixel categories;
[0369] The sum of the pixel value differences of the four pixel categories is accumulated into the second array, corresponding to the array positions of the four pixel categories.
[0370] Please refer to Fig. 20, which shows a block diagram of a computer device provided by an embodiment of the present application. The computer device may be the encoding end device described above, or the decoding end device described above. The computer device 2000 may include: a processor 2001, a memory 2002, a communication interface 2003, an encoder / decoder 2004, and a bus 2005.
[0371] The processor 2001 includes one or more processing cores. The processor 2001 executes various functional applications and information processing by running software programs and modules.
[0372] The memory 2002 may be used to store a computer program, and the processor 2001 may be used to execute the computer program to implement the above-mentioned data processing method for video encoding and decoding.
[0373] The communication interface 2003 may be used to communicate with other devices, such as receiving and transmitting audio and video data.
[0374] The encoder / decoder 2004 may be used to implement encoding and decoding functions, such as encoding and decoding audio and video data.
[0375] The memory 2002 is connected to the processor 2001 via a bus 2005 .
[0376] In addition, the memory 2002 can be implemented by any type of volatile or non-volatile storage device or a combination thereof. The volatile or non-volatile storage device includes but is not limited to: a magnetic disk or an optical disk, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM (Erasable Programmable Read-Only Memory), an SRAM (Static Random-Access Memory), a ROM (Read-Only Memory), a magnetic storage device, a flash memory, and a PROM (Programmable read-only memory).
[0377] Those skilled in the art will understand that Fig. 20 The structure shown in the figure does not constitute a limitation on the computer device 2000, and the computer device 2000 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.
[0378] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one instruction, at least one program, a code set or an instruction set is stored. When the at least one instruction, the at least one program, the code set or the instruction set is executed by a processor, the data processing method for video encoding and decoding is implemented.
[0379] In an exemplary embodiment, a computer program product or a computer program is also provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the above-mentioned data processing method for video encoding and decoding.
[0380] It should be understood that the "plurality" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0381] The above description is only an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A data processing method for video encoding and decoding, characterized in that: The method is implemented by a computer device based on an assembly instruction set, and the method includes: Obtain a reconstructed pixel group and a pixel difference group corresponding to the reconstructed pixel group; the reconstructed pixel group includes pixel values of N reconstructed pixels in a video frame; the pixel difference group includes pixel value differences of the N reconstructed pixels; the pixel value difference is a difference between a pixel value of the reconstructed pixel and a pixel value of an original pixel corresponding to the reconstructed pixel; the pixel value is represented by 8 bits, and the pixel value difference is represented by 16 bits; The following steps are executed in a loop until the data in the reconstructed pixel group and the pixel difference group are processed: the pixel values of M pixels are read from the reconstructed pixel group to obtain a first vector, and the pixel value differences corresponding to the M pixels are read from the pixel difference group to obtain a second vector and a third vector; M is the bit width / 8 of the assembly instruction set; the first vector is composed of the pixel values of the M pixels connected end to end; the second vector is composed of the pixel value differences corresponding to the first M / 2 pixels of the M pixels connected end to end; the third vector is composed of the pixel value differences corresponding to the last M / 2 pixels of the M pixels connected end to end; based on the first vector, the second vector and the third vector, the number of pixel values belonging to each pixel classification in the pixel values of the M pixels and the pixel value differences belonging to each pixel classification in the pixel value differences corresponding to the M pixels are obtained; In response to the data in the reconstructed pixel group and the pixel difference group being processed, the band compensation statistical information of the reconstructed pixel group is obtained; the band compensation statistical information includes a first array and a second array; the first array is used to record the number of pixel values belonging to each pixel classification in the reconstructed pixel group; the second array is used to indicate the sum of the pixel value differences belonging to each pixel classification in the pixel difference group.
2. The method according to claim 1, characterized in that The acquiring, based on the first vector, the second vector, and the third vector, the number of pixel values belonging to each pixel category in the M pixels, and the pixel value difference belonging to each pixel category in the pixel value differences corresponding to the M pixels, includes: A classification result indication vector is obtained by left-shifting the vector elements corresponding to each pixel value in the first vector; the vector element at the position corresponding to each pixel value in the classification result indication vector is used to indicate the pixel classification to which the corresponding pixel value belongs; Based on the classification result indication vector, the second vector and the third vector, for each pixel classification in at least one pixel classification included in the pixel values of the M pixels, the number of pixel values belonging to each pixel classification in the pixel values of the M pixels and the pixel value differences corresponding to the M pixels belonging to each pixel classification are obtained respectively.
3. The method according to claim 2, characterized in that The obtaining of the classification result indication vector by left-shifting the vector elements corresponding to each pixel value in the first vector comprises: Using 16 bits as a shift unit, left-shift the vector element corresponding to each pixel value in the first vector by 3 bits to obtain a shift result vector; Performing an AND operation on the shift result vector and the first template vector to obtain the classification result indication vector; The first template vector is composed of M 8-bit vector elements; the value of each 8-bit vector element in the first template vector is 31.
4. The method according to claim 2, characterized in that: The method of obtaining, based on the classification result indication vector, the second vector and the third vector, for each pixel classification in at least one pixel classification included in the pixel values of the M pixels, the number of pixel values belonging to each pixel classification in the pixel values of the M pixels and the pixel value difference values belonging to each pixel classification in the pixel value differences corresponding to the M pixels, respectively, includes: Obtaining an 8-bit pixel value of a target pixel; the target pixel is a pixel among the M pixels for which statistical processing has not yet been completed; Shift the 8-bit pixel value of the target pixel left by 3 bits to obtain a classification representation vector of the target pixel classification corresponding to the target pixel; Obtaining an expanded vector of the target pixel classification, wherein the expanded vector is formed by connecting M classification representation vectors of the target pixel classification end to end; Taking 8 bits as a comparison unit, comparing the expanded bit vector of the target pixel classification with the classification result indication vector, setting the bits of the comparison units with differences in the expanded bit vector of the target pixel classification to a first value, and setting the bits of the same comparison units in the expanded bit vector of the target pixel classification to a second value, to obtain a comparison result vector of the target pixel classification; the first value is one of 0 and 1, and the second value is the other of 0 and 1 except the first value; Based on the comparison result vector of the target pixel classification, obtaining the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels; Based on the comparison result vector of the target pixel classification, the second vector and the third vector, the pixel value difference corresponding to the target pixel classification is obtained among the pixel value differences corresponding to the M pixels.
5. The method according to claim 4, characterized in that The step of obtaining the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels based on the comparison result vector of the target pixel classification includes: Obtaining the most significant bit of each comparison unit in the comparison result vector of the target pixel classification, and concatenating them to obtain a comparison mask vector of the target pixel classification; The number of bits whose value is the second value in the comparison mask vector is counted to obtain the number of pixel values belonging to the target pixel classification among the pixel values of the M pixels.
6. The method according to claim 5, characterized in that The method further comprises: In response to the second value being 1, inverting the comparison mask vector bit by bit to obtain an inverted mask vector; Performing an AND operation on the inverted mask vector and the to-be-processed mark vector to update the to-be-processed mark vector; the value of each bit in the to-be-processed mark vector is used to indicate whether a corresponding pixel in the M pixels has been processed; the initial value of each bit in the to-be-processed mark vector is 1; A bit with a value of 1 is selected from the updated to-be-processed mark vector, and the pixel value corresponding to the selected bit is obtained as the 8-bit pixel value of the new target pixel.
7. The method according to claim 4, characterized in that The step of obtaining the pixel value difference corresponding to the target pixel classification from among the pixel value differences corresponding to the M pixels based on the comparison result vector of the target pixel classification, the second vector and the third vector comprises: The comparison result vector of the target pixel classification is ANDed with the second vector and the third vector respectively to obtain the pixel value difference corresponding to the target pixel classification among the pixel value differences corresponding to the M pixels.
8. The method according to claim 7, characterized in that The step of performing AND operations on the comparison result vector of the target pixel classification, the second vector and the third vector, respectively, to obtain the pixel value difference corresponding to the target pixel classification among the pixel value differences corresponding to the M pixels, includes: Expanding the vector elements of the first half of the comparison result vector of the target pixel classification from 8 bits to 16 bits to obtain a first comparison result expansion vector; Performing an AND operation on the first comparison result extended vector and the second vector to obtain a first difference vector; the first difference vector includes the pixel value difference corresponding to the target pixel classification among the pixel value differences corresponding to the first M / 2 pixels of the M pixels; Expanding the vector elements of the second half of the comparison result vector of the target pixel classification from 8 bits to 16 bits to obtain a second comparison result expansion vector; Performing an AND operation on the second comparison result extended vector and the third vector to obtain a second difference vector; the second difference vector includes the pixel value difference corresponding to the target pixel classification among the pixel value differences corresponding to the last M / 2 pixels among the pixel values of the M pixels; The first difference vector and the second difference vector are added with 16 bits as one pixel element to obtain a classification difference vector of the target pixel classification; each 16-bit vector element in the classification difference vector constitutes a pixel value difference.
9. The method according to claim 8, characterized in that The method further comprises: The classification difference vector of the target pixel classification is accumulated to the difference statistic vector corresponding to the target pixel classification in the third array, with 16 bits as one vector element.
10. The method according to claim 9, characterized in that The method further comprises: In response to the number of processed pixels in the pixels corresponding to the reconstructed pixel group satisfying a specified condition, accumulating the third array into the second array; The specified conditions include the following conditions: The number of processed pixels reaches a specified value; Alternatively, the number of processed pixels is equal to the number of pixels corresponding to the reconstructed pixel group.
11. The method according to claim 10, characterized in that The value of M is 32, and the bit width of the assembly instruction set is 256; and the step of accumulating the third array to the second array includes: Obtain the difference statistical vectors corresponding to the four unprocessed pixel categories in the third array; The difference statistical vectors corresponding to the four pixel classifications are respectively multiplied and added with the second template vector to obtain first difference representation vectors corresponding to the four pixel classifications; the second template vector is composed of M / 2 16-bit vector elements, and the value of each 16-bit vector element in the second template vector is 1; Taking the two first difference representation vectors as a group, taking 32 bits as a vector element, performing addition processing on the shaping vectors in the horizontal direction, and obtaining two second difference representation vectors; Taking 32 bits as one vector element, performing a shaping vector addition process on two second difference representation vectors in a horizontal direction to obtain a third difference representation vector; Taking 32 bits as one vector element, performing an addition process of the first half and the second half of the third difference representation vector as the shaping vector, to obtain a fourth difference representation vector; the four 32-bit vector elements included in the fourth difference representation vector are respectively the sums of the pixel value differences of the four pixel categories; The sum of the pixel value differences of the four pixel categories is accumulated into the second array, corresponding to the array positions of the four pixel categories.
12. A data processing device for video encoding and decoding, characterized in that: The device is run based on an assembly instruction set, and the device includes: A first acquisition module is used to acquire a reconstructed pixel group and a pixel difference group corresponding to the reconstructed pixel group; the reconstructed pixel group includes pixel values of N reconstructed pixels in a video frame; the pixel difference group includes pixel value differences of the N reconstructed pixels; the pixel value difference is a difference between a pixel value of the reconstructed pixel and a pixel value of an original pixel corresponding to the reconstructed pixel; the pixel value is represented by 8 bits, and the pixel value difference is represented by 16 bits; A loop module, for looping the following steps until the data in the reconstructed pixel group and the pixel difference group are processed: reading pixel values of M pixels from the reconstructed pixel group to obtain a first vector, and reading pixel value differences corresponding to the M pixels from the pixel difference group to obtain a second vector and a third vector; M is the bit width / 8 of the assembly instruction set; the first vector is composed of the pixel values of the M pixels connected end to end; the second vector is composed of the pixel value differences corresponding to the first M / 2 pixels of the M pixels connected end to end; the third vector is composed of the pixel value differences corresponding to the last M / 2 pixels of the M pixels connected end to end; based on the first vector, the second vector and the third vector, obtaining the number of pixel values belonging to each pixel classification in the pixel values of the M pixels, and the pixel value differences belonging to each pixel classification in the pixel value differences corresponding to the M pixels; A second acquisition module is used to acquire the band compensation statistical information of the reconstructed pixel group in response to the data in the reconstructed pixel group and the pixel difference group being processed; the band compensation statistical information includes a first array and a second array; the first array is used to record the number of pixel values belonging to each pixel classification in the reconstructed pixel group; the second array is used to indicate the sum of the pixel value differences belonging to each pixel classification in the pixel difference group.
13. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the data processing method for video encoding and decoding as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the computer program is loaded and executed by the processor to implement the data processing method for video encoding and decoding as described in any one of claims 1 to 11.
15. A computer program product, characterized in that The computer program product comprises a computer program, which is stored in a computer-readable storage medium; the computer program is read and executed by a processor of a computer device to implement the data processing method for video encoding and decoding as claimed in any one of claims 1 to 11.
Citation Information
Patent Citations
Statistical method for offset of SAO (Session-At-Once) mode in H.265 video coding
CN104486630A
Method and device for compensating video coding
CN108810543A
Method and device for sampling point self-adaptive compensation, equipment and medium
CN113068037A
Image processing method of Gaussian mixture model based on FPGA
CN114693504A
Artificial rainfall apparatus for removing dust particles
KR1020200122152A
