# Patent

## Title
Rotation of prediction residual blocks in video coding with transform skipping

## Abstract

Techniques are described for coding residual data of a prediction residual block with transform skipping. A transform may be skipped for a residual block when the residual block is coded using either a lossless coding mode or a lossy coding mode in a transform skip mode. According to the techniques, based on a transform being skipped for a residual block, a rotation unit included in a video encoder or a video decoder determines whether to rotate the residual block prior to coding residual data of the residual block. In some examples, a rotation value may be explicitly signaled between the video encoder and the video decoder. In other examples, the video encoder and the video decoder may each independently determine whether to rotate the residual block based on a type of boundary at two or more edges of the residual block.

## Background
This application claims the benefit of U.S. Provisional Application No. 61/670,569, filed Jul. 11, 2012; U.S. Provisional Application No. 61/815,148, filed Apr. 23, 2013; and U.S. Provisional Application No. 61/833,781, filed Jun. 11, 2013, the entire content of each of which are incorporated herein by reference.


TECHNICAL FIELD
This disclosure relates to video coding (i.e., video encoding and video decoding) with transform skipping.
BACKGROUND
Digital video capabilities can be incorporated into a wide range of devices, including digital televisions, digital direct broadcast systems, wireless broadcast systems, personal digital assistants (PDAs), laptop or desktop computers, tablet computers, e-book readers, digital cameras, digital recording devices, digital media players, video gaming devices, video game consoles, cellular or satellite radio telephones, so-called “smart phones,” video teleconferencing devices, video streaming devices, and the like. Digital video devices implement video compression techniques, such as those described in the standards defined by MPEG-2, MPEG-4, ITU-T H.263, ITU-T H.264/MPEG-4, Part 10, Advanced Video Coding (AVC), the High Efficiency Video Coding (HEVC) standard presently under development, and extensions of such standards. The video devices may transmit, receive, encode, decode, and/or store digital video information more efficiently by implementing such video compression techniques.
Video compression techniques perform spatial (intra-picture) prediction and/or temporal (inter-picture) prediction to reduce or remove redundancy inherent in video sequences. For block-based video coding, a video slice (i.e., a video frame or a portion of a video frame) may be partitioned into video blocks, which may also be referred to as treeblocks, coding units (CUs) and/or coding nodes. Video blocks in an intra-coded (I) slice of a picture are encoded using spatial prediction with respect to reference samples in neighboring blocks in the same picture. Video blocks in an inter-coded (P or B) slice of a picture may use spatial prediction with respect to reference samples in neighboring blocks in the same picture or temporal prediction with respect to reference samples in other reference pictures. Pictures may be referred to as frames, and reference pictures may be referred to a reference frames.
Spatial or temporal prediction results in a predictive block for a block to be coded. Residual data represents pixel differences between the original block to be coded and the predictive block. An inter-coded block is encoded according to a motion vector that points to a block of reference samples forming the predictive block, and the residual data indicating the difference between the pixels of the coded block and the predictive block. An intra-coded block is encoded according to an intra-coding mode and the residual data. For further compression, the residual data may be transformed from the pixel domain to a transform domain, resulting in residual transform coefficients, which then may be quantized. The quantized transform coefficients, initially arranged in a two-dimensional array, may be scanned in order to produce a one-dimensional vector of transform coefficients, and entropy coding may be applied to achieve even more compression.
SUMMARY
In general, this disclosure describes techniques for coding residual data of a prediction residual block with transform skipping. The residual data comprises pixel difference values between a video block and a prediction block. A transform may be skipped for a residual block when the residual block is coded using either a lossless coding mode or a lossy coding mode in a transform skip mode. Without applying a transform to the residual block, the residual data with higher energy, i.e., larger pixel difference values, than average may not be positioned at a top left corner of the residual block, which is expected for entropy coding.
According to the techniques, based on a transform being skipped for a residual block, a rotation unit included in a video encoder or a video decoder determines whether to rotate the residual block prior to coding residual data of the residual block. In some examples, a rotation value may be explicitly signaled between the video encoder and the video decoder. In other examples, the video encoder and the video decoder may each independently determine whether to rotate the residual block based on a type of boundary at two or more edges of the residual block. In this case, the rotation unit determines a type of boundary at two or more edges of the residual block, and then determines whether to rotate the residual block based on the type of boundary at the edges in order to reposition the residual data.
In one example, this disclosure is directed to a method of decoding video data, the method comprising skipping an inverse transform for a residual block of the video data based on one or more syntax elements indicating transform skipping for the residual block, and determining whether to rotate the residual block prior to reconstructing a video block from residual data of the residual block.
In another example, this disclosure is directed to a method of encoding video data, the method comprising skipping a transform for a residual block calculated from a video block of the video data, and determining whether to rotate the residual block prior to encoding the residual data of the residual block.
In a further example, this disclosure is directed to a video coding device for coding video data, the device comprising one or more processors configured to skip a transform for a residual block of the video data, and determine whether to rotate the residual block prior to coding the residual data of the residual block.
In an additional example, this disclosure is directed to a video coding device for coding video data, the device comprising means for skipping a transform for a residual block of the video data, and means for determining whether to rotate the residual block prior to coding the residual data of the residual block.
In another example, this disclosure is directed to a computer readable medium comprising instructions for coding video data, the instructions, when executed, cause one or more programmable processors to skip a transform for a residual block of the video data, and determine whether to rotate the residual block prior to coding the residual data of the residual block.
The details of one or more examples are set forth in the accompanying drawings and the description below. Other features, objects, and advantages will be apparent from the description and drawings, and from the claims.



BRIEF DESCRIPTION OF DRAWINGS
FIG. 1 is a block diagram illustrating an example video encoding and decoding system that may utilize the techniques described in this disclosure to code residual data with transform skipping.
FIG. 2 is a block diagram illustrating an example video encoder that may implement the techniques described in this disclosure to determine whether to rotate a residual block prior to encoding residual data of the residual block.
FIG. 3 is a block diagram illustrating an example video decoder that may implement the techniques described in this disclosure to determine whether to rotate a residual block prior to reconstructing a video block from residual data of the residual block.
FIG. 4 is a block diagram illustrating a coding unit (CU) of a residual block partitioned into one or more prediction units (PUs) according to a motion prediction mode and multiple transform units (TUs) according to a quad-tree data structure.
FIG. 5 is a flowchart illustrating an exemplary operation of a video encoder determining whether to rotate a residual block prior to encoding residual data of the residual block.
FIG. 6 is a flowchart illustrating an exemplary operation of a video decoder determining whether to rotate a residual block prior to reconstructing a video block from residual data of the residual block.
FIG. 7 is a flowchart illustrating one example operation of determining whether to rotate a residual block by a predetermined rotation value based on a type of boundary at edges of the residual block.
FIG. 8 is a flowchart illustrating another example operation of determining whether to rotate a residual block including determining a rotation value for the residual block based on a type of boundary at edges of the residual block for each of two or more possible rotation values.
FIG. 9 is a flowchart illustrating an example operation of aligning block sizes of residual blocks for which rotation can be performed with block sizes for which a transform can be skipped in a lossy coding mode.
FIG. 10 is a flowchart illustrating an example operation of aligning block sizes of residual blocks for which flipping of residual data sample values along a diagonal can be performed with block sizes for which a transform can be skipped in a lossy coding mode.



DETAILED DESCRIPTION
This disclosure describes techniques for coding residual data of a prediction residual block with transform skipping. The residual data of the residual block comprises pixel difference values between pixels of a video block to be coded and corresponding pixels of a prediction block generated for the block to be coded. A transform may be skipped for a residual block when the residual block is coded using either a lossless coding mode or a lossy coding mode in a transform skip mode. Without applying a transform to the residual block, the residual data with higher energy, i.e., larger pixel difference values, than average may not be positioned at a top left corner of the residual block, which is expected for entropy coding.
When the transform is skipped for the residual block, entropy coding efficiency may be improved by rotating the residual block during encoding in order to position the residual data with higher energy than average at the top left corner of the residual block. During decoding, the rotation performed during encoding needs to be reversed in order to reconstruct the original video block from the residual block and a prediction block.
In the intra-prediction mode, when a transform is skipped for a residual block, the residual data with higher energy than average is typically positioned at a bottom right corner of the residual block. In some cases, the intra-prediction residual block may be automatically rotated by 180 degrees prior to coding the residual block in order to position the residual data with higher energy than average at the top left corner of the residual block. In the inter-prediction mode, however, it may not always be desirable to automatically rotate the residual block by 180 degrees.
According to the techniques of this disclosure, based on a transform being skipped for a residual block, a rotation unit included in a video encoder or a video decoder determines whether to rotate the residual block prior to coding residual data of the residual block. In some examples, a rotation value may be explicitly signaled between the video encoder and the video decoder. In other examples, the video encoder and the video decoder may each independently determine whether to rotate the residual block based on a type of boundary at two or more edges of the residual block.
In the inter-prediction mode, residual data at a transform unit (TU) boundary of the residual block, i.e., a boundary between two TUs that belong to the same prediction unit (PU), typically has lower energy than average residual data in the residual block. Further, residual data at a PU boundary of the residual block, i.e., a boundary between two TUs that belong to different PUs, typically has higher energy than average residual data in the residual block. Based on this observation, the techniques of this disclosure including rotating an inter-prediction residual block with transform skipping based on a type of boundary at two or more edges of the residual block. For example, the rotation unit may determine a type of boundary at two or more edges of the residual block, and then determine whether to rotate the residual block based on the type of boundary at the edges in order to reposition the residual data.
In some examples, the rotation unit determines to either rotate the residual block by a predetermined rotation value, e.g., 180 degrees, or not rotate the residual block. In other examples, the rotation unit determines a rotation value by which to rotate the residual block from two or more rotation values, e.g., 0 degrees or no rotation, 180 degrees, 90 degrees or 270 degrees.
On the encoding side, the rotation positions the residual data with higher energy than average at a top left corner of the rotated residual block prior to encoding the residual data of the residual block to improve entropy coding efficiency. On the decoding side, the rotation reverses the rotation performed during encoding and returns the residual data with higher energy than average to its original position in the original residual block in order to reconstruct a video block from the residual block using a predictive block.
FIG. 1 is a block diagram illustrating an example video encoding and decoding system 10 that may utilize the techniques described in this disclosure to code residual data with transform skipping. As shown in FIG. 1, system 10 includes a source device 12 that generates encoded video data to be decoded, e.g., at a later time, by a destination device 14. Source device 12 and destination device 14 may comprise any of a wide range of devices, including desktop computers, notebook (i.e., laptop) computers, tablet computers, set-top boxes, telephone handsets such as so-called “smart” phones, so-called “smart” pads, televisions, cameras, display devices, digital media players, video gaming consoles, video streaming device, or the like. In some cases, source device 12 and destination device 14 may be equipped for wireless communication.
Destination device 14 may receive the encoded video data to be decoded via a link 16. Link 16 may comprise any type of medium or device capable of moving the encoded video data from source device 12 to destination device 14. In one example, link 16 may comprise a communication medium to enable source device 12 to transmit encoded video data directly to destination device 14 in real-time. The encoded video data may be modulated according to a communication standard, such as a wireless communication protocol, and transmitted to destination device 14. The communication medium may comprise any wireless or wired communication medium, such as a radio frequency (RF) spectrum or one or more physical transmission lines. The communication medium may form part of a packet-based network, such as a local area network, a wide-area network, or a global network such as the Internet. The communication medium may include routers, switches, base stations, or any other equipment that may be useful to facilitate communication from source device 12 to destination device 14.
Alternatively, encoded data may be output from output interface 22 to a storage device 34. Similarly, encoded data may be accessed from storage device 34 by input interface. Storage device 34 may include any of a variety of distributed or locally accessed data storage media such as a hard drive, Blu-ray discs, DVDs, CD-ROMs, flash memory, volatile or non-volatile memory, or any other suitable digital storage media for storing encoded video data. In a further example, storage device 34 may correspond to a file server or another intermediate storage device that may hold the encoded video generated by source device 12. Destination device 14 may access stored video data from storage device 34 via streaming or download. The file server may be any type of server capable of storing encoded video data and transmitting that encoded video data to the destination device 14. Example file servers include a web server (e.g., for a website), an FTP server, network attached storage (NAS) devices, or a local disk drive. Destination device 14 may access the encoded video data through any standard data connection, including an Internet connection. This may include a wireless channel (e.g., a Wi-Fi connection), a wired connection (e.g., DSL, cable modem, etc.), or a combination of both that is suitable for accessing encoded video data stored on a file server. The transmission of encoded video data from storage device 34 may be a streaming transmission, a download transmission, or a combination of both.
The techniques of this disclosure are not necessarily limited to wireless applications or settings. The techniques may be applied to video coding in support of any of a variety of multimedia applications, such as over-the-air television broadcasts, cable television transmissions, satellite television transmissions, streaming video transmissions, e.g., via the Internet, encoding of digital video for storage on a data storage medium, decoding of digital video stored on a data storage medium, or other applications. In some examples, system 10 may be configured to support one-way or two-way video transmission to support applications such as video streaming, video playback, video broadcasting, and/or video telephony.
In the example of FIG. 1, source device 12 includes a video source 18, video encoder 20 and an output interface 22. In some cases, output interface 22 may include a modulator/demodulator (modem) and/or a transmitter. In source device 12, video source 18 may include a source such as a video capture device, e.g., a video camera, a video archive containing previously captured video, a video feed interface to receive video from a video content provider, and/or a computer graphics system for generating computer graphics data as the source video, or a combination of such sources. As one example, if video source 18 is a video camera, source device 12 and destination device 14 may form so-called camera phones or video phones. However, the techniques described in this disclosure may be applicable to video coding in general, and may be applied to wireless and/or wired applications.
The captured, pre-captured, or computer-generated video may be encoded by video encoder 12. The encoded video data may be transmitted directly to destination device 14 via output interface 22 of source device 20. The encoded video data may also (or alternatively) be stored onto storage device 34 for later access by destination device 14 or other devices, for decoding and/or playback.
Destination device 14 includes an input interface 28, a video decoder 30, and a display device 32. In some cases, input interface 28 may include a receiver and/or a modem. Input interface 28 of destination device 14 receives the encoded video data over link 16. The encoded video data communicated over link 16, or provided on storage device 34, may include a variety of syntax elements generated by video encoder 20 for use by a video decoder, such as video decoder 30, in decoding the video data. Such syntax elements may be included with the encoded video data transmitted on a communication medium, stored on a storage medium, or stored a file server.
Display device 32 may be integrated with, or external to, destination device 14. In some examples, destination device 14 may include an integrated display device and also be configured to interface with an external display device. In other examples, destination device 14 may be a display device. In general, display device 32 displays the decoded video data to a user, and may comprise any of a variety of display devices such as a liquid crystal display (LCD), a plasma display, an organic light emitting diode (OLED) display, or another type of display device.
Digital video devices implement video compression techniques to encode and decode digital video information more efficiently. Video compression may apply spatial (intra-frame) prediction and/or temporal (inter-frame) prediction techniques to reduce or remove redundancy inherent in video sequences. Video encoder 20 and video decoder 30 may operate according to a video coding standard, such as the High Efficiency Video Coding (HEVC) standard presently under development, and may conform to the HEVC Test Model (HM). Alternatively, video encoder 20 and video decoder 30 may operate according to other proprietary or industry video coding standards. The techniques of this disclosure, however, are not limited to any particular coding standard.
Video coding standards include ITU-T H.261, ISO/IEC MPEG-1 Visual, ITU-T H.262 or ISO/IEC MPEG-2 Visual, ITU-T H.263, ISO/IEC MPEG-4 Visual and ITU-T H.264 (also known as ISO/IEC MPEG-4 AVC), including its Scalable Video Coding (SVC) and Multiview Video Coding (MVC) extensions. In addition, there is the new video coding standard, namely HEVC, being developed by the Joint Collaboration Team on Video Coding (JCT-VC) of ITU-T Video Coding Experts Group (VCEG) and ISO/IEC Motion Picture Experts Group (MPEG).
“Working draft 7,” or “WD7,” of the upcoming HEVC standard is described in document HCTVC-11003, Bross et al., “High Efficiency Video Coding (HEVC) Text Specification Draft 7,” Joint Collaborative Team on Video Coding (JCT-VC) of ITU-T SG16 WP3 and ISO/IEC JTC1/SC29/WG11, 9th Meeting: Geneva, Switzerland, Apr. 27, 2012 to May 7, 2012, which, as of 3 Jul. 2013, is downloadable from http://phenix.it-sudparis.eu/jct/doc_end_user/documents/9_Geneva/wg11/JCTVC-I1003-v6.zip. In addition, “working draft 8” or “WD8” of the HEVC standard is described in document JCTVC-J1003_d7, Bross et al., “High Efficiency Video Coding (HEVC) Text Specification Draft 8,” Joint Collaborative Team on Video Coding (JCT-VC) of ITU-T SG16 WP3 and ISO/IEC JTC1/SC29/WG11, 10th Meeting: Stockholm, Sweden, 11-20 Jul. 2012, which, as of 3 Jul. 2013, is available from http://phenix.int-evry.fr/jct/doc_end_user/documents/10_Stockholm/wg11/JCTVC-J1003-v8.zip.
Although not shown in FIG. 1, in some aspects, video encoder 20 and video decoder 30 may each be integrated with an audio encoder and decoder, and may include appropriate MUX-DEMUX units, or other hardware and software, to handle encoding of both audio and video in a common data stream or separate data streams. If applicable, in some examples, MUX-DEMUX units may conform to the ITU H.223 multiplexer protocol, or other protocols such as the user datagram protocol (UDP).
Video encoder 20 and video decoder 30 each may be implemented as any of a variety of suitable encoder circuitry, such as one or more microprocessors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), discrete logic, software, hardware, firmware or any combinations thereof. When the techniques are implemented partially in software, a device may store instructions for the software in a suitable, non-transitory computer-readable medium and execute the instructions in hardware using one or more processors to perform the techniques of this disclosure. Each of video encoder 20 and video decoder 30 may be included in one or more encoders or decoders, either of which may be integrated as part of a combined encoder/decoder (CODEC) in a respective device.
The JCT-VC is working on development of the HEVC standard. The HEVC standardization efforts are based on an evolving model of a video coding device referred to as the HEVC Test Model (HM). The HM presumes several additional capabilities of video coding devices relative to existing devices according to, e.g., ITU-T H.264/AVC. For example, whereas H.264 provides nine intra-prediction encoding modes, the HM may provide as many as thirty-four intra-prediction encoding modes.
In general, the working model of the HM describes that a video frame or picture may be partitioned into one or more slices, which may be further partitioned into a sequence of treeblocks or largest coding units (LCU), which may be further partitioned into coding units (CUs). A CU generally refers to an image region that serves as a basic unit to which various coding tools are applied for video compression. A CU usually has a luminance component, denoted as Y, and two chroma components, denoted as U and V. Depending on the video sampling format, the size of the U and V components, in terms of number of samples, may be the same as or different from the size of the Y component. A CU is typically square, and may be considered to be similar to a so-called macroblock, e.g., under other video coding standards such as ITU-T H.264. Coding according to some of the presently proposed aspects of the developing HEVC standard will be described in this application for purposes of illustration. However, the techniques described in this disclosure may be useful for other video coding processes, such as those defined according to H.264 or other standard or proprietary video coding processes.
According to the HM, a CU includes a coding node and one or more prediction units (PUs) and/or one or more transform units (TUs) associated with the coding node. Syntax data within a bitstream may define a treeblock or LCU, which is a largest CU in terms of the number of pixels. In general, a CU has a similar purpose to a macroblock of H.264, except that a CU does not have a size distinction. Thus, a CU may be split into sub-CUs. In general, references in this disclosure to a CU may refer to a largest coding unit of a picture or a sub-CU of an LCU. An LCU may be split into sub-CUs, and each sub-CU may be further split into sub-CUs. Syntax data for a bitstream may define a maximum number of times an LCU may be split, referred to as CU depth. Accordingly, a bitstream may also define a smallest coding unit (SCU). This disclosure also uses the term “block” or “portion” to refer to any of a CU, PU, or TU. In general, “portion” may refer to any sub-set of a video frame.
An LCU may be associated with a quadtree data structure. In general, a quadtree data structure includes one node per CU, where a root node corresponds to the LCU. If a CU is split into four sub-CUs, the node corresponding to the CU includes four leaf or child nodes, each of which corresponds to one of the sub-CUs. Each node of the quadtree data structure may provide syntax data for the corresponding CU. For example, a node in the quadtree may include a split flag, indicating whether the CU corresponding to the node is split into sub-CUs. Syntax elements for a CU may be defined recursively, and may depend on whether the CU is split into sub-CUs. If a CU is not split further, it may be referred to as a leaf-CU.
Moreover, TUs of leaf-CUs may also be associated with respective quadtree data structures, such as a residual quadtree (RQT). That is, a leaf-CU may include a quadtree indicating how the leaf-CU is partitioned into TUs. This disclosure refers to the quadtree indicating how an LCU is partitioned as a CU quadtree and the quadtree indicating how a leaf-CU is partitioned into TUs as a TU quadtree. The root node of a TU quadtree generally corresponds to a leaf-CU, while the root node of a CU quadtree generally corresponds to an LCU. TUs of the TU quadtree that are not split are referred to as leaf-TUs. A TU may be square or non-square in shape.
A leaf-CU may include one or more PUs. In general, a PU represents all or a portion of the corresponding CU, and may include data for retrieving a reference sample for the PU. For example, when the PU is intra-mode encoded, the PU may include data describing an intra-prediction mode for the PU. As another example, when the PU is inter-mode encoded, the PU may include data defining a motion vector for the PU. The data defining the motion vector may describe, for example, a horizontal component of the motion vector, a vertical component of the motion vector, a resolution for the motion vector (e.g., one-quarter pixel precision or one-eighth pixel precision), a reference frame to which the motion vector points, and/or a reference list (e.g., list 0 or list 1) for the motion vector. Data for the leaf-CU defining the PUs may also describe, for example, partitioning of the CU into one or more PUs. Partitioning modes may differ depending on whether the CU is uncoded, intra-prediction mode coded, or inter-prediction mode coded. For intra coding, a PU may be treated the same as a leaf-TU. PUs may be partitioned to be square or non-square in shape.
In general, a TU is used for the transform and quantization processes. Following prediction, residual data values are calculated for the video block identified by the coding node using a predictive block. The coding node is then updated to reference the residual values rather than the original video block. The residual values comprise pixel difference values that may be transformed into transform coefficients, quantized, and scanned to produce serialized transform coefficients for entropy coding. The coding node may once again be updated to refer to these serialized transform coefficients.
A video sequence typically includes a series of video frames or pictures. A group of pictures (GOP) generally comprises a series of one or more of the video pictures. A GOP may include syntax data in a header of the GOP, a header of one or more of the pictures, or elsewhere, that describes a number of pictures included in the GOP. Each slice of a picture may include slice syntax data that describes an encoding mode for the respective slice. Each slice is further partitioned into video blocks that are used encode the video data. A video block may correspond to a coding node within a CU. The video blocks may have fixed or varying sizes, and may differ in size according to a specified coding standard.
As an example, the HM supports prediction in various PU sizes. Assuming that the size of a particular CU is 2N×2N, the HM supports intra-prediction in PU sizes of 2N×2N or N×N, and inter-prediction in symmetric PU sizes of 2N×2N, 2N×N, N×2N, or N×N. The HM also supports asymmetric partitioning for inter-prediction in PU sizes of 2N×nU, 2N×nD, nL×2N, and nR×2N. In asymmetric partitioning, one direction of a CU is not partitioned, while the other direction is partitioned into 25% and 75%. The portion of the CU corresponding to the 25% partition is indicated by an “n” followed by an indication of “Up”, “Down,” “Left,” or “Right.” Thus, for example, “2N×nU” refers to a 2N×2N CU that is partitioned horizontally with a 2N×0.5N PU on top and a 2N×1.5N PU on bottom.
In this disclosure, “N×N” and “N by N” may be used interchangeably to refer to the pixel dimensions of a video block in terms of vertical and horizontal dimensions, e.g., 16×16 pixels or 16 by 16 pixels. In general, a 16×16 block will have 16 pixels in a vertical direction (y=16) and 16 pixels in a horizontal direction (x=16). Likewise, an N×N block generally has N pixels in a vertical direction and N pixels in a horizontal direction, where N represents a nonnegative integer value. The pixels in a block may be arranged in rows and columns. Moreover, blocks need not necessarily have the same number of pixels in the horizontal direction as in the vertical direction. For example, blocks may comprise N×M pixels, where M is not necessarily equal to N.
To code a block (e.g., a PU of video data), a predictor for the block is first derived. The predictor, also referred to as a predictive block, can be derived either through intra (I) prediction (i.e., spatial prediction) or inter (P or B) prediction (i.e. temporal prediction). Hence, some prediction units may be intra-coded (I) using spatial prediction with respect to reference samples in neighboring reference blocks in the same frame (or slice), and other prediction units may be uni-directionally inter-coded (P) or bi-directionally inter-coded (B) with respect to blocks of reference samples in other previously-coded frames (or slices). In each case, the reference samples may be used to form a predictive block for a block to be coded.
Upon identification of a predictive block, the difference between the original video data block and its predictive block is determined. This difference may be referred to as the prediction residual data, and indicates the pixel differences between the pixel values in the block to the coded and the pixel sample values in the predictive block selected to represent the coded block. To achieve better compression, the prediction residual data may be transformed, e.g., using a discrete cosine transform (DCT), an integer transform, a Karhunen-Loeve (K-L) transform, or another transform.
The residual data in a transform block, such as a TU, may be arranged in a two-dimensional (2D) array of pixel difference values residing in the spatial, pixel domain. A transform converts the residual pixel values into a two-dimensional array of transform coefficients in a transform domain, such as a frequency domain. For further compression, the transform coefficients may be quantized prior to entropy coding. Quantization generally refers to a process in which transform coefficients are quantized to possibly reduce the amount of data used to represent the coefficients. The quantization process may reduce the bit depth associated with some or all of the coefficients. For example, an n-bit value may be rounded down to an m-bit value during quantization, where n is greater than m.
To entropy code a block of quantized transform coefficients, a scanning process is usually performed so that the two-dimensional (2D) array of quantized transform coefficients in a block is rearranged, according to a particular scan order, into an ordered, one-dimensional (1D) array, i.e., vector, of transform coefficients. In some examples, a predefined scan order is used to scan the quantized transform coefficients to produce a serialized vector that can be entropy encoded. In other examples, an adaptive scan can be performed.
Entropy coding is then applied to the vector of transform coefficients. The scan of the quantized transform coefficients in a transform unit serializes the 2D array of transform coefficients for the entropy coder. A significance map may be generated to indicate the positions of significant (i.e., non-zero) coefficients. Scanning may be applied to scan levels of significant (i.e., nonzero) coefficients, and/or to code signs of the significant coefficients. An entropy coder applies entropy coding, such as Context Adaptive Variable Length Coding (CAVLC), Context Adaptive Binary Arithmetic Coding (CABAC), Probability Interval Partitioning Entropy Coding (PIPE), or the like, to the one-dimensional vector of scanned quantized transform coefficients.
To perform CABAC, a context within a context model is assigned to a symbol to be transmitted. The context may relate to, for example, whether neighboring values of the symbol are non-zero or not. To perform CAVLC, a variable length code is selected for a symbol to be transmitted. Codewords in VLC may be constructed such that relatively shorter codes correspond to more probable symbols, while longer codes correspond to less probable symbols. In this way, the use of VLC may achieve a bit savings over, for example, using equal-length codewords for each symbol to be transmitted. The probability determination may be based on a context assigned to the symbol.
In some cases, a transform may be skipped prior to coding residual data of a prediction residual block. In one example, the residual block may be coded using the lossy coding mode in a transform skip mode in which the transform is not applied to the residual block prior to coding the residual data of the residual block. In this case, quantization may still be performed on the residual data of the residual block. For example, HEVC uses a syntax element to indicate the transform skip mode for a TU, i.e., the transform_skip_flag syntax element. In another example, the residual block may be coded using the lossless coding mode in which both the transform and quantization are skipped to achieve lossless coding of the residual data in the residual block. For example, HEVC uses a syntax element to indicate the lossless coding mode for a CU, i.e., the cu_transquant_bypass_flag syntax element.
In JCTVC-J0093 (He, D. et al., “Rotation of Residual Block for Transform Skipping,” Joint Collaborative Team on Video Coding (JCT-VC) of ITU-T SG16 WP3 and ISO/IEC JTC1/SC29/WG11, 10th Meeting: Stockholm, Sweden, Jul. 11-20, 2012), it is proposed that when a transform is skipped for a residual block in the intra-prediction mode, the residual block is automatically rotated by 180 degrees before applying entropy coding of the residual data. A similar idea is proposed in JCTVC-J0053 (An, J. et al., “Residue Scan for Intra Transform Skip Mode,” Joint Collaborative Team on Video Coding (JCT-VC) of ITU-T SG16 WP3 and ISO/IEC JTC1/SC29/WG11, 10th Meeting: Stockholm, Sweden, Jul. 11-20, 2012) where the direction of scanning the residual data in the intra-prediction residual block (i.e., the pixel difference values) for entropy coding is automatically changed to achieve the same purpose. Similarly, in JCTVC-K0294 (Weerakkody, R. et al., “Mirroring of Coefficients for Transform Skipping,” Joint Collaborative Team on Video Coding (JCT-VC) of ITU-T SG16 WP3 and ISO/IEC JTC1/SC29/WG11, 11th Meeting: Shanghai, China, Oct. 10-19, 2012), it is proposed that, depending on the scan being used, residual data of the intra-prediction residual block is automatically flipped along the main diagonal or the anti-diagonal of the residual block.
Furthermore, in the lossless coding mode, a transform is always skipped for a residual block. JCTVC-J0093 proposes to extend the automatic rotation of the prediction residual block by 180 degrees to the lossless coding mode for both the intra-prediction and inter-prediction modes. Some of these ideas are also discussed in JCTVC-J0468 (Tsukuba et al., “Combination of JCTVC-J0069 and JCTVC-J0093,” Joint Collaborative Team on Video Coding (JCT-VC) of ITU-T SG 16 WP 3 and ISO/IEC JTC 1/SC 29/WG 11, 10th Meeting, Stockholm, Sweden, July 2012), and JCTVC-M0333 (Sole et al., “AhG8: Residual rotation and significance map context for screen content coding,” Joint Collaborative Team on Video Coding (JCT-VC) of ITU-T SG 16 WP 3 and ISO/IEC JTC 1/SC 29/WG 11, 13th Meeting, Incheon, KR, April 2013). The methods proposed in JCTVC-J0053 and JCTVC-K0294 can also be extended to the lossless coding mode for both the intra-prediction and inter-prediction modes.
In intra-coding, the samples from which prediction is performed are positioned on the left side or the top side of a video block. As the distance of the predicted samples from the top side and the left side increases, the prediction error tends to increase. For this reason, the residual data sample values at the bottom right corner of the residual block typically have higher absolute magnitudes compared to those at the top left corner. Transform coefficient coding, i.e., entropy coding, is designed assuming that higher energy residual data is concentrated in the top left corner. For intra-prediction residual blocks, therefore, the automatic rotation of the residual video block by 180 degrees is effective to improve entropy coding efficiency when the lossy coding mode in the transform skip mode is used.
Residual blocks coded in the lossless mode, however, may use intra-prediction residual blocks or inter-prediction residual blocks. For inter-prediction residual blocks, the residual data does not possess the property described above for intra-prediction residual blocks. It may not always be desirable to perform the automatic rotation by 180 degrees for inter-prediction residual blocks.
The techniques of this disclosure include, based on a transform being skipped for a residual block, determining whether or not to rotate the residual block prior to coding residual data of the residual block. In some examples, a rotation value for the residual block may be explicitly signaled in a bitstream between video encoder 20 and video decoder 30. In other examples, video encoder 20 and the video decoder 30 may each independently determine whether to rotate the residual block based on a type of boundary at two or more edges of the residual block.
In JCTVC-G281 (An, J. et al., “Non-CE7: Boundary-Dependent Transform for Inter-Predicted Residue,” Joint Collaborative Team on Video Coding (JCT-VC) of ITU-T SG16 WP3 and ISO/IEC JTC1/SC29/WG11, 7th Meeting: Geneva, Switzerland, Nov. 21-30, 2011), the following observation was made regarding the energy of inter-predicted residual data. For a residual block that comprises a TU, if a neighboring block at a particular edge (top, bottom, left or right) of the residual block belongs to the same PU as the residual block, i.e., the neighboring block is a TU belonging to the same PU, the particular edge is a TU boundary and the residual data at the TU boundary typically has lower energy than average residual data of the residual block. On the other hand, if a neighboring block at a particular edge of the residual video block belongs to a different PU than the residual block, i.e., the neighboring block is a TU belonging to a different PU, the particular edge is a PU boundary and the residual data at the TU boundary typically has higher energy than average residual data of the residual block. In this disclosure, a level of energy of residual data at an edge of the residual block is proportional to the size of the residual data, i.e., the absolute magnitude of pixel differences for the residual data sample values at the edge of the residual video block.
Based on the above observation, the techniques of this disclosure include rotating an inter-prediction residual block with transform skipping based on a type of boundary at two or more edges of the residual block. According to the techniques, a rotation unit included in a video encoder or a video decoder determines a type of boundary at two or more edges of the residual block, and then determines, based on the type of boundary at the edges, whether to rotate the residual block in order to position the residual data at the PU boundaries of the original residual block at a top left corner of the rotated residual block. The techniques may be performed by a video coder, such as video encoder 20 or video decoder 30.
In some examples, the rotation unit determines to either rotate the residual block by a predetermined rotation value, e.g., 180 degrees, or not rotate the residual block. In other examples, the rotation unit determines a rotation value by which to rotate the residual block from two or more rotation values, e.g., 0 degrees or no rotation, 180 degrees, 90 degrees or 270 degrees. On the encoding side, the rotation is selected to position the residual data with higher energy than average at a top left corner of the rotated residual block prior to encoding the residual data of the residual block to improve entropy coding efficiency. On the decoding side, the rotation reverses the rotation performed during encoding and returns the residual data with higher energy than average to its original position in the original residual block in order to reconstruct a video block from the residual block using a predictive block.
FIG. 2 is a block diagram illustrating an example video encoder 20 that may implement the techniques described in this disclosure to determine whether to rotate a residual block prior to encoding residual data of the residual block. Video encoder 20 may perform intra- and inter-coding of video blocks within video slices. Intra-coding relies on spatial prediction to reduce or remove spatial redundancy in video within a given video frame or picture. Inter-coding relies on temporal prediction to reduce or remove temporal redundancy in video within adjacent frames or pictures of a video sequence. Intra-mode (I mode) may refer to any of several spatial based compression modes. Inter-modes, such as uni-directional prediction (P mode) or bi-prediction (B mode), may refer to any of several temporal-based compression modes.
In the example of FIG. 2, video encoder 20 includes a partitioning unit 35, prediction processing unit 41, reference picture memory 64, summer 50, transform processing unit 52, quantization unit 54, rotation unit 66 and entropy encoding unit 56. Prediction processing unit 41 includes motion estimation unit 42, motion compensation unit 44, and intra prediction processing unit 46. For video block reconstruction, video encoder 20 also includes inverse quantization unit 58, inverse transform processing unit 60, and summer 62. A deblocking filter (not shown in FIG. 2) may also be included to filter block boundaries to remove blockiness artifacts from reconstructed video. If desired, the deblocking filter would typically filter the output of summer 62. Additional loop filters (in loop or post loop) may also be used in addition to the deblocking filter.
As shown in FIG. 2, video encoder 20 receives video data, and partitioning unit 35 partitions the data into video blocks. This partitioning may also include partitioning into slices, tiles, or other larger units, as wells as video block partitioning, e.g., according to a quadtree structure of LCUs and CUs. Video encoder 20 generally illustrates the components that encode video blocks within a video slice to be encoded. The slice may be divided into multiple video blocks (and possibly into sets of video blocks referred to as tiles). Prediction processing unit 41 may select one of a plurality of possible coding modes, such as one of a plurality of intra coding modes or one of a plurality of inter coding modes, for the current video block based on error results (e.g., coding rate and the level of distortion). Prediction processing unit 41 may provide the resulting intra- or inter-coded block to summer 50 to generate residual block data and to summer 62 to reconstruct the encoded block for use as a reference picture.
Intra prediction processing unit 46 within prediction processing unit 41 may perform intra-predictive coding of the current video block relative to one or more neighboring blocks in the same frame or slice as the current block to be coded to provide spatial compression. Motion estimation unit 42 and motion compensation unit 44 within prediction processing unit 41 perform inter-predictive coding of the current video block relative to one or more predictive blocks in one or more reference pictures to provide temporal compression.
Motion estimation unit 42 may be configured to determine the inter-prediction mode for a video slice according to a predetermined pattern for a video sequence. The predetermined pattern may designate video slices in the sequence as P slices or B slices. Motion estimation unit 42 and motion compensation unit 44 may be highly integrated, but are illustrated separately for conceptual purposes. Motion estimation, performed by motion estimation unit 42, is the process of generating motion vectors, which estimate motion for video blocks. A motion vector, for example, may indicate the displacement of a PU of a video block within a current video frame or picture relative to a predictive block within a reference picture.
A predictive block is a block that is found to closely match the PU of the video block to be coded in terms of pixel difference, which may be determined by sum of absolute difference (SAD), sum of square difference (SSD), or other difference metrics. In some examples, video encoder 20 may calculate values for sub-integer pixel positions of reference pictures stored in reference picture memory 64. For example, video encoder 20 may interpolate values of one-quarter pixel positions, one-eighth pixel positions, or other fractional pixel positions of the reference picture. Therefore, motion estimation unit 42 may perform a motion search relative to the full pixel positions and fractional pixel positions and output a motion vector with fractional pixel precision.
Motion estimation unit 42 calculates a motion vector for a PU of a video block in an inter-coded slice by comparing the position of the PU to the position of a predictive block of a reference picture. The reference picture may be selected from a first reference picture list (List 0) or a second reference picture list (List 1), each of which identify one or more reference pictures stored in reference picture memory 64. Motion estimation unit 42 sends the calculated motion vector to entropy encoding unit 56 and motion compensation unit 44.
Motion compensation, performed by motion compensation unit 44, may involve fetching or generating the predictive block based on the motion vector determined by motion estimation, possibly performing interpolations to sub-pixel precision. Upon receiving the motion vector for the PU of the current video block, motion compensation unit 44 may locate the predictive block to which the motion vector points in one of the reference picture lists. Video encoder 20 forms a residual video block by subtracting pixel values of the predictive block from the pixel values of the current video block being coded, forming pixel difference values. The pixel difference values form residual data for the block, and may include both luma and chroma difference components. Summer 50 represents the component or components that perform this subtraction operation. Motion compensation unit 44 may also generate syntax elements associated with the video blocks and the video slice for use by video decoder 30 in decoding the video blocks of the video slice.
Intra-prediction processing unit 46 may intra-predict a current block, as an alternative to the inter-prediction performed by motion estimation unit 42 and motion compensation unit 44, as described above. In particular, intra-prediction processing unit 46 may determine an intra-prediction mode to use to encode a current block. In some examples, intra-prediction processing unit 46 may encode a current block using various intra-prediction modes, e.g., during separate encoding passes, and intra-prediction processing unit 46 may select an appropriate intra-prediction mode to use from the tested modes. For example, intra-prediction processing unit 46 may calculate rate-distortion values using a rate-distortion analysis for the various tested intra-prediction modes, and select the intra-prediction mode having the best rate-distortion characteristics among the tested modes. Rate-distortion analysis generally determines an amount of distortion (or error) between an encoded block and an original, unencoded block that was encoded to produce the encoded block, as well as a bit rate (that is, a number of bits) used to produce the encoded block. Intra-prediction processing unit 46 may calculate ratios from the distortions and rates for the various encoded blocks to determine which intra-prediction mode exhibits the best rate-distortion value for the block.
In any case, after selecting an intra-prediction mode for a block, intra-prediction processing unit 46 may provide information indicative of the selected intra-prediction mode for the block to entropy coding unit 56. Entropy coding unit 56 may encode the information indicating the selected intra-prediction mode in accordance with the techniques of this disclosure. Video encoder 20 may include in the transmitted bitstream configuration data, which may include a plurality of intra-prediction mode index tables and a plurality of modified intra-prediction mode index tables (also referred to as codeword mapping tables), definitions of encoding contexts for various blocks, and indications of a most probable intra-prediction mode, an intra-prediction mode index table, and a modified intra-prediction mode index table to use for each of the contexts.
After prediction processing unit 41 generates the predictive block for the current video block via either inter-prediction or intra-prediction, video encoder 20 forms residual video blocks by subtracting the predictive block from the current video block. Residual data in the residual video blocks comprise pixel difference values between the current video block to be coded and the predictive block. The residual video blocks may comprise one or more TUs that include at least a portion of the residual data for the video block. When the video block is coded using the lossy coding mode, each of the residual blocks are applied to transform processing unit 52. Transform processing unit 52 transforms the residual data into residual transform coefficients using a transform, such as a discrete cosine transform (DCT) or a conceptually similar transform. Transform processing unit 52 may convert the residual video data from a pixel domain to a transform domain, such as a frequency domain.
Transform processing unit 52 may send the resulting transform coefficients to quantization unit 54. Quantization unit 54 quantizes the transform coefficients to further reduce bit rate. The quantization process may reduce the bit depth associated with some or all of the coefficients. The degree of quantization may be modified by adjusting a quantization parameter. In some examples, quantization unit 54 may then perform a scan of the matrix including the quantized transform coefficients. Alternatively, entropy encoding unit 56 may perform the scan.
When the video block is coded using the lossy coding mode in a transform skip mode, a transform is not applied to the residual blocks. Moreover, when the video block is coded using the lossless coding mode, neither a transform nor quantization is applied to the residual blocks. According to the techniques of this disclosure, when the transform is skipped for a residual block, the residual block is applied to rotation unit 66. In this case, the residual data remains in the pixel domain and comprises pixel difference values at spatial pixel positions. This is opposed to converting the residual data to the transform domain as transform coefficients at positions corresponding to frequency components using transform processing unit 52.
Rotation unit 66 determines whether or not to rotate the residual block to position residual data with higher energy, i.e., larger pixel difference values, than average in a top left corner of the residual block. The shifting of high energy residual data typically occurs as a result of the transform process performed by transform processing unit 52. When the transform is skipped, however, it may be desirable to rotate the residual block because entropy encoding unit 56 was designed based on the assumption that high energy residual data would be concentrated at a top left corner of a transformed residual block.
In the case of intra-prediction residual blocks, rotation unit 66 may automatically rotate the residual blocks by 180 degrees to position the residual data with higher energy than average at the top left corner of the residual block. When a transform is skipped for intra-prediction residual blocks, the high energy residual data typically concentrates at the bottom right corner such that the 180 degree rotation will improve entropy coding efficiency. In the case of inter-prediction residual blocks, the high energy residual data may be concentrated at any position within the residual blocks. In that case, rotation unit 66 may first determine whether to rotate the residual block and then, based on the determination, either rotate the residual block by a determined rotation value or not rotate the residual block. In some examples, rotation unit 66 may apply the determined rotation value to the residual block in a counterclockwise direction. Example operations for determining whether to rotate an inter-prediction residual block are described in more detail below with respect to FIGS. 5-8.
For the lossy coding mode in the transform skip mode, rotation unit 66 sends the rotated residual block to quantization unit 54 for further compression prior to entropy encoding by entropy encoding unit 56. In some cases, the residual block may be sent to quantization unit 54 before determining whether to rotate the residual block with rotation unit 66. For the lossless coding mode, rotation unit 66 sends the rotated residual block directly to entropy encoding unit 56 for entropy encoding without any further compression.
Entropy encoding unit 56 entropy encodes residual coefficients, e.g., quantized transform coefficients, quantized residual coefficients or uncompressed residual coefficients. For example, entropy encoding unit 56 may perform context adaptive variable length coding (CAVLC), context adaptive binary arithmetic coding (CABAC), syntax-based context-adaptive binary arithmetic coding (SBAC), probability interval partitioning entropy (PIPE) coding or another entropy encoding methodology or technique. Following the entropy encoding by entropy encoding unit 56, the encoded bitstream may be transmitted to a video decoder, e.g., video decoder 30, or archived for later transmission or retrieval by a video decoder. Entropy encoding unit 56 may also entropy encode the motion vectors and the other syntax elements for the current video slice being coded.
Inverse quantization unit 58 and inverse transform processing unit 60 apply inverse quantization and inverse transformation, respectively, to the quantized transform coefficients in order to reconstruct the residual block in the pixel domain for later use as a reference block of a reference picture. For the lossy coding mode in the transform skip mode, inverse quantization unit 58 applies inverse quantization to the quantized residual coefficients and rotation unit 66 performs a reverse rotation to return the high energy residual data back to its original position in order to reconstruct the residual block. In some cases, the quantized residual coefficients may be sent to rotation unit 66 to perform the reverse rotation before performing inverse quantization with inverse quantization unit 58. For the lossless coding mode, rotation unit 66 performs a reverse rotation of the residual coefficients to return the high energy residual data back to its original position in order to reconstruct the residual block.
Motion compensation unit 44 may then calculate a reference block by adding the reconstructed residual block to a predictive block of one of the reference pictures within one of the reference picture lists. Motion compensation unit 44 may also apply one or more interpolation filters to the reconstructed residual block to calculate sub-integer pixel values for use in motion estimation. Summer 62 adds the reconstructed residual block to the motion compensated prediction block produced by motion compensation unit 44 to produce a reference block for storage in reference picture memory 64. The reference block may be used by motion estimation unit 42 and motion compensation unit 44 as a reference block to inter-predict a block in a subsequent video frame or picture.
Video encoder 20 may be configured to perform the techniques of this disclosure, including skipping a transform for a residual block, and determining whether to rotate the residual block. Rotation unit 66 of video encoder 20 may determine whether or not to rotate the residual block. In some examples, rotation unit 66 determines whether to rotate the residual block based on the number of bits needed to entropy encode the residual block. For example, rotation unit 66 may determine whether to rotate the residual block based on the rotation value that results in the lowest number of bits for entropy encoding. In other examples, rotation unit 66 may determine whether to rotate the residual block based on a type of boundary at two or more edges of the residual block.
When the residual block is rotated, rotation unit 66 of video encoder 20 may determine to rotate the residual block by a predetermined rotation value, or may determine a rotation value by which to rotate the residual block. In either case, video encoder 20 then rotates the residual block by the determined rotation value prior to encoding the residual data of the residual block with entropy encoding unit 56. Example operations for determining whether to rotate an inter-prediction residual block based on the type of boundary at the edges of the residual block are described in more detail below with respect to FIGS. 5-8.
In some examples, video encoder 20 may only signal whether transform skipping is used for the residual block, i.e., whether the residual block is encoded using the lossless coding mode or using the lossy coding mode in the transform skip mode. In this case, a video decoder may use the same operation of determining the type of boundary at the edges of the residual block to determine whether to rotate the residual block to reverse the rotation performed during encoding in order to reconstruct the video block from the residual block. In other examples, video encoder 20 may signal a rotation value of the rotation applied to the residual block during encoding to a video decoder. In this case, the video decoder may rotate the residual block based on the signaled rotation value to reverse the rotation performed during encoding in order to reconstruct the video block from the residual block.
In some additional examples, video encoder 20 is configured to perform the techniques of this disclosure, including skipping a transform for a residual block and rotating the residual block when a size of the residual block is less than or equal to a threshold block size. The threshold block size may be equal to a block size for which transform skipping and rotation is allowed in the lossy coding mode. In this way, the block sizes for which rotation may be performed are aligned, i.e., the same, for residual blocks coded using either the lossless coding mode or the lossy coding mode in the transform skip mode. This technique may be applicable to both inter-prediction residual blocks and intra-prediction residual block.
Furthermore, video encoder 20 may be configured to perform the techniques of this disclosure, including skipping a transform for a residual block, and flipping residual data sample values along a diagonal of the residual block when a size of the residual block is less than or equal to the threshold block size. Flipping the residual data sample values of the residual block includes swapping residual data sample values on one side of a diagonal with residual data sample values at corresponding mirror image locations on the other side of the diagonal of the residual block. This technique may also be applicable to both inter-prediction residual blocks and intra-prediction residual block.
In some examples, in the case of the lossless coding mode, the rotation or flipping may be applied only to intra-prediction residual blocks with sizes less than or equal to the threshold block size. In other examples, the rotation of flipping may be applied to all residual blocks, i.e., intra-prediction and inter-prediction residual blocks, with sizes less than or equal to the threshold block size. In addition examples, in the case of the lossy coding mode in the transform skip mode, the rotation or flipping may be applied only to intra-prediction residual blocks, or may be applied to both intra-prediction and inter-prediction residual blocks.
FIG. 3 is a block diagram illustrating an example video decoder 30 that may implement the techniques described in this disclosure to determine whether to rotate a residual block prior to reconstructing a video block from residual data of the residual block. In the example of FIG. 3, video decoder 30 includes an entropy decoding unit 80, prediction processing unit 81, inverse quantization unit 86, inverse transformation unit 88, rotation unit 94, summer 90, and reference picture memory 92. Prediction processing unit 81 includes motion compensation unit 82 and intra prediction processing unit 84. Video decoder 30 may, in some examples, perform a decoding pass generally reciprocal to the encoding pass described with respect to video encoder 20 from FIG. 2.
During the decoding process, video decoder 30 receives an encoded video bitstream that represents video blocks of an encoded video slice and associated syntax elements from a video encoder, such as video encoder 20. Entropy decoding unit 80 of video decoder 30 entropy decodes the bitstream to generate residual coefficients, motion vectors, and other syntax elements. Entropy decoding unit 80 forwards the motion vectors and other syntax elements to prediction processing unit 81. Video decoder 30 may receive the syntax elements at the video slice level and/or the video block level.
When the video slice is coded as an intra-coded (I) slice, intra prediction processing unit 84 of prediction processing unit 81 may generate prediction data for a video block of the current video slice based on a signaled intra prediction mode and data from previously decoded blocks of the current frame or picture. When the video frame is coded as an inter-coded (i.e., B or P) slice, motion compensation unit 82 of prediction processing unit 81 produces predictive blocks for a video block of the current video slice based on the motion vectors and other syntax elements received from entropy decoding unit 80. The predictive blocks may be produced from one of the reference pictures within one of the reference picture lists. Video decoder 30 may construct the reference frame lists, List 0 and List 1, using default construction techniques based on reference pictures stored in reference picture memory 92.
Motion compensation unit 82 determines prediction information for a video block of the current video slice by parsing the motion vectors and other syntax elements, and uses the prediction information to produce the predictive blocks for the current video block being decoded. For example, motion compensation unit 82 uses some of the received syntax elements to determine a prediction mode (e.g., intra- or inter-prediction) used to code the video blocks of the video slice, an inter-prediction slice type (e.g., B slice or P slice), construction information for one or more of the reference picture lists for the slice, motion vectors for each inter-encoded video block of the slice, inter-prediction status for each inter-coded video block of the slice, and other information to decode the video blocks in the current video slice.
Motion compensation unit 82 may also perform interpolation based on interpolation filters. Motion compensation unit 82 may use interpolation filters as used by video encoder 20 during encoding of the video blocks to calculate interpolated values for sub-integer pixels of reference blocks. In this case, motion compensation unit 82 may determine the interpolation filters used by video encoder 20 from the received syntax elements and use the interpolation filters to produce predictive blocks.
As described above, entropy decoding unit 80 entropy decodes the bitstream to generate residual coefficients, e.g., quantized transform coefficients, quantized residual coefficients or uncompressed residual coefficients, of a video block. When the video block is coded using the lossy coding mode, inverse quantization unit 86 inverse quantizes, i.e., de-quantizes, the quantized transform coefficients of the residual block provided in the bitstream. The inverse quantization process may include use of a quantization parameter calculated for each video block in the video slice to determine a degree of quantization and, likewise, a degree of inverse quantization that should be applied. Inverse transform processing unit 88 applies an inverse transform, e.g., an inverse DCT, an inverse integer transform, or a conceptually similar inverse transform process, to the transform coefficients in order to reconstruct the residual blocks in the pixel domain.
When the video block is coded using the lossy coding mode in a transform skip mode, an inverse transform is not applied to the residual blocks. Moreover, when the video block is coded using the lossless coding mode, neither an inverse transform nor dequantization is applied to the residual blocks. According to the techniques of this disclosure, when the inverse transform is skipped for residual coefficients of a residual block, the residual block is applied to rotation unit 94. In this case, the residual data remains in the pixel domain and comprises pixel difference values at spatial pixel positions. This is opposed to converting the residual data from the transform domain as transform coefficients at positions corresponding to frequency components using inverse transform processing unit 88.
Rotation unit 94 may rotate the residual block in order to reverse rotation performed during encoding that positioned residual data with higher energy, i.e., larger pixel difference values, than average in a top left corner of the residual block. The shifting of high energy residual data back to its original position typically occurs as a result of the inverse transform process performed by inverse transform processing unit 88. When the inverse transform is skipped, however, it may be necessary to rotate the residual block to properly reconstruct the video block using a predictive block.
For the lossy coding mode in the transform skip mode, inverse quantization unit 86 applies inverse quantization to the quantized residual coefficients of the residual block provided in the bitstream for decompression. Rotation unit 94 then performs a rotation to reverse the rotation performed during encoding and return the high energy residual data back to its original position in order to reconstruct the residual block. In some cases, the quantized residual coefficients may be sent to rotation unit 94 to perform the reverse rotation before performing inverse quantization with inverse quantization unit 86. For the lossless coding mode, rotation unit 94 directly receives the residual coefficients of the residual block provided in the bitstream without any decompression. Rotation unit 94 then performs a rotation to reverse the rotation performed during encoding and return the high energy residual data back to its original position in order to reconstruct the residual block. In this manner, the pixel difference values are rotated back to the original spatial positions of the corresponding pixels.
In the case of intra-prediction residual blocks with transform skipping, the high energy residual data typically concentrates at the bottom right corner such that a 180-degree rotation during encoding will improve entropy coding efficiency. In this case, rotation unit 94 may automatically rotate the intra-prediction residual blocks by 180 degrees to return the residual data with higher energy than average back to its position at the bottom right corner of the original residual block.
In the case of inter-prediction residual blocks, the high energy residual data may be concentrated at any position within the residual blocks. In this case, rotation unit 94 first determines whether to rotate the residual block and then, based on the determination, either rotates the residual block by a determined rotation value or does not rotate the residual block. In order to reverse rotation performed on the residual block during encoding, rotation unit 94 determines whether to rotate the residual block, but applies the determined rotation value in an opposite direction than rotation unit 66 of video encoder 20 from FIG. 2, e.g., in the clockwise direction as opposed to the counterclockwise direction.
After motion compensation unit 82 generates the predictive block for the current video block based on the motion vectors and other syntax elements, video decoder 30 forms a decoded video block by summing the reconstructed residual blocks with the corresponding predictive blocks generated by motion compensation unit 82. More specifically, the pixel difference values of the residual block are summed with corresponding predictive pixel values of the corresponding predictive blocks. This summation process is performed for both luma and chroma blocks in order to reconstruct the entire video block. Summer 90 represents the component or components that perform this summation operation. If desired, a deblocking filter may also be applied to filter the decoded blocks in order to remove blockiness artifacts. Other loop filters (either in the coding loop or after the coding loop) may also be used to smooth pixel transitions, or otherwise improve the video quality. The decoded video blocks in a given frame or picture are then stored in reference picture memory 92, which stores reference pictures used for subsequent motion compensation. Reference picture memory 92 also stores decoded video for later presentation on a display device, such as display device 32 of FIG. 1.
Video decoder 30 may be configured to perform the techniques of this disclosure, including skipping an inverse transform for a residual block, and determining whether to rotate the residual block. Rotation unit 94 of video decoder 30 may determine whether or not to rotate the residual block. In some examples, rotation unit 94 determines whether to rotate the residual block based on syntax elements in the bitstream that indicate a rotation value for the residual block used at video encoder 20. In other examples, rotation unit 94 may determine whether to rotate the residual block based on a type of boundary at two or more edges of the residual block.
When the residual block is rotated, rotation unit 94 of video decoder 30 may determine to rotate the residual block by a predetermined rotation value, or may determine a rotation value by which to rotate the residual block. In either case, video decoder 30 then rotates the residual block by the determined rotation value prior to reconstructing a video block from the residual block using a predictive block. Example operations for determining whether to rotate an inter-prediction residual block based on the type of boundary at the edges of the residual block are described in more detail below with respect to FIGS. 5-8.
In some examples, video decoder 30 may receive syntax elements that only indicate whether transform skipping is used for the residual block, i.e., whether the residual block is encoded using the lossless coding mode or using the lossy coding mode in the transform skip mode. In this case, rotation unit 94 uses the same operation as video encoder 20 to determine a type of boundary at the edges of the residual block to determine whether to rotate the residual block to reverse the rotation performed during encoding in order to reconstruct the video block from the residual block. In other examples, video decoder 30 may receive syntax elements that indicate a rotation value of the rotation, e.g., 0, 90, 180 or 270 degrees, applied to the residual block during encoding. In this case, rotation unit 94 may rotate the residual block based on the signaled rotation value to reverse the rotation performed during encoding, e.g., by rotating 0, 90, 180 or 270 degrees in an opposite direction, in order to reconstruct the video block from the residual block. Example operations for determining whether to rotate an inter-prediction residual block are described in more detail below with respect to FIGS. 5-8.
In some additional examples, video decoder 30 is configured to perform the techniques of this disclosure, including skipping a transform for a residual block and rotating the residual block when a size of the residual block is less than or equal to a threshold block size. The threshold block size may be equal to a block size for which transform skipping and rotation is allowed in the lossy coding mode. In this way, the block sizes for which rotation may be performed are aligned, i.e., the same, for residual blocks coded using either the lossless coding mode or the lossy coding mode in the transform skip mode. This technique may be applicable to both inter-prediction residual blocks and intra-prediction residual block.
Furthermore, video decoder 30 may be configured to perform the techniques of this disclosure, including skipping a transform for a residual block, and flipping residual data sample values along a diagonal of the residual block when a size of the residual block is less than or equal to a threshold block size. Flipping the residual data sample values of the residual block includes swapping residual data sample values on one side of a diagonal with residual data sample values at corresponding mirror image locations on the other side of the diagonal of the residual block. This technique may be applicable to both inter-prediction residual blocks and intra-prediction residual block.
In some examples, in the case of the lossless coding mode, the rotation or flipping may be applied only to intra-prediction residual blocks with sizes less than or equal to the threshold block size. In other examples, the rotation of flipping may be applied to all residual blocks, i.e., intra-prediction and inter-prediction residual blocks, with sizes less than or equal to the threshold block size. In addition examples, in the case of the lossy coding mode in the transform skip mode, the rotation or flipping may be applied only to intra-prediction residual blocks, or may be applied to both intra-prediction and inter-prediction residual blocks.
FIG. 4 is a block diagram illustrating a CU 100 of a residual block partitioned into one or more PUs 102, 104 according to a motion prediction mode and multiple TUs 110, 112, 114, 116 according to a quad-tree data structure. In FIG. 4, PU boundaries are illustrated as bold, solid lines around the edge of PUs 102 and 104. A PU boundary comprises a boundary between two TUs that belong to different PUs, e.g., the boundary between TU 110 within PU 102 and TU 114 within PU 104. In FIG. 4, TU boundaries are illustrates as bold, dashed lines between TU 110 and TU 112 within PU 102, and between TU 114 and TU 116 within PU 104. A TU boundary comprises a boundary between two TUs that belong to the same PU, e.g., the boundary between TU 110 and TU 112 within PU 102
In general, this disclosure describes techniques for coding residual data of a prediction residual block, e.g., TU 112, with transform skipping. The residual data of TU 112 comprises pixel difference values between a portion of a video block and an associated prediction block. A transform may be skipped for TU 112 when TU 112 is coded using either a lossless coding mode or a lossy coding mode in a transform skip mode. Without applying a transform to TU 112, the residual data with higher energy, i.e., larger pixel difference values, than average may not be positioned at a top left corner of TU 112, which is expected for entropy coding.
In the intra-prediction mode, when a transform is skipped for a residual block, the residual data with higher energy than average is typically positioned at a bottom right corner of the intra-prediction residual block. In some cases, the intra-prediction residual block may be automatically rotated by 180 degrees prior to coding the residual block in order to position the residual data with higher energy than average at the top left corner of the residual block. In the inter-prediction mode, however, it may not always be desirable to automatically rotate the residual block by 180 degrees.
The following observation has been made regarding the energy of residual data of an inter-prediction residual block. Residual data at a TU boundary of the inter-prediction residual block typically has lower energy than average residual data in the residual block. Further, residual data at a PU boundary of the inter-prediction residual block typically has higher energy than average residual data in the residual block. Based on this observation, the techniques of this disclosure include rotating an inter-prediction residual block with transform skipping, e.g., TU 112, based on a type of boundary at two or more edges of TU 112.
According to the techniques of this disclosure, when a transform is skipped for TU 112, a rotation unit (e.g., rotation unit 66 of video encoder 20 from FIG. 2 or rotation unit 94 of video decoder 30 from FIG. 3) may determine a type of boundary at two or more edges of TU 112, and then determine whether to rotate TU 112 in order to position the residual data at the PU boundaries of the original-version of TU 112 at a top left corner of the rotated-version of TU 112. In some cases, the techniques may only be applied to inter-prediction residual blocks coded using the lossless coding mode or the lossy coding mode in a transform skip mode. In that case, intra-predicted residual blocks coded using the lossless coding mode or the lossy coding mode in the transform skip mode may automatically be rotated by 180 degrees prior to coding the residual data in the residual video blocks. In other cases, the techniques may also be applied to both inter-prediction and intra-prediction residual blocks coded using the lossless coding mode or the lossy coding mode in the transform skip mode.
In some examples, the techniques include determining to either rotate TU 112 by a predetermined rotation value, e.g., 180 degrees, or not rotate TU 112. In other examples, the techniques include determining a rotation value by which to rotate TU 112 from two or more rotation values, e.g., 0 degrees or no rotation, 180 degrees, 90 degrees or 270 degrees. On the encoding side, the rotation is performed to position the residual data with higher energy than average at a top left corner of the rotated-version of TU 112 prior to encoding the residual data of TU 112 to improve entropy coding efficiency. In some cases, the rotations may be performed in the counterclockwise direction on the encoding side. On the decoding side, the rotation is performed to reverse the rotation performed during encoding and return the residual data with higher energy than average to its original position in TU 112 in order to reconstruct a video block from TU 112 using a predictive block. In some cases, the rotations may be performed in the clockwise direction on the decoding side.
In a first example of the techniques of this disclosure, an intra-prediction residual block for which a transform is skipped is automatically rotated by 180 degrees prior to coding the residual data of the residual blocks. Conversely, no rotation is applied for inter-prediction residual blocks, e.g., TU 112, regardless of whether the transform is skipped.
In a second example of the techniques of this disclosure, a residual block may either be rotated by 180 degrees or not rotated, depending on a type of boundary at the edges of the residual block. Limiting rotation to 0 or 180 degrees may be desirable because rotation by 90 degrees or 270 degrees is difficult to implement in hardware because it may require a transpose buffer. In general, if the left and top edges of the residual block are PU boundaries, e.g., TU 110, the residual data in the top left corner is likely to have higher energy than average residual data in TU 110. In that case, a rotation of TU 110 by 180 degrees may not be desirable because the high energy residual data is already concentrated at the top left corner of TU 110. Therefore, a video coding device may determine to not perform rotation of TU 110. If, however, the left and top edges of the residual block are TU boundaries and the right and bottom edges of the residual video block are PU boundaries, then a rotation by 180 degrees may be desirable in order to position the high energy residual data in the top left corner of the rotated-version of the residual block. Therefore, a video coding device may determine to rotate that residual block by 180 degrees.
According to the techniques of this disclosure, a rotation unit of a video coding device may classify each edge of a residual block as a PU boundary or a TU boundary. The rotation unit then applies a rule to determine whether to rotate the residual block by 180 degrees. If the number of PU boundaries on the right and bottom edges of the residual block is greater than the number of PU boundaries on the left and top edges of the residual block, the rotation unit determines to rotate the residual block by 180 degrees. Table 1, below, shows the combinations of edge classifications for which the rotation by 180 degrees would be performed. For the remaining combinations, the rotation unit of the video coding device determines to not perform rotation for the residual block. In case where the number of PU boundaries for the left and top edges is equal to the number PU boundaries at the bottom and right edges of the residual block, the rotation unit of the video coding device may determine to either rotate the residual block by 180 degrees or not rotate the residual block.










