Image coding method, device, computer equipment, storage medium and program product

By allocating bit counts to the tiles in the current row of the image and building a bit count pool, dynamically obtaining the number of bits required for encoding, the problem of low image quality in traditional image encoding methods is solved, and more efficient image compression and better image image quality.

CN119172544BActive Publication Date: 2025-02-11深圳市欧冶半导体有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411661618.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-20
Publication Date
2025-02-11
Estimated Expiration
2044-11-20

AI Technical Summary

Technical Problem

When the traditional image encoding method encodes each row of the image, the fixed number of bits leads to a low quality of the encoded image.

Method used

By allocating the first number of bits to each tiles in the current row of the image, and building a bit count pool, dynamically obtaining the second number of bit count and the additional number of bit counts based on the filling degree of the bit count pool and the image complexity of the tiles to be encoded, the second number of bit count and the additional number of bit counts are performed. coding.

Benefits of technology

The encoded image quality is improved, especially the encoding effect of complex tiles, and the number of unused bits is effectively utilized, improving the image compression efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119172544B_ABST
    Figure CN119172544B_ABST
Patent Text Reader

Abstract

The present application relates to an image encoding method, apparatus, computer equipment, storage medium and program product. The method comprises: allocating a corresponding first number of bits to each block of the current row of the image in sequence; constructing a bit pool based on the spare number of bits; when encoding the block to be encoded in the current row, determining the fullness of the bit pool according to the waterline value of the bit pool; in the bit pool, obtaining a second number of bits according to the fullness and the image complexity of the block to be encoded; in addition, obtaining a first additional number of bits by using the fullness of the bit pool in the previous row; encoding the block to be encoded by using the first number of bits, the second number of bits and the first additional number of bits to obtain the encoding result of the block to be encoded. The use of this method can effectively improve the quality of the encoded image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image encoding method, apparatus, computer equipment, storage medium and program product. Background Art

[0002] Image coding (i.e., image compression) can effectively reduce the size of image data, which is beneficial to image storage, image transmission, and other downstream services, so images are usually encoded. Traditional solutions usually use a specific encoding method to encode each row of the image separately, such as using a fixed number of bits to encode each row of the image. This encoding method may result in low quality of the encoded image. Summary of the invention

[0003] Based on this, it is necessary to provide an image encoding method, apparatus, computer equipment, storage medium and program product to address the above technical problems, which can effectively improve the quality of encoded images.

[0004] In a first aspect, the present application provides an image encoding method, the method comprising:

[0005] Allocating corresponding first bit numbers to each block of the current row of the image in sequence;

[0006] Allocating spare bits for the current row, and building a bit pool based on the spare bits;

[0007] When encoding the to-be-encoded picture blocks of the current row, the fullness of the bit pool is determined according to the waterline value of the bit pool; wherein, after encoding of any picture block of the current row is completed, if the number of bits allocated to any picture block is not fully used, it is released to the bit pool; the waterline value is the minimum value of the number of spare bits in the bit pool during the encoding process;

[0008] In the bit number pool, a second bit number is obtained according to the fullness and the image complexity of the to-be-encoded image block;

[0009] If the pool fullness of the bit number pool in the preceding row meets the fullness condition, obtaining a third bit number in the bit number pool as the first additional bit number of the to-be-encoded image block; the preceding row is an upper row adjacent to the current row in the image;

[0010] The image block to be encoded is encoded using the first number of bits of the image block to be encoded, the second number of bits, and the first additional number of bits to obtain an encoding result of the image block to be encoded.

[0011] In one embodiment, the method further comprises:

[0012] Detecting the image complexity of the to-be-encoded image block;

[0013] The acquiring, in the bit number pool, a second bit number according to the fullness and the image complexity of the to-be-encoded picture block comprises:

[0014] The second number of bits to be allocated is determined according to the image complexity and the fullness, and the second number of bits is obtained from the bit number pool.

[0015] In one of the embodiments, the preceding row includes a first preceding row; after obtaining the second number of bits in the bit number pool according to the fullness and the image complexity of the to-be-encoded block, the method further includes:

[0016] Determine whether a waterline value of the first preceding row bit pool and a waterline value of the second preceding row bit pool are greater than or equal to a first preset number of bits; the second preceding row is an upper row of the image adjacent to the first preceding row;

[0017] If both are greater than or equal to the first preset number of bits, obtaining a fourth number of bits from the bit number pool as a second additional number of bits for the to-be-encoded picture block;

[0018] The step of encoding the image block to be encoded by using the first number of bits of the image block to be encoded, the second number of bits, and the first additional number of bits to obtain an encoding result of the image block to be encoded includes:

