当前位置: 首页 > 编程日记 > 正文

FFmpeg中libavutil库简介及测试代码

libavutil是一个实用库,用于辅助多媒体编程。此库包含安全的可移植字符串函数、随机数生成器、数据结构、附加数学函数、加密和多媒体相关功能(如像素和样本格式的枚举)。libavcodec和libavformat并不依赖此库。

以下是测试代码,包括base64, aes, des, hash, log, md5, sha, sha512, tea, twofish, xteaa。

funset.hpp:

#ifndef FBC_FFMPEG_TEST_FUNSET_HPP_
#define FBC_FFMPEG_TEST_FUNSET_HPP_// libavutil
int test_ffmpeg_libavutil_xtea(); // XTEA(eXtended Tiny Encryption Algorithm)
int test_ffmpeg_libavutil_twofish(); // Twofish crypto algorithm
int test_ffmpeg_libavutil_tea(); // TEA(Tiny Encryption Algorithm)
int test_ffmpeg_libavutil_sha512(); // SHA(Secure Hash Algorithm), SHA-512/224, SHA-512/256, SHA-384, SHA-512 
int test_ffmpeg_libavutil_sha(); // SHA(Secure Hash Algorithm), SHA-1, SHA-224, SHA-256 
int test_ffmpeg_libavutil_md5(); // MD5
int test_ffmpeg_libavutil_log(); // Log
int test_ffmpeg_libavutil_hash(); // hash function
int test_ffmpeg_libavutil_des(); // DES symmetric encryption algorithm
int test_ffmpeg_libavutil_aes(); // AES symmetric encryption algorithm
int test_ffmpeg_libavutil_base64(); // base64 codec#endif // FBC_FFMPEG_TEST_FUNSET_HPP_

test_ffmpeg_libavutil.cpp:

#include "funset.hpp"
#include <string.h>
#include <iostream>
#include <string>
#include <memory>
#include <vector>#ifdef __cplusplus
extern "C" {
#endif#include <libavutil/base64.h>
#include <libavutil/aes.h>
#include <libavutil/mem.h>
#include <libavutil/des.h>
#include <libavutil/hash.h>
#include <libavutil/log.h>
#include <libavutil/md5.h>
#include <libavutil/sha.h>
#include <libavutil/sha512.h>
#include <libavutil/tea.h>
#include <libavutil/xtea.h>
#include <libavutil/twofish.h>#ifdef __cplusplus
}
#endifint test_ffmpeg_libavutil_xtea()
{const char* src = "https://blog.csdn.net/fengbingchun";const uint8_t key[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};size_t length = strlen(src);int blocks_count = (length + 7) / 8; // count number of 8 byte blocksstd::unique_ptr<uint8_t[]> cipher_text(new uint8_t[blocks_count * 8]), plain_text(new uint8_t[blocks_count * 8]);fprintf(stdout, "src length: %d, blocks_count: %d\n", length, blocks_count);// encryptAVXTEA* ctx1 = av_xtea_alloc();if (!ctx1) {fprintf(stderr, "fail to av_xtea_alloc\n");return -1;}av_xtea_init(ctx1, key);av_xtea_crypt(ctx1, cipher_text.get(), (const uint8_t*)src, blocks_count, nullptr, 0);av_free(ctx1);// decryptAVXTEA* ctx2 = av_xtea_alloc();if (!ctx2) {fprintf(stderr, "fail to av_xtea_alloc\n");return -1;}av_xtea_init(ctx2, key);av_xtea_crypt(ctx2, plain_text.get(), (const uint8_t*)cipher_text.get(), blocks_count, nullptr, 1);av_free(ctx2);fprintf(stdout, "src data: %s\n", src);fprintf(stdout, "cipher text: %s\n", (const char*)cipher_text.get());fprintf(stdout, "plain text: %s\n", (const char*)plain_text.get());if (memcmp(src, (const char*)plain_text.get(), length)) {fprintf(stderr, "fail to xtea encrypt/decrypt\n");return -1;}	return 0;
}int test_ffmpeg_libavutil_twofish()
{return -1;// the execution result is incorrect, i don't know why ???const char* src = "https://blog.csdn.net/fengbingchun";const uint8_t key[32] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};const int key_bits = 256; // 128, 192, 256size_t length = strlen(src);int blocks_count = (length + 15) / 16; // count number of 16 byte blocksstd::unique_ptr<uint8_t[]> cipher_text(new uint8_t[blocks_count * 16]), plain_text(new uint8_t[blocks_count * 16]);fprintf(stdout, "src length: %d, blocks_count: %d\n", length, blocks_count);uint8_t iv[16];memcpy(iv, "HALLO123HALLO123", 16);// encryptAVTWOFISH* ctx1 = av_twofish_alloc();if (!ctx1) {fprintf(stderr, "fail to av_twofish_alloc\n");return -1;}av_twofish_init(ctx1, key, key_bits);av_twofish_crypt(ctx1, cipher_text.get(), (const uint8_t*)src, blocks_count, /*iv*/nullptr, 0);av_free(ctx1);if (blocks_count * 16 > length)cipher_text[length] = '\0';// decryptAVTWOFISH* ctx2 = av_twofish_alloc();if (!ctx2) {fprintf(stderr, "fail to av_twofish_alloc\n");return -1;}av_twofish_init(ctx2, key, key_bits);av_twofish_crypt(ctx2, plain_text.get(), (uint8_t*)cipher_text.get(), blocks_count, /*iv*/nullptr, 1);av_free(ctx2);if (blocks_count * 16 > length)plain_text[length] = '\0';fprintf(stdout, "src data: %s\n", src);fprintf(stdout, "cipher text: %s\n", (const char*)cipher_text.get());fprintf(stdout, "plain text: %s\n", (const char*)plain_text.get());if (memcmp(src, (const char*)plain_text.get(), length)) {fprintf(stderr, "fail to twofish encrypt/decrypt\n");return -1;}	return 0;
}int test_ffmpeg_libavutil_tea()
{const char* src = "https://blog.csdn.net/fengbingchun";const uint8_t key[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};size_t length = strlen(src);int blocks_count = (length + 7) / 8; // count number of 8 byte blocksstd::unique_ptr<uint8_t[]> cipher_text(new uint8_t[blocks_count * 8]), plain_text(new uint8_t[blocks_count * 8]);fprintf(stdout, "src length: %d, blocks_count: %d\n", length, blocks_count);// encryptstruct AVTEA* ctx1 = av_tea_alloc();if (!ctx1) {fprintf(stderr, "fail to av_tea_alloc\n");return -1;}av_tea_init(ctx1, key, 64);av_tea_crypt(ctx1, cipher_text.get(), (const uint8_t*)src, blocks_count, nullptr, 0);av_free(ctx1);// decryptstruct AVTEA* ctx2 = av_tea_alloc();if (!ctx2) {fprintf(stderr, "fail to av_tea_alloc\n");return -1;}av_tea_init(ctx2, key, 64);av_tea_crypt(ctx2, plain_text.get(), (const uint8_t*)cipher_text.get(), blocks_count, nullptr, 1);av_free(ctx2);fprintf(stdout, "src data: %s\n", src);fprintf(stdout, "cipher text: %s\n", (const char*)cipher_text.get());fprintf(stdout, "plain text: %s\n", (const char*)plain_text.get());if (memcmp(src, (const char*)plain_text.get(), length)) {fprintf(stderr, "fail to tea encrypt/decrypt\n");return -1;}	return 0;
}int test_ffmpeg_libavutil_sha512()
{const int hash_length[4] = {224, 256, 384, 512}; // SHA-512/224, SHA-512/256, SHA-384, SHA-512const char* src = "https://blog.csdn.net/fengbingchun";struct AVSHA512* ctx = av_sha512_alloc();if (!ctx) {fprintf(stderr, "fail to av_sha512_alloc\n");return -1;}for (int i = 0; i < 4; ++i) {unsigned char digest[64];av_sha512_init(ctx, hash_length[i]);av_sha512_update(ctx, (const uint8_t*)src, strlen(src));av_sha512_final(ctx, digest);				fprintf(stdout, "sha512: ");//for (int j = 0; j < 64; ++j)for (int j = 0; j < hash_length[i] >> 3; ++j)fprintf(stdout, "%02x", digest[j]);fprintf(stdout, "\n");}av_free(ctx);return 0;
}int test_ffmpeg_libavutil_sha()
{const int hash_length[3] = {160, 224, 256}; // SHA-1, SHA-224, SHA-256const char* src = "https://blog.csdn.net/fengbingchun";struct AVSHA* ctx = av_sha_alloc();if (!ctx) {fprintf(stderr, "fail to av_sha_alloc\n");return -1;}for (int i = 0; i < 3; ++i) {unsigned char digest[32];av_sha_init(ctx, hash_length[i]);av_sha_update(ctx, (const uint8_t*)src, strlen(src));av_sha_final(ctx, digest);				fprintf(stdout, "sha: ");//for (int j = 0; j < 32; ++j)for (int j = 0; j < hash_length[i] >> 3; ++j)fprintf(stdout, "%02x", digest[j]);fprintf(stdout, "\n");}av_free(ctx);return 0;
}int test_ffmpeg_libavutil_md5()
{const char* src = "https://blog.csdn.net/fengbingchun";uint8_t md5val[16];av_md5_sum(md5val, (const uint8_t*)src, strlen(src));fprintf(stdout, "md5sum: ");for (int i = 0; i < 16; ++i)fprintf(stdout, "%02x", md5val[i]);fprintf(stdout, "\n");return 0;
}int test_ffmpeg_libavutil_log()
{av_log_set_level(AV_LOG_TRACE);av_log(nullptr, AV_LOG_TRACE, "trace message\n");av_log(nullptr, AV_LOG_DEBUG, "debug message\n");av_log(nullptr, AV_LOG_VERBOSE, "verbose message\n");av_log(nullptr, AV_LOG_INFO, "info message\n");av_log(nullptr, AV_LOG_WARNING, "warning message\n");av_log(nullptr, AV_LOG_ERROR, "error message\n");av_log(nullptr, AV_LOG_FATAL, "fatal message\n");av_log(nullptr, AV_LOG_PANIC, "panic message\n");return 0;
}int test_ffmpeg_libavutil_hash()
{std::vector<const char*> hash_names;int index = 0;do {hash_names.push_back(av_hash_names(index));++index;} while(hash_names[hash_names.size()-1]);fprintf(stdout, "supported hash algorithms: ");for (auto name : hash_names) {if (name)fprintf(stdout, "%s,  ", name);}fprintf(stdout, "\n");const char* src[2] = {"https://blog.csdn.net/fengbingchun", "https://github.com/fengbingchun"};int dst_buf_size = AV_HASH_MAX_SIZE * 8;for (int i = 0; i < 2; ++i) {struct AVHashContext* ctx = nullptr;if (av_hash_alloc(&ctx, hash_names[i]) < 0) {fprintf(stderr, "fail to av_hash_alloc: %d\n", i);return -1;}av_hash_init(ctx);av_hash_update(ctx, (const uint8_t*)src[i], strlen(src[i]));std::unique_ptr<uint8_t[]> dst(new uint8_t[dst_buf_size]);memset(dst.get(), 0, dst_buf_size);av_hash_final_hex(ctx, dst.get(), dst_buf_size);fprintf(stdout, "hash name: %s, hex: %s\n", av_hash_get_name(ctx), dst.get());av_hash_freep(&ctx);}return 0;
}int test_ffmpeg_libavutil_des()
{const uint8_t key[16] = { 0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3, 0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59 };const std::string src = "https://blog.csdn.net/fengbingchun";size_t length = src.length();int blocks_count = (length + 7) / 8; // count number of 8 byte blocksstd::unique_ptr<uint8_t[]> cipher_text(new uint8_t[blocks_count * 8]), plain_text(new uint8_t[blocks_count * 8]);fprintf(stdout, "src length: %d, blocks_count: %d\n", length, blocks_count);// encryptionstruct AVDES b1;av_des_init(&b1, key, 64, 0);av_des_crypt(&b1, cipher_text.get(), (const uint8_t*)src.c_str(), blocks_count, nullptr, 0);fprintf(stdout, "src data: %s\n", src.c_str());fprintf(stdout, "cipher text: %s\n", (const char*)cipher_text.get());// decryptionstruct AVDES b2;av_des_init(&b2, key, 64, 1);av_des_crypt(&b2, plain_text.get(), (const uint8_t*)cipher_text.get(), blocks_count, nullptr, 1);fprintf(stdout, "plain text: %s\n", (const char*)plain_text.get());if (memcmp(src.c_str(), (const char*)plain_text.get(), length)) {fprintf(stderr, "fail to des encrypt/decrypt\n");return -1;}return 0;
}int test_ffmpeg_libavutil_aes()
{const uint8_t key[16] = { 0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3, 0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59 };const std::string src = "https://blog.csdn.net/fengbingchun";size_t length = src.length();int blocks_count = (length + 15) / 16; // count number of 16 byte blocksstd::unique_ptr<uint8_t[]> cipher_text(new uint8_t[blocks_count * 16]), plain_text(new uint8_t[blocks_count * 16]);fprintf(stdout, "src length: %d, blocks_count: %d\n", length, blocks_count);// encryptionstruct AVAES* b1 = av_aes_alloc();if (!b1) {fprintf(stderr, "fail to av_aes_alloc\n");return -1;}av_aes_init(b1, key, 128, 0);av_aes_crypt(b1, cipher_text.get(), (const uint8_t*)src.c_str(), blocks_count, nullptr, 0);av_free(b1);fprintf(stdout, "src data: %s\n", src.c_str());fprintf(stdout, "cipher text: %s\n", (const char*)cipher_text.get());// decryptionstruct AVAES* b2 = av_aes_alloc();if (!b2) {fprintf(stderr, "fail to av_aes_alloc\n");return -1;}av_aes_init(b2, key, 128, 1);av_aes_crypt(b2, plain_text.get(), (const uint8_t*)cipher_text.get(), blocks_count, nullptr, 1);av_free(b2);fprintf(stdout, "plain text: %s\n", (const char*)plain_text.get());if (memcmp(src.c_str(), (const char*)plain_text.get(), length)) {fprintf(stderr, "fail to aes encrypt/decrypt\n");return -1;}return 0;
}int test_ffmpeg_libavutil_base64()
{const std::string blog_addr = "https://blog.csdn.net/fengbingchun";int length_src = blog_addr.length();int length_dst = AV_BASE64_SIZE(length_src);std::unique_ptr<char[]> dst1(new char[length_dst]);char* tmp = av_base64_encode(dst1.get(), length_dst, (const uint8_t*)blog_addr.c_str(), length_src);if (!tmp) {fprintf(stderr, "fail to av_base64_encode\n");return -1;}int length_dst2 = AV_BASE64_DECODE_SIZE(length_dst);std::unique_ptr<uint8_t[]> dst2(new uint8_t[length_dst2]);int size = av_base64_decode(dst2.get(), dst1.get(), length_dst2);if (size < 0) {fprintf(stderr, "fail to av_base64_decode");return -1;}if (memcmp(blog_addr.c_str(), (const char*)dst2.get(), size)) {fprintf(stderr, "fail to base64 encode/decode\n");return -1;}if (length_dst2 > size)dst2.get()[size] = '\0';fprintf(stdout, "src string: %s\n", blog_addr.c_str());fprintf(stdout, "encode result: %s\n", dst1.get());fprintf(stdout, "decode result: %s\n", (char*)dst2.get());return 0;
}

其中test_ffmpeg_libavutil_xtea的执行结果如下:

GitHub: https://github.com/fengbingchun/OpenCV_Test

相关文章:

区块链人才月均薪酬1.6万元?

在上周&#xff0c;我国宣布将重点推动区块链技术的发展&#xff0c;这个消息无疑是为区块链开发者们打了一直强心剂&#xff0c;简直是喜大普奔啊 &#xff01; 因为之前区块链这个技术虽然一直在圈内很火&#xff0c;但是却没有得到国家的全面认可和推广&#xff0c;所以很多…

用最少的时间学最多的数据挖掘知识(附教程数据源)| CSDN博文精选

作者 | 宋莹来源 | 数据派THU&#xff08;ID:DatapiTHU&#xff09;本文为你介绍数据挖掘的知识及应用。引言最近笔者学到了一个新词&#xff0c;叫做“认知折叠”。就是将复杂的事物包装成最简单的样子&#xff0c;让大家不用关心里面的细节就能方便使用。作为数据科学领域从业…

WKWebView 的使用简介

1. navigationDelegate [objc] view plaincopy print?- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation { // 类似UIWebView的 -webViewDidStartLoad: NSLog("didStartProvisionalNavigation"); [UIAppli…

FFmpeg中libswscale库简介及测试代码

libswscale库功能主要包括高度优化的图像缩放、颜色空间和像素格式转换操作。 以下是测试代码(test_ffmpeg_libswscale.cpp)&#xff1a; #include "funset.hpp" #include <string.h> #include <iostream> #include <string> #include <memor…

FFmpeg中libswresample库简介及测试代码

libswresample库功能主要包括高度优化的音频重采样、rematrixing和样本格式转换操作。 以下是测试代码(test_ffmpeg_libswresample.cpp)&#xff0c;对音频了解较少&#xff0c;测试代码是参考examples中的&#xff1a; #include "funset.hpp" #include <iostre…

高德地图POI搜索,附近地图搜索,类似附近的人搜索

效果图&#xff1a; 首先导入道德地图的SDK&#xff0c;导入步骤不在这里介绍 2&#xff1a;包含头文件&#xff1a; [objc] view plaincopy #import <AMapSearchKit/AMapSearchAPI.h> 3&#xff1a;代码 [javascript] view plaincopy property(nonatomic,strong)AMap…

手把手教你实现PySpark机器学习项目——回归算法

作者 | hecongqing 来源 | AI算法之心&#xff08;ID:AIHeartForYou&#xff09;【导读】PySpark作为工业界常用于处理大数据以及分布式计算的工具&#xff0c;特别是在算法建模时起到了非常大的作用。PySpark如何建模呢&#xff1f;这篇文章手把手带你入门PySpark&#xff0c;…

mcDropdown使用方法

最近使用了mcDropdown插件&#xff0c;百度一查&#xff0c;资料较少&#xff0c;只看到了mcDropdown官网的英文说明文档&#xff0c;所以今天就写点&#xff0c;以便以后使用。 第一步&#xff1a;引用jquery库和css jQuery v1.2.6 (or higher)*jquery.mcdropdown.js Plug-inj…

Windows上通过VLC播放器搭建rtsp流媒体测试地址操作步骤

1. 从https://www.videolan.org/index.zh.html 下载最新的windows 64bit 3.0.6版本并安装&#xff1b; 2. 打开VLC media player&#xff0c;依次点击按钮&#xff1a;”媒体” --> “流”&#xff0c;如下图所示&#xff1a; 3. 点击”添加”按钮&#xff0c;选择一个视频…

Swift - AppDelegate.swift类中默认方法的介绍

项目创建后&#xff0c;AppDelegate类中默认带有如下几个方法&#xff0c;具体功能如下&#xff1a; 1&#xff0c;应用程序第一次运行时执行这个方法只有在App第一次运行的时候被执行过一次&#xff0c;每次App从后台激活时都不会再执行该方法。&#xff08;注&#xff1a;所有…

上热搜了!“学了Python6个月,竟然找不到工作!”

在编程界&#xff0c;Python是一种神奇的存在。有人认为&#xff0c;只有用Python才能优雅写代码&#xff0c;提高代码效率&#xff1b;但另一部分人恨不能把Python喷成筛子。那么&#xff0c;Python到底有没有用&#xff0c;为什么用Python找不到工作&#xff1f;CSDN小姐姐带…

Linux0.00内核为什么要自己设置0x80号陷阱门来调用write_char过程?

我一开始没注意这个问题&#xff0c;只是通过陷阱门觉得很绕弯子&#xff0c;为何不在3级用户代码里直接调用write_char&#xff0c;今天自己写程序想用call调用代码段&#xff0c;才发现了大问题。我写了个类似于write_char的过程&#xff0c;代码如下&#xff1a;dividing_li…

iOS支付宝(Alipay)接入详细流程,比微信支付更简单,项目实战中的问题分析

最近在项目中接入了微信支付和支付宝支付&#xff0c;总的来说没有那么坑&#xff0c;很多人都说文档不全什么的&#xff0c;确实没有面面 俱到&#xff0c;但是认真一步一步测试下还是妥妥的&#xff0c;再配合懂得后台&#xff0c;效率也是很高的&#xff0c;看了这篇文章&a…

LIVE555简介及在Windows上通过VS2013编译操作步骤

LIVE555是使用开放标准协议(RTP/RTCP, RTSP, SIP)形成的一组用于多媒体流C库。这些库支持的平台包括Unix(包括Linux和Mac OS X)、Windows和QNX(以及其它符号POSIX的系统)。这些库已经被用于实现的应用例如LIVE555媒体服务器、LIVE555代理服务器(RTSP服务器应用)以及vobStreamer…

GitHub App终于来了,iPhone用户可尝鲜,「同性交友」更加便捷

整理 | 夕颜出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09;【导读】据外媒 VentureBeat 报道&#xff0c;在 11 月 13 日举行的 GitHub Universe 上&#xff0c;微软宣布了面向程序员和开发人员的一系列升级&#xff0c;包括针对 iOS 智能手机和 iPad 推出的 GitHub…

[NHibernate]代码生成器的使用

目录 写在前面 文档与系列文章 代码生成器的使用 总结 写在前面 前面的文章介绍了nhibernate的相关知识&#xff0c;都是自己手敲的代码&#xff0c;有时候显得特别的麻烦&#xff0c;比如你必须编写持久化类&#xff0c;映射文件等等&#xff0c;举得例子比较简单&#xff0c;…

RapidJSON简介及使用

RapidJSON是腾讯开源的一个高效的C JSON解析器及生成器&#xff0c;它是只有头文件的C库。RapidJSON是跨平台的&#xff0c;支持Windows, Linux, Mac OS X及iOS, Android。它的源码在https://github.com/Tencent/rapidjson/&#xff0c;稳定版本为2016年发布的1.1.0版本。 Rap…

高德地图关键字搜索oc版

.h文件 // MapSearchViewController.h // JMT // // Created by walker on 16/10/11. // Copyright © 2016年 BOOTCAMP. All rights reserved. // #import <UIKit/UIKit.h> #import <AMapNaviKit/MaMapKit.h> #import <AMapSearchKit/AMapSearchKit.h&…

同一个内容,对比Java、C、PHP、Python的代码量,结局意外了

为什么都说Python容易上手&#xff01;是真的吗&#xff1f;都说Python通俗易懂&#xff0c;容易上手&#xff0c;甚至不少网友表示「完成同一个任务&#xff0c;C 语言要写 1000 行代码&#xff0c;Java 只需要写 100 行&#xff0c;而 Python 可能只要 20 行」到底是真的还是…

图片存储思考:

http://blog.csdn.net/liuruhong/article/details/4072386

LIVE555中RTSP客户端接收媒体流分析及测试代码

LIVE555中testProgs目录下的testRTSPClient.cpp代码用于测试接收RTSP URL指定的媒体流&#xff0c;向服务器端发送的命令包括&#xff1a;DESCRIBE、SETUP、PLAY、TERADOWN。 1. 设置使用环境&#xff1a;new一个BasicTaskScheduler对象&#xff1b;new一个BasicUsageEnvironm…

swift代理传值

比如我们这个场景&#xff0c;B要给A传值&#xff0c;那B就拥有代理属性&#xff0c; A就是B的代理&#xff0c;很简单吧&#xff01;有代理那就离不开协议&#xff0c;所以第一步就是声明协议。在那里声明了&#xff1f;谁拥有代理属性就在那里声明&#xff0c;所以代码就是这…

重磅:腾讯正式开源图计算框架Plato,十亿级节点图计算进入分钟级时代

整理 | 唐小引 来源 | CSDN&#xff08;ID&#xff1a;CSDNnews&#xff09;腾讯开源进化 8 年&#xff0c;进入爆发期。 继刚刚连续开源 TubeMQ、Tencent Kona JDK、TBase、TKEStack 四款重点开源项目后&#xff0c;腾讯开源再次迎来重磅项目&#xff01;北京时间 11 月 14 日…

类似ngnix的多进程监听用例

2019独角兽企业重金招聘Python工程师标准>>> 多进程监听适合于短连接&#xff0c;且连接间无交集的应用。前两天简单写了一个&#xff0c;在这里保存一下。 #include <sys/types.h>#include <stdarg.h>#include <signal.h>#include <unistd.h&…

今日头条李磊等最新论文:用于文本生成的核化贝叶斯Softmax

译者 | Raku 出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09;摘要用于文本生成的神经模型需要在解码阶段具有适当词嵌入的softmax层&#xff0c;大多数现有方法采用每个单词单点嵌入的方式&#xff0c;但是一个单词可能具有多种意义&#xff0c;在不同的背景下&#…

FFmpeg中RTSP客户端拉流测试代码

之前在https://blog.csdn.net/fengbingchun/article/details/91355410中给出了通过LIVE555实现拉流的测试代码&#xff0c;这里通过FFmpeg来实现&#xff0c;代码量远小于LIVE555&#xff0c;实现模块在libavformat。 在4.0及以上版本中&#xff0c;FFmpeg有了些变动&#xff…

虚拟机下运行linux通过nat模式与主机通信、与外网连接

首先&#xff1a;打开虚拟机的编辑菜单下的虚拟网络编辑器&#xff0c;选中VMnet8 NAT模式。通过NAT设置获取网关IP&#xff0c;通过DHCP获取可配置的IP区间。同时&#xff0c;将虚拟机的虚拟机菜单的设置选项中的网络适配器改为NAT模式。即可&#xff01; 打开linux&#xff0…

远程过程调用RPC简介

RPC(Remote Procedure Call, 远程过程调用)&#xff1a;是一种通过网络从远程计算机程序上请求服务&#xff0c;而不需要了解底层网络技术的思想。 RPC是一种技术思想而非一种规范或协议&#xff0c;常见RPC技术和框架有&#xff1a; (1). 应用级的服务框架&#xff1a;阿里的…

iOS开发:沙盒机制以及利用沙盒存储字符串、数组、字典等数据

iOS开发&#xff1a;沙盒机制以及利用沙盒存储字符串、数组、字典等数据 1、初识沙盒&#xff1a;(1)、存储在内存中的数据&#xff0c;程序关闭&#xff0c;内存释放&#xff0c;数据就会丢失&#xff0c;这种数据是临时的。要想数据永久保存&#xff0c;将数据保存成文件&am…

支撑亿级用户“刷手机”​,百度Feed流背后的新技术装备有多牛?

导读&#xff1a;截止到2018年底&#xff0c;我国网民使用手机上网的比例已高达98.6%&#xff0c;移动互联网基本全方位覆盖。智能手机的操作模式让我们更倾向于通过简单的“划屏”动作&#xff0c;相对于传统的文本交互方式来获取信息&#xff0c;用户更希望一拿起手机就能刷到…