TABLE 1









Boundary














Left
Top
Right
Bottom
Rotation







TU
TU
PU
PU
180 degrees



TU
TU
TU
PU
180 degrees



TU
TU
PU
TU
180 degrees



TU
PU
PU
PU
180 degrees



PU
TU
PU
PU
180 degrees










As an example, the rotation unit of the video coding device may determine whether to rotate the residual block of TU 112, for example, by 180 degrees based on the type of boundary at each edge of TU 112. The rotation unit determines a first number of PU boundaries at a left edge and a top edge of TU 112 to be equal to one PU boundary, i.e., the top edge. The rotation unit also determines a second number of PU boundaries at a right edge and a bottom edge of TU 112 to be equal to two PU boundaries, i.e., both the right edge and the bottom edge. In this case, the second number of PU boundaries is greater than the first number of PU boundaries, so the rotation unit determines to rotate TU 112 by 180 degrees prior to coding the residual data of TU 112.
In a third example of the techniques of this disclosure, a rotation unit of a video coding device may consider up to four possible rotation values for each residual video block, i.e., 0 degrees or no rotation, 180 degrees, 90 degrees, and 270 degrees. In some cases, the rotation unit may only consider two of the rotation values, e.g., 0 degrees and 180 degrees, because rotation by 90 degrees or 270 degrees is difficult to implement in hardware because it may require a transpose buffer. In this example, therefore, only no rotation or rotation by 180 degrees is considered.
After applying each of the rotation values (0, 180, 90, and 270 degrees), the rotation unit calculates the number of PU boundaries at the left and top edges of the residual block for the respective one of the rotation values. Let these numbers of PU boundaries be denoted by n0, n180, n90, and n270. Similarly, after applying each of the rotation values (0, 180, 90, and 270 degrees), the rotation unit calculates the number of PU boundaries at the right and bottom edges of the residual block for the respective one of the rotation values. Let these numbers of PU boundaries be denoted by m0, m180, m90, and m270. The rotations may be performed in the counterclockwise direction on the encoding side, and the rotations may be performed in the clockwise direction on the decoding side.
According to these techniques, the rotation unit of the video coding device then calculates difference values between the number of PU boundaries at the left and top edges of the residual block and the right and bottom edges of the residual block for each of the rotation values, i.e., d0=(n0−m0), d90=(n90−m90), d180=(n180−m180), and d270=(n270−m270). The rotation unit determines the maximum difference value from the difference values d0, d90, d180, and d270 for all the rotation values. The rotation unit of the video coding device then determines to rotate the residual block by the rotation value corresponding to the maximum difference value.
If two or more of the difference values are equal to the maximum difference value, the rotation unit may select the rotation value to be applied to the residual block according to a predetermined order. One example of the predetermined order is: no rotation, rotation by 180 degrees, rotation by 90 degrees, and rotation by 270 degrees. In this example, if d0, d90, and d180 are all equal to the maximum difference value, no rotation is applied to the residual block. If d90 and d180 are both equal to the maximum difference value, the rotation value of 180 degrees is applied to the residual block. In other examples, different orders of selecting the rotation in the case of a maximum value tie may be used. Table 2, below, shows two combinations of boundary types for an original residual block and the resulting rotation values for the residual block.










