Class SubDvd

java.lang.Object
bdsup2sub.supstream.dvd.SubDvd
All Implemented Interfaces:
DvdSubtitleStream, SubtitleStream

public class SubDvd extends Object implements DvdSubtitleStream
Handling of SUB/IDX (VobSub) streams.
  • Field Details

    • configuration

      private static final Configuration configuration
    • logger

      private static final Logger logger
    • subPictures

      private final List<SubPictureDVD> subPictures
      ArrayList of captions contained in the current file
    • srcPalette

      private Palette srcPalette
      color palette read from idx file
    • palette

      private Palette palette
      color palette created for last decoded caption
    • bitmap

      private Bitmap bitmap
      bitmap of the last decoded caption
    • screenWidth

      private int screenWidth
      screen width of imported VobSub
    • screenHeight

      private int screenHeight
      screen height of imported VobSub
    • globalXOffset

      private int globalXOffset
      global x offset
    • globalYOffset

      private int globalYOffset
      global y offset
    • globalDelay

      private int globalDelay
      global delay
    • languageIndex

      private int languageIndex
      index of language read from IDX
    • streamID

      private int streamID
      stream ID
    • buffer

      private final FileBuffer buffer
      FileBuffer for reading SUB
    • primaryColorIndex

      private int primaryColorIndex
      index of dominant color for the current caption
    • forcedFrameCount

      private int forcedFrameCount
      number of forced captions in the current file
    • lastAlpha

      private static int[] lastAlpha
      store last alpha values for invisible workaround
  • Constructor Details

  • Method Details

    • readIdx

      private void readIdx(String idxFile) throws CoreException
      Throws:
      CoreException
    • readSubFrame

      private void readSubFrame(SubPictureDVD pic, long endOfs, FileBuffer buffer) throws CoreException
      Read one frame from SUB file
      Parameters:
      pic - SubPicture object for this frame
      endOfs - end offset
      buffer - File Buffer to read from
      Throws:
      CoreException
    • decode

      public void decode(int index) throws CoreException
      Description copied from interface: SubtitleStream
      Decode caption.
      Specified by:
      decode in interface SubtitleStream
      Parameters:
      index - Index of caption
      Throws:
      CoreException
    • decode

      private void decode(SubPictureDVD pic) throws CoreException
      Throws:
      CoreException
    • getFramePalette

      public int[] getFramePalette(int index)
      Description copied from interface: DvdSubtitleStream
      Get frame Palette.
      Specified by:
      getFramePalette in interface DvdSubtitleStream
      Parameters:
      index - Index of caption
      Returns:
      Integer array with 4 entries representing the frame palette
    • getOriginalFramePalette

      public int[] getOriginalFramePalette(int index)
      Description copied from interface: DvdSubtitleStream
      Get original frame Palette (as they were before editing).
      Specified by:
      getOriginalFramePalette in interface DvdSubtitleStream
      Parameters:
      index - index of caption
      Returns:
      Integer array with 4 entries representing the original frame palette.
    • getFrameAlpha

      public int[] getFrameAlpha(int index)
      Description copied from interface: DvdSubtitleStream
      Get frame alpha values.
      Specified by:
      getFrameAlpha in interface DvdSubtitleStream
      Parameters:
      index - Index of caption
      Returns:
      Integer array with 4 entries representing the frame alpha values
    • getOriginalFrameAlpha

      public int[] getOriginalFrameAlpha(int index)
      Description copied from interface: DvdSubtitleStream
      Get original frame alpha values (as they were before editing).
      Specified by:
      getOriginalFrameAlpha in interface DvdSubtitleStream
      Parameters:
      index - Index of caption
      Returns:
      Integer array with 4 entries representing the original frame alpha values.
    • getImage

      public BufferedImage getImage(Bitmap bm)
      Description copied from interface: SubtitleStream
      Return given Bitmap as BufferedImage (using current Palette).
      Specified by:
      getImage in interface SubtitleStream
      Parameters:
      bm - Bitmap to convert.
      Returns:
      BufferedImage of given bitmap
    • getPalette

      public Palette getPalette()
      Description copied from interface: SubtitleStream
      Return the Palette of the current (last decoded) frame.
      Specified by:
      getPalette in interface SubtitleStream
      Returns:
      Palette of the current frame
    • getBitmap

      public Bitmap getBitmap()
      Description copied from interface: SubtitleStream
      Return the Bitmap of the current (last decoded) frame.
      Specified by:
      getBitmap in interface SubtitleStream
      Returns:
      Bitmap of the current frame
    • getImage

      public BufferedImage getImage()
      Description copied from interface: SubtitleStream
      Return current (last decoded) frame
      Specified by:
      getImage in interface SubtitleStream
      Returns:
      Current (last decoded) frame
    • getPrimaryColorIndex

      public int getPrimaryColorIndex()
      Description copied from interface: SubtitleStream
      Get index of most dominant opaque color (for DVD subtitle export).
      Specified by:
      getPrimaryColorIndex in interface SubtitleStream
      Returns:
      Index of most dominant opaque color
    • getSubPicture

      public SubPicture getSubPicture(int index)
      Description copied from interface: SubtitleStream
      Get SubPicture of given frame.
      Specified by:
      getSubPicture in interface SubtitleStream
      Parameters:
      index - Index of caption
      Returns:
      SubPicture of caption
    • getFrameCount

      public int getFrameCount()
      Description copied from interface: SubtitleStream
      Get number of frames in the currently loaded subtitle stream.
      Specified by:
      getFrameCount in interface SubtitleStream
      Returns:
      Number of frames
    • getForcedFrameCount

      public int getForcedFrameCount()
      Description copied from interface: SubtitleStream
      Get number of forced frames in the currently loaded subtitle stream.
      Specified by:
      getForcedFrameCount in interface SubtitleStream
      Returns:
      Number of forced frames
    • isForced

      public boolean isForced(int index)
      Description copied from interface: SubtitleStream
      Get forced flag of given frame.
      Specified by:
      isForced in interface SubtitleStream
      Parameters:
      index - Index of caption
      Returns:
      Forced flag of given frame
    • close

      public void close()
      Description copied from interface: SubtitleStream
      Close input stream.
      Specified by:
      close in interface SubtitleStream
    • getEndTime

      public long getEndTime(int index)
      Description copied from interface: SubtitleStream
      Get end time stamp of given frame.
      Specified by:
      getEndTime in interface SubtitleStream
      Parameters:
      index - Index of caption
      Returns:
      End time stamp of given frame in 90kHz resolution
    • getStartTime

      public long getStartTime(int index)
      Description copied from interface: SubtitleStream
      Get start time stamp of given frame.
      Specified by:
      getStartTime in interface SubtitleStream
      Parameters:
      index - Index of caption
      Returns:
      Start time stamp of given frame in 90kHz resolution
    • getStartOffset

      public long getStartOffset(int index)
      Description copied from interface: SubtitleStream
      Get start offset (in input stream) of given frame.
      Specified by:
      getStartOffset in interface SubtitleStream
      Parameters:
      index - Index of caption
      Returns:
      Start offset of given frame in input stream
    • getLanguageIndex

      public int getLanguageIndex()
      Description copied from interface: DvdSubtitleStream
      Get language index read from Idx.
      Specified by:
      getLanguageIndex in interface DvdSubtitleStream
      Returns:
      language index.
    • getSrcPalette

      public Palette getSrcPalette()
      Description copied from interface: DvdSubtitleStream
      Get imported 16 color DVD Palette.
      Specified by:
      getSrcPalette in interface DvdSubtitleStream
      Returns:
      Imported 16 color DVD Palette.
    • setSrcPalette

      public void setSrcPalette(Palette pal)
      Description copied from interface: DvdSubtitleStream
      Replace imported 16 color DVD Palette with a new Palette.
      Specified by:
      setSrcPalette in interface DvdSubtitleStream
      Parameters:
      pal - New Palette