VLC  3.0.15
Data Structures | Macros | Enumerations | Functions
decoder.c File Reference
Include dependency graph for decoder.c:

Data Structures

struct  decoder_owner_sys_t
 

Macros

#define MAX_CC_DECODERS   64 /* The es_out only creates one type of es */
 
#define DECODER_BOGUS_VIDEO_DELAY   ((mtime_t)(DEFAULT_PTS_DELAY * 30))
 
#define DECODER_SPU_VOUT_WAIT_DURATION   ((int)(0.200*CLOCK_FREQ))
 
#define BLOCK_FLAG_CORE_PRIVATE_RELOADED   (1 << BLOCK_FLAG_CORE_PRIVATE_SHIFT)
 

Enumerations

enum  reload { RELOAD_NO_REQUEST, RELOAD_DECODER, RELOAD_DECODER_AOUT }
 

Functions

static int LoadDecoder (decoder_t *p_dec, bool b_packetizer, const es_format_t *restrict p_fmt)
 Load a decoder module. More...
 
static void UnloadDecoder (decoder_t *p_dec)
 Unload a decoder module. More...
 
static int ReloadDecoder (decoder_t *p_dec, bool b_packetizer, const es_format_t *restrict p_fmt, enum reload reload)
 
static void DecoderUpdateFormatLocked (decoder_t *p_dec)
 
static vout_thread_t * aout_request_vout (void *p_private, vout_thread_t *p_vout, const video_format_t *p_fmt, bool b_recyle)
 
static bool aout_replaygain_changed (const audio_replay_gain_t *a, const audio_replay_gain_t *b)
 
static int aout_update_format (decoder_t *p_dec)
 
static int vout_update_format (decoder_t *p_dec)
 
static picture_t * vout_new_buffer (decoder_t *p_dec)
 
static subpicture_t * spu_new_buffer (decoder_t *p_dec, const subpicture_updater_t *p_updater)
 
static int DecoderGetInputAttachments (decoder_t *p_dec, input_attachment_t ***ppp_attachment, int *pi_attachment)
 
static mtime_t DecoderGetDisplayDate (decoder_t *p_dec, mtime_t i_ts)
 
static int DecoderGetDisplayRate (decoder_t *p_dec)
 
block_t * decoder_NewAudioBuffer (decoder_t *dec, int samples)
 This function will return a new audio buffer usable by a decoder as an output buffer. More...
 
subpicture_t * decoder_NewSubpicture (decoder_t *p_decoder, const subpicture_updater_t *p_dyn)
 This function will return a new subpicture usable by a decoder as an output buffer. More...
 
static void RequestReload (decoder_t *p_dec)
 
int decoder_GetInputAttachments (decoder_t *p_dec, input_attachment_t ***ppp_attachment, int *pi_attachment)
 This function gives all input attachments at once. More...
 
mtime_t decoder_GetDisplayDate (decoder_t *p_dec, mtime_t i_ts)
 This function converts a decoder timestamp into a display date comparable to mdate(). More...
 
int decoder_GetDisplayRate (decoder_t *p_dec)
 This function returns the current input rate. More...
 
void decoder_AbortPictures (decoder_t *p_dec, bool b_abort)
 Abort any calls of decoder_NewPicture. More...
 
static void DecoderWaitUnblock (decoder_t *p_dec)
 
static int DecoderTimedWait (decoder_t *p_dec, mtime_t deadline)
 
static void DecoderUpdatePreroll (int64_t *pi_preroll, const block_t *p)
 
static void DecoderFixTs (decoder_t *p_dec, mtime_t *pi_ts0, mtime_t *pi_ts1, mtime_t *pi_duration, int *pi_rate, mtime_t i_ts_bound)
 
static void DecoderPlayCc (decoder_t *p_dec, block_t *p_cc, const decoder_cc_desc_t *p_desc)
 
static void PacketizerGetCc (decoder_t *p_dec, decoder_t *p_dec_cc)
 
static int DecoderQueueCc (decoder_t *p_videodec, block_t *p_cc, const decoder_cc_desc_t *p_desc)
 
static int DecoderPlayVideo (decoder_t *p_dec, picture_t *p_picture, unsigned *restrict pi_lost_sum)
 
static void DecoderUpdateStatVideo (decoder_owner_sys_t *p_owner, unsigned decoded, unsigned lost)
 
static int DecoderQueueVideo (decoder_t *p_dec, picture_t *p_pic)
 
static int DecoderPlayAudio (decoder_t *p_dec, block_t *p_audio, unsigned *restrict pi_lost_sum)
 
static void DecoderUpdateStatAudio (decoder_owner_sys_t *p_owner, unsigned decoded, unsigned lost)
 
static int DecoderQueueAudio (decoder_t *p_dec, block_t *p_aout_buf)
 
static void DecoderPlaySpu (decoder_t *p_dec, subpicture_t *p_subpic)
 
static void DecoderUpdateStatSpu (decoder_owner_sys_t *p_owner, unsigned decoded, unsigned lost)
 
static int DecoderQueueSpu (decoder_t *p_dec, subpicture_t *p_spu)
 
static void DecoderProcess (decoder_t *p_dec, block_t *p_block)
 Decode a block. More...
 
static void DecoderDecode (decoder_t *p_dec, block_t *p_block)
 
static void DecoderProcessFlush (decoder_t *p_dec)
 
static void * DecoderThread (void *p_data)
 The decoding main loop. More...
 
static decoder_t * CreateDecoder (vlc_object_t *p_parent, input_thread_t *p_input, const es_format_t *fmt, input_resource_t *p_resource, sout_instance_t *p_sout)
 Create a decoder object. More...
 
static void DeleteDecoder (decoder_t *p_dec)
 Destroys a decoder object. More...
 
static void DecoderUnsupportedCodec (decoder_t *p_dec, const es_format_t *fmt, bool b_decoding)
 
static decoder_t * decoder_New (vlc_object_t *p_parent, input_thread_t *p_input, const es_format_t *fmt, input_clock_t *p_clock, input_resource_t *p_resource, sout_instance_t *p_sout)
 
decoder_t * input_DecoderNew (input_thread_t *p_input, es_format_t *fmt, input_clock_t *p_clock, sout_instance_t *p_sout)
 Spawns a new decoder thread from the input thread. More...
 
decoder_t * input_DecoderCreate (vlc_object_t *p_parent, const es_format_t *fmt, input_resource_t *p_resource)
 Spawn a decoder thread outside of the input thread. More...
 
void input_DecoderDelete (decoder_t *p_dec)
 Kills a decoder thread and waits until it's finished. More...
 
void input_DecoderDecode (decoder_t *p_dec, block_t *p_block, bool b_do_pace)
 Put a block_t in the decoder's fifo. More...
 
bool input_DecoderIsEmpty (decoder_t *p_dec)
 This function returns true if the decoder fifo is empty and false otherwise. More...
 
void input_DecoderDrain (decoder_t *p_dec)
 Signals that there are no further blocks to decode, and requests that the decoder drain all pending buffers. More...
 
void input_DecoderFlush (decoder_t *p_dec)
 Requests that the decoder immediately discard all pending buffers. More...
 
void input_DecoderGetCcDesc (decoder_t *p_dec, decoder_cc_desc_t *p_desc)
 This function get cc channels descriptions. More...
 
static bool input_DecoderHasCCChanFlag (decoder_t *p_dec, vlc_fourcc_t codec, int i_channel)
 
int input_DecoderSetCcState (decoder_t *p_dec, vlc_fourcc_t codec, int i_channel, bool b_decode)
 This function activates the request closed caption channel. More...
 
int input_DecoderGetCcState (decoder_t *p_dec, vlc_fourcc_t codec, int i_channel, bool *pb_decode)
 This function returns an error if the requested channel does not exist and set pb_decode to the channel status(active or not) otherwise. More...
 
void input_DecoderChangePause (decoder_t *p_dec, bool b_paused, mtime_t i_date)
 This function changes the pause state. More...
 
void input_DecoderChangeDelay (decoder_t *p_dec, mtime_t i_delay)
 This function changes the delay. More...
 
void input_DecoderStartWait (decoder_t *p_dec)
 This function makes the decoder start waiting for a valid data block from its fifo. More...
 
void input_DecoderStopWait (decoder_t *p_dec)
 This function exits the waiting mode of the decoder. More...
 
