Browse Source

Plan 9 from Bell Labs 2008-06-24

David du Colombier 12 years ago
parent
commit
ce658d7629
71 changed files with 21137 additions and 9966 deletions
  1. 36 40
      dist/replica/_plan9.db
  2. 36 40
      dist/replica/plan9.db
  3. 69 0
      dist/replica/plan9.log
  4. 25 202
      sys/man/1/mp3dec
  5. 2 2
      sys/src/cmd/winwatch.c
  6. 340 0
      sys/src/games/mp3dec/COPYING
  7. 21 0
      sys/src/games/mp3dec/COPYRIGHT
  8. 607 0
      sys/src/games/mp3dec/D.dat
  9. 1 0
      sys/src/games/mp3dec/README
  10. 0 266
      sys/src/games/mp3dec/audio.c
  11. 0 89
      sys/src/games/mp3dec/audio.h
  12. 0 48
      sys/src/games/mp3dec/audio_dummy.c
  13. 237 0
      sys/src/games/mp3dec/bit.c
  14. 47 0
      sys/src/games/mp3dec/bit.h
  15. 0 231
      sys/src/games/mp3dec/buffer.c
  16. 0 13
      sys/src/games/mp3dec/buffer.h
  17. 0 732
      sys/src/games/mp3dec/common.c
  18. 0 22
      sys/src/games/mp3dec/common.h
  19. 0 337
      sys/src/games/mp3dec/control_generic.c
  20. 0 168
      sys/src/games/mp3dec/dct64.c
  21. 0 223
      sys/src/games/mp3dec/decode.c
  22. 0 231
      sys/src/games/mp3dec/decode_2to1.c
  23. 0 238
      sys/src/games/mp3dec/decode_4to1.c
  24. 0 288
      sys/src/games/mp3dec/decode_ntom.c
  25. 580 0
      sys/src/games/mp3dec/decoder.c
  26. 91 0
      sys/src/games/mp3dec/decoder.h
  27. 0 37
      sys/src/games/mp3dec/equalize.dat
  28. 0 34
      sys/src/games/mp3dec/equalizer.c
  29. 81 0
      sys/src/games/mp3dec/fixed.c
  30. 472 0
      sys/src/games/mp3dec/fixed.h
  31. 494 0
      sys/src/games/mp3dec/frame.c
  32. 115 0
      sys/src/games/mp3dec/frame.h
  33. 0 263
      sys/src/games/mp3dec/genre.h
  34. 0 127
      sys/src/games/mp3dec/getbits.c
  35. 0 33
      sys/src/games/mp3dec/getbits.h
  36. 0 129
      sys/src/games/mp3dec/getlopt.c
  37. 0 66
      sys/src/games/mp3dec/getlopt.h
  38. 33 0
      sys/src/games/mp3dec/global.h
  39. 0 353
      sys/src/games/mp3dec/httpget.c
  40. 3087 0
      sys/src/games/mp3dec/huffman.c
  41. 48 321
      sys/src/games/mp3dec/huffman.h
  42. 62 0
      sys/src/games/mp3dec/imdct_s.dat
  43. 0 154
      sys/src/games/mp3dec/l2tables.h
  44. 0 155
      sys/src/games/mp3dec/layer1.c
  45. 534 0
      sys/src/games/mp3dec/layer12.c
  46. 31 0
      sys/src/games/mp3dec/layer12.h
  47. 0 296
      sys/src/games/mp3dec/layer2.c
  48. 2517 1699
      sys/src/games/mp3dec/layer3.c
  49. 30 0
      sys/src/games/mp3dec/layer3.h
  50. 950 0
      sys/src/games/mp3dec/mad.h
  51. 216 0
      sys/src/games/mp3dec/main.c
  52. 14 63
      sys/src/games/mp3dec/mkfile
  53. 0 1202
      sys/src/games/mp3dec/mpg123.c
  54. 0 370
      sys/src/games/mp3dec/mpg123.h
  55. 77 0
      sys/src/games/mp3dec/qc_table.dat
  56. 0 488
      sys/src/games/mp3dec/readers.c
  57. 8747 0
      sys/src/games/mp3dec/rq_table.dat
  58. 106 0
      sys/src/games/mp3dec/sf_table.dat
  59. 159 0
      sys/src/games/mp3dec/stream.c
  60. 108 0
      sys/src/games/mp3dec/stream.h
  61. 857 0
      sys/src/games/mp3dec/synth.c
  62. 69 0
      sys/src/games/mp3dec/synth.h
  63. 0 153
      sys/src/games/mp3dec/tabinit.c
  64. 0 193
      sys/src/games/mp3dec/term.c
  65. 0 39
      sys/src/games/mp3dec/term.h
  66. 100 0
      sys/src/games/mp3dec/timer.h
  67. 91 0
      sys/src/games/mp3dec/version.c
  68. 47 3
      sys/src/games/mp3dec/version.h
  69. 0 279
      sys/src/games/mp3dec/wav.c
  70. 0 279
      sys/src/games/mp3dec/xfermem.c
  71. 0 60
      sys/src/games/mp3dec/xfermem.h

+ 36 - 40
dist/replica/_plan9.db

@@ -264,7 +264,7 @@
 386/bin/games/jukefs - 775 sys sys 1196742485 164538
 386/bin/games/mahjongg - 775 sys sys 1210392721 165427
 386/bin/games/memo - 775 sys sys 1210392726 156830
-386/bin/games/mp3dec - 775 sys sys 1212377334 389058
+386/bin/games/mp3dec - 775 sys sys 1214263280 222185
 386/bin/games/mp3enc - 775 sys sys 1196220182 530357
 386/bin/games/playlistfs - 775 sys sys 1210648934 149337
 386/bin/games/sokoban - 775 sys sys 1210563675 165646
@@ -7450,7 +7450,7 @@ sys/man/1/mc - 664 sys sys 1196638932 552
 sys/man/1/mk - 664 sys sys 1196638935 13198
 sys/man/1/mkdir - 664 sys sys 1196638932 717
 sys/man/1/mlmgr - 664 sys sys 1196638935 2542
-sys/man/1/mp3dec - 664 sys sys 1196638935 4987
+sys/man/1/mp3dec - 664 sys sys 1214263162 792
 sys/man/1/mp3enc - 664 sys sys 1196638935 3236
 sys/man/1/ms2html - 664 sys sys 1196638935 1252
 sys/man/1/mtime - 664 sys sys 1196638936 239
@@ -14548,7 +14548,7 @@ sys/src/cmd/wikifs/wdir.c - 664 sys sys 1018211094 876
 sys/src/cmd/wikifs/wiki.h - 664 sys sys 1113275619 1897
 sys/src/cmd/wikifs/wiki2html.c - 664 sys sys 1128176575 916
 sys/src/cmd/wikifs/wiki2text.c - 664 sys sys 1018211094 779
-sys/src/cmd/winwatch.c - 664 sys sys 1113312596 4869
+sys/src/cmd/winwatch.c - 664 sys sys 1214259087 4882
 sys/src/cmd/xd.c - 664 sys sys 1124993597 5770
 sys/src/cmd/yacc.c - 664 sys sys 1161442160 58076
 sys/src/games - 20000000775 sys sys 1128271724 0
@@ -14568,43 +14568,39 @@ sys/src/games/mahjongg/mkfile - 664 sys sys 1191354593 241
 sys/src/games/memo.c - 664 sys sys 1130853201 6471
 sys/src/games/mkfile - 664 sys sys 1196228150 621
 sys/src/games/mp3dec - 20000000775 sys sys 1196207939 0
-sys/src/games/mp3dec/audio.c - 664 sys sys 956186249 5802
-sys/src/games/mp3dec/audio.h - 664 sys sys 956186249 2275
-sys/src/games/mp3dec/audio_dummy.c - 664 sys sys 956186347 770
-sys/src/games/mp3dec/buffer.c - 664 sys sys 956186250 4925
-sys/src/games/mp3dec/buffer.h - 664 sys sys 956186250 349
-sys/src/games/mp3dec/common.c - 664 sys sys 956186250 18447
-sys/src/games/mp3dec/common.h - 664 sys sys 956186250 459
-sys/src/games/mp3dec/control_generic.c - 664 sys sys 956186250 7166
-sys/src/games/mp3dec/dct64.c - 664 sys sys 956186250 3556
-sys/src/games/mp3dec/decode.c - 664 sys sys 956186251 4711
-sys/src/games/mp3dec/decode_2to1.c - 664 sys sys 956186251 5064
-sys/src/games/mp3dec/decode_4to1.c - 664 sys sys 956186251 5439
-sys/src/games/mp3dec/decode_ntom.c - 664 sys sys 956186251 6114
-sys/src/games/mp3dec/equalize.dat - 664 sys sys 956186251 459
-sys/src/games/mp3dec/equalizer.c - 664 sys sys 956186251 513
-sys/src/games/mp3dec/genre.h - 664 sys sys 956186251 2564
-sys/src/games/mp3dec/getbits.c - 664 sys sys 956186251 2139
-sys/src/games/mp3dec/getbits.h - 664 sys sys 956186251 1095
-sys/src/games/mp3dec/getlopt.c - 664 sys sys 956186252 2660
-sys/src/games/mp3dec/getlopt.h - 664 sys sys 956186252 1665
-sys/src/games/mp3dec/httpget.c - 664 sys sys 956186252 7340
-sys/src/games/mp3dec/huffman.h - 664 sys sys 956186252 15949
-sys/src/games/mp3dec/l2tables.h - 664 sys sys 956186252 8305
-sys/src/games/mp3dec/layer1.c - 664 sys sys 956186252 3764
-sys/src/games/mp3dec/layer2.c - 664 sys sys 956186252 8602
-sys/src/games/mp3dec/layer3.c - 664 sys sys 956186252 50154
-sys/src/games/mp3dec/mkfile - 664 sys sys 1196685451 853
-sys/src/games/mp3dec/mpg123.c - 664 sys sys 956186253 33082
-sys/src/games/mp3dec/mpg123.h - 664 sys sys 956256699 9852
-sys/src/games/mp3dec/readers.c - 664 sys sys 956186253 9684
-sys/src/games/mp3dec/tabinit.c - 664 sys sys 956186253 4530
-sys/src/games/mp3dec/term.c - 664 sys sys 956186253 3534
-sys/src/games/mp3dec/term.h - 664 sys sys 956186254 949
-sys/src/games/mp3dec/version.h - 664 sys sys 956186254 74
-sys/src/games/mp3dec/wav.c - 664 sys sys 956256257 6410
-sys/src/games/mp3dec/xfermem.c - 664 sys sys 956186254 5261
-sys/src/games/mp3dec/xfermem.h - 664 sys sys 956186254 1742
+sys/src/games/mp3dec/COPYING - 664 sys sys 1214261190 17992
+sys/src/games/mp3dec/COPYRIGHT - 664 sys sys 1214261191 918
+sys/src/games/mp3dec/D.dat - 664 sys sys 1214261191 26473
+sys/src/games/mp3dec/README - 664 sys sys 1214261191 61
+sys/src/games/mp3dec/bit.c - 664 sys sys 1214261191 6853
+sys/src/games/mp3dec/bit.h - 664 sys sys 1214261191 1613
+sys/src/games/mp3dec/decoder.c - 664 sys sys 1214261191 11548
+sys/src/games/mp3dec/decoder.h - 664 sys sys 1214261191 2844
+sys/src/games/mp3dec/fixed.c - 664 sys sys 1214261191 1795
+sys/src/games/mp3dec/fixed.h - 664 sys sys 1214261191 12915
+sys/src/games/mp3dec/frame.c - 664 sys sys 1214261191 11888
+sys/src/games/mp3dec/frame.h - 664 sys sys 1214261192 3970
+sys/src/games/mp3dec/global.h - 664 sys sys 1214261192 1121
+sys/src/games/mp3dec/huffman.c - 664 sys sys 1214261192 72433
+sys/src/games/mp3dec/huffman.h - 664 sys sys 1214261192 1570
+sys/src/games/mp3dec/imdct_s.dat - 664 sys sys 1214261192 2591
+sys/src/games/mp3dec/layer12.c - 664 sys sys 1214261192 13623
+sys/src/games/mp3dec/layer12.h - 664 sys sys 1214261192 1097
+sys/src/games/mp3dec/layer3.c - 664 sys sys 1214261193 70012
+sys/src/games/mp3dec/layer3.h - 664 sys sys 1214261193 1037
+sys/src/games/mp3dec/mad.h - 664 sys sys 1214261193 26716
+sys/src/games/mp3dec/main.c - 664 sys sys 1214261400 3954
+sys/src/games/mp3dec/mkfile - 664 sys sys 1214261193 241
+sys/src/games/mp3dec/qc_table.dat - 664 sys sys 1214261193 3987
+sys/src/games/mp3dec/rq_table.dat - 664 sys sys 1214261194 485879
+sys/src/games/mp3dec/sf_table.dat - 664 sys sys 1214261195 6561
+sys/src/games/mp3dec/stream.c - 664 sys sys 1214261195 4453
+sys/src/games/mp3dec/stream.h - 664 sys sys 1214261195 4219
+sys/src/games/mp3dec/synth.c - 664 sys sys 1214261195 24366
+sys/src/games/mp3dec/synth.h - 664 sys sys 1214261195 1950
+sys/src/games/mp3dec/timer.h - 664 sys sys 1214261195 2879
+sys/src/games/mp3dec/version.c - 664 sys sys 1214261195 2105
+sys/src/games/mp3dec/version.h - 664 sys sys 1214261195 1610
 sys/src/games/mp3enc - 20000000775 sys sys 1196206922 0
 sys/src/games/mp3enc/README - 664 sys sys 986804225 1921
 sys/src/games/mp3enc/VbrTag.c - 664 sys sys 986804077 14889

+ 36 - 40
dist/replica/plan9.db

@@ -264,7 +264,7 @@
 386/bin/games/jukefs - 775 sys sys 1196742485 164538
 386/bin/games/mahjongg - 775 sys sys 1210392721 165427
 386/bin/games/memo - 775 sys sys 1210392726 156830
-386/bin/games/mp3dec - 775 sys sys 1212377334 389058
+386/bin/games/mp3dec - 775 sys sys 1214263280 222185
 386/bin/games/mp3enc - 775 sys sys 1196220182 530357
 386/bin/games/playlistfs - 775 sys sys 1210648934 149337
 386/bin/games/sokoban - 775 sys sys 1210563675 165646
