mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-12-05 01:11:52 +08:00
优化代码
除1024改成右移10位
This commit is contained in:
parent
67668c9f2c
commit
87b42ab492
@ -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;
|
||||
|
@ -377,7 +377,7 @@ Sdp::Ptr AACTrack::getSdp(uint8_t payload_type) const {
|
||||
WarnL << getCodecName() << " Track未准备好";
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_shared<AACSdp>(getExtraData()->toString(), payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() / 1024);
|
||||
return std::make_shared<AACSdp>(getExtraData()->toString(), payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() >> 10);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -361,7 +361,7 @@ Sdp::Ptr H264Track::getSdp(uint8_t payload_type) const {
|
||||
WarnL << getCodecName() << " Track未准备好";
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_shared<H264Sdp>(_sps, _pps, payload_type, getBitRate() / 1024);
|
||||
return std::make_shared<H264Sdp>(_sps, _pps, payload_type, getBitRate() >> 10);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -267,7 +267,7 @@ Sdp::Ptr H265Track::getSdp(uint8_t payload_type) const {
|
||||
WarnL << getCodecName() << " Track未准备好";
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_shared<H265Sdp>(_vps, _sps, _pps, payload_type, getBitRate() / 1024);
|
||||
return std::make_shared<H265Sdp>(_vps, _sps, _pps, payload_type, getBitRate() >> 10);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -47,7 +47,7 @@ private:
|
||||
};
|
||||
|
||||
Sdp::Ptr JPEGTrack::getSdp(uint8_t) const {
|
||||
return std::make_shared<JPEGSdp>(getBitRate() / 1024);
|
||||
return std::make_shared<JPEGSdp>(getBitRate() >> 10);
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ Sdp::Ptr L16Track::getSdp(uint8_t payload_type) const {
|
||||
WarnL << getCodecName() << " Track未准备好";
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_shared<L16Sdp>(payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() / 1024);
|
||||
return std::make_shared<L16Sdp>(payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() >> 10);
|
||||
}
|
||||
|
||||
Track::Ptr L16Track::clone() const {
|
||||
|
@ -62,7 +62,7 @@ Sdp::Ptr OpusTrack::getSdp(uint8_t payload_type) const {
|
||||
WarnL << getCodecName() << " Track未准备好";
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_shared<OpusSdp>(payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() / 1024);
|
||||
return std::make_shared<OpusSdp>(payload_type, getAudioSampleRate(), getAudioChannel(), getBitRate() >> 10);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -570,7 +570,7 @@ void getStatisticJson(const function<void(Value &val)> &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<void(Value &val)> &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;
|
||||
|
@ -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 << "</a></li>\r\n";
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user