Audacity 3.2.0
Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
OpusExportProcessor::OggPacket Struct Referencefinal
Collaboration diagram for OpusExportProcessor::OggPacket:
[legend]

Public Types

using byte_type = std::remove_pointer_t< decltype(ogg_packet::packet)>
 

Public Member Functions

 OggPacket (int64_t packetNo, bool resizable)
 
 OggPacket (int64_t packetNo)
 
 OggPacket (int64_t packetNo, long size, bool resizable)
 
void Resize (long size)
 
void Reset () noexcept
 
void MarkBOS () noexcept
 
void MarkEOS () noexcept
 
void Write (const void *data, const long length)
 
template<typename IntType >
void Write (IntType value)
 
byte_typeGetBuffer ()
 
size_t GetBufferSize () const
 

Public Attributes

ogg_packet packet {}
 

Private Attributes

std::vector< byte_typebuffer
 
bool resizable { false }
 

Detailed Description

Definition at line 236 of file ExportOpus.cpp.

Member Typedef Documentation

◆ byte_type

using OpusExportProcessor::OggPacket::byte_type = std::remove_pointer_t<decltype(ogg_packet::packet)>

Definition at line 238 of file ExportOpus.cpp.

Constructor & Destructor Documentation

◆ OggPacket() [1/3]

OpusExportProcessor::OggPacket::OggPacket ( int64_t  packetNo,
bool  resizable 
)
inline

Definition at line 241 of file ExportOpus.cpp.

242 : resizable { resizable }
243 {
244 packet.packetno = packetNo;
245 }

References packet.

◆ OggPacket() [2/3]

OpusExportProcessor::OggPacket::OggPacket ( int64_t  packetNo)
inlineexplicit

Definition at line 247 of file ExportOpus.cpp.

248 : OggPacket { packetNo, false }
249 {
250 }
OggPacket(int64_t packetNo, bool resizable)
Definition: ExportOpus.cpp:241

◆ OggPacket() [3/3]

OpusExportProcessor::OggPacket::OggPacket ( int64_t  packetNo,
long  size,
bool  resizable 
)
inline

Definition at line 252 of file ExportOpus.cpp.

253 : OggPacket { packetNo, resizable }
254 {
255 Resize(size);
256 }

References Resize(), and size.

Here is the call graph for this function:

Member Function Documentation

◆ GetBuffer()

byte_type * OpusExportProcessor::OggPacket::GetBuffer ( )
inline

Definition at line 322 of file ExportOpus.cpp.

323 {
324 return buffer.data();
325 }
std::vector< byte_type > buffer
Definition: ExportOpus.cpp:335

References buffer.

◆ GetBufferSize()

size_t OpusExportProcessor::OggPacket::GetBufferSize ( ) const
inline

Definition at line 327 of file ExportOpus.cpp.

328 {
329 return buffer.size();
330 }

References buffer.

◆ MarkBOS()

void OpusExportProcessor::OggPacket::MarkBOS ( )
inlinenoexcept

Definition at line 269 of file ExportOpus.cpp.

270 {
271 packet.b_o_s = 1;
272 }

References packet.

Referenced by OpusExportProcessor::WriteOpusHeader().

Here is the caller graph for this function:

◆ MarkEOS()

void OpusExportProcessor::OggPacket::MarkEOS ( )
inlinenoexcept

Definition at line 274 of file ExportOpus.cpp.

275 {
276 packet.e_o_s = 1;
277 }

References packet.

◆ Reset()

void OpusExportProcessor::OggPacket::Reset ( )
inlinenoexcept

Definition at line 264 of file ExportOpus.cpp.

265 {
266 packet.bytes = 0;
267 }

References packet.

◆ Resize()

void OpusExportProcessor::OggPacket::Resize ( long  size)
inline

Definition at line 258 of file ExportOpus.cpp.

259 {
260 buffer.resize(size);
261 packet.packet = buffer.data();
262 }

References buffer, packet, and size.

Referenced by OggPacket(), and Write().

Here is the caller graph for this function:

◆ Write() [1/2]

void OpusExportProcessor::OggPacket::Write ( const void *  data,
const long  length 
)
inline

Definition at line 279 of file ExportOpus.cpp.

280 {
281 const auto nextPos = packet.bytes + length;
282
283 if (nextPos > buffer.size())
284 {
285 if (resizable)
286 Resize(std::max<size_t>(1024, buffer.size() * 2));
287 else
289 XO("Buffer overflow in OGG packet"), OPUS_BUFFER_TOO_SMALL);
290 }
291
292 std::copy(
293 reinterpret_cast<const byte_type*>(data),
294 reinterpret_cast<const byte_type*>(data) + length,
295 buffer.data() + packet.bytes);
296
297 packet.bytes = nextPos;
298 }
XO("Cut/Copy/Paste")
void FailExport(const TranslatableString &title, int errorCode=0)
Definition: ExportOpus.cpp:67
void copy(const T *src, T *dst, int32_t n)
Definition: VectorOps.h:40
std::remove_pointer_t< decltype(ogg_packet::packet)> byte_type
Definition: ExportOpus.cpp:238

References buffer, staffpad::vo::copy(), anonymous_namespace{ExportOpus.cpp}::FailExport(), packet, resizable, Resize(), and XO().

Referenced by Write(), OpusExportProcessor::WriteOpusHeader(), and OpusExportProcessor::WriteTags().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Write() [2/2]

template<typename IntType >
void OpusExportProcessor::OggPacket::Write ( IntType  value)
inline

Definition at line 301 of file ExportOpus.cpp.

302 {
303 static_assert(std::is_integral_v<IntType>);
304 if constexpr (sizeof (IntType) == 1)
305 {
306 Write(&value, 1);
307 }
308 else
309 {
310 if (IsLittleEndian ())
311 {
312 Write(&value, sizeof (IntType));
313 }
314 else
315 {
316 IntType swapped = SwapIntBytes(value);
317 Write(&swapped, sizeof (IntType));
318 }
319 }
320 }
constexpr IntType SwapIntBytes(IntType value) noexcept
Swap bytes in an integer.
Definition: MemoryX.h:377
bool IsLittleEndian() noexcept
Check that machine is little-endian.
Definition: MemoryX.h:368
void Write(const void *data, const long length)
Definition: ExportOpus.cpp:279

References IsLittleEndian(), SwapIntBytes(), and Write().

Here is the call graph for this function:

Member Data Documentation

◆ buffer

std::vector<byte_type> OpusExportProcessor::OggPacket::buffer
private

Definition at line 335 of file ExportOpus.cpp.

Referenced by GetBuffer(), GetBufferSize(), Resize(), and Write().

◆ packet

ogg_packet OpusExportProcessor::OggPacket::packet {}

◆ resizable

bool OpusExportProcessor::OggPacket::resizable { false }
private

Definition at line 336 of file ExportOpus.cpp.

Referenced by Write().


The documentation for this struct was generated from the following file: