{-# 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.H264QvbrSettings
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaConvert.Types.H264QvbrSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Settings for quality-defined variable bitrate encoding with the H.265
-- codec. Use these settings only when you set QVBR for Rate control mode
-- (RateControlMode).
--
-- /See:/ 'newH264QvbrSettings' smart constructor.
data H264QvbrSettings = H264QvbrSettings'
  { -- | Optional. Specify a value here to set the QVBR quality to a level that
    -- is between whole numbers. For example, if you want your QVBR quality
    -- level to be 7.33, set qvbrQualityLevel to 7 and set
    -- qvbrQualityLevelFineTune to .33. MediaConvert rounds your QVBR quality
    -- level to the nearest third of a whole number. For example, if you set
    -- qvbrQualityLevel to 7 and you set qvbrQualityLevelFineTune to .25, your
    -- actual QVBR quality level is 7.33.
    H264QvbrSettings -> Maybe Double
qvbrQualityLevelFineTune :: Prelude.Maybe Prelude.Double,
    -- | Use this setting only when Rate control mode is QVBR and Quality tuning
    -- level is Multi-pass HQ. For Max average bitrate values suited to the
    -- complexity of your input video, the service limits the average bitrate
    -- of the video part of this output to the value that you choose. That is,
    -- the total size of the video element is less than or equal to the value
    -- you set multiplied by the number of seconds of encoded output.
    H264QvbrSettings -> Maybe Natural
maxAverageBitrate :: Prelude.Maybe Prelude.Natural,
    -- | Use this setting only when you set Rate control mode (RateControlMode)
    -- to QVBR. Specify the target quality level for this output. MediaConvert
    -- determines the right number of bits to use for each part of the video to
    -- maintain the video quality that you specify. When you keep the default
    -- value, AUTO, MediaConvert picks a quality level for you, based on
    -- characteristics of your input video. If you prefer to specify a quality
    -- level, specify a number from 1 through 10. Use higher numbers for
    -- greater quality. Level 10 results in nearly lossless compression. The
    -- quality level for most broadcast-quality transcodes is between 6 and 9.
    -- Optionally, to specify a value between whole numbers, also provide a
    -- value for the setting qvbrQualityLevelFineTune. For example, if you want
    -- your QVBR quality level to be 7.33, set qvbrQualityLevel to 7 and set
    -- qvbrQualityLevelFineTune to .33.
    H264QvbrSettings -> Maybe Natural
qvbrQualityLevel :: Prelude.Maybe Prelude.Natural
  }
  deriving (H264QvbrSettings -> H264QvbrSettings -> Bool
(H264QvbrSettings -> H264QvbrSettings -> Bool)
-> (H264QvbrSettings -> H264QvbrSettings -> Bool)
-> Eq H264QvbrSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: H264QvbrSettings -> H264QvbrSettings -> Bool
$c/= :: H264QvbrSettings -> H264QvbrSettings -> Bool
== :: H264QvbrSettings -> H264QvbrSettings -> Bool
$c== :: H264QvbrSettings -> H264QvbrSettings -> Bool
Prelude.Eq, ReadPrec [H264QvbrSettings]
ReadPrec H264QvbrSettings
Int -> ReadS H264QvbrSettings
ReadS [H264QvbrSettings]
(Int -> ReadS H264QvbrSettings)
-> ReadS [H264QvbrSettings]
-> ReadPrec H264QvbrSettings
-> ReadPrec [H264QvbrSettings]
-> Read H264QvbrSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [H264QvbrSettings]
$creadListPrec :: ReadPrec [H264QvbrSettings]
readPrec :: ReadPrec H264QvbrSettings
$creadPrec :: ReadPrec H264QvbrSettings
readList :: ReadS [H264QvbrSettings]
$creadList :: ReadS [H264QvbrSettings]
readsPrec :: Int -> ReadS H264QvbrSettings
$creadsPrec :: Int -> ReadS H264QvbrSettings
Prelude.Read, Int -> H264QvbrSettings -> ShowS
[H264QvbrSettings] -> ShowS
H264QvbrSettings -> String
(Int -> H264QvbrSettings -> ShowS)
-> (H264QvbrSettings -> String)
-> ([H264QvbrSettings] -> ShowS)
-> Show H264QvbrSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [H264QvbrSettings] -> ShowS
$cshowList :: [H264QvbrSettings] -> ShowS
show :: H264QvbrSettings -> String
$cshow :: H264QvbrSettings -> String
showsPrec :: Int -> H264QvbrSettings -> ShowS
$cshowsPrec :: Int -> H264QvbrSettings -> ShowS
Prelude.Show, (forall x. H264QvbrSettings -> Rep H264QvbrSettings x)
-> (forall x. Rep H264QvbrSettings x -> H264QvbrSettings)
-> Generic H264QvbrSettings
forall x. Rep H264QvbrSettings x -> H264QvbrSettings
forall x. H264QvbrSettings -> Rep H264QvbrSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep H264QvbrSettings x -> H264QvbrSettings
$cfrom :: forall x. H264QvbrSettings -> Rep H264QvbrSettings x
Prelude.Generic)

-- |
-- Create a value of 'H264QvbrSettings' 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:
--
-- 'qvbrQualityLevelFineTune', 'h264QvbrSettings_qvbrQualityLevelFineTune' - Optional. Specify a value here to set the QVBR quality to a level that
-- is between whole numbers. For example, if you want your QVBR quality
-- level to be 7.33, set qvbrQualityLevel to 7 and set
-- qvbrQualityLevelFineTune to .33. MediaConvert rounds your QVBR quality
-- level to the nearest third of a whole number. For example, if you set
-- qvbrQualityLevel to 7 and you set qvbrQualityLevelFineTune to .25, your
-- actual QVBR quality level is 7.33.
--
-- 'maxAverageBitrate', 'h264QvbrSettings_maxAverageBitrate' - Use this setting only when Rate control mode is QVBR and Quality tuning
-- level is Multi-pass HQ. For Max average bitrate values suited to the
-- complexity of your input video, the service limits the average bitrate
-- of the video part of this output to the value that you choose. That is,
-- the total size of the video element is less than or equal to the value
-- you set multiplied by the number of seconds of encoded output.
--
-- 'qvbrQualityLevel', 'h264QvbrSettings_qvbrQualityLevel' - Use this setting only when you set Rate control mode (RateControlMode)
-- to QVBR. Specify the target quality level for this output. MediaConvert
-- determines the right number of bits to use for each part of the video to
-- maintain the video quality that you specify. When you keep the default
-- value, AUTO, MediaConvert picks a quality level for you, based on
-- characteristics of your input video. If you prefer to specify a quality
-- level, specify a number from 1 through 10. Use higher numbers for
-- greater quality. Level 10 results in nearly lossless compression. The
-- quality level for most broadcast-quality transcodes is between 6 and 9.
-- Optionally, to specify a value between whole numbers, also provide a
-- value for the setting qvbrQualityLevelFineTune. For example, if you want
-- your QVBR quality level to be 7.33, set qvbrQualityLevel to 7 and set
-- qvbrQualityLevelFineTune to .33.
newH264QvbrSettings ::
  H264QvbrSettings
newH264QvbrSettings :: H264QvbrSettings
newH264QvbrSettings =
  H264QvbrSettings' :: Maybe Double -> Maybe Natural -> Maybe Natural -> H264QvbrSettings
H264QvbrSettings'
    { $sel:qvbrQualityLevelFineTune:H264QvbrSettings' :: Maybe Double
qvbrQualityLevelFineTune =
        Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:maxAverageBitrate:H264QvbrSettings' :: Maybe Natural
maxAverageBitrate = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:qvbrQualityLevel:H264QvbrSettings' :: Maybe Natural
qvbrQualityLevel = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Optional. Specify a value here to set the QVBR quality to a level that
-- is between whole numbers. For example, if you want your QVBR quality
-- level to be 7.33, set qvbrQualityLevel to 7 and set
-- qvbrQualityLevelFineTune to .33. MediaConvert rounds your QVBR quality
-- level to the nearest third of a whole number. For example, if you set
-- qvbrQualityLevel to 7 and you set qvbrQualityLevelFineTune to .25, your
-- actual QVBR quality level is 7.33.
h264QvbrSettings_qvbrQualityLevelFineTune :: Lens.Lens' H264QvbrSettings (Prelude.Maybe Prelude.Double)
h264QvbrSettings_qvbrQualityLevelFineTune :: (Maybe Double -> f (Maybe Double))
-> H264QvbrSettings -> f H264QvbrSettings
h264QvbrSettings_qvbrQualityLevelFineTune = (H264QvbrSettings -> Maybe Double)
-> (H264QvbrSettings -> Maybe Double -> H264QvbrSettings)
-> Lens
     H264QvbrSettings H264QvbrSettings (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\H264QvbrSettings' {Maybe Double
qvbrQualityLevelFineTune :: Maybe Double
$sel:qvbrQualityLevelFineTune:H264QvbrSettings' :: H264QvbrSettings -> Maybe Double
qvbrQualityLevelFineTune} -> Maybe Double
qvbrQualityLevelFineTune) (\s :: H264QvbrSettings
s@H264QvbrSettings' {} Maybe Double
a -> H264QvbrSettings
s {$sel:qvbrQualityLevelFineTune:H264QvbrSettings' :: Maybe Double
qvbrQualityLevelFineTune = Maybe Double
a} :: H264QvbrSettings)

-- | Use this setting only when Rate control mode is QVBR and Quality tuning
-- level is Multi-pass HQ. For Max average bitrate values suited to the
-- complexity of your input video, the service limits the average bitrate
-- of the video part of this output to the value that you choose. That is,
-- the total size of the video element is less than or equal to the value
-- you set multiplied by the number of seconds of encoded output.
h264QvbrSettings_maxAverageBitrate :: Lens.Lens' H264QvbrSettings (Prelude.Maybe Prelude.Natural)
h264QvbrSettings_maxAverageBitrate :: (Maybe Natural -> f (Maybe Natural))
-> H264QvbrSettings -> f H264QvbrSettings
h264QvbrSettings_maxAverageBitrate = (H264QvbrSettings -> Maybe Natural)
-> (H264QvbrSettings -> Maybe Natural -> H264QvbrSettings)
-> Lens
     H264QvbrSettings H264QvbrSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\H264QvbrSettings' {Maybe Natural
maxAverageBitrate :: Maybe Natural
$sel:maxAverageBitrate:H264QvbrSettings' :: H264QvbrSettings -> Maybe Natural
maxAverageBitrate} -> Maybe Natural
maxAverageBitrate) (\s :: H264QvbrSettings
s@H264QvbrSettings' {} Maybe Natural
a -> H264QvbrSettings
s {$sel:maxAverageBitrate:H264QvbrSettings' :: Maybe Natural
maxAverageBitrate = Maybe Natural
a} :: H264QvbrSettings)

