New Video Playback Engine For Dreamcast (RoQ)

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Multimedia Mike
DC Developer
DC Developer
Posts: 35
Joined: Thu Mar 17, 2011 11:57 pm
Has liked: 0
Been liked: 0
Contact:

Re: New Video Playback Engine For Dreamcast (RoQ)

Post by Multimedia Mike » Wed Mar 30, 2011 10:33 am

Chilly Willy wrote:
Multimedia Mike wrote:
Chilly Willy wrote:Is there some way to control the bitrate on ffmpeg when encoding as roq? I've tried virtually every option and nothing changes. It's permanently at q = 0.0.
Did you try the '-qscale' option?
Yes. The -qscale option works for the svq1 codec, but not the roqvideo codec. Oh, it also only outputs 30 FPS. I can't change that either. I think the ffmpeg encoder is just hardcoded for these things.
The original RoQ format was extremely rigid. First, there was the fact that width and height both needed to be powers of 2. And then FPS was hardcoded to 30 fps.

I should fix the FFmpeg RoQ muxer to allow arbitrary framerate. But if you're comfortable changing and recompiling FFmpeg source, look in libavformat/idroqenc.c (very short file). You'll see this data structure:

Code: Select all

    static const uint8_t header[] = {
        0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
    };
See 0x1E? That's 30 fps. You can hardcode it to something else.
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has liked: 0
Been liked: 2 times

Re: New Video Playback Engine For Dreamcast (RoQ)

Post by Chilly Willy » Wed Mar 30, 2011 6:25 pm

Multimedia Mike wrote:
Chilly Willy wrote:
Multimedia Mike wrote:
Chilly Willy wrote:Is there some way to control the bitrate on ffmpeg when encoding as roq? I've tried virtually every option and nothing changes. It's permanently at q = 0.0.
Did you try the '-qscale' option?
Yes. The -qscale option works for the svq1 codec, but not the roqvideo codec. Oh, it also only outputs 30 FPS. I can't change that either. I think the ffmpeg encoder is just hardcoded for these things.
The original RoQ format was extremely rigid. First, there was the fact that width and height both needed to be powers of 2. And then FPS was hardcoded to 30 fps.

I should fix the FFmpeg RoQ muxer to allow arbitrary framerate. But if you're comfortable changing and recompiling FFmpeg source, look in libavformat/idroqenc.c (very short file). You'll see this data structure:

Code: Select all

    static const uint8_t header[] = {
        0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
    };
See 0x1E? That's 30 fps. You can hardcode it to something else.
Thanks. I'll pull the latest repo and see about compiling it. It should be better than what's in the Ubuntu repo in any case.

I was wanting to try something like 15 FPS. Lower FPS was common on older consoles as that both cut the amount of space the video took AND gave you twice the time for decoding frames.
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has liked: 0
Been liked: 3 times

Re: New Video Playback Engine For Dreamcast (RoQ)

Post by PH3NOM » Wed Mar 30, 2011 10:19 pm

Multimedia Mike wrote:
PH3NOM wrote: For libXviD, yes, 512x256 is my target resolution. Something like RoQ should be 512x512.
A few days ago I tested some code to make benchmarks at various stages using my current SH4 optimized build of libxvidcore-1.3.0-rc1.
The sample AVI was encoded as DivX@512x256p, 23.976fps, 1Mbps, MP3@48kHz, 2ch, 128kbps
Here is the sample clip I used, from a recent Family Guy episode http://www.megaupload.com/?d=JKY4ZSYQ

52.75fps = read avi packet -> decode video
43.82fps = read avi packet -> decode video -> color conversion
38.30fps = read avi packet -> decode video -> color conversion -> transfer/draw decoded image
30.64fps = read avi packet -> decode video/audio -> color conversion -> transfer/draw decoded image + stream audio
I'm a bit confused-- this last line implies that this is a solved problem.
Implies, sure. Guarantees, no.

30.64fps process speed recorded at final stage is an average.
Using libXviD, frame complexity has a very significant impact on decoder speed.
Some seconds may be processing 20fps and some may be 40fps.
The problem being frame-skip occurs when process speed is less than video's frame-rate.
And, as benchmarking indicates, the color-space conversion has the most effect on playback speed.
Multimedia Mike
DC Developer
DC Developer
Posts: 35
Joined: Thu Mar 17, 2011 11:57 pm
Has liked: 0
Been liked: 0
Contact:

