Image encoding / decoding method and apparatus, and recording medium storing bitstream

The template-based induction method for intra prediction modes in image encoding and decoding adaptsively signals flags based on template area costs, enhancing encoding efficiency and reducing unnecessary signaling for high-resolution images.

JP2025502798APending Publication Date: 2025-01-28LG ELECTRONICS INC
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
JP2024539482
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2021-12-29
Filing Date
2022-12-29
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

Existing image compression technologies struggle to efficiently encode and decode high-resolution and high-quality images, particularly in adapting intra prediction modes for optimal compression without unnecessary flag signaling.

Method used

The method employs a template-based induction approach to adaptively signal flags for intra prediction modes, determining the current block intra prediction mode based on the cost of adjacent template areas, and updating the initial mode using available template areas for efficient encoding and decoding.

Benefits of technology

This approach optimizes intra prediction modes by reducing unnecessary flag signaling and improving encoding efficiency, allowing for better compression and decoding of high-resolution images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2025502798000001_ABST
    Figure 2025502798000001_ABST
Patent Text Reader

Abstract

The image decoding / encoding method and apparatus according to the present disclosure can determine an intra prediction mode of a current block based on whether the intra prediction mode of the current block is derived based on the cost of a template region adjacent to the current block, determine a reference sample of the current block, and generate a prediction sample of the current block based on the intra prediction mode and the reference sample.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present invention relates to an image encoding / decoding method and apparatus, and a recording medium storing a bitstream. [Background technology]

[0002] 2. Description of the Related Art In recent years, the demand for high-resolution, high-quality images such as high definition (HD) images and ultra high definition (UHD) images has increased in various application fields, and as a result, highly efficient image compression techniques have come under scrutiny.

[0003] There are various image compression techniques, such as inter-prediction technology that predicts pixel values ​​contained in a current picture from pictures before or after the current picture, intra-prediction technology that predicts pixel values ​​contained in the current picture using pixel information within the current picture, and entropy coding technology that assigns short codes to values ​​that occur frequently and long codes to values ​​that occur less frequently. Using such image compression techniques, image data can be effectively compressed and transmitted or stored. Summary of the Invention [Problem to be solved by the invention]

[0004] The present disclosure seeks to provide a method and apparatus for deriving intra-prediction modes through a template region-based deriving method.

[0005] The present disclosure seeks to provide a method and apparatus for signaling a flag for adaptively using a template region-based guidance method.

[0006] The present disclosure seeks to provide a method and apparatus for deriving / setting an intra-prediction mode based on a flag for adaptively using a template region-based deriving method.

[0007] The present disclosure seeks to provide a method and apparatus for setting and updating an initial intra-prediction mode in a template region-based guided manner. [Means for solving the problem]

[0008] The image decoding method and apparatus according to the present disclosure may derive an intra prediction mode of a current block based on a flag of the current block, determine a reference sample of the current block, and generate a prediction sample of the current block based on the intra prediction mode and the reference sample, where the flag may indicate whether the intra prediction mode of the current block is induced based on a cost of a template region adjacent to the current block.

[0009] In the image decoding method and apparatus according to the present disclosure, the flag may be signaled from a bitstream based on whether a template region of the current block is available or not.

[0010] In the image decoding method and apparatus according to the present disclosure, if the template region of the current block is available, the flag may be signaled from the bitstream, and if the template region of the current block is not available, the flag may not be signaled from the bitstream and the flag may be induced to be 0.

[0011] In the image decoding method and apparatus according to the present disclosure, if the template region of the current block is available, the flag may be signaled from the bitstream, and if the template region of the current block is not available, the flag may not be signaled from the bitstream and the flag may be induced to be 1.

[0012] In the image decoding method and apparatus according to the present disclosure, if the flag is induced to be 1, the intra prediction mode of the current block may be set to a planar mode.

[0013] In the image decoding method and apparatus according to the present disclosure, if the flag is induced to be 1, the intra prediction mode of the current block may be set to a DC mode.

[0014] In the image decoding method and apparatus according to the present disclosure, when the flag is 1, the intra prediction mode of the current block may be determined based on a cost calculated from the template region, and when the flag is 0, the intra prediction mode of the current block may be induced based on intra prediction mode information of the current block.

[0015] In the image decoding method and apparatus according to the present disclosure, if the flag is 1, an initial intra prediction mode of the current block may be set to a DC mode.

[0016] In the image decoding method and apparatus according to the present disclosure, an initial intra-prediction mode of the current block may be updated based on a cost for one or more intra-prediction modes available to the current block.

[0017] In the image decoding method and apparatus according to the present disclosure, the flag may be signaled from a bitstream regardless of whether the template region of the current block is available or not.

[0018] The image encoding method and apparatus according to the present disclosure may determine whether an intra prediction mode of a current block is determined based on a cost of a template region adjacent to the current block, determine an intra prediction mode of the current block based on the determination result, determine a reference sample of the current block, and generate a prediction sample of the current block based on the intra prediction mode and the reference sample. Here, a flag indicating whether the intra prediction mode of the current block is determined based on the cost of the template region may be coded into a bitstream.

[0019] A computer-readable digital storage medium having encoded video / image information stored thereon is provided that enables an image decoding method to be performed by a decoding apparatus according to the present disclosure.

[0020] A computer-readable digital storage medium is provided having stored thereon video / image information generated by the image encoding method of the present disclosure.

[0021] A method and apparatus are provided for transmitting video / image information generated by the image encoding method according to the present disclosure. Effect of the Invention

[0022] According to the present disclosure, the encoder / decoder can calculate a cost from a predetermined template region and derive an optimal intra prediction mode based on the cost.

[0023] According to the present disclosure, by restricting the conditions for signaling / encoding flags for adaptively using the template region-based guidance method, unnecessary flag signaling / encoding can be eliminated.

[0024] The present disclosure can eliminate redundancy with the MPM-based guiding method by guiding / setting the intra-prediction mode based on a flag for adaptively using the template region-based guiding method. [Brief description of the drawings]

[0025] [Figure 1] FIG. 1 illustrates a video / image coding system according to the present disclosure. [Diagram 2] 1 is a schematic block diagram of an encoding device to which embodiments of the present disclosure can be applied, in which video / image signals are encoded; [Diagram 3]1 is a schematic block diagram of a decoding device to which embodiments of the present disclosure can be applied, for decoding video / image signals; [Figure 4] FIG. 2 is a diagram illustrating an intra prediction method performed by a decoding device according to an embodiment of the present disclosure. [Diagram 5] FIG. 1 is a diagram showing a schematic configuration of an intra prediction unit (331) that performs the intra prediction method according to the present disclosure. [Figure 6] FIG. 2 is a diagram illustrating an intra prediction method performed by an encoding device according to an embodiment of the present disclosure. [Figure 7] FIG. 2 is a diagram showing a schematic configuration of an intra prediction unit (222) that performs the intra prediction method according to the present disclosure. [Figure 8] FIG. 1 illustrates an example of a content streaming system to which embodiments of the present disclosure can be applied. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0026] The present disclosure may be modified in various ways and may have various embodiments, and specific embodiments are illustrated in the drawings and described in detail. However, this is not intended to limit the present disclosure to a specific embodiment, and it should be understood that the present disclosure includes all modifications, equivalents, or alternatives within the spirit and technical scope of the present disclosure. In the description of each figure, similar reference numerals are used for similar components.

[0027] Terms such as first, second, etc. may be used to describe various components, but these components should not be limited by such terms. These terms are used only to distinguish one component from another. For example, a first component can be named a second component, and similarly, the second component can be named a first component, without departing from the scope of the present disclosure. The term "and / or" includes a combination of multiple associated listed items or any items of multiple associated listed items.

[0028] When a component is referred to as being "coupled" or "connected" to another component, it should be understood that the component may be directly coupled or connected to the other component, and that there may be additional components in between. On the other hand, when a component is referred to as being "directly coupled" or "directly connected" to another component, it should be understood that there are no additional components in between.

[0029] The terms used in this application are merely for describing certain embodiments and are not intended to limit the present disclosure. The singular term includes the plural term unless otherwise specified in the context. In this application, the terms "comprise" or "have" are intended to specify the presence of features, numbers, steps, operations, components, parts, or combinations thereof described in the specification, and should be understood not to preclude the presence or addition of one or more other features, numbers, steps, operations, components, parts, or combinations thereof.

[0030] The present disclosure relates to video / image coding. For example, the methods / embodiments disclosed herein may be applied to methods disclosed in the versatile video coding (VVC) standard. Also, the methods / embodiments disclosed herein may be applied to methods disclosed in the essential video coding (EVC) standard, the AOMedia Video 1 (AV1) standard, the 2nd generation of audio video coding standard (AVS2), or the next generation video / image coding standard (e.g., H.267 or H.268).

[0031] This specification presents various embodiments relating to video / image coding, and unless otherwise specified, the above embodiments may be performed in combination with each other.

[0032] In this specification, a video may mean a collection of a series of images over time. A picture generally means a unit showing one image at a specific time period, and a slice / tile is a unit constituting a part of a picture in coding. A slice / tile may include one or more coding tree units (CTUs). One picture may be composed of one or more slices / tiles. A tile is a rectangular area composed of multiple CTUs in a specific tile column and a specific tile row of a picture. A tile column is a rectangular area of ​​CTUs having a height equal to the height of the picture and a width specified by a syntax requirement of a picture parameter set. A tile row is a rectangular area of ​​CTUs having a height specified by a picture parameter set and a width equal to the width of the picture. CTUs in one tile are arranged consecutively by CTU raster scanning, while tiles in one picture may be arranged consecutively by tile raster scanning. A slice may include an integer number of complete tiles or an integer number of consecutive complete CTU rows within the tiles of a picture that may be exclusively contained in a single NAL unit, whereas a picture may be partitioned into two or more sub-pictures, which may be rectangular regions of one or more slices in the picture.

[0033] A picture element, pixel, or pel can mean the smallest unit that constitutes one picture (or image). A term corresponding to a pixel may be "sample." A sample can generally indicate a pixel or a pixel value, and may indicate only a pixel / pixel value of a luminance (luma) component, or may indicate only a pixel / pixel value of a chrominance (chroma) component.

[0034] A unit may refer to a basic unit of image processing. A unit may include at least one of a specific region of a picture and information related to the region. A unit may include one luma block and two chroma (e.g., cb, cr) blocks. A unit may be used interchangeably with terms such as a block or an area. In general, an MxN block may include a set (or array) of samples or transform coefficients consisting of M columns and N rows.

[0035] As used herein, "A or B" can mean "A only," "B only," or "both A and B." In other words, as used herein, "A or B" can be interpreted as "A and / or B." For example, as used herein, "A, B or C" can mean "A only," "B only," "C only," or "any combination of A, B and C."

[0036] As used herein, a slash ( / ) or a comma can mean "and / or." For example, "A / B" can mean "A and / or B." Thus, "A / B" can mean "A only," "B only," or "both A and B." For example, "A, B, C" can mean "A, B, or C."

[0037] In the present specification, "at least one of A and B" can mean "A only," "B only," or "both A and B." In addition, in the present specification, the expression "at least one of A or B" or "at least one of A and / or B" may be interpreted as being the same as "at least one of A and B."

[0038] In addition, in this specification, "at least one of A, B and C" can mean "A only," "B only," "C only," or "any combination of A, B and C." In addition, "at least one of A, B or C" or "at least one of A, B and / or C" can mean "at least one of A, B and C."

[0039] In addition, parentheses used in this specification may mean "for example." Specifically, when "prediction (intra prediction)" is displayed, "intra prediction" may be proposed as an example of "prediction." In other words, "prediction" in this specification is not limited to "intra prediction," and "intra prediction" may be proposed as an example of "prediction." In addition, when "prediction (i.e., intra prediction)" is displayed, "intra prediction" may be proposed as an example of "prediction."

[0040] In this specification, technical features individually described in the same drawing may be embodied individually or simultaneously.

[0041] FIG. 1 is a diagram illustrating a video / image coding system according to this disclosure.

[0042] Referring to FIG. 1, a video / image coding system may include a first device (a source device) and a second device (a receiving device).

[0043] A source device may transmit encoded video / image information or data to a receiving device through a digital storage medium or a network in the form of a file or streaming. The source device may include a video source, an encoding device, and a transmitting unit. The receiving device may include a receiving unit, a decoding device, and a renderer. The encoding device may be referred to as a video / image encoding device, and the decoding device may be referred to as a video / image decoding device. The transmitter may be included in the encoding device. The receiver may be included in the decoding device. The renderer may include a display unit, which may be a separate device or an external component.

[0044] A video source may acquire video / images through a video / image capture, synthesis or generation process, etc. A video source may include a video / image capture device and / or a video / image generation device. A video / image capture device may include one or more cameras, a video / image archive containing previously captured videos / images, etc. A video / image generation device may include a computer, tablet, smartphone, etc., and may (electronically) generate video / images. For example, a virtual video / image may be generated through a computer, etc., in which case the video / image capture process may be replaced by a process in which the associated data is generated.

[0045] An encoding device may encode an input video / image. The encoding device may perform a series of steps such as prediction, transformation, quantization, etc. for compression and coding efficiency. The encoded data (encoded video / image information) may be output in the form of a bitstream.

