# Patent

## Title
Adaptive reshaping for layered coding of enhanced dynamic range signals

## Abstract

An encoder receives an input enhanced dynamic range (EDR) image to be coded in a layered representation. Input images may be gamma-coded or perceptually-coded using a bit-depth format not supported by one or more video encoders. The input image is remapped to one or more quantized layers to generate output code words suitable for compression using the available video encoders. Algorithms to determine optimum function parameters for linear and non-linear mapping functions are presented. Given a mapping function, the reverse mapping function may be transmitted to a decoder as a look-up table or it may be approximated using a piecewise polynomial approximation. A polynomial approximation technique for representing reverse-mapping functions and chromaticity translation schemes to reduce color shifts are also presented.

## Background
CROSS-REFERENCE TO RELATED APPLICATIONS
This application claims the benefit of priority to U.S. Provisional Patent Application No. 61/836,044 filed 17 Jun. 2013; U.S. Provisional Patent Application No. 61/951,914 filed 12 Mar. 2014; and U.S. Provisional Patent Application No. 62/002,631 filed 23 May 2014, each of which is hereby incorporated by reference in its entirety
The present application may also be related to International Application No. PCT/US2014/031716 filed 25 Mar. 2014, incorporated herein by reference in its entirety.


TECHNOLOGY
The present invention relates generally to video images. More particularly, an embodiment of the present invention relates to the adaptive reshaping of images with high or enhanced dynamic range for layered coding and decoding.
BACKGROUND
As used herein, the term ‘dynamic range’ (DR) may relate to a capability of the human psychovisual system (HVS) to perceive a range of intensity (e.g., luminance, luma) in an image, e.g., from darkest darks (blacks) to brightest brights (whites). In this sense, DR relates to a ‘scene-referred’ intensity. DR may also relate to the ability of a display device to adequately or approximately render an intensity range of a particular breadth. In this sense, DR relates to a ‘display-referred’ intensity. Unless a particular sense is explicitly specified to have particular significance at any point in the description herein, it should be inferred that the term may be used in either sense, e.g. interchangeably.
As used herein, the term high dynamic range (HDR) relates to a DR breadth that spans the some 14-15 orders of magnitude of the human visual system (HVS). For example, well adapted humans with essentially normal vision (e.g., in one or more of a statistical, biometric or ophthalmological sense) have an intensity range that spans about 15 orders of magnitude. Adapted humans may perceive dim light sources of as few as a mere handful of photons. Yet, these same humans may perceive the near painfully brilliant intensity of the noonday sun in desert, sea or snow (or even glance into the sun, however briefly to prevent damage). This span though is available to ‘adapted’ humans, e.g., those whose HVS has a time period in which to reset and adjust.
In contrast, the DR over which a human may simultaneously perceive an extensive breadth in intensity range may be somewhat truncated, in relation to HDR. As used herein, the terms enhanced dynamic range (EDR) or visual dynamic range (VDR) may individually or interchangeably relate to the DR that is simultaneously perceivable by a HVS. As used herein, EDR may relate to a DR that spans 5 to 6 orders of magnitude. Thus while perhaps somewhat narrower in relation to true scene referred HDR, EDR nonetheless represents a wide DR breadth.
In practice, images comprise one or more color components (e.g., luma Y and chroma Cb and Cr) wherein each color component is represented by a precision of n-bits per pixel (e.g., n=8).). Although luminance dynamic range and bit depth are not equivalent entities, they are often related. Images where n≦8 (e.g., color 24-bit JPEG images) are considered images of standard dynamic range, while images where n>8 may be considered images of enhanced dynamic range. EDR and HDR images may also be stored and distributed using high-precision (e.g., 16-bit) floating-point formats, such as the OpenEXR file format developed by Industrial Light and Magic.
Video signals may be characterized by multiple parameters, such as bit-depth, color space, color gamut, and resolution. Modern televisions and video playback devices (e.g., Blu-ray players) support a variety of resolutions, including standard-definition (e.g., 720×480i) and high-definition (HD) (e.g., 1920×1080p). Ultra high-definition (UHD) is a next generation resolution format with at least a 3,840×2,160 resolution (referred to as 4K UHD) and options to go as high as 7680×4320 (referred to as 8K UHD). Ultra high-definition may also be referred to as Ultra HD, UHDTV, or super high-vision. As used herein, UHD denotes any resolution higher than HD resolution.
To support backwards compatibility with legacy, 8-bit, playback devices as well as new HDR or UHD coding and display technologies, multiple formats may be used to deliver UHD and HDR (or EDR) video data from an upstream device to downstream devices. Given an EDR stream, some decoders may use a set of 8-bit layers to reconstruct an HD SDR or EDR version of the content. Advanced decoders may use a second set of layers, coded at a higher bit depth than the traditional 8 bits, to reconstruct an UHD EDR version of the content to render it on more capable displays. As appreciated by the inventor here, improved techniques for the coding and distribution of EDR video are desirable.
The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section. Similarly, issues identified with respect to one or more approaches should not assume to have been recognized in any prior art on the basis of this section, unless otherwise indicated.



BRIEF DESCRIPTION OF THE DRAWINGS
An embodiment of the present invention is illustrated by way of example, and not in way by limitation, in the figures of the accompanying drawings and in which like reference numerals refer to similar elements and in which:
FIG. 1A depicts an example framework of EDR layered encoding according to an embodiment of the present invention;
FIG. 1B depicts an example framework of EDR layered decoding according to an embodiment of the present invention;
FIG. 2 depicts an example EDR-signal reshaping function based on a power function, wherein function parameter cc is determined according to an embodiment of the present invention;
FIG. 3 depicts an example process for determining the optimum exponent of a forward shaping function for EDR inputs according to an embodiment of the present invention;
FIG. 4 depicts an example process for determining a forward mapping of EDR code words according to an embodiment of the present invention;
FIG. 5 depicts an example of intermediate mapping of input EDR code words (vc) to block-based scaling factors (k(vc)) computed according to an embodiment of the present invention;
FIG. 6 depicts an example mapping of input EDR code words to the final output reshaped symbols according to an embodiment of the present invention;
FIG. 7 depicts an example of reverse mapping computed according to an embodiment of the present invention;
FIG. 8A and FIG. 8B depict an example of chromaticity range scaling according to an embodiment of the present invention; and
FIG. 9 depicts an example of a coding and decoding pipeline according to an embodiment of the present invention.



DESCRIPTION OF EXAMPLE EMBODIMENTS
Adaptive reshaping techniques for the layered coding of video images with enhanced dynamic range (EDR) are described herein. In the following description, for the purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, that the present invention may be practiced without these specific details. In other instances, well-known structures and devices are not described in exhaustive detail, in order to avoid unnecessarily occluding, obscuring, or obfuscating the present invention.
OVERVIEW
Example embodiments described herein relate to the adaptive reshaping of video images with high or enhanced dynamic range for efficient layered coding. An encoder receives an input enhanced dynamic range (EDR) image to be coded in a layered representation. Input images may be gamma-coded or perceptually-coded using a bit-depth format not supported by one or more of available video encoders. The input image is remapped to one or more quantized layers to generate output code words suitable for compression using the available video encoders.
In one embodiment the remapping is based on a power-function using a single function parameter. Techniques are presented to determine the optimum function parameter based on computing a block-based complexity measure for each block in the input EDR image and then evaluating the amount of the quantization-induced distortion in the quantized image.
In another embodiment, an optimal mapping is generated using a block-based complexity metric, such as the standard deviation, and a block-based linear quantization model, where a separate optimal quantizer scaler is determined for each image block. The separate optimal scalers are combined to determine an envelope slope for each input code word, and an optimal forward mapping function between input and output code words is determined based on the envelope slopes. A reverse mapping function may be transmitted to a decoder as a look-up table or it may be approximated using a piecewise polynomial approximation.
In another embodiment, given a reverse mapping lookup table, the inverse mapping function is approximated using a piece-wise polynomial approximation technique.
In a decoder, the coded bitstream layers are decoded to generate decoded video layers which are recombined to generate a single decoded signal. Then, given received parameters that define the encoder reshaping or mapping functions, the decoded signal is inversely mapped to generate an estimate of the original EDR signal transmitted from an encoder to the decoder.
In another embodiment, the chromaticity color components of the input video signal may be translated so that the coordinates of a desired white point are approximately shifted to the center of the translated chromaticity range.
Example Framework for Video Signal Reshaping and Layered Decomposition
Layered Coding and Decoding
Existing display and play-back devices, such as HDTVs, set-top boxes, or Blu-ray players, typically support signals of up to 1080p HD resolution (e.g., 1920×1080 at 60 frames per second). For consumer applications, such signals are now typically compressed using a bit-depth of 8 bits per pixel per color component in a luma-chroma color format where typically the chroma components have a lower resolution than then luma component (e.g., the YCbCr or YUV 4:2:0 color format). Because of the 8-bit depth and the corresponding low dynamic range, such signals are typically referred to as signals with standard dynamic range (SDR). As new television standards are being developed, such as Ultra High Definition (UHD), it may be desirable to encode signals with enhanced resolution and/or enhanced dynamic range.
Video images are typically gamma-encoded to compensate for properties of the human vision system. For example, ITU-R Rec. 2020 defines the recommended gamma encoding of UHDTV signals. For EDR images, perceptual quantization (PQ), may provide a better alternative to traditional gamma coding. The human visual system responds to increasing light levels in a very non-linear way. A human's ability to see a stimulus is affected by the luminance of that stimulus, the size of the stimulus, the spatial frequency(ies) making up the stimulus, and the luminance level that the eyes have adapted to at the particular moment one is viewing the stimulus. A perceptual quantizer function maps linear input gray levels to output gray levels that better match the contrast sensitivity thresholds in the human visual system. Examples of PQ mapping functions are described in PCT Application with Ser. No. PCT/US2012/068212 (to be referred as the '212 application) titled “Perceptual luminance nonlinearity-based image data exchange across different display capabilities,” by J. S. Miller et al., filed on Dec. 6, 2012, and incorporated herein by reference in its entirety, where given a fixed stimulus size, for every luminance level (i.e., the stimulus level), a minimum visible contrast step at that luminance level is selected according to the most sensitive adaptation level and the most sensitive spatial frequency (according to HVS models). Compared to the traditional gamma curve, which represents the response curve of a physical cathode ray tube (CRT) device and coincidently may have a very rough similarity to the way the human visual system responds, a PQ curve, as determined by the '212 application, imitates the true visual response of the human visual system using a relatively simple functional model.
In U.S. Provisional Application Ser. No. 61/805,388, to be referred from now on as the '388 application, titled “Encoding perceptually-quantized video content in multi-layer VDR coding,” filed on Mar. 26, 2013 and incorporated herein by reference in its entirety, (filed also as PCT/US2014/031716 on Mar. 25, 2014), the inventors described an image reshaping technique for the efficient coding and transmission of PQ-coded EDR image data using a two-layer encoder. This application expands upon the '388 application by describing novel mapping or reshaping techniques applicable to coding EDR data using both single-layer or multi-layer encoders.
FIG. 1A depicts an example framework of EDR layered encoding according to an embodiment of the present invention. Input signal (102) comprises a sequence of video frames with EDR pixel values that may have been gamma- or PQ-encoded. The system includes at least one base-layer (BL) video encoder (120-0) and may include one or more enhancement-layer (EL) video encoders (120-1, 120-L−1), up to L−1, for a total of L encoding layers. For example, for L=2, the system comprises a dual-layer encoder. Video encoders (120) may all be the same or different, implementing any of the known or future coding formats for video compression, such as: MPEG-2, MPEG-4, part 2, H.264 (or AVC), H.265 (or HEVC), and the like. Furthermore, a video encoder in one layer may support a different bit depth than a video encoder in another layer. For example, without loss of generality, embodiments may include the following configurations:

    
    
        A single layer, HEVC encoder, supporting at least a bit depth of 10 bits, but preferably supporting 12 bits or more.
        A dual layer encoder, where both encoders may encode using the same format, say H.264, and both encoders support the same or different bit depths (say, 8 bits and 10 bits)
        A dual-layer encoder, wherein the two encoders may encode using different coding formats and each one may support different bit depths (say, 8-bits, and 10-bits or more)
        A multi-layer encoder, where at least one encoder is an 8-bit MPEG-2 encoder and at least one other encoder is either an HEVC or H.264 encoder.

Video encoders (120) may all be implemented by a single processor or by one or more processors.

    
    


According to an embodiment, a signal reshaping module (110) quantizes the input EDR signal (denoted as v) (102) into a signal s (112) that fits better the characteristics of the video encoders (120), such as the maximum supported bit depth. As used herein, the terms reshaping, quantization, and (forward) mapping denote equivalent functionality of mapping an input signal from a first dynamic range into an output signal of a second dynamic range, typically lower than the first dynamic range, and may be used interchangeably.
Let Bl denote the bit-depth used by the l-th layer video encoder (120-l, l=0, 1, 2, . . . , L−1), then, each layer can support up to Nl=2Bl input code words for a total of NT=N0+N1+ . . . +NL−1 code words. For example, for L=1 (single layer) and B0=10, there exist 210=1024 quantized code words. For L=2 (dual layer) and B0=B1=8, then there exist 28+28=512 quantized code words. When L=2 and B0=10 and B1=8, then there exist a total of the 210+28=1280 quantized code words. Hence, the system may accommodate any combination of video coding standards, each one operating at its own bit-depth.
Let s=ƒ(v) denote the signal reshaping/quantization function (110). Examples of such functions will be described in more detail later on. Parameters identifying the reshaping function may be included in a metadata signal (119). In some embodiments the metadata (119) may be encoded by metadata encoder (125), and the coded metadata (127) may be signaled to a decoder, as the one depicted in FIG. 1B, for proper inverse quantization and decoding. In another embodiment, signal reshaping (110) may comprise a family of signal reshaping functions, using separate shaping functions for one or more layers or one or more chroma components within a layer. For example, in an embodiment, the signal reshaping function for the base layer (l=0) may be a linear function, while the signal reshaping function for the first enhancement layer (l=1) may comprise a non-linear function or a piece-wise linear function.
Layer Decomposition
In an embodiment, let pixel values of quantized signal s (112) be partitioned into L segments defined by segment borders {pi, i=0, 1, . . . , L}, where p0 denotes typically the smallest possible value for s (e.g., p0=0) and




  
    
      
        
          
            p
            i
          
          =
          
            
              
                ∑
                
                  j
                  =
                  0
                
                
                  i
                  -
                  1
                
              
              ⁢
              
                
              
              ⁢
              
                
                  N
                  j
                
                ⁢
                
                  
                
                ⁢
                for
                ⁢
                
                  
                
                ⁢
                i
              
            
            =
            1
          
        
        ,
        ⋯
        ,
        
          L
          .
        
      
    
    
      
        (
        1
        )
      
    
  




For example, for L=1, p0=0 and pl=N0. This module will encode all code words into the base layer.
For L=2, p0=0, p1=N0, p2=N0+N1. In an embodiment, pixels with code word between {p0, p1} will be coded in layer 0 and pixels with code words between {p1, p2} will be encoded in layer 1. In general, given L layers, for each layer l, sl pixels at that layer are coded as;

sl=Clip3(s,pl,pl+1−1)−pl,l=0,1,2, . . . ,L−1,  (2)

where d=Clip3(s, a, b) denotes a clipping function, where d=s, if a≦s≦b, d=a, if s<a, and d=b, if s>b.

After layer decomposition (115), in an embodiment, each layer sl (117-l, l=0, 1, . . . L−1) may be encoded independently by video encoders (120 to generate compressed bit streams (122). As discussed in the '388 application, in some embodiments, the system depicted in FIG. 1A may be modified to allow for inter-layer prediction as well. In such embodiments, a predictor may be used to estimate pixels values of the l-th layer based on pixel values of the l−1 layer; then instead of coding the pixel values of the l-th layer directly one simply encodes and transmits the residual between the actual values and the predicted values.
In some embodiments, the coded bit streams (122), the coded metadata (127), and other data (e.g. audio data), may be multiplexed into a single bit stream and transmitted to a decoder as a single, multiplexed, bit stream (not shown).
FIG. 1B depicts an example framework of EDR layered decoding according to an embodiment of the present invention. As depicted in FIG. 1B, after demultiplexing of a received bit stream that may combine audio, video, and ancillary data (not shown), each of the received coded bit streams (122) is fed to an array of video decoders (130). Decoders 130) correspond to encoders (120) and generate one or more of decoded video signals (132). Using a signal inverse reshaping and layer composer (140) unit, the received layered signals are combined and inverse-shaped to generate signal {circumflex over (v)} (142), which represents an estimate of the original EDR signal (102). In an embodiment, output EDR signal (142) may be generated as




  
    
      
        
          
            v
            ^
          
          =
          
            
              f
              
                -
                1
              
            
            ⁡
            
              (
              
                
                  ∑
                  
                    i
                    =
                    0
                  
                  
                    L
                    -
                    1
                  
                
                ⁢
                
                  
                
                ⁢
                
                  
                    s
                    ^
                  
                  i
                
              
              )
            
          
        
        ,
      
    
    
      
        (
        3
        )
      
    
  




