Reference line usage in decoder-side intra derivation

TIMD with adaptive reference line selection addresses inefficiencies in existing video coding standards by implicitly deriving intra prediction modes, improving compression efficiency and reducing complexity through adaptive reference line selection.

WO2026096708A1PCT designated stage Publication Date: 2026-05-07MEDIATEK INC +6
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
MEDIATEK INC
Filing Date
2025-10-30
Publication Date
2026-05-07

AI Technical Summary

Technical Problem

Existing video coding standards like HEVC and VVC face challenges in efficiently deriving intra prediction modes without explicit signaling, leading to suboptimal compression efficiency and increased computational complexity.

Method used

The method employs template-based intra mode derivation (TIMD) with adaptive reference line selection, allowing the encoder and decoder to implicitly determine intra prediction modes using different sets of reference samples for various template regions, reducing the need for explicit signaling and enhancing prediction accuracy.

Benefits of technology

This approach improves compression efficiency and reduces computational complexity by adaptively selecting reference lines for intra prediction, leading to more accurate mode derivation and enhanced video coding performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure US2025053249_07052026_PF_FP_ABST
    Figure US2025053249_07052026_PF_FP_ABST
Patent Text Reader

Abstract

A method for using template based intra mode derivation (TIMD) with adaptive reference line selection is provided. A video coder generates a prediction of a template region neighboring the current block for each candidate intra mode in a set of candidate intra modes. Different sets of reference samples from different reference lines may be used for generating predictions for different candidate intra modes and / or different template regions. The video coder computes a difference value between reconstruction samples of the template region and the generated prediction of the template region for each candidate intra mode. The video coder derives an intra mode based on the computed difference values for the set of candidate intra modes. The video coder computes a predictor of the current block based on the derived intra mode and use the computed predictor to encode or decode the current block.
Need to check novelty before this filing date? Find Prior Art

Description

REFERENCE LINE USAGE IN DECODER-SIDE INTRA DERIVATIONCROSS REFERENCE TO RELATED PATENT APPLICATION(S)

[0001] The present disclosure is part of a non-provisional application that claims the priority benefit of U.S. Provisional Patent Application No. 63 / 714,965, filed on 1 November 2024. Content of the above-listed application is herein incorporated by reference.TECHNICAL FIELD

[0002] The present disclosure relates generally to video coding. In particular, the present disclosure relates to methods of coding pixel blocks by intra prediction.BACKGROUND

[0003] Unless otherwise indicated herein, approaches described in this section are not prior art to the claims listed below and are not admitted as prior art by inclusion in this section.

[0004] High-Efficiency Video Coding (HEVC) is an international video coding standard developed by the Joint Collaborative Team on Video Coding (JCT-VC). HEVC is based on the hybrid block-based motion-compensated DCT-like transform coding architecture. The basic unit for compression, termed coding unit (CU), is a 2Nx2N square block of pixels, and each CU can be recursively split into four smaller CUs until the predefined minimum size is reached. Each CU contains one or multiple prediction units (PUs).

[0005] Versatile video coding (VVC) is the latest international video coding standard developed by the Joint Video Expert Team (JVET) of ITU-T SG16 WP3 and ISO / IEC JTC1 / SC29 / WG11. The input video signal is predicted from the reconstructed signal, which is derived from the coded picture regions. The prediction residual signal is processed by a block transform. The transform coefficients are quantized and entropy coded together with other side information in the bitstream. The reconstructed signal is generated from the prediction signal and the reconstructed residual signal after inverse transform on the de-quantized transform coefficients. The reconstructed signal is further processed by in-loop filtering for removing coding artifacts. The decoded pictures are stored in the frame buffer for predicting the future pictures in the input video signal.

[0006] In WC, a coded picture is partitioned into non-overlapped square block regions represented by the associated coding tree units (CTUs). The leaf nodes of a coding tree correspond to the coding units (CUs). A coded picture can be represented by a collection of slices, each comprising an integer number of CTUs. The individual CTUs in a slice are processed in raster-scan order. A bi-predictive (B) slice may be decoded using intra prediction or inter prediction with at most two motion vectors (MVs) and reference indices to predict the sample values of each block. A predictive (P) slice is decoded using intra prediction or inter prediction with at most one motion vector and reference index to predict the sample values of each block. An intra (I) slice is decoded using intra prediction only.

[0007] A CTU can be partitioned into one or multiple non-overlapped coding units(CUs) using the quadtree (QT) with nested multi-type-tree (MTT) structure to adaptto various local motion and texture characteristics. A CU can be further split into smaller CUs using one of the five split types: quad-tree partitioning, vertical binary tree partitioning, horizontal binary tree partitioning, vertical center-side triple-tree partitioning, horizontal center-side triple-tree partitioning.

[0008] Each CU contains one or more prediction units (PUs). The prediction unit, together with the associated CU syntax, works as a basic unit for signaling the predictor information. The specified prediction process is employed to predict the values of the associated pixel samples inside the PU. Each CU may contain one or more transform units (TUs) for representing the prediction residual blocks. A transform unit (TU) is comprised of a transform block (TB) of luma samples and two corresponding transform blocks of chroma samples and each TB correspond to one residual block of samples from one color component. An integer transform is applied to a transform block. The level values of quantized coefficients together with other side information are entropy coded in the bitstream. The terms coding tree block (CTB), coding block (CB), prediction block (PB), and transform block (TB) are defined to specify the 2-D sample array of one-color component associated with CTU, CU, PU, and TU, respectively. Thus, a CTU consists of one luma CTB, two chroma CTBs, and associated syntax elements. A similar relationship is valid for CU, PU, and TU.

[0009] For each inter-predicted CU, motion parameters consisting of motion vectors, reference picture indices and reference picture list usage index, and additional information are used for inter-predicted sample generation. The motion parameter can be signalled in an explicit or implicit manner. When a CU is codedwith skip mode, the CU is associated with one Pll and has no significant residual coefficients, no coded motion vector delta or reference picture index. A merge mode is specified whereby the motion parameters for the current CU are obtained from neighbouring CUs, including spatial and temporal candidates, and additional schedules introduced in VVC. The merge mode can be applied to any interpredicted CU. The alternative to merge mode is the explicit transmission of motion parameters, where motion vector, corresponding reference picture index for each reference picture list and reference picture list usage flag and other needed information are signalled explicitly per each CU.SUMMARY

[0010] The following summary is illustrative only and is not intended to be limiting in any way. That is, the following summary is provided to introduce concepts, highlights, benefits and advantages of the novel and non-obvious techniques described herein. Select and not all implementations are further described below in the detailed description. Thus, the following summary is not intended to identify essential features of the claimed subject matter, nor is it intended for use in determining the scope of the claimed subject matter.

[0011] Some embodiments of the disclosure provide a method for using template based intra mode derivation (TIMD) with adaptive reference line selection. A video coder receives data to be encoded or decoded as a current block of pixels of a current picture of a video. The video coder generates a prediction of a template region neighboring the current block for each candidate intra mode in a set ofcandidate intra modes. Different sets of reference samples from different reference lines may be used for generating predictions for different candidate intra modes and / or different template regions. A set of reference samples may occupy a row of samples neighboring the current block, a column of samples neighboring the current block, a L-shape of samples neighboring the current block, or a L-shape of samples neighboring a combination of the current block and at least a part of the template region. The video coder computes a difference value between reconstruction samples of the template region and the generated prediction of the template region for each candidate intra mode. The video coder derives an intra mode based on the computed difference values for the set of candidate intra modes. The video coder computes a predictor of the current block based on the derived intra mode and use the computed predictor to encode or decode the current block.

[0012] In some embodiments, the predictions of the above template and of the left templates may use different sets of reference samples that occupy different rows or different columns of the current picture. In some embodiments, the prediction of the template region uses different sets of reference samples that occupy different rows or different columns of the current picture for when the template region does not comprise an above template versus when the template region does not comprise a left template.

[0013] In some embodiments, a first set of reference samples used for generating a first prediction of the template region for a first candidate intra mode and a second set of reference samples used for generating a second prediction of thetemplate region for a second candidate intra mode may occupy different rows or different columns of samples in the current picture. For example, the first set of reference samples may be in an inner most reference line that is adjacent to the current block and the second set of reference samples may be in a reference line that is above the template region or left of the template region.

[0014] For example, the first candidate intra mode may be planar intra mode that uses the inner most reference line and the second candidate intra mode may be an angular intra mode that is below horizontal (18) or beyond vertical (50) which uses a reference line that is left of the template region or above the template region.

[0015] For another example, the first candidate intra mode may be an angular intra mode that is between horizontal (mode 18) and vertical (mode 50), or is DC intra mode that use the inner most reference line, while the second candidate intra mode may be planar intra mode that use reference lines above or left of the template region.

[0016] In some embodiments, when the first candidate intra mode is an angular intra mode in vertical angular direction, the first set of reference samples is in a reference line adjacent to top side of the current block, and when the first candidate intra mode is an angular intra mode in horizontal angular direction, the first set of reference samples is in a reference line adjacent to left side of the current block.

[0017] In some embodiments, at least a part of the first set of reference samples is reversed for generating the first prediction of the template region for the first candidate intra mode, and a remaining part of the first set of reference samples is not reversed for generating the first prediction of the template region for the firstcandidate intra mode. When the first candidate intra mode is an angular intra mode between horizontal angular direction and vertical angular direction, an intra prediction angle is reversed to generate the prediction of the template region. When the first candidate intra mode is an angular intra mode below horizontal angular direction, an intra prediction angle for the left template is reversed to generate the prediction of the template region. When the first candidate intra mode is an angular intra mode beyond vertical angular direction an intra prediction angle for the above template is reversed to generate the prediction of the template region.

[0018] In some embodiments, a prediction by planar intra mode may be generated by using reference samples to generate a predictor having a size of the current block. In some embodiments, a prediction by planar intra mode is generated by using reference samples to generate a prediction of a region that encompass the template region and the current block. In some embodiments, a prediction by planar intra mode prediction may be extrapolated from reference samples near bottom of the current block and reference samples that are above the current block.BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings are included to provide a further understanding of the present disclosure, and are incorporated in and constitute a part of the present disclosure. The drawings illustrate implementations of the present disclosure and, together with the description, serve to explain the principles of the present disclosure. It is appreciable that the drawings are notnecessarily in scale as some components may be shown to be out of proportion than the size in actual implementation in order to clearly illustrate the concept of the present disclosure.