[0019] The image block to be encoded is encoded using the first number of bits, the second number of bits, the first additional number of bits, and the second additional number of bits of the image block to obtain an encoding result of the image block to be encoded.

[0020] In one embodiment, the method further comprises:

[0021] Determine whether the waterline value of the first preceding bit number pool is greater than the waterline value of the second preceding bit number pool;

[0022] If yes, obtaining a fifth number of bits from the bit number pool as a third additional number of bits of the to-be-encoded picture block;

[0023] The step of encoding the image block to be encoded by using the first number of bits of the image block to be encoded, the second number of bits, the first additional number of bits, and the second additional number of bits to obtain an encoding result of the image block to be encoded includes:

[0024] The image block to be encoded is encoded using the first number of bits, the second number of bits, the first extra number of bits, the second extra number of bits and the third extra number of bits of the image block to obtain an encoding result of the image block to be encoded.

[0025] In one of the embodiments, the pool fullness of the preceding bit pool satisfies the fullness condition including that the waterline value of the preceding bit pool is greater than or equal to a first preset bit number; and the method further includes:

[0026] If the waterline value of the bit pool of the previous row is less than the first preset bit number and greater than or equal to the second preset bit number, determining whether to allocate additional bits when encoding the previous row of the current row;

[0027] If no additional number of bits is allocated, encoding the to-be-encoded image block according to the first number of bits and the second number of bits to obtain an encoding result of the to-be-encoded image block;

[0028] If an additional number of bits is allocated, the to-be-encoded picture block is encoded according to the first number of bits, the second number of bits and the first additional number of bits to obtain an encoding result of the to-be-encoded picture block.

[0029] In one embodiment, the method further comprises:

[0030] If the fullness of the previous bit number pool does not meet the fullness condition, the to-be-encoded image block is encoded according to the first number of bits and the second number of bits to obtain an encoding result of the to-be-encoded image block.

[0031] In a second aspect, the present application further provides an image encoding device, the device comprising:

[0032] A first allocation module, used for sequentially allocating corresponding first bit numbers to each image block in a current row of the image;

[0033] A second allocation module, configured to allocate spare bits to the current row and construct a bit pool based on the spare bits;

[0034] A judgment module, used for determining the fullness of the bit pool according to the waterline value of the bit pool when encoding the to-be-encoded picture block of the current row; wherein, after encoding of any picture block of the current row is completed, if the number of bits allocated to any picture block is not used up, it is released to the bit pool; the waterline value is the minimum value of the number of spare bits in the bit pool during the encoding process;

[0035] an acquisition module, configured to acquire a second number of bits in the bit number pool according to the fullness and the image complexity of the to-be-encoded image block; if the pool fullness of the preceding bit number pool satisfies the fullness condition, acquire a third number of bits in the bit number pool as a first additional number of bits for the to-be-encoded image block; the preceding row is an upper row in the image adjacent to the current row;

[0036] The encoding module is used to encode the image block to be encoded by using the first number of bits of the image block to be encoded, the second number of bits and the first additional number of bits to obtain an encoding result of the image block to be encoded.

[0037] In one embodiment, the device further comprises:

[0038] A detection module, used for detecting the image complexity of the to-be-encoded image block;

[0039] The acquisition module is further used to determine the second number of bits required to be allocated according to the image complexity and the fullness, and to obtain the second number of bits from the bit number pool.

[0040] In one embodiment, the judgment module is further used to judge whether the waterline value of the first preceding row bit number pool and the waterline value of the second preceding row bit number pool are greater than or equal to a first preset bit number; the second preceding row is an upper row adjacent to the first preceding row in the image;

[0041] The acquisition module is further configured to acquire a fourth bit number from the bit number pool as a second additional bit number of the to-be-encoded image block if both are greater than or equal to the first preset bit number;

[0042] The encoding module is further used to encode the image block to be encoded using the first number of bits of the image block to be encoded, the second number of bits, the first additional number of bits and the second additional number of bits to obtain an encoding result of the image block to be encoded.

[0043] In one of the embodiments, the judgment module is further used to judge whether the waterline value of the first preceding bit number pool is greater than the waterline value of the second preceding bit number pool;

[0044] The acquisition module is further configured to, if yes, acquire a fifth bit number from the bit number pool as a third additional bit number of the to-be-encoded picture block;

[0045] The encoding module is used to encode the image block to be encoded using the first number of bits, the second number of bits, the first additional number of bits, the second additional number of bits and the third additional number of bits of the image block to be encoded, so as to obtain an encoding result of the image block to be encoded.

[0046] In one of the embodiments, the pool fullness of the preceding bit number pool satisfies the fullness condition including that the waterline value of the preceding bit number pool is greater than or equal to the first preset bit number;

[0047] The determination module is further configured to determine whether to allocate additional bits when encoding the previous row of the current row if the waterline value of the bit number pool of the previous row is less than the first preset bit number and greater than or equal to the second preset bit number;

[0048] The encoding module is also used to, if no additional bits are allocated, encode the image block to be encoded according to the first number of bits and the second number of bits to obtain an encoding result of the image block to be encoded; if additional bits are allocated, encode the image block to be encoded according to the first number of bits, the second number of bits and the first additional number of bits to obtain an encoding result of the image block to be encoded.

[0049] In one of the embodiments, the encoding module is further used to encode the image block to be encoded according to the first number of bits and the second number of bits to obtain an encoding result of the image block to be encoded if the fullness of the previous bit number pool does not meet the fullness condition.

[0050] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the image encoding method when executing the computer program.

[0051] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the image encoding method are implemented.

[0052] In a fifth aspect, the present application also provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the image encoding method are implemented.

[0053] The above-mentioned image encoding method, apparatus, computer equipment, storage medium and computer program product sequentially allocate a corresponding first number of bits to each block of the current row of the image, allocate a spare number of bits to the current row, and construct a bit number pool based on the spare number of bits, so as to be beneficial in increasing the number of additional bits when encoding each block of the current row; therefore, when encoding the blocks to be encoded in the current row, the fullness of the bit number pool is determined according to the waterline value of the bit number pool; wherein, after the encoding of any block of the current row is completed, if the number of bits allocated to any block has not been used up, it is released to the bit number pool; the waterline value is the number of spare bits in the bit number pool reached during the encoding process. minimum value; in the bit pool, a second number of bits is obtained according to the fullness and the image complexity of the to-be-encoded picture block; in addition, in addition to considering the image complexity, the pool fullness of the preceding bit pool is also considered, and a first additional number of bits is obtained in the bit pool, and the to-be-encoded picture block is encoded according to the first number of bits, the second number of bits and the first additional number of bits of the to-be-encoded picture block, which can effectively improve the image quality of the complex picture block after encoding; in addition, for the picture block with low complexity, the number of bits that are not used up during encoding can also be released to the bit pool, so that it can be applied to the encoding of the picture block with high complexity, which is beneficial to improving the image quality of the complex picture block after encoding. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] FIG1 is a diagram showing an application environment of an image encoding method according to an embodiment;

[0055] FIG2 is a schematic diagram of a flow chart of an image encoding method in one embodiment;

[0056] FIG3 is a schematic diagram of a flow chart of an image encoding method in another embodiment;

[0057] FIG4 is a block diagram of a structure of an image encoding device according to an embodiment;

[0058] FIG5 is a structural block diagram of an image encoding device in another embodiment;

[0059] FIG. 6 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0061] It should be noted that in the following description, the terms "first, second and third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first, second and third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.

[0062] The image encoding method provided in the embodiment of the present application can be applied in the application environment shown in FIG1. ​​In which, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers.

[0063] The image coding method can be executed by the terminal 102 or the server 104, or by the terminal 102 and the server 104 in collaboration. Taking the execution of the image coding method by the terminal 102 as an example, the terminal 102 sequentially allocates a corresponding first number of bits to each block of the current row of the image; allocates a spare number of bits to the current row, and builds a bit number pool based on the spare number of bits; when encoding the block to be encoded in the current row, determines the fullness of the bit number pool according to the waterline value of the bit number pool; wherein, after the encoding of any block of the current row is completed, if the number of bits allocated to any block has not been used up, then Release to the bit pool; the waterline value is the minimum value of the spare bits in the bit pool during the encoding process; in the bit pool, obtain the second bit according to the fullness and the image complexity of the block to be encoded; if the pool fullness of the preceding bit pool meets the fullness condition, then obtain the third bit in the bit pool as the first additional bit of the block to be encoded; the preceding row is the previous row adjacent to the current row in the image; use the first bit, the second bit and the first additional bit of the block to be encoded to encode the block to be encoded, and obtain the encoding result of the block to be encoded. After the encoding of the entire image is completed using the above-mentioned image encoding method, the encoding result of the entire image can be stored in the server 104, or sent to a friend through the server 104.

[0064] Among them, the terminal 102 can be a smart phone, a tablet computer, a laptop computer, a desktop computer, an Internet of Things device and a portable wearable device. The Internet of Things device can be a smart speaker, a smart TV, a smart air conditioner and a smart car device, etc.

[0065] Server 104 can be an independent physical server or a service node in a blockchain system. A peer-to-peer network is formed between the service nodes in the blockchain system. The peer-to-peer protocol is an application layer protocol running on the Transmission Control Protocol (TCP). In addition, server 104 can also be a server cluster composed of multiple physical servers, and can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.

[0066] In one embodiment, as shown in FIG. 2 , an image encoding method is provided. The method may be executed by the server or the terminal in FIG. 1 , or by the server and the terminal in collaboration. The method is described by taking the method executed by the terminal in FIG. 1 as an example, and includes the following steps:

[0067] S202, allocating corresponding first bit numbers to each block in the current row of the image in sequence.

[0068] The image can be a single image collected, such as a person image, a landscape image, an object image, a building image, and other types of images; it can also be a video frame in a video. Therefore, the image encoding method of the present application can be used to encode images or videos, thereby effectively compressing the size of images and videos. It should be pointed out that the image encoding process of the present application is essentially an image compression process.

[0069] The current row may be a row of an image that needs to be encoded in the image. Each image block of the current row may be a current row divided into different image blocks, such as a current row with a width and height of K×1 divided into a number of a different image blocks, each with a width and height of (K / a)×1.

[0070] It should be pointed out that when encoding each line of the image, the terminal will allocate a corresponding first number of bits (block_bit) to each block of the line; in addition, a spare number of bits will be allocated to the line to build a bit pool, so that during the encoding process, the corresponding size of bits (such as additional bits) will be dynamically selected from the bit pool, and the block will be encoded using the additional bits and the first number of bits allocated to the block and the second number of bits (pool_bit).

[0071] In one embodiment, the terminal may allocate an average number of first bits to each tile in the current row of the image based on the average image complexity of the tiles in the current row of the image, or the image complexity of regular tiles in the current row (i.e., regular complexity); in addition, the terminal may also allocate first bit numbers of different sizes to each tile in the current row in sequence, wherein the first bit number of each tile belongs to a specific selected value interval, and the difference between its maximum value and minimum value is not large, such as being less than or equal to a preset difference.

[0072] S204: Allocate spare bits for the current row, and build a bit pool based on the spare bits.

[0073] The number of spare bits may be the number of bits that can be dynamically allocated when facing a picture block with high complexity, thereby facilitating ensuring the image quality of the picture block with high complexity.

[0074] It should be noted that the sum of the first number of allocated bits and the number of spare bits must at least meet the compression ratio requirement.

[0075] S206, when encoding the to-be-encoded picture block of the current row, determining the fullness of the bit pool according to the waterline value of the bit pool.

[0076] Among them, after the encoding of any tile in the current row is completed, if the bits allocated to any tile are not used up, they are released to the bit pool, so that other tiles can obtain additional bits for encoding in combination with the actual image complexity when encoding.

[0077] The waterline value is the minimum value reached by the number of spare bits in the bit pool during the encoding process. If the spare bits in the bit pool are being consumed during the encoding process, the original number of spare bits in the bit pool will continue to decrease, assuming it decreases to a. At this time, when encoding to the next tile, due to the low image complexity of the tile, there will be remaining bits after encoding (that is, the allocated bits are not used up). At this time, the remaining bits after encoding will be released to the bit pool. At this time, the number of bits in the bit pool increases, but the original number of spare bits in the bit pool is still a, that is, the waterline value of the bit pool has not changed.

[0078] The fullness may be the degree to which the number of bits in the bit pool that can be used for allocation during encoding is sufficient, and its value range may be 0 to 1, where 0 indicates that the bit pool is not full, 1 indicates that the bit pool is very full, and a value between 0 and 0.5 indicates a low fullness, and a value between 0.5 and 1 indicates a high fullness. It should be noted that, under the condition of a certain image complexity, the greater the fullness, the more second bits are allocated, and the smaller the fullness, the fewer second bits are allocated.

[0079] The to-be-encoded block may be any block in the current row of the image that is currently to be encoded.

[0080] In one embodiment, after the terminal determines the size between the waterline value of the bit pool and the first preset bit number, the terminal can use the determination result to mark the fullness of the bit pool; in addition, it can also combine the second preset bit number to determine the size between the waterline value and the second preset bit number, and can use the determination result to mark the fullness of the bit pool.

[0081] For example, during the encoding process, the number of spare bits in the bit pool of the current row may be decreasing, that is, the waterline value of the bit pool is curr_line_min_pool. If curr_line_min_pool is greater than a threshold a (larger), it means that when allocating bits, the fullness of the bit pool is high, recorded as curr_line_bufferness = 1; if curr_line_min_pool is less than a threshold b (smaller), it means that when allocating bits, the fullness of the bit pool is low, recorded as curr_line_bufferness = 0. In addition, for the previous line (such as the previous line of the current line), the number of spare bits in the bit pool may have been decreasing during the encoding process, that is, the waterline value of the bit pool is prev_line_min_pool. If prev_line_min_pool is greater than a certain threshold a, it means that when allocating bits, the fullness of the bit pool is relatively high, recorded as prev_line_bufferness = 1; if prev_line_min_pool is less than a certain threshold b, it means that when allocating bits, the fullness of the bit pool is relatively low, recorded as prev_line_bufferness = 0.

