summaryrefslogtreecommitdiff
path: root/rotord/src/ffmpeg_fas.h
blob: 0c5110335805bfbf4b33c128280de2600f307f7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*****************************************************************************
 * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
 * 
 * This file is part of the Frame Accurate Seeking extension library to 
 * ffmpeg (ffmpeg-fas).
 * 
 * ffmpeg-fas is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by 
 * the Free Software Foundation; either version 3 of the License, or (at your 
 * option) any later version.
 *
 * The ffmpeg-fas library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with the ffmpeg-fas library.  If not, see <http://www.gnu.org/licenses/>.
 *
 ******************************************************************************/

#ifndef FFMPEG_FAS_H
#define FFMPEG_FAS_H

/* If C++ then we need to __extern "C". Compiler defines __cplusplus */
#ifdef __cplusplus
#define __extern extern "C"
#else
#define __extern extern
#endif

 
#ifndef UINT64_C
#define UINT64_C(c) (c ## ULL)
#endif

#include "seek_indices.h"
#include <libswscale/swscale.h> 


static struct SwsContext *Sctx;
static int sws_flags = SWS_BICUBIC;


typedef enum
{
  FAS_GRAY8    = 1,
  FAS_RGB24    = 2,
  FAS_BGR24    = 3,
  FAS_ARGB32   = 4,
  FAS_ABGR32   = 5,
  FAS_YUV420P  = 6,
  FAS_YUYV422  = 7,
  FAS_UYVY422  = 8,
  FAS_YUV422P  = 9,
  FAS_YUV444P  = 10,
} fas_color_space_type;

typedef struct
{
  unsigned char *data;
  int width;
  int height;
  int bytes_per_line;
  fas_color_space_type color_space;
} fas_raw_image_type;


/**********************************************************************
 * Video IO Types
 **********************************************************************/

typedef struct fas_context_struct* fas_context_ref_type;

typedef enum
{
  FAS_SUCCESS,
  FAS_FAILURE,
  FAS_INVALID_ARGUMENT,
  FAS_OUT_OF_MEMORY,
  FAS_UNSUPPORTED_FORMAT,
  FAS_UNSUPPORTED_CODEC,
  FAS_NO_MORE_FRAMES,
  FAS_DECODING_ERROR,
  FAS_SEEK_ERROR,
} fas_error_type;

typedef enum
{
  FAS_FALSE = 0,
  FAS_TRUE  = 1
} fas_boolean_type;


__extern void             fas_initialize (fas_boolean_type logging, fas_color_space_type format);
__extern void             fas_set_format (fas_color_space_type format);

__extern fas_error_type   fas_open_video  (fas_context_ref_type *context_ptr, char *file_path);
__extern fas_error_type   fas_close_video (fas_context_ref_type context);

__extern char*            fas_error_message (fas_error_type error);

__extern fas_boolean_type fas_frame_available (fas_context_ref_type context);
__extern int              fas_get_frame_index (fas_context_ref_type context);
__extern fas_error_type   fas_step_forward    (fas_context_ref_type context);

__extern fas_error_type   fas_get_frame  (fas_context_ref_type context, fas_raw_image_type *image_ptr);
__extern void             fas_free_frame (fas_raw_image_type image);

__extern fas_error_type   fas_seek_to_nearest_key     (fas_context_ref_type context, int target_index);
__extern fas_error_type   fas_seek_to_frame           (fas_context_ref_type context, int target_index);

__extern int              fas_get_frame_count         (fas_context_ref_type context);
__extern int              fas_get_frame_count_fast    (fas_context_ref_type context);

__extern fas_error_type   fas_put_seek_table  (fas_context_ref_type context, seek_table_type table);
__extern seek_table_type  fas_get_seek_table  (fas_context_ref_type context);

/* will extract raw 420p if the video is in that format -- needs to be alloced ahead of time*/
__extern fas_error_type  fas_fill_420p_ptrs (fas_context_ref_type context, unsigned char *y, unsigned char *u, unsigned char *v);

/* will extract gray8 data from movie (will convert to ensure you get it) -- need to be alloc'ed ahead of time*/
__extern fas_error_type  fas_fill_gray8_ptr(fas_context_ref_type context, unsigned char *y);

__extern int  fas_get_current_width(fas_context_ref_type context);
__extern int  fas_get_current_height(fas_context_ref_type context);

__extern unsigned long long fas_get_frame_duration(fas_context_ref_type context);

#endif