avcpp 3.2.1
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
pixelformat.h
Go to the documentation of this file.
1#pragma once
2
9
10#include <string>
11#include <iostream>
12
13#include "averror.h"
14#include "ffmpeg.h"
15
16extern "C" {
17#include <libavutil/pixfmt.h>
18#include <libavutil/pixdesc.h>
19}
20
21// We need not to be back compatible:
22#ifdef PixelFormat
23#undef PixelFormat
24#endif
25
26namespace av {
27
40class PixelFormat : public PixSampleFmtWrapper<PixelFormat, AVPixelFormat>
41{
42public:
45 using Parent::Parent;
46
50 PixelFormat() = default;
56 explicit PixelFormat(const char* name) noexcept;
62 explicit PixelFormat(const std::string& name) noexcept;
63
64 // Info functions
72 const char* name(OptionalErrorCode ec = throws()) const;
73
82 const AVPixFmtDescriptor* descriptor(OptionalErrorCode ec = throws()) const;
83
91 int bitsPerPixel(OptionalErrorCode ec = throws()) const;
92
100 size_t planesCount(OptionalErrorCode ec = throws()) const;
101
108 PixelFormat swapEndianness() const noexcept;
109
110 // See FF_LOSS_xxx flags
120 size_t convertionLoss(PixelFormat dstFmt, bool srcHasAlpha = false) const noexcept;
121};
122
123} // namespace av
124
Error codes, error categories and the OptionalErrorCode convention.
Carries the caller's choice between exceptions and error codes.
Definition averror.h:96
int bitsPerPixel(OptionalErrorCode ec=throws()) const
Bits needed for one pixel.
PixSampleFmtWrapper< PixelFormat, AVPixelFormat > Parent
The wrapper this type builds on.
Definition pixelformat.h:44
const char * name(OptionalErrorCode ec=throws()) const
Name of the format.
PixelFormat(const char *name) noexcept
Look a pixel format up by name.
size_t convertionLoss(PixelFormat dstFmt, bool srcHasAlpha=false) const noexcept
What a conversion to another format would lose.
const AVPixFmtDescriptor * descriptor(OptionalErrorCode ec=throws()) const
FFmpeg description of the format.
PixelFormat swapEndianness() const noexcept
The same format with the opposite byte order.
PixelFormat()=default
Create an unset format, equivalent to AV_PIX_FMT_NONE.
PixelFormat(const std::string &name) noexcept
Look a pixel format up by name.
size_t planesCount(OptionalErrorCode ec=throws()) const
Number of image planes.
FFmpeg types re-exported for the public API and small value wrappers.
Root namespace of the library.
Definition audioresampler.h:19