[0046] The transmitting unit can transmit the encoded video / image information or data output in the form of a bitstream to a receiving unit of a receiving device through a digital storage medium or a network in the form of a file or streaming. The digital storage medium can include various storage media such as USB, SD, CD, DVD, Blu-ray, HDD, SSD, etc. The transmitting unit can include elements for generating a media file according to a predetermined file format and can include elements for transmission through a broadcasting / communication network. The receiving unit can receive / extract the bitstream and transmit it to a decoding device.

[0047] The decoding device can decode the video / image by performing a series of steps such as inverse quantization, inverse transformation, prediction, etc., which correspond to the operations of the encoding device.

[0048] The renderer can render the decoded video / images. The rendered video / images can be displayed on a display unit.

[0049] FIG. 2 is a schematic block diagram of an encoding device to which the embodiments of the present disclosure can be applied, in which encoding of video / image signals is performed.

[0050] Referring to FIG. 2, the encoding device 200 may include an image partitioner 210, a predictor 220, a residual processor 230, an entropy encoder 240, an adder 250, a filter 260, and a memory 270. The predictor 220 may include an inter predictor 221 and an intra predictor 222. The residual processor 230 may include a transformer 232, a quantizer 233, a dequantizer 234, and an inverse transformer 235. The residual processor 230 may further include a subtractor 231. The adder 250 may be referred to as a reconstruction unit or a reconstruction block generator. The image divider 210, the prediction unit 220, the residual processor 230, the entropy encoding unit 240, the adder 250, and the filtering unit 260 may be configured by one or more hardware components (e.g., an encoding device chipset or a processor) depending on the embodiment. In addition, the memory 270 may include a decoded picture buffer (DPB) and may be configured by a digital storage medium. The hardware components may further include the memory 270 as an internal / external component.

[0051] The image division unit 210 may divide an input image (or picture, frame) input to the encoding device 200 into one or more processing units. As an example, the processing units may be called coding units (CUs). In this case, the coding units may be recursively divided from a coding tree unit (CTU) or a largest coding unit (LCU) according to a quad-tree binary-tree ternary-tree (QTBTTT) structure.

[0052] For example, one coding unit may be divided into a plurality of coding units having a deeper depth based on a quad tree structure, a binary tree structure, and / or a tertiary structure. In this case, for example, the quad tree structure may be applied first, and the binary tree structure and / or the tertiary structure may be applied later. Alternatively, the binary tree structure may be applied before the quad tree structure. A coding procedure according to the present specification may be performed based on a final coding unit that is not further divided. In this case, based on coding efficiency according to image characteristics, the largest coding unit may be immediately used as the final coding unit, or, if necessary, the coding unit may be recursively divided into coding units of a lower depth, and a coding unit having an optimal size may be used as the final coding unit. Here, the coding procedure may include procedures such as prediction, transformation, and restoration, which will be described later.

[0053] As another example, the processing unit may further include a prediction unit (PU) or a transform unit (TU). In this case, the prediction unit and the transform unit may be divided or partitioned from the above-mentioned final coding unit, respectively. The prediction unit may be a unit of sample prediction, and the transform unit may be a unit for deriving transform coefficients and / or a unit for deriving a residual signal from the transform coefficients.

[0054] A unit may be used interchangeably with terms such as block or area. In general, an MxN block may represent a set of samples or transform coefficients consisting of M columns and N rows. A sample may generally represent a pixel or pixel value, or may represent only a pixel / pixel value of a luma component, or may represent only a pixel / pixel value of a chroma component. A sample may be used in terms corresponding to one picture (or image), pixel, or pel.

[0055] The encoding apparatus 200 may subtract a prediction signal (prediction block, prediction sample array) output from the inter prediction unit 221 or the intra prediction unit 222 from an input image signal (original block, original sample array) to generate a residual signal (residual block, residual sample array), and the generated residual signal is transmitted to the conversion unit 232. In this case, a unit in the encoding apparatus 200 that subtracts the prediction signal (prediction block, prediction sample array) from the input image signal (original block, original sample array) may be called a subtraction unit 231.

[0056] The prediction unit 220 may perform prediction on a block to be processed (hereinafter, referred to as a current block) and generate a predicted block including a prediction sample for the current block. The prediction unit 220 may determine whether intra prediction or inter prediction is applied to the current block or CU. The prediction unit 220 may generate various information related to prediction, such as prediction mode information, as described below in the description of each prediction mode, and transmit the information to the entropy encoding unit 240. The prediction information may be encoded by the entropy encoding unit 240 and output in the form of a bitstream.

[0057] The intra prediction unit 222 may predict the current block by referring to samples in the current picture. The referenced samples may be located in the neighborhood of the current block or may be located at a certain distance from the current block depending on the prediction mode. In the intra prediction, the prediction mode may include one or more non-directional modes and a plurality of directional modes. The non-directional modes may include at least one of a DC mode or a planar mode. The directional modes may include 33 directional modes or 65 directional modes depending on the fineness of the prediction direction. However, this is an example, and more or less directional modes may be used depending on the setting. The intra prediction unit 222 may also determine the prediction mode to be applied to the current block using the prediction modes applied to the neighboring blocks.

[0058] The inter prediction unit 221 may derive a prediction block for a current block based on a reference block (reference sample array) specified by a motion vector on a reference picture. In this case, in order to reduce the amount of motion information transmitted in the inter prediction mode, the motion information may be predicted in units of a block, a sub-block, or a sample based on the correlation of motion information between a neighboring block and a current block. The motion information may include a motion vector and a reference picture index. The motion information may further include inter prediction direction information (L0 prediction, L1 prediction, Bi prediction, etc.). In the case of inter prediction, the neighboring block may include a spatial neighboring block present in the current picture and a temporal neighboring block present in the reference picture. The reference picture including the reference block and the reference picture including the temporal neighboring block may be the same or different. The temporal neighboring block may be called a collocated reference block, a collocated CU (colCU), etc., and the reference picture including the temporal neighboring block may be called a collocated picture (colPic). For example, the inter prediction unit 221 may generate information indicating which candidates are used to derive a motion vector and / or a reference picture index of the current block by forming a motion information candidate list based on neighboring blocks. Inter prediction may be performed based on various prediction modes, and for example, in the case of a skip mode and a merge mode, the inter prediction unit 221 may use motion information of neighboring blocks as motion information of the current block. In the case of the skip mode, unlike the merge mode, a residual signal may not be transmitted.In the case of motion vector prediction (MVP) mode, the motion vector of the current block can be indicated by using the motion vector of the neighboring block as a motion vector predictor and signaling the motion vector difference.

[0059] The prediction unit 220 may generate a prediction signal based on various prediction methods described later. For example, the prediction unit may apply intra prediction or inter prediction for prediction of one block, and may simultaneously apply intra prediction and inter prediction. This may be referred to as a combined inter and intra prediction (CIIP) mode. The prediction unit may also be based on an intra block copy (IBC) prediction mode or a palette mode for prediction of a block. The IBC prediction mode or palette mode may be used for coding of content images / videos such as games, such as screen content coding (SCC). IBC basically performs prediction within a current picture, but may be performed similarly to inter prediction in that a reference block is derived within the current picture. That is, IBC may use at least one of the inter prediction methods described herein. The palette mode may be considered as an example of intra coding or intra prediction. When the palette mode is applied, a sample value within the picture may be signaled based on information regarding a palette table and a palette index. The predicted signal generated by the prediction unit 220 may be used to generate a reconstructed signal or a residual signal.

[0060] The transform unit 232 may generate transform coefficients by applying a transform technique to the residual signal. For example, the transform technique may include at least one of a discrete cosine transform (DCT), a discrete sine transform (DST), a Karhunen-Loeve transform (KLT), a graph-based transform (GBT), or a conditionally non-linear transform (CNT). Here, the GBT refers to a transform obtained from a graph in which information on the relationship between pixels is expressed as a graph. The CNT refers to a transform obtained based on a predicted signal generated using all previously restored pixels. In addition, the transform process may be applied to pixel blocks having the same square size, or may be applied to non-square blocks of variable size.

[0061] The quantization unit 233 quantizes the transform coefficients and transmits the quantized transform coefficients to the entropy encoding unit 240, and the entropy encoding unit 240 may encode the quantized signal (information about the quantized transform coefficients) and output it as a bitstream. The information about the quantized transform coefficients may be called residual information. The quantization unit 233 may rearrange the quantized transform coefficients in a block form into a one-dimensional vector form based on a coefficient scan order, and may generate information about the quantized transform coefficients based on the quantized transform coefficients in the one-dimensional vector form.

[0062] The entropy encoding unit 240 may perform various encoding methods such as exponential Golomb, context-adaptive variable length coding (CAVLC), context-adaptive binary arithmetic coding (CABAC), etc. The entropy encoding unit 240 may also encode information required for video / image restoration (e.g., values ​​of syntax elements, etc.) together with or separately from the quantized transform coefficients.

[0063] The encoded information (e.g., encoded video / image information) may be transmitted or stored in the form of a bitstream in units of network abstraction layer (NAL) units. The video / image information may further include information on various parameter sets, such as an adaptation parameter set (APS), a picture parameter set (PPS), a sequence parameter set (SPS), or a video parameter set (VPS). The video / image information may further include general constraint information. In this specification, information and / or syntax elements transmitted / signaled from an encoding device to a decoding device may be included in the video / image information. The video / image information may be encoded by the above-mentioned encoding procedure and included in the bitstream. The bitstream may be transmitted through a network or stored in a digital storage medium. Here, the network may include a broadcast network and / or a communication network, and the digital storage medium may include various storage media, such as a USB, SD, CD, DVD, Blu-ray, HDD, SSD, and the like. The signal output from the entropy encoding unit 240 may be transmitted by a transmitting unit (not shown) and / or stored by a storage unit (not shown) configured as an internal / external element of the encoding apparatus 200, or the transmitting unit may be included in the entropy encoding unit 240.

[0064] The quantized transform coefficients output from the quantizer 233 may be used to generate a prediction signal. For example, the inverse quantizer 234 and the inverse transformer 235 may apply inverse quantization and inverse transform to the quantized transform coefficients to reconstruct a residual signal (residual block or residual sample). The adder 250 may generate a reconstructed signal (reconstructed picture, reconstructed block, reconstructed sample array) by adding the reconstructed residual signal to a prediction signal output from the inter predictor 221 or the intra predictor 222. When there is no residual for the current block, such as when a skip mode is applied, the predicted block may be used as a reconstructed block. The adder 250 may be called a reconstruction unit or a reconstructed block generator. The generated reconstruction signal may be used for intra prediction of the next current block in the current picture, or may be used for inter prediction of the next picture after filtering, as described below. Meanwhile, LMCS (luma mapping with chroma scaling) may be applied during picture encoding and / or reconstruction.

[0065] The filtering unit 260 may apply filtering to the reconstructed signal to improve subjective / objective image quality. For example, the filtering unit 260 may apply various filtering methods to the reconstructed picture to generate a modified reconstructed picture, and may store the modified reconstructed picture in the memory 270, specifically, in the DPB of the memory 270. The various filtering methods may include deblocking filtering, sample adaptive offset, an adaptive loop filter, a bilateral filter, and the like. The filtering unit 260 may generate various information related to filtering and transmit it to the entropy encoding unit 240. The information related to filtering may be encoded by the entropy encoding unit 240 and output in the form of a bitstream.

[0066] The modified reconstructed picture transmitted to the memory 270 may be used as a reference picture in the inter prediction unit 221. In this way, when inter prediction is applied, the encoding apparatus can avoid prediction mismatch between the encoding apparatus 200 and the decoding apparatus, and can also improve coding efficiency.

[0067] The DPB of the memory 270 may store the modified reconstructed picture to be used as a reference picture in the inter prediction unit 221. The memory 270 may store motion information of a block from which motion information in the current picture is derived (or encoded) and / or motion information of a block in an already reconstructed picture. The stored motion information may be transmitted to the inter prediction unit 221 to be used as motion information of a spatial neighboring block or motion information of a temporal neighboring block. The memory 270 may store reconstructed samples of reconstructed blocks in the current picture and transmit them to the intra prediction unit 222.

[0068] FIG. 3 is a schematic block diagram of a decoding device to which the embodiments of the present disclosure can be applied, for decoding video / image signals.

[0069] 3, the decoding device 300 may include an entropy decoding unit (entropy decoder, 310), a residual processor (residual processor, 320), a predictor (predictor, 330), an adder (adder, 340), a filter (filter, 350), and a memory (memory, 360). The predictor 330 may include an inter predictor 331 and an intra predictor 332. The residual processor 320 may include a dequantizer (dequantizer, 321) and an inverse transformer (inverse transformer, 321).

[0070] The above-mentioned entropy decoding unit 310, residual processing unit 320, prediction unit 330, addition unit 340, and filtering unit 350 may be configured by one hardware component (e.g., a decoding device chipset or processor) according to an embodiment. Also, the memory 360 may include a decoded picture buffer (DPB) and may be configured by a digital storage medium. The hardware component may further include the memory 360 as an internal / external component.

[0071] When a bitstream including video / image information is input, the decoding apparatus 300 can restore an image corresponding to the process in which the video / image information is processed by the encoding apparatus of FIG. 2. For example, the decoding apparatus 300 can derive units / blocks based on block division related information obtained from the bitstream. The decoding apparatus 300 can perform decoding using a processing unit applied in the encoding apparatus. Thus, the processing unit for decoding may be a coding unit, and the coding unit may be divided from a coding tree unit or a maximum coding unit according to a quad tree structure, a binary tree structure, and / or a tertiary tree structure. One or more transform units may be derived from the coding unit. Then, the restored image signal decoded and output by the decoding apparatus 300 may be reproduced by a reproduction device.

[0072] The decoding device 300 may receive a signal output from the encoding device of FIG. 2 in the form of a bitstream, and the received signal may be decoded by the entropy decoding unit 310. For example, the entropy decoding unit 310 may parse the bitstream and derive information (e.g., video / image information) required for image restoration (or picture restoration). The video / image information may further include information on various parameter sets, such as an adaptation parameter set (APS), a picture parameter set (PPS), a sequence parameter set (SPS), or a video parameter set (VPS). The video / image information may also include general constraint information. The decoding device may decode a picture further based on information on the parameter set and / or the general constraint information. Signal / received information and / or syntax elements described later in this specification may be decoded by the decoding procedure and obtained from the bitstream. For example, the entropy decoding unit 310 may decode information in a bitstream based on a coding method such as exponential Golomb coding, CAVLC, or CABAC, and output values ​​of syntax elements required for image restoration and quantized values ​​of transform coefficients related to residuals. More specifically, the CABAC entropy decoding method may receive bins corresponding to each syntax element in the bitstream, determine a context model using information on the syntax element to be decoded and decoding information on neighboring and to-be-decoded blocks or information on symbols / bins decoded in a previous step, predict the occurrence probability of bins according to the determined context model, and perform arithmetic decoding of the bins to generate symbols corresponding to the values ​​of each syntax element. In this case, the CABAC entropy decoding method may update the context model using information on the decoded symbols / bins for the context model of the next symbol / bin after determining the context model.Among the information decoded by the entropy decoding unit 310, information related to prediction may be provided to a prediction unit (inter prediction unit 332 and intra prediction unit 331), and residual values ​​entropy decoded by the entropy decoding unit 310, i.e., quantized transform coefficients and related parameter information, may be input to the residual processing unit 320. The residual processing unit 320 may derive a residual signal (residual block, residual sample, residual sample array). Also, among the information decoded by the entropy decoding unit 310, information related to filtering may be provided to the filtering unit 350. Meanwhile, a receiving unit (not shown) for receiving a signal output from an encoding device may be further configured as an internal / external element of the decoding device 300, or the receiving unit may be a component of the entropy decoding unit 310.

[0073] Meanwhile, the decoding device according to the present specification may be called a video / image / picture decoding device, and the decoding device may be divided into an information decoding device (video / image / picture information decoding device) and a sample decoding device (video / image / picture sample decoding device). The information decoding device may include the entropy decoding unit 310, and the sample decoding device may include at least one of the inverse quantization unit 321, the inverse transform unit 322, the addition unit 340, the filtering unit 350, the memory 360, the inter prediction unit 332, and the intra prediction unit 331.

[0074] The inverse quantization unit 321 may inverse quantize the quantized transform coefficients and output the transform coefficients. The inverse quantization unit 321 may rearrange the quantized transform coefficients in a two-dimensional block form. In this case, the rearrangement may be performed based on a coefficient scan order performed in an encoding device. The inverse quantization unit 321 may perform inverse quantization on the quantized transform coefficients using a quantization parameter (e.g., quantization step size information) to obtain transform coefficients.

[0075] The inverse transform unit 322 inversely transforms the transform coefficients to obtain a residual signal (residual block, residual sample array).

[0076] The prediction unit 320 may perform prediction on a current block and generate a predicted block including a prediction sample for the current block. The prediction unit 320 may determine whether intra prediction or inter prediction is applied to the current block based on the prediction information output from the entropy decoding unit 310, and may determine a specific intra / inter prediction mode.

[0077] The prediction unit 320 may generate a prediction signal based on various prediction methods described later. For example, the prediction unit 320 may apply intra prediction or inter prediction for prediction of one block, and may also apply intra prediction and inter prediction simultaneously. This may be called a combined inter and intra prediction (CIIP) mode. The prediction unit may also be based on an intra block copy (IBC) prediction mode or a palette mode for prediction of a block. The IBC prediction mode or palette mode may be used for content image / video coding such as games, such as screen content coding (SCC). IBC basically performs prediction within a current picture, but may be performed similarly to inter prediction in that a reference block is derived within the current picture. That is, IBC may use at least one of the inter prediction methods described herein. The palette mode may be considered as an example of intra coding or intra prediction. When the palette mode is applied, information regarding a palette table and a palette index may be included in the video / image information and signaled.

[0078] The intra prediction unit 331 may predict the current block by referring to samples in the current picture. The referenced samples may be located in the neighborhood of the current block or at a certain distance from the current block depending on the prediction mode. In intra prediction, the prediction modes may include one or more non-directional modes and a plurality of directional modes. The intra prediction unit 331 may determine the prediction mode to be applied to the current block using the prediction modes applied to the neighboring blocks.

[0079] The inter prediction unit 332 may derive a prediction block for the current block based on a reference block (reference sample array) specified by a motion vector on a reference picture. In this case, in order to reduce the amount of motion information transmitted in the inter prediction mode, the motion information may be predicted in units of blocks, sub-blocks, or samples based on the correlation of motion information between neighboring blocks and the current block. The motion information may include a motion vector and a reference picture index. The motion information may further include inter prediction direction information (L0 prediction, L1 prediction, Bi prediction, etc.). In the case of inter prediction, the neighboring blocks may include spatial neighboring blocks present in the current picture and temporal neighboring blocks present in the reference picture. For example, the inter prediction unit 332 may configure a motion information candidate list based on the neighboring blocks and derive a motion vector and / or a reference picture index for the current block based on the received candidate selection information. Inter prediction may be performed based on various prediction modes, and the information regarding the prediction may include information indicating an inter prediction mode for the current block.

[0080] The adder 340 can generate a reconstructed signal (reconstructed picture, reconstructed block, reconstructed sample array) by adding the acquired residual signal to a prediction signal (prediction block, prediction sample array) output from a prediction unit (including the inter prediction unit 332 and / or the intra prediction unit 331). When there is no residual for the current block, such as when the skip mode is applied, the prediction block may be used as the reconstructed block.

[0081] The adder 340 may be referred to as a reconstruction unit or a reconstruction block generator. The generated reconstruction signal may be used for intra prediction of a next block to be processed in a current picture, may be output after filtering as described below, or may be used for inter prediction of a next picture. Meanwhile, LMCS (luma mapping with chroma scaling) may be applied during picture decoding.

[0082] The filtering unit 350 may apply filtering to the reconstructed signal to improve subjective / objective image quality. For example, the filtering unit 350 may apply various filtering methods to the reconstructed picture to generate a modified reconstructed picture, and may transmit the modified reconstructed picture to the memory 360, specifically, to the DPB of the memory 360. The various filtering methods may include deblocking filtering, sample adaptive offset, an adaptive loop filter, a bilateral filter, etc.

[0083] The (modified) reconstructed picture stored in the DPB of the memory 360 may be used as a reference picture in the inter prediction unit 332. The memory 360 may store motion information of a block from which motion information in the current picture is derived (or decoded) and / or motion information of a block in an already reconstructed picture. The stored motion information may be transmitted to the inter prediction unit 260 to be used as motion information of a spatial neighboring block or motion information of a temporal neighboring block. The memory 360 may store reconstructed samples of reconstructed blocks in the current picture and transmit them to the intra prediction unit 331.

[0084] In this specification, the embodiments described for the filtering unit 260, inter prediction unit 221, and intra prediction unit 222 of the encoding device 200 may also be applied identically or correspondingly to the filtering unit 350, inter prediction unit 332, and intra prediction unit 331 of the decoding device 300, respectively.

[0085] FIG. 4 is a diagram illustrating an intra prediction method performed by a decoding device according to an embodiment of the present disclosure.

[0086] Referring to FIG. 4, an intra prediction mode of a current block can be derived (S400).

[0087] The intra prediction mode of the current block may be derived from intra prediction modes already defined in the decoding device. The already defined intra prediction modes may include a non-directional mode and a directional mode. Here, the non-directional mode may include at least one of a planar mode and a DC mode. The intra prediction mode of the current block may be derived based on a most proabable mode (MPM) or based on a template region of the current block.

[0088] MPM-based Guidance Method

[0089] According to the MPM-based derivation method, the intra prediction mode of the current block may be derived based on the signaled intra prediction mode information, where the intra prediction mode information includes one or more flags and / or indexes, as described below, based on which the intra prediction mode of the current block may be derived.

[0090] The intra prediction modes predefined in the decoding apparatus may be divided into K groups, where K may be an integer of 2, 3, 4 or more. For convenience of explanation, it is assumed that the predefined intra prediction modes are divided into three groups, and the three groups are referred to as first to third groups.

[0091] The first group may include one or more non-directional modes, which may mean at least one of a planar mode or a DC mode.

[0092] The second group may be referred to as an MPM list, which may include a plurality of most probable modes (MPMs). The plurality of MPMs may include at least one of intra prediction modes, guided modes, or default modes of neighboring blocks adjacent to the current block.

[0093] The peripheral blocks may include at least one of a left block, an upper block, a lower left block, an upper right block, or an upper left block. The modes of the peripheral blocks may be added to the MPM list in sequence according to a priority order between the peripheral blocks. Here, the priority order may be defined in the order of the left block, the upper block, the lower left block, the upper right block, and the upper left block, or in the order of the upper block, the left block, the lower left block, the upper right block, and the upper left block. Alternatively, the priority order may be adaptively determined based on the size and / or shape of the current block. For example, if the height of the current block is greater than the width, the priority order of the upper block, the left block, the lower left block, the upper right block, and the upper left block may be used. Conversely, if the width of the current block is greater than the height, the priority order of the left block, the upper block, the lower left block, the upper right block, and the upper left block may be used.

[0094] The induced mode may be induced by adding or subtracting an offset to the intra prediction mode of the neighboring block. Alternatively, the induced mode may be induced by adding or subtracting an offset to a default mode, which will be described later. Here, the offset may be an integer of 1, 2, 3, 4, or more. The induced mode may be induced based on a neighboring block having a high priority among the neighboring blocks. The induced mode may not be induced based on a neighboring block having a low priority among the neighboring blocks. Here, the neighboring block having a high priority may include at least one of a left block or an upper block. Conversely, the neighboring block having a low priority may include at least one of a lower left block, an upper right block, or an upper left block. However, when the intra prediction mode of the neighboring block corresponds to a non-directional mode, the induced mode may not be induced based on the intra prediction mode of the neighboring block.

[0095] The default mode may refer to a mode already defined in the decoding device for constructing an MPM list. For example, the default mode may include at least one of a planar mode, a DC mode, a horizontal mode, a vertical mode, or a diagonal mode. Here, the diagonal mode may refer to one or more of a lower left diagonal mode, an upper left diagonal mode, or an upper right diagonal mode.

[0096] The second group may be divided into two sub-groups, which are called a primary MPM list and a secondary MPM list. As an example, when the MPM list is composed of N MPMs, the top M MPMs belonging to the MPM list may be included in the primary MPM list, and the remaining (NM) MPMs may be included in the secondary MPM list. That is, the primary MPM list may include MPMs having indexes of 0 to (M-1) belonging to the MPM list. Here, N may refer to the maximum number of MPMs that can be included in the MPM list. M refers to the maximum number of MPMs that can be included in the primary MPM list, and for example, M may be an integer of 3, 4, 5, 6, or more.

[0097] A third group may include remaining modes that do not belong to the first and second groups among the already defined intra prediction modes.

[0098] In the above embodiment, the first group is defined as a separate group distinct from the second group, but is not limited thereto. For example, the first group and the second group may be defined as one group, and in this case, the non-directional mode of the first group may be any one of the MPMs included in the MPM list of the second group.

[0099] One or more flags may be signaled to identify a group and / or sub-group to which the intra-prediction mode of the current block belongs, and the flags may include at least one of a first flag indicating whether the intra-prediction mode of the current block belongs to a first group, a second flag indicating whether the intra-prediction mode of the current block belongs to a second group (i.e., an MPM list), a third flag indicating whether the intra-prediction mode of the current block belongs to the first MPM list, or a fourth flag indicating whether the intra-prediction mode of the current block belongs to a second MPM list.

[0100] When the second group is identified by the flag, an index identifying one of the MPMs belonging to the second group may be signaled. An intra prediction mode of the current block may be derived based on the MPM identified by the index. Or, when the first MPM list is identified by the flag, an index identifying one of the MPMs belonging to the first MPM list may be signaled. An intra prediction mode of the current block may be derived based on the MPM identified by the index. Or, when the second MPM list is identified by the flag, an index identifying one of the MPMs belonging to the second MPM list may be signaled. An intra prediction mode of the current block may be derived based on the MPM identified by the index. Similarly, when the first group (or the third group) is identified by the flag, an index identifying one of the intra prediction modes belonging to the first group (or the third group) may be separately signaled, and an intra prediction mode of the current block may be derived based on the signaled index. However, when the first group (or the third group) is configured with one intra prediction mode, the signaling of the index may be omitted.

[0101] The above flags may be signaled with dependencies between them. For example, the first flag may be parsed after the second flag is parsed from the bitstream. The first flag may be parsed if the second flag is True. Or, the second flag may be parsed after the first flag is parsed from the bitstream. The second flag may be parsed if the first flag is False. If the second flag is True, the third flag (or the fourth flag) may be parsed from the bitstream, and if the second flag is False, the third flag (or the fourth flag) may not be parsed from the bitstream. Or, the fourth flag may be parsed after the third flag is parsed from the bitstream. The fourth flag may be parsed if the third flag is False.

[0102] Template Region-Based Guidance Method

[0103] At the decoder side, the intra prediction mode may be derived based on template regions adjacent to the current block, as will be described in detail below.

[0104] A cost for each of the predefined candidate modes may be calculated.

[0105] The predetermined candidate mode may refer to a plurality of intra prediction modes that are previously defined in the same way in the encoding device and the decoding device. Alternatively, for template region-based guidance, a candidate list composed of the candidate modes may be generated, and costs may be calculated for the candidate modes belonging to the candidate list. Alternatively, costs may be calculated only for the top N candidate modes in the generated candidate list. Here, N may be a value previously defined in the same way in the encoding device and the decoding device. For example, N may be an integer of 2, 3, 4, 5, or more.

[0106] The candidate list for template region-based guidance may be constructed in the same manner as the MPM list described above, or the candidate list may correspond to the first MPM list or the second MPM list described above, or the candidate list may be constructed of a combination of the first and second groups (i.e., MPM lists) described above, or a combination of subgroups of the first and second groups (i.e., the first MPM list or the second MPM list).

[0107] The cost may be calculated as a sum of absolute difference (SAD) between the predicted samples in the template domain and the reconstructed samples. Alternatively, the cost may be calculated as a sum of absolute transformed difference (SATD) between the predicted samples in the template domain and the reconstructed samples. Here, SATD may mean SAD transformed into a frequency domain. As an example of the transform, a Hadamard transform may be used, but is not limited thereto. The predicted samples in the template domain may be generated based on the above-mentioned candidate modes.

[0108] The template region for cost calculation may be a region adjacent to the current block that has already been restored, for example, the template region may include at least one of a top peripheral region, a left peripheral region, an upper left peripheral region, a lower left peripheral region, or a top right peripheral region of the current block.

[0109] The template region may be a region that has already been defined in the same manner in both the encoding apparatus and the decoding apparatus in order to calculate the cost. Alternatively, the template region may be variably determined based on information specifying the position of the template region. In this case, the information specifying the position of the template region may be signaled in a bitstream. Alternatively, the position of the template region may be determined based on at least one of whether the current block is located at a boundary of a coding tree unit, the size of the current block (e.g., width, height, width-to-height ratio, product of width and height), the division type of the current block, the prediction mode of the surrounding region, or the availability of the surrounding region.

[0110] For example, when the current block is located at the top boundary of the coding tree unit, at least one of the top, top left, or top right surrounding area of ​​the current block may not be referenced to calculate the cost. When the width of the current block is greater than the height, one of the top or left surrounding area (e.g., the top surrounding area) may be referenced to calculate the cost, and the other one (e.g., the left surrounding area) may not be referenced to calculate the cost. Conversely, when the width of the current block is less than the height, one of the top or left surrounding area (e.g., the left surrounding area) may be referenced to calculate the cost, and the other one (e.g., the top surrounding area) may not be referenced to calculate the cost. When the current block is generated by horizontal block division, the top surrounding area may not be referenced to calculate the cost. Conversely, when the current block is generated by vertical block division, the left surrounding area may not be referenced to calculate the cost. When the surrounding area of ​​the current block is coded in inter mode, the surrounding area may not be referenced to calculate the cost. However, the present invention is not limited to this, and the surrounding area may be referenced to calculate the cost regardless of the prediction mode of the surrounding area.

[0111] The template region may be composed of N reference sample lines, where N may be an integer of 1, 2, 3, 4, or more. The number of reference sample lines constituting the template region may be the same regardless of the position of the surrounding region, or may differ depending on the position of the surrounding region. The cost may be calculated based on all samples belonging to the template region. Alternatively, the cost may be calculated using only a reference sample line at a predetermined position in the template region. Alternatively, the cost may be calculated based on all samples belonging to the reference sample line at the predetermined position, or the cost may be calculated using only samples at the predetermined position in the reference sample line at the predetermined position. The reference sample line and / or the position of the sample for the cost calculation may be determined based on at least one of whether the current block is located at a boundary of a coding tree unit, the size of the current block (e.g., width, height, width-to-height ratio, product of width and height), the division type of the current block, the prediction mode of the surrounding region, or the availability of the surrounding region. Alternatively, information indicating the position of the reference sample line for the cost calculation may be signaled in a bitstream.

[0112] One candidate mode having the smallest cost among the costs calculated for the candidate modes may be selected. For example, the costs for each of the five candidate modes in the candidate list may be calculated. The five candidate modes in the candidate list may be reordered in ascending order of the calculated costs. A top candidate mode may be selected from the reordered five candidate modes.

[0113] Alternatively, at least two candidate modes having the smallest cost among the costs calculated for the candidate modes may be selected. For example, the costs for five candidate modes in the candidate list may be calculated. The five candidate modes in the candidate list may be rearranged in ascending order of the calculated costs. The top two candidate modes may be selected from the rearranged five candidate modes.

[0114] One or more candidate modes selected by the above process may be set as the intra prediction mode of the current block.

[0115] Alternatively, when at least two candidate modes are selected by the above process, the intra prediction mode of the current block may be derived based on a comparison between the selected candidate modes and / or a comparison between at least one of the selected candidate modes and a threshold. For example, the intra prediction mode of the current block may be derived based on whether the selected candidate mode satisfies the following condition:

[0116] [Condition] costMode2 < (K x costMode1)

[0117] In the above condition, costMode1 may mean a cost calculated based on any one of the selected candidate modes, and costMode2 may mean a cost calculated based on any other of the selected candidate modes. For example, costMode1 may mean a cost calculated based on a candidate mode having a smaller cost among the selected candidate modes, and costMode2 may mean a cost calculated based on a candidate mode having a larger cost among the selected candidate modes. In the above condition, K represents a predetermined comparison factor, which may be a value previously defined for both the encoding device and the decoding device. For example, K may be an integer of 1, 2, or more, or may mean a real number such as 1 / 2 or 1 / 4.

[0118] If the condition is satisfied, the selected candidate mode may be set as the intra prediction mode of the current block, whereas if the condition is not satisfied, a candidate mode having a cost of costMode1 may be set as the intra prediction mode of the current block, and a candidate mode having a cost of costMode2 may not be used as the intra prediction mode of the current block.

[0119] The above-mentioned template region-based derivation method may be adaptively used based on a predetermined flag (Timd_flag). Here, the flag may indicate whether the intra prediction mode of the current block is derived based on a cost calculated from the template region of the current block. For example, when the flag is a first value, the intra prediction mode of the current block may be derived by the template region-based derivation method, and when the flag is a second value, the intra prediction mode of the current block may be derived by the MPM-based derivation method.

[0120] The flag may be signaled from the bitstream based on at least one of: 1) whether a template region-based guidance method is available; 2) whether the luma component of the current block is valid; 3) whether the prediction mode of the current block is an intra mode; 4) whether the component type of the current block is a luma component; 5) whether the size of the current block is greater than a predetermined threshold size; 6) whether the slice to which the current block belongs is an I-slice; or 7) whether a gradient-based guidance method is applied to the current block.

[0121] Whether the template region-based guidance method is available may be determined based on a flag signaled at at least one of the following levels: a video sequence, a picture, a picture header, or a slice header.

[0122] If the current block is a single-tree type or dual-tree type luminance block, the luminance component of the current block may be determined to be valid. On the other hand, if the current block is a dual-tree type chrominance block, the luminance component of the current block may be determined to be invalid. Here, the single-tree type may refer to a tree type in which a chrominance block of a coding unit has a partition structure subordinate to the partition structure of the luminance block, and the dual-tree type may refer to a tree type in which a chrominance block of a coding unit has a partition structure independent of the luminance block.

[0123] Even if the current block is a single tree type, if the current block is a chrominance block, the component type of the current block may be determined to be False. On the other hand, even if the current block is a single tree type, if the current block is a luminance block, the component type of the current block may be determined to be True. If the current block is a dual tree type luminance block, the component type of the current block may be determined to be True, and if the current block is a dual tree type chrominance block, the component type of the current block may be determined to be False.

[0124] The gradient-based guidance method may refer to a method of deriving an intra prediction mode based on a gradient calculated from a neighboring region of a current block in terms of a decoding device.

[0125] For example, the flags may be signaled as shown in Table 1 below.

[0126] [Table 1]

[0127] In Table 1, sps.useTimd may indicate whether a template region-based guiding method is available for the video sequence to which the current block belongs. W and H indicate the width and height of the current block, respectively, and dimd may indicate whether a gradient-based guiding method is used. Y.valid() may indicate whether the luma component is valid for the current block, and predMode may indicate the prediction mode of the current block. isLuma() may indicate whether the component type of the current block is a luma component.

[0128] According to Table 1, the flag (Timd_flag) may be signaled from the bitstream if: 1) a template region-based guidance method is available for the video sequence to which the current block belongs; 2) the luma component is enabled for the current block; 3) the prediction mode of the current block is intra mode; 4) the component type of the current block is a luma component; 5) the product of the width and height of the current block is less than 1024; 6) the type of slice to which the current block belongs is an I slice; and 7) the gradient-based guidance method is not applied to the current block.

[0129] If the signaled flag is 1, the intra prediction mode of the current block may be induced by a template region-based induced method, and if the signaled flag is 0, the intra prediction mode of the current block may be induced by an MPM-based induced method.

[0130] On the other hand, if the conditions according to Table 1 are not met, the flag may not be signaled from the bitstream. In this case, the flag may be induced to 0, and the intra prediction mode of the current block may be induced by the MPM-based induced method.

[0131] If the neighboring blocks of the current block are not available, the template region for calculating the cost cannot be configured. In this case, the already set initial intra prediction mode may be used as the intra prediction mode of the current block. In this case, the value of the already set initial intra prediction mode may be set to 0, which corresponds to the planar mode. That is, even if the parsed flag according to the conditions of Table 1 is 1, if the neighboring blocks of the current block are not available, the template region-based guiding method is not used and the intra prediction mode of the current block may be set to the already set mode, the planar mode.

[0132] However, the first MPM in the MPM list according to the above-mentioned MPM-based guidance method may be a planar mode. That is, when the neighboring blocks of the current block are not available and the flag (Timd_flag) is 1, the intra prediction mode of the current block is the already set planar mode, which is the same as the planar mode, which is the first MPM in the MPM list. Therefore, when the neighboring blocks of the current block are not available, it may be unnecessary to signal a flag indicating whether the template region-based guidance method is applied. In order to prevent such unnecessary signaling, when the neighboring blocks are not available, the template region-based guidance method may be restricted so that it is not allowed.

[0133] If a template region for cost calculation cannot be constructed because neighboring blocks are not available, the decoding device cannot calculate the cost from the template region and cannot derive the intra-prediction mode of the current block, so the signaling condition of the flag may be restricted so that the template region-based deriving method is not allowed.

[0134] The flag may be signaled from the bitstream based on at least one of: 1) whether a template region based guidance method is available; 2) whether the luma component of the current block is valid; 3) whether the prediction mode of the current block is an intra mode; 4) whether the component type of the current block is a luma component; 5) whether the size of the current block is greater than a predetermined threshold size; 6) whether the slice to which the current block belongs is an I slice; or 7) whether a gradient based guidance method is applied to the current block; or 8) whether a template region of the current block is available.

[0135] The conditions 1) to 7) are as described above, and a duplicate explanation will be omitted here.

[0136] If the template region satisfies one or more of the following conditions, the template region may be determined to be unavailable, and if not, the template region may be determined to be available. For example, if all of the surrounding blocks belonging to the template region satisfy one or more of the following conditions, the template region may be determined to be unavailable, and if not, the template region may be determined to be available. Or, if at least one of the surrounding blocks belonging to the template region satisfies one or more of the following conditions, the template region may be determined to be unavailable, and if not, the template region may be determined to be available.

[0137] 1) The x-coordinate of the top left sample in the surrounding block is less than 0.

[0138] 2) The y-coordinate of the top left sample in the surrounding block is less than 0.

[0139] 3) The x-coordinate of the top left sample in the surrounding block is equal to or greater than the picture width.

[0140] 4) The y-coordinate of the top left sample in the surrounding block is equal to or greater than the height of the picture.

[0141] 5) The neighboring blocks have a later decoding order than the current block.

[0142] 6) The neighboring blocks are included in a different slice than the current block.

[0143] 7) The neighboring blocks are contained in different tiles than the current block.

[0144] For example, the flags may be signaled as follows in Table 2:

[0145] [Table 2]

[0146] In Table 2, sps.useTimd, Y.valid(), predMode, and isLuma() are as described with reference to Table 1, and the repeated description will be omitted here. In Table 2, isAvailableTemplate() may indicate whether a template region is available. If one or more of the above conditions are met, isAvailableTemplate() may be determined to be 1 (or True), and if not, isAvailableTemplate() may be determined to be 0 (or False).

[0147] According to Table 2, the flag (Timd_flag) may be signaled from the bitstream if 1) a gradient-based guidance method is available for the video sequence to which the current block belongs, 2) the luma component is enabled for the current block, 3) the prediction mode of the current block is intra mode, 4) the component type of the current block is a luma component, 5) the product of the width and height of the current block is less than 1024, 6) the type of slice to which the current block belongs is an I slice, 7) the gradient-based guidance method is not applied to the current block, and 8) the template region of the current block is available.

[0148] If the conditions according to Table 2 are not met, the flag may not be signaled from the bitstream and may be induced as 0 (or False). In this case, the intra prediction mode of the current block may be induced by the MPM-based induced method described above.

[0149] If a template region for cost calculation cannot be constructed because neighboring blocks are not available, the decoding device cannot calculate the cost from the template region and cannot derive the intra-prediction mode of the current block, so the signaling condition of the flag may be restricted so that the template region-based deriving method is not allowed.

[0150] [Table 3]

[0151] In Table 3, isAvailableTemplate() may indicate whether a template region is available. According to Table 3, if the template region of the current block is available, a flag (Timd_flag) is signaled from the bitstream, otherwise, the flag may not be signaled from the bitstream.

[0152] If the flag is not signaled from the bitstream, the flag may be induced as True (or 1) as shown in Table 3. However, the intra prediction mode of the current block may be induced as a mode that is predefined in the same manner in the encoding device and the decoding device. Here, the predefined mode may be a planar mode. Thus, even if the flag is induced as 1 because the flag is not signaled from the bitstream, the intra prediction mode of the current block may be restricted so as not to be induced by the template region-based induced method.

[0153] Or, the flag may be signaled in the bitstream if it meets the conditions according to Table 1. The signaled flag may be updated / changed taking into account the availability of template regions.

[0154] For example, the flag (Timd_flag) may be signaled from the bitstream if 1) a template region-based derivation method is available for the video sequence to which the current block belongs, 2) a luma component is enabled for the current block, 3) a prediction mode for the current block is an intra mode, 4) a component type for the current block is a luma component, 5) a product of the width and height of the current block is less than 1024, 6) a type of slice to which the current block belongs is an I slice, and 7) a gradient-based derivation method is not applied to the current block. If the signaled flag is 1, it may be further determined whether a template region for the current block is available. If the determination result indicates that a template region is available, the signaled flag may be maintained at 1, and if not, the signaled flag may be updated / changed to 0. In this case, the intra prediction mode of the current block may be induced as a mode (e.g., a planar mode) that is already defined in the same manner for the encoding device and the decoding device, or may be induced by the above-mentioned MPM-based derivation method.

[0155] If a template region for cost calculation cannot be constructed because neighboring blocks are not available, the decoding device cannot calculate the cost from the template region and cannot derive the intra-prediction mode of the current block, so the signaling condition of the flag may be restricted so that the template region-based deriving method is not allowed.

[0156] [Table 4]

[0157] In Table 4, isAvailableTemplate() may indicate whether a template region is available. According to Table 4, if the template region of the current block is available, a flag (Timd_flag) is signaled from the bitstream, otherwise the flag may not be signaled from the bitstream.

[0158] If the flag is not signaled from the bitstream, the flag may be induced to be True (or 1) as shown in Table 4. However, the intra prediction mode of the current block may be induced to be a mode that is predefined in the same manner in the encoding device and the decoding device. Here, the predefined mode may be a DC mode. Thus, even if the flag is induced to be 1 because the flag is not signaled from the bitstream, the intra prediction mode of the current block may be restricted not to be induced by the template region-based induction method.

[0159] Or, the flag may be signaled in the bitstream if it meets the conditions according to Table 1. The signaled flag may be updated / changed taking into account the availability of template regions.

[0160] For example, the flag (Timd_flag) may be signaled from the bitstream if 1) a template region-based derivation method is available for the video sequence to which the current block belongs, 2) a luma component is enabled for the current block, 3) a prediction mode for the current block is an intra mode, 4) a component type for the current block is a luma component, 5) a product of the width and height of the current block is less than 1024, 6) a type of slice to which the current block belongs is an I slice, and 7) a gradient-based derivation method is not applied to the current block. If the signaled flag is 1, it may be further determined whether a template region for the current block is available. If the determination result indicates that a template region is available, the signaled flag may be maintained at 1, and if not, the signaled flag may be updated / changed to 0. In this case, the intra prediction mode of the current block may be induced as a mode (e.g., DC mode) already defined in the same manner for the encoding device and the decoding device, or may be induced by the above-mentioned MPM-based derivation method.

[0161] As described above, the flag (Timd_flag) for the current block may be signaled from the bitstream based on at least one of: 1) whether a gradient-based guidance method is available, 2) whether the luma component of the current block is valid, 3) whether the prediction mode of the current block is an intra mode, 4) whether the component type of the current block is a luma component, 5) whether the size of the current block is greater than a predetermined threshold size, 6) whether the slice to which the current block belongs is an I slice, or 7) whether a gradient-based guidance method is applied to the current block.

[0162] For example, as shown in Table 1, if certain conditions are met, namely, 1) a gradient-based guidance method is available for the video sequence to which the current block belongs, 2) the luma component is enabled for the current block, 3) the prediction mode of the current block is intra mode, 4) the component type of the current block is a luma component, 5) the product of the width and height of the current block is less than 1024, 6) the type of slice to which the current block belongs is an I slice, and 7) the gradient-based guidance method is not applied to the current block, a flag (Timd_flag) may be signaled from the bitstream.

[0163] If the signaled flag is true (or 1), the initial intra prediction mode of the current block may be set to a predefined mode that is the same for both the encoding device and the decoding device. The initial intra prediction mode of the current block may be set to a predefined mode regardless of the availability of a template region. Here, the predefined mode may be a planar mode. However, if the planar mode is used as the predefined mode, this may result in duplication with using the planar mode as the first MPM in the MPM list. Therefore, a DC mode may be used as the predefined mode.

[0164] The initial intra prediction mode of the current block may be updated / changed to an intra prediction mode induced by the above-mentioned template region-based induced method. Specifically, the initial intra prediction mode of the current block may be updated / changed based on the cost for each of one or more intra prediction modes available to the current block. Here, the one or more intra prediction modes available to the current block may refer to the above-mentioned candidate modes. The initial intra prediction mode of the current block may be updated / changed based on a candidate mode having a minimum cost among the costs calculated for the candidate modes.

[0165] Referring to FIG. 4, a reference sample for a current block may be determined (S410).

[0166] Reference samples for intra prediction of the current block may be determined from one or more reference sample lines, and the current block may use one reference sample line or may use two or more reference sample lines.

[0167] A reference sample line for intra prediction of the current block may be selected from a plurality of reference sample line candidates that are predefined in the same manner in the encoding device and the decoding device, and the predefined plurality of reference sample line candidates may include at least one of a first reference sample line adjacent to the current block, a second reference sample line that is 1-sample away from the current block, a third reference sample line that is 2-samples away from the current block, or a fourth reference sample line that is 3-samples away from the current block.

[0168] In order to determine the reference sample line of the current block, index information for identifying the position of the reference sample line to which the reference sample of the current block belongs may be used. For example, index information for identifying one of the plurality of reference sample line candidates may be signaled. Or, when two reference sample lines are used for intra prediction of the current block, two pieces of index information for identifying two reference sample lines among the plurality of reference sample line candidates may be signaled. Or, one of the two reference sample lines may be a default reference sample line, and signaling of the index information for the default reference sample line may be omitted, and only the index information for the other of the two reference sample lines may be signaled. Here, the default reference sample line refers to a reference sample line at a position that has already been defined in the same manner in the encoding device and the decoding device, and may be, for example, a first reference sample line adjacent to the current block.

[0169] Alternatively, the reference sample line of the current block may be used to determine the intra-prediction mode of the current block, in which case operation S410 may be performed before operation S400.

[0170] Referring to FIG. 4, intra prediction of the current block may be performed based on the intra prediction mode of the current block and a reference sample (S420).

[0171] When the intra prediction mode of the current block is a planar mode, the prediction sample of the current block may be generated by a first prediction sample, a second prediction sample, or a weighted sum of the first and second prediction samples. Here, the first prediction sample may be generated by horizontal interpolation. For example, the first prediction sample may be generated by interpolating a reference sample located at an upper right corner of the current block and one or more reference samples located on the same horizontal line as the first prediction sample. The second prediction sample may be generated by vertical interpolation. For example, the second prediction sample may be generated by interpolating a reference sample located at a lower left corner of the current block and one or more reference samples located on the same vertical line as the second prediction sample.

[0172] When the intra prediction mode of the current block is DC mode, an average value of neighboring samples of the current block may be calculated, and the calculated average value may be set for all prediction samples in the current block. Here, the neighboring samples may include top reference samples and left reference samples of the current block. However, the average value may be calculated using only top reference samples or left reference samples according to the type of the current block.

[0173] When the intra prediction mode of the current block is a directional mode, a projection may be performed on a reference sample line according to the angle of the directional mode. If a reference sample exists at the projected position, the reference sample may be set as a predicted sample of the current block. If a reference sample does not exist at the projected position, a sample corresponding to the projected position may be generated using one or more neighboring samples adjacent to the projected position. For example, a sample at the projected position (i.e., a decimal pel position) may be generated by performing interpolation based on two or more neighboring samples adjacent in both directions based on the projected position. Alternatively, any one of a plurality of neighboring samples adjacent to the projected position may be set as a sample at the projected position. In this case, a neighboring sample closest to the projected position among a plurality of neighboring samples adjacent to the projected position may be used. A predicted sample of the current block may be generated based on a sample at the projected position.

[0174] A plurality of reference sample lines may be used for intra prediction of the current block, and in this case, a projected position may exist for each reference sample line, i.e., samples of a plurality of projected positions may be determined, and a prediction sample of the current block may be generated based on a weighted sum of these.

[0175] When one intra prediction mode is derived for the current block by the MPM-based derivation method or the template region-based derivation method, intra prediction of the current block may be performed based on the intra prediction mode.

[0176] Alternatively, at least two intra prediction modes may be induced for the current block by the MPM-based deriving method or the template region-based deriving method. In this case, a prediction sample of the current block may be generated based on the at least two intra prediction modes, and a final prediction sample of the current block may be generated based on a weighted sum of the generated prediction samples. Hereinafter, for convenience of explanation, it is assumed that two intra prediction modes are induced for the current block, and these are referred to as a first intra prediction mode and a second intra prediction mode, respectively.

[0177] For a current block, a first prediction sample may be generated based on a first intra prediction mode, and a second prediction sample may be generated based on a second intra prediction mode, and a final prediction sample for the current block may be generated based on a weighted sum of the first prediction sample and the second prediction sample.

[0178] When the first and second intra prediction modes are derived by a template region based derivation method, weights for the weighted sum may be determined based on at least one of the costs calculated based on the two intra prediction modes. For example, weights applied to the first predicted sample and the second predicted sample may be determined according to Equation 1 below.

[0179] [Formula 1]

[0180] w1 = costMode2 / (costMode1 + costMode2)

[0181] w2 = 1 - w1

[0182] In Equation 1, w1 may represent a weighting applied to a first predicted sample, w2 may represent a weighting applied to a second predicted sample, costMode1 may represent a cost calculated based on a first intra prediction mode, and costMode2 may represent a cost calculated based on a second intra prediction mode.

[0183] When the first and second intra prediction modes are derived by an MPM-based derivation method, the weighting value for the weighted sum may be determined taking into consideration at least one of a mode value, a position of a group to which the corresponding intra prediction mode belongs, or whether the mode is a non-directional mode. For example, when the first intra prediction mode has a mode value smaller than that of the second intra prediction mode, a relatively large weighting value may be applied to the first prediction sample according to the first intra prediction mode. Or, when the group to which the first intra prediction mode belongs is a higher group than the group to which the second intra prediction mode belongs (for example, when the first intra prediction mode belongs to the first group and the second intra prediction mode belongs to the second group), a relatively large weighting value may be applied to the first prediction sample according to the first intra prediction mode. Or, when the first intra prediction mode is a non-directional mode and the second intra prediction mode is a directional mode, a relatively large weighting value may be applied to the first prediction sample according to the first intra prediction mode. When the first and second intra prediction modes are both non-directional modes, the same weighting value may be applied to the first prediction sample and the second prediction sample, or a relatively larger weighting value may be applied to the prediction sample corresponding to the intra prediction mode having a relatively smaller mode value among the first and second intra prediction modes.

[0184] The first and second intra prediction modes may share one same reference sample line. Alternatively, a reference sample line may be determined independently for each of the first and second intra prediction modes. The first and second predicted samples may be generated based on different reference sample lines. That is, the number / position of reference sample lines used to generate the first predicted sample may be different from the number / position of reference sample lines used to generate the second predicted sample.

[0185] Meanwhile, the prediction samples generated based on the at least two intra prediction modes may be corrected based on neighboring reconstruction samples of the current block. A final prediction sample of the current block may be generated based on a weighted sum of the corrected prediction samples. The weights for the weighted sum are as described above. Hereinafter, a method of correcting prediction samples for each intra prediction mode will be described in detail.

