CN111787326B - Entropy coding and decoding method and device - Google Patents
Entropy coding and decoding method and device Download PDFInfo
- Publication number
- CN111787326B CN111787326B CN202010758338.9A CN202010758338A CN111787326B CN 111787326 B CN111787326 B CN 111787326B CN 202010758338 A CN202010758338 A CN 202010758338A CN 111787326 B CN111787326 B CN 111787326B
- Authority
- CN
- China
- Prior art keywords
- value
- prediction
- decoded
- decoding
- current
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 71
- 238000012545 processing Methods 0.000 claims abstract description 34
- 238000006243 chemical reaction Methods 0.000 claims description 7
- 238000004590 computer program Methods 0.000 claims description 6
- 230000006835 compression Effects 0.000 abstract description 24
- 238000007906 compression Methods 0.000 abstract description 24
- 238000010586 diagram Methods 0.000 description 12
- 238000013139 quantization Methods 0.000 description 10
- 238000005516 engineering process Methods 0.000 description 4
- 230000009466 transformation Effects 0.000 description 4
- 230000009286 beneficial effect Effects 0.000 description 3
- 238000001914 filtration Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 230000002441 reversible effect Effects 0.000 description 3
- 230000000007 visual effect Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000007781 pre-processing Methods 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 238000011084 recovery Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000002123 temporal effect Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/102—Methods 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/13—Adaptive entropy coding, e.g. adaptive variable length coding [AVLC] or context adaptive binary arithmetic coding [CABAC]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/169—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
- H04N19/184—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being bits, e.g. of the compressed video stream
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/70—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by syntax aspects related to video coding, e.g. related to compression standards
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The application discloses a method and a device for entropy coding and entropy decoding, wherein the entropy coding method comprises the following steps: converting two-dimensional data to be coded to be subjected to entropy coding into one-dimensional data to be coded, wherein the one-dimensional data to be coded comprises a plurality of data elements to be coded, and each data element to be coded comprises a sign bit and a numerical value; performing coding prediction processing on the numerical value of each element to be coded to determine coding prediction information of each element to be coded, wherein the coding prediction information comprises a coding prediction value, and the coding prediction value of each element to be coded is less than or equal to the corresponding numerical value; and coding the coding prediction information, and coding the sign bit to generate a corresponding code stream. The embodiment of the application can effectively reduce the data volume of entropy coding, and further improve the coding compression efficiency of the video.
Description
Technical Field
Embodiments of the present disclosure relate to image or video processing technologies, and in particular, to a method and an apparatus for entropy encoding and entropy decoding.
Background
At present, when a video image is transmitted end to end, in order to save bandwidth resources required for transmission, compression coding is usually performed on the transmitted video image.
The basic idea of video compression coding is to reduce the correlation of video data as much as possible, i.e. to remove redundant information, while ensuring the visual effect. So-called video data redundancy information is mainly aimed at spatial, temporal and visual redundancy, and video compression essentially reduces the amount of these redundancies so that the largest information is contained with the smallest symbols. The redundancy of video data can be eliminated by performing coding compression processing such as prediction, transformation, quantization, entropy coding and the like on original data, so as to achieve the purpose of compression.
In recent years, as high-definition and ultra-high-definition video applications gradually come into the visual field of people, the video compression technology is greatly challenged, and higher requirements on the existing video compression technology are provided for improving the encoding quality and the compression rate of monitoring videos.
Disclosure of Invention
The application provides a method and a device for entropy coding and entropy decoding, so as to meet the higher requirement on video compression rate in the existing video compression technology.
In a first aspect, an embodiment of the present application provides an entropy encoding method, where the method includes:
converting two-dimensional data to be coded to be subjected to entropy coding into one-dimensional data to be coded, wherein the one-dimensional data to be coded comprises a plurality of data elements to be coded, and each data element to be coded comprises a sign bit and a numerical value;
Performing coding prediction processing on the numerical value of each element to be coded to determine coding prediction information of each element to be coded, wherein the coding prediction information comprises a coding prediction value, and the coding prediction value of each element to be coded is less than or equal to the corresponding numerical value;
and coding the coding prediction information, and coding the sign bit to generate a corresponding code stream.
In a second aspect, an embodiment of the present application further provides an entropy decoding method, where the method includes:
decoding the code stream to be subjected to entropy decoding to obtain a plurality of numerical values to be decoded, a plurality of prediction labels and a plurality of sign bit information;
according to the prediction labels, decoding and predicting the numerical values to be decoded to determine the decoding prediction values of the numerical values to be decoded;
and converting one-dimensional data consisting of the sign bit information and the decoding predicted value into two-dimensional decoding data.
In a third aspect, an embodiment of the present application further provides an entropy encoding apparatus, where the apparatus includes:
the device comprises a two-dimensional coding data conversion unit, a one-dimensional coding data conversion unit and a coding unit, wherein the two-dimensional coding data to be subjected to entropy coding is converted into one-dimensional coding data to be subjected, the one-dimensional coding data to be subjected comprises a plurality of elements to be coded, and each element to be coded comprises a sign bit and a numerical value;
The encoding prediction unit is used for performing encoding prediction processing on the numerical value of each element to be encoded to determine encoding prediction information of each element to be encoded, wherein the encoding prediction information comprises an encoding prediction value, and the encoding prediction value of each element to be encoded is less than or equal to the corresponding numerical value;
and the coding processing unit is used for coding the coding prediction information and coding the sign bit to generate a corresponding code stream.
In a fourth aspect, an embodiment of the present application further provides an entropy decoding apparatus, where the apparatus includes:
the code stream decoding unit is used for decoding the code stream to be subjected to entropy decoding to obtain a plurality of numerical values to be decoded, a plurality of prediction labels and a plurality of sign bit information;
the decoding prediction unit is used for performing decoding prediction processing on each numerical value to be decoded according to the plurality of prediction labels so as to determine a decoding prediction value of each numerical value to be decoded;
and the one-dimensional data conversion unit is used for converting the one-dimensional data consisting of the sign bit information and the decoding predicted value into two-dimensional decoding data.
In a fifth aspect, the present application further provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the entropy encoding method or the entropy decoding method described above when executing the computer program.
In a sixth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is configured to implement the entropy encoding method or the entropy decoding method described above when executed by a processor.
The application has the following beneficial effects:
in this embodiment, in addition to sign bit encoding, the coding prediction information may be encoded after determining the coding prediction information of each to-be-encoded data element, and since the coding prediction value in the coding prediction information of each to-be-encoded data element is less than or equal to the corresponding value, compared with encoding the value of each to-be-encoded data element, encoding the coding prediction information may effectively reduce the data amount of entropy encoding, thereby improving the coding compression efficiency of the video.
Meanwhile, the entropy decoding adopts a prediction mode reverse to the entropy encoding, so that the encoding and decoding consistency can be ensured, and the encoding compression rate can be further improved.
Drawings
FIG. 1 is a flowchart of an embodiment of an entropy encoding method provided in an embodiment of the present application;
FIG. 2 is a schematic diagram of a hybrid coding framework provided in an embodiment of the present application;
FIG. 3 is a flowchart of another embodiment of an entropy encoding method provided in the second embodiment of the present application;
FIG. 4 is a schematic diagram of a coding prediction process in the second embodiment of the present application;
FIG. 5 is a flowchart of an embodiment of an entropy decoding method provided in the third embodiment of the present application;
fig. 6 is a flowchart of a decoding prediction process according to a third embodiment of the present application;
FIG. 7 is a schematic diagram of a decoding prediction process according to a third embodiment of the present application;
FIG. 8 is a block diagram illustrating an entropy encoding apparatus according to a fourth embodiment of the present disclosure;
fig. 9 is a block diagram of an embodiment of an entropy decoding apparatus according to a fifth embodiment of the present application;
fig. 10 is a schematic structural diagram of a computer device according to a sixth embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting of the application. It should be further noted that, for the convenience of description, only some of the structures related to the present application are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of an embodiment of an entropy encoding method provided in an embodiment of the present application, where entropy encoding is encoding without losing any information according to an entropy principle in an encoding process, and entropy encoding compression is lossless compression, and an implementation principle is to use new encoding to represent input data, so as to achieve an effect of compression. In the video encoding stage, entropy encoding is the last link in video encoding and is also the core link for improving the video compression rate.
The influence of different entropy coding modes on the compression ratio of final video coding is different, and the same preprocessing mode can improve the video compression ratio by more than 10% by using a better entropy coding mode, so that entropy coding always occupies a great weight in the research of video coding algorithms.
An alternative video coding architecture is a hybrid coding framework, and fig. 2 shows a schematic diagram of the hybrid coding framework, which can include at least a rate control module, a transform quantization module, a prediction mode module, a filtering module, an entropy coding module, etc. as shown in fig. 2. An exemplary video encoding flow for the above framework may include the following processes: first, a frame of original video frame (i.e., a frame to be coded) is divided into basic CTU (coding tree unit), and then each CTU unit is operated. And secondly, predicting the prediction mode of each CTU unit through a prediction mode module to find the optimal prediction mode of the CTU. And then, performing difference calculation on the original CTU data and the predicted data, and entering the obtained difference into a transformation quantization module. And performing lossless compression entropy coding operation on the transformed and quantized data by using an entropy coding module to generate a coded code stream. And simultaneously, performing inverse transformation and inverse quantization on the transformed and quantized data, filtering the result in a filtering module, and storing the filtered data as a reference frame of the next frame. The code rate control module is responsible for controlling the quantization degree of the transformation quantization module and does not participate in the specific coding process of the CTU.
The entropy coding method of the embodiment of the present application may be executed by an entropy coding module, and specifically may include the following steps:
In this step, the two-dimensional data to be entropy encoded may be the data received by the entropy encoding module and output by the previous module. For example, in fig. 2, the two-dimensional data to be encoded by entropy encoding may include data output by a transform quantization module.
In one embodiment, for the received two-dimensional data to be encoded, the entropy encoding module may select a current one-dimensional scanning mode according to information provided by a module preceding the entropy encoding module, and scan the two-dimensional data to be encoded into one-dimensional data to be encoded according to the scanning mode.
Illustratively, following the conditions provided by the previous modules, alternative scan patterns may include, but are not limited to: a row scan, a column scan, or a Zig-Zag scan.
It should be noted that, in the specific process of scanning the two-dimensional data to be encoded into the one-dimensional data to be encoded according to the selected scanning mode, reference may be made to a common scanning processing method, which is not described in detail in this embodiment.
As an example of this embodiment, a number of data elements to be encoded may be included in one-dimensional data to be encoded, where each data element to be encoded may include a sign bit and a numerical value. For example, the one-dimensional data to be encoded obtained by scanning a certain frame of video after entering the entropy encoding module may be:
“-3,0,-51,-1,0,-26,-13,-1,3,0,51,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-2,-1,2,-1,1,-1,0,-1,1,0,1,-1,0,-2,-1,1,0,2,-1,1,1,0,-2,-2,-1,1,0,2,-1,-2,-1,-1,2,-1,1,-3,-1,-1,-1,-1,1,0,3,1,0,-1,-1,1,0,1,1,1,1,3,0,51,1,1,1,1,2,1,1,0,1,1,0,2,1,1,0,2,1,2,1,0,3,1,0,1,1,-6,0,-10,-2,0,3,1,-1,0,1,-1,0,-4,1,6,0,10,-1,0,0,0,0,0,0,1,0,0,0,0,0,0”
in the above string of data, for example, "-3", the former "-" is the sign bit, and "3" is the numerical value.
And step 120, performing coding prediction processing on the numerical value of each to-be-coded data element to determine coding prediction information of each to-be-coded data element.
The inventor finds that the one-dimensional data to be coded has predictability in the process of entropy coding operation by adopting an entropy coding module, can predict the following data by using the previous data, and optimizes the part to improve the video coding compression rate based on the finding.
In this step, after obtaining the one-dimensional data to be encoded, the entropy encoding module performs encoding prediction processing according to a preset prediction rule on the numerical value of each data element to be encoded in the one-dimensional data to be encoded, so as to determine encoding prediction information of each data element to be encoded.
As an example, the encoding prediction information of the data element to be encoded may comprise an encoding prediction value and/or a prediction tag. The encoding prediction value can be a value obtained by encoding and predicting a numerical value, and the encoding prediction value is smaller than or equal to the corresponding numerical value; the predictive tag is used as a guide for data recovery during the decoding phase. The above "and/or" means that each element to be encoded has a corresponding encoding prediction value, but not each element to be encoded has a corresponding prediction tag, that is, some elements to be encoded have corresponding prediction tags, and some elements to be encoded do not have corresponding prediction tags.
And step 130, performing coding processing on the coding prediction information, and performing coding processing on the sign bit to generate a corresponding code stream.
In this step, the entropy coding module may perform sign bit coding on the sign bit, and may perform coding processing on the coding prediction information after determining the coding prediction information of each element to be coded, so as to generate a corresponding code stream.
In one embodiment, step 130 may further include the steps of:
carrying out probability coding on the coding prediction value; and encoding the prediction tag.
In this embodiment, probability coding may be performed on a digital string composed of the coding prediction values of each to-be-coded data element, and the recorded digital string composed of each prediction tag and the coded sign bit may be coded at the same time, so as to generate a corresponding code stream.
In this embodiment, in addition to sign bit encoding, encoding prediction information may be encoded after determining encoding prediction information of each to-be-encoded data element, and since an encoding prediction value in the encoding prediction information of each to-be-encoded data element is less than or equal to a corresponding value, compared with encoding the value of each to-be-encoded data element, encoding the encoding prediction information may effectively reduce the data amount of entropy encoding, thereby improving the encoding compression efficiency of a video.
Example two
Fig. 3 is a flowchart of another entropy encoding method embodiment provided in the second embodiment of the present application, where the embodiment specifically describes a process of performing encoding prediction processing on a numerical value of each to-be-encoded data element in step 120 to determine encoding prediction information of each to-be-encoded data element, that is, step 120 further may include the following steps:
step 120-1, determining a first variable value and a second variable value corresponding to the current data element to be encoded.
In this embodiment, two variables, namely a first variable and a second variable, may be preset, and the corresponding first variable value and second variable value may be updated after each determination of the encoding prediction information and used for the next data element to be encoded. For the data element to be encoded currently being processed, the corresponding first variable value is used for representing the encoding prediction value of the previous data element to be encoded, and the second variable value is used for representing the value of the previous non-zero data element to be encoded.
In the initialization phase, the first variable value and the second variable value may be initialized, and in one example, both the first variable value and the second variable value may be initialized to a value of 0. For example, for a first data element to be encoded, both the first variable value and the second variable value are 0.
Step 120-2, determining the encoding prediction value of the to-be-encoded data element according to the first variable value, the second variable value and the current numerical value of the to-be-encoded data element, and determining whether the prediction tag of the to-be-encoded data element needs to be recorded, if yes, determining the prediction tag corresponding to the numerical value of the to-be-encoded data element, and recording the prediction tag.
In this step, the coding prediction value of the data element to be coded may be related to the coding prediction value of the previous data element to be coded (i.e. the first variable value) and/or the value of the previous non-zero data element to be coded (i.e. the second variable value), in addition to the value of the data element to be coded. That is, the coding prediction value of the current data element to be coded may be predicted according to the value of the current data element to be coded, the coding prediction value of the previous data element to be coded, and/or the value of the previous non-zero data element to be coded.
In an embodiment, the step of determining the coding prediction value of the data element to be coded may further include the following steps:
and if the numerical value of the current element to be coded is 0, determining the coding prediction value of the element to be coded as 0.
In this embodiment, if the value of the current element to be encoded is 0, the corresponding encoding prediction value is also 0.
In another embodiment, the step of determining the encoding prediction value of the data element to be encoded further includes the following steps:
if the numerical value of the current data element to be encoded is not 0, judging whether the numerical value of the current data element to be encoded is larger than the second variable value; if so, determining the encoding predicted value of the to-be-encoded data element as the difference value obtained by subtracting the second variable value from the numerical value of the to-be-encoded data element; if not, determining the encoding prediction value of the to-be-encoded data element as the numerical value of the to-be-encoded data element.
In this embodiment, if the value of the current data element to be encoded is not 0, it may be determined whether to compress the value of the current data element to be encoded according to a comparison between the value of the current data element to be encoded and the value of the previous non-zero data element to be encoded (i.e., the second variable value). Specifically, if the value of the current data element to be encoded is greater than the second variable value, the value of the current data element to be encoded is compressed, and the encoding prediction value of the data element to be encoded is determined as the difference value obtained by subtracting the second variable value from the value of the data element to be encoded. If the numerical value of the current data element to be encoded is smaller than the second variable value, the numerical value of the current data element to be encoded is not compressed, and the encoding prediction value of the data element to be encoded is determined as the numerical value of the data element to be encoded.
For example, assuming that the value of the current data element to be encoded is 6, the second variable value is 1, and the value of the current data element to be encoded is greater than the second variable value, the encoding prediction value of the current data element to be encoded is determined as: 6-1-5.
For another example, assuming that the value of the current data element to be encoded is 1, the second variable value is 4, and the value of the current data element to be encoded is smaller than the second variable value, the encoding prediction value of the current data element to be encoded is determined as: 1, i.e. the value of the data element to be encoded is reserved.
In step 120-2, after obtaining the encoding prediction value of the current to-be-encoded data element, it may be determined whether the current to-be-encoded data element needs to record the prediction tag according to the encoding prediction value and the encoding prediction value of the previous to-be-encoded data element and/or the value of the previous non-zero to-be-encoded data element.
As an example, the predictive label may include a first predictive label and a second predictive label. It should be noted that the terms "first" and "second" in the embodiments of the present application are used for distinguishing similar objects and are not necessarily used for describing a specific order or sequence. For example, the first predictive tag may be 0 and the second predictive tag may be 1.
In an embodiment, the step of determining whether the prediction tag of the to-be-encoded data element needs to be recorded, and if yes, determining the prediction tag corresponding to the numerical value of the to-be-encoded data element further includes the following steps:
if the encoding predicted value of the current element to be encoded is 0, judging whether the first variable value is 0; if the first variable value is 0, judging that the prediction label of the data element to be coded is not recorded; if the first variable value is not 0, determining that the prediction label of the data element to be encoded is recorded, and determining the prediction label as a first prediction label.
In this embodiment, in the case that the encoding prediction value of the current to-be-encoded data element is 0, it may be checked whether the first variable value is 0, that is, whether the encoding prediction value of the previous to-be-encoded data element is 0, and if the first variable value is 0, the prediction tag of the to-be-encoded data element is not recorded; if the first variable value is not 0, the prediction tag of the data element to be encoded is recorded and recorded as the first prediction tag, e.g. the prediction tag is recorded as 0.
In another embodiment, the step of determining whether the prediction tag of the to-be-encoded data element needs to be recorded, and if yes, determining the prediction tag corresponding to the numerical value of the to-be-encoded data element further includes the following steps:
If the encoding predicted value of the current element to be encoded is not 0, judging whether the encoding predicted value of the element to be encoded is greater than the second variable value; if yes, judging that the prediction label of the data element to be coded is not recorded; if not, determining to record the prediction tag of the data element to be encoded, and determining the prediction tag as a first prediction tag or a second prediction tag.
In this embodiment, if the encoding prediction value of the current data element to be encoded is not 0, it may be determined whether to record the prediction tag of the data element to be encoded according to the comparison with the value (i.e., the second variable value) of the previous non-zero data element to be encoded. If the encoding predicted value of the to-be-encoded data element is larger than the second variable value, the prediction label of the to-be-encoded data element is not recorded, otherwise, the prediction label of the to-be-encoded data element is recorded as the first prediction label or the second prediction label.
In one embodiment, if the encoding prediction value of the data element to be encoded is smaller than the second variable value, and when the encoding prediction value is equal to the value of the data element to be encoded, the prediction tag of the data element to be encoded is determined as the first prediction tag; and if the encoding predicted value of the to-be-encoded data element is smaller than the second variable value and the encoding predicted value of the to-be-encoded data element is equal to the difference value obtained by subtracting the second variable value from the numerical value of the to-be-encoded data element, determining the prediction tag as a second prediction tag.
For example, assuming that the value of the to-be-encoded data element is 1, the encoding prediction value of the to-be-encoded data element is 1, and the second variable value is 4, the encoding prediction value of the to-be-encoded data element is equal to the value thereof, and is smaller than the second variable value, the prediction tag of the to-be-encoded data element may be determined as the first prediction tag, for example, the prediction tag of the to-be-encoded data element is recorded as 0.
For another example, assuming that the value of the data element to be encoded is 10, the encoding prediction value of the data element to be encoded is 4, and the second variable value is 6, the encoding prediction value of the data element to be encoded is equal to the value minus the second variable value, and the encoding prediction value of the data element to be encoded is smaller than the second variable value, the prediction tag of the data element to be encoded may be determined as the second prediction tag, for example, the prediction tag of the data element to be encoded is recorded as 1.
For another example, assuming that the value of the to-be-encoded data element is 6, the encoding prediction value of the to-be-encoded data element is 5, and the second variable value is 1, the encoding prediction value of the to-be-encoded data element is equal to the value minus the second variable value, but since the encoding prediction value of the to-be-encoded data element is greater than the second variable value, the prediction tag of the to-be-encoded data element is not recorded.
And step 120-3, updating the first variable value to the encoding prediction value of the current to-be-encoded data element.
In this step, after determining the encoding prediction value of the current data element to be encoded, the first variable value may be updated, and the first variable value is updated to the encoding prediction value of the current data element to be encoded.
For example, assuming that the first variable value is 0, the encoding prediction value 4 of the current data element to be encoded may be updated to 4.
And 120-4, determining whether the second variable value is updated or not according to the current numerical value of the data element to be encoded, and updating the second variable value according to the current numerical value of the data element to be encoded when the second variable value is judged to be updated.
In this step, whether the second variable value needs to be updated is related to the value of the current data element to be encoded. Since the second variable value is recorded as a non-zero value, in one embodiment, step 120-4 may further include the steps of:
if the value of the current data element to be coded is 0, judging that the second variable value does not need to be updated; if the value of the current data element to be encoded is not 0, it is determined that the second variable value needs to be updated, and the second variable value is updated to the value of the current data element to be encoded.
For example, if the value of the current data element to be encoded is 0, the second variable value is kept unchanged. If the value of the current data element to be encoded is 6 and the second variable value is 1, the second variable value may be updated to 6.
In order to more clearly explain the process of the encoding prediction processing in the present embodiment, the following is explained by using the encoding prediction processing schematic diagram of fig. 4 and a specific example:
the process of FIG. 4 is described as follows:
initialize the first variable value and the second variable value to 0.
Determine whether the value of the current data element to be encoded is 0.
If the value of the current data element to be encoded is 0, a non-predicted branch is entered, which is followed by: and keeping the current data 0, namely determining the encoding prediction value of the data element to be encoded as 0. It is then determined whether the first variable value is 0. If the first variable value is 0, the prediction tag of the data element to be encoded is not recorded. If the first variable value is not 0, the prediction tag of the data element to be encoded is recorded as 0.
If the value of the current data element to be encoded is not 0, the prediction branch is entered. First, it is determined whether the first variable value is 0. And if the first variable value is not 0, judging the magnitude of the value of the current data element to be encoded and the magnitude of the second variable value. And if the current value is larger than the second variable value, determining the encoding predicted value of the data element to be encoded as the difference value of the current value and the second variable value. Otherwise, the coding prediction value of the data element to be coded is determined as the current value. If the first variable value is 0, the magnitude of the current value of the data element to be encoded and the magnitude of the second variable value also need to be judged, and if the current value is greater than the second variable value, the encoding predicted value of the data element to be encoded is determined as the difference value of the current value and the second variable value. Otherwise, the coding prediction value of the data element to be coded is determined as the current value.
And comparing the encoding predicted value of the current data element to be encoded with the magnitude of the second variable value, and recording the prediction tag if the encoding predicted value of the current data element to be encoded is smaller than the second variable value. Otherwise, no prediction tag is recorded.
For example, assuming that the one-dimensional data to be encoded is "0, 4,1,6,0, 10", the first variable value and the second variable value are initialized to be 0, and according to the flow of fig. 4, the encoding prediction processing performed for each data element to be encoded is as follows:
and reading a data element '0', namely, the value of the current data element to be coded is 0, and entering an unpredicted branch. Because the first variable value is initialized to 0, the encoding prediction value of the current to-be-encoded data element is 0, and the prediction tag is not recorded.
Data element "4" is read and the prediction branch is entered. The first variable value is 0, the current value 4 and the second variable value are judged, because the second variable value is 0, the coding predicted value of the current element to be coded is 4-0-4, and the coding predicted value 4 is larger than the second variable value 0, so that the prediction label is not recorded. At the same time, the second variable value is updated to 4 and the first variable value is updated to 4.
The data element "1" is read. The current value is 1 and the predicted branch is entered. The first variable value is 4, the second variable value is 4, and the current value 1 is smaller than the second variable value 4, so that the encoding prediction value of the current to-be-encoded data element is the current value 1. Meanwhile, since the current encoding prediction value 1 is smaller than the second variable value 4, the recording prediction tag is 0. The second variable value is updated to be 1 and the first variable value is 1.
Data element "6" is read and the prediction branch is entered. The first variable value is 1, the second variable value is 1, and the current value 6 is greater than the second variable value 1, so that the encoding prediction value of the current to-be-encoded data element is 6-1-5. Meanwhile, since the encoding prediction value 5 is greater than the second variable value 1, the prediction tag is not recorded. The second variable value is updated to 6 and the first variable value is 5.
The data element "0" is read and the non-predicted branch is entered. The first variable value is 5 and not 0. The encoding prediction value of the current to-be-encoded data element is 0, and the recording prediction tag is 0. The first variable value is updated to 0 and the second variable value is still 6.
Data element "10" is read and the prediction branch is entered. The first variable value is 0, the second variable value is 6, and the current value 10 is greater than the second variable value 6, so that the encoding prediction value of the current to-be-encoded data element is 10-6-4. Since the encoding prediction value 4 is smaller than the second variable value 6, the prediction tag is recorded as 1.
Through the above process, the number string composed of the encoding prediction values obtained by encoding and predicting the one-dimensional data to be encoded is "0, 4, 1, 5, 0, 4", and the number string composed of the prediction tags is "0, 0, 1".
In this embodiment, in the process of determining the coding prediction information of each to-be-coded data element, factors such as a numerical value of a current to-be-coded data element, a coding prediction value of a previous to-be-coded data element, and a numerical value of a previous non-zero to-be-coded data element are comprehensively considered, so that the determined coding prediction value is less than or equal to the current numerical value, and the data amount of entropy coding can be reduced. In addition, because not every element of data to be coded records the prediction tag, the data amount of entropy coding is further reduced, and the coding compression rate of entropy coding is improved.
EXAMPLE III
Fig. 5 is a flowchart of an embodiment of an entropy decoding method provided in the third embodiment of the present application, where entropy decoding is used as a first step of a video decoding process, and is used to parse a code stream to obtain a syntax element for use in reconstructing an image in a subsequent step.
If a compressed and encoded stream is to be decoded back into the original image data, the encoding process needs to be reversed. An alternative decoding process may include the steps of: when the coded stream data is received, Entropy Decoding (Entropy Decoding) is performed, and then Inverse coefficient Prediction (Inverse Prediction) and Inverse quantization (Inverse quantization) are performed, followed by Inverse Lapped Transform (Inverse Lapped Transform), and then Inverse Color Space Transform (Inverse Color Space) is performed. Taking the JPEG standard as an example, the encoded stream is first subjected to Variable Length Decoding (Variable Length Decoding), then the DC term coefficient is subjected to Inverse coefficient prediction, Inverse quantization, Inverse Discrete cosine transform (Inverse Discrete cosine transform), and finally the color space is converted from YCbCr to the desired color space to complete the Decoding of the image.
The entropy decoding method of the embodiment of the application may be executed by the entropy decoding module, and specifically may include the following steps:
and 510, decoding the code stream to be subjected to entropy decoding to obtain a plurality of values to be decoded, a plurality of prediction labels and a plurality of sign bit information.
In this embodiment, after the entropy decoding module reads in the code stream output by the entropy encoding module, entropy decoding is performed on the code stream to obtain entropy decoding data for use by subsequent modules. As an example, entropy decoded data may include, but is not limited to: a plurality of values to be decoded, a plurality of prediction labels and a plurality of sign bit information.
In one embodiment, step 510 may further include the steps of:
and respectively carrying out probability decoding, label decoding and sign bit decoding on the code stream to be subjected to entropy decoding to obtain a plurality of corresponding numerical values to be decoded, a plurality of prediction labels and a plurality of sign bit information.
In this embodiment, a series of one-dimensional values to be decoded can be obtained by performing probability decoding on the code stream.
One or more prediction tags may be obtained by tag decoding the code stream, and the prediction tags may include, for example, a first prediction tag and a second prediction tag, for example, the first prediction tag may be 0 and the second prediction tag may be 1.
One or more sign bit information may be obtained by sign bit decoding the code stream.
And step 520, performing decoding prediction processing on each value to be decoded according to the plurality of prediction labels to determine a decoding prediction value of each value to be decoded.
In this step, after obtaining the prediction tag and the value to be decoded, the entropy decoding module may perform decoding prediction processing according to a prediction rule reverse to the prediction rule in encoding, so as to determine a decoding prediction value of each value to be decoded.
In one embodiment, referring to FIG. 6, step 520 may further include the steps of:
step 520-1, determining a third variable value and a fourth variable value corresponding to the current value to be decoded.
In the entropy decoding stage, two variables, namely a third variable and a fourth variable, may also be set in advance, and the corresponding third variable value and fourth variable value may be updated after the decoding prediction value is determined each time and used for the next value to be decoded. For the value to be decoded currently being processed, the corresponding third variable value is used for representing the decoding prediction value corresponding to the previous value to be decoded, and the fourth variable value is used for representing the previous non-zero decoding prediction value.
During the initialization phase, the third variable value and the fourth variable value, both of which may be initialized to a value of 0 in one example, may be initialized. For example, for the first value to be decoded, the third variable value and the fourth variable value are both 0.
And 520-2, judging whether the current value to be decoded has a corresponding prediction tag according to the third variable value, the fourth variable value and the current value to be decoded, and determining a decoding prediction value corresponding to the current value to be decoded according to the judgment result.
In this step, the decoding prediction value corresponding to the value to be decoded may be related to the decoding prediction value (i.e. the third variable value) of the previous value to be decoded and/or the decoding prediction value (i.e. the fourth variable value) of the previous non-zero value in addition to the value to be decoded. That is, the current decoded prediction value may be predicted from the current value to be decoded and the previous decoded prediction value.
In one embodiment, if the current value to be decoded is 0, step 520-2 may further include the following steps:
judging whether the third variable value is 0 or not; if the third variable value is 0, judging that the current value to be decoded does not have a corresponding prediction tag, and determining a decoding prediction value corresponding to the current value to be decoded as 0; if the third variable value is not 0, determining that the current value to be decoded has a corresponding prediction tag, reading the prediction tag, and if the prediction tag is the first prediction tag, determining the decoding prediction value corresponding to the current value to be decoded as 0; and if the prediction tag is the second prediction tag, determining a decoding prediction value corresponding to the current numerical value to be decoded as the fourth variable value.
In this embodiment, if the current value to be decoded is 0, the decoding prediction value (i.e. the third variable value) corresponding to the previous value to be decoded may be used as a reference to determine whether the third variable value is 0; and if the third variable value is 0, judging that the current value to be decoded does not have a corresponding prediction tag, and determining the decoding prediction value corresponding to the current value to be decoded as 0. Otherwise, if the third variable value is not 0, determining that the current value to be decoded has a corresponding prediction tag, and reading the prediction tag. If the prediction label is a first prediction label, for example, 0, determining a decoding prediction value corresponding to the current numerical value to be decoded as 0; and if the prediction tag is the second prediction tag, for example, 1, determining the decoding prediction value corresponding to the current value to be decoded as the fourth variable value.
For example, if the current value to be decoded is 0 and the decoding prediction value corresponding to the previous value to be decoded is also 0, it is determined that the current value to be decoded 0 does not have a corresponding prediction tag, and the decoding prediction value corresponding to the current value to be decoded is determined to be 0.
For another example, if the current value to be decoded is 0, the decoding prediction value corresponding to the previous value to be decoded is 6, and the previous non-zero decoding prediction value is 6, it is determined that the current value to be decoded 0 has a corresponding prediction tag and reads the prediction tag, and if the read prediction tag is 0, the decoding prediction value corresponding to the current value to be decoded is determined to be 0; and if the read prediction tag is 1, determining a decoding prediction value corresponding to the current numerical value to be decoded as 6.
In another embodiment, if the current value to be decoded is not 0, step 520-2 may further include the steps of:
judging whether the current value to be decoded is larger than the fourth variable value; if so, judging that the current value to be decoded does not have a corresponding prediction tag, and determining a decoding prediction value corresponding to the current value to be decoded as the sum of the value to be decoded and the fourth variable value; if not, judging that the current value to be decoded has a corresponding prediction tag, reading the prediction tag, and if the prediction tag is a second prediction tag, determining a decoding prediction value corresponding to the current value to be decoded as the sum of the value to be decoded and the fourth variable value; and if the prediction tag is the first prediction tag, determining a decoding prediction value corresponding to the current numerical value to be decoded as the numerical value to be decoded.
In this embodiment, if the current value to be decoded is not 0, the previous non-zero decoding prediction value (i.e. the fourth variable value) may be used as a reference to determine whether the current value to be decoded is greater than the fourth variable value; and if the current value to be decoded is larger than the fourth variable value, judging that the current value to be decoded does not have a corresponding prediction tag, and determining the decoding prediction value corresponding to the current value to be decoded as the sum of the value to be decoded and the fourth variable value. Otherwise, if the current value to be decoded is smaller than or equal to the fourth variable value, the current value to be decoded is determined to have a corresponding prediction tag, and the prediction tag is read. If the prediction tag is a first prediction tag, for example, 0, determining a decoding prediction value corresponding to the current value to be decoded as the value to be decoded; if the prediction tag is the second prediction tag, for example, 1, the decoding prediction value corresponding to the current value to be decoded is determined as the sum of the value to be decoded and the fourth variable value.
For example, if the current value to be decoded is 4 and the previous non-zero decoded prediction value is 1, 4>1, the current value to be decoded has no corresponding prediction tag, and the decoded prediction value corresponding to the current value to be decoded is determined to be 4+1 ═ 5.
For another example, if the current value to be decoded is 1, the previous non-zero decoding prediction value is 4, and 1<4, the current value to be decoded has a corresponding prediction tag and reads the prediction tag, and if the read prediction tag is 0, the decoding prediction value corresponding to the current value to be decoded is determined to be 1; if the read prediction tag is 1, determining that the decoding prediction value corresponding to the current value to be decoded is 4+ 1-5.
And step 520-3, updating the third variable value to a decoding predicted value corresponding to the current numerical value to be decoded.
In this step, after the decoding predicted value corresponding to the current value to be decoded is determined, the third variable value may be updated, and the third variable value is updated to the decoding predicted value corresponding to the current value to be decoded.
For example, assuming that the third variable value is 0 and the decoding prediction value corresponding to the current value to be decoded is 4, the third variable value may be updated to 4.
And step 520-4, determining whether the fourth variable value is updated according to the current value to be decoded, and updating the fourth variable value according to the decoding predicted value corresponding to the current value to be decoded when the fourth variable value is judged to need to be updated.
In this step, whether the fourth variable value needs to be updated or not needs to comprehensively consider the current value to be decoded and the decoding prediction value corresponding to the current value to be decoded.
In one embodiment, step 520-4 may further include the steps of:
and if the current value to be decoded is 0 and the decoding predicted value corresponding to the current value to be decoded is 0, judging that the fourth variable value is not updated.
And if the current value to be decoded is 0 but the decoding prediction value corresponding to the current value to be decoded is not 0, or the current value to be decoded is not 0, determining to update the fourth variable value, and updating the fourth variable value to the decoding prediction value corresponding to the current value to be decoded.
In order to more clearly explain the process of the decoding prediction processing in the present embodiment, the following is explained by using a decoding prediction processing schematic diagram of fig. 7 and a specific example:
The decoding prediction process of fig. 7 is described as follows:
initialize the third variable value and the fourth variable value to 0.
Determine whether the current value to be decoded is 0.
If the current value to be decoded is 0, the third variable value is judged. And if the third variable value is also 0, judging that the current value to be decoded has no prediction label, and determining the decoding prediction value corresponding to the current value to be decoded as 0. If the third variable value is not 0, it is determined that the current value to be decoded has a prediction tag and the prediction tag is read. If the prediction tag is 1, determining that the current value to be decoded is obtained according to prediction, determining the decoding prediction value corresponding to the current value to be decoded as a fourth variable value, and updating the fourth variable value to the decoding prediction value corresponding to the current value to be decoded; and if the prediction tag is 0, judging that the current numerical value to be decoded is not obtained according to prediction, and determining the decoding prediction value corresponding to the current numerical value to be decoded as 0.
If the current value to be decoded is not 0, the current value to be decoded and the previous non-zero data (i.e. the fourth variable value) are judged. And if the current value to be decoded is smaller than the fourth variable value, judging that the current value to be decoded has the prediction tag and reading the prediction tag. If the prediction tag is 1, determining that the current value to be decoded is obtained according to the prediction, and determining the decoding prediction value corresponding to the current value to be decoded as the sum of the current value to be decoded and the fourth variable value; and if the prediction tag is 0, judging that the current numerical value to be decoded is not obtained according to prediction, and determining the decoding prediction value corresponding to the current numerical value to be decoded as the current numerical value to be decoded. And if the current value to be decoded is larger than the fourth variable value, judging that the current value to be decoded does not have the prediction tag, and determining the decoding predicted value corresponding to the current value to be decoded as the sum of the current value to be decoded and the fourth variable value. And then updating the fourth variable value into a decoding predicted value corresponding to the current value to be decoded.
For example, assuming that a plurality of values to be decoded are "0, 4, 1, 5, 0, 4", a plurality of prediction tags are "0, 0, 1", respectively, the value of the third variable and the value of the fourth variable are initialized to 0, and according to the flow of fig. 7, the decoding prediction process performed for each value to be decoded is as follows:
reading the value to be decoded "0", namely, the current value to be decoded is 0, and because the third variable value and the fourth variable value are both 0, the prediction tag is not read, and the decoding prediction value corresponding to the current value to be decoded is determined to be 0.
Reading the value to be decoded "4", and determining the decoding prediction value corresponding to the current value to be decoded as 4+0 to 4 without reading the prediction tag since the fourth variable values are all 0, 4> 0. The third variable value and the fourth variable value are updated to 4 simultaneously.
And reading a value to be decoded of '1', wherein the third variable value and the fourth variable value are both 4, and 1<4, so that the prediction tag is read, the read prediction tag is 0, and the decoding prediction value corresponding to the current value to be decoded is determined as the current value to be decoded of 1. The third variable value and the fourth variable value are updated to 1 simultaneously.
Reading the value to be decoded "5", wherein the third variable value and the fourth variable value are both 1, 5>1, so that the prediction tag is not read, and the decoding prediction value corresponding to the current value to be decoded is determined to be 5+ 1-6. The third variable value and the fourth variable value are updated to 6 simultaneously.
And reading the value to be decoded of '0', wherein the third variable value is 6 and is not 0, so that the prediction label is read, the read prediction label is 0, and the decoding prediction value corresponding to the current value to be decoded is determined as the current value to be decoded of 0. Simultaneously updating the third variable value to 0; the value of the fourth variable remains constant and is still 6.
The value "4" to be decoded is read, and since the third variable value is 0, the fourth variable value is 6. And if 4<6, reading the prediction tag, and if the read prediction tag is 1, determining the decoding prediction value corresponding to the current value to be decoded as 4+ 6-10. The third variable value and the fourth variable value are updated to 10 simultaneously.
Through the above process, the numerical string composed of the decoding predicted values obtained by decoding and predicting the numerical values to be decoded is "0, 4, 1, 6, 0, 10".
In this step, after the decoding prediction process of step 520 obtains the decoding prediction value corresponding to each value to be decoded, each decoding prediction value and each sign bit information may be combined to obtain a string of one-dimensional digital strings with sign bits. The one-dimensional digital string is then subjected to inverse one-dimensional scanning to generate two-dimensional decoded data. The two-dimensional decoded data may be provided to subsequent modules for continued decoding to reconstruct the image.
In this embodiment, the entropy decoding adopts a prediction mode reverse to the entropy encoding, so that the encoding compression rate can be further improved while the encoding and decoding consistency is ensured.
Example four
Fig. 8 is a block diagram of an embodiment of an entropy encoding apparatus according to a fourth embodiment of the present application, where the apparatus may include:
the two-dimensional encoding data converting unit 810 is configured to convert two-dimensional to-be-encoded data to be subjected to entropy encoding into one-dimensional to-be-encoded data, where the one-dimensional to-be-encoded data includes a plurality of to-be-encoded data elements, and each to-be-encoded data element includes a sign bit and a numerical value.
And an encoding prediction unit 820, configured to perform encoding prediction processing on the numerical value of each to-be-encoded data element to determine encoding prediction information of each to-be-encoded data element, where the encoding prediction information includes an encoding prediction value, and the encoding prediction value of each to-be-encoded data element is less than or equal to a corresponding numerical value.
And an encoding processing unit 830, configured to perform encoding processing on the encoded prediction information and encode the sign bit to generate a corresponding code stream.
In one possible embodiment of the present application, the encoded prediction information further includes a prediction tag; the coding prediction unit 820 may include the following sub-units:
The variable value determining subunit is used for determining a first variable value and a second variable value corresponding to the current element to be encoded, wherein the first variable value is used for representing an encoding prediction value of the previous element to be encoded, and the second variable value is used for representing a value of the previous non-zero element to be encoded;
the encoding prediction value and prediction tag determining subunit is configured to determine, according to the first variable value, the second variable value, and a current value of the to-be-encoded data element, an encoding prediction value of the to-be-encoded data element, and determine whether a prediction tag of the to-be-encoded data element needs to be recorded, and if yes, determine a prediction tag corresponding to the value of the to-be-encoded data element, and record the prediction tag;
the variable value updating subunit is used for updating the first variable value into an encoding prediction value of the current to-be-encoded data element; and determining whether the second variable value is updated or not according to the value of the current data element to be encoded, and updating the second variable value according to the value of the current data element to be encoded when the second variable value is judged to be updated.
In a possible embodiment of the embodiments of the present application, the encoding prediction value and prediction tag determination subunit is further configured to:
if the numerical value of the current element to be coded is 0, determining the coding prediction value of the element to be coded as 0;
if the numerical value of the current data element to be encoded is not 0, judging whether the numerical value of the current data element to be encoded is larger than the second variable value; if so, determining the encoding predicted value of the to-be-encoded data element as the difference value of the numerical value of the to-be-encoded data element minus the second variable value; if not, determining the encoding prediction value of the to-be-encoded data element as the numerical value of the to-be-encoded data element.
In one possible embodiment of the embodiments of the present application, the prediction labels comprise a first prediction label and a second prediction label; the coding prediction value and prediction tag determination subunit is further configured to:
if the encoding predicted value of the current to-be-encoded data element is 0, judging whether the first variable value is 0; if the first variable value is 0, judging that the prediction label of the data element to be coded is not recorded; if the first variable value is not 0, determining to record the prediction tag of the data element to be encoded, and determining the prediction tag as a first prediction tag;
If the encoding predicted value of the current element to be encoded is not 0, judging whether the encoding predicted value of the element to be encoded is greater than the second variable value; if yes, judging that the prediction label of the data element to be coded is not recorded; if not, determining to record the prediction tag of the data element to be encoded, and determining the prediction tag as a first prediction tag or a second prediction tag.
In a possible embodiment of the embodiments of the present application, the encoding prediction value and prediction tag determination subunit is further configured to:
when the encoding predicted value of the to-be-encoded data element is the numerical value of the to-be-encoded data element, determining the prediction tag as a first prediction tag;
and when the encoding predicted value of the to-be-encoded data element is the difference value obtained by subtracting the second variable value from the numerical value of the to-be-encoded data element, determining the prediction tag as a second prediction tag.
In one possible embodiment of the present application, the variable value updating subunit is further configured to:
if the value of the current data element to be coded is 0, judging that the second variable value does not need to be updated;
and if the numerical value of the current data element to be encoded is not 0, judging that the second variable value needs to be updated, and updating the second variable value into the numerical value of the current data element to be encoded.
In a possible embodiment of the present application, the encoding processing unit 830 is further configured to:
carrying out probability coding on the coding prediction value;
and encoding the prediction tag.
It should be noted that the entropy coding apparatus provided in the embodiments of the present application can execute the entropy coding method provided in any embodiment of the present application, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE five
Fig. 9 is a block diagram of an embodiment of an entropy decoding apparatus according to a fifth embodiment of the present application, where the apparatus may include:
the code stream decoding unit 910 is configured to decode a code stream to be entropy decoded, to obtain a plurality of values to be decoded, a plurality of prediction tags, and a plurality of sign bit information.
And a decoding prediction unit 920, configured to perform decoding prediction processing on each to-be-decoded value according to the plurality of prediction tags, so as to determine a decoding prediction value of each to-be-decoded value.
A one-dimensional data conversion unit 930 configured to convert one-dimensional data composed of the sign bit information and the decoding prediction value into two-dimensional decoded data.
In one possible embodiment of the present application, the decoding prediction unit 920 further includes the following sub-units:
And the variable value determining subunit is used for determining a third variable value and a fourth variable value corresponding to the current value to be decoded, wherein the third variable value is used for representing a decoding predicted value corresponding to the previous value to be decoded, and the fourth variable value is used for representing a previous non-zero decoding predicted value.
And the prediction tag and decoding prediction value determining subunit is used for judging whether the current value to be decoded has a corresponding prediction tag or not according to the third variable value, the fourth variable value and the current value to be decoded, and determining the decoding prediction value corresponding to the current value to be decoded according to the judgment result.
The variable value updating subunit is used for updating the third variable value into a decoding predicted value corresponding to the current value to be decoded; and determining whether the fourth variable value is updated or not according to the current value to be decoded, and updating the fourth variable value according to the decoding predicted value corresponding to the current value to be decoded when the fourth variable value is judged to be updated.
In a possible embodiment of the present application, if the current value to be decoded is 0, the prediction tag and decoding prediction value determining subunit is further configured to:
Judging whether the third variable value is 0 or not;
if the third variable value is 0, judging that the current value to be decoded does not have a corresponding prediction tag, and determining a decoding prediction value corresponding to the current value to be decoded as 0;
if the third variable value is not 0, determining that the current value to be decoded has a corresponding prediction tag, reading the prediction tag, and if the prediction tag is the first prediction tag, determining the decoding prediction value corresponding to the current value to be decoded as 0; and if the prediction tag is the second prediction tag, determining a decoding prediction value corresponding to the current numerical value to be decoded as the fourth variable value.
In a possible embodiment of the present application, if the current value to be decoded is not 0, the prediction tag and decoded prediction value determining subunit is further configured to:
judging whether the current value to be decoded is larger than the fourth variable value;
if so, judging that the current value to be decoded does not have a corresponding prediction tag, and determining a decoding prediction value corresponding to the current value to be decoded as the sum of the value to be decoded and the fourth variable value;
if not, judging that the current value to be decoded has a corresponding prediction tag, reading the prediction tag, and if the prediction tag is a second prediction tag, determining a decoding prediction value corresponding to the current value to be decoded as the sum of the value to be decoded and the fourth variable value; and if the prediction tag is the first prediction tag, determining a decoding prediction value corresponding to the current numerical value to be decoded as the numerical value to be decoded.
In one possible embodiment of the present application, the variable value updating subunit is further configured to:
if the current value to be decoded is 0 and the decoding predicted value corresponding to the current value to be decoded is 0, determining not to update the fourth variable value;
and if the current value to be decoded is 0 but the decoding predicted value corresponding to the current value to be decoded is not 0, or the current value to be decoded is not 0, determining to update the fourth variable value, and updating the fourth variable value to the decoding predicted value corresponding to the current value to be decoded.
In a possible embodiment of the present application, the code stream decoding unit 910 is further configured to:
and respectively carrying out probability decoding, label decoding and sign bit decoding on the code stream to be subjected to entropy decoding to obtain a plurality of corresponding numerical values to be decoded, a plurality of prediction labels and a plurality of sign bit information.
It should be noted that the entropy decoding apparatus provided in the embodiments of the present application can execute the entropy decoding method provided in any embodiment of the present application, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE six
Fig. 10 is a schematic structural diagram of a computer apparatus according to a sixth embodiment of the present application, as shown in fig. 10, the computer apparatus includes a processor 100, a memory 101, an input device 102, and an output device 103; the number of processors 100 in the computer device may be one or more, and one processor 100 is taken as an example in fig. 10; the processor 100, the memory 101, the input device 102 and the output device 103 in the computer apparatus may be connected by a bus or other means, and the connection by the bus is exemplified in fig. 10.
The memory 101 is used as a computer-readable storage medium for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the entropy encoding method or the entropy decoding method in the embodiments of the present application. The processor 100 executes various functional applications of the computer device and data processing by executing software programs, instructions and modules stored in the memory 101, that is, implements the above-described method.
The memory 101 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, memory 101 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, memory 101 may further include memory located remotely from processor 100, which may be connected to a computer device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 102 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function controls of the computer device. The output device 103 may include a display device such as a display screen.
EXAMPLE seven
An embodiment seventh of the present application further provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform the method of any one of the first to third embodiments.
From the above description of the embodiments, it is obvious for those skilled in the art that the present application can be implemented by software and necessary general hardware, and certainly can be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present application or portions thereof contributing to the prior art may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods described in the embodiments of the present application.
It should be noted that, in the embodiment of the search apparatus, each included unit and each included module are merely divided according to functional logic, but are not limited to the above division, as long as corresponding functions can be implemented; in addition, specific names of the functional units are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the present application.
It is to be noted that the foregoing is only illustrative of the presently preferred embodiments and application of the principles of the present invention. It will be understood by those skilled in the art that the present application is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the application. Therefore, although the present application has been described in more detail with reference to the above embodiments, the present application is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims (17)
1. An entropy encoding method, characterized in that the method comprises:
converting two-dimensional data to be coded to be subjected to entropy coding into one-dimensional data to be coded, wherein the one-dimensional data to be coded comprises a plurality of data elements to be coded, and each data element to be coded comprises a sign bit and a numerical value;
Performing coding prediction processing on the numerical value of each element to be coded to determine coding prediction information of each element to be coded, wherein the coding prediction information comprises a coding prediction value, and the coding prediction value of each element to be coded is less than or equal to the corresponding numerical value;
coding the coding prediction information, and coding the sign bit to generate a corresponding code stream;
the encoding prediction processing of the numerical value of each to-be-encoded data element to determine the encoding prediction information of each to-be-encoded data element includes:
determining a first variable value and a second variable value corresponding to a current data element to be encoded, wherein the first variable value is used for representing an encoding predicted value of a previous data element to be encoded, and the second variable value is used for representing a value of a previous non-zero data element to be encoded;
and determining the encoding prediction value of the data element to be encoded according to the first variable value, the second variable value and the value of the current data element to be encoded.
2. An entropy coding method according to claim 1, wherein the coding prediction information further includes a prediction tag;
The encoding prediction processing of the numerical value of each to-be-encoded data element to determine the encoding prediction information of each to-be-encoded data element further includes:
determining whether the prediction label of the data element to be coded needs to be recorded, if so, determining the prediction label corresponding to the numerical value of the data element to be coded, and recording the prediction label;
updating the first variable value into a coding prediction value of the current to-be-coded data element;
and determining whether the second variable value is updated or not according to the value of the current data element to be encoded, and updating the second variable value according to the value of the current data element to be encoded when the second variable value is judged to be updated.
3. An entropy coding method according to claim 2, wherein the determining of the coding prediction value of the data element to be coded comprises:
if the numerical value of the current element to be coded is 0, determining the coding prediction value of the element to be coded as 0;
if the numerical value of the current data element to be encoded is not 0, judging whether the numerical value of the current data element to be encoded is larger than the second variable value; if so, determining the encoding predicted value of the to-be-encoded data element as the difference value of the numerical value of the to-be-encoded data element minus the second variable value; if not, determining the encoding prediction value of the to-be-encoded data element as the numerical value of the to-be-encoded data element.
4. An entropy encoding method according to claim 3, wherein the prediction labels include a first prediction label and a second prediction label;
the determining whether the prediction tag of the data element to be encoded needs to be recorded, and if so, determining the prediction tag corresponding to the numerical value of the data element to be encoded, including:
if the encoding predicted value of the current to-be-encoded data element is 0, judging whether the first variable value is 0; if the first variable value is 0, determining that the prediction label of the data element to be coded is not recorded; if the first variable value is not 0, determining to record the prediction tag of the data element to be encoded, and determining the prediction tag as a first prediction tag;
if the encoding predicted value of the current to-be-encoded data element is not 0, judging whether the encoding predicted value of the to-be-encoded data element is greater than the second variable value; if so, judging that the prediction label of the data element to be coded is not recorded; if not, determining to record the prediction tag of the data element to be encoded, and determining the prediction tag as a first prediction tag or a second prediction tag.
5. The entropy encoding method of claim 4, wherein determining the prediction tag as the first prediction tag or the second prediction tag comprises:
When the encoding predicted value of the to-be-encoded data element is the numerical value of the to-be-encoded data element, determining the prediction tag as a first prediction tag;
and when the encoding predicted value of the to-be-encoded data element is the difference value obtained by subtracting the second variable value from the numerical value of the to-be-encoded data element, determining the prediction tag as a second prediction tag.
6. An entropy coding method according to any one of claims 2 to 5, wherein the determining whether the second variable value is updated according to the value of the current data element to be coded, and updating the second variable value according to the value of the current data element to be coded when it is determined that the second variable value needs to be updated, includes:
if the value of the current data element to be coded is 0, judging that the second variable value does not need to be updated;
and if the numerical value of the current data element to be encoded is not 0, judging that the second variable value needs to be updated, and updating the second variable value into the numerical value of the current data element to be encoded.
7. An entropy coding method according to any one of claims 2 to 5, wherein the encoding process of the coding prediction information includes:
Carrying out probability coding on the coding prediction value;
and encoding the prediction tag.
8. An entropy decoding method, characterized in that the method comprises:
decoding the code stream to be subjected to entropy decoding to obtain a plurality of numerical values to be decoded, a plurality of prediction labels and a plurality of sign bit information;
according to the prediction labels, decoding and predicting the numerical values to be decoded to determine the decoding prediction values of the numerical values to be decoded;
converting one-dimensional data consisting of the sign bit information and the decoding predicted value into two-dimensional decoding data;
the decoding and predicting processing is performed on each numerical value to be decoded according to the plurality of prediction labels to determine a decoding prediction value of each numerical value to be decoded, and the decoding prediction method comprises the following steps:
determining a third variable value and a fourth variable value corresponding to the current value to be decoded, wherein the third variable value is used for representing a decoding predicted value corresponding to the previous value to be decoded, and the fourth variable value is used for representing a previous non-zero decoding predicted value;
and judging whether the current value to be decoded has a corresponding prediction tag or not according to the third variable value, the fourth variable value and the current value to be decoded, and determining a decoding prediction value corresponding to the current value to be decoded according to the judgment result.
9. An entropy decoding method as claimed in claim 8, wherein the performing, according to the prediction tags, decoding prediction processing on the values to be decoded to determine the decoding prediction value of each value to be decoded further includes:
updating the third variable value to a decoding predicted value corresponding to the current value to be decoded;
and determining whether the fourth variable value is updated or not according to the current value to be decoded, and updating the fourth variable value according to the decoding predicted value corresponding to the current value to be decoded when the fourth variable value is judged to be updated.
10. An entropy decoding method as claimed in claim 9, wherein if the current value to be decoded is 0, the determining whether the current value to be decoded has a corresponding prediction tag according to the third variable value, the fourth variable value and the current value to be decoded, and determining the decoding prediction value corresponding to the current value to be decoded according to the result of the determining includes:
judging whether the third variable value is 0 or not;
if the third variable value is 0, judging that the current value to be decoded does not have a corresponding prediction tag, and determining a decoding prediction value corresponding to the current value to be decoded as 0;
If the third variable value is not 0, determining that the current value to be decoded has a corresponding prediction tag, reading the prediction tag, and if the prediction tag is the first prediction tag, determining a decoding prediction value corresponding to the current value to be decoded as 0; and if the prediction label is a second prediction label, determining a decoding prediction value corresponding to the current numerical value to be decoded as the fourth variable value.
11. An entropy decoding method as claimed in claim 9, wherein if the current value to be decoded is not 0, the determining whether the current value to be decoded has a corresponding prediction tag according to the third variable value, the fourth variable value and the current value to be decoded, and determining a decoding prediction value corresponding to the current value to be decoded according to a result of the determining includes:
judging whether the current value to be decoded is larger than the fourth variable value;
if so, judging that the current numerical value to be decoded does not have a corresponding prediction label, and determining a decoding prediction value corresponding to the current numerical value to be decoded as the sum of the numerical value to be decoded and the fourth variable value;
if not, judging that the current value to be decoded has a corresponding prediction label, reading the prediction label, and if the prediction label is a second prediction label, determining the decoding prediction value corresponding to the current value to be decoded as the sum of the value to be decoded and the fourth variable value; and if the prediction label is the first prediction label, determining a decoding prediction value corresponding to the current numerical value to be decoded as the numerical value to be decoded.
12. An entropy decoding method according to claim 10 or 11, wherein the determining whether the fourth variable value is updated according to the current value to be decoded, and updating the fourth variable value according to the decoding predicted value corresponding to the current value to be decoded when it is determined that the fourth variable value needs to be updated, comprises:
if the current value to be decoded is 0 and the decoding predicted value corresponding to the current value to be decoded is 0, judging that the fourth variable value is not updated;
and if the current value to be decoded is 0 but the decoding prediction value corresponding to the current value to be decoded is not 0, or the current value to be decoded is not 0, determining to update the fourth variable value, and updating the fourth variable value to the decoding prediction value corresponding to the current value to be decoded.
13. An entropy decoding method according to any one of claims 8 to 11, wherein the decoding the code stream to be entropy decoded to obtain a plurality of values to be decoded, a plurality of prediction labels, and a plurality of sign bit information includes:
and respectively carrying out probability decoding, label decoding and sign bit decoding on the code stream to be subjected to entropy decoding to obtain a plurality of corresponding numerical values to be decoded, a plurality of prediction labels and a plurality of sign bit information.
14. An entropy encoding apparatus, characterized in that the apparatus comprises:
the device comprises a two-dimensional coding data conversion unit, a one-dimensional coding data conversion unit and a coding unit, wherein the two-dimensional coding data to be subjected to entropy coding is converted into one-dimensional coding data to be subjected, the one-dimensional coding data to be subjected comprises a plurality of elements to be coded, and each element to be coded comprises a sign bit and a numerical value;
the encoding prediction unit is used for performing encoding prediction processing on the numerical value of each element to be encoded to determine encoding prediction information of each element to be encoded, wherein the encoding prediction information comprises an encoding prediction value, and the encoding prediction value of each element to be encoded is smaller than or equal to the corresponding numerical value;
the coding processing unit is used for coding the coding prediction information and coding the sign bit to generate a corresponding code stream;
the coding prediction unit may include the following sub-units:
the variable value determining subunit is used for determining a first variable value and a second variable value corresponding to the current to-be-encoded data element, wherein the first variable value is used for representing an encoding predicted value of a previous to-be-encoded data element, and the second variable value is used for representing a value of a previous non-zero to-be-encoded data element;
And the encoding prediction value and prediction label determining subunit is used for determining the encoding prediction value of the to-be-encoded data element according to the first variable value, the second variable value and the current value of the to-be-encoded data element.
15. An entropy decoding apparatus, characterized in that the apparatus comprises:
the code stream decoding unit is used for decoding the code stream to be subjected to entropy decoding to obtain a plurality of values to be decoded, a plurality of prediction labels and a plurality of sign bit information;
the decoding and predicting unit is used for performing decoding and predicting processing on each numerical value to be decoded according to the plurality of prediction labels so as to determine a decoding and predicting value of each numerical value to be decoded;
a one-dimensional data conversion unit for converting one-dimensional data composed of the sign bit information and the decoding prediction value into two-dimensional decoding data;
the decoding prediction unit may further comprise the following sub-units:
a variable value determining subunit, configured to determine a third variable value and a fourth variable value corresponding to a current value to be decoded, where the third variable value is used to indicate a decoding prediction value corresponding to a previous value to be decoded, and the fourth variable value is used to indicate a previous non-zero decoding prediction value
And the prediction tag and decoding prediction value determining subunit is used for judging whether the current value to be decoded has a corresponding prediction tag or not according to the third variable value, the fourth variable value and the current value to be decoded, and determining the decoding prediction value corresponding to the current value to be decoded according to the judgment result.
16. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1-7 and/or 8-13 when executing the program.
17. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7 and/or 8-13.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010758338.9A CN111787326B (en) | 2020-07-31 | 2020-07-31 | Entropy coding and decoding method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010758338.9A CN111787326B (en) | 2020-07-31 | 2020-07-31 | Entropy coding and decoding method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111787326A CN111787326A (en) | 2020-10-16 |
CN111787326B true CN111787326B (en) | 2022-06-28 |
Family
ID=72766577
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010758338.9A Active CN111787326B (en) | 2020-07-31 | 2020-07-31 | Entropy coding and decoding method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111787326B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118694750A (en) * | 2021-05-21 | 2024-09-24 | 华为技术有限公司 | Encoding/decoding method, apparatus, device, storage medium, and computer program |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101609680A (en) * | 2009-06-01 | 2009-12-23 | 华为技术有限公司 | The method of compressed encoding and decoding, encoder and code device |
CN103404035A (en) * | 2011-01-14 | 2013-11-20 | 弗兰霍菲尔运输应用研究公司 | Entropy encoding and decoding scheme |
CN108737822A (en) * | 2016-04-20 | 2018-11-02 | 联发科技股份有限公司 | Entropy coding method and entropy decoding method and accordingly entropy coder, entropy decoder |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR101549823B1 (en) * | 2008-09-02 | 2015-09-04 | 삼성전자주식회사 | Method and apparatus for encoding/decoding image using adaptive binarization |
US20190208225A1 (en) * | 2018-01-02 | 2019-07-04 | Qualcomm Incorporated | Sign prediction in video coding |
CN110708552B (en) * | 2019-08-27 | 2021-12-31 | 杭州海康威视数字技术股份有限公司 | Decoding method, encoding method and device |
-
2020
- 2020-07-31 CN CN202010758338.9A patent/CN111787326B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101609680A (en) * | 2009-06-01 | 2009-12-23 | 华为技术有限公司 | The method of compressed encoding and decoding, encoder and code device |
CN103404035A (en) * | 2011-01-14 | 2013-11-20 | 弗兰霍菲尔运输应用研究公司 | Entropy encoding and decoding scheme |
CN108737822A (en) * | 2016-04-20 | 2018-11-02 | 联发科技股份有限公司 | Entropy coding method and entropy decoding method and accordingly entropy coder, entropy decoder |
Non-Patent Citations (1)
Title |
---|
HEVC熵编码技术研究及并行算法设计;祁跻;《中国优秀硕士论文学位论文全文数据库》;20150415;全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN111787326A (en) | 2020-10-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP5957560B2 (en) | Video encoding / decoding method and apparatus using large size transform unit | |
US9503729B2 (en) | Encoding or decoding method and apparatus | |
JP4700491B2 (en) | Adaptive coefficient scan ordering | |
RU2503138C2 (en) | Embedded graphics coding for images with sparse histograms | |
KR100801364B1 (en) | Decoding apparatus or encoding apparatus wherein intermediate buffer is inserted between arithmetic sign decoder or encoder and debinarizer or binarizer | |
RU2417518C2 (en) | Efficient coding and decoding conversion units | |
CN107743239B (en) | Method and device for encoding and decoding video data | |
US20050259877A1 (en) | Intra compression of pixel blocks using predicted mean | |
CA2739304A1 (en) | Moving image encoding apparatus, moving image decoding apparatus, moving image encoding method, moving image decoding method, moving image encoding program, moving image decodingprogram, and moving image encoding/decoding system | |
WO2010050152A1 (en) | Pixel prediction value generation procedure automatic generation method, image encoding method, image decoding method, devices using these methods, programs for these methods, and recording medium on which these programs are recorded | |
CN110021369B (en) | Gene sequencing data compression and decompression method, system and computer readable medium | |
CN101653004A (en) | Decoder for selectively decoding predetermined data units from a coded bit stream | |
CN103188494A (en) | Apparatus and method for encoding/decoding depth image by skipping discrete cosine transform | |
US10349075B2 (en) | Method and device for lossless compression of video data | |
JP4460521B2 (en) | Orthogonal transform coefficient scanning method, inverse scanning method, scanning device, inverse scanning device, program thereof, and computer-readable recording medium recording the program | |
CN111787326B (en) | Entropy coding and decoding method and device | |
CN101980464B (en) | Data coding method, decoding method, coder and decoder | |
Shoba et al. | A Study on Data Compression Using Huffman Coding Algorithms | |
JP2002064821A (en) | Method for compressing dynamic image information and its system | |
Kuo et al. | An efficient spatial prediction-based image compression scheme | |
US6125211A (en) | Progressive image transmission | |
US20230239470A1 (en) | Video encoding and decoding methods, encoder, decoder, and storage medium | |
JPH0621828A (en) | Vector quantizing decoder | |
KR100460947B1 (en) | Device for processing image signal and method thereof | |
CN115880379A (en) | Semantic scalable image coding method, system, device and storage medium |
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 | ||
TR01 | Transfer of patent right |
Effective date of registration: 20221206 Address after: 31a, 15 / F, building 30, maple mall, bangrang Road, Brazil, Singapore Patentee after: Baiguoyuan Technology (Singapore) Co.,Ltd. Address before: 5-13 / F, West Tower, building C, 274 Xingtai Road, Shiqiao street, Panyu District, Guangzhou, Guangdong 510000 Patentee before: GUANGZHOU BAIGUOYUAN INFORMATION TECHNOLOGY Co.,Ltd. |
|
TR01 | Transfer of patent right |