void input_DecoderWait (decoder_t *p_dec)
 This function waits for the decoder to actually receive data. More...
 
void input_DecoderFrameNext (decoder_t *p_dec, mtime_t *pi_duration)
 This function force the display of the next picture and fills the stream time consumed. More...
 
bool input_DecoderHasFormatChanged (decoder_t *p_dec, es_format_t *p_fmt, vlc_meta_t **pp_meta)
 This function will return true if the ES format or meta data have changed since the last call. More...
 
size_t input_DecoderGetFifoSize (decoder_t *p_dec)
 This function returns the current size in bytes of the decoder fifo. More...
 
void input_DecoderGetObjects (decoder_t *p_dec, vout_thread_t **pp_vout, audio_output_t **pp_aout)
 This function returns the objects associated to a decoder. More...
 

Macro Definition Documentation

◆ BLOCK_FLAG_CORE_PRIVATE_RELOADED

#define BLOCK_FLAG_CORE_PRIVATE_RELOADED   (1 << BLOCK_FLAG_CORE_PRIVATE_SHIFT)

◆ DECODER_BOGUS_VIDEO_DELAY

#define DECODER_BOGUS_VIDEO_DELAY   ((mtime_t)(DEFAULT_PTS_DELAY * 30))

◆ DECODER_SPU_VOUT_WAIT_DURATION

#define DECODER_SPU_VOUT_WAIT_DURATION   ((int)(0.200*CLOCK_FREQ))

◆ MAX_CC_DECODERS

#define MAX_CC_DECODERS   64 /* The es_out only creates one type of es */

Enumeration Type Documentation

◆ reload

enum reload
Enumerator
RELOAD_NO_REQUEST 
RELOAD_DECODER 
RELOAD_DECODER_AOUT 

Function Documentation

◆ aout_replaygain_changed()

static bool aout_replaygain_changed ( const audio_replay_gain_t *  a,
const audio_replay_gain_t *  b 
)
static

◆ aout_request_vout()

static vout_thread_t* aout_request_vout ( void *  p_private,
vout_thread_t *  p_vout,
const video_format_t *  p_fmt,
bool  b_recyle 
)
static

◆ aout_update_format()

static int aout_update_format ( decoder_t *  p_dec)
static

◆ CreateDecoder()

static decoder_t* CreateDecoder ( vlc_object_t *  p_parent,
input_thread_t *  p_input,
const es_format_t *  fmt,
input_resource_t *  p_resource,
sout_instance_t *  p_sout 
)
static

Create a decoder object.

Parameters
p_inputthe input thread
p_esthe es descriptor
b_packetizerinstead of a decoder
Returns
the decoder object

References aout_update_format(), AUDIO_ES, es_format_t::audio_replay_gain, AUDIO_REPLAY_GAIN_MAX, decoder_owner_sys_t::b_draining, decoder_owner_sys_t::b_first, decoder_owner_sys_t::b_fmt_description, decoder_owner_sys_t::b_has_data, decoder_owner_sys_t::b_idle, es_format_t::b_packetized, decoder_owner_sys_t::b_supported, decoder_owner_sys_t::b_waiting, block_FifoNew(), decoder_owner_sys_t::cc, DecoderGetDisplayDate(), DecoderGetDisplayRate(), DecoderGetInputAttachments(), DecoderQueueAudio(), DecoderQueueCc(), DecoderQueueSpu(), DecoderQueueVideo(), DecoderUpdateStatAudio(), DecoderUpdateStatSpu(), DecoderUpdateStatVideo(), decoder_owner_sys_t::desc, decoder_owner_sys_t::drained, decoder_owner_sys_t::error, es_format_Init(), decoder_owner_sys_t::flushing, decoder_owner_sys_t::fmt, decoder_t::fmt_out, decoder_owner_sys_t::frames_countdown, decoder_cc_desc_t::i_608_channels, decoder_cc_desc_t::i_708_channels, es_format_t::i_cat, decoder_owner_sys_t::i_last_rate, decoder_owner_sys_t::i_preroll_end, decoder_owner_sys_t::i_spu_channel, decoder_owner_sys_t::i_spu_order, decoder_owner_sys_t::i_ts_delay, INPUT_RATE_DEFAULT, LoadDecoder(), decoder_owner_sys_t::lock, MAX_CC_DECODERS, msg_Err, decoder_owner_sys_t::p_aout, decoder_owner_sys_t::p_description, decoder_owner_sys_t::p_fifo, decoder_owner_sys_t::p_input, decoder_t::p_owner, decoder_owner_sys_t::p_packetizer, decoder_owner_sys_t::p_resource, decoder_owner_sys_t::p_sout, decoder_owner_sys_t::p_sout_input, decoder_owner_sys_t::p_spu_vout, decoder_owner_sys_t::p_vout, decoder_owner_sys_t::pause_date, decoder_owner_sys_t::paused, audio_replay_gain_t::pb_gain, audio_replay_gain_t::pb_peak, decoder_t::pf_aout_format_update, audio_replay_gain_t::pf_gain, decoder_t::pf_get_attachments, decoder_t::pf_get_display_date, decoder_t::pf_get_display_rate, audio_replay_gain_t::pf_peak, decoder_t::pf_queue_audio, decoder_t::pf_queue_cc, decoder_t::pf_queue_sub, decoder_t::pf_queue_video, decoder_t::pf_spu_buffer_new, decoder_owner_sys_t::pf_update_stat, decoder_t::pf_vout_buffer_new, decoder_t::pf_vout_format_update, decoder_owner_sys_t::pp_decoder, decoder_owner_sys_t::reload, RELOAD_NO_REQUEST, SPU_ES, spu_new_buffer(), unlikely, UnloadDecoder(), VIDEO_ES, vlc_cond_init(), vlc_custom_create, vlc_mutex_init(), vlc_object_release, VLC_TS_INVALID, vout_new_buffer(), vout_update_format(), decoder_owner_sys_t::wait_acknowledge, decoder_owner_sys_t::wait_fifo, decoder_owner_sys_t::wait_request, and decoder_owner_sys_t::wait_timed.

Referenced by decoder_New().

◆ decoder_New()

static decoder_t* decoder_New ( vlc_object_t *  p_parent,
input_thread_t *  p_input,
const es_format_t *  fmt,
input_clock_t *  p_clock,
input_resource_t *  p_resource,
sout_instance_t *  p_sout 
)
static

◆ DecoderDecode()

static void DecoderDecode ( decoder_t *  p_dec,
block_t *  p_block 
)
static

< No error

< Unspecified error

Referenced by DecoderProcess().

◆ DecoderFixTs()

static void DecoderFixTs ( decoder_t *  p_dec,
mtime_t *  pi_ts0,
mtime_t *  pi_ts1,
mtime_t *  pi_duration,
int *  pi_rate,
mtime_t  i_ts_bound 
)
static

◆ DecoderGetDisplayDate()

static mtime_t DecoderGetDisplayDate ( decoder_t *  p_dec,
mtime_t  i_ts 
)
static

◆ DecoderGetDisplayRate()

static int DecoderGetDisplayRate ( decoder_t *  p_dec)
static

◆ DecoderGetInputAttachments()

static int DecoderGetInputAttachments ( decoder_t *  p_dec,
input_attachment_t ***  ppp_attachment,
int *  pi_attachment 
)
static

◆ DecoderPlayAudio()

static int DecoderPlayAudio ( decoder_t *  p_dec,
block_t *  p_audio,
unsigned *restrict  pi_lost_sum 
)
static

◆ DecoderPlayCc()

static void DecoderPlayCc ( decoder_t *  p_dec,
block_t *  p_cc,
const decoder_cc_desc_t *  p_desc 
)
static

◆ DecoderPlaySpu()

static void DecoderPlaySpu ( decoder_t *  p_dec,
subpicture_t *  p_subpic 
)
static

◆ DecoderPlayVideo()

static int DecoderPlayVideo ( decoder_t *  p_dec,
picture_t *  p_picture,
unsigned *restrict  pi_lost_sum 
)
static

◆ DecoderProcess()

static void DecoderProcess ( decoder_t *  p_dec,
block_t *  p_block 
)
static

◆ DecoderProcessFlush()

static void DecoderProcessFlush ( decoder_t *  p_dec)
static

Referenced by DecoderThread().

◆ DecoderQueueAudio()

static int DecoderQueueAudio ( decoder_t *  p_dec,
block_t *  p_aout_buf 
)
static

Referenced by CreateDecoder().

◆ DecoderQueueCc()

static int DecoderQueueCc ( decoder_t *  p_videodec,
block_t *  p_cc,
const decoder_cc_desc_t *  p_desc 
)
static

Referenced by CreateDecoder().

◆ DecoderQueueSpu()

static int DecoderQueueSpu ( decoder_t *  p_dec,
subpicture_t *  p_spu 
)
static

Referenced by CreateDecoder().

◆ DecoderQueueVideo()

static int DecoderQueueVideo ( decoder_t *  p_dec,
picture_t *  p_pic 
)
static

Referenced by CreateDecoder().

◆ DecoderThread()

static void* DecoderThread ( void *  p_data)
static

◆ DecoderTimedWait()

static int DecoderTimedWait ( decoder_t *  p_dec,
mtime_t  deadline 
)
static

◆ DecoderUnsupportedCodec()

static void DecoderUnsupportedCodec ( decoder_t *  p_dec,
const es_format_t *  fmt,
bool  b_decoding 
)
static

◆ DecoderUpdateFormatLocked()

static void DecoderUpdateFormatLocked ( decoder_t *  p_dec)
static

◆ DecoderUpdatePreroll()

static void DecoderUpdatePreroll ( int64_t *  pi_preroll,
const block_t *  p 
)
inlinestatic

Referenced by DecoderProcess().

◆ DecoderUpdateStatAudio()

static void DecoderUpdateStatAudio ( decoder_owner_sys_t *  p_owner,
unsigned  decoded,
unsigned  lost 
)
static

Referenced by CreateDecoder().

◆ DecoderUpdateStatSpu()

static void DecoderUpdateStatSpu ( decoder_owner_sys_t *  p_owner,
unsigned  decoded,
unsigned  lost 
)
static

Referenced by CreateDecoder().

◆ DecoderUpdateStatVideo()

static void DecoderUpdateStatVideo ( decoder_owner_sys_t *  p_owner,
unsigned  decoded,
unsigned  lost 
)
static

Referenced by CreateDecoder().

◆ DecoderWaitUnblock()

static void DecoderWaitUnblock ( decoder_t *  p_dec)
static

◆ DeleteDecoder()

static void DeleteDecoder ( decoder_t *  p_dec)
static

◆ input_DecoderChangeDelay()

void input_DecoderChangeDelay ( decoder_t *  p_dec,
mtime_t  i_delay 
)

This function changes the delay.

◆ input_DecoderChangePause()

void input_DecoderChangePause ( decoder_t *  ,
bool  b_paused,
mtime_t  i_date 
)

This function changes the pause state.

The date parameter MUST hold the exact date at which the change has been done for proper vout/aout pausing.

◆ input_DecoderCreate()

decoder_t* input_DecoderCreate ( vlc_object_t *  p_parent,
const es_format_t *  fmt,
input_resource_t *  p_resource 
)

Spawn a decoder thread outside of the input thread.

References decoder_New().

◆ input_DecoderDecode()

void input_DecoderDecode ( decoder_t *  p_dec,
block_t *  p_block,
bool  b_do_pace 
)

◆ input_DecoderDelete()

void input_DecoderDelete ( decoder_t *  p_dec)

◆ input_DecoderDrain()

void input_DecoderDrain ( decoder_t *  p_dec)

Signals that there are no further blocks to decode, and requests that the decoder drain all pending buffers.

This is used to ensure that all intermediate buffers empty and no samples get lost at the end of the stream.

Note
The function does not actually wait for draining. It just signals that draining should be performed once the decoder has emptied FIFO.

References decoder_owner_sys_t::b_draining, decoder_owner_sys_t::p_fifo, decoder_t::p_owner, vlc_fifo_Lock(), vlc_fifo_Signal(), and vlc_fifo_Unlock().

Referenced by EsOutControlLocked().

◆ input_DecoderFlush()

void input_DecoderFlush ( decoder_t *  p_dec)

◆ input_DecoderFrameNext()

void input_DecoderFrameNext ( decoder_t *  p_dec,
mtime_t *  pi_duration 
)

This function force the display of the next picture and fills the stream time consumed.

◆ input_DecoderGetCcDesc()

