// Copyright (c) 2023, Alliance for Open Media. All rights reserved
//
// This source code is subject to the terms of the BSD 3-Clause Clear License
// and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear
// License was not distributed with this source code in the LICENSE file, you
// can obtain it at www.aomedia.org/license/software-license/bsd-3-c-c. If the
// Alliance for Open Media Patent License 1.0 was not distributed with this
// source code in the PATENTS file, you can obtain it at
// www.aomedia.org/license/patent.

edition = "2023";

package iamf_tools_cli_proto;

option features.enum_type = CLOSED;

enum AnimationType {
  ANIMATE_INVALID = 0;
  ANIMATE_STEP = 1;
  ANIMATE_LINEAR = 2;
  ANIMATE_BEZIER = 3;
}

// Values are represented to align with the IAMF spec.
//
// See https://aomediacodec.github.io/iamf/v1.1.0.html#syntax-mix-gain-param for
// further details.
//
// See detailed examples on Q7.8 format below in `AnimationLinearInt16`.
message AnimationStepInt16 {
  int32 start_point_value = 1;  // Q7.8.
}

// Values are represented to align with the IAMF spec.
//
// See https://aomediacodec.github.io/iamf/v1.1.0.html#syntax-mix-gain-param for
// further details.
//
// See detailed examples on Q7.8 format below in `AnimationLinearInt16`.
message AnimationLinearInt16 {
  int32 start_point_value = 1;  // Q7.8.
  int32 end_point_value = 2;    // Q7.8.
}

// Values are represented to align with the IAMF spec.
//
// See https://aomediacodec.github.io/iamf/v1.1.0.html#syntax-mix-gain-param for
// further details.
//
// To convert from dB to Q7.8, multiply by 256. Example:
//  - For -3 dB, set the proto value to 256 * -3 = -768.
//  - For +6 dB, set the proto value to 256 * 6 = 1536.
//
// To convert from a float in the range [0.0, 1.0] to Q0.8. Multiply by 256 and
// clamp to the range [0, 255]. Examples:
//  - For a control point relative time of 0.5, set the proto value to
//    clam(0.5 * 256, 0, 255) = 128.
//  - For a control point relative time of 1.0, set the proto value to
//    clamp(1.0 * 256, 0, 255) = 255.
message AnimationBezierInt16 {
  int32 start_point_value = 1;             // Q7.8.
  int32 end_point_value = 2;               // Q7.8.
  int32 control_point_value = 3;           // Q7.8.
  uint32 control_point_relative_time = 4;  // Q0.8.
}

message AnimatedParameterDataInt16 {
  oneof parameter_data {
    AnimationStepInt16 step = 1;
    AnimationLinearInt16 linear = 2;
    AnimationBezierInt16 bezier = 3;
  }
}

message MixGainParameterData {
  AnimationType animation_type = 1;
  AnimatedParameterDataInt16 param_data = 2;
}

enum DMixPMode {
  DMIXP_MODE_INVALID = 0;

  //                       (alpha, beta,  gamma, delta, w_idx_offset)
  DMIXP_MODE_1 = 1;  //    (    1,     1, 0.707, 0.707,           -1)
  DMIXP_MODE_2 = 2;  //    (0.707, 0.707, 0.707, 0.707,           -1)
  DMIXP_MODE_3 = 3;  //    (    1, 0.866, 0.866, 0.866,           -1)
  DMIXP_MODE_RESERVED_A = 4;
  DMIXP_MODE_1_N = 5;  //  (    1,     1, 0.707, 0.707,            1)
  DMIXP_MODE_2_N = 6;  //  (0.707, 0.707, 0.707, 0.707,            1)
  DMIXP_MODE_3_N = 7;  //  (    1, 0.866, 0.866, 0.866,            1)
  DMIXP_MODE_RESERVED_B = 8;
}

message DemixingInfoParameterData {
  DMixPMode dmixp_mode = 1;
  uint32 reserved = 2;
}

message ReconGains {
  reserved 1;

  // Mapping from a bit position to a recon gain value.
  // If recon_gain[j] is defined, then the j-th bit of recon_gain_flags[i]
  // (for the i-th layer) will be set.
  map<uint32, uint32> recon_gain = 2;
}

message ReconGainInfoParameterData {
  reserved 1;

  // Length = `num_layers`.
  repeated ReconGains recon_gains_for_layer = 2;
}
