Patent Description:
High Efficiency Video Coding (HEVC) is a video compression standard. In the prior art, 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.

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.

In the BO mode, classification is performed based on a pixel value range, to equally divide pixel values into <NUM> bands. For example, a pixel value range of an <NUM>-bit image is [<NUM>, <NUM>]. In this case, during division of bands, each band includes eight pixel values, and a pixel value range of the kth band is [<NUM>, <NUM>+<NUM>].

During implementation of an existing BO mode, the residual values and the number of pixels of bands <NUM> to <NUM> in a current coding tree block (CTB) are calculated through the following steps:.

<NPL> discloses an efficient VLSI design for SAO estimation with a dual-clock architecture that processes statistics collection (SC) and parameter decision (PD), the two main functional blocks of SAO estimation, at high- and lowspeed clocks, respectively. In particular, it derives a cumulative residual value and a cumulative number of reconstructed pixel for each band on the basis of units of 2x2 pixels.

<NPL> discloses a low cost highthroughput VLSI implementation of SAO parameter estimation during encoding to derive a cumulative residual value and a cumulative number of reconstructed pixel for each band on the basis of units of 4x4 pixels using comparators and masks.

However, the inventors find that the above calculation method is time-consuming, which severely restricts application of the BO technology in scenarios such as live streaming, and also increases power consumption of a mobile device.

In view of this, a method and apparatus for data processing in a band offset mode of sample adaptive offset, a computer-readable storage medium and a computer program product are currently provided, to resolve a problem that an existing BO technology is time-consuming in calculating the residual values and the number of pixels of bands <NUM> to <NUM> in a CTB.

The present application provides a method for data processing in a band offset mode of sample adaptive offset according to claim <NUM>.

The present application further provides an apparatus for data processing in a band offset mode of sample adaptive according to claim <NUM>.

The present application further provides a computer-readable storage medium having computer instructions stored thereon that, when executed by a processor, cause the processor to perform the steps of the above method.

The above technical solutions have the following beneficial effects:
In the embodiments of the present application, a target reconstructed image is acquired, 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, a band value of each traversed reconstructed pixel is calculated, and a residual value between each traversed reconstructed pixel and a corresponding original pixel is calculated; the calculated band value of each reconstructed pixel is stored in a first array, and the calculated residual value between each reconstructed pixel and the corresponding original pixel is stored in a second array; whether m consecutive band values in the first array belong to the same band is determined, where m is an integer greater than or equal to <NUM>; and if the m consecutive band values in the first array belong to the same band, a cumulative residual value of m reconstructed pixels corresponding to the m band values is calculated at a time based on a residual value in the second array, and a cumulative number of the m reconstructed pixels is calculated. In the embodiments of the present application, when it is determined, through traversal, that a plurality of pixels belong to the same band, the calculation of the residuals of these pixels belonging to the same band and the calculation of the number of these pixels are completed at a time, thereby reducing memory read and write operations, and further reducing the calculation time consumption and reducing power consumption.

Enabling disclosure can be found in <FIG> and corresponding passages.

The advantages of the present application are further described below with reference to accompanying drawings and specific embodiments.

Exemplary embodiments are illustrated in detail herein, 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.

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.

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, 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".

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.

<FIG> a schematic block diagram of a method for data processing in a band 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 <NUM> and a server <NUM>. A wireless or wired connection is formed between the computer device <NUM> and the server <NUM>. The computer device <NUM> may be a mobile phone, an iPad, a tablet computer, a server, or the like. The sever <NUM> 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).

<FIG> is a schematic flowchart of a method for data processing in a band 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 a band offset mode of sample adaptive offset in this embodiment includes the following steps.

In step S20, a target reconstructed image is acquired, and the target reconstructed image is divided into a plurality of non-overlapping coding tree blocks.

