{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.MediaConvert.Types.DolbyVision
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaConvert.Types.DolbyVision where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaConvert.Types.DolbyVisionLevel6Metadata
import Amazonka.MediaConvert.Types.DolbyVisionLevel6Mode
import Amazonka.MediaConvert.Types.DolbyVisionMapping
import Amazonka.MediaConvert.Types.DolbyVisionProfile
import qualified Amazonka.Prelude as Prelude

-- | Create Dolby Vision Profile 5 or Profile 8.1 compatible video output.
--
-- /See:/ 'newDolbyVision' smart constructor.
data DolbyVision = DolbyVision'
  { -- | Use these settings when you set DolbyVisionLevel6Mode to SPECIFY to
    -- override the MaxCLL and MaxFALL values in your input with new values.
    DolbyVision -> Maybe DolbyVisionLevel6Metadata
l6Metadata :: Prelude.Maybe DolbyVisionLevel6Metadata,
    -- | Use Dolby Vision Mode to choose how the service will handle Dolby Vision
    -- MaxCLL and MaxFALL properies.
    DolbyVision -> Maybe DolbyVisionLevel6Mode
l6Mode :: Prelude.Maybe DolbyVisionLevel6Mode,
    -- | Required when you set Dolby Vision Profile to Profile 8.1. When you set
    -- Content mapping to None, content mapping is not applied to the
    -- HDR10-compatible signal. Depending on the source peak nit level,
    -- clipping might occur on HDR devices without Dolby Vision. When you set
    -- Content mapping to HDR10 1000, the transcoder creates a 1,000 nits peak
    -- HDR10-compatible signal by applying static content mapping to the
    -- source. This mode is speed-optimized for PQ10 sources with metadata that
    -- is created from analysis. For graded Dolby Vision content, be aware that
    -- creative intent might not be guaranteed with extreme 1,000 nits trims.
    DolbyVision -> Maybe DolbyVisionMapping
mapping :: Prelude.Maybe DolbyVisionMapping,
    -- | Required when you enable Dolby Vision. Use Profile 5 to include
    -- frame-interleaved Dolby Vision metadata in your output. Your input must
    -- include Dolby Vision metadata or an HDR10 YUV color space. Use Profile
    -- 8.1 to include frame-interleaved Dolby Vision metadata and HDR10
    -- metadata in your output. Your input must include Dolby Vision metadata.
    DolbyVision -> Maybe DolbyVisionProfile
profile :: Prelude.Maybe DolbyVisionProfile
  }
  deriving (DolbyVision -> DolbyVision -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DolbyVision -> DolbyVision -> Bool
$c/= :: DolbyVision -> DolbyVision -> Bool
== :: DolbyVision -> DolbyVision -> Bool
$c== :: DolbyVision -> DolbyVision -> Bool
Prelude.Eq, ReadPrec [DolbyVision]
ReadPrec DolbyVision
Int -> ReadS DolbyVision
ReadS [DolbyVision]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DolbyVision]
$creadListPrec :: ReadPrec [DolbyVision]
readPrec :: ReadPrec DolbyVision
$creadPrec :: ReadPrec DolbyVision
readList :: ReadS [DolbyVision]
$creadList :: ReadS [DolbyVision]
readsPrec :: Int -> ReadS DolbyVision
$creadsPrec :: Int -> ReadS DolbyVision
Prelude.Read, Int -> DolbyVision -> ShowS
[DolbyVision] -> ShowS
DolbyVision -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DolbyVision] -> ShowS
$cshowList :: [DolbyVision] -> ShowS
show :: DolbyVision -> String
$cshow :: DolbyVision -> String
showsPrec :: Int -> DolbyVision -> ShowS
$cshowsPrec :: Int -> DolbyVision -> ShowS
Prelude.Show, forall x. Rep DolbyVision x -> DolbyVision
forall x. DolbyVision -> Rep DolbyVision x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DolbyVision x -> DolbyVision
$cfrom :: forall x. DolbyVision -> Rep DolbyVision x
Prelude.Generic)

-- |
-- Create a value of 'DolbyVision' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'l6Metadata', 'dolbyVision_l6Metadata' - Use these settings when you set DolbyVisionLevel6Mode to SPECIFY to
-- override the MaxCLL and MaxFALL values in your input with new values.
--
-- 'l6Mode', 'dolbyVision_l6Mode' - Use Dolby Vision Mode to choose how the service will handle Dolby Vision
-- MaxCLL and MaxFALL properies.
--
-- 'mapping', 'dolbyVision_mapping' - Required when you set Dolby Vision Profile to Profile 8.1. When you set
-- Content mapping to None, content mapping is not applied to the
-- HDR10-compatible signal. Depending on the source peak nit level,
-- clipping might occur on HDR devices without Dolby Vision. When you set
-- Content mapping to HDR10 1000, the transcoder creates a 1,000 nits peak
-- HDR10-compatible signal by applying static content mapping to the
-- source. This mode is speed-optimized for PQ10 sources with metadata that
-- is created from analysis. For graded Dolby Vision content, be aware that
-- creative intent might not be guaranteed with extreme 1,000 nits trims.
--
-- 'profile', 'dolbyVision_profile' - Required when you enable Dolby Vision. Use Profile 5 to include
-- frame-interleaved Dolby Vision metadata in your output. Your input must
-- include Dolby Vision metadata or an HDR10 YUV color space. Use Profile
-- 8.1 to include frame-interleaved Dolby Vision metadata and HDR10
-- metadata in your output. Your input must include Dolby Vision metadata.
newDolbyVision ::
  DolbyVision