[0082] S208: Obtain a second number of bits in the bit number pool according to the fullness and the image complexity of the to-be-encoded picture block.

[0083] In one embodiment, the terminal can detect the image complexity of the block to be encoded; therefore, when obtaining the second number of bits, the fullness of the bit pool of the current row can be obtained in advance, and then the second number of bits to be allocated can be determined based on the image complexity and the fullness, and the second number of bits can be obtained from the bit pool.

[0084] For example, during the encoding process, the number of spare bits in the bit pool of the current row may be decreasing, that is, the waterline value of the bit pool is curr_line_min_pool. If curr_line_min_pool is greater than a threshold a, the fullness of the bit pool curr_line_bufferness = 1; if curr_line_min_pool is less than a threshold b, the fullness of the bit pool curr_line_bufferness = 0.

[0085] S210: If the pool fullness of the preceding bit pool satisfies the fullness condition, a third number of bits is obtained from the bit pool as a first additional number of bits of the to-be-encoded picture block.

[0086] The preceding row may be the first preceding row, and specifically may be an upper row adjacent to the current row in the image, that is, a row adjacent to the current row that has been image encoded.

[0087] In one embodiment, the terminal determines whether the pool fullness of the preceding bit number pool meets the fullness condition, such as determining whether the waterline value of the preceding bit number pool is greater than or equal to the first preset bit number. If so, a third bit number is obtained in the bit number pool as the first additional bit number of the image block to be encoded.

[0088] In one embodiment, the above-mentioned preceding row includes a first preceding row; the terminal determines whether the waterline value of the first preceding row bit pool and the waterline value of the second preceding row bit pool are greater than or equal to the first preset number of bits; if both are greater than or equal to the first preset number of bits, a fourth number of bits is obtained from the bit pool as the second additional number of bits for the block to be encoded. In addition, the terminal may also allocate additional bits to the block to be encoded to obtain a second additional number of bits, that is, in addition to continuing to allocate additional bits from the bit pool, it may also be possible to allocate directly without using the bit pool in order to avoid the bit pool being insufficient for the allocation of subsequent blocks.

[0089] The second preceding row may be an upper row adjacent to the first preceding row in the image, that is, a row adjacent to the first preceding row that has been image encoded.

[0090] For example, the terminal may record the prev_line_bufferness of the previous two lines. When processing the current line, if the prev_line_bufferness of the n-2 line is 1 and the prev_line_bufferness of the n-1 line is 1, then when allocating the to-be-encoded blocks of the current line, in addition to the number of bits that originally need to be allocated (i.e., bit_1), an additional number of bits (i.e., bit_2) may be allocated.

[0091] In one embodiment, the terminal may also determine whether the waterline value of the first preceding bit number pool is greater than the waterline value of the second preceding bit number pool; if so, obtain the fifth number of bits from the bit number pool as the third additional number of bits for the to-be-encoded image block. In addition, the terminal may also directly allocate additional bits to the to-be-encoded image block to obtain the third additional number of bits.

[0092] For example, the terminal records the prev_line_min_pool of the previous two rows. When processing the current row, if the prev_line_min_pool of n-2 is greater than a threshold a, the prev_line_min_pool of n-1 is greater than the threshold a, and the prev_line_min_pool of n-1 is greater than the prev_line_min_pool of n-2, then when allocating the current row, in addition to the extra bit_1 and bit_2, an additional bit (i.e., bit_3) can be allocated; at this time, the number of bits allocated to the block to be encoded = block_bit+pool_bit+bit_1+bit_2+bit_3.

[0093] S212, encoding the image block to be encoded by using the first number of bits, the second number of bits and the first additional number of bits of the image block to be encoded, to obtain an encoding result of the image block to be encoded.

[0094] In one embodiment, the terminal may adopt a coding method such as GRC coding or bit plane coding to encode the block to be encoded using the first number of bits, the second number of bits and the first additional number of bits of the block to be encoded to obtain a coding result of the block to be encoded.

[0095] In one embodiment, the terminal can use the first number of bits, the second number of bits and the first extra number of bits of the block to be encoded to encode the block to be encoded, and obtain the encoding result of the block to be encoded; in addition, after obtaining the second extra number of bits, the terminal can also use the first number of bits, the second number of bits, the first extra number of bits and the second extra number of bits of the block to be encoded to encode the block to be encoded, and obtain the encoding result of the block to be encoded; in addition, after obtaining the third extra number of bits, the terminal can also use the first number of bits, the second number of bits, the first extra number of bits, the second extra number of bits and the third extra number of bits of the block to be encoded to encode the block to be encoded, and obtain the encoding result of the block to be encoded.

