chromium/media/formats/ac3/ac3_util.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "media/formats/ac3/ac3_util.h"

#include "base/logging.h"
#include "media/base/bit_reader.h"

namespace media {

namespace {

// The size in byte of a (E-)AC3 synchronization frame header.
const int kHeaderSizeInByte =;
// The number of new samples per (E-)AC3 audio block.
const int kAudioSamplesPerAudioBlock =;
// Each synchronization frame has 6 blocks that provide 256 new audio samples.
const int kAudioSamplePerAc3SyncFrame =;
// Number of audio blocks per E-AC3 synchronization frame, indexed by
// numblkscod.
const int kBlocksPerSyncFrame[] =;
// Sample rates, indexed by fscod.
const int kSampleRate[] =;
// Nominal bitrates in kbps, indexed by frmsizecod / 2.
const int kBitrate[] =;
// 16-bit words per synchronization frame, indexed by frmsizecod.
const int kSyncFrameSizeInWordsFor44kHz[] =;

// Utility for unpacking (E-)AC3 header. Note that all fields are encoded.
class Ac3Header {};

Ac3Header::Ac3Header(const uint8_t* data, int size) {}

// Search for next synchronization word, which is 0x0B-0x77.
const uint8_t* FindNextSyncWord(const uint8_t* const begin,
                                const uint8_t* const end) {}

// Returns the number of audio samples represented by the given E-AC3
// synchronization frame.
int ParseEac3SyncFrameSampleCount(Ac3Header& header) {}

// Returns the size in bytes of the given E-AC3 synchronization frame.
int ParseEac3SyncFrameSize(Ac3Header& header) {}

// Returns the number of audio samples in an AC3 synchronization frame.
int GetAc3SyncFrameSampleCount() {}

// Returns the size in bytes of the given AC3 synchronization frame.
int ParseAc3SyncFrameSize(Ac3Header& header) {}

// Returns the total number of audio samples in the given buffer, which contains
// several complete (E-)AC3 syncframes.
int ParseTotalSampleCount(const uint8_t* data, size_t size, bool is_eac3) {}

}  // namespace anonymous

// static
int Ac3Util::ParseTotalAc3SampleCount(const uint8_t* data, size_t size) {}

// static
int Ac3Util::ParseTotalEac3SampleCount(const uint8_t* data, size_t size) {}

}  // namespace media