# US 2014/0192864 A1 · Moving image coding apparatus, code amount control method, and storage medium

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2014/0192864 A1
- Document ID: US20140192864A1
- Status: Published application
- Kind: A1
- Application number: 14/103,060
- Filed: 2013-12-11
- Published: 2014-07-10
- Earliest claimed: 2012-12-11
- Assignees: MegaChips Corporation
- Applicants: MegaChips Corporation
- Inventors: Takuya Hiraoka; Akira Okamoto
- Web page: https://patentgrep.com/patent/US20140192864A1

## CPC

- H04N 19/124: Quantisation
- H04N 19/126: Details of normalisation or weighting functions, e.g. normalisation matrices or variable uniform quantisers
- H04N 19/15: by monitoring actual compressed data size at the memory before deciding storage at the transmission buffer
- H04N 19/176: the region being a block, e.g. a macroblock
- H04N 19/198: {including smoothing of a sequence of encoding parameters, e.g. by averaging, by choice of the maximum, minimum or median value}
- H04N 19/137: Motion inside a coding unit, e.g. average field, frame or block difference
- H04N: PICTORIAL COMMUNICATION, e.g. TELEVISION

## Abstract

A moving image coding apparatus, a code amount control method, and a code amount control program enable appropriate code amount control to be performed in units shorter than frames. The moving image coding apparatus includes a coding unit, a quantization parameter determination unit, and a target code amount setting unit. The target code amount setting unit designates the number of macroblocks and sets a target code amount as a code amount to be allocated to the designated number of macroblocks. The quantization parameter determination unit calculates, for each macroblock, a quantization parameter to be used in quantization of a current macroblock based on a sum of absolute transformed differences SATD used in a motion estimate process. The moving image coding apparatus performs quantization using the calculated quantization parameter value.

## Claims

### Claim 1

A moving image coding apparatus that codes a moving image signal for forming a frame image including a plurality of macroblocks, and controls an amount of code to be generated in coding the moving image signal, the apparatus comprising:
a target code amount setting unit configured to designate the number of macroblocks and set a target code amount as a code amount to be allocated to the designated number of macroblocks;
a quantization parameter determination unit configured to determine a quantization parameter value to be used in quantization performed in coding the moving image signal; and
a coding unit configured to code the moving image signal and perform quantization with respect to the moving image signal using the quantization parameter value determined by the quantization parameter determination unit,
wherein the coding unit includes a storage unit configured to store at least one previous frame image, and a motion estimate unit configured to obtain a difference image by extracting a reference frame image from the at least one previous frame image stored in the storage unit and calculating a difference between a current macroblock that is a processing target macroblock and an image region of the reference frame image having the same size as the current macroblock, obtain a sum of absolute transformed differences of the obtained difference image, and calculate a motion vector based on the obtained sum of absolute transformed differences, and
the quantization parameter determination unit determines the quantization parameter value based on the sum of absolute transformed differences for the current macroblock obtained by the motion estimate unit.

### Claim 2 (depends on 1)

The moving image coding apparatus according to claim 1, wherein
the target code amount setting unit sets a target code amount targetBit as a code amount to be allocated to 2×k1 macroblocks, where k1 is a natural number, and
the quantization parameter determination unit includes
a FIFO SATD storage configured to store sums of absolute transformed differences for N1 macroblocks, where N1 is a natural number, and store the sum of absolute transformed differences for the current macroblock obtained by the motion estimate unit,
a FIFO code amount storage configured to store code amounts for N1 macroblocks, where N1 is a natural number, and store a code amount generated when a macroblock that is one-macroblock previous to the current macroblock is coded,
a current code amount calculation unit configured to obtain, from the FIFO SATD storage, a sum of absolute transformed differences recent_SATD for the current macroblock and sums of absolute transformed differences for k1 previous macroblocks, where k1 is a natural number and k1≦N1, calculate an average avrg_AllocatedBit of the sums of absolute transformed differences for the k1 previous macroblocks, obtain, from the FIFO code amount storage, code amounts for k1 previous macroblocks, where k1 is a natural number and k1≦N1, calculate an average avrg_AllocatedBit of the code amounts for the k1 previous macroblocks, and calculate a total code amount usedBit allocated to the k1 previous macroblocks, and calculate a code amount current_AllocatedBit to be allocated to the current macroblock by using the formulas:
allocatedBit=targetBit−usedBit,
avrg_AllocatedBit=allocatedBit/k1,
and
current_AllocatedBit=avrg_AllocatedBit+coe×(recent_SATD−avrg_SATD),
where coe is a coefficient,
a median-QP-transformed code amount calculation unit configured to obtain, from the FIFO code amount storage, a code amount recent_AllocatedBit for the macroblock that is one-macroblock previous to the current macroblock, and calculate a median-QP-transformed code amount by quantizing the obtained code amount recent_AllocatedBit using a median of possible quantization parameter values in the quantization performed by the coding unit, and
a QP calculation unit configured to calculate a quantization parameter value to be used in coding the current macroblock based on the transformed code amount calculated by the median-QP-transformed code amount calculation unit for the macroblock that is one-macroblock previous to the current macroblock and the code amount current_AllocatedBit to be allocated to the current macroblock calculated by the current code amount calculation unit.

### Claim 3 (depends on 2)

The moving image coding apparatus according to claim 2, wherein
the quantization parameter determination unit further includes
an IIR filter unit configured to obtain a median-QP-transformed code amount predBitQP26 by performing IIR filtering with respect to the median-QP-transformed code amount bitQP26 calculated by the median-QP-transformed code amount calculation unit using the code amount recent_AllocatedBit for the macroblock that is one-macroblock previous to the current macroblock, and
the QP calculation unit calculates a quantization parameter value QP to be used in coding the current macroblock by using the formula:
QP=C0−6×log 2(current_AllocatedBit/predBitQP26),
where C0 is a median of possible quantization parameter values, and
log 2 ( ) is a function that calculates a logarithm to the base 2.

### Claim 4 (depends on 2)

The moving image coding apparatus according to claim 2, wherein
the median-QP-transformed code amount calculation unit includes
a code amount transform unit configured to transform a code amount recent_AllocatedBit of a macroblock that is one-macroblock previous to a current macroblock to a transformed code amount by quantizing the code amount recent_AllocatedBit using a median of possible quantization parameter values in the quantization performed by the coding unit;
a FIFO intra MB storage configured to store median-QP-transformed code amounts for N3 intra macroblocks, where N3 is a natural number, wherein the FIFO intra MB storage stores the transformed code amount obtained by the code amount transform unit when the macroblock that is one-macroblock previous to the current macroblock is an intra macroblock;
a FIFO inter MB storage configured to store median-QP-transformed code amounts for N4 inter macroblocks, where N4 is a natural number, wherein the FIFO inter MB storage stores the transformed code amount obtained by the code amount transform unit when the macroblock that is one-macroblock previous to the current macroblock is an inter macroblock;
a first average calculation unit configured to calculate an average predBitQP26(1) of median-QP-transformed code amounts for N3 intra macroblocks stored in the FIFO intra MB storage; and
a second average calculation unit configured to calculate an average predBitQP26(0) of median-QP-transformed code amounts for N4 inter macroblocks stored in the FIFO inter MB storage,
wherein the QP calculation unit
(1) calculates the quantization parameter value to be used in coding the current macroblock based on the average predBitQP26(1) of the median-QP-transformed code amounts of the intra macroblocks when the current macroblock is an intra macroblock, and
(2) calculates the quantization parameter value to be used in coding the current macroblock based on the average predBitQP26(0) of the median-QP-transformed code amounts of the inter macroblocks when the current macroblock is an inter macroblock.

### Claim 5 (depends on 4)

The moving image coding apparatus according to claim 4, wherein
(1) when the current macroblock is an intra macroblock, the QP calculation unit calculates the quantization parameter value QP to be used in coding the current macroblock by using the formula:
QP=C0−6×log 2(current_AllocatedBit/predBitQP26(1)),
where C0 is a median of possible quantization parameter values, and
log 2 ( ) is a function that calculates a logarithm to the base 2, and
(2) when the current macroblock is an inter macroblock, the QP calculation unit calculates the quantization parameter value QP to be used in coding the current macroblock by using the formula:
QP=C0−6×log 2(current_AllocatedBit/predBitQP26(0)),
where C0 is a median of possible quantization parameter values, and
log 2 ( ) is a function that calculates a logarithm to the base 2.

### Claim 6 (depends on 4)

The moving image coding apparatus according to claim 4, wherein
the quantization parameter determination unit further includes
a data transform unit configured to obtain a target code amount per macroblock IdealMBBit from the target code amount targetBit,
an integration unit configured to calculate a sum sum_diff of differences between an actually generated code amount and a target code amount using a code amount recent_AllocatedBit of the macroblock that is one-macroblock previous to the current macroblock and the target code amount IdealMBBit by performing processing corresponding to the formula:
sum_diff=sum_diff+(IdealMBBit−recent_AllocatedBit), and
a current code amount correction unit configured to correct the code amount current_AllocatedBit to be allocated to the current macroblock calculated by the current code amount calculation unit based on the sum sum_diff, and
the QP calculation unit calculates the quantization parameter value to be used in coding the current macroblock based on the code amount current_AllocatedBit corrected by the current code amount correction unit.

### Claim 7 (depends on 6)

The moving image coding apparatus according to claim 6, wherein
when the code amount current_AllocatedBit to be allocated to the current macroblock calculated by the current code amount calculation unit is a code amount current_AllocatedBit0, the current code amount correction unit obtains a corrected code amount current_AllocatedBit1 by performing processing corresponding to the formula:
current_AllocatedBit1=current_AllocatedBit0+{sum_diff/(k1×2)}, and
(1) when the current macroblock is an intra macroblock,
the QP calculation unit calculates, based on the corrected code amount current_AllocatedBit1 obtained by the current code amount correction unit, the quantization parameter value QP to be used in coding the current macroblock by using the formula:
QP=C0−6×log 2(current_AllocatedBit1/predBitQP26(1))
where C0 is a median of possible quantization parameter values, and
log 2 ( ) is a function that calculates a logarithm to the base 2, and
(2) when the current macroblock is an inter macroblock, the QP calculation unit calculates, based on the corrected code amount current_AllocatedBit1 obtained by the current code amount correction unit, the quantization parameter value QP to be used in coding the current macroblock by using the formula:
QP=C0−6×log 2(current_AllocatedBit1/predBitQP26(0))
where C0 is a median of possible quantization parameter values, and
log 2 ( ) is a function that calculates a logarithm to the base 2.

### Claim 8 (depends on 6)

The moving image coding apparatus according to claim 6, wherein
the median-QP-transformed code amount calculation unit obtains an intra macroblock number intraNum that is the number of intra macroblocks occurring in a predetermined previous period, and
when the current macroblock is an intra macroblock and the intra macroblock number intraNum in the predetermined previous period is less than or equal to a predetermined threshold, the current code amount correction unit corrects the code amount current_AllocatedBit by performing processing corresponding to the formula:
current_AllocatedBit=current_AllocatedBit1+add1,
where add1 (>0) is a code amount to be added, and
the QP calculation unit calculates the quantization parameter value to be used in coding the current macroblock based on the code amount current_AllocatedBit corrected by the current code amount correction unit.

### Claim 9