newDolbyVision :: DolbyVision
newDolbyVision =
  DolbyVision'
    { $sel:l6Metadata:DolbyVision' :: Maybe DolbyVisionLevel6Metadata
l6Metadata = forall a. Maybe a
Prelude.Nothing,
      $sel:l6Mode:DolbyVision' :: Maybe DolbyVisionLevel6Mode
l6Mode = forall a. Maybe a
Prelude.Nothing,
      $sel:mapping:DolbyVision' :: Maybe DolbyVisionMapping
mapping = forall a. Maybe a
Prelude.Nothing,
      $sel:profile:DolbyVision' :: Maybe DolbyVisionProfile
profile = forall a. Maybe a
Prelude.Nothing
    }

-- | Use these settings when you set DolbyVisionLevel6Mode to SPECIFY to
-- override the MaxCLL and MaxFALL values in your input with new values.
dolbyVision_l6Metadata :: Lens.Lens' DolbyVision (Prelude.Maybe DolbyVisionLevel6Metadata)
dolbyVision_l6Metadata :: Lens' DolbyVision (Maybe DolbyVisionLevel6Metadata)
dolbyVision_l6Metadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DolbyVision' {Maybe DolbyVisionLevel6Metadata
l6Metadata :: Maybe DolbyVisionLevel6Metadata
$sel:l6Metadata:DolbyVision' :: DolbyVision -> Maybe DolbyVisionLevel6Metadata
l6Metadata} -> Maybe DolbyVisionLevel6Metadata
l6Metadata) (\s :: DolbyVision
s@DolbyVision' {} Maybe DolbyVisionLevel6Metadata
a -> DolbyVision
s {$sel:l6Metadata:DolbyVision' :: Maybe DolbyVisionLevel6Metadata
l6Metadata = Maybe DolbyVisionLevel6Metadata
a} :: DolbyVision)

-- | Use Dolby Vision Mode to choose how the service will handle Dolby Vision
-- MaxCLL and MaxFALL properies.
dolbyVision_l6Mode :: Lens.Lens' DolbyVision (Prelude.Maybe DolbyVisionLevel6Mode)
dolbyVision_l6Mode :: Lens' DolbyVision (Maybe DolbyVisionLevel6Mode)
dolbyVision_l6Mode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DolbyVision' {Maybe DolbyVisionLevel6Mode
l6Mode :: Maybe DolbyVisionLevel6Mode
$sel:l6Mode:DolbyVision' :: DolbyVision -> Maybe DolbyVisionLevel6Mode
l6Mode} -> Maybe DolbyVisionLevel6Mode
l6Mode) (\s :: DolbyVision
s@DolbyVision' {} Maybe DolbyVisionLevel6Mode
a -> DolbyVision
s {$sel:l6Mode:DolbyVision' :: Maybe DolbyVisionLevel6Mode
l6Mode = Maybe DolbyVisionLevel6Mode
a} :: DolbyVision)

-- | Required when you set Dolby Vision Profile to Profile 8.1. When you set
-- Content mapping to None, content mapping is not applied to the
-- HDR10-compatible signal. Depending on the source peak nit level,
-- clipping might occur on HDR devices without Dolby Vision. When you set
-- Content mapping to HDR10 1000, the transcoder creates a 1,000 nits peak
-- HDR10-compatible signal by applying static content mapping to the
-- source. This mode is speed-optimized for PQ10 sources with metadata that
-- is created from analysis. For graded Dolby Vision content, be aware that
-- creative intent might not be guaranteed with extreme 1,000 nits trims.
dolbyVision_mapping :: Lens.Lens' DolbyVision (Prelude.Maybe DolbyVisionMapping)
dolbyVision_mapping :: Lens' DolbyVision (Maybe DolbyVisionMapping)
dolbyVision_mapping = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DolbyVision' {Maybe DolbyVisionMapping
mapping :: Maybe DolbyVisionMapping
$sel:mapping:DolbyVision' :: DolbyVision -> Maybe DolbyVisionMapping
mapping} -> Maybe DolbyVisionMapping
mapping) (\s :: DolbyVision
s@DolbyVision' {} Maybe DolbyVisionMapping
a -> DolbyVision
s {$sel:mapping:DolbyVision' :: Maybe DolbyVisionMapping
mapping = Maybe DolbyVisionMapping
a} :: DolbyVision)