[0186] When the prediction sample of the current block is generated based on a non-directional mode (e.g., planar mode, DC mode), the corrected prediction sample may be generated based on a weighted sum of the prediction sample of the current block and one or more surrounding samples. Here, the one or more surrounding samples may include at least one of a top surrounding sample located on the same vertical line as the prediction sample or a left surrounding sample located on the same horizontal line as the prediction sample. A weight value for the weighted sum may be derived based on the position of the prediction sample and the size of the current block. For example, the weight value may be derived as shown in Equation 2 below.

[0187] [Formula 2]

[0188] wT[ y ] = 32 >> ( ( y << 1 ) >> shift )

[0189] wL[ x ] = 32 >> ( ( x << 1 ) >> shift)

[0190] shift = ( Log2( nTbW ) + Log2( nTbH ) - 2 ) >> 2

[0191] In Equation 2, wT may represent a weight applied to the top neighboring sample, and wL may represent a weight applied to the left neighboring sample. x and y represent the coordinates of the predicted sample. The variable shift is a variable for scaling and may be derived based on the width (nTbW) and height (nTbH) of the current block.

[0192] When the prediction sample of the current block is generated based on the vertical mode, the compensated prediction sample may be generated based on a weighted sum of the prediction sample of the current block and a reference sample. Here, the reference sample may be determined based on at least one of the variation between neighboring samples or the prediction sample. The variation may mean a difference between a left neighboring sample located on the same horizontal line as the prediction sample and a previously defined neighboring sample (e.g., the upper left neighboring sample). For example, the reference sample may be determined according to the following Equation 3:

[0193] [Formula 3]

[0194] refL[ x ][ y ] = p[ -1 ][ y ] - p[ -1 ][ -1 ] + predSamples[ x ][ y ]

[0195] In Equation 3, refL refers to a reference sample, p[-1][y] and p[-1][-1] refer to the left neighboring sample located on the same horizontal line as the predicted sample and the neighboring sample already defined, respectively, and predSamples[x][y] refers to the predicted sample at the (x, y) coordinate in the current block.

[0196] The weights for the weighted sum may be derived based on the position of the prediction sample and the size of the current block. For example, the weights may be derived as shown in Equation 4 below, which is described in Equation 2.

[0197] [Formula 4]

[0198] wL[ x ] = 32 >> ( ( x << 1 ) >> shift )

[0199] shift = ( Log2( nTbW ) + Log2( nTbH ) - 2 ) >> 2

[0200] When the prediction sample of the current block is generated based on the horizontal mode, the corrected prediction sample may be generated based on a weighted sum of the prediction sample of the current block and a reference sample. Here, the reference sample may be determined based on at least one of a variation between neighboring samples or a prediction sample. The variation may mean a difference between an upper neighboring sample located on the same vertical line as the prediction sample and a previously defined neighboring sample (e.g., an upper left neighboring sample). For example, the reference sample may be determined according to the following Equation 5.

[0201] [Formula 5]

[0202] refT[ x ][ y ] = p[ x ][ -1 ] - p[ -1 ][ -1 ] + predSamples[ x ][ y ]

[0203] In Equation 5, refT refers to a reference sample, p[x][-1] and p[-1][-1" may refer to the upper neighboring sample located on the same vertical line as the predicted sample and the previously defined neighboring sample, respectively. predSamples[x][y] may refer to the predicted sample at the (x, y) coordinate in the current block.

[0204] The weights for the weighted sum may be derived based on the position of the prediction sample and the size of the current block. For example, the weights may be derived as shown in Equation 6 below, which is described in Equation 2.

[0205] [Formula 6]

[0206] wT[ x ] = 32 >> ( ( y << 1 ) >> shift )

[0207] shift = ( Log2( nTbW ) + Log2( nTbH ) - 2 ) >> 2

[0208] When the prediction sample of the current block is generated based on a directional mode (excluding the vertical mode and horizontal mode), the corrected prediction sample may be generated based on a weighted sum of the prediction sample of the current block and a reference sample. Here, as described above, the prediction sample is generated based on a sample at a position projected in a forward direction according to the angle of the directional mode. The reference sample may mean a sample at a position projected in a backward direction according to the angle of the directional mode. When the backward projected position corresponds to an integer pel position, a sample at the position may be set as a reference sample. When the backward projected position corresponds to a fractional pel position, a reference sample may be determined based on samples at one or more integer pel positions adjacent to the position. In this case, one sample closest to the backward projected position may be set as a reference sample, and a reference sample at an integer pel position may be derived by interpolating a plurality of samples adjacent to the backward projected position.

[0209] The weights for the weighted sum may be derived based on the position of the prediction sample, the angle of the directional mode, and the size of the current block. This may be derived differently depending on whether the directional mode has vertical directionality. A mode having vertical directionality may mean a mode adjacent to the vertical mode, and a mode having horizontal directionality may mean a mode adjacent to the horizontal mode.

[0210] For example, when the directional mode is a mode having vertical directionality, the weights for the weighted sum may be derived as shown in Equation 7 below.

[0211] [Formula 7]

[0212] wL[ x ] = 32 >> ( ( x << 1 ) >> shift )

[0213] shift = Min( 2, Log2( nTbH ) - Floor( Log2( 3 * invAngle - 2 ) ) + 8 )

[0214] In Equation 7, wL may represent a weighting value applied to the reference sample, and x may represent the x-coordinate of the predicted sample. The variable shift is a variable for scaling and may be derived based on the height (nTbH) of the current block and the angle (invAngle) of the intra prediction mode of the current block.

[0215] Alternatively, when the directional mode is a mode having horizontal directionality, the weights for the weighted sum may be derived as shown in Equation 8 below.

[0216] [Formula 8]

[0217] wT[ y ] = 32 >> ( ( y << 1 ) >> shift )

[0218] shift = Min( 2, Log2( nTbW ) - Floor( Log2( 3 * invAngle - 2 ) ) + 8 )

[0219] In Equation 8, wT may represent a weighting value applied to the reference sample, and y may represent the y-coordinate of the predicted sample. The variable shift is a variable for scaling and may be derived based on the width (nTbW) of the current block and the angle (invAngle) of the intra prediction mode of the current block.

[0220] The correction of the predicted sample may be adaptively performed based on at least one of the size of the current block, the position of the reference sample line of the current block, or the intra prediction mode of the current block. For example, if at least one of the width or height of the current block is greater than or equal to a predetermined threshold value, the correction of the predicted sample may be performed, and if not, the correction of the predicted sample may not be performed. Here, the threshold value may be 4, 8, or more. If the position of the reference sample line of the current block is a position that is previously defined to be the same in the encoding device and the decoding device, the correction of the predicted sample may be performed, and if not, the correction of the predicted sample may not be performed. Here, the previously defined position may correspond to a first reference sample line adjacent to the current block. If the intra prediction mode of the current block is a non-directional mode or a directional mode having some mode values ​​of the previously defined directional modes, the correction of the predicted sample may be performed, and if not, the correction of the predicted sample may not be performed. Here, the some mode values ​​may include at least one of a mode value greater than or equal to a vertical mode, or a mode value less than or equal to a horizontal mode. Alternatively, if the intra prediction mode of the current block is a directional mode, the prediction samples may be corrected, and if the intra prediction mode of the current block is a non-directional mode, the prediction samples may not be corrected.

[0221] Information indicating whether correction of the predicted sample is performed may be signaled in the bitstream, i.e., if the information indicates that correction of the predicted sample is performed, the predicted sample may be corrected by the above-mentioned method, otherwise the predicted sample may be set as the final predicted sample without further correction.

[0222] FIG. 5 is a diagram showing a schematic configuration of the intra prediction unit 331 that performs the intra prediction method according to the present disclosure.

[0223] Referring to FIG. 5, the intra prediction unit 331 may include a mode guidance unit 500, a reference sample determination unit 510, and a predicted sample generation unit 520.

[0224] The mode inducer 500 may induce the intra prediction mode of the current block.

[0225] The intra prediction mode of the current block may be derived from intra prediction modes already defined in the decoding apparatus. The intra prediction mode of the current block may be derived based on the MPM or based on the template region of the current block. This has been described with reference to FIG. 4, and detailed description thereof will be omitted here.

[0226] The mode induction unit 500 may adaptively use the template region-based induction method based on a predetermined flag. Here, the flag may indicate whether the intra prediction mode of the current block is induced based on a cost calculated from a template region adjacent to the current block. The flag may be signaled from the bitstream when a predetermined condition is satisfied, as described with reference to Tables 1 to 4.

[0227] If the flag is not signaled, the mode induction unit 500 may induce the flag to 0 and induce the intra prediction mode of the current block according to an MPM-based induction method. Alternatively, if the flag is not signaled, the mode induction unit 500 may induce the flag to 1 and induce the intra prediction mode of the current block as a mode that is predefined in the same manner in the encoding device and the decoding device. Here, the predefined mode may be a planar mode or a DC mode.

[0228] Or, even if the flag is signaled while satisfying a certain condition as shown in Table 1, the mode guidance unit 500 may update / change the signaled flag by further considering whether the template region is available. Furthermore, when the signaled flag is updated / changed to 0, the mode guidance unit 500 may guide the intra prediction mode of the current block as a mode (e.g., planar mode or DC mode) that is already defined equally to the encoding device and the decoding device, or may guide it according to the above-mentioned MPM-based guidance method.

[0229] Alternatively, even if the flag is signaled because a certain condition is satisfied, the mode induction unit 500 may set the initial intra prediction mode of the current block to a mode that is predefined in the encoding device and the decoding device. Here, the predefined mode may be a planar mode or a DC mode. Then, the mode induction unit 500 may update / change the initial intra prediction mode of the current block based on the intra prediction mode induced by the above-mentioned template region-based induction method.

[0230] The reference sample determination unit 510 may determine a reference sample for intra prediction of a current block from one or more reference sample lines. To this end, the reference sample determination unit 510 may select one or more reference sample lines from a plurality of reference sample line candidates that are previously defined in common to the encoding device and the decoding device. Predetermined index information may be used to select the reference sample line, as described with reference to FIG.

[0231] The prediction sample generating unit 520 may perform intra prediction of the current block based on the intra prediction mode of the current block and the reference sample. A specific intra prediction method has been described with reference to FIG. 4, and therefore will not be described here.

[0232] FIG. 6 illustrates an intra prediction method performed by an encoding device according to an embodiment of the present disclosure.

[0233] Referring to FIG. 6, an intra-prediction mode for a current block can be determined (S600).

[0234] The intra prediction mode of the current block may be determined from intra prediction modes already defined in the encoding device. The intra prediction mode of the current block may be determined based on the MPM or based on the cost of the template region of the current block.

[0235] MPM-based decision method

[0236] According to the MPM-based determination method, an optimal intra-prediction mode for a current block may be determined, and intra-prediction mode information for identifying the optimal intra-prediction mode may be coded into a bitstream. In this manner, the MPM-based determination method may be distinguished from the template region-based determination method described below in that intra-prediction mode information is coded and transmitted to a decoding device.

[0237] The intra prediction modes predefined in the encoding apparatus may be divided into K groups, where K may be an integer of 2, 3, 4, or more. For example, the predefined intra prediction modes may be divided into three groups, and the method of configuring the three groups is as described with reference to FIG.

[0238] In order to identify a group and / or sub-group to which the same mode as the intra prediction mode of the current block belongs, one or more flags may be coded into the bitstream. Here, the flags may include at least one of a first flag indicating whether the same mode as the intra prediction mode of the current block belongs to a first group, a second flag indicating whether the same mode as the intra prediction mode of the current block belongs to a second group (i.e., an MPM list), a third flag indicating whether the same mode as the intra prediction mode of the current block belongs to the first MPM list, or a fourth flag indicating whether the same mode as the intra prediction mode of the current block belongs to a second MPM list.

[0239] When the intra prediction mode of the current block belongs to the second group, an index identifying one of the MPMs belonging to the second group may be coded into the bitstream. The index may identify an MPM that is the same as the intra prediction mode of the current block among the MPMs belonging to the second group. Alternatively, when the intra prediction mode of the current block belongs to a first MPM list, an index identifying one of the MPMs belonging to the first MPM list may be coded into the bitstream. The index may identify an MPM that is the same as the intra prediction mode of the current block among the MPMs belonging to the first MPM list. Alternatively, when the intra prediction mode of the current block belongs to a second MPM list, an index identifying one of the MPMs belonging to the second MPM list may be coded into the bitstream. The index may identify an MPM that is the same as the intra prediction mode of the current block among the MPMs belonging to the second MPM list. Similarly, when the intra prediction mode of the current block belongs to the first group (or the third group), an index identifying one of the intra prediction modes belonging to the first group (or the third group) may be coded into the bitstream. The index may identify the same mode as the intra prediction mode of the current block among the intra prediction modes belonging to the first group (or the third group). However, when the first group (or the third group) is configured with one intra prediction mode, coding of the index may be omitted.

[0240] The above-mentioned flags may be coded with dependencies between the flags. For example, the first flag may be coded after the second flag is coded into the bitstream. The first flag may be coded when the second flag is True. Or, the second flag may be coded after the first flag is coded into the bitstream. The second flag may be coded when the first flag is False. When the second flag is True, the third flag (or the fourth flag) may be coded into the bitstream, and when the second flag is False, the third flag (or the fourth flag) may not be coded into the bitstream. Or, the fourth flag may be coded after the third flag is coded into the bitstream. Or, the fourth flag may be coded when the third flag is False.

[0241] Template Region-Based Decision Method

[0242] At the encoder side, an intra prediction mode may be derived based on a template region adjacent to a current block. That is, a cost of the template region may be calculated for a certain candidate mode. Here, the cost may be calculated as SAD or SATD of a predicted sample in the template region and an original sample (or a reconstructed sample). One or more candidate modes having a minimum cost among the costs calculated for the candidate modes may be selected. An intra prediction mode of the current block may be set based on the selected one or more candidate modes. A specific template region-based determination method has been described with reference to FIG. 4, and a duplicate description will be omitted here.

[0243] It may be determined whether the intra prediction mode of the current block is determined based on a cost calculated from a template region of the current block. Based on the result of the determination, a predetermined flag (Timd_flag) may be coded into the bitstream. Here, the flag may indicate whether the intra prediction mode of the current block is determined based on a cost calculated from a template region of the current block. For example, if the intra prediction mode of the current block is determined by a template region-based determination method, the flag may be coded to a first value, and if not, the flag may be coded to a second value.

[0244] However, the flag may be coded into the bitstream based on at least one of: 1) whether a template region-based guidance method is available; 2) whether the luma component of the current block is valid; 3) whether the prediction mode of the current block is an intra mode; 4) whether the component type of the current block is a luma component; 5) whether the size of the current block is greater than a predetermined threshold size; 6) whether the slice to which the current block belongs is an I-slice; or 7) whether a gradient-based guidance method is applied.

