AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VideoFrame.hpp
Go to the documentation of this file.
1 #ifndef _AV_TRANSCODER_FRAME_VIDEO_FRAME_HPP_
2 #define _AV_TRANSCODER_FRAME_VIDEO_FRAME_HPP_
3 
4 #include "Frame.hpp"
6 
7 extern "C" {
8 #include <libavutil/pixfmt.h>
9 #include <libavutil/pixdesc.h>
10 }
11 
12 namespace avtranscoder
13 {
14 
15 /**
16  * @brief Description to create a video frame.
17  * @param width
18  * @param height
19  * @param pixelFormat
20  */
21 struct AvExport VideoFrameDesc
22 {
23 public:
24  VideoFrameDesc(const size_t width = 0, const size_t height = 0, const AVPixelFormat pixelFormat = AV_PIX_FMT_NONE);
25  VideoFrameDesc(const size_t width, const size_t height, const std::string& pixelFormatName);
26 
27  /**
28  * @brief Set the attributes from the given profile.
29  * @see Profile
30  */
31  void setParameters(const ProfileLoader::Profile& profile);
32 
33 public:
34  size_t _width;
35  size_t _height;
37  double _fps;
38 };
39 
40 /**
41  * @brief This class describes decoded video data.
42  */
43 class AvExport VideoFrame : public Frame
44 {
45 public:
46  VideoFrame(const VideoFrameDesc& ref);
47  VideoFrame(const Frame& otherFrame);
48 
49  size_t getWidth() const { return _frame->width; }
50  size_t getHeight() const { return _frame->height; }
51  AVPixelFormat getPixelFormat() const { return static_cast<AVPixelFormat>(_frame->format); }
52  VideoFrameDesc desc() const { return VideoFrameDesc(getWidth(), getHeight(), getPixelFormat()); }
53 
54  size_t getSize() const; ///< in bytes/**
55 
56  /**
57  * @brief Assign the given value to all the data of the picture.
58  */
59  void assign(const unsigned char value);
60 
61  /**
62  * @brief Assign the given ptr of data to the data of the picture.
63  * @warning the given ptr should have the size of the picture.
64  * @see getSize
65  */
66  void assign(const unsigned char* ptrValue);
67 
68 private:
69  /**
70  * @brief Allocate the image buffer of the frame.
71  */
72  void allocateAVPicture(const VideoFrameDesc& desc);
73 
74  /**
75  * @note To allocate new image buffer if needed.
76  * @see allocateAVPicture
77  */
78  friend class VideoGenerator;
79 };
80 }
81 
82 #endif
Description to create a video frame.
Definition: VideoFrame.hpp:21
This class describes decoded video data.
Definition: VideoFrame.hpp:43
std::map< std::string, std::string > Profile
#define AV_PIX_FMT_NONE
Definition: common.hpp:44
AVPixelFormat getPixelFormat() const
Definition: VideoFrame.hpp:51
size_t getHeight() const
Definition: VideoFrame.hpp:50
This class describes decoded (raw) audio or video data.
Definition: Frame.hpp:16
VideoFrameDesc desc() const
Definition: VideoFrame.hpp:52
size_t getWidth() const
Definition: VideoFrame.hpp:49
#define AVPixelFormat
Definition: common.hpp:43