Skip to content

Commit

Permalink
Document the intention between the OutputSampleRate and `InputSampl…
Browse files Browse the repository at this point in the history
…eRate` distinction.

  - Maybe we change the function names in the future (`SampleRateForTimingPurposes`?). But for now, just update documentation.
  - Confusingly the spec defines an asymmetry between Opus and other codecs, so this documentation tries to make it extra clear that timing information for Opus is treated as a special case.
  - b/383392238: Pertains to FFmpeg/FFmpeg@76049d1, where `ffmpeg` updated to agree with the `iamf-tools` handling of timing for IAMF-Opus.

PiperOrigin-RevId: 712535637
  • Loading branch information
jwcullen committed Jan 7, 2025
1 parent 662762c commit 3af5518
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
10 changes: 10 additions & 0 deletions iamf/obu/codec_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,22 @@ class CodecConfigObu : public ObuBase {
absl::Status ReadAndValidateDecoderConfig(ReadBitBuffer& rb);

/*!\brief Gets the output sample rate associated with the OBU.
*
* This sample rate is used for timing and offset calculations as per
* section 3.11 of the IAMF spec.
*
* - AAC, FLAC, LPCM: Based on the sample rate of the input stream.
* - Opus: Always 48kHz ("The sample rate used for computing offsets SHALL
* be 48 kHz.").
*
* \return Output sample rate in Hz if the OBU was initialized successfully.
*/
uint32_t GetOutputSampleRate() const { return output_sample_rate_; }

/*!\brief Gets the input sample rate associated with the OBU.
*
* The sample rate of the data before being passed to the underlying codec
* libraries.
*
* \return Input sample rate in Hz if the OBU was initialized successfully.
*/
Expand Down
6 changes: 6 additions & 0 deletions iamf/obu/decoder_config/aac_decoder_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ class AacDecoderConfig {
absl::Status ReadAndValidate(int16_t audio_roll_distance, ReadBitBuffer& rb);

/*!\brief Gets the output sample rate of the `AacDecoderConfig`.
*
* This sample rate is used for timing and offset calculations.
*
* IAMF v1.1.0 section 3.11.2 specifies:
* > "The sample rate used for computing offsets SHALL be the rate indicated
* by the samplingFrequencyIndex in GASpecificConfig()."
*
* \param output_sample_rate Output sample rate.
* \return `absl::OkStatus()` if successful. `absl::InvalidArgumentError()`
Expand Down
6 changes: 6 additions & 0 deletions iamf/obu/decoder_config/flac_decoder_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ class FlacDecoderConfig {
int16_t audio_roll_distance, ReadBitBuffer& rb);

/*!\brief Gets the output sample rate represented within the decoder config.
*
* This sample rate is used for timing and offset calculations.
*
* IAMF v1.1.0 section 3.11.3 specifies:
* > "The sample rate used for computing offsets SHALL be the sampling rate
* indicated in the METADATA_BLOCK."
*
* \param output_sample_rate Output sample rate.
* \return `absl::OkStatus()` if successful. `absl::InvalidArgumentError()`
Expand Down
5 changes: 5 additions & 0 deletions iamf/obu/decoder_config/lpcm_decoder_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class LpcmDecoderConfig {
absl::Status ReadAndValidate(int16_t audio_roll_distance, ReadBitBuffer& rb);

/*!\brief Gets the output sample rate represented within the decoder config.
*
* This sample rate is used for timing and offset calculations.
*
* IAMF v1.1.0 section 3.11.4 specifies:
* > "The sample rate used for computing offsets SHALL be sample_rate."
*
* \param output_sample_rate Output sample rate.
* \return `absl::OkStatus()` if successful. `absl::InvalidArgumentError()`
Expand Down
5 changes: 4 additions & 1 deletion iamf/obu/decoder_config/opus_decoder_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ class OpusDecoderConfig {

/*!\brief Gets the output sample rate represented within the decoder config.
*
* IAMF Spec requires the output to be 48,000 Hz.
* This sample rate is used for timing and offset calculations.
*
* IAMF v1.1.0 section 3.11.1 specifies:
* > "The sample rate used for computing offsets SHALL be 48 kHz."
*
* \return Output sample rate.
*/
Expand Down

0 comments on commit 3af5518

Please sign in to comment.