int main(void)
{
    Rational *rational = make_rational(3, 7);
    print_rational(rational);

    double d = rational_to_double(rational);
    printf("%lf\n", d);

    Rational *square = mult_rational(rational, rational);
    print_rational(square);
	
    free_rational(rational);
    free_rational(square);

    return EXIT_SUCCESS;
}
示例#2
0
static VideoDecoderStatus
decode(VideoDecoder *vdec, Movie *m, Image *p, DemuxedPacket *dp, unsigned int len, unsigned int *used_r)
{
  struct videodecoder_divx *vdm = (struct videodecoder_divx *)vdec->opaque;
  unsigned char *buf = dp->data;
  int res;

  if (len == 0)
    return VD_NEED_MORE_DATA;
  *used_r = len;

  vdm->dec_frame.length = len;
  vdm->dec_frame.bitstream = buf;
  vdm->dec_frame.bmp = memory_ptr(image_rendered_image(p));
  vdm->dec_frame.render_flag = vdm->to_skip > 0 ? 0 : 1;
  vdm->dec_frame.stride = 0;
  pthread_mutex_lock(&vdec->update_mutex);
  if ((res = decore(vdm->dec_handle, DEC_OPT_FRAME, &vdm->dec_frame, NULL)) != DEC_OK) {
    if (res == DEC_BAD_FORMAT) {
      err_message("OPT_FRAME returns DEC_BAD_FORMAT\n");
    } else {
      err_message("OPT_FRAME returns %d\n", res);
    }
    pthread_mutex_unlock(&vdec->update_mutex);
    return VD_ERROR;
  }

  m->current_frame++;
  if (vdm->to_skip > 0) {
    vdm->to_skip--;
    pthread_mutex_unlock(&vdec->update_mutex);
    return VD_OK;
  }

  vdec->ts_base = dp->ts_base;
  vdec->pts = m->current_frame * 1000 / rational_to_double(m->framerate);
  vdec->to_render++;
  while (m->status == _PLAY && vdec->to_render > 0)
    pthread_cond_wait(&vdec->update_cond, &vdec->update_mutex);
  pthread_mutex_unlock(&vdec->update_mutex);

  return VD_OK;
}