gmerlin-avdecoder
Functions

Functions

BGAV_PUBLIC int bgav_video_has_still (bgav_t *bgav, int stream)
 Determine if a still image is available for reading.
 
BGAV_PUBLIC int bgav_read_video (bgav_t *bgav, gavl_video_frame_t *frame, int stream)
 Decode a video frame.
 
BGAV_PUBLIC void bgav_skip_video (bgav_t *bgav, int stream, int64_t *time, int scale, int exact)
 Skip forward in a video stream.
 
BGAV_PUBLIC gavl_video_source_t * bgav_get_video_source (bgav_t *bgav, int stream)
 Return the video source for a video stream.
 
BGAV_PUBLIC gavl_video_source_t * bgav_get_overlay_source (bgav_t *bgav, int stream)
 Return the video source for an overlay stream.
 
BGAV_PUBLIC int bgav_read_audio (bgav_t *bgav, gavl_audio_frame_t *frame, int stream, int num_samples)
 Decode audio samples.
 
BGAV_PUBLIC gavl_audio_source_t * bgav_get_audio_source (bgav_t *bgav, int stream)
 Return the audio source for this stream.
 
BGAV_PUBLIC int bgav_has_subtitle (bgav_t *bgav, int stream)
 Check, if a new subtitle is available.
 
BGAV_PUBLIC int bgav_read_subtitle_overlay (bgav_t *bgav, gavl_overlay_t *ovl, int stream)
 Decode an overlay subtitle.
 
BGAV_PUBLIC int bgav_read_subtitle_text (bgav_t *bgav, char **ret, int *ret_alloc, int64_t *start_time, int64_t *duration, int stream)
 Decode a text subtitle.
 

Detailed Description

Function Documentation

◆ bgav_video_has_still()

BGAV_PUBLIC int bgav_video_has_still ( bgav_t bgav,
int  stream 
)

Determine if a still image is available for reading.

Parameters
bgavA decoder instance
streamStream index (starting with 0)
Returns
1 if a still image is available, 0 else

This should be used, if the framerate_mode of the video format is GAVL_FRAMERATE_STILL. In earlier versions, streams consisting of one or more still images outputted the same image repeatedly as if it was a video stream. Since 1.0.1 each image is decoded exactly once. The end-of-file detection happens in a similar way as for subtitles: bgav_video_has_still returns 1 and the following bgav_read_video returns 0.

Since 1.0.1

◆ bgav_read_video()

BGAV_PUBLIC int bgav_read_video ( bgav_t bgav,
gavl_video_frame_t frame,
int  stream 
)

Decode a video frame.

Parameters
bgavA decoder instance
frameThe frame to which the image will be decoded.
streamStream index (starting with 0)
Returns
1 if a frame could be decoded, 0 for EOF.

◆ bgav_skip_video()

BGAV_PUBLIC void bgav_skip_video ( bgav_t bgav,
int  stream,
int64_t *  time,
int  scale,
int  exact 
)

Skip forward in a video stream.

Parameters
bgavA decoder instance
streamStream index (starting with 0)
timeThe time to skip to (will be changed to the true time)
scaleScale by which the time is scaled
exact1 if an exact skip should be done, 0 for faster approximate skip

Use this function if it turns out, that the machine is too weak to decode all frames. Set exact to 0 to make the skipping even faster but less accurate.

◆ bgav_get_video_source()

BGAV_PUBLIC gavl_video_source_t * bgav_get_video_source ( bgav_t bgav,
int  stream 
)

Return the video source for a video stream.

Parameters
bgavA decoder instance
streamStream index (starting with 0)
Returns
A video source to get the frames from

This is an alternative to using bgav_video_has_still and bgav_read_video. A gavl_video_source_t lets you read frames with optimized buffer management and implicit format conversion. For a still stream, if no image is available, the source will return GAVL_VIDEO_SOURCE_AGAIN.

◆ bgav_get_overlay_source()

BGAV_PUBLIC gavl_video_source_t * bgav_get_overlay_source ( bgav_t bgav,
int  stream 
)

Return the video source for an overlay stream.

Parameters
bgavA decoder instance
streamStream index (starting with 0)
Returns
A video source to get the overlays from

◆ bgav_read_audio()

BGAV_PUBLIC int bgav_read_audio ( bgav_t bgav,
gavl_audio_frame_t frame,
int  stream,
int  num_samples 
)

Decode audio samples.

Parameters
bgavA decoder instance
frameThe frame to which the samples will be decoded.
streamStream index (starting with 0)
num_samplesNumber of samples to be decoded
Returns
The number of actually decoded samples, which can be smaller than num_samples. 0 means EOF.

◆ bgav_get_audio_source()

BGAV_PUBLIC gavl_audio_source_t * bgav_get_audio_source ( bgav_t bgav,
int  stream 
)

Return the audio source for this stream.

Parameters
bgavA decoder instance
streamStream index (starting with 0)
Returns
A audio source to get the frames from

This is an alternative to using bgav_read_audio. A gavl_audio_source_t lets you read frames with optimized buffer management and implicit format conversion.

◆ bgav_has_subtitle()

BGAV_PUBLIC int bgav_has_subtitle ( bgav_t bgav,
int  stream 
)

Check, if a new subtitle is available.

Parameters
bgavA decoder instance
streamStream index (starting with 0)
Returns
1 if a subtitle is available.

Use this function to check in advance, if it would make sense to call bgav_read_subtitle_overlay or bgav_read_subtitle_text.

◆ bgav_read_subtitle_overlay()

BGAV_PUBLIC int bgav_read_subtitle_overlay ( bgav_t bgav,
gavl_overlay_t ovl,
int  stream 
)

Decode an overlay subtitle.

Parameters
bgavA decoder instance
ovlThe overlay to which the subtitle will be decoded.
streamStream index (starting with 0)
Returns
1 if a subtitle could be decoded, 0 else

If this function returns 1, a subtitle was decoded. If this function returns 0 and bgav_has_subtitle returned 0 before as well, there is no subtitle yet available, but there might come others at a later point in the stream. If this function returns 0 and bgav_has_subtitle returned 1 before, it means, that you reached the end of the subtitle stream.

◆ bgav_read_subtitle_text()

BGAV_PUBLIC int bgav_read_subtitle_text ( bgav_t bgav,
char **  ret,
int *  ret_alloc,
int64_t *  start_time,
int64_t *  duration,
int  stream 
)

Decode a text subtitle.

Parameters
bgavA decoder instance
retThe string, where the text will be stored.
ret_allocThe number of allocated bytes for ret
start_timeReturns the start time
durationReturns the duration
streamStream index (starting with 0)
Returns
1 if a subtitle could be decoded, 0 else

If this function returns 1, a subtitle was decoded. If this function returns 0 and bgav_has_subtitle returned 0 before as well, there is no subtitle yet available, but there might come others at a later point in the stream. If this function returns 0 and bgav_has_subtitle returned 1 before, it means, that you reached the end of the subtitle stream. start_time and duration are scaled by the timescale of the subtitle stream (see bgav_get_subtitle_format).