TABLE 2









Boundary














Left
Top
Right
Bottom
Rotation







TU
PU
PU
TU
90 degrees







counterclockwise



PU
TU
TU
PU
270 degrees







counterclockwise










As an example, a rotation unit of a video coder may determine whether to rotate the residual video block of TU 112, for example, by 0 degrees, 180 degrees, 90 degrees counterclockwise, or 270 degrees counterclockwise, based on the type of boundary at each edge of TU 112. The rotation unit determines a first number of PU boundaries at a left edge and a top edge of TU 112 for each of the rotation values such that n0=1, n180=2, n90=2, and n270=1. The rotation unit then determines a second number of PU boundaries at a right edge and a bottom edge of TU 112 for each of the rotation values such that m0=2, n180=1, n90=1, and n270=2.
The rotation unit then calculates a difference value between the first number of PU boundaries and the second number of PU boundaries for each of the rotation values such that d0=−1, d180=1, d90=1, and d270=−1. The rotation unit next determines a maximum difference value from the difference values for all the rotation values of TU 112 to be equal to d180 and d90, which are both equal to 1. In the case of a tie, the rotation value of 180 degrees is selected over 90 degrees, according to the predetermined order described above. The rotation unit of the video coding device then determines to rotate the residual block by the rotation value with the maximum difference value, which is 180 degrees in this case, prior to coding the residual data in the residual video block.
FIG. 5 is a flowchart illustrating an exemplary operation of a video encoder determining whether to rotate a residual block prior to encoding residual data of the residual block. The operation is described with respect to video encoder 20 from FIG. 2. Video encoder 20 calculates the residual block from a video block using a predictive block from motion compensation unit 44 in the inter-prediction mode (120). In some examples, the residual block may be coded using a lossless coding mode in which both a transform and quantization are always skipped for the residual block. In other examples, the residual block may be coded using a lossy coding mode in a transform skip mode in which only the transform is skipped for the residual block.
In response to selecting to code the residual block using transform skipping, video encoder 20 skips performing the transform for the residual block at transform processing unit 52 (122). As one example, video encoder 20 may encode a syntax element, i.e., cu_transquant_bypass_flag, that indicates whether the residual block is coded using a lossless coding mode in which both a transform and quantization are always skipped for the residual block. In another example, video encoder 20 may encode a syntax element, i.e., transform_skip_flag, indicates whether a transform skip mode is used, in which only the transform is skipped, during coding of the residual block using a lossy coding mode.
According to the techniques, when the transform is skipped for the residual block, rotation unit 66 of video encoder 20 determines a type of boundary at each edge of the residual block (124). The type of boundary at a particular edge of the residual block indicates a level of energy of the residual data typically found at the particular edge of the residual block. Rotation unit 66 then determines whether to rotate the residual block based on the type of boundary at each edge (126). Rotation unit 66 may determine to rotate the residual block in order to position the residual data with higher energy than average at a top left corner of the residual block to improve entropy coding efficiency.
When rotation unit 66 determines to rotate the residual block (YES branch of 128), rotation unit 66 rotates the residual block by a determined rotation value (130). In some cases, described in more detail with respect to FIG. 7, the determined rotation value may be a static, predetermined rotation value, e.g., 180 degrees. In other cases, described in more detail with respect to FIG. 8, rotation unit 66 may determine the rotation value by which to rotate the residual block from a plurality of rotation values. The plurality of rotation values may include 180 degrees, 90 degrees counterclockwise or 270 degrees counterclockwise.
When rotation unit 66 determines to not rotate the residual block (NO branch of 128), rotation unit 66 does not rotate the residual block. Regardless of whether rotation unit 66 rotates the residual block, entropy encoding unit 56 encodes the residual data of the residual block (132). In some cases, e.g., the lossy coding mode in transform skip mode, the residual data of the residual block may be quantized using quantization unit 54 prior to entropy encoding by entropy encoding unit 56. It may also be possible to quantize the residual data of the residual block using quantization unit 54 prior to determining whether to rotate the residual block with rotation unit 66. In other cases, e.g., the lossless coding mode, both the transform and quantization are skipped and the residual data of the residual block is directly entropy encoded by entropy encoding unit 56 without any further compression.
Alternatively, instead of determining the type of boundary at each of the edges of the residual block and determining whether to rotate based on the type of boundary at the edges, rotation unit 66 may determine whether to rotate the residual block based on the number of bits needed to entropy encode the residual block. In this case, rotation unit 66 may apply one or more rotation values to the residual block and determine, for each rotation value, the number of bits needed to entropy encode the quantized residual coefficients included in the rotated residual block. Rotation unit 66 may then determine whether to rotate the residual block based on the rotation value that results in the lowest number of bits for entropy encoding.
In this alternative example, entropy encoding unit 56 may encode syntax elements that indicate whether to rotate the residual block. The video decoder does not have access to identical information to determine whether to rotate or the rotation value for the residual block. The rotation value, therefore, needs to be signaled explicitly in the bitstream. In case of only two possible rotation values, i.e., 0 degrees or no rotation and 180 degrees, one bit is sufficient to signal the rotation value. Entropy encoding unit 56 may CABAC code the bit using a context or in bypass mode. In case of four possible rotation value, i.e., 0 degrees, 180 degrees, 90 degrees counterclockwise, or 270 degrees counterclockwise, two bits may be used to signal the rotation value. Entropy encoding unit 56 may CABAC code the two bits using a context or in bypass mode.
FIG. 6 is a flowchart illustrating an exemplary operation of a video decoder determining whether to rotate a residual block prior to reconstructing a video block from residual data of the residual block. The operation is described with respect to video decoder 30 from FIG. 3. Entropy decoding unit 80 of video decoder 30 decodes residual data of the residual block and associated syntax elements from a bitstream for a video block received from a video encoder (140). As one example, a syntax element, i.e., cu_transquant_bypass_flag, indicates whether the residual block is coded using a lossless coding mode in which both a transform and quantization are always skipped for the residual block. In another example, a syntax element, i.e., transform_skip_flag, indicates whether a transform skip mode is used, in which only the transform is skipped, during coding of the residual block using a lossy coding mode.
In some cases, e.g., the lossy coding mode in transform skip mode, the residual data of the residual block is dequantized using inverse quantization unit 86 prior to rotating the residual block and reconstructing the video block from the residual data of the residual block. It may also be possible to determine whether to rotate the residual block with rotation unit 94 prior to dequantizing the residual data of the residual block using inverse quantization unit 86. In other cases, e.g., the lossless coding mode, both dequantization and the inverse transform are skipped and the residual data of the residual block is used to directly reconstruct the video block without any further decompression.
Video decoder 30 skips performing the inverse transform for the residual block at inverse transform processing unit 88 based on transform skipping indicated by the associated syntax elements (142). According to the techniques, when the inverse transform is skipped for the residual block, rotation unit 94 of video decoder 30 determines a type of boundary at each edge of the residual block (144). Rotation unit 94 then determines whether to rotate the residual block based on the type of boundary at each edge (146). Rotation unit 94 may determine to rotate the residual block in order to reverse a rotation of the residual block performed during encoding that positioned the residual data with higher energy than average at a top left corner of the residual block to improve entropy coding efficiency.
When rotation unit 94 determines to rotate the residual block (YES branch of 148), rotation unit 94 rotates the residual block by a determined rotation value (150). In some cases, described in more detail with respect to FIG. 7, the determined rotation value may be a static, predetermined rotation value, e.g., 180 degrees. In other cases, described in more detail with respect to FIG. 8, rotation unit 94 may determine the rotation value by which to rotate the residual block from a plurality of rotation values. The plurality of rotation values may include 180 degrees, 90 degrees clockwise or 270 degrees clockwise, e.g., in the case where the video encoder performed rotation in the counterclockwise direction.
When rotation unit 94 determines to not rotate the residual block (NO branch of 148), rotation unit 94 does not rotate the residual block. Regardless of whether rotation unit 94 rotates the residual block, video decoder 30 reconstructs the video block from the residual block using a predictive block from motion compensation unit 82 in the inter-prediction mode (152).
Alternatively, instead of determining the type of boundary at each of the edges of the residual block and determining whether to rotate based on the type of boundary at the edges, rotation unit 94 may determine whether to rotate the residual block based on syntax elements that indicate whether to rotate the residual block by an explicitly signaled rotation value. In this case, the video encoder may determine whether to rotate the residual block based on the number of bits needed to entropy encode the residual block. For example, the video encoder may determine whether to rotate the residual block based on a rotation value that results in the lowest number of bits for entropy encoding, and explicitly signal the rotation value to video decoder 30.
In this alternative example, entropy decoding unit 80 may decode syntax elements that indicate whether to rotate the residual block. Video decoder 30 does not have access to identical information as the video encoder to determine whether to rotate or the rotation value for the residual block. The rotation value, therefore, needs to be signaled explicitly in the bitstream. In case of only two possible rotation values, i.e., 0 degrees or no rotation and 180 degrees, one bit is sufficient to signal the rotation value. Entropy decoding unit 80 may CABAC code the bit using a context or in bypass mode. In case of four possible rotation value, i.e., 0 degrees, 180 degrees, 90 degrees clockwise, or 270 degrees clockwise, two bits may be used to signal the rotation value. Entropy decoding unit 80 may CABAC code the two bits using a context or in bypass mode.
FIG. 7 is a flowchart illustrating one example operation of determining whether to rotate a residual block by a predetermined rotation value based on a type of boundary at edges of the residual block. The illustrated operation is a more detailed example of step 126 from FIGS. 5 and 146 from FIG. 6 of determining whether to rotate the residual block based on the type of boundary at the edges.
When a transform is skipped for the residual block, e.g., a lossless coding mode or a lossy coding mode in a transform skip mode, entropy coding efficiency may be improved by rotating the residual block during encoding in order to position the residual data with higher energy than average at a top left corner of the residual block. During decoding, the rotation performed during encoding needs to be reversed in order to properly reconstruct the video block from the residual block using a predictive block in the inter-prediction mode.
In the inter-prediction mode, if a particular edge of the residual block is a TU boundary between two TUs within the same PU, residual data at the TU boundary of the residual block typically has lower energy than average residual data in the residual block. Further, if a particular edge of the residual block is a PU boundary between two TUs in different PUs, residual data at the PU boundary of the residual block typically has higher energy than average residual data in the residual block. Based on this observation, the techniques illustrated in FIG. 7 use the type of boundary at the edges of the residual block to determine whether to rotate the residual block by a predetermined rotation value, e.g., 180 degrees, to position the residual data at the PU boundaries of the original residual block at a top left corner of the rotated residual block. On the encoding side, this rotation positions the residual data with higher energy than average at a top left corner of the rotated residual block to improve entropy coding efficiency. On the decoding side, this rotation reverses the rotation performed during encoding and returns the residual data with higher energy than average to its original position in the original residual block.
The operation illustrated in FIG. 7 will be described with respect to rotation unit 66 of video encoder 20 from FIG. 2. In other examples, the same operation may also be performed by rotation unit 94 of video decoder 30 from FIG. 3. In the illustrated operation, rotation unit 66 may either rotate the residual block by the predetermined rotation value, e.g., 180 degrees, or not rotate the residual block. In order to determine whether to rotate the residual block, rotation unit 66 determines a first number of PU boundaries at a left edge and a top edge of the residual block (160). Rotation unit 66 also determines a second number of PU boundaries at a right edge and a bottom edge of the residual block (162).
If the second number of PU boundaries is greater than the first number of PU boundaries (YES branch of 164), the residual data with higher energy than average is likely concentrated at a bottom right corner of the residual block. In this case, rotation unit 66 rotates the residual block by the predetermined rotation value (168). Rotating the residual block by 180 degrees, for example, will position the residual data with higher energy than average at a top left corner of the rotated residual block. On the other hand, if the second number of PU boundaries is less than or equal to the first number of PU boundaries (NO branch of 164), the residual data with higher energy than average is likely already concentrated at the top left corner of the residual block. In that case, rotation unit 66 does not rotate the residual block (166).
FIG. 8 is a flowchart illustrating another example operation of determining whether to rotate a residual block including determining a rotation value for the residual block based on a type of boundary at edges of the residual block for each of two or more possible rotation values. The illustrated operation is another more detailed example of step 126 from FIGS. 5 and 146 from FIG. 6 of determining whether to rotate the residual block based on the type of boundary at the edges.
When a transform is skipped for the residual block, e.g., a lossless coding mode or a lossy coding mode in a transform skip mode, entropy coding efficiency may be improved by rotating the residual block during encoding in order to position the residual data with higher energy than average at a top left corner of the residual block. During decoding, the rotation performed during encoding needs to be reversed in order to properly reconstruct the video block from the residual block using a predictive block in the inter-prediction mode.
In the inter-prediction mode, if a particular edge of the residual block is a TU boundary between two TUs within the same PU, residual data at the TU boundary of the residual block typically has lower energy than average residual data in the residual block. Further, if a particular edge of the residual block is a PU boundary between two TUs in different PUs, residual data at the PU boundary of the residual block typically has higher energy than average residual data in the residual block. Based on this observation, the techniques illustrated in FIG. 8 use the type of boundary at the edges of the residual block to determine a rotation value by which to rotate the residual block, e.g., 0, 180, 90 or 270 degrees, to position the residual data at the PU boundaries of the original residual block at a top left corner of the rotated residual block. On the encoding side, this rotation positions the residual data with higher energy than average at a top left corner of the rotated residual block to improve entropy coding efficiency. On the decoding side, this rotation reverses the rotation performed during encoding and returns the residual data with higher energy than average to its original position in the original residual block.
The operation illustrated in FIG. 8 will be described with respect to rotation unit 66 of video encoder 20 from FIG. 2. In other examples, the same operation may also be performed by rotation unit 94 of video decoder 30 from FIG. 3. In the illustrated operation, rotation unit 66 may rotate the residual block by a rotation value selected from a plurality of rotation values. In some cases, the rotation values may include 0 degrees, i.e., no rotation, and 180 degrees. In other cases, the rotation values may include 0 degrees, 180 degrees, 90 degrees and 270 degrees. As an example, on the encoding side, the rotation values may be in a counterclockwise direction, and, on the decoding side, the rotation values may be in a clockwise direction
In order to determine the rotation value by which to rotate the residual block, rotation unit 66 determines a first number of PU boundaries at a left edge and a top edge of the residual block for each of the rotation values (170). Rotation unit 66 also determines a second number of PU boundaries at a right edge and a bottom edge of the residual block for each of the rotation values (172). Rotation unit 66, therefore, performs each of the possible rotations of the residual block and determines the location and number of PU boundaries at each of the rotations.
Rotation unit 66 calculates a difference value between the first number and the second number for each of the rotation values (174). In this way, rotation unit 66 determines where the residual data with higher energy than average is likely concentrated in the residual block after each of the rotations is performed. Rotation unit 66 then determines a maximum difference value from the calculated difference values for all of the rotation values (176). In order to maximize the concentration of residual data with higher energy than average at a top left corner of the residual block, rotation value 66 selects the one of the rotation values associated with the maximum difference value. Rotation unit 94 then rotates the residual block by the rotation value with the maximum difference value (178).
FIG. 9 is a flowchart illustrating an example operation of aligning block sizes of residual blocks for which rotation can be performed in both lossy and lossless coding modes with block sizes for which a transform can be skipped in the lossy coding mode. The illustrated operation in FIG. 9 will be described with respect to rotation unit 66 of video encoder 20 from FIG. 2. In other examples, the same operation may also be performed by rotation unit 94 of video decoder 30 from FIG. 3. The illustrated operation may be applied to both intra-prediction residual blocks and inter-prediction residual blocks.
The techniques described above include rotating a residual block by a determined rotation value when a transform is skipped for the residual block. The above techniques describe performing the rotation for both inter-prediction residual blocks and intra-prediction residual blocks that are coded using either the lossless coding mode or the lossy coding in a transform skip mode.
In the lossless coding mode, a transform is skipped for all residual block sizes, and a rotation may be performed for all residual block sizes. Performing rotation for large size residual blocks, such as 16×16 or 32×32 blocks, however, may be difficult for hardware implementations. In the lossy coding mode, a transform skip mode is only available for residual blocks having a particular size. A rotation is only performed in the lossy coding mode when a transform is skipped, so the rotation is also limited to residual blocks having the particular size. In some cases, the particular size for residual blocks in the lossy coding mode may comprise a 4×4 TU. Therefore, determining whether to rotate the residual block may depend on the cu_transquant_bypass_flag indicating the lossless coding mode, the transform skip flag indicating the transform skip mode in the lossy coding mode, and a size of the residual block.
In the operation illustrated in FIG. 9, rotation unit 66 receives a residual block when a transform is skipped for the residual block, i.e., the residual block is coded using the lossless coding mode or the lossy coding mode in a transform skip mode. As described above, in the lossy coding mode the residual blocks for which a transform can be skipped and rotation performed are already limited to a particular size, e.g., 4×4. The techniques of this disclosure include restricting the size of residual blocks for which rotation can be performed in the lossless coding mode.
In this case, in order to determine whether to rotate the residual block, rotation unit 66 determines a size of the residual block (180). If the size of the residual block is less than or equal to a threshold block size (YES branch of 182), then rotation unit 66 determines whether to rotate the residual block by a determined rotation value (186). If the size of the residual block is greater than the particular block size (NO branch of 182), rotation unit 66 does not rotate the residual block (184). The rotation determination may be performed by one of the operations described in more detail above. In some examples, if the residual block is an intra-prediction residual block, the rotation will always be applied when the block size of the residual block satisfies the threshold block size criterion. In some cases, the rotation of the residual block may be limited to 180 degrees. In other cases, the rotation of the residual block may be determined to be one of 0 degrees, 90 degrees, 180 degrees or 270 degrees according to the techniques described above.
In one example, the threshold size for performing rotation of the residual blocks in the lossless coding mode is 8×8. In this case, the rotation can be applied to both intra-prediction and inter-prediction residual blocks in the lossless coding mode that satisfy the threshold block size criterion (i.e., the residual block size is less than or equal to the threshold block size).
In another example, the threshold size for performing rotation of the residual blocks in the lossless coding mode is equal to the particular block size for which a transform can be skipped in the lossy coding mode, e.g., 4×4. In this case, the rotation can be applied to both intra-prediction and inter-prediction residual blocks in the lossless coding mode that satisfy the threshold block size criterion. Setting the threshold block size equal to the block size for which a transform can be skipped in the lossy coding mode aligns the block size processing for lossless and lossy coding mode cases.
In an additional example, the threshold size for performing rotation of the residual blocks in the lossless coding mode is equal to the particular block size for which a transform can be skipped in the lossy coding mode, e.g., 4×4. In this case, the rotation can be applied only to intra-prediction residual blocks in the lossless coding mode that satisfy the threshold block size criterion. In this case, no rotation may be applied to inter-prediction residual blocks in the lossless coding mode regardless of block size.
In a further example, the threshold size for performing rotation of the residual blocks in either the lossy coding mode or the lossless coding mode is equal to the particular block size for which a transform can be skipped in the lossy coding mode, e.g., 4×4. In this case, the rotation can be applied to only intra-prediction residual blocks in the lossy coding mode with transform skipping that satisfy the threshold block size criterion, and to both intra-prediction and inter-prediction residual blocks in the lossless coding mode that satisfy the threshold block size criterion.
FIG. 10 is a flowchart illustrating an example operation of aligning block sizes of residual blocks for which flipping of residual data sample values along a diagonal can be performed in both lossy and lossless coding modes with block sizes for which a transform can be skipped in the lossy coding mode. The illustrated operation in FIG. 10 will be described with respect to rotation unit 66 of video encoder 20 from FIG. 2. In other examples, the same operation may also be performed by rotation unit 94 of video decoder 30 from FIG. 3. The illustrated operation may be applied to both intra-prediction residual blocks and inter-prediction residual blocks.
The techniques described above that apply to the rotation of a residual block may also apply to flipping residual data sample values of the residual block. As discussed above, JCTVC-K0294 proposed that, depending on the scan being used, sample values of an intra prediction residual block may be flipped along the main diagonal or the anti-diagonal of the residual block when a transform is skipped for the residual block. The criterion for when a rotation can be performed for a residual block, described above with respect to FIG. 9, can also be applied to determine when flipping of the prediction residual values can be performed.
When the residual data sample values of a residual block are flipped, the sample values on one side of a diagonal swap places with sample values at corresponding mirror image locations on the other side of the diagonal of the residual block. In some examples, flipping the sample values of the residual block may include mirroring the sample values across the main diagonal of the residual block, i.e., the diagonal line from the top-left corner to the bottom-right corner of the residual block. In other examples, flipping the sample value of the residual block may include mirroring the sample values across the anti-diagonal of the residual block, i.e., the diagonal line from the bottom-left corner to the top-right corner of the residual block. In some cases, the sample values of the residual block will be flipped about the main diagonal when either a horizontal or a vertical scanning mode is selected for the transform-skipped residual block. In other cases, the sample values of the residual block will be flipped about the anti-diagonal when a diagonal scanning mode is selected for the transform-skipped residual block.
In the lossless coding mode, a transform is skipped for all residual block sizes, and flipping may be performed for all residual block sizes. In the lossy coding mode, a transform skip mode is only available for residual blocks having a particular size. Flipping is only performed in the lossy coding mode when a transform is skipped, so the flipping is also limited to residual blocks having the particular size. In some cases, the particular size for residual blocks in the lossy coding mode may comprise a 4×4 TU.
In the operation illustrated in FIG. 10, rotation unit 66 receives a residual block when a transform is skipped for the residual block, i.e., the residual block is coded using the lossless coding mode or the lossy coding mode in a transform skip mode. As described above, in the lossy coding mode the residual blocks for which a transform can be skipped and the flipping performed are already limited to a particular size, e.g., 4×4. The techniques of this disclosure include restricting the size of residual blocks for which flipping can be performed in the lossless coding mode.
In this case, in order to determine whether to flip the residual block, rotation unit 66 determines a size of the residual block (190). If the size of the residual block is less than or equal to a threshold block size (YES branch of 192), then rotation unit 66 determines whether to flip the residual data sample values along a diagonal of the residual block (196). If the size of the residual block is greater than the particular block size (NO branch of 192), rotation unit 66 does not flip the residual data sample values of the residual block (194). The residual data sample values may be flipped along a main diagonal, i.e., top-left to bottom-right, or along an anti-diagonal, i.e., bottom-left to top-right, of the residual block.
In one example, the threshold size for flipping residual data of the residual blocks in the lossless coding mode is 8×8. In this case, the flipping can be applied to residual data of both intra-prediction and inter-prediction residual blocks in the lossless coding mode that satisfy the threshold block size criterion (i.e., the residual block size is less than or equal to the threshold block size).
In another example, the threshold size for flipping residual data of the residual blocks in the lossless coding mode is equal to the particular block size for which a transform can be skipped in the lossy coding mode, e.g., 4×4. In this case, the flipping can be applied to residual data of both intra-prediction and inter-prediction residual blocks in the lossless coding mode that satisfy the threshold block size criterion. Setting the threshold block size equal to the block size for which a transform can be skipped in the lossy coding mode aligns the block size processing for lossless and lossy coding mode cases.
In an additional example, the threshold size for flipping residual data of the residual blocks in the lossless coding mode is equal to the particular block size for which a transform can be skipped in the lossy coding mode, e.g., 4×4. In this case, the flipping can be applied only to residual data of intra-prediction residual blocks in the lossless coding mode that satisfy the threshold block size criterion. In this case, no flipping may be applied to residual data of inter-prediction residual blocks in the lossless coding mode regardless of block size.
In a further example, the threshold size for flipping residual data of the residual blocks in either the lossy coding mode or the lossless coding mode is equal to the particular block size for which a transform can be skipped in the lossy coding mode, e.g., 4×4. In this case, the flipping can be applied to residual data of only intra-prediction residual blocks in the lossy coding mode with transform skipping that satisfy the threshold block size criterion, and to residual data of both intra-prediction and inter-prediction residual blocks in the lossless coding mode that satisfy the threshold block size criterion.
In one or more examples, the functions described may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted over, as one or more instructions or code, a computer-readable medium and executed by a hardware-based processing unit. Computer-readable media may include computer-readable storage media, which corresponds to a tangible medium such as data storage media, or communication media including any medium that facilitates transfer of a computer program from one place to another, e.g., according to a communication protocol. In this manner, computer-readable media generally may correspond to (1) tangible computer-readable storage media which is non-transitory or (2) a communication medium such as a signal or carrier wave. Data storage media may be any available media that can be accessed by one or more computers or one or more processors to retrieve instructions, code and/or data structures for implementation of the techniques described in this disclosure. A computer program product may include a computer-readable medium.
By way of example, and not limitation, such computer-readable storage media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage, or other magnetic storage devices, flash memory, or any other medium that can be used to store desired program code in the form of instructions or data structures and that can be accessed by a computer. Also, any connection is properly termed a computer-readable medium. For example, if instructions are transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. It should be understood, however, that computer-readable storage media and data storage media do not include connections, carrier waves, signals, or other transient media, but are instead directed to non-transient, tangible storage media. Disk and disc, as used herein, includes compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray disc, where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
Instructions may be executed by one or more processors, such as one or more digital signal processors (DSPs), general purpose microprocessors, application specific integrated circuits (ASICs), field programmable logic arrays (FPGAs), or other equivalent integrated or discrete logic circuitry. Accordingly, the term “processor,” as used herein may refer to any of the foregoing structure or any other structure suitable for implementation of the techniques described herein. In addition, in some aspects, the functionality described herein may be provided within dedicated hardware and/or software modules configured for encoding and decoding, or incorporated in a combined codec. Also, the techniques could be fully implemented in one or more circuits or logic elements.
The techniques of this disclosure may be implemented in a wide variety of devices or apparatuses, including a wireless handset, an integrated circuit (IC) or a set of ICs (e.g., a chip set). Various components, modules, or units are described in this disclosure to emphasize functional aspects of devices configured to perform the disclosed techniques, but do not necessarily require realization by different hardware units. Rather, as described above, various units may be combined in a codec hardware unit or provided by a collection of interoperative hardware units, including one or more processors as described above, in conjunction with suitable software and/or firmware.
Various examples have been described. These and other examples are within the scope of the following claims.