Specifically, the target reconstructed image is an image obtained after a reconstructed image is deblocked, and is a frame of reconstructed image.

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 coding tree unit (CTU) size preset by an encoder. For example, a size of the target reconstructed image is <NUM>×<NUM>, and the CTU size is <NUM>×<NUM>. In this case, the target reconstructed image may be divided into four non-overlapping coding tree blocks.

In step S21, all reconstructed pixels in each coding tree block are traversed, a band value of each traversed reconstructed pixel is calculated, and a residual value between each traversed reconstructed pixel and a corresponding original pixel is calculated.

Specifically, a coding tree block (CTB) may be a brightness 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, for example, includes <NUM>×<NUM>, <NUM>×<NUM>, and <NUM>×<NUM> pixels. In an example, <FIG> shows an area including <NUM>×<NUM> reconstructed pixels in a coding tree block, and pixel values of the reconstructed pixels in this area are shown in the figure.

It should be noted that, for the coding tree block shown in <FIG>, an <NUM>-bit image is used as an example. A reconstructed pixel is a pixel obtained after each pixel in an original image is restored.

In this embodiment, when a band value of each reconstructed pixel is calculated, a range of pixel values included in each band may be first determined based on a pixel value range of pixels in the image. For example, if the pixel value range of the pixels in the image is <NUM>-<NUM>, it may be determined that each band includes <NUM>/<NUM>=<NUM> pixel values; or if the pixel value range of the pixels in the image is <NUM>-<NUM>, it may be determined that each band includes <NUM> pixel values.

In an example, after a band value of each reconstructed pixel in <FIG> is calculated, a band value, shown in <FIG>, that corresponds to each reconstructed pixel may be obtained.

A residual difference 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.

It may be understood that, in this embodiment of the present application, to reduce a data processing time, band values and residual values of all reconstructed pixels in the coding tree block may be calculated in advance, instead of calculating the band values and the residual values when the values need to be used.

In step S22, the calculated band value of each reconstructed pixel is stored in a first array, and the calculated residual value between each reconstructed pixel and a corresponding original pixel is stored in a second array.

Specifically, to facilitate subsequent sequential acquisition of the band value of each reconstructed pixel and the residual value between each reconstructed pixel and a corresponding original pixel, the band value may be stored in the first array, and the residual value may be stored in the second array. For example, the band value is stored in a bttype array, and the residual value is stored in a btdiff array.

In step S23, whether m consecutive band values in the first array belong to a same band is determined, where m is an integer greater than or equal to <NUM>.

In an example, whether a first batch of eight consecutive band values in the first array belong to the same band is determined. If the eight band values belong to the same band, a next batch of eight consecutive band values may be further acquired from the first array, and whether the next batch of eight consecutive band values belong to the same band is determined, until determining is performed on all band values in the first array.

In step S24, if the m consecutive band values in the first array belong to the same band, a cumulative residual value of m reconstructed pixels corresponding to the m consecutive band values is calculated at a time based on the residual value in the second array, and a cumulative number of the m reconstructed pixels is calculated.

Specifically, the cumulative residual value is a cumulative sum of residual values between the m reconstructed pixels and corresponding original pixels. For example, m=<NUM>, and residual values between the eight reconstructed pixels and corresponding original pixels are <NUM>, <NUM>, <NUM>, <NUM>, <NUM>, <NUM>, <NUM>, <NUM>. In this case, the cumulative residual value=<NUM>+<NUM>+<NUM>+<NUM>+<NUM>+<NUM>+<NUM>+<NUM>=<NUM>.

The cumulative number is the number of the m reconstructed pixels. For example, if m=<NUM>, the cumulative number is also <NUM>; or if m=<NUM>, the cumulative number is <NUM>.

In this embodiment, when it is determined that the m consecutive band values in the first array belong to the same band, residual values of the m reconstructed pixels corresponding to the m band values may be read from the second array at a time, and then a cumulative sum of the m read residual values may be calculated at a time, without a need to read the m residual values from the second array one by one or accumulating the read residual values one by one.