[0020] FIG. 1 illustrates 67 intra predictions modes, including 65 directional or angular intra prediction modes.

[0021] FIG. 2 illustrates neighboring reconstructed samples used for decoderside intra mode derivation (DIMD) chroma mode.

[0022] FIG. 3 illustrates target samples, template samples, and reference samples used in intra mode derivation.

[0023] FIG. 4 illustrates derivation of TIMD modes using a set of common reference samples for both the current block and its template.

[0024] FIGS. 5A-5C show using the inner-most reference line as the reference samples for generating the DC mode predictor for TIMD.

[0025] FIGS. 6A-6B show reference samples that are used for generating planar intra predictor for TIMD.

[0026] FIGS. 7A-7B show shifted reference samples that are used for generating planar intra-predictor for TIMD.

[0027] FIGS. 8A-8B illustrate the reference samples that are used for block-size- based planar mode for generating template predictor.

[0028] FIGS. 9A-9B illustrate reference samples in a L-shaped reference line that surrounds a current block being used for generating planar intra-predictor for TIMD.

[0029] FIGS. 10A-10C illustrate reference samples in inverse L-shaped reference lines being used for generating planar intra-predictor for TIMD.

[0030] FIGS. 11A-11B illustrate using extrapolation-based planar mode to generate planar mode intra-prediction for TIMD.

[0031] FIG. 12 illustrates using a whole block covering the current block and the above and left templates to generate planar mode intra-prediction for TIMD.

[0032] FIGS. 13A-13B illustrate the reference samples and reference lines used to generate horizontal and vertical intra predictors for TIMD.

[0033] FIGS. 14A-14I illustrate the reference samples and reference lines used to generate angular intra predictor for different angle ranges for TIMD.

[0034] FIG. 15 illustrates an example video encoder that may implement TIMD prediction.

[0035] FIG. 16 illustrates portions of the video encoder that implement TIMD with adaptive reference line selection.

[0036] FIG. 17 conceptually illustrates a process that encodes a block of pixels using TIMD with adaptive reference line selection.

[0037] FIG. 18 illustrates an example video decoder that may implement TIMD prediction.

[0038] FIG. 19 illustrates portions of the video decoder that implement TIMD with adaptive reference line selection.

[0039] FIG. 20 conceptually illustrates a process that decodes a block of pixels using TIMD with adaptive reference line selection.

[0040] FIG. 21 conceptually illustrates an electronic system with which some embodiments of the present disclosure are implemented.DETAILED DESCRIPTION

[0041] In the following detailed description, numerous specific details are set forth by way of examples in order to provide a thorough understanding of the relevant teachings. Any variations, derivatives and / or extensions based on teachings described herein are within the protective scope of the present disclosure. In some instances, well-known methods, procedures, components, and / or circuitry pertaining to one or more example implementations disclosed herein may be described at a relatively high level without detail, in order to avoid unnecessarily obscuring aspects of teachings of the present disclosure.I. Intra Prediction

[0042] Intra-prediction method exploits one or more reference lines adjacent to the current prediction unit (PU) and one of the intra-prediction modes to generate the predictors for the current PU. The Intra-prediction direction can be chosen among a mode set containing multiple prediction directions, DC mode, and Planar mode. The intra prediction mode may also refer to any intra mode which determines the predictor of the current block using the spatially reconstructed samples. The number of directional intra modes may be 33 or extended to 65 direction modes. By including DC and Planar modes, the number of intra-prediction mode is 35 or extended to 67. FIG. 1 illustrates 67 intra predictions modes, including 65 directional or angular intra prediction modes (from 2 to 66).

[0043] Some intra-prediction modes (e.g., 3 or 5) are identified as a set of most probable modes (MPM) for intra-prediction in current prediction block so an index may be signaled to select one of the MPMs.

[0044] In VVC, the results of intra prediction of DC, planar and several angular modes may be further modified by a position dependent intra prediction combination (PDPC) method. PDPC is an intra prediction method which invokes a combination of the boundary reference samples and HEVC style intra prediction with filtered boundary reference samples. PDPC may be applied to the following intra modes without signaling: planar, DC, intra angles less than or equal to horizontal, and intra angles greater than or equal to vertical and less than or equal to 80. / / . Decoder-Side Intra Mode Derivation (DIMD)

[0045] In some embodiments, instead of signaling intra mode explicitly, the information is derived at both encoder and decoder from the neighboring reconstructed samples of current block. Decoder-Side Intra Mode Derivation (DIMD) is a technique in which one or more, for example, two, intra prediction modes such as angles or directions are derived from the reconstructed neighbor samples (template) of a block, and those two predictors are combined with the non-angular predictor such as planar mode predictor with the weights derived from the gradients. The DIMD mode may be used as an alternative prediction mode and / or is always checked in high-complexity RDO mode. To implicitly derive the intra prediction modes of a block, a texture gradient analysis is performed at both encoder and decoder sides. This process starts with an empty Histogram of Gradient (HoG) having 65 entries, corresponding to the 65 angular / directional intra prediction modes. Amplitudes of these entries are determined during the texture gradient analysis.

[0046] In some embodiments, when DIMD is applied, two intra modes are derived from the reconstructed neighbor samples, and those two predictors are combined with the planar mode predictor with the weights derived from the gradients. The division operations in weight derivation are performed utilizing a lookup table (LUT) based integerization scheme. For example, the division operation in the orientation calculationOrient = Gy Gx is computed by the following LUT-based scheme: x = Floor( Log2( Gx ) ) normDiff = ( ( Gx« 4 ) » x ) & 15 x +=( 3 + ( normDiff != 0 ) ? 1 : 0 )Orient = (Gy* ( DivSigTable[ normDiff ] | 8 ) + ( 1«( x-1 ) )) » x whereDivSigTable

[0016] = { 0, 7, 6, 5 ,5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0 }.

[0047] The derived intra modes are included into the primary list of intra most probable modes (MPM), so the DIMD process is performed before the MPM list is constructed. The primary derived intra mode of a DIMD block is stored with a block and is used for MPM list construction of the neighboring blocks.

[0048] In some embodiments, the intra mode(s) derived by DIMD is used differently for 2Nx2N CUs versus for NxN CUs. For 2Nx2N CUs, the DIMD mode is used as the intra mode for intra prediction when the corresponding CU-level DIMD flag is turned on. For NxN CUs, the DIMD mode is used to replace one candidate of the existing MPM list to improve the efficiency of intra mode coding.

[0049] PIMP for intra 2Nx2N CUs

[0050] For intra 2Nx2N CUs, the PIMP is used as one additional intra mode, which is adaptively selected by comparing the PIMP intra mode with the optimal normal intra mode (i.e., being explicitly signaled). One flag is signaled for each intra 2Nx2N CU to indicate the usage of the PIMP. If the flag is one, then the CU is predicted using the intra mode derived by PIMP; otherwise, the PIMP is not applied and the CU is predicted using the intra mode explicitly signaled in the bitstream. When the PIMP is enabled, chroma components always reuse the same intra mode as that derived for luma component, i.e., PM mode.

[0051] Additionally, for each PIMP-coded CU, the blocks in the CU can adaptively select to derive their intra modes at either PU-level or TU-level. Specifically, when the PIMP flag is one, another CU-level PIMP control flag is signaled to indicate the level at which the PIMP is performed. If this flag is zero, it means that the PIMP is performed at the PU level and all the TUs in the PU use the same derived intra mode for their intra prediction; otherwise (i.e., the PIMP control flag is one), it means that the PIMP is performed at the TU level and each TU in the PU derives its own intra mode.

[0052] Further, when the PIMP is enabled, the number of angular directions increases to 129, and the PC and planar modes still remain the same. To accommodate the increased granularity of angular intra modes, the precision of intra interpolation filtering for PIMP-coded CUs increases from 1 / 32-pel to 1 / 64- pel. Additionally, in order to use the derived intra mode of a PIMP coded CU as MPM candidate for neighboring intra blocks, those 129 directions of the PIMP-coded CUs are converted to “normal” intra modes (i.e. , 65 angular intra directions) before they are used as MPM.

[0053] PIMP for intra NxN CUs

[0054] In some embodiments, intra modes of intra NxN CUs are always signaled. However, to improve the efficiency of intra mode coding, the intra modes derived from PIMP are used as MPM candidates for predicting the intra modes of four PUs in the CU. In order to not increase the overhead of MPM index signaling, the PIMP candidate is always placed I inserted at the first place in the MPM list and the last existing MPM candidate is removed. Also, pruning operation is performed such that the PIMP candidate will not be added to the MPM list if it is redundant.

[0055] PIMP chroma mode

[0056] PIMP chroma mode uses the PIMP derivation method to derive the chroma intra prediction mode of the current block based on the neighboring reconstructed Y, Cb and Cr samples in the second neighboring row and column. FIG. 2 illustrates neighboring reconstructed samples used for PIMP chroma mode. Specifically, a horizontal gradient and a vertical gradient are calculated for each collocated reconstructed luma sample of the current chroma block, as well as the reconstructed Cb and Cr samples, to build a HoG. Then the intra prediction mode with the largest histogram amplitude values is used for performing chroma intra prediction of the current chroma block.

[0057] In some embodiments, when the intra prediction mode derived from the PIMP chroma mode is the same as the intra prediction mode derived from the PM mode, the intra prediction mode with the second largest histogram amplitude valueis used as the DIMD chroma mode. A CU level flag is signaled to indicate whether the proposed DIMD chroma mode is applied. / / / . Template Based Intra Mode Derivation (TIMD)

[0058] For mode selection, template matching method can be applied by computing the cost between reconstructed samples and predicted samples. One of the examples is template-based intra mode derivation (TIMD). TIMD is a coding method in which the intra prediction mode of a CU is implicitly derived by using a neighboring template at both encoder and decoder, instead of the encoder signaling the exact intra prediction mode to the decoder.