## Claims

1. A method of decoding video data, the method comprising:
skipping an inverse transform for a residual block of the video data based on one or more syntax elements indicating transform skipping for the residual block;
determining a type of boundary at each edge of the residual block, wherein, for a respective edge of the residual block, based on samples on either side of the respective edge belonging to the same prediction unit (PU), the respective edge of the residual block is a TU boundary, and wherein, based on samples on either side of the respective edge belonging to different PUs, the respective edge of the residual block is a PU boundary;
determining a first number of PU boundaries at a left edge and a top edge of the residual block based on the determined type of boundary at each edge of the residual block;
determining a second number of PU boundaries at a right edge and a bottom edge of the residual block based on the determined type of boundary at each edge of the residual block; and
determining, based on the second number of PU boundaries being greater than the first number of PU boundaries, to rotate the residual block prior to reconstructing a video block from residual data of the residual block.

2. The method of claim 1, wherein the residual block comprises an inter-prediction residual block in one of a lossless coding mode or a lossy coding mode with transform skipping.

3. The method of claim 2, further comprising automatically rotating an intra-prediction residual block in one of a lossless coding mode or a lossy coding mode with transform skipping.

4. The method of claim 1, further comprising, based on the determination to rotate the residual block, rotating the residual block to reverse a rotation performed during encoding the residual data of the residual block that positioned the residual data with higher energy than average at a top left corner of the residual block.

