video play and audio work, but framerate is terrible

master
lerabot 4 years ago
parent 197611b6f0
commit cab179ca09
  1. BIN
      1ST_READ.BIN
  2. 2
      Makefile
  3. 131
      README
  4. 14153
      cdi4dc.log
  5. 21
      dreamroq-player.c
  6. BIN
      dreamroq-player.elf
  7. 4
      dreamroqlib.c
  8. BIN
      id_soft.roq
  9. BIN
      output.bin

Binary file not shown.

@ -39,6 +39,8 @@ cd: $(TARGET)
@mkisofs -C 0,11702 -V Reaperi_Cycle -G $(KOS_BASE)/IP.BIN -r -J -l -m '*.o' -o ../$(PROJECT_NAME).iso $(DIR)
@$(KOS_BASE)/utils/cdi4dc/cdi4dc ../$(PROJECT_NAME).iso ../$(PROJECT_NAME).cdi -d > cdi4dc.log
../redream ../$(PROJECT_NAME).cdi
#sudo arp -s 192.168.0.99 00:d0:f1:03:14:02
#sudo ../dc-tool-ip -t dreamcast -c ./ -x dreamroq-player.elf
dist:
rm -f $(OBJS) romdisk.o romdisk.img

131
README

@ -0,0 +1,131 @@
Dreamroq by Mike Melanson (mike -at- multimedia.cx)
R2 update by Josh Pearson ([email protected])
Original topic [here](http://dcemulation.org/phpBB/viewtopic.php?f=29&t=100995&hilit=dreamroq&start=20)
Introduction
============
Dreamroq is a RoQ playback library designed for the Sega Dreamcast video
game console.
RoQ is a relatively simple video file format developed for video-heavy
CD-ROM games. Read more about the format here:
http://wiki.multimedia.cx/index.php?title=RoQ
The Dreamroq library includes a player component that is designed to run
under the KallistiOS (KOS) open source operating system. Read more about
KOS at:
http://gamedev.allusion.net/softprj/kos/
The library also includes a sample testing utility that can be built
and executed on Unix systems. This utility is useful for debugging and
validation.
RoQ sample files can be found at:
http://samples.mplayerhq.hu/game-formats/idroq/
RoQ files can also be created using the Switchblade encoder:
http://icculus.org/~riot/
A version of Switchblade is also included in FFmpeg and many derivative
programs:
http://ffmpeg.org/
License
=======
Dreamroq is meant to be license-compatible with the rest of the KallistiOS
operating system, which is a BSD-style open source license. You can read
the specific text in LICENSE.KOS.
Building (Unix)
===============
To build and test on Linux/Mac OS X/Cygwin, simply type:
make
in the source directory. This will build the executable test-dreamroq. This
utility has the following usage:
./test-dreamroq <file.roq>
This will decode the RoQ file from the command line into a series of PNM
files in the current working directory (watch out-- this could take up a
lot of disk space).
Building (KOS)
==============
There are 2 Makefiles included with Dreamroq. The first -- implicitly
invoked when running a bare 'make' command as seen in the "Building (Unix)"
section -- builds the test utility. The second Makefile is Makefile.KOS,
invoked with:
make -f Makefile.KOS
This is a standard KOS Makefile which assumes that a KOS build environment
is available. This is covered in the KOS documentation. This step will
build a file named dreamroq-player.elf which can be loaded onto a Dreamcast
console via standard means (also outside the scope of this document).
The file dreamcast-player.c contains a hardcoded RoQ file path in its
main function. It is best if this points to a file burned on an optical
disc. It is also viable to build a small RoQ file as a ROM disk into the
ELF file (which is well supported in KOS) and load the file from the '/rd'
mount point.
Bugs, Issues, and Future Development
====================================
:R2 Release by PH3NOM:
I have updated the dreamroq library to support decoding of DPCM
audio samples encoded in the RoQ stream.
The KOS Dreamcast player has been updated to support streaming
of the decoded samples, directly using the Dreamcast's AICA
audio hardware, running in a seperate thread.
DMA transfers to the PVR and rendering of the frame is executed
in a seperate thread, so the decoder can continue to process the
next frame while the current frame is being processed by the PVR.
Furthermore, a frame-rate timer has been implemented, so the video
should be played back at correct speed. Also, the allocated PVR
memory is now freed on exit of the player.
====================================
/* deprecated */
The library only does video playback; no sound right now.
The video decoder is not 100% correct yet. You will likely notice a few
artifacts which need to be ironed out.
Many of the video rendering modes could be optimized slightly by copying
pairs of pixels as 32-bit units. This should work on any mode except motion
compensated blocks; the latter could experience alignment issues which
the DC's SH-4 can't handle.
The library is a tad slow. Profiling indicates that the main bottleneck
is loading data from disc; the video decoder itself is pretty fast. The
player might benefit by moving data loading (I/O-bound operation) into a
separate thread. For that matter, the phase which sends the decoded
texture to the graphics hardware via DMA and renders it should also be
in a separate thread.
The player is just a proof of concept at this point. It doesn't try to
render frames with proper timing-- it just plays them as fast as possible
(which often isn't very fast, mostly due to the I/O bottleneck).
If the RoQ video is taller than it is wide, expect some odd rendering.
The API between the library and the client app leaves a bit to be desired.
Notably absent is some proper initialization and teardown mechanism.
Currently, the first call to the render callback initializes the PVR buffers
but they are never explicitly freed.

File diff suppressed because it is too large Load Diff

@ -97,14 +97,15 @@ static void *video_thd(void *ptr)
{
render_thd=1; /* Signal Thread is active */
/* Match the Auido and Video Time Stamps */
/* Match the Audio and Video Time Stamps */
VTS = ++frame / VIDEO_RATE;
while( ATS < VTS ) thd_pass();
/* Draw the frame using the PVR */
pvr_draw_frame_dma(&roq_vram_ptr);
printf("Rendered Frame %u\n", frame);
//printf("Rendered Frame %u\n", frame);
render_thd=0; /* Signal Thread is finished */
return NULL;
}
static int render_cb(unsigned short *buf, int width, int height, int stride,
@ -123,11 +124,14 @@ static int render_cb(unsigned short *buf, int width, int height, int stride,
PVR_LIST_OP_POLY, PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED, 10.0f);
graphics_initialized = 1;
printf("Graphics initialized\n");
}
/* Wait for last frame to finish render */
while(render_thd)
thd_pass();
while(render_thd){
//printf("Still rendering");
thd_pass();
}
/* Current decoded frame */
pvr_dma_load( (unsigned char *)buf, &roq_vram_ptr);
@ -135,6 +139,7 @@ static int render_cb(unsigned short *buf, int width, int height, int stride,
/* Create a thread to render the current frame */
//Try 1 onr 0 for first arg
render_thread = thd_create(0, video_thd, NULL);
printf("Render Thread Active %d\n", render_thd);
return ROQ_SUCCESS;
}
@ -143,8 +148,10 @@ maple_device_t *cont; //Controller
cont_state_t *state; //State of inputs
static int quit_cb()
{
/*
cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
/* check controller state */
// check controller state
state = maple_dev_status(cont);
// If the state/controller is unavailable
@ -155,6 +162,8 @@ static int quit_cb()
state->buttons = ~state->buttons;
return (state->buttons & CONT_START);
*/
return ROQ_SUCCESS;
}
int main()
@ -168,7 +177,7 @@ int main()
printf("dreamroq_play(C) Multimedia Mike Melanson & Josh PH3NOM Pearson 2011\n");
/* To disable a callback, simply replace the function name by 0 */
status = dreamroq_play("/cd/sample.roq", 1, render_cb, 0, 0);
status = dreamroq_play("/cd/id_soft.roq", 1, render_cb, audio_cb, quit_cb);
printf("dreamroq_play() status = %d\n", status);

Binary file not shown.

@ -511,6 +511,7 @@ int dreamroq_play(char *filename, int loop, render_callback render_cb,
free (state.frame[0]);
free (state.frame[1]);
status = ROQ_NO_MEMORY;
printf(" RoQ_INFO: NO_MEMORY");
break;
}
memset(state.frame[0], 0, state.texture_height * state.stride * sizeof(unsigned short));
@ -518,12 +519,14 @@ int dreamroq_play(char *filename, int loop, render_callback render_cb,
/* set this flag so that this code is not executed again when
* looping */
printf(" RoQ_INFO: Info initialized\n");
initialized = 1;
break;
case RoQ_QUAD_CODEBOOK:
status = roq_unpack_quad_codebook(read_buffer, chunk_size,
chunk_arg, &state);
printf(" RoQ_QUAD: unpack status = %d (0 = succes)\n", status);
break;
case RoQ_QUAD_VQ:
@ -532,6 +535,7 @@ int dreamroq_play(char *filename, int loop, render_callback render_cb,
if (render_cb)
status = render_cb(state.frame[state.current_frame],
state.width, state.height, state.stride, state.texture_height);
printf(" RoQ_QUAD_VQ: unpack status = %d (0 = succes)\n", status);
break;
case RoQ_SOUND_MONO:

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save