[0059] In some embodiments, for each intra prediction mode in MPMs, as well as the wide-angle modes if the above-right and / or bottom-left reference samples are available, the sum of absolute transformed differences (SATD) between the prediction and reconstruction samples of the template is calculated. The calculated SATDs are used to identify a set of intra prediction modes for TIMD.

[0060] FIG. 3 illustrates target samples, template samples, and reference samples used in intra mode derivation. As illustrated, samples of a current block 300 (of block size N) are the target samples for which intra prediction mode is to be estimated. The template 310 specifies a set of already reconstructed samples, which are used to derive the intra mode. The template size is denoted as the number of samples within the template that extends to the above and the left of the target block, i.e. , L. The prediction samples of the template 310 are generated using the reference samples of the template 310 for each candidate intra prediction mode. The predictors on the templates 310 are generated based on referencesamples (in a reference line 320) that is adjacent to the template 310 (also referred to as the reference line of the template). For example, in some embodiments, a template size of 2 (i.e. , L=2) is used for 4x4 and 8x8 blocks and a template size of 4 (i.e., L=4) is used for 16x16 and larger blocks.

[0061] For each intra prediction mode, the absolute difference (SAD) is calculated between the reconstructed template samples and its prediction samples obtained from the reference samples 320 of the template 310. The intra prediction mode that yields the minimum SAD is selected as the final intra prediction mode of the target samples in the current block 300. The candidate modes may be 67 intra prediction modes as in WC or extended to 131 intra prediction modes.

[0062] A. Decoder-side derived TIMD

[0063] In some embodiments, the intra prediction mode of a ClI was derived with a template-based method at both encoder and decoder (decoder-side derived, or DIMD like), instead of being signalled to the decoder. For the example of FIG. 3, both the encoder and the decoder generate the prediction samples of the template 310 by using the reference samples 320 of the template 310 for each candidate mode. Both the encoder and the decoder calculate a cost as the SATD between the prediction and the reconstruction samples of the template 310 for each intra prediction mode. Both the encoder and the decoder select the intra prediction mode with the minimum cost as the intra prediction mode to be used for intra prediction of the CU.

[0064] In some embodiments, a progressive mode search method is used to select the DIMD mode from all allowed intra prediction modes, in which the searchinterval was reduced to half in each step. Although this progressive search method can reduce the number of the modes to be checked, in some embodiments, the starting modes are always the same for all CUs. Different regions in the video have different characteristics.

[0065] B. TIMD using MPMs

[0066] In some embodiments, most probable modes (MPMs) may be used to indicate the directional information of a CU, and that the intra prediction mode of current CU is derived from the MPMs. In some embodiments, a template-based intra mode derivation (TIMD) method using MPMs, in which a TIMD mode is derived from MPMs using the neighbouring template. The TIMD mode is used as an additional intra prediction method for a CU. In some embodiments, for each intra prediction mode in MPMs, the SATD between the prediction and reconstruction samples of the template is calculated. The intra prediction mode with the minimum SATD is selected as the TIMD mode and used for intra prediction of current CU. In some embodiments, when secondary MPM is enabled, both the primary MPMs and the secondary MPMs are used to derive the TIMD mode.

[0067] In some embodiments, position dependent intra prediction combination (PDPC) may be included in the derivation of the TIMD mode. In some embodiments, Gradient PDPC is also included in the derivation of the TIMD mode. In some embodiments, 6-tap interpolation filter is not used in the derivation of the TIMD mode.

[0068] In some embodiments, the construction of the MPM list is modified in the derivation of TIMD mode. During the construction of MPM list, intra predictionmode of a neighbouring block may be derived as planar when it is inter-coded. To improve the accuracy of MPM list, when a neighbouring block is inter-coded, a propagated intra prediction mode may be derived using the motion vector and reference picture and used in the construction of MPM list. This modification is only applied to the derivation of the TIMD mode.

[0069] In some embodiments, a flag is signalled in sequence parameter set (SPS) to enable / disable TIMD using MPM. When the flag is true, a CU level flag is signalled to indicate whether TIMD is used. In some embodiments, a TIMD flag is signalled right after the MIP flag. If the TIMD flag is equal to true, the remaining syntax elements related to luma intra prediction mode, including MRL, ISP, and normal parsing stage for luma intra prediction modes, are all skipped. In some embodiments, a DIMD method with prediction fusion using planar is implemented. When “DIMD” flag is equal to true, the TIMD flag is not signalled and set equal to false.

[0070] In the example of FIG. 3, unlike the template samples 310 which are always from reconstructed region, the reference samples 320 of the template 310 may not be reconstructed yet when encoding / decoding the current block 300. In this case, in some embodiments, existing reference samples may be utilized to substitute the unavailable reference samples with the available reference samples.

[0071] C. TIMD with Common Reference Samples

[0072] In some embodiments, TIMD with common reference samples (TIMD- CRS) is used to generate the predictor of the current block. In TIMD-CRS, the reference samples for the templates is the taken from a same reference line orsame set of reference samples for generating predictors of the current block. FIG.4 illustrates derivation of TIMD modes using a set of common reference samples for both the current block and its template. As illustrated, a current block 400 has its neighboring top template region 412 and left template region 414 as its template 410. A same set of samples (e.g. , a set of one or more reference lines) 420 is used to generate a predictor for the current block 400 and prediction samples for the template 410 for TIMD.

[0073] In some embodiments, for Planar mode, some reference samples are mirrored with respect to the reference line: for above template, top-left reference sample is used in place of bottom-left reference sample for predicting current block; for left template, top-left reference sample is used in place of top-right reference sample for predicting current block. DC mode remains unchanged for TIMD-CRS.

[0074] In some embodiments, for some angular modes and some templates, the prediction direction shall be reversed and point to the reference lines. In some embodiments, PDPC is applied on negative modes, where the sample to be predicted is located between the intersection of the prediction line and the reference lines 420. The remainder of the mode derivation process (SATD-based cost evaluation, mode sorting, fusion rules) are the same as TIMD.IV. Adaptive Selection of Reference Lines for TIMD

[0075] A reference line adjacent or closest to the current block (reference line 0, or inner most reference line, or the reference line that is one pixel distance away from current block) may be used to generate template predictor in TIMD. A reference line that is 2 line or 4 lines further away from current block than thereference line 0, may also be utilized to generate template predictor. However, fixed selection of reference line in TIMD in intra prediction may not be suitable for various video coding and lacks flexibility. Some embodiments of the disclosure provide a new reference line based TIMD process. The selection of reference line can be adaptively changed and utilized to generate template predictor for different intra modes, including DC, planar, angular modes. In some embodiments, the number of reference lines can be one or more to further assist template predictor generation.

[0076] A. Reference Line Based TIMD DC Predictor

[0077] In some embodiments, for DC predictor (for the template) in intraprediction, the inner most reference line is used to generate the template predictor. In some embodiments, for a current block that is a square block, the DC predictor is the average sample value of the left and above side samples. In embodiments, for a current block that is a non-square block, the DC predictor is the sample value of longer-side samples.

[0078] FIGS. 5A-5C show using the inner-most reference line as the reference samples for generating the DC mode predictor for TIMD. In the figures, the innermost reference line 510 provides the reference samples for generating the DC intra predictor for a current block 500, an above template 502, and a left template 504. The inner-most reference line 510 includes above-side samples 512 and left-side samples 514.

[0079] FIG. 5A shows an example in which the current block 500 is a square block such that the DC predictor is the average sample value of above-sidesamples 512 and the left-side samples 514. FIG. 5B shows an example in which the current block 500 is a non-square block with longer-side samples above the current block such that the DC predictor is the average of the above-side samples 512. FIG. 5C shows an example in which the current block 500 is a non-square block with longer-side samples at its left such that the DC predictor is the average of the left-side samples 514.

[0080] In some embodiments, for DC predictor in intra-prediction, one or more inner reference lines can be used to generate the template predictor. In some embodiments, the reference line that is N pixel distance away from current block is used to generate the template predictor. In some embodiments, one or more reference lines are used to generate DC predictor. In some embodiments, reference lines are subsampled to generate the DC predictor (e.g., only reference samples located at position of power of 2 are used to generate the DC predictor.) In some embodiments, reference lines are upsampled to generate DC predictor. For example, reference samples are extrapolated to generate more reference samples and then extrapolated reference samples are used to generate DC predictor.

[0081] B. Reference Line Based HMD Planar Predictor

[0082] In some embodiments, corresponding spatial neighboring reference lines are used to generate planar intra prediction for template predictors. Instead of using outer reference line, for each template predictor, spatial neighboring reference line is used. Specifically, samples spatially neighboring the above template are used for generating the planar predictor of the above template, andsamples spatially neighboring the left template are used for generating the planar predictor of the left template.

[0083] FIGS. 6A-6B shows reference samples that are used for generating planar intra predictor for TIMD. For a current block 600 having above template 610 and left template 620, FIG. 6A shows the reference samples 615 that are used for generating the planar intra predictor for the above template 610, which are located above and left of the above template 610. FIG. 6B shows the reference samples 625 that are used for generating the planar intra predictor for the left template 620, which are located above and left of the left template 620.

[0084] In some embodiments, shifted reference samples are used to generate planar intra-prediction for the template predictors, instead of using corresponding spatial neighboring reference samples. The shifted reference samples, for both the above template and the left template, are located in a reference line above the above template and left of the left template. FIGS. 7A-7B show shifted reference samples that are used for generating planar intra-predictor for TIMD. For a current block 700 having above template 710 and left template 720, FIG. 7A shows the shifted reference samples 712 and 714 used for generating the planar intra predictor for the above template 710. FIG. 7B shows the shifted reference samples 722 and 724 used for generating the planar intra predictor for the left template 720. The shifted samples 712, 714, 722, and 724 are all above the above template 710 and left of the left template 720.

[0085] In some embodiments, a block-size-based planar mode is used to generate planar intra-prediction for template predictors. When generating atemplate predictor, a block-sized template predictor with size of (block width x block height) is generated, but only a subsection of the template predictor with size of (template width x block height) or (block width x template height) is used for TIMD process. FIGS. 8A-8B illustrate the reference samples that are used for block-size- based planar mode for generating template predictor. As illustrated, the template predictors are generated for the above template 810 (sized W x H_temp) and the left template 820 (sized W_temp x H) near the current block 800 (sized W x H).