5. The method of claim 1, further comprising, based on a determination to rotate the residual block, rotating the residual block by a predetermined rotation value.

6. The method of claim 1, wherein determining whether to rotate the residual block comprises determining a rotation value for the residual block, the method further comprising rotating the residual block by the determined rotation value.

7. The method of claim 1, wherein determining whether to rotate the residual block comprises decoding one or more syntax elements indicating whether to rotate the residual block.

8. The method of claim 1, further comprising, based on the second number of PU boundaries being less than or equal to the first number of PU boundaries, determining to not rotate the residual block.

9. A method of encoding video data, the method comprising:
skipping a transform for a residual block calculated from a video block of the video data;
determining a type of boundary at each edge of the residual block, wherein, for a respective edge of the residual block, based on samples on either side of the respective edge belonging to the same prediction unit (PU), the respective edge of the residual block is a TU boundary, and wherein, based on samples on either side of the respective edge belonging to different PUs, the respective edge of the residual block is a PU boundary;
determining a first number of PU boundaries at a left edge and a top edge of the residual block based on the determined type of boundary at each edge of the residual block;
determining a second number of PU boundaries at a right edge and a bottom edge of the residual block based on the determined type of boundary at each edge of the residual block; and
determining, based on the second number of PU boundaries being greater than the first number of PU boundaries, to rotate the residual block prior to reconstructing a video block from residual data of the residual block.