@@ -7450,7 +7450,7 @@ sys/man/1/mc - 664 sys sys 1196638932 552
 sys/man/1/mk - 664 sys sys 1196638935 13198
 sys/man/1/mkdir - 664 sys sys 1196638932 717
 sys/man/1/mlmgr - 664 sys sys 1196638935 2542
-sys/man/1/mp3dec - 664 sys sys 1196638935 4987
+sys/man/1/mp3dec - 664 sys sys 1214263162 792
 sys/man/1/mp3enc - 664 sys sys 1196638935 3236
 sys/man/1/ms2html - 664 sys sys 1196638935 1252
 sys/man/1/mtime - 664 sys sys 1196638936 239
@@ -14548,7 +14548,7 @@ sys/src/cmd/wikifs/wdir.c - 664 sys sys 1018211094 876
 sys/src/cmd/wikifs/wiki.h - 664 sys sys 1113275619 1897
 sys/src/cmd/wikifs/wiki2html.c - 664 sys sys 1128176575 916
 sys/src/cmd/wikifs/wiki2text.c - 664 sys sys 1018211094 779
-sys/src/cmd/winwatch.c - 664 sys sys 1113312596 4869
+sys/src/cmd/winwatch.c - 664 sys sys 1214259087 4882
 sys/src/cmd/xd.c - 664 sys sys 1124993597 5770
 sys/src/cmd/yacc.c - 664 sys sys 1161442160 58076
 sys/src/games - 20000000775 sys sys 1128271724 0
@@ -14568,43 +14568,39 @@ sys/src/games/mahjongg/mkfile - 664 sys sys 1191354593 241
 sys/src/games/memo.c - 664 sys sys 1130853201 6471
 sys/src/games/mkfile - 664 sys sys 1196228150 621
 sys/src/games/mp3dec - 20000000775 sys sys 1196207939 0
-sys/src/games/mp3dec/audio.c - 664 sys sys 956186249 5802
-sys/src/games/mp3dec/audio.h - 664 sys sys 956186249 2275
-sys/src/games/mp3dec/audio_dummy.c - 664 sys sys 956186347 770
-sys/src/games/mp3dec/buffer.c - 664 sys sys 956186250 4925
-sys/src/games/mp3dec/buffer.h - 664 sys sys 956186250 349
-sys/src/games/mp3dec/common.c - 664 sys sys 956186250 18447
-sys/src/games/mp3dec/common.h - 664 sys sys 956186250 459
-sys/src/games/mp3dec/control_generic.c - 664 sys sys 956186250 7166
-sys/src/games/mp3dec/dct64.c - 664 sys sys 956186250 3556
-sys/src/games/mp3dec/decode.c - 664 sys sys 956186251 4711
-sys/src/games/mp3dec/decode_2to1.c - 664 sys sys 956186251 5064
-sys/src/games/mp3dec/decode_4to1.c - 664 sys sys 956186251 5439
-sys/src/games/mp3dec/decode_ntom.c - 664 sys sys 956186251 6114
-sys/src/games/mp3dec/equalize.dat - 664 sys sys 956186251 459
-sys/src/games/mp3dec/equalizer.c - 664 sys sys 956186251 513
-sys/src/games/mp3dec/genre.h - 664 sys sys 956186251 2564
-sys/src/games/mp3dec/getbits.c - 664 sys sys 956186251 2139
-sys/src/games/mp3dec/getbits.h - 664 sys sys 956186251 1095
-sys/src/games/mp3dec/getlopt.c - 664 sys sys 956186252 2660
-sys/src/games/mp3dec/getlopt.h - 664 sys sys 956186252 1665
-sys/src/games/mp3dec/httpget.c - 664 sys sys 956186252 7340
-sys/src/games/mp3dec/huffman.h - 664 sys sys 956186252 15949
-sys/src/games/mp3dec/l2tables.h - 664 sys sys 956186252 8305
-sys/src/games/mp3dec/layer1.c - 664 sys sys 956186252 3764
-sys/src/games/mp3dec/layer2.c - 664 sys sys 956186252 8602
-sys/src/games/mp3dec/layer3.c - 664 sys sys 956186252 50154
-sys/src/games/mp3dec/mkfile - 664 sys sys 1196685451 853
-sys/src/games/mp3dec/mpg123.c - 664 sys sys 956186253 33082
-sys/src/games/mp3dec/mpg123.h - 664 sys sys 956256699 9852
-sys/src/games/mp3dec/readers.c - 664 sys sys 956186253 9684
-sys/src/games/mp3dec/tabinit.c - 664 sys sys 956186253 4530
-sys/src/games/mp3dec/term.c - 664 sys sys 956186253 3534
-sys/src/games/mp3dec/term.h - 664 sys sys 956186254 949
-sys/src/games/mp3dec/version.h - 664 sys sys 956186254 74
-sys/src/games/mp3dec/wav.c - 664 sys sys 956256257 6410
-sys/src/games/mp3dec/xfermem.c - 664 sys sys 956186254 5261
-sys/src/games/mp3dec/xfermem.h - 664 sys sys 956186254 1742
+sys/src/games/mp3dec/COPYING - 664 sys sys 1214261190 17992
+sys/src/games/mp3dec/COPYRIGHT - 664 sys sys 1214261191 918
+sys/src/games/mp3dec/D.dat - 664 sys sys 1214261191 26473
+sys/src/games/mp3dec/README - 664 sys sys 1214261191 61
+sys/src/games/mp3dec/bit.c - 664 sys sys 1214261191 6853
+sys/src/games/mp3dec/bit.h - 664 sys sys 1214261191 1613
+sys/src/games/mp3dec/decoder.c - 664 sys sys 1214261191 11548
+sys/src/games/mp3dec/decoder.h - 664 sys sys 1214261191 2844
+sys/src/games/mp3dec/fixed.c - 664 sys sys 1214261191 1795
+sys/src/games/mp3dec/fixed.h - 664 sys sys 1214261191 12915
+sys/src/games/mp3dec/frame.c - 664 sys sys 1214261191 11888
+sys/src/games/mp3dec/frame.h - 664 sys sys 1214261192 3970
+sys/src/games/mp3dec/global.h - 664 sys sys 1214261192 1121
+sys/src/games/mp3dec/huffman.c - 664 sys sys 1214261192 72433
+sys/src/games/mp3dec/huffman.h - 664 sys sys 1214261192 1570
+sys/src/games/mp3dec/imdct_s.dat - 664 sys sys 1214261192 2591
+sys/src/games/mp3dec/layer12.c - 664 sys sys 1214261192 13623
+sys/src/games/mp3dec/layer12.h - 664 sys sys 1214261192 1097
+sys/src/games/mp3dec/layer3.c - 664 sys sys 1214261193 70012
+sys/src/games/mp3dec/layer3.h - 664 sys sys 1214261193 1037
+sys/src/games/mp3dec/mad.h - 664 sys sys 1214261193 26716
+sys/src/games/mp3dec/main.c - 664 sys sys 1214261400 3954
+sys/src/games/mp3dec/mkfile - 664 sys sys 1214261193 241
+sys/src/games/mp3dec/qc_table.dat - 664 sys sys 1214261193 3987
+sys/src/games/mp3dec/rq_table.dat - 664 sys sys 1214261194 485879
+sys/src/games/mp3dec/sf_table.dat - 664 sys sys 1214261195 6561
+sys/src/games/mp3dec/stream.c - 664 sys sys 1214261195 4453
+sys/src/games/mp3dec/stream.h - 664 sys sys 1214261195 4219
+sys/src/games/mp3dec/synth.c - 664 sys sys 1214261195 24366
+sys/src/games/mp3dec/synth.h - 664 sys sys 1214261195 1950
+sys/src/games/mp3dec/timer.h - 664 sys sys 1214261195 2879
+sys/src/games/mp3dec/version.c - 664 sys sys 1214261195 2105
+sys/src/games/mp3dec/version.h - 664 sys sys 1214261195 1610
 sys/src/games/mp3enc - 20000000775 sys sys 1196206922 0
 sys/src/games/mp3enc/README - 664 sys sys 986804225 1921
 sys/src/games/mp3enc/VbrTag.c - 664 sys sys 986804077 14889

+ 69 - 0
dist/replica/plan9.log

@@ -19900,3 +19900,72 @@
 1213894803 1 c sys/src/cmd/ip/imap4d/search.c - 664 sys sys 1213893891 4557
 1213894803 2 c sys/src/cmd/tlssrv.c - 664 sys sys 1213893726 3478
 1213900204 0 c sys/games/lib/fortunes - 664 sys sys 1213899205 269744
+1214260207 0 c sys/src/cmd/winwatch.c - 664 sys sys 1214259087 4882
+1214263804 0 c 386/bin/games/mp3dec - 775 sys sys 1214263280 222185
+1214263804 1 c sys/man/1/mp3dec - 664 sys sys 1214263162 792
+1214263804 2 a sys/src/games/mp3dec/COPYING - 664 sys sys 1214261190 17992
+1214263804 3 a sys/src/games/mp3dec/COPYRIGHT - 664 sys sys 1214261191 918
+1214263804 4 a sys/src/games/mp3dec/D.dat - 664 sys sys 1214261191 26473
+1214263804 5 a sys/src/games/mp3dec/README - 664 sys sys 1214261191 61
+1214263804 6 a sys/src/games/mp3dec/bit.c - 664 sys sys 1214261191 6853
+1214263804 7 a sys/src/games/mp3dec/bit.h - 664 sys sys 1214261191 1613
+1214263804 8 a sys/src/games/mp3dec/decoder.c - 664 sys sys 1214261191 11548
+1214263804 9 a sys/src/games/mp3dec/decoder.h - 664 sys sys 1214261191 2844
+1214263804 10 a sys/src/games/mp3dec/fixed.c - 664 sys sys 1214261191 1795
+1214263804 11 a sys/src/games/mp3dec/fixed.h - 664 sys sys 1214261191 12915
+1214263804 12 a sys/src/games/mp3dec/frame.c - 664 sys sys 1214261191 11888
+1214263804 13 a sys/src/games/mp3dec/frame.h - 664 sys sys 1214261192 3970
+1214263804 14 a sys/src/games/mp3dec/global.h - 664 sys sys 1214261192 1121
+1214263804 15 a sys/src/games/mp3dec/huffman.c - 664 sys sys 1214261192 72433
+1214263804 16 c sys/src/games/mp3dec/huffman.h - 664 sys sys 1214261192 1570
+1214263804 17 a sys/src/games/mp3dec/imdct_s.dat - 664 sys sys 1214261192 2591
+1214263804 18 a sys/src/games/mp3dec/layer12.c - 664 sys sys 1214261192 13623
+1214263804 19 a sys/src/games/mp3dec/layer12.h - 664 sys sys 1214261192 1097
+1214263804 20 c sys/src/games/mp3dec/layer3.c - 664 sys sys 1214261193 70012
+1214263804 21 a sys/src/games/mp3dec/layer3.h - 664 sys sys 1214261193 1037
+1214263804 22 a sys/src/games/mp3dec/mad.h - 664 sys sys 1214261193 26716
+1214263804 23 a sys/src/games/mp3dec/main.c - 664 sys sys 1214261400 3954
+1214263804 24 c sys/src/games/mp3dec/mkfile - 664 sys sys 1214261193 241
+1214263804 25 a sys/src/games/mp3dec/qc_table.dat - 664 sys sys 1214261193 3987
+1214263804 26 a sys/src/games/mp3dec/rq_table.dat - 664 sys sys 1214261194 485879
+1214263804 27 a sys/src/games/mp3dec/sf_table.dat - 664 sys sys 1214261195 6561
+1214263804 28 a sys/src/games/mp3dec/stream.c - 664 sys sys 1214261195 4453
+1214263804 29 a sys/src/games/mp3dec/stream.h - 664 sys sys 1214261195 4219
+1214263804 30 a sys/src/games/mp3dec/synth.c - 664 sys sys 1214261195 24366
+1214263804 31 a sys/src/games/mp3dec/synth.h - 664 sys sys 1214261195 1950
+1214263804 32 a sys/src/games/mp3dec/timer.h - 664 sys sys 1214261195 2879
+1214263804 33 a sys/src/games/mp3dec/version.c - 664 sys sys 1214261195 2105
+1214263804 34 c sys/src/games/mp3dec/version.h - 664 sys sys 1214261195 1610
+1214263804 35 d sys/src/games/mp3dec/xfermem.h - 664 sys sys 956186254 0
+1214263804 36 d sys/src/games/mp3dec/xfermem.c - 664 sys sys 956186254 0
+1214263804 37 d sys/src/games/mp3dec/wav.c - 664 sys sys 956256257 0
+1214263804 38 d sys/src/games/mp3dec/term.h - 664 sys sys 956186254 0
+1214263804 39 d sys/src/games/mp3dec/term.c - 664 sys sys 956186253 0
+1214263804 40 d sys/src/games/mp3dec/tabinit.c - 664 sys sys 956186253 0
+1214263804 41 d sys/src/games/mp3dec/readers.c - 664 sys sys 956186253 0
+1214263804 42 d sys/src/games/mp3dec/mpg123.h - 664 sys sys 956256699 0
+1214263804 43 d sys/src/games/mp3dec/mpg123.c - 664 sys sys 956186253 0
+1214263804 44 d sys/src/games/mp3dec/layer2.c - 664 sys sys 956186252 0
+1214263804 45 d sys/src/games/mp3dec/layer1.c - 664 sys sys 956186252 0
+1214263804 46 d sys/src/games/mp3dec/l2tables.h - 664 sys sys 956186252 0
+1214263804 47 d sys/src/games/mp3dec/httpget.c - 664 sys sys 956186252 0
+1214263804 48 d sys/src/games/mp3dec/getlopt.h - 664 sys sys 956186252 0
+1214263804 49 d sys/src/games/mp3dec/getlopt.c - 664 sys sys 956186252 0
+1214263804 50 d sys/src/games/mp3dec/getbits.h - 664 sys sys 956186251 0
+1214263804 51 d sys/src/games/mp3dec/getbits.c - 664 sys sys 956186251 0
+1214263804 52 d sys/src/games/mp3dec/genre.h - 664 sys sys 956186251 0
+1214263804 53 d sys/src/games/mp3dec/equalizer.c - 664 sys sys 956186251 0
+1214263804 54 d sys/src/games/mp3dec/equalize.dat - 664 sys sys 956186251 0
+1214263804 55 d sys/src/games/mp3dec/decode_ntom.c - 664 sys sys 956186251 0
+1214263804 56 d sys/src/games/mp3dec/decode_4to1.c - 664 sys sys 956186251 0
+1214263804 57 d sys/src/games/mp3dec/decode_2to1.c - 664 sys sys 956186251 0
+1214263804 58 d sys/src/games/mp3dec/decode.c - 664 sys sys 956186251 0
+1214263804 59 d sys/src/games/mp3dec/dct64.c - 664 sys sys 956186250 0
+1214263804 60 d sys/src/games/mp3dec/control_generic.c - 664 sys sys 956186250 0
+1214263804 61 d sys/src/games/mp3dec/common.h - 664 sys sys 956186250 0
+1214263804 62 d sys/src/games/mp3dec/common.c - 664 sys sys 956186250 0
+1214263804 63 d sys/src/games/mp3dec/buffer.h - 664 sys sys 956186250 0
+1214263804 64 d sys/src/games/mp3dec/buffer.c - 664 sys sys 956186250 0
+1214263804 65 d sys/src/games/mp3dec/audio_dummy.c - 664 sys sys 956186347 0
+1214263804 66 d sys/src/games/mp3dec/audio.h - 664 sys sys 956186249 0
+1214263804 67 d sys/src/games/mp3dec/audio.c - 664 sys sys 956186249 0