[0086] As illustrated in FIG. 8A, reference samples 812 above the above templates 810 providing the reference samples has width W of the current block 800. Reference samples 814 left of the left templates 820 has the height H of the current block 800. The reference samples 812 and 814 are used to generate a predictor 840 having the size of the current block 800 (W x H). A portion (W x template height) of the predictor 840 is used as the template predictor 845 for the above template 810 for planar mode intra-prediction.

[0087] As illustrated in FIG. 8B, reference samples 822 above the above templates 810 providing the reference samples has width W of the current block 800. Reference samples 824 left of the left templates 820 has the height H of the current block 800. The reference samples 822 and 824 are used to generate a predictor 850 having the size of the current block 800 (W x H). A portion (template width x H) of the predictor 850 is used as the template predictor 855 for the left template 820 for planar mode intra prediction.

[0088] In some embodiments, an inner L-shape-based planar mode is used to generate the template predictor Specifically, to generate the template predictor, areference line that surrounds (or neighbors or is adjacent to) the current block is used to generate template predictor having the corresponding size. FIGS. 9A-9B illustrate reference samples in a L-shaped reference line 930 that surrounds a current block 900 being used for generating planar intra-predictor for TIMD. FIG. 9A shows the portion of the L-shaped reference line 930 that surrounds the current block 900 to generate a predictor for the above template 910. FIG. 9B shows using a portion of the L-shaped reference line 930 that surrounds the current block 900 to generate a predictor for the left template 920.

[0089] In some embodiments, reference sample in an inverse L-shape surrounding the templates are used for generating planar predictor intra-prediction. One side in L-shape is reversed to surround the template predictor region to generate the template predictor using the spatial neighboring reference samples. For a current block 1000, above template 1010, and left template 1020, FIGS. 10A- 10C illustrate reference samples in inverse L-shaped reference lines 1030 and 1040 being used for generating planar intra-predictor for TIMD. The inverse L- shaped reference line 1032 surrounds the above templates 1010. The inverse L- shaped reference line 1034 surrounds the left template 1020. FIG. 10A illustrates using inverse L-shaped reference lines 1032 and 1034 to generate the planar intra predictor for both above and left templates 1010 and 1020. FIG. 10B illustrates using the inverse L-shaped reference line 1032 to generate planar intra predictor for the above template 1010. FIG. 10C illustrates using inverse L-shaped reference line 1034 to generate planar intra predictor for the left template 1020.

[0090] In some embodiments, an extrapolation-based planar mode is used forgenerating planar mode intra-prediction. For a current block 1100 and its above and left templates 1110 and 1120, FIGS. 11A-11B illustrate using extrapolationbased planar mode to generate planar mode intra-prediction for TIMD. First as shown in FIG. 11A, a sample 1131 is identified from a reference line 1130 at the left of the current block 1100, the sample 1131 being at a same vertical position as the bottom of the current block 1100. The sample 1131 is extended along the bottom of the current block 1100 to be become samples 1132 and used as a first anchor of extrapolation. (Already reconstructed) top reference samples 1140 along the top of the current block are used as the second anchor of extrapolation. The first and second anchor are used to calculate a gradient (GradA) from bottom to top. After deriving the gradient, the samples in the above template 1110 (e.g., positions labeled “B” in the figure) for bilinear interpolation in planar mode are set to equal to the top reference samples 1140 (positions labeled “A”) from current block plus gradient, where gradient value could be modified by some constant related to pixel line distance, or B= Clip(A + GradA * K).

[0091] Second, as shown in FIG. 11 B, a sample 1141 is identified from the reference line 1140 above the current block 1100, the sample 1141 being at the same horizontal position as the right side of the current block 1100. The sample 1141 is extended along the right side of the current block 1100 to become right reference samples 1142 to be used as a first anchor of extrapolation. (Already reconstructed) left reference samples 1130 along the left of the current block are used as second anchor of extrapolation. The first and second anchor are used to calculate a gradient (Grade) from right to left. After deriving the gradient, thesamples in the left template 1120 (e g., positions labeled “D” in the figure) for bilinear interpolation in planar mode are set to equal to the left reference samples 1130 (positions labeled “C”) from current block plus gradient, or D= Clip(C + Grade * K), where gradient value may be modified by some constant related to pixel line distance.

[0092] In some embodiments, for planar predictor in intra-prediction for TIMD, a whole block covering template region and the current block is used. FIG. 12 illustrates using a whole block covering the current block and the above and left templates to generate planar mode intra-prediction for TIMD. As illustrated, the size of the current block 1200 is Wx H, the size of the above template region 1210 is W x H_Above, and the size of the left template region 1220 is W_Left x H. A whole block 1205 covers the current block 1200, the above template 1210, and the left template 1220.

[0093] The outer reference samples 1230 of the whole block 1205 are used to generate a (W + W_Left) x (H_Above + H) planar predictor 1240, and some regions of this whole block predictor 1240 can be used as the above template planar predictor and left template planar predictor. For example, the region Wx H_Above inside the generated whole block planar predictor 1240 is used as above template predictor 1242 for the above template 1210 and the region W_Left x H inside the generated planar whole block predictor 1240 is used as left template predictor 1244 for the left template 1220.

[0094] C. Reference Line Based TIMD Horizontal and Vertical Predictor

[0095] In some embodiments, for horizontal and vertical predictor in intra-prediction, for each template predictor, some inverse intra-prediction is performed using reference line closer to current block. For example, for vertical mode in left- above-template case, when generating above-template predictor, inverse intraprediction is performed using reference line closer to current block. For a current block 1300 and its above and left templates 1310 and 1320, FIGS. 13A-13B illustrate the reference samples and reference lines used to generate horizontal and vertical intra predictors for TIMD.

[0096] FIG. 13A shows generating vertical mode intra predictor using a horizontal reference line 1330 that is close (adjacent) to top boundary of the current block 1300, with section 1332 of the reference line used to generate the template predictor for the above template 1310 and the section 1334 of the reference line used to generate the template predictor for the left template 1320.

[0097] FIG. 13B shows generating horizontal mode intra predictor using a vertical reference line 1340 that is close (adjacent) to the left boundary of the current block 1300, with section 1342 of the reference line used to generate the template predictor for the above template 1310 and the section 1344 of the reference line used to generate the template predictor for the left template 1320.

[0098] D. Reference Line based TIMD Angular Predictor

[0099] In some embodiments, for angular predictor in TIMD, for different intra prediction angle range (as shown in FIG. 1), different reference lines may be used to generate the template predictor. FIGS. 14A-14I illustrate the reference samples and reference lines used to generate angular intra predictor for different angle ranges for TIMD. The reference samples used for intra prediction of the currentblock 1400 and the templates 1410 and 1420 are from different reference lines 1430, 1435, 1440, and 1445. Reference lines 1430 and 1440 are closest / adjacent to the current block, while reference lines 1435 and 1445 are left of or above the templates.

[0100] FIGS. 14A-14C show the reference samples being used for intra prediction angles range between 18 (horizontal) and 50 (vertical). Reference lines 1430 and 1440 are used to provide reference samples the intra prediction of the template(s). Intra prediction angle is reversed to generate the template predictors for both templates 1410 and 1420. FIG. 14A shows the case when both above and left templates 1410 and 1420 are used TIMD. FIG. 14B shows the case when only the left template 1420 is used for TIMD. FIG. 14C shows the case when only the above template 1410 is used for TIMD.

[0101] FIGS. 14D-14F show the reference samples being used for intra prediction angles range less than 18 (17 and below). Intra prediction angle is reversed to generate the template predictor for the left template 1420 but not for the above template 1410. FIG. 14D shows the case when both above and left templates 1410 and 1420 are used for TIMD, where only the reference line 1440 is used for intra prediction. FIG. 14E shows the case when only the left template 1420 is used for TIMD, and that the reference lines 1430 and 1440 are used for intra prediction. FIG. 14F shows the case when only the above template 1410 is used for TIMD, and that the reference line 1435 and 1440 are used for intra prediction, the reference line 1435 being above the above template 1410, unlike reference line 1430.

[0102] FIGS. 14G-14I show the reference samples being used for intra prediction angles range more than 50 (51 and above). The intra prediction angle is reversed to generate the template predictor for the above template 1410 but not for the left template 1 20. FIG. 14G shows the case when both above and left templates 1410 and 1420 are used TIMD, where only the reference line 1430 is used for intra prediction. FIG. 14H shows the case when only the above template 1410 is used for TIMD, and that the reference line 1430 and 1440 are used for intra prediction. FIG. 141 shows the case when only the left template 1420 is used for TIMD, and that the reference lines 1430 and 1445 are used for intra prediction, the reference line 1445 being left of the left template 1420, unlike reference line 1440 which is adjacent to the current block.

[0103] E. Multiple Reference Line based TIMD for DC, Planar, and Angular Mode

[0104] In some embodiments, multiple reference lines may be used in TIMD to have more reference samples to generate template predictor. In some embodiments, multiple reference lines can also be used to generate angle- reversed and regular angle template predictor.

[0105] In some embodiments, multiple reference lines are used. In one or more reference lines, the intra prediction angles are reversed and in other reference lines, regular intra prediction angle is used. In some embodiments, multiple reference lines are used. One or more predictors generated from different reference lines or from regular intra prediction angle or from reversed intra prediction angle can be blended together to generate a final template predictor.

[0106] Any of the foregoing proposed methods can be implemented in encoders and / or decoders. For example, any of the proposed methods can be implemented in predictor derivation module of an encoder, and / or a predictor derivation module of a decoder. Alternatively, any of the proposed methods can be implemented as a circuit coupled to the predictor derivation module of the encoder and / or the predictor derivation module of the decoder, so as to provide the information needed by the predictor derivation module.I / . Example Video Encoder

