AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Frame.hpp
Go to the documentation of this file.
1 #ifndef _AV_TRANSCODER_FRAME_FRAME_HPP_
2 #define _AV_TRANSCODER_FRAME_FRAME_HPP_
3 
5 
6 extern "C" {
7 #include <libavutil/frame.h>
8 }
9 
10 namespace avtranscoder
11 {
12 
13 /**
14  * @brief This class describes decoded (raw) audio or video data.
15  */
16 class AvExport Frame
17 {
18 public:
19  /**
20  * @brief Allocate an empty frame.
21  * @warn This only allocates the AVFrame itself, not the data buffers.
22  */
23  Frame();
24 
25  /**
26  * @brief Copy properties and reference data of the other frame
27  */
28  Frame(const Frame& otherFrame);
29 
30  virtual ~Frame();
31 
32  /**
33  * @brief Get all the data of the frame.
34  */
35  unsigned char** getData() { return _frame->data; }
36 
37  /**
38  * @brief Returns the size in byte.
39  * For video, size in bytes of each picture line.
40  * For audio, size in bytes of each plane.
41  * @note For audio, only linesize[0] may be set. For planar audio, each channel
42  * plane must be the same size.
43  */
44  int* getLineSize() const { return _frame->linesize; }
45 
46  /**
47  * @return Size of the corresponding packet containing the compressed frame (in bytes)
48  * @warning returns a negative value if the size is unknown
49  */
50  int getEncodedSize() const;
51 
52  /**
53  * @brief Copy the data of the given Frame.
54  * @note This function does not allocate anything: the current frame must be already initialized and
55  * allocated with the same parameters as the given frame, to be ready for memcpy instructions.
56  */
57  void copyData(const Frame& frameToRef);
58 
59  /**
60  * @brief Copy all the fields that do not affect the data layout in the buffers.
61  */
62  void copyProperties(const Frame& otherFrame);
63 
64  /**
65  * @brief Copy frame properties and create a new reference to data of the given frame.
66  * @warning This method allocates new data that will be freed only by calling the destructor of the referenced frame.
67  */
68  void refFrame(const Frame& otherFrame);
69 
70  /**
71  * @brief Unreference all the buffers referenced by frame and reset the frame fields.
72  */
73  void clear();
74 
75  /**
76  * @return If it corresponds to a valid audio frame.
77  * @see AudioFrame
78  */
79  bool isAudioFrame() const;
80 
81  /**
82  * @return If it corresponds to a valid video frame.
83  * @see VideoFrame
84  */
85  bool isVideoFrame() const;
86 
87 #ifndef SWIG
88  AVFrame& getAVFrame() { return *_frame; }
89  const AVFrame& getAVFrame() const { return *_frame; }
90  const unsigned char** getData() const { return const_cast<const unsigned char**>(_frame->data); }
91 #endif
92 
93 private:
94  void allocateAVFrame();
95 
96 protected:
97  AVFrame* _frame;
98 };
99 }
100 
101 #endif
const unsigned char ** getData() const
Definition: Frame.hpp:90
unsigned char ** getData()
Get all the data of the frame.
Definition: Frame.hpp:35
AVFrame * _frame
Definition: Frame.hpp:97
This class describes decoded (raw) audio or video data.
Definition: Frame.hpp:16
int * getLineSize() const
Returns the size in byte. For video, size in bytes of each picture line. For audio, size in bytes of each plane.
Definition: Frame.hpp:44
AVFrame & getAVFrame()
Definition: Frame.hpp:88
const AVFrame & getAVFrame() const
Definition: Frame.hpp:89