|
Forum Index : Microcontroller and PC projects : PicoMite Video player
| Author | Message | ||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 11488 |
Here RGB332 at 30fps from SDcard - coming in RC21. Will also work with buffered TFT drivers You can already play RGB121 videos with the current release - see the manual CONVERTER.pdf File converter vid2rgb121.zip Sample video in RGB121 cartoon.zip '============================================================ ' RGB121 framebuffer video player (companion to vid2rgb121.py) ' ' Fast path: each frame is read straight from the file into a RAM ' buffer with MEMORY INPUT (no INPUT$/LONGSTRING loop), then BLIT ' MEMORY decodes the RLE nibbles directly onto the LIVE screen ' (no framebuffer, no FRAMEBUFFER COPY). ' ' .vc frame layout on disk: ' uint32 blobLen (little-endian) ' uint16 width | 0x8000 \ BLIT MEMORY header ' uint16 height / ' bytes rle... (colour<<4)|count, count 1..15 ' ' On HDMI/USB the base display must be 640x480; MODE 2 makes it a ' 320x240, 16-colour RGB121 surface: ' OPTION RESOLUTION 640x480[,315000] (one-off, persists) '============================================================ Option EXPLICIT Const F_HANDLER = 1 Const T_ESC = 27 Drive "b:" Dim STRING vidFile = "cartoon.121" Dim STRING audFile = ""'"sample-2.aud" ' set to "" if the clip has no audio Dim FLOAT fps = 30 ' MUST match the converter's --fps Dim FLOAT frameMs = 1000 / fps Dim INTEGER vDelay = 0 ' ms A/V sync nudge ' --- per-frame RAM buffer (NOT a long string: raw integer array) ----- ' Holds one compressed frame blob (header + RLE). 320x240 worst case ' is ~76 KB; 9700 ints = 77.6 KB headroom. Dim INTEGER buf%(9700) Dim INTEGER baddr% = Peek(VARADDR buf%()) ' frame data address for BLIT MEMORY Dim INTEGER lenbuf%(1) ' 16 bytes scratch for the length word ' --- screen: MODE 2 draws straight to the live 320x240 RGB121 display MODE 2 CLS Dim INTEGER blobLen, frames = 0 Open vidFile For INPUT As #F_HANDLER If audFile <> "" Then Play WAV audFile Pause vDelay Timer = 0 Do If Eof(#F_HANDLER) Then Exit Do ' --- read the 4-byte little-endian blob length straight into RAM --- lenbuf%(0) = 0 Memory INPUT F_HANDLER, 4, lenbuf%() blobLen = lenbuf%(0) ' low 4 bytes = length, upper pre-zeroed ' --- read the whole frame blob in one go, then decode onto screen --- Memory INPUT F_HANDLER, blobLen, buf%() Blit Memory baddr%, 0, 0 frames = frames + 1 ' --- pace to the encode fps so audio stays in sync (drift-free) --- Do While Timer < frames * frameMs Loop If Asc(Inkey$) = T_ESC Then Exit Do Loop Close #F_HANDLER Play STOP Print "Played "; frames; " frames in "; Str$(Timer/1000); " s" End |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |