Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#29 Parser library for Dirac to implement Random Access

open
None
5
2007-04-04
2007-04-04
No

Patch Submitted by Andrew Kennedy.

NOTE: The patch restructures the decoder library into a Parser library that parses the dirac bitstream and a Decoder library that decodes the bitstream.
The patch is out of date with the current CVS source and can be applied to the source dated 5-12-2006.

-------
Andrew Kennedy's Summary of Changes

- There is now a DiracParser library used in decoding, which contains code re-factored from the DiracDecoder library. The parser library returns parse-units when are then passed into the decoder library for decompression.

- The byteio library now has 2 ways of processing compressed data. Either as a chunk of bytes held in internal memory (as now) or as pointing to a
file stream within the byteio library itself. This second option is now the default (ie used from decmain.cpp). This allows the implementation of
seeking - both forward and backward - to be implemented without too many
issues to overcome.

- Forward and backward seeking has been implemented within the DiracParser library using a file stream. Currently, the seeking involved is only suitable for scrub seeking and is not frame accurate. Currently, it finds the correct display frame and then moves back to the previous I-frame for decoding onward. A next step would be frame-accurate seeking, but this would require a partial decode of the data in the Parser library to
produce a chain of frame references in order to be completely accurate.The DiracParser library has an API (dirac_parser_seek) that can be used to specify a forward or backward seek. One thing I found in implementation is that because the seeking works on display frame-numbers, this could be quite awkward because only by visiting each unit could each frame-number be discovered, and so care needs to be taken about which direction to process in. Perhaps it would have been easier to implement if, after each
access-unit, there was a list of display order and byte-offsets in the GOP. This would also make seeking faster as searching would jump from access-unit directly to access-unit, instead of processing each unit (even better if it also could include a 'decode from' field, eg. '-4' would indicate that decoding must start from 4 frames back in order to decode
this frame, so includes the frame references in a single number).

- Decoding can start and stop at a particular frame number. 'Start' and 'Stop' have been added to the command-line parameters. The 'start' option
peforms a seek before entering the decode loop. However, the actual decoding takes place at the first access-unit prior to the wanted frame number.

TESTING
The seek functionality can be tested by (for example in decmain.cpp) adding:
case DECODER_STATE_PICTURE_AVAIL:
if(num_frames==15)
dirac_parser_seek(parser, 35)

TO DO
The following work needs to be done:
- Update the ffmpeg/mplayer patches to take into account the parser library and modified API.
- Fix a bug when seeking using ffmpeg. Note, this is ***NOT*** to do with the new seeking functionality. For example, if using ffmpeg some video was encoded using Dirac and output as an avi file, then the avi container
handles the seeking and byte offsets by building an internal index table. Currently, there is an issue/bug within Dirac that prevents this approach
from working properly.

- Add seeking to the Dirac directshow filter. This could be done using the current seeking functionality for scrubbing. Then it could be determined
if further optimisation work is needed i.e random access seeking or on-the-fly indexing. The directshow filter (like the player patch) currently accesses the dirac byte-stream directly, and this needs to be
changed so that it uses the parser to ensure that the code doesn't always have to be updated in multiple places.
--------------------------------

Discussion

  • Patch file to implement random access of Dirac bitstream

     
    Attachments
    • assigned_to: nobody --> asuraparaju