[0107] FIG. 15 illustrates an example video encoder 1500 that may implement TIMD prediction. As illustrated, the video encoder 1500 receives input video signal from a video source 1505 and encodes the signal into bitstream 1595. The video encoder 1500 has several components or modules for encoding the signal from the video source 1505, at least including some components selected from a transform module 1510, a quantization module 1511 , an inverse quantization module 1514, an inverse transform module 1515, an intra estimation module 1524, an intra prediction module 1525, a motion compensation module 1530, a motion estimation module 1535, an in-loop filter 1545, a reconstructed picture buffer 1550, a MV buffer 1565, and a MV prediction module 1575, and an entropy encoder 1590. The motion compensation module 1530 and the motion estimation module 1535 are part of an inter-prediction module 1540. The intra-prediction module 1525 and the intra- estimation module 1524 are part of a current picture prediction module 1520, which uses current picture reconstructed samples as reference samples for prediction of the current block.

[0108] In some embodiments, the modules 1510 - 1590 are modules of software instructions being executed by one or more processing units (e.g., a processor) of a computing device or electronic apparatus. In some embodiments, the modules 1510 - 1590 are modules of hardware circuits implemented by one or more integrated circuits (ICs) of an electronic apparatus. Though the modules 1510 - 1590 are illustrated as being separate modules, some of the modules can be combined into a single module.

[0109] The video source 1505 provides a raw video signal that presents pixel data of each video frame without compression. A subtractor 1508 computes the difference between the raw video pixel data of the video source 1505 and the predicted pixel data 1513 from the motion compensation module 1530 or intraprediction module 1525 as prediction residual 1509. The transform module 1510 converts the difference (or the residual pixel data or residual signal 1508) into transform coefficients (e.g., by performing Discrete Cosine Transform, or DCT). The quantization module 1511 quantizes the transform coefficients into quantized data (or quantized coefficients) 1512, which is encoded into the bitstream 1595 by the entropy encoder 1590.

[0110] The inverse quantization module 1514 de-quantizes the quantized data (or quantized coefficients) 1512 to obtain transform coefficients 1518, and the inverse transform module 1515 performs inverse transform on the transform coefficients 1518 to produce reconstructed residual 1519. The reconstructed residual 1519 is added with the predicted pixel data 1513 to produce reconstructed pixel data 1517. In some embodiments, the reconstructed pixel data 1517 istemporarily stored in a line buffer 1527 (or intra prediction buffer) for intra-picture prediction and spatial MV prediction. The reconstructed pixels are filtered by the in-loop filter 1545 and stored in the reconstructed picture buffer 1550. In some embodiments, the reconstructed picture buffer 1550 is a storage external to the video encoder 1500. In some embodiments, the reconstructed picture buffer 1550 is a storage internal to the video encoder 1500.

[0111] The intra estimation module 1524 derives intra-prediction data (e.g., intra prediction modes) based on the reconstructed pixel data 1517 (stored in the line buffer 1527). The intra-prediction data is provided to the entropy encoder 1590 to be encoded into bitstream 1595. The intra-prediction data is also used by the intraprediction module 1525 to produce the predicted pixel data 1513.

[0112] The motion estimation module 1535 performs inter-prediction by producing MVs to reference pixel data of previously decoded frames stored in the reconstructed picture buffer 1550. These MVs are provided to the motion compensation module 1530 to produce predicted pixel data.

[0113] Instead of encoding the complete actual MVs in the bitstream, the video encoder 1500 uses MV prediction to generate predicted MVs, and the difference between the MVs used for motion compensation and the predicted MVs is encoded as residual motion data and stored in the bitstream 1595.

[0114] The MV prediction module 1575 generates the predicted MVs based on reference MVs that were generated for encoding previously video frames, i.e. , the motion compensation MVs that were used to perform motion compensation. The MV prediction module 1575 retrieves reference MVs from previous video framesfrom the MV buffer 1565. The video encoder 1500 stores the MVs generated for the current video frame in the MV buffer 1565 as reference MVs for generating predicted MVs.

[0115] The MV prediction module 1575 uses the reference MVs to create the predicted MVs. The predicted MVs can be computed by spatial MV prediction or temporal MV prediction. The difference between the predicted MVs and the motion compensation MVs (MC MVs) of the current frame (residual motion data) are encoded into the bitstream 1595 by the entropy encoder 1590.

[0116] The entropy encoder 1590 encodes various parameters and data into the bitstream 1595 by using entropy-coding techniques such as context-adaptive binary arithmetic coding (CABAC) or Huffman encoding. The entropy encoder 1590 encodes various header elements, flags, along with the quantized transform coefficients 1512, and the residual motion data as syntax elements into the bitstream 1595. The bitstream 1595 is in turn stored in a storage device or transmitted to a decoder over a communications medium such as a network.

[0117] The in-loop filter 1545 performs filtering or smoothing operations on the reconstructed pixel data 1517 to reduce the artifacts of coding, particularly at boundaries of pixel blocks. In some embodiments, the filtering or smoothing operations performed by the in-loop filter 1545 include deblock filter (DBF), sample adaptive offset (SAO), and / or adaptive loop filter (ALF). In some embodiments, luma mapping chroma scaling (LMCS) is performed before the loop filters.

[0118] FIG. 16 illustrates portions of the video encoder 1500 that implementTIMD with adaptive reference line selection. Specifically, the figure illustrates thecomponents of the current picture prediction module 1520 of the video encoder 1500. As illustrated, the current picture prediction module 1520 includes a template predictor generator 1610, a TIMD process module 1620, and the intra-prediction module 1525.

[0119] For each template region (e.g., above template or left template of the current block), the template predictor generator 1610 generates a template predictor for each of the candidate intra prediction modes for TIMD. The candidate intra prediction modes may include some or all 67 intra prediction modes, including DC mode, planar mode, and some or all of the angular intra modes (2 to 66). The generated template predictors 1615 for the template region(s) are provided to the TIMD process module 1620 for the different candidate intra modes. Sections IV- A, IV-B, IV-C, and IV-D describe various methods for generating template predictors for different candidate intra prediction modes.

[0120] In some embodiments, the template predictor generator 1610 (with a reference line selector 1612) may use different sets of reference samples from different reference lines for different candidate intra modes and / or for different template regions. The different reference lines may occupy different rows or different columns of the current block. One candidate intra mode may use a reference line that is adjacent or closest to the current block, while another candidate intra mode may use a reference line that is left of the left template and above the above the template, still another candidate intra mode may use reference samples in different rows or different columns for when the above template is unavailable and for when the left template is unavailable. The adaptiveselection of different sets of reference samples or reference lines are described in Section IV for different intra modes.

[0121] The TIMD process module 1620 uses the generated template predictors 1615 for the different candidate intra modes to select one or more TIMD intra modes 1625. For each candidate intra mode, the TIMD process module 1620 computes a difference value (e.g., SATD) between the corresponding template predictor with the template’s reconstructed samples (retrieved from the reconstructed picture buffer 1550 and the line buffer 1527). The selection of the TIMD intra modes is made based on the computed different values for the different candidate intra modes. The selected TIMD intra mode(s) is / are provided to the intra prediction module 1525, which may generate a predictor 1630 of the current block based on the selected TIMD intra mode(s). The generated predictor may then be used as the predicted pixel data 1513.

[0122] FIG. 17 conceptually illustrates a process 1700 that encodes a block of pixels using TIMD with adaptive reference line selection. In some embodiments, one or more processing units (e.g., a processor) of a computing device implementing the encoder 1500 performs the process 1700 by executing instructions stored in a computer readable medium. In some embodiments, an electronic apparatus implementing the encoder 1500 performs the process 1700.

[0123] The encoder receives (at block 1710) data to be encoded as a current block of pixels in a current picture.

[0124] The encoder generates (at block 1720) a prediction of a template region neighboring the current block for each candidate intra mode in a set of candidateintra modes, where different sets of reference samples from different reference lines are used for predictions for at least two different candidate intra modes and / or different template regions. A set of reference samples may occupy a row of samples neighboring the current block, a column of samples neighboring the current block, a L-shape of samples neighboring the current block, or a L-shape of samples neighboring a combination of the current block and at least a part of the template region.

[0125] In some embodiments, the predictions of the above template and of the left templates may use different sets of reference samples that occupy different rows or different columns of the current picture (as described by reference to e.g., FIGS. 6A-6B). In some embodiments, the prediction of the template region uses different sets of reference samples that occupy different rows or different columns of the current picture for when the template region does not comprise an above template versus when the template region does not comprise a left template (as described by reference to e.g., FIGS. 14D-14F or 14G-14I).

[0126] In some embodiments, a first set of reference samples is used for generating a first prediction of the template region for the first candidate intra mode and a second set of reference samples is used for generating a second prediction of the template region for the second candidate intra mode, with the first set of reference samples occupying a first row or column of the current picture and the second set of reference samples occupying a second, different row or column of the current picture.

[0127] For example, the first set of reference samples may be in an inner most reference line that is adjacent to the current block and the second set of reference samples may be in a reference line that is above the template region or left of the template region.

[0128] For example, the first candidate intra mode may be planar intra mode that uses the inner most reference line (as described by reference to e.g., FIGS. 9A- 11 B) and the second candidate intra mode may be an angular intra mode that is below horizontal (<18) or beyond vertical (>50) which uses a reference line that is left of the template region or above the template region.

[0129] For another example, the first candidate intra mode may be an angular intra mode that is between horizontal (mode 18) and vertical (mode 50) (as described by reference to e.g., FIGS. 14A-14C), or is DC intra mode (as described by reference to e.g., FIGS. 5A-5C) that use the inner most reference line, while the second candidate intra mode may be planar intra mode (as described by reference to e.g., FIGS. 7A-8B) that use reference lines above or left of the template region.

[0130] In some embodiments, when the first candidate intra mode is an angular intra mode in vertical angular direction, the first set of reference samples is in a reference line adjacent to top side of the current block, and when the first candidate intra mode is an angular intra mode in horizontal angular direction, the first set of reference samples is in a reference line adjacent to left side of the current block (as described by reference to e.g., FIGS. 13A-13B.)