[0096] In the above embodiment, the case where the waterline value is greater than or equal to the first preset number of bits is considered. Next, the case where the waterline value is less than the first preset number of bits is analyzed, as follows:

[0097] In one embodiment, if the waterline value of the previous bit pool of the terminal is less than the first preset bit number and greater than or equal to the second preset bit number, the terminal determines whether to allocate additional bits when encoding the previous row of the current row; if the additional bits are not allocated, the block to be encoded is encoded according to the first bit number and the second bit number to obtain the encoding result of the block to be encoded; if the additional bits are allocated, the block to be encoded is encoded according to the first bit number, the second bit number and the first additional bit number to obtain the encoding result of the block to be encoded.

[0098] In another embodiment, if the fullness of the previous bit number pool does not meet the fullness condition, the block to be encoded is encoded according to the first bit number and the second bit number to obtain the encoding result of the block to be encoded.

[0099] For example, if the corresponding prev_line_bufferness=0, no additional bits are allocated to each block of the current row; if prev_line_min_pool is between thresholds a and b, it is determined whether additional bits are allocated to the previous row; if additional bits are allocated when the previous row is processed, additional bits are allocated to the current row; if additional bits are not allocated when the previous row is processed, additional bits are not allocated to the current row either.

[0100] As an example, the solution of the present application is described in conjunction with FIG3 , as follows:

[0101] When encoding the tiles in the previous row, record the watermark value of the previous row pool; when the current row needs to be processed, first allocate a certain number of bits to each tile in the current row, and allocate a certain number of bits as a pool; detect the complexity of each tile in the current row; calculate the number of bits that need to be reallocated based on the number of allocated bits, complexity, the watermark value of the previous row pool, and the watermark value of the current row pool; encode the tiles in the current row using the originally allocated number of bits and the reallocated number of bits. The reallocated number of bits includes the second number of bits and each additionally allocated number of bits.

[0102] In the above embodiment, the corresponding first number of bits is allocated to each block of the current row of the image in turn, and a spare number of bits is allocated to the current row. A bit pool is constructed based on the spare number of bits, which can help to increase the number of additional bits when encoding each block of the current row; therefore, when encoding the blocks to be encoded in the current row, the fullness of the bit pool is determined according to the waterline value of the bit pool; wherein, after the encoding of any block of the current row is completed, if the number of bits allocated to any block is not used up, it is released to the bit pool; the waterline value is the minimum value reached by the number of spare bits in the bit pool during the encoding process; in the bit pool , obtaining a second number of bits according to the fullness and image complexity of the to-be-encoded image block; in addition, in addition to considering the image complexity, the pool fullness of the preceding bit pool is also considered, obtaining a first additional number of bits in the bit pool, and encoding the to-be-encoded image block according to the first number of bits, the second number of bits and the first additional number of bits of the to-be-encoded image block, which can effectively improve the image quality of the complex image block after encoding; in addition, for the image block with low complexity, the number of bits that are not used up during encoding can also be released to the bit pool, so that it can be applied to the encoding of the image block with high complexity, which is beneficial to improving the image quality of the complex image block after encoding.

[0103] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0104] Based on the same inventive concept, the embodiment of the present application also provides an image coding device for implementing the above-mentioned image coding method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more image coding device embodiments provided below can refer to the limitations on the image coding method above, and will not be repeated here.

[0105] In one embodiment, as shown in FIG. 4 , an image encoding device is provided, including: a first allocation module 402, a second allocation module 404, a determination module 406, an acquisition module 408 and an encoding module 410, wherein:

[0106] A first allocation module 402, configured to sequentially allocate a corresponding first number of bits to each block in a current row of the image;

[0107] A second allocation module 404 is used to allocate spare bits for the current row and build a bit pool based on the spare bits;

[0108] The judgment module 406 is used to determine the fullness of the bit pool according to the waterline value of the bit pool when encoding the block to be encoded in the current row; wherein, after the encoding of any block in the current row is completed, if the number of bits allocated to any block is not used up, it is released to the bit pool; the waterline value is the minimum value of the number of spare bits in the bit pool during the encoding process;

[0109] An acquisition module 408, configured to acquire a second number of bits in the bit number pool according to the fullness and the image complexity of the to-be-encoded image block;

[0110] The encoding module 410 is used to encode the image block to be encoded by using the first number of bits, the second number of bits and the first additional number of bits of the image block to be encoded, so as to obtain an encoding result of the image block to be encoded.

