mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-21 22:57:31 +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();
|
mCodecContext->extradata_size = mExtraData->Length();
|
||||||
// FFmpeg may use SIMD instructions to access the data which reads the
|
// 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.
|
// 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);
|
mExtraData->AppendElements(FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
#endif
|
||||||
mCodecContext->extradata = mExtraData->Elements();
|
mCodecContext->extradata = mExtraData->Elements();
|
||||||
} else {
|
} else {
|
||||||
mCodecContext->extradata_size = 0;
|
mCodecContext->extradata_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR < 57
|
||||||
if (codec->capabilities & CODEC_CAP_DR1) {
|
if (codec->capabilities & CODEC_CAP_DR1) {
|
||||||
mCodecContext->flags |= CODEC_FLAG_EMU_EDGE;
|
mCodecContext->flags |= CODEC_FLAG_EMU_EDGE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (mLib->avcodec_open2(mCodecContext, codec, nullptr) < 0) {
|
if (mLib->avcodec_open2(mCodecContext, codec, nullptr) < 0) {
|
||||||
NS_WARNING("Couldn't initialise ffmpeg decoder");
|
NS_WARNING("Couldn't initialise ffmpeg decoder");
|
||||||
|
|
|
||||||
|
|
@ -69,12 +69,14 @@ FFmpegLibWrapper::Link()
|
||||||
AV_FUNC_55 = 1 << 2,
|
AV_FUNC_55 = 1 << 2,
|
||||||
AV_FUNC_56 = 1 << 3,
|
AV_FUNC_56 = 1 << 3,
|
||||||
AV_FUNC_57 = 1 << 4,
|
AV_FUNC_57 = 1 << 4,
|
||||||
|
AV_FUNC_58 = 1 << 5,
|
||||||
AV_FUNC_AVUTIL_53 = AV_FUNC_53 | AV_FUNC_AVUTIL_MASK,
|
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_54 = AV_FUNC_54 | AV_FUNC_AVUTIL_MASK,
|
||||||
AV_FUNC_AVUTIL_55 = AV_FUNC_55 | 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_56 = AV_FUNC_56 | AV_FUNC_AVUTIL_MASK,
|
||||||
AV_FUNC_AVUTIL_57 = AV_FUNC_57 | 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
|
AV_FUNC_AVUTIL_ALL = AV_FUNC_AVCODEC_ALL | AV_FUNC_AVUTIL_MASK
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -94,6 +96,9 @@ FFmpegLibWrapper::Link()
|
||||||
case 57:
|
case 57:
|
||||||
version = AV_FUNC_57;
|
version = AV_FUNC_57;
|
||||||
break;
|
break;
|
||||||
|
case 58:
|
||||||
|
version = AV_FUNC_58;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
FFMPEG_LOG("Unknown avcodec version");
|
FFMPEG_LOG("Unknown avcodec version");
|
||||||
Unlink();
|
Unlink();
|
||||||
|
|
@ -142,9 +147,9 @@ FFmpegLibWrapper::Link()
|
||||||
AV_FUNC(av_log_set_level, AV_FUNC_AVUTIL_ALL)
|
AV_FUNC(av_log_set_level, AV_FUNC_AVUTIL_ALL)
|
||||||
AV_FUNC(av_malloc, AV_FUNC_AVUTIL_ALL)
|
AV_FUNC(av_malloc, AV_FUNC_AVUTIL_ALL)
|
||||||
AV_FUNC(av_freep, 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_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(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(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)
|
AV_FUNC_OPTION(av_frame_get_colorspace, AV_FUNC_AVUTIL_ALL)
|
||||||
#undef AV_FUNC
|
#undef AV_FUNC
|
||||||
#undef AV_FUNC_OPTION
|
#undef AV_FUNC_OPTION
|
||||||
|
|
@ -175,4 +180,4 @@ FFmpegLibWrapper::Unlink()
|
||||||
PodZero(this);
|
PodZero(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,15 @@ static FFmpegLibWrapper sLibAV;
|
||||||
|
|
||||||
static const char* sLibs[] = {
|
static const char* sLibs[] = {
|
||||||
#if defined(XP_DARWIN)
|
#if defined(XP_DARWIN)
|
||||||
|
"libavcodec.58.dylib",
|
||||||
"libavcodec.57.dylib",
|
"libavcodec.57.dylib",
|
||||||
"libavcodec.56.dylib",
|
"libavcodec.56.dylib",
|
||||||
"libavcodec.55.dylib",
|
"libavcodec.55.dylib",
|
||||||
"libavcodec.54.dylib",
|
"libavcodec.54.dylib",
|
||||||
"libavcodec.53.dylib",
|
"libavcodec.53.dylib",
|
||||||
#else
|
#else
|
||||||
|
"libavcodec.so.58",
|
||||||
|
"libavcodec-ffmpeg.so.58",
|
||||||
"libavcodec-ffmpeg.so.57",
|
"libavcodec-ffmpeg.so.57",
|
||||||
"libavcodec-ffmpeg.so.56",
|
"libavcodec-ffmpeg.so.56",
|
||||||
"libavcodec.so.57",
|
"libavcodec.so.57",
|
||||||
|
|
@ -134,6 +137,7 @@ FFmpegRuntimeLinker::CreateDecoderModule()
|
||||||
case 55:
|
case 55:
|
||||||
case 56: module = FFmpegDecoderModule<55>::Create(&sLibAV); break;
|
case 56: module = FFmpegDecoderModule<55>::Create(&sLibAV); break;
|
||||||
case 57: module = FFmpegDecoderModule<57>::Create(&sLibAV); break;
|
case 57: module = FFmpegDecoderModule<57>::Create(&sLibAV); break;
|
||||||
|
case 58: module = FFmpegDecoderModule<58>::Create(&sLibAV); break;
|
||||||
default: module = nullptr;
|
default: module = nullptr;
|
||||||
}
|
}
|
||||||
return module.forget();
|
return module.forget();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue