CDImage: Support SBI replacement subchannel Q for cue/bin images
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
#include "YBaseLib/Log.h"
|
||||
#include "cd_image.h"
|
||||
#include "cd_subchannel_replacement.h"
|
||||
#include <libcue/libcue.h>
|
||||
#include <map>
|
||||
Log_SetChannel(CDImageCueSheet);
|
||||
@ -12,9 +13,12 @@ public:
|
||||
|
||||
bool OpenAndParse(const char* filename);
|
||||
|
||||
bool ReadSubChannelQ(SubChannelQ* subq) override;
|
||||
|
||||
private:
|
||||
Cd* m_cd = nullptr;
|
||||
std::map<std::string, std::FILE*> m_files;
|
||||
CDSubChannelReplacement m_sbi;
|
||||
};
|
||||
|
||||
CDImageCueSheet::CDImageCueSheet() = default;
|
||||
@ -44,6 +48,17 @@ static std::string GetPathDirectory(const char* path)
|
||||
return str;
|
||||
}
|
||||
|
||||
static std::string ReplaceExtension(std::string_view path, std::string_view new_extension)
|
||||
{
|
||||
std::string_view::size_type pos = path.rfind('.');
|
||||
if (pos == std::string::npos)
|
||||
return std::string(path);
|
||||
|
||||
std::string ret(path, 0, pos + 1);
|
||||
ret.append(new_extension);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CDImageCueSheet::OpenAndParse(const char* filename)
|
||||
{
|
||||
std::FILE* cue_fp = std::fopen(filename, "rb");
|
||||
@ -202,9 +217,20 @@ bool CDImageCueSheet::OpenAndParse(const char* filename)
|
||||
}
|
||||
|
||||
m_lba_count = disc_lba;
|
||||
|
||||
m_sbi.LoadSBI(ReplaceExtension(filename, "sbi").c_str());
|
||||
|
||||
return Seek(1, Position{0, 0, 0});
|
||||
}
|
||||
|
||||
bool CDImageCueSheet::ReadSubChannelQ(SubChannelQ* subq)
|
||||
{
|
||||
if (m_sbi.GetReplacementSubChannelQ(m_position_on_disc, subq->data))
|
||||
return true;
|
||||
|
||||
return CDImage::ReadSubChannelQ(subq);
|
||||
}
|
||||
|
||||
std::unique_ptr<CDImage> CDImage::OpenCueSheetImage(const char* filename)
|
||||
{
|
||||
std::unique_ptr<CDImageCueSheet> image = std::make_unique<CDImageCueSheet>();
|
||||
|
||||
Reference in New Issue
Block a user