Welcome, Guest. Please login or register.

Author Topic: I need some advice from experienced coder regarding A/V hdd streaming please  (Read 1258 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Amiga_NutTopic starter

  • Hero Member
  • *****
  • Join Date: Jan 2007
  • Posts: 926
    • Show only replies by Amiga_Nut
Not sure where I should post this so general chat it is :)

I have some spare time, although writing a new game too so not that much free time for this, but I was discussing playback of movie files on an Atari STE with someone and had a few ideas of a better way to do this on Amiga. Feedback appreciated.

Fix the resolution of the movie for my first attempt at doing this to simplify things. So for example I will take a 320x160 32 colour resolution as a start point.

So my idea now is to create a single file. This file will be composed of uncompressed data so the images for the frames and the associated sound for each grouping of frames are at fixed regular intervals. This means that if I create a file and this file goes as follows.....

| Frame1 | Frame2 | Frame3 | Frame4 | Frame5 | 0.2sec Sound Frames1-5 | Frame6 | ...

So as all the frames are uncompressed the start of each 5 frames of video and it's associated 1/5th of a second of uncompressed 8 bit sampled sound will be at fixed points and can easily be loaded in segments of repeating equal sizes for each 20% of a seconds worth of movie.

So here is the key, the bit that sort of struck me after thinking about removing seek time delays for lots of tiny files and distinct separate audio/video files. What if I do the following....

1. Load the first 180kb (5 x 32kb frames and 20kb of sample data) of the file and begin to transfer it via DMA starting at one of two predefined chip memory address locations called start_addr1.

2. Load the next 180kb of the file into the second predefined address in chip memory called start_addr2.

REPEAT

3. IF audio sample not currently playing on left channel 2 and right channel 2 THEN......
Begin to play the 20kb of audio data stored at start and end address locations
(start_addr1 + 160kb) - (start_addr1 + 180kb) using left channel 2 and right channel 2.
ELSE go back to 3

4 Begin a loop to set beginning of screen memory to 5 values stepped through
(start_addr1) + 0
WAIT VSYNC x2
(start_addr1) + 32
WAIT VSYNC x2
(start_addr1) + 64
WAIT VSYNC x2
(start_addr1) + 96
WAIT VSYNC x2
(start_addr1) + 128

5 Start reading in next 180kb segment of file into chip ram at start_addr1 via DMA

6. IF audio sample finished playing on left channel 1 and right channel 1 THEN......
Begin to play the 20kb of audio data stored at start and end address locations
(start_addr2 + 160kb) - (start_addr2 + 180kb) using left channel 2 and right channel 2.
ELSE go back to 6

7 Begin a loop to set beginning of screen memory to 5 values stepped through
(start_addr2) + 0
WAIT VSYNC x2
(start_addr2) + 32
WAIT VSYNC x2
(start_addr2) + 64
WAIT VSYNC x2
(start_addr2) + 96
WAIT VSYNC x2
(start_addr2) + 128

8 Start reading in next 180kb segment of file into chip ram at start_addr2 via DMA

UNTIL end of file.

Worried audio would crackle due to gaps when no audio is being played or even overlap because I am locked to a VSYNC fiftieths of a second and that only gives the code as much time effectively as two 2/50th of a second for

a. setting the 5th,10th,15th,20th...... frames to display by writing a new screen memory location
b. initiate DMA transfer operation for reading in next segment of 180kb of data.
c. polling the hardware to start playing next 0.2 second segment of audio
d. setting screen memory to display frames 6,11,16,21....etc

It's not accurate enough for synchronizing each audio segment perfectly is it OR will it be OK as long as I can get to part c. within 2/50ths of a second to check (and start if it has just finished playing) the next audio segment before continuing to display the first frame of next five segments.

What do you think?
 

Offline mousehouse

I am far from being an expert, but doing 320x240, 5 bit planes at 50 fps is a 320 x 240 x 5 x 50 / ( 8 x 1024 ) = 2344KBps data stream. My guess is not all systems are able to do this.

Tahoe showed me a HAM video player that probably does some nasty stuff called HAMP.RUN, it would not display te dancing girls on my 3000 because of too slow disk access...

You could try to get a more efficient (differential?) schema and see if the CPU can create the new image fast enough or check out one of the existing movie file formats... Or just lower the image size...
A3000T
 

Offline Amiga_NutTopic starter

  • Hero Member
  • *****
  • Join Date: Jan 2007
  • Posts: 926
    • Show only replies by Amiga_Nut
It's 320x160 frame size not 320x240 ;) This gives a nice 16:9 widescreen video on regular 4:3 CRT monitors of old (or newer 4:3 aspect TVs too).
 

Offline jj

  • Lifetime Member
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4052
  • Country: wales
  • Thanked: 2 times
  • Gender: Male
    • Show only replies by jj
Quote from: mousehouse;672520
I am far from being an expert, but doing 320x240, 5 bit planes at 50 fps is a 320 x 240 x 5 x 50 / ( 8 x 1024 ) = 2344KBps data stream. My guess is not all systems are able to do this.
 
Tahoe showed me a HAM video player that probably does some nasty stuff called HAMP.RUN, it would not display te dancing girls on my 3000 because of too slow disk access...
 
You could try to get a more efficient (differential?) schema and see if the CPU can create the new image fast enough or check out one of the existing movie file formats... Or just lower the image size...

Why on earth would you be displaying video at 50 fps.  The film would look a bit odd.  Given pal films are 24 fps
“We don't stop playing because we grow old; we grow old because we stop playing.” - George Bernard Shaw

Xbox Live: S0ulA55a551n2
 
Registered MorphsOS 3.13 user on Powerbook G4 15"