shcodecs_decoder.h File Reference

Decoder functions. More...

#include <shcodecs/shcodecs_common.h>

Go to the source code of this file.

Typedefs

typedef struct SHCodecs_Decoder SHCodecs_Decoder
typedef int(* SHCodecs_Decoded_Callback )(SHCodecs_Decoder *decoder, unsigned char *y_buf, int y_size, unsigned char *c_buf, int c_size, void *user_data)
 Signature of a callback for libshcodecs to call when it has decoded YUV 4:2:0 data.

Functions

SHCodecs_Decoder * shcodecs_decoder_init (int width, int height, SHCodecs_Format format)
 Initialize the VPU4 for decoding a given video format.
void shcodecs_decoder_close (SHCodecs_Decoder *decoder)
 Deallocate resources used to initialize the VPU4, and reset it for future use.
int shcodecs_decoder_set_decoded_callback (SHCodecs_Decoder *decoder, SHCodecs_Decoded_Callback decoded_cb, void *user_data)
 Set the callback for libshcodecs to call when decoded data is available.
int shcodecs_decoder_set_frame_by_frame (SHCodecs_Decoder *decoder, int frame_by_frame)
 Set the data input mode for frame-by-frame input, or for continuous data streaming input.
int shcodecs_decode (SHCodecs_Decoder *decoder, unsigned char *data, int len)
 Decode a buffer of input data.
int shcodecs_decoder_finalize (SHCodecs_Decoder *decoder)
 Finalize decoding of a stream.
int shcodecs_decoder_get_frame_count (SHCodecs_Decoder *decoder)
 Retrieve the count of decoded frames.

Detailed Description

Decoder functions.


Typedef Documentation

typedef int(* SHCodecs_Decoded_Callback)(SHCodecs_Decoder *decoder, unsigned char *y_buf, int y_size, unsigned char *c_buf, int c_size, void *user_data)

Signature of a callback for libshcodecs to call when it has decoded YUV 4:2:0 data.

To pause decoding, return 1 from this callback.

Parameters:
decoder The SHCodecs_Decoder* handle
y_buf The decoded Y plane
y_size The size in bytes of the decoded Y data
c_buf The decoded C plane
c_size The size in bytes of the decoded C data
user_data Arbitrary data supplied by user
Return values:
0 Continue decoding
1 Pause decoding, return from shcodecs_decode()

Function Documentation

int shcodecs_decode ( SHCodecs_Decoder *  decoder,
unsigned char *  data,
int  len 
)

Decode a buffer of input data.

This function will call the previously registered callback each time it has decoded a complete frame. If that callback returns 1, decoding is paused and shcodecs_decode() will return immediately. The decode state will be retained between successive calls.

Parameters:
decoder The SHCodecs_Decoder* handle
data A memory buffer containing compressed video data
len The length in bytes of the data
Returns:
The number of bytes of input that were used. Note that this may be zero even if frames were decoded, in the case that the decoder was previously paused and is being resumed.
void shcodecs_decoder_close ( SHCodecs_Decoder *  decoder  ) 

Deallocate resources used to initialize the VPU4, and reset it for future use.

Parameters:
decoder The SHCodecs_Decoder* handle
int shcodecs_decoder_finalize ( SHCodecs_Decoder *  decoder  ) 

Finalize decoding of a stream.

This will flush any partial decode state, which may result in a final frame being extracted. The previously registered callback will be called if a complete frame is decoded. Note that previously generated frames will be referenced, so do not free any of the image buffers you were using for shcodecs_decode() before calling this function.

finalize() generates the final frames after all input data has been read in. The reason the call exists is that the encoded data order is not necessarily the same as presentation order, so the frames are re-ordered. finalize() signals to the decoder that the re-ordering buffer should be flushed.

The encoded data for most video frames is a description of the difference between this and previous video images, which is why it needs to reference the previously generated frames (both during normal decode and during finalization).

Parameters:
decoder The SHCodecs_Decoder* handle
Returns:
The number of final frames extracted by this call
int shcodecs_decoder_get_frame_count ( SHCodecs_Decoder *  decoder  ) 

Retrieve the count of decoded frames.

Parameters:
decoder The SHCodecs_Decoder* handle
Returns:
The total number of frames decoded by decoder
SHCodecs_Decoder* shcodecs_decoder_init ( int  width,
int  height,
SHCodecs_Format  format 
)

Initialize the VPU4 for decoding a given video format.

Parameters:
width The video image width
height The video image height
format SHCodecs_Format_MPEG4 or SHCODECS_Format_H264
Returns:
decoder The SHCodecs_Decoder* handle
int shcodecs_decoder_set_decoded_callback ( SHCodecs_Decoder *  decoder,
SHCodecs_Decoded_Callback  decoded_cb,
void *  user_data 
)

Set the callback for libshcodecs to call when decoded data is available.

Parameters:
decoder The SHCodecs_Decoder* handle
decoded_cb The callback function
user_data Additional data to pass to the callback function
int shcodecs_decoder_set_frame_by_frame ( SHCodecs_Decoder *  decoder,
int  frame_by_frame 
)

Set the data input mode for frame-by-frame input, or for continuous data streaming input.

If the calling application does its own packet demuxing and passes individiual packets to shcodecs, then set this function. Otherwise, arbitrary data can be streamed in and shcodecs will scan for packet boundaries.

Parameters:
decoder The SHCodecs_Decoder* handle
frame_by_frame Flag: Input data is passed in one frame blocks if set to a non-zero value.
Return values:
0 Success
Generated on Fri Aug 26 15:01:40 2011 for libshcodecs by  doxygen 1.6.3