-- | Use this setting only when you set Rate control mode (RateControlMode)
-- to QVBR. Specify the target quality level for this output. MediaConvert
-- determines the right number of bits to use for each part of the video to
-- maintain the video quality that you specify. When you keep the default
-- value, AUTO, MediaConvert picks a quality level for you, based on
-- characteristics of your input video. If you prefer to specify a quality
-- level, specify a number from 1 through 10. Use higher numbers for
-- greater quality. Level 10 results in nearly lossless compression. The
-- quality level for most broadcast-quality transcodes is between 6 and 9.
-- Optionally, to specify a value between whole numbers, also provide a
-- value for the setting qvbrQualityLevelFineTune. For example, if you want
-- your QVBR quality level to be 7.33, set qvbrQualityLevel to 7 and set
-- qvbrQualityLevelFineTune to .33.
h264QvbrSettings_qvbrQualityLevel :: Lens.Lens' H264QvbrSettings (Prelude.Maybe Prelude.Natural)
h264QvbrSettings_qvbrQualityLevel :: (Maybe Natural -> f (Maybe Natural))
-> H264QvbrSettings -> f H264QvbrSettings
h264QvbrSettings_qvbrQualityLevel = (H264QvbrSettings -> Maybe Natural)
-> (H264QvbrSettings -> Maybe Natural -> H264QvbrSettings)
-> Lens
     H264QvbrSettings H264QvbrSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\H264QvbrSettings' {Maybe Natural
