Logo Search packages:      
Sourcecode: libtheora version File versions

int theora_decode_packetin ( theora_state th,
ogg_packet *  op 
)

Input a packet containing encoded data into the theora decoder.

Parameters:
th A theora_state handle previously initialized for decoding.
op An ogg_packet containing encoded theora data.
Return values:
OC_BADPACKET op does not contain encoded video data

Definition at line 323 of file toplevel.c.

References theora_state::granulepos, theora_state::internal_decode, OC_BADPACKET, and theora_decode_packetin().

Referenced by theora_decode_packetin().

                                                           {
  long ret;
  PB_INSTANCE *pbi=(PB_INSTANCE *)(th->internal_decode);

  pbi->DecoderErrorCode = 0;

#ifndef LIBOGG2
  oggpackB_readinit(pbi->opb,op->packet,op->bytes);
#else
  oggpackB_readinit(pbi->opb,op->packet);
#endif

  /* verify that this is a video frame */
  theora_read(pbi->opb,1,&ret);

  if (ret==0) {
    ret=LoadAndDecode(pbi);

    if(ret)return ret;

    if(pbi->PostProcessingLevel)
      PostProcess(pbi);

    if(op->granulepos>-1)
      th->granulepos=op->granulepos;
    else{
      if(th->granulepos==-1){
        th->granulepos=0;
      }else{
        if(pbi->FrameType==BASE_FRAME){
          long frames= th->granulepos & ((1<<pbi->keyframe_granule_shift)-1);
          th->granulepos>>=pbi->keyframe_granule_shift;
          th->granulepos+=frames+1;
          th->granulepos<<=pbi->keyframe_granule_shift;
        }else
          th->granulepos++;
      }
    }

    return(0);
  }

  return OC_BADPACKET;
}


Generated by  Doxygen 1.6.0   Back to index