10. The method of claim 9, wherein the residual block comprises an inter-prediction residual block in one of a lossless coding mode or a lossy coding mode with transform skipping.

11. The method of claim 10, further comprising automatically rotating an intra-prediction residual block in one of a lossless coding mode or a lossy coding mode with transform skipping.

12. The method of claim 9, further comprising, based on the determination to rotate the residual block, rotating the residual block in order to position the residual data with higher energy than average at a top left corner of the residual block.

13. The method of claim 9, further comprising, based on a determination to rotate the residual block, rotating the residual block by a predetermined rotation value.

14. The method of claim 9, wherein determining whether to rotate the residual block comprises determining a rotation value for the residual block, further comprising rotating the residual block by the determined rotation value.

15. The method of claim 9, further comprising encoding one or more syntax elements indicating whether to rotate the residual block.

16. The method of claim 9, further comprising, based on the second number of PU boundaries being less than or equal to the first number of PU boundaries, determining to not rotate the residual block.

17. A video coding device for coding video data, the device comprising one or more processors configured to:
skip a transform for a residual block of the video data;
determine a type of boundary at each edge of the residual block, wherein, for a respective edge of the residual block, based on samples on either side of the respective edge belonging to the same prediction unit (PU), the respective edge of the residual block is a TU boundary, and wherein, based on samples on either side of the respective edge belonging to different PUs, the respective edge of the residual block is a PU boundary;
determine a first number of PU boundaries at a left edge and a top edge of the residual block based on the determined type of boundary at each edge of the residual block;
determine a second number of PU boundaries at a right edge and a bottom edge of the residual block based on the determined type of boundary at each edge of the residual block; and
determine, based on the second number of PU boundaries being greater than the first number of PU boundaries, to rotate the residual block prior to reconstructing a video block from residual data of the residual block.