void input_DecoderGetCcDesc ( decoder_t *  p_dec,
decoder_cc_desc_t *  p_desc 
)

This function get cc channels descriptions.

Referenced by EsOutSend().

◆ input_DecoderGetCcState()

int input_DecoderGetCcState ( decoder_t *  p_dec,
vlc_fourcc_t  codec,
int  i_channel,
bool *  pb_decode 
)

This function returns an error if the requested channel does not exist and set pb_decode to the channel status(active or not) otherwise.

< Unspecified error

< No error

◆ input_DecoderGetFifoSize()

size_t input_DecoderGetFifoSize ( decoder_t *  p_dec)

This function returns the current size in bytes of the decoder fifo.

◆ input_DecoderGetObjects()

void input_DecoderGetObjects ( decoder_t *  ,
vout_thread_t **  ,
audio_output_t **   
)

This function returns the objects associated to a decoder.

They must be released using vlc_object_release().

Referenced by EsOutControlLocked().

◆ input_DecoderHasCCChanFlag()

static bool input_DecoderHasCCChanFlag ( decoder_t *  p_dec,
vlc_fourcc_t  codec,
int  i_channel 
)
static

◆ input_DecoderHasFormatChanged()

bool input_DecoderHasFormatChanged ( decoder_t *  p_dec,
es_format_t *  p_fmt,
vlc_meta_t **  pp_meta 
)

This function will return true if the ES format or meta data have changed since the last call.

In which case, it will do a copy of the current es_format_t if p_fmt is not NULL and will do a copy of the current description if pp_meta is non NULL. The es_format_t MUST be freed by es_format_Clean and *pp_meta MUST be freed by vlc_meta_Delete. Otherwise it will return false and will not initialize p_fmt and *pp_meta.

Referenced by EsOutSend().

◆ input_DecoderIsEmpty()

bool input_DecoderIsEmpty ( decoder_t *  p_dec)

This function returns true if the decoder fifo is empty and false otherwise.

◆ input_DecoderNew()

decoder_t* input_DecoderNew ( input_thread_t *  p_input,
es_format_t *  fmt,
input_clock_t *  p_clock,
sout_instance_t *  p_sout 
)

Spawns a new decoder thread from the input thread.

Parameters
p_inputthe input thread
p_esthe es descriptor
Returns
the spawned decoder object

References decoder_New(), input_priv(), and VLC_OBJECT.

◆ input_DecoderSetCcState()

int input_DecoderSetCcState ( decoder_t *  p_dec,
vlc_fourcc_t  codec,
int  i_channel,
bool  b_decode 
)

This function activates the request closed caption channel.

< Unspecified error

< Unspecified error

< Unspecified error

< No error

Referenced by input_DecoderDelete().

◆ input_DecoderStartWait()

void input_DecoderStartWait ( decoder_t *  p_dec)

This function makes the decoder start waiting for a valid data block from its fifo.

◆ input_DecoderStopWait()

void input_DecoderStopWait ( decoder_t *  p_dec)

This function exits the waiting mode of the decoder.

◆ input_DecoderWait()

void input_DecoderWait ( decoder_t *  p_dec)

This function waits for the decoder to actually receive data.

◆ LoadDecoder()

static int LoadDecoder ( decoder_t *  p_dec,
bool  b_packetizer,
const es_format_t *restrict  p_fmt 
)
static

◆ PacketizerGetCc()

static void PacketizerGetCc ( decoder_t *  p_dec,
decoder_t *  p_dec_cc 
)
static

Referenced by DecoderProcess().

◆ ReloadDecoder()

static int ReloadDecoder ( decoder_t *  p_dec,
bool  b_packetizer,
const es_format_t *restrict  p_fmt,
enum reload  reload 
)
static

◆ RequestReload()

static void RequestReload ( decoder_t *  p_dec)
static

◆ spu_new_buffer()

static subpicture_t* spu_new_buffer ( decoder_t *  p_dec,
const subpicture_updater_t *  p_updater 
)
static

◆ UnloadDecoder()

static void UnloadDecoder ( decoder_t *  p_dec)
static

◆ vout_new_buffer()

static picture_t* vout_new_buffer ( decoder_t *  p_dec)
static

◆ vout_update_format()

static int vout_update_format ( decoder_t *  p_dec)
static