DATA PROCESSING METHOD AND DEVICE FOR EDGE OFFSET MODE BASED ON SAMPLING-ADAPTIVE OFFSET
Patent Information
- Application Number
- DE602022027067
- Authority / Receiving Office
- DE · DE
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2021-02-24
- Filing Date
- 2022-01-20
- Publication Date
- 2025-12-17
- Estimated Expiration
- 2042-01-20
AI Technical Summary
The existing methods for calculating pixel categories and residuals in the edge offset mode of sample adaptive offset (SAO) are time-consuming, necessitating the reading of reconstructed pixels multiple times, which significantly affects performance.
A method and apparatus for data processing in the edge offset mode of SAO that involves dividing a target reconstructed image into non-overlapping coding tree blocks, traversing pixels to calculate residual values and categories, and accumulating residual values and pixel counts based on predefined categories, reducing the number of times pixels need to be read.
This approach significantly reduces computing time by completing the calculation of pixel categories in the edge offset modes in less than a quarter of the previous time, thereby enhancing processing efficiency.
Description
Technical Field
[0001] The present application relates to the field of data processing technologies in an edge offset mode of sample adaptive offset, and in particular, to a method and apparatus for data processing in an edge offset mode of sample adaptive offset, a computer-readable storage medium, and a computer program product.Background
[0002] High Efficiency Video Coding (HEVC) is a video compression standard. After a video is compressed through HEVC, to reduce a distortion between a reconstructed image and an original image, pixel compensation is performed on the reconstructed image by using a sample adaptive offset (SAO) technology.
[0003] When pixel compensation is performed by using the SAO technology, pixel compensation may be implemented in an edge offset (EO) mode or a band offset (BO) mode. The EO technology categorizes a current reconstructed pixel by comparing a size of the current reconstructed pixel with a size of an adjacent pixel. Based on position differences of pixels to be selected, the edge offset is implemented along four directions: a horizontal direction (EO0), a vertical direction (EO1), a 135° direction (EO2), and a 45° direction (EO3).
[0004] In the implementation process of the existing EO mode, a separate function will be written for each EO direction, that is, four functions need to be written for the four EO directions, and each function is used to complete the calculation of a category of a pixel in the corresponding direction, and implement a process of calculating residuals and the number.
[0005] In US2014334536A1, a method for signaling sample adaptive offset (SAO) band offset syntax elements in a video encoder is provided that includes receiving a plurality of band offset syntax elements, entropy encoding an absolute value of a magnitude of each band offset syntax element in a compressed video bit stream, and entropy encoding a sign of each non-zero band offset syntax element in the compressed video bit stream following the absolute values of the magnitudes.
[0006] In EP3177014A1, provided is a video encoding apparatus comprising an encoder configured to generate encoded video data by encoding an input video; a decoder configured to decode video data to which a filter to compensate for a pixel value is to be applied, wherein the video data is from the encoded video data; an adaptive loop filter (ALF) parameter predictor configured to generate an ALF filter parameter by using information of the decoded video data, wherein the ALF filter parameter is configured to be applied to an ALF filter to compensate for a value of a current pixel by using a value of a neighboring pixel adjacent to the current pixel and a filter coefficient with respect to the neighboring pixel; a sample adaptive offset (SAO) filter unit configured to apply a SAO filter to the decoded video data, wherein the SAO filter compensates for a value of a current pixel by using at least one of an edge offset and a band offset; an ALF filter unit configured to apply, by using the ALF filter parameter, the ALF filter to video data to which the SAO filter has been applied; and an entropy encoder configured to perform entropy encoding on the ALF filter parameter.
[0007] In US2015010052A1, an apparatus for sample adaptive offset (SAO) filtering in video encoding is provided. A unified processing engine collects statistics on a block of pixels, determines a minimum RD cost (J) for each category of band offsets and edge offsets; determines a RD cost to find the optimal SAO type and determines a cost for each of the left SAO parameters and the up SAO parameters. The unified processing engine operates for three iterations: once for luminance once for each chrominance. A SAO merge decision unit determines an optimal mode and generates current LCU Parameters. The RD offset unit determination includes determining whether the sign of the minimum offset is proper for the category of edge offset. The RD offset is determined using a programmable look-up table indexed by the offset to estimate a rate. The unified processing engine operates on a three stage pipeline: loading blocks; processing; and updating blocks.
[0008] In CHIH-MING FU ET AL:"Sample Adaptive Offset in the HEVC Standard", IEEE TRANSACTIONS ON CIRCUITS AND SYSTEMS FOR VIDEO TECHNOLOGY, IEEE, USA, vol. 22, no. 12, 1 December 2012 (2012-12-01), pages 1755-1764, an overview on sample adaptive offset filtering in accordance with the HEVC standard is provided.
[0009] However, the inventors found that, in such method, it is necessary to read a reconstructed pixel four times, which will consume a lot of time and seriously affect the performance of SAO.Summary
[0010] In view of this, a method and apparatus for data processing in an edge offset mode of sample adaptive offset, a computer-readable storage medium and a computer program product are currently provided, to resolve a problem that the calculation of a category of each pixel in an EO mode along each direction and residuals and the number is time-consuming.
[0011] The present application provides a method for data processing in an edge offset mode of sample adaptive offset, including: obtaining a target reconstructed image, and dividing the target reconstructed image into a plurality of non-overlapping coding tree blocks; traversing all reconstructed pixels in each coding tree block, and calculating a residual value between each reconstructed pixel and a corresponding original pixel, wherein the coding tree block comprises a boundary part and a non-boundary part, wherein the boundary part comprises an uppermost row, a lowermost row, a leftmost column, and a rightmost column in the coding tree block, wherein the non-boundary part comprises a part of the coding tree block except the uppermost row, the lowermost row, the leftmost column, and the rightmost column, and wherein a pixel in the non-boundary part is a first reconstructed pixel and a pixel in the boundary part is a second reconstructed pixel; traversing all first reconstructed pixels in the non-boundary part of the coding tree block, determining a category of each traversed first reconstructed pixel in each of edge offset modes along four directions, where the four directions include a horizontal direction, a vertical direction, a 135° direction, and a 45° direction, and wherein the determined category is one of a category 0, a category 1, a category 2, a category 3, and a category 4, and wherein the category 1 indicates that a pixel value of a reconstructed pixel currently to be calculated is less than pixel values of two reference pixels, the category 2 indicates that a pixel value of a reconstructed pixel currently to be calculated is equal to a pixel value of one of the reference pixels and less than a pixel value of the other reference pixel, the category 3 indicates that a pixel value of a reconstructed pixel currently to be calculated is equal to a pixel value of one of the reference pixels and greater than a pixel value of the other reference pixel, the category 4 indicates that a pixel value of a reconstructed pixel currently to be calculated is greater than pixel values of the two reference pixels, the category 0 indicates that a pixel value does not belong to any of the category 1, the category 2, the category 3, and the category 4, and storing the category of each first reconstructed pixel in each of the edge offset modes along the four directions into a variable represented by 4M bits, wherein the category of each first reconstructed pixel along each of the four directions is represented by M bits and M is an integer greater than or equal to 3; traversing all second reconstructed pixels in the boundary part of the coding tree block, determining a category of each traversed second reconstructed pixel in an edge offset mode along a single direction from the horizontal direction and the vertical direction, wherein if the second reconstructed pixel is a pixel in the uppermost row or the lowermost row, the single direction is the horizontal direction, and if the second reconstructed pixel is a pixel in the leftmost column or the rightmost column, the single direction is the vertical direction, and storing the category of each second reconstructed pixel in the edge offset mode along the single direction into the variable represented by 4M bits, wherein the category of each second reconstructed pixel along the single direction from the four directions is represented by M bits and M is an integer greater than or equal to 3, wherein a category of each second reconstructed pixel in each of the edge offset modes along the other directions from the four directions except for the single direction is represented by a preset value, and wherein the preset value is set to be different from values of the categories; obtaining, from the variable, the categories of all the reconstructed pixels in the edge offset modes along the four directions; calculating the accumulated residual values of reconstructed pixels under each of the different categories in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value; and calculating the accumulated numbers of reconstructed pixels under each of the different categories in each of the edge offset modes along the four directions, based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, and the category of each second reconstructed pixel in the edge offset mode along the single direction.
[0012] Optionally, there are five categories, each category is represented by four bits, and the categories of each reconstructed pixel in the edge offset modes along the four directions are represented by 16 bits.
[0013] Optionally, the obtaining, from the variable, the categories of all the reconstructed pixels in the edge offset modes along the four directions includes: performing an and operation on the variable and a preset 16-bit value, and using an operation result as a category, stored in the variable, of each reconstructed pixel in an edge offset mode along one direction; performing a 4-bit shift on the variable to obtain an updated variable; performing an and operation on the updated variable and the preset 16-bit value, and using an operation result as a category of the reconstructed pixel in an edge offset mode along another direction; and returning to perform the step of performing a 4-bit shift on the variable to obtain an updated variable, until the categories of each reconstructed pixel in the edge offset modes along all the directions are obtained.
[0014] Optionally, the preset 16-bit value is 0x000f, and the performing a 4-bit shift on the categories, represented by 16 bits, of each obtained reconstructed pixel in the edge offset modes along the four directions to obtain categories after the shift includes: performing a 4-bit right shift on the categories, represented by 16 bits, of each obtained reconstructed pixel in the edge offset modes along the four directions to obtain categories after the right shift.
[0015] Optionally, the preset 16-bit value is 0xf000, and the performing a 4-bit shift on the categories, represented by 16 bits, of each obtained reconstructed pixel in the edge offset modes along the four directions to obtain categories after the shift includes: performing a 4-bit left shift on the categories, represented by 16 bits, of each obtained reconstructed pixel in the edge offset modes along the four directions to obtain categories after the left shift.
[0016] Optionally, the step of obtaining an accumulated residual value by accumulating each residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value includes: calculating an accumulated residual value of reconstructed pixels under each of all the categories except a preset category in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value.
[0017] The present application further provides an apparatus for data processing in an edge offset mode of sample adaptive offset, including: an obtaining means configured to obtain a target reconstructed image, and divide the target reconstructed image into a plurality of non-overlapping coding tree blocks; a first traversal means configured to traverse all reconstructed pixels in each coding tree block, and calculate a residual value between each reconstructed pixel and a corresponding original pixel, wherein the coding tree block comprises a boundary part and a non-boundary part, wherein the boundary part comprises an uppermost row, a lowermost row, a leftmost column, and a rightmost column in the coding tree block, wherein the non-boundary part comprises a part of the coding tree block except the uppermost row, the lowermost row, the leftmost column, and the rightmost column, and wherein a pixel in the non-boundary part is a first reconstructed pixel and a pixel in the boundary part is a second reconstructed pixel; a second traversal means configured to traverse all first reconstructed pixels in the non-boundary part of the coding tree block, determine a category of each traversed first reconstructed pixel in each of edge offset modes along four directions, where the four directions include a horizontal direction, a vertical direction, a 135° direction, and a 45° direction, and wherein the determined category is one of a category 0, a category 1, a category 2, a category 3, and a category 4, and wherein the category 1 indicates that a pixel value of a reconstructed pixel currently to be calculated is less than pixel values of two reference pixels, the category 2 indicates that a pixel value of a reconstructed pixel currently to be calculated is equal to a pixel value of one of the reference pixels and less than a pixel value of the other reference pixel, the category 3 indicates that a pixel value of a reconstructed pixel currently to be calculated is equal to a pixel value of one of the reference pixels and greater than a pixel value of the other reference pixel, the category 4 indicates that a pixel value of a reconstructed pixel currently to be calculated is greater than pixel values of the two reference pixels, the category 0 indicates that a pixel value does not belong to any of the category 1, the category 2, the category 3, and the category 4, and store the category of each first reconstructed pixel in each of the edge offset modes along the four directions into a variable represented by 4M bits, wherein the category of each first reconstructed pixel along each of the four directions is represented by M bits and M is an integer greater than or equal to 3; a third traversal means configured to traverse all second reconstructed pixels in the boundary part of the coding tree block, and determine a category of each traversed second reconstructed pixel in an edge offset mode along a single direction from the horizontal direction and the vertical direction, wherein if the second reconstructed pixel is a reconstructed pixel in the uppermost row or the lowermost row, the single direction is the horizontal direction, and if the second reconstructed pixel is a reconstructed pixel in the leftmost column or the rightmost column, the single direction is the vertical direction, and store the category of each second reconstructed pixel in the edge offset mode along the single direction into the variable represented by 4M bits, wherein the category of each second reconstructed pixel along the single direction from the four directions is represented by M bits and M is an integer greater than or equal to 3, wherein a category of each second reconstructed pixel in each of the edge offset modes along the other directions from the four directions except for the single direction is represented by a preset value, and wherein the preset value is set to be different from values of the categories; and a calculation means configured to: obtain, from the variable, the categories of all the reconstructed pixels in the edge offset modes along the four directions; calculate the accumulated residual values of reconstructed pixels under each of the different categories in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value; and calculate the accumulated numbers of reconstructed pixels under each of the different categories in each of the edge offset modes along the four directions, based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, and the category of each second reconstructed pixel in the edge offset mode along the single direction.
[0018] The present application further provides a computer-readable storage medium having computer-readable instructions stored thereon, where when the computer-readable instructions are executed by a processor, the steps of the method as described above are implemented.
[0019] The present application further provides a computer program product comprising instructions which, when executed by a computer, cause the computer to carry out the method as described above.
[0020] The above technical solutions have the beneficial effects as follows.
[0021] In the embodiments of the present application, a target reconstructed image is obtained, and the target reconstructed image is divided into a plurality of non-overlapping coding tree blocks; all reconstructed pixels in each coding tree block are traversed, and a residual value between each reconstructed pixel and a corresponding original pixel is calculated; all first reconstructed pixels in a non-boundary part of the coding tree block are traversed, and a category of each traversed first reconstructed pixel in each of edge offset modes along four directions is calculated, where the four directions include a horizontal direction, a vertical direction, a 135° direction, and a 45° direction; all second reconstructed pixels in a boundary part of the coding tree block are traversed, and a category of each traversed second reconstructed pixel in an edge offset mode along a single direction is calculated; and an accumulated residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions and an accumulated number of reconstructed pixels under the category are calculated based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value. In the embodiments of the present application, the categories of each reconstructed pixel in the edge offset modes along the four directions are calculated at a time, so that the calculation of the categories of each reconstructed pixel in the edge offset modes along the four directions can be completed by spending a little more time than 1 / 4 of that spent before, greatly reducing the computing time.Brief Description of the Drawings
[0022] FIG. 1 is a schematic diagram of an environment for a method for data processing in an edge offset mode of sample adaptive offset according to an embodiment of the present application; FIG. 2 is a flowchart of an embodiment of a method for data processing in an edge offset mode of sample adaptive offset according to the present application; FIG. 3 is a schematic diagram of edge offset modes along four directions according to the present application; FIG. 4 is a detailed schematic flowchart of a step of calculating an accumulated residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value, according to an implementation of the present application; FIG. 5 is a diagram of program means of an embodiment of an apparatus for data processing in an edge offset mode of sample adaptive offset according to the present application; and FIG. 6 is a schematic diagram of a hardware structure of a computer device for performing a method for data processing in an edge offset mode of sample adaptive offset according to an embodiment of the present application. Detailed Description
[0023] The advantages of the present application are further described below with reference to accompanying drawings and specific embodiments.
[0024] Exemplary embodiments are illustrated in detail here, and examples thereof are shown in the accompanying drawings. When the following description refers to the figures, the same numerals in different figures represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure. Instead, they are merely examples of apparatuses and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0025] The terms used in the present disclosure are merely for the purpose of describing specific embodiments, and are not intended to limit the present disclosure. The terms "a / an", "said", and "the" in the singular form used in the present disclosure and the appended claims are also intended to include the plural form unless otherwise clearly indicated in the context. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0026] It should be understood that although the terms, such as first, second, and third, may be used in the present disclosure to describe various types of information, such information should not be limited to these terms. These terms are merely used to distinguish the same type of information from one another. For example, without departing from the scope of the present disclosure, first information may alternatively be referred to as second information, and similarly, second information may alternatively be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when" or "upon" or "in response to determining".
[0027] In the description of the present application, it should be understood that, the reference numerals of steps do not indicate the order of execution of the steps, but are merely to facilitate the description of the present application and differentiation between the steps, and thus will not be interpreted as limiting the present application.
[0028] FIG. 1 is a schematic architectural diagram of a method for data processing in an edge offset mode of sample adaptive offset according to an embodiment of the present application. In an exemplary embodiment, a system of the application environment may include a computer device 10 and a server 20. A wireless or wired connection is formed between the computer device 10 and the server 20. The computer device 10 may be a mobile phone, an iPad, a tablet computer, a server, or the like. The sever 20 may be a rack server, a blade server, a tower server, or a cabinet server (including an independent server or a server cluster that includes a plurality of servers).
[0029] FIG. 2 is a schematic flowchart of a method for data processing in an edge offset mode of sample adaptive offset according to an embodiment of the present application. It may be understood that the flowchart in this method embodiment is not intended to limit an execution sequence of the steps. The following gives exemplary description by using a computer device as an execution body. It can be learned from the figure that the method for data processing in an edge offset mode of sample adaptive offset in this embodiment includes the following steps.
[0030] In step S20, a target reconstructed image is obtained, and the target reconstructed image is divided into a plurality of non-overlapping coding tree blocks.
[0031] Specifically, the target reconstructed image is an image obtained after a reconstructed image is deblocked, and is a frame of reconstructed image.
[0032] In this embodiment, when the target reconstructed image is divided into coding tree blocks, the entire frame of image is divided into blocks based on a size of a coding tree unit (CTU) preset by an encoder. For example, a size of the target reconstructed image is 128*128, and the size of the CTU is 64*64. In this case, the target reconstructed image may be divided into four non-overlapping coding tree blocks.
[0033] In step S21, all reconstructed pixels in each coding tree block are traversed, and a residual value between each reconstructed pixel and a corresponding original pixel is calculated.
[0034] Specifically, a coding tree block (CTB) may be a luma CTB or a chroma CTB included in a coding tree unit (CTU) in a sample adaptive offset (SAO) technology in HEVC. A coding tree block includes a plurality of reconstructed pixels.
[0035] It should be noted that a reconstructed pixel is a pixel obtained after each pixel in an original image is restored.
[0036] A residual value diff between each reconstructed pixel and a corresponding original pixel is a difference between a pixel value a of the reconstructed pixel and a pixel value b of the corresponding original pixel, that is, diff = a - b.
[0037] It can be understood that, in this embodiment of the present invention, to reduce a data processing time, residual values of all reconstructed pixels in the coding tree block may be calculated in advance, instead of calculating the residual values when the values need to be used.
[0038] In step S22, all first reconstructed pixels in a non-boundary part of the coding tree block are traversed, and a category of each traversed first reconstructed pixel in each of edge offset modes along four directions is calculated, where the four directions include a horizontal direction, a vertical direction, a 135° direction, and a 45° direction.
[0039] Specifically, the non-boundary part is relative to the boundary part, where the boundary part refers to the uppermost row, the lowermost row, the leftmost column, and the rightmost column in the coding tree block, and correspondingly, the non-boundary part is the part of the coding tree block except the uppermost row, the lowermost row, the leftmost column, and the rightmost column.
[0040] In this embodiment, all the first reconstructed pixels in the non-boundary part are all pixels in the coding tree block except the pixels in the uppermost row, the lowermost row, the leftmost column, and the rightmost column.
[0041] The edge offset (EO) mode may be specifically divided into edge offset modes along four directions, namely, a horizontal direction (EO0), a vertical direction (EO1), a 135° direction (EO2), and a 45° direction (EO3).
[0042] As an example, the edge offset modes along the four directions are shown in FIG. 3. In FIG. 3, c represents a reconstructed pixel currently to be calculated, and a and b represent reference pixels of the reconstructed pixel currently to be calculated.
[0043] In each edge offset mode, each reconstructed pixel in the coding tree block may be classified into five different categories, namely, category0, category1, category2, category3, and category4, that is, a category 0, a category 1, a category 2, a category 3, and a category 4. The category 1 indicates that a pixel value of the reconstructed pixel currently to be calculated is less than pixel values of the two reference pixels, this category belongs to Positive offset, and an offset value is greater than or equal to 0. The category 2 indicates that a pixel value of the reconstructed pixel currently to be calculated is equal to a pixel value of one of the reference pixels and less than a pixel value of the other reference pixel, this category belongs to Positive offset, and an offset value is greater than or equal to 0. The category 3 indicates that a pixel value of the reconstructed pixel currently to be calculated is equal to a pixel value of one of the reference pixels and greater than a pixel value of the other reference pixel, this category belongs to Negative offset, and an offset value is less than or equal to 0. The category 4 indicates that a pixel value of the reconstructed pixel currently to be calculated is greater than pixel values of the two reference pixels, this category belongs to Negative offset, and an offset value is less than or equal to 0. The category 0 indicates that a pixel value of the reconstructed pixel currently to be calculated falls outside of the above four cases, and a reconstructed pixel belonging to this category does not need pixel compensation.
[0044] In this embodiment, after each first reconstructed pixel is traversed, the categories of the first reconstructed pixel in the edge offset modes along the four directions can be calculated at a time by using one preset function, without a need to use a plurality of functions to calculate the categories in the edge offset modes along the directions.
[0045] In step S23, all second reconstructed pixels in a boundary part of the coding tree block are traversed, and a category of each traversed second reconstructed pixel in an edge offset mode along a single direction is calculated.
[0046] Specifically, since a pixel in the boundary part has an edge offset mode along only one direction, to calculate a category of each second reconstructed pixel, it is only necessary to calculate the category of the second pixel in the edge offset mode along the corresponding direction. For example, if a second reconstructed pixel currently to be calculated is a pixel in the uppermost row of the boundary part, because a pixel in the uppermost row has only the edge offset mode along the horizontal direction (EO0), only a category in the edge offset mode along the horizontal direction may be calculated for the second reconstructed pixel in the uppermost row. If a second reconstructed pixel currently to be calculated is a pixel in the lowermost row of the boundary part, because a pixel in the lowermost row also has only the edge offset mode along the horizontal direction, only a category in the edge offset mode along the horizontal direction may be calculated for the second reconstructed pixel in the lowermost row. If a second reconstructed pixel currently to be calculated is a pixel in the leftmost column of the boundary part, because a pixel in the leftmost column has only the edge offset mode along the vertical direction (EO1), only a category in the edge offset mode along the vertical direction may be calculated for the second reconstructed pixel in the leftmost column. If a second reconstructed pixel currently to be calculated is a pixel in the rightmost column of the boundary part, because a pixel in the rightmost column also has only the edge offset mode along the vertical direction (EO1), only a category in the edge offset mode along the vertical direction may be calculated for the second reconstructed pixel in the rightmost column.
[0047] It can be understood that categories of the second pixels in the boundary part in the edge offset modes along the other directions may not be calculated. Alternatively, to ensure that each pixel has categories in all the edge offset modes along the four directions, the categories of the second pixels in the boundary part in the edge offset modes along the other directions may be represented by a preset value. It can be understood that the preset value cannot be the same as values representing the categories in the edge offset modes.
[0048] In step S24, an accumulated residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions and an accumulated number of reconstructed pixels under the category are calculated based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value.
[0049] Specifically, the accumulated residual value is an accumulated sum of residual values between all reconstructed pixels under the same category in the edge offset mode along each direction and their corresponding original pixels. In other words, the accumulated residual value includes an accumulated sum of residual values between all reconstructed pixels under the category 0 in the EO0 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 1 in the EO0 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 2 in the EO0 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 3 in the EO0 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 4 in the EO0 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 0 in the EO1 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 1 in the EO1 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 2 in the EO1 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 3 in the EO1 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 4 in the EO1 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 0 in the EO2 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 1 in the EO2 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 2 in the EO2 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 3 in the EO2 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 4 in the EO2 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 0 in the EO3 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 1 in the EO3 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 2 in the EO3 mode and their corresponding original pixels, an accumulated sum of residual values between all reconstructed pixels under the category 3 in the EO3 mode and their corresponding original pixels, and an accumulated sum of residual values between all reconstructed pixels under the category 4 in the EO3 mode and their corresponding original pixels.
[0050] The accumulated number is the number of all reconstructed pixels under the same category in the edge offset mode along each direction. For example, if there are eight reconstructed pixels under the category 0 in the EO0 mode, the accumulated number is 8; and if there are five reconstructed pixels under the category 2 in the EO1 mode, the accumulated number is 5.
[0051] In this embodiment, to calculate an accumulated residual value of reconstructed pixels under each category in each EO mode, the reconstructed pixels may be found first, then corresponding residual values of the found pixels are found from the calculated residual values, and finally, all the corresponding residual values are accumulated to obtain the accumulated residual value under the category x (x is 0, 1, 2, 3, or 4) in the EO mode, and the number of pixels is calculated at the same time.
[0052] As an example, assuming that there are eight reconstructed pixels under the category 0 in the EO0 mode, and residual values between the eight reconstructed pixels and their corresponding original pixels are 5, 8, 7, 6, 4, 3, 12, and 9, the accumulated residual value = 5 + 8 + 7 + 6 + 4 + 3 + 12 + 9 = 54, and the accumulated number is 8; and assuming that there are five reconstructed pixels under the category 2 in the EO1 mode, and residual values between the five reconstructed pixels and their corresponding original pixels are 5, 8, 7, 6, and 4, the accumulated residual value = 5 + 8 + 7 + 6 + 4 = 30, and the accumulated number is 5.
[0053] In this embodiment of the present application, all reconstructed pixels in each coding tree block are traversed, and a residual value between each reconstructed pixel and a corresponding original pixel is calculated; all first reconstructed pixels in a non-boundary part of the coding tree block are traversed, and a category of each traversed first reconstructed pixel in each of edge offset modes along four directions is calculated, where the four directions include a horizontal direction, a vertical direction, a 135° direction, and a 45° direction; all second reconstructed pixels in a boundary part of the coding tree block are traversed, and a category of each traversed second reconstructed pixel in an edge offset mode along a single direction is calculated; and an accumulated residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions and an accumulated number of reconstructed pixels under the category are calculated based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value. In the embodiments of the present application, the categories of each reconstructed pixel in the edge offset modes along the four directions are calculated at a time, so that the calculation of the categories of each reconstructed pixel in the edge offset modes along the four directions can be completed by spending a little more time than 1 / 4 of that spent before, greatly reducing the computing time.
[0054] According to experimental statistics, through the calculation method of the present application, the EO means can be accelerated by about 32.8%, and can be accelerated by about 3.28% when applied to live streaming scenarios, reducing a live streaming delay.
[0055] In an exemplary implementation, referring to FIG. 4, the step of calculating an accumulated residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value may include steps S40 to S42.
[0056] In step S40, all the first reconstructed pixels are traversed, and the category of each first reconstructed pixel in each of the edge offset modes along the four directions are stored into a variable in a concatenation manner.
[0057] Specifically, the category of each first reconstructed pixel in each EO direction may be represented by m bits, since there are only five categories in total, a minimum value of m in this embodiment may be 3, that is, each of the five categories may be represented at least by a 3-bit value, and in this case, the categories of each pixel in the four EO directions may be fully represented by only 12 bits.
[0058] It can be understood that, in a computer system, a piece of data is represented by 12 bits, which is inconvenient during processing. Therefore, in this embodiment, to facilitate subsequent processing of category data, the value of m is preferably 4, that is, the categories of each reconstructed pixel in the four EO directions are represented by a 16-bit value. Certainly, in other implementations of the present application, the value of m may alternatively be 8, and the categories in the four EO directions are represented by a 32-bit value. In this implementation, the value of m is not limited.
[0059] As an example, when the value of m is 4, the category of each first reconstructed pixel in each of the edge offset modes along the four directions may be stored into a 16-bit variable in a concatenation manner, for example, stored into a 16-bit variable et in a concatenation manner. It should be noted that the variable may be a global variable or a local variable, which is not limited in this embodiment.
[0060] In step S41, the category of each first reconstructed pixel in each of the edge offset modes along the four directions is obtained from the variable.
[0061] Specifically, since the variable includes the categories of each first reconstructed pixel in the edge offset modes along the four directions, information about the categories may be directly extracted when needed.
[0062] In step S42, an accumulated residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions is calculated based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value.
[0063] Specifically, this step is the same as step S23, and will not be described in detail in this embodiment.
[0064] In this embodiment, the category values of each first reconstructed pixel in the four EO modes are combined into one variable, so that an amount of data to be stored and transmitted can be reduced.
[0065] In an exemplary implementation, the calculating an accumulated residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value may further include: traversing all the second reconstructed pixels, and storing the category of each second reconstructed pixel in the edge offset mode along the single direction into the variable in a concatenation manner, where a category of each second reconstructed pixel in each of the edge offset modes along the other directions is represented by a preset value.
[0066] Specifically, to facilitate subsequent processing of the category information of all reconstructed pixels, in this embodiment, category information of each second reconstructed pixel in the edge offset mode along only a single direction may also be concatenated to have a value with the same bits as the category information of the first reconstructed pixel, and the concatenated category information is also stored into the variable.
[0067] The single direction refers to an EO mode of a current second reconstructed pixel. Specifically, if the current second reconstructed pixel is a pixel in the uppermost row or the lowermost row, the single direction is the horizontal direction (EO0); or if the current second reconstructed pixel is a pixel in the leftmost column or the rightmost column, the single direction is the vertical direction (EO1).
[0068] The other directions are directions of the current second reconstructed pixel different from the single direction. Specifically, if the current second reconstructed pixel is a pixel in the uppermost row or the lowermost row, the other directions are the vertical direction (EO1), the 135° direction (EO2), and the 45° direction (EO3); or if the current second reconstructed pixel is a pixel in the leftmost column or the rightmost column, the other directions are the horizontal direction (EO0), the 135° direction (EO2), and the 45° direction (EO3).
[0069] As an example, assuming that each category is represented by four bits, the category in the EO0 mode is represented by the 1 st< bit to the 4 th< bit in the variable, the category in the EO1 mode is represented by the 5 th< bit to the 8 th< bit in the variable, the category in the EO2 mode is represented by the 9 th< bit to the 12 th< bit in the variable, and the category in the EO3 mode is represented by the 13 th< bit to the 16 th< bit in the variable, the category of each second reconstructed pixel in the edge offset mode along a single direction may be stored at corresponding positions in the variable in a concatenated manner when category concatenation is performed, and the preset value is added to the other positions in the variable. For example, if the category is the category of the second reconstructed pixel in the EO0 mode, a value representing the category may be added to the 1 st< bit to the 4 th< bit in the variable, and the other bits in the variable may be represented by the preset value. For another example, if the category is the category of the second reconstructed pixel in the EO1 mode, a value representing the category may be added to the 5 th< bit to the 8 th< bit in the variable, and the other bits in the variable may also be represented by the preset value.
[0070] It should be noted that the preset value is a preset or default value, and the preset value needs to be different from the values of the categories, for example, if the values corresponding to the five categories are 0, 1, 2, 3, and 4, the preset value may be 5, 6, 7, 8, etc.
[0071] The obtaining, from the variable, the category of each first reconstructed pixel in each of the edge offset modes along the four directions includes: obtaining, from the variable, the categories of all the reconstructed pixels in the edge offset modes along the four directions.
[0072] Specifically, when the variable includes categories of a first reconstructed pixel and a second reconstructed pixel, the categories of all the reconstructed pixels in the edge offset modes along the four directions can be obtained from the variable when the categories need to be obtained.
[0073] In an exemplary implementation, the obtaining, from the variable, the categories of all the reconstructed pixels in the edge offset modes along the four directions may include: performing an and operation on the variable and a preset 16-bit value, and using an operation result as a category, stored in the variable, of each reconstructed pixel in an edge offset mode along one direction; performing a 4-bit shift on the variable to obtain an updated variable; performing an and operation on the updated variable and the preset 16-bit value, and using an operation result as a category of the reconstructed pixel in an edge offset mode along another direction; and returning to perform the step of performing a 4-bit shift on the variable to obtain an updated variable, until the categories of each reconstructed pixel in the edge offset modes along all the directions are obtained.
[0074] Specifically, the preset 16-bit value may be 0x000f or 0xf000.
[0075] As an example, when the preset 16-bit value is 0x000f, an "& (and)" operation can be performed on the variable et and 0x000f to obtain the four least significant bits of the original variable et, so that a category of each reconstructed pixel in the EO0 mode is obtained from the variable et, and an accumulated residual value and an accumulated number for each category in the EO0 mode can be subsequently calculated separately. After the accumulated residual value and the accumulated number for each category in the EO0 mode are calculated, a 4-bit right shift can be performed on the variable et, and an "&" operation can be performed on the shifted variable et and 0x000f to obtain the 5 th< bit to the 8 th< bit of the original variable et, so that a category of each reconstructed pixel in the EO1 mode is obtained from the variable et, and an accumulated residual value and an accumulated number for each category in the EO1 mode can be subsequently calculated separately. After the accumulated residual value and the accumulated number for each category in the EO1 mode are calculated, a 4-bit right shift can continue to be performed on the variable et, and an "&" operation can be performed on the shifted variable et and 0x000f to obtain the 9 th< bit to the 12 th< bit of the original variable et, so that a category of each reconstructed pixel in the EO2 mode is obtained from the variable et, and an accumulated residual value and an accumulated number for each category in the EO2 mode can be subsequently calculated separately. After the accumulated residual value and the accumulated number for each category in the EO2 mode are calculated, a 4-bit right shift can continue to be performed on the variable et, and an "&" operation can be performed on the shifted variable et and 0x000f to obtain the 13 th< bit to the 16 th< bit of the original variable et, namely, the four most significant bits, so that a category of each reconstructed pixel in the EO3 mode is obtained from the variable et, and an accumulated residual value and an accumulated number for each category in the EO3 mode can be subsequently calculated separately.
[0076] In an exemplary implementation, when the preset 16-bit value is 0x000f, the performing a 4-bit shift on the variable to obtain an updated variable includes: performing a 4-bit right shift on the variable to obtain an updated variable.
[0077] As an example, if a category included in the variable is 0x378B, the category after the right shift is 0x0378.
[0078] It can be understood that when the shift is performed, all the categories included in the variable need to be shifted.
[0079] In an exemplary implementation, when the preset 16-bit value is 0xf000, the performing a 4-bit shift on the variable to obtain an updated variable includes: performing a 4-bit left shift on the variable to obtain an updated variable.
[0080] As an example, if a category included in the variable is 0x378B, the category after the left shift is 0x78B0.
[0081] It can be understood that when the shift is performed, all the categories included in the variable need to be shifted.
[0082] In an exemplary implementation, the step of calculating an accumulated residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value includes: calculating an accumulated residual value of reconstructed pixels under each of all the categories except a preset category in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value.
[0083] Specifically, the preset category is the category 0 in the above embodiment. In this embodiment, since pixel compensation does not need to be performed for the reconstructed pixels under the category 0, that is, the calculation results of the accumulated residual value and the accumulated number of the reconstructed pixels under the category 0 are useless. Therefore, in this embodiment, during the calculation of accumulated residual values, only the accumulated residual values for all the categories except the category 0 can be calculated to reduce the calculation amount, that is, an accumulated residual value of reconstructed pixels under the category 0 is not calculated.
[0084] FIG. 5 is a diagram of program means of an embodiment of an apparatus 50 for data processing in an edge offset mode of sample adaptive offset according to the present application.
[0085] In this embodiment, the apparatus 50 for data processing in an edge offset mode of sample adaptive offset includes a series of computer-readable instructions stored in a memory. When the computer-readable instructions are executed by a processor, the function for data processing in an edge offset mode of sample adaptive offset according to each embodiment of the present application can be implemented. In some embodiments, the apparatus 50 for data processing in an edge offset mode of sample adaptive offset may be divided into one or more means based on specific operations implemented by various parts of the computer-readable instructions. For example, in FIG. 5, the apparatus 50 for data processing in an edge offset mode of sample adaptive offset may be divided into an obtaining means 51, a first traversal means 52, a second traversal means 53, a third traversal means 54, and a calculation means 55.
[0086] The obtaining means 51 is configured to obtain a target reconstructed image, and divide the target reconstructed image into a plurality of non-overlapping coding tree blocks.
[0087] The first traversal means 52 is configured to traverse all reconstructed pixels in each coding tree block, and calculate a residual value between each reconstructed pixel and a corresponding original pixel.
[0088] The second traversal means 53 is configured to traverse all first reconstructed pixels in a non-boundary part of the coding tree block, and calculate a category of each traversed first reconstructed pixel in each of edge offset modes along four directions, where the four directions include a horizontal direction, a vertical direction, a 135° direction, and a 45° direction.
[0089] The third traversal means 54 is configured to traverse all second reconstructed pixels in a boundary part of the coding tree block, and calculate a category of each traversed second reconstructed pixel in an edge offset mode along a single direction.
[0090] The calculation means 55 is configured to calculate an accumulated residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions and an accumulated number of reconstructed pixels under the category based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value.
[0091] In an exemplary implementation, the calculation means 55 is further configured to: traverse all the first reconstructed pixels, and store the category of each first reconstructed pixel in each of the edge offset modes along the four directions into a variable in a concatenation manner; obtain, from the variable, the category of each first reconstructed pixel in each of the edge offset modes along the four directions; and calculate an accumulated residual value of reconstructed pixels under each of the different categories in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value.
[0092] In an exemplary implementation, the calculation means 55 is further configured to traverse all the second reconstructed pixels, and store the category of each second reconstructed pixel in the edge offset mode along the single direction into the variable in a concatenation manner, where a category of each second reconstructed pixel in each of the edge offset modes along the other directions is represented by a preset value.
[0093] The calculation means 55 is further configured to obtain, from the variable, the categories of all the reconstructed pixels in the edge offset modes along the four directions.
[0094] In an exemplary implementation, there are five categories, each category is represented by four bits, and the categories of each reconstructed pixel in the edge offset modes along the four directions are represented by 16 bits.
[0095] In an exemplary implementation, the calculation means 55 is further configured to: perform an and operation on the variable and a preset 16-bit value, and use an operation result as a category, stored in the variable, of each reconstructed pixel in an edge offset mode along one direction; perform a 4-bit shift on the variable to obtain an updated variable; perform an and operation on the updated variable and the preset 16-bit value, and use an operation result as a category of the reconstructed pixel in an edge offset mode along another direction; and return to perform the step of performing a 4-bit shift on the variable to obtain an updated variable, until the categories of each reconstructed pixel in the edge offset modes along all the directions are obtained.
[0096] In an exemplary implementation, when the preset 16-bit value is 0x000f, the calculation means 55 is further configured to perform a 4-bit right shift on the variable to obtain an updated variable.
[0097] In an exemplary implementation, when the preset 16-bit value is 0xf000, the calculation means 55 is further configured to perform a 4-bit left shift on the variable to obtain an updated variable.
[0098] In this embodiment of the present application, all reconstructed pixels in each coding tree block are traversed, and a residual value between each reconstructed pixel and a corresponding original pixel is calculated; all first reconstructed pixels in a non-boundary part of the coding tree block are traversed, and a category of each traversed first reconstructed pixel in each of edge offset modes along four directions is calculated, where the four directions include a horizontal direction, a vertical direction, a 135° direction, and a 45° direction, all second reconstructed pixels in a boundary part of the coding tree block are traversed, and a category of each traversed second reconstructed pixel in an edge offset mode along a single direction is calculated; and an accumulated residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions and an accumulated number of reconstructed pixels under the category are calculated based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value. In the embodiments of the present application, the categories of each reconstructed pixel in the edge offset modes along the four directions are calculated at a time, so that the calculation of the categories of each reconstructed pixel in the edge offset modes along the four directions can be completed by spending a little more time than 1 / 4 of that spent before, greatly reducing the computing time.
[0099] FIG. 6 is a schematic diagram of a hardware architecture of a computer device 10 suitable for performing a method for data processing in an edge offset mode of sample adaptive offset according to an embodiment of the present application. In this embodiment, the computer device 10 is a device that can automatically perform numerical calculation and / or information processing according to preset or prestored instructions. For example, the computer device may be a tablet computer, a notebook computer, a desktop computer, a rack server, a blade server, a tower server, a cabinet server (including an independent server, or a server cluster composed of a plurality of servers), etc. As shown in FIG. 6, the computer device 10 at least includes, but is not limited to: a memory 120, a processor 121, and a network interface 122, which may be communicatively linked to each other by using a system bus.
[0100] The memory 120 includes at least one type of computer-readable storage medium. The readable storage medium may be volatile or non-volatile. Specifically, the readable storage medium includes a flash memory, a hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disc, and the like. In some embodiments, the memory 120 may be an internal storage means of the computer device 10, for example, a hard disk or memory of the computer device 10. In some other embodiments, the memory 120 may alternatively be an external storage device of the computer device 10, for example, a plug-in type hard disk equipped on the computer device 10, a smart media card (SMC for short), a secure digital (SD for short) card, or a flash card. Certainly, the memory 120 may alternatively include both the internal storage means of the computer device 10 and the external storage device of the computer device. In this embodiment, the memory 120 is generally configured to store an operating system and various application software installed on the computer device 10, such as program code for a method for data processing in an edge offset mode of sample adaptive offset. In addition, the memory 120 may be further configured to temporarily store various types of data that have been output or are to be output.
[0101] In some embodiments, the processor 121 may be a central processing unit (CPU for short), a controller, a microcontroller, a microprocessor, or other chips for data processing in an edge offset mode of sample adaptive offset. The processor 121 is generally configured to control overall operation of the computer device 10, for example, execute control, processing, and the like related to data interaction or communication with the computer device 10. In this embodiment, the processor 121 is configured to run program code stored in the memory 120 or to process data.
[0102] The network interface 122may include a wireless network interface or a wired network interface. The network interface 122 is generally configured to establish a communication link between the computer device 10 and other computer devices. For example, the network interface 122 is configured to connect the computer device 10 to an external terminal by using a network, and establish a data transmission channel, a communication link, and the like between the computer device 10 and the external terminal. The network may be a wireless or wired network, such as Intranet, Internet, the Global System for Mobile Communications (GSM for short), wideband code division multiple access (WCDMA for short), a 4G network, a 5G network, Bluetooth, or Wi-Fi.
[0103] It should be noted that FIG. 6 shows only a computer device having components 120 to 122, but it should be understood that not all of the illustrated components are required to be implemented, and more or fewer components may be implemented instead.
[0104] In this embodiment, the method for data processing in an edge offset mode of sample adaptive offset stored in the memory 120 may alternatively be divided into one or more program means and executed by one or more processors (by the processor 121 in this embodiment) to implement the present application.
[0105] An embodiment of the present application provides a computer-readable storage medium having computer-readable instructions stored thereon, where when the computer-readable instructions are executed by a processor, the steps of the method for data processing in an edge offset mode of sample adaptive offset in the embodiments are implemented.
[0106] In this embodiment, the computer-readable storage medium includes a flash memory, a hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disc, and the like. In some embodiments, the computer-readable storage medium may be an internal storage unit of the computer device, for example, a hard disk or memory of the computer device. In some other embodiments, the computer-readable storage medium may alternatively be an external storage device of the computer device, for example, a plug-in type hard disk equipped on the computer device, a smart media card (SMC for short), a secure digital (SD for short) card, or a flash card. Certainly, the computer-readable storage medium may alternatively include both the internal storage unit of the computer device and the external storage device of the computer device. In this embodiment, the computer-readable storage medium is generally configured to store an operating system and various application software installed on the computer device, such as program code for a method for data processing in an edge offset mode of sample adaptive offset in the embodiments. In addition, the computer-readable storage medium may be configured to temporarily store various types of data that have been output or are to be output.
[0107] The apparatus embodiments described above are merely exemplary, where units illustrated as separate components may be or may not be physically separated, and the components illustrated as units may be or may not be physical units. That is, the components may be positioned at one place or distributed on at least two network units. The object of the solutions in the embodiments of the present application can be achieved by selecting some or all of the means therein according to actual needs. Those of ordinary skill in the art can understand and implement the solutions without any creative effort.
[0108] Through the descriptions of the above implementations, those of ordinary skill in the art can clearly understand that the implementations can be implemented by software and general hardware platforms. Definitely, the implementations can also be implemented by hardware. Those of ordinary skill in the art can understand that all or some of the procedures in the methods of the foregoing embodiments can be implemented by computer-readable instructions to instruct related hardware. The program can be stored in a computer-readable storage medium. The program, when executed, may include the procedures in the above method embodiments. The storage medium may be a magnetic disk, an optical disc, a read-only memory (ROM), or a random access memory (RAM).
[0109] Finally, it should be noted that the above embodiments are merely used for illustrating rather than limiting the technical solutions of the present application. The invention is set out in the appended claims.
Claims
1. A computer-implemented method for data processing in an edge offset mode of sample adaptive offset, comprising: obtaining (S20) a target reconstructed image, and dividing the target reconstructed image into a plurality of non-overlapping coding tree blocks; traversing (S21) all reconstructed pixels in each coding tree block, and calculating a residual value between each reconstructed pixel and a corresponding original pixel, wherein the coding tree block comprises a boundary part and a non-boundary part, wherein the boundary part comprises an uppermost row, a lowermost row, a leftmost column, and a rightmost column in the coding tree block, wherein the non-boundary part comprises a part of the coding tree block except the uppermost row, the lowermost row, the leftmost column, and the rightmost column, and wherein a pixel in the non-boundary part is a first reconstructed pixel and a pixel in the boundary part is a second reconstructed pixel; traversing (S22) all first reconstructed pixels in the non-boundary part of the coding tree block, determining a category of each traversed first reconstructed pixel in each of edge offset modes along four directions, wherein the four directions comprise a horizontal direction, a vertical direction, a 135° direction, and a 45° direction, and wherein the determined category is one of a category 0, a category 1, a category 2, a category 3, and a category 4, and wherein the category 1 indicates that a pixel value of a reconstructed pixel currently to be calculated is less than pixel values of two reference pixels, the category 2 indicates that a pixel value of a reconstructed pixel currently to be calculated is equal to a pixel value of one of the reference pixels and less than a pixel value of the other reference pixel, the category 3 indicates that a pixel value of a reconstructed pixel currently to be calculated is equal to a pixel value of one of the reference pixels and greater than a pixel value of the other reference pixel, the category 4 indicates that a pixel value of a reconstructed pixel currently to be calculated is greater than pixel values of the two reference pixels, the category 0 indicates that a pixel value does not belong to any of the category 1, the category 2, the category 3, and the category 4, and storing (S40) the category of each first reconstructed pixel in each of the edge offset modes along the four directions into a variable represented by 4M bits, wherein the category of each first reconstructed pixel along each of the four directions is represented by M bits and M is an integer greater than or equal to 3; traversing (S23) all second reconstructed pixels in the boundary part of the coding tree block, determining a category of each traversed second reconstructed pixel in an edge offset mode along a single direction from the horizontal direction and the vertical direction, wherein if the second reconstructed pixel is a pixel in the uppermost row or the lowermost row, the single direction is the horizontal direction, and if the second reconstructed pixel is a pixel in the leftmost column or the rightmost column, the single direction is the vertical direction, and storing the category of each second reconstructed pixel in the edge offset mode along the single direction into the variable represented by 4M bits, wherein the category of each second reconstructed pixel along the single direction from the four directions is represented by M bits and M is an integer greater than or equal to 3, wherein a category of each second reconstructed pixel in each of the edge offset modes along the other directions from the four directions except for the single direction is represented by a preset value, and wherein the preset value is set to be different from values of the categories; obtaining, from the variable, the categories of all the reconstructed pixels in the edge offset modes along the four directions; calculating (S42) the accumulated residual values of reconstructed pixels under each of the different categories in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value; and calculating the accumulated numbers of reconstructed pixels under each of the different categories in each of the edge offset modes along the four directions, based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, and the category of each second reconstructed pixel in the edge offset mode along the single direction.
2. The method for data processing in the edge offset mode of sample adaptive offset according to claim 1, wherein there are five categories, each category is represented by four bits, the categories of each reconstructed pixel in the edge offset modes along the four directions are represented by 16 bits, and the obtaining, from the variable, the categories of all the reconstructed pixels in the edge offset modes along the four directions comprises: performing an and operation on the variable and a preset 16-bit value, and using an operation result as a category, stored in the variable, of each reconstructed pixel in an edge offset mode along one direction; performing a 4-bit shift on the variable to obtain an updated variable; performing an and operation on the updated variable and the preset 16-bit value, and using an operation result as a category of the reconstructed pixel in an edge offset mode along another direction; and returning to perform the step of performing a 4-bit shift on the variable to obtain an updated variable, until the categories of each reconstructed pixel in the edge offset modes along all the directions are obtained.
3. The method for data processing in the edge offset mode of sample adaptive offset according to claim 2, wherein the preset 16-bit value is 0x000f, and the performing a 4-bit shift on the variable to obtain an updated variable comprises: performing a 4-bit right shift on the variable to obtain an updated variable.
4. The method for data processing in the edge offset mode of sample adaptive offset according to claim 2, wherein the preset 16-bit value is 0xf000, and the performing a 4-bit shift on the variable to obtain an updated variable comprises: performing a 4-bit left shift on the variable to obtain an updated variable.
5. The method for data processing in the edge offset mode of sample adaptive offset according to any one of claims 2 to 4, wherein the step of obtaining an accumulated residual value by accumulating each residual value of reconstructed pixels under each of different categories in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value comprises: calculating an accumulated residual value of reconstructed pixels under each of all the categories except a preset category in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value.
6. An apparatus (50) for data processing in an edge offset mode of sample adaptive offset, comprising: an obtaining means (51) configured to obtain a target reconstructed image, and divide the target reconstructed image into a plurality of non-overlapping coding tree blocks; a first traversal means (52) configured to traverse all reconstructed pixels in each coding tree block, and calculate a residual value between each reconstructed pixel and a corresponding original pixel, wherein the coding tree block comprises a boundary part and a non-boundary part, wherein the boundary part comprises an uppermost row, a lowermost row, a leftmost column, and a rightmost column in the coding tree block, wherein the non-boundary part comprises a part of the coding tree block except the uppermost row, the lowermost row, the leftmost column, and the rightmost column, and wherein a pixel in the non-boundary part is a first reconstructed pixel and a pixel in the boundary part is a second reconstructed pixel; a second traversal means (53) configured to traverse all first reconstructed pixels in the non-boundary part of the coding tree block, determine a category of each traversed first reconstructed pixel in each of edge offset modes along four directions, wherein the four directions comprise a horizontal direction, a vertical direction, a 135° direction, and a 45° direction, and wherein the determined category is one of a category 0, a category 1, a category 2, a category 3, and a category 4, and wherein the category 1 indicates that a pixel value of a reconstructed pixel currently to be calculated is less than pixel values of two reference pixels, the category 2 indicates that a pixel value of a reconstructed pixel currently to be calculated is equal to a pixel value of one of the reference pixels and less than a pixel value of the other reference pixel, the category 3 indicates that a pixel value of a reconstructed pixel currently to be calculated is equal to a pixel value of one of the reference pixels and greater than a pixel value of the other reference pixel, the category 4 indicates that a pixel value of a reconstructed pixel currently to be calculated is greater than pixel values of the two reference pixels, the category 0 indicates that a pixel value does not belong to any of the category 1, the category 2, the category 3, and the category 4, and store the category of each first reconstructed pixel in each of the edge offset modes along the four directions into a variable represented by 4M bits, wherein the category of each first reconstructed pixel along each of the four directions is represented by M bits and M is an integer greater than or equal to 3; a third traversal means (54) configured to traverse all second reconstructed pixels in the boundary part of the coding tree block, and determine a category of each traversed second reconstructed pixel in an edge offset mode along a single direction from the horizontal direction and the vertical direction, wherein if the second reconstructed pixel is a reconstructed pixel in the uppermost row or the lowermost row, the single direction is the horizontal direction, and if the second reconstructed pixel is a reconstructed pixel in the leftmost column or the rightmost column, the single direction is the vertical direction, and store the category of each second reconstructed pixel in the edge offset mode along the single direction into the variable represented by 4M bits, wherein the category of each second reconstructed pixel along the single direction from the four directions is represented by M bits and M is an integer greater than or equal to 3, wherein a category of each second reconstructed pixel in each of the edge offset modes along the other directions from the four directions except for the single direction is represented by a preset value, and wherein the preset value is set to be different from values of the categories; and a calculation means (55) configured to: obtain, from the variable, the categories of all the reconstructed pixels in the edge offset modes along the four directions; calculate the accumulated residual values of reconstructed pixels under each of the different categories in each of the edge offset modes along the four directions based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, the category of each second reconstructed pixel in the edge offset mode along the single direction, and each residual value; and calculate the accumulated numbers of reconstructed pixels under each of the different categories in each of the edge offset modes along the four directions, based on the category of each first reconstructed pixel in each of the edge offset modes along the four directions, and the category of each second reconstructed pixel in the edge offset mode along the single direction.
7. The apparatus for data processing in the edge offset mode of sample adaptive offset according to claim 6, wherein the means comprises: at least one processor; and at least one memory comprising computer program code, the at least one memory and computer program code configured to, with the at least one processor, cause the performance of the apparatus.
8. A computer-readable storage medium, having computer-readable instructions stored thereon, when the computer-readable instructions are executed by a processor, the steps of the method for data processing in an edge offset mode of sample adaptive offset according to any one of claims 1 to 5 are implemented.
9. A computer program product comprising instructions which, when executed by a computer, cause the computer to carry out the method of any one of claims 1 to 5.