#ifdef UNSAFE_BUFFERS_BUILD
#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 …
static int Read16(const uint8_t* p) { … }
static uint32_t Read24(const uint8_t* p) { … }
static uint32_t Read32(const uint8_t* p) { … }
static uint32_t Read32LE(const uint8_t* p) { … }
static bool StartsWith(const uint8_t* buffer,
size_t buffer_size,
const char* prefix) { … }
static bool StartsWith(const uint8_t* buffer,
size_t buffer_size,
const uint8_t* prefix,
size_t prefix_size) { … }
static uint64_t ReadBits(BitReader* reader, int num_bits) { … }
const int kAc3FrameSizeTable[38][3] = …;
static bool CheckAac(const uint8_t* buffer, int buffer_size) { … }
const uint16_t kAc3SyncWord = …;
static bool CheckAc3(const uint8_t* buffer, int buffer_size) { … }
static bool CheckEac3(const uint8_t* buffer, int buffer_size) { … }
static bool CheckBink(const uint8_t* buffer, int buffer_size) { … }
static bool CheckCaf(const uint8_t* buffer, int buffer_size) { … }
static bool kSamplingFrequencyValid[16] = …;
static bool kExtAudioIdValid[8] = …;
static bool CheckDts(const uint8_t* buffer, int buffer_size) { … }
static bool CheckDV(const uint8_t* buffer, int buffer_size) { … }
static bool CheckGsm(const uint8_t* buffer, int buffer_size) { … }
static bool AdvanceToStartCode(const uint8_t* buffer,
int buffer_size,
int* offset,
int bytes_needed,
int num_bits,
uint32_t start_code) { … }
static bool CheckH261(const uint8_t* buffer, int buffer_size) { … }
static bool CheckH263(const uint8_t* buffer, int buffer_size) { … }
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[] = …;
static bool CheckHls(const uint8_t* buffer, int buffer_size) { … }
static bool CheckMJpeg(const uint8_t* buffer, int buffer_size) { … }
enum Mpeg2StartCodes { … };
static bool CheckMpeg2ProgramStream(const uint8_t* buffer, int buffer_size) { … }
const uint8_t kMpeg2SyncWord = …;
static bool CheckMpeg2TransportStream(const uint8_t* buffer, int buffer_size) { … }
enum Mpeg4StartCodes { … };
static bool CheckMpeg4BitStream(const uint8_t* buffer, int buffer_size) { … }
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) { … }
static bool CheckMp3(const uint8_t* buffer, int buffer_size) { … }
static bool VerifyNumber(const uint8_t* buffer,
int buffer_size,
int* offset,
int max_digits) { … }
static inline bool VerifyCharacters(const uint8_t* buffer,
int buffer_size,
int* offset,
char c1,
char c2) { … }
static bool CheckSrt(const uint8_t* buffer, int buffer_size) { … }
static int GetElementId(BitReader* reader) { … }
static uint64_t GetVint(BitReader* reader) { … }
static bool CheckWebm(const uint8_t* buffer, int buffer_size) { … }
enum VC1StartCodes { … };
static bool CheckVC1(const uint8_t* buffer, int buffer_size) { … }
static const char kAmrSignature[] = …;
static const uint8_t kAsfSignature[] = …;
static const char kAssSignature[] = …;
static const char kAssBomSignature[] = …;
static const uint8_t kWtvSignature[] = …;
static MediaContainerName LookupContainerByFirst4(const uint8_t* buffer,
int buffer_size) { … }
MediaContainerName DetermineContainer(const uint8_t* buffer, int buffer_size) { … }
}
}