AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VideoGenerator.cpp
Go to the documentation of this file.
1 #include "VideoGenerator.hpp"
2 
3 #include <AvTranscoder/util.hpp>
5 
6 #include <sstream>
7 
8 namespace avtranscoder
9 {
10 
12  : _inputFrame(NULL)
13  , _blackImage(NULL)
14  , _frameDesc(frameDesc)
15 {
16 }
17 
19 {
20  delete _blackImage;
21 }
22 
24 {
25  // check the given frame
26  if(!frameBuffer.isVideoFrame())
27  {
28  LOG_WARN("The given frame is not a valid video frame: allocate a new AVPicture to put generated data into it.");
29  frameBuffer.clear();
30  static_cast<VideoFrame&>(frameBuffer).allocateAVPicture(_frameDesc);
31  }
32 
33  // Generate black image
34  if(!_inputFrame)
35  {
36  // Generate the black image only once
37  if(!_blackImage)
38  {
39  std::stringstream msg;
40  msg << "Generate a black image with the following features:" << std::endl;
41  msg << "width = " << _frameDesc._width << std::endl;
42  msg << "height = " << _frameDesc._height << std::endl;
43  msg << "pixel format = rgb24" << std::endl;
44  LOG_INFO(msg.str())
45 
46  VideoFrame& imageBuffer = static_cast<VideoFrame&>(frameBuffer);
47 
48  // Input of convert
49  // @todo support PAL (0 to 255) and NTFS (16 to 235)
51  desc._pixelFormat = getAVPixelFormat("rgb24");
52  VideoFrame intermediateBuffer(desc);
53  const unsigned char fillChar = 0;
54  intermediateBuffer.assign(fillChar);
55 
56  // Output of convert
57  _blackImage = new VideoFrame(imageBuffer.desc());
58 
59  // Convert and store the black image
60  VideoTransform videoTransform;
61  videoTransform.convert(intermediateBuffer, *_blackImage);
62  }
63  LOG_DEBUG("Copy data of the black image when decode next frame")
64  frameBuffer.copyData(*_blackImage);
65  }
66  // Take image from _inputFrame
67  else
68  {
69  LOG_DEBUG("Copy data of the image specified when decode next frame")
70  frameBuffer.copyData(*_inputFrame);
71  }
72  return true;
73 }
74 
75 bool VideoGenerator::decodeNextFrame(Frame& frameBuffer, const size_t channelIndex)
76 {
77  return false;
78 }
79 }
const VideoFrameDesc _frameDesc
The description of the black image (width, height...)
Description to create a video frame.
Definition: VideoFrame.hpp:21
bool decodeNextFrame(Frame &frameBuffer)
Decode next frame.
bool isVideoFrame() const
Definition: Frame.cpp:96
This class describes decoded video data.
Definition: VideoFrame.hpp:43
void clear()
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: Frame.cpp:71
Frame * _inputFrame
A frame given from outside (has link, no ownership)
VideoGenerator(const VideoGenerator &videoGenerator)
AVPixelFormat getAVPixelFormat(const std::string &pixelFormat)
Get the corresponding AVPixelFormat from the pixel format name.
Definition: util.cpp:90
#define LOG_INFO(...)
Definition: log.hpp:23
void assign(const unsigned char value)
Assign the given value to all the data of the picture.
Definition: VideoFrame.cpp:90
#define LOG_WARN(...)
Definition: log.hpp:29
This class describes decoded (raw) audio or video data.
Definition: Frame.hpp:16
VideoFrame * _blackImage
The generated black image (has ownership)
#define LOG_DEBUG(...)
Definition: log.hpp:17
void copyData(const Frame &frameToRef)
Copy the data of the given Frame.
Definition: Frame.cpp:48
void convert(const Frame &srcFrame, Frame &dstFrame)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy