Logo Search packages:      
Sourcecode: libtheora version File versions  Download package

double theora_granule_time ( theora_state th,
ogg_int64_t  granulepos 
)

Convert a granulepos to absolute time in seconds. The granulepos is interpreted in the context of a given theora_state handle.

Parameters:
th A previously initialized theora_state handle (encode or decode)
granulepos The granulepos to convert.
Returns:
The absolute time in seconds corresponding to granulepos.
Return values:
-1. The given granulepos is undefined (i.e. negative), or
-1. The function has been disabled because floating point support is not available.

Definition at line 410 of file toplevel.c.

References theora_info::fps_denominator, theora_info::fps_numerator, PB_INSTANCE::info, theora_state::internal_decode, theora_state::internal_encode, PB_INSTANCE::keyframe_granule_shift, and theora_granule_time().

Referenced by theora_granule_time().

                                                                   {
#ifndef THEORA_DISABLE_FLOAT
  CP_INSTANCE *cpi=(CP_INSTANCE *)(th->internal_encode);
  PB_INSTANCE *pbi=(PB_INSTANCE *)(th->internal_decode);

  if(cpi)pbi=&cpi->pb;

  if(granulepos>=0){
    ogg_int64_t iframe=granulepos>>pbi->keyframe_granule_shift;
    ogg_int64_t pframe=granulepos-(iframe<<pbi->keyframe_granule_shift);

    return (iframe+pframe)*
      ((double)pbi->info.fps_denominator/pbi->info.fps_numerator);

  }
#endif

  return(-1); /* negative granulepos or float calculations disabled */
}


Generated by  Doxygen 1.6.0   Back to index