CN113873244B - Coefficient coding and decoding method and coefficient coding and decoding device - Google Patents

Coefficient coding and decoding method and coefficient coding and decoding device Download PDF

Info

Publication number
CN113873244B
CN113873244B CN202010615529.XA CN202010615529A CN113873244B CN 113873244 B CN113873244 B CN 113873244B CN 202010615529 A CN202010615529 A CN 202010615529A CN 113873244 B CN113873244 B CN 113873244B
Authority
CN
China
Prior art keywords
coefficient
template
zero
quantized coefficient
quantized
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010615529.XA
Other languages
Chinese (zh)
Other versions
CN113873244A (en
Inventor
牛犇犇
王力强
郑建铧
何芸
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tsinghua University
Huawei Technologies Co Ltd
Original Assignee
Tsinghua University
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tsinghua University, Huawei Technologies Co Ltd filed Critical Tsinghua University
Priority to CN202010615529.XA priority Critical patent/CN113873244B/en
Publication of CN113873244A publication Critical patent/CN113873244A/en
Application granted granted Critical
Publication of CN113873244B publication Critical patent/CN113873244B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/127Prioritisation of hardware or computational resources

Abstract

The embodiment of the application discloses a coefficient coding and decoding method and a coefficient coding and decoding device, which are used for reducing redundant coding and decoding modes and improving coding and decoding performance in the process of coefficient coding and decoding. In the coefficient coding method, carrying out quantization operation on the residual block to obtain a quantized coefficient block; determining distribution information of non-zero coefficients in a quantized coefficient block corresponding to each template in a plurality of templates by using the preset templates, wherein the templates comprise: the distribution information of the current template corresponding to the non-zero coefficient comprises: distribution of non-zero coefficients in an inner region and an outer region of the current template; scanning and encoding the quantized coefficient blocks according to the distribution information of each template in the templates corresponding to the nonzero coefficients respectively so as to obtain coefficient encoding results corresponding to the templates respectively; and selecting a target template from the templates according to coefficient coding results respectively corresponding to the templates, wherein the target template and the coefficient coding results corresponding to the target template are contained in a coding code stream to be transmitted.

Description

Coefficient coding and decoding method and coefficient coding and decoding device
Technical Field
The present application relates to the field of computer processing, and in particular, to a coefficient encoding and decoding method and a coefficient encoding and decoding device.
Background
Video compression in electronic devices is now an essential processing approach, and video compression is increasingly important in saving transmission bandwidth and storage devices.
The hybrid coding framework is a basic framework which is always adopted in the video compression standard evolution process, and from the earliest H.261 standard to the mainstream H.264/advanced video coding (advanced video coding, AVC) and H.265/efficient video coding (high efficiency video coding, HEVC) standards and the under-study multifunctional video coding (Versatile Video Coding, VVC) standards are all compression methods based on a block division module, an intra/inter prediction module, a transformation module, a quantization module and a coefficient coding module, so that the spatial time redundancy of video information is reduced, and the high-frequency information is eliminated by utilizing the visual characteristics of human eyes, so that a good compression effect is obtained. Correspondingly, a coefficient decoding module, an inverse quantization module and an inverse transformation module are also adopted in the video decoding process.
The coefficient coding module is an important part in a video compression hybrid coding frame, and a two-dimensional quantized coefficient block is obtained after transformation and quantization operation of a residual block. The coefficient coding module converts the quantized coefficient block from two dimensions to one dimension, codes the position and amplitude information of all quantized coefficients, and writes the coded information into the code stream. The mode of converting the quantized coefficient block from two dimensions to one dimension is called scanning, and since the transformation module can be realized by adopting discrete cosine transformation (discrete cosine transform, DCT), the scanning mode adopted by the coefficient coding block can be Zig-zag or diagonal scanning, the scanning of the quantized coefficient can be more intensively completed, and more reasonable context modeling and coding processes can be performed in the scanning process.
However, in a practical application scenario, the distribution of quantization coefficients is related to various factors, such as intra prediction direction, frame type, quantization parameters (quantity parameter, QP), etc. These result in different types of distribution of quantization coefficients, such as directionality, sparsity, etc. Under the distribution, the Zig-zag scanning mode and the diagonal scanning mode can generate more zero coefficient scanning positions, so that the problems of redundant coding and coding performance loss are caused. Similarly, there is a problem of redundancy decoding and decoding performance loss at the coefficient decoding end.
Disclosure of Invention
The embodiment of the application provides a coefficient coding and decoding method and a coefficient coding and decoding device, which are used for reducing redundant coding and decoding modes and improving coding and decoding performance in the process of coefficient coding and decoding.
In order to solve the technical problems, the embodiment of the application provides the following technical scheme:
in a first aspect, an embodiment of the present application provides a coefficient encoding method, including: performing quantization operation on the residual block to obtain a quantized coefficient block; determining distribution information of non-zero coefficients in the quantized coefficient block corresponding to each template in the templates by using a plurality of preset templates, wherein the templates comprise: the distribution information of the non-zero coefficient corresponding to the current template comprises: the distribution condition of the non-zero coefficient in the inner area and the outer area of the current template, wherein the inner area of the current template is smaller than or equal to the area size of the quantization coefficient block, and the inner areas of different templates in the templates are different; scanning and encoding the quantized coefficient blocks according to the distribution information of the non-zero coefficient corresponding to each template in the templates respectively to obtain coefficient encoding results corresponding to the templates respectively; and selecting a target template from the templates according to coefficient coding results respectively corresponding to the templates, wherein the target template and the coefficient coding results corresponding to the target template are contained in a coding code stream to be transmitted. According to the method and the device for determining the distribution information of the quantized coefficients, based on the diversity distribution of the quantized coefficients, various templates can be used for determining the distribution information of the non-zero coefficients corresponding to each template in the templates, so that the non-zero coefficients corresponding to the distribution information of each template in the templates can be used for scanning and encoding, a target template selected from the templates and a coefficient encoding result corresponding to the target template are included in a final code stream to be transmitted, and therefore the scanning mode and the encoding mode of each quantized coefficient of the whole quantized coefficient block can be better adjusted, the scanning cost and the encoding cost in the coefficient encoding process can be effectively reduced, the redundant encoding mode can be reduced, and the encoding performance in the coefficient encoding process can be improved.
In one possible implementation manner, the determining, using a plurality of preset templates, distribution information of non-zero coefficients in the quantized coefficient block corresponding to each template in the plurality of templates includes: determining a basic unit for scanning the quantized coefficient block; determining a first distribution parameter of the basic unit according to the distribution condition of the basic unit in an inner area or an outer area of the current template, wherein the distribution information of the non-zero coefficient in the quantization coefficient block corresponding to the current template comprises: the index of the current template and the first distribution parameter of the basic unit. In the embodiment of the application, the index of the current template and the first distribution parameter of the basic unit can be used as a set of conditions corresponding to the current template, and the index of the current template and the first distribution parameter of the basic unit can be used for determining whether to select the current template as the target template.
In one possible implementation manner, when all basic units in the quantized coefficient block are in the internal area of the current template, the value of the first distribution parameter of the basic units is a first numerical value; or when the basic unit belonging to the external area of the current template in the quantized coefficient block comprises a non-zero coefficient, the value of the first distribution parameter of the basic unit is a second value. In the scheme, according to the values of the coefficients included in the basic units in the quantized coefficient block and the position relation between the basic units and the current template, a plurality of values of the first distribution parameters of the basic units can be set, so that the plurality of values of the first distribution parameters of the basic units can be obtained respectively, and the distribution condition of the basic units in the inner area or the outer area of the current template can be obtained through the first distribution parameters of the basic units.
In one possible implementation, when the basic unit is a coefficient point in the quantized coefficient block, the first distribution parameter of the basic unit includes: the value of a first coefficient point which belongs to the inner area of the current template in the quantized coefficient block and the value of a second coefficient point which belongs to the outer area of the current template in the quantized coefficient block; the value of the first coefficient point is the value of a coefficient point belonging to the inner area of the current template in the quantized coefficient block; the value of the second coefficient point is the value of the coefficient point belonging to the external area of the current template in the quantized coefficient block, or the value of the second coefficient point is zero. In this scheme, the coefficient points in the first distribution parameter of the basic unit may be divided into two types, that is, a first coefficient point in the quantized coefficient block, which belongs to the inner area of the current template, and a second coefficient point in the quantized coefficient block, which belongs to the outer area of the current template, where the values of the first coefficient point and the second coefficient point are different, for example, the value of the first coefficient point is the value of the coefficient point in the quantized coefficient block, which belongs to the inner area of the current template. The second coefficient point has two values: one is that the value of the second coefficient point is the value of the coefficient point belonging to the external area of the current template in the quantized coefficient block, and the value of the other second coefficient point is zero, namely the value of the coefficient point belonging to the external area of the current template in the quantized coefficient block can be forcedly set to be zero. The distribution condition of the basic unit in the inner area or the outer area of the current template can be obtained through the value of the first coefficient point and the value of the second coefficient point in the first distribution parameter of the basic unit.
In one possible implementation manner, when the basic unit is a coefficient point in the quantized coefficient block, the scanning and encoding the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each of the templates respectively, so as to obtain coefficient encoding results corresponding to the templates respectively, includes: determining a syntax element to be encoded corresponding to the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each template in the plurality of templates and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block and the last non-zero position coordinates corresponding to the quantized coefficient block; when all non-zero coefficients in the quantized coefficient block belong to the inner area of the current template in the templates, scanning the inner area of the current template, and skipping scanning the outer area of the current template; and encoding the syntax element to be encoded corresponding to the non-zero coefficient scanned from the inner area of the current template to obtain a coefficient encoding result corresponding to the current template. In the embodiment of the application, when the basic unit is a coefficient point in the quantized coefficient block, and the current quantized coefficient block does not perform coefficient group division, the scanned basic unit is the coefficient point. According to the embodiment of the application, the scanning mode and the coding mode of the basic unit are adjusted by introducing a plurality of templates, and the shapes of the templates can adapt to different basic unit distribution conditions. When all the basic units are concentrated in the template, the scanning of the outer area of the current template is skipped, so that the scanning range can be reduced, and the position information coding cost of the basic units outside the template is reduced. Therefore, the coefficient scanning cost and the syntax element coding cost can be reduced in the embodiment of the application.
In one possible implementation manner, when the basic unit is a coefficient point in the quantized coefficient block, the scanning and encoding the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each of the templates respectively, so as to obtain coefficient encoding results corresponding to the templates respectively, includes: determining a syntax element to be encoded corresponding to the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each template in the plurality of templates and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block and the last non-zero position coordinates corresponding to the quantized coefficient block; scanning an inner area and an outer area of a current template belonging to the templates when non-zero coefficients exist in the outer area of the current template in the quantization coefficient block; coding quantization coefficient position information corresponding to a non-zero coefficient scanned from an inner region of the current template, skipping coding of a last non-zero identifier corresponding to the non-zero coefficient scanned from the inner region of the current template, and coding syntax elements to be coded corresponding to the non-zero coefficient scanned from an outer region of the current template to obtain a coefficient coding result corresponding to the current template; or when non-zero coefficients exist in the quantization coefficient block in the outer region of the current template belonging to the templates, scanning the inner region and the outer region of the current template; and encoding quantized coefficient position information corresponding to the non-zero coefficient scanned from the inner area of the current template, encoding a syntax element to be encoded corresponding to the non-zero coefficient scanned from the outer area of the current template, and encoding last non-zero position coordinates corresponding to the quantized coefficient block to obtain a coefficient encoding result corresponding to the current template. When part of basic units are distributed outside the template, the coding of the last non-zero mark corresponding to the non-zero coefficient scanned from the inner area of the current template is skipped, so that the position information coding cost of the basic units inside the template can be reduced according to the auxiliary information of the template. In addition, in the embodiment of the application, when part of basic units are distributed outside the template, the quantized coefficient blocks correspond to the last non-zero position coordinates, one quantized coefficient block corresponds to one last non-zero position coordinate, and no last non-zero information is required to be set for each coefficient block, so that the coding cost of the quantized coefficient blocks can be reduced for coding the last non-zero position coordinates corresponding to the quantized coefficient blocks.
In one possible implementation manner, the encoding the last non-zero position coordinate corresponding to the quantized coefficient block includes: and encoding the last non-zero position coordinates corresponding to the quantized coefficient block according to the current template. In the embodiment of the application, when part of basic units are distributed outside the template, the last non-zero position coordinates corresponding to the quantized coefficient blocks are encoded according to the current template, the encoding cost of the last non-zero position coordinates corresponding to the quantized coefficient blocks can be reduced through the current template, for example, the size of the inner area of the template is subtracted from the last non-zero position coordinates corresponding to the quantized coefficient blocks, so that the last non-zero position coordinates corresponding to the quantized coefficient blocks can be obtained, and the encoding cost of the quantized coefficient blocks can be reduced through the corresponding relation between the template and the last non-zero position coordinates corresponding to the quantized coefficient blocks.
In one possible implementation, when the basic unit is a coefficient group in the quantized coefficient block, the first distribution parameter of the basic unit includes: the value of a first coefficient group in the quantized coefficient block, which belongs to the inner area of the current template, and the value of a second coefficient group in the quantized coefficient block, which belongs to the outer area of the current template; wherein the value of the first coefficient group includes the value of a coefficient point belonging to the inner area of the current template in the quantized coefficient block; the values of the second coefficient group include values of coefficient points belonging to an external area of the current template in the quantized coefficient block, or the values of the second coefficient group include zero. In the embodiment of the present application, the values of the first coefficient set and the second coefficient set are different, for example, the value of the first coefficient set is the value of the coefficient set belonging to the inner area of the current template in the quantized coefficient block. The second coefficient group has two values: one is that the value of the second coefficient group is the value of the coefficient group belonging to the external area of the current template in the quantized coefficient block, and the value of the other second coefficient group is zero, i.e. the value of the coefficient group belonging to the external area of the current template in the quantized coefficient block can be forcedly set to zero. The distribution condition of the basic unit in the inner area or the outer area of the current template can be obtained through the value of the first coefficient group and the value of the second coefficient group in the first distribution parameters of the basic unit.
In one possible implementation manner, when the basic unit is a coefficient group in the quantized coefficient block, the scanning and encoding the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each of the templates respectively, so as to obtain coefficient encoding results corresponding to the templates respectively, includes: determining a syntax element to be encoded corresponding to the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each template in the plurality of templates and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero position coordinate corresponding to the quantized coefficient block; when all non-zero coefficient groups in the quantized coefficient block belong to the inner area of the current template in the templates, scanning the inner area of the current template, and skipping scanning the outer area of the current template; and encoding the syntax elements to be encoded corresponding to the non-zero coefficient groups scanned from the inner area of the current template, and encoding the syntax elements to be encoded corresponding to the non-zero coefficients included in the non-zero coefficient groups scanned from the inner area of the current template, so as to obtain coefficient encoding results corresponding to the current template. In the embodiment of the application, when the basic unit is a coefficient group in the quantized coefficient block, the basic unit of scanning is the coefficient group when the current quantized coefficient block is subjected to CG division. According to the embodiment of the application, the scanning mode and the coding mode of the basic unit are adjusted by introducing a plurality of templates, and the shapes of the templates can adapt to different basic unit distribution conditions. When all basic units are concentrated in the template, the scanning of the external area of the current template is skipped, so that the scanning range can be reduced, and the position information coding cost of the basic units outside the template is reduced.
In one possible implementation manner, when the basic unit is a coefficient group in the quantized coefficient block, the scanning and encoding the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each of the templates respectively, so as to obtain coefficient encoding results corresponding to the templates respectively, includes: determining a syntax element to be encoded corresponding to the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each template in the plurality of templates and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero position coordinate corresponding to the quantized coefficient block; scanning the inner area and the outer area of the current template when a non-zero coefficient group exists in the outer area belonging to the current template in the quantized coefficient block; encoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner region of the current template, skipping encoding of the last non-zero identifier corresponding to the non-zero coefficient group scanned from the inner region of the current template, encoding the syntax element to be encoded corresponding to the non-zero coefficient group scanned from the outer region of the current template, and encoding the syntax element to be encoded corresponding to the non-zero coefficient included in the non-zero coefficient groups scanned from the inner region and the outer region of the current template to obtain a coefficient encoding result corresponding to the current template; or when a non-zero coefficient group exists in the external area belonging to the current template in the quantized coefficient block, scanning the internal area and the external area of the current template; and encoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner area of the current template, encoding the last non-zero position coordinate corresponding to the quantized coefficient block, encoding the syntax element to be encoded corresponding to the non-zero coefficient group scanned from the outer area of the current template, and encoding the syntax element to be encoded corresponding to the non-zero coefficient included in the non-zero coefficient group scanned from the inner area and the outer area of the current template, so as to obtain the coefficient encoding result corresponding to the current template. According to the embodiment of the application, the scanning mode and the coding mode of the basic unit are adjusted by introducing the target template, and the shape of the template can adapt to different basic unit distribution conditions. When part of basic units are distributed outside the template, the coding of the last non-zero mark corresponding to the non-zero coefficient group scanned from the inner area of the current template is skipped, so that the position information coding cost of the basic units inside the template can be reduced according to the auxiliary information of the template. Therefore, the coefficient scanning cost and the syntax element coding cost can be reduced in the embodiment of the application. In addition, in the embodiment of the application, when part of basic units are distributed outside the template, the quantized coefficient blocks correspond to the last non-zero position coordinates, one quantized coefficient block corresponds to one last non-zero position coordinate, and no last non-zero information is required to be set for each coefficient block, so that the coding cost of the quantized coefficient blocks can be reduced for coding the last non-zero position coordinates corresponding to the quantized coefficient blocks.
In one possible implementation manner, the encoding the last non-zero position coordinate corresponding to the quantized coefficient block includes: and encoding the last non-zero position coordinates corresponding to the quantized coefficient block according to the current template. In the embodiment of the application, when part of basic units are distributed outside the template, the last non-zero position coordinates corresponding to the quantized coefficient blocks are encoded according to the current template, the encoding cost of the last non-zero position coordinates corresponding to the quantized coefficient blocks can be reduced through the current template, for example, the size of the inner area of the template is subtracted from the last non-zero position coordinates corresponding to the quantized coefficient blocks, so that the last non-zero position coordinates corresponding to the quantized coefficient blocks can be obtained, and the encoding cost of the quantized coefficient blocks can be reduced through the corresponding relation between the template and the last non-zero position coordinates corresponding to the quantized coefficient blocks.
In one possible implementation manner, the selecting a target template from the templates according to the coefficient coding results corresponding to the templates respectively includes: respectively acquiring coefficient coding costs corresponding to the templates according to coefficient coding results corresponding to the templates respectively; and selecting the minimum cost from coefficient coding costs corresponding to the templates, wherein the target template is the template corresponding to the selected minimum cost. The template with the minimum coefficient coding cost is selected in the embodiment of the application, and the coding mode of the quantized coefficient can be adaptively adjusted under the condition of ensuring low calculation complexity and storage complexity so as to reduce the cost of coefficient coding.
In one possible implementation, each of the plurality of templates includes: the device comprises a first module, a second module and a third module, wherein the first module is positioned in the left vertical direction of the quantized coefficient block, the second module is positioned in the left upper corner area of the quantized coefficient block, and the third module is positioned in the upper horizontal direction of the quantized coefficient block. In the embodiment of the application, each template formed by the first module, the second module and the third module can identify the distribution position of the non-zero coefficient in the quantized coefficient block, wherein the distribution position refers to whether the non-zero coefficient is positioned in the inner area of the template or the outer area of the template.
In one possible implementation, each template of the plurality of templates includes 1 second module, a ratio between a region size of the second module and a region size of the quantization coefficient block is greater than 0 and less than or equal to 1; and/or, each template in the plurality of templates comprises a plurality of second modules, and the length of the second module, close to the left vertical direction, in each template is larger than the length of the second module, far away from the left vertical direction, in each template. In the embodiment of the application, a plurality of different templates can be generated through the configuration of the area size of the second module, so that the distribution positions of the non-zero coefficients in the quantized coefficient block can be identified by using the templates, wherein the distribution positions refer to whether the non-zero coefficients are positioned in the inner area of the template or the outer area of the template.
In one possible implementation, the length of the first module is less than or equal to the length of the quantized coefficient block, or the length of the first module is determined by at least one of a template to which the first module belongs and the size of the quantized coefficient block; the length of the third module is smaller than or equal to the length of the quantized coefficient block, or the length of the third module is determined by at least one of a template to which the third module belongs and the size of the quantized coefficient block. In the embodiment of the application, the first module and the third module in the templates can be regarded as double arms connected with the second module, the length of the first module and the length of the third module can be flexibly configured, and a plurality of different templates can be generated through the configuration of the length of the first module and the length of the third module, so that the distribution positions of the non-zero coefficients in the quantized coefficient blocks can be identified by using a plurality of templates, and the distribution positions refer to whether the non-zero coefficients are positioned in the inner area of the templates or the outer area of the templates.
In a second aspect, an embodiment of the present application further provides a coefficient decoding method, including: acquiring a target template and a coefficient coding result corresponding to the target template from a received coding code stream; determining distribution information of the non-zero coefficient to be decoded in the coefficient coding result corresponding to the template according to the target template, wherein the distribution information of the non-zero coefficient to be decoded corresponding to the target template comprises the following steps: distribution conditions of the non-zero coefficients to be decoded in an inner area and an outer area of the target template; and scanning and decoding the non-zero coefficient to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template so as to obtain a quantized coefficient block. The code stream received in the embodiment of the application comprises the target template, the target template can be used for determining the distribution information of the non-zero coefficient to be decoded corresponding to each template in the templates, and the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template is determined based on the distribution information of the non-zero coefficient corresponding to each template in the templates, so that the scanning mode and the decoding mode of each quantized coefficient to be decoded can be better adjusted, the scanning cost and the decoding cost in the coefficient decoding process can be effectively reduced, the redundant decoding mode can be reduced, and the decoding performance in the coefficient decoding process can be improved.
In one possible implementation manner, the distribution information of the non-zero coefficient to be decoded corresponding to the target template includes a template index of the target template and a basic unit distribution parameter, where the basic unit distribution parameter is used to determine the distribution situation of the non-zero coefficient to be decoded in an inner area and an outer area of the target template. For the target template, a basic unit distribution parameter may be generated, where the basic unit distribution parameter may also be referred to as a basic unit distribution condition, and the basic unit distribution parameter records a distribution condition of a basic unit in an inner area or an outer area of the target template.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient point in the quantized coefficient block to be decoded, the scanning and decoding the non-zero coefficient to be decoded according to the distribution situation of the non-zero coefficient to be decoded in the inner area and the outer area of the target template to obtain the quantized coefficient block includes: determining a syntax element to be decoded corresponding to the quantized coefficient block to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block to be decoded and the last non-zero position coordinates corresponding to the quantized coefficient block to be decoded; when all non-zero coefficients in the quantized coefficient block to be encoded belong to the inner region of the target template, scanning the inner region of the target template, and skipping scanning the outer region of the target template; and decoding the syntax element to be decoded corresponding to the non-zero coefficient scanned from the internal area of the target template to obtain a quantization coefficient block corresponding to the target template. According to the embodiment of the application, the scanning mode and the decoding mode of the basic unit are adjusted by introducing a plurality of templates, and the shapes of the templates can adapt to different basic unit distribution conditions. When all the basic units are concentrated in the template, the scanning of the outer area of the current template is skipped, so that the scanning range can be reduced, and the decoding cost of the position information of the basic units outside the template is reduced. Therefore, the coefficient scanning cost and the syntax element decoding cost can be reduced in the embodiment of the application.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient point in the quantized coefficient block to be decoded, the scanning and decoding the non-zero coefficient to be decoded according to the distribution situation of the non-zero coefficient to be decoded in the inner area and the outer area of the target template to obtain the quantized coefficient block includes: determining a syntax element to be decoded corresponding to the quantized coefficient block to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block to be decoded and the last non-zero position coordinates corresponding to the quantized coefficient block to be decoded; scanning the inner area and the outer area of the target template when the non-zero coefficient exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; decoding quantized coefficient position information corresponding to a non-zero coefficient scanned from an inner region of the target template, skipping decoding of a last non-zero identification corresponding to the non-zero coefficient scanned from the inner region of the target template, and decoding syntax elements to be decoded corresponding to the non-zero coefficient scanned from an outer region of the target template to obtain quantized coefficient blocks corresponding to the target template; or when non-zero coefficients exist in the outer region belonging to the target template in the quantized coefficient block to be decoded, scanning the inner region and the outer region of the target template; and decoding quantized coefficient position information corresponding to the non-zero coefficient scanned from the inner area of the target template, decoding syntax elements to be decoded corresponding to the non-zero coefficient scanned from the outer area of the target template, and decoding last non-zero position coordinates corresponding to the quantized coefficient block to obtain the quantized coefficient block corresponding to the target template. When part of basic units are distributed outside the template, decoding of the last non-zero identification corresponding to the non-zero coefficient scanned from the inner area of the current template is skipped, so that the position information decoding cost of the basic units inside the template can be reduced according to the auxiliary information of the template. In addition, in the embodiment of the application, when part of basic units are distributed outside the template, the quantized coefficient blocks correspond to the last non-zero position coordinates, one quantized coefficient block corresponds to one last non-zero position coordinate, and no last non-zero information is required to be set for each coefficient block, so that the decoding cost of the quantized coefficient blocks can be reduced for decoding the last non-zero position coordinates corresponding to the quantized coefficient blocks.
In one possible implementation manner, the decoding the last non-zero position coordinate corresponding to the quantized coefficient block includes: and decoding the last non-zero position coordinates corresponding to the quantized coefficient block according to the current template. In the embodiment of the application, when part of basic units are distributed outside the template, decoding is performed on the last non-zero position coordinates corresponding to the quantized coefficient blocks according to the current template, decoding overhead of the last non-zero position coordinates corresponding to the quantized coefficient blocks can be reduced through the current template, for example, the size of an inner area of the template is subtracted from the last non-zero position coordinates corresponding to the quantized coefficient blocks, so that a last non-zero position coordinate terminal value corresponding to the quantized coefficient blocks can be obtained, and decoding cost of the quantized coefficient blocks can be reduced through the corresponding relation between the template and the last non-zero position coordinates corresponding to the quantized coefficient blocks.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient set in the quantized coefficient block to be decoded, the scanning and decoding the non-zero coefficient to be decoded according to the distribution situation of the non-zero coefficient to be decoded in the inner area and the outer area of the target template to obtain the quantized coefficient block includes: determining a syntax element to be decoded corresponding to the quantized coefficient block to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero position coordinate corresponding to the quantized coefficient block to be decoded; when all non-zero coefficient groups in the quantized coefficient block to be decoded belong to the inner region of the target template, scanning the inner region of the target template, and skipping scanning the outer region of the target template; and decoding the syntax elements to be decoded corresponding to the non-zero coefficient groups scanned from the inner area of the target template, and decoding the syntax elements to be decoded corresponding to the non-zero coefficients included in the non-zero coefficient groups scanned from the inner area of the target template, so as to obtain the quantization coefficient blocks corresponding to the target template. According to the embodiment of the application, the scanning mode and the decoding mode of the basic unit are adjusted by introducing a plurality of templates, and the shapes of the templates can adapt to different basic unit distribution conditions. When all basic units are concentrated in the template, the scanning of the external area of the current template is skipped, so that the scanning range can be reduced, and the decoding cost of the position information of the basic units outside the template is reduced.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient set in the quantized coefficient block to be decoded, the scanning and decoding the non-zero coefficient to be decoded according to the distribution situation of the non-zero coefficient to be decoded in the inner area and the outer area of the target template to obtain the quantized coefficient block includes: determining a syntax element to be decoded corresponding to the quantized coefficient block to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero position coordinate corresponding to the quantized coefficient block to be decoded; scanning the inner area and the outer area of the target template when a non-zero coefficient group exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; decoding quantization coefficient group position information corresponding to a non-zero coefficient group scanned from an inner region of the target template, skipping decoding of a last non-zero flag corresponding to the non-zero coefficient group scanned from the inner region of the target template, decoding syntax elements to be decoded corresponding to the non-zero coefficient group scanned from an outer region of the target template, and decoding syntax elements to be decoded corresponding to non-zero coefficients included in the non-zero coefficient groups scanned from the inner region and the outer region of the target template to obtain quantization coefficient blocks corresponding to the target template; or when a non-zero coefficient group exists in an external area belonging to a target template in the quantized coefficient block to be decoded, scanning the internal area and the external area of the target template; and decoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner area of the target template, decoding the last non-zero position coordinate corresponding to the quantized coefficient block, decoding the syntax element to be decoded corresponding to the non-zero coefficient group scanned from the outer area of the target template, and decoding the syntax element to be decoded corresponding to the non-zero coefficient included in the non-zero coefficient group scanned from the inner area and the outer area of the target template to obtain the quantized coefficient block corresponding to the target template. When all basic units are concentrated in the template, the scanning of the external area of the current template is skipped, so that the scanning range can be reduced, and the decoding cost of the position information of the basic units outside the template is reduced. In addition, in the embodiment of the application, when part of basic units are distributed outside the template, the quantized coefficient blocks correspond to the last non-zero position coordinates, one quantized coefficient block corresponds to one last non-zero position coordinate, and no last non-zero information is required to be set for each coefficient block, so that the decoding cost of the quantized coefficient blocks can be reduced for decoding the last non-zero position coordinates corresponding to the quantized coefficient blocks.
In one possible implementation manner, the decoding the last non-zero position coordinate corresponding to the quantized coefficient block includes: and decoding the last non-zero position coordinates corresponding to the quantized coefficient block according to the current template. In the embodiment of the application, when part of basic units are distributed outside the template, decoding is performed on the last non-zero position coordinates corresponding to the quantized coefficient blocks according to the current template, decoding overhead of the last non-zero position coordinates corresponding to the quantized coefficient blocks can be reduced through the current template, for example, the size of an inner area of the template is subtracted from the last non-zero position coordinates corresponding to the quantized coefficient blocks, so that a last non-zero position coordinate terminal value corresponding to the quantized coefficient blocks can be obtained, and decoding cost of the quantized coefficient blocks can be reduced through the corresponding relation between the template and the last non-zero position coordinates corresponding to the quantized coefficient blocks.
In one possible implementation, the target template includes: the device comprises a first module, a second module and a third module, wherein the first module is positioned in the left vertical direction of the quantized coefficient block, the second module is positioned in the left upper corner area of the quantized coefficient block, and the third module is positioned in the upper horizontal direction of the quantized coefficient block. In the embodiment of the application, each template formed by the first module, the second module and the third module can identify the distribution position of the non-zero coefficient in the quantized coefficient block, wherein the distribution position refers to whether the non-zero coefficient is positioned in the inner area of the template or the outer area of the template.
In one possible implementation, the target template includes 1 second module, and a ratio between a region size of the second module and a region size of the quantization coefficient block is greater than 0 and less than or equal to 1; and/or the target template comprises a plurality of second modules, and the length of the second modules, close to the left vertical direction, in the target template is larger than the length of the second modules, far away from the left vertical direction, in the target template. In the embodiment of the application, a plurality of different templates can be generated through the configuration of the area size of the second module, so that the distribution positions of the non-zero coefficients in the quantized coefficient block can be identified by using the templates, wherein the distribution positions refer to whether the non-zero coefficients are positioned in the inner area of the template or the outer area of the template.
In one possible implementation manner, the length of the first module is smaller than or equal to the length of the quantized coefficient block, or the length of the first module is determined by at least one of a target template to which the first module belongs and the size of the quantized coefficient block; the length of the third module is smaller than or equal to the length of the quantized coefficient block, or the length of the third module is determined by at least one of a target template to which the third module belongs and the size of the quantized coefficient block. In the embodiment of the application, the first module and the third module in the template can be regarded as double arms connected with the second module, the length of the first module and the length of the third module can be flexibly configured, and a plurality of different templates can be generated through the configuration of the length of the first module and the length of the third module, so that the distribution positions of the nonzero coefficients in the quantized coefficient blocks can be identified by using the target template, and the distribution positions refer to whether the nonzero coefficients are positioned in the inner area of the target template or the outer area of the template.
In a third aspect, an embodiment of the present application provides a coefficient encoding apparatus, including: the processing module is used for carrying out quantization operation on the residual block to obtain a quantized coefficient block; the processing module is configured to determine distribution information of non-zero coefficients in the quantized coefficient block corresponding to each of the templates by using a preset plurality of templates, where the templates include: the distribution information of the non-zero coefficient corresponding to the current template comprises: the distribution condition of the non-zero coefficient in the inner area and the outer area of the current template, wherein the inner area of the current template is smaller than or equal to the area size of the quantization coefficient block, and the inner areas of different templates in the templates are different; the processing module is used for respectively scanning and encoding the quantized coefficient blocks according to the distribution information of the non-zero coefficient corresponding to each template in the templates so as to obtain coefficient encoding results corresponding to the templates respectively; and selecting a target template from the templates according to coefficient coding results respectively corresponding to the templates, wherein the target template and the coefficient coding results corresponding to the target template are contained in a coding code stream to be transmitted of a transceiver module.
In one possible implementation, the plurality of templates includes: the current template and the processing module are used for determining a basic unit for scanning the quantized coefficient block; determining a first distribution parameter of the basic unit according to the distribution condition of the basic unit in an inner area or an outer area of the current template, wherein the distribution information of the non-zero coefficient in the quantization coefficient block corresponding to the current template comprises: the index of the current template and the first distribution parameter of the basic unit.
In one possible implementation manner, when all basic units in the quantized coefficient block are in the internal area of the current template, the value of the first distribution parameter of the basic units is a first numerical value; or when the basic unit belonging to the external area of the current template in the quantized coefficient block comprises a non-zero coefficient, the value of the first distribution parameter of the basic unit is a second value.
In one possible implementation, when the basic unit is a coefficient point in the quantized coefficient block, the first distribution parameter of the basic unit includes: the value of a first coefficient point which belongs to the inner area of the current template in the quantized coefficient block and the value of a second coefficient point which belongs to the outer area of the current template in the quantized coefficient block; the value of the first coefficient point is the value of a coefficient point belonging to the inner area of the current template in the quantized coefficient block; the value of the second coefficient point is the value of the coefficient point belonging to the external area of the current template in the quantized coefficient block, or the value of the second coefficient point is zero.
In one possible implementation manner, when the basic unit is a coefficient point in the quantized coefficient block, the processing module is configured to determine, according to distribution information of the non-zero coefficient corresponding to each of the templates and a preset scanning manner, a syntax element to be encoded corresponding to the quantized coefficient block, where the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block and the last non-zero position coordinates corresponding to the quantized coefficient block; when all non-zero coefficients in the quantized coefficient block belong to the inner area of the current template in the templates, scanning the inner area of the current template, and skipping scanning the outer area of the current template; and encoding the syntax element to be encoded corresponding to the non-zero coefficient scanned from the inner area of the current template to obtain a coefficient encoding result corresponding to the current template.
In one possible implementation manner, when the basic unit is a coefficient point in the quantized coefficient block, the processing module is configured to determine, according to distribution information of the non-zero coefficient corresponding to each of the templates and a preset scanning manner, a syntax element to be encoded corresponding to the quantized coefficient block, where the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block and the last non-zero position coordinates corresponding to the quantized coefficient block; scanning an inner area and an outer area of a current template belonging to the templates when non-zero coefficients exist in the outer area of the current template in the quantization coefficient block; coding quantization coefficient position information corresponding to a non-zero coefficient scanned from an inner region of the current template, skipping coding of a last non-zero identifier corresponding to the non-zero coefficient scanned from the inner region of the current template, and coding syntax elements to be coded corresponding to the non-zero coefficient scanned from an outer region of the current template to obtain a coefficient coding result corresponding to the current template; or when non-zero coefficients exist in the quantization coefficient block in the outer region of the current template belonging to the templates, scanning the inner region and the outer region of the current template; and encoding quantized coefficient position information corresponding to the non-zero coefficient scanned from the inner area of the current template, encoding a syntax element to be encoded corresponding to the non-zero coefficient scanned from the outer area of the current template, and encoding last non-zero position coordinates corresponding to the quantized coefficient block to obtain a coefficient encoding result corresponding to the current template.
In a possible implementation manner, the processing module is configured to encode last non-zero position coordinates corresponding to the quantized coefficient block according to the current template.
In one possible implementation, when the basic unit is a coefficient group in the quantized coefficient block, the first distribution parameter of the basic unit includes: the value of a first coefficient group in the quantized coefficient block, which belongs to the inner area of the current template, and the value of a second coefficient group in the quantized coefficient block, which belongs to the outer area of the current template; wherein the value of the first coefficient group includes the value of a coefficient point belonging to the inner area of the current template in the quantized coefficient block; the values of the second coefficient group include values of coefficient points belonging to an external area of the current template in the quantized coefficient block, or the values of the second coefficient group include zero.
In one possible implementation manner, when the basic unit is a coefficient group in the quantized coefficient block, the processing module is configured to determine, according to distribution information of the non-zero coefficient corresponding to each of the templates and a preset scanning manner, a syntax element to be encoded corresponding to the quantized coefficient block, where the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero position coordinate corresponding to the quantized coefficient block; when all non-zero coefficient groups in the quantized coefficient block belong to the inner area of the current template in the templates, scanning the inner area of the current template, and skipping scanning the outer area of the current template; and encoding the syntax elements to be encoded corresponding to the non-zero coefficient groups scanned from the inner area of the current template, and encoding the syntax elements to be encoded corresponding to the non-zero coefficients included in the non-zero coefficient groups scanned from the inner area of the current template, so as to obtain coefficient encoding results corresponding to the current template.
In one possible implementation manner, when the basic unit is a coefficient group in the quantized coefficient block, the processing module is configured to determine, according to distribution information of the non-zero coefficient corresponding to each of the templates and a preset scanning manner, a syntax element to be encoded corresponding to the quantized coefficient block, where the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero position coordinate corresponding to the quantized coefficient block; scanning the inner area and the outer area of the current template when a non-zero coefficient group exists in the outer area belonging to the current template in the quantized coefficient block; encoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner region of the current template, skipping encoding of the last non-zero identifier corresponding to the non-zero coefficient group scanned from the inner region of the current template, encoding the syntax element to be encoded corresponding to the non-zero coefficient group scanned from the outer region of the current template, and encoding the syntax element to be encoded corresponding to the non-zero coefficient included in the non-zero coefficient groups scanned from the inner region and the outer region of the current template to obtain a coefficient encoding result corresponding to the current template; or when a non-zero coefficient group exists in the external area belonging to the current template in the quantized coefficient block, scanning the internal area and the external area of the current template; and encoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner area of the current template, encoding the last non-zero position coordinate corresponding to the quantized coefficient block, encoding the syntax element to be encoded corresponding to the non-zero coefficient group scanned from the outer area of the current template, and encoding the syntax element to be encoded corresponding to the non-zero coefficient included in the non-zero coefficient group scanned from the inner area and the outer area of the current template, so as to obtain the coefficient encoding result corresponding to the current template.
In a possible implementation manner, the processing module is configured to encode last non-zero position coordinates corresponding to the quantized coefficient block according to the current template.
In a possible implementation manner, the processing module is configured to obtain coefficient coding costs corresponding to the multiple templates according to coefficient coding results corresponding to the multiple templates respectively; and selecting the minimum cost from coefficient coding costs corresponding to the templates, wherein the target template is the template corresponding to the selected minimum cost.
In one possible implementation, each of the plurality of templates includes: the device comprises a first module, a second module and a third module, wherein the first module is positioned in the left vertical direction of the quantized coefficient block, the second module is positioned in the left upper corner area of the quantized coefficient block, and the third module is positioned in the upper horizontal direction of the quantized coefficient block.
In one possible implementation, each template of the plurality of templates includes 1 second module, a ratio between a region size of the second module and a region size of the quantization coefficient block is greater than 0 and less than or equal to 1; and/or, each template in the plurality of templates comprises a plurality of second modules, and the length of the second module, close to the left vertical direction, in each template is larger than the length of the second module, far away from the left vertical direction, in each template.
In one possible implementation, the length of the first module is less than or equal to the length of the quantized coefficient block, or the length of the first module is determined by at least one of a template to which the first module belongs and the size of the quantized coefficient block; the length of the third module is smaller than or equal to the length of the quantized coefficient block, or the length of the third module is determined by at least one of a template to which the third module belongs and the size of the quantized coefficient block.
In a third aspect of the present application, the constituent modules of the coefficient encoding apparatus may also perform the steps described in the foregoing first aspect and in various possible implementations, see in detail the foregoing description of the first aspect and in various possible implementations.
In a fourth aspect, an embodiment of the present application provides a coefficient decoding apparatus, including: the processing module is used for acquiring a target template and a coefficient coding result corresponding to the target template from the coding code stream received by the receiving and transmitting module; the processing module is configured to determine, according to the target template, distribution information of a non-zero coefficient to be decoded in the coefficient encoding result, where the distribution information of the non-zero coefficient to be decoded, corresponding to the target template, includes: distribution conditions of the non-zero coefficients to be decoded in an inner area and an outer area of the target template; and the processing module is used for scanning and decoding the non-zero coefficient to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template so as to obtain a quantized coefficient block.
In one possible implementation manner, the distribution information of the non-zero coefficient to be decoded corresponding to the target template includes a template index of the target template and a basic unit distribution parameter, where the basic unit distribution parameter is used to determine the distribution situation of the non-zero coefficient to be decoded in an inner area and an outer area of the target template.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient point in a quantized coefficient block to be decoded, the processing module is configured to determine, according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of the target template and a preset scanning manner, a syntax element to be decoded corresponding to the quantized coefficient block to be decoded, where the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block to be decoded and the last non-zero position coordinates corresponding to the quantized coefficient block to be decoded; when all non-zero coefficients in the quantized coefficient block to be encoded belong to the inner region of the target template, scanning the inner region of the target template, and skipping scanning the outer region of the target template; and decoding the syntax element to be decoded corresponding to the non-zero coefficient scanned from the internal area of the target template to obtain a quantization coefficient block corresponding to the target template.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient point in a quantized coefficient block to be decoded, the processing module is configured to determine, according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of the target template and a preset scanning manner, a syntax element to be decoded corresponding to the quantized coefficient block to be decoded, where the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block to be decoded and the last non-zero position coordinates corresponding to the quantized coefficient block to be decoded; scanning the inner area and the outer area of the target template when the non-zero coefficient exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; decoding quantized coefficient position information corresponding to a non-zero coefficient scanned from an inner region of the target template, skipping decoding of a last non-zero identification corresponding to the non-zero coefficient scanned from the inner region of the target template, and decoding syntax elements to be decoded corresponding to the non-zero coefficient scanned from an outer region of the target template to obtain quantized coefficient blocks corresponding to the target template; or when non-zero coefficients exist in the outer region belonging to the target template in the quantized coefficient block to be decoded, scanning the inner region and the outer region of the target template; and decoding quantized coefficient position information corresponding to the non-zero coefficient scanned from the inner area of the target template, decoding syntax elements to be decoded corresponding to the non-zero coefficient scanned from the outer area of the target template, and decoding last non-zero position coordinates corresponding to the quantized coefficient block to obtain the quantized coefficient block corresponding to the target template.
In a possible implementation manner, the processing module is configured to decode the last non-zero position coordinate corresponding to the quantized coefficient block according to the current template.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient group in a quantized coefficient block to be decoded, the processing module is configured to determine, according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of the target template and a preset scanning manner, a syntax element to be decoded corresponding to the quantized coefficient block to be decoded, where the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero position coordinate corresponding to the quantized coefficient block to be decoded; when all non-zero coefficient groups in the quantized coefficient block to be decoded belong to the inner region of the target template, scanning the inner region of the target template, and skipping scanning the outer region of the target template; and decoding the syntax elements to be decoded corresponding to the non-zero coefficient groups scanned from the inner area of the target template, and decoding the syntax elements to be decoded corresponding to the non-zero coefficients included in the non-zero coefficient groups scanned from the inner area of the target template, so as to obtain the quantization coefficient blocks corresponding to the target template.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient group in a quantized coefficient block to be decoded, the processing module is configured to determine, according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of the target template and a preset scanning manner, a syntax element to be decoded corresponding to the quantized coefficient block to be decoded, where the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero position coordinate corresponding to the quantized coefficient block to be decoded; scanning the inner area and the outer area of the target template when a non-zero coefficient group exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; decoding quantization coefficient group position information corresponding to a non-zero coefficient group scanned from an inner region of the target template, skipping decoding of a last non-zero flag corresponding to the non-zero coefficient group scanned from the inner region of the target template, decoding syntax elements to be decoded corresponding to the non-zero coefficient group scanned from an outer region of the target template, and decoding syntax elements to be decoded corresponding to non-zero coefficients included in the non-zero coefficient groups scanned from the inner region and the outer region of the target template to obtain quantization coefficient blocks corresponding to the target template; or when a non-zero coefficient group exists in an external area belonging to a target template in the quantized coefficient block to be decoded, scanning the internal area and the external area of the target template; and decoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner area of the target template, decoding the last non-zero position coordinate corresponding to the quantized coefficient block, decoding the syntax element to be decoded corresponding to the non-zero coefficient group scanned from the outer area of the target template, and decoding the syntax element to be decoded corresponding to the non-zero coefficient included in the non-zero coefficient group scanned from the inner area and the outer area of the target template to obtain the quantized coefficient block corresponding to the target template.
In a possible implementation manner, the processing module is configured to decode the last non-zero position coordinate corresponding to the quantized coefficient block according to the current template.
In one possible implementation, the target template includes: the device comprises a first module, a second module and a third module, wherein the first module is positioned in the left vertical direction of the quantized coefficient block, the second module is positioned in the left upper corner area of the quantized coefficient block, and the third module is positioned in the upper horizontal direction of the quantized coefficient block.
In one possible implementation, the target template includes 1 second module, and a ratio between a region size of the second module and a region size of the quantization coefficient block is greater than 0 and less than or equal to 1; and/or the target template comprises a plurality of second modules, and the length of the second modules, close to the left vertical direction, in the target template is larger than the length of the second modules, far away from the left vertical direction, in the target template.
In one possible implementation manner, the length of the first module is smaller than or equal to the length of the quantized coefficient block, or the length of the first module is determined by at least one of a target template to which the first module belongs and the size of the quantized coefficient block; the length of the third module is smaller than or equal to the length of the quantized coefficient block, or the length of the third module is determined by at least one of a target template to which the third module belongs and the size of the quantized coefficient block.
In a fourth aspect of the present application, the constituent modules of the coefficient decoding apparatus may also perform the steps described in the foregoing second aspect and various possible implementations, see the foregoing description of the second aspect and various possible implementations for details.
In a fifth aspect, embodiments of the present application provide a computer readable storage medium having instructions stored therein which, when run on a computer, cause the computer to perform the method of the first or second aspects described above.
In a sixth aspect, an embodiment of the present application provides a computer readable storage medium, where instructions are stored, when the instructions are executed on a computer, to cause the computer to execute the encoded code stream obtained by the coefficient encoding method described in the first aspect.
In a seventh aspect, embodiments of the present application provide a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of the first or second aspect described above.
In an eighth aspect, an embodiment of the present application provides a coefficient encoding apparatus, where the coefficient encoding apparatus may include an image encoding apparatus or a chip, and the coefficient encoding apparatus includes: a processor. The coefficient encoding apparatus may further include a memory; the memory is used for storing instructions; the processor is configured to execute the instructions in the memory to cause the coefficient encoding apparatus to perform the method according to any one of the preceding first aspects.
In a ninth aspect, an embodiment of the present application provides a coefficient decoding apparatus, which may include an image decoding apparatus or an entity such as a chip, where the coefficient decoding apparatus includes: a processor. The coefficient decoding apparatus may further include a memory; the memory is used for storing instructions; the processor is configured to execute the instructions in the memory to cause the coefficient decoding apparatus to perform the method of any of the preceding second aspects.
In a tenth aspect, the present application provides a chip system comprising a processor for supporting a coefficient encoding apparatus or a coefficient decoding apparatus to implement the functions referred to in the first or second aspect above, for example, to transmit or process data and/or information referred to in the method above. In one possible design, the chip system further includes a memory for holding program instructions and data necessary for the coefficient encoding apparatus or the coefficient decoding apparatus. The chip system can be composed of chips, and can also comprise chips and other discrete devices.
Drawings
FIG. 1 is a schematic diagram of a coefficient processing system according to an embodiment of the present application;
Fig. 2 is a schematic diagram of a coefficient encoding apparatus and a coefficient decoding apparatus applied to a terminal device according to an embodiment of the present application;
FIG. 3 is a schematic diagram of an interaction flow between a coefficient encoding apparatus and a coefficient decoding apparatus according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a Zig-zag scanning method according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a hybrid coding framework according to an embodiment of the present application;
FIG. 6 is a schematic block diagram of a coefficient encoding method according to an embodiment of the present application;
fig. 7a to 7e are schematic diagrams of preset templates according to an embodiment of the present application;
fig. 8 is a schematic flow block diagram of a coefficient decoding method according to an embodiment of the present application;
fig. 9a is a schematic diagram of encoding a syntax element to be encoded corresponding to a quantized coefficient block according to an embodiment of the present application;
fig. 9b is a schematic diagram of encoding a syntax element to be encoded corresponding to a quantized coefficient block according to another embodiment of the present application;
FIG. 10a is a block diagram illustrating a process of another coefficient encoding method according to an embodiment of the present application;
fig. 10b is a schematic flow block diagram of a coefficient decoding method according to an embodiment of the present application;
FIGS. 11a to 11d are schematic diagrams of preset templates according to embodiments of the present application;
FIG. 12a is a schematic diagram of the performance test results of the coefficient coding under AI configuration provided by an embodiment of the application;
FIG. 12b is a schematic diagram of a performance test result of coefficient coding in RA configuration according to an embodiment of the present application;
fig. 13 is a schematic diagram of a composition structure of a coding device according to an embodiment of the present application;
fig. 14 is a schematic diagram of a composition structure of a coding and decoding apparatus according to an embodiment of the present application;
FIG. 15 is a schematic diagram of a coding device according to another embodiment of the present application;
fig. 16 is a schematic diagram of a composition structure of another encoding and decoding apparatus according to an embodiment of the present application.
Detailed Description
The embodiment of the application provides a coefficient coding and decoding method and a coefficient coding and decoding device, which are used for reducing redundant coding and decoding modes and improving coding and decoding performance in the process of coefficient coding and decoding.
Embodiments of the present application are described below with reference to the accompanying drawings.
The terms first, second and the like in the description and in the claims and in the above-described figures, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances and are merely illustrative of the manner in which embodiments of the application have been described in connection with the description of the objects having the same attributes. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of elements is not necessarily limited to those elements, but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The technical scheme of the embodiment of the application can be applied to various coefficient processing systems, and is shown in fig. 1, which is a schematic diagram of the composition structure of the coefficient processing system provided by the embodiment of the application. The coefficient processing system 100 may include: coefficient encoding means 101 and coefficient decoding means 102. Wherein, the coefficient encoding device 101 may be configured to perform quantization operation on the residual block to obtain a quantized coefficient block; determining distribution information of non-zero coefficients in a quantization coefficient block corresponding to each template in the templates by using a plurality of preset templates, wherein the distribution information of the non-zero coefficients corresponding to each template in the templates comprises: the distribution of the non-zero coefficients in the inner area and the outer area of each template in the templates respectively, wherein the inner area of the current template is smaller than or equal to the area size of the quantization coefficient block, and the inner areas of different templates in the templates are different, for example, the inner areas of different templates in the templates are different in size, or the positions of the inner areas of different templates in the templates are different; scanning and encoding the quantized coefficient blocks according to the distribution information of the non-zero coefficients corresponding to each template in the templates respectively to obtain coefficient encoding results corresponding to the templates respectively; and selecting a target template from the templates according to coefficient coding results respectively corresponding to the templates, wherein the target template and the coefficient coding results corresponding to the target template are contained in a coding code stream to be transmitted. In addition, the coefficient coding result may be a coefficient coding code stream (may also be referred to as a compressed code stream or a coding code stream to be transmitted), then the code stream may be transmitted to the coefficient decoding apparatus 102 through a coefficient transmission channel, the coefficient decoding apparatus 102 may receive the code stream, and then the coefficient decoding apparatus 102 obtains a target template and a coefficient coding result corresponding to the target template from the received coding code stream; determining distribution information of the non-zero coefficient to be decoded in the coefficient coding result corresponding to each of the templates according to the target template, wherein the distribution information of the non-zero coefficient to be decoded corresponding to each of the templates comprises: distribution of non-zero coefficients to be decoded in an inner region and an outer region of the target template; and scanning and decoding the non-zero coefficient to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template to obtain a quantized coefficient block.
In the embodiment of the application, the coefficient coding device can be applied to various terminal devices with coefficient communication requirements, wireless devices with coefficient transcoding requirements and core network devices, for example, the coefficient coding device can be a coefficient coder of the terminal devices or the wireless devices or the core network devices. Similarly, the coefficient decoding apparatus may be applied to various terminal devices having a coefficient communication requirement, wireless devices having a coefficient transcoding requirement, and core network devices, and for example, the coefficient decoding apparatus may be a coefficient decoder of the above terminal device or wireless device or core network device.
For example, the coefficient encoding device is embodied as a coefficient encoder, and the coefficient decoding device is embodied as a coefficient decoder. The terminal device may include: the coefficient encoder and the channel encoder, or the terminal device may include a coefficient decoder and a channel decoder. Specifically, the channel encoder is used for channel encoding the coefficient signal, the channel decoder is used for channel decoding the coefficient signal, and the coefficient encoder is used for encoding the original coefficient region, for example, the coefficient encoder has a lossless encoding function. The coefficient decoder is used for decoding the coefficient encoded information, e.g. the coefficient decoder has a lossless decoding function. For example, lossless coding methods that may be used include entropy coding, huffman coding, and the like. For example, lossless decoding methods that can be used include entropy decoding, huffman decoding, and the like.
As shown in fig. 2, a schematic diagram of a coefficient encoding apparatus and a coefficient decoding apparatus applied to a terminal device according to an embodiment of the present application is shown. The first terminal device 20 may include: a coefficient encoder 201 and a channel encoder 202. The second terminal device 21 may include: a coefficient decoder 211 and a channel decoder 212. The first terminal device 20 is connected to a first network communication device 22, which is wireless or wired, and the first network communication device 22 is connected to a second network communication device 23, which is wireless or wired, through a digital channel, and the second terminal device 21 is connected to the second network communication device 23, which is wireless or wired. The above-mentioned wireless or wired network communication device may be referred to generally as a signal transmission device, such as a communication base station, a data exchange device, or the like.
In the coefficient communication, a terminal device serving as a transmitting end performs coefficient coding on the acquired coefficient signal, performs channel coding, and then performs transmission in a digital channel through a wireless network or a core network. And the terminal equipment serving as the receiving end performs channel decoding according to the received signal to obtain a coefficient signal coding code stream, and then the coefficient signal is recovered through coefficient decoding and played back by the terminal equipment of the receiving end.
Next, a method for encoding and decoding coefficients according to an embodiment of the present application will be described based on the foregoing system architecture, and the coefficient encoding apparatus and the coefficient decoding apparatus. As shown in fig. 3, an interactive flow chart between a coefficient encoding apparatus and a coefficient decoding apparatus in an embodiment of the present application is shown, where steps 301 to 304 may be performed by the coefficient encoding apparatus (hereinafter referred to as an encoding end), and steps 311 to 313 may be performed by the coefficient decoding apparatus (hereinafter referred to as a decoding end), and mainly include the following processes:
301. and carrying out quantization operation on the residual block to obtain a quantized coefficient block.
The encoding end can conduct inter-frame or intra-frame prediction on the original image block, so that a predicted image block can be obtained, and the original image block and the predicted image block are subtracted to obtain a residual block. After obtaining the residual block, the encoding end may perform quantization operation on the residual block, where the quantization operation may also be referred to as quantization processing, to obtain a quantized coefficient block.
In some embodiments of the present application, before the quantization operation is performed on the residual block by the encoding end, whether the transformation operation is needed or not may be further determined according to the prediction encoding mode, if the transformation operation is needed, the transformation operation may be performed on the residual block first, and then the quantization operation may be performed, so that a quantized coefficient block may be obtained, and if the transformation operation is not needed, the quantization operation may be performed directly on the residual block, so that a quantized coefficient block may be obtained.
302. Determining distribution information of non-zero coefficients in a quantized coefficient block corresponding to each template in a plurality of templates by using the preset templates, wherein the templates comprise: the distribution information of the current template corresponding to the non-zero coefficient comprises: the distribution of non-zero coefficients in the inner region and the outer region of the current template, wherein the inner region of the current template is smaller than or equal to the region size of the quantized coefficient block, and the inner regions of different templates in the templates are different.
In the embodiment of the application, the encoding end can be preconfigured with a plurality of templates, and each template can be provided with a template index. In the embodiment of the present application, the number of templates is not limited, for example, the templates may be configured to be 4, or 6, or other numbers, which are not limited herein. The model in the embodiment of the application can be used for confirming the distribution condition of non-zero coefficients in the quantized coefficient block. The template can cover a certain area in the quantized coefficient block, the size of the covered area of the template in the quantized coefficient block is not limited, and the size of the covered area of the template can be determined by the shape of the template. Specifically, the inner region of the current template is smaller than or equal to the region size of the quantized coefficient block, i.e., the template cannot exceed the region size of the quantized coefficient block, but the region size of the template may be equal to the region size of the quantized coefficient block. In addition, in the embodiment of the present application, the internal areas of different templates in the plurality of templates are different, for example, the sizes of the internal areas of different templates in the plurality of templates are different, or the positions of the internal areas of different templates in the plurality of templates are different, that is, each template in the plurality of templates covers a certain area in the quantized coefficient block, and these areas are different, so that the coefficient points in the quantized coefficient block have two distribution forms, that is, the coefficient points may be located inside the template, or located outside the template and belong to the quantized coefficient block.
It should be noted that, the inner area of the current template is smaller than or equal to the area size of the quantized coefficient block, that is, the inner area size of each template in the plurality of templates cannot exceed the area size of the quantized coefficient block, but the inner area size of the template may be equal to the area size of the quantized coefficient block, which will be described in detail in the following examples of the template.
In the embodiment of the application, the encoding end can use each template in the templates to determine the distribution information of the non-zero coefficient in the quantized coefficient block corresponding to each template in the templates, wherein the non-zero coefficient refers to the coefficient point with a value not being zero in the quantized coefficient block, and the non-zero coefficient in the quantized coefficient block corresponds to the zero coefficient. The non-zero coefficients in the quantized coefficient block correspond to the distribution information of each template, e.g., the plurality of templates includes: the distribution information of the current template corresponding to the non-zero coefficient comprises: the distribution of non-zero coefficients in the inner region as well as in the outer region of the current template, e.g. the current template may refer to any one of a plurality of templates. I.e. by each of the templates a distribution position of non-zero coefficients in the quantized coefficient block can be identified, which refers to whether the non-zero coefficients are located in an inner region of the template or in an outer region of the template.
In the embodiment of the application, the shapes of templates pre-configured by the encoding end have various implementation modes, and a template index can be set for each shape template. Most non-zero coefficients are concentrated in the upper left corner region due to the nature of the upper left corner energy concentration exhibited by the quantized coefficient block as a whole, and the lower right corner region of the quantized coefficient block typically has only sporadic coefficient values. Except for special cases where the intra prediction modes are horizontal and vertical, the non-zero coefficients may exhibit either horizontal or vertical distribution characteristics. In general, the distribution rule of the left upper angle is followed, and the non-zero coefficient is gradually sparse from the left upper part to the right lower part. Based on this analysis, the internal region distribution of the template also conforms to the characteristic of energy aggregation in the quantized coefficient block, and the template can be located in the upper left corner region of the quantized coefficient block, while considering that the non-zero coefficient may exhibit horizontal or vertical distribution characteristics, the template can also be located in the vertical direction at the lower left side of the quantized coefficient block and in the horizontal direction at the upper right side, and in practical application, the sizes of specific coverage areas of multiple templates are different.
In some embodiments of the application, each of the plurality of templates comprises: a first module, a second module and a third module, wherein,
The first module is located in the left vertical direction of the quantized coefficient block, the second module is located in the upper left corner region of the quantized coefficient block, and the third module is located in the upper horizontal direction of the quantized coefficient block.
Specifically, in an embodiment of the present application, the templates may include at least three types of modules, where the modules are part of the templates, for example, each template includes: the first module, the second module and the third module, the first module is located in the left vertical direction of the quantized coefficient block, so as to cover non-zero coefficients which may exhibit vertical distribution characteristics in the quantized coefficient block, the second module is located in the upper left corner region of the quantized coefficient block, so as to cover non-zero coefficients which may exhibit upper left corner aggregation characteristics in the quantized coefficient block as a whole, the third module is located in the upper horizontal direction of the quantized coefficient block, so as to cover non-zero coefficients which may exhibit horizontal distribution characteristics in the quantized coefficient block, and the sizes of the inner regions of the first module and the third module may be the same, or the sizes of the inner regions of the first module and the third module may be different, which is not limited herein. In the embodiment of the application, each template formed by the first module, the second module and the third module can identify the distribution position of the non-zero coefficient in the quantized coefficient block, wherein the distribution position refers to whether the non-zero coefficient is positioned in the inner area of the template or the outer area of the template.
It will be appreciated that in the above template, the second module refers to the rectangular frame in the upper left corner of the block of quantized coefficients, the first module and the third module can be considered as the two arms of the rectangular frame, the first module is the lower left arm of the rectangular frame, and the third module is the upper right arm of the rectangular frame. See for details the examples in the examples that follow.
In some embodiments of the present application, each of the plurality of templates includes 1 number of second modules, and a ratio between a region size of the second module and a region size of the quantization coefficient block is greater than 0 and less than or equal to 1; and/or the number of the groups of groups,
the number of the second modules included in each of the templates is multiple, and the length of the second module, close to the left vertical direction, in each template is larger than that of the second module, far away from the left vertical direction, in each template.
The second modules are located in the upper left corner area of the quantized coefficient block, and the number of the second modules may be 1 or more, for example, when there are only 1 second modules in the template, the sizes of the second modules in the template may be configured, and the sizes of the second modules in different templates may be different, for example, the area sizes of the second modules are 1 with the area sizes of the quantized coefficient block, that is, the sizes of the template and the quantized coefficient block are the same, and the sizes of the first module and the third module in the template are 0, that is, the first module and the third module are not present at this time. For example, the area size of the second module and the area size of the quantization coefficient block are 1/4,1/2,3/4, and the area size of the second module can be specifically configured by using the scene. In the embodiment of the application, a plurality of different templates can be generated through the configuration of the area size of the second module, so that the distribution positions of the non-zero coefficients in the quantized coefficient block can be identified by using the templates, wherein the distribution positions refer to whether the non-zero coefficients are positioned in the inner area of the template or the outer area of the template.
For another example, when there are multiple second modules in the templates, the sizes of the multiple second modules in one template may be configured in the templates, and the sizes of the second modules in different templates may also be different, for example, 2 second modules may be included in the template 1, 4 second modules may be included in the template 2, and 8 second modules may be included in the template 3. The sizes of the second modules in the same template can also be different, for example, the length of the second module close to the left vertical direction in each template is larger than the length of the second module far away from the left vertical direction in each template, so that the second modules in the templates can be combined to form a 'ladder-shaped' boundary design, the number of the second modules in each template can be specifically configured by applying a scene, and the area size of a plurality of the second modules in one template can be flexibly configured. In the embodiment of the application, a plurality of different templates can be generated through the configuration of the area size of the second module and the configuration of the number of the second modules, so that the distribution positions of the non-zero coefficients in the quantized coefficient block can be identified by using the templates, wherein the distribution positions refer to whether the non-zero coefficients are positioned in the inner area of the template or the outer area of the template.
In some embodiments of the present application, the length of the first module is less than or equal to the length of the quantized coefficient block, or the length of the first module is determined by at least one of a template to which the first module belongs, the size of the quantized coefficient block;
the length of the third module is smaller than or equal to the length of the quantized coefficient block, or the length of the third module is determined by at least one of a template to which the third module belongs and the size of the quantized coefficient block.
The first module and the third module can be regarded as double arms connected with the second module in the templates, the length of the first module and the length of the third module can be flexibly configured, and a plurality of different templates can be generated through the configuration of the length of the first module and the length of the third module, so that the distribution positions of non-zero coefficients in the quantized coefficient blocks can be identified by using a plurality of templates, and the distribution positions refer to whether the non-zero coefficients are positioned in the inner area of the templates or positioned in the outer area of the templates.
For example, the length of the first module is smaller than or equal to the length of the quantized coefficient block, or the length of the first module is determined by at least one of the template to which the first module belongs and the size of the quantized coefficient block. Next, the configuration of the length of the first module is illustrated, and the configuration of the length of the third module is similar to the configuration of the length of the first module. For example, for a template with index 0, the template size is the same as the quantized coefficient block, the double arm length can be considered to be 0, and for other indexed templates, the double arm length can be adjusted by different parameter settings. The double arm length can be fixed to 3/4 of the quantized coefficient block size, for example. Or adaptively adjusting the length of the double arms according to the template index, wherein for the template with index=1, the length of the double arms is 1/2 of the size of the quantized coefficient block; for a template with index=2, the double arm length is 3/4 of the quantized coefficient block size; for the template with index=3, the double arm length is the entire quantized coefficient block size.
In some embodiments of the present application, taking a process of determining distribution information of non-zero coefficients in a quantized coefficient block corresponding to a current template as an example, step 302 determines, using a plurality of preset templates, distribution information of non-zero coefficients in a quantized coefficient block corresponding to each of the plurality of templates, including:
determining a basic unit for scanning the quantized coefficient block;
determining a first distribution parameter of the basic unit according to the distribution condition of the basic unit in the inner area or the outer area of the current template, wherein the distribution information of the non-zero coefficient in the quantized coefficient block corresponding to the current template comprises: the index of the current template and the first distribution parameter of the base unit.
Taking the processing of the current template in the plurality of templates as an example, the current template may refer to any one of the plurality of templates, and the processing of the other templates in the plurality of templates except the current template is similar to the processing of the current module. The index of the current template, e.g. denoted as template idx, determines the basic unit of the scan of the quantized coefficient block, which may be a coefficient point or a coefficient group (coefficient group, CG), e.g. the basic unit comprises non-zero coefficients and/or zero coefficients in the quantized coefficient block. For the current template, a first distribution parameter of the basic unit may be generated, where the first distribution parameter of the basic unit may also be referred to as a first distribution situation of the basic unit (e.g. denoted as template_flag), and the distribution situation of the basic unit in an inner area or an outer area of the current template is recorded in the first distribution parameter of the basic unit. In the embodiment of the application, the index of the current template and the first distribution parameter of the basic unit can be used as a set of conditions corresponding to the current template, and the index of the current template and the first distribution parameter of the basic unit can be used for determining whether to select the current template as the target template.
Further, in some embodiments of the present application, when all the basic units in the quantized coefficient block are located in the inner area of the current template, the first distribution parameter of the basic units takes a first value; or alternatively, the process may be performed,
when the basic unit belonging to the external area of the current template in the quantized coefficient block comprises a non-zero coefficient, the value of the first distribution parameter of the basic unit is a second value.
According to the values of the coefficients included in the basic units in the quantized coefficient block and the position relation between the basic units and the current template, a plurality of values of the first distribution parameters of the basic units can be set, so that a plurality of values of the first distribution parameters of the basic units can be obtained respectively, and the distribution condition of the basic units in the inner area or the outer area of the current template can be obtained through the first distribution parameters of the basic units.
For example, the template indexes template_idx corresponding to the 4 preset templates are respectively 0, 1, 2 and 3. For each template, when all basic units in an equivalent coefficient block (hereinafter referred to as a coefficient block for short) are in the template, the template corresponding to the basic unit distribution condition template_flag is equal to 1; when a non-zero basic unit exists in the external area of the template, the basic unit distribution condition template_flag corresponding to the template is equal to 0.
Next, the determination of the first distribution parameter of the base unit is illustrated for various implementations of the base unit.
In some embodiments of the present application, when the base unit is a coefficient point in a quantized coefficient block, the first distribution parameters of the base unit include: the value of a first coefficient point belonging to the inner area of the current template in the quantized coefficient block and the value of a second coefficient point belonging to the outer area of the current template in the quantized coefficient block;
the value of the first coefficient point is the value of a coefficient point belonging to the inner area of the current template in the quantized coefficient block;
the value of the second coefficient point is the value of the coefficient point belonging to the external area of the current template in the quantized coefficient block, or the value of the second coefficient point is zero.
Specifically, the coefficient points in the first distribution parameter of the basic unit may be divided into two types, that is, a first coefficient point in the quantized coefficient block, which belongs to the inner area of the current template, and a second coefficient point in the quantized coefficient block, which belongs to the outer area of the current template, where the values of the first coefficient point and the second coefficient point are different, for example, the value of the first coefficient point is the value of the coefficient point in the quantized coefficient block, which belongs to the inner area of the current template. The second coefficient point has two values: one is that the value of the second coefficient point is the value of the coefficient point belonging to the external area of the current template in the quantized coefficient block, and the value of the other second coefficient point is zero, namely the value of the coefficient point belonging to the external area of the current template in the quantized coefficient block can be forcedly set to be zero. The distribution condition of the basic unit in the inner area or the outer area of the current template can be obtained through the value of the first coefficient point and the value of the second coefficient point in the first distribution parameter of the basic unit.
For example, as follows, the current quantized coefficient block is not coefficient-group-divided, and the basic unit is a coefficient point. Rate distortion optimization selection was performed using 4 preset templates. For each template index, two operations are respectively performed on the quantized coefficient block, one is to set all coefficients outside the template to 0, and the other is to reserve all coefficients outside the template, wherein each operation corresponds to one basic unit distribution condition, so that two basic unit distribution conditions exist.
In some embodiments of the present application, when the base unit is a coefficient group in a quantized coefficient block, the first distribution parameters of the base unit include: the value of a first coefficient group belonging to the inner area of the current template in the quantized coefficient block and the value of a second coefficient group belonging to the outer area of the current template in the quantized coefficient block;
wherein the value of the first coefficient group includes the value of a coefficient point belonging to the inner area of the current template in the quantized coefficient block;
the values of the second coefficient group include values of coefficient points belonging to an outer region of the current template in the quantized coefficient block, or the values of the second coefficient group include zero.
Specifically, the coefficient groups in the first distribution parameters of the basic unit may be divided into two types, that is, a first coefficient group in the quantized coefficient block, which belongs to the inner area of the current template, and a second coefficient group in the quantized coefficient block, which belongs to the outer area of the current template, where the values of the first coefficient group and the second coefficient group are different, for example, the value of the first coefficient group is the value of the coefficient group in the quantized coefficient block, which belongs to the inner area of the current template. The second coefficient group has two values: one is that the value of the second coefficient group is the value of the coefficient group belonging to the external area of the current template in the quantized coefficient block, and the value of the other second coefficient group is zero, i.e. the value of the coefficient group belonging to the external area of the current template in the quantized coefficient block can be forcedly set to zero. The distribution condition of the basic unit in the inner area or the outer area of the current template can be obtained through the value of the first coefficient group and the value of the second coefficient group in the first distribution parameters of the basic unit.
303. And respectively scanning and encoding the quantized coefficient blocks according to the distribution information of each template in the plurality of templates corresponding to the nonzero coefficients so as to obtain coefficient encoding results respectively corresponding to the plurality of templates.
In an embodiment of the present application, the plurality of templates includes: the distribution information of the current template corresponding to the non-zero coefficient comprises: the distribution of the non-zero coefficient in the inner area and the outer area of the current template, so that the quantized coefficient block can be scanned and encoded according to the distribution information of each template in the templates corresponding to the non-zero coefficient for each template to obtain the coefficient encoding result corresponding to each template respectively. The non-zero coefficients in the quantized coefficient blocks covered by different templates are different, and different scanning modes and encoding modes can be executed through different templates, so that different templates are used for scanning and encoding, and different coefficient encoding results can be generated. Various scanning modes may be adopted in the embodiment of the present application, for example, as shown in fig. 4, a Zig-zag mode may be adopted in the embodiment of the present application, the extending direction of the left line in fig. 4 is a scanning mode for the quantization coefficient block, and the scanning mode of the Zig-zag mode is illustrated from small to large on the right side in fig. 4.
In some embodiments of the present application, when the basic unit is a coefficient point in the quantized coefficient block, the quantized coefficient block is scanned and encoded according to distribution information of each template in the plurality of templates corresponding to the non-zero coefficient, so as to obtain coefficient encoding results corresponding to the plurality of templates, respectively, including:
determining a syntax element to be encoded corresponding to a quantized coefficient block according to distribution information of each template in a plurality of templates corresponding to a non-zero coefficient and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be encoded corresponding to the quantized coefficient block includes: quantized coefficient position information corresponding to coefficient points in the quantized coefficient block and last non-zero position coordinates corresponding to the quantized coefficient block;
when all non-zero coefficients in the quantized coefficient block belong to the inner area of the current template in the plurality of templates, scanning the inner area of the current template, and skipping the scanning of the outer area of the current template; and encoding the syntax element to be encoded corresponding to the non-zero coefficient scanned from the inner area of the current template to obtain a coefficient encoding result corresponding to the current template.
The syntax element to be encoded corresponding to the quantized coefficient block refers to a syntax element to be encoded in the quantized coefficient block, for example, the syntax element to be encoded corresponding to each coefficient point in the quantized coefficient block includes: each coefficient point in the quantized coefficient block corresponds to quantized coefficient position information and a last non-zero identification corresponding to each coefficient point, which may be used to identify whether the coefficient point identifies whether the current non-zero coefficient is a last non-zero coefficient in the quantized coefficient block. There are various implementations of quantized coefficient position information, for example, quantized coefficient position information may be a significance map (sigma) or run (run), where sigma identifies whether each quantized coefficient is 0 and run identifies a scan run between every two non-zero quantized coefficients. The last non-zero flag may be is_last_coef, which indicates whether the current non-zero coefficient is the last non-zero coefficient in the coefficient block. Without limitation, the syntax element to be encoded corresponding to the coefficient point may further include non-zero coefficient magnitude information and sign bit identification (sign), for example, the non-zero coefficient magnitude information may be magnitude (level), the magnitude information identifying each non-zero coefficient, and the sign identifying the sign information of each non-zero coefficient.
For another example, the quantized coefficient block may include position information corresponding to each coefficient point and a last non-zero position coordinate corresponding to the quantized coefficient block, where the last non-zero position coordinate corresponding to the quantized coefficient block is used to identify a position coordinate of a last non-zero basic unit in the quantized coefficient block, for example, the position coordinate of the last non-zero basic unit may include a horizontal coordinate and a vertical coordinate, and in this embodiment of the present application, a coordinate system adopted by the position coordinate of the last non-zero basic unit is not limited.
In the embodiment of the application, when the basic unit is a coefficient point in the quantized coefficient block, and the current quantized coefficient block is not subjected to CG division, the scanned basic unit is the coefficient point. According to the embodiment of the application, the scanning mode and the coding mode of the basic unit are adjusted by introducing a plurality of templates, and the shapes of the templates can adapt to different basic unit distribution conditions. When all the basic units are concentrated in the template, the scanning of the outer area of the current template is skipped, so that the scanning range can be reduced, and the position information coding cost of the basic units outside the template is reduced. Therefore, the coefficient scanning cost and the syntax element coding cost can be reduced in the embodiment of the application.
In some embodiments of the present application, when the basic unit is a coefficient point in the quantized coefficient block, the quantized coefficient block is scanned and encoded according to distribution information of each template in the plurality of templates corresponding to the non-zero coefficient, so as to obtain coefficient encoding results corresponding to the plurality of templates, respectively, including:
determining a syntax element to be encoded corresponding to a quantized coefficient block according to distribution information of each template in a plurality of templates corresponding to a non-zero coefficient and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be encoded corresponding to the quantized coefficient block includes: quantized coefficient position information corresponding to coefficient points in the quantized coefficient block and last non-zero position coordinates corresponding to the quantized coefficient block;
scanning the inner area and the outer area of the current template when the non-zero coefficients exist in the outer area of the current template belonging to a plurality of templates in the quantized coefficient block; coding quantization coefficient position information corresponding to a non-zero coefficient scanned from an inner area of a current template, skipping coding of a last non-zero identifier corresponding to the non-zero coefficient scanned from the inner area of the current template, and coding syntax elements to be coded corresponding to the non-zero coefficient scanned from an outer area of the current template to obtain a coefficient coding result corresponding to the current template; or alternatively, the process may be performed,
Scanning the inner area and the outer area of the current template when the non-zero coefficients exist in the outer area of the current template belonging to a plurality of templates in the quantized coefficient block; and encoding quantized coefficient position information corresponding to the non-zero coefficient scanned from the inner area of the current template, encoding a syntax element to be encoded corresponding to the non-zero coefficient scanned from the outer area of the current template, and encoding final non-zero position coordinates corresponding to the quantized coefficient block to obtain a coefficient encoding result corresponding to the current template.
In the embodiment of the present application, when the basic unit is a coefficient point in the quantized coefficient block, and the current quantized coefficient block is not CG-divided, the scanned basic unit is the coefficient point. When part of basic units are distributed outside the template, the coding of the last non-zero mark corresponding to the non-zero coefficient scanned from the inner area of the current template is skipped, so that the position information coding cost of the basic units inside the template can be reduced according to the auxiliary information of the template.
In addition, in the embodiment of the application, when part of basic units are distributed outside the template, the quantized coefficient blocks correspond to the last non-zero position coordinates, one quantized coefficient block corresponds to one last non-zero position coordinate, and no last non-zero information is required to be set for each coefficient block, so that the coding cost of the quantized coefficient blocks can be reduced for coding the last non-zero position coordinates corresponding to the quantized coefficient blocks.
Further, in some embodiments of the present application, encoding the last non-zero position coordinates corresponding to the quantized coefficient block includes:
and encoding the last non-zero position coordinates corresponding to the quantized coefficient blocks according to the current template.
In the embodiment of the application, when part of basic units are distributed outside the template, the last non-zero position coordinates corresponding to the quantized coefficient blocks are encoded according to the current template, the encoding cost of the last non-zero position coordinates corresponding to the quantized coefficient blocks can be reduced through the current template, for example, the size of the inner area of the template is subtracted from the last non-zero position coordinates corresponding to the quantized coefficient blocks, so that the last non-zero position coordinates corresponding to the quantized coefficient blocks can be obtained, and the encoding cost of the quantized coefficient blocks can be reduced through the corresponding relation between the template and the last non-zero position coordinates corresponding to the quantized coefficient blocks.
In some embodiments of the present application, when the basic unit is a coefficient group in a quantized coefficient block, the quantized coefficient block is scanned and encoded according to distribution information of a non-zero coefficient corresponding to each of the templates, so as to obtain coefficient encoding results corresponding to the templates, respectively, including:
Determining a syntax element to be encoded corresponding to a quantized coefficient block according to distribution information of each template in a plurality of templates corresponding to a non-zero coefficient and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero position coordinate corresponding to the quantized coefficient block;
when all non-zero coefficient groups in the quantized coefficient block belong to the inner area of the current template in the plurality of templates, scanning the inner area of the current template, and skipping the scanning of the outer area of the current template; and encoding the syntax elements to be encoded corresponding to the non-zero coefficient groups scanned from the inner region of the current template, and encoding the syntax elements to be encoded corresponding to the non-zero coefficients included in the non-zero coefficient groups scanned from the inner region of the current template, so as to obtain coefficient encoding results corresponding to the current template.
The syntax element to be encoded corresponding to the quantized coefficient block refers to a syntax element to be encoded in the quantized coefficient block, for example, the syntax element to be encoded corresponding to each coefficient group in the quantized coefficient block includes: each coefficient set in the quantized coefficient block corresponds to quantized coefficient position information and a last non-zero identification for each coefficient set, which may be used to identify whether the coefficient set identifies whether the current non-zero coefficient is a last non-zero coefficient in the quantized coefficient block. There are various implementations of quantized coefficient position information, for example, quantized coefficient position information may be a significance map (cg_sigma) or a run (cg_run), where cg_sign identifies whether each quantized coefficient is 0 and cg_run identifies a scan run between every two non-zero quantized coefficients. The last non-zero flag may be is_last_cg, which indicates whether the current non-zero coefficient is the last non-zero coefficient in the coefficient block.
In the embodiment of the application, when the basic unit is a coefficient group in the quantized coefficient block, the basic unit of scanning is the coefficient group when the current quantized coefficient block is subjected to CG division. According to the embodiment of the application, the scanning mode and the coding mode of the basic unit are adjusted by introducing a plurality of templates, and the shapes of the templates can adapt to different basic unit distribution conditions. When all basic units are concentrated in the template, the scanning of the external area of the current template is skipped, so that the scanning range can be reduced, and the position information coding cost of the basic units outside the template is reduced.
In some embodiments of the present application, when the basic unit is a coefficient group in a quantized coefficient block, the quantized coefficient block is scanned and encoded according to distribution information of a non-zero coefficient corresponding to each of the templates, so as to obtain coefficient encoding results corresponding to the templates, respectively, including:
determining a syntax element to be encoded corresponding to a quantized coefficient block according to distribution information of each template in a plurality of templates corresponding to a non-zero coefficient and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero position coordinate corresponding to the quantized coefficient block;
Scanning the inner area and the outer area of the current template when a non-zero coefficient group exists in the outer area belonging to the current template in the quantized coefficient block; encoding quantization coefficient group position information corresponding to a non-zero coefficient group scanned from an inner region of a current template, skipping encoding of a last non-zero identifier corresponding to the non-zero coefficient group scanned from the inner region of the current template, encoding syntax elements to be encoded corresponding to the non-zero coefficient group scanned from an outer region of the current template, and encoding syntax elements to be encoded corresponding to non-zero coefficients included in the non-zero coefficient group scanned from the inner region and the outer region of the current template to obtain coefficient encoding results corresponding to the current template; or alternatively, the process may be performed,
scanning the inner area and the outer area of the current template when a non-zero coefficient group exists in the outer area belonging to the current template in the quantized coefficient block; and encoding the quantized coefficient group position information corresponding to the nonzero coefficient group scanned from the inner area of the current template, encoding the last nonzero position coordinate corresponding to the quantized coefficient block according to the current template, encoding the syntax element to be encoded corresponding to the nonzero coefficient group scanned from the outer area of the current template, and encoding the syntax element to be encoded corresponding to the nonzero coefficient included in the nonzero coefficient group scanned from the inner area and the outer area of the current template, so as to obtain the coefficient encoding result corresponding to the current template.
In the embodiment of the application, when the basic unit is a coefficient group in the quantized coefficient block, the basic unit of scanning is the coefficient group when the current quantized coefficient block is subjected to CG division. According to the embodiment of the application, the scanning mode and the coding mode of the basic unit are adjusted by introducing the target template, and the shape of the template can adapt to different basic unit distribution conditions. When part of basic units are distributed outside the template, the coding of the last non-zero mark corresponding to the non-zero coefficient group scanned from the inner area of the current template is skipped, so that the position information coding cost of the basic units inside the template can be reduced according to the auxiliary information of the template. Therefore, the coefficient scanning cost and the syntax element coding cost can be reduced in the embodiment of the application.
In addition, in the embodiment of the application, when part of basic units are distributed outside the template, the quantized coefficient blocks correspond to the last non-zero position coordinates, one quantized coefficient block corresponds to one last non-zero position coordinate, and no last non-zero information is required to be set for each coefficient block, so that the coding cost of the quantized coefficient blocks can be reduced for coding the last non-zero position coordinates corresponding to the quantized coefficient blocks.
Further, in some embodiments of the present application, encoding the last non-zero position coordinates corresponding to the quantized coefficient block includes:
and encoding the last non-zero position coordinates corresponding to the quantized coefficient blocks according to the current template.
In the embodiment of the application, when part of basic units are distributed outside the template, the last non-zero position coordinates corresponding to the quantized coefficient blocks are encoded according to the current template, the encoding cost of the last non-zero position coordinates corresponding to the quantized coefficient blocks can be reduced through the current template, for example, the size of the inner area of the template is subtracted from the last non-zero position coordinates corresponding to the quantized coefficient blocks, so that the last non-zero position coordinates corresponding to the quantized coefficient blocks can be obtained, and the encoding cost of the quantized coefficient blocks can be reduced through the corresponding relation between the template and the last non-zero position coordinates corresponding to the quantized coefficient blocks.
304. And selecting a target template from the templates according to coefficient coding results respectively corresponding to the templates, wherein the target template and the coefficient coding results corresponding to the target template are contained in a coding code stream to be transmitted.
In the embodiment of the application, aiming at the problems of scanning redundancy and coding redundancy caused by the diversity distribution of quantized coefficients in the coefficient coding process, different templates are adopted to identify the distribution condition of non-zero coefficients in the inner area and the outer area of each template in a plurality of templates, and a target template can be selected from the templates, wherein the target template and the coefficient coding result corresponding to the target template are contained in a coding code stream to be transmitted, the selected target template is carried in the code stream, and the coding mode of the quantized coefficients can be adaptively adjusted under the condition of ensuring low calculation complexity and low storage complexity so as to reduce the cost of coefficient coding. In addition, the encoding end can also carry the target template and the coefficient encoding result corresponding to the target template in the code stream, so that the decoding end can use the target template to identify the distribution condition of the non-zero coefficient in the inner area and the outer area of the target template, thereby simplifying the scanning redundancy and decoding redundancy of the decoding end.
In some embodiments of the present application, selecting a target template from a plurality of templates according to coefficient encoding results respectively corresponding to the plurality of templates includes:
respectively obtaining coefficient coding costs corresponding to the templates according to coefficient coding results corresponding to the templates respectively;
and selecting the minimum cost from coefficient coding costs corresponding to the templates, wherein the target template is the template corresponding to the selected minimum cost.
Specifically, according to the coefficient coding result corresponding to each template, the coefficient coding cost corresponding to each template can be obtained respectively, and the minimum cost can be selected from the coefficient coding costs corresponding to a plurality of templates according to the cost minimum principle, wherein the target template is the template corresponding to the selected minimum cost.
For example, the encoding end selects the template index corresponding to the smallest cost and the basic unit distribution situation corresponding to the template from all the preset 4 types of template traversal as the target template decided by the final template of the quantization coefficient block, for example, the template index and the basic unit distribution situation corresponding to the template are respectively identified by using one syntax element, and the optimal index and distribution situation are selected through rate distortion optimization (rate distortion optimation, RDO). The target template and the coefficient coding result corresponding to the target template are contained in the coding code stream to be transmitted, the selected target template is carried in the code stream, and the index of the selected target template and the corresponding basic unit distribution condition are written into the code stream.
In the embodiment of the application, after the coding end can generate the code stream, the coding end can send the code stream to the decoding end through the coefficient transmission channel, and the decoding end needs to decode by adopting a coefficient decoding method corresponding to the coding end. Specifically, the decoding end performs the following steps 311 to 313.
311. And acquiring a target template and a coefficient coding result corresponding to the target template from the received coding code stream.
The encoding terminal transmits an encoded code stream, the decoding terminal receives the code stream, the code stream comprises a target template and a coefficient encoding result corresponding to the target template, and the coefficient encoding result corresponding to the target template is obtained after the encoding terminal encodes the coefficient encoding result.
312. Determining distribution information of a non-zero coefficient to be decoded corresponding to a target template in a coefficient coding result according to the target template, wherein the distribution information of the non-zero coefficient to be decoded corresponding to the target template comprises: distribution of non-zero coefficients to be decoded in the inner region and the outer region of the target template.
In the embodiment of the application, the decoding end can use the target template to determine the distribution information of the target template corresponding to the non-zero coefficient in the quantized coefficient block, wherein the non-zero coefficient refers to the coefficient point with the value not being zero in the quantized coefficient block, and the zero coefficient corresponds to the non-zero coefficient in the quantized coefficient block. The distribution information of the non-zero coefficient corresponding to the target template comprises: the distribution of the non-zero coefficients in the inner region and the outer region of the target template, i.e. the distribution position of the non-zero coefficients in the quantized coefficient block can be identified by the target template, wherein the distribution position refers to whether the non-zero coefficients are located in the inner region or the outer region of the template.
In some embodiments of the application, the target template comprises: a first module, a second module and a third module, wherein,
the first module is located in the left vertical direction of the quantized coefficient block, the second module is located in the upper left corner region of the quantized coefficient block, and the third module is located in the upper horizontal direction of the quantized coefficient block.
Specifically, in an embodiment of the present application, the templates may include at least three types of modules, where the modules are part of the templates, for example, each template includes: the first module is located in the left vertical direction of the quantized coefficient block, so that non-zero coefficients which may exhibit vertical distribution characteristics in the quantized coefficient block can be covered, the second module is located in an upper left corner region of the quantized coefficient block, so that non-zero coefficients which may exhibit upper left corner aggregation characteristics in the quantized coefficient block as a whole can be covered, and the third module is located in the upper horizontal direction of the quantized coefficient block, so that non-zero coefficients which may exhibit horizontal distribution characteristics in the quantized coefficient block can be covered. In the embodiment of the application, each template formed by the first module, the second module and the third module can identify the distribution position of the non-zero coefficient in the quantized coefficient block, wherein the distribution position refers to whether the non-zero coefficient is positioned in the inner area of the template or the outer area of the template.
It will be appreciated that in the above template, the second module refers to the rectangular frame in the upper left corner of the block of quantized coefficients, the first module and the third module can be considered as the two arms of the rectangular frame, the first module is the lower left arm of the rectangular frame, and the third module is the upper right arm of the rectangular frame. See for details the examples in the examples that follow.
In some embodiments of the present application, the target template includes 1 second module, a ratio between a region size of the second module and a region size of the quantization coefficient block is greater than 0 and less than or equal to 1; and/or the number of the groups of groups,
the target template comprises a plurality of second modules, and the length of the second modules, close to the left vertical direction, in the target template is larger than the length of the second modules, far away from the left vertical direction, in each template.
The second modules are located in the upper left corner area of the quantized coefficient block, and the number of the second modules may be 1 or more, for example, when there are only 1 second modules in the template, the sizes of the second modules in the template may be configured, and the sizes of the second modules in different templates may be different, for example, the area sizes of the second modules are 1 with the area sizes of the quantized coefficient block, that is, the sizes of the template and the quantized coefficient block are the same, and the sizes of the first module and the third module in the template are 0, that is, the first module and the third module are not present at this time. For example, the area size of the second module and the area size of the quantization coefficient block are 1/4,1/2,3/4, and the area size of the second module can be specifically configured by using the scene. In the embodiment of the application, a plurality of different templates can be generated through the configuration of the area size of the second module, so that the distribution positions of the non-zero coefficients in the quantized coefficient block can be identified by using the templates, wherein the distribution positions refer to whether the non-zero coefficients are positioned in the inner area of the template or the outer area of the template.
For another example, when there are multiple second modules in the templates, the sizes of the multiple second modules in one template may be configured in the templates, and the sizes of the second modules in different templates may also be different, for example, 2 second modules may be included in the template 1, 4 second modules may be included in the template 2, and 8 second modules may be included in the template 3. The sizes of the second modules in the same template can also be different, for example, the length of the second module close to the left vertical direction in each template is larger than the length of the second module far away from the left vertical direction in each template, so that the second modules in the templates can be combined to form a 'ladder-shaped' boundary design, the number of the second modules in each template can be specifically configured by applying a scene, and the area size of a plurality of the second modules in one template can be flexibly configured. In the embodiment of the application, a plurality of different templates can be generated through the configuration of the area size of the second module and the configuration of the number of the second modules, so that the distribution positions of the non-zero coefficients in the quantized coefficient block can be identified by using the templates, wherein the distribution positions refer to whether the non-zero coefficients are positioned in the inner area of the template or the outer area of the template.
In some embodiments of the present application, the length of the first module is less than or equal to the length of the quantized coefficient block, or the length of the first module is determined by at least one of a target template to which the first module belongs, and the size of the quantized coefficient block;
the length of the third module is smaller than or equal to the length of the quantized coefficient block, or the length of the third module is determined by at least one of a target template to which the third module belongs and the size of the quantized coefficient block.
The first module and the third module can be regarded as double arms connected with the second module in the templates, the length of the first module and the length of the third module can be flexibly configured, and a plurality of different templates can be generated through the configuration of the length of the first module and the length of the third module, so that the target templates can be used for identifying the distribution positions of the non-zero coefficients in the quantized coefficient blocks, wherein the distribution positions refer to whether the non-zero coefficients are located in the inner area of the target templates or located in the outer area of the templates.
In some embodiments of the present application, the distribution information of the non-zero coefficient to be decoded corresponding to the target template includes a template index of the target template and a basic unit distribution parameter, where the basic unit distribution parameter is used to determine a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of the target template.
Wherein the index of the target template is denoted as template idx, a base unit of scanning the quantized coefficient block is determined, which base unit may be a coefficient point or a coefficient group (coefficient group, CG), for example, the base unit comprising non-zero coefficients and/or zero coefficients in the quantized coefficient block. For the target template, a base unit distribution parameter may be generated, which may also be referred to as a base unit distribution (e.g., denoted as template_flag), in which a distribution of base units in an inner area or an outer area of the target template is recorded.
313. And scanning and decoding the non-zero coefficient to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template to obtain a quantized coefficient block.
In the embodiment of the application, the distribution information of the target template corresponding to the non-zero coefficient comprises: the distribution of the non-zero coefficients in the inner area and the outer area of the target template can be used for scanning and decoding the quantized coefficient blocks according to the distribution information of the target template corresponding to the non-zero coefficients so as to obtain the quantized coefficient blocks corresponding to the target. The non-zero coefficients in the quantized coefficient blocks covered by different templates are different, different scanning modes and decoding modes can be executed through different templates, and the decoding end only needs to scan and decode according to a target template carried in a code stream, so that the decoding end can use the target template to identify the distribution condition of the non-zero coefficients in the inner area and the outer area of the target template, and scanning redundancy and decoding redundancy of the decoding end can be simplified.
Various scanning modes may be adopted in the embodiment of the present application, for example, as shown in fig. 4, a Zig-zag mode may be adopted in the embodiment of the present application, the extending direction of the left line in fig. 4 is a scanning mode for the quantization coefficient block, and the scanning mode of the Zig-zag mode is illustrated from small to large on the right side in fig. 4.
In some embodiments of the present application, when a basic unit for scanning a non-zero coefficient to be decoded is a coefficient point in a quantized coefficient block to be decoded, scanning and decoding the non-zero coefficient to be decoded according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of a target template to obtain the quantized coefficient block, including:
determining a syntax element to be decoded corresponding to a quantized coefficient block to be decoded according to the distribution condition of non-zero coefficients to be decoded in an inner area and an outer area of a target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: quantized coefficient position information corresponding to coefficient points in a quantized coefficient block to be decoded and last non-zero position coordinates corresponding to the quantized coefficient block to be decoded;
When all non-zero coefficients in the quantized coefficient block to be encoded belong to the inner region of the target template, scanning the inner region of the target template, and skipping scanning the outer region of the target template; and decoding the syntax element to be decoded corresponding to the non-zero coefficient scanned from the internal area of the target template to obtain a quantization coefficient block corresponding to the target template.
The syntax element to be decoded corresponding to the quantized coefficient block refers to a syntax element to be decoded in the quantized coefficient block, for example, the syntax element to be decoded corresponding to each coefficient point in the quantized coefficient block includes: each coefficient point in the quantized coefficient block corresponds to quantized coefficient position information and a last non-zero identification corresponding to each coefficient point, which may be used to identify whether the coefficient point identifies whether the current non-zero coefficient is a last non-zero coefficient in the quantized coefficient block. There are various implementations of quantized coefficient position information, for example, quantized coefficient position information may be a significance map (sigma) or run (run), where sigma identifies whether each quantized coefficient is 0 and run identifies a scan run between every two non-zero quantized coefficients. The last non-zero flag may be is_last_coef, which indicates whether the current non-zero coefficient is the last non-zero coefficient in the coefficient block. Without limitation, the syntax element to be decoded corresponding to the coefficient point may further include non-zero coefficient magnitude information and sign bit identification (sign), for example, the non-zero coefficient magnitude information may be magnitude (level), the magnitude information identifying each non-zero coefficient, and the sign identifying the sign information of each non-zero coefficient.
For another example, the quantized coefficient block may include position information corresponding to each coefficient point and a last non-zero position coordinate corresponding to the quantized coefficient block, where the last non-zero position coordinate corresponding to the quantized coefficient block is used to identify a position coordinate of a last non-zero basic unit in the quantized coefficient block, for example, the position coordinate of the last non-zero basic unit may include a horizontal coordinate and a vertical coordinate, and in this embodiment of the present application, a coordinate system adopted by the position coordinate of the last non-zero basic unit is not limited.
In the embodiment of the application, when the basic unit is a coefficient point in the quantized coefficient block, and the current quantized coefficient block is not subjected to CG division, the scanned basic unit is the coefficient point. According to the embodiment of the application, the scanning mode and the decoding mode of the basic unit are adjusted by introducing a plurality of templates, and the shapes of the templates can adapt to different basic unit distribution conditions. When all the basic units are concentrated in the template, the scanning of the outer area of the current template is skipped, so that the scanning range can be reduced, and the decoding cost of the position information of the basic units outside the template is reduced. Therefore, the coefficient scanning cost and the syntax element decoding cost can be reduced in the embodiment of the application.
In some embodiments of the present application, when a basic unit for scanning a non-zero coefficient to be decoded is a coefficient point in a quantized coefficient block to be decoded, scanning and decoding the non-zero coefficient to be decoded according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of a target template to obtain the quantized coefficient block, including:
determining a syntax element to be decoded corresponding to a quantized coefficient block to be decoded according to the distribution condition of non-zero coefficients to be decoded in an inner area and an outer area of a target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: quantized coefficient position information corresponding to coefficient points in a quantized coefficient block to be decoded and last non-zero position coordinates corresponding to the quantized coefficient block to be decoded;
scanning the inner area and the outer area of the target template when the non-zero coefficient exists in the outer area belonging to the target template in the quantized coefficient block to be coded; decoding quantized coefficient position information corresponding to a non-zero coefficient scanned from an inner region of a target template, skipping decoding of a last non-zero identifier corresponding to the non-zero coefficient scanned from the inner region of the target template, and decoding syntax elements to be decoded corresponding to the non-zero coefficient scanned from an outer region of the target template to obtain quantized coefficient blocks corresponding to the target template; or alternatively, the process may be performed,
Scanning the inner area and the outer area of the target template when the non-zero coefficient exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; and decoding the quantized coefficient position information corresponding to the non-zero coefficient scanned from the inner area of the target template, decoding the syntax element to be decoded corresponding to the non-zero coefficient scanned from the outer area of the target template, and decoding the last non-zero position coordinate corresponding to the quantized coefficient block according to the target template to obtain the quantized coefficient block corresponding to the target template.
In the embodiment of the present application, when the basic unit is a coefficient point in the quantized coefficient block, and the current quantized coefficient block is not CG-divided, the scanned basic unit is the coefficient point. When part of basic units are distributed outside the template, decoding of the last non-zero identification corresponding to the non-zero coefficient scanned from the inner area of the current template is skipped, so that the position information decoding cost of the basic units inside the template can be reduced according to the auxiliary information of the template.
In addition, in the embodiment of the application, when part of basic units are distributed outside the template, the quantized coefficient blocks correspond to the last non-zero position coordinates, one quantized coefficient block corresponds to one last non-zero position coordinate, and no last non-zero information is required to be set for each coefficient block, so that the decoding cost of the quantized coefficient blocks can be reduced for decoding the last non-zero position coordinates corresponding to the quantized coefficient blocks.
Further, in some embodiments of the present application, decoding the last non-zero position coordinates corresponding to the quantized coefficient block includes:
and decoding the last non-zero position coordinates corresponding to the quantized coefficient block according to the current template.
In the embodiment of the application, when part of basic units are distributed outside the template, decoding is performed on the last non-zero position coordinates corresponding to the quantized coefficient blocks according to the current template, decoding overhead of the last non-zero position coordinates corresponding to the quantized coefficient blocks can be reduced through the current template, for example, the size of an inner area of the template is subtracted from the last non-zero position coordinates corresponding to the quantized coefficient blocks, so that a last non-zero position coordinate terminal value corresponding to the quantized coefficient blocks can be obtained, and decoding cost of the quantized coefficient blocks can be reduced through the corresponding relation between the template and the last non-zero position coordinates corresponding to the quantized coefficient blocks.
In some embodiments of the present application, when a basic unit for scanning a non-zero coefficient to be decoded is a coefficient group in a quantized coefficient block to be decoded, scanning and decoding the non-zero coefficient to be decoded according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of a target template to obtain the quantized coefficient block, including:
Determining a syntax element to be decoded corresponding to a quantized coefficient block to be decoded according to the distribution condition of non-zero coefficients to be decoded in an inner area and an outer area of a target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero position coordinate corresponding to the quantized coefficient block to be decoded;
when all non-zero coefficient groups in the quantized coefficient block to be decoded belong to the inner region of the target template, scanning the inner region of the target template, and skipping the scanning of the outer region of the target template; decoding syntax elements to be decoded corresponding to the non-zero coefficient groups scanned from the inner region of the target template, and decoding syntax elements to be decoded corresponding to the non-zero coefficients included in the non-zero coefficient groups scanned from the inner region of the target template, so as to obtain quantization coefficient blocks corresponding to the target template.
The syntax element to be decoded corresponding to the quantized coefficient block refers to a syntax element to be decoded in the quantized coefficient block, for example, the syntax element to be decoded corresponding to each coefficient group in the quantized coefficient block includes: each coefficient set in the quantized coefficient block corresponds to quantized coefficient position information and a last non-zero identification for each coefficient set, which may be used to identify whether the coefficient set identifies whether the current non-zero coefficient is a last non-zero coefficient in the quantized coefficient block. There are various implementations of quantized coefficient position information, for example, quantized coefficient position information may be a significance map (cg_sigma) or a run (cg_run), where cg_sign identifies whether each quantized coefficient is 0 and cg_run identifies a scan run between every two non-zero quantized coefficients. The last non-zero flag may be is_last_cg, which indicates whether the current non-zero coefficient is the last non-zero coefficient in the coefficient block.
In the embodiment of the application, when the basic unit is a coefficient group in the quantized coefficient block, the basic unit of scanning is the coefficient group when the current quantized coefficient block is subjected to CG division. According to the embodiment of the application, the scanning mode and the decoding mode of the basic unit are adjusted by introducing a plurality of templates, and the shapes of the templates can adapt to different basic unit distribution conditions. When all basic units are concentrated in the template, the scanning of the external area of the current template is skipped, so that the scanning range can be reduced, and the decoding cost of the position information of the basic units outside the template is reduced.
In some embodiments of the present application, when a basic unit for scanning a non-zero coefficient to be decoded is a coefficient group in a quantized coefficient block to be decoded, scanning and decoding the non-zero coefficient to be decoded according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of a target template to obtain the quantized coefficient block, including:
determining a syntax element to be decoded corresponding to a quantized coefficient block to be decoded according to the distribution condition of non-zero coefficients to be decoded in an inner area and an outer area of a target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero position coordinate corresponding to the quantized coefficient block to be decoded;
scanning the inner area and the outer area of the target template when a non-zero coefficient group exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; decoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner region of the target template, skipping decoding of the last non-zero identification corresponding to the non-zero coefficient group scanned from the inner region of the target template, decoding the syntax element to be decoded corresponding to the non-zero coefficient group scanned from the outer region of the target template, and decoding the syntax element to be decoded corresponding to the non-zero coefficient included in the non-zero coefficient group scanned from the inner region and the outer region of the target template to obtain the quantized coefficient block corresponding to the target template; or alternatively, the process may be performed,
Scanning the inner area and the outer area of the target template when a non-zero coefficient group exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; decoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner region of the target template, decoding the last non-zero position coordinate corresponding to the quantized coefficient block according to the target template, decoding the syntax element to be decoded corresponding to the non-zero coefficient group scanned from the outer region of the target template, and decoding the syntax element to be decoded corresponding to the non-zero coefficient included in the non-zero coefficient group scanned from the inner region and the outer region of the target template to obtain the quantized coefficient block corresponding to the target template.
In the embodiment of the application, when the basic unit is a coefficient group in the quantized coefficient block, the basic unit of scanning is the coefficient group when the current quantized coefficient block is subjected to CG division. According to the embodiment of the application, the scanning mode and the decoding mode of the basic unit are adjusted by introducing the target template, and the shape of the template can adapt to different basic unit distribution conditions. When all basic units are concentrated in the template, the scanning of the external area of the current template is skipped, so that the scanning range can be reduced, and the decoding cost of the position information of the basic units outside the template is reduced.
In addition, in the embodiment of the application, when part of basic units are distributed outside the template, the quantized coefficient blocks correspond to the last non-zero position coordinates, one quantized coefficient block corresponds to one last non-zero position coordinate, and no last non-zero information is required to be set for each coefficient block, so that the decoding cost of the quantized coefficient blocks can be reduced for decoding the last non-zero position coordinates corresponding to the quantized coefficient blocks.
Further, in some embodiments of the present application, decoding the last non-zero position coordinates corresponding to the quantized coefficient block includes:
and decoding the last non-zero position coordinates corresponding to the quantized coefficient block according to the current template.
In the embodiment of the application, when part of basic units are distributed outside the template, decoding is performed on the last non-zero position coordinates corresponding to the quantized coefficient blocks according to the current template, decoding overhead of the last non-zero position coordinates corresponding to the quantized coefficient blocks can be reduced through the current template, for example, the size of an inner area of the template is subtracted from the last non-zero position coordinates corresponding to the quantized coefficient blocks, so that a last non-zero position coordinate terminal value corresponding to the quantized coefficient blocks can be obtained, and decoding cost of the quantized coefficient blocks can be reduced through the corresponding relation between the template and the last non-zero position coordinates corresponding to the quantized coefficient blocks.
As can be seen from the foregoing description of the coefficient encoding and decoding method, the embodiment of the present application is based on the diversity distribution of quantized coefficients, and may determine the distribution information of each template in the plurality of templates corresponding to the non-zero coefficient by using multiple templates, so that the distribution information of each template in the plurality of templates corresponding to the non-zero coefficient may be used for scanning and encoding, and the final code stream to be transmitted includes the target template selected from the plurality of templates and the coefficient encoding result corresponding to the target template. The code stream received in the embodiment of the application comprises the target template, the target template can be used for determining the distribution information of each template in the templates corresponding to the non-zero coefficient to be decoded, and the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template is determined based on the distribution information of each template in the templates corresponding to the non-zero coefficient, so that the scanning mode and the decoding mode of each quantized coefficient to be decoded can be better adjusted, the scanning cost and the decoding cost in the coefficient decoding process can be effectively reduced, the redundant decoding mode can be reduced, and the decoding performance in the coefficient decoding process can be improved.
In order to better understand and implement the above-mentioned schemes of the embodiments of the present application, the following specific description will exemplify the corresponding application scenario.
In the development of video coding standards, hybrid coding frameworks are based. Fig. 5 is a schematic diagram of a hybrid coding framework according to an embodiment of the present application, and for an input video sequence, it is first required to perform a coding block division operation. Starting from the largest size block, traversing all possible block division conditions through iterative division, and obtaining the optimal coding block division result through a rate distortion optimization strategy.
For the resulting encoded block, it is necessary to perform intra prediction or inter prediction operations thereon. For example, the best matching block is obtained as the prediction block of the current coding block by intra-mode prediction or inter-frame motion estimation using the encoded block information as a reference.
And for the current coding block, subtracting the original block from the predicted block to obtain a corresponding residual block. And for the residual block, firstly performing transformation operation, transforming the residual block into a transformation coefficient block with the same size, and then performing quantization operation to obtain a quantization coefficient block.
Scanning and entropy coding operation is carried out on the obtained quantized coefficient block on one side, two-dimensional to one-dimensional conversion is carried out on the quantized coefficient block, and the position and amplitude information of all coefficients are coded and written into a code stream; and on the other hand, performing inverse quantization and inverse transformation operations on the residual block to obtain a final reconstructed residual block.
The reconstructed residual block is added with a predicted block obtained by intra-frame or inter-frame prediction in the past to obtain a finally output reconstructed block, and reference pixel information of a subsequent encoding process is used.
Embodiments of the present application relate to a coefficient encoding module, and in particular, to a scanning and entropy encoding process, as shown in the dashed box of fig. 5.
The embodiment of the application provides a specific coefficient coding and decoding scheme, which can be realized through program codes in a memory or can be directly embedded into a coder-decoder system through a hardware module. The encoding end of the embodiment of the application processes a quantized coefficient block obtained by transforming and quantizing a residual block. According to the embodiment of the application, the scanning mode and the coding mode of the basic unit are adjusted by introducing a plurality of templates, and the coding of the whole coefficient block is carried out according to each group of template indexes and the basic unit distribution condition parameters corresponding to the templates, so that the corresponding coding cost is obtained. Finally, the optimal template index and the basic unit distribution condition corresponding to the template are selected through a rate distortion optimization (rate distortion optimation, RDO) operation. Both the template index and the base unit distribution case syntax elements will be written in the code stream.
Five different embodiments are illustrated below.
Embodiment one of the application
Referring to fig. 6, an embodiment of the present application provides a coefficient encoding method based on template scanning, which includes:
step S11: residual blocks with different sizes can be used for judging whether transformation operation is needed according to a prediction coding mode, and subsequent quantization operation is carried out to obtain a quantized coefficient block.
If the current residual block is in a transform skip mode, the quantization operation is directly performed without performing the transform operation, so as to obtain a quantized coefficient block with the same size; if the current residual block is not in the transformation skip mode, transformation operation is carried out, and quantization operation is carried out to obtain quantized coefficient blocks with the same size.
For example, the transform skip mode corresponds to the syntax element transform_skip, and takes a value of 0 or 1. When the transform_skip value is 1, no transformation operation is performed; when the transform_skip takes a value of 0, a transform operation such as DCT transform or the like is required.
In the embodiment of the present application, the basic unit in the h.264 standard is a coefficient point, and the mode of dividing the coefficient group (coefficient group, CG) is adopted in the h.265 standard.
Step S12: the current quantized coefficient block does not undergo Coefficient Group (CG) division, and the basic unit is a coefficient point. Rate Distortion Optimization (RDO) selection may be performed using, for example, 4 preset templates. For each template index (template_idx), two operations are respectively carried out on the quantized coefficient block, namely, all coefficients in the template are kept unchanged, all coefficients outside the template are forcedly set to be 0, and all coefficients in the template and outside the template are kept, and two basic unit distribution conditions (template_flag) are respectively corresponding. And respectively calculating the coefficient coding cost under a group of (template_idx, template_flag) conditions corresponding to each template.
For a block of quantized coefficients, non-zero coefficients (also referred to as non-zero elements) may be distributed within the template or may be distributed outside the template. The description is made by syntax element template_flag, respectively. When template_flag=1, all coefficients outside the template are forcedly set to 0, and only coefficients inside the template are reserved; when the template_flag=0, then there is no such forced operation, and the original coefficient values outside the templates are retained, so that for each template index template_idx, one base unit distribution case template_flag is corresponding.
Wherein, 4 preset templates are shown in fig. 7a to 7 d. The template includes an upper left corner region and two arms, wherein the upper left corner regions of FIGS. 7 a-7 d correspond to four cases [1*1], [1/4*1/4], [1/2*1/2], and [3/4*3/4], respectively. The arm width of the double arm is calculated proportionally according to the size of the coefficient block, for example, 1/8 or 1/4 of the size of the coefficient block. The length of the double arms can be obtained through presetting, and can also be controlled through a certain parameter, and influencing factors comprise the current coefficient block size, the aspect ratio and the like. However, the embodiment of the present application is not limited to using the above 4 preset templates, for example, a template shown in fig. 7e may be used, fig. 7e illustrates that the lengths of the two arms are different, in fig. 7e, the arm length at the lower left of the template is the same as the length of the coefficient block, and the arm length at the upper right of the template is 7/8 of the length of the coefficient block.
Wherein, the template indexes template_idx corresponding to the 4 preset templates are respectively 0, 1, 2 and 3. For each template, when all basic units in the coefficient block are positioned in the template, the basic unit distribution condition template_flag corresponding to the template is equal to 1; when a non-zero basic unit exists in the external area of the template, the basic unit distribution condition template_flag corresponding to the template is equal to 0.
Taking fig. 7a as an example, each small square represents a basic unit. The shape of the template is described in fig. 7a using the width W and height H of the quantized coefficient block. The form consists of an upper left corner rectangle and double arms. The sizes of the upper left corner rectangles of the 4 templates are [1/4*1/4], [1/2*1/2], [3/4*3/4] and [1*1] of the quantization coefficient block sizes, respectively. Take [1/4*1/4] as an example, i.e., a rectangle with an upper left corner dimension of (1/4*W and 1/4*H). The dimensions of the arms are constituted by the arm width and the arm length. The parameters are also obtained by the pre-design. In the description of fig. 7b, the arm width is 1/8 of the size of the corresponding quantized coefficient block, and the arm length extends to the entire size.
The coefficient coding of the quantized coefficient block is as follows, with each set of parameters (template_idx and template_flag) set:
the coefficients are encoded one by using a Zig-zag scanning mode, and syntax elements to be encoded comprise: significance map (sigmap), magnitude (level), last non-zero flag (is_last_coef), and sign flag (sign). Or the syntax element to be encoded comprises: run, magnitude (level), last non-zero flag (is_last_coef), sign flag (sign), etc. Where sigmap identifies whether each quantized coefficient is 0 and run identifies the scan run between every two non-zero quantized coefficients, both of which may be used to describe the position information of each quantized coefficient. level identifies the magnitude information for each non-zero coefficient, sign identifies the sign information for each non-zero coefficient, is_last_coef identifies whether the current non-zero coefficient is the last non-zero coefficient in the coefficient block. The scan matrix size is the same as the quantization coefficient block size. When all non-zero coefficients are in the template (template_flag=1), skipping the template outer region during coefficient scanning, reducing the scanning region, and not encoding whether the non-zero identification sigmap of the outer coefficient is no longer encoded or skipping the counting of the run length; when there are non-zero coefficients in the template outer region (template_flag=0), then the non-zero coefficients in the template inner are not the last non-zero coefficients, skipping the encoding of whether the non-zero coefficients in the template inner are last non-zero coefficient identifications (is_last_coef).
Step S13: and selecting a template index (template_idx) corresponding to the minimum cost and a template corresponding basic unit distribution condition (template_flag) from all the preset 4 template traversals as final template decisions of the quantized coefficient block. Two syntax elements, namely, a template_idx and a template_flag, are written into the bitstream.
The template index can be written into the code stream by a mode of 2-bit fixed-length codes, and can also be written into the code stream by a mode of variable-length codes. When the template index is 0, the syntax element of the basic unit distribution condition corresponding to the template does not need to be rewritten, and the value of the basic unit distribution condition can be directly determined to be 1. When the template index is not 0, the syntax element of the template corresponding to the basic unit distribution condition needs to be written into the code stream.
As shown in fig. 8, a schematic flow block diagram of a coefficient decoding method according to an embodiment of the present application is provided, where the embodiment of the present application provides a coefficient decoding method based on template scanning, which includes:
step S21: and analyzing a template index (template_idx) of the current coefficient block and a template corresponding basic unit distribution condition (template_flag) from the code stream.
The template index can be analyzed by a mode of 2 bit fixed-length codes, and can also be analyzed by a mode of variable-length codes. When the template index is 0, the syntax element of the basic unit distribution condition corresponding to the template does not need to be analyzed, and the value of the basic unit distribution condition can be directly determined to be 1. When the template index is not 0, the syntax element of the basic unit distribution condition corresponding to the template needs to be analyzed.
Step S22: and determining the shape of the template according to the template index (template_idx), and determining the distribution condition of non-zero coefficients in the current quantized coefficient block according to the distribution condition (template_flag) of the corresponding basic unit of the template.
In step S22, two syntax elements, namely, template_idx and template_flag, are parsed. the template_idx represents the template shape, and the template_flag represents the distribution condition of the corresponding basic units of the template. The two syntax elements are decoded independently of each other, from which the shape of the template used can be deduced, and whether all non-zero coefficients are concentrated inside the template.
Among them, 4 template shapes corresponding to the template index template_idx are shown in fig. 7a to 7 d. For each template, the template corresponding basic unit distribution condition template_flag equal to 1 indicates that all basic units in the coefficient block are positioned in the template; the template corresponding base unit distribution case template_flag being equal to 0 indicates that a non-zero base unit exists in the template outer area.
Step S23: the coefficients are decoded one by one using a Zig-zag scan. The encoding end carries out encoding compression on the quantized coefficient blocks to obtain code streams, the decoding end analyzes relevant information from the code streams, and the complete quantized coefficient blocks are reconstructed. The scan matrix size is the same as the current coefficient block size. When all non-zero coefficients are in the template (template_flag=1), skipping the template outer region during coefficient scanning, reducing the scanning region, and not decoding whether the non-zero identification sigmap of the outer coefficient is no longer decoded or skipping the counting of the run length; when there are non-zero coefficients in the template outer region (template_flag=0), then the non-zero coefficients inside the template are not the last non-zero coefficients, skipping decoding of the identification (is_last_coef) of whether the non-zero coefficients in the template inner are last non-zero coefficients.
As shown in fig. 9a, a schematic diagram for encoding a syntax element to be encoded corresponding to a quantized coefficient block according to an embodiment of the present application, for example, a basic unit is a coefficient point, and encoding of basic unit location information in the quantized coefficient block may be described by a syntax element sigmap or run. The sigmap identifies whether each base unit is 0 and run identifies the scan run between every two non-zero base units. When all non-zero base units are inside the template (template_flag=1), as shown in fig. 9a, the black area is the template and the cross position is the non-zero base unit. Black arrows represent the basic cell scan direction. When the basic unit scans, the white area outside the template is skipped, and the scanning area is reduced. When using the sigma p to describe base unit position information encoding, the encoding of whether or not the external base unit is a non-zero identification (sigma p) is skipped. When run is used to describe the base unit position information encoding, the count of runs (run) of the external base unit is skipped.
As shown in fig. 9b, another schematic diagram of encoding a syntax element to be encoded corresponding to a quantized coefficient block according to an embodiment of the present application is provided, for example, a basic unit is a coefficient point, and encoding basic unit end non-zero information in the quantized coefficient block, where the basic unit end non-zero information can be described by a syntax element is_last_coef or (last_coef_x, last_coef_y). is_last_coef identifies whether the current non-zero base unit is the last non-zero base unit in the quantized coefficient block. (last_coef_x, last_coef_y) represents the horizontal and vertical position coordinates of the last non-zero basic cell in the current quantized coefficient block. When a non-zero base unit exists in the region outside the template (template_flag=0), as shown in fig. 9b, the black region is the template, the cross position is the non-zero base unit inside the template, and the dot position is the last non-zero base unit outside the template. Black arrows represent the basic cell scan direction. When the basic unit is scanned, the non-zero basic unit inside the template is not the last non-zero basic unit. When the is_last_coef is used to describe the last non-zero information of the base unit, the encoding of whether each non-zero base unit in the template interior is a last non-zero base unit identification (is_last_coef) is skipped. When (last_coef_x, last_coef_y) is used to describe the last non-zero information of the basic unit, the value of the position coordinates (last_coef_x, last_coef_y) can be further subtracted by the width of the template double arms, that is, (last_coef_x-W/8, last_coef_y-H/8) can be used as the final last non-zero basic unit position coordinates, which are obtained by the corresponding relation between the template and the position coordinates (last_coef_x, last_coef_y), so that the final last non-zero basic unit position coordinates are encoded into the code stream, compared with the encoding of the template and the position coordinates (last_coef_x, last_coef_y), the encoding cost is reduced.
Step S24: and performing inverse quantization operation on the obtained quantized coefficient block, judging whether inverse transformation operation is needed or not according to the predictive coding mode, and finally obtaining a reconstructed residual block.
As can be seen from the foregoing illustration, the embodiments of the present application are applicable to coefficient coding schemes in which coefficient blocks are not partitioned by Coefficient Groups (CG). The scanning mode of each coefficient of the whole coefficient block and the coding method of the grammar element can be better adjusted by further confirming the non-zero coefficient distribution condition in the coefficient block by adding a plurality of templates, and the scanning cost and the coding cost are effectively reduced. In addition, the embodiment of the application reserves the friendliness of hardware design, does not add a new scanning matrix and a new scanning mode, does not need to increase extra hardware consumption, and has good applicability and mobility.
On the basis of a coefficient scanning scheme, 4 groups of templates with different shapes and two corresponding grammar elements are added, so that the distribution condition of non-zero coefficients in a coefficient block inside and outside a specified template is identified. In the case of knowing the coefficient distribution in the coefficient block, the scanning and encoding scheme of each coefficient in the coefficient block is adjusted according to the shape of the template, so that unnecessary scanning cost and partial syntax element encoding cost can be reduced.
Embodiment II of the application
Referring to fig. 10a, an embodiment of the present application provides a coefficient encoding method based on template scanning, which includes:
step S31: and judging whether transformation operation is needed or not according to the prediction coding mode by residual blocks with different sizes, and carrying out subsequent quantization operation to obtain a quantized coefficient block.
If the current residual block is in a transform skip mode, the quantization operation is directly performed without performing the transform operation, so as to obtain a quantization coefficient block with the same size; if the current residual block is not in the transformation skip mode, transformation operation is carried out, and quantization operation is carried out to obtain quantized coefficient blocks with the same size.
Step S32: the current quantized coefficient block is divided into Coefficient Groups (CG), the basic unit being CG. And 4 preset templates are used for Rate Distortion Optimization (RDO) selection, and two operations are respectively carried out on the quantization coefficient blocks for each template (template_idx), wherein one is to forcedly set all CG outside the template to 0, and the other is to reserve all CG outside the template, and the two basic unit distribution conditions (template_flag) are respectively corresponding. The coefficient coding cost for each set (template_idx, template_flag) of conditions is calculated.
Wherein, under each set of parameter (template_idx, template_flag) setting, the coefficient coding mode of the quantized coefficient block is as follows:
CG is coded one by using a Zig-zag scanning manner, and syntax elements to be coded include: cg_sigmap and is_last_cg, etc., or syntax elements to be encoded include cg_run and is_last_cg, etc. Where cg_sigmap identifies whether each CG is 0, CG run identifies the scan run between every two non-zero CGs, both of which can be used to describe the location information of each CG. is_last_cg identifies whether the current non-zero CG is the last non-zero CG in the coefficient block. The scan matrix size is 1/4 of the quantization coefficient block size. In current HEVC and AVS standard implementations, CG is specified as 4*4 in size. For a scan matrix in CG units, its size is 1/4 of the coefficient block size, this ratio may be fixed. When all non-zero CGs are in the template interior (template_flag=1), skipping the template exterior region during coefficient scanning, reducing the scanning region, and no longer encoding whether the non-zero identification cg_sigmap of the exterior CG or skipping the counting of the run-length cg_run; when there is a non-zero CG in the template outer area (template_flag=0), then the non-zero CG in the template inner is not the last non-zero CG, and the encoding of whether the non-zero CG in the template inner is the last non-zero CG identification (is_last_cg) is skipped.
When the base unit is CG, the entire coefficient encoding process includes an inter-CG encoding process and an intra-CG encoding process. For each non-zero CG, the coding process of its internal coefficients may use the coding scheme in the h.264 standard, and the coding of the coefficient blocks is done by saliency map (sigmap), amplitude (level), last non-zero identification (is_last_coef) and sign bit identification (sign). Coding of the coefficient blocks may also be accomplished by run, level, last non-zero index (is_last_coef) and sign bit identification (sign) using coding schemes in the AVS standard.
Step S33: and selecting a template index (template_idx) corresponding to the minimum cost and a template corresponding basic unit distribution condition (template_flag) from all the preset 4 template traversals as final template decisions of the quantized coefficient block. Two syntax elements, namely, a template_idx and a template_flag, are written into the bitstream.
The embodiment of the present application provides a coefficient decoding method based on template scanning, as shown in fig. 10b, which includes:
step S41: and analyzing a template index (template_idx) of the current coefficient block and a template corresponding basic unit distribution condition (template_flag) from the code stream.
The template index can be analyzed by a 2bit fixed-length code mode or a variable-length code mode. When the template index is 0, the syntax element of the basic unit distribution condition corresponding to the template does not need to be analyzed, and the value of the basic unit distribution condition can be directly determined to be 1. When the template index is not 0, the syntax element of the basic unit distribution condition corresponding to the template needs to be analyzed.
Step S42: and determining the shape of the template according to the template index (template_idx), and determining the distribution condition of non-zero CG in the current quantized coefficient block according to the distribution condition (template_flag) of the corresponding basic unit of the template.
Step S43: CG is decoded one by one using a Zig-zag scan. The scan matrix size is 1/4 of the current coefficient block size. When all non-zero CG are in the template interior (template_flag=1), skipping the template exterior region during coefficient scanning, reducing the scanning region, and no longer decoding whether the external CG is non-zero identification cg_sigmap or skipping the counting of the run-length cg_run; when there is a non-zero CG in the template outer area (template_flag=0), then the non-zero CG in the template inner is not the last non-zero CG, and the decoding of whether the non-zero CG in the template inner is the last non-zero CG mark (is_last_cg) is skipped. The decoding process of the internal coefficients for each non-zero CG will not be described in detail.
As shown in fig. 9a, a schematic diagram for encoding a syntax element to be encoded corresponding to a quantized coefficient block according to an embodiment of the present application, for example, a basic unit is a coefficient set, and encoding of basic unit location information in the quantized coefficient block may be described by a syntax element cg_sigmap or cg_run. cg_sigmap identifies whether each elementary unit is 0, cg_run identifies the scan run between every two non-zero elementary units. When all non-zero base units are inside the template (template_flag=1), as shown in fig. 9 a. The black area is used as a template, and the position of the cross star is a non-zero basic unit. Black arrows represent the basic cell scan direction. When the basic unit scans, the white area outside the template is skipped, and the scanning area is reduced. When the coding of the base unit position information is described using cg_sigmap, the coding of whether or not the external base unit is nonzero identification (cg_sigmap) is skipped. When the basic unit position information encoding is described using cg_run, the count of the run (cg_run) of the external basic unit is skipped.
As shown in fig. 9b, another schematic diagram of encoding a syntax element to be encoded corresponding to a quantized coefficient block according to an embodiment of the present application is provided, for example, a basic unit is a coefficient group, and encoding basic unit end non-zero information in the quantized coefficient block, where the basic unit end non-zero information may be described by a syntax element is_last_cg or (last_cg_x, last_cg_y). is_last_cg identifies whether the current non-zero base unit is the last non-zero base unit in the quantized coefficient block. (last_cg_x, last_cg_y) represents the horizontal and vertical position coordinates of the last non-zero base unit in the current block of quantized coefficients. When a non-zero base unit exists in the region outside the template (template_flag=0), as shown in fig. 9b, the black region is the template, the cross position is the non-zero base unit inside the template, and the dot position is the last non-zero base unit outside the template. Black arrows represent the basic cell scan direction. When the basic unit is scanned, the non-zero basic unit inside the template is not the last non-zero basic unit. When the is_last_cg is used to describe the base unit last non-zero information, the encoding of whether each non-zero base unit in the template interior is a last non-zero base unit identification (is_last_cg) is skipped. When (last_cg_x, last_cg_y) is used to describe the last non-zero information of the basic unit, the value of the position coordinate (last_cg_x, last_cg_y) can be further subtracted by the width of the template double arm, that is, (last_cg_x-W/8, last_cg_y-H/8) can be used as the final last non-zero basic unit position coordinate, which is obtained by the corresponding relation between the template and the position coordinate (last_cg_x, last_cg_y), so that the final last non-zero basic unit position coordinate is encoded into the code stream, compared with the encoding of the template and the position coordinate (last_cg_x, last_cg_y), the encoding cost is reduced.
Step S44: and performing inverse quantization operation on the obtained quantized coefficient block, judging whether inverse transformation operation is needed or not according to the predictive coding mode, and finally obtaining a reconstructed residual block.
As can be seen from the foregoing illustration, the embodiments of the present application are applicable to a coefficient coding scheme in the case where coefficient blocks are divided into Coefficient Groups (CG). By adding a plurality of templates to further confirm the nonzero CG distribution condition in the coefficient block, the scanning mode of each CG of the whole coefficient block and the coding method of the grammar element can be better adjusted, and the scanning cost and the coding cost are effectively reduced.
The embodiment of the application adds 4 groups of templates with different shapes and two corresponding grammar elements on the basis of a coefficient scanning scheme. The distribution of non-zero CG in the coefficient block inside and outside the appointed template is identified. In the case of CG distribution in a known coefficient block, the scanning and encoding scheme of each CG in the coefficient block is adjusted according to the shape of the template, so that unnecessary scanning costs and partial syntax element encoding costs can be reduced. The main difference between the embodiments of the present application and the first embodiment is that the applicable coefficient coding base unit is different. In the first embodiment, the coefficient coding base unit is a coefficient point, and in the present embodiment, the coefficient coding base unit is CG. When the basic units of the coefficient block are coefficient points and CG, a similar coefficient coding flow may be adopted, and the first embodiment corresponds to a similar scanning and coding scheme adjustment.
Embodiment III of the application
Next, different template shapes will be described, and in the first embodiment of the present application and the second embodiment of the present application, the shapes of the 4 templates are all in the form of rectangular frame+double arm. In the embodiment of the present application, the type of the upper left corner portion is changed, a stepped boundary design along the start of the double arm is adopted, and 4 templates are shown in fig. 11a to 11 d. Wherein the upper left corner region corresponds to the four cases of [1*1], [1/4*1/4], [1/2*1/2] and [3/4*3/4], respectively. The lower right-hand stair-shaped boundary is positioned at the lower secondary diagonal, and integrally forms a stair-shaped boundary design.
The block of quantized coefficients as a whole exhibits the property of upper left corner energy aggregation due to the effect of the DCT transform. Most non-zero coefficients are concentrated in the upper left corner and the lower right corner region typically has only sporadic coefficient values. Except for special cases where the intra prediction modes are horizontal and vertical, the non-zero coefficients may exhibit either horizontal or vertical distribution characteristics. In general, the distribution rule of the left upper angle is followed, and the non-zero coefficient is gradually sparse from the left upper part to the right lower part. The step-shaped boundary ensures that the template area can stably cover the coefficient distribution area and can better adapt to the quantization coefficient distribution condition under the general statistics condition.
From the foregoing illustration, it will be appreciated that embodiments of the present application provide another type of template shape, with the upper left corner region modified to be a stepped boundary design along the origin of the double arms. The distribution condition of the quantization coefficients under the general statistical condition can be better adapted.
Fourth embodiment of the application
Next, different template combinations will be described, in the first embodiment and the second embodiment of the present application, 4 templates with rectangular boundaries at the upper left corner are used, as shown in fig. 7a to 7 d; in the third embodiment of the present application, 4 templates with the upper left corner as a step boundary are used, as shown in fig. 11a to 11 d; of the two sets of templates, the two templates with index template_idx of 0 are identical, and the two sets of templates together have a total of 7 template shapes. Among the four templates of the upper left rectangle and the four templates of the upper left step, when template_idx=1, the two templates are not identical. The boundaries of the stepped templates are at the rectangular minor diagonal and do not cover the complete upper left corner rectangular area.
In the embodiment of the application, 7 templates are combined for use in the RDO process of the encoding end, the encoding cost corresponding to each template is calculated respectively, and the template index (template_idx) corresponding to the minimum cost and the template corresponding basic unit distribution condition (template_flag) are selected as the final template decision of the quantized coefficient block.
Wherein, 7 template indexes can be written into the code stream through 4-bit specific length codes, and can also be written into the code stream through variable length codes.
As can be seen from the foregoing illustration, embodiments of the present application provide a combined encoding result for different types of templates, which better adapts to quantization coefficient distribution by using finer template shapes.
Embodiment five of the application
Next, different arm length parameter settings will be described, and in the first embodiment and the second embodiment of the present application, the arm lengths of the arms in the different templates are the same as the size of the quantized coefficient block, that is, the arms extend to the entire quantized coefficient block size. In the embodiment of the application, the extension length of the double arm is changed so that the double arm length can be smaller than the quantized coefficient block size. For a template with index template_idx of 0, the template size is the same as the quantized coefficient block, and the double arm length can be considered to be 0, because the template shape is the entire coefficient block under the condition of template_idx=0, and the double arm length in this case can be considered to be 0. For other indexed templates, the length of the arms can be adjusted by different parameter settings. The double arm length can be fixed to 3/4 of the quantized coefficient block size, for example. Or adaptively adjusting the length of the double arms according to the template index, wherein for the template of which template_idx=1, the length of the double arms is 1/2 of the size of the quantized coefficient block; for a template with template_idx=2, the double arm length is 3/4 quantized coefficient block size; for a template with template_idx=3, the double arm length is the entire quantized coefficient block size; after modification of preset conditions, the double-arm lengths of different templates can be smaller than the size of the quantized coefficient block, and the double-arm lengths participate in the RDO process of the coding end.
The embodiment of the application provides a plurality of different template shapes, the extension length of the double arms can be smaller than the size of the quantized coefficient block, and the template of the type can be suitable for quantized coefficient distribution under the general statistical condition. Because of the aggregation characteristic of the upper left corner of the DCT transformation, the coefficient has a larger probability of 0 in the area far from the upper left corner except for special cases of horizontal and vertical intra-frame prediction modes, and the like, and the double-arm length adjustment is beneficial to reducing the scanning and coding cost.
As can be seen from the foregoing illustration, in the embodiment of the present application, the scanning mode and the encoding mode of the basic unit are adjusted by introducing a plurality of templates, and the shapes of the templates can adapt to different basic unit distribution conditions, so that the scanning cost and the encoding cost can be effectively reduced. In addition, the embodiment of the application reserves the friendliness of hardware design, does not add a new scanning matrix and a new scanning mode, does not need to increase extra hardware consumption, and has good applicability and mobility.
The coding and decoding method in the first embodiment of the application is realized based on reference software HPM3.3 of digital audio and video coding and decoding technical standard (audio video coding standard, AVS) 3 standard. The general test conditions of the AVS3 standard define a plurality of sequences under different resolutions used in the general test, and parameters such as a corresponding test frame number under the configuration of an intra-frame mode (al intra, AI), a random access mode (RA), and the like, and an intra-frame period (IntraPeriod), and the like, so that the test requirements under different scenes can be satisfied. The performance tests under the two configurations of the full-frame mode and the random access mode are performed under the general test condition of the AVS3 standard, as shown in fig. 12a and fig. 12b, fig. 12a is a schematic diagram of the performance test result of the coefficient code under the AI configuration provided by the embodiment of the present application, and fig. 12b is a schematic diagram of the performance test result of the coefficient code under the RA configuration provided by the embodiment of the present application. The performance gain of the algorithm is measured objectively using the BD-rate value, which represents the performance gain of the algorithm, with YUV representing the three components. Where a negative number represents a performance gain and a positive number represents a performance loss. In the algorithm evaluation, the performance considerations of component Y are much greater than component UV. That is, the coefficient coding and decoding method provided by the embodiment of the present application is beneficial from the viewpoint of the expression of the component Y. Specifically, as can be seen from fig. 12a and fig. 12b, in the AI mode, the gain of the coefficient coding and decoding method provided by the embodiment of the present application is 0.06% in the Y component, and in the RA mode, the gain of the coefficient coding and decoding method provided by the embodiment of the present application is 0.09% in the Y component. Therefore, the effectiveness of the coefficient coding and decoding method provided by the embodiment of the application can be illustrated.
It should be noted that, for simplicity of description, the foregoing method embodiments are all described as a series of acts, but it should be understood by those skilled in the art that the present application is not limited by the order of acts described, as some steps may be performed in other orders or concurrently in accordance with the present application. Further, those skilled in the art will recognize that the embodiments described in the specification are all of the preferred embodiments, and that the acts and modules referred to are not necessarily required for the present application.
In order to facilitate better implementation of the above-described aspects of embodiments of the present application, the following provides related devices for implementing the above-described aspects.
Referring to fig. 13, a coefficient encoding apparatus 1300 according to an embodiment of the present application may include: a transceiver module 1301, a processing module 1302, wherein,
the processing module is used for carrying out quantization operation on the residual block to obtain a quantized coefficient block;
the processing module is configured to determine distribution information of non-zero coefficients in the quantized coefficient block corresponding to each of the templates by using a preset plurality of templates, where the templates include: the distribution information of the non-zero coefficient corresponding to the current template comprises: the distribution condition of the non-zero coefficient in the inner area and the outer area of the current template, wherein the inner area of the current template is smaller than or equal to the area size of the quantization coefficient block, and the inner areas of different templates in the templates are different;
The processing module is used for respectively scanning and encoding the quantized coefficient blocks according to the distribution information of the non-zero coefficient corresponding to each template in the templates so as to obtain coefficient encoding results corresponding to the templates respectively;
and selecting a target template from the templates according to coefficient coding results respectively corresponding to the templates, wherein the target template and the coefficient coding results corresponding to the target template are contained in a coding code stream to be transmitted of a transceiver module.
In one possible implementation, the processing module is configured to determine a basic unit for scanning the quantized coefficient block; determining a first distribution parameter of the basic unit according to the distribution condition of the basic unit in an inner area or an outer area of the current template, wherein the distribution information of the non-zero coefficient in the quantization coefficient block corresponding to the current template comprises: the index of the current template and the first distribution parameter of the basic unit.
In one possible implementation manner, when all basic units in the quantized coefficient block are in the internal area of the current template, the value of the first distribution parameter of the basic units is a first numerical value; or when the basic unit belonging to the external area of the current template in the quantized coefficient block comprises a non-zero coefficient, the value of the first distribution parameter of the basic unit is a second value.
In one possible implementation, when the basic unit is a coefficient point in the quantized coefficient block, the first distribution parameter of the basic unit includes: the value of a first coefficient point which belongs to the inner area of the current template in the quantized coefficient block and the value of a second coefficient point which belongs to the outer area of the current template in the quantized coefficient block; the value of the first coefficient point is the value of a coefficient point belonging to the inner area of the current template in the quantized coefficient block; the value of the second coefficient point is the value of the coefficient point belonging to the external area of the current template in the quantized coefficient block, or the value of the second coefficient point is zero.
In one possible implementation manner, when the basic unit is a coefficient point in the quantized coefficient block, the processing module is configured to determine, according to distribution information of the non-zero coefficient corresponding to each of the templates and a preset scanning manner, a syntax element to be encoded corresponding to the quantized coefficient block, where the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block and the last non-zero position coordinates corresponding to the quantized coefficient block; when all non-zero coefficients in the quantized coefficient block belong to the inner area of the current template in the templates, scanning the inner area of the current template, and skipping scanning the outer area of the current template; and encoding the syntax element to be encoded corresponding to the non-zero coefficient scanned from the inner area of the current template to obtain a coefficient encoding result corresponding to the current template.
In one possible implementation manner, when the basic unit is a coefficient point in the quantized coefficient block, the processing module is configured to determine, according to distribution information of the non-zero coefficient corresponding to each of the templates and a preset scanning manner, a syntax element to be encoded corresponding to the quantized coefficient block, where the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block and the last non-zero position coordinates corresponding to the quantized coefficient block; scanning an inner area and an outer area of a current template belonging to the templates when non-zero coefficients exist in the outer area of the current template in the quantization coefficient block; coding quantization coefficient position information corresponding to a non-zero coefficient scanned from an inner region of the current template, skipping coding of a last non-zero identifier corresponding to the non-zero coefficient scanned from the inner region of the current template, and coding syntax elements to be coded corresponding to the non-zero coefficient scanned from an outer region of the current template to obtain a coefficient coding result corresponding to the current template; or when non-zero coefficients exist in the quantization coefficient block in the outer region of the current template belonging to the templates, scanning the inner region and the outer region of the current template; and encoding quantized coefficient position information corresponding to the non-zero coefficient scanned from the inner area of the current template, encoding a syntax element to be encoded corresponding to the non-zero coefficient scanned from the outer area of the current template, and encoding last non-zero position coordinates corresponding to the quantized coefficient block to obtain a coefficient encoding result corresponding to the current template.
In a possible implementation manner, the processing module is configured to encode last non-zero position coordinates corresponding to the quantized coefficient block according to the current template.
In one possible implementation, when the basic unit is a coefficient group in the quantized coefficient block, the first distribution parameter of the basic unit includes: the value of a first coefficient group in the quantized coefficient block, which belongs to the inner area of the current template, and the value of a second coefficient group in the quantized coefficient block, which belongs to the outer area of the current template; wherein the value of the first coefficient group includes the value of a coefficient point belonging to the inner area of the current template in the quantized coefficient block; the values of the second coefficient group include values of coefficient points belonging to an external area of the current template in the quantized coefficient block, or the values of the second coefficient group include zero.
In one possible implementation manner, when the basic unit is a coefficient group in the quantized coefficient block, the processing module is configured to determine, according to distribution information of the non-zero coefficient corresponding to each of the templates and a preset scanning manner, a syntax element to be encoded corresponding to the quantized coefficient block, where the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero position coordinate corresponding to the quantized coefficient block; when all non-zero coefficient groups in the quantized coefficient block belong to the inner area of the current template in the templates, scanning the inner area of the current template, and skipping scanning the outer area of the current template; and encoding the syntax elements to be encoded corresponding to the non-zero coefficient groups scanned from the inner area of the current template, and encoding the syntax elements to be encoded corresponding to the non-zero coefficients included in the non-zero coefficient groups scanned from the inner area of the current template, so as to obtain coefficient encoding results corresponding to the current template.
In one possible implementation manner, when the basic unit is a coefficient group in the quantized coefficient block, the processing module is configured to determine, according to distribution information of the non-zero coefficient corresponding to each of the templates and a preset scanning manner, a syntax element to be encoded corresponding to the quantized coefficient block, where the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero position coordinate corresponding to the quantized coefficient block; scanning the inner area and the outer area of the current template when a non-zero coefficient group exists in the outer area belonging to the current template in the quantized coefficient block; encoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner region of the current template, skipping encoding of the last non-zero identifier corresponding to the non-zero coefficient group scanned from the inner region of the current template, encoding the syntax element to be encoded corresponding to the non-zero coefficient group scanned from the outer region of the current template, and encoding the syntax element to be encoded corresponding to the non-zero coefficient included in the non-zero coefficient groups scanned from the inner region and the outer region of the current template to obtain a coefficient encoding result corresponding to the current template; or when a non-zero coefficient group exists in the external area belonging to the current template in the quantized coefficient block, scanning the internal area and the external area of the current template; and encoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner area of the current template, encoding the last non-zero position coordinate corresponding to the quantized coefficient block, encoding the syntax element to be encoded corresponding to the non-zero coefficient group scanned from the outer area of the current template, and encoding the syntax element to be encoded corresponding to the non-zero coefficient included in the non-zero coefficient group scanned from the inner area and the outer area of the current template, so as to obtain the coefficient encoding result corresponding to the current template.
In a possible implementation manner, the processing module is configured to encode last non-zero position coordinates corresponding to the quantized coefficient block according to the current template.
In a possible implementation manner, the processing module is configured to obtain coefficient coding costs corresponding to the multiple templates according to coefficient coding results corresponding to the multiple templates respectively; and selecting the minimum cost from coefficient coding costs corresponding to the templates, wherein the target template is the template corresponding to the selected minimum cost.
In one possible implementation, each of the plurality of templates includes: the device comprises a first module, a second module and a third module, wherein the first module is positioned in the left vertical direction of the quantized coefficient block, the second module is positioned in the left upper corner area of the quantized coefficient block, and the third module is positioned in the upper horizontal direction of the quantized coefficient block.
In one possible implementation, each template of the plurality of templates includes 1 second module, a ratio between a region size of the second module and a region size of the quantization coefficient block is greater than 0 and less than or equal to 1; and/or, each template in the plurality of templates comprises a plurality of second modules, and the length of the second module, close to the left vertical direction, in each template is larger than the length of the second module, far away from the left vertical direction, in each template.
In one possible implementation, the length of the first module is less than or equal to the length of the quantized coefficient block, or the length of the first module is determined by at least one of a template to which the first module belongs and the size of the quantized coefficient block; the length of the third module is smaller than or equal to the length of the quantized coefficient block, or the length of the third module is determined by at least one of a template to which the third module belongs and the size of the quantized coefficient block.
As can be seen from the foregoing illustration, the residual block is first quantized to obtain a quantized coefficient block; and then determining distribution information of non-zero coefficients in the quantized coefficient block corresponding to each template in the templates by using a plurality of preset templates, wherein the templates comprise current templates, and the distribution information of the non-zero coefficients corresponding to the current templates comprises: the distribution condition of the non-zero coefficients in the inner area and the outer area of the current template, wherein the inner area of the current template is smaller than or equal to the area size of the quantization coefficient block, and the inner areas of different templates in the templates are different; then, the quantized coefficient block is scanned and coded according to the distribution information of each template in the plurality of templates corresponding to the non-zero coefficients, so as to obtain coefficient coding results corresponding to the templates respectively; and finally, selecting a target template from the templates according to coefficient coding results respectively corresponding to the templates, wherein the target template and the coefficient coding results corresponding to the target template are contained in the coded code stream to be transmitted. According to the method and the device for determining the distribution information of the quantized coefficients, based on the diversity distribution of the quantized coefficients, various templates can be used for determining the distribution information of the non-zero coefficients corresponding to each template in the templates, so that the non-zero coefficients corresponding to the distribution information of each template in the templates can be used for scanning and encoding, a target template selected from the templates and a coefficient encoding result corresponding to the target template are included in a final code stream to be transmitted, and therefore the scanning mode and the encoding mode of each quantized coefficient of the whole quantized coefficient block can be better adjusted, the scanning cost and the encoding cost in the coefficient encoding process can be effectively reduced, the redundant encoding mode can be reduced, and the encoding performance in the coefficient encoding process can be improved.
Referring to fig. 14, a coefficient decoding apparatus 1400 according to an embodiment of the present application may include: a transceiver module 1401, a processing module 1402, wherein,
the processing module is used for acquiring a target template and a coefficient coding result corresponding to the target template from the coding code stream received by the receiving and transmitting module;
the processing module is configured to determine, according to the target template, distribution information of a non-zero coefficient to be decoded in the coefficient encoding result, where the distribution information of the non-zero coefficient to be decoded, corresponding to the target template, includes: distribution conditions of the non-zero coefficients to be decoded in an inner area and an outer area of the target template;
and the processing module is used for scanning and decoding the non-zero coefficient to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template so as to obtain a quantized coefficient block.
In one possible implementation manner, the distribution information of the non-zero coefficient to be decoded corresponding to the target template includes a template index of the target template and a basic unit distribution parameter, where the basic unit distribution parameter is used to determine the distribution situation of the non-zero coefficient to be decoded in an inner area and an outer area of the target template.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient point in a quantized coefficient block to be decoded, the processing module is configured to determine, according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of the target template and a preset scanning manner, a syntax element to be decoded corresponding to the quantized coefficient block to be decoded, where the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block to be decoded and the last non-zero position coordinates corresponding to the quantized coefficient block to be decoded; when all non-zero coefficients in the quantized coefficient block to be encoded belong to the inner region of the target template, scanning the inner region of the target template, and skipping scanning the outer region of the target template; and decoding the syntax element to be decoded corresponding to the non-zero coefficient scanned from the internal area of the target template to obtain a quantization coefficient block corresponding to the target template.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient point in a quantized coefficient block to be decoded, the processing module is configured to determine, according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of the target template and a preset scanning manner, a syntax element to be decoded corresponding to the quantized coefficient block to be decoded, where the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block to be decoded and the last non-zero position coordinates corresponding to the quantized coefficient block to be decoded; scanning the inner area and the outer area of the target template when the non-zero coefficient exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; decoding quantized coefficient position information corresponding to a non-zero coefficient scanned from an inner region of the target template, skipping decoding of a last non-zero identification corresponding to the non-zero coefficient scanned from the inner region of the target template, and decoding syntax elements to be decoded corresponding to the non-zero coefficient scanned from an outer region of the target template to obtain quantized coefficient blocks corresponding to the target template; or when non-zero coefficients exist in the outer region belonging to the target template in the quantized coefficient block to be decoded, scanning the inner region and the outer region of the target template; and decoding quantized coefficient position information corresponding to the non-zero coefficient scanned from the inner area of the target template, decoding syntax elements to be decoded corresponding to the non-zero coefficient scanned from the outer area of the target template, and decoding last non-zero position coordinates corresponding to the quantized coefficient block to obtain the quantized coefficient block corresponding to the target template.
In a possible implementation manner, the processing module is configured to decode the last non-zero position coordinate corresponding to the quantized coefficient block according to the current template.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient group in a quantized coefficient block to be decoded, the processing module is configured to determine, according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of the target template and a preset scanning manner, a syntax element to be decoded corresponding to the quantized coefficient block to be decoded, where the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero position coordinate corresponding to the quantized coefficient block to be decoded; when all non-zero coefficient groups in the quantized coefficient block to be decoded belong to the inner region of the target template, scanning the inner region of the target template, and skipping scanning the outer region of the target template; and decoding the syntax elements to be decoded corresponding to the non-zero coefficient groups scanned from the inner area of the target template, and decoding the syntax elements to be decoded corresponding to the non-zero coefficients included in the non-zero coefficient groups scanned from the inner area of the target template, so as to obtain the quantization coefficient blocks corresponding to the target template.
In one possible implementation manner, when the basic unit for scanning the non-zero coefficient to be decoded is a coefficient group in a quantized coefficient block to be decoded, the processing module is configured to determine, according to a distribution condition of the non-zero coefficient to be decoded in an inner area and an outer area of the target template and a preset scanning manner, a syntax element to be decoded corresponding to the quantized coefficient block to be decoded, where the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero position coordinate corresponding to the quantized coefficient block to be decoded; scanning the inner area and the outer area of the target template when a non-zero coefficient group exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; decoding quantization coefficient group position information corresponding to a non-zero coefficient group scanned from an inner region of the target template, skipping decoding of a last non-zero flag corresponding to the non-zero coefficient group scanned from the inner region of the target template, decoding syntax elements to be decoded corresponding to the non-zero coefficient group scanned from an outer region of the target template, and decoding syntax elements to be decoded corresponding to non-zero coefficients included in the non-zero coefficient groups scanned from the inner region and the outer region of the target template to obtain quantization coefficient blocks corresponding to the target template; or when a non-zero coefficient group exists in an external area belonging to a target template in the quantized coefficient block to be decoded, scanning the internal area and the external area of the target template; and decoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner area of the target template, decoding the last non-zero position coordinate corresponding to the quantized coefficient block, decoding the syntax element to be decoded corresponding to the non-zero coefficient group scanned from the outer area of the target template, and decoding the syntax element to be decoded corresponding to the non-zero coefficient included in the non-zero coefficient group scanned from the inner area and the outer area of the target template to obtain the quantized coefficient block corresponding to the target template.
In a possible implementation manner, the processing module is configured to decode the last non-zero position coordinate corresponding to the quantized coefficient block according to the current template.
In one possible implementation, the target template includes: the device comprises a first module, a second module and a third module, wherein the first module is positioned in the left vertical direction of the quantized coefficient block, the second module is positioned in the left upper corner area of the quantized coefficient block, and the third module is positioned in the upper horizontal direction of the quantized coefficient block.
In one possible implementation, the target template includes 1 second module, and a ratio between a region size of the second module and a region size of the quantization coefficient block is greater than 0 and less than or equal to 1; and/or the target template comprises a plurality of second modules, and the length of the second modules, close to the left vertical direction, in the target template is larger than the length of the second modules, far away from the left vertical direction, in the target template.
In one possible implementation manner, the length of the first module is smaller than or equal to the length of the quantized coefficient block, or the length of the first module is determined by at least one of a target template to which the first module belongs and the size of the quantized coefficient block; the length of the third module is smaller than or equal to the length of the quantized coefficient block, or the length of the third module is determined by at least one of a target template to which the third module belongs and the size of the quantized coefficient block.
As can be seen from the foregoing illustration, first, a target template and a coefficient coding result corresponding to the target template are obtained from a received coded code stream; secondly, determining distribution information of the non-zero coefficient to be decoded in the coefficient coding result corresponding to each template in the plurality of templates according to the target template, wherein the distribution information of the non-zero coefficient to be decoded corresponding to each template in the plurality of templates comprises the following steps: distribution of non-zero coefficients to be decoded in an inner region and an outer region of the target template; and finally, scanning and decoding the non-zero coefficient to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template to obtain a quantized coefficient block. The code stream received in the embodiment of the application comprises the target template, the target template can be used for determining the distribution information of each template in the templates corresponding to the non-zero coefficient to be decoded, and the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template is determined based on the distribution information of each template in the templates corresponding to the non-zero coefficient, so that the scanning mode and the decoding mode of each quantized coefficient to be decoded can be better adjusted, the scanning cost and the decoding cost in the coefficient decoding process can be effectively reduced, the redundant decoding mode can be reduced, and the decoding performance in the coefficient decoding process can be improved.
It should be noted that, because the content of information interaction and execution process between the modules/units of the above-mentioned device is based on the same concept as the method embodiment of the present application, the technical effects brought by the content are the same as the method embodiment of the present application, and the specific content can be referred to the description in the foregoing illustrated method embodiment of the present application, which is not repeated herein.
The embodiment of the application also provides a computer storage medium, wherein the computer storage medium stores a program, and the program executes part or all of the steps described in the embodiment of the method.
Referring to fig. 15, referring to another coefficient encoding apparatus provided in an embodiment of the present application, a coefficient encoding apparatus 1500 includes:
a receiver 1501, a transmitter 1502, a processor 1503 and a memory 1504 (where the number of processors 1503 in the coefficient encoding apparatus 1500 may be one or more, one processor being an example in fig. 15). In some embodiments of the application, the receiver 1501, transmitter 1502, processor 1503 and memory 1504 may be connected by a bus or otherwise, where a bus connection is illustrated in fig. 15.
Memory 1504 may include read only memory and random access memory and provide instructions and data to the processor 1503. A portion of the memory 1504 may also include non-volatile random access memory (non-volatile random access memory, NVRAM). The memory 1504 stores an operating system and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, where the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various underlying services and handling hardware-based tasks.
The processor 1503 controls the operation of the coefficient encoding apparatus, the processor 1503 may also be referred to as a central processing unit (central processing unit, CPU). In a specific application, the individual components of the coefficient encoding apparatus are coupled together by a bus system, which may include, in addition to a data bus, a power bus, a control bus, a status signal bus, etc. For clarity of illustration, however, the various buses are referred to in the figures as bus systems.
The method disclosed in the above embodiment of the present application may be applied to the processor 1503 or implemented by the processor 1503. The processor 1503 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in the processor 1503 or by instructions in the form of software. The processor 1503 described above may be a general purpose processor, a digital signal processor (digital signal processing, DSP), an application specific integrated circuit (application specific integrated circuit, ASIC), a field-programmable gate array (field-programmable gate array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software modules in a decoding processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or an electrically erasable programmable memory, register, or other well-established storage medium. The storage medium is located in the memory 1504 and the processor 1503 reads the information in the memory 1504 and in combination with its hardware performs the steps of the above method.
The receiver 1501 may be used to receive input digital or character information and to generate signal inputs related to the relevant settings and function control of the coefficient encoding apparatus, the transmitter 1502 may comprise a display device such as a display screen, and the transmitter 1502 may be used to output digital or character information via an external interface.
In an embodiment of the present application, the processor 1503 is configured to perform the coefficient encoding method performed by the coefficient encoding apparatus shown in fig. 3 in the foregoing embodiment.
Referring to fig. 16, referring to another coefficient decoding apparatus provided in an embodiment of the present application, a coefficient decoding apparatus 1600 includes:
a receiver 1601, a transmitter 1602, a processor 1603, and a memory 1604 (where the number of processors 1603 in the coefficient decoding apparatus 1600 may be one or more, one processor is illustrated in fig. 16). In some embodiments of the application, the receiver 1601, transmitter 1602, processor 1603, and memory 1604 may be connected by a bus or otherwise, where a bus connection is illustrated in fig. 16.
Memory 1604 may include read only memory and random access memory, and provides instructions and data to processor 1603. A portion of the memory 1604 may also include NVRAM. The memory 1604 stores an operating system and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, where the operating instructions may include various operating instructions for performing various operations. The operating system may include various system programs for implementing various underlying services and handling hardware-based tasks.
The processor 1603 controls the operation of the coefficient decoding apparatus, and the processor 1603 may also be referred to as a CPU. In a specific application, the individual components of the coefficient decoding apparatus are coupled together by a bus system, which may include, in addition to a data bus, a power bus, a control bus, a status signal bus, etc. For clarity of illustration, however, the various buses are referred to in the figures as bus systems.
The method disclosed in the above embodiment of the present application may be applied to the processor 1603 or implemented by the processor 1603. Processor 1603 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuitry in hardware or instructions in software in processor 1603. The processor 1603 described above may be a general purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software modules in a decoding processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or an electrically erasable programmable memory, register, or other well-established storage medium. The storage medium is located in the memory 1604 and the processor 1603 reads information in the memory 1604 and performs the steps of the method described above in connection with its hardware.
In an embodiment of the present application, the processor 1603 is configured to perform the coefficient encoding method performed by the coefficient decoding apparatus shown in fig. 3 in the foregoing embodiment.
In another possible design, the coefficient coding scheme provided by the embodiment of the present application may be implemented by program codes in a memory, or may be directly embedded in the coefficient encoding apparatus and the coefficient decoding apparatus by a hardware module. When the coefficient encoding apparatus or the coefficient decoding apparatus is a chip in a terminal, the chip includes: a processing unit, which may be, for example, a processor, and a communication unit, which may be, for example, an input/output interface, pins or circuitry, etc. The processing unit may execute the computer-executable instructions stored by the storage unit to cause a chip within the terminal to perform the wireless communication method of any one of the above-described first aspects. Alternatively, the storage unit is a storage unit in the chip, such as a register, a cache, or the like, and the storage unit may also be a storage unit in the terminal located outside the chip, such as a read-only memory (ROM) or other type of static storage device that may store static information and instructions, a random access memory (random access memory, RAM), or the like.
The processor mentioned in any of the above may be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the program of the method of the first or second aspect.
It should be further noted that the above-described apparatus embodiments are merely illustrative, and that the units described as separate units may or may not be physically separate, and that units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, in the drawings of the embodiment of the device provided by the application, the connection relation between the modules represents that the modules have communication connection, and can be specifically implemented as one or more communication buses or signal lines.
From the above description of the embodiments, it will be clear to those skilled in the art that the present application may be implemented by means of software plus necessary general purpose hardware, or of course by means of special purpose hardware, including application specific integrated circuits, special purpose CPUs, special purpose memories, special purpose components, etc. Generally, functions performed by computer programs can be easily implemented by corresponding hardware, and specific hardware structures for implementing the same functions can be varied, such as analog circuits, digital circuits, or dedicated circuits. However, a software program implementation is a preferred embodiment for many more of the cases of the present application. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a readable storage medium, such as a floppy disk, a usb disk, a removable hard disk, a ROM, a RAM, a magnetic disk or an optical disk of a computer, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments of the present application.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product.
The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by a wired (e.g., coaxial cable, fiber optic, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be stored by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., a floppy Disk, a hard Disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a Solid State Disk (SSD)), or the like.

Claims (30)

1. A coefficient encoding method, comprising:
performing quantization operation on the residual block to obtain a quantized coefficient block;
determining distribution information of non-zero coefficients in the quantized coefficient block corresponding to each template in the templates by using a plurality of preset templates, wherein the templates comprise: the distribution information of the non-zero coefficient corresponding to the current template comprises: the distribution condition of the non-zero coefficient in the inner area and the outer area of the current template, wherein the inner area of the current template is smaller than or equal to the area size of the quantization coefficient block, and the inner areas of different templates in the templates are different;
scanning and encoding the quantized coefficient blocks according to the distribution information of the non-zero coefficient corresponding to each template in the templates respectively to obtain coefficient encoding results corresponding to the templates respectively;
and selecting a target template from the templates according to coefficient coding results respectively corresponding to the templates, wherein the target template and the coefficient coding results corresponding to the target template are contained in a coding code stream to be transmitted.
2. The method according to claim 1, wherein determining distribution information of non-zero coefficients in the quantized coefficient block corresponding to each of the plurality of templates using a preset plurality of templates comprises:
determining a basic unit for scanning the quantized coefficient block;
determining a first distribution parameter of the basic unit according to the distribution condition of the basic unit in an inner area or an outer area of the current template, wherein the distribution information of the non-zero coefficient in the quantization coefficient block corresponding to the current template comprises: the index of the current template and the first distribution parameter of the basic unit.
3. The method according to claim 2, wherein the value of the first distribution parameter of the basic unit is a first value when all basic units in the quantized coefficient block are located in the inner region of the current template;
or alternatively, the process may be performed,
when the basic unit belonging to the external area of the current template in the quantized coefficient block comprises a non-zero coefficient, the value of the first distribution parameter of the basic unit is a second value.
4. A method according to claim 2 or 3, wherein when the base unit is a coefficient point in the quantized coefficient block, the first distribution parameter of the base unit comprises: the value of a first coefficient point which belongs to the inner area of the current template in the quantized coefficient block and the value of a second coefficient point which belongs to the outer area of the current template in the quantized coefficient block;
The value of the first coefficient point is the value of a coefficient point belonging to the inner area of the current template in the quantized coefficient block;
the value of the second coefficient point is the value of the coefficient point belonging to the external area of the current template in the quantized coefficient block, or the value of the second coefficient point is zero.
5. The method according to any one of claims 2 to 4, wherein when the basic unit is a coefficient point in the quantized coefficient block, the scanning and encoding the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each of the templates to obtain coefficient encoding results corresponding to the templates, respectively, includes:
determining a syntax element to be encoded corresponding to the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each template in the plurality of templates and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block and the last non-zero position coordinates corresponding to the quantized coefficient block;
When all non-zero coefficients in the quantized coefficient block belong to the inner area of the current template in the templates, scanning the inner area of the current template, and skipping scanning the outer area of the current template; and encoding the syntax element to be encoded corresponding to the non-zero coefficient scanned from the inner area of the current template to obtain a coefficient encoding result corresponding to the current template.
6. The method according to any one of claims 2 to 4, wherein when the basic unit is a coefficient point in the quantized coefficient block, the scanning and encoding the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each of the templates to obtain coefficient encoding results corresponding to the templates, respectively, includes:
determining a syntax element to be encoded corresponding to the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each template in the plurality of templates and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block and the last non-zero position coordinates corresponding to the quantized coefficient block;
Scanning an inner area and an outer area of a current template belonging to the templates when non-zero coefficients exist in the outer area of the current template in the quantization coefficient block; coding quantization coefficient position information corresponding to a non-zero coefficient scanned from an inner region of the current template, skipping coding of a last non-zero identifier corresponding to the non-zero coefficient scanned from the inner region of the current template, and coding syntax elements to be coded corresponding to the non-zero coefficient scanned from an outer region of the current template to obtain a coefficient coding result corresponding to the current template; or alternatively, the process may be performed,
scanning an inner area and an outer area of a current template belonging to the templates when non-zero coefficients exist in the outer area of the current template in the quantization coefficient block; and encoding quantized coefficient position information corresponding to the non-zero coefficient scanned from the inner area of the current template, encoding a syntax element to be encoded corresponding to the non-zero coefficient scanned from the outer area of the current template, and encoding last non-zero position coordinates corresponding to the quantized coefficient block to obtain a coefficient encoding result corresponding to the current template.
7. The method of claim 6, wherein encoding the last non-zero position coordinates corresponding to the block of quantized coefficients comprises:
and encoding the last non-zero position coordinates corresponding to the quantized coefficient block according to the current template.
8. A method according to claim 2 or 3, wherein when the base unit is a set of coefficients in the block of quantized coefficients, the first distribution parameters of the base unit comprise: the value of a first coefficient group in the quantized coefficient block, which belongs to the inner area of the current template, and the value of a second coefficient group in the quantized coefficient block, which belongs to the outer area of the current template;
wherein the value of the first coefficient group includes the value of a coefficient point belonging to the inner area of the current template in the quantized coefficient block;
the values of the second coefficient group include values of coefficient points belonging to an external area of the current template in the quantized coefficient block, or the values of the second coefficient group include zero.
9. The method according to claim 2, 3 or 8, wherein when the basic unit is a coefficient group in the quantized coefficient block, the scanning and encoding the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each of the templates to obtain coefficient encoding results corresponding to the templates, respectively, includes:
Determining a syntax element to be encoded corresponding to the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each template in the plurality of templates and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero position coordinate corresponding to the quantized coefficient block;
when all non-zero coefficient groups in the quantized coefficient block belong to the inner area of the current template in the templates, scanning the inner area of the current template, and skipping scanning the outer area of the current template; and encoding the syntax elements to be encoded corresponding to the non-zero coefficient groups scanned from the inner area of the current template, and encoding the syntax elements to be encoded corresponding to the non-zero coefficients included in the non-zero coefficient groups scanned from the inner area of the current template, so as to obtain coefficient encoding results corresponding to the current template.
10. The method according to claim 2, 3 or 8, wherein when the basic unit is a coefficient group in the quantized coefficient block, the scanning and encoding the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each of the templates to obtain coefficient encoding results corresponding to the templates, respectively, includes:
determining a syntax element to be encoded corresponding to the quantized coefficient block according to the distribution information of the non-zero coefficient corresponding to each template in the plurality of templates and a preset scanning mode, wherein the syntax element to be encoded corresponding to the quantized coefficient block comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be encoded corresponding to the quantized coefficient block includes: the quantized coefficient position information corresponding to the coefficient group in the quantized coefficient block and the last non-zero position coordinate corresponding to the quantized coefficient block;
scanning the inner area and the outer area of the current template when a non-zero coefficient group exists in the outer area belonging to the current template in the quantized coefficient block; encoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner region of the current template, skipping encoding of the last non-zero identifier corresponding to the non-zero coefficient group scanned from the inner region of the current template, encoding the syntax element to be encoded corresponding to the non-zero coefficient group scanned from the outer region of the current template, and encoding the syntax element to be encoded corresponding to the non-zero coefficient included in the non-zero coefficient groups scanned from the inner region and the outer region of the current template to obtain a coefficient encoding result corresponding to the current template; or alternatively, the process may be performed,
Scanning the inner area and the outer area of the current template when a non-zero coefficient group exists in the outer area belonging to the current template in the quantized coefficient block; and encoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner area of the current template, encoding the last non-zero position coordinate corresponding to the quantized coefficient block, encoding the syntax element to be encoded corresponding to the non-zero coefficient group scanned from the outer area of the current template, and encoding the syntax element to be encoded corresponding to the non-zero coefficient included in the non-zero coefficient group scanned from the inner area and the outer area of the current template, so as to obtain the coefficient encoding result corresponding to the current template.
11. The method of claim 10, wherein encoding the last non-zero position coordinates corresponding to the block of quantized coefficients comprises:
and encoding the last non-zero position coordinates corresponding to the quantized coefficient block according to the current template.
12. The method according to any one of claims 1 to 11, wherein selecting a target template from the plurality of templates according to coefficient encoding results respectively corresponding to the plurality of templates comprises:
Respectively acquiring coefficient coding costs corresponding to the templates according to coefficient coding results corresponding to the templates respectively;
and selecting the minimum cost from coefficient coding costs corresponding to the templates, wherein the target template is the template corresponding to the selected minimum cost.
13. The method of any one of claims 1 to 12, wherein each of the plurality of templates comprises: a first module, a second module and a third module, wherein,
the first module is located in a left vertical direction of the quantized coefficient block, the second module is located in an upper left corner region of the quantized coefficient block, and the third module is located in an upper horizontal direction of the quantized coefficient block.
14. The method of claim 13, wherein each template of the plurality of templates comprises 1 second module, a ratio between a region size of the second module and a region size of the quantization coefficient block being greater than 0 and less than or equal to 1; and/or the number of the groups of groups,
each of the templates comprises a plurality of second modules, and the length of the second module, close to the left vertical direction, in each template is larger than the length of the second module, away from the left vertical direction, in each template.
15. The method according to claim 13 or 14, wherein the length of the first module is smaller than or equal to the length of the quantized coefficient block, or the length of the first module is determined by at least one of a template to which the first module belongs, the size of the quantized coefficient block;
the length of the third module is smaller than or equal to the length of the quantized coefficient block, or the length of the third module is determined by at least one of a template to which the third module belongs and the size of the quantized coefficient block.
16. A coefficient decoding method, comprising:
acquiring a target template and a coefficient coding result corresponding to the target template from a received coding code stream;
determining distribution information of the non-zero coefficient to be decoded in the coefficient coding result corresponding to the template according to the target template, wherein the distribution information of the non-zero coefficient to be decoded corresponding to the target template comprises the following steps: distribution conditions of the non-zero coefficients to be decoded in an inner area and an outer area of the target template;
scanning and decoding the non-zero coefficient to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template to obtain a quantized coefficient block, wherein the inner area of the target template is smaller than or equal to the area size of the quantized coefficient block, the target template belongs to a plurality of preset templates, and the inner areas of different templates in the templates are different.
17. The method of claim 16, wherein the distribution information of the non-zero coefficients to be decoded corresponding to the target template includes a template index of the target template and a base unit distribution parameter, wherein the base unit distribution parameter is used for determining a distribution condition of the non-zero coefficients to be decoded in an inner area and an outer area of the target template.
18. The method according to claim 16 or 17, wherein when the basic unit for scanning the non-zero coefficients to be decoded is a coefficient point in the quantized coefficient block to be decoded, the scanning and decoding the non-zero coefficients to be decoded according to the distribution of the non-zero coefficients to be decoded in the inner area and the outer area of the target template to obtain the quantized coefficient block includes:
determining a syntax element to be decoded corresponding to the quantized coefficient block to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block to be decoded and the last non-zero position coordinates corresponding to the quantized coefficient block to be decoded;
When all non-zero coefficients in the quantized coefficient block to be encoded belong to the inner region of the target template, scanning the inner region of the target template, and skipping the scanning of the outer region of the target template; and decoding the syntax element to be decoded corresponding to the non-zero coefficient scanned from the internal area of the target template to obtain a quantization coefficient block corresponding to the target template.
19. The method according to claim 16 or 17, wherein when the basic unit for scanning the non-zero coefficients to be decoded is a coefficient point in the quantized coefficient block to be decoded, the scanning and decoding the non-zero coefficients to be decoded according to the distribution of the non-zero coefficients to be decoded in the inner area and the outer area of the target template to obtain the quantized coefficient block includes:
determining a syntax element to be decoded corresponding to the quantized coefficient block to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient position information corresponding to the coefficient point in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient point, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded includes: the quantized coefficient position information corresponding to the coefficient points in the quantized coefficient block to be decoded and the last non-zero position coordinates corresponding to the quantized coefficient block to be decoded;
Scanning the inner area and the outer area of the target template when the non-zero coefficient exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; decoding quantized coefficient position information corresponding to a non-zero coefficient scanned from an inner region of the target template, skipping decoding of a last non-zero identification corresponding to the non-zero coefficient scanned from the inner region of the target template, and decoding syntax elements to be decoded corresponding to the non-zero coefficient scanned from an outer region of the target template to obtain quantized coefficient blocks corresponding to the target template; or alternatively, the process may be performed,
scanning the inner area and the outer area of the target template when the non-zero coefficient exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; and decoding quantized coefficient position information corresponding to the non-zero coefficient scanned from the inner area of the target template, decoding syntax elements to be decoded corresponding to the non-zero coefficient scanned from the outer area of the target template, and decoding last non-zero position coordinates corresponding to the quantized coefficient block to obtain the quantized coefficient block corresponding to the target template.
20. The method of claim 19, wherein decoding the last non-zero position coordinates corresponding to the block of quantized coefficients comprises:
and decoding the last non-zero position coordinates corresponding to the quantized coefficient block according to the current template.
21. The method according to claim 16 or 17, wherein when the basic unit for scanning the non-zero coefficients to be decoded is a coefficient group in a quantized coefficient block to be decoded, the scanning and decoding the non-zero coefficients to be decoded according to the distribution of the non-zero coefficients to be decoded in the inner region and the outer region of the target template to obtain the quantized coefficient block includes:
determining a syntax element to be decoded corresponding to the quantized coefficient block to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero position coordinate corresponding to the quantized coefficient block to be decoded;
When all non-zero coefficient groups in the quantized coefficient block to be decoded belong to the inner region of the target template, scanning the inner region of the target template, and skipping scanning the outer region of the target template; and decoding the syntax elements to be decoded corresponding to the non-zero coefficient groups scanned from the inner area of the target template, and decoding the syntax elements to be decoded corresponding to the non-zero coefficients included in the non-zero coefficient groups scanned from the inner area of the target template, so as to obtain the quantization coefficient blocks corresponding to the target template.
22. The method according to claim 16 or 17, wherein when the basic unit for scanning the non-zero coefficients to be decoded is a coefficient group in a quantized coefficient block to be decoded, the scanning and decoding the non-zero coefficients to be decoded according to the distribution of the non-zero coefficients to be decoded in the inner region and the outer region of the target template to obtain the quantized coefficient block includes:
determining a syntax element to be decoded corresponding to the quantized coefficient block to be decoded according to the distribution condition of the non-zero coefficient to be decoded in the inner area and the outer area of the target template and a preset scanning mode, wherein the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero identifier corresponding to the coefficient group, or the syntax element to be decoded corresponding to the quantized coefficient block to be decoded comprises: the quantized coefficient group position information corresponding to the coefficient group in the quantized coefficient block to be decoded and the last non-zero position coordinate corresponding to the quantized coefficient block to be decoded;
Scanning the inner area and the outer area of the target template when a non-zero coefficient group exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; decoding quantization coefficient group position information corresponding to a non-zero coefficient group scanned from an inner region of the target template, skipping decoding of a last non-zero flag corresponding to the non-zero coefficient group scanned from the inner region of the target template, decoding syntax elements to be decoded corresponding to the non-zero coefficient group scanned from an outer region of the target template, and decoding syntax elements to be decoded corresponding to non-zero coefficients included in the non-zero coefficient groups scanned from the inner region and the outer region of the target template to obtain quantization coefficient blocks corresponding to the target template; or alternatively, the process may be performed,
scanning the inner area and the outer area of the target template when a non-zero coefficient group exists in the outer area belonging to the target template in the quantized coefficient block to be decoded; and decoding the quantized coefficient group position information corresponding to the non-zero coefficient group scanned from the inner area of the target template, decoding the last non-zero position coordinate corresponding to the quantized coefficient block, decoding the syntax element to be decoded corresponding to the non-zero coefficient group scanned from the outer area of the target template, and decoding the syntax element to be decoded corresponding to the non-zero coefficient included in the non-zero coefficient group scanned from the inner area and the outer area of the target template to obtain the quantized coefficient block corresponding to the target template.
23. The method of claim 22, wherein decoding the last non-zero position coordinates corresponding to the block of quantized coefficients comprises:
and decoding the last non-zero position coordinates corresponding to the quantized coefficient block according to the current template.
24. The method of any one of claims 16 to 23, wherein the target template comprises: a first module, a second module and a third module, wherein,
the first module is located in a left vertical direction of the quantized coefficient block, the second module is located in an upper left corner region of the quantized coefficient block, and the third module is located in an upper horizontal direction of the quantized coefficient block.
25. The method of claim 24, wherein the target template comprises 1 second module, a ratio between a region size of the second module and a region size of the quantization coefficient block being greater than 0 and less than or equal to 1; and/or the number of the groups of groups,
the target template comprises a plurality of second modules, and the length of the second modules, close to the left vertical direction, in the target template is larger than that of the second modules, far away from the left vertical direction, in the target template.
26. The method according to claim 24 or 25, wherein the length of the first module is smaller than or equal to the length of the quantized coefficient block, or the length of the first module is determined by at least one of a target template to which the first module belongs, the size of the quantized coefficient block;
the length of the third module is smaller than or equal to the length of the quantized coefficient block, or the length of the third module is determined by at least one of a target template to which the third module belongs and the size of the quantized coefficient block.
27. A coefficient encoding apparatus, characterized in that the coefficient encoding apparatus comprises: a processor and a memory, the processor being for coupling with the memory, reading and executing instructions in the memory, performing the method of any of claims 1 to 15.
28. A coefficient decoding apparatus, characterized in that the coefficient decoding apparatus comprises: a processor and a memory, the processor being for coupling with the memory, reading and executing instructions in the memory, performing the method of any of claims 16 to 26.
29. A computer readable storage medium comprising instructions which, when run on a computer, cause the computer to perform the method of any one of claims 1 to 13 or 14 to 22.
30. A computer-readable storage medium comprising a coded bitstream obtained according to the coefficient coding method of any one of claims 1 to 15.
CN202010615529.XA 2020-06-30 2020-06-30 Coefficient coding and decoding method and coefficient coding and decoding device Active CN113873244B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010615529.XA CN113873244B (en) 2020-06-30 2020-06-30 Coefficient coding and decoding method and coefficient coding and decoding device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010615529.XA CN113873244B (en) 2020-06-30 2020-06-30 Coefficient coding and decoding method and coefficient coding and decoding device

Publications (2)

Publication Number Publication Date
CN113873244A CN113873244A (en) 2021-12-31
CN113873244B true CN113873244B (en) 2023-10-20

Family

ID=78981387

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010615529.XA Active CN113873244B (en) 2020-06-30 2020-06-30 Coefficient coding and decoding method and coefficient coding and decoding device

Country Status (1)

Country Link
CN (1) CN113873244B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1848960A (en) * 2005-01-06 2006-10-18 高通股份有限公司 Residual coding in compliance with a video standard using non-standardized vector quantization coder
CN105338351A (en) * 2014-05-28 2016-02-17 华为技术有限公司 Template coupling based intraframe prediction encoding and decoding method and apparatus, and array scanning method and apparatus
WO2019185818A1 (en) * 2018-03-29 2019-10-03 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. Transform coefficient block coding
CN110365993A (en) * 2012-06-01 2019-10-22 威勒斯媒体国际有限公司 Arithmetic decoding device, picture decoding apparatus, arithmetic coding device and picture coding device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010016453A (en) * 2008-07-01 2010-01-21 Sony Corp Image encoding apparatus and method, image decoding apparatus and method, and program
US9036710B2 (en) * 2012-03-08 2015-05-19 Blackberry Limited Unified transform coefficient encoding and decoding

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1848960A (en) * 2005-01-06 2006-10-18 高通股份有限公司 Residual coding in compliance with a video standard using non-standardized vector quantization coder
CN110365993A (en) * 2012-06-01 2019-10-22 威勒斯媒体国际有限公司 Arithmetic decoding device, picture decoding apparatus, arithmetic coding device and picture coding device
CN105338351A (en) * 2014-05-28 2016-02-17 华为技术有限公司 Template coupling based intraframe prediction encoding and decoding method and apparatus, and array scanning method and apparatus
WO2019185818A1 (en) * 2018-03-29 2019-10-03 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. Transform coefficient block coding

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
《A novel fast DCT coefficient scan architecture》;Da An 等;《2009 Picture Coding Symposium》;20090721;全文 *
《AHG12:Raster scan order subpicture,JVET-S0206》;Mitra Damghanian等;《JVET会议》;20200619;全文 *
一种基于行程编码和小波变换的图像压缩编码算法;王常远等;《计算机应用》;20070601;全文 *
王常远等.一种基于行程编码和小波变换的图像压缩编码算法.《计算机应用》.2007, *

Also Published As

Publication number Publication date
CN113873244A (en) 2021-12-31

Similar Documents

Publication Publication Date Title
US9992497B2 (en) High throughput significance map processing for CABAC in HEVC
US11695962B2 (en) Encoding and decoding methods and corresponding devices
US11381822B2 (en) Scalar quantizer decision scheme for dependent scalar quantization
WO2020182104A1 (en) Encoding and decoding methods, decoding device, and encoding device
CN113873244B (en) Coefficient coding and decoding method and coefficient coding and decoding device
CN112106365A (en) Method and apparatus for adaptive context modeling in video encoding and decoding
CN116982262A (en) State transition for dependent quantization in video coding
CN107409216B (en) Image encoding and decoding method, encoding and decoding device and corresponding computer program
US20180070109A1 (en) Encoding of images by vector quantization
US20230039840A1 (en) Picture processing method and apparatus
CN114885160A (en) Video encoding and decoding method and device, computer readable medium and electronic equipment
CN116998150A (en) State transition for grid quantization in video coding and decoding
CN116980609A (en) Video data processing method, device, storage medium and equipment
CN115943628A (en) Method and system for combined lossless and lossy coding
CN112042193A (en) Encoding and decoding video

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant