# US 2021/0084336 A1 · Efficient context model computation design in transform coefficient coding

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

- Number: US 2021/0084336 A1
- Document ID: US20210084336A1
- Status: Published application
- Kind: A1
- Application number: 17/106,898
- Filed: 2020-11-30
- Published: 2021-03-18
- Earliest claimed: 2018-01-30
- Assignees: Google Inc.
- Applicants: Google LLC
- Inventors: Jingning Han; James Zern; Linfeng Zhang; Ching-Han Chiang; Yaowu Xu
- Web page: https://patentgrep.com/patent/US20210084336A1

## CPC

- H04N 19/60: using transform coding
- H04N 19/129: Scanning of coding units, e.g. zig-zag scan of transform coefficients or flexible macroblock ordering [FMO]
- H04N 19/13: Adaptive entropy coding, e.g. adaptive variable length coding [AVLC] or context adaptive binary arithmetic coding [CABAC]
- H04N 19/18: the unit being a set of transform coefficients
- H04N 19/184: the unit being bits, e.g. of the compressed video stream
- H04N 19/88: involving rearrangement of data among different coding units, e.g. shuffling, interleaving, scrambling or permutation of pixel data or permutation of transform coefficient data among different blocks
- H04N: PICTORIAL COMMUNICATION, e.g. TELEVISION

## Abstract

A processor is configured to maintain, for encoding current values related to the transform coefficients a first line buffer and a second line buffer. The current values are arranged along a current scan-order anti-diagonal line. The first line buffer includes first values of a first scan-order anti-diagonal line. The second line buffer includes second values of a second scan-order anti-diagonal line. The processor is further configured to interleave the first values and the second values in a destination buffer; select, using the destination buffer, a probability distribution for coding a current value of the current values; entropy encode, in a compressed bitstream, the current value using the probability distribution; and replace, for coding values of an immediately subsequent scan-order anti-diagonal line to the current scan-order anti-diagonal line, one of the second line buffer or the first line buffer with the current scan-order anti-diagonal line.

## Claims

### Claim 1

An apparatus for encoding a transform block of transform coefficients, the apparatus comprising:
a processor configured to:
maintain, for encoding current values related to the transform coefficients a first line buffer and a second line buffer,
wherein the current values are arranged along a current scan-order anti-diagonal line of a scan order,
wherein the first line buffer includes first values of a first scan-order anti-diagonal line scanned immediately before the current scan-order anti-diagonal line, and
wherein the second line buffer includes second values of a second scan-order anti-diagonal line scanned immediately before the first scan-order anti-diagonal line;
interleave the first values of the first line buffer and the second values of the second line buffer in a destination buffer;
select, using the destination buffer, a probability distribution for coding a current value of the current values;
entropy encode, in a compressed bitstream, the current value using the probability distribution; and
replace, for coding values of an immediately subsequent scan-order anti-diagonal line to the current scan-order anti-diagonal line, one of the second line buffer or the first line buffer with the current scan-order anti-diagonal line.

### Claim 2 (depends on 1)

The apparatus of claim 1, wherein to interleave the first values of the first line buffer and the second values of the second line buffer in the destination buffer comprises to:
use a hardware instruction to interleave the first values and the second values in the destination buffer.

### Claim 3 (depends on 2)

The apparatus of claim 2, wherein the hardware instruction is one of unpackhi or unparcklo.

### Claim 4 (depends on 2)

The apparatus of claim 2, wherein the processor is further configured to:
calculate a respective cumulative sum for at least some locations of the destination buffer.

### Claim 5 (depends on 4)

The apparatus of claim 4, wherein to calculate the respective cumulative sum for the at least some locations of the destination buffer comprises to:
add a destination buffer value at a location of the at least some locations of the destination buffer to a cumulative sum corresponding to an immediately preceding location of the destination buffer.

### Claim 6 (depends on 5)

The apparatus of claim 5, wherein to determine, using the destination buffer, the probability distribution for coding the current value of the current scan-order anti-diagonal line comprises to:
calculate a difference between a first cumulative sum corresponding to a first location of the destination buffer and a second cumulative sum corresponding to a second location of the destination buffer, wherein the first cumulative sum and the second cumulative sum are selected based on a position of the current value; and
determine the probability distribution using the difference.

### Claim 7 (depends on 6)

