Apparatus and method for encoding and decoding Bayer array images
Through the combination of quantizer, predictor and variable length encoder, the problem of large memory space occupancy in Bayer array image compression is solved, distortion-free compression is achieved, and compression efficiency and image quality are improved.
Patent Information
- Application Number
- CN202410321267.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-01-17
- Filing Date
- 2024-03-20
- Publication Date
- 2025-07-18
AI Technical Summary
The prior art takes up a large memory space when compressing Bayer array images and may lead to image quality distortion, and a distortion-free compression scheme is urgently needed to reduce memory space occupancy and maintain image quality.
Using a combination of a quantizer, predictor and variable length encoder, the Bayer array image is encoded and decoded by quantizing the difference value and calculating the encoding of continuous zero and non-zero integers, and quantization processing is performed using quantization parameters Q and equations, and the continuous zero and non-zero integers are encoded and decoded in combination with the encoding table.
It realizes reducing memory space usage without distortion, maintaining image quality, and improving compression efficiency through encoding and decoding processes.
Smart Images

Figure CN120343249A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video codecs, and in particular, to an apparatus and method for encoding and decoding Bayer pattern images. Background Art
[0002] In digital cameras, smart phones, and other imaging systems, an image signal processor (ISP) is a special component whose main function is to process the raw output data from a Bayer color filter array (CFA) and convert it into a high-quality image. Before the demosaicing step, the ISP obtains a low / standard dynamic range (LSDR) image (each pixel contains only one color) related to the Bayer pattern image. At this stage, by combining a series of LSDR images with different exposure times, the ISP can generate a high dynamic range (HDR) image. Since these LSDR images are taken at different time points, these LSDR images are sequentially compressed and stored in a dynamic random access memory (DRAM). Then, these compressed data are read back from the DRAM, decompressed, and combined to generate an HDR image. Therefore, there is an urgent need in the industry for a lossless compression scheme that allows the compressed data to occupy less memory space and the user does not feel any loss of image quality. Summary of the Invention
[0003] In view of the above problems, one object of the present invention is to provide a video encoding apparatus for Bayer pattern images, which allows the compressed data to occupy less memory space and the user does not feel any loss of image quality.
[0004] According to an embodiment of the present invention, there is provided a video encoding apparatus for Bayer pattern images, including: a quantizer, a predictor, and a variable length encoder. The quantizer is used to quantize the difference D between an input pixel and a current predicted pixel according to a quantization parameter Q and an equation to generate a quantization value Δ in a quantization sequence, where the equation is
[0005]
[0006] The predictor, coupled to the quantizer, is configured to perform a set of first operations, including: providing the current predicted pixel according to the position of a current segment in a current Bayer array image. The variable length encoder, coupled to the quantizer, is configured to perform a set of second operations, including: (1) calculating the number ZR of consecutive zeros, where ZR consecutive zeros are located before the next non-zero integer in the quantization sequence or at the end segment of the quantization sequence; (2) encoding the ZR consecutive zeros as a first codeword with a first set of codewords; (3) encoding the next non-zero integer as a second codeword with a second set of codewords; and (4) repeating the second operations (1) to (3) until all quantization values in the quantization sequence are processed to generate a coded byte. Wherein, A satisfies the following equation: (Q × A + 1) = N, and wherein N = 2 d ≥2 n , where n represents the bit width of the input pixel and d is an integer.
[0007] Another embodiment of the present invention provides a video coding method for a Bayer array image, including the following steps: quantizing the difference D between an input pixel and a current predicted pixel according to a quantization parameter Q and an equation to generate a quantization value Δ in a quantization sequence, wherein the equation is Providing the current predicted pixel according to the position of a current segment in a current Bayer array image; calculating the number ZR of consecutive zeros, where ZR consecutive zeros are located before the next non-zero integer in the quantization sequence or at the end segment of the quantization sequence; encoding the ZR consecutive zeros as a first codeword with a first set of codewords; encoding the next non-zero integer as a second codeword with a second set of codewords; and repeating the calculating step, the step of encoding the ZR consecutive zeros as the first codeword, and the step of encoding the next non-zero integer as the second codeword until all quantization values in the quantization sequence are processed to generate a coded byte; wherein, A satisfies the following equation: (Q × A + 1) = N; and wherein, N = N = 2 d ≥2 n , where n represents the bit width of the input pixel and d is an integer.
[0008] Another embodiment of the present invention provides a video decoding device for a Bayer array image, comprising: a variable length decoder and a predictor. The variable length decoder is configured to perform a set of first operations, including: comparing, in an alternating manner, a leading bit pattern of a coded byte with all codewords in a first codeword set and a second codeword set to generate a decoded value, where the decoded value can be a set of consecutive zeros or a non-zero integer. The predictor is coupled to the variable length decoder and is configured to perform a set of second operations, including: providing a current predicted pixel according to the position of a current reconstruction segment in a current reconstructed Bayer array image.
[0009] Another embodiment of the present invention provides a video decoding method for a Bayer array image, comprising the following steps: comparing, in an alternating manner, a leading bit pattern of a coded byte with all codewords in a first codeword set and a second codeword set to generate a decoded value, where the decoded value can be a set of consecutive zeros or a non-zero integer; and providing a current predicted pixel according to the position of a current reconstruction segment relative to a current reconstructed Bayer array image.
[0010] The above and other objects and advantages of the present invention will be described in detail below in conjunction with the following drawings, detailed description of embodiments, and claims. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 This is an embodiment of the present invention, showing an example of an encoding / decoding system 100.
[0012] Figure 2 This is an embodiment of the present invention, showing a schematic diagram of a segment encoder 200 for a Bayer array image.
[0013] Figure 3 This is an embodiment of the present invention, showing the relationship between N, Q, and A values.
[0014] Figure 4 This is an embodiment of the present invention, showing a part of the result values calculated from different equations with the same quantization level / parameter Q = 3 (D values range from -3 to 14).
[0015] Figure 5 This is an embodiment of the present invention, showing a schematic diagram of a segment decoder 500 for a Bayer array image.
[0016] [Symbol Description]
[0017] 110 Image sensor
[0018] 120 ISP
[0019] 130 DRAM
[0020] 200 Section Encoder
[0021] 210 Subtractor
[0022] 220 Quantizer
[0023] 230 Variable - Length Encoder
[0024] 240 Limiter
[0025] 250, 510 Predictor
[0026] 260 Adder
[0027] 270 Multiplier
[0028] 500 Section Decoder
[0029] 510 Variable - Length Decoder Detailed Implementation Manner
[0030] The relevant terms mentioned throughout the specification and the subsequent claims are defined as follows, unless otherwise specifically specified in this specification: Singular terms such as "a" and "the" both include the singular and plural meanings; the symbol " / " includes the meanings of "or" and "and". Throughout the specification, circuit elements with the same function are denoted by the same reference symbols.
[0031] Please note that the encoding - decoding system 100 embedded in the ISP 120 is only an example and not a limitation of the present invention. In actual implementation, the encoding - decoding system 100 can adopt any other configuration, such as being embedded in other image - processing devices, which also falls within the scope of the present invention.
[0032] Figure 1 This is an embodiment of the present invention, showing an example of an encoding - decoding system 100. Refer to Figure 1, the codec system 100 is embedded in the ISP 120 of an imaging system (such as a digital camera). The ISP 120 receives the Bayer array image from the image sensor 110 (such as a Bayer CFA) through the Mobile Industry Processor Interface (MIPI), and before performing the demosaicing step, selectively performs zero or more steps in the denoising, white balancing, color transform, exposure correction, and gamma correction steps to generate an LSDR image. In the LSDR image, each pixel has only one color and is represented by 8, 10, 12, 14, or 16-bit data (i.e., the bit width). Since these LSDR images are taken at different time points, the codec system 100 sequentially compresses these LSDR images and stores them in the DRAM 130. After that, the codec system 100 reads back the data compression data and decompression data from the DRAM 130. Then, the ISP 120 combines the images to generate an HDR image. Figure 1 The codec system 100 in the embodiment of Figure 2 the segment encoder 200 and Figure 5 the segment decoder 500. At the same time, the segment encoder 200 and the segment decoder 500 are disposed within the ISP 120. In another embodiment, the segment encoder 200 and the segment decoder 500 are respectively disposed in two different imaging devices / systems.
[0033] Figure 2 This is an embodiment of the present invention, showing a schematic diagram of the segment encoder 200 for the Bayer array image. Refer to Figure 2 , the segment encoder 200 of the present invention includes a subtractor 210, a quantizer 220, a variable length coder (VLC) 230, a clipper 240, a predictor 230, an adder 260, and a multiplier 270. Generally, each LSDR image is divided into multiple segments and fed into the segment encoder 200 in a segment-by-segment and pixel-by-pixel manner. The operation modes of the segment encoder 200 and the segment decoder 500 are described in detail below, and it is assumed that the width W of each segment is 32 pixels and each pixel has only one color and is represented by 8-bit (n = 8) data, where n represents the bit width of the input pixel s[k].
[0034] An input pixel s[k] of a current section of a current LSDR image is fed into a subtractor 210. After that, the subtractor 210 subtracts the value of the current predicted pixel p[k] from the value of the input pixel s[k] to obtain a difference D, where k = 0 to 31. Then, a quantizer 220 quantizes the difference D according to a quantization step / parameter Q, for example, calculates to generate a quantized value delta, where represents the floor function. However, in a computer system, division is not easy to implement, but multiplication and right shift are relatively easy to implement. In one embodiment, the following code and Equation 1 are provided in the quantizer 220 for quantization:
[0035]
[0036] delta = D < 0? -Δ : Δ; / / If D < 0, delta = -Δ, otherwise, delta = Δ
[0037] where both N and A are integers. If the input pixel s[k] contains an n-bit data, then N = 2 n . Since N is a power of 2, "right shift" can be used to replace division. For example, if N = 4096, the numerator has to be right-shifted 12 times / bit to obtain the Δ value.
[0038] Figure 3 Shows the relationship between the values of N, Q, and A. Figure 3 The A value in n must satisfy the condition: (Q × A + 1) = N. When choosing the A value, the selected N value must be greater than or equal to the corresponding 2 n value. For example, assume n = 10 and Q = 5. According to Figure 3 , in the third column from the left, no A value is supported; at this time, there are two choices. One can choose A = 819 in the column corresponding to N = 4096, or choose A = 13107 in the column corresponding to N = 65536. Note that both of the above corresponding N values are greater than 2 10 (n = 10).
[0039] Figure 4 Shows a part of the result values calculated by different equations with the same quantization step / parameter Q = 3 (D value ranges from -3 to 14), where Equation is existing, and Equation 1 is calculated according to N = 4096 and A = 1365. Figure 4 The second row in the table shows the result value of calculating , and Equation is derived from a modified version. From Figure 4 It can be observed that, compared with the quotient of the second row (row), the distribution of the calculated result values of the third row (Equation 2) is even more averaged, and all groups are centered around multiples of 3. In order to approximate the calculated result values of Equation 2, Equation 3 has been previously published in the industry. However, it is obvious that the data in the third row and the fourth row do not match, and in the fourth row corresponding to Equation 3, the data near D = 0 are not evenly distributed; on the contrary, the data in the third row (Equation 2) and the fifth row (Equation 1) match perfectly. The absolute correctness and even distribution of the calculated result values of Equation 1 of the present invention minimize the quantization error and assist in lossless compression / decompression, where the above quantization error refers to the difference between the difference D and its quantization value delta.
[0040] Returning to Figure 2 , the VLC 230 encodes a sequence of quantization values delta using the run value coding method of the present invention to generate a coded bitstream. In this specification, the term "zero-run (ZR)" refers to the number of consecutive zeros in the above sequence of quantization values delta, and these consecutive zeros are located before the next non-zero integer in the quantization sequence or at the end of the quantization sequence. Table 1 shows the coding table for different ZRs (i.e., different numbers of consecutive zeros).
[0041]
[0042] In Table 1, the term "end of segment (EOS)" refers to the situation in the above-mentioned quantization value delta sequence where the subsequent / remaining values (until the end of the quantization value delta sequence) are all equal to 0. The term "ESC-run (ER)" refers to a preset number of consecutive zeros in the above-mentioned quantization value delta sequence; thus, in the above-mentioned quantization value delta sequence, when ZR > ER, ZR consecutive zeros are encoded as ER plus (ZR - ER) consecutive zeros. For example, 7 consecutive zeros (ZR = 7 and ER = 3) are encoded in the format of {3, 3, 1}, that is, 10’b1110111010. In Table 1, the five codewords are five unary codes, corresponding to 0 zeros (i.e., no zeros), 1 zero, 2 zeros, 3 zeros, and the situation where the remaining values (until the end of the sequence) are all equal to 0 in the above-mentioned quantization value delta sequence respectively. In Table 1, each codeword (i.e., each unary code) uses ZR 1s plus a 0 to represent a corresponding ZR value. However, this is not a limitation of the present invention. In another embodiment, each codeword (i.e., each unary code) uses ZR 0s plus a 1 to represent a corresponding ZR value.
[0043] Table 2 shows the encoding table for non-zero integers.
[0044]
[0045]
[0046] In Table 2, x represents 0 or 1, and s represents the sign of the delta value; in addition, the larger the magnitude of the delta value, the larger the number of bits / depth in the corresponding codeword. For example, if "s = +1" represents a negative sign, the delta value of -5 is encoded as the codeword 6’b110011, and the delta value of +8 is encoded as the codeword 8’b11100000. Each codeword sequentially includes a class code, an index code, and a sign code, where the class code is a unary code. For a non-zero delta value equal to -9, using the unary encoding method to encode its class q produces a class code 4’b1110, where using q bits and in binary format to represent an integer C = |-9| modulo 2 q= 1 to generate an index code 3'b001; finally, append a sign bit value of 1 to the index code to form a codeword 8'b11100011. In each codeword in Table 2, each stage code (i.e., each unary code) uses q 1s plus a 0 to represent a stage q, and the index code is arranged between the stage code and the sign code. However, this is not a limitation of the present invention. In another embodiment, in each codeword, each stage code (i.e., each unary code) uses q 0s plus a 1 to represent a stage q, and the sign code is arranged between the stage code and the index code.
[0047] One of the features of the operation value encoding method of the present invention is that: according to the encoding tables in Table 1 and Table 2, consecutive zeros and non-zero integers are encoded in an alternating manner. In other words, the output of the VLC 230 includes two flags, which are repeated continuously until the end of the segment. These two flags are respectively the first codeword representing ZR consecutive zeros (determined by Table 1) and the second codeword representing a non-zero integer (determined by Table 2). For example, after receiving the following quantization value delta sequence (a total of W quantization values delta): {+2, -3, 0, 0, 0, 1, 4, 0, 0, 0, 0…, 0}, the VLC 230 regards (+2) as "ZR = 0 plus (+2)" and encodes it as 5'b01000 (= 1'b0 + 4'b1000); the VLC 230 regards (-3) as "ZR = 0 plus (-3)" and encodes it as 5'b01011 (= 1'b0 + 4'b1011); the VLC 230 regards {0, 0, 0, 1} as "ER = 3, ZR = 0 plus (+1)" and encodes it as 7'b1110000 (= 4'b1110 + 1'b0 + 2'b00); the VLC 230 regards the subsequent / remaining zeros in the end segment of the sequence: {0, 0, 0, 0…, 0} as EOS and encodes it as a single codeword 4'1111.
[0048] In one embodiment, the following code is provided in the VLC 230 to encode the quantization value delta sequence:
[0049]
[0050]
[0051]
[0052] Next, the multiplier 270 multiplies each delta value by Q to obtain a product value cp. Then, the adder 260 adds the product value cp and the current predicted value p[k] to obtain a sum V. Then, the limiter 240 receives the sum V according to the minimum value Mi and the maximum value Ma to generate a current reconstructed pixel r[k], so Mi <= r[k] <= Ma.
[0053] In one embodiment, the following code is provided in predictor 250 for prediction: p[k] = k <= 1? (bx == 0? dc : r[W - 2 + k]) : r[k - 2];
[0054] (bx, by) are the coordinates of the leftmost pixel of the current segment in the current LSDR image, W is the width of the current segment, and dc = 2 n-1 , where bx = 0 to (Wi - 1) and by = 0 to (Hi - 1), and Wi and Hi represent the width and height of each LSDR image respectively. The above code for prediction performs the following steps: (1) When k > 1, the value of the current predicted pixel p[k] is equal to the value of the second immediately preceding reconstructed pixel r[k - 2] (if k > 1, then p[k] = r[k - 2]); (2) If k <= 1, check whether bx is equal to 0; (3) If bx = 0, it means that the current segment is located at the leftmost side of the current LSDR image, so set p[k] = dc = 2 n-1 ; (4) If bx ≠ 0 and k <= 1, set p[k] = r[W - 2 + k], where r[W] is a one-dimensional array of size W that is shared and overwriteable. If bx ≠ 0, it means that the current segment is not located at the leftmost side of the current LSDR image.
[0055] Figure 5 This is an embodiment of the present invention, showing a schematic diagram of a segment decoder 500 for a Bayer array image. Refer to Figure 5 , the segment decoder 500 of the present invention includes a variable length decoder (VLD) 510, a clipper 240, a predictor 520, an adder 260, and a multiplier 270. Generally speaking, the decoding process performed by the segment decoder 500 is opposite to the encoding process performed by the above segment encoder 200. The VLD 510 compares the front / leading bit pattern of the encoded bitstream with all the codewords in Table 1 and Table 2 in an alternating manner to generate a decoded value delta in a decoded data sequence. The decoded value delta can be a group of consecutive zeros (i.e., a series of zeros) or a non-zero integer. In other words, the VLD 510 first compares the front / leading bit pattern of the encoded bitstream with all the codewords in Table 1 to generate a corresponding decoded value delta, and then compares the next front / leading bit pattern of the encoded bitstream with all the codewords in Table 2 to generate a corresponding decoded value delta. In this way, the above process is repeated until the entire encoded bitstream is processed. For details, please refer to the following code.
[0056] The structures and operations of predictors 250 and 520 are similar. For example, the following code is provided in predictor 520 for prediction: p[k] = k <= 1? (ax == 0? dc : r[W - 2 + k]) : r[k - 2];
[0057] (ax, ay) are the coordinates of the leftmost pixel of the current reconstructed segment in the current decompressed / reconstructed LSDR image, k represents the index value of the current reconstructed pixel in the current reconstructed segment, W is the width of the current reconstructed segment, and dc = 2 n-1 , where k = 0 to (W - 1), ax = 0 to (Wi - 1), and ay = 0 to (Hi - 1), and Wi and Hi represent the width and height of each reconstructed LSDR image respectively. The code for the prediction of predictor 520 performs the following steps: (1) When k > 1, the value of the current predicted pixel p[k] is equal to the value of the second previous reconstructed pixel r[k - 2] (if k > 1, then p[k] = r[k - 2]); (2) If k <= 1, check whether ax is equal to 0; (3) If ax = 0, it means that the current reconstructed segment is located at the leftmost of the current reconstructed LSDR image, so set p[k] = dc = 2 n-1 ; (4) If ax ≠ 0 and k <= 1, set p[k] = r[W - 2 + k], where r[W] is a one-dimensional array of size W, shared and overwriteable. If ax ≠ 0, it means that the current reconstructed segment is not located at the leftmost of the current reconstructed LSDR image.
[0058] As for the remaining components (240, 260, and 270) of segment decoder 500, they operate in the same way as in segment encoder 200 and will not be elaborated further. Finally, segment decoder 500 outputs the current reconstructed pixel r[k] of the current reconstructed segment. 32 reconstructed pixels (since W = 32) form a reconstructed segment, and a set of reconstructed segments forms a reconstructed LSDR image. In one embodiment, the following code is provided in VLD 510 to decode the encoded bitstream:
[0059]
[0060]
[0061]
[0062]
[0063] In the above code, the function peep(m, ptr) represents reading m bits from the current pointer / address ptr without changing ptr; the function fetch(m, ptr) represents reading m bits from the current pointer / address ptr and changing ptr to (ptr + m), where ptr is a pointer / address pointing to the front end of the encoded bit stream.
[0064] In short, the compression ratio of the segment encoder 200 of the present invention is greater than or equal to 2x; in addition, the encoded bit stream output by the segment encoder 200 can be mathematically reversed and decompressed in the segment decoder 500 to generate a high-quality reconstructed image, so that, to the human eye, it is exactly the same as the input image (fed into the segment encoder 200). Furthermore, the process of encoding and decoding using the encoding tables in Table 1 and Table 2 of the present invention is both simple and accurate.
[0065] The segment encoder 200 and the segment decoder 500 of the present invention can be implemented by software, customized hardware (such as a field programmable gate array or an application specific integrated circuit), or a combination of software (or firmware) and hardware. In a preferred embodiment, the VLC 230 and the predictor 250 in the segment encoder 200 are implemented using at least one first storage device and at least one first general-purpose processor; the VLD 510 and the predictor 520 in the segment decoder 500 are implemented using at least one second storage device and at least one second general-purpose processor. The at least one first storage device stores a first processor-executable program, and the at least one second storage device stores a second processor-executable program. When the at least one first general-purpose processor executes the first processor-executable program, the at least one first general-purpose processor is configured to operate as: VLC 230 and predictor 250. When the at least one second general-purpose processor executes the second processor-executable program, the at least one second general-purpose processor is configured to operate as: VLD 510 and predictor 520.
[0066] The above is only a preferred embodiment of the present invention and is not intended to limit the scope of the patent application of the present invention; all other equivalent changes or modifications made without departing from the spirit disclosed by the present invention shall be included in the above patent application scope.
Claims
1. A video encoding device for Bayer array images, characterized in that Comprising: A quantizer for quantizing a difference D between an input pixel and a current predicted pixel according to a quantization parameter Q and an equation to generate a quantization value Δ in a quantization sequence, wherein the equation is A predictor, coupled to the quantizer, for performing a first set of operations, including: providing the current predicted pixel according to the position of a current section in a current Bayer array image; and A variable length encoder, coupled to the quantizer, for performing a second set of operations, including: (1) calculating the number ZR of consecutive zeros, where ZR consecutive zeros are located before the next non-zero integer in the quantization sequence or at the end section of the quantization sequence; (2) encoding the ZR consecutive zeros into a first codeword with a first set of codewords; (3) encoding the next non-zero integer into a second codeword with a second set of codewords; and (4) repeating the second operations (1) to (3) until all quantization values in the quantization sequence are processed to generate a coded byte; where A satisfies the following equation: (Q × A + 1) = N; and where N = 2 d ≥ 2 n , n represents the bit width of the input pixel and d is an integer.
2. The device according to claim 1, characterized in that, Further comprising: A subtractor, coupled between the quantizer and the predictor, for subtracting the value of the current predicted pixel from the value of the input pixel to generate the difference D.
3. The device according to claim 1, characterized in that, Further comprising: A multiplier, coupled between the quantizer and the variable length encoder, for multiplying the quantization value by Q to obtain a product value; And An adder, coupled between the predictor and the multiplier, for adding the product value to the current predicted pixel to obtain a current reconstructed pixel.
4. The device according to claim 1, characterized in that, The first set of codewords includes a first unary code, a second unary code, a third unary code, a fourth unary code, and a fifth unary code, corresponding to 0 zero, 1 zero, 2 zeros, 3 zeros in the quantization sequence respectively, and subsequent quantization values all being equal to zero, and the length of each unary code in the first set of codewords is less than 5 bits.
5. The device according to claim 4, characterized in that The second operation of encoding the ZR consecutive zeros into the first codeword with the first set of codewords in (2) includes: When ZR >= 3 and the ZR consecutive zeros are located before the next non-zero integer in the quantization sequence, (21) generating the fourth unary code as part of the first codeword, (22) setting ZR equal to (ZR - 3), and (23) repeating the second operations (21) and (22) until ZR < 3; When ZR = 0 and the ZR consecutive zeros are located before the next non-zero integer in the quantization sequence, generating the first unary code as part of the first codeword; When ZR = 1 and the ZR consecutive zeros are located before the next non-zero integer in the quantization sequence, generating the second unary code as part of the first codeword; When ZR = 2 and the ZR consecutive zeros are located before the next non-zero integer in the quantization sequence, generating the third unary code as part of the first codeword; and When ZR > 0 and the ZR consecutive zeros are located at the end section of the quantization sequence, setting the first codeword equal to the fifth unary code.
6. The device according to claim 1, wherein Each codeword of the second codeword group includes a class code and an index code, and the (3) second operation of encoding the next non-zero integer into the second codeword using the second codeword group includes: Encode q using a unary encoding to produce the class code, where and B represents the next non-zero integer; and An integer C is represented using (q + 1) bits and a binary format to form the index code, where C = |B| modulo 2 q , and one of the (q + 1) bits of the index code is a sign bit corresponding to the sign of B.
7. The device according to claim 1, characterized in that, The first operation of providing the current predicted pixel includes; When k > 1, providing the value of the current predicted pixel equal to the value of a previous second reconstructed pixel; When the current section is located at the leftmost side of the current Bayer array image, provide the value of the current predicted pixel to be equal to 2 n-1 ; When the current section is not located at the leftmost side of the current Bayer array image and k = 0, providing the value of the current predicted pixel equal to the value of the last second reconstructed pixel corresponding to the previous section; And When the current section is not located at the leftmost side of the current Bayer array image and k = 1, providing the value of the current predicted pixel equal to the value of the last reconstructed pixel corresponding to the previous section; Wherein, k represents the index number of the input pixel in the current section.
8. A video encoding method for Bayer array images, characterized in that, Including the following steps: Quantize a difference D between an input pixel and a current predicted pixel according to a quantization parameter Q and an equation to generate a quantization value Δ in a quantization sequence, where the equation is According to the position of a current section in a current Bayer array image, providing the current predicted pixel; Calculating the number of consecutive zeros ZR, where the ZR consecutive zeros are located before the next non-zero integer of the quantization sequence or at the end segment of the quantization sequence; Encoding the ZR consecutive zeros into a first codeword using a first codeword group; Encoding the next non-zero integer into a second codeword using a second codeword group; and Repeating the calculating step, the step of encoding the ZR consecutive zeros into the first codeword, and the step of encoding the next non-zero integer into the second codeword until all quantization values in the quantization sequence are processed to generate a coded byte; Wherein, A satisfies the following equation: (Q × A + 1) = N; and where N = 2 d ≥ 2 n , n represents the bit width of the input pixel and d is an integer.
9. The method according to claim 8, wherein Further includes: Subtracting the value of the current predicted pixel from the value of the input pixel to generate the difference D.
10. The method according to claim 8, wherein Further includes: Multiplying the quantization value by Q to obtain a product value; And Adding the product value to the current predicted pixel to obtain a current reconstructed pixel.
11. The method according to claim 8, wherein The first codeword group includes a first unary code, a second unary code, a third unary code, a fourth unary code, and a fifth unary code, corresponding to 0 zero, 1 zero, 2 zeros, 3 zeros in the quantization sequence respectively, and all subsequent quantization values are equal to zero, and the length of each unary code in the first codeword group is less than 5 bits.
12. The method according to claim 11, wherein The step of encoding the ZR consecutive zeros into the first codeword includes: When ZR >= 3 and the ZR consecutive zeros are located before the next non-zero integer of the quantization sequence, (a) Generating the fourth unary code as part of the first codeword, (b) Setting ZR equal to (ZR - 3), (c) Repeating steps (a) and (b) until ZR < 3; When ZR = 0 and the ZR consecutive zeros are located before the next non-zero integer of the quantization sequence, generating the first unary code as part of the first codeword; When ZR = 1 and the ZR consecutive zeros are located before the next non-zero integer of the quantization sequence, generating the second unary code as part of the first codeword; When ZR = 2 and the ZR consecutive zeros are before the next non-zero integer in the quantization sequence, generate the third unary code as part of the first codeword; When ZR > 0 and the ZR consecutive zeros are at the end segment of the quantization sequence, set the first codeword equal to the fifth unary code.
13. The method according to claim 8, wherein Each codeword of the second codeword group includes a class code and an index code, and the step of encoding the next non-zero integer as the second codeword includes: Encode q using unary encoding to obtain the class code, where and B represents the next non-zero integer; An integer C is represented using (q + 1) bits and a binary format to form the index code, where C = |B| modulo 2 q and one of the (q + 1) bits of the index code is a sign bit corresponding to the sign of B.
14. The method according to claim 8, wherein The step of providing the current predicted pixel includes: When k > 1, provide the value of the current predicted pixel equal to the value of a previous second reconstructed pixel; When the current section is located at the leftmost side of the current Bayer array image, provide the value of the current predicted pixel to be equal to 2 n-1 ; When the current segment is not at the leftmost side of the current Bayer array image and k = 0, provide the value of the current predicted pixel equal to the value of the second last reconstructed pixel corresponding to the previous segment; and When the current segment is not at the leftmost side of the current Bayer array image and k = 1, provide the value of the current predicted pixel equal to the value of the last reconstructed pixel corresponding to the previous segment; where k represents the index number of the input pixel in the current segment.
15. A video decoding device for a Bayer array image, characterized in that, Comprising: A variable length decoder for performing a set of first operations, including: in an alternating manner, comparing the leading bit pattern of an encoded byte with all the codewords in a first codeword group and a second codeword group to generate a decoded value, the decoded value can be a set of consecutive zeros or a non-zero integer; and A predictor coupled to the variable length decoder for performing a set of second operations, including: providing a current predicted pixel according to the position of a current reconstructed segment in a current reconstructed Bayer array image.
16. The device according to claim 15, characterized in that, Further comprising: A multiplier coupled to the variable length decoder for multiplying the decoded value by a quantization parameter to obtain a product value; And An adder coupled between the predictor and the multiplier for adding the product value and the current predicted pixel to obtain a current reconstructed pixel of the current reconstructed segment.
17. The device according to claim 15, characterized in that, The first codeword group includes a plurality of unary codes, where the length of the unary code is less than 5 bits and corresponds to different numbers of consecutive zeros of the decoded value, and where the second codeword group includes a class code and an index code.
18. The device according to claim 17, characterized in that, The first codeword group includes a first unary code, a second unary code, a third unary code, and a fourth unary code corresponding to the decoded value equal to 0 zero, 1 zero, 2 zeros, and 3 zeros respectively, and where the first codeword group further includes a fifth unary code corresponding to the subsequent decoded values in the current reconstructed segment all being equal to zero.
19. The device according to claim 18, wherein The first operation of the comparison includes: Reset ZR, where ZR represents the number of consecutive zeros; Compare the 4-bit leading bit pattern with the five unary codes of the first codeword group; When the leading bit pattern matches the fifth unary code, set the subsequent decoded values in the current reconstructed segment all equal to zero; When the leading bit pattern matches the fourth unary code, (1) Add 3 to ZR, (2) Remove the first 4 bits before the encoded bitstream to restore the leading bit pattern, and (3) Repeat the first operations (1) to (2) until the leading bit pattern does not match the fourth unary code; When the leading bit pattern matches the first unary code, keep ZR unchanged; When the leading bit pattern matches the second unary code, add 1 to ZR; When the leading bit pattern matches the third unary code, add 2 to ZR; and When ZR > 0, provide the decoded value including ZR consecutive zeros.
20. The device according to claim 17, characterized in that, The first operation of the comparison includes: Calculate the number L of consecutive preset bit values in the front-end bit pattern N , so as to obtain the class code, where the class code is a unary code; Before removing the encoded bitstream (L N + 1) bits to provide the leading bit pattern of the next (L N + 1) bits as the index code; and Obtain the decoded value according to the class code and the index code; Among them, one of the (L N +1) bits of the index code is a sign bit.
21. The device according to claim 15, characterized in that, The second operation of providing the current predicted pixel includes: When k > 1, provide the value of the current predicted pixel equal to the value of a previous second reconstructed pixel; When the current reconstruction section is located at the leftmost side of the current reconstructed Bayer array image, provide the value of the current predicted pixel to be equal to 2 n-1 ; When the current reconstructed segment is not located at the leftmost side of the current reconstructed Bayer array image and k = 0, provide the value of the current predicted pixel equal to the value of the second last reconstructed pixel corresponding to the previous reconstructed segment; and When the current reconstructed segment is not located at the leftmost side of the current reconstructed Bayer array image and k = 1, provide the value of the current predicted pixel equal to the value of the last reconstructed pixel corresponding to the previous reconstructed segment; Wherein, k represents the index number of the current reconstructed pixel in the current reconstructed segment.
22. A video decoding method for a Bayer array image, characterized in that, Comprising the following steps: In an alternating manner, compare the leading bit pattern of an encoded byte with all the codewords in a first codeword group and a second codeword group to generate a decoded value, which can be a group of consecutive zeros or a non-zero integer; And Provide a current predicted pixel according to the position of a current reconstructed segment relative to a current reconstructed Bayer array image.
23. The method according to claim 22, wherein Further comprising: Multiply the decoded value by a quantization parameter to obtain a product value; And Add the product value to the current predicted pixel to obtain a current reconstructed pixel of the current reconstructed segment.
24. The method according to claim 22, wherein The first codeword group includes a plurality of unary codes, wherein the length of the unary code is less than 5 bits and corresponds to different numbers of consecutive zeros of the decoded value, and wherein the second codeword group includes a class code and an index code.
25. The method according to claim 24, wherein The first codeword group includes a first unary code, a second unary code, a third unary code, and a fourth unary code corresponding to the decoded value being equal to 0 zeros, 1 zero, 2 zeros, and 3 zeros respectively, wherein the first codeword group further includes a fifth unary code corresponding to the subsequent decoded values in the current reconstructed segment being all equal to 0.
26. The method according to claim 25, wherein The comparison step includes: Reset ZR, where ZR represents the number of consecutive zeros; Compare the 4-bit leading bit pattern with the five unary codes of the first codeword group; When the leading bit pattern matches the fifth unary code, set the subsequent decoded values in the current reconstructed segment to be all equal to 0; When the leading bit pattern matches the fourth unary code, (1) Add 3 to ZR, (2) remove the first 4 bits before the encoded bitstream to restore the leading bit pattern, and (3) repeat steps (1) to (2) until the leading bit pattern does not match the fourth unary code; When the leading bit pattern matches the first unary code, keep ZR unchanged; When the leading bit pattern matches the second unary code, add 1 to ZR; When the leading bit pattern matches the third unary code, add 2 to ZR; and When ZR > 0, provide the decoded value including ZR consecutive zeros.
27. The method according to claim 24, wherein The comparison step includes: Calculate the number L of consecutive preset bit values in the front-end bit pattern N , to obtain the class code, wherein the class code is a unary code; Remove the (L N + 1) bits before the encoded bitstream to provide the leading bit pattern of the next (L N + 1) bits as the index code; and Obtain the decoded value according to the class code and the index code; Among them, one of the (L N + 1) bits of the index code is a sign bit.
28. The method according to claim 22, characterized in that, The provided second operation includes: When k > 1, provide the value of the current predicted pixel equal to the value of a previous second reconstructed pixel; When the current reconstruction section is located at the leftmost side of the current reconstructed Bayer array image, provide the value of the current predicted pixel to be equal to 2 n-1 ; When the current reconstructed segment is not located at the leftmost side of the current reconstructed Bayer array image and k = 0, provide the value of the current predicted pixel equal to the value of the second last reconstructed pixel corresponding to the previous reconstructed segment; and When the current reconstructed segment is not located at the leftmost side of the current reconstructed Bayer array image and k = 1, provide the value of the current predicted pixel equal to the value of the last reconstructed pixel corresponding to the previous reconstructed segment; where k represents the index number of the current reconstructed pixel in the current reconstructed segment.