Modifying a scan order to limit scan distance
Generating a new scan order includes incrementing a next index value after assigning the next index value to a coefficient in the new scan order; assigning, to a first coefficient at a first scan index m in the original scan order, a first scan index in the new scan order, the first coefficient is a context coefficient for entropy coding a parent coefficient that is at a parent scan index n in the original scan order; adding, to a list, a first item indicative of the parent coefficient and parent scan index n; before assigning a second scan index to a second coefficient that is at a second index m+j in the original scan order, wherein j>1, assigning the next index value to the parent coefficient, and removing the first item from the list; and assigning the next index value to the second coefficient in the new scan order.
1. A method for coding a transform block of coefficients, comprising:
identifying an original scan order for coding the coefficients;
generating a new scan order from the original scan order such that a maximum scan distance of the new scan order is less than or equal to a predetermined distance, wherein generating the new scan order comprising:
maintaining a next index value, wherein the next index value is incremented by 1 after being assigned to a coefficient in the new scan order;
assigning, to a first coefficient at a first scan index m in the original scan order, a first scan index in the new scan order, wherein the first coefficient is a context coefficient for entropy coding a parent coefficient, the parent coefficient being at a parent scan index n in the original scan order;
adding, to a list, a first item indicative of the parent coefficient and parent scan index n;
before assigning a second scan index to a second coefficient that is at a second index m+j in the original scan order, wherein j>1:
assigning the next index value to the parent coefficient; and
removing the first item from the list; and
assigning the next index value to the second coefficient in the new scan order; and
coding the coefficients based on the new scan order.
2. The method of claim 1 , wherein assigning the next index value to the parent coefficient and removing the first item from the list are performed in response to determining that a scan distance of the parent coefficient in the new scan order becomes greater than or equal to a conservative maximum distance if the next index value is assigned to the second coefficient before the parent coefficient.
3. The method of claim 2 , wherein the conservative maximum distance, conserve_max_distance, and the predetermined distance, max_distance, are such that
conserve_max_distance=max_distance−ceiling(max_unscanned_neighbors*(max_context_neighbors−1)/max_context_neighbors),
wherein max_unscanned_neighbors is a maximum number of unprocessed coefficients of the transform block for which at least one context coefficient has been processed, and
wherein max_context_neighbors is a maximum number of coefficients that use a same neighboring coefficient as context information.
4. The method of claim 1 , wherein the max_unscanned_neighbors is related to a width, tx_width, and a height, tx_height, of the transform block.
5. The method of claim 4 , wherein max_unscanned_neighbors=tx_width+tx_height−1.
6. The method of claim 1 , wherein the parent coefficient is immediately below the first coefficient in the transform block.
7. The method of claim 1 , wherein the parent coefficient is to an immediate right of the first coefficient in the transform block.
8. An apparatus for decoding a transform block of coefficients, comprising:
a processor that:
generates a new scan order from an original scan order such that a maximum scan distance of the new scan order is less than or equal to a predetermined distance, wherein to generate the new scan order comprises to:
maintain a next index value, wherein the next index value is incremented by 1 after being assigned to a coefficient in the new scan order;
assign, to a first coefficient at a first scan index m in the original scan order, a first scan index in the new scan order, wherein the first coefficient is a context coefficient for entropy coding a parent coefficient, the parent coefficient being at a parent scan index n in the original scan order;
before assigning a second scan index to a second coefficient that is at a second index m+j in the original scan order, wherein j>1, assign the next index value to the parent coefficient; and
assign the next index value to the second coefficient in the new scan order; and
decodes the coefficients based on the new scan order.
9. The apparatus of claim 8 , wherein to assign the next index value to the parent coefficient is performed in response to determining that a scan distance of the parent coefficient in the new scan order becomes greater than or equal to a conservative maximum distance if the next index value is assigned to the second coefficient before the parent coefficient.
10. The apparatus of claim 9 , wherein the conservative maximum distance, conserve_max_distance, and the predetermined distance, max_distance, are such that
conserve_max_distance=max_distance−ceiling(max_unscanned_neighbors*(max_context_neighbors−1)/max_context_neighbors),
wherein max_unscanned_neighbors is a maximum number of unprocessed coefficients of the transform block for which at least one context coefficient has been processed, and
wherein max_context_neighbors is a maximum number of coefficients that use a same neighboring coefficient as context information.
11. The apparatus of claim 8 , wherein the max_unscanned_neighbors is related to a width, tx_width, and a height, tx_height, of the transform block.
12. The apparatus of claim 11 , wherein max_unscanned_neighbors=tx_width+tx_height−1.
13. The apparatus of claim 8 , wherein the parent coefficient is immediately below the first coefficient in the transform block.
14. The apparatus of claim 8 , wherein the parent coefficient is to an immediate right of the first coefficient in the transform block.
15. An apparatus for encoding a transform block of coefficients, comprising:
a memory; and
a processor, wherein the memory includes instructions executable by the processor to:
generate a new scan order from an original scan order such that a maximum scan distance of the new scan order is less than or equal to a predetermined distance, wherein to generate the new scan order comprises instructions to:
maintain a next index value, wherein the next index value is incremented by 1 after being assigned to a coefficient in the new scan order;
assign, to a first coefficient at a first scan index m in the original scan order, a first scan index in the new scan order, wherein the first coefficient is a context coefficient for entropy coding a parent coefficient, the parent coefficient being at a parent scan index n in the original scan order;
before assigning a second scan index to a second coefficient that is at a second index m+j in the original scan order, wherein j>1, assign the next index value to the parent coefficient; and
assign the next index value to the second coefficient in the new scan order; and
encode the coefficients based on the new scan order.
16. The apparatus of claim 15 , wherein to assign the next index value to the parent coefficient is performed in response to determining that a scan distance of the parent coefficient in the new scan order becomes greater than or equal to a conservative maximum distance if the next index value is assigned to the second coefficient before the parent coefficient.
17. The apparatus of claim 16 , wherein the conservative maximum distance, conserve_max_distance, and the predetermined distance, max_distance, are such that
conserve_max_distance=max_distance−ceiling(max_unscanned_neighbors*(max_context_neighbors−1)/max_context_neighbors),
wherein max_unscanned_neighbors is a maximum number of unprocessed coefficients of the transform block for which at least one context coefficient has been processed, and
wherein max_context_neighbors is a maximum number of coefficients that use a same neighboring coefficient as context information.
18. The apparatus of claim 15 , wherein the max_unscanned_neighbors is related to a width, tx_width, and a height, tx_height, of the transform block.
19. The apparatus of claim 18 , wherein max_unscanned_neighbors=tx_width+tx_height−1.
20. The apparatus of claim 15 , wherein the parent coefficient is immediately below the first coefficient or to an immediate right of the first coefficient in the transform block.