A method for controlling a code amount to be generated in coding a moving image signal for forming a frame image including a plurality of macroblocks, the method comprising:
setting a target code amount targetBit as a code amount to be allocated to 2×k1 macroblocks, where k1 is a natural number;
obtaining a sum of absolute transformed differences calculated from a difference image indicating a difference between a current macroblock and a corresponding image region of a reference frame image in a motion estimate process;
obtaining a sum of absolute transformed differences recent_SATD for the current macroblock and sums of absolute transformed differences for k1 previous macroblocks, where k1 is a natural number and k1≦N1, and calculating an average avrg_AllocatedBit of the sums of absolute transformed differences for the k1 previous macroblocks;
obtaining code amounts for k1 previous macroblocks, where k1 is a natural number and k1≦N1, and calculating an average avrg_AllocatedBit of the code amounts for the k1 previous macroblocks, and calculating a total code amount usedBit allocated to the k1 previous macroblocks, and
calculating a code amount current_AllocatedBit to be allocated to the current macroblock by using the formulas:
allocatedBit=targetBit−usedBit,
avrg_AllocatedBit=allocatedBit/k1,
and
current_AllocatedBit=avrg_AllocatedBit+coe×(recent_SATD−avrg_SATD),
where coe is a coefficient;
obtaining a code amount recent_AllocatedBit for a macroblock that is one-macroblock previous to the current macroblock, and calculating a transformed code amount bitQP26 by quantizing the obtained code amount recent_AllocatedBit using a median of possible quantization parameter values in a quantization performed in coding the moving image signal;
obtaining a median-QP-transformed code amount predBitQP26 by performing IIR filtering with respect to the median-QP-transformed code amount bitQP26 calculated by the step of calculating the median-QP-transformed code amount using the code amount recent_AllocatedBit for the macroblock that is one-macroblock previous to the current macroblock; and
calculating a quantization parameter value QP to be used in coding the current macroblock by using the formula:
QP=C0−6×log 2(current_AllocatedBit/predBitQP26),
where C0 is a median of possible quantization parameter values, and
log 2 ( ) is a function that calculates a logarithm to the base 2.

### Claim 10

A method for controlling a code amount to be generated in coding a moving image signal for forming a frame image including a plurality of macroblocks, the method comprising:
setting a target code amount targetBit as a code amount to be allocated to 2×k1 macroblocks, where k1 is a natural number;
obtaining a sum of absolute transformed differences calculated from a difference image indicating a difference between a current macroblock and a corresponding image region of a reference frame image in a motion estimate process;
obtaining a sum of absolute transformed differences recent_SATD for the current macroblock and sums of absolute transformed differences for k1 previous macroblocks, where k1 is a natural number and k1≦N1, and calculating an average avrg_AllocatedBit of the sums of absolute transformed differences for the k1 previous macroblocks;
obtaining code amounts for k1 previous macroblocks, where k1 is a natural number and k1≦N1, and calculating an average avrg_AllocatedBit of the code amounts for the k1 previous macroblocks, and calculating a total code amount usedBit allocated to the k1 previous macroblocks;
calculating a code amount current_AllocatedBit to be allocated to the current macroblock by using the formulas:
allocatedBit=targetBit−usedBit,
avrg_AllocatedBit=allocatedBit/k1,
and
current_AllocatedBit=avrg_AllocatedBit+coe×(recent_SATD−avrg_SATD),
where coe is a coefficient;
transforming a code amount recent_AllocatedBit for a macroblock that is one-macroblock previous to the current macroblock to a transformed code amount by quantizing the code amount recent_AllocatedBit using a median of possible quantization parameter values in a quantization performed in coding the moving image signal;
storing, for an intra macroblock, the transformed code amount obtained in the step of transforming the code amount recent_AllocatedBit when the macroblock that is one-macroblock previous to the current macroblock is an intra macroblock;
storing, for an inter macroblock, the transformed code amount obtained in the step of transforming the code amount recent_AllocatedBit when the macroblock that is one-macroblock previous to the current macroblock is an inter macroblock;
calculating a first average predBitQP26(1) of median-QP-transformed code amounts for intra macroblocks stored in the step of storing the transformed code amount for an intra macroblock;
calculating a second average predBitQP26(0) of median-QP-transformed code amounts for inter macroblocks stored in the step of storing the transformed code amount for an inter macroblock; and
(1) calculating a quantization parameter value to be used in coding the current macroblock based on the average predBitQP26(1) of median-QP-transformed code amounts for intra macroblocks when the current macroblock is an intra macroblock, and (2) calculating the quantization parameter value to be used in coding the current macroblock based on the average predBitQP26(0) of median-QP-transformed code amounts for inter macroblocks when the current macroblock is an inter macroblock.

### Claim 11 (depends on 9)

A computer readable storage medium storing a program enabling a computer to implement the code amount control method according to claim 9.

### Claim 12 (depends on 10)

A computer readable storage medium storing a program enabling a computer to implement the code amount control method according to claim 10.
