Commit Graph

159 Commits

Author SHA1 Message Date
kris
b2c00784b0 Minor code cleanups 2019-06-21 22:08:22 +01:00
kris
b0e83d2faf Clear the (D)HGR display before showing it, so we don't see garbage
during startup.

Clear keyboard strobe before exiting.
2019-06-20 21:23:18 +01:00
kris
7d041a6a84 Store video frames in {basename}/{mode}/{palette}/ directory to
disambiguate different values (for palettes in particular)
2019-06-20 21:15:52 +01:00
kris
a732a0e034 Fix merge 2019-06-19 22:28:31 +01:00
kris
e3cb6fe7d1 Merge branch 'dhgr' of https://github.com/KrisKennaway/ii-vision into dhgr 2019-06-19 22:16:36 +01:00
kris
2cda5ea22c Merge branch 'dhgr' of https://github.com/KrisKennaway/ii-vision into dhgr 2019-06-19 22:14:24 +01:00
kris
cf3c687a8f Fix merges after rebase 2019-06-19 22:10:15 +01:00
kris
4d9e1e510b random.getrandbits() is much faster than random.randint() 2019-06-19 22:06:54 +01:00
kris
edefe649f4 Parametrize the RGB palette to encode with, and support both NTSC and
IIGS palettes.

Move the palette diff_matrix generation into make_data_tables.py since
that is the only place it is used.

Demand-load the edit distance matrices when transcoding.
2019-06-19 22:06:54 +01:00
kris
696eb61bf4 Compress the precomputed edit_distance arrays 2019-06-19 22:04:06 +01:00
kris
f07cabafb7 Add type annotations 2019-06-19 22:04:02 +01:00
kris
33aa4d46c4 Rename FrameSequencer to FrameGrabber and break out into separate file.
Add a test case that the bmp2dhr output of input filenames containing
'.'  are handled correctly.

Break out video.Mode into video_mode.VideoMode to resolve circular
dependency.
2019-06-19 22:04:02 +01:00
kris
fac2089206 Add tests for _diff_weights 2019-06-19 22:02:13 +01:00
kris
5d9ffe7d8b No longer used 2019-06-19 22:02:13 +01:00
kris
fd49736b71 FrameSequencer:
- Extract out a (File)FrameSequencer class from Video to encapsulate
the generation of still frames.  This also makes Video easier to test.

- Fix FileFrameSequencer.frames() to correctly handle filenames
  containing '.'