It should be noted that, after the cumulative residual value is calculated and the cumulative number is calculated, the obtained cumulative residual value may be added to a sum variable of a corresponding band p, the cumulative number m may be added to a count variable of the corresponding band p, and then a subsequent processing operation is performed. In this embodiment, the subsequent processing operation belongs to the prior art, and details are not described in this embodiment.

In this embodiment of the present application, all reconstructed pixels in a coding tree block are traversed, a band value of each traversed reconstructed pixel is calculated, and a residual value between each traversed reconstructed pixel and a corresponding original pixel is calculated; the calculated band value of each reconstructed pixel is stored in a first array, and the calculated residual value between each reconstructed pixel and the corresponding original pixel is stored in a second array; whether m consecutive band values in the first array belong to the same band is determined, where m is an integer greater than or equal to <NUM>; and if the m consecutive band values in the first array belong to the same band, a cumulative residual value of m reconstructed pixels corresponding to the m band values is calculated at a time based on a residual value in the second array, and a cumulative number of the m reconstructed pixels is calculated. In the embodiments of the present application, when it is determined, through traversal, that a plurality of pixels belong to the same band, the calculation of the residuals of these pixels belonging to the same band and the calculation of the number of these pixels are completed at a time, thereby reducing memory read and write operations, and further reducing the calculation time consumption and reducing power consumption.

Through experimental statistics, memory read and write operations of a BO means can be reduced by approximately <NUM>% by using the calculation method in the present application. In addition, for no matter the Android/iOS of a mobile device or a PC, memory read and write operations are quite slow and power-consuming. Therefore, because memory read and write operations are reduced in the present application, power consumption can be greatly reduced in the calculation scheme of the present application. In addition, the BO means can also be accelerated by approximately <NUM>% in the calculation method. In the prior art, in a scenario such as live streaming, a processing time of a BO means accounts for approximately <NUM>% of the entire coding/decoding time. If the technical solution of the present application is applied to the BO means, live streaming coding can be directly accelerated by approximately <NUM>%. This can not only reduce power consumption, but also accelerate live streaming coding.

In an exemplary implementation, as shown in <FIG>, the method for data processing in a band offset mode of sample adaptive offset further includes the following steps.

In step S50, if the m consecutive band values in the first array do not belong to the same band, whether n consecutive band values of the m consecutive band values belong to the same band is further determined, where n < m, and n is an integer greater than or equal to <NUM>.

In an example, m=<NUM>, and n=<NUM>. In this case, when it is determined that the eight consecutive band values in the first array do not belong to the same band, for example, when five consecutive band values belong to a band <NUM>, and the other three band values belong to a band <NUM>, whether four consecutive band values of the eight band values belong to the same band may be further determined.

It should be noted that the n consecutive band values may be n consecutive band values at any locations of the m band values, for example, may be the <NUM>st band value to the nth band value of the m band values, the <NUM>nd band value to the (n+<NUM>)th band value of the m band values, or the <NUM>rd band value to the (n+<NUM>)th band value of the m band values.

Preferably, the n consecutive band values are the <NUM>st band value to the nth band value of the m band values, or the (m-n+<NUM>)th band value to the mth band value of the m band values. In an example, when m=<NUM> and n=<NUM>, the four consecutive band values are the <NUM>st band value to the <NUM>th band value of the eight band values, or the four consecutive band values are the <NUM>th band value to the <NUM>th band value of the eight band values.

In step S51, if the n consecutive band values belong to the same band, a cumulative residual value of n reconstructed pixels corresponding to the n consecutive band values is calculated at a time based on the residual value in the second array, and a cumulative number of the n reconstructed pixels is calculated.

Specifically, when it is determined that the n consecutive band values belong to the same band, residual values of the n reconstructed pixels corresponding to the n band values may be read from the second array at a time, and then a cumulative sum of the n read residual values may be calculated at a time, without a need to read the n residual values from the second array one by one or accumulating the read residual values one by one.

