From: Steinar H. Gunderson Date: Wed, 6 Jan 2016 22:23:01 +0000 (+0100) Subject: Remove more std:: instances. X-Git-Tag: 1.0.0~51 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=9b9f5c84113b8a818f296467fd2150ce6a095fbe Remove more std:: instances. --- diff --git a/filter.cpp b/filter.cpp index a5cd767..d737cb0 100644 --- a/filter.cpp +++ b/filter.cpp @@ -11,6 +11,8 @@ #include "filter.h" +using namespace std; + #ifdef __SSE__ // For SSE, we set the denormals-as-zero flag instead. @@ -49,8 +51,8 @@ void Filter::update() float sn, cs; float cutoff_freq = omega; - cutoff_freq = std::min(cutoff_freq, (float)M_PI); - cutoff_freq = std::max(cutoff_freq, 0.001f); + cutoff_freq = min(cutoff_freq, (float)M_PI); + cutoff_freq = max(cutoff_freq, 0.001f); calcSinCos(cutoff_freq, &sn, &cs); if (resonance <= 0) resonance = 0.001f; @@ -352,9 +354,9 @@ void StereoFilter::render(float *inout_left_ptr, unsigned n_samples, float cutof we need to raise the answer to the Nth power. */ -std::complex Filter::evaluate_transfer_function(float omega) +complex Filter::evaluate_transfer_function(float omega) { - std::complex z = exp(std::complex(0.0f, omega)); - std::complex z2 = z * z; - return std::pow((b0 * z2 + b1 * z + b2) / (1.0f * z2 + a1 * z + a2), filter_order); + complex z = exp(complex(0.0f, omega)); + complex z2 = z * z; + return pow((b0 * z2 + b1 * z + b2) / (1.0f * z2 + a1 * z + a2), filter_order); } diff --git a/glwidget.cpp b/glwidget.cpp index 01d372f..3d5b0f9 100644 --- a/glwidget.cpp +++ b/glwidget.cpp @@ -47,8 +47,8 @@ void GLWidget::clean_context() void GLWidget::initializeGL() { - static std::once_flag flag; - std::call_once(flag, [this]{ + static once_flag flag; + call_once(flag, [this]{ global_mixer = new Mixer(QGLFormat::toSurfaceFormat(format()), global_flags.num_cards); global_mainwindow->mixer_created(global_mixer); global_mixer->start(); diff --git a/h264encode.cpp b/h264encode.cpp index d263b3a..2833073 100644 --- a/h264encode.cpp +++ b/h264encode.cpp @@ -33,6 +33,8 @@ #include "httpd.h" #include "timebase.h" +using namespace std; + class QOpenGLContext; class QSurface; @@ -1623,7 +1625,7 @@ void H264Encoder::save_codeddata(storage_task task) // Encode and add all audio frames up to and including the pts of this video frame. for ( ;; ) { int64_t audio_pts; - std::vector audio; + vector audio; { unique_lock lock(frame_queue_mutex); frame_queue_nonempty.wait(lock, [this]{ return copy_thread_should_quit || !pending_audio_frames.empty(); }); @@ -1697,7 +1699,7 @@ void H264Encoder::save_codeddata(storage_task task) // this is weird. but it seems to put a new frame onto the queue void H264Encoder::storage_task_enqueue(storage_task task) { - std::unique_lock lock(storage_task_queue_mutex); + unique_lock lock(storage_task_queue_mutex); storage_task_queue.push(move(task)); srcsurface_status[task.display_order % SURFACE_NUM] = SRC_SURFACE_IN_ENCODING; storage_task_queue_changed.notify_all(); @@ -1709,7 +1711,7 @@ void H264Encoder::storage_task_thread() storage_task current; { // wait until there's an encoded frame - std::unique_lock lock(storage_task_queue_mutex); + unique_lock lock(storage_task_queue_mutex); storage_task_queue_changed.wait(lock, [this]{ return storage_thread_should_quit || !storage_task_queue.empty(); }); if (storage_thread_should_quit) return; current = move(storage_task_queue.front()); @@ -1724,7 +1726,7 @@ void H264Encoder::storage_task_thread() save_codeddata(move(current)); { - std::unique_lock lock(storage_task_queue_mutex); + unique_lock lock(storage_task_queue_mutex); srcsurface_status[current.display_order % SURFACE_NUM] = SRC_SURFACE_FREE; storage_task_queue_changed.notify_all(); } @@ -1792,9 +1794,9 @@ H264Encoder::H264Encoder(QSurface *surface, int width, int height, HTTPD *httpd) memset(&pic_param, 0, sizeof(pic_param)); memset(&slice_param, 0, sizeof(slice_param)); - storage_thread = std::thread(&H264Encoder::storage_task_thread, this); + storage_thread = thread(&H264Encoder::storage_task_thread, this); - copy_thread = std::thread([this]{ + copy_thread = thread([this]{ //SDL_GL_MakeCurrent(window, context); QOpenGLContext *context = create_context(this->surface); eglBindAPI(EGL_OPENGL_API); @@ -1830,7 +1832,7 @@ bool H264Encoder::begin_frame(GLuint *y_tex, GLuint *cbcr_tex) { { // Wait until this frame slot is done encoding. - std::unique_lock lock(storage_task_queue_mutex); + unique_lock lock(storage_task_queue_mutex); storage_task_queue_changed.wait(lock, [this]{ return storage_thread_should_quit || (srcsurface_status[current_storage_frame % SURFACE_NUM] == SRC_SURFACE_FREE); }); if (storage_thread_should_quit) return false; } @@ -1890,7 +1892,7 @@ bool H264Encoder::begin_frame(GLuint *y_tex, GLuint *cbcr_tex) return true; } -void H264Encoder::add_audio(int64_t pts, std::vector audio) +void H264Encoder::add_audio(int64_t pts, vector audio) { { unique_lock lock(frame_queue_mutex); @@ -1899,7 +1901,7 @@ void H264Encoder::add_audio(int64_t pts, std::vector audio) frame_queue_nonempty.notify_all(); } -void H264Encoder::end_frame(RefCountedGLsync fence, int64_t pts, const std::vector &input_frames) +void H264Encoder::end_frame(RefCountedGLsync fence, int64_t pts, const vector &input_frames) { { unique_lock lock(frame_queue_mutex); diff --git a/mainwindow.cpp b/mainwindow.cpp index ede1fb6..f15e56a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -51,7 +51,7 @@ MainWindow::MainWindow() transition_btn1 = ui->transition_btn1; transition_btn2 = ui->transition_btn2; transition_btn3 = ui->transition_btn3; - qRegisterMetaType>("std::vector"); + qRegisterMetaType>("std::vector"); connect(ui->me_preview, &GLWidget::transition_names_updated, this, &MainWindow::set_transition_names); qRegisterMetaType("Mixer::Output"); } @@ -220,12 +220,12 @@ void MainWindow::relayout() // The previews will be constrained by the remaining height, and the width. double preview_label_height = previews[0]->title_bar->geometry().height() + ui->preview_displays->spacing(); // Wrong spacing? int preview_total_width = ui->preview_displays->geometry().width(); - double preview_height = std::min(remaining_height - preview_label_height, (preview_total_width / double(previews.size())) * 9.0 / 16.0); + double preview_height = min(remaining_height - preview_label_height, (preview_total_width / double(previews.size())) * 9.0 / 16.0); remaining_height -= preview_height + preview_label_height + ui->vertical_layout->spacing(); ui->vertical_layout->setStretch(0, lrintf(me_height)); ui->vertical_layout->setStretch(1, 0); // Don't stretch the audiostrip. - ui->vertical_layout->setStretch(2, std::max(1, remaining_height)); // Spacer. + ui->vertical_layout->setStretch(2, max(1, remaining_height)); // Spacer. ui->vertical_layout->setStretch(3, lrintf(preview_height + preview_label_height)); // Set the widths for the previews. diff --git a/mixer.cpp b/mixer.cpp index 6105006..1a4a3f9 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -204,7 +204,7 @@ float find_peak(const float *samples, size_t num_samples) { float m = fabs(samples[0]); for (size_t i = 1; i < num_samples; ++i) { - m = std::max(m, fabs(samples[i])); + m = max(m, fabs(samples[i])); } return m; } diff --git a/pbo_frame_allocator.cpp b/pbo_frame_allocator.cpp index f64ea5f..370fa3d 100644 --- a/pbo_frame_allocator.cpp +++ b/pbo_frame_allocator.cpp @@ -106,7 +106,7 @@ FrameAllocator::Frame PBOFrameAllocator::alloc_frame() { Frame vf; - std::unique_lock lock(freelist_mutex); // Meh. + unique_lock lock(freelist_mutex); // Meh. if (freelist.empty()) { printf("Frame overrun (no more spare PBO frames), dropping frame!\n"); } else { @@ -125,7 +125,7 @@ void PBOFrameAllocator::release_frame(Frame frame) printf("%d bytes overflow after last (PBO) frame\n", int(frame.overflow)); } - std::unique_lock lock(freelist_mutex); + unique_lock lock(freelist_mutex); freelist.push(frame); //--sumsum; } diff --git a/stereocompressor.cpp b/stereocompressor.cpp index 3c522cc..7a77d07 100644 --- a/stereocompressor.cpp +++ b/stereocompressor.cpp @@ -4,6 +4,8 @@ #include "stereocompressor.h" +using namespace std; + namespace { // Implement a less accurate but faster pow(x, y). We use the standard identity @@ -99,9 +101,9 @@ void StereoCompressor::process(float *buf, size_t num_samples, float threshold, if (fabs(*right_ptr) > peak_level) peak_level = float(fabs(*right_ptr)); if (peak_level > compr_level) { - compr_level = std::min(compr_level * attack_increment, peak_level); + compr_level = min(compr_level * attack_increment, peak_level); } else { - compr_level = std::max(compr_level * release_increment, 0.0001f); + compr_level = max(compr_level * release_increment, 0.0001f); } float scalefactor_with_gain = compressor_knee(compr_level, threshold, inv_threshold, inv_ratio_minus_one, makeup_gain); @@ -112,7 +114,7 @@ void StereoCompressor::process(float *buf, size_t num_samples, float threshold, *right_ptr *= scalefactor_with_gain; right_ptr += 2; - peak_level = std::max(peak_level * peak_increment, 0.0001f); + peak_level = max(peak_level * peak_increment, 0.0001f); } // Store attenuation level for debug/visualization. diff --git a/theme.cpp b/theme.cpp index 0019300..e1fa816 100644 --- a/theme.cpp +++ b/theme.cpp @@ -89,7 +89,7 @@ int wrap_lua_object(lua_State* L, const char *class_name, Args&&... args) { // Construct the C++ object and put it on the stack. void *mem = lua_newuserdata(L, sizeof(T)); - new(mem) T(std::forward(args)...); + new(mem) T(forward(args)...); // Look up the metatable named , and set it on the new object. luaL_getmetatable(L, class_name); @@ -111,7 +111,7 @@ int wrap_lua_object_nonowned(lua_State* L, const char *class_name, Args&&... arg { // Construct the pointer ot the C++ object and put it on the stack. T **obj = (T **)lua_newuserdata(L, sizeof(T *)); - *obj = new T(std::forward(args)...); + *obj = new T(forward(args)...); // Look up the metatable named , and set it on the new object. luaL_getmetatable(L, class_name); @@ -157,11 +157,11 @@ bool checkbool(lua_State* L, int idx) return lua_toboolean(L, idx); } -std::string checkstdstring(lua_State *L, int index) +string checkstdstring(lua_State *L, int index) { size_t len; const char* cstr = lua_tolstring(L, index, &len); - return std::string(cstr, len); + return string(cstr, len); } int EffectChain_new(lua_State* L) @@ -284,7 +284,7 @@ int LiveInputWrapper_connect_signal(lua_State* L) int ImageInput_new(lua_State* L) { assert(lua_gettop(L) == 1); - std::string filename = checkstdstring(L, 1); + string filename = checkstdstring(L, 1); return wrap_lua_object_nonowned(L, "ImageInput", filename); } @@ -384,7 +384,7 @@ int Effect_set_float(lua_State *L) { assert(lua_gettop(L) == 3); Effect *effect = (Effect *)get_effect(L, 1); - std::string key = checkstdstring(L, 2); + string key = checkstdstring(L, 2); float value = luaL_checknumber(L, 3); if (!effect->set_float(key, value)) { luaL_error(L, "Effect refused set_float(\"%s\", %d) (invalid key?)", key.c_str(), int(value)); @@ -396,7 +396,7 @@ int Effect_set_int(lua_State *L) { assert(lua_gettop(L) == 3); Effect *effect = (Effect *)get_effect(L, 1); - std::string key = checkstdstring(L, 2); + string key = checkstdstring(L, 2); float value = luaL_checknumber(L, 3); if (!effect->set_int(key, value)) { luaL_error(L, "Effect refused set_int(\"%s\", %d) (invalid key?)", key.c_str(), int(value)); @@ -408,7 +408,7 @@ int Effect_set_vec3(lua_State *L) { assert(lua_gettop(L) == 5); Effect *effect = (Effect *)get_effect(L, 1); - std::string key = checkstdstring(L, 2); + string key = checkstdstring(L, 2); float v[3]; v[0] = luaL_checknumber(L, 3); v[1] = luaL_checknumber(L, 4); @@ -424,7 +424,7 @@ int Effect_set_vec4(lua_State *L) { assert(lua_gettop(L) == 6); Effect *effect = (Effect *)get_effect(L, 1); - std::string key = checkstdstring(L, 2); + string key = checkstdstring(L, 2); float v[4]; v[0] = luaL_checknumber(L, 3); v[1] = luaL_checknumber(L, 4); @@ -756,7 +756,7 @@ Theme::Chain Theme::get_chain(unsigned num, float t, unsigned width, unsigned he return chain; } -std::string Theme::get_channel_name(unsigned channel) +string Theme::get_channel_name(unsigned channel) { unique_lock lock(m); lua_getglobal(L, "channel_name"); @@ -766,7 +766,7 @@ std::string Theme::get_channel_name(unsigned channel) exit(1); } - std::string ret = lua_tostring(L, -1); + string ret = lua_tostring(L, -1); lua_pop(L, 1); assert(lua_gettop(L) == 0); return ret; @@ -804,7 +804,7 @@ void Theme::set_wb(unsigned channel, double r, double g, double b) assert(lua_gettop(L) == 0); } -std::vector Theme::get_transition_names(float t) +vector Theme::get_transition_names(float t) { unique_lock lock(m); lua_getglobal(L, "get_transitions"); @@ -814,7 +814,7 @@ std::vector Theme::get_transition_names(float t) exit(1); } - std::vector ret; + vector ret; lua_pushnil(L); while (lua_next(L, -2) != 0) { ret.push_back(lua_tostring(L, -1)); diff --git a/vu_common.cpp b/vu_common.cpp index 7b14f2f..d16b732 100644 --- a/vu_common.cpp +++ b/vu_common.cpp @@ -20,8 +20,8 @@ int lufs_to_pos(float level_lu, int height) } int y = lrintf(height * (level_lu - min_level) / (max_level - min_level)); - y = std::max(y, 0); - y = std::min(y, height - 1); + y = max(y, 0); + y = min(y, height - 1); return y; } @@ -45,8 +45,8 @@ void draw_vu_meter(QPainter &painter, float range_low_lu, float range_high_lu, i int max_y = lufs_to_pos(level, height) - 1; painter.fillRect(margin, min_y, width - 2 * margin, max_y - min_y, off); - int min_draw_y = std::max(min_y, min_on_y); - int max_draw_y = std::min(max_y, max_on_y); + int min_draw_y = max(min_y, min_on_y); + int max_draw_y = min(max_y, max_on_y); if (min_draw_y < max_draw_y) { painter.fillRect(margin, min_draw_y, width - 2 * margin, max_draw_y - min_draw_y, on); }