ffmpeg: update cellAtracXDec to ffmpeg 7

This commit is contained in:
Megamouse
2025-10-14 20:30:53 +02:00
parent e5848f4731
commit a053abfba4
2 changed files with 39 additions and 33 deletions
+35 -29
View File
@@ -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;
+4 -4
View File
@@ -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.