3 #include <Media/Libav.hpp>
6 #include <libavutil/frame.h>
9 #include <ossia/dataflow/float_to_sample.hpp>
17 : target_buffer_size{target_buffer_size}
23 virtual void add_frame(AVFrame& frame,
const tcb::span<ossia::float_vector> vec) = 0;
25 int target_buffer_size{};
30 using AudioFrameEncoder::AudioFrameEncoder;
32 boost::container::vector<int16_t> data;
34 void add_frame(AVFrame& frame,
const tcb::span<ossia::float_vector> vec)
override
36 const int channels = vec.size();
37 const int frames = vec[0].size();
39 data.resize(frames * channels, boost::container::default_init);
40 auto ptr = data.data();
41 for(
int i = 0; i < frames; i++)
42 for(
int c = 0; c < channels; c++)
43 *ptr++ = ossia::float_to_sample<int16_t, 16>(vec[c][i]);
45 frame.data[0] = (uint8_t*)data.data();
46 frame.data[1] =
nullptr;
52 using AudioFrameEncoder::AudioFrameEncoder;
54 boost::container::vector<int32_t> data;
55 void add_frame(AVFrame& frame,
const tcb::span<ossia::float_vector> vec)
override
57 const int channels = vec.size();
58 const int frames = vec[0].size();
60 data.resize(frames * channels, boost::container::default_init);
61 auto ptr = data.data();
62 for(
int i = 0; i < frames; i++)
63 for(
int c = 0; c < channels; c++)
64 *ptr++ = ossia::float_to_sample<int32_t, 24>(vec[c][i]);
66 frame.data[0] = (uint8_t*)data.data();
67 frame.data[1] =
nullptr;
73 using AudioFrameEncoder::AudioFrameEncoder;
75 boost::container::vector<int32_t> data;
76 void add_frame(AVFrame& frame,
const tcb::span<ossia::float_vector> vec)
override
78 const int channels = vec.size();
79 const int frames = vec[0].size();
81 data.resize(frames * channels, boost::container::default_init);
82 auto ptr = data.data();
83 for(
int i = 0; i < frames; i++)
84 for(
int c = 0; c < channels; c++)
85 *ptr++ = ossia::float_to_sample<int32_t, 32>(vec[c][i]);
87 frame.data[0] = (uint8_t*)data.data();
88 frame.data[1] =
nullptr;
94 using AudioFrameEncoder::AudioFrameEncoder;
96 boost::container::vector<float> data;
98 void add_frame(AVFrame& frame,
const tcb::span<ossia::float_vector> vec)
override
100 const int channels = vec.size();
101 const int frames = vec[0].size();
103 data.resize(frames * channels, boost::container::default_init);
104 auto ptr = data.data();
105 for(
int i = 0; i < frames; i++)
106 for(
int c = 0; c < channels; c++)
109 frame.data[0] = (uint8_t*)data.data();
110 frame.data[1] =
nullptr;
116 using AudioFrameEncoder::AudioFrameEncoder;
118 boost::container::vector<double> data;
120 void add_frame(AVFrame& frame,
const tcb::span<ossia::float_vector> vec)
override
122 const int channels = vec.size();
123 const int frames = vec[0].size();
125 data.resize(frames * channels, boost::container::default_init);
126 auto ptr = data.data();
127 for(
int i = 0; i < frames; i++)
128 for(
int c = 0; c < channels; c++)
131 frame.data[0] = (uint8_t*)data.data();
132 frame.data[1] =
nullptr;
138 using AudioFrameEncoder::AudioFrameEncoder;
140 void add_frame(AVFrame& frame,
const tcb::span<ossia::float_vector> vec)
override
142 const int channels = vec.size();
143 if(channels <= AV_NUM_DATA_POINTERS)
145 for(
int i = 0; i < channels; ++i)
147 frame.data[i] =
reinterpret_cast<uint8_t*
>(vec[i].data());
154 =
static_cast<uint8_t**
>(av_malloc(channels *
sizeof(*frame.extended_data)));
156 for(; i < AV_NUM_DATA_POINTERS; ++i)
158 frame.data[i] =
reinterpret_cast<uint8_t*
>(vec[i].data());
159 frame.extended_data[i] =
reinterpret_cast<uint8_t*
>(vec[i].data());
161 for(; i < channels; ++i)
162 frame.extended_data[i] =
reinterpret_cast<uint8_t*
>(vec[i].data());
Binds the rendering pipeline to ossia processes.
Definition: CameraDevice.cpp:28
Definition: AudioFrameEncoder.hpp:15
Definition: AudioFrameEncoder.hpp:115
Definition: AudioFrameEncoder.hpp:93
Definition: AudioFrameEncoder.hpp:137
Definition: AudioFrameEncoder.hpp:29
Definition: AudioFrameEncoder.hpp:51
Definition: AudioFrameEncoder.hpp:72