]> git.sesse.net Git - nageru/commitdiff
Remove more std:: instances.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 6 Jan 2016 22:23:01 +0000 (23:23 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 6 Jan 2016 22:23:01 +0000 (23:23 +0100)
filter.cpp
glwidget.cpp
h264encode.cpp
mainwindow.cpp
mixer.cpp
pbo_frame_allocator.cpp
stereocompressor.cpp
theme.cpp
vu_common.cpp

index a5cd76733f3f5325af1c511a3f4c007e6c6cf8e9..d737cb086565170a286bb27f9312e4a84a80c0de 100644 (file)
@@ -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<double> Filter::evaluate_transfer_function(float omega)
+complex<double> Filter::evaluate_transfer_function(float omega)
 {
-       std::complex<float> z = exp(std::complex<float>(0.0f, omega));
-       std::complex<float> z2 = z * z;
-       return std::pow((b0 * z2 + b1 * z + b2) / (1.0f * z2 + a1 * z + a2), filter_order);
+       complex<float> z = exp(complex<float>(0.0f, omega));
+       complex<float> z2 = z * z;
+       return pow((b0 * z2 + b1 * z + b2) / (1.0f * z2 + a1 * z + a2), filter_order);
 }
index 01d372f1adb92f0ca6abee6f07119056a8dc9ed2..3d5b0f97abe86a494bedda4ee5607e14499a2be2 100644 (file)
@@ -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();
index d263b3a44105d1672cb15b4b31d7f25621f666ae..28330737782f38532dbc162bfdbc295844d33115 100644 (file)
@@ -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<float> audio;
+        vector<float> audio;
         {
              unique_lock<mutex> 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<std::mutex> lock(storage_task_queue_mutex);
+       unique_lock<mutex> 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<std::mutex> lock(storage_task_queue_mutex);
+                       unique_lock<mutex> 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<std::mutex> lock(storage_task_queue_mutex);
+                       unique_lock<mutex> 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<std::mutex> lock(storage_task_queue_mutex);
+               unique_lock<mutex> 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<float> audio)
+void H264Encoder::add_audio(int64_t pts, vector<float> audio)
 {
        {
                unique_lock<mutex> lock(frame_queue_mutex);
@@ -1899,7 +1901,7 @@ void H264Encoder::add_audio(int64_t pts, std::vector<float> audio)
        frame_queue_nonempty.notify_all();
 }
 
-void H264Encoder::end_frame(RefCountedGLsync fence, int64_t pts, const std::vector<RefCountedFrame> &input_frames)
+void H264Encoder::end_frame(RefCountedGLsync fence, int64_t pts, const vector<RefCountedFrame> &input_frames)
 {
        {
                unique_lock<mutex> lock(frame_queue_mutex);
index ede1fb6827de668b0264fedc8953eec3be05a429..f15e56ae008e5c5058e7f39807d21f05cf073670 100644 (file)
@@ -51,7 +51,7 @@ MainWindow::MainWindow()
        transition_btn1 = ui->transition_btn1;
        transition_btn2 = ui->transition_btn2;
        transition_btn3 = ui->transition_btn3;
-       qRegisterMetaType<std::vector<std::string>>("std::vector<std::string>");
+       qRegisterMetaType<vector<string>>("std::vector<std::string>");
        connect(ui->me_preview, &GLWidget::transition_names_updated, this, &MainWindow::set_transition_names);
        qRegisterMetaType<Mixer::Output>("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<int>(1, remaining_height));  // Spacer.
+       ui->vertical_layout->setStretch(2, max<int>(1, remaining_height));  // Spacer.
        ui->vertical_layout->setStretch(3, lrintf(preview_height + preview_label_height));
 
        // Set the widths for the previews.
index 61050067b7b9dd60c652a855336eea54f68dec9d..1a4a3f9d3c292f4d4aaa85a4415c8420bc1083b7 100644 (file)
--- 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;
 }
index f64ea5ff519f0d6ce4ea3a0b0eab040a14c309aa..370fa3d1ea7e145ce1f0e5dee54a2e7610a0f040 100644 (file)
@@ -106,7 +106,7 @@ FrameAllocator::Frame PBOFrameAllocator::alloc_frame()
 {
         Frame vf;
 
-       std::unique_lock<std::mutex> lock(freelist_mutex);  // Meh.
+       unique_lock<mutex> 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<std::mutex> lock(freelist_mutex);
+       unique_lock<mutex> lock(freelist_mutex);
        freelist.push(frame);
        //--sumsum;
 }
index 3c522cc5891301e8a36cb253e9eb9840e503d458..7a77d078426cb1e8cc3f219fe418dcb1d7e99f46 100644 (file)
@@ -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.
index 001930019187478ff19c57e79bbc9dc7dbf0cf86..e1fa8163884095b0c6b466871e2cf9757f568868 100644 (file)
--- 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>(args)...);
+       new(mem) T(forward<Args>(args)...);
 
        // Look up the metatable named <class_name>, 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>(args)...);
+       *obj = new T(forward<Args>(args)...);
 
        // Look up the metatable named <class_name>, 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<ImageInput>(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<mutex> 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<std::string> Theme::get_transition_names(float t)
+vector<string> Theme::get_transition_names(float t)
 {
        unique_lock<mutex> lock(m);
        lua_getglobal(L, "get_transitions");
@@ -814,7 +814,7 @@ std::vector<std::string> Theme::get_transition_names(float t)
                exit(1);
        }
 
-       std::vector<std::string> ret;
+       vector<string> ret;
        lua_pushnil(L);
        while (lua_next(L, -2) != 0) {
                ret.push_back(lua_tostring(L, -1));
index 7b14f2f196a8683b29fb00f07e7f758c533e2dff..d16b732e0625e88ee3183ef830c4a993c3c89658 100644 (file)
@@ -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);
                }