1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

I cannot do anything

This commit is contained in:
Nekotekina 2014-03-02 03:50:47 +04:00
parent 4828723d5c
commit 9e62b330b1
6 changed files with 103 additions and 29 deletions

View File

@ -26,6 +26,7 @@ template
> >
class SMutexBase class SMutexBase
{ {
static_assert(sizeof(T) == sizeof(std::atomic<T>), "Invalid SMutexBase type");
std::atomic<T> owner; std::atomic<T> owner;
public: public:

View File

@ -714,13 +714,13 @@ int cellAudioSetNotifyEventQueue(u64 key)
m_config.event_key = key; m_config.event_key = key;
EventQueue* eq; /*EventQueue* eq;
if (!Emu.GetEventManager().GetEventQueue(key, eq)) if (!Emu.GetEventManager().GetEventQueue(key, eq))
{ {
return CELL_AUDIO_ERROR_PARAM; return CELL_AUDIO_ERROR_PARAM;
} }*/
// TODO: connect port // TODO: connect port (?????)
return CELL_OK; return CELL_OK;
} }

View File

@ -167,6 +167,7 @@ u32 dmuxOpen(Demuxer* data)
stream = backup; stream = backup;
continue; continue;
} }
//stream = backup;
es.push(stream, len - pes.size - 3, pes); es.push(stream, len - pes.size - 3, pes);
} }
else else

View File