[0131] In some embodiments, at least a part of the first set of reference samples is reversed for generating the first prediction of the template region for the firstcandidate intra mode, and a remaining part of the first set of reference samples is not reversed for generating the first prediction of the template region for the first candidate intra mode. When the first candidate intra mode is an angular intra mode between horizontal angular direction and vertical angular direction, an intra prediction angle is reversed to generate the prediction of the template region. When the first candidate intra mode is an angular intra mode below horizontal angular direction, an intra prediction angle for the left template is reversed to generate the prediction of the template region. When the first candidate intra mode is an angular intra mode beyond vertical angular direction an intra prediction angle for the above template is reversed to generate the prediction of the template region.

[0132] In some embodiments, a prediction by planar intra mode may be generated by using reference samples to generate a predictor having a size of the current block (as described by reference to e.g., FIGS. 8A-8B). In some embodiments, a prediction by planar intra mode is generated by using reference samples to generate a prediction of a region that encompass the template region and the current block (as described by reference to e.g., FIGS. 12). In some embodiments, a prediction by planar intra mode prediction may be extrapolated from reference samples near bottom of the current block and reference samples that are above the current block, (as described by reference to e.g., FIGS. 11A- 11 B).

[0133] The encoder computes (at block 1730) a difference value (e.g., SATD or SAD) between reconstruction samples of the template region and the generated prediction of the template region for each candidate intra mode. The encoderderives (at block 1740) or select an intra mode based on the computed difference values for the different candidate intra modes. The encoder computes (at block 1750) a predictor of the current block based on the derived intra mode. The encoder encodes (at block 1760) the current block by using computed predictor to produce prediction residuals.VI. Example Video Decoder

[0134] In some embodiments, an encoder may signal (or generate) one or more syntax element in a bitstream, such that a decoder may parse said one or more syntax element from the bitstream.

[0135] FIG. 18 illustrates an example video decoder 1800 that may implement TIMD prediction. As illustrated, the video decoder 1800 is an image-decoding or video-decoding circuit that receives a bitstream 1895 and decodes the content of the bitstream into pixel data of video frames for display. The video decoder 1800 has several components or modules for decoding the bitstream 1895, including some components selected from an inverse quantization module 181 , an inverse transform module 1815, an intra-prediction module 1825, a motion compensation module 1830, an in-loop filter 1845, a decoded picture buffer 1850, a MV buffer 1865, a MV prediction module 1875, and a parser 1890. The motion compensation module 1830 is part of an inter-prediction module 1840. The intra-prediction module 1825 is part of a current picture prediction module 1820, which uses current picture reconstructed samples as reference samples for prediction of the current block.

[0136] In some embodiments, the modules 1814 - 1890 are modules ofsoftware instructions being executed by one or more processing units (e.g., a processor) of a computing device. In some embodiments, the modules 1814 - 1890 are modules of hardware circuits implemented by one or more ICs of an electronic apparatus. Though the modules 1814 - 1890 are illustrated as being separate modules, some of the modules can be combined into a single module.

[0137] The parser 1890 (or entropy decoder) receives the bitstream 1895 and performs initial parsing according to the syntax defined by a video-coding or imagecoding standard. The parsed syntax element includes various header elements, flags, as well as quantized data (or quantized coefficients) 1812. The parser 1890 parses out the various syntax elements by using entropy-coding techniques such as context-adaptive binary arithmetic coding (CABAC) or Huffman encoding.

[0138] The inverse quantization module 1814 de-quantizes the quantized data (or quantized coefficients) 1812 to obtain transform coefficients, and the inverse transform module 1815 performs inverse transform on the transform coefficients 1818 to produce reconstructed residual signal 1819. The reconstructed residual signal 1819 is added with predicted pixel data 1813 from the intra-prediction module 1825 or the motion compensation module 1830 to produce decoded pixel data 1817. The decoded pixels data are filtered by the in-loop filter 1845 and stored in the decoded picture buffer 1850. In some embodiments, the decoded picture buffer 1850 is a storage external to the video decoder 1800. In some embodiments, the decoded picture buffer 1850 is a storage internal to the video decoder 1800.

[0139] The intra-prediction module 1825 receives intra-prediction data from bitstream 1895 and according to which, produces the predicted pixel data 1813from the decoded pixel data 1817 stored in the decoded picture buffer 1850. In some embodiments, the decoded pixel data 1817 is also stored in a line buffer 1827 (or intra prediction buffer) for intra-picture prediction and spatial MV prediction.

[0140] In some embodiments, the content of the decoded picture buffer 1850 is used for display. A display device 1805 either retrieves the content of the decoded picture buffer 1850 for display directly, or retrieves the content of the decoded picture buffer to a display buffer. In some embodiments, the display device receives pixel values from the decoded picture buffer 1850 through a pixel transport.

[0141] The motion compensation module 1830 produces predicted pixel data 1813 from the decoded pixel data 1817 stored in the decoded picture buffer 1850 according to motion compensation MVs (MC MVs). These motion compensation MVs are decoded by adding the residual motion data received from the bitstream 1895 with predicted MVs received from the MV prediction module 1875.

[0142] The MV prediction module 1875 generates the predicted MVs based on reference MVs that were generated for decoding previous video frames, e.g., the motion compensation MVs that were used to perform motion compensation. The MV prediction module 1875 retrieves the reference MVs of previous video frames from the MV buffer 1865. The video decoder 1800 stores the motion compensation MVs generated for decoding the current video frame in the MV buffer 1865 as reference MVs for producing predicted MVs.

[0143] The in-loop filter 1845 performs filtering or smoothing operations on thedecoded pixel data 1817 to reduce the artifacts of coding, particularly at boundaries of pixel blocks. In some embodiments, the filtering or smoothing operations performed by the in-loop filter 1845 include deblock filter (DBF), sample adaptive offset (SAO), and / or adaptive loop filter (ALF). In some embodiments, luma mapping chroma scaling (LMCS) is performed before the loop filters.

[0144] FIG. 19 illustrates portions of the video decoder 1800 that implement TIMD with adaptive reference line selection. Specifically, the figure illustrates the components of the current picture prediction module 1820 of the video decoder 1800. As illustrated, the current picture prediction module 1820 includes a template predictor generator 1910, a TIMD process module 1920, and the intra-prediction module 1825.

[0145] For each template region (e.g., above template or left template of the current block), the template predictor generator 1910 generates a template predictor for each of the candidate intra prediction modes for TIMD. The candidate intra prediction modes may include some or all 67 intra prediction modes, including DC mode, planar mode, and some or all of the angular intra modes (2 to 66). The generated template predictors 1915 for the template region(s) are provided to the TIMD process module 1920 for the different candidate intra modes. Sections IV- A, IV-B, IV-C, and IV-D describe various methods for generating template predictors for different candidate intra prediction modes.

[0146] In some embodiments, the template predictor generator 1910 (with a reference line selector 1912) may use different sets of reference samples from different reference lines for different candidate intra modes and / or for differenttemplate regions. The different reference lines may occupy different rows or different columns of the current block. One candidate intra mode may use a reference line that is adjacent or closest to the current block, while another candidate intra mode may use a reference line that is left of the left template and above the above the template, still another candidate intra mode may use reference samples in different rows or different columns for when the above template is unavailable and for when the left template is unavailable. The adaptive selection of different sets of reference samples or reference lines are described in Section IV for different intra modes.

[0147] The TIMD process module 1920 uses the generated template predictors 1915 for the different candidate intra modes to select one or more TIMD intra modes 1925. For each candidate intra mode, the TIMD process module 1920 computes a difference value (e.g., SATD) between the corresponding template predictor with the template’s reconstructed samples (retrieved from the decoded picture buffer 1850 and the line buffer 1827). The selection of the TIMD intra modes is made based on the computed different values for the different candidate intra modes. The selected TIMD intra mode(s) is / are provided to the intra prediction module 1825, which may generate a predictor 1930 of the current block based on the selected TIMD intra mode(s). The generated predictor may then be used as the predicted pixel data 1813.

[0148] FIG. 20 conceptually illustrates a process 2000 that decodes a block of pixels using TIMD with adaptive reference line selection. In some embodiments, one or more processing units (e.g., a processor) of a computing deviceimplementing the decoder 1800 performs the process 2000 by executing instructions stored in a computer readable medium. In some embodiments, an electronic apparatus implementing the decoder 1800 performs the process 2000.

[0149] The decoder receives (at block 2010) data to be decoded as a current block of pixels in a current picture.

[0150] The decoder generates (at block 2020) a prediction of a template region neighboring the current block for each candidate intra mode in a set of candidate intra modes, where different sets of reference samples from different reference lines are used for predictions for at least two different candidate intra modes and / or different template regions. A set of reference samples may occupy a row of samples neighboring the current block, a column of samples neighboring the current block, a L-shape of samples neighboring the current block, or a L-shape of samples neighboring a combination of the current block and at least a part of the template region.

[0151] In some embodiments, the predictions of the above template and of the left templates may use different sets of reference samples that occupy different rows or different columns of the current picture (as described by reference to e.g., FIGS. 6A-6B). In some embodiments, the prediction of the template region uses different sets of reference samples that occupy different rows or different columns of the current picture for when the template region does not comprise an above template versus when the template region does not comprise a left template (as described by reference to e.g., FIGS. 14D-14F or 14G-14I).

[0152] In some embodiments, a first set of reference samples is used for generating a first prediction of the template region for the first candidate intra mode and a second set of reference samples is used for generating a second prediction of the template region for the second candidate intra mode, with the first set of reference samples occupying a first row or column of the current picture and the second set of reference samples occupying a second, different row or column of the current picture.

[0153] For example, the first set of reference samples may be in an inner most reference line that is adjacent to the current block and the second set of reference samples may be in a reference line that is above the template region or left of the template region.

[0154] For example, the first candidate intra mode may be planar intra mode that uses the inner most reference line (as described by reference to e.g., FIGS. 9A- 11 B) and the second candidate intra mode may be an angular intra mode that is below horizontal (<18) or beyond vertical (>50) which uses a reference line that is left of the template region or above the template region.

[0155] For another example, the first candidate intra mode may be an angular intra mode that is between horizontal (mode 18) and vertical (mode 50) (as described by reference to e.g., FIGS. 14A-14C), or is DC intra mode (as described by reference to e.g., FIGS. 5A-5C) that use the inner most reference line, while the second candidate intra mode may be planar intra mode (as described by reference to e.g., FIGS. 7A-8B) that use reference lines above or left of the template region.

[0156] In some embodiments, when the first candidate intra mode is an angular intra mode in vertical angular direction, the first set of reference samples is in a reference line adjacent to top side of the current block, and when the first candidate intra mode is an angular intra mode in horizontal angular direction, the first set of reference samples is in a reference line adjacent to left side of the current block (as described by reference to e.g., FIGS. 13A-13B.)

[0157] In some embodiments, at least a part of the first set of reference samples is reversed for generating the first prediction of the template region for the first candidate intra mode, and a remaining part of the first set of reference samples is not reversed for generating the first prediction of the template region for the first candidate intra mode. When the first candidate intra mode is an angular intra mode between horizontal angular direction and vertical angular direction, an intra prediction angle is reversed to generate the prediction of the template region. When the first candidate intra mode is an angular intra mode below horizontal angular direction, an intra prediction angle for the left template is reversed to generate the prediction of the template region. When the first candidate intra mode is an angular intra mode beyond vertical angular direction an intra prediction angle for the above template is reversed to generate the prediction of the template region.

[0158] In some embodiments, a prediction by planar intra mode may be generated by using reference samples to generate a predictor having a size of the current block (as described by reference to e.g., FIGS. 8A-8B). In some embodiments, a prediction by planar intra mode is generated by using reference samples to generate a prediction of a region that encompass the template regionand the current block (as described by reference to e.g., FIGS. 12). In some embodiments, a prediction by planar intra mode prediction may be extrapolated from reference samples near bottom of the current block and reference samples that are above the current block, (as described by reference to e.g., FIGS. 11A- 11 B).

[0159] The decoder computes (at block 2030) a difference value (e.g., SATD or SAD) between reconstruction samples of the template region and the generated prediction of the template region for each candidate intra mode. The decoder derives (at block 2040) or select an intra mode based on the computed difference values for the different candidate intra modes. The decoder computes (at block 2050) a predictor of the current block based on the derived intra mode. The decoder reconstructs (at block 2060) the current block by using computed predictor to combine with prediction residuals. The decoder may then provide the reconstructed current block for display or output as part of the reconstructed current picture.VII. Example Electronic System

[0160] Many of the above-described features and applications are implemented as software processes that are specified as a set of instructions recorded on a computer readable storage medium (also referred to as computer readable medium). When these instructions are executed by one or more computational or processing unit(s) (e.g., one or more processors, cores of processors, or other processing units), they cause the processing unit(s) to perform the actions indicated in the instructions. Examples of computer readable media include, butare not limited to, CD-ROMs, flash drives, random-access memory (RAM) chips, hard drives, erasable programmable read only memories (EPROMs), electrically erasable programmable read-only memories (EEPROMs), etc. The computer readable media does not include carrier waves and electronic signals passing wirelessly or over wired connections.

[0161] In this specification, the term “software” is meant to include firmware residing in read-only memory or applications stored in magnetic storage which can be read into memory for processing by a processor. Also, in some embodiments, multiple software inventions can be implemented as sub-parts of a larger program while remaining distinct software inventions. In some embodiments, multiple software inventions can also be implemented as separate programs. Finally, any combination of separate programs that together implement a software invention described here is within the scope of the present disclosure. In some embodiments, the software programs, when installed to operate on one or more electronic systems, define one or more specific machine implementations that execute and perform the operations of the software programs.

[0162] FIG. 21 conceptually illustrates an electronic system 2100 with which some embodiments of the present disclosure are implemented. The electronic system 2100 may be a computer (e g., a desktop computer, personal computer, tablet computer, etc.), phone, PDA, or any other sort of electronic device. Such an electronic system includes various types of computer readable media and interfaces for various other types of computer readable media. Electronic system 2100 includes a bus 2105, processing unit(s) 2110, a graphics-processing unit(GPU) 2115, a system memory 2120, a network 2125, a read-only memory 2130, a permanent storage device 2135, input devices 2140, and output devices 2145.

[0163] The bus 2105 collectively represents all system, peripheral, and chipset buses that communicatively connect the numerous internal devices of the electronic system 2100. For instance, the bus 2105 communicatively connects the processing unit(s) 2110 with the GPU 2115, the read-only memory 2130, the system memory 2120, and the permanent storage device 2135.

[0164] From these various memory units, the processing unit(s) 2110 retrieves instructions to execute and data to process in order to execute the processes of the present disclosure. The processing unit(s) may be a single processor or a multi-core processor in different embodiments. Some instructions are passed to and executed by the GPU 2115. The GPU 2115 can offload various computations or complement the image processing provided by the processing unit(s) 2110.

[0165] The read-only-memory (ROM) 2130 stores static data and instructions that are used by the processing unit(s) 2110 and other modules of the electronic system. The permanent storage device 2135, on the other hand, is a read-and- write memory device. This device is a non-volatile memory unit that stores instructions and data even when the electronic system 2100 is off. Some embodiments of the present disclosure use a mass-storage device (such as a magnetic or optical disk and its corresponding disk drive) as the permanent storage device 2135.

[0166] Other embodiments use a removable storage device (such as a floppy disk, flash memory device, etc., and its corresponding disk drive) as the permanentstorage device. Like the permanent storage device 2135, the system memory 2120 is a read-and-write memory device. However, unlike storage device 2135, the system memory 2120 is a volatile read-and-write memory, such a random access memory. The system memory 2120 stores some of the instructions and data that the processor uses at runtime. In some embodiments, processes in accordance with the present disclosure are stored in the system memory 2120, the permanent storage device 2135, and / or the read-only memory 2130. For example, the various memory units include instructions for processing multimedia clips in accordance with some embodiments. From these various memory units, the processing unit(s) 2110 retrieves instructions to execute and data to process in order to execute the processes of some embodiments.

[0167] The bus 2105 also connects to the input and output devices 2140 and 2145. The input devices 2140 enable the user to communicate information and select commands to the electronic system. The input devices 2140 include alphanumeric keyboards and pointing devices (also called “cursor control devices”), cameras (e.g., webcams), microphones or similar devices for receiving voice commands, etc. The output devices 2145 display images generated by the electronic system or otherwise output data. The output devices 2145 include printers and display devices, such as cathode ray tubes (CRT) or liquid crystal displays (LCD), as well as speakers or similar audio output devices. Some embodiments include devices such as a touchscreen that function as both input and output devices.

