Ejemplo n.º 1
0
/* fas_put_seek_table */
fas_error_type fas_put_seek_table (fas_context_ref_type context, seek_table_type table)
{
  if (NULL == context || FAS_FALSE == context->is_video_active)
    return private_show_error("null context or inactive video", FAS_INVALID_ARGUMENT);

  seek_release_table (&context->seek_table);
  context->seek_table = seek_copy_table(table);

  return FAS_SUCCESS;
}
Ejemplo n.º 2
0
int main (int argc, char **argv)
{
  fas_error_type video_error;
  fas_context_ref_type context;
  
  if (argc < 3) {
    fprintf (stderr, "usage: %s <video_file> <seek_table>\n", argv[0]);
    fail("arguments\n");
  }

  fprintf(stderr, "%s : ", argv[1]);

  seek_table_type table = read_table_file(argv[2]);
  if (table.num_entries == 0)
    fail("bad table\n");
  
  fas_initialize (FAS_FALSE, FAS_RGB24);
  
  video_error = fas_open_video (&context, argv[1]);
  if (video_error != FAS_SUCCESS)    fail("fail on open\n");
  
  video_error = fas_put_seek_table(context, table);
  if (video_error != FAS_SUCCESS)    fail("fail on put_seek_table\n");
    
  if (fas_get_frame_count(context) < 0)
    fail("n_frames = -1\n");

  if (fas_get_frame_count(context) < TEST_SET_SIZE)
      do_random_test(context, 0, fas_get_frame_count(context) - 1, N_ITERATIONS);
  else if (fas_get_frame_count(context) < TEST_SET_SIZE * 2)
    {
      do_random_test(context, 0, fas_get_frame_count(context) / 2 - 1, N_ITERATIONS / 2);
      do_random_test(context, fas_get_frame_count(context) / 2 + 1, fas_get_frame_count(context) - 1 , N_ITERATIONS / 2);   
    }
  else
    {
      do_random_test(context, 0, TEST_SET_SIZE, N_ITERATIONS / 2);
      do_random_test(context, fas_get_frame_count(context) - TEST_SET_SIZE, fas_get_frame_count(context) - 1 , N_ITERATIONS / 2);   
    }

  seek_release_table(&table);
  fas_close_video(context);
  
  success();
}
Ejemplo n.º 3
0
/* fas_close_video */
fas_error_type fas_close_video (fas_context_ref_type context)
{
  if (NULL == context)
    return private_show_error("NULL context provided for fas_close_video()", FAS_INVALID_ARGUMENT);

  if (!(context->is_video_active))
    {
      private_show_warning ("Redundant attempt to close an inactive video");
      return FAS_SUCCESS;
    }

  if (context->codec_context)
    if (avcodec_find_decoder (context->codec_context->codec_id))
      avcodec_close(context->codec_context);

  if (context->format_context)
    av_close_input_file (context->format_context);

  if (context->rgb_frame_buffer)
    av_free (context->rgb_frame_buffer);

  if (context->gray8_frame_buffer)
    av_free (context->gray8_frame_buffer);

  if (context->rgb_buffer)
    av_free(context->rgb_buffer);

  if (context->gray8_buffer)
    av_free(context->gray8_buffer);

  if (context->frame_buffer)
    av_free (context->frame_buffer);

  seek_release_table (&(context->seek_table));

  context->is_video_active = FAS_FALSE;

  free (context);

  return FAS_SUCCESS;
}