#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/ffmpeg/ffmpeg_common.h"
#include "base/hash/sha1.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/decoder_buffer.h"
#include "media/base/encryption_scheme.h"
#include "media/base/media_util.h"
#include "media/base/supported_types.h"
#include "media/base/video_aspect_ratio.h"
#include "media/base/video_color_space.h"
#include "media/base/video_decoder_config.h"
#include "media/base/video_util.h"
#include "media/formats/mp4/box_definitions.h"
#include "media/media_buildflags.h"
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
#include "media/formats/mp4/aac.h"
#if BUILDFLAG(ENABLE_PLATFORM_HEVC)
#include "media/formats/mp4/hevc.h"
#endif
#endif
namespace media {
namespace {
EncryptionScheme GetEncryptionScheme(const AVStream* stream) { … }
VideoDecoderConfig::AlphaMode GetAlphaMode(const AVStream* stream) { … }
VideoColorSpace GetGuessedColorSpace(const VideoColorSpace& color_space) { … }
}
static const int kFFmpegOutputBufferPaddingSize = …;
static_assert …;
static_assert …;
static const AVRational kMicrosBase = …;
base::TimeDelta ConvertFromTimeBase(const AVRational& time_base,
int64_t timestamp) { … }
int64_t ConvertToTimeBase(const AVRational& time_base,
const base::TimeDelta& timestamp) { … }
AudioCodec CodecIDToAudioCodec(AVCodecID codec_id) { … }
AVCodecID AudioCodecToCodecID(AudioCodec audio_codec,
SampleFormat sample_format) { … }
static VideoCodec CodecIDToVideoCodec(AVCodecID codec_id) { … }
AVCodecID VideoCodecToCodecID(VideoCodec video_codec) { … }
static VideoCodecProfile ProfileIDToVideoCodecProfile(int profile) { … }
static int VideoCodecProfileToProfileID(VideoCodecProfile profile) { … }
SampleFormat AVSampleFormatToSampleFormat(AVSampleFormat sample_format,
AVCodecID codec_id) { … }
static AVSampleFormat SampleFormatToAVSampleFormat(SampleFormat sample_format) { … }
bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context,
EncryptionScheme encryption_scheme,
AudioDecoderConfig* config) { … }
std::unique_ptr<AVCodecContext, ScopedPtrAVFreeContext>
AVStreamToAVCodecContext(const AVStream* stream) { … }
bool AVStreamToAudioDecoderConfig(const AVStream* stream,
AudioDecoderConfig* config) { … }
void AudioDecoderConfigToAVCodecContext(const AudioDecoderConfig& config,
AVCodecContext* codec_context) { … }
bool AVStreamToVideoDecoderConfig(const AVStream* stream,
VideoDecoderConfig* config) { … }
void VideoDecoderConfigToAVCodecContext(
const VideoDecoderConfig& config,
AVCodecContext* codec_context) { … }
ChannelLayout ChannelLayoutToChromeChannelLayout(int64_t layout, int channels) { … }
#if !defined(ARCH_CPU_LITTLE_ENDIAN)
#error The code below assumes little-endianness.
#endif
VideoPixelFormat AVPixelFormatToVideoPixelFormat(AVPixelFormat pixel_format) { … }
std::string AVErrorToString(int errnum) { … }
int32_t HashCodecName(const char* codec_name) { … }
}