- Temporarily switch to the BMP2DHR NTSC palette (#5) for evaluation.

Video:
- Temporarily hardcode DHGR decoding

- Optimize _heapify_priorities() by using numpy to vectorize the
  construction of the list of tuples.  This requires changing the
  random nonce to an int so the intermediate array has a uniform type.

- Use the efficient 28-bit representation of DHGR (aux, main, aux,
  main) tuples introduced in DHGRBitmap to evaluate diffs

- Switch to np.int type for accumulating diffs, and random.randint(0,
  10000) instead of float for nonce values.

- Fix/improve some of the error evaluation in _index_changes:
  - skip offsets whose diffs have already been cleared
  - hoist some stuff out of _compute_error into the parent

- Add some validation that when we run out of work to do with a frame,
  the source and target memory maps should be equal.  This isn't
  happening sometimes, i.e. there is a bug.
2019-06-19 22:02:13 +01:00
kris
15c77f2465 Remove unused code.
Add a new DHGRBitmap class that efficiently represents the
DHGR interleaving of the (aux, main) MemoryMap as a sequence of
28-bit integers.

This allows for easily extracting the 8-bit and 12-bit subsequences
representing the DHGR pixels that are influenced when storing a byte
at offsets 0..3 within the interleaved (aux, main, aux, main)
sequence.

Since we have precomputed all of the pairwise differences between
these 8- and 12-bit values, this allows us to efficiently compute the
edit distances between pairs of screen bytes (and/or arrays)
2019-06-19 21:54:52 +01:00
kris
9c90665e96 Fix warnings 2019-06-19 21:54:52 +01:00
kris
494503aa88 Precompute the edit distance between the 8-bit (2-pixel) and 12-bit
(3-pixel) sequences that may be modified when storing bytes to the
DHGR display.

This relies on producing an efficient linear representation of the
DHGR framebuffer in terms of a packed 28-bit representation of (Aux,
Main, Aux, Main) screen bytes.
2019-06-19 21:54:52 +01:00
kris
b33b730bfa Map DHGR colours to RGB values (for now using the BMP2DHR default
NTSC palette), and compute the matrix of pairwise perceptual
differences between these colours, using CIE2000 delta values.
2019-06-19 21:54:49 +01:00
kris
cb287ea0e7 Add a DHGRColours enum mapping the DHGR logical colours to their
(memory-order) 4-bit values.
2019-06-19 21:54:49 +01:00
kris
5dcbca4aae Exit gracefully when running out of video frames 2019-06-19 21:54:07 +01:00
kris
38663088ef Remove CycleCounter, it's unused 2019-06-19 21:51:45 +01:00
kris
bd0aa6ad6b Simplify the accounting of audio ticks in video framing, and fix an off-by-one that was causing audio and video to become desynchronized.
Switch from 14340Hz to 14700Hz, which is 44100/3 i.e. a divisor of the
most common audio input sample rate.  This gives better quality
(and/or faster to encode) audio quality at the cost of producing <2%
faster playback.
2019-06-19 21:47:49 +01:00
kris
32bb4347ad Fix unit test 2019-06-19 21:45:58 +01:00
kris
a6d7cf73b1 Fix warning about missing newline at EOF 2019-06-17 23:46:52 +01:00
kris
079036042a Add TODO about Opcode.apply being currently unused 2019-06-17 23:46:24 +01:00
kris
1dcd16744b Add a .gitignore file 2019-06-17 23:45:05 +01:00
kris
20a6f03482 Default to DHGR and NTSC palette 2019-06-15 21:32:56 +01:00
kris
44f8ab39e4 Vectorizing does not help, the array is not big enough to amortize the
python overheads.
2019-06-15 21:30:25 +01:00
kris
bf2057cbb9 random.getrandbits() is much faster than random.randint() 2019-06-15 21:23:36 +01:00
kris
ca817999f6 Parametrize the RGB palette to encode with, and support both NTSC and
IIGS palettes.

Move the palette diff_matrix generation into make_data_tables.py since
that is the only place it is used.

Demand-load the edit distance matrices when transcoding.
2019-06-15 21:02:00 +01:00
kris
824154fd39 Compress the precomputed edit_distance arrays 2019-06-14 22:08:34 +01:00
kris
c2c57b47d5 Add type annotations 2019-06-14 22:03:37 +01:00
kris
549752e112 Rename FrameSequencer to FrameGrabber and break out into separate file.
Add a test case that the bmp2dhr output of input filenames containing
'.'  are handled correctly.

Break out video.Mode into video_mode.VideoMode to resolve circular
dependency.
2019-06-14 21:59:39 +01:00
kris
d5f2482a0a Add tests for _diff_weights 2019-06-14 00:13:28 +01:00
kris
b781bf3a10 No longer used 2019-06-14 00:13:14 +01:00
kris
ec65684221 FrameSequencer:
- Extract out a (File)FrameSequencer class from Video to encapsulate
the generation of still frames.  This also makes Video easier to test.

- Fix FileFrameSequencer.frames() to correctly handle filenames
  containing '.'

- Temporarily switch to the BMP2DHR NTSC palette (#5) for evaluation.

Video:
- Temporarily hardcode DHGR decoding

- Optimize _heapify_priorities() by using numpy to vectorize the
  construction of the list of tuples.  This requires changing the
  random nonce to an int so the intermediate array has a uniform type.

- Use the efficient 28-bit representation of DHGR (aux, main, aux,
  main) tuples introduced in DHGRBitmap to evaluate diffs

- Switch to np.int type for accumulating diffs, and random.randint(0,
  10000) instead of float for nonce values.

- Fix/improve some of the error evaluation in _index_changes:
  - skip offsets whose diffs have already been cleared
  - hoist some stuff out of _compute_error into the parent

- Add some validation that when we run out of work to do with a frame,
  the source and target memory maps should be equal.  This isn't
  happening sometimes, i.e. there is a bug.
2019-06-14 00:12:26 +01:00
kris
4251c9938f Remove unused code.
Add a new DHGRBitmap class that efficiently represents the
DHGR interleaving of the (aux, main) MemoryMap as a sequence of
28-bit integers.

This allows for easily extracting the 8-bit and 12-bit subsequences
representing the DHGR pixels that are influenced when storing a byte
at offsets 0..3 within the interleaved (aux, main, aux, main)
sequence.

Since we have precomputed all of the pairwise differences between
these 8- and 12-bit values, this allows us to efficiently compute the
edit distances between pairs of screen bytes (and/or arrays)
2019-06-13 23:44:41 +01:00
kris
a172214f16 Fix warnings 2019-06-13 23:41:28 +01:00
kris
5387eae674 Fix warning about missing newline at EOF 2019-06-13 23:40:55 +01:00
kris
fb14a20380 Precompute the edit distance between the 8-bit (2-pixel) and 12-bit
(3-pixel) sequences that may be modified when storing bytes to the
DHGR display.

This relies on producing an efficient linear representation of the
DHGR framebuffer in terms of a packed 28-bit representation of (Aux,
Main, Aux, Main) screen bytes.
2019-06-13 23:27:30 +01:00
kris
9f950739f9 Map DHGR colours to RGB values (for now using the BMP2DHR default
NTSC palette), and compute the matrix of pairwise perceptual
differences between these colours, using CIE2000 delta values.
2019-06-12 22:14:11 +01:00
kris
bed29004c2 Add a DHGRColours enum mapping the DHGR logical colours to their
(memory-order) 4-bit values.
2019-06-12 22:12:26 +01:00
kris
2d7d4acef7 Fix test 2019-06-12 22:06:58 +01:00
kris
2156522d0f Add a .gitignore file 2019-06-12 21:50:27 +01:00
kris
b84f40308b Add TODO about Opcode.apply being currently unused 2019-06-12 21:42:17 +01:00
kris
721eb3112d Fix bug with DHGR bank switching: we were emitting the last writes to
a bank after switching to the new one, which caused video corruption.
2019-06-12 21:37:30 +01:00
kris
0c44fe634f Remove stray comment 2019-04-25 21:29:38 +01:00
kris
782156967b Add --video_mode HGR|DHGR option to support both video modes uniformly. 2019-04-25 17:38:04 +01:00
kris
a188216f90 Add a video Mode enum. 2019-04-25 16:28:25 +01:00