Decklink: Fix codec prefercence

This commit is contained in:
Martin Piatka
2019-03-01 13:51:33 +01:00
parent 897fb4bde5
commit b18115d54e
3 changed files with 13 additions and 4 deletions

View File

@@ -45,6 +45,7 @@
#endif
#include <map>
#include <vector>
#include <string>
#include <utility>
@@ -54,7 +55,7 @@ std::string bmd_hresult_to_string(HRESULT res);
// Order of codecs is important because it is used as a preference list (upper
// codecs are favored) returned by DISPLAY_PROPERTY_CODECS property (display)
static std::map<codec_t, BMDPixelFormat> uv_to_bmd_codec_map = {
static std::vector<std::pair<codec_t, BMDPixelFormat>> uv_to_bmd_codec_map = {
{ R12L, bmdFormat12BitRGBLE },
{ R10k, bmdFormat10BitRGBX },
{ v210, bmdFormat10BitYUV },

View File

@@ -62,6 +62,7 @@
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include "blackmagic_common.h"
#include "audio/audio.h"
@@ -802,7 +803,9 @@ static HRESULT set_display_mode_properties(struct vidcap_decklink_state *s, stru
result = displayMode->GetName(&displayModeString);
if (result == S_OK)
{
auto it = uv_to_bmd_codec_map.find(s->codec);
auto it = std::find_if(uv_to_bmd_codec_map.begin(),
uv_to_bmd_codec_map.end(),
[&s](const std::pair<codec_t, BMDPixelFormat>& el){ return el.first == s->codec; });
if (it == uv_to_bmd_codec_map.end()) {
LOG(LOG_LEVEL_ERROR) << "Unsupported codec: " << get_codec_name(s->codec) << "!\n";
return E_FAIL;
@@ -1157,7 +1160,9 @@ vidcap_decklink_init(const struct vidcap_params *params, void **state)
displayMode->Release();
continue;
}
auto it = uv_to_bmd_codec_map.find(s->codec);
auto it = std::find_if(uv_to_bmd_codec_map.begin(),
uv_to_bmd_codec_map.end(),
[&s](const std::pair<codec_t, BMDPixelFormat>& el){ return el.first == s->codec; });
if (it == uv_to_bmd_codec_map.end()) {
LOG(LOG_LEVEL_ERROR) << "Unsupported codec: " << get_codec_name(s->codec) << "!\n";
goto error;

View File

@@ -68,6 +68,7 @@
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include "DeckLinkAPIVersion.h"
@@ -657,7 +658,9 @@ display_decklink_reconfigure_video(void *state, struct video_desc desc)
s->vid_desc = desc;
auto it = uv_to_bmd_codec_map.find(desc.color_spec);
auto it = std::find_if(uv_to_bmd_codec_map.begin(),
uv_to_bmd_codec_map.end(),
[&desc](const std::pair<codec_t, BMDPixelFormat>& el){ return el.first == desc.color_spec; });
if (it == uv_to_bmd_codec_map.end()) {
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Unsupported pixel format!\n");
goto error;