+ 25 - 202
sys/man/1/mp3dec

@@ -1,217 +1,42 @@
 .TH MP3DEC 1
 .SH NAME
-mp3dec \- play audio MPEG 1.0/2.0 file (layers 1, 2 and 3)
+mp3dec \- decode audio MPEG files (layers 1, 2 and 3)
 .SH SYNOPSIS
 .B mp3dec
 [
-.B \-0124cmqsvy
-] [
-.BI \-a " dev"
-] [
-.BI \-b " size"
-] [
-.BI \-d " n"
-] [
-.BI \-f " factor"
-] [
-.BI \-g " gain"
-] [
-.BI \-h " n"
-] [
-.BI \-k " num"
-] [
-.BI \-n " num"
-] [
 .B -o
-.B [shl]
-] [
-.BI \-p " proxy"
-] [
-.BI \-r " rate"
+.I outfile
+]
+[
+.I file
+\&...
 ]
-.IR file " ...
 .SH DESCRIPTION
 .I Mp3dec
-reads one or more
-.IR file s
-(which may be URLs)
-and, by default, plays them on the audio device.
-The output format is raw (headerless) linear PCM audio data,
-16-bit, stereo, in host byte order.
-.IR File
-is assumed to contain a valid MPEG-1/2 audio layer-1, -2 or -3 bit stream.
-Any name starting with
-.L http://
-is recognized as a URL.
-.LP
-Interrupting
+decodes one or more MPEG audio files, writing
+16-bit stereo linear PCM sample data to
+.I outfile
+(default
+.BR /dev/audio ).
+If no files are named,
 .I mp3dec