[0245] Whether the template region-based guidance method is available may be determined based on a flag coded at least one level of the video sequence, the picture, the picture header, or the slice header.

[0246] If the current block is a single-tree type or dual-tree type luminance block, the luminance component of the current block may be determined to be valid. On the other hand, if the current block is a dual-tree type chrominance block, the luminance component of the current block may be determined to be invalid. Here, the single-tree type may refer to a tree type in which a chrominance block of a coding unit has a partition structure subordinate to the partition structure of the luminance block, and the dual-tree type may refer to a tree type in which a chrominance block of a coding unit has a partition structure independent of the luminance block.

[0247] Even if the current block is a single tree type, if the current block is a chrominance block, it may be determined that the component type of the current block is a luma component as False. On the other hand, even if the current block is a single tree type, if the current block is a luma block, it may be determined that the component type of the current block is a luma component as True. If the current block is a dual tree type luma block, it may be determined that the component type of the current block is a luma component as True, and if the current block is a dual tree type chrominance block, it may be determined that the component type of the current block is a luma component as False.

[0248] The gradient-based guidance method may refer to a method of guiding an intra prediction mode based on a gradient calculated from a neighboring region of a current block in an encoding device.

[0249] For example, as described in Table 1, the flag (Timd_flag) may be coded into the bitstream if: 1) a template region-based guidance method is available for the video sequence to which the current block belongs; 2) the luma component is enabled for the current block; 3) the prediction mode of the current block is intra mode; 4) the component type of the current block is a luma component; 5) the product of the width and height of the current block is less than 1024; 6) the type of slice to which the current block belongs is an I slice; and 7) the gradient-based guidance method is not applied to the current block.

[0250] In this case, if the intra prediction mode of the current block is determined by a template region-based decision method, the flag may be coded to 1, and if not (e.g., if the intra prediction mode of the current block is determined by an MPM-based decision method), the flag may be coded to 0.

[0251] On the other hand, if the conditions according to Table 1 are not satisfied, the flag may not be coded into the bitstream. In this case, the flag may be induced to be 0, and the intra prediction mode of the current block may be determined by the MPM-based determination method.

[0252] If the neighboring blocks of the current block are not available, the template region for calculating the cost cannot be configured. In this case, the already set initial intra prediction mode may be used as the intra prediction mode of the current block. In this case, the value of the already set initial intra prediction mode may be set to 0, which corresponds to the planar mode. That is, even if the flag coded according to the conditions of Table 1 is 1, if the neighboring blocks of the current block are not available, the template region-based determination method is not used and the intra prediction mode of the current block may be set to the already set mode, the planar mode.

[0253] However, the first MPM in the MPM list according to the above-mentioned MPM-based decision method may be a planar mode. That is, when the neighboring blocks of the current block are not available and the flag (Timd_flag) is coded to 1, the intra prediction mode of the current block is the already set planar mode, which is the same as the planar mode, which is the first MPM in the MPM list. Therefore, it may be unnecessary to code a flag indicating whether the template region-based decision method is applied when the neighboring blocks of the current block are not available. In order to prevent such unnecessary coding, the template region-based decision method may be restricted so that it is not allowed when the neighboring blocks are not available.

[0254] When a template region for cost calculation cannot be constructed because neighboring blocks are not available, the encoding apparatus cannot calculate the cost from the template region and therefore cannot determine the intra prediction mode of the current block by the template region-based determination method, and therefore may restrict the encoding conditions of the flag so that the template region-based determination method is not permitted.

[0255] The flag may be coded into the bitstream based on at least one of: 1) whether a template region-based guidance method is available; 2) whether the luma component of the current block is valid; 3) whether the prediction mode of the current block is an intra mode; 4) whether the component type of the current block is a luma component; 5) whether the size of the current block is greater than a predetermined threshold size; 6) whether the slice to which the current block belongs is an I-slice; 7) whether a gradient-based guidance method is applied to the current block; or 8) whether a template region of the current block is available.

[0256] The above conditions 1) to 7) are as described above, and therefore will not be described here again. If a template region satisfies one or more of the following conditions, the template region may be determined to be unavailable, and if not, the template region may be determined to be available.

[0257] 1) The x-coordinate of the top left sample in the surrounding block is less than 0.

[0258] 2) The y-coordinate of the top left sample in the surrounding block is less than 0.

[0259] 3) The x-coordinate of the top left sample in the surrounding block is equal to or greater than the picture width.

[0260] 4) The y-coordinate of the top left sample in the surrounding block is equal to or greater than the height of the picture.

[0261] 5) The neighboring blocks have a later decoding order than the current block.

[0262] 6) The neighboring blocks are included in a different slice than the current block.

[0263] 7) The neighboring blocks are contained in different tiles than the current block.

[0264] For example, as described in Table 2, the flag (Timd_flag) may be coded into the bitstream if 1) a gradient-based guidance method is available for the video sequence to which the current block belongs, 2) the luma component is enabled for the current block, 3) the prediction mode of the current block is intra mode, 4) the component type of the current block is a luma component, 5) the product of the width and height of the current block is less than 1024, 6) the type of slice to which the current block belongs is an I slice, 7) the gradient-based guidance method is not applied to the current block, and 8) the template region of the current block is available.

[0265] If the conditions according to Table 2 are not met, the flag may not be coded into the bitstream and may be induced as 0 (or False). In this case, the intra prediction mode of the current block may be determined by the above-mentioned MPM-based determination method.

[0266] When a template region for cost calculation cannot be constructed because neighboring blocks are not available, the encoding apparatus cannot calculate the cost from the template region and cannot determine the intra prediction mode of the current block by the template region-based determination method, and therefore may restrict the encoding conditions of the flag so that the template region-based determination method is not allowed.

[0267] As described in Table 3, if the template region of the current block is available, the flag (Timd_flag) is coded into the bitstream, otherwise the flag does not need to be coded into the bitstream.

[0268] If the flag is not coded in the bitstream, the flag may be induced to be True (or 1) as shown in Table 3. However, the intra prediction mode of the current block may be induced to be a mode that is predefined in the same manner in the encoding device and the decoding device. Here, the predefined mode may be a planar mode. Thus, even if the flag is induced to be 1 because the flag is not coded in the bitstream, the intra prediction mode of the current block may be restricted not to be determined by the template region-based determination method.

[0269] Alternatively, the flag may be coded into the bitstream if it satisfies the conditions according to Table 1. However, the coded flag may be updated / changed taking into account the availability of template regions.

[0270] For example, the flag (Timd_flag) may be coded into a bitstream if 1) a template region-based guiding method is available for the video sequence to which the current block belongs, 2) a luminance component is enabled for the current block, 3) a prediction mode for the current block is an intra mode, 4) a component type for the current block is a luminance component, 5) a product of the width and height of the current block is less than 1024, 6) a type of a slice to which the current block belongs is an I slice, and 7) a gradient-based guiding method is not applied to the current block. If the flag is coded to 1, it may be further determined whether a template region for the current block is available. If the determination result indicates that the template region is available, the flag may be maintained to 1, and if not, the flag may be updated / changed to 0. In this case, the intra prediction mode of the current block may be induced as a mode (e.g., a planar mode) that is already defined in the same manner for the encoding device and the decoding device, or may be determined by the above-mentioned MPM-based determination method.

[0271] When a template region for cost calculation cannot be constructed because neighboring blocks are not available, the encoding apparatus cannot calculate the cost from the template region and cannot determine the intra prediction mode of the current block by the template region-based determination method, and therefore may restrict the encoding conditions of the flag so that the template region-based determination method is not allowed.

[0272] As described in Table 4, if the neighboring blocks of the current block are available, the flag (Timd_flag) is coded into the bitstream, otherwise the flag does not need to be coded into the bitstream.

[0273] If the flag is not coded in the bitstream, the flag may be induced to be True (or 1) as shown in Table 4. However, the intra prediction mode of the current block may be induced to be a mode that is predefined in the same manner in the encoding device and the decoding device. Here, the predefined mode may be a DC mode. Thus, even if the flag is induced to be 1 because the flag is not coded in the bitstream, the intra prediction mode of the current block may be restricted not to be determined by the template region-based determination method.

[0274] Alternatively, the flag may be coded into the bitstream if it satisfies the conditions according to Table 1. However, the coded flag may be updated / changed taking into account the availability of template regions.

[0275] For example, if 1) a template region-based guiding method is available for the video sequence to which the current block belongs, 2) a luma component is enabled for the current block, 3) a prediction mode for the current block is an intra mode, 4) a component type for the current block is a luma component, 5) a product of the width and height of the current block is less than 1024, 6) a type of a slice to which the current block belongs is an I slice, and 7) a gradient-based guiding method is not applied to the current block, the flag (Timd_flag) may be coded into a bitstream. If the flag is coded to 1, it may be further determined whether a template region for the current block is available. If the template region is available as a result of the determination, the flag may be maintained to 1, and if not, the flag may be updated / changed to 0. In this case, the intra prediction mode of the current block may be induced as a mode (e.g., DC mode) that is already defined in the same manner for the encoding device and the decoding device, or may be determined by the above-mentioned MPM-based determination method.

[0276] As described above, the flag (Timd_flag) for the current block may be coded into the bitstream based on at least one of: 1) whether a template region-based guidance method is available; 2) whether the luma component of the current block is valid; 3) whether the prediction mode of the current block is an intra mode; or 4) whether the component type of the current block is a luma component; 5) whether the size of the current block is greater than a predetermined threshold size; 6) whether the slice to which the current block belongs is an I slice; or 7) whether a gradient-based guidance method is applied to the current block.

[0277] For example, as shown in Table 1, if certain conditions are met, namely, 1) a gradient-based guidance method is available for the video sequence to which the current block belongs, 2) the luma component is enabled for the current block, 3) the prediction mode of the current block is intra mode, 4) the component type of the current block is a luma component, 5) the product of the width and height of the current block is less than 1024, 6) the type of slice to which the current block belongs is an I slice, and 7) the gradient-based guidance method is not applied to the current block, a flag (Timd_flag) may be coded into the bitstream.

[0278] If the flag is coded as True (or 1), the initial intra prediction mode of the current block may be set to a predefined mode that is the same for both the encoding device and the decoding device. The initial intra prediction mode of the current block may be set to a predefined mode regardless of the availability of a template region. Here, the predefined mode may be a planar mode. However, if the planar mode is used as the predefined mode, this may result in duplication with using the planar mode as the first MPM in the MPM list. Therefore, the DC mode may be used as the predefined mode.

[0279] The initial intra prediction mode of the current block may be updated / changed to the intra prediction mode determined by the above-mentioned template region-based determination method.

[0280] Referring to FIG. 6, a reference sample for a current block may be determined (S610).

[0281] Reference samples for intra prediction of the current block may be determined from one or more reference sample lines, and the current block may use one reference sample line or may use two or more reference sample lines.

[0282] A reference sample line for intra prediction of the current block may be selected from a plurality of reference sample line candidates that are predefined in the same manner in the encoding device and the decoding device, and the predefined plurality of reference sample line candidates may include at least one of a first reference sample line adjacent to the current block, a second reference sample line that is 1-sample away from the current block, a third reference sample line that is 2-samples away from the current block, or a fourth reference sample line that is 3-samples away from the current block.

