зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1211335: Have FFMpegDecoderModule properly return if a codec is supported. r=cpearce
This commit is contained in:
Родитель
a02b64b149
Коммит
9861c50a98
|
@ -70,24 +70,16 @@ ChoosePixelFormat(AVCodecContext* aCodecContext, const PixelFormat* aFormats)
|
|||
nsresult
|
||||
FFmpegDataDecoder<LIBAV_VER>::InitDecoder()
|
||||
{
|
||||
StaticMutexAutoLock mon(sMonitor);
|
||||
|
||||
FFMPEG_LOG("Initialising FFmpeg decoder.");
|
||||
|
||||
if (!sFFmpegInitDone) {
|
||||
avcodec_register_all();
|
||||
#ifdef DEBUG
|
||||
av_log_set_level(AV_LOG_DEBUG);
|
||||
#endif
|
||||
sFFmpegInitDone = true;
|
||||
}
|
||||
|
||||
AVCodec* codec = avcodec_find_decoder(mCodecID);
|
||||
AVCodec* codec = FindAVCodec(mCodecID);
|
||||
if (!codec) {
|
||||
NS_WARNING("Couldn't find ffmpeg decoder");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
StaticMutexAutoLock mon(sMonitor);
|
||||
|
||||
if (!(mCodecContext = avcodec_alloc_context3(codec))) {
|
||||
NS_WARNING("Couldn't init ffmpeg context");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -240,4 +232,18 @@ FFmpegDataDecoder<LIBAV_VER>::PrepareFrame()
|
|||
return mFrame;
|
||||
}
|
||||
|
||||
/* static */ AVCodec*
|
||||
FFmpegDataDecoder<LIBAV_VER>::FindAVCodec(AVCodecID aCodec)
|
||||
{
|
||||
StaticMutexAutoLock mon(sMonitor);
|
||||
if (!sFFmpegInitDone) {
|
||||
avcodec_register_all();
|
||||
#ifdef DEBUG
|
||||
av_log_set_level(AV_LOG_DEBUG);
|
||||
#endif
|
||||
sFFmpegInitDone = true;
|
||||
}
|
||||
return avcodec_find_decoder(aCodec);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
nsresult Drain() override;
|
||||
nsresult Shutdown() override;
|
||||
|
||||
static AVCodec* FindAVCodec(AVCodecID aCodec);
|
||||
|
||||
protected:
|
||||
// Flush and Drain operation, always run
|
||||
virtual void ProcessFlush();
|
||||
|
|
|
@ -68,8 +68,13 @@ public:
|
|||
|
||||
bool SupportsMimeType(const nsACString& aMimeType) override
|
||||
{
|
||||
return FFmpegAudioDecoder<V>::GetCodecId(aMimeType) != AV_CODEC_ID_NONE ||
|
||||
FFmpegH264Decoder<V>::GetCodecId(aMimeType) != AV_CODEC_ID_NONE;
|
||||
AVCodecID audioCodec = FFmpegAudioDecoder<V>::GetCodecId(aMimeType);
|
||||
AVCodecID videoCodec = FFmpegH264Decoder<V>::GetCodecId(aMimeType);
|
||||
if (audioCodec == AV_CODEC_ID_NONE && videoCodec == AV_CODEC_ID_NONE) {
|
||||
return false;
|
||||
}
|
||||
AVCodecID codec = audioCodec != AV_CODEC_ID_NONE ? audioCodec : videoCodec;
|
||||
return !!FFmpegDataDecoder<V>::FindAVCodec(codec);
|
||||
}
|
||||
|
||||
ConversionRequired
|
||||
|
|
Загрузка…
Ссылка в новой задаче