where ƒ−1 ( ) denotes the inverse (or a close approximation of the inverse) of the signal-reshaping function (110), and ŝl denotes the reconstructed layer signals (132), representing a very close approximation of the original sl signals (117). As depicted in FIG. 1B, there is no inter-layer prediction between the received layers; however, as it is known in the art of video coding, the system can easily be extended to decoders where ŝl signals are generated using received residual signals and inter-layer prediction.

EDR Signal Reshaping Using a Power-Function

As described in the '388 application, for PQ-coded signals, in an embodiment, the signal reshaping function (110) may be expressed as:




  
    
      
        
          
            s
            i
          
          =
          
            round
            ⁡
            
              (
              
                
                  
                    (
                    
                      
                        c
                        H
                      
                      -
                      
                        c
                        L
                      
                    
                    )
                  
                  ⁢
                  
                    
                      (
                      
                        
                          
                            v
                            i
                          
                          -
                          
                            v
                            L
                          
                        
                        
                          
                            v
                            H
                          
                          -
                          
                            v
                            L
                          
                        
                      
                      )
                    
                    α
                  
                
                +
                
                  c
                  L
                
              
              )
            
          
        
        ,
      
    
    
      
        (
        4
        )
      
    
  




where vL and vH denote the minimal value and maximal values in a color channel under consideration of the input EDR signal (102), and cL and cH denote the corresponding minimal and maximal output values. For example, in an embodiment, cL=0 and cH=pL−1, as defined in equation (1). The value of a is constant, but may be adapted and changed on a per frame, per scene, or other suitable criterion basis. FIG. 2 depicts an example of the power reshaping function of equation (4) for α<1. In an embodiment, if the input (112) is PQ-coded, then α>1, otherwise, if the input (112) is gamma-coded, then α<1.

In the '388 application, a method was described to determine an optimal value of α using a block-complexity metric (MEDR) based on the standard deviation of pixels within a block or the difference between the minimum and maximum pixel values within the block. In addition to these metrics, other complexity measures could be applied based on either the spatial or frequency characteristics of a block. For example, MEDR may correspond to the variance of pixels in the block, the DC value of a block, or another function of its pixel values or DCT coefficients.
Consider a video scene that comprises F video frames, each frame partitioned into N blocks (e.g., each block is 8×8 pixels). The image blocks may be overlapping, or in a preferred embodiment, non-overlapping. FIG. 3 depicts a process for computing an optimal α based on a generalized block-complexity measure MEDR(j,n) (e.g., without loss of generality, the standard deviation of pixel values within a block).
As depicted in FIG. 3, after step (305), where MEDR(j,n) is computed for each block in all frames in the scene, in step (310), a set Φj is constructed that includes all image blocks for which a certain criterion is satisfied (e.g., MEDR(j,n)>T, where T is a pre-specified threshold, say 0).
Steps (315), (320), and (325) comprise a loop (327) that is computed for a variety of αj values within a predetermined range (e.g., MIN_α≦αj≦MAX_α). For example, initially αj may be set equal to 1 and then be increased or decreased depending on how the original EDR video data is coded. For example, for PQ-coded data it will be increased and for gamma-coded data it will be decreased. In step (320), using the given αj and equation (4), the input data EDR is quantized and a new metric MLD(j,n,αj) may be computed for each quantized block. In some embodiments, complexity measure MLD may be identical to complexity measure MEDR In some other embodiments, the two complexity measures may be different. The more one quantizes the input EDR data, the more the characteristics of the quantized signal (112) will change. Ideally, the quantization (110) should distort the input as little as possible. In step (325), a measure of the distortion due to quantization may be applied to identify whether the selected αj value is optimum or not. For example, in an embodiment, αj may be selected as optimum if




  
    
      
        
        
          Φ
          j
        
        
      
      -
      
        
          ∑
          
            n
            ∈
            
              Φ
              j
            
          
        
        ⁢
        
          
        
        ⁢
        
          (
          
            
              
                M
                LD
              
              ⁡
              
                (
                
                  j
                  ,
                  n
                  ,
                  
                    α
                    j
                  
                
                )
              
            
            >
            
              T
              σ
            
          
          )
        
      
    
    ==
    0
  
  ,




where Tσ is another predetermined threshold (e.g., Tσ=0).

After all blocks in a scene have been quantized, an overall optimal alpha value is selected in step (330). For example, in an embodiment, for α>1, the overall optimal α is selected as the one that is minimum across all optimum αj values. Similarly, for α<1, the overall optimal α is selected as the one that is maximum across all optimum αj values.
In some embodiments, to adjust for quantization effects due to the lossy compression by video encoders (120), the overall optimum alpha may be further adjusted (e.g., α=α+Δa, where Δ is a negative value when α>1 and Δ is a positive value when α<1). The same parameter optimization process may also be easily extended to other linear or non-linear quantization and reshaping functions characterized by more than one function parameter.
Table 1 provides in pseudo-code an example algorithm for reshaping gamma-coded values according to an embodiment based on the process depicted in FIG. 3, where the desired α<1.







TABLE 1





Method to compute optimal α for gamma-coded EDR signals















//Initialize for each frame j within a scene of F total frames


αopt[j] = 1.0 for all j.


// for each frame


for( j = 0; j < F ; j++ ){


 // STEP 1.a : calculate complexity measurement for each block n in EDR


domain


  Calculate MEDR(j, n) for all values of n


 // STEP 1.b : Identify those blocks that satisfy a complexity criterion


  Construct Φj = {i|MEDR(j, n) > T}


 // STEP 2: Apply the reshaping function and compute updated 


complexity metrics for different α


 for( αj = 1.0; αj > MIN_a; αj = αj−0.1) {


   // STEP 2a: quantize EDR using power function with αj


 


   



  
    s
    
      j
      ,
      i
    
  
  =
  
    round
    ⁢
    
      
    
    ⁢
    
      (
      
        
          
            (
            
              
                c
                H
              
              -
              
                c
                L
              
            
            )
          
          ⁢
          
            
              (
              
                
                  
                    v
                    
                      j
                      ,
                      i
                    
                  
                  -
                  
                    v
                    L
                  
                
                
                  
                    v
                    H
                  
                  -
                  
                    v
                    L
                  
                
              
              )
            
            
              α
              j
            
          
        
        +
        
          c
          L
        
      
      )
    
  






 


   // STEP 2b: calculate complexity measurement for each block after


layer decomposition


   Calculate MLD(j, n, αj) for all n


   // STEP 2c: calculate whether given αj causes near-zero deviation


 


   



  if
  (
  
    
      
        
        
          Φ
          j
        
        
      
      -
      
        
          ∑
          
            n
            ∈
            
              Φ
              j
            
          
        
        ⁢
        
          
        
        ⁢
        
          (
          
            
              
                M
                LD
              
              ⁡
              
                (
                
                  j
                  ,
                  n
                  ,
                  
                    α
                    j
                  
                
                )
              
            
            >
            
              T
              σ
            
          
          )
        
      
    
    ==
    0
  
  )






 


    αopt[j] = αj


   else


    break;


 }


}


// STEP 3: find the maximal αopt[j] as the final α


  α = max{ αopt[j] }


//Apply optional safety margin


  α = α + Δa,









In a decoder, the inverse shaping operation (140) can be expressed as




  
    
      
        
          
            v
            ^
          
          i
        
        =
        
          
            
              (
              
                
                  v
                  H
                
                -
                
                  v
                  L
                
              
              )
            
            ⁢
            
              
                (
                
                  
                    
                      
                        s
                        ^
                      
                      i
                    
                    -
                    
                      c
                      L
                    
                  
                  
                    
                      c
                      H
                    
                    -
                    
                      c
                      L
                    
                  
                
                )
              
              
                1
                /
                α
              
            
          
          +
          
            
              v
              L
            
            .
          
        
      
    
    
      
        (
        5
        )
      
    
  




In some embodiments, the power function of equation (4) may be expressed as a piecewise linear polynomial, a piecewise 2-d or 3-d order polynomial, or a piecewise B-spline. In such implementations, it is suggested that smoothness and monotonicity constraints across the pieces should be enforced to avoid quantization-related artifacts. Then search methods similar to those described earlier or in the '388 application may be applied.
Block-Adaptive Reshaping Function
Consider again a video scene that comprises F video frames, each frame partitioned into N blocks (e.g., each block is 8×8 pixels). The image blocks may be overlapping, or in a preferred embodiment, non-overlapping. FIG. 4 depicts an example data flow for mapping input EDR code words (102) into reshaped output values (112), according to an embodiment.
As described before, one can define a block-based complexity measure (MEDR). In an embodiment, in step (405), without loss of generality, consider the complexity measure to be computed based on the standard deviation (std) of the pixels in the block. Note that checking whether the standard deviation of block n in frame j (j=1, 2, . . . , F) is zero (e.g., MEDR(j,n)=stdjn=0) is equal to checking whether the difference between the maximal value, (e.g., B(j,n)), in this block and the minimal value, (e.g., A(j,n)), in this block is 0.
Assuming the reshaping function (110) is constructed by a piecewise linear line, then for inputs viε[A(j,n) B(j,n)], a local quantizer can be expressed as:




  
    
      
        
          
            s
            i
          
          =
          
            round
            ⁡
            
              (
              
                
                  
                    k
                    ⁡
                    
                      (
                      
                        j
                        ,
                        n
                      
                      )
                    
                  
                  ⁢
                  
                    (
                    
                      
                        c
                        H
                      
                      -
                      
                        c
                        L
                      
                    
                    )
                  
                  ⁢
                  
                    (
                    
                      
                        
                          v
                          i
                        
                        -
                        
                          v
                          L
                        
                      
                      
                        
                          v
                          H
                        
                        -
                        
                          v
                          L
                        
                      
                    
                    )
                  
                
                +
                
                  c
                  L
                
              
              )
            
          
        
        ,
      
    
    
      
        (
        6
        )
      
    
  




where k(j,n) is a scaling factor to adjust the quantizer's slope at the n-th block in the j-th frame.

In step (410), let Φ denote a set of all blocks for which the block metric satisfies a certain criterion. For example, let Φ denote the set of all blocks that have non-zero standard deviation before quantization, or

Φ={(j,n)|B(j,n)−A(j,n)>0}.  (7)

In an embodiment, given a threshold Tth, where, without loss of generality, Tth≧1, given a block's min and max pixel values, in step (415), an optimal k(j,n) may be derived as




  
    
      
        
          k
          ⁡
          
            (
            
              j
              ,
              n
            
            )
          
        
        =
        
          
            T
            th
          
          ⁢
          
            
              
                
                  v
                  H
                
                -
                
                  v
                  L
                
              
              
                
                  (
                  
                    
                      c
                      H
                    
                    -
                    
                      c
                      L
                    
                  
                  )
                
                ⁢
                
                  (
                  
                    
                      B
                      ⁡
                      
                        (
                        
                          j
                          ,
                          n
                        
                        )
                      
                    
                    -
                    
                      A
                      ⁡
                      
                        (
                        
                          j
                          ,
                          n
                        
                        )
                      
                    
                  
                  )
                
              
            
            .
          
        
      
    
    
      
        (
        8
        )
      
    
  




Given the data {A(j,n), B(j,n), k(j,n)}, this triplet of values reveals that inside segment [A(j,n), B(j,n)], the quantizer should have a slope of at least k(j,n). Given that a particular EDR code (e.g., vc) may belong to multiple [A(j,n), B(j,n)] segments, for EDR code word vc, one needs to determine the maximal slope to satisfy all blocks for each code word.
Let θ(vc) denote the set of all segments across all blocks that cover the code word vc, or

θ(vc)={(j,n)|A(j,n)≦vc≦B(j,n),(j,n)εΦ}.  (9)

Then, in step (420), the required slope at code word vc may be determined as the envelope of all optimal slopes within those blocks that belong to the θ(vc) set, or





  
    
      
        
          k
          ⁡
          
            (
            
              v
              c
            
            )
          
        
        =
        
          
            max
            
              
                (
                
                  j
                  ,
                  n
                
                )
              
              ∈
              
                θ
                ⁡
                
                  (
                  
                    v
                    c
                  
                  )
                
              
            
          
          ⁢
          
            
              k
              ⁡
              
                (
                
                  j
                  ,
                  n
                
                )
              
            
            .
          
        
      
    
    
      
        (
        10
        )
      
    
  




In step (425), let the sum of all such envelope slopes be denoted as




  
    
      
        
          k
          =
          
            
              ∑
              
                v
                c
              
            
            ⁢
            
              
            
            ⁢
            
              k
              ⁡
              
                (
                
                  v
                  c
                
                )
              
            
          
        
        ,
      
    
    
      
        (
        11
        )
      
    
  




then, for each vc code word, without loss of generality, in step (430), a cumulative slope function may be defined as





  
    
      
        
          K
          ⁡
          
            (
            
              v
              c
            
            )
          
        
        =
        
          
            ∑
            
              i
              =
              0
            
            
              v
              c
            
          
          ⁢
          
            
          
          ⁢
          
            
              k
              ⁡
              
                (
                i
                )
              
            
            .
          
        
      
    
    
      
        (
        12
        )
      
    
  




To guarantee that all code words are mapped within the [cL, cH] bounds, the mapping from vc code words to si values may be computed using





  
    
      
        
          
            K
            _
          
          ⁡
          
            (
            
              v
              c
            
            )
          
        
        =
        
          
            round
            ⁡
            
              (
              
                
                  
                    
                      c
                      H
                    
                    -
                    
                      c
                      L
                    
                  
                  k
                
                ⁢
                
                  K
                  ⁡
                  
                    (
                    
                      v
                      c
                    
                    )
                  
                
              
              )
            
          
          .
        
      
    
    
      
        (
        13
        )
      
    
  




Given equation (13), a mapping between input vc values and output si values may be computed using a forward-mapping look-up table (e.g., LUTF(vc)=K(vc). In an embodiment, this table may be stored with the data or transmitted to a decoder as part of the image metadata (119) so that the decoder may reconstruct the inverse-mapping process.

In an example embodiment, Table 2 summarizes the mapping process depicted in FIG. 4 using pseudo code.







TABLE 2







// STEP 1: find max and min value


for( j = 0; j < F ; j++ ){


  for( n = 0; n < N; n++)


   // STEP 1.a : find the maximal value for each block n in EDR 


   domain


   Calculate B(j, n)


   // STEP 1.b : find the minimal value for each block n in EDR 


   domain


   Calculate A(j, n)


 end


end


// STEP 2 : find block with (B(j, n) − A(j, n))> 0; i.e. non-zero std block 


index


Construct Φ = {(j, n) | B(j, n) − A(j, n) > 0}


for each block in Φ


   // STEP 2.a: calculate optimal slope


 


   



  
    k
    ⁡
    
      (
      
        j
        ,
        n
      
      )
    
  
  =
  
    
      T
      th
    
    ⁢
    
      
        
          v
          H
        
        -
        
          v
          L
        
      
      
        
          (
          
            
              c
              H
            
            -
            
              c
              L
            
          
          )
        
        ⁢
        
          (
          
            
              B
              ⁡
              
                (
                
                  j
                  ,
                  n
                
                )
              
            
            -
            
              A
              ⁡
              
                (
                
                  j
                  ,
                  n
                
                )
              
            
          
          )
        
      
    
  






 


end


// STEP 3: find optimal slope


for each valid EDR code word vc


 


 



   
  
    
      
        
          
            θ
            ⁡
            
              (
              
                v
                c
              
              )
            
          
          =
          
            {
            
              
                
                  (
                  
                    j
                    ,
                    n
                  
                  )
                
                |
                
                  
                    A
                    ⁡
                    
                      (
                      
                        j
                        ,
                        n
                      
                      )
                    
                  
                  ≤
                  
                    v
                    c
                  
                  ≤
                  
                    B
                    ⁡
                    
                      (
                      
                        j
                        ,
                        n
                      
                      )
                    
                  
                
              
              ,
              
                
                  (
                  
                    j
                    ,
                    n
                  
                  )
                
                ∈
                Φ
              
            
            }
          
        
      
    
    
      
        
           
          
            
              k
              ⁡
              
                (
                
                  v
                  c
                
                )
              
            
            =
            
              
                max
                
                  
                    (
                    
                      j
                      ,
                      n
                    
                    )
                  
                  ∈
                  
                    θ
                    ⁡
                    
                      (
                      
                        v
                        c
                      
                      )
                    
                  
                
              
              ⁢
              
                k
                ⁡
                
                  (
                  
                    j
                    ,
                    n
                  
                  )
                
              
            
          
        
      
    
  






 


end


 






  k
  =
  
    
      ∑
      
        v
        c
      
    
    ⁢
    
      
    
    ⁢
    
      k
      ⁡
      
        (
        
          v
          c
        
        )
      
    
  






 


// STEP 4: find optimal EDR LUT by accumulating the slope and taking


normalization


 






  
    
      K
      ⁡
      
        (
        
          v
          c
        
        )
      
    
    =
    
      
        ∑
        
          i
          =
          0
        
        
          v
          c
        
      
      ⁢
      
        
      
      ⁢
      
        
          k
          ⁡
          
            (
            i
            )
          
        
        ⁢
        
          
            
          
          ⁢
          
            
          
        
        ⁢
        for
        ⁢
        
          
        
        ⁢
        all
        ⁢
        
          
            
          
          ⁢
          
            
          
        
        ⁢
        
          v
          c
        
      
    
  
  ,
  then






 






  
    
      K
      _
    
    ⁡
    
      (
      
        v
        c
      
      )
    
  
  =
  
    round
    ⁢
    
      
    
    ⁢
    
      
        (
        
          
            
              
                c
                H
              
              -
              
                c
                L
              
            
            k
          
          ⁢
          
            K
            ⁡
            
              (
              
                v
                c
              
              )
            
          
        
        )
      
      .
    
  













In some embodiments, in equation (12), alternative functions may be used to compute the cumulative slope function K(vc). For example, the k(vc) values may be filtered or weighted before being summed up, as in




  
    
      
        
          
            k
            ⁢
            
              (
              
                v
                c
              
              )
            
          
          =
          
            
              ∑
              
                i
                =
                
                  -
                  u
                
              
              u
            
            ⁢
            
              
            
            ⁢
            
              
                w
                i
              
              ⁢
              
                k
                ⁡
                
                  (
                  
                    
                      v
                      c
                    
                    +
                    i
                  
                  )
                
              
            
          
        
        ,
      
    
    
      
        (
        14
        )
      
    
  




where wi denote predetermined weights or filter coefficient of a filter with (2u+1) filter taps (e.g., u=2 and the filter coefficients correspond to those of a low-pass filter).

FIG. 5 depicts an example plot of vc code words versus envelope slope k(vc) values for a test sequence of frames given the [cL, cH] range of [0, 255].
Given the data depicted in FIG. 5, FIG. 6 depicts an example of the vc versus K(vc) mapping.
Inverse Reshaping
In a decoder, given the K(vc) values of equation (13), an inverse quantizer or reshaping function (140) may be determined as follows:
for each decoded code word ŝc, let

ω(sc)={i|K(vi)=sc},  (15)

then





  
    
      
        
          
            
              K
              _
            
            
              -
              1
            
          
          ⁡
          
            (
            
              
                s
                ^
              
              c
            
            )
          
        
        =
        
          
            
              ∑
              
                i
                ∈
                
                  ω
                  ⁡
                  
                    (
                    
                      
                        s
                        ^
                      
                      c
                    
                    )
                  
                
              
            
            ⁢
            
              
            
            ⁢
            
              v
              i
            
          
          
            
            
              ω
              ⁡
              
                (
                
                  
                    s
                    ^
                  
                  c
                
                )
              
            
            
          
        
      
    
    
      
        (
        16
        )
      
    
  




In other words, for a given code word in the quantized domain, sc, the corresponding estimated EDR code word {circumflex over (v)}c is constructed by: first grouping all pixels having quantized value ŝc, finding the corresponding EDR code words, and then taking the average for all collected EDR code words. From equation (16), a backward look-up table LUTB(ŝc)=K−1(ŝc) may be constructed and either stored with the data or transmitted to the decoder, e.g., as part of metadata (119).
Given the data depicted in FIG. 6, FIG. 7 depicts an example of ŝc versus K−1(ŝc) mapping or inverse reshaping (140).
In an embodiment, the mapping defined by the K−1(ŝc) relationship may be transmitter to the decoder using metadata (119, 127). Such an approach may be too expensive in terms of bit rate overhead. For example, for 8-bit data, a look-up table may comprise 255 entries, to be transmitted each time there is a scene change. In other embodiments, the inverse mapping may be translated into a piecewise polynomial approximation. Such polynomials may typically comprise first and second-order polynomials, although, higher-order polynomials or B-splines could be used as well. The number of polynomials approximating a LUT for a certain layer l (l=0, 1, . . . , L−1) may vary according to available bandwidth and processing complexity. In an embodiment, the base layer uses up to 8 segments while the enhancement layer uses a single segment.
Table 3 depicts an example algorithm to approximate the decoder LUT table using second-order polynomials according to an embodiment.







TABLE 3





LUT approximation using 2d-order polynomials















// Input :








//
LUTB : Inverse reshaping lookup table









//
ε
 : maximal error tolerance between LUT values and approximated values


//
Nl
: number of code words in layer l


//
pl
 : partition code word separating layer l−1 and l







// Output:








//
mx(t) : pivot points for input


//
my(t):  corresponding output value


//
 a(i,j) : Polynomial coefficients








T = 0;
 // counter to count number of pivot points


Len_LUT = Nl;
// number of entries in the lth layer







LUT[ x ] = LUTB[ x + pl ] ; // segment of backward reshaper used in lth layer








mx(0) = 0;
 // first pivot point ; input value


my(0) = LUTB[pl];
  // first pivot point ; output value


converge = 0;
 // flag to check convergence







while( ! converge ){


  found_one_seg = 0;


  cnt = 1;


  // find one segment which won't exceed the maximal tolerance error


  while( ~found_one_seg ){


     // STEP 1 : move pivot candidate to next feasible point


     m = mx(T ) + cnt;


    // STEP 2: approximate value from LUT[mx(T )] to LUT[m]


    // by a 2nd order polynomial


     f( T, i ) = a( T, 2 )* i2 + a( T, 1 ) * i + a( T, 0)


     where a( T, 2 ), a( T, 1 ), and a( T, 0) are the fitted polynomial coefficients


     // Compute the maximum approximation error


     for( i = mx(T ) ; i <= m ; i ++){


       εi = f (T ,i) − LUT(i)


     }


     εmax = max{εi,i = mx(T),...,m}


     // STEP 3.(a) if max error exceeds tolerance, take the previous one


     if( ( εmax > ε )&&( T < Len_LUT ) ){


       found_one_seg = 1;


       T++;


       mx(T) = m − 1 ;


        my(T ) = LUT(mx(T ) );


    }


    // STEP 3.(b) reach the last entry


     else if( (εmax <= ε ) &&( m == Len_LUT ) ){


       found_one_seg = 1;


       T++;


       mx(T) = m;


       my(T ) = LUT(mx(T ) );


        converge = 1


    }


     // STEP 4: increase the counter


    cnt ++;


  }


}









As depicted in Table 3, in an embodiment, inputs to the approximation process include: the original look-up table (computed, say, using equation (16)), an acceptable error tolerance between the values in the LUT and those generated by the polynomial approximation, the number of available code words, and its first code word value (see equation (1)). The output may include the end-points of each polynomials (also referred to as pivot points), and the polynomial coefficients.
Starting from the first pivot point, the algorithm attempts to fit the maximum possible range of available code words using, without loss of generality, a second degree polynomial. Any known polynomial-fit algorithms may be used, such as mean-square error polynomial fit, and the like.
When the computed maximum error exceeds the input tolerance, then the parameters of the optimal polynomial are stored, and a search for new polynomial starts, until the whole LUT table is mapped.
In some embodiments, the number of polynomials that may be used to approximate a LUT may be constrained to a fixed value, say eight. In that case, a higher tolerance for error may be incorporated in to the algorithm.
The method of Table 3 may also be easily modified to accommodate other approximation functions, such as higher-order polynomials, B-splines, or a combination of approximation functions.
Coding in Perceptually Uniform Color Spaces
Video signals are typically rendered in the familiar RGB color space; however, most video compression standards, such as MPEG-2, H.264 (AVC), H.265 (HEVC), and the like, have been optimized to operate in an opponent color space, such as YCbCr or YUV. These color spaces are adequate for coding and transmitting 8-10 bit standard-dynamic range (SDR) video, however, from a bits per pixel requirements point of view, they may not be the most efficient when coding and transmitting EDR video. For example, in the past, the Lu′v′ and Log(L)u′v′ color spaces have also been suggested.
As appreciated by the inventors, encoding of signals in perceptually uniform spaces may benefit by additional processing of the u′ and v′ chromaticity data before being processed by a video codec. For example, in an embodiment, in an encoder, such processing may be performed on input signal (102) as part of the signal reshaping process (110).
White Point Translation
In an embodiment, the conversion from linear XYZ to a Luma u′v′ color space may comprise the following steps:

    
    
        a) Define the coordinates of the White Point (e.g., D65)
        b) Solve for Luma=ƒ(Y), and
        c) Solve for u′ and v′ from X, Y, and Z
    
    


As used herein, the function ƒ(Y) denotes any lightness-related function, such as L (or L′), log(L), and the like. In a preferred embodiment, ƒ(Y) may represent the perceptual quantization (PQ) mapping function as described in the '212 Application.
In an embodiment, the white point may be defined as D65 (6500K) with u′ and v′ coordinates:

    Du=d65u=0.1978300066428;
    Dv=d65v=0.4683199949388;


In an embodiment, u′ and v′ may be derived as




  
    
      
        
          
            u
            ′
          
          =
          
            
              4
              ⁢
              
                
              
              ⁢
              X
            
            
              X
              +
              
                15
                ⁢
                
                  
                
                ⁢
                Y
              
              +
              
                3
                ⁢
                
                  
                
                ⁢
                Z
              
            
          
        
        ,
      
    
    
      
        (
        
          17
          ⁢
          a
        
        )
      
    
  
  
    
      
        
          
            v
            ′
          
          =
          
            
              9
              ⁢
              
                
              
              ⁢
              Y
            
            
              X
              +
              
                15
                ⁢
                
                  
                
                ⁢
                Y
              
              +
              
                3
                ⁢
                
                  
                
                ⁢
                Z
              
            
          
        
        ,
        
          

        
        ⁢
        
          
            if
            ⁡
            
              (
              
                X
                +
                
                  15
                  ⁢
                  
                    
                  
                  ⁢
                  Y
                
                +
                
                  3
                  ⁢
                  
                    
                  
                  ⁢
                  Z
                
              
              )
            
          
          ≠
          0
        
        ,
        and
      
    
    
      
        (
        
          17
          ⁢
          b
        
        )
      
    
  
  
    
      
        
          u
          ′
        
        =
        Du
      
    
    
      
        (
        
          17
          ⁢
          c
        
        )
      
    
  
  
    
      
        
          
            v
            ′
          
          =
          Dv
        
        ⁢
        
          

        
        ⁢
        
          
            if
            ⁢
            
              (
              
                X
                +
                
                  15
                  ⁢
                  
                    
                  
                  ⁢
                  Y
                
                +
                
                  3
                  ⁢
                  
                    
                  
                  ⁢
                  Z
                
              
              )
            
          
          =
          0.
        
      
    
    
      
        (
        
          17
          ⁢
          d
        
        )
      
    
  




The inverse operation comprises:

    
    
        a) Define the coordinates of the White Point (e.g., D65)
        b) Solve for Y=ƒ−1 (Luma)
        c) Solve for X and Z from u′ and v′
    
    


For example, in an embodiment that uses a perceptual quantization function according to the '212 Application, one may apply the corresponding inverse PQ mapping to generate the Y pixel values.
In an embodiment, X and Z may be derived as:




  
    
      
        
          X
          =
          
            Y
            ⁢
            
              
                9
                ⁢
                
                  
                
                ⁢
                
                  u
                  ′
                
              
              
                4
                ⁢
                
                  
                
                ⁢
                
                  v
                  ′
                
              
            
          
        
        ,
      
    
    
      
        (
        
          18
          ⁢
          a
        
        )
      
    
  
  
    
      
        
          Z
          =
          
            Y
            ⁢
            
              
                12
                -
                
                  3
                  ⁢
                  
                    
                  
                  ⁢
                  
                    u
                    ′
                  
                
                -
                
                  20
                  ⁢
                  
                    
                  
                  ⁢
                  
                    v
                    ′
                  
                
              
              
                4
                ⁢
                
                  
                
                ⁢
                
                  v
                  ′
                
              
            
          
        
        ,
        
          

        
        ⁢
        
          
            if
            ⁢
            
              
            
            ⁢
            
              v
              ′
            
          
          ≠
          0
        
        ,
        and
      
    
    
      
        (
        
          18
          ⁢
          b
        
        )
      
    
  
  
    
      
        
          X
          =
          
            Z
            =
            Y
          
        
        ,
        
          
            if
            ⁢
            
              
            
            ⁢
            
              v
              ′
            
          
          =
          0.
        
      
    
    
      
        (
        
          18
          ⁢
          c
        
        )
      
    
  




FIG. 8A depicts a traditional mapping of a white point (805) (e.g., D65) in the u′v′ chromaticity space. As depicted in FIG. 8A, the range of the u′ and v′ chromaticity values is approximately (0, 0.623) for u′ and (0, 0.587) for v′. As depicted in FIG. 8A, the D65 white point is not centered in the u′v′ signal representation. This may result in color shifts after sub-sampling and up-sampling the chroma components to translate between the original 4:4:4 color format and the 4:2:0 or 4:2:2 color formats typically being used in video coding. To alleviate such color shifts, it is suggested to apply a transform function to the chromaticity values. In one embodiment, the transform function shifts the white point approximately to the center of the translated u′v′; however, the white point may be translated to any other color value where one may want to see chroma errors to gravitate. For example, if translated values u′t and v′t are in the range (0, 1), then the following mapping may be applied:

u′t=(u′−Du)a1+b1,  (19a)

v′t=(v′−Dv)a2+b2,  (19b)

where Du and Dv denote the original u′ and v′ coordinates of the selected white point, (b1, b2) determine the coordinates of the desired position of the white point in the translated color space, and ai (i=1, 2) are constants computed based on the desired translation point and the minimum and maximum values of u′ and v′. In one embodiment, the translation parameters (e.g., a1 and a2) may be fixed for the whole video sequence. In another embodiment, the translation parameters may be computed on a per scene or per frame basis to take advantage of changes in the chromaticity range of the incoming content.

FIG. 8B depicts a mapping of the white point (805) in the translated chromaticity space according to an example embodiment. In FIG. 8B, the original u′ and v′ chromaticity values are translated so that the selected point (e.g., D65) is approximately at the center (0.5, 0.5) of the translated chromaticity space. For example, if translated values u′t and v′t are in (0, 1), then for b1=b2=0.5, in one embodiment, the following mapping may be applied:

u′t=(u′−Du)1.175+0.5,  (20a)

v′t=(v′−Dv)1.105+0.5,  (20b)

where Du and Dv denote the u′ and v′ coordinates of the selected white point. This translation will result in chroma errors appearing as a desaturation rather than as a hue shift. A person of ordinary skill in the art will appreciate that a non-linear function may also be applied to the u′ and v′ chromaticity values to achieve the same translation. Such a non-linear function may allocate higher precision to near-neutrals to further decrease the visibility of color errors due to coding and quantization.

Reducing Chroma Entropy

The visibility of chroma detail may be further improved if the u′ and v′ pixel components are multiplied by a function of the luminosity. For example, in an embodiment, the translated chromaticity values may be derived as:

u′t=g(Luma)(u′−Du)a1+b1,  (21a)

v′t=g(Luma)(v′−Dv)a2+b2,  (21b)

where g(Luma) denotes a function of the luma channel. In an embodiment, g(Luma)=Luma.

In a decoder, the incoming signal may be denoted as Luma u′tv′t. In many applications, this signal must be converted back to XYZ, RGB, or some other color space before further processing. In an example embodiment, the color conversion process from Luma u′tv′t to XYZ may comprise the following steps:

    
    
        a) Undo the Luma encoding

Y=ƒ−1(Luma)

        b) Undo the range scaling on the u′t and v′t values to recover u′ and v′
        c) Use equation (18) to restore X and Z
    
    


In some embodiments, the Luma, u′t and v′t components of the incoming signal may be normalized into the (0, 1) range before any color transformations. In some embodiments, equations (17)-(21) may be implemented using a combination of look-up tables, multiplications, and additions. For example, in an embodiment, let

Y=ƒ−1(Luma),

    B=3u′,
    C=20v′, and
    D=1/(4v′)

denote the outputs of three look-up tables with Luma, u′, and v′ as their inputs, then, from equation (18), the X, and Z values may be computed using four multiplications and two additions as:

Z=(Y*D)*(12−B−C),

and

X=(Y*D)*(3*B).