[0283] Index information for identifying a position of a reference sample line to which a reference sample of the current block belongs may be coded into a bitstream. For example, index information for identifying one of the plurality of reference sample line candidates may be coded. Or, when two reference sample lines are used for intra prediction of the current block, two pieces of index information for identifying two reference sample lines among the plurality of reference sample line candidates may be coded. Or, one of the two reference sample lines may be a default reference sample line, and coding of index information for the default reference sample line may be omitted, and only index information for the other of the two reference sample lines may be coded. Here, the default reference sample line refers to a reference sample line at a position that is previously defined in the same manner in the encoding device and the decoding device, and may be, for example, a first reference sample line adjacent to the current block.

[0284] Alternatively, the reference sample line of the current block may be used to determine the intra-prediction mode of the current block, in which case operation S610 may be performed before operation S600.

[0285] Referring to FIG. 6, a prediction sample of a current block may be generated based on an intra prediction mode of the current block and a reference sample (S620).

[0286] The method of generating the predicted sample is the same as that described with reference to Fig. 4, and therefore a detailed description thereof will be omitted here. A residual sample, which is the difference between an original sample of the current block and a predicted sample, is generated and encoded to generate a bitstream.

[0287] Meanwhile, multiple reference sample lines may be used for intra prediction of the current block, and in this case, a projected position may exist for each reference sample line, i.e., samples of multiple projected positions may be determined, and a prediction sample of the current block may be generated based on a weighted sum of these samples.

[0288] When one intra prediction mode is induced for the current block by the MPM-based deriving method or the template region-based deriving method, intra prediction of the current block may be performed based on the intra prediction mode. Alternatively, at least two intra prediction modes may be induced for the current block by the MPM-based determination method or the template region-based determination method. Prediction samples corresponding to the at least two intra prediction modes may be generated, and the prediction sample of the current block may be generated by a weighted sum of the prediction samples. This has been described with reference to FIG. 4, and detailed description thereof will be omitted here.

[0289] As described above, the at least two intra prediction modes for the current block may share the same reference sample line, or a reference sample line may be determined independently for each of the at least two intra prediction modes.

[0290] Alternatively, the prediction samples generated based on the at least two intra prediction modes may be corrected based on neighboring reconstruction samples of the current block, and the final prediction sample of the current block may be generated based on a weighted sum of the corrected prediction samples. A specific method of correcting the prediction samples has been described with reference to FIG. 4, and a duplicate description will be omitted here.

[0291] FIG. 7 is a diagram showing a schematic configuration of the intra prediction unit 222 that performs the intra prediction method according to the present disclosure.

[0292] Referring to FIG. 7, the intra prediction unit 222 may include a mode decision unit 700, a reference sample decision unit 710, and a predicted sample generation unit 720.

[0293] The mode decision unit 700 may decide an intra-prediction mode of a current block.

[0294] The intra prediction mode of the current block may be derived from intra prediction modes already defined in the encoding device. The intra prediction mode of the current block may be determined based on the MPM or derived based on the cost of a template region adjacent to the current block. This has been described with reference to FIG. 6, and detailed description thereof will be omitted here.

[0295] The mode determination unit 700 may determine a predetermined flag (Timd_flag) to adaptively use the above-mentioned template region-based determination method. Here, the flag may indicate whether the intra prediction mode of the current block is determined based on a cost calculated from a template region adjacent to the current block. The mode determination unit 700 may determine the flag and encode the flag when a predetermined condition is satisfied, as described with reference to Tables 1 to 4.

[0296] If the flag is not coded, the mode decision unit 700 may induce the flag to be 0 and may decide the intra prediction mode of the current block according to an MPM-based decision method. Alternatively, if the flag is not coded, the mode decision unit 700 may induce the flag to be 1 and may set the intra prediction mode of the current block to a mode that is predefined in the same manner in the encoding device and the decoding device. Here, the predefined mode may be a planar mode or a DC mode.

[0297] Or, even if the flag is coded satisfying a predetermined condition as shown in Table 1, the mode decision unit 700 may update / change the coded flag by further considering whether a template region is available. Furthermore, when the coded flag is updated / changed to 0, the mode decision unit 700 may induce the intra prediction mode of the current block as a mode (e.g., planar mode or DC mode) that is already defined in the same manner in the encoding device and the decoding device, or may decide according to the above-mentioned MPM-based decision method.

[0298] Alternatively, even if the flag is coded to satisfy a certain condition, the mode decision unit 700 may set the initial intra prediction mode of the current block to a mode that is predefined in the encoding device and the decoding device. Here, the predefined mode may be a planar mode or a DC mode. Then, the mode decision unit 700 may update / change the initial intra prediction mode of the current block based on the intra prediction mode determined by the above-mentioned template region-based decision method.

[0299] The reference sample determination unit 710 may determine a reference sample for intra prediction of a current block from one or more reference sample lines. To this end, the reference sample determination unit 710 may select one or more reference sample lines from a plurality of reference sample line candidates that are predefined in common in the encoding apparatus and the decoding apparatus. Predetermined index information identifying the selected reference sample line may be coded into a bitstream.

[0300] The prediction sample generating unit 720 may perform intra prediction of the current block based on the intra prediction mode of the current block and the reference sample. A specific intra prediction method has been described with reference to FIG. 6, and therefore will not be described here.

[0301] In the above-described embodiments, the method is described based on a flow chart with a series of steps or blocks, but the embodiment is not limited to the order of steps, and some steps may occur in a different order or simultaneously with other steps described above. In addition, those skilled in the art will understand that the steps shown in the flow chart are not exclusive, and other steps may be included, or one or more steps of the flow chart may be deleted without affecting the scope of the embodiments of this document.

[0302] The methods according to the embodiments of the present document described above may be embodied in the form of software, and the encoding device and / or decoding device according to the present document may be included in an image processing device such as a TV, a computer, a smartphone, a set-top box, or a display device.

[0303] When the embodiments in this document are embodied as software, the methods described above may be embodied as modules (processes, functions, etc.) that perform the functions described above. The modules may be stored in a memory and executed by a processor. The memory may be provided inside or outside the processor and may be coupled to the processor by various means known in the art. The processor may include an application-specific integrated circuit (ASIC), other chipsets, logic circuits, and / or data processing devices. The memory may include a read-only memory (ROM), a random access memory (RAM), a flash memory, a memory card, a storage medium, and / or other storage devices. That is, the embodiments described in this document may be embodied and executed on a processor, microprocessor, controller, or chip. For example, the functional units shown in each figure may be embodied and executed on a computer, processor, microprocessor, controller, or chip. In this case, information (e.g., information on instructions) or algorithms for the implementation may be stored in a digital storage medium.

[0304] In addition, the decoding device and encoding device to which the embodiments of the present specification are applied may be included in a multimedia broadcast transmitting / receiving device, a mobile communication terminal, a home cinema video device, a digital cinema video device, a surveillance camera, a video conversation device, a real-time communication device such as a video communication, a mobile streaming device, a storage medium, a camcorder, a custom video (VoD) service providing device, an over-the-top video (OTT) device, an internet streaming service providing device, a three-dimensional (3D) video device, a virtual reality (VR) device, an argument reality (AR) device, an image telephone video device, a transportation means terminal (e.g., a vehicle (including an autonomous vehicle) terminal, an airplane terminal, a ship terminal, etc.), and a medical video device, etc., and may be used to process a video signal or a data signal. For example, an over-the-top video (OTT) device may include a game console, a Blu-ray player, an internet-connected TV, a home theater system, a smartphone, a tablet PC, a digital video recorder (DVR), etc.

[0305] In addition, the processing method to which the embodiments of the present specification are applied may be produced in the form of a program executed by a computer and may be stored in a computer-readable recording medium. Multimedia data having a data structure according to the embodiments of the present specification may also be stored in a computer-readable recording medium. The computer-readable recording medium includes any kind of storage device and distributed storage device in which computer-readable data is stored. The computer-readable recording medium may include, for example, a Blu-ray Disc (BD), a Universal Serial Bus (USB), a ROM, a PROM, an EPROM, an EEPROM, a RAM, a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device. The computer-readable recording medium may also include a medium embodied in the form of a carrier wave (e.g., transmission via the Internet). In addition, a bitstream generated by the encoding method may be stored in a computer-readable recording medium or transmitted through a wired or wireless communication network.

[0306] Furthermore, the embodiments of the present specification may be embodied as a computer program product by program code, the program code being executable by a computer according to the embodiments of the present specification. The program code may be stored on a computer readable carrier.

[0307] FIG. 8 illustrates an example of a content streaming system to which the embodiments of the present disclosure can be applied.

[0308] Referring to FIG. 8, a content streaming system to which the embodiments of the present specification are applied may broadly include an encoding server, a streaming server, a web server, a media storage, a user device, and a multimedia input device.

[0309] The encoding server compresses content input from a multimedia input device such as a smartphone, camera, camcorder, etc. into digital data to generate a bitstream and transmits the bitstream to the streaming server. As another example, when a multimedia input device such as a smartphone, camera, camcorder, etc. directly generates a bitstream, the encoding server may be omitted.

[0310] The bitstream may be generated by an encoding method or a bitstream generation method to which the embodiments of the present specification are applied, and the streaming server may temporarily store the bitstream in the process of transmitting or receiving the bitstream.

[0311] The streaming server transmits multimedia data to a user device based on a user request via a web server, and the web server acts as a medium to inform the user of available services. When a user requests a desired service from the web server, the web server transmits the request to the streaming server, and the streaming server transmits multimedia data to the user. In this case, the content streaming system may include a separate control server, and in this case, the control server plays a role of controlling commands / responses between devices in the content streaming system.

[0312] The streaming server may receive the content from a media storage and / or an encoding server. For example, when receiving the content from the encoding server, the content may be received in real time. In this case, the streaming server may store the bitstream for a certain period of time in order to provide a smooth streaming service.

[0313] Examples of the user devices include mobile phones, smart phones, laptop computers, digital broadcasting terminals, personal digital assistants (PDAs), portable multimedia players (PMPs), navigation systems, slate PCs, tablet PCs, ultrabooks, wearable devices (e.g., smartwatches, smart glass, head mounted displays (HMDs)), digital TVs, desktop computers, and digital signage.

[0314] Each server in the content streaming system may be operated as a distributed server, in which case data received by each server may be processed in a distributed manner.

[0315] The claims described herein may be combined in various ways. For example, the technical features of the method claims herein may be combined and embodied as an apparatus, the technical features of the apparatus claims herein may be combined and embodied as a method, the technical features of the method claims herein and the technical features of the apparatus claims herein may be combined and embodied as an apparatus, and the technical features of the method claims herein and the technical features of the apparatus claims herein may be combined and embodied as a method.

Claims

1. deriving an intra prediction mode of the current block based on a flag of the current block, the flag indicating whether the intra prediction mode of the current block is derived based on a cost of a template region adjacent to the current block; determining a reference sample of the current block; generating a predicted sample of the current block based on the intra prediction mode and the reference sample.

2. The image decoding method of claim 1 , wherein the flag is signaled from a bitstream based on whether a template region of the current block is available or not.

3. the flag is signaled from the bitstream if a template region for the current block is available; The image decoding method of claim 2 , wherein if the template region of the current block is not available, the flag is not signaled from the bitstream and the flag is induced to be 0. 3 .

4. the flag is signaled from the bitstream if a template region for the current block is available; The image decoding method of claim 2 , wherein if the neighboring blocks of the current block are not available, the flag is not signaled from the bitstream and the flag is induced to be 1. .

5. The image decoding method of claim 4 , wherein if the flag is induced to be 1, an intra prediction mode of the current block is set to a planar mode.

6. The image decoding method of claim 4 , wherein if the flag is induced to be 1, an intra prediction mode of the current block is set to a DC mode.

7. If the flag is 1, an intra prediction mode of the current block is determined based on a cost calculated from the template region; The image decoding method of claim 1 , wherein if the flag is 0, the intra prediction mode of the current block is derived based on intra prediction mode information of the current block.

8. The image decoding method of claim 7 , wherein if the flag is 1, an initial intra-prediction mode of the current block is set to a DC mode.

9. The image decoding method of claim 8 , wherein the initial intra-prediction mode of the current block is updated based on a cost for one or more intra-prediction modes available to the current block.

10. The image decoding method of claim 9 , wherein the flag is signaled from a bitstream regardless of whether a template region of the current block is available or not.

11. determining whether an intra prediction mode of a current block is determined based on a cost of a template region adjacent to the current block; determining an intra prediction mode of the current block based on the determination result; determining a reference sample of the current block; generating a predicted sample of the current block based on the intra prediction mode and the reference sample; A method for encoding an image, comprising: encoding a flag into a bitstream, the flag indicating whether an intra prediction mode of the current block is determined based on a cost of the template region.

12. 1. A computer-readable storage medium for storing a bitstream generated by an image encoding method, the image encoding method comprising: determining whether an intra prediction mode of a current block is determined based on a cost of a template region adjacent to the current block; determining an intra prediction mode of the current block based on the determination result; determining a reference sample of the current block; generating a predicted sample of the current block based on the intra prediction mode and the reference sample; A computer-readable storage medium, wherein a flag is encoded into a bitstream indicating whether an intra-prediction mode of the current block is determined based on a cost of the template region.

Citation Information

Cited By

  • Video Coding Method, Apparatus, Computer Program, and Electronic Device

    JP2025521399A

  • Video codec methods, apparatus, computer programs, and electronic devices.

    JP7875303B2