Skip to content

Commit d60088d

Browse files
author
Clement Champetier
committed
util: added getPixel/SampleFormatName functions
1 parent 8fb4004 commit d60088d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/AvTranscoder/util.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ AVSampleFormat getAVSampleFormat(const std::string& sampleFormat)
105105
return av_get_sample_fmt(sampleFormat.c_str());
106106
}
107107

108+
std::string getPixelFormatName(const AVPixelFormat pixelFormat)
109+
{
110+
const char* formatName = av_get_pix_fmt_name(pixelFormat);
111+
return formatName ? std::string(formatName) : "";
112+
}
113+
114+
std::string getSampleFormatName(const AVSampleFormat sampleFormat)
115+
{
116+
const char* formatName = av_get_sample_fmt_name(sampleFormat);
117+
return formatName ? std::string(formatName) : "";
118+
}
119+
108120
NamesArray getFormatsNames()
109121
{
110122
NamesArray formatsNames;

src/AvTranscoder/util.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ AVPixelFormat AvExport getAVPixelFormat(const std::string& pixelFormat);
5050
*/
5151
AVSampleFormat AvExport getAVSampleFormat(const std::string& sampleFormat);
5252

53+
/**
54+
* @return The name of the given pixel format.
55+
* @note Returns an empty string if the format is not found.
56+
*/
57+
std::string AvExport getPixelFormatName(const AVPixelFormat pixelFormat);
58+
59+
/**
60+
* @return The name of the given sample format.
61+
* @note Returns an empty string if the format is not found.
62+
*/
63+
std::string AvExport getSampleFormatName(const AVSampleFormat sampleFormat);
64+
5365
#ifndef SWIG
5466
/**
5567
* @brief Get array of short/long names of all format supported by FFmpeg / libav.

0 commit comments

Comments
 (0)