qvbrQualityLevel :: Maybe Natural
$sel:qvbrQualityLevel:H264QvbrSettings' :: H264QvbrSettings -> Maybe Natural
qvbrQualityLevel} -> Maybe Natural
qvbrQualityLevel) (\s :: H264QvbrSettings
s@H264QvbrSettings' {} Maybe Natural
a -> H264QvbrSettings
s {$sel:qvbrQualityLevel:H264QvbrSettings' :: Maybe Natural
qvbrQualityLevel = Maybe Natural
a} :: H264QvbrSettings)

instance Core.FromJSON H264QvbrSettings where
  parseJSON :: Value -> Parser H264QvbrSettings
parseJSON =
    String
-> (Object -> Parser H264QvbrSettings)
-> Value
-> Parser H264QvbrSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"H264QvbrSettings"
      ( \Object
x ->
          Maybe Double -> Maybe Natural -> Maybe Natural -> H264QvbrSettings
H264QvbrSettings'
            (Maybe Double
 -> Maybe Natural -> Maybe Natural -> H264QvbrSettings)
-> Parser (Maybe Double)
-> Parser (Maybe Natural -> Maybe Natural -> H264QvbrSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"qvbrQualityLevelFineTune")
            Parser (Maybe Natural -> Maybe Natural -> H264QvbrSettings)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> H264QvbrSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"maxAverageBitrate")
            Parser (Maybe Natural -> H264QvbrSettings)
-> Parser (Maybe Natural) -> Parser H264QvbrSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"qvbrQualityLevel")
      )

instance Prelude.Hashable H264QvbrSettings

instance Prelude.NFData H264QvbrSettings

instance Core.ToJSON H264QvbrSettings where
  toJSON :: H264QvbrSettings -> Value
toJSON H264QvbrSettings' {Maybe Double
Maybe Natural
qvbrQualityLevel :: Maybe Natural
maxAverageBitrate :: Maybe Natural
qvbrQualityLevelFineTune :: Maybe Double
$sel:qvbrQualityLevel:H264QvbrSettings' :: H264QvbrSettings -> Maybe Natural
$sel:maxAverageBitrate:H264QvbrSettings' :: H264QvbrSettings -> Maybe Natural
$sel:qvbrQualityLevelFineTune:H264QvbrSettings' :: H264QvbrSettings -> Maybe Double
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"qvbrQualityLevelFineTune" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
qvbrQualityLevelFineTune,
            (Text
"maxAverageBitrate" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxAverageBitrate,
            (Text
"qvbrQualityLevel" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
qvbrQualityLevel
          ]
      )