decklink: Add 2.1 & 4.1 surround layouts
The list of channel layouts available for decklink input is missing 2.1 & 4.1 layouts. The commit adds them. This aligns the decklink input with the speaker layouts available at outputs. Having different layouts as input and output invokes FFmpeg resampler, which remixes the channels in non trivial way except when downmixing to stereo. This patch allows to avoid such uncontrolled remix of channels with decklink input.
This commit is contained in:
parent
292ad0fe97
commit
974e64eb23
@ -22,6 +22,11 @@ int check_buffer(struct audio_repack *repack,
|
||||
|
||||
/*
|
||||
* Swap channel 3 & 4, 5 & 7, 6 & 8 and squash arrays
|
||||
* 2.1:
|
||||
*
|
||||
* | FL | FR | LFE | emp | emp | emp |emp |emp |
|
||||
* | | |
|
||||
* | FL | FR | LFE |
|
||||
* 4.0 (quad):
|
||||
*
|
||||
* | FL | FR | BR | BL | emp | emp |emp |emp |
|
||||
@ -57,12 +62,23 @@ int repack_squash_swap(struct audio_repack *repack,
|
||||
const __m128i *src = (__m128i *)bsrc;
|
||||
const __m128i *esrc = src + frame_count;
|
||||
uint16_t *dst = (uint16_t *)repack->packet_buffer;
|
||||
while (src != esrc) {
|
||||
__m128i target = _mm_load_si128(src++);
|
||||
__m128i buf = _mm_shufflelo_epi16(target,_MM_SHUFFLE(2, 3, 1, 0));
|
||||
__m128i buf2 = _mm_shufflehi_epi16(buf, _MM_SHUFFLE(1, 0, 3, 2));
|
||||
_mm_storeu_si128((__m128i *)dst, buf2);
|
||||
dst += 8 - squash;
|
||||
/* 2.1 audio does not require re-ordering but still needs squashing
|
||||
* in order to avoid sampling issues.
|
||||
*/
|
||||
if (squash == 5) {
|
||||
while (src != esrc) {
|
||||
__m128i target = _mm_load_si128(src++);
|
||||
_mm_storeu_si128((__m128i *)dst, target);
|
||||
dst += 8 - squash;
|
||||
}
|
||||
} else {
|
||||
while (src != esrc) {
|
||||
__m128i target = _mm_load_si128(src++);
|
||||
__m128i buf = _mm_shufflelo_epi16(target, _MM_SHUFFLE(2, 3, 1, 0));
|
||||
__m128i buf2 = _mm_shufflehi_epi16(buf, _MM_SHUFFLE(1, 0, 3, 2));
|
||||
_mm_storeu_si128((__m128i *)dst, buf2);
|
||||
dst += 8 - squash;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -77,6 +93,12 @@ int audio_repack_init(struct audio_repack *repack,
|
||||
return -1;
|
||||
|
||||
switch (repack_mode) {
|
||||
case repack_mode_8to3ch_swap23:
|
||||
repack->base_src_size = 8 * (16 / 8);
|
||||
repack->base_dst_size = 3 * (16 / 8);
|
||||
repack->extra_dst_size = 5;
|
||||
repack->repack_func = &repack_squash_swap;
|
||||
break;
|
||||
case repack_mode_8to4ch_swap23:
|
||||
repack->base_src_size = 8 * (16 / 8);
|
||||
repack->base_dst_size = 4 * (16 / 8);
|
||||
|
@ -26,6 +26,7 @@ struct audio_repack {
|
||||
};
|
||||
|
||||
enum _audio_repack_mode {
|
||||
repack_mode_8to3ch_swap23,
|
||||
repack_mode_8to4ch_swap23,
|
||||
repack_mode_8to5ch_swap23,
|
||||
repack_mode_8to6ch_swap23,
|
||||
|
@ -46,6 +46,8 @@ static inline int ConvertChannelFormat(speaker_layout format)
|
||||
static inline audio_repack_mode_t ConvertRepackFormat(speaker_layout format)
|
||||
{
|
||||
switch (format) {
|
||||
case SPEAKERS_2POINT1:
|
||||
return repack_mode_8to3ch_swap23;
|
||||
case SPEAKERS_4POINT0:
|
||||
return repack_mode_8to4ch_swap23;
|
||||
case SPEAKERS_4POINT1:
|
||||
@ -103,7 +105,6 @@ void DeckLinkDeviceInstance::HandleAudioPacket(
|
||||
if (channelFormat != SPEAKERS_UNKNOWN &&
|
||||
channelFormat != SPEAKERS_MONO &&
|
||||
channelFormat != SPEAKERS_STEREO &&
|
||||
channelFormat != SPEAKERS_2POINT1 &&
|
||||
maxdevicechannel >= 8 &&
|
||||
isWin) {
|
||||
|
||||
@ -247,7 +248,6 @@ bool DeckLinkDeviceInstance::StartCapture(DeckLinkDeviceMode *mode_)
|
||||
if (channelFormat != SPEAKERS_UNKNOWN &&
|
||||
channelFormat != SPEAKERS_MONO &&
|
||||
channelFormat != SPEAKERS_STEREO &&
|
||||
channelFormat != SPEAKERS_2POINT1 &&
|
||||
maxdevicechannel >= 8 &&
|
||||
isWin) {
|
||||
|
||||
|
@ -156,8 +156,12 @@ static bool decklink_device_changed(obs_properties_t *props,
|
||||
}
|
||||
|
||||
if (device->GetMaxChannel() >= 8) {
|
||||
obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_2_1CH,
|
||||
SPEAKERS_2POINT1);
|
||||
obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_4_0CH,
|
||||
SPEAKERS_4POINT0);
|
||||
obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_4_1CH,
|
||||
SPEAKERS_4POINT1);
|
||||
obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_5_1CH,
|
||||
SPEAKERS_5POINT1);
|
||||
obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_7_1CH,
|
||||
|
Loading…
x
Reference in New Issue
Block a user