For example, in an embodiment, for a 10-bit encoded signal, each LUT may have 1024 entries, each at a high-enough precision (e.g., 32 bits) for the target application.
FIG. 9 depicts an example of a coding and decoding pipeline according to an embodiment of the present invention. Input signal (902) may be in RGB 4:4:4 or any other suitable color format. In step (910), signal (902) is translated to a perceptual Luma u′v′ format, for example, using a perceptual quantization (PQ) mapping for the luminance value and equations (17) for the chromaticity values. In step (915), a transform, for example as depicted in equations (19)-(21) is applied to translate the original u′v′ chromaticity values to translated chromaticity values u′t and v′t so that the white point is placed approximately at the center of the translated chromaticity space. The color-transformed and translated Luma u′tv′t 4:4:4 signal (e.g., 917) may be color sub-sampled (not shown) to a 4:2:0 or 4:2:2 format before being coded by a video encoder (920). Video encoder (920) may comprise signal reshaping (110) and layer decomposition (115) processes as described earlier. On the receiver, video decoder (930) generates a decoded signal (932). Video decoder (930) may comprise signal inverse reshaping and layer composer (140). After optional color up-sampling (e.g., from 4:2:0 to 4:4:4), a reverse chromaticity translation step (935) may translate the Luma u′tv′t signal (932) back to a Luma u′v′ signal (937), by reversing the translation operations in (915). Finally, Luma u′v′ signal (937) may be translated to an output signal (942) in the RGB or other appropriate color space for display or further processing.
Coding in Perceptually Quantized IPT Color Space
White point translation may be applied to other color spaces as well, such as the IPT color space or the IPT-PQ color space, a perceptually quantized color space that appears to be ideally suited for the coding of video signals with enhanced or high dynamic range. The IPT-PQ color space was first described in PCT Application PCT/US2014/016304, filed on Feb. 13, 2014, titled “Display management for high dynamic range video,” by R. Atkins et al., which is incorporated herein by reference in its entirety.
The IPT color space, as described in “Development and testing of a color space (ipt) with improved hue uniformity”, by F. Ebner and M. D. Fairchild, in Proc. 6th Color Imaging Conference: Color Science, Systems, and Applications, IS&T, Scottsdale, Ariz., November 1998, pp. 8-13 (to be referred as the Ebner paper), which is incorporated herein by reference in its entirety, is a model of the color difference between cones in the human visual system. In this sense it is like the YCbCr or CIE-Lab color spaces; however, it has been shown in some scientific studies to better mimic human visual processing than these spaces. Like CIE-Lab, IPT is a normalized space to some reference luminance. In an embodiment, the normalization may be based on the maximum luminance of the target display.
The term “PQ” as used herein refers to perceptual quantization. The human visual system responds to increasing light levels in a very non-linear way. A human's ability to see a stimulus is affected by the luminance of that stimulus, the size of the stimulus, the spatial frequency(ies) making up the stimulus, and the luminance level that the eyes have adapted to at the particular moment one is viewing the stimulus. In a preferred embodiment, a perceptual quantizer function maps linear input gray levels to output gray levels that better match the contrast sensitivity thresholds in the human visual system. Examples of PQ mapping functions are described in the '212 application, where given a fixed stimulus size, for every luminance level (i.e., the stimulus level), a minimum visible contrast step at that luminance level is selected according to the most sensitive adaptation level and the most sensitive spatial frequency (according to HVS models). Compared to the traditional gamma curve, which represents the response curve of a physical cathode ray tube (CRT) device and coincidently may have a very rough similarity to the way the human visual system responds, a PQ curve, as determined by the '212 application, imitates the true visual response of the human visual system using a relatively simple functional model.
Table 1 describes the calculation of the Perceptual Curve EOTF for converting digital video code values into absolute linear luminance levels at a point of display. Also included is the inverse OETF calculation for converting absolute linear luminance into digital code values







TABLE 1







Exemplary Equation Definitions:


D = Perceptual Curve digital code value, SDI-legal unsigned integer,


10 or 12 bits


b = number of bits per component in digital signal representation,


10 or 12


V = normalized Perceptual Curve signal value, 0 ≦ V ≦ 1


Y = normalized luminance value, 0 ≦ Y ≦ 1


L = absolute luminance value, 0 ≦ L ≦ 10,000 cd/m2


Exemplary EOTF Decode Equations:


 






  V
  =
  
    
      D
      -
      
        4
        ·
        
          2
          
            b
            -
            10
          
        
      
    
    
      1015
      ·
      
        2
        
          b
          -
          10
        
      
    
  






 












  Y
  =
  
    
      (
      
        
          max
          ⁡
          
            [
            
              
                (
                
                  
                    v
                    
                      1
                      /
                      m
                    
                  
                  -
                  
                    c
                    1
                  
                
                )
              
              ,
              0
            
            ]
          
        
        
          
            c
            2
          
          -
          
            
              c
              3
            
            ⁢
            
              v
              
                1
                /
                m
              
            
          
        
      
      )
    
    
      1
      /
      n
    
  




(t1)


 


L=10,000 · Y



Exemplary OETF Encode Equations:



 






  Y
  =
  
    L
    
      10
      ⁢
      
        ,
      
      ⁢
      000
    
  







 






  V
  =
  
    
      (
      
        
          
            c
            1
          
          +
          
            
              c
              2
            
            ⁢
            
              Y
              n
            
          
        
        
          1
          +
          
            
              c
              3
            
            ⁢
            
              Y
              n
            
          
        
      
      )
    
    m
  




(t2)


 


D = INT (1015 · V · 2b−10) + 4 · 2b−10
(t3)


Exemplary Constants:



 


 



  n
  =
  
    
      
        2610
        4096
      
      ×
      
        1
        4
      
    
    ≈
    0.15930176
  







 


 



  m
  =
  
    
      
        2523
        4096
      
      ×
      128
    
    =
    78.84375
  







 


 



  
    c
    1
  
  =
  
    
      
        c
        3
      
      -
      
        c
        2
      
      +
      1
    
    =
    
      
        3424
        4096
      
      =
      0.8359375
    
  







 


 



  
    c
    2
  
  =
  
    
      
        2413
        4096
      
      ×
      32
    
    =
    18.8515625
  







 


 



  
    c
    3
  
  =
  
    
      
        2392
        4096
      
      ×
      32
    
    =
    18.6875
  









Notes:


1. The operator INT returns the value of 0 for fractional parts in the range of 0 to 0.4999 . . . and +1 for fractional parts in the range of 0.5 to 0.9999 . . . , i.e. it rounds up fractions above 0.5.


2. All constants are defined as exact multiples of 12 bit rationals to avoid rounding concerns.


3. R, G, or B signal components are to be computed in the same way as the Y signal component described above.






Converting a signal to the IPT-PQ color space may include the following steps:

    
    
        a) Convert the signal from the input color space (e.g., RGB or YCbCr) to XYZ
        b) Convert the signal from XYZ to IPT-PQ as follows:
        
            a. Apply a 3×3 XYZ to LMS matrix to convert the signal from XYZ to LMS
            b. Convert each color component of the LMS signal to a perceptually-quantized LMS signal (L′M′S′ or LMS-PQ) (e.g., by applying equation (t2))
            c. Apply a 3×3 LMS to IPT matrix to convert the LMS-PQ signal to the IPT-PQ color space
        
        
    
    


Examples of the 3×3 XYZ to LMS and L′M′S′ (or LMS-PQ) to IPT conversion matrices may be found in the Ebner paper. Assuming the chroma components of the IPT-PQ signal (e.g., P′ and T′) are in the range (−0.5, 0.5), a bias a (e.g., a=0.5) may be added so that the range of the chroma components is substantially within the range (0, 1), e.g.:

P′=P′+a  (22a)

T′=T′+a  (22b)

The inverse color operation may include the following steps:

    
    
        a) Subtract any bias values that were added to the chroma components
        b) Apply a 3×3 I′P′T′ to LMS conversion matrix to convert from IPT-PQ to LMS-PQ
        c) Apply an inverse PQ function to convert from LMS-PQ to LMS (e.g., using equation (t1))
        d) Apply a 3×3 LMS to XYZ transform to convert from LMS to XYZ, and
        e) Convert from XYZ to the device-dependent color space of choice (e.g., RGB or YCbCr).

In practice, color transformation steps during encoding and/or decoding may be performed using pre-computed 1-D Look-up tables (LUTs).

Reducing Chroma Entropy

    
    


As described earlier, the visibility of chroma detail may be further improved if the P′ and T′ pixel components are multiplied by a function of the luminosity (e.g., I′). For example, in an embodiment, the translated chromaticity values may be derived as:

P′t=g(I′)(P′−a)+a,  (23a)

T′t=g(I′)(T′−a)+a,  (23b)

where g(I′) denotes a linear or non-linear function of the luma channel (I′). In an embodiment, g(I′)=I′.

Example Computer System Implementation
Embodiments of the present invention may be implemented with a computer system, systems configured in electronic circuitry and components, an integrated circuit (IC) device such as a microcontroller, a field programmable gate array (FPGA), or another configurable or programmable logic device (PLD), a discrete time or digital signal processor (DSP), an application specific IC (ASIC), and/or apparatus that includes one or more of such systems, devices or components. The computer and/or IC may perform, control, or execute instructions relating to adaptive reshaping techniques for the layered coding of video images with enhanced dynamic range (EDR), such as those described herein. The computer and/or IC may compute any of a variety of parameters or values that relate to the adaptive reshaping processes described herein. The image and video embodiments may be implemented in hardware, software, firmware and various combinations thereof.
Certain implementations of the invention comprise computer processors which execute software instructions which cause the processors to perform a method of the invention. For example, one or more processors in a display, an encoder, a set top box, a transcoder or the like may implement methods related to adaptive reshaping techniques for the layered coding of video images with enhanced dynamic range (EDR), as described above by executing software instructions in a program memory accessible to the processors. The invention may also be provided in the form of a program product. The program product may comprise any medium which carries a set of computer-readable signals comprising instructions which, when executed by a data processor, cause the data processor to execute a method of the invention. Program products according to the invention may be in any of a wide variety of forms. The program product may comprise, for example, physical media such as magnetic data storage media including floppy diskettes, hard disk drives, optical data storage media including CD ROMs, DVDs, electronic data storage media including ROMs, flash RAM, or the like. The computer-readable signals on the program product may optionally be compressed or encrypted.
Where a component (e.g. a software module, processor, assembly, device, circuit, etc.) is referred to above, unless otherwise indicated, reference to that component (including a reference to a “means”) should be interpreted as including as equivalents of that component any component which performs the function of the described component (e.g., that is functionally equivalent), including components which are not structurally equivalent to the disclosed structure which performs the function in the illustrated example embodiments of the invention.
EQUIVALENTS, EXTENSIONS, ALTERNATIVES AND MISCELLANEOUS
Example embodiments that relate to the adaptive reshaping techniques for the layered coding of video images with enhanced dynamic range (EDR), are thus described. In the foregoing specification, embodiments of the present invention have been described with reference to numerous specific details that may vary from implementation to implementation. Thus, the sole and exclusive indicator of what is the invention, and is intended by the applicants to be the invention, is the set of claims that issue from this application, in the specific form in which such claims issue, including any subsequent correction. Any definitions expressly set forth herein for terms contained in such claims shall govern the meaning of such terms as used in the claims. Hence, no limitation, element, property, feature, advantage or attribute that is not expressly recited in a claim should limit the scope of such claim in any way. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense.