-- | Required when you enable Dolby Vision. Use Profile 5 to include
-- frame-interleaved Dolby Vision metadata in your output. Your input must
-- include Dolby Vision metadata or an HDR10 YUV color space. Use Profile
-- 8.1 to include frame-interleaved Dolby Vision metadata and HDR10
-- metadata in your output. Your input must include Dolby Vision metadata.
dolbyVision_profile :: Lens.Lens' DolbyVision (Prelude.Maybe DolbyVisionProfile)
dolbyVision_profile :: Lens' DolbyVision (Maybe DolbyVisionProfile)
dolbyVision_profile = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DolbyVision' {Maybe DolbyVisionProfile
profile :: Maybe DolbyVisionProfile
$sel:profile:DolbyVision' :: DolbyVision -> Maybe DolbyVisionProfile
profile} -> Maybe DolbyVisionProfile
profile) (\s :: DolbyVision
s@DolbyVision' {} Maybe DolbyVisionProfile
a -> DolbyVision
s {$sel:profile:DolbyVision' :: Maybe DolbyVisionProfile
profile = Maybe DolbyVisionProfile
a} :: DolbyVision)

instance Data.FromJSON DolbyVision where
  parseJSON :: Value -> Parser DolbyVision
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DolbyVision"
      ( \Object
x ->
          Maybe DolbyVisionLevel6Metadata
-> Maybe DolbyVisionLevel6Mode
-> Maybe DolbyVisionMapping
-> Maybe DolbyVisionProfile
-> DolbyVision
DolbyVision'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"l6Metadata")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"l6Mode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"mapping")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"profile")
      )

instance Prelude.Hashable DolbyVision where
  hashWithSalt :: Int -> DolbyVision -> Int
hashWithSalt Int
_salt DolbyVision' {Maybe DolbyVisionLevel6Metadata
Maybe DolbyVisionLevel6Mode
Maybe DolbyVisionMapping
Maybe DolbyVisionProfile
profile :: Maybe DolbyVisionProfile
mapping :: Maybe DolbyVisionMapping
l6Mode :: Maybe DolbyVisionLevel6Mode
l6Metadata :: Maybe DolbyVisionLevel6Metadata
$sel:profile:DolbyVision' :: DolbyVision -> Maybe DolbyVisionProfile
$sel:mapping:DolbyVision' :: DolbyVision -> Maybe DolbyVisionMapping
$sel:l6Mode:DolbyVision' :: DolbyVision -> Maybe DolbyVisionLevel6Mode
$sel:l6Metadata:DolbyVision' :: DolbyVision -> Maybe DolbyVisionLevel6Metadata
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DolbyVisionLevel6Metadata
l6Metadata
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DolbyVisionLevel6Mode
l6Mode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DolbyVisionMapping
mapping
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DolbyVisionProfile
profile

instance Prelude.NFData DolbyVision where
  rnf :: DolbyVision -> ()
rnf DolbyVision' {Maybe DolbyVisionLevel6Metadata
Maybe DolbyVisionLevel6Mode
Maybe DolbyVisionMapping
Maybe DolbyVisionProfile
profile :: Maybe DolbyVisionProfile
mapping :: Maybe DolbyVisionMapping
l6Mode :: Maybe DolbyVisionLevel6Mode
l6Metadata :: Maybe DolbyVisionLevel6Metadata
$sel:profile:DolbyVision' :: DolbyVision -> Maybe DolbyVisionProfile
$sel:mapping:DolbyVision' :: DolbyVision -> Maybe DolbyVisionMapping
$sel:l6Mode:DolbyVision' :: DolbyVision -> Maybe DolbyVisionLevel6Mode
$sel:l6Metadata:DolbyVision' :: DolbyVision -> Maybe DolbyVisionLevel6Metadata
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DolbyVisionLevel6Metadata
l6Metadata
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DolbyVisionLevel6Mode
l6Mode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DolbyVisionMapping
mapping
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DolbyVisionProfile
profile

instance Data.ToJSON DolbyVision where
  toJSON :: DolbyVision -> Value
toJSON DolbyVision' {Maybe DolbyVisionLevel6Metadata
Maybe DolbyVisionLevel6Mode
Maybe DolbyVisionMapping
Maybe DolbyVisionProfile
profile :: Maybe DolbyVisionProfile
mapping :: Maybe DolbyVisionMapping
l6Mode :: Maybe DolbyVisionLevel6Mode
l6Metadata :: Maybe DolbyVisionLevel6Metadata
$sel:profile:DolbyVision' :: DolbyVision -> Maybe DolbyVisionProfile
$sel:mapping:DolbyVision' :: DolbyVision -> Maybe DolbyVisionMapping
$sel:l6Mode:DolbyVision' :: DolbyVision -> Maybe DolbyVisionLevel6Mode
$sel:l6Metadata:DolbyVision' :: DolbyVision -> Maybe DolbyVisionLevel6Metadata
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"l6Metadata" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DolbyVisionLevel6Metadata
l6Metadata,
            (Key
"l6Mode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DolbyVisionLevel6Mode
l6Mode,
            (Key
"mapping" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DolbyVisionMapping
mapping,
            (Key
"profile" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DolbyVisionProfile
profile
          ]
      )