Skip to content

Commit f5b9ac9

Browse files
committed
Format: added codecSupported() for AVCodecID
1 parent 74da3f8 commit f5b9ac9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/format.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ namespace av {
66
namespace internal {
77

88
bool codec_supported(const AVCodecTag * const *codecTag, const FmtCodec &codec)
9+
{
10+
return codec_supported(codecTag, codec.id());
11+
}
12+
13+
bool codec_supported(const AVCodecTag *const *codecTag, AVCodecID codec_id)
914
{
1015
if (!codecTag) // any codec supported
1116
return true;
1217

1318
unsigned int tag;
14-
return !!av_codec_get_tag2(codecTag, codec.id(), &tag);
19+
return !!av_codec_get_tag2(codecTag, codec_id, &tag);
1520
}
1621

1722
} // ::internal

src/format.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ using avcpp_format_const = typename std::conditional<
1919
using FmtCodec = class Codec;
2020
namespace internal {
2121
bool codec_supported(const AVCodecTag *const *codecTag, const FmtCodec &codec);
22+
bool codec_supported(const AVCodecTag *const *codecTag, AVCodecID codec_id);
2223
} // ::internal
2324

2425
template<typename T>
@@ -56,6 +57,13 @@ struct Format : public FFWrapperPtr<T>
5657
return internal::codec_supported(m_raw->codec_tag, codec);
5758
}
5859

60+
bool codecSupported(AVCodecID codec_id) const noexcept
61+
{
62+
if (!m_raw)
63+
return false;
64+
return internal::codec_supported(m_raw->codec_tag, codec_id);
65+
}
66+
5967
protected:
6068
using FFWrapperPtr<T>::m_raw;
6169
};

0 commit comments

Comments
 (0)