mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 23:38:38 +09:00
Add support for libavcodec 58/FFmpeg 4.0
This commit is contained in:
parent
e44a157583
commit
d87cc84005
3 changed files with 20 additions and 5 deletions
|
|
@ -69,15 +69,21 @@ FFmpegDataDecoder<LIBAV_VER>::InitDecoder()
|
|||
mCodecContext->extradata_size = mExtraData->Length();
|
||||
// FFmpeg may use SIMD instructions to access the data which reads the
|
||||
// data in 32 bytes block. Must ensure we have enough data to read.
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 58
|
||||
mExtraData->AppendElements(AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
#else
|
||||
mExtraData->AppendElements(FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
#endif
|
||||
mCodecContext->extradata = mExtraData->Elements();
|
||||
} else {
|
||||
mCodecContext->extradata_size = 0;
|
||||
}
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 57
|
||||
if (codec->capabilities & CODEC_CAP_DR1) {
|
||||
mCodecContext->flags |= CODEC_FLAG_EMU_EDGE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mLib->avcodec_open2(mCodecContext, codec, nullptr) < 0) {
|
||||
NS_WARNING("Couldn't initialise ffmpeg decoder");
|
||||
|
|
|
|||
|
|
@ -69,12 +69,14 @@ FFmpegLibWrapper::Link()
|
|||
AV_FUNC_55 = 1 << 2,
|
||||
AV_FUNC_56 = 1 << 3,
|
||||
AV_FUNC_57 = 1 << 4,
|
||||
AV_FUNC_58 = 1 << 5,
|
||||
AV_FUNC_AVUTIL_53 = AV_FUNC_53 | AV_FUNC_AVUTIL_MASK,
|
||||
AV_FUNC_AVUTIL_54 = AV_FUNC_54 | AV_FUNC_AVUTIL_MASK,
|
||||
AV_FUNC_AVUTIL_55 = AV_FUNC_55 | AV_FUNC_AVUTIL_MASK,
|
||||
AV_FUNC_AVUTIL_56 = AV_FUNC_56 | AV_FUNC_AVUTIL_MASK,
|
||||
AV_FUNC_AVUTIL_57 = AV_FUNC_57 | AV_FUNC_AVUTIL_MASK,
|
||||
AV_FUNC_AVCODEC_ALL = AV_FUNC_53 | AV_FUNC_54 | AV_FUNC_55 | AV_FUNC_56 | AV_FUNC_57,
|
||||
AV_FUNC_AVUTIL_58 = AV_FUNC_58 | AV_FUNC_AVUTIL_MASK,
|
||||
AV_FUNC_AVCODEC_ALL = AV_FUNC_53 | AV_FUNC_54 | AV_FUNC_55 | AV_FUNC_56 | AV_FUNC_57 | AV_FUNC_58,
|
||||
AV_FUNC_AVUTIL_ALL = AV_FUNC_AVCODEC_ALL | AV_FUNC_AVUTIL_MASK
|
||||
};
|
||||
|
||||
|
|
@ -94,6 +96,9 @@ FFmpegLibWrapper::Link()
|
|||
case 57:
|
||||
version = AV_FUNC_57;
|
||||
break;
|
||||
case 58:
|
||||
version = AV_FUNC_58;
|
||||
break;
|
||||
default:
|
||||
FFMPEG_LOG("Unknown avcodec version");
|
||||
Unlink();
|
||||
|
|
@ -142,9 +147,9 @@ FFmpegLibWrapper::Link()
|
|||
AV_FUNC(av_log_set_level, AV_FUNC_AVUTIL_ALL)
|
||||
AV_FUNC(av_malloc, AV_FUNC_AVUTIL_ALL)
|
||||
AV_FUNC(av_freep, AV_FUNC_AVUTIL_ALL)
|
||||
AV_FUNC(av_frame_alloc, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57))
|
||||
AV_FUNC(av_frame_free, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57))
|
||||
AV_FUNC(av_frame_unref, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57))
|
||||
AV_FUNC(av_frame_alloc, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
|
||||
AV_FUNC(av_frame_free, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
|
||||
AV_FUNC(av_frame_unref, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
|
||||
AV_FUNC_OPTION(av_frame_get_colorspace, AV_FUNC_AVUTIL_ALL)
|
||||
#undef AV_FUNC
|
||||
#undef AV_FUNC_OPTION
|
||||
|
|
@ -175,4 +180,4 @@ FFmpegLibWrapper::Unlink()
|
|||
PodZero(this);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla
|
||||
|
|
|
|||
|
|
@ -27,12 +27,15 @@ static FFmpegLibWrapper sLibAV;
|
|||
|
||||
static const char* sLibs[] = {
|
||||
#if defined(XP_DARWIN)
|
||||
"libavcodec.58.dylib",
|
||||
"libavcodec.57.dylib",
|
||||
"libavcodec.56.dylib",
|
||||
"libavcodec.55.dylib",
|
||||
"libavcodec.54.dylib",
|
||||
"libavcodec.53.dylib",
|
||||
#else
|
||||
"libavcodec.so.58",
|
||||
"libavcodec-ffmpeg.so.58",
|
||||
"libavcodec-ffmpeg.so.57",
|
||||
"libavcodec-ffmpeg.so.56",
|
||||
"libavcodec.so.57",
|
||||
|
|
@ -134,6 +137,7 @@ FFmpegRuntimeLinker::CreateDecoderModule()
|
|||
case 55:
|
||||
case 56: module = FFmpegDecoderModule<55>::Create(&sLibAV); break;
|
||||
case 57: module = FFmpegDecoderModule<57>::Create(&sLibAV); break;
|
||||
case 58: module = FFmpegDecoderModule<58>::Create(&sLibAV); break;
|
||||
default: module = nullptr;
|
||||
}
|
||||
return module.forget();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue