X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fmixer.cpp;h=465e96708c716c80302f40a7d3ad8987a7d5214e;hb=56b842e00ad8d4e20176df6f4434d2b0885bced0;hp=d2133346f33d005d87bf392c58e9589914b293b7;hpb=bcd177e1daf5a63d7bf877bc5d30d8803dfd472c;p=nageru diff --git a/nageru/mixer.cpp b/nageru/mixer.cpp index d213334..465e967 100644 --- a/nageru/mixer.cpp +++ b/nageru/mixer.cpp @@ -110,11 +110,17 @@ void ensure_texture_resolution(PBOFrameAllocator::Userdata *userdata, unsigned f assert(false); } - if (first || - width != userdata->last_width[field] || - height != userdata->last_height[field] || - cbcr_width != userdata->last_cbcr_width[field] || - cbcr_height != userdata->last_cbcr_height[field]) { + const bool recreate_main_texture = + first || + width != userdata->last_width[field] || + height != userdata->last_height[field] || + cbcr_width != userdata->last_cbcr_width[field] || + cbcr_height != userdata->last_cbcr_height[field]; + const bool recreate_v210_texture = + global_flags.ten_bit_input && + (first || v210_width != userdata->last_v210_width[field] || height != userdata->last_height[field]); + + if (recreate_main_texture) { // We changed resolution since last use of this texture, so we need to create // a new object. Note that this each card has its own PBOFrameAllocator, // we don't need to worry about these flip-flopping between resolutions. @@ -166,14 +172,14 @@ void ensure_texture_resolution(PBOFrameAllocator::Userdata *userdata, unsigned f userdata->last_cbcr_width[field] = cbcr_width; userdata->last_cbcr_height[field] = cbcr_height; } - if (global_flags.ten_bit_input && - (first || v210_width != userdata->last_v210_width[field])) { + if (recreate_v210_texture) { // Same as above; we need to recreate the texture. glBindTexture(GL_TEXTURE_2D, userdata->tex_v210[field]); check_error(); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, v210_width, height, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, nullptr); check_error(); userdata->last_v210_width[field] = v210_width; + userdata->last_height[field] = height; } } @@ -1077,7 +1083,7 @@ void Mixer::thread_func() master_card_index = output_card_index; } else { master_card_is_output = false; - master_card_index = theme->map_signal(master_clock_channel); + master_card_index = theme->map_signal_to_card(master_clock_channel); assert(master_card_index < num_cards + num_video_inputs); } @@ -1134,12 +1140,12 @@ void Mixer::thread_func() if (fabs(new_frame->neutral_color.r - last_received_neutral_color[card_index].r) > 1e-3 || fabs(new_frame->neutral_color.g - last_received_neutral_color[card_index].g) > 1e-3 || fabs(new_frame->neutral_color.b - last_received_neutral_color[card_index].b) > 1e-3) { - theme->set_wb_for_signal(card_index, new_frame->neutral_color.r, new_frame->neutral_color.g, new_frame->neutral_color.b); + theme->set_wb_for_card(card_index, new_frame->neutral_color.r, new_frame->neutral_color.g, new_frame->neutral_color.b); last_received_neutral_color[card_index] = new_frame->neutral_color; } if (new_frame->frame->data_copy != nullptr && mjpeg_encoder->should_encode_mjpeg_for_card(card_index)) { - RGBTriplet neutral_color = theme->get_white_balance_for_signal(card_index); + RGBTriplet neutral_color = theme->get_white_balance_for_card(card_index); mjpeg_encoder->upload_frame(pts_int, card_index, new_frame->frame, new_frame->video_format, new_frame->y_offset, new_frame->cbcr_offset, move(raw_audio[card_index]), neutral_color); } @@ -1238,11 +1244,11 @@ void Mixer::trim_queue(CaptureCard *card, size_t safe_queue_length) pair Mixer::get_channels_json() { Channels ret; - for (int channel_idx = 2; channel_idx < theme->get_num_channels(); ++channel_idx) { + for (int channel_idx = 0; channel_idx < theme->get_num_channels(); ++channel_idx) { Channel *channel = ret.add_channel(); - channel->set_index(channel_idx); - channel->set_name(theme->get_channel_name(channel_idx)); - channel->set_color(theme->get_channel_color(channel_idx)); + channel->set_index(channel_idx + 2); + channel->set_name(theme->get_channel_name(channel_idx + 2)); + channel->set_color(theme->get_channel_color(channel_idx + 2)); } string contents; google::protobuf::util::MessageToJsonString(ret, &contents); // Ignore any errors.