It should be noted that, after the cumulative residual value and the cumulative number are calculated, the obtained cumulative residual value may be added to a sum variable of a corresponding band p, the cumulative number n may be added to a count variable of the corresponding band p, and then a subsequent processing operation is performed. In this embodiment, the subsequent processing operation belongs to the prior art, and details are not described in this embodiment.

In this embodiment, when it is determined that the m consecutive band values do not belong to the same band, whether the n consecutive band values of the m band values belong to the same band is further determined, and when the n consecutive band values belong to the same band, the calculation of the residuals of these pixels belonging to the same band and the calculation of the number of these pixels are completed at a time, thereby reducing memory read and write operations, and further reducing the calculation time consumption and reducing power consumption.

It should be noted that, in this embodiment, when it is determined that the n consecutive band values do not belong to the same band, whether k consecutive band values belong to the same band may be further determined, where k is an integer less than n. In this embodiment, a specific number of times of performing the above determining step is not limited in this embodiment, and may be set based on an actual situation.

In an exemplary implementation, as shown in <FIG>, the step of determining whether m consecutive band values in the first array belong to the same band may include steps S60 to S63.

In step S60, the m consecutive band values are read from the first array, and the read band values are stored in a first variable with preset bits.

Specifically, the first variable may be a global variable or a local variable. In this embodiment, the first variable is preferably a local variable, for example, a local variable classIdx_64. The number of preset bits is a preset value. For example, the preset bits are <NUM> bits. It may be understood that the number of preset bits may alternatively be another value, and a specific value of the preset bits may be set based on an actual situation.

In an example, the read band values may be stored in a <NUM>-bit local variable classIdx_64.

In step S61, one of the band values is fetched from the first variable, and the fetched band value is copied m-<NUM> times to obtain the copied band values.

Specifically, one band value may be randomly fetched from m band values included in the first variable, for example, the <NUM>nd band value is fetched. Alternatively, a band value at a preset location may be fetched from the m band values included in the first variable, where the preset location is preset or defaulted. For example, if the preset location is the <NUM>st location, a band value in the <NUM>st location may be fetched.

In this embodiment, after a band value is fetched, to make the number of finally obtained band values be the same as the number of band values included in the first variable, the fetched band value may be copied m-<NUM> times to obtain copied band values, and the copied band values are stored in a second variable with the preset bits to obtain m band values.

In step S62, the copied band values are stored in a second variable with the preset bits.

Specifically, the second variable is of the same type as the first variable, and may be a global variable or a local variable. In this embodiment, the second variable is preferably a local variable, for example, a local variable classIdx_rep. The number of preset bits is a preset value. For example, the preset bits are <NUM> bits.

In an example, the copied band values may be stored in a <NUM>-bit local variable classIdx_rep.

In step S63, whether the first variable is equal to the second variable is determined, and whether the m consecutive band values in the first array belong to the same band is determined based on a determination result.

Specifically, when the determining result is that the first variable is equal to the second variable, it may be determined that the m consecutive band values in the first array belong to the same band; or when the determining result is that the first variable is not equal to the second variable, it may be determined that the m consecutive band values in the first array do not belong to the same band.

In this embodiment, the second variable is generated by copying the fetched band value m-<NUM> times, thereby reducing a time for generating the second variable.

In an exemplary implementation, as shown in <FIG>, when the first variable is not equal to the second variable, the determining whether n consecutive band values of the m band values belong to the same band may include steps S70 and S71.

In step S70, values in a preset number of bits that correspond to the n consecutive band values are acquired from each of the first variable and the second variable.

Specifically, the preset number of bits may be determined based on the number of bits used to represent each band value. For example, when a band value is represented by an <NUM>-bit value, it may be determined that the preset number of bits is 8n; when a band value is represented by a <NUM>-bit value, it may be determined that the preset number of bits is 5n; or when a band value is represented by a <NUM>-bit value, it may be determined that the preset number of bits is 16n.

