avcpp 3.2.1
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
avutils.h File Reference

Common helpers: comparisons, value lookup, non-copyable base, string utilities.

#include "avcpp/avconfig.h"
#include <ranges>
#include <string>
#include <string_view>
#include <vector>
#include <deque>
#include <memory>
#include <mutex>
#include <sstream>
#include <algorithm>
#include <functional>
#include <type_traits>
#include <limits>
#include <span>
#include "ffmpeg.h"
#include "avtime.h"
#include <libavutil/avstring.h>
#include <libavutil/mem.h>
#include <libavformat/avformat.h>

Go to the source code of this file.

Classes

class  av::noncopyable
 Base class that deletes copying and assignment. More...
struct  av::EmptyDeleter
 Deleter that does nothing. More...
struct  av::v1::AvDeleter
 Free functors for the FFmpeg resource types. More...
struct  av::v2::SmartDeleter
 Template facade over the per-type deleters of namespace v1. More...
class  av::ScopedValue< T, V >
 Functor to take next element in list/array. More...
class  av::ScopeOutAction
 The ScopeOutAction class - guard-type class that allows points callback that will be called at the scope out. More...
struct  av::SentinelEndPolicy< T >
 Sentinel policy that defines well-known range end pointer. More...
struct  av::SentinelUntilPolicy< T >
 Sentinel policy that defines well-known sequence end marker, like '\0' at the C-string end or special value like NULL. More...
struct  av::ArraySentinel< T, Policy >
 Policy based sentinel marker. More...
struct  av::ReferenceSelector< T, U, true >
 Selects a reference as the dereference result. More...
struct  av::ReferenceSelector< T, U, false >
 Selects a value as the dereference result. More...
struct  av::ArrayIterator< T, U >
 Wrapped array iterator. More...
class  av::ArrayView< T, U, Policy >
 C-array (FFmpeg) wrapper witch can iterate over collection and represents any element via light-weight view U. More...
struct  av::EqualComparator< T >
 Predicate that compares an element with a stored value. More...

Namespaces

namespace  av
 Root namespace of the library.
namespace  av::v1
 The AvDeleter struct Unified delete functor for variois FFMPEG/libavformat/libavcodec and so on resource allocators.

Macros

#define setFFmpegLoggingLevel   set_logging_level
 Old name of set_logging_level(), kept for source compatibility.

Functions

template<typename R, typename T>
R av::lexical_cast (const T &v)
 Convert a value through its stream representation.
void av::set_logging_level (int32_t level)
 This method can be used to turn up or down FFmpeg's logging level.
void av::set_logging_level (const std::string &level)
 Like.
void av::dumpBinaryBuffer (uint8_t *buffer, int buffer_size, int width=16)
 dump_binary_buffer Dump binary buffer to std out in HEX view
std::string av::error2string (int error)
 C++ verstion of the av_err2str().
std::string_view av::wrap2sview (const char *value) noexcept
 Wraps a nullable C string into a string_view without copying.
template<typename T>
std::unique_ptr< T, void(*)(void *)> av::malloc (size_t size)
 Allocate memory with the FFmpeg allocator.
template<typename T>
std::unique_ptr< T, void(*)(void *)> av::mallocz (size_t size)
 Allocate zeroed memory with the FFmpeg allocator.
template<typename T>
std::unique_ptr< T, void(*)(void *)> av::memdup (const void *p, size_t size)
 Copy a memory block using the FFmpeg allocator.
std::unique_ptr< char, void(*)(void *)> av::strdup (std::string_view value)
 Duplicates a string using the FFmpeg allocator.
template<typename T>
void av::freep (T *&ptr) noexcept
 Frees a buffer allocated by the FFmpeg allocator and resets the pointer.
template<class U>
auto av::make_array_view_size (auto *ptr, std::size_t size)
 Helper to create array view with well-known size.
template<class U>
auto av::make_array_view_until (auto *ptr, auto value)
 Helper to create array view with end marker.
template<typename T, typename L>
requires std::ranges::range<L> && requires(L& r) { std::ranges::empty(r); }
T av::guessValue (const T &value, L list)
 Select more approptiate value from given value list.
template<typename T, typename L, typename C>
T av::guessValue (const T &value, const L *list, C endListComparator)
 Select more approptiate value from given value list.
template<typename T, typename Container>
void av::array_to_container (const T *array, std::size_t nelements, Container &container)
 Append a fixed number of array elements to a container.
template<typename T, typename Container, typename Callable>
void av::array_to_container (const T *array, std::size_t nelements, Container &container, Callable convert)
 Append converted array elements to a container.
template<typename T, typename Container, typename Compare>
void av::array_to_container (const T *array, Container &container, Compare isEnd)
 Append elements until the predicate reports the end of the list.
template<typename T, typename Container, typename Compare, typename Callable>
void av::array_to_container (const T *array, Container &container, Compare isEnd, Callable convert)
 Append converted elements until the predicate reports the end of the list.
void av::hex_dump (FILE *f, const uint8_t *buf, std::size_t size)
 Write a hexadecimal dump of a buffer to a C stream.
void av::hex_dump_log (void *avcl, int level, const uint8_t *buf, std::size_t size)
 Write a hexadecimal dump of a buffer through the FFmpeg log system.
void av::hex_dump (FILE *f, std::span< const uint8_t > buf)
 Write a hexadecimal dump of a span to a C stream.
void av::hex_dump_log (void *avcl, int level, std::span< const uint8_t > buf)
 Write a hexadecimal dump of a span through the FFmpeg log system.

Variables

constexpr auto av::NoPts = static_cast<int64_t>(AV_NOPTS_VALUE)
 Timestamp value meaning "no timestamp".
constexpr auto av::TimeBase = static_cast<int>(AV_TIME_BASE)
 Denominator of the global time base used for container-level timestamps.
constexpr auto av::TimeBaseQ = AVRational{1, AV_TIME_BASE}
 The global time base as a rational value.

Macro Definition Documentation

◆ setFFmpegLoggingLevel

#define setFFmpegLoggingLevel   set_logging_level
Deprecated
Use set_logging_level().