-will skip to the next argument
-.IR file .
-Two interrupts within a second will terminate
-.IR mp3dec .
-.LP
-Options are:
-.TF "-f fact"
-.TP
-.B "-0 -1"
-Decode only channel 0 (left) or channel 1 (right),
-respectively.  These options are available for stereo MPEG streams only.
-.TP
-.B "-2 -4"
-Down-sample with ratio 2:1 (22 kHz) or 4:1 (11 kHz),
-respectively.
-Saves some CPU cycles, but the 4:1 ratio, at least, sounds ugly.
-.TP
-.BI "-a " dev
-Specify the audio device to use.  The default is
-.BR /dev/audio .
-Use this option if you have multiple audio devices and
-the default is not what you want.
-.TP
-.BI "-b " size
-Use an audio output buffer of
-.I size
-Kbytes.  This is useful to work around short periods of heavy
-system activity, which would normally cause the audio output
-to be interrupted.
-You should specify a buffer size of at least 1024
-(i.e. 1 Mb, which equals about 6 seconds of audio data) or more;
-less than about 300 does not make much sense.  The default is 0,
-which turns buffering off.
-.TP
-.B -c
-Check for filter range violations, and report them for each frame
-if any occur.
-.TP
-.BI "-d " n
-Only play every
-.IR n 'th
-frame.  This will cause the MPEG stream to be played
-.I n
-times faster, which can be used for special
-effects.  Can also be combined with the
-.B -h
-option to play 3 out of 4 frames etc.
-Sound quality will be poor.
-.TP
-.BI "-f " factor
-Change scale factor (default: 32768).
-.TP
-.BI "-g " gain
-Set audio hardware output gain (default: don't change).
-.TP
-.BI "-h " n
-Play each frame
-.I n
-times.  This will cause the MPEG stream
-to be played at
-.RI 1/ n 'th
-speed
-.RI ( n
-times slower), which can be
-used for special effects.  Can also be combined with the
-.B -d
-option to double every third frame or things like that.
-Sound quality will be poor.
-.TP
-.BI "-k " num
-Skip the first
-.I num
-frames.  By default the decoding starts at the first frame.
-.TP
-.B -m
-Mix both channels.
-This option is available for stereo MPEG layer-3 streams only.  It takes less
-CPU time than full stereo decoding.
-.TP
-.BI "-n " num
-Decode only
-.I num
-frames.  By default the complete stream is decoded.
-.TP
+reads standard input.
+.PP
+In the absence of the
 .B -o
-Direct audio output to the speaker
-.RB ( s ),
-headphones
-.RB ( h ),
-or line-out
-.RB ( l ).
-.TP
-.BI "-p " proxy
-The specified
-.I proxy
-will be used for HTTP requests.  It
-should be specified as a full URL (``http://host.domain:port/''),
-but the
-.L http://
-prefix, the port number and the trailing
-slash are optional (the default port is 80).  Specifying
-.B none
-means not to use any proxy.
-In the absence of
-.BR -p ,
+option,
 .I mp3dec
-looks for environment variables named
-.BR MP3_HTTP_PROXY ,
-.BR http_proxy ,
-and
-.BR HTTP_PROXY ,
-in that order.
-.TP
-.B -q
-Quiet: suppress diagnostic messages.
-.TP
-.BI "-r " rate
-Set sample rate (default: automatic).  You may want to
-change this if you need a constant bitrate independent of the MPEG stream rate.
-.I Mp3dec
-automagically converts the rate.
-You should then combine this with \-\-stereo or \-\-mono.
-.TP
-.B -s
-Write the decoded audio samples to standard output.
-.TP
-.BI "-u " auth
-HTTP authentication to use when fetching files via HTTP.
-The format used is
-.IB user : password.
-.TP
-.B -v
-Increase the verbosity level
-(e.g., prints the frame numbers during decoding).
-.TP
-.B -y
-Try to resync and continue decoding if an error occurs in
-the input file.  Also try to recover from certain broken
-headers.  Useful if you have a broken MPEG file, on which
+also opens
+.BR /dev/volume
+and sets the sample rate for playback to
+match the audio stream.
+When writing to
+.IR outfile ,
 .I mp3dec
-normally gives up saying `Illegal header'.  Be careful:
-Broken locations in MPEG files might cause sharp, loud pops or
-clicks, which might damage your speakers if played too loud.
-.TP
-.B \-z
-Shuffle play: randomly shuffles the argument files.
-.TP
-.B -Z
-Fully random play.
-.TP
-.B --stereo
-Force stereo output.
-.TP
-.B --reopen
-Forces reopening the audio device after every song.
-.TP
-.B --8bit
-Forces 8-bit output.
+prints a warning to standard error
+if the stream rate is not 44100 Hz.
 .SH BUGS
 It's another GNU behemoth, lightly tamed.
-.PP
-It's slow.
-.PP
-MPEG-2 Layers 1 and 2 are not tested and may not work.
-Free-format streams are not supported.
-No CRC error checking is performed.
 .SH SOURCE
 .B /sys/src/games/mp3dec
 .SH "SEE ALSO"
@@ -219,6 +44,4 @@ No CRC error checking is performed.
 .IR juke (7),
 .IR playlistfs (7)
 .br
-.B http://www.sfs.nphil.uni-tuebingen.de/~hipp/mpg123.html
-.br
-.B http://ftp.tu-clausthal.de/pub/unix/audio/mpg123
+.B http://www.underbit.com/products/mad/

+ 2 - 2
sys/src/cmd/winwatch.c

@@ -274,7 +274,7 @@ main(int argc, char **argv)
 	refreshwin();
 	redraw(screen, 1);
 	einit(Emouse|Ekeyboard);
-	Etimer = etimer(0, 5000);
+	Etimer = etimer(0, 2500);
 
 	for(;;){
 		switch(eread(Emouse|Ekeyboard|Etimer, &e)){
@@ -285,7 +285,7 @@ main(int argc, char **argv)
 		case Emouse:
 			if(e.mouse.buttons)
 				click(e.mouse);
-			break;
+			/* fall through  */
 		default:	/* Etimer */
 			refreshwin();
 			redraw(screen, 0);

+ 340 - 0
sys/src/games/mp3dec/COPYING

@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.

+ 21 - 0
sys/src/games/mp3dec/COPYRIGHT

@@ -0,0 +1,21 @@
+
+ libmad - MPEG audio decoder library
+ Copyright (C) 2000-2004 Underbit Technologies, Inc.
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+ If you would like to negotiate alternate licensing terms, you may do
+ so by contacting: Underbit Technologies, Inc. <info@underbit.com>
+

+ 607 - 0
sys/src/games/mp3dec/D.dat

@@ -0,0 +1,607 @@
+/*
+ * libmad - MPEG audio decoder library
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * $Id: D.dat,v 1.9 2004/01/23 09:41:32 rob Exp $
+ */
+
+/*
+ * These are the coefficients for the subband synthesis window. This is a
+ * reordered version of Table B.3 from ISO/IEC 11172-3.
+ *
+ * Every value is parameterized so that shift optimizations can be made at
+ * compile-time. For example, every value can be right-shifted 12 bits to
+ * minimize multiply instruction times without any loss of accuracy.
+ */
+
+  {  PRESHIFT(0x00000000) /*  0.000000000 */,	/*  0 */
+    -PRESHIFT(0x0001d000) /* -0.000442505 */,
+     PRESHIFT(0x000d5000) /*  0.003250122 */,
+    -PRESHIFT(0x001cb000) /* -0.007003784 */,
+     PRESHIFT(0x007f5000) /*  0.031082153 */,
+    -PRESHIFT(0x01421000) /* -0.078628540 */,
+     PRESHIFT(0x019ae000) /*  0.100311279 */,
+    -PRESHIFT(0x09271000) /* -0.572036743 */,
+     PRESHIFT(0x1251e000) /*  1.144989014 */,
+     PRESHIFT(0x09271000) /*  0.572036743 */,
+     PRESHIFT(0x019ae000) /*  0.100311279 */,
+     PRESHIFT(0x01421000) /*  0.078628540 */,
+     PRESHIFT(0x007f5000) /*  0.031082153 */,
+     PRESHIFT(0x001cb000) /*  0.007003784 */,
+     PRESHIFT(0x000d5000) /*  0.003250122 */,
+     PRESHIFT(0x0001d000) /*  0.000442505 */,
+
+     PRESHIFT(0x00000000) /*  0.000000000 */,
+    -PRESHIFT(0x0001d000) /* -0.000442505 */,
+     PRESHIFT(0x000d5000) /*  0.003250122 */,
+    -PRESHIFT(0x001cb000) /* -0.007003784 */,
+     PRESHIFT(0x007f5000) /*  0.031082153 */,
+    -PRESHIFT(0x01421000) /* -0.078628540 */,
+     PRESHIFT(0x019ae000) /*  0.100311279 */,
+    -PRESHIFT(0x09271000) /* -0.572036743 */,
+     PRESHIFT(0x1251e000) /*  1.144989014 */,
+     PRESHIFT(0x09271000) /*  0.572036743 */,
+     PRESHIFT(0x019ae000) /*  0.100311279 */,
+     PRESHIFT(0x01421000) /*  0.078628540 */,
+     PRESHIFT(0x007f5000) /*  0.031082153 */,
+     PRESHIFT(0x001cb000) /*  0.007003784 */,
+     PRESHIFT(0x000d5000) /*  0.003250122 */,
+     PRESHIFT(0x0001d000) /*  0.000442505 */ },
+
+  { -PRESHIFT(0x00001000) /* -0.000015259 */,	/*  1 */
+    -PRESHIFT(0x0001f000) /* -0.000473022 */,
+     PRESHIFT(0x000da000) /*  0.003326416 */,
+    -PRESHIFT(0x00207000) /* -0.007919312 */,
+     PRESHIFT(0x007d0000) /*  0.030517578 */,
+    -PRESHIFT(0x0158d000) /* -0.084182739 */,
+     PRESHIFT(0x01747000) /*  0.090927124 */,
+    -PRESHIFT(0x099a8000) /* -0.600219727 */,
+     PRESHIFT(0x124f0000) /*  1.144287109 */,
+     PRESHIFT(0x08b38000) /*  0.543823242 */,
+     PRESHIFT(0x01bde000) /*  0.108856201 */,
+     PRESHIFT(0x012b4000) /*  0.073059082 */,
+     PRESHIFT(0x0080f000) /*  0.031478882 */,
+     PRESHIFT(0x00191000) /*  0.006118774 */,
+     PRESHIFT(0x000d0000) /*  0.003173828 */,
+     PRESHIFT(0x0001a000) /*  0.000396729 */,
+
+    -PRESHIFT(0x00001000) /* -0.000015259 */,
+    -PRESHIFT(0x0001f000) /* -0.000473022 */,
+     PRESHIFT(0x000da000) /*  0.003326416 */,
+    -PRESHIFT(0x00207000) /* -0.007919312 */,
+     PRESHIFT(0x007d0000) /*  0.030517578 */,
+    -PRESHIFT(0x0158d000) /* -0.084182739 */,
+     PRESHIFT(0x01747000) /*  0.090927124 */,
+    -PRESHIFT(0x099a8000) /* -0.600219727 */,
+     PRESHIFT(0x124f0000) /*  1.144287109 */,
+     PRESHIFT(0x08b38000) /*  0.543823242 */,
+     PRESHIFT(0x01bde000) /*  0.108856201 */,
+     PRESHIFT(0x012b4000) /*  0.073059082 */,
+     PRESHIFT(0x0080f000) /*  0.031478882 */,
+     PRESHIFT(0x00191000) /*  0.006118774 */,
+     PRESHIFT(0x000d0000) /*  0.003173828 */,
+     PRESHIFT(0x0001a000) /*  0.000396729 */ },
+
+  { -PRESHIFT(0x00001000) /* -0.000015259 */,	/*  2 */
+    -PRESHIFT(0x00023000) /* -0.000534058 */,
+     PRESHIFT(0x000de000) /*  0.003387451 */,
+    -PRESHIFT(0x00245000) /* -0.008865356 */,
+     PRESHIFT(0x007a0000) /*  0.029785156 */,
+    -PRESHIFT(0x016f7000) /* -0.089706421 */,
+     PRESHIFT(0x014a8000) /*  0.080688477 */,
+    -PRESHIFT(0x0a0d8000) /* -0.628295898 */,
+     PRESHIFT(0x12468000) /*  1.142211914 */,
+     PRESHIFT(0x083ff000) /*  0.515609741 */,
+     PRESHIFT(0x01dd8000) /*  0.116577148 */,
+     PRESHIFT(0x01149000) /*  0.067520142 */,
+     PRESHIFT(0x00820000) /*  0.031738281 */,
+     PRESHIFT(0x0015b000) /*  0.005294800 */,
+     PRESHIFT(0x000ca000) /*  0.003082275 */,
+     PRESHIFT(0x00018000) /*  0.000366211 */,
+
+    -PRESHIFT(0x00001000) /* -0.000015259 */,
+    -PRESHIFT(0x00023000) /* -0.000534058 */,
+     PRESHIFT(0x000de000) /*  0.003387451 */,
+    -PRESHIFT(0x00245000) /* -0.008865356 */,
+     PRESHIFT(0x007a0000) /*  0.029785156 */,
+    -PRESHIFT(0x016f7000) /* -0.089706421 */,
+     PRESHIFT(0x014a8000) /*  0.080688477 */,
+    -PRESHIFT(0x0a0d8000) /* -0.628295898 */,
+     PRESHIFT(0x12468000) /*  1.142211914 */,
+     PRESHIFT(0x083ff000) /*  0.515609741 */,
+     PRESHIFT(0x01dd8000) /*  0.116577148 */,
+     PRESHIFT(0x01149000) /*  0.067520142 */,
+     PRESHIFT(0x00820000) /*  0.031738281 */,
+     PRESHIFT(0x0015b000) /*  0.005294800 */,
+     PRESHIFT(0x000ca000) /*  0.003082275 */,
+     PRESHIFT(0x00018000) /*  0.000366211 */ },
+
+  { -PRESHIFT(0x00001000) /* -0.000015259 */,	/*  3 */
+    -PRESHIFT(0x00026000) /* -0.000579834 */,
+     PRESHIFT(0x000e1000) /*  0.003433228 */,
+    -PRESHIFT(0x00285000) /* -0.009841919 */,
+     PRESHIFT(0x00765000) /*  0.028884888 */,
+    -PRESHIFT(0x0185d000) /* -0.095169067 */,
+     PRESHIFT(0x011d1000) /*  0.069595337 */,
+    -PRESHIFT(0x0a7fe000) /* -0.656219482 */,
+     PRESHIFT(0x12386000) /*  1.138763428 */,
+     PRESHIFT(0x07ccb000) /*  0.487472534 */,
+     PRESHIFT(0x01f9c000) /*  0.123474121 */,
+     PRESHIFT(0x00fdf000) /*  0.061996460 */,
+     PRESHIFT(0x00827000) /*  0.031845093 */,
+     PRESHIFT(0x00126000) /*  0.004486084 */,
+     PRESHIFT(0x000c4000) /*  0.002990723 */,
+     PRESHIFT(0x00015000) /*  0.000320435 */,
+
+    -PRESHIFT(0x00001000) /* -0.000015259 */,
+    -PRESHIFT(0x00026000) /* -0.000579834 */,
+     PRESHIFT(0x000e1000) /*  0.003433228 */,
+    -PRESHIFT(0x00285000) /* -0.009841919 */,
+     PRESHIFT(0x00765000) /*  0.028884888 */,
+    -PRESHIFT(0x0185d000) /* -0.095169067 */,
+     PRESHIFT(0x011d1000) /*  0.069595337 */,
+    -PRESHIFT(0x0a7fe000) /* -0.656219482 */,
+     PRESHIFT(0x12386000) /*  1.138763428 */,
+     PRESHIFT(0x07ccb000) /*  0.487472534 */,
+     PRESHIFT(0x01f9c000) /*  0.123474121 */,
+     PRESHIFT(0x00fdf000) /*  0.061996460 */,
+     PRESHIFT(0x00827000) /*  0.031845093 */,
+     PRESHIFT(0x00126000) /*  0.004486084 */,
+     PRESHIFT(0x000c4000) /*  0.002990723 */,
+     PRESHIFT(0x00015000) /*  0.000320435 */ },
+
+  { -PRESHIFT(0x00001000) /* -0.000015259 */,	/*  4 */
+    -PRESHIFT(0x00029000) /* -0.000625610 */,
+     PRESHIFT(0x000e3000) /*  0.003463745 */,
+    -PRESHIFT(0x002c7000) /* -0.010848999 */,
+     PRESHIFT(0x0071e000) /*  0.027801514 */,
+    -PRESHIFT(0x019bd000) /* -0.100540161 */,
+     PRESHIFT(0x00ec0000) /*  0.057617187 */,
+    -PRESHIFT(0x0af15000) /* -0.683914185 */,
+     PRESHIFT(0x12249000) /*  1.133926392 */,
+     PRESHIFT(0x075a0000) /*  0.459472656 */,
+     PRESHIFT(0x0212c000) /*  0.129577637 */,
+     PRESHIFT(0x00e79000) /*  0.056533813 */,
+     PRESHIFT(0x00825000) /*  0.031814575 */,
+     PRESHIFT(0x000f4000) /*  0.003723145 */,
+     PRESHIFT(0x000be000) /*  0.002899170 */,
+     PRESHIFT(0x00013000) /*  0.000289917 */,
+
+    -PRESHIFT(0x00001000) /* -0.000015259 */,
+    -PRESHIFT(0x00029000) /* -0.000625610 */,
+     PRESHIFT(0x000e3000) /*  0.003463745 */,
+    -PRESHIFT(0x002c7000) /* -0.010848999 */,
+     PRESHIFT(0x0071e000) /*  0.027801514 */,
+    -PRESHIFT(0x019bd000) /* -0.100540161 */,
+     PRESHIFT(0x00ec0000) /*  0.057617187 */,
+    -PRESHIFT(0x0af15000) /* -0.683914185 */,
+     PRESHIFT(0x12249000) /*  1.133926392 */,
+     PRESHIFT(0x075a0000) /*  0.459472656 */,
+     PRESHIFT(0x0212c000) /*  0.129577637 */,
+     PRESHIFT(0x00e79000) /*  0.056533813 */,
+     PRESHIFT(0x00825000) /*  0.031814575 */,
+     PRESHIFT(0x000f4000) /*  0.003723145 */,
+     PRESHIFT(0x000be000) /*  0.002899170 */,
+     PRESHIFT(0x00013000) /*  0.000289917 */ },
+
+  { -PRESHIFT(0x00001000) /* -0.000015259 */,	/*  5 */
+    -PRESHIFT(0x0002d000) /* -0.000686646 */,
+     PRESHIFT(0x000e4000) /*  0.003479004 */,
+    -PRESHIFT(0x0030b000) /* -0.011886597 */,
+     PRESHIFT(0x006cb000) /*  0.026535034 */,
+    -PRESHIFT(0x01b17000) /* -0.105819702 */,
+     PRESHIFT(0x00b77000) /*  0.044784546 */,
+    -PRESHIFT(0x0b619000) /* -0.711318970 */,
+     PRESHIFT(0x120b4000) /*  1.127746582 */,
+     PRESHIFT(0x06e81000) /*  0.431655884 */,
+     PRESHIFT(0x02288000) /*  0.134887695 */,
+     PRESHIFT(0x00d17000) /*  0.051132202 */,
+     PRESHIFT(0x0081b000) /*  0.031661987 */,
+     PRESHIFT(0x000c5000) /*  0.003005981 */,
+     PRESHIFT(0x000b7000) /*  0.002792358 */,
+     PRESHIFT(0x00011000) /*  0.000259399 */,
+
+    -PRESHIFT(0x00001000) /* -0.000015259 */,
+    -PRESHIFT(0x0002d000) /* -0.000686646 */,
+     PRESHIFT(0x000e4000) /*  0.003479004 */,
+    -PRESHIFT(0x0030b000) /* -0.011886597 */,
+     PRESHIFT(0x006cb000) /*  0.026535034 */,
+    -PRESHIFT(0x01b17000) /* -0.105819702 */,
+     PRESHIFT(0x00b77000) /*  0.044784546 */,
+    -PRESHIFT(0x0b619000) /* -0.711318970 */,
+     PRESHIFT(0x120b4000) /*  1.127746582 */,
+     PRESHIFT(0x06e81000) /*  0.431655884 */,
+     PRESHIFT(0x02288000) /*  0.134887695 */,
+     PRESHIFT(0x00d17000) /*  0.051132202 */,
+     PRESHIFT(0x0081b000) /*  0.031661987 */,
+     PRESHIFT(0x000c5000) /*  0.003005981 */,
+     PRESHIFT(0x000b7000) /*  0.002792358 */,
+     PRESHIFT(0x00011000) /*  0.000259399 */ },
+
+  { -PRESHIFT(0x00001000) /* -0.000015259 */,	/*  6 */
+    -PRESHIFT(0x00031000) /* -0.000747681 */,
+     PRESHIFT(0x000e4000) /*  0.003479004 */,
+    -PRESHIFT(0x00350000) /* -0.012939453 */,
+     PRESHIFT(0x0066c000) /*  0.025085449 */,
+    -PRESHIFT(0x01c67000) /* -0.110946655 */,
+     PRESHIFT(0x007f5000) /*  0.031082153 */,
+    -PRESHIFT(0x0bd06000) /* -0.738372803 */,
+     PRESHIFT(0x11ec7000) /*  1.120223999 */,
+     PRESHIFT(0x06772000) /*  0.404083252 */,
+     PRESHIFT(0x023b3000) /*  0.139450073 */,
+     PRESHIFT(0x00bbc000) /*  0.045837402 */,
+     PRESHIFT(0x00809000) /*  0.031387329 */,
+     PRESHIFT(0x00099000) /*  0.002334595 */,
+     PRESHIFT(0x000b0000) /*  0.002685547 */,
+     PRESHIFT(0x00010000) /*  0.000244141 */,
+
+    -PRESHIFT(0x00001000) /* -0.000015259 */,
+    -PRESHIFT(0x00031000) /* -0.000747681 */,
+     PRESHIFT(0x000e4000) /*  0.003479004 */,
+    -PRESHIFT(0x00350000) /* -0.012939453 */,
+     PRESHIFT(0x0066c000) /*  0.025085449 */,
+    -PRESHIFT(0x01c67000) /* -0.110946655 */,
+     PRESHIFT(0x007f5000) /*  0.031082153 */,
+    -PRESHIFT(0x0bd06000) /* -0.738372803 */,
+     PRESHIFT(0x11ec7000) /*  1.120223999 */,
+     PRESHIFT(0x06772000) /*  0.404083252 */,
+     PRESHIFT(0x023b3000) /*  0.139450073 */,
+     PRESHIFT(0x00bbc000) /*  0.045837402 */,
+     PRESHIFT(0x00809000) /*  0.031387329 */,
+     PRESHIFT(0x00099000) /*  0.002334595 */,
+     PRESHIFT(0x000b0000) /*  0.002685547 */,
+     PRESHIFT(0x00010000) /*  0.000244141 */ },
+
+  { -PRESHIFT(0x00002000) /* -0.000030518 */,	/*  7 */
+    -PRESHIFT(0x00035000) /* -0.000808716 */,
+     PRESHIFT(0x000e3000) /*  0.003463745 */,
+    -PRESHIFT(0x00397000) /* -0.014022827 */,
+     PRESHIFT(0x005ff000) /*  0.023422241 */,
+    -PRESHIFT(0x01dad000) /* -0.115921021 */,
+     PRESHIFT(0x0043a000) /*  0.016510010 */,
+    -PRESHIFT(0x0c3d9000) /* -0.765029907 */,
+     PRESHIFT(0x11c83000) /*  1.111373901 */,
+     PRESHIFT(0x06076000) /*  0.376800537 */,
+     PRESHIFT(0x024ad000) /*  0.143264771 */,
+     PRESHIFT(0x00a67000) /*  0.040634155 */,
+     PRESHIFT(0x007f0000) /*  0.031005859 */,
+     PRESHIFT(0x0006f000) /*  0.001693726 */,
+     PRESHIFT(0x000a9000) /*  0.002578735 */,
+     PRESHIFT(0x0000e000) /*  0.000213623 */,
+
+    -PRESHIFT(0x00002000) /* -0.000030518 */,
+    -PRESHIFT(0x00035000) /* -0.000808716 */,
+     PRESHIFT(0x000e3000) /*  0.003463745 */,
+    -PRESHIFT(0x00397000) /* -0.014022827 */,
+     PRESHIFT(0x005ff000) /*  0.023422241 */,
+    -PRESHIFT(0x01dad000) /* -0.115921021 */,
+     PRESHIFT(0x0043a000) /*  0.016510010 */,
+    -PRESHIFT(0x0c3d9000) /* -0.765029907 */,
+     PRESHIFT(0x11c83000) /*  1.111373901 */,
+     PRESHIFT(0x06076000) /*  0.376800537 */,
+     PRESHIFT(0x024ad000) /*  0.143264771 */,
+     PRESHIFT(0x00a67000) /*  0.040634155 */,
+     PRESHIFT(0x007f0000) /*  0.031005859 */,
+     PRESHIFT(0x0006f000) /*  0.001693726 */,
+     PRESHIFT(0x000a9000) /*  0.002578735 */,
+     PRESHIFT(0x0000e000) /*  0.000213623 */ },
+
+  { -PRESHIFT(0x00002000) /* -0.000030518 */,	/*  8 */
+    -PRESHIFT(0x0003a000) /* -0.000885010 */,
+     PRESHIFT(0x000e0000) /*  0.003417969 */,
+    -PRESHIFT(0x003df000) /* -0.015121460 */,
+     PRESHIFT(0x00586000) /*  0.021575928 */,
+    -PRESHIFT(0x01ee6000) /* -0.120697021 */,
+     PRESHIFT(0x00046000) /*  0.001068115 */,
+    -PRESHIFT(0x0ca8d000) /* -0.791213989 */,
+     PRESHIFT(0x119e9000) /*  1.101211548 */,
+     PRESHIFT(0x05991000) /*  0.349868774 */,
+     PRESHIFT(0x02578000) /*  0.146362305 */,
+     PRESHIFT(0x0091a000) /*  0.035552979 */,
+     PRESHIFT(0x007d1000) /*  0.030532837 */,
+     PRESHIFT(0x00048000) /*  0.001098633 */,
+     PRESHIFT(0x000a1000) /*  0.002456665 */,
+     PRESHIFT(0x0000d000) /*  0.000198364 */,
+
+    -PRESHIFT(0x00002000) /* -0.000030518 */,
+    -PRESHIFT(0x0003a000) /* -0.000885010 */,
+     PRESHIFT(0x000e0000) /*  0.003417969 */,
+    -PRESHIFT(0x003df000) /* -0.015121460 */,
+     PRESHIFT(0x00586000) /*  0.021575928 */,
+    -PRESHIFT(0x01ee6000) /* -0.120697021 */,
+     PRESHIFT(0x00046000) /*  0.001068115 */,
+    -PRESHIFT(0x0ca8d000) /* -0.791213989 */,
+     PRESHIFT(0x119e9000) /*  1.101211548 */,
+     PRESHIFT(0x05991000) /*  0.349868774 */,
+     PRESHIFT(0x02578000) /*  0.146362305 */,
+     PRESHIFT(0x0091a000) /*  0.035552979 */,
+     PRESHIFT(0x007d1000) /*  0.030532837 */,
+     PRESHIFT(0x00048000) /*  0.001098633 */,
+     PRESHIFT(0x000a1000) /*  0.002456665 */,
+     PRESHIFT(0x0000d000) /*  0.000198364 */ },
+
+  { -PRESHIFT(0x00002000) /* -0.000030518 */,	/*  9 */
+    -PRESHIFT(0x0003f000) /* -0.000961304 */,
+     PRESHIFT(0x000dd000) /*  0.003372192 */,
+    -PRESHIFT(0x00428000) /* -0.016235352 */,
+     PRESHIFT(0x00500000) /*  0.019531250 */,
+    -PRESHIFT(0x02011000) /* -0.125259399 */,
+    -PRESHIFT(0x003e6000) /* -0.015228271 */,
+    -PRESHIFT(0x0d11e000) /* -0.816864014 */,
+     PRESHIFT(0x116fc000) /*  1.089782715 */,
+     PRESHIFT(0x052c5000) /*  0.323318481 */,
+     PRESHIFT(0x02616000) /*  0.148773193 */,
+     PRESHIFT(0x007d6000) /*  0.030609131 */,
+     PRESHIFT(0x007aa000) /*  0.029937744 */,
+     PRESHIFT(0x00024000) /*  0.000549316 */,
+     PRESHIFT(0x0009a000) /*  0.002349854 */,
+     PRESHIFT(0x0000b000) /*  0.000167847 */,
+
+    -PRESHIFT(0x00002000) /* -0.000030518 */,
+    -PRESHIFT(0x0003f000) /* -0.000961304 */,
+     PRESHIFT(0x000dd000) /*  0.003372192 */,
+    -PRESHIFT(0x00428000) /* -0.016235352 */,
+     PRESHIFT(0x00500000) /*  0.019531250 */,
+    -PRESHIFT(0x02011000) /* -0.125259399 */,
+    -PRESHIFT(0x003e6000) /* -0.015228271 */,
+    -PRESHIFT(0x0d11e000) /* -0.816864014 */,
+     PRESHIFT(0x116fc000) /*  1.089782715 */,
+     PRESHIFT(0x052c5000) /*  0.323318481 */,
+     PRESHIFT(0x02616000) /*  0.148773193 */,
+     PRESHIFT(0x007d6000) /*  0.030609131 */,
+     PRESHIFT(0x007aa000) /*  0.029937744 */,
+     PRESHIFT(0x00024000) /*  0.000549316 */,
+     PRESHIFT(0x0009a000) /*  0.002349854 */,
+     PRESHIFT(0x0000b000) /*  0.000167847 */ },
+
+  { -PRESHIFT(0x00002000) /* -0.000030518 */,	/* 10 */
+    -PRESHIFT(0x00044000) /* -0.001037598 */,
+     PRESHIFT(0x000d7000) /*  0.003280640 */,
+    -PRESHIFT(0x00471000) /* -0.017349243 */,
+     PRESHIFT(0x0046b000) /*  0.017257690 */,
+    -PRESHIFT(0x0212b000) /* -0.129562378 */,
+    -PRESHIFT(0x0084a000) /* -0.032379150 */,
+    -PRESHIFT(0x0d78a000) /* -0.841949463 */,
+     PRESHIFT(0x113be000) /*  1.077117920 */,
+     PRESHIFT(0x04c16000) /*  0.297210693 */,
+     PRESHIFT(0x02687000) /*  0.150497437 */,
+     PRESHIFT(0x0069c000) /*  0.025817871 */,
+     PRESHIFT(0x0077f000) /*  0.029281616 */,
+     PRESHIFT(0x00002000) /*  0.000030518 */,
+     PRESHIFT(0x00093000) /*  0.002243042 */,
+     PRESHIFT(0x0000a000) /*  0.000152588 */,
+
+    -PRESHIFT(0x00002000) /* -0.000030518 */,
+    -PRESHIFT(0x00044000) /* -0.001037598 */,
+     PRESHIFT(0x000d7000) /*  0.003280640 */,
+    -PRESHIFT(0x00471000) /* -0.017349243 */,
+     PRESHIFT(0x0046b000) /*  0.017257690 */,
+    -PRESHIFT(0x0212b000) /* -0.129562378 */,
+    -PRESHIFT(0x0084a000) /* -0.032379150 */,
+    -PRESHIFT(0x0d78a000) /* -0.841949463 */,
+     PRESHIFT(0x113be000) /*  1.077117920 */,
+     PRESHIFT(0x04c16000) /*  0.297210693 */,
+     PRESHIFT(0x02687000) /*  0.150497437 */,
+     PRESHIFT(0x0069c000) /*  0.025817871 */,
+     PRESHIFT(0x0077f000) /*  0.029281616 */,
+     PRESHIFT(0x00002000) /*  0.000030518 */,
+     PRESHIFT(0x00093000) /*  0.002243042 */,
+     PRESHIFT(0x0000a000) /*  0.000152588 */ },
+
+  { -PRESHIFT(0x00003000) /* -0.000045776 */,	/* 11 */
+    -PRESHIFT(0x00049000) /* -0.001113892 */,
+     PRESHIFT(0x000d0000) /*  0.003173828 */,
+    -PRESHIFT(0x004ba000) /* -0.018463135 */,
+     PRESHIFT(0x003ca000) /*  0.014801025 */,
+    -PRESHIFT(0x02233000) /* -0.133590698 */,
+    -PRESHIFT(0x00ce4000) /* -0.050354004 */,
+    -PRESHIFT(0x0ddca000) /* -0.866363525 */,
+     PRESHIFT(0x1102f000) /*  1.063217163 */,
+     PRESHIFT(0x04587000) /*  0.271591187 */,
+     PRESHIFT(0x026cf000) /*  0.151596069 */,
+     PRESHIFT(0x0056c000) /*  0.021179199 */,
+     PRESHIFT(0x0074e000) /*  0.028533936 */,
+    -PRESHIFT(0x0001d000) /* -0.000442505 */,
+     PRESHIFT(0x0008b000) /*  0.002120972 */,
+     PRESHIFT(0x00009000) /*  0.000137329 */,
+
+    -PRESHIFT(0x00003000) /* -0.000045776 */,
+    -PRESHIFT(0x00049000) /* -0.001113892 */,
+     PRESHIFT(0x000d0000) /*  0.003173828 */,
+    -PRESHIFT(0x004ba000) /* -0.018463135 */,
+     PRESHIFT(0x003ca000) /*  0.014801025 */,
+    -PRESHIFT(0x02233000) /* -0.133590698 */,
+    -PRESHIFT(0x00ce4000) /* -0.050354004 */,
+    -PRESHIFT(0x0ddca000) /* -0.866363525 */,
+     PRESHIFT(0x1102f000) /*  1.063217163 */,
+     PRESHIFT(0x04587000) /*  0.271591187 */,
+     PRESHIFT(0x026cf000) /*  0.151596069 */,
+     PRESHIFT(0x0056c000) /*  0.021179199 */,
+     PRESHIFT(0x0074e000) /*  0.028533936 */,
+    -PRESHIFT(0x0001d000) /* -0.000442505 */,
+     PRESHIFT(0x0008b000) /*  0.002120972 */,
+     PRESHIFT(0x00009000) /*  0.000137329 */ },
+
+  { -PRESHIFT(0x00003000) /* -0.000045776 */,	/* 12 */
+    -PRESHIFT(0x0004f000) /* -0.001205444 */,
+     PRESHIFT(0x000c8000) /*  0.003051758 */,
+    -PRESHIFT(0x00503000) /* -0.019577026 */,
+     PRESHIFT(0x0031a000) /*  0.012115479 */,
+    -PRESHIFT(0x02326000) /* -0.137298584 */,
+    -PRESHIFT(0x011b5000) /* -0.069168091 */,
+    -PRESHIFT(0x0e3dd000) /* -0.890090942 */,
+     PRESHIFT(0x10c54000) /*  1.048156738 */,
+     PRESHIFT(0x03f1b000) /*  0.246505737 */,
+     PRESHIFT(0x026ee000) /*  0.152069092 */,
+     PRESHIFT(0x00447000) /*  0.016708374 */,
+     PRESHIFT(0x00719000) /*  0.027725220 */,
+    -PRESHIFT(0x00039000) /* -0.000869751 */,
+     PRESHIFT(0x00084000) /*  0.002014160 */,
+     PRESHIFT(0x00008000) /*  0.000122070 */,
+
+    -PRESHIFT(0x00003000) /* -0.000045776 */,
+    -PRESHIFT(0x0004f000) /* -0.001205444 */,
+     PRESHIFT(0x000c8000) /*  0.003051758 */,
+    -PRESHIFT(0x00503000) /* -0.019577026 */,
+     PRESHIFT(0x0031a000) /*  0.012115479 */,
+    -PRESHIFT(0x02326000) /* -0.137298584 */,
+    -PRESHIFT(0x011b5000) /* -0.069168091 */,
+    -PRESHIFT(0x0e3dd000) /* -0.890090942 */,
+     PRESHIFT(0x10c54000) /*  1.048156738 */,
+     PRESHIFT(0x03f1b000) /*  0.246505737 */,
+     PRESHIFT(0x026ee000) /*  0.152069092 */,
+     PRESHIFT(0x00447000) /*  0.016708374 */,
+     PRESHIFT(0x00719000) /*  0.027725220 */,
+    -PRESHIFT(0x00039000) /* -0.000869751 */,
+     PRESHIFT(0x00084000) /*  0.002014160 */,
+     PRESHIFT(0x00008000) /*  0.000122070 */ },
+
+  { -PRESHIFT(0x00004000) /* -0.000061035 */,	/* 13 */
+    -PRESHIFT(0x00055000) /* -0.001296997 */,
+     PRESHIFT(0x000bd000) /*  0.002883911 */,
+    -PRESHIFT(0x0054c000) /* -0.020690918 */,
+     PRESHIFT(0x0025d000) /*  0.009231567 */,
+    -PRESHIFT(0x02403000) /* -0.140670776 */,
+    -PRESHIFT(0x016ba000) /* -0.088775635 */,
+    -PRESHIFT(0x0e9be000) /* -0.913055420 */,
+     PRESHIFT(0x1082d000) /*  1.031936646 */,
+     PRESHIFT(0x038d4000) /*  0.221984863 */,
+     PRESHIFT(0x026e7000) /*  0.151962280 */,
+     PRESHIFT(0x0032e000) /*  0.012420654 */,
+     PRESHIFT(0x006df000) /*  0.026840210 */,
+    -PRESHIFT(0x00053000) /* -0.001266479 */,
+     PRESHIFT(0x0007d000) /*  0.001907349 */,
+     PRESHIFT(0x00007000) /*  0.000106812 */,
+
+    -PRESHIFT(0x00004000) /* -0.000061035 */,
+    -PRESHIFT(0x00055000) /* -0.001296997 */,
+     PRESHIFT(0x000bd000) /*  0.002883911 */,
+    -PRESHIFT(0x0054c000) /* -0.020690918 */,
+     PRESHIFT(0x0025d000) /*  0.009231567 */,
+    -PRESHIFT(0x02403000) /* -0.140670776 */,
+    -PRESHIFT(0x016ba000) /* -0.088775635 */,
+    -PRESHIFT(0x0e9be000) /* -0.913055420 */,
+     PRESHIFT(0x1082d000) /*  1.031936646 */,
+     PRESHIFT(0x038d4000) /*  0.221984863 */,
+     PRESHIFT(0x026e7000) /*  0.151962280 */,
+     PRESHIFT(0x0032e000) /*  0.012420654 */,
+     PRESHIFT(0x006df000) /*  0.026840210 */,
+    -PRESHIFT(0x00053000) /* -0.001266479 */,
+     PRESHIFT(0x0007d000) /*  0.001907349 */,
+     PRESHIFT(0x00007000) /*  0.000106812 */ },
+
+  { -PRESHIFT(0x00004000) /* -0.000061035 */,	/* 14 */
+    -PRESHIFT(0x0005b000) /* -0.001388550 */,
+     PRESHIFT(0x000b1000) /*  0.002700806 */,
+    -PRESHIFT(0x00594000) /* -0.021789551 */,
+     PRESHIFT(0x00192000) /*  0.006134033 */,
+    -PRESHIFT(0x024c8000) /* -0.143676758 */,
+    -PRESHIFT(0x01bf2000) /* -0.109161377 */,
+    -PRESHIFT(0x0ef69000) /* -0.935195923 */,
+     PRESHIFT(0x103be000) /*  1.014617920 */,
+     PRESHIFT(0x032b4000) /*  0.198059082 */,
+     PRESHIFT(0x026bc000) /*  0.151306152 */,
+     PRESHIFT(0x00221000) /*  0.008316040 */,
+     PRESHIFT(0x006a2000) /*  0.025909424 */,
+    -PRESHIFT(0x0006a000) /* -0.001617432 */,
+     PRESHIFT(0x00075000) /*  0.001785278 */,
+     PRESHIFT(0x00007000) /*  0.000106812 */,
+
+    -PRESHIFT(0x00004000) /* -0.000061035 */,
+    -PRESHIFT(0x0005b000) /* -0.001388550 */,
+     PRESHIFT(0x000b1000) /*  0.002700806 */,
+    -PRESHIFT(0x00594000) /* -0.021789551 */,
+     PRESHIFT(0x00192000) /*  0.006134033 */,
+    -PRESHIFT(0x024c8000) /* -0.143676758 */,
+    -PRESHIFT(0x01bf2000) /* -0.109161377 */,
+    -PRESHIFT(0x0ef69000) /* -0.935195923 */,
+     PRESHIFT(0x103be000) /*  1.014617920 */,
+     PRESHIFT(0x032b4000) /*  0.198059082 */,
+     PRESHIFT(0x026bc000) /*  0.151306152 */,
+     PRESHIFT(0x00221000) /*  0.008316040 */,
+     PRESHIFT(0x006a2000) /*  0.025909424 */,
+    -PRESHIFT(0x0006a000) /* -0.001617432 */,
+     PRESHIFT(0x00075000) /*  0.001785278 */,
+     PRESHIFT(0x00007000) /*  0.000106812 */ },
+
+  { -PRESHIFT(0x00005000) /* -0.000076294 */,	/* 15 */
+    -PRESHIFT(0x00061000) /* -0.001480103 */,
+     PRESHIFT(0x000a3000) /*  0.002487183 */,
+    -PRESHIFT(0x005da000) /* -0.022857666 */,
+     PRESHIFT(0x000b9000) /*  0.002822876 */,
+    -PRESHIFT(0x02571000) /* -0.146255493 */,
+    -PRESHIFT(0x0215c000) /* -0.130310059 */,
+    -PRESHIFT(0x0f4dc000) /* -0.956481934 */,
+     PRESHIFT(0x0ff0a000) /*  0.996246338 */,
+     PRESHIFT(0x02cbf000) /*  0.174789429 */,
+     PRESHIFT(0x0266e000) /*  0.150115967 */,
+     PRESHIFT(0x00120000) /*  0.004394531 */,
+     PRESHIFT(0x00662000) /*  0.024932861 */,
+    -PRESHIFT(0x0007f000) /* -0.001937866 */,
+     PRESHIFT(0x0006f000) /*  0.001693726 */,
+     PRESHIFT(0x00006000) /*  0.000091553 */,
+
+    -PRESHIFT(0x00005000) /* -0.000076294 */,
+    -PRESHIFT(0x00061000) /* -0.001480103 */,
+     PRESHIFT(0x000a3000) /*  0.002487183 */,
+    -PRESHIFT(0x005da000) /* -0.022857666 */,
+     PRESHIFT(0x000b9000) /*  0.002822876 */,
+    -PRESHIFT(0x02571000) /* -0.146255493 */,
+    -PRESHIFT(0x0215c000) /* -0.130310059 */,
+    -PRESHIFT(0x0f4dc000) /* -0.956481934 */,
+     PRESHIFT(0x0ff0a000) /*  0.996246338 */,
+     PRESHIFT(0x02cbf000) /*  0.174789429 */,
+     PRESHIFT(0x0266e000) /*  0.150115967 */,
+     PRESHIFT(0x00120000) /*  0.004394531 */,
+     PRESHIFT(0x00662000) /*  0.024932861 */,
+    -PRESHIFT(0x0007f000) /* -0.001937866 */,
+     PRESHIFT(0x0006f000) /*  0.001693726 */,
+     PRESHIFT(0x00006000) /*  0.000091553 */ },
+
+  { -PRESHIFT(0x00005000) /* -0.000076294 */,	/* 16 */
+    -PRESHIFT(0x00068000) /* -0.001586914 */,
+     PRESHIFT(0x00092000) /*  0.002227783 */,
+    -PRESHIFT(0x0061f000) /* -0.023910522 */,
+    -PRESHIFT(0x0002d000) /* -0.000686646 */,
+    -PRESHIFT(0x025ff000) /* -0.148422241 */,
+    -PRESHIFT(0x026f7000) /* -0.152206421 */,
+    -PRESHIFT(0x0fa13000) /* -0.976852417 */,
+     PRESHIFT(0x0fa13000) /*  0.976852417 */,
+     PRESHIFT(0x026f7000) /*  0.152206421 */,
+     PRESHIFT(0x025ff000) /*  0.148422241 */,
+     PRESHIFT(0x0002d000) /*  0.000686646 */,
+     PRESHIFT(0x0061f000) /*  0.023910522 */,
+    -PRESHIFT(0x00092000) /* -0.002227783 */,
+     PRESHIFT(0x00068000) /*  0.001586914 */,
+     PRESHIFT(0x00005000) /*  0.000076294 */,
+
+    -PRESHIFT(0x00005000) /* -0.000076294 */,
+    -PRESHIFT(0x00068000) /* -0.001586914 */,
+     PRESHIFT(0x00092000) /*  0.002227783 */,
+    -PRESHIFT(0x0061f000) /* -0.023910522 */,
+    -PRESHIFT(0x0002d000) /* -0.000686646 */,
+    -PRESHIFT(0x025ff000) /* -0.148422241 */,
+    -PRESHIFT(0x026f7000) /* -0.152206421 */,
+    -PRESHIFT(0x0fa13000) /* -0.976852417 */,
+     PRESHIFT(0x0fa13000) /*  0.976852417 */,
+     PRESHIFT(0x026f7000) /*  0.152206421 */,
+     PRESHIFT(0x025ff000) /*  0.148422241 */,
+     PRESHIFT(0x0002d000) /*  0.000686646 */,
+     PRESHIFT(0x0061f000) /*  0.023910522 */,
+    -PRESHIFT(0x00092000) /* -0.002227783 */,
+     PRESHIFT(0x00068000) /*  0.001586914 */,
+     PRESHIFT(0x00005000) /*  0.000076294 */ }

+ 1 - 0
sys/src/games/mp3dec/README

@@ -0,0 +1 @@
+This is a copy of libmad-0.15.1b minimally ported to Plan 9.

+ 0 - 266
sys/src/games/mp3dec/audio.c

@@ -1,266 +0,0 @@
-
-#include "mpg123.h"
-
-void audio_info_struct_init(struct audio_info_struct *ai)
-{
-#ifdef AUDIO_USES_FD
-  ai->fn = -1;
-#endif
-#ifdef SGI
-#if 0
-  ALconfig config;
-  ALport port;
-#endif
-#endif
-  ai->rate = -1;
-  ai->gain = -1;
-  ai->output = -1;
-#ifdef ALSA
-  ai->handle = NULL;
-  ai->alsa_format.format = -1;
-  ai->alsa_format.rate = -1;
-  ai->alsa_format.channels = -1;
-#endif
-  ai->device = NULL;
-  ai->channels = -1;
-  ai->format = -1;
-}
-
-#define NUM_CHANNELS 2
-#define NUM_ENCODINGS 6
-#define NUM_RATES 10
-
-struct audio_name audio_val2name[NUM_ENCODINGS+1] = {
- { AUDIO_FORMAT_SIGNED_16  , "signed 16 bit" , "s16 " } ,
- { AUDIO_FORMAT_UNSIGNED_16, "unsigned 16 bit" , "u16 " } ,  
- { AUDIO_FORMAT_UNSIGNED_8 , "unsigned 8 bit" , "u8  " } ,
- { AUDIO_FORMAT_SIGNED_8   , "signed 8 bit" , "s8  " } ,
- { AUDIO_FORMAT_ULAW_8     , "mu-law (8 bit)" , "ulaw " } ,
- { AUDIO_FORMAT_ALAW_8     , "a-law (8 bit)" , "alaw " } ,
- { -1 , NULL }
-};
-
-#if 0
-static char *channel_name[NUM_CHANNELS] = 
- { "mono" , "stereo" };
-#endif
-
-static int channels[NUM_CHANNELS] = { 1 , 2 };
-static int rates[NUM_RATES] = { 
-	 8000, 11025, 12000, 
-	16000, 22050, 24000,
-	32000, 44100, 48000,
-	8000	/* 8000 = dummy for user forced */
-
-};
-static int encodings[NUM_ENCODINGS] = {
- AUDIO_FORMAT_SIGNED_16, 
- AUDIO_FORMAT_UNSIGNED_16,
- AUDIO_FORMAT_UNSIGNED_8,
- AUDIO_FORMAT_SIGNED_8,
- AUDIO_FORMAT_ULAW_8,
- AUDIO_FORMAT_ALAW_8
-};
-
-static char capabilities[NUM_CHANNELS][NUM_ENCODINGS][NUM_RATES];
-
-void audio_capabilities(struct audio_info_struct *ai)
-{
-	int fmts;
-	int i,j,k,k1=NUM_RATES-1;
-	struct audio_info_struct ai1 = *ai;
-
-        if (param.outmode != DECODE_AUDIO) {
-		memset(capabilities,1,sizeof(capabilities));
-		return;
-	}
-
-	memset(capabilities,0,sizeof(capabilities));
-	if(param.force_rate) {
-		rates[NUM_RATES-1] = param.force_rate;
-		k1 = NUM_RATES;
-	}
-
-	if(audio_open(&ai1) < 0) {
-		perror("audio");
-		exit(1);
-	}
-
-	for(i=0;i<NUM_CHANNELS;i++) {
-		for(j=0;j<NUM_RATES;j++) {
-			ai1.channels = channels[i];
-			ai1.rate = rates[j];
-			fmts = audio_get_formats(&ai1);
-			if(fmts < 0)
-				continue;
-			for(k=0;k<NUM_ENCODINGS;k++) {
-				if((fmts & encodings[k]) == encodings[k])
-					capabilities[i][k][j] = 1;
-			}
-		}
-	}
-
-	audio_close(&ai1);
-
-	if(param.verbose > 1) {
-		fprintf(stderr,"\nAudio capabilities:\n        |");
-		for(j=0;j<NUM_ENCODINGS;j++) {
-			fprintf(stderr," %5s |",audio_val2name[j].sname);
-		}
-		fprintf(stderr,"\n --------------------------------------------------------\n");
-		for(k=0;k<k1;k++) {
-			fprintf(stderr," %5d  |",rates[k]);
-			for(j=0;j<NUM_ENCODINGS;j++) {
-				if(capabilities[0][j][k]) {
-					if(capabilities[1][j][k])
-						fprintf(stderr,"  M/S  |");
-					else
-						fprintf(stderr,"   M   |");
-				}
-				else if(capabilities[1][j][k])
-					fprintf(stderr,"   S   |");
-				else
-					fprintf(stderr,"       |");
-			}
-			fprintf(stderr,"\n");
-		}
-		fprintf(stderr,"\n");
-	}
-}
-
-static int rate2num(int r)
-{
-	int i;
-	for(i=0;i<NUM_RATES;i++) 
-		if(rates[i] == r)
-			return i;
-	return -1;
-}
-
-
-static int audio_fit_cap_helper(struct audio_info_struct *ai,int rn,int f0,int f2,int c)
-{
-	int i;
-
-        if(rn >= 0) {
-                for(i=f0;i<f2;i++) {
-                        if(capabilities[c][i][rn]) {
-                                ai->rate = rates[rn];
-                                ai->format = encodings[i];
-                                ai->channels = channels[c];
-				return 1;
-                        }
-                }
-        }
-	return 0;
-
-}
-
-/*
- * c=num of channels of stream
- * r=rate of stream
- */
-void audio_fit_capabilities(struct audio_info_struct *ai,int c,int r)
-{
-	int rn;
-	int f0=0;
-	
-	if(param.force_8bit) {
-		f0 = 2;
-	}
-
-	c--; /* stereo=1 ,mono=0 */
-
-	if(param.force_mono >= 0)
-		c = 0;
-	if(param.force_stereo)
-		c = 1;
-
-	if(param.force_rate) {
-		rn = rate2num(param.force_rate);
-		if(audio_fit_cap_helper(ai,rn,f0,2,c))
-			return;
-		if(audio_fit_cap_helper(ai,rn,2,NUM_ENCODINGS,c))
-			return;
-
-		if(c == 1 && !param.force_stereo)
-			c = 0;
-		else if(c == 0 && !param.force_mono)
-			c = 1;
-
-		if(audio_fit_cap_helper(ai,rn,f0,2,c))
-			return;
-		if(audio_fit_cap_helper(ai,rn,2,NUM_ENCODINGS,c))
-			return;
-
-		fprintf(stderr,"No supported rate found!\n");
-		exit(1);
-	}
-
-	rn = rate2num(r>>0);
-	if(audio_fit_cap_helper(ai,rn,f0,2,c))
-		return;
-	rn = rate2num(r>>1);
-	if(audio_fit_cap_helper(ai,rn,f0,2,c))
-		return;
-	rn = rate2num(r>>2);
-	if(audio_fit_cap_helper(ai,rn,f0,2,c))
-		return;
-
-	rn = rate2num(r>>0);
-	if(audio_fit_cap_helper(ai,rn,2,NUM_ENCODINGS,c))
-		return;
-	rn = rate2num(r>>1);
-	if(audio_fit_cap_helper(ai,rn,2,NUM_ENCODINGS,c))
-		return;
-	rn = rate2num(r>>2);
-	if(audio_fit_cap_helper(ai,rn,2,NUM_ENCODINGS,c))
-		return;
-
-
-        if(c == 1 && !param.force_stereo)
-		c = 0;
-        else if(c == 0 && !param.force_mono)
-                c = 1;
-
-        rn = rate2num(r>>0);
-        if(audio_fit_cap_helper(ai,rn,f0,2,c))
-                return;
-        rn = rate2num(r>>1);
-        if(audio_fit_cap_helper(ai,rn,f0,2,c))
-                return;
-        rn = rate2num(r>>2);
-        if(audio_fit_cap_helper(ai,rn,f0,2,c))
-                return;
-
-        rn = rate2num(r>>0);
-        if(audio_fit_cap_helper(ai,rn,2,NUM_ENCODINGS,c))
-                return;
-        rn = rate2num(r>>1);
-        if(audio_fit_cap_helper(ai,rn,2,NUM_ENCODINGS,c))
-                return;
-        rn = rate2num(r>>2);
-        if(audio_fit_cap_helper(ai,rn,2,NUM_ENCODINGS,c))
-                return;
-
-	fprintf(stderr,"No supported rate found!\n");
-	exit(1);
-}
-
-char *audio_encoding_name(int format)
-{
-	int i;
-
-	for(i=0;i<NUM_ENCODINGS;i++) {
-		if(audio_val2name[i].val == format)
-			return audio_val2name[i].name;
-	}
-	return "Unknown";
-}
-
-#if !defined(SOLARIS) && !defined(__NetBSD__) || defined(NAS)
-void audio_queueflush(struct audio_info_struct *ai)
-{
-}
-#endif
-

+ 0 - 89
sys/src/games/mp3dec/audio.h

@@ -1,89 +0,0 @@
-/* 
- * Audio 'LIB' defines
- */
-
-#define AUDIO_OUT_HEADPHONES       0x01
-#define AUDIO_OUT_INTERNAL_SPEAKER 0x02
-#define AUDIO_OUT_LINE_OUT         0x04
-
-enum { DECODE_TEST, DECODE_AUDIO, DECODE_FILE, DECODE_BUFFER, DECODE_WAV,
-	DECODE_AU,DECODE_CDR,DECODE_AUDIOFILE };
-
-#define AUDIO_FORMAT_MASK	  0x100
-#define AUDIO_FORMAT_16		  0x100
-#define AUDIO_FORMAT_8		  0x000
-
-#define AUDIO_FORMAT_SIGNED_16    0x110
-#define AUDIO_FORMAT_UNSIGNED_16  0x120
-#define AUDIO_FORMAT_UNSIGNED_8   0x1
-#define AUDIO_FORMAT_SIGNED_8     0x2
-#define AUDIO_FORMAT_ULAW_8       0x4
-#define AUDIO_FORMAT_ALAW_8       0x8
-
-/* 3% rate tolerance */
-#define AUDIO_RATE_TOLERANCE	  3
-
-#if 0
-#if defined(HPUX) || defined(SUNOS) || defined(SOLARIS) || defined(OSS) || defined(__NetBSD__) || defined(SPARCLINUX) || defined(__FreeBSD__)
-#endif
-#endif
-
-#define AUDIO_USES_FD
-
-#ifdef SGI
-/* #include <audio.h> */
-#include <dmedia/audio.h>
-#endif
-
-
-#ifdef ALSA
-#include <sys/asoundlib.h>
-#endif
-
-struct audio_info_struct
-{
-#ifdef AUDIO_USES_FD
-  int fn; /* filenumber */
-#endif
-#ifdef SGI
-  ALconfig config;
-  ALport port;
-#endif
-  long rate;
-  long gain;
-  int output;
-#ifdef ALSA
-  void *handle;
-  snd_pcm_format_t alsa_format;
-#endif
-  char *device;
-  int channels;
-  int format;
-  int private1;
-  void *private2;
-};
-
-struct audio_name {
-  int  val;
-  char *name;
-  char *sname;
-};
-
-extern void audio_capabilities(struct audio_info_struct *);
-extern void audio_fit_capabilities(struct audio_info_struct *ai,int c,int r);
-
-extern char *audio_encoding_name(int format);
-
-extern int audio_play_samples(struct audio_info_struct *,unsigned char *,int);
-extern int audio_open(struct audio_info_struct *);
-extern int audio_reset_parameters(struct audio_info_struct *);
-extern int audio_rate_best_match(struct audio_info_struct *ai);
-extern int audio_set_rate(struct audio_info_struct *);
-extern int audio_set_format(struct audio_info_struct *);
-extern int audio_get_formats(struct audio_info_struct *);
-extern int audio_set_channels(struct audio_info_struct *);
-extern int audio_write_sample(struct audio_info_struct *,short *,int);
-extern int audio_close(struct audio_info_struct *);
-extern void audio_info_struct_init(struct audio_info_struct *);
-extern void audio_queueflush(struct audio_info_struct *ai);
-

+ 0 - 48
sys/src/games/mp3dec/audio_dummy.c

@@ -1,48 +0,0 @@
-
-#include "mpg123.h"
-
-int audio_open(struct audio_info_struct *ai)
-{
-  fprintf(stderr,"No audio device support compiled into this binary (use -s).\n");
-  return -1;
-}
-
-int audio_reset_parameters(struct audio_info_struct *ai)
-{
-  return 0;
-}
-
-int audio_rate_best_match(struct audio_info_struct *ai)
-{
-  return 0;
-}
-
-int audio_set_rate(struct audio_info_struct *ai)
-{
-  return 0;
-}
-
-int audio_set_channels(struct audio_info_struct *ai)
-{
-  return 0;
-}
-
-int audio_set_format(struct audio_info_struct *ai)
-{
-  return 0;
-}
-
-int audio_get_formats(struct audio_info_struct *ai)
-{
-  return AUDIO_FORMAT_SIGNED_16;
-}
-
-int audio_play_samples(struct audio_info_struct *ai,unsigned char *buf,int len)
-{
-  return len;
-}
-
-int audio_close(struct audio_info_struct *ai)
-{
-  return 0;
-}

+ 237 - 0
sys/src/games/mp3dec/bit.c

@@ -0,0 +1,237 @@
+/*
+ * libmad - MPEG audio decoder library
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * $Id: bit.c,v 1.12 2004/01/23 09:41:32 rob Exp $
+ */
+
+# ifdef HAVE_CONFIG_H
+#  include "config.h"
+# endif
+
+# include "global.h"
+
+# ifdef HAVE_LIMITS_H
+#  include <limits.h>
+# else
+#  define CHAR_BIT  8
+# endif
+
+# include "bit.h"
+
+/*
+ * This is the lookup table for computing the CRC-check word.
+ * As described in section 2.4.3.1 and depicted in Figure A.9
+ * of ISO/IEC 11172-3, the generator polynomial is:
+ *
+ * G(X) = X^16 + X^15 + X^2 + 1
+ */
+static
+unsigned short const crc_table[256] = {
+  0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
+  0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
+  0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
+  0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
+  0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2,
+  0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1,
+  0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1,
+  0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082,
+
+  0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192,
+  0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1,
+  0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1,
+  0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2,
+  0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151,
+  0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162,
+  0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132,
+  0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101,
+
+  0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312,
+  0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321,
+  0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371,
+  0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342,
+  0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1,
+  0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2,
+  0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2,
+  0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381,
+
+  0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291,
+  0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2,
+  0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2,
+  0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1,
+  0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252,
+  0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261,
+  0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
+  0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202
+};
+
+# define CRC_POLY  0x8005
+
+/*
+ * NAME:	bit->init()
+ * DESCRIPTION:	initialize bit pointer struct
+ */
+void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte)
+{
+  bitptr->byte  = byte;
+  bitptr->cache = 0;
+  bitptr->left  = CHAR_BIT;
+}
+
+/*
+ * NAME:	bit->length()
+ * DESCRIPTION:	return number of bits between start and end points
+ */
+unsigned int mad_bit_length(struct mad_bitptr const *begin,
+			    struct mad_bitptr const *end)
+{
+  return begin->left +
+    CHAR_BIT * (end->byte - (begin->byte + 1)) + (CHAR_BIT - end->left);
+}
+
+/*
+ * NAME:	bit->nextbyte()
+ * DESCRIPTION:	return pointer to next unprocessed byte
+ */
+unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr)
+{
+  return bitptr->left == CHAR_BIT ? bitptr->byte : bitptr->byte + 1;
+}
+
+/*
+ * NAME:	bit->skip()
+ * DESCRIPTION:	advance bit pointer
+ */
+void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len)
+{
+  bitptr->byte += len / CHAR_BIT;
+  bitptr->left -= len % CHAR_BIT;
+
+  if (bitptr->left > CHAR_BIT) {
+    bitptr->byte++;
+    bitptr->left += CHAR_BIT;
+  }
+
+  if (bitptr->left < CHAR_BIT)
+    bitptr->cache = *bitptr->byte;
+}
+
+/*
+ * NAME:	bit->read()
+ * DESCRIPTION:	read an arbitrary number of bits and return their UIMSBF value
+ */
+unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len)
+{
+  register unsigned long value;
+
+  if (bitptr->left == CHAR_BIT)
+    bitptr->cache = *bitptr->byte;
+
+  if (len < bitptr->left) {
+    value = (bitptr->cache & ((1 << bitptr->left) - 1)) >>
+      (bitptr->left - len);
+    bitptr->left -= len;
+
+    return value;
+  }
+
+  /* remaining bits in current byte */
+
+  value = bitptr->cache & ((1 << bitptr->left) - 1);
+  len  -= bitptr->left;
+
+  bitptr->byte++;
+  bitptr->left = CHAR_BIT;
+
+  /* more bytes */
+
+  while (len >= CHAR_BIT) {
+    value = (value << CHAR_BIT) | *bitptr->byte++;
+    len  -= CHAR_BIT;
+  }
+
+  if (len > 0) {
+    bitptr->cache = *bitptr->byte;
+
+    value = (value << len) | (bitptr->cache >> (CHAR_BIT - len));
+    bitptr->left -= len;
+  }
+
+  return value;
+}
+
+# if 0
+/*
+ * NAME:	bit->write()
+ * DESCRIPTION:	write an arbitrary number of bits
+ */
+void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len,
+		   unsigned long value)
+{
+  unsigned char *ptr;
+
+  ptr = (unsigned char *) bitptr->byte;
+
+  /* ... */
+}
+# endif
+
+/*
+ * NAME:	bit->crc()
+ * DESCRIPTION:	compute CRC-check word
+ */
+unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len,
+			   unsigned short init)
+{
+  register unsigned int crc;
+
+  for (crc = init; len >= 32; len -= 32) {
+    register unsigned long data;
+
+    data = mad_bit_read(&bitptr, 32);
+
+    crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 24)) & 0xff];
+    crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 16)) & 0xff];
+    crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >>  8)) & 0xff];
+    crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >>  0)) & 0xff];
+  }
+
+  switch (len / 8) {
+  case 3: crc = (crc << 8) ^
+	    crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
+  case 2: crc = (crc << 8) ^
+	    crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
+  case 1: crc = (crc << 8) ^
+	    crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
+
+  len %= 8;
+
+  case 0: break;
+  }
+
+  while (len--) {
+    register unsigned int msb;
+
+    msb = mad_bit_read(&bitptr, 1) ^ (crc >> 15);
+
+    crc <<= 1;
+    if (msb & 1)
+      crc ^= CRC_POLY;
+  }
+
+  return crc & 0xffff;
+}

+ 47 - 0
sys/src/games/mp3dec/bit.h

@@ -0,0 +1,47 @@
+/*
+ * libmad - MPEG audio decoder library
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * $Id: bit.h,v 1.12 2004/01/23 09:41:32 rob Exp $
+ */
+
+# ifndef LIBMAD_BIT_H
+# define LIBMAD_BIT_H
+
+struct mad_bitptr {
+  unsigned char const *byte;
+  unsigned short cache;
+  unsigned short left;
+};
+
+void mad_bit_init(struct mad_bitptr *, unsigned char const *);
+
+# define mad_bit_finish(bitptr)		/* nothing */
+
+unsigned int mad_bit_length(struct mad_bitptr const *,
+			    struct mad_bitptr const *);
+
+# define mad_bit_bitsleft(bitptr)  ((bitptr)->left)
+unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *);
+
+void mad_bit_skip(struct mad_bitptr *, unsigned int);
+unsigned long mad_bit_read(struct mad_bitptr *, unsigned int);
+void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long);
+
+unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short);
+
+# endif

+ 0 - 231
sys/src/games/mp3dec/buffer.c

@@ -1,231 +0,0 @@
-/*
- *   buffer.c
- *
- *   Oliver Fromme  <oliver.fromme@heim3.tu-clausthal.de>
- *   Mon Apr 14 03:53:18 MET DST 1997
- */
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "mpg123.h"
-
-int outburst = MAXOUTBURST;
-int preload;
-
-static int intflag = FALSE;
-static int usr1flag = FALSE;
-
-static void catch_interrupt (void)
-{
-	intflag = TRUE;
-}
-
-static void catch_usr1 (void)
-{
-	usr1flag = TRUE;
-}
-
-/* Interfaces to writer process */
-
-extern void buffer_sig(int signal, int block);
-
-void buffer_ignore_lowmem(void)
-{
-#ifndef NOXFERMEM
-	if(buffermem->wakeme[XF_READER])
-		xfermem_putcmd(buffermem->fd[XF_WRITER], XF_CMD_WAKEUP);
-#endif
-}
-
-void buffer_end(void)
-{
-#ifndef NOXFERMEM
-	xfermem_putcmd(buffermem->fd[XF_WRITER], XF_CMD_TERMINATE);
-#endif
-}
-
-void buffer_resync(void)
-{
-	buffer_sig(SIGINT, TRUE);
-}
-
-void buffer_reset(void)
-{
-	buffer_sig(SIGUSR1, TRUE);
-}
-
-void buffer_start(void)
-{
-	buffer_sig(SIGCONT, FALSE);
-}
-
-void buffer_stop(void)
-{
-	buffer_sig(SIGSTOP, FALSE);
-}
-
-extern int buffer_pid;
-
-void buffer_sig(int signal, int block)
-{
-	
-#ifndef NOXFERMEM
-	
-	kill(buffer_pid, signal);
-	
-	if (!buffermem || !block)
-		return;
-
-	if(xfermem_block(XF_WRITER, buffermem) != XF_CMD_WAKEUP) 
-		perror("Could not resync/reset buffers");
-#endif
-	
-	return;
-}
-
-#ifndef NOXFERMEM
-
-void buffer_loop(struct audio_info_struct *ai, sigset_t *oldsigset)
-{
-	int bytes;
-	int my_fd = buffermem->fd[XF_READER];
-	txfermem *xf = buffermem;
-	int done = FALSE;
-
-	catchsignal (SIGINT, catch_interrupt);
-	catchsignal (SIGUSR1, catch_usr1);
-	sigprocmask (SIG_SETMASK, oldsigset, NULL);
-	if (param.outmode == DECODE_AUDIO) {
-		if (audio_open(ai) < 0) {
-			perror("audio");
-			exit(1);
-		}
-	}
-
-	for (;;) {
-		if (intflag) {
-			intflag = FALSE;
-			if (param.outmode == DECODE_AUDIO)
-				audio_queueflush (ai);
-			xf->readindex = xf->freeindex;
-			if (xf->wakeme[XF_WRITER])
-				xfermem_putcmd(my_fd, XF_CMD_WAKEUP);
-		}
-		if (usr1flag) {
-			usr1flag = FALSE;
-			/*   close and re-open in order to flush
-			 *   the device's internal buffer before
-			 *   changing the sample rate.   [OF]
-			 */
-			/* writer must block when sending SIGUSR1
-			 * or we will lose all data processed 
-			 * in the meantime! [dk]
-			 */
-			xf->readindex = xf->freeindex;
-			/* We've nailed down the new starting location -
-			 * writer is now safe to go on. [dk]
-			 */
-			if (xf->wakeme[XF_WRITER])
-				xfermem_putcmd(my_fd, XF_CMD_WAKEUP);
-			if (param.outmode == DECODE_AUDIO) {
-				audio_close (ai);
-				ai->rate = xf->buf[0]; 
-				ai->channels = xf->buf[1]; 
-				ai->format = xf->buf[2];
-				if (audio_open(ai) < 0) {
-					perror("audio");
-					exit(1);
-				}
-			}
-		}
-		if ( (bytes = xfermem_get_usedspace(xf)) < outburst ) {
-			/* if we got a buffer underrun we first
-			 * fill 1/8 of the buffer before continue/start
-			 * playing */
-			preload = xf->size>>3;
-			if(preload < outburst)
-				preload = outburst;
-		}
-		if(bytes < preload) {
-			int cmd;
-			if (done && !bytes) { 
-				break;
-			}
-
-			if(!done) {
-
-				cmd = xfermem_block(XF_READER, xf);
-
-				switch(cmd) {
-
-					/* More input pending. */
-					case XF_CMD_WAKEUP_INFO:
-						continue;
-					/* Yes, we know buffer is low but
-					 * know we don't care.
-					 */
-					case XF_CMD_WAKEUP:
-						break;	/* Proceed playing. */
-					case XF_CMD_TERMINATE:
-						/* Proceed playing without 
-						 * blocking any further.
-						 */
-						done=TRUE;
-						break;
-					case -1:
-						if(errno==EINTR)
-							continue;
-						perror("Yuck! Error in buffer handling...");
-						done = TRUE;
-						xf->readindex = xf->freeindex;
-						xfermem_putcmd(xf->fd[XF_READER], XF_CMD_TERMINATE);
-						break;
-					default:
-						fprintf(stderr, "\nEh!? Received unknown command 0x%x in buffer process. Tell Daniel!\n", cmd);
-				}
-			}
-		}
-		preload = outburst; /* set preload to lower mark */
-		if (bytes > xf->size - xf->readindex)
-			bytes = xf->size - xf->readindex;
-		if (bytes > outburst)
-			bytes = outburst;
-
-		if (param.outmode == DECODE_FILE)
-			bytes = write(OutputDescriptor, xf->data + xf->readindex, bytes);
-		else if (param.outmode == DECODE_AUDIO)
-			bytes = audio_play_samples(ai,
-				(unsigned char *) (xf->data + xf->readindex), bytes);
-
-		if(bytes < 0) {
-			bytes = 0;
-			if(errno != EINTR) {
-				perror("Ouch ... error while writing audio data: ");
-				/*
-				 * done==TRUE tells writer process to stop
-				 * sending data. There might be some latency
-				 * involved when resetting readindex to 
-				 * freeindex so we might need more than one
-				 * cycle to terminate. (The number of cycles
-				 * should be finite unless I managed to mess
-				 * up something. ;-) [dk]
-				 */
-				done = TRUE;	
-				xf->readindex = xf->freeindex;
-				xfermem_putcmd(xf->fd[XF_READER], XF_CMD_TERMINATE);
-			}
-		}
-
-		xf->readindex = (xf->readindex + bytes) % xf->size;
-		if (xf->wakeme[XF_WRITER])
-			xfermem_putcmd(my_fd, XF_CMD_WAKEUP);
-	}
-
-	if (param.outmode == DECODE_AUDIO)
-		audio_close (ai);
-}
-
-#endif
-
-/* EOF */

+ 0 - 13
sys/src/games/mp3dec/buffer.h

@@ -1,13 +0,0 @@
-/*
- * Application specific interaction between main and buffer
- * process. This is much less generic than the functions in
- * xfermem so I chose to put it in buffer.[hc].
- * 01/28/99 [dk]
- */
-
-void buffer_ignore_lowmem(void);
-void buffer_end(void);
-void buffer_resync(void);
-void buffer_reset(void);
-void buffer_start(void);
-void buffer_stop(void);

+ 0 - 732
sys/src/games/mp3dec/common.c

@@ -1,732 +0,0 @@
-#include <ctype.h>
-#include <stdlib.h>
-#include <signal.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-
-#include <fcntl.h>
-
-#ifdef READ_MMAP
-#include <sys/mman.h>
-#ifndef MAP_FAILED
-#define MAP_FAILED ( (void *) -1 )
-#endif
-#endif
-
-#include "mpg123.h"
-#include "genre.h"
-#include "common.h"
-
-int tabsel_123[2][3][16] = {
-   { {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,},
-     {0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,},
-     {0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,} },
-
-   { {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,},
-     {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,},
-     {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,} }
-};
-
-long freqs[9] = { 44100, 48000, 32000, 22050, 24000, 16000 , 11025 , 12000 , 8000 };
-
-struct bitstream_info bsi;
-
-static int fsizeold=0,ssize;
-static unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */
-static unsigned char *bsbuf=bsspace[1],*bsbufold;
-static int bsnum=0;
-
-static unsigned long oldhead = 0;
-unsigned long firsthead=0;
-
-unsigned char *pcm_sample;
-int pcm_point = 0;
-int audiobufsize = AUDIOBUFSIZE;
-
-#ifdef VARMODESUPPORT
-	/*
-	 *   This is a dirty hack!  It might burn your PC and kill your cat!
-	 *   When in "varmode", specially formatted layer-3 mpeg files are
-	 *   expected as input -- it will NOT work with standard mpeg files.
-	 *   The reason for this:
-	 *   Varmode mpeg files enable my own GUI player to perform fast
-	 *   forward and backward functions, and to jump to an arbitrary
-	 *   timestamp position within the file.  This would be possible
-	 *   with standard mpeg files, too, but it would be a lot harder to
-	 *   implement.
-	 *   A filter for converting standard mpeg to varmode mpeg is
-	 *   available on request, but it's really not useful on its own.
-	 *
-	 *   Oliver Fromme  <oliver.fromme@heim3.tu-clausthal.de>
-	 *   Mon Mar 24 00:04:24 MET 1997
-	 */
-int varmode = FALSE;
-int playlimit;
-#endif
-
-static int decode_header(struct frame *fr,unsigned long newhead);
-
-void audio_flush(int outmode, struct audio_info_struct *ai)
-{
-  if (pcm_point) {
-    switch (outmode) {
-      case DECODE_FILE:
-        write (OutputDescriptor, pcm_sample, pcm_point);
-        break;
-      case DECODE_AUDIO:
-        audio_play_samples (ai, pcm_sample, pcm_point);
-        break;
-      case DECODE_BUFFER:
-        write (buffer_fd[1], pcm_sample, pcm_point);
-        break;
-      case DECODE_WAV:
-      case DECODE_CDR:
-      case DECODE_AU:
-        wav_write(pcm_sample, pcm_point);
-        break;
-    }
-    pcm_point = 0;
-  }
-}
-
-#if !defined(WIN32) && !defined(GENERIC)
-void (*catchsignal(int signum, void(*handler)()))()
-{
-  struct sigaction new_sa;
-  struct sigaction old_sa;
-
-#ifdef DONT_CATCH_SIGNALS
-  printf ("Not catching any signals.\n");
-  return ((void (*)()) -1);
-#endif
-
-  new_sa.sa_handler = handler;
-  sigemptyset(&new_sa.sa_mask);
-  new_sa.sa_flags = 0;
-  if (sigaction(signum, &new_sa, &old_sa) == -1)
-    return ((void (*)()) -1);
-  return (old_sa.sa_handler);
-}
-#endif
-
-void read_frame_init (void)
-{
-    oldhead = 0;
-    firsthead = 0;
-}
-
-int head_check(unsigned long head)
-{
-    if( (head & 0xffe00000) != 0xffe00000)
-	return FALSE;
-    if(!((head>>17)&3))
-	return FALSE;
-    if( ((head>>12)&0xf) == 0xf)
-	return FALSE;
-    if( ((head>>10)&0x3) == 0x3 )
-	return FALSE;
-    if ((head & 0xffff0000) == 0xfffe0000)
-      return FALSE;
-
-    return TRUE;
-}
-
-
-
-/*****************************************************************
- * read next frame
- */
-int read_frame(struct frame *fr)
-{
-  unsigned long newhead;
-  static unsigned char ssave[34];
-
-  fsizeold=fr->framesize;       /* for Layer3 */
-
-  if (param.halfspeed) {
-    static int halfphase = 0;
-    if (halfphase--) {
-      bsi.bitindex = 0;
-      bsi.wordpointer = (unsigned char *) bsbuf;
-      if (fr->lay == 3)
-        memcpy (bsbuf, ssave, ssize);
-      return 1;
-    }
-    else
-      halfphase = param.halfspeed - 1;
-  }
-
-read_again:
-  if(!rd->head_read(rd,&newhead))
-    return FALSE;
-
-  if(1 || oldhead != newhead || !oldhead)
-  {
-
-init_resync:
-
-    fr->header_change = 2;
-    if(oldhead) {
-      if((oldhead & 0xc00) == (newhead & 0xc00)) {
-        if( (oldhead & 0xc0) == 0 && (newhead & 0xc0) == 0)
-    	  fr->header_change = 1; 
-        else if( (oldhead & 0xc0) > 0 && (newhead & 0xc0) > 0)
-	  fr->header_change = 1;
-      }
-    }
-
-
-#ifdef SKIP_JUNK
-	if(!firsthead && !head_check(newhead) ) {
-		int i;
-
-		fprintf(stderr,"Junk at the beginning %08lx\n",newhead);
-
-		/* I even saw RIFF headers at the beginning of MPEG streams ;( */
-		if(newhead == ('R'<<24)+('I'<<16)+('F'<<8)+'F') {
-			if(!rd->head_read(rd,&newhead))
-				return 0;
-			while(newhead != ('d'<<24)+('a'<<16)+('t'<<8)+'a') {
-				if(!rd->head_shift(rd,&newhead))
-					return 0;
-			}
-			if(!rd->head_read(rd,&newhead))
-				return 0;
-			fprintf(stderr,"Skipped RIFF header!\n");
-			goto read_again;
-		}
-		{
-			/* step in byte steps through next 64K */
-			for(i=0;i<65536;i++) {
-				if(!rd->head_shift(rd,&newhead))
-					return 0;
-				if(head_check(newhead))
-					break;
-#if 0
-fprintf(stderr,"%08lx ",newhead);
-#endif
-			}
-			if(i == 65536) {
-				fprintf(stderr,"Giving up searching valid MPEG header\n");
-				return 0;
-			}
-		}
-		/* 
-		 * should we additionaly check, whether a new frame starts at
-		 * the next expected position? (some kind of read ahead)
-		 * We could implement this easily, at least for files.
-		 */
-	}
-#endif
-
-    if( (newhead & 0xffe00000) != 0xffe00000) {
-      if (!param.quiet)
-        fprintf(stderr,"Illegal Audio-MPEG-Header 0x%08lx at offset 0x%lx.\n",
-              newhead,rd->tell(rd)-4);
-    /* and those ugly ID3 tags */
-      if((newhead & 0xffffff00) == ('T'<<24)+('A'<<16)+('G'<<8)) {
-           rd->skip_bytes(rd,124);
-           fprintf(stderr,"Skipped ID3 Tag!\n");
-           goto read_again;
-      }
-      if (param.tryresync) {
-        int try = 0;
-            /* Read more bytes until we find something that looks
-               reasonably like a valid header.  This is not a
-               perfect strategy, but it should get us back on the
-               track within a short time (and hopefully without
-               too much distortion in the audio output).  */
-        do {
-          try++;
-          if(!rd->head_shift(rd,&newhead))
-		return 0;
-          if (!oldhead)
-            goto init_resync;       /* "considered harmful", eh? */
-
-        } while ((newhead & HDRCMPMASK) != (oldhead & HDRCMPMASK)
-              && (newhead & HDRCMPMASK) != (firsthead & HDRCMPMASK));
-        if (!param.quiet)
-          fprintf (stderr, "Skipped %d bytes in input.\n", try);
-      }
-      else
-        return (0);
-    }
-
-    if (!firsthead) {
-      if(!decode_header(fr,newhead))
-        goto read_again;
-      firsthead = newhead;
-    }
-    else
-      if(!decode_header(fr,newhead))
-        return 0;
-
-  }
-  else
-    fr->header_change = 0;
-
-  /* flip/init buffer for Layer 3 */
-  bsbufold = bsbuf;
-  bsbuf = bsspace[bsnum]+512;
-  bsnum = (bsnum + 1) & 1;
-
-  /* read main data into memory */
-  if(!rd->read_frame_body(rd,bsbuf,fr->framesize))
-    return 0;
-
-  bsi.bitindex = 0;
-  bsi.wordpointer = (unsigned char *) bsbuf;
-
-  if (param.halfspeed && fr->lay == 3)
-    memcpy (ssave, bsbuf, ssize);
-
-  return 1;
-
-}
-
-/****************************************
- * HACK,HACK,HACK: step back <num> frames
- * can only work if the 'stream' isn't a real stream but a file
- */
-int back_frame(struct reader *rds,struct frame *fr,int num)
-{
-  long bytes;
-  unsigned long newhead;
-  
-  if(!firsthead)
-    return 0;
-  
-  bytes = (fr->framesize+8)*(num+2);
-  
-  if(rds->back_bytes(rds,bytes) < 0)
-    return -1;
-  if(!rds->head_read(rds,&newhead))
-    return -1;
-  
-  while( (newhead & HDRCMPMASK) != (firsthead & HDRCMPMASK) ) {
-    if(!rds->head_shift(rds,&newhead))
-      return -1;
-  }
-  
-  if(rds->back_bytes(rds,4) <0)
-    return -1;
-
-  read_frame(fr);
-  read_frame(fr);
-  
-  if(fr->lay == 3) {
-    set_pointer(512);
-  }
-  
-  return 0;
-}
-
-
-/*
- * decode a header and write the information
- * into the frame structure
- */
-static int decode_header(struct frame *fr,unsigned long newhead)
-{
-    if(!head_check(newhead))
-      return 0;
-
-    if( newhead & (1<<20) ) {
-      fr->lsf = (newhead & (1<<19)) ? 0x0 : 0x1;
-      fr->mpeg25 = 0;
-    }
-    else {
-      fr->lsf = 1;
-      fr->mpeg25 = 1;
-    }
-    
-    if (!param.tryresync || !oldhead) {
-          /* If "tryresync" is true, assume that certain
-             parameters do not change within the stream! */
-      fr->lay = 4-((newhead>>17)&3);
-      if( ((newhead>>10)&0x3) == 0x3) {
-        fprintf(stderr,"Stream error\n");
-        exit(1);
-      }
-      if(fr->mpeg25) {
-        fr->sampling_frequency = 6 + ((newhead>>10)&0x3);
-      }
-      else
-        fr->sampling_frequency = ((newhead>>10)&0x3) + (fr->lsf*3);