In this embodiment, a specific number of bits of a value to be acquired is related to locations of the n band values in the m band values.

In an example, m=<NUM>, n=<NUM>, each band value is represented by an <NUM>-bit value, the first variable with the preset bits is a <NUM>-bit first variable, the four band values are the <NUM>st band value to the <NUM>th band value of the eight band values. In this case, when the values in the preset number of bits that correspond to the n consecutive band values are acquired from the first variable and the second variable, values from the <NUM>st bit to the <NUM>nd bit may be acquired from each of the first variable and the second variable.

It may be understood that when the four band values are the <NUM>nd band value to the <NUM>th band value of the eight band values, when the value that has the preset number of bits and that corresponds to the n band values is acquired from the first variable and the second variable, a value with the <NUM>th bit to the <NUM>th bit may be obtained from each of the first variable and the second variable.

In an exemplary implementation, if m=<NUM>, n=<NUM>, each band value is represented by an <NUM>-bit value, and the first variable with the preset bits is a <NUM>-bit first variable, the acquiring, from each of the first variable and the second variable, a value that has a preset number of bits and that corresponds to the n band values may include:
acquiring, from each of the first variable and the second variable, values in <NUM> least significant bits or <NUM> most significant bits.

In this embodiment, to facilitate acquisition of values from the first variable and the second variable, the value with the <NUM> least significant bits or the <NUM> most significant bits may be directly acquired.

In step S71, whether a value acquired from the first variable is equal to a value acquired from the second variable is determined, and whether the n consecutive band values of the m consecutive band values belong to the same band is determined based on a determination result.

Specifically, when the determining result is that the value acquired from the first variable is equal to the value acquired from the second variable, it may be determined that the n consecutive band values of the m band values belong to the same band; or when the determining result is that the value acquired from the first variable is not equal to the value acquired from the second variable, it may be determined that the n consecutive band values of the m band values do not belong to the same band.

In an exemplary implementation, the method further includes:
if the m consecutive band values in the first array do not belong to the same band, separately calculating the residual value of each reconstructed pixel and a number of reconstructed pixels.

Specifically, when the m consecutive band values in the first array do not belong to the same band, in other words, belong to different bands, a residual value of each reconstructed pixel and the number of reconstructed pixels may be separately calculated. That is, only one residual value is read from the second array at a time. Then the read residual value is added to a sum variable of a corresponding band p, and a number <NUM> is added to a count variable of the corresponding band p. Then a subsequent processing operation is performed. In this embodiment, the subsequent processing operation belongs to the prior art, and details are not described in this embodiment.

<FIG> is a diagram of program means of an embodiment of an apparatus <NUM> for data processing in a band offset mode of sample adaptive offset according to the present application.

In this embodiment, the apparatus <NUM> for data processing in a band offset mode of sample adaptive offset includes a series of computer program instructions stored in a memory. When the computer program instructions are executed by a processor, the function for data processing in a band offset mode of sample adaptive offset according to each embodiment of the present application can be implemented. In some embodiments, the apparatus <NUM> for data processing in a band 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 program instructions. For example, in <FIG>, the apparatus <NUM> for data processing in a band offset mode of sample adaptive offset may be divided into an acquisition means <NUM>, a traversal means <NUM>, a storage means <NUM>, a determining means <NUM>, and a calculation means <NUM>.

The acquisition means <NUM> is configured to acquire a target reconstructed image, and divide the target reconstructed image into a plurality of non-overlapping coding tree blocks.

The traversal means <NUM> is configured to: traverse all reconstructed pixels in each coding tree block, calculate a band value of each traversed reconstructed pixel, and calculate a residual value between each traversed reconstructed pixel and a corresponding original pixel.