Re: New Video Playback Engine For Dreamcast (RoQ)

Post by Multimedia Mike » Thu Mar 31, 2011 10:14 am

PH3NOM wrote:And, as benchmarking indicates, the color-space conversion has the most effect on playback speed.
Okay, I finally took a look at the conversion code. If I'm looking in the write place (YV12_TO_YUYV macro in src/image/colorspace.c), it's doing a lot more math per pixel than is strictly necessary. It's not doing any upsampling but it seems to be doing more pointer arithmetic per sample than is really needed.

I'll see if I can come up with something faster (and prove it's faster).
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has liked: 0
Been liked: 3 times

Re: New Video Playback Engine For Dreamcast (RoQ)

Post by PH3NOM » Thu Mar 31, 2011 10:43 pm

Multimedia Mike wrote:
PH3NOM wrote:And, as benchmarking indicates, the color-space conversion has the most effect on playback speed.
Okay, I finally took a look at the conversion code. If I'm looking in the write place (YV12_TO_YUYV macro in src/image/colorspace.c), it's doing a lot more math per pixel than is strictly necessary. It's not doing any upsampling but it seems to be doing more pointer arithmetic per sample than is really needed.

I'll see if I can come up with something faster (and prove it's faster).
Awesome, thank you for taking a look!

Its almost a shame that the PVR has hardware accelerated YV12->UYVY conversion, because nobody know how to utilize it.

Can the concept you described be applied here?
http://multimedia.cx/yuv-3d-rgb.txt

Because what your describing to me, sounds like a change to the code that could potentially be sent upstream. Or would it apply specifically to the DC?
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has liked: 0
Been liked: 3 times

Re: New Video Playback Engine For Dreamcast (RoQ)

Post by PH3NOM » Mon Dec 12, 2011 10:38 pm

To update the library DreamRoQ, patbier, of www.alicedreams.com , has contacted me to add audio support.

Complimenting the work of Multimedia Mike, I have added decoding of RoQ audio ( http://wiki.multimedia.cx/index.php?title=Id_RoQ_DPCM ) to the DreamRoQ library.

The Dreamcast player has been updated, to implement audio decoding with video synchronization.

Until Mike updates the project at github, get it here:
http://www.megaupload.com/?d=XEWFHO0Z
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has liked: 0
Been liked: 2 times

Re: New Video Playback Engine For Dreamcast (RoQ)

Post by Chilly Willy » Tue Dec 13, 2011 4:47 pm

Nifty! Good work. :grin:
coldev
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 26
Joined: Tue Nov 01, 2011 7:30 pm
Has liked: 0
Been liked: 0
Contact:

Re: New Video Playback Engine For Dreamcast (RoQ)

Post by coldev » Tue Dec 13, 2011 6:36 pm

great work..

:lol:
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has liked: 0
Been liked: 3 times

Re: New Video Playback Engine For Dreamcast (RoQ)

Post by PH3NOM » Fri Feb 03, 2012 3:19 pm

Small update to the player, now using fast threaded DMA video rendering process.

Thanks to patbier for continued interest in seeming this player improved upon.
dreamroq-r2.2.tar.gz
(15.31 KiB) Downloaded 86 times
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has liked: 0
Been liked: 3 times

Re: New Video Playback Engine For Dreamcast (RoQ)

Post by PH3NOM » Thu Aug 23, 2012 1:28 pm

Not being bothered to upload this to a server elsewhere, I will post this as an attachment here.

This is mainly posted for Patbier.

DreamRoQ r2.3 is a small update to the previous r2.2.
It now uses a lower-latency audio driver, and implements A/V timestamps to maintain synchronization.
dreamroq-r2.3.tar
DreamRoQ r2.3
(C) Mike Melanson
Updated by PH3NOM
(64 KiB) Downloaded 78 times
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has liked: 0
Been liked: 0

Re: New Video Playback Engine For Dreamcast (RoQ)

Post by patbier » Thu Aug 23, 2012 2:44 pm

Thanks a lot ;)
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
Post Reply