forked from gbooker/perian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FrameBuffer.h
130 lines (115 loc) · 4.49 KB
/
FrameBuffer.h
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
/*
* FrameBuffer.h
* Created by Graham Booker on 1/30/07.
*
* This file is part of Perian.
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* This file implements a mechanisms for tracking frame data and dependencies
* as well as yet to be parsed data. It is intented to minimize memcpys
*/
typedef struct FrameData_s FrameData;
typedef struct FFusionData_s FFusionData;
struct FrameData_s
{
uint8_t *buffer; /*!< @brief Compressed frame data*/
unsigned int dataSize; /*!< @brief Size of buffer*/
long frameNumber; /*!< @brief Frame number as counted by QT*/
short type; /*!< @brief FFmpeg frame type*/
short skippabble; /*!< @brief True if this frame is not a reference for any other frames (B Frame)*/
short decoded; /*!< @brief True if this frame is already decoded*/
FrameData *prereqFrame; /*!< @brief The frame's data which must be decoded to fully display this frame */
FrameData *nextFrame; /*!< @brief The next frame to decode if this one is already decoded. This is for predictive decoding */
FFusionData *data; /*!< @brief Pointer to the data set*/
};
typedef struct DataRingBuffer_s {
} DataRingBuffer;
struct FFusionData_s
{
FrameData unparsedFrames; /*!< @brief buffer storage for data that's not yet parsed (packed data for subsequent frames)*/
/* private */
unsigned int frameSize; /*!< @brief Size of frames array in elements*/
unsigned int frameRead; /*!< @brief Current frame read index*/
unsigned int frameWrite; /*!< @brief Current frame write index*/
FrameData *frames; /*!< @brief array of frames*/
unsigned int ringSize; /*!< @brief Size of ring buffer in bytes*/
unsigned int ringRead; /*!< @brief Current read byte index*/
unsigned int ringWrite; /*!< @brief Current write byte index*/
uint8_t *ringBuffer; /*!< @brief Ring buffer for all data*/
FFusionData *previousData; /*!< @brief Pointer to previous FFusionData struct that's kept during expansion and freed when it's data isn't used anymore*/
};
/*!
* @brief Initialize a FFusionData structure
*
* @param data The data to initialize
* @param dataSize The frame count to start with
* @param bufferSize The ring buffer size to start with
*/
void FFusionDataSetup(FFusionData *data, int dataSize, int bufferSize);
/*!
* @brief Deinitialize a FFusionData structure
*
* @param data The data to deinitialize (data is not freed)
*/
void FFusionDataFree(FFusionData *data);
/*!
* @brief Sets the ring buffer pointer to the given buffer (no parsing used)
*
* @param data The FFusionData
* @param buffer The buffer to place in data
* @param bufferSize The size of the buffer
*/
uint8_t *FFusionCreateEntireDataBuffer(FFusionData *data, uint8_t *buffer, int bufferSize);
/*!
* @brief Append a parsed frame's data
*
* @param data The FFusionData
* @param buffer The frame's data
* @param bufferSize The size of the buffer
* @param type The FFmpeg type for this frame
*/
FrameData *FFusionDataAppend(FFusionData *data, uint8_t *buffer, int dataSize, int type);
/*!
* @brief Sets the unparsed data buffer
*
* @param data The FFusionData
* @param buffer The unparsed data
* @param bufferSize The size of the buffer
*/
void FFusionDataSetUnparsed(FFusionData *data, uint8_t *buffer, int bufferSize);
void FFusionDataReadUnparsed(FFusionData *data);
/*!
* @brief Mark a frame as no longer needed
*
* @param toData the completed Frame
*/
void FFusionDataMarkRead(FrameData *toData);
/*!
* @brief Find a frame's data
*
* @param data The FFusionData
* @param frameNumber The frame number as assigned by QT
* @return The frame data if found, NULL otherwise
*/
FrameData *FFusionDataFind(FFusionData *data, int frameNumber);
/*!
* @brief Get a frame's prerequisite for decode
*
* @param toData the frame to check
* @return The frame's prereq if exists, NULL otherwise
*/
FrameData *FrameDataCheckPrereq(FrameData *toData);