This commit is contained in:
Nekotekina 2015-04-12 23:16:30 +03:00
parent ea5110cec3
commit fea6fd1a70
14 changed files with 323 additions and 303 deletions

View file

@ -509,11 +509,14 @@ bool adecCheckType(AudioCodecType type)
return true;
}
int cellAdecQueryAttr(vm::ptr<CellAdecType> type, vm::ptr<CellAdecAttr> attr)
s32 cellAdecQueryAttr(vm::ptr<CellAdecType> type, vm::ptr<CellAdecAttr> attr)
{
cellAdec.Warning("cellAdecQueryAttr(type_addr=0x%x, attr_addr=0x%x)", type.addr(), attr.addr());
cellAdec.Warning("cellAdecQueryAttr(type=*0x%x, attr=*0x%x)", type, attr);
if (!adecCheckType(type->audioCodecType)) return CELL_ADEC_ERROR_ARG;
if (!adecCheckType(type->audioCodecType))
{
return CELL_ADEC_ERROR_ARG;
}
// TODO: check values
attr->adecVerLower = 0x280000; // from dmux
@ -523,36 +526,41 @@ int cellAdecQueryAttr(vm::ptr<CellAdecType> type, vm::ptr<CellAdecAttr> attr)
return CELL_OK;
}
int cellAdecOpen(vm::ptr<CellAdecType> type, vm::ptr<CellAdecResource> res, vm::ptr<CellAdecCb> cb, vm::ptr<u32> handle)
s32 cellAdecOpen(vm::ptr<CellAdecType> type, vm::ptr<CellAdecResource> res, vm::ptr<CellAdecCb> cb, vm::ptr<u32> handle)
{
cellAdec.Warning("cellAdecOpen(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)",
type.addr(), res.addr(), cb.addr(), handle.addr());
cellAdec.Warning("cellAdecOpen(type=*0x%x, res=*0x%x, cb=*0x%x, handle=*0x%x)", type, res, cb, handle);
if (!adecCheckType(type->audioCodecType)) return CELL_ADEC_ERROR_ARG;
if (!adecCheckType(type->audioCodecType))
{
return CELL_ADEC_ERROR_ARG;
}
*handle = adecOpen(new AudioDecoder(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg));
return CELL_OK;
}
int cellAdecOpenEx(vm::ptr<CellAdecType> type, vm::ptr<CellAdecResourceEx> res, vm::ptr<CellAdecCb> cb, vm::ptr<u32> handle)
s32 cellAdecOpenEx(vm::ptr<CellAdecType> type, vm::ptr<CellAdecResourceEx> res, vm::ptr<CellAdecCb> cb, vm::ptr<u32> handle)
{
cellAdec.Warning("cellAdecOpenEx(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)",
type.addr(), res.addr(), cb.addr(), handle.addr());
cellAdec.Warning("cellAdecOpenEx(type=*0x%x, res=*0x%x, cb=*0x%x, handle=*0x%x)", type, res, cb, handle);
if (!adecCheckType(type->audioCodecType)) return CELL_ADEC_ERROR_ARG;
if (!adecCheckType(type->audioCodecType))
{
return CELL_ADEC_ERROR_ARG;
}
*handle = adecOpen(new AudioDecoder(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg));
return CELL_OK;
}
int cellAdecClose(u32 handle)
s32 cellAdecClose(u32 handle)
{
cellAdec.Warning("cellAdecClose(handle=%d)", handle);
std::shared_ptr<AudioDecoder> adec;
if (!Emu.GetIdManager().GetIDData(handle, adec))
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
if (!adec)
{
return CELL_ADEC_ERROR_ARG;
}
@ -575,12 +583,13 @@ int cellAdecClose(u32 handle)
return CELL_OK;
}
int cellAdecStartSeq(u32 handle, u32 param_addr)
s32 cellAdecStartSeq(u32 handle, u32 param)
{
cellAdec.Warning("cellAdecStartSeq(handle=%d, param_addr=0x%x)", handle, param_addr);
cellAdec.Warning("cellAdecStartSeq(handle=%d, param=*0x%x)", handle, param);
std::shared_ptr<AudioDecoder> adec;
if (!Emu.GetIdManager().GetIDData(handle, adec))
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
if (!adec)
{
return CELL_ADEC_ERROR_ARG;
}
@ -594,25 +603,25 @@ int cellAdecStartSeq(u32 handle, u32 param_addr)
case CELL_ADEC_TYPE_ATRACX_6CH:
case CELL_ADEC_TYPE_ATRACX_8CH:
{
auto param = vm::ptr<const CellAdecParamAtracX>::make(param_addr);
const auto atx = vm::ptr<const CellAdecParamAtracX>::make(param);
task.at3p.sample_rate = param->sampling_freq;
task.at3p.channel_config = param->ch_config_idx;
task.at3p.channels = param->nch_out;
task.at3p.frame_size = param->nbytes;
task.at3p.extra_config = param->extra_config_data;
task.at3p.output = param->bw_pcm;
task.at3p.downmix = param->downmix_flag;
task.at3p.ats_header = param->au_includes_ats_hdr_flg;
task.at3p.sample_rate = atx->sampling_freq;
task.at3p.channel_config = atx->ch_config_idx;
task.at3p.channels = atx->nch_out;
task.at3p.frame_size = atx->nbytes;
task.at3p.extra_config = atx->extra_config_data;
task.at3p.output = atx->bw_pcm;
task.at3p.downmix = atx->downmix_flag;
task.at3p.ats_header = atx->au_includes_ats_hdr_flg;
cellAdec.Todo("*** CellAdecParamAtracX: sr=%d, ch_cfg=%d(%d), frame_size=0x%x, extra=0x%x, output=%d, downmix=%d, ats_header=%d",
task.at3p.sample_rate, task.at3p.channel_config, task.at3p.channels, task.at3p.frame_size, (u32&)task.at3p.extra_config, task.at3p.output, task.at3p.downmix, task.at3p.ats_header);
break;
}
case CELL_ADEC_TYPE_MP3:
{
auto param = vm::ptr<const CellAdecParamMP3>::make(param_addr);
const auto mp3 = vm::ptr<const CellAdecParamMP3>::make(param);
cellAdec.Todo("*** CellAdecParamMP3: bw_pcm=%d", param->bw_pcm);
cellAdec.Todo("*** CellAdecParamMP3: bw_pcm=%d", mp3->bw_pcm);
break;
}
default:
@ -627,12 +636,13 @@ int cellAdecStartSeq(u32 handle, u32 param_addr)
return CELL_OK;
}
int cellAdecEndSeq(u32 handle)
s32 cellAdecEndSeq(u32 handle)
{
cellAdec.Warning("cellAdecEndSeq(handle=%d)", handle);
std::shared_ptr<AudioDecoder> adec;
if (!Emu.GetIdManager().GetIDData(handle, adec))
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
if (!adec)
{
return CELL_ADEC_ERROR_ARG;
}
@ -641,12 +651,13 @@ int cellAdecEndSeq(u32 handle)
return CELL_OK;
}
int cellAdecDecodeAu(u32 handle, vm::ptr<CellAdecAuInfo> auInfo)
s32 cellAdecDecodeAu(u32 handle, vm::ptr<CellAdecAuInfo> auInfo)
{
cellAdec.Log("cellAdecDecodeAu(handle=%d, auInfo_addr=0x%x)", handle, auInfo.addr());
cellAdec.Log("cellAdecDecodeAu(handle=%d, auInfo=*0x%x)", handle, auInfo);
std::shared_ptr<AudioDecoder> adec;
if (!Emu.GetIdManager().GetIDData(handle, adec))
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
if (!adec)
{
return CELL_ADEC_ERROR_ARG;
}
@ -663,12 +674,13 @@ int cellAdecDecodeAu(u32 handle, vm::ptr<CellAdecAuInfo> auInfo)
return CELL_OK;
}
int cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
s32 cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
{
cellAdec.Log("cellAdecGetPcm(handle=%d, outBuffer_addr=0x%x)", handle, outBuffer.addr());
cellAdec.Log("cellAdecGetPcm(handle=%d, outBuffer=*0x%x)", handle, outBuffer);
std::shared_ptr<AudioDecoder> adec;
if (!Emu.GetIdManager().GetIDData(handle, adec))
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
if (!adec)
{
return CELL_ADEC_ERROR_ARG;
}
@ -778,12 +790,13 @@ int cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
return CELL_OK;
}
int cellAdecGetPcmItem(u32 handle, vm::ptr<u32> pcmItem_ptr)
s32 cellAdecGetPcmItem(u32 handle, vm::ptr<vm::bptr<CellAdecPcmItem>> pcmItem)
{
cellAdec.Log("cellAdecGetPcmItem(handle=%d, pcmItem_ptr_addr=0x%x)", handle, pcmItem_ptr.addr());
cellAdec.Log("cellAdecGetPcmItem(handle=%d, pcmItem=**0x%x)", handle, pcmItem);
std::shared_ptr<AudioDecoder> adec;
if (!Emu.GetIdManager().GetIDData(handle, adec))
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
if (!adec)
{
return CELL_ADEC_ERROR_ARG;
}
@ -797,7 +810,7 @@ int cellAdecGetPcmItem(u32 handle, vm::ptr<u32> pcmItem_ptr)
AVFrame* frame = af.data;
auto pcm = vm::ptr<CellAdecPcmItem>::make(adec->memAddr + adec->memBias);
const auto pcm = vm::ptr<CellAdecPcmItem>::make(adec->memAddr + adec->memBias);
adec->memBias += 512;
if (adec->memBias + 512 > adec->memSize)
@ -852,7 +865,7 @@ int cellAdecGetPcmItem(u32 handle, vm::ptr<u32> pcmItem_ptr)
memset(mp3.get_ptr(), 0, sizeof(CellAdecMP3Info));
}
*pcmItem_ptr = pcm.addr();
*pcmItem = pcm;
return CELL_OK;
}