[0111] In one embodiment, as shown in FIG5 , the device further comprises:

[0112] A detection module 412, used to detect the image complexity of the to-be-encoded image block;

[0113] The acquisition module 408 is further used to determine the second number of bits required to be allocated according to the image complexity and fullness, and obtain the second number of bits from the bit pool.

[0114] In one embodiment, the determination module 406 is further configured to determine whether a waterline value of a first preceding row bit pool and a waterline value of a second preceding row bit pool are greater than or equal to a first preset number of bits; the second preceding row is a previous row adjacent to the first preceding row in the image;

[0115] The acquisition module 408 is further configured to acquire a fourth bit number from the bit number pool as a second additional bit number of the to-be-encoded picture block if both are greater than or equal to the first preset bit number;

[0116] The encoding module 410 is further configured to encode the image block to be encoded by using the first bit number, the second bit number, the first additional bit number and the second additional bit number of the image block to be encoded, to obtain an encoding result of the image block to be encoded.

[0117] In one embodiment, the determination module 406 is further configured to determine whether the waterline value of the first preceding bit number pool is greater than the waterline value of the second preceding bit number pool;

[0118] The obtaining module 408 is further configured to obtain, if yes, a fifth number of bits from the bit number pool as a third additional number of bits of the to-be-encoded picture block;

[0119] The encoding module 410 is used to encode the image block to be encoded by using the first bit number, the second bit number, the first extra bit number, the second extra bit number and the third extra bit number of the image block to obtain an encoding result of the image block to be encoded.

[0120] In one of the embodiments, the pool fullness of the preceding bit number pool satisfies the fullness condition including that a waterline value of the preceding bit number pool is greater than or equal to a first preset bit number;

[0121] The determination module 406 is further configured to determine whether to allocate additional bits when encoding the previous row of the current row if the waterline value of the bit pool of the previous row is less than the first preset bit number and greater than or equal to the second preset bit number;

[0122] The encoding module 410 is also used to, if no additional bits are allocated, encode the image block to be encoded according to the first bit number and the second bit number to obtain the encoding result of the image block to be encoded; if additional bits are allocated, encode the image block to be encoded according to the first bit number, the second bit number and the first additional bit number to obtain the encoding result of the image block to be encoded.

[0123] In one of the embodiments, the encoding module 410 is further used to encode the image block to be encoded according to the first bit number and the second bit number to obtain the encoding result of the image block to be encoded if the fullness of the previous bit number pool does not meet the fullness condition.

[0124] In the above embodiment, the corresponding first number of bits is allocated to each block of the current row of the image in turn, and a spare number of bits is allocated to the current row. A bit pool is constructed based on the spare number of bits, which can help to increase the number of additional bits when encoding each block of the current row; therefore, when encoding the blocks to be encoded in the current row, the fullness of the bit pool is determined according to the waterline value of the bit pool; wherein, after the encoding of any block of the current row is completed, if the number of bits allocated to any block is not used up, it is released to the bit pool; the waterline value is the minimum value reached by the number of spare bits in the bit pool during the encoding process; in the bit pool , obtaining a second number of bits according to the fullness and image complexity of the to-be-encoded image block; in addition, in addition to considering the image complexity, the pool fullness of the preceding bit pool is also considered, obtaining a first additional number of bits in the bit pool, and encoding the to-be-encoded image block according to the first number of bits, the second number of bits and the first additional number of bits of the to-be-encoded image block, which can effectively improve the image quality of the complex image block after encoding; in addition, for the image block with low complexity, the number of bits that are not used up during encoding can also be released to the bit pool, so that it can be applied to the encoding of the image block with high complexity, which is beneficial to improving the image quality of the complex image block after encoding.

[0125] Each module in the above-mentioned image encoding device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0126] In one embodiment, a computer device is provided, which may be a server, including a processor, a memory, an input / output interface (I / O for short) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store image data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, an image encoding method is implemented.

[0127] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an image encoding method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.

[0128] Those skilled in the art will understand that the structure shown in FIG. 6 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0129] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above-mentioned image encoding method when executing the computer program.

[0130] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned image encoding method are implemented.

[0131] In one embodiment, a computer program product is provided, comprising a computer program, which implements the steps of the above-mentioned image encoding method when executed by a processor.

[0132] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0133] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0134] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0135] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. An image coding method, characterized in that: The method comprises: Allocating corresponding first bit numbers to each block of the current row of the image in sequence; Allocating spare bits for the current row, and building a bit pool based on the spare bits; When encoding the to-be-encoded picture blocks of the current row, the fullness of the bit pool is determined according to the waterline value of the bit pool; wherein, after encoding of any picture block of the current row is completed, if the number of bits allocated to any picture block is not fully used, it is released to the bit pool; the waterline value is the minimum value of the number of spare bits in the bit pool during the encoding process; In the bit number pool, a second bit number is obtained according to the fullness and the image complexity of the to-be-encoded image block; If the pool fullness of the bit number pool in the preceding row meets the fullness condition, obtaining a third bit number in the bit number pool as the first additional bit number of the to-be-encoded image block; the preceding row is an upper row adjacent to the current row in the image; The image block to be encoded is encoded using the first number of bits of the image block to be encoded, the second number of bits, and the first additional number of bits to obtain an encoding result of the image block to be encoded.

2. The method according to claim 1, characterized in that The method further comprises: Detecting the image complexity of the to-be-encoded image block; The acquiring, in the bit number pool, a second bit number according to the fullness and the image complexity of the to-be-encoded picture block comprises: The second number of bits to be allocated is determined according to the image complexity and the fullness, and the second number of bits is obtained from the bit pool.

3. The method according to claim 1, characterized in that The said prior is the first prior; After obtaining the second bit number in the bit number pool according to the fullness and the image complexity of the to-be-encoded picture block, the method further includes: Determine whether a waterline value of the first preceding row bit pool and a waterline value of the second preceding row bit pool are greater than or equal to a first preset number of bits; the second preceding row is an upper row of the image adjacent to the first preceding row; If both are greater than or equal to the first preset number of bits, obtaining a fourth number of bits from the bit number pool as a second additional number of bits for the to-be-encoded picture block; The step of encoding the image block to be encoded by using the first number of bits of the image block to be encoded, the second number of bits, and the first additional number of bits to obtain an encoding result of the image block to be encoded includes: The image block to be encoded is encoded using the first number of bits, the second number of bits, the first additional number of bits, and the second additional number of bits of the image block to obtain an encoding result of the image block to be encoded.

4. The method according to claim 3, characterized in that The method further comprises: Determine whether the waterline value of the first preceding bit number pool is greater than the waterline value of the second preceding bit number pool; If yes, obtaining a fifth number of bits from the bit number pool as a third additional number of bits of the to-be-encoded picture block; The step of encoding the image block to be encoded by using the first number of bits of the image block to be encoded, the second number of bits, the first additional number of bits, and the second additional number of bits to obtain an encoding result of the image block to be encoded includes: The image block to be encoded is encoded using the first number of bits, the second number of bits, the first extra number of bits, the second extra number of bits and the third extra number of bits of the image block to obtain an encoding result of the image block to be encoded.

5. The method according to claim 1, characterized in that The pool fullness of the preceding bit pool satisfies the fullness condition, including that the waterline value of the preceding bit pool is greater than or equal to a first preset bit number; the method further includes: If the waterline value of the bit pool of the previous row is less than the first preset bit number and greater than or equal to the second preset bit number, determining whether to allocate additional bits when encoding the previous row of the current row; If no additional number of bits is allocated, encoding the to-be-encoded image block according to the first number of bits and the second number of bits to obtain an encoding result of the to-be-encoded image block; If an additional number of bits is allocated, the to-be-encoded picture block is encoded according to the first number of bits, the second number of bits and the first additional number of bits to obtain an encoding result of the to-be-encoded picture block.

6. The method according to claim 5, characterized in that The method further comprises: If the fullness of the previous bit number pool does not meet the fullness condition, the to-be-encoded image block is encoded according to the first number of bits and the second number of bits to obtain an encoding result of the to-be-encoded image block.

7. An image encoding device, characterized in that The device comprises: A first allocation module, used for sequentially allocating corresponding first bit numbers to each image block in a current row of the image; A second allocation module, configured to allocate spare bits to the current row and construct a bit pool based on the spare bits; A judgment module, used for determining the fullness of the bit pool according to the waterline value of the bit pool when encoding the to-be-encoded picture block of the current row; wherein, after encoding of any picture block of the current row is completed, if the number of bits allocated to any picture block is not used up, it is released to the bit pool; the waterline value is the minimum value of the number of spare bits in the bit pool during the encoding process; an acquisition module, configured to acquire a second number of bits in the bit number pool according to the fullness and the image complexity of the to-be-encoded image block; if the pool fullness of the preceding bit number pool satisfies the fullness condition, acquire a third number of bits in the bit number pool as a first additional number of bits for the to-be-encoded image block; the preceding row is an upper row in the image adjacent to the current row; The encoding module is used to encode the image block to be encoded by using the first number of bits of the image block to be encoded, the second number of bits and the first additional number of bits to obtain an encoding result of the image block to be encoded.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Coder rate control method and module, chip, electronic equipment and storage medium

    CN115103190A

  • Code rate control method based on image complexity and related device

    CN116456092A