18. The device of claim 17, wherein the residual block comprises an inter-prediction residual block in one of a lossless coding mode or a lossy coding mode with transform skipping.

19. The device of claim 18, wherein the processors are configured to automatically rotate an intra-prediction residual block in one of a lossless coding mode or a lossy coding mode with transform skipping.

20. The device of claim 17, wherein the video coding device comprises a video encoding device for encoding video data, and wherein, based on the determination to rotate the residual block, the processors are configured to rotate the residual block in order to position the residual data with higher energy than average at a top left corner of the residual block.

21. The device of claim 17, wherein the video coding device comprises a video decoding device for decoding video data, and wherein, based on a determination to rotate the residual block, the processors are configured to rotate the residual block to reverse a rotation performed during encoding the residual data of the residual block that positioned the residual data with higher energy than average at a top left corner of the residual block.

22. The device of claim 17, wherein, based on a determination to rotate the residual block, the processors are configured to rotate the residual block by a predetermined rotation value.

23. The device of claim 17, wherein the processors are configured to determine a rotation value for the residual block, and rotate the residual block by the determined rotation value.

24. The device of claim 17, further comprising coding one or more syntax elements indicating whether to rotate the residual block.

25. The device of claim 17, wherein, based on the second number of PU boundaries being less than or equal to the first number of PU boundaries, the processors are configured to determine to not rotate the residual block.

26. A video coding device for coding video data, the device comprising:
means for skipping a transform for a residual block of the video data;
means for determining a type of boundary at each edge of the residual block, wherein, for a respective edge of the residual block, based on samples on either side of the respective edge belonging to the same prediction unit (PU), the respective edge of the residual block is a TU boundary, and wherein, based on samples on either side of the respective edge belonging to different PUs, the respective edge of the residual block is a PU boundary;
means for determining a first number of PU boundaries at a left edge and a top edge of the residual block based on the determined type of boundary at each edge of the residual block;
means for determining a second number of PU boundaries at a right edge and a bottom edge of the residual block based on the determined type of boundary at each edge of the residual block; and
means for determining, based on the second number of PU boundaries being greater than the first number of PU boundaries, to rotate the residual block prior to reconstructing a video block from residual data of the residual block.

27. The device of claim 26, wherein the residual block comprises an inter-prediction residual block in one of a lossless coding mode or a lossy coding mode with transform skipping.

28. The device of claim 27, further comprising means for automatically rotating an intra-prediction residual block in one of a lossless coding mode or a lossy coding mode with transform skipping.

29. The device of claim 26, further comprising means for coding one or more syntax elements indicating whether to rotate the residual block.

30. A non-transitory computer readable medium comprising instructions for coding video data, the instructions, when executed, cause one or more programmable processors to:
skip a transform for a residual block of the video data;
determine a type of boundary at each edge of the residual block, wherein, for a respective edge of the residual block, based on samples on either side of the respective edge belonging to the same prediction unit (PU), the respective edge of the residual block is a TU boundary, and wherein, based on samples on either side of the respective edge belonging to different PUs, the respective edge of the residual block is a PU boundary;
determine a first number of PU boundaries at a left edge and a top edge of the residual block based on the determined type of boundary at each edge of the residual block;
determine a second number of PU boundaries at a right edge and a bottom edge of the residual block based on the determined type of boundary at each edge of the residual block; and
determine, based on the second number of PU boundaries being greater than the first number of PU boundaries, to rotate the residual block prior to reconstructing a video block from residual data of the residual block.