diff --git a/src/video_capture/decklink.cpp b/src/video_capture/decklink.cpp index f94cd8e85..2e0bdbb46 100644 --- a/src/video_capture/decklink.cpp +++ b/src/video_capture/decklink.cpp @@ -119,6 +119,7 @@ struct vidcap_decklink_state { struct timeval t0; bool detect_format; + bool is_10b; }; static HRESULT set_display_mode_properties(struct vidcap_decklink_state *s, struct tile *tile, IDeckLinkDisplayMode* displayMode, /* out */ BMDPixelFormat *pf); @@ -170,10 +171,10 @@ public: unique_lock lk(s->lock); switch(flags) { case bmdDetectedVideoInputYCbCr422: - s->codec = UYVY; + s->codec = s->is_10b ? v210 : UYVY; break; case bmdDetectedVideoInputRGB444: - s->codec = RGBA; + s->codec = s->is_10b ? R10k : RGBA; break; default: fprintf(stderr, "[Decklink] Unhandled color spec!\n"); @@ -817,6 +818,8 @@ vidcap_decklink_init(const struct vidcap_params *params, void **state) return VIDCAP_INIT_NOERR; } + s->is_10b = get_bits_per_component(s->codec) == 10; + if(vidcap_params_get_flags(params) & (VIDCAP_FLAG_AUDIO_EMBEDDED | VIDCAP_FLAG_AUDIO_AESEBU | VIDCAP_FLAG_AUDIO_ANALOG)) { s->grab_audio = TRUE; switch(vidcap_params_get_flags(params) & (VIDCAP_FLAG_AUDIO_EMBEDDED | VIDCAP_FLAG_AUDIO_AESEBU | VIDCAP_FLAG_AUDIO_ANALOG)) { diff --git a/src/video_codec.c b/src/video_codec.c index 497df71fa..2ac4d15d7 100644 --- a/src/video_codec.c +++ b/src/video_codec.c @@ -217,6 +217,17 @@ void show_codec_help(const char *module, const codec_t *codecs8, const codec_t * } } +int get_bits_per_component(codec_t codec) +{ + unsigned int i = (unsigned int) codec; + + if (i < sizeof codec_info / sizeof(struct codec_info_t)) { + return codec_info[i].bits_per_channel; + } else { + return 0; + } +} + double get_bpp(codec_t codec) { unsigned int i = (unsigned int) codec; diff --git a/src/video_codec.h b/src/video_codec.h index 4941f1a08..61ef6e872 100644 --- a/src/video_codec.h +++ b/src/video_codec.h @@ -8,7 +8,7 @@ * @author Dalibor Matura <255899@mail.muni.cz> * @author Ian Wesley-Smith */ -/* Copyright (c) 2005-2013 CESNET z.s.p.o. +/* Copyright (c) 2005-2017 CESNET z.s.p.o. * * Redistribution and use in source and binary forms, with or without * modification, is permitted provided that the following conditions @@ -65,9 +65,11 @@ extern "C" { typedef void (*decoder_t)(unsigned char *dst, const unsigned char *src, int dst_len, int rshift, int gshift, int bshift); -/** Prints list of suppored codecs for video module - */ +/// Prints list of suppored codecs for video module void show_codec_help(const char *module, const codec_t *codecs8, const codec_t *codecs10); +/// @returns number of bits per color component +int get_bits_per_component(codec_t codec) __attribute__((pure)); +/// @returns number of bytes per pixel double get_bpp(codec_t codec) __attribute__((pure)); uint32_t get_fourcc(codec_t codec) __attribute__((pure)); int get_halign(codec_t codec) __attribute__((pure));