home *** CD-ROM | disk | FTP | other *** search
/ MPEG Toolkit / MPEG Toolkit.iso / os2 / mpegenc / os2port.txt < prev    next >
Encoding:
Text File  |  1997-01-01  |  5.3 KB  |  122 lines

  1. Porting of Berkeley mpeg_encode to 32 bit OS/2
  2. ----------------------------------------------
  3.  
  4. The ported source, ported executable and this file will be / have been
  5. sent to toe.cs.berkeley.edu. I also intend to upload this elsewhere.
  6.  
  7. The target compiler was IBM C-Set++ 2.0. Optimisation was not turned on as in
  8. my experience this often breaks things.
  9.  
  10. The supplied source references long filenames (>8.3) and so I truncated to
  11. the FAT 8.3 convention. Perhaps it would be better if the Berkeley people could
  12. use the 8.3 convention too.
  13.  
  14. I always defined OS2, so that wherever I had to add a hack, I could use
  15. #ifdef OS2. Wherever I made a change, I put a comment with @@@ in it.
  16. The files os2port.h and os2port.c encompass any additional source required.
  17.  
  18. I built all the code multithreaded (/Gm+). This was obviously not a requirement
  19. but is the way I build all my code. Single threaded librarys never seem to
  20. make a significant difference in performance.
  21.  
  22. I wrote various makefile.os2's for pbmplus and the directories below it.
  23. I found I had to change MAKE variable $(INCLUDE) to another name (ie: $(INCL))
  24. so that ICC didn't get confused searching for system header files.
  25.  
  26. for pbmplus/makefile.os2 I had to write out the makes for each of the 4 sub-
  27. directories in full, as shell 'foreach' type things can be done in OS/2 NMAKE.
  28.  
  29. In libpbm1.c I had to ensure errno was correctly defined from errno.h, and not
  30. some assume extern statement in the code. In OS/2, using /Gm+ errno actually
  31. maps to a function which returns the correct errno for the current thread.
  32.  
  33. Wherever I saw a fopen() call, I had to be sure either binary or ASCII was
  34. intended. The original authors always gave "r" or "w" although they could have
  35. aided portability by using "rb" etc. (on all systems I know the b is ignored).
  36.  
  37. In pbmplus.h I define SYSV if OS2 is defined so that I get the right string
  38. functions etc.. I also found it best to use /Sa to force strict ANSI and
  39. get __STDC__ defined.
  40.  
  41. OS/2 has no 'times' interface, so I fake it up in os2port.c.
  42.  
  43. I compiled with no sockets/parallel compression options. However I found that
  44. in bitio.c, Bitio_WriteToSocket still referenced socket stuff. So I commented
  45. out the body of this function.
  46.  
  47. popen() and pclose() do not exist in OS/2. Rather naff implementations can
  48. be found in os2port.c. I am not even sure they work properly. I have tried :-
  49.  
  50.     INPUT_CONVERT gbmref * x.ppm && type x.ppm && del x.ppm
  51.  
  52. (gbmref is a program that can read and write a wide variety of bitmap file
  53. types. Here the output format is PPM. gbmref does not write to stdout though).
  54.  
  55.  
  56. Suggested improvements
  57. ----------------------
  58.  
  59. Although the encoder appears to do an excellent job at encoding,
  60. architecturally it does not appear to be designed with software re-use in mind.
  61.  
  62. Use 8.3 naming convention for files. Allows easier port to OS/2 and DOS.
  63.  
  64. Use ANSI fully prototyped definitions everywhere. How many machines can you
  65. name having only K&R C compilers and not ANSI?
  66.  
  67. Build a module that has an agreed simple interface that uses PBMPLUS to get
  68. the individual image bits and supplys them in a file format independent encoder
  69. suited format. Due to interface, other bitmap tools may now be substituted
  70. for PBMPLUS, such as my GBM, or libtiff.a, or fetch-data-from-memory stream,
  71. or whatever.
  72.  
  73. Build encoder module, using above module to obtain uncompressed frames.
  74. Calls external functions to send data to output 'file' stream, that can now
  75. also be in memory.
  76.  
  77. Make configuration of parameters via entrypoints into encoder module. Write
  78. seperate module to read .param file and call these entrypoints. Allows easy
  79. integration to flashy user interfaces to control these parameters, without
  80. having to knock up temporary .param files.
  81.  
  82. Also, have statistics queryable from the encoder module and have seperate
  83. module to write summary to statistics file. Therefore can user GUI to display
  84. results instead, or can discard them if not interested.
  85.  
  86. Finally, place encoder driver stuff (the rest) in main driving module with
  87. main() etc., and have this call the other modules. Also, only allow this
  88. module to issue an exit() call. Have all other module return error codes in
  89. error conditions, rather than bombing mid-function. This increases the
  90. encapsulation of the module.
  91.  
  92. Perhaps each module could be a library with a single interface header.
  93.  
  94. All of the above are obvious software engineering issues. I would try to do
  95. some of the above myself, only, hey, thats not my job... :-)
  96.  
  97. Use #defines OPEN_READ_ASCII, OPEN_READ_BINARY as "r" "rb" on OS/2 and DOS,
  98. or "r" "r" on UNIX. Use these wherever fopen() is used.
  99.  
  100. Add option to set amount of 'chugging messages' displayed as encode proceeds.
  101. They are very boring to the uninitiated. -quiet option?
  102.  
  103. Give description in documentation on what is required to make a .mpg file that
  104. can be played by the Xing I-frame only player.
  105.  
  106.  
  107. Legal-junk
  108. ----------
  109.  
  110. This port was done in my own time with my own equiptment.
  111. It is nothing to do with IBM (despite my address quoted below being in IBM),
  112. or any other company.
  113.  
  114. The basic code I started from may be "freely distributed", so are my
  115. porting changes, and therefore so is the final result.
  116.  
  117.  
  118. {{{ Andy Key
  119.  
  120. Internet: ak@vnet.ibm.com            # Contract valid until Sept 94
  121. IBM-VNET: AKEY @ HVTVM5                # so addresses valid until then
  122.