The storage means <NUM> is configured to store the calculated band value of each reconstructed pixel in a first array, and store the calculated residual value between each reconstructed pixel and a corresponding original pixel in a second array.

The determining means <NUM> is configured to determine whether m consecutive band values in the first array belong to a same band, where m is an integer greater than or equal to <NUM>.

The calculation means <NUM> is configured to: if the m consecutive band values in the first array belong to the same band, calculate, at a time based on the residual value in the second array, a cumulative residual value of m reconstructed pixels corresponding to the m consecutive band values, and calculate a cumulative number of the m reconstructed pixels.

In an exemplary implementation, the determining means <NUM> is further configured to: if the m consecutive band values in the first array do not belong to the same band, further determine whether n consecutive band values of the m consecutive band values belong to the same band, where n < m, and n is an integer greater than or equal to <NUM>; and if the n consecutive band values belong to the same band, calculate, at a time based on the residual value in the second array, a cumulative residual value of n reconstructed pixels corresponding to the n consecutive band values, and calculate a cumulative number of the n reconstructed pixels.

In an exemplary implementation, the determining means <NUM> is further configured to: read the m consecutive band values from the first array, and store the read band values in a first variable with preset bits; fetch one of the band values from the first variable, and copy the fetched band value m-<NUM> times to obtain the copied band values; store the copied band values in a second variable with the preset bits; and determine whether the first variable is equal to the second variable, and determine, based on a determination result, whether the m consecutive band values in the first array belong to the same band.

In an exemplary implementation, when the first variable is not equal to the second variable, the determining means <NUM> is further configured to: acquire, from each of the first variable and the second variable, values in a preset number of bits that correspond to the n consecutive band values; and determine whether the value acquired from the first variable is equal to the value acquired from the second variable, and determine, based on a determination result, whether the n consecutive band values of the m consecutive band values belong to the same band.

In an exemplary implementation, the determining means <NUM> is further configured to fetch a band value at a preset location from the first variable.

In an exemplary implementation, m=<NUM>, n=<NUM>, each band value is represented by an <NUM>-bit value, the first variable with the preset bits is a <NUM>-bit first variable, and the determining means <NUM> is further configured to acquire, from each of the first variable and the second variable, values in <NUM> least significant bits or <NUM> most significant bits.

In an exemplary implementation, the apparatus <NUM> for data processing in a band offset mode of sample adaptive offset further includes a calculation means.

The counting means is configured to: if the m consecutive band values in the first array do not belong to the same band, separately calculate the residual value of each reconstructed pixel and a number of reconstructed pixels.

In the embodiments of the present application, a target reconstructed image is acquired, 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, a band value of each traversed reconstructed pixel is calculated, and a residual value between each traversed reconstructed pixel and a corresponding original pixel is calculated; the calculated band value of each reconstructed pixel is stored in a first array, and the calculated residual value between each reconstructed pixel and the corresponding original pixel is stored in a second array; whether m consecutive band values in the first array belong to the same band is determined, where m is an integer greater than or equal to <NUM>; and if the m consecutive band values in the first array belong to the same band, a cumulative residual value of m reconstructed pixels corresponding to the m band values is calculated at a time based on a residual value in the second array, and a cumulative number of the m reconstructed pixels is calculated. In the embodiments of the present application, when it is determined, through traversal, that a plurality of pixels belong to the same band, the calculation of the residuals of these pixels belonging to the same band and the calculation of the number of these pixels are completed at a time, thereby reducing memory read and write operations, and further reducing the calculation time consumption and reducing power consumption.

<FIG> is a schematic diagram of a hardware structure of a computer device <NUM> suitable for performing a method for data processing in a band offset mode of sample adaptive offset according to an embodiment of the present application. In this embodiment, the computer device <NUM> 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, or a cabinet server (including an independent server or a server cluster that includes a plurality of servers). As shown in <FIG>, the computer device <NUM> at least includes, but is not limited to: a memory <NUM>, a processor <NUM>, and a network interface <NUM> that may be communicatively linked to each other by using a system bus.

