forked from suyu/suyu
codec: Replace deprecated av_init_packet usage
This commit is contained in:
parent
0be4e402e2
commit
356e10898f
1 changed files with 13 additions and 9 deletions
|
@ -134,9 +134,8 @@ void Codec::Initialize() {
|
||||||
if (!av_codec_ctx->hw_device_ctx) {
|
if (!av_codec_ctx->hw_device_ctx) {
|
||||||
LOG_INFO(Service_NVDRV, "Using FFmpeg software decoding");
|
LOG_INFO(Service_NVDRV, "Using FFmpeg software decoding");
|
||||||
}
|
}
|
||||||
const auto av_error = avcodec_open2(av_codec_ctx, av_codec, nullptr);
|
if (const int res = avcodec_open2(av_codec_ctx, av_codec, nullptr); res < 0) {
|
||||||
if (av_error < 0) {
|
LOG_ERROR(Service_NVDRV, "avcodec_open2() Failed with result {}", res);
|
||||||
LOG_ERROR(Service_NVDRV, "avcodec_open2() Failed.");
|
|
||||||
avcodec_close(av_codec_ctx);
|
avcodec_close(av_codec_ctx);
|
||||||
av_buffer_unref(&av_gpu_decoder);
|
av_buffer_unref(&av_gpu_decoder);
|
||||||
return;
|
return;
|
||||||
|
@ -164,12 +163,17 @@ void Codec::Decode() {
|
||||||
frame_data = vp9_decoder->ComposeFrameHeader(state);
|
frame_data = vp9_decoder->ComposeFrameHeader(state);
|
||||||
vp9_hidden_frame = vp9_decoder->WasFrameHidden();
|
vp9_hidden_frame = vp9_decoder->WasFrameHidden();
|
||||||
}
|
}
|
||||||
AVPacket packet{};
|
AVPacket* packet = av_packet_alloc();
|
||||||
av_init_packet(&packet);
|
if (!packet) {
|
||||||
packet.data = frame_data.data();
|
LOG_ERROR(Service_NVDRV, "av_packet_alloc failed");
|
||||||
packet.size = static_cast<s32>(frame_data.size());
|
return;
|
||||||
if (const int ret = avcodec_send_packet(av_codec_ctx, &packet); ret) {
|
}
|
||||||
LOG_DEBUG(Service_NVDRV, "avcodec_send_packet error {}", ret);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
// Only receive/store visible frames
|
// Only receive/store visible frames
|
||||||
|
|
Loading…
Reference in a new issue