- Main Page
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

# dirac_parser.h File Reference

C interface to Dirac decoder. More...

`#include <libdirac_common/dirac_types.h>`
`#include <libdirac_decoder/decoder_types.h>`

Go to the source code of this file.

## Classes
struct | dirac_decoder_t
## Typedefs
typedef DecoderState | dirac_decoder_state_t
## Functions
DllExport dirac_decoder_t * | dirac_decoder_init (int verbose)
DllExport void | dirac_decoder_close (dirac_decoder_t *decoder)
DllExport dirac_decoder_state_t | dirac_parse (dirac_decoder_t *decoder)
DllExport void | dirac_buffer (dirac_decoder_t *decoder, unsigned char *start, unsigned char *end)
DllExport void | dirac_set_buf (dirac_decoder_t *decoder, unsigned char *buf[3], void *id)
DllExport void | dirac_skip (dirac_decoder_t *decoder, int skip)

## Detailed Description

C interface to Dirac decoder.

A set of 'C' functions that define the public interface to the Dirac decoder. Refer to the the reference decoder source code, decoder/decmain.cpp for an example of how to use the "C" interface. The pseudocode below gives a brief description of the "C" interface usage.

     #include <libdirac_decoder/dirac_parser.h>\n
     Initialise the decodern

     decoder_handle = dirac_decoder_init();
     do
     {
         dirac_decoder_state_t state = dirac_parse (decoder);
         switch (state)
         {
         case STATE_BUFFER:
             read more data.
             Pass data to the decoder.
             dirac_buffer (decoder_handle, data_start, data_end)
             break;

         case STATE_SEQUENCE:
             handle start of sequence.
             The decoder returns the sequence parameters in the
             seq_params member of the decoder handle.
             Allocate space for the frame data buffers and pass
             this to the decoder.
             dirac_set_buf (decoder_handle, buf, NULL);
             break;

         case STATE_SEQUENCE_END:
             Deallocate frame data buffers
             break;

         case STATE_PICTURE_START:
             handle start of picture data
             The decoder sets the frame_params member in the
             decoder handle to the details of the next frame
             to be processed.
             break;

         case STATE_PICTURE_AVAIL:
             Handle picture data.
             The decoder sets the fbuf member in the decoder
             handle to the frame decoded.
             break;

         case STATE_INVALID:
             Unrecoverable error. Stop all processing
             break;
         }
     } while (data available && decoder state != STATE_INVALID

     Free the decoder resources
     dirac_decoder_close(decoder_handle)

Definition in file dirac_parser.h.

## Function Documentation

DllExport void dirac_buffer | ( | dirac_decoder_t * | decoder,
|  | unsigned char * | start,
|  | unsigned char * | end
| ) |

  | Copy data into internal buffer Parameters:
  | decoder | Decoder object
  | start | Start of data
  | end | End of data
Definition at line 79 of file dirac_parser.cpp. References dirac_decoder_t::parser, and dirac::DiracParser::SetBuffer().

DllExport void dirac_decoder_close | ( | dirac_decoder_t * | decoder | ) |

  | Release the decoder resources Parameters:
  | decoder | Decoder object
Definition at line 64 of file dirac_parser.cpp. References dirac_decoder_t::fbuf, and dirac_decoder_t::parser.

DllExport dirac_decoder_t* dirac_decoder_init | ( | int | verbose | ) |

  | Decoder Init Initialise the decoder. Parameters:
  | verbose | boolean flag to set verbose output
Returns: decoder handle Definition at line 49 of file dirac_parser.cpp. References dirac_framebuf_t::buf, dirac_decoder_t::fbuf, dirac_framebuf_t::id, and dirac_decoder_t::parser.

DllExport dirac_decoder_state_t dirac_parse | ( | dirac_decoder_t * | decoder | ) |

  | Parses the data in the input buffer. This function returns the following values. STATE_BUFFER: Not enough data in internal buffer to process STATE_SEQUENCE: Start of sequence detected. The seq_params member in the decoder object is set to the details of the next sequence to be processed. STATE_PICTURE_START: Start of picture detected. The frame_params member of the decoder object is set to the details of the next frame to be processed. STATE_PICTURE_AVAIL: Decoded picture available. The frame_aprams member of the decoder object is set the the details of the decoded frame available. The fbuf member of the decoder object has the luma and chroma data of the decompressed frame. STATE_SEQUENCE_END: End of sequence detected. STATE_INVALID: Invalid stream. Stop further processing. Parameters:
  | decoder | Decoder object
Returns: Decoder state Definition at line 209 of file dirac_parser.cpp. References dirac_decoder_t::frame_avail, dirac::Frame::GetFparams(), dirac::DiracParser::GetNextFrame(), dirac::DiracParser::GetNextFrameParams(), dirac::DiracParser::Parse(), dirac_decoder_t::parser, and dirac_decoder_t::state.

DllExport void dirac_set_buf | ( | dirac_decoder_t * | decoder,
|  | unsigned char * | buf[3],
|  | void * | id
| ) |

  | Set the output buffer into which the decoder copies the decoded data Parameters:
  | decoder | Decoder object
  | buf | Array of char buffers to hold luma and chroma data
  | id | User data
Definition at line 259 of file dirac_parser.cpp. References dirac_framebuf_t::buf, dirac_decoder_t::fbuf, and dirac_framebuf_t::id.

DllExport void dirac_skip | ( | dirac_decoder_t * | decoder,
|  | int | skip
| ) |

  | Skip the next frame to be decoded Parameters:
  | decoder | Decoder object
  | skip | Value 0 - decode next frame; 1 - skip next frame
Definition at line 249 of file dirac_parser.cpp. References dirac_decoder_t::parser, and dirac::DiracParser::SetSkip().