The memory <NUM> 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 <NUM> may be an internal storage means of the computer device <NUM>, for example, a hard disk or memory of the computer device <NUM>. In some other embodiments, the memory <NUM> may alternatively be an external storage device of the computer device <NUM>, for example, a plug-in type hard disk equipped on the computer device <NUM>, a smart media card (SMC for short), a secure digital (SD for short) card, or a flash card. Certainly, the memory <NUM> may alternatively include both the internal storage means of the computer device <NUM> and the external storage device of the computer device. In this embodiment, the memory <NUM> is generally configured to store an operating system and various application software installed on the computer device <NUM>, such as program code for a method for data processing in a band offset mode of sample adaptive offset. In addition, the memory <NUM> may be further configured to temporarily store various types of data that have been output or are to be output.

In some embodiments, the processor <NUM> may be a central processing unit (CPU for short), a controller, a microcontroller, a microprocessor, or other chips for data processing in a band offset mode of sample adaptive offset. The processor <NUM> is generally configured to control overall operations of the computer device <NUM>, for example, perform control, processing, and the like related to data exchange or communication with the computer device <NUM>. In this embodiment, the processor <NUM> is configured to run program code stored in the memory <NUM> or to process data.

The network interface <NUM> may include a wireless network interface or a wired network interface. The network interface <NUM> is generally configured to establish a communication link between the computer device <NUM> and other computer devices. For example, the network interface <NUM> is configured to connect the computer device <NUM> to an external terminal by using a network, and establish a data transmission channel, a communication link, and the like between the computer device <NUM> 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 <NUM> network, a <NUM> network, Bluetooth, or Wi-Fi.

It should be noted that <FIG> shows only a computer device having components <NUM> to <NUM>, 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.

In this embodiment, the method for data processing in a band offset mode of sample adaptive offset stored in the memory <NUM> may alternatively be divided into one or more program means and executed by one or more processors (by the processor <NUM> in this embodiment) to implement the present application.

An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, where when the computer program is executed by a processor, the steps of the method for data processing in a band offset mode of sample adaptive offset in the embodiments are implemented.

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 a band 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.

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.

Claim 1:
A computer-implemented method for data processing in a band offset mode of sample adaptive offset, comprising:
acquiring (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, calculating, in a sequence, a band value of each traversed reconstructed pixel, and calculating, in the sequence, a residual value between each traversed reconstructed pixel and a corresponding original pixel;
storing (S22), in the sequence, the calculated band value of each reconstructed pixel in a first array, and storing, in the sequence, the calculated residual value between each reconstructed pixel and the corresponding original pixel in a second array;
determining (S23) whether m consecutive band values in the first array belong to a same band, wherein m is an integer greater than or equal to <NUM>;
in response to determining that the m consecutive band values in the first array belong to the same band, calculating (S24), at once based on the residual values in the second array of m reconstructed pixels corresponding to the m consecutive band values, a first cumulative residual value of the m reconstructed pixels corresponding to the m consecutive band values, and calculating a first cumulative number of the m reconstructed pixels;
adding the first cumulative residual value to a sum variable of said same band, and adding the first cumulative number to a count variable of said same band; and
performing a pixel compensation on the target reconstructed image based on the sum variable and the count variable;
characterized in that:
in response to determining that the m consecutive band values in the first array do not belong to the same band, further determining whether n consecutive band values of the m consecutive band values belong to the same band, wherein n < m and n is an integer greater than or equal to <NUM>;
in response to determining that the n consecutive band values belong to the same band, calculating, at once based on the residual values in the second array of n reconstructed pixels corresponding to the n consecutive band values, a second cumulative residual value of the n reconstructed pixels, and calculating a second cumulative number of the n reconstructed pixels; and
adding the second cumulative residual value to the
sum variable of said same band, and adding the second cumulative number to the count variable of said same band.