{-# 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.MediaConnect.Types.EncodingParameters
-- 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.MediaConnect.Types.EncodingParameters where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaConnect.Types.EncoderProfile
import qualified Amazonka.Prelude as Prelude

-- | A collection of parameters that determine how MediaConnect will convert
-- the content. These fields only apply to outputs on flows that have a CDI
-- source.
--
-- /See:/ 'newEncodingParameters' smart constructor.
data EncodingParameters = EncodingParameters'
  { -- | A setting on the encoder that drives compression settings. This property
    -- only applies to video media streams associated with outputs that use the
    -- ST 2110 JPEG XS protocol, with a flow source that uses the CDI protocol.
    EncodingParameters -> EncoderProfile
encoderProfile :: EncoderProfile,
    -- | A value that is used to calculate compression for an output. The bitrate
    -- of the output is calculated as follows: Output bitrate = (1 \/
    -- compressionFactor) * (source bitrate) This property only applies to
    -- outputs that use the ST 2110 JPEG XS protocol, with a flow source that
    -- uses the CDI protocol. Valid values are floating point numbers in the
    -- range of 3.0 to 10.0, inclusive.
    EncodingParameters -> Double
compressionFactor :: Prelude.Double
  }
  deriving (EncodingParameters -> EncodingParameters -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncodingParameters -> EncodingParameters -> Bool
$c/= :: EncodingParameters -> EncodingParameters -> Bool
== :: EncodingParameters -> EncodingParameters -> Bool
$c== :: EncodingParameters -> EncodingParameters -> Bool
Prelude.Eq, ReadPrec [EncodingParameters]
ReadPrec EncodingParameters
Int -> ReadS EncodingParameters
ReadS [EncodingParameters]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EncodingParameters]
$creadListPrec :: ReadPrec [EncodingParameters]
readPrec :: ReadPrec EncodingParameters
$creadPrec :: ReadPrec EncodingParameters
readList :: ReadS [EncodingParameters]
$creadList :: ReadS [EncodingParameters]
readsPrec :: Int -> ReadS EncodingParameters
$creadsPrec :: Int -> ReadS EncodingParameters
Prelude.Read, Int -> EncodingParameters -> ShowS
[EncodingParameters] -> ShowS
EncodingParameters -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncodingParameters] -> ShowS
$cshowList :: [EncodingParameters] -> ShowS
show :: EncodingParameters -> String
$cshow :: EncodingParameters -> String
showsPrec :: Int -> EncodingParameters -> ShowS
$cshowsPrec :: Int -> EncodingParameters -> ShowS
Prelude.Show, forall x. Rep EncodingParameters x -> EncodingParameters
forall x. EncodingParameters -> Rep EncodingParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EncodingParameters x -> EncodingParameters
$cfrom :: forall x. EncodingParameters -> Rep EncodingParameters x
Prelude.Generic)

-- |
-- Create a value of 'EncodingParameters' 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:
--
-- 'encoderProfile', 'encodingParameters_encoderProfile' - A setting on the encoder that drives compression settings. This property
-- only applies to video media streams associated with outputs that use the
-- ST 2110 JPEG XS protocol, with a flow source that uses the CDI protocol.
--
-- 'compressionFactor', 'encodingParameters_compressionFactor' - A value that is used to calculate compression for an output. The bitrate
-- of the output is calculated as follows: Output bitrate = (1 \/
-- compressionFactor) * (source bitrate) This property only applies to
-- outputs that use the ST 2110 JPEG XS protocol, with a flow source that
-- uses the CDI protocol. Valid values are floating point numbers in the
-- range of 3.0 to 10.0, inclusive.
newEncodingParameters ::
  -- | 'encoderProfile'
  EncoderProfile ->
  -- | 'compressionFactor'
  Prelude.Double ->
  EncodingParameters
newEncodingParameters :: EncoderProfile -> Double -> EncodingParameters
newEncodingParameters
  EncoderProfile
pEncoderProfile_
  Double
pCompressionFactor_ =
    EncodingParameters'
      { $sel:encoderProfile:EncodingParameters' :: EncoderProfile
encoderProfile =
          EncoderProfile
pEncoderProfile_,
        $sel:compressionFactor:EncodingParameters' :: Double
compressionFactor = Double
pCompressionFactor_
      }

-- | A setting on the encoder that drives compression settings. This property
-- only applies to video media streams associated with outputs that use the
-- ST 2110 JPEG XS protocol, with a flow source that uses the CDI protocol.
encodingParameters_encoderProfile :: Lens.Lens' EncodingParameters EncoderProfile
encodingParameters_encoderProfile :: Lens' EncodingParameters EncoderProfile
encodingParameters_encoderProfile = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncodingParameters' {EncoderProfile
encoderProfile :: EncoderProfile
$sel:encoderProfile:EncodingParameters' :: EncodingParameters -> EncoderProfile
encoderProfile} -> EncoderProfile
encoderProfile) (\s :: EncodingParameters
s@EncodingParameters' {} EncoderProfile
a -> EncodingParameters
s {$sel:encoderProfile:EncodingParameters' :: EncoderProfile
encoderProfile = EncoderProfile
a} :: EncodingParameters)

-- | A value that is used to calculate compression for an output. The bitrate
-- of the output is calculated as follows: Output bitrate = (1 \/
-- compressionFactor) * (source bitrate) This property only applies to
-- outputs that use the ST 2110 JPEG XS protocol, with a flow source that
-- uses the CDI protocol. Valid values are floating point numbers in the
-- range of 3.0 to 10.0, inclusive.
encodingParameters_compressionFactor :: Lens.Lens' EncodingParameters Prelude.Double
encodingParameters_compressionFactor :: Lens' EncodingParameters Double
encodingParameters_compressionFactor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncodingParameters' {Double
compressionFactor :: Double
$sel:compressionFactor:EncodingParameters' :: EncodingParameters -> Double
compressionFactor} -> Double
compressionFactor) (\s :: EncodingParameters
s@EncodingParameters' {} Double
a -> EncodingParameters
s {$sel:compressionFactor:EncodingParameters' :: Double
compressionFactor = Double
a} :: EncodingParameters)

instance Data.FromJSON EncodingParameters where
  parseJSON :: Value -> Parser EncodingParameters
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EncodingParameters"
      ( \Object
x ->
          EncoderProfile -> Double -> EncodingParameters
EncodingParameters'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"encoderProfile")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"compressionFactor")
      )

instance Prelude.Hashable EncodingParameters where
  hashWithSalt :: Int -> EncodingParameters -> Int
hashWithSalt Int
_salt EncodingParameters' {Double
EncoderProfile
compressionFactor :: Double
encoderProfile :: EncoderProfile
$sel:compressionFactor:EncodingParameters' :: EncodingParameters -> Double
$sel:encoderProfile:EncodingParameters' :: EncodingParameters -> EncoderProfile
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EncoderProfile
encoderProfile
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
compressionFactor

instance Prelude.NFData EncodingParameters where
  rnf :: EncodingParameters -> ()
rnf EncodingParameters' {Double
EncoderProfile
compressionFactor :: Double
encoderProfile :: EncoderProfile
$sel:compressionFactor:EncodingParameters' :: EncodingParameters -> Double
$sel:encoderProfile:EncodingParameters' :: EncodingParameters -> EncoderProfile
..} =
    forall a. NFData a => a -> ()
Prelude.rnf EncoderProfile
encoderProfile
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
compressionFactor