chromium/media/base/container_names.cc

// Copyright 2013 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/base/container_names.h"

#include <stddef.h>
#include <string.h>

#include <limits>

#include "base/check_op.h"
#include "base/numerics/safe_conversions.h"
#include "media/base/bit_reader.h"
#include "third_party/abseil-cpp/absl/strings/ascii.h"

namespace media {

namespace container_names {

#define TAG(a, b, c, d)

#define RCHECK(x)

#define UTF8_BYTE_ORDER_MARK

// Helper function to read 2 bytes (16 bits, big endian) from a buffer.
static int Read16(const uint8_t* p) {}

// Helper function to read 3 bytes (24 bits, big endian) from a buffer.
static uint32_t Read24(const uint8_t* p) {}

// Helper function to read 4 bytes (32 bits, big endian) from a buffer.
static uint32_t Read32(const uint8_t* p) {}

// Helper function to read 4 bytes (32 bits, little endian) from a buffer.
static uint32_t Read32LE(const uint8_t* p) {}

// Helper function to do buffer comparisons with a string without going off the
// end of the buffer.
static bool StartsWith(const uint8_t* buffer,
                       size_t buffer_size,
                       const char* prefix) {}

// Helper function to do buffer comparisons with another buffer (to allow for
// embedded \0 in the comparison) without going off the end of the buffer.
static bool StartsWith(const uint8_t* buffer,
                       size_t buffer_size,
                       const uint8_t* prefix,
                       size_t prefix_size) {}

// Helper function to read up to 64 bits from a bit stream.
// TODO(chcunningham): Delete this helper and replace with direct calls to
// reader that handle read failure. As-is, we hide failure because returning 0
// is valid for both a successful and failed read.
static uint64_t ReadBits(BitReader* reader, int num_bits) {}

const int kAc3FrameSizeTable[38][3] =;

// Checks for an ADTS AAC container.
static bool CheckAac(const uint8_t* buffer, int buffer_size) {}

const uint16_t kAc3SyncWord =;

// Checks for an AC3 container.
static bool CheckAc3(const uint8_t* buffer, int buffer_size) {}

// Checks for an EAC3 container (very similar to AC3)
static bool CheckEac3(const uint8_t* buffer, int buffer_size) {}

// Additional checks for a BINK container.
static bool CheckBink(const uint8_t* buffer, int buffer_size) {}

// Additional checks for a CAF container.
static bool CheckCaf(const uint8_t* buffer, int buffer_size) {}

static bool kSamplingFrequencyValid[16] =;
static bool kExtAudioIdValid[8] =;

// Additional checks for a DTS container.
static bool CheckDts(const uint8_t* buffer, int buffer_size) {}

// Checks for a DV container.
static bool CheckDV(const uint8_t* buffer, int buffer_size) {}


// Checks for a GSM container.
static bool CheckGsm(const uint8_t* buffer, int buffer_size) {}

// Advance to the first set of |num_bits| bits that match |start_code|. |offset|
// is the current location in the buffer, and is updated. |bytes_needed| is the
// number of bytes that must remain in the buffer when |start_code| is found.
// Returns true if start_code found (and enough space in the buffer after it),
// false otherwise.
static bool AdvanceToStartCode(const uint8_t* buffer,
                               int buffer_size,
                               int* offset,
                               int bytes_needed,
                               int num_bits,
                               uint32_t start_code) {}

// Checks for an H.261 container.
static bool CheckH261(const uint8_t* buffer, int buffer_size) {}

// Checks for an H.263 container.
static bool CheckH263(const uint8_t* buffer, int buffer_size) {}

// Checks for an H.264 container.
static bool CheckH264(const uint8_t* buffer, int buffer_size) {}

static const char kHlsSignature[] =;
static const char kHls1[] =;
static const char kHls2[] =;
static const char kHls3[] =;

// Additional checks for a HLS container.
static bool CheckHls(const uint8_t* buffer, int buffer_size) {}

// Checks for a MJPEG stream.
static bool CheckMJpeg(const uint8_t* buffer, int buffer_size) {}

enum Mpeg2StartCodes {};

// Checks for a MPEG2 Program Stream.
static bool CheckMpeg2ProgramStream(const uint8_t* buffer, int buffer_size) {}

const uint8_t kMpeg2SyncWord =;

// Checks for a MPEG2 Transport Stream.
static bool CheckMpeg2TransportStream(const uint8_t* buffer, int buffer_size) {}

enum Mpeg4StartCodes {};

// Checks for a raw MPEG4 bitstream container.
static bool CheckMpeg4BitStream(const uint8_t* buffer, int buffer_size) {}

// Additional checks for a MOV/QuickTime/MPEG4 container.
static bool CheckMov(const uint8_t* buffer, int buffer_size) {}

enum MPEGVersion {};
enum MPEGLayer {};

static int kSampleRateTable[4][4] =;

static int kBitRateTableV1L1[16] =;
static int kBitRateTableV1L2[16] =;
static int kBitRateTableV1L3[16] =;
static int kBitRateTableV2L1[16] =;
static int kBitRateTableV2L23[16] =;

static bool ValidMpegAudioFrameHeader(const uint8_t* header,
                                      int header_size,
                                      int* framesize) {}

// Additional checks for a MP3 container.
static bool CheckMp3(const uint8_t* buffer, int buffer_size) {}

// Check that the next characters in |buffer| represent a number. The format
// accepted is optional whitespace followed by 1 or more digits. |max_digits|
// specifies the maximum number of digits to process. Returns true if a valid
// number is found, false otherwise.
static bool VerifyNumber(const uint8_t* buffer,
                         int buffer_size,
                         int* offset,
                         int max_digits) {}

// Check that the next character in |buffer| is one of |c1| or |c2|. |c2| is
// optional. Returns true if there is a match, false if no match or out of
// space.
static inline bool VerifyCharacters(const uint8_t* buffer,
                                    int buffer_size,
                                    int* offset,
                                    char c1,
                                    char c2) {}

// Checks for a SRT container.
static bool CheckSrt(const uint8_t* buffer, int buffer_size) {}

// Read a Matroska Element Id.
static int GetElementId(BitReader* reader) {}

// Read a Matroska Unsigned Integer (VINT).
static uint64_t GetVint(BitReader* reader) {}

// Additional checks for a WEBM container.
static bool CheckWebm(const uint8_t* buffer, int buffer_size) {}

enum VC1StartCodes {};

// Checks for a VC1 bitstream container.
static bool CheckVC1(const uint8_t* buffer, int buffer_size) {}

// For some formats the signature is a bunch of characters. They are defined
// below. Note that the first 4 characters of the string may be used as a TAG
// in LookupContainerByFirst4. For signatures that contain embedded \0, use
// uint8_t[].
static const char kAmrSignature[] =;
static const uint8_t kAsfSignature[] =;
static const char kAssSignature[] =;
static const char kAssBomSignature[] =;
static const uint8_t kWtvSignature[] =;

// Attempt to determine the container type from the buffer provided. This is
// a simple pass, that uses the first 4 bytes of the buffer as an index to get
// a rough idea of the container format.
static MediaContainerName LookupContainerByFirst4(const uint8_t* buffer,
                                                  int buffer_size) {}

// Attempt to determine the container name from the buffer provided.
MediaContainerName DetermineContainer(const uint8_t* buffer, int buffer_size) {}

}  // namespace container_names

}  // namespace media