## Claims

1. A method for coding a sequence of input enhanced dynamic range (EDR) images comprising image blocks, the method comprising:
receiving said sequence of input enhanced dynamic range (EDR) images;
computing block-complexity metrics for one or more of the image blocks in at least one input image in the sequence of input EDR images, said block-complexity metrics being representative for a variation in pixel values;
constructing a first set of the image blocks, the first set comprising image blocks for which their computed block-complexity metric satisfies a predetermined criterion;
for each block in the first set of the image blocks determining an optimal slope (k(j,n)) according to a slope generation function for a linear quantization model, said optimal slope representing a minimal slope of the linear quantization model for said block;
for each input code word (vc) of the sequence of input EDR images:
constructing a second set of image blocks, the second set comprising blocks that belong to the first set of the image blocks and wherein the input code word is within minimum and maximum pixel values of the image block; and
generating an envelope slope (k(vc)) for the input code word, said envelope slope being computed using the maximum optimal slope among the optimal slopes of the blocks in the second set of image blocks;

computing a sum (k) of all the envelope slopes for all code words; and
for each input code word:
generating a cumulative slope (K(vc)), the cumulative slope comprising a sum of the envelope slopes up to and including said input code word; and
generating a mapping function between the input code word and an output code word, the mapping function computed from the cumulative slope of the code word and the sum of all the envelope slopes for all code words.

2. The method of claim 1, further comprising:
applying the mapping function to the input EDR images to generate reshaped images;
decomposing the reshaped images into one or more layers; and
encoding the one or more layers using one or more video encoders.

3. The method of claim 2, wherein, given a reshaped pixel s, and L layers, the decomposing step comprises mapping the s pixel into sl pixel values


sl=Clip3(s,pl,pl+1−1)−pl,

wherein l=0, 1, . . . , L−1, denotes one of the L layers, Clip3( ) is a clipping function that clips the reshaped pixel s between the values of pl and pl+1−1, and pl denotes the smallest pixel value of the reshaped sequence at level l.

4. The method of claim 3, wherein p0=0 and




  
    
      p
      i
    
    =
    
      
        
          ∑
          
            j
            =
            0
          
          
            i
            -
            1
          
        
        ⁢
        
          
        
        ⁢
        
          
            N
            j
          
          ⁢
          
            
          
          ⁢
          for
          ⁢
          
            
          
          ⁢
          i
        
      
      =
      1
    
  
  ,
  ...
  ⁢
  
    
  
  ,
  L
  ,



where Nj denotes the number of code words available for a video encoder at level j.

5. The method of claim 1, wherein the linear quantization model comprises a function denoted by




  
    
      s
      i
    
    =
    
      round
      ⁡
      
        (
        
          
            
              k
              ⁡
              
                (
                
                  j
                  ,
                  n
                
                )
              
            
            ⁢
            
              (
              
                
                  c
                  H
                
                -
                
                  c
                  L
                
              
              )
            
            ⁢
            
              (
              
                
                  
                    v
                    i
                  
                  -
                  
                    v
                    L
                  
                
                
                  
                    v
                    H
                  
                  -
                  
                    v
                    L
                  
                
              
              )
            
          
          +
          
            c
            L
          
        
        )
      
    
  
  ,



where vL and vH denote a minimum and a maximum code word value in the EDR input sequence, cL and cH denote a minimum and a maximum output code value, k(j,n) denotes a quantization slope for the n-th block in the j-th frame in the EDR input sequence, vi denotes an input code word and si denotes a corresponding output code word.

6. The method of claim 5, wherein the optimal slope k(j,n) is generated by computing




  
    
      k
      ⁡
      
        (
        
          j
          ,
          n
        
        )
      
    
    =
    
      
        T
        th
      
      ⁢
      
        
          
            v
            H
          
          -
          
            v
            L
          
        
        
          
            (
            
              
                c
                H
              
              -
              
                c
                L
              
            
            )
          
          ⁢
          
            (
            
              
                B
                ⁡
                
                  (
                  
                    j
                    ,
                    n
                  
                  )
                
              
              -
              
                A
                ⁡
                
                  (
                  
                    j
                    ,
                    n
                  
                  )
                
              
            
            )
          
        
      
    
  
  ,



where Tth is a predetermined threshold, B(j,n) denotes a maximum pixel value in block n in frame j, and A(j,n) denotes a minimum pixel value in block n in frame j.

7. The method of claim 1, wherein computing the block-complexity metric of an image block comprises computing the difference between the maximum and minimum pixel values in the image block, and wherein the first set of image blocks comprises all image blocks for which their block-complexity metric is larger than 0.

8. The method of claim 1, wherein generating the envelope slope k(vc) for the vc code word comprises computing




  
    
      k
      ⁡
      
        (
        
          v
          c
        
        )
      
    
    =
    
      
        max
        
          
            (
            
              j
              ,
              n
            
            )
          
          ∈
          
            θ
            ⁡
            
              (
              
                v
                c
              
              )
            
          
        
      
      ⁢
      
        k
        ⁡
        
          (
          
            j
            ,
            n
          
          )
        
      
    
  
  ,



where k(j,n) denotes the optimal slope for a block n in frame j of the input EDR sequence of images, and θ(vc) denotes the second set of image blocks.

9. The method of claim 1, wherein computing the cumulative slope K(vc) for code word vc comprises computing




  
    
      K
      ⁡
      
        (
        
          v
          c
        
        )
      
    
    =
    
      
        ∑
        
          i
          =
          0
        
        
          v
          c
        
      
      ⁢
      
        
      
      ⁢
      
        k
        ⁡
        
          (
          i
          )
        
      
    
  
  ,




where k(i) denotes the envelope slope for the i-th input EDR code word.

10. The method of claim 1, wherein generating the mapping function, K(vc), between the input code word and the output code word comprises computing




  
    
      
        K
        _
      
      ⁡
      
        (
        
          v
          c
        
        )
      
    
    =
    
      round
      ⁡
      
        (
        
          
            
              
                c
                H
              
              -
              
                c
                L
              
            
            k
          
          ⁢
          
            K
            ⁡
            
              (
              
                v
                c
              
              )
            
          
        
        )
      
    
  
  ,




where K(vc) denotes the cumulative slope for code word vc, k denotes the sum of all the envelope slopes for all code words, and cL and cH denote a minimum and a maximum output code value.

11. The method of claim 1, further comprising:
in a receiver comprising a processor, receiving a mapped code word generated using the mapping function;
for the received mapped code word, identifying all EDR code words that may be mapped to the received mapped code word using the mapping function; and
generating an inverse mapping by mapping the received mapped code word to an output EDR code word computed based on an average of all the identified EDR code words mapped to the received mapped code word.

12. The method of claim 1, wherein a first video encoder encodes a first layer using a first bit depth and a second video encoder encodes a second layer using a second bit depth, wherein the second bit depth is different than the first bit depth.

13. The method of claim 12, wherein the first bit depth is 8 bits and the second bit depth is 10 bits, 12 bits, or 14 bits.

14. The method of claim 13, wherein the first coding format is the MPEG-2 coding format and the second coding format is the AVC or HEVC coding format.

15. The method of claim 1, wherein a first video encoder encodes a first layer using a first coding format and a second video encoder encodes a second layer using a second coding format, wherein the second coding format is different than the first coding format.

16. An apparatus comprising a processor and configured to perform the method recited in claim 1.

17. A non-transitory computer-readable storage medium having stored thereon computer-executable instruction for executing a method in accordance with claim 1.