# US 10,375,404 B1 · Methods for rate control in an MB (macroblock) layer and apparatuses using the same

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

- Number: US 10,375,404 B1
- Document ID: US10375404B1
- Status: Granted
- Kind: B1
- Application number: 15/926,116
- Filed: 2018-03-20
- Published: 2019-08-01
- Granted: 2019-08-06
- Earliest claimed: 2018-01-29
- Assignees: Shanghai Zhaoxin Semiconductor Co., Ltd.
- Applicants: Shanghai Zhaoxin Semiconductor Co., Ltd.
- Inventors: Yongtao Zhao; Ruiyang Chen; Wei Wang
- Web page: https://patentgrep.com/patent/US10375404B1

## CPC

- H04N 19/126: Details of normalisation or weighting functions, e.g. normalisation matrices or variable uniform quantisers
- H04N 19/25: with scene description coding, e.g. binary format for scenes [BIFS] compression
- H04N 19/137: Motion inside a coding unit, e.g. average field, frame or block difference
- H04N 19/149: by estimating the code amount by means of a model, e.g. mathematical model or statistical model
- H04N 19/176: the region being a block, e.g. a macroblock
- H04N 19/42: characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation (H04N19/635 takes precedence)
- H04N 19/593: involving spatial prediction techniques
- H04N: PICTORIAL COMMUNICATION, e.g. TELEVISION

## Abstract

The invention introduces a method for rate control in an MB (macroblock) layer, including: calculating a prediction MAD (Mean Absolute Difference) of a current MB of a current frame according to a real MAD of a previous MB of a previous frame; calculating a real MAD of the current MB of the current frame; performing an adjustment procedure to adjust the prediction MAD of the current MB of the current frame according to the real MAD of the current MB of the current frame to obtain a final MAD of the current MB of the current frame; calculating a quantization parameter of the current MB of the current frame according to the final MAD of the current MB of the current frame; and outputting the quantization parameter of the current MB of the current frame to a quantizer.

## Claims

### Claim 1

A method for rate control in an MB (macroblock) layer, comprising:
calculating a prediction MAD (Mean Absolute Difference) of a current MB of a current frame according to a real MAD of a previous MB of a previous frame, wherein the current MB and the previous MB are located at the same two-dimensional coordinates of the current frame and the previous frame, respectively, and the real MAD of the previous MB of the previous frame reflects the variances between raw data and reconstructed data of the previous MB;
calculating a real MAD of the current MB of the current frame, wherein the real MAD of the current MB of the current frame reflects the variances between raw data and reconstructed data of the current MB;
performing an adjustment procedure to adjust the prediction MAD of the current MB of the current frame according to the real MAD of the current MB of the current frame to obtain a final MAD of the current MB of the current frame;
calculating a quantization parameter of the current MB of the current frame according to the final MAD of the current MB of the current frame; and
outputting the quantization parameter of the current MB of the current frame to a quantizer, thereby enabling the quantizer to generate a compressed video stream under a rate corresponding to the current MB of the current frame.

### Claim 2 (depends on 1)

The method of claim 1, wherein the prediction MAD of the current MB of the current frame is calculated using a linear prediction model.

### Claim 3 (depends on 2)

The method of claim 2, wherein the prediction MAD of the current MB of the current frame is calculated using an Equation:
PredMADi,j=a1×RealMADi-1,j+a2;
PredMADi,j represents the prediction MAD of the current MB of the current frame, RealMADi-1,j represents the real MAD of the previous MB of the previous frame, and a1 and a2 are parameters of the linear prediction model.

### Claim 4 (depends on 3)

The method of claim 3 wherein the parameters a1 and a2 are fit by generalized least squares according to historical data.

### Claim 5 (depends on 1)

The method of claim 1, wherein the real MAD of the current MB of the current frame is calculated using an Equation:
RealMAD
i
,
j
=
(
∑
m
=
0
M
-
1
⁢
∑
n
=
0
N
-
1
⁢

CstPixel
m
,
n
-
OriPixel
m
,
n

)
/
(
M
×
N
)
;
RealMADi,j represents the real MAD of the current MB of the current frame, M represents a total number of rows of the current MB of the current frame, N represents a total number of columns of the current MB of the current frame, PredPixelm,n represents a prediction pixel of the nth column of the mth row of the current MB of the current frame, and OriPixelm,n represents a raw pixel of the nth column of the mth row of the current MB of the current frame.

### Claim 6 (depends on 1)

The method of claim 1, wherein the adjustment procedure comprises:
calculating an adjustment coefficient of the current MB of the current frame according to the prediction and real MADs of the current MB of the current frame and accumulated deltas of all MBs before the current MB of the current frame;
calculating an increment of the current MB of the current frame according to the prediction and real MADs and the adjustment coefficient of the current MB of the current frame; and
calculating the final MAD of the current MB of the current frame according to the prediction MAD and the increment of the current MB of the current frame.

### Claim 7 (depends on 6)

The method of claim 6, wherein the adjustment coefficient is greater than 0 and is smaller than or equal to 1.

### Claim 8 (depends on 6)

The method of claim 6, wherein the adjustment coefficient of the current MB of the current frame is calculated using an Equation:
α
i
,
j
=
2
-
2
×
ab
⁢
⁢
s
⁡
(
∑
k
=
0
j
-
1
⁢
Delta
i
,
k
+
RealMAD
i
,
j
-
PredMAD
i
,
j
)
;
αi,j represents the adjustment coefficient of the current MB of the current frame,
∑
k
=
0
j
-
1
⁢
Delta
i
,
k
represents the accumulated deltas from the 0th MB to the j−1th MB of the current frame, PredMADi, j represents the prediction MAD of the current MB of the current frame, RealMADi,j represents the real MAD of the current MB of the current frame.

### Claim 9 (depends on 6)

The method of claim 6, wherein the increment of the current MB of the current frame is calculated using an Equation:
Deltai,j=αi,j×(RealMADi,j−PredMADi,j);
Deltai,j represents the increment of the current MB of the current frame, αi,j represents the adjustment coefficient of the current MB of the current frame, RealMADi,j represents the real MAD of the current MB of the current frame, and PredMADi,j represents the prediction MAD of the current MB of the current frame.

### Claim 10 (depends on 6)

The method of claim 6, wherein the final MAD of the current MB of the current frame is calculated using an Equation:
FinMADi,j=PredMADi,j+Deltai,j;
FinMADi,j represents the final MAD of the current MB of the current frame, PredMADi,j represents the prediction MAD of the current MB of the current frame, and Deltai,j represents the increment of the current MB of the current frame.

### Claim 11

An apparatus for rate control in an MB (macroblock) layer, comprising:
a quantizer; and
a quantization parameter calculator, coupled to the quantizer, calculating a prediction MAD (Mean Absolute Difference) of a current MB of a current frame according to a real MAD of a previous MB of a previous frame, wherein the current MB and the previous MB are located at the same two-dimensional coordinates of the current frame and the previous frame, respectively, and the real MAD of the previous MB of the previous frame reflects the variances between raw data and reconstructed data of the previous MB; calculating a real MAD of the current MB of the current frame, wherein the real MAD of the current MB of the current frame reflects the variances between raw data and reconstructed data of the current MB; performing an adjustment procedure to adjust the prediction MAD of the current MB of the current frame according to the real MAD of the current MB of the current frame to obtain a final MAD of the current MB of the current frame; calculating a quantization parameter of the current MB of the current frame according to the final MAD of the current MB of the current frame; and outputting the quantization parameter of the current MB of the current frame to a quantizer, thereby enabling the quantizer to generate a compressed video stream under a rate corresponding to the current MB of the current frame.

### Claim 12 (depends on 11)

The apparatus of claim 11, wherein the prediction MAD of the current MB of the current frame is calculated using a linear prediction model.

### Claim 13 (depends on 12)

The apparatus of claim 12, wherein the prediction MAD of the current MB of the current frame is calculated using an Equation:
PredMADi,j=a1×RealMADi-1,j+a2;
PredMADi,j represents the prediction MAD of the current MB of the current frame, RealMADi,j represents the real MAD of the previous MB of the previous frame, and a1 and a2 are parameters of the linear prediction model.

### Claim 14 (depends on 13)

The apparatus of claim 13, wherein the parameters a1 and a2 are fit by generalized least squares according to historical data.

### Claim 15 (depends on 11)

The apparatus of claim 11, wherein the real MAD of the current MB of the current frame is calculated using an Equation:
RealMAD
i
,
j
=
(
∑
m
=
0
M
-
1
⁢
∑
n
=
0
N
-
1
⁢

CstPixel
m
,
n
-
OriPixel
m
,
n

)
/
(
M
×
N
)
;
RealMADi,j represents the real MAD of the current MB of the current frame, M represents a total number of rows of the current MB of the current frame, N represents a total number of columns of the current MB of the current frame, PredPixelm,n represents a prediction pixel of the nth column of the mth row of the current MB of the current frame, and OriPixelm,n represents a raw pixel of the nth column of the mth row of the current MB of the current frame.

### Claim 16 (depends on 11)

The apparatus of claim 11, wherein the adjustment procedure comprises:
calculating an adjustment coefficient of the current MB of the current frame according to the prediction and real MADs of the current MB of the current frame and accumulated deltas of all MBs before the current MB of the current frame;
calculating an increment of the current MB of the current frame according to the prediction and real MADs and the adjustment coefficient of the current MB of the current frame; and
calculating the final MAD of the current MB of the current frame according to the prediction MAD and the increment of the current MB of the current frame.

### Claim 17 (depends on 16)

The apparatus of claim 16, wherein the adjustment coefficient is greater than 0 and is smaller than or equal to 1.

### Claim 18 (depends on 16)

The apparatus of claim 16, wherein the adjustment coefficient of the current MB of the current frame is calculated using an Equation:
α
i
,
j
=
2
-
2
×
ab
⁢
⁢
s
⁡
(
∑
k
=
0
j
-
1
⁢
Delta
i
,
k
+
RealMAD
i
,
j
-
PredMAD
i
,
j
)
;
αi,j represents the adjustment coefficient of the current MB of the current frame,
∑
k
=
0
j
-
1
⁢
Delta
i
,
k
represents the accumulated deltas from the 0th MB to the j−1th MB of the current frame, PredMADi,j represents the prediction MAD of the current MB of the current frame, RealMADi,j represents the real MAD of the current MB of the current frame.

### Claim 19 (depends on 16)

The apparatus of claim 16, wherein the increment of the current MB of the current frame is calculated using an Equation:
Deltai,j=αi,j×(RealMADi,j−PredMADi,j);
Deltai,j represents the increment of the current MB of the current frame, αi,j represents the adjustment coefficient of the current MB of the current frame, RealMADi,j represents the real MAD of the current MB of the current frame, and PredMADi,j represents the prediction MAD of the current MB of the current frame.

### Claim 20 (depends on 16)

The apparatus of claim 16, wherein the final MAD of the current MB of the current frame is calculated using an Equation:
FinMADi,j=PredMADi,j+Deltai,j;
FinMADi,j represents the final MAD of the current MB of the current frame, PredMADi,j represents the prediction MAD of the current MB of the current frame, and Deltai,j represents the increment of the current MB of the current frame.
