summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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() {
134 if (!av_codec_ctx->hw_device_ctx) { 134 if (!av_codec_ctx->hw_device_ctx) {
135 LOG_INFO(Service_NVDRV, "Using FFmpeg software decoding"); 135 LOG_INFO(Service_NVDRV, "Using FFmpeg software decoding");
136 } 136 }
137 const auto av_error = avcodec_open2(av_codec_ctx, av_codec, nullptr); 137 if (const int res = avcodec_open2(av_codec_ctx, av_codec, nullptr); res < 0) {
138 if (av_error < 0) { 138 LOG_ERROR(Service_NVDRV, "avcodec_open2() Failed with result {}", res);
139 LOG_ERROR(Service_NVDRV, "avcodec_open2() Failed.");
140 avcodec_close(av_codec_ctx); 139 avcodec_close(av_codec_ctx);
141 av_buffer_unref(&av_gpu_decoder); 140 av_buffer_unref(&av_gpu_decoder);
142 return; 141 return;
@@ -164,12 +163,17 @@ void Codec::Decode() {
164 frame_data = vp9_decoder->ComposeFrameHeader(state); 163 frame_data = vp9_decoder->ComposeFrameHeader(state);
165 vp9_hidden_frame = vp9_decoder->WasFrameHidden(); 164 vp9_hidden_frame = vp9_decoder->WasFrameHidden();
166 } 165 }
167 AVPacket packet{}; 166 AVPacket* packet = av_packet_alloc();
168 av_init_packet(&packet); 167 if (!packet) {
169 packet.data = frame_data.data(); 168 LOG_ERROR(Service_NVDRV, "av_packet_alloc failed");
170 packet.size = static_cast<s32>(frame_data.size()); 169 return;
171 if (const int ret = avcodec_send_packet(av_codec_ctx, &packet); ret) { 170 }
172 LOG_DEBUG(Service_NVDRV, "avcodec_send_packet error {}", ret); 171 packet->data = frame_data.data();
172 packet->size = static_cast<s32>(frame_data.size());
173 const int send_pkt_ret = avcodec_send_packet(av_codec_ctx, packet);
174 av_packet_free(&packet);
175 if (send_pkt_ret != 0) {
176 LOG_DEBUG(Service_NVDRV, "avcodec_send_packet error {}", send_pkt_ret);
173 return; 177 return;
174 } 178 }
175 // Only receive/store visible frames 179 // Only receive/store visible frames