From 87b42ab49201b56171c1b01037cfe80eba80a799 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Fri, 29 Nov 2024 23:07:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 除1024改成右移10位 --- api/source/mk_util.cpp | 4 ++-- ext-codec/AAC.cpp | 2 +- ext-codec/H264.cpp | 2 +- ext-codec/H265.cpp | 2 +- ext-codec/JPEG.cpp | 2 +- ext-codec/L16.cpp | 2 +- ext-codec/Opus.cpp | 2 +- server/WebApi.cpp | 4 ++-- src/Http/HttpFileManager.cpp | 4 ++-- src/Rtmp/Rtmp.cpp | 4 ++-- tests/test_flv.cpp | 2 +- tests/test_ps.cpp | 2 +- tests/test_rtp.cpp | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/api/source/mk_util.cpp b/api/source/mk_util.cpp index 13e64887..8b8e91c3 100644 --- a/api/source/mk_util.cpp +++ b/api/source/mk_util.cpp @@ -196,7 +196,7 @@ API_EXPORT void API_CALL mk_get_statistic(on_mk_get_statistic_cb func, void *use #ifdef ENABLE_MEM_DEBUG auto bytes = getTotalMemUsage(); val["memory.memUsage"] = bytes; - val["memory.memUsageMB"] = (int)(bytes / 1024 / 1024); + val["memory.memUsageMB"] = (int)(bytes >> 20); val["memory.memBlock"] = getTotalMemBlock(); static auto block_type_size = getBlockTypeSize(); { @@ -240,7 +240,7 @@ API_EXPORT void API_CALL mk_get_statistic(on_mk_get_statistic_cb func, void *use #ifdef ENABLE_MEM_DEBUG auto bytes = getThisThreadMemUsage(); val["memUsage"] = bytes; - val["memUsageMB"] = bytes / 1024 / 1024; + val["memUsageMB"] = bytes >> 20; val["memBlock"] = getThisThreadMemBlock(); { int i = 0; diff --git a/ext-codec/AAC.cpp b/ext-codec/AAC.cpp index d17ea494..614ec979 100644 --- a/ext-codec/AAC.cpp +++ b/ext-codec/AAC.cpp @@ -377,7 +377,7 @@ Sdp::Ptr AACTrack::getSdp(uint8_t payload_type) const { WarnL << getCodecName() << " Track未准备好"; return nullptr; } - return std::make_shared(getExtraData()->toString(), payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() / 1024); + return std::make_shared(getExtraData()->toString(), payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() >> 10); } namespace { diff --git a/ext-codec/H264.cpp b/ext-codec/H264.cpp index fa0d97e2..984e2111 100644 --- a/ext-codec/H264.cpp +++ b/ext-codec/H264.cpp @@ -361,7 +361,7 @@ Sdp::Ptr H264Track::getSdp(uint8_t payload_type) const { WarnL << getCodecName() << " Track未准备好"; return nullptr; } - return std::make_shared(_sps, _pps, payload_type, getBitRate() / 1024); + return std::make_shared(_sps, _pps, payload_type, getBitRate() >> 10); } namespace { diff --git a/ext-codec/H265.cpp b/ext-codec/H265.cpp index 8566bb1e..ff2a1b92 100644 --- a/ext-codec/H265.cpp +++ b/ext-codec/H265.cpp @@ -267,7 +267,7 @@ Sdp::Ptr H265Track::getSdp(uint8_t payload_type) const { WarnL << getCodecName() << " Track未准备好"; return nullptr; } - return std::make_shared(_vps, _sps, _pps, payload_type, getBitRate() / 1024); + return std::make_shared(_vps, _sps, _pps, payload_type, getBitRate() >> 10); } namespace { diff --git a/ext-codec/JPEG.cpp b/ext-codec/JPEG.cpp index df9964f3..d265f0b1 100644 --- a/ext-codec/JPEG.cpp +++ b/ext-codec/JPEG.cpp @@ -47,7 +47,7 @@ private: }; Sdp::Ptr JPEGTrack::getSdp(uint8_t) const { - return std::make_shared(getBitRate() / 1024); + return std::make_shared(getBitRate() >> 10); } diff --git a/ext-codec/L16.cpp b/ext-codec/L16.cpp index 64ff4da1..e91d9043 100644 --- a/ext-codec/L16.cpp +++ b/ext-codec/L16.cpp @@ -61,7 +61,7 @@ Sdp::Ptr L16Track::getSdp(uint8_t payload_type) const { WarnL << getCodecName() << " Track未准备好"; return nullptr; } - return std::make_shared(payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() / 1024); + return std::make_shared(payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() >> 10); } Track::Ptr L16Track::clone() const { diff --git a/ext-codec/Opus.cpp b/ext-codec/Opus.cpp index beea2a13..2f227813 100644 --- a/ext-codec/Opus.cpp +++ b/ext-codec/Opus.cpp @@ -62,7 +62,7 @@ Sdp::Ptr OpusTrack::getSdp(uint8_t payload_type) const { WarnL << getCodecName() << " Track未准备好"; return nullptr; } - return std::make_shared(payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() / 1024); + return std::make_shared(payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() >> 10); } namespace { diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 873f33cb..ed3f0b28 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -570,7 +570,7 @@ void getStatisticJson(const function &cb) { #ifdef ENABLE_MEM_DEBUG auto bytes = getTotalMemUsage(); val["totalMemUsage"] = (Json::UInt64) bytes; - val["totalMemUsageMB"] = (int) (bytes / 1024 / 1024); + val["totalMemUsageMB"] = (int) (bytes >> 20); val["totalMemBlock"] = (Json::UInt64) getTotalMemBlock(); static auto block_type_size = getBlockTypeSize(); { @@ -604,7 +604,7 @@ void getStatisticJson(const function &cb) { auto bytes = getThisThreadMemUsage(); val["threadName"] = getThreadName(); val["threadMemUsage"] = (Json::UInt64) bytes; - val["threadMemUsageMB"] = (Json::UInt64) (bytes / 1024 / 1024); + val["threadMemUsageMB"] = (Json::UInt64) (bytes >> 20); val["threadMemBlock"] = (Json::UInt64) getThisThreadMemBlock(); { int i = 0; diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index 6f53b8d3..c9701d43 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -284,9 +284,9 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st } else if (fileSize < 1024 * 1024) { ss << fixed << setprecision(2) << " (" << fileSize / 1024.0 << "KB)"; } else if (fileSize < 1024 * 1024 * 1024) { - ss << fixed << setprecision(2) << " (" << fileSize / 1024 / 1024.0 << "MB)"; + ss << fixed << setprecision(2) << " (" << (fileSize >> 10) / 1024.0 << "MB)"; } else { - ss << fixed << setprecision(2) << " (" << fileSize / 1024 / 1024 / 1024.0 << "GB)"; + ss << fixed << setprecision(2) << " (" << (fileSize >> 20) / 1024.0 << "GB)"; } ss << "\r\n"; } diff --git a/src/Rtmp/Rtmp.cpp b/src/Rtmp/Rtmp.cpp index d1d44c11..9b6ae466 100644 --- a/src/Rtmp/Rtmp.cpp +++ b/src/Rtmp/Rtmp.cpp @@ -34,14 +34,14 @@ VideoMeta::VideoMeta(const VideoTrack::Ptr &video) { _metadata.set("framerate", video->getVideoFps()); } if (video->getBitRate()) { - _metadata.set("videodatarate", video->getBitRate() / 1024); + _metadata.set("videodatarate", video->getBitRate() >> 10); } _metadata.set("videocodecid", Factory::getAmfByCodecId(video->getCodecId())); } AudioMeta::AudioMeta(const AudioTrack::Ptr &audio) { if (audio->getBitRate()) { - _metadata.set("audiodatarate", audio->getBitRate() / 1024); + _metadata.set("audiodatarate", audio->getBitRate() >> 10); } if (audio->getAudioSampleRate() > 0) { _metadata.set("audiosamplerate", audio->getAudioSampleRate()); diff --git a/tests/test_flv.cpp b/tests/test_flv.cpp index c0bd09e0..23e2d0b3 100644 --- a/tests/test_flv.cpp +++ b/tests/test_flv.cpp @@ -84,7 +84,7 @@ static bool loadFile(const char *path){ } timeStamp_last = timeStamp; } - WarnL << total_size / 1024 << "KB"; + WarnL << (total_size >> 10) << "KB"; fclose(fp); return true; } diff --git a/tests/test_ps.cpp b/tests/test_ps.cpp index b1413f65..5a78b228 100644 --- a/tests/test_ps.cpp +++ b/tests/test_ps.cpp @@ -85,7 +85,7 @@ static bool loadFile(const char *path, const EventPoller::Ptr &poller) { if (ps_decoder) { ps_decoder->input(text, lSize); } - WarnL << lSize / 1024 << "KB"; + WarnL << (lSize >> 10) << "KB"; fclose(fp); return true; } diff --git a/tests/test_rtp.cpp b/tests/test_rtp.cpp index 6bd8d8fb..e2f558a8 100644 --- a/tests/test_rtp.cpp +++ b/tests/test_rtp.cpp @@ -89,7 +89,7 @@ static bool loadFile(const char *path, const EventPoller::Ptr &poller) { poller->doDelayTask(1, [do_read, total_size, process]() mutable { auto ret = do_read(); if (!ret) { - WarnL << *total_size / 1024 << "KB"; + WarnL << (*total_size >> 10) << "KB"; } return ret; });