[0168] Finally, as shown in FIG. 21 , bus 2105 also couples electronic system 2100 to a network 2125 through a network adapter (not shown). In this manner, the computer can be a part of a network of computers (such as a local area network (“LAN”), a wide area network (“WAN”), or an Intranet, or a network of networks, such as the Internet. Any or all components of electronic system 2100 may be used in conjunction with the present disclosure.

[0169] Some embodiments include electronic components, such as microprocessors, storage and memory that store computer program instructions in a machine-readable or computer-readable medium (alternatively referred to as computer-readable storage media, machine-readable media, or machine-readable storage media). Some examples of such computer-readable media include RAM, ROM, read-only compact discs (CD-ROM), recordable compact discs (CD-R), rewritable compact discs (CD-RW), read-only digital versatile discs (e.g., DVD- ROM, dual-layer DVD-ROM), a variety of recordable / rewritable DVDs (e.g., DVD- RAM, DVD-RW, DVD+RW, etc.), flash memory (e.g., SD cards, mini-SD cards, micro-SD cards, etc.), magnetic and / or solid state hard drives, read-only and recordable Blu-Ray® discs, ultra-density optical discs, any other optical or magnetic media, and floppy disks. The computer-readable media may store a computer program that is executable by at least one processing unit and includes sets of instructions for performing various operations. Examples of computer programs or computer code include machine code, such as is produced by a compiler, and files including higher-level code that are executed by a computer, an electronic component, or a microprocessor using an interpreter.

[0170] While the above discussion primarily refers to microprocessor or multicore processors that execute software, many of the above-described features and applications are performed by one or more integrated circuits, such as application specific integrated circuits (ASICs) or field programmable gate arrays (FPGAs). In some embodiments, such integrated circuits execute instructions that are stored on the circuit itself. In addition, some embodiments execute software stored in programmable logic devices (PLDs), ROM, or RAM devices.

[0171] As used in this specification and any claims of this application, the terms “computer”, “server”, “processor”, and “memory” all refer to electronic or other technological devices. These terms exclude people or groups of people. For the purposes of the specification, the terms display or displaying means displaying on an electronic device. As used in this specification and any claims of this application, the terms “computer readable medium,” “computer readable media,” and “machine readable medium” are entirely restricted to tangible, physical objects that store information in a form that is readable by a computer. These terms exclude any wireless signals, wired download signals, and any other ephemeral signals.

[0172] While the present disclosure has been described with reference to numerous specific details, one of ordinary skill in the art will recognize that the present disclosure can be embodied in other specific forms without departing from the spirit of the present disclosure. In addition, a number of the figures (including FIG. 17 and FIG. 20) conceptually illustrate processes. The specific operations of these processes may not be performed in the exact order shown and described.The specific operations may not be performed in one continuous series ofoperations, and different specific operations may be performed in different embodiments. Furthermore, the process could be implemented using several subprocesses, or as part of a larger macro process. Thus, one of ordinary skill in the art would understand that the present disclosure is not to be limited by the foregoing illustrative details, but rather is to be defined by the appended claims.Additional Notes

[0173] The herein-described subject matter sometimes illustrates different components contained within, or connected with, different other components. It is to be understood that such depicted architectures are merely examples, and that in fact many other architectures can be implemented which achieve the same functionality. In a conceptual sense, any arrangement of components to achieve the same functionality is effectively "associated" such that the desired functionality is achieved. Hence, any two components herein combined to achieve a particular functionality can be seen as "associated with" each other such that the desired functionality is achieved, irrespective of architectures or intermediate components. Likewise, any two components so associated can also be viewed as being "operably connected", or "operably coupled", to each other to achieve the desired functionality, and any two components capable of being so associated can also be viewed as being "operably couplable", to each other to achieve the desired functionality. Specific examples of operably couplable include but are not limited to physically mateable and / or physically interacting components and / or wirelessly interactable and / or wirelessly interacting components and / or logically interacting and / or logically interactable components.

[0174] Further, with respect to the use of substantially any plural and / or singular terms herein, those having skill in the art can translate from the plural to the singular and / or from the singular to the plural as is appropriate to the context and / or application. The various singular / plural permutations may be expressly set forth herein for sake of clarity.

[0175] Moreover, it will be understood by those skilled in the art that, in general, terms used herein, and especially in the appended claims, e.g., bodies of the appended claims, are generally intended as “open” terms, e.g., the term “including” should be interpreted as “including but not limited to,” the term “having” should be interpreted as “having at least,” the term “includes” should be interpreted as “includes but is not limited to,” etc. It will be further understood by those within the art that if a specific number of an introduced claim recitation is intended, such an intent will be explicitly recited in the claim, and in the absence of such recitation no such intent is present. For example, as an aid to understanding, the following appended claims may contain usage of the introductory phrases "at least one" and "one or more" to introduce claim recitations. However, the use of such phrases should not be construed to imply that the introduction of a claim recitation by the indefinite articles "a" or "an" limits any particular claim containing such introduced claim recitation to implementations containing only one such recitation, even when the same claim includes the introductory phrases "one or more" or "at least one" and indefinite articles such as "a" or "an," e.g., “a” and / or “an” should be interpreted to mean “at least one” or “one or more;” the same holds true for the use of definite articles used to introduce claim recitations. In addition, even if a specific numberof an introduced claim recitation is explicitly recited, those skilled in the art will recognize that such recitation should be interpreted to mean at least the recited number, e.g., the bare recitation of "two recitations," without other modifiers, means at least two recitations, or two or more recitations. Furthermore, in those instances where a convention analogous to “at least one of A, B, and C, etc.” is used, in general such a construction is intended in the sense one having skill in the art would understand the convention, e.g., “a system having at least one of A, B, and C” would include but not be limited to systems that have A alone, B alone, C alone, A and B together, A and C together, B and C together, and / or A, B, and C together, etc. In those instances where a convention analogous to “at least one of A, B, or C, etc.” is used, in general such a construction is intended in the sense one having skill in the art would understand the convention, e.g., “a system having at least one of A, B, or C” would include but not be limited to systems that have A alone, B alone, C alone, A and B together, A and C together, B and C together, and / or A, B, and C together, etc. It will be further understood by those within the art that virtually any disjunctive word and / or phrase presenting two or more alternative terms, whether in the description, claims, or drawings, should be understood to contemplate the possibilities of including one of the terms, either of the terms, or both terms. For example, the phrase “A or B” will be understood to include the possibilities of “A” or “B” or “A and B.”

[0176] From the foregoing, it will be appreciated that various implementations of the present disclosure have been described herein for purposes of illustration, and that various modifications may be made without departing from the scope and spiritof the present disclosure. Accordingly, the various implementations disclosed herein are not intended to be limiting, with the true scope and spirit being indicated by the following claims.

Claims

CLAIMSWhat is claimed is:

1. A video coding method comprising: receiving data to be encoded or decoded as a current block of pixels of a current picture of a video; generating a prediction of a template region neighboring the current block for each candidate intra mode in a set of candidate intra modes comprising at least first and second candidate intra modes, wherein a first set of reference samples is used for generating a first prediction of the template region for the first candidate intra mode and a second set of reference samples is used for generating a second prediction of the template region for the second candidate intra mode, wherein the first set of reference samples occupy a first row or column of the current picture and the second set of reference samples occupy a second, different row or column of the current picture; computing a difference value between reconstruction samples of the template region and the generated prediction of the template region for each candidate intra mode in the set of two or more candidate intra modes; deriving an intra mode based on the computed difference values for the set of candidate intra modes; computing a predictor of the current block based on the derived intra mode; and encoding or decoding the current block by using the computed predictor.

2. The video coding method of claim 1 , wherein the first set of reference samples are in an inner most reference line that is adjacent to the current block and the second set of reference samples are in a reference line that is above the template region or left of the template region.

3. The video coding method of claim 2, wherein the first candidate intra mode is an angular intra mode between horizontal angular direction and vertical angular direction and the second candidate intra mode is an angular intra mode below horizontal angular direction or beyond vertical angular direction.

4. The video coding method of claim 2, wherein the second candidate intra mode is planar intra mode.

5. The video coding method of claim 4, wherein the first candidate intra mode is an angular intra mode below horizontal angular direction or beyond vertical angular direction.

6. The video coding method of claim 4, wherein the first candidate intra mode is DC intra mode, wherein: when the current block is a square block, a prediction by DC intra mode is the average sample value of samples in a reference line adjacent to the current block at the current block’s above-side and left-side;when the current block is a non-square block with longer-side samples above the current block, a prediction by DC intra mode is the average of samples in the reference line adjacent to the above-side of the current block; when the current block is a non-square block with longer-side samples at left of the current block, a prediction by DC intra mode is the average of samples in the reference line adjacent to the left-side of the current block.

7. The video coding method of claim 4, wherein the prediction by planar intra mode is generated by using the second set of reference samples to generate a predictor having a size of the current block.

8. The video coding method of claim 4, wherein the prediction by planar intra mode is generated by using the second set of reference samples to generate a prediction of a region that encompass the template region and the current block.

9. The video coding method of claim 1 , wherein the first candidate intra mode is planar intra mode that uses inner most reference line and the second candidate intra mode is an angular intra mode using a reference line that is left of the template region or above the template region, the angular intra mode being below horizontal angular direction or beyond vertical angular direction.

10. The video coding method of claim 9, wherein the planar intra mode prediction is extrapolated from reference samples near bottom of the current block and reference samples that are above the current block.

11. The video coding method of claim 1 , wherein the first set of reference samples are in an inner most reference line that is adjacent to the current block and the second set of reference samples are in a reference line that is adjacent to the template region at its left side and its above side.

12. The video coding method of claim 1 , wherein the template region comprises an above template that is above the current block and a left template that is left of the current block and a prediction of the template region comprises a prediction of the above template and a prediction of the left template, wherein the prediction of the above template and the prediction of the left template use different sets of reference samples that occupy different rows or different columns of the current picture.

13. The video coding method of claim 1 , wherein the prediction of the template region uses different sets of reference samples that occupy different rows or different columns of the current picture for when the template region does not comprise an above template versus when the template region does not comprise a left template.

14. The video coding method of claim 1 , wherein at least a part of the first set of reference samples is reversed for generating the first prediction of the template region for the first candidate intra mode, and a remaining part of the first set of reference samples is not reversed for generating the first prediction of the template region for the first candidate intra mode.

15. The video coding method of claim 1 , wherein when the first candidate intra mode is an angular intra mode between horizontal angular direction and vertical angular direction, an intra prediction angle is reversed to generate the prediction of the template region.

16. The video coding method of claim 1 , wherein when the first candidate intra mode is an angular intra mode below horizontal angular direction, an intra prediction angle for the left template is reversed to generate the prediction of the template region.

17. The video coding method of claim 1 , wherein when the first candidate intra mode is an angular intra mode beyond vertical angular direction an intra prediction angle for the above template is reversed to generate the prediction of the template region.

18. The video coding method of claim 1 , wherein when the first candidate intra mode is an angular intra mode in vertical angular direction, the first set ofreference samples is in a reference line adjacent to top side of the current block, wherein when the first candidate intra mode is an angular intra mode in horizontal angular direction, the first set of reference samples is in a reference line adjacent to left side of the current block.

19. The video coding method of claim 1 , wherein the first set of reference samples occupy a row of samples neighboring the current block, a column of samples neighboring the current block, a L-shape of samples neighboring the current block, or a L-shape of samples neighboring a combination of the current block and at least a part of the template region.

20. An electronic apparatus comprising: a video coder circuit configured to perform operations comprising: receiving data to be encoded or decoded as a current block of pixels of a current picture of a video; generating a prediction of a template region neighboring the current block for each candidate intra mode in a set of candidate intra modes comprising at least first and second candidate intra modes, wherein a first set of reference samples is used for generating a first prediction of the template region for the first candidate intra mode and a second set of reference samples is used for generating a second prediction of the template region for the second candidate intra mode, wherein the first set of reference samples occupy a first row or column of thecurrent picture and the second set of reference samples occupy a second, different row or column of the current picture; computing a difference value between reconstruction samples of the template region and the generated prediction of the template region for each candidate intra mode in the set of candidate intra modes; deriving an intra mode based on the computed difference values for the set of candidate intra modes; computing a predictor of the current block based on the derived intra mode; and encoding or decoding the current block by using the computed predictor.

21. A video decoding method comprising: receiving data to be decoded as a current block of pixels of a current picture of a video; generating a prediction of a template region neighboring the current block for each candidate intra mode in a set of candidate intra modes comprising at least first and second candidate intra modes, wherein a first set of reference samples is used for generating a first prediction of the template region for the first candidate intra mode and a second set of reference samples is used for generating a second prediction of the template region for the second candidate intra mode, wherein the first set of reference samples occupy a first row or column of the current pictureand the second set of reference samples occupy a second, different row or column of the current picture; computing a difference value between reconstruction samples of the template region and the generated prediction of the template region for each candidate intra mode in the set of candidate intra modes; deriving an intra mode based on the computed difference values for the set of candidate intra modes; computing a predictor of the current block based on the derived intra mode; and reconstructing the current block by using the computed predictor.

22. A video encoding method comprising: receiving data to be encoded as a current block of pixels of a current picture of a video; generating a prediction of a template region neighboring the current block for each candidate intra mode in a set of candidate intra modes comprising at least first and second candidate intra modes, wherein a first set of reference samples is used for generating a first prediction of the template region for the first candidate intra mode and a second set of reference samples is used for generating a second prediction of the template region for the second candidate intra mode, wherein the first set of reference samples occupy a first row or column of the current picture and the second set of reference samples occupy a second, different row or column of the current picture;computing a difference value between reconstruction samples of the template region and the generated prediction of the template region for each candidate intra mode in the set of candidate intra modes; deriving an intra mode based on the computed difference values for the set of candidate intra modes; computing a predictor of the current block based on the derived intra mode; and encoding the current block by using the computed predictor.