summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-08-07 21:31:14 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-08-12 07:28:01 +0200
commit356e10898f47aec113e45962ee3480353dadf3bc (patch)
treed8f73667ce5f30b0c1f74630e30cf41d3822eaa5
parentcmake: Always find LIBVA, update windows FFmpeg version (diff)
downloadyuzu-356e10898f47aec113e45962ee3480353dadf3bc.tar
yuzu-356e10898f47aec113e45962ee3480353dadf3bc.tar.gz
yuzu-356e10898f47aec113e45962ee3480353dadf3bc.tar.bz2
yuzu-356e10898f47aec113e45962ee3480353dadf3bc.tar.lz
yuzu-356e10898f47aec113e45962ee3480353dadf3bc.tar.xz
yuzu-356e10898f47aec113e45962ee3480353dadf3bc.tar.zst
yuzu-356e10898f47aec113e45962ee3480353dadf3bc.zip
-rw-r--r--src/video_core/command_classes/codecs/codec.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/video_core/command_classes/codecs/codec.cpp b/src/video_core/command_classes/codecs/codec.cpp
index e4ee63e31..0ad6162ca 100644
--- a/src/video_core/command_classes/codecs/codec.cpp
+++ b/src/video_core/command_classes/codecs/codec.cpp
@@ -134,9 +134,8 @@ void Codec::Initialize() {
if (!av_codec_ctx->hw_device_ctx) {
LOG_INFO(Service_NVDRV, "Using FFmpeg software decoding");
}
- const auto av_error = avcodec_open2(av_codec_ctx, av_codec, nullptr);
- if (av_error < 0) {
- LOG_ERROR(Service_NVDRV, "avcodec_open2() Failed.");
+ if (const int res = avcodec_open2(av_codec_ctx, av_codec, nullptr); res < 0) {
+ LOG_ERROR(Service_NVDRV, "avcodec_open2() Failed with result {}", res);
avcodec_close(av_codec_ctx);
av_buffer_unref(&av_gpu_decoder);
return;
@@ -164,12 +163,17 @@ void Codec::Decode() {
frame_data = vp9_decoder->ComposeFrameHeader(state);
vp9_hidden_frame = vp9_decoder->WasFrameHidden();
}
- AVPacket packet{};
- av_init_packet(&packet);
- packet.data = frame_data.data();
- packet.size = static_cast<s32>(frame_data.size());
- if (const int ret = avcodec_send_packet(av_codec_ctx, &packet); ret) {
- LOG_DEBUG(Service_NVDRV, "avcodec_send_packet error {}", ret);
+ AVPacket* packet = av_packet_alloc();
+ if (!packet) {
+ LOG_ERROR(Service_NVDRV, "av_packet_alloc failed");
+ return;
+ }
+ packet->data = frame_data.data();
+ packet->size = static_cast<s32>(frame_data.size());
+ const int send_pkt_ret = avcodec_send_packet(av_codec_ctx, packet);
+ av_packet_free(&packet);
+ if (send_pkt_ret != 0) {
+ LOG_DEBUG(Service_NVDRV, "avcodec_send_packet error {}", send_pkt_ret);
return;
}
// Only receive/store visible frames