@ -373,12 +373,11 @@ struct PesHeader
, dts(0xffffffffffffffff) , dts(0xffffffffffffffff)
, ch(0) , ch(0)
, size(0) , size(0)
, new_au(false) , new_au(true)
{ {
u16 header; u16 header;
stream.get(header); stream.get(header);
stream.get(size); stream.get(size);
new_au = true;
if (size) if (size)
{ {
//ConLog.Write(">>>>> Pes Header (size=%d)", size); //ConLog.Write(">>>>> Pes Header (size=%d)", size);

View File

@ -6,6 +6,7 @@
extern "C" extern "C"
{ {
#include "libavcodec\avcodec.h" #include "libavcodec\avcodec.h"
#include "libavformat\avformat.h"
#include "libavutil\imgutils.h" #include "libavutil\imgutils.h"
} }
@ -14,6 +15,29 @@ extern "C"
void cellVdec_init(); void cellVdec_init();
Module cellVdec(0x0005, cellVdec_init); Module cellVdec(0x0005, cellVdec_init);
int vdecRead(void* opaque, u8* buf, int buf_size)
{
VideoDecoder& vdec = *(VideoDecoder*)opaque;
if (vdec.reader.size < (u32)buf_size) buf_size = vdec.reader.size;
if (!buf_size)
{
return AVERROR_EOF;
}
else if (!Memory.CopyToReal(buf, vdec.reader.addr, buf_size))
{
ConLog.Error("vdecRead: data reading failed (buf_size=0x%x)", buf_size);
Emu.Pause();
return 0;
}
else
{
vdec.reader.addr += buf_size;
vdec.reader.size -= buf_size;
return buf_size;
}
}
u32 vdecQueryAttr(CellVdecCodecType type, u32 profile, u32 spec_addr /* may be 0 */, mem_ptr_t<CellVdecAttr> attr) u32 vdecQueryAttr(CellVdecCodecType type, u32 profile, u32 spec_addr /* may be 0 */, mem_ptr_t<CellVdecAttr> attr)
{ {
switch (type) // TODO: check profile levels switch (type) // TODO: check profile levels
@ -98,25 +122,33 @@ u32 vdecOpen(VideoDecoder* data)
{ {
vdecPacket(u32 size) vdecPacket(u32 size)
{ {
av_new_packet(this, size + FF_INPUT_BUFFER_PADDING_SIZE); av_init_packet(this);
data = (u8*)av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
this->size -= FF_INPUT_BUFFER_PADDING_SIZE; // ???????????????????? this->size = size + FF_INPUT_BUFFER_PADDING_SIZE;
} }
~vdecPacket() ~vdecPacket()
{ {
av_free_packet(this); av_free(data);
//av_free_packet(this);
} }
} au(task.size); } au(task.size);
if (task.pts || task.dts) if ((task.pts || task.dts) && task.pts != ~0 && task.dts != ~0)
{ {
vdec.pts = task.pts; vdec.pts = task.pts;
vdec.dts = task.dts; vdec.dts = task.dts;
}
au.pts = vdec.pts; au.pts = vdec.pts;
au.dts = vdec.dts; au.dts = vdec.dts;
au.flags = AV_PKT_FLAG_KEY;
}
else
{
au.pts = vdec.pts;
au.dts = vdec.dts;
}
if (task.mode != CELL_VDEC_DEC_MODE_NORMAL) if (task.mode != CELL_VDEC_DEC_MODE_NORMAL)
{ {
@ -124,16 +156,32 @@ u32 vdecOpen(VideoDecoder* data)
break; break;
} }
vdec.reader.addr = task.addr;
vdec.reader.size = task.size;
if (!Memory.CopyToReal(au.data, task.addr, task.size)) if (!Memory.CopyToReal(au.data, task.addr, task.size))
{ {
ConLog.Error("vdecDecodeAu: AU data accessing failed(addr=0x%x, size=0x%x)", task.addr, task.size); ConLog.Error("vdecDecodeAu: AU data accessing failed(addr=0x%x, size=0x%x)", task.addr, task.size);
break; break;
} }
/*{
wxFile dump;
dump.Open(wxString::Format("0x%llx-0x%llx.dump", au.pts, au.dts), wxFile::write);
dump.Write(au.data, task.size + FF_INPUT_BUFFER_PADDING_SIZE);
dump.Close();
}*/
int got_picture = 0; int got_picture = 0;
//vdec.ctx->flags |= CODEC_FLAG_TRUNCATED; //vdec.ctx->flags |= CODEC_FLAG_TRUNCATED;
//vdec.ctx->flags2 |= CODEC_FLAG2_CHUNKS; //vdec.ctx->flags2 |= CODEC_FLAG2_CHUNKS;
vdec.ctx->flags2 |= CODEC_FLAG2_LOCAL_HEADER;
vdec.ctx->codec_tag = *(u32*)"DAVC";
//vdec.ctx->stream_codec_tag = *(u32*)"DAVC";
//avcodec_get_frame_defaults(vdec.frame);
int decode = avcodec_decode_video2(vdec.ctx, vdec.frame, &got_picture, &au); int decode = avcodec_decode_video2(vdec.ctx, vdec.frame, &got_picture, &au);
if (decode < 0) if (decode < 0)
@ -142,22 +190,10 @@ u32 vdecOpen(VideoDecoder* data)
break; break;
} }
ConLog.Write("Frame decoded (pts=0x%llx, dts=0x%llx, addr=0x%x, result=0x%x)",
au.pts, au.dts, task.addr, decode);
Callback cb;
cb.SetAddr(vdec.cbFunc);
cb.Handle(vdec.id, CELL_VDEC_MSG_TYPE_AUDONE, 0, vdec.cbArg);
cb.Branch(false);
if (got_picture) if (got_picture)
{ {
ConLog.Write("got_picture (%d, vdec: pts=0x%llx, dts=0x%llx)", got_picture, vdec.pts, vdec.dts); ConLog.Write("got_picture (%d, vdec: pts=0x%llx, dts=0x%llx)", got_picture, vdec.pts, vdec.dts);
vdec.pts += 3003;
vdec.dts += 3003;
/*if (vdec.out_data[0]) av_freep(vdec.out_data[0]); /*if (vdec.out_data[0]) av_freep(vdec.out_data[0]);
int err = av_image_alloc(vdec.out_data, vdec.linesize, vdec.ctx->width, vdec.ctx->height, vdec.ctx->pix_fmt, 1); int err = av_image_alloc(vdec.out_data, vdec.linesize, vdec.ctx->width, vdec.ctx->height, vdec.ctx->pix_fmt, 1);
@ -174,8 +210,6 @@ u32 vdecOpen(VideoDecoder* data)
vdec.ctx->pix_fmt, vdec.ctx->width, vdec.ctx->height);*/ vdec.ctx->pix_fmt, vdec.ctx->width, vdec.ctx->height);*/
vdec.buf_size = a128(av_image_get_buffer_size(vdec.ctx->pix_fmt, vdec.ctx->width, vdec.ctx->height, 1)); vdec.buf_size = a128(av_image_get_buffer_size(vdec.ctx->pix_fmt, vdec.ctx->width, vdec.ctx->height, 1));
vdec.dts = task.dts;
vdec.pts = task.pts;
vdec.userdata = task.userData; vdec.userdata = task.userData;
vdec.has_picture = true; vdec.has_picture = true;
@ -184,6 +218,13 @@ u32 vdecOpen(VideoDecoder* data)
cb.Handle(vdec.id, CELL_VDEC_MSG_TYPE_PICOUT, 0, vdec.cbArg); cb.Handle(vdec.id, CELL_VDEC_MSG_TYPE_PICOUT, 0, vdec.cbArg);
cb.Branch(false); cb.Branch(false);
} }
ConLog.Write("Frame decoded (pts=0x%llx, dts=0x%llx, addr=0x%x, result=0x%x)", au.pts, au.dts, task.addr, decode);
Callback cb;
cb.SetAddr(vdec.cbFunc);
cb.Handle(vdec.id, CELL_VDEC_MSG_TYPE_AUDONE, 0, vdec.cbArg);
cb.Branch(false);
} }
break; break;

View File

@ -679,6 +679,8 @@ struct VdecTask
} }
}; };
int vdecRead(void* opaque, u8* buf, int buf_size);
class VideoDecoder class VideoDecoder
{ {
public: public:
@ -689,14 +691,23 @@ public:
AVCodec* codec; AVCodec* codec;
AVCodecContext* ctx; AVCodecContext* ctx;
AVFormatContext* fmt;
AVFrame* frame; AVFrame* frame;
AVDictionary* opts; AVDictionary* opts;
u8* io_buf;
u32 buf_size; u32 buf_size;
u64 pts; u64 pts;
u64 dts; u64 dts;
u64 pos;
u64 userdata; u64 userdata;
volatile bool has_picture; volatile bool has_picture;
struct VideoReader
{
u32 addr;
u32 size;
} reader;
const CellVdecCodecType type; const CellVdecCodecType type;
const u32 profile; const u32 profile;
const u32 memAddr; const u32 memAddr;
@ -714,6 +725,7 @@ public:
, is_finished(false) , is_finished(false)
, is_running(false) , is_running(false)
, has_picture(false) , has_picture(false)
, pos(0)
{ {
codec = avcodec_find_decoder(AV_CODEC_ID_H264); codec = avcodec_find_decoder(AV_CODEC_ID_H264);
if (!codec) if (!codec)
@ -744,12 +756,32 @@ public:
Emu.Pause(); Emu.Pause();
return; return;
} }
fmt = avformat_alloc_context();
if (!fmt)
{
ConLog.Error("VideoDecoder(): avformat_alloc_context failed");
Emu.Pause();
return;
}
io_buf = (u8*)av_malloc(4096);
fmt->pb = avio_alloc_context(io_buf, 4096, 0, this, vdecRead, NULL, NULL);
if (!fmt->pb)
{
ConLog.Error("VideoDecoder(): avio_alloc_context failed");
Emu.Pause();
return;
}
//memset(&out_data, 0, sizeof(out_data)); //memset(&out_data, 0, sizeof(out_data));
//memset(&linesize, 0, sizeof(linesize)); //memset(&linesize, 0, sizeof(linesize));
} }
~VideoDecoder() ~VideoDecoder()
{ {
if (io_buf) av_free(io_buf);
if (fmt)
{
avformat_free_context(fmt);
}
if (frame) av_frame_free(&frame); if (frame) av_frame_free(&frame);
if (ctx) if (ctx)
{ {