mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Clear hw_device_ctx in AVCodecContext.
This commit is contained in:
parent
acd76fc97b
commit
bfe47a1ba2
1 changed files with 8 additions and 3 deletions
|
@ -86,6 +86,8 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool InitHw(AVCodecContext *context, AVHWDeviceType type) {
|
[[nodiscard]] bool InitHw(AVCodecContext *context, AVHWDeviceType type) {
|
||||||
|
AVCodecContext *parent = static_cast<AVCodecContext*>(context->opaque);
|
||||||
|
|
||||||
auto hwDeviceContext = (AVBufferRef*)nullptr;
|
auto hwDeviceContext = (AVBufferRef*)nullptr;
|
||||||
AvErrorWrap error = av_hwdevice_ctx_create(
|
AvErrorWrap error = av_hwdevice_ctx_create(
|
||||||
&hwDeviceContext,
|
&hwDeviceContext,
|
||||||
|
@ -101,11 +103,13 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) {
|
||||||
"Trying \"%1\" hardware acceleration for \"%2\" decoder."
|
"Trying \"%1\" hardware acceleration for \"%2\" decoder."
|
||||||
).arg(av_hwdevice_get_type_name(type)
|
).arg(av_hwdevice_get_type_name(type)
|
||||||
).arg(context->codec->name));
|
).arg(context->codec->name));
|
||||||
if (context->hw_device_ctx) {
|
if (parent->hw_device_ctx) {
|
||||||
av_buffer_unref(&context->hw_device_ctx);
|
av_buffer_unref(&parent->hw_device_ctx);
|
||||||
}
|
}
|
||||||
context->hw_device_ctx = av_buffer_ref(hwDeviceContext);
|
parent->hw_device_ctx = av_buffer_ref(hwDeviceContext);
|
||||||
av_buffer_unref(&hwDeviceContext);
|
av_buffer_unref(&hwDeviceContext);
|
||||||
|
|
||||||
|
context->hw_device_ctx = parent->hw_device_ctx;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,6 +298,7 @@ CodecPointer MakeCodecPointer(CodecDescriptor descriptor) {
|
||||||
|
|
||||||
if (descriptor.hwAllowed) {
|
if (descriptor.hwAllowed) {
|
||||||
context->get_format = GetHwFormat;
|
context->get_format = GetHwFormat;
|
||||||
|
context->opaque = context;
|
||||||
} else {
|
} else {
|
||||||
DEBUG_LOG(("Video Info: Using software \"%2\" decoder."
|
DEBUG_LOG(("Video Info: Using software \"%2\" decoder."
|
||||||
).arg(codec->name));
|
).arg(codec->name));
|
||||||
|
|
Loading…
Add table
Reference in a new issue