The apparatus of claim 6, wherein a distance between the first location of the destination buffer and the second location of the destination buffer is related to a number of scan positions of the already coded values of a template, wherein the template indicates, for a to-be-coded value, scan positions of already coded values, the scan positions arranged, in the template, in at least two anti-diagonal lines.

### Claim 8

An apparatus for decoding a transform block, the apparatus comprising:
a processor configured to:
store, in a first line buffer, first values of a first scan-order diagonal line scanned immediately before a current scan-order diagonal line of the transform block;
store, in a second line buffer, second values of a second scan-order diagonal line scanned immediately before the first scan-order diagonal line;
interleave the first values of the first line buffer and the second values of the second line buffer in a destination buffer;
select, using the destination buffer, a probability distribution for coding a current value of the current scan-order diagonal line;
entropy decode, from a compressed bitstream, the current value using the probability distribution; and
replace, for coding values of an immediately subsequent scan-order diagonal line to the current scan-order diagonal line, one of the second line buffer or the first line buffer with current values of the current scan-order diagonal line.

### Claim 9 (depends on 8)

The apparatus of claim 8, wherein to interleave the first values of the first line buffer and the second values of the second line buffer in the destination buffer comprises to:
use a hardware instruction to interleave the first values and the second values in the destination buffer.

### Claim 10 (depends on 9)

The apparatus of claim 9, wherein the hardware instruction is one of unpackhi or unparcklo.

### Claim 11 (depends on 9)

The apparatus of claim 9, wherein the processor is further configured to:
calculate a respective cumulative sum for at least some locations of the destination buffer.

### Claim 12 (depends on 11)

The apparatus of claim 11, wherein to calculate the respective cumulative sum for the at least some locations of the destination buffer comprises to:
add a destination buffer value at a location of the at least some locations of the destination buffer to a cumulative sum corresponding to an immediately preceding location of the destination buffer.

### Claim 13 (depends on 12)

The apparatus of claim 12, wherein to determine, using the destination buffer, the probability distribution for coding the current value of the current scan-order diagonal line comprises to:
calculate a difference between a first cumulative sum corresponding to a first location of the destination buffer and a second cumulative sum corresponding to a second location of the destination buffer, wherein the first cumulative sum and the second cumulative sum are selected based on a position of the current value; and
determine the probability distribution using the difference.

### Claim 14 (depends on 13)

The apparatus of claim 13, wherein a distance between the first location of the destination buffer and the second location of the destination buffer is related to a number of scan positions of the already coded values of a template, wherein the template indicates, for a to-be-coded value, scan positions of already coded values, the scan positions arranged, in the template, in at least two anti-diagonal lines.

### Claim 15

A method for decoding a transform block, comprising:
storing, in a first line buffer, first values of a first scan-order diagonal line scanned immediately before a current scan-order diagonal line of the transform block;
storing, in a second line buffer, second values of a second scan-order diagonal line scanned immediately before the first scan-order diagonal line;
interleaving the first values of the first line buffer and the second values of the second line buffer in a destination buffer;
selecting, using the destination buffer, a probability distribution for coding a current value of the current scan-order diagonal line;
entropy decoding, from a compressed bitstream, the current value using the probability distribution; and
replacing, for coding values of an immediately subsequent scan-order diagonal line to the current scan-order diagonal line, one of the second line buffer or the first line buffer with current values of the current scan-order diagonal line.

### Claim 16 (depends on 15)

The method of claim 15, wherein interleaving the first values of the first line buffer and the second values of the second line buffer in the destination buffer comprises:
using a hardware instruction to interleave the first values and the second values in the destination buffer.

### Claim 17 (depends on 16)

The method of claim 16, wherein the hardware instruction is one of unpackhi or unparcklo.

### Claim 18 (depends on 16)

The method of claim 16, further comprising:
calculating a respective cumulative sum for at least some locations of the destination buffer.

### Claim 19 (depends on 18)

The method of claim 18, wherein calculating the respective cumulative sum for the at least some locations of the destination buffer comprises:
adding a destination buffer value at a location of the at least some locations of the destination buffer to a cumulative sum corresponding to an immediately preceding location of the destination buffer.

### Claim 20 (depends on 19)

The method of claim 19, wherein determining, using the destination buffer, the probability distribution for coding the current value of the current scan-order diagonal line comprises:
calculating a difference between a first cumulative sum corresponding to a first location of the destination buffer and a second cumulative sum corresponding to a second location of the destination buffer, wherein the first cumulative sum and the second cumulative sum are selected based on a position of the current value; and
determining the probability distribution using the difference.
