CINEMA 1.0 - fast video player for the Nokia 9210 Communicator
===============================================================

Sami Vuori, written together with Claude (Anthropic).  Icon by ChatGPT.
Free software under the GNU General Public License, version 2 or later
(see LICENCE below).

Cinema plays video with sound on the Nokia 9210 / 9210c / 9210i (Series 80
v1.0, Symbian 6.0).  The phone has no video decoder and a ~52 MHz ARM, so
every frame is prepared on a PC ahead of time: scaled, converted to the
display's exact native pixel format (EColor4K, 12-bit 0x0RGB) and packed.
On the phone Cinema only unpacks and copies: on real hardware it writes
frames straight into the screen buffer, past the window server.

Every clip is shown at double its stored size (nearest neighbour, like
RealPlayer on this phone) whenever the doubled picture still fits the
640x200 screen.  So a 320x100 clip fills the screen, and a 640x200 clip is
shown 1:1.  320x100 at 15 fps is the tested sweet spot: 11-13 fps on busy
footage on a real 9210.

The user interface is in English or Finnish.  The installer picks the
language that matches the phone's own language setting and only asks when
neither matches.


ON THE PHONE
------------
Install Cinema.SIS, then copy your clips (a .CIN and the .WAV with the same
name) to D:\CINEMA\ on the memory card.  C:\CINEMA\ in phone memory works
too.

Clip list:  Up/Down selects, Enter (or the Play softkey) plays.  A clip you
            left part-way shows its position, and playing it again
            resumes from there.

Playing:    Enter / Space   pause and resume
            Left / Right    seek 5 seconds back / forward
            Up / Down       volume, 10 % a step (shown for a moment)
            Tab             full screen on/off (playback starts full screen)
            L               loop on/off (on by default)
            R               restart from the beginning
            Backspace / Esc back to the clip list, remembering the position

The Menu key has the same commands in four menus (File, View, Play, Tools);
Tools > About lists the keys.


MAKING CLIPS (PC)
-----------------
Needs Python 3 and ffmpeg (https://ffmpeg.org/).  numpy makes conversion
much faster and is needed for --vq; Pillow is only needed for --extract.

Easiest: the GUI front end, which finds ffmpeg by itself:

    python cinema_gui.py

Or the command line:

    python cinema_convert.py movie.mp4 --size 320x100 --fps 15 --vq
    python cinema_convert.py movie.mp4 -o clip.CIN --start 10:00 --end 15:00

Both write clip.CIN plus clip.WAV (8000 Hz mono PCM) next to each other.

Two encodings:

  --vq      vector quantization: lossy, very small (a 2-minute trailer at
            320x100/15 fps is about 4 MB + 1.8 MB of audio), and the fastest
            to play.  Recommended.  --vq-k (codebook size, default 256; up
            to 4096 looks sharper and plays just as fast) and --vq-block
            (default 2) set the quality.
  default   lossless: run-length coding with delta frames, motion
            compensation and keyframes.  Exact pixels, but roughly 4-5x
            bigger than --vq.

Other options:

  --size WxH          frame size, letterboxed to fit (default 160x96)
  --fps N             target frame rate (default 7)
  --start / --end     trim, as SS, MM:SS or HH:MM:SS
  --no-audio          no .WAV
  --audio-rate N      Hz: 8000 (default), 11025, 16000, 22050, 32000,
                      44100 or 48000
  --audio-channels N  1 (default) or 2; the 9210's speaker is mono anyway

To check a clip without a phone (needs Pillow):

    python cinema_convert.py clip.CIN --extract -o check_

writes every frame as check_0000.png, check_0001.png, ...
`python cinema_format.py` runs the container's self-test.


BUILD (9210 SDK, Series 80 v1.0)
--------------------------------
    bldmake bldfiles
    abld build armi urel        (phone)
    abld build wins udeb        (emulator)
    makesis Cinema.pkg          ->  Cinema.SIS

Cinema.mmp has LANG 01 09, so the build makes Cinema.r01 (English) and
Cinema.r09 (Finnish) instead of a single Cinema.rsc; the .pkg packs both
and the installer keeps one.

Cinema.pkg must stay UTF-16LE with a BOM and CRLF line endings (this SDK's
makesis silently makes an empty SIS from an ASCII .pkg).  Edit
Cinema.pkg.txt and regenerate it:

    powershell -Command "[IO.File]::WriteAllText('Cinema.pkg', (Get-Content -Raw 'Cinema.pkg.txt'), [Text.Encoding]::Unicode)"

AIF\Cinema.aif is the built icon file (from appicon_64x50.bmp and
appicon_25x20.bmp) that the .pkg installs.

The emulator has no D: drive, so put test clips under \CINEMA\ on the host
folder that the WINS build maps to the emulator's C: drive.


.CIN FORMAT
-----------
The exact byte layout is in the header comment of cinema_format.py.  In
short: a 16-byte header (magic "CIN1", version 7, pixel format, size, frame
rate, frame count), a codebook for VQ clips, then the frame records, each a
flag byte, a u32 length and the data.  Audio lives in the companion .WAV,
played and seeked with CMdaAudioRecorderUtility.  Video and audio are kept
in step with a wall clock: when decoding falls behind, Cinema skips ahead
to the next keyframe.


FILES
-----
Bld.inf  Cinema.mmp  Cinema.hrh     project
Cinema.rss                          menus, softkeys and all UI text (EN + FI)
Cinema.h                            class declarations
Cinema_Main.cpp  Cinema_Application.cpp  Cinema_Document.cpp
Cinema_AppUi.cpp                    app shell, menu commands
Cinema_AppView.cpp                  clip list, playback, seeking, drawing
Cinema_Clip.h/.cpp                  reads and decodes .CIN video
Cinema_Audio.h/.cpp                 plays and seeks the .WAV
Cinema.pkg / Cinema.pkg.txt         SIS package and its editable master
AIF\Cinema.aif, appicon_*.bmp       icon
cinema_format.py                    the .CIN container (PC side)
cinema_convert.py                   video -> .CIN + .WAV converter
cinema_gui.py                       GUI for the converter (Tkinter)
cinema_vq.py                        VQ measurement prototype


LICENCE
-------
Copyright (C) 2026 Sami Vuori.

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.  It is distributed WITHOUT ANY WARRANTY; see COPYING for
the full licence.
