From a053abfba47984b7e367df8e4bf12d96d1c6e61f Mon Sep 17 00:00:00 2001 From: Megamouse Date: Tue, 14 Oct 2025 20:30:53 +0200 Subject: [PATCH] ffmpeg: update cellAtracXDec to ffmpeg 7 --- rpcs3/Emu/Cell/Modules/cellAtracXdec.cpp | 64 +++++++++++++----------- rpcs3/Emu/Cell/Modules/cellAtracXdec.h | 8 +-- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellAtracXdec.cpp b/rpcs3/Emu/Cell/Modules/cellAtracXdec.cpp index 36228d8a5e..c55cf7b60f 100644 --- a/rpcs3/Emu/Cell/Modules/cellAtracXdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAtracXdec.cpp @@ -111,7 +111,41 @@ void AtracXdecDecoder::alloc_avcodec() fmt::throw_exception("avcodec_find_decoder() failed"); } - ensure(!(codec->capabilities & AV_CODEC_CAP_SUBFRAMES)); + packet = av_packet_alloc(); + if (!packet) + { + fmt::throw_exception("av_packet_alloc() failed"); + } + + frame = av_frame_alloc(); + if (!frame) + { + fmt::throw_exception("av_frame_alloc() failed"); + } +} + +void AtracXdecDecoder::free_avcodec() +{ + if (packet) + { + av_packet_free(&packet); + } + if (frame) + { + av_frame_free(&frame); + } + if (ctx) + { + avcodec_free_context(&ctx); + } +} + +void AtracXdecDecoder::init_avcodec() +{ + if (ctx) + { + avcodec_free_context(&ctx); + } ctx = avcodec_alloc_context3(codec); if (!ctx) @@ -133,34 +167,6 @@ void AtracXdecDecoder::alloc_avcodec() frame->buf[0] = av_buffer_create(frame->data[0], ATXDEC_SAMPLES_PER_FRAME * sizeof(f32) * frame->ch_layout.nb_channels, [](void*, uint8_t*){}, nullptr, 0); return 0; }; - - packet = av_packet_alloc(); - if (!packet) - { - fmt::throw_exception("av_packet_alloc() failed"); - } - - frame = av_frame_alloc(); - if (!frame) - { - fmt::throw_exception("av_frame_alloc() failed"); - } -} - -void AtracXdecDecoder::free_avcodec() -{ - av_packet_free(&packet); - av_frame_free(&frame); - avcodec_free_context(&ctx); -} - -void AtracXdecDecoder::init_avcodec() -{ - if (int err = avcodec_close(ctx); err) - { - fmt::throw_exception("avcodec_close() failed (err=0x%x='%s')", err, utils::av_error_to_string(err)); - } - ctx->block_align = nbytes; ctx->ch_layout.nb_channels = nch_in; ctx->sample_rate = sampling_freq; diff --git a/rpcs3/Emu/Cell/Modules/cellAtracXdec.h b/rpcs3/Emu/Cell/Modules/cellAtracXdec.h index a670a242c2..7fc5e49956 100644 --- a/rpcs3/Emu/Cell/Modules/cellAtracXdec.h +++ b/rpcs3/Emu/Cell/Modules/cellAtracXdec.h @@ -192,10 +192,10 @@ struct AtracXdecDecoder // HLE exclusive b8 config_is_set = false; // For savestates - const AVCodec* codec; - AVCodecContext* ctx; - AVPacket* packet; - AVFrame* frame; + const AVCodec* codec = nullptr; + AVCodecContext* ctx = nullptr; + AVPacket* packet = nullptr; + AVFrame* frame = nullptr; u8 spurs_stuff[84]; // 120 bytes on LLE, pointers to CellSpurs, CellSpursTaskset, etc.