音频demo:将PCM数据与alaw、mulaw、g711数据的相互转换

1、README

前言

g711

(截图来源:https://blog.csdn.net/u014470361/article/details/88837776)

我的理解:

首先需要知道的是u-law/a-law是用于脉冲编码的压缩/解压缩算法。而G.711是指在8KHz采样率(单声道)中,使用的u-law或a-law算法对音频进行压缩的一种语音压缩标准。但是,使用这两种压缩算法进行压缩的音频并不一定是G.711,要在8KHz采样率(单声道)的才是,压缩其他采样率和多声道得到的u-law/a-law文件只要设置对应的采样率和声道数照样能解压播放。

a. 编译

demo引用了开源代码g711.cg711.h,然后在此基础上封装成g711_wraper.cg711_wraper.h,并编写自己的测试程序main.c进行验证。整个demo程序共5个源文件,可以编译到任意环境下使用(非类Unix系统可能需要简单调整main.c中包含的头文件):

$ make   # 或者: make CC=your-crosscompile-gcc
b. 使用
examples: 
         ./pcm_alaw_ulaw -h
         ./pcm_alaw_ulaw --help
         ./pcm_alaw_ulaw -m pcm_2_alaw -i ./audio/test_8000_16_1.pcm -o ./test_8000_8_1.g711a
         ./pcm_alaw_ulaw -m pcm_2_ulaw -i ./audio/test_8000_16_1.pcm -o ./test_8000_8_1.g711u
         ./pcm_alaw_ulaw -m alaw_2_pcm -i ./audio/test_8000_8_1.g711a -o ./test_8000_16_1.pcm
         ./pcm_alaw_ulaw -m ulaw_2_pcm -i ./audio/test_8000_8_1.g711u -o ./test_8000_16_1.pcm
         ./pcm_alaw_ulaw -m alaw_2_ulaw -i ./audio/test_8000_8_1.g711a -o ./test_8000_8_1.g711u
         ./pcm_alaw_ulaw -m ulaw_2_alaw -i ./audio/test_8000_8_1.g711u -o ./test_8000_8_1.g711a
         ./pcm_alaw_ulaw --mode pcm_2_ulaw --input_file=./audio/test_8000_16_2.pcm --output_file=./test_8000_8_2.ulaw
         ./pcm_alaw_ulaw --mode pcm_2_ulaw --input_file=./audio/test_22050_16_1.pcm --output_file=./test_22050_8_1.ulaw
         ./pcm_alaw_ulaw --mode pcm_2_alaw --input_file=./audio/test_44100_16_2.pcm --output_file=./test_44100_8_2.alaw
         ...
         [mode: pcm_2_alaw | pcm_2_ulaw | alaw_2_pcm | ulaw_2_pcm | alaw_2_ulaw | ulaw_2_alaw]
c. demo目录架构
.
├── audio
│   ├── test_22050_16_1.pcm
│   ├── test_22050_8_1.ulaw
│   ├── test_44100_16_2.pcm
│   ├── test_44100_8_2.alaw
│   ├── test_8000_16_1.pcm
│   ├── test_8000_16_2.pcm
│   ├── test_8000_8_1.g711a
│   ├── test_8000_8_1.g711u
│   └── test_8000_8_2.ulaw
├── docs
│   ├── G711编码原理及代码_szfhy的博客-CSDN博客_g711编码.mhtml
│   └── 音频采样及编解码——LPCM 、ADPCM、G711、G726、AAC_夜风的博客-CSDN博客_adpcm.mhtml
├── main.c
├── Makefile
├── pcm_aulaw.c
├── pcm_aulaw.h
├── pcm_aulaw_wraper.c
├── pcm_aulaw_wraper.h
└── README.md

2、主要代码片段

pcm_aulaw.c
/*
 * This source code is a product of Sun Microsystems, Inc. and is provided
 * for unrestricted use.  Users may copy or modify this source code without
 * charge.
 *
 * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
 * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
 *
 * Sun source code is provided with no support and without any obligation on
 * the part of Sun Microsystems, Inc. to assist in its use, correction,
 * modification or enhancement.
 *
 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
 * OR ANY PART THEREOF.
 *
 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
 * or profits or other special, indirect and consequential damages, even if
 * Sun has been advised of the possibility of such damages.
 *
 * Sun Microsystems, Inc.
 * 2550 Garcia Avenue
 * Mountain View, California  94043
 */
/*
 * December 30, 1994:
 * Functions linear2alaw, linear2ulaw have been updated to correctly
 * convert unquantized 16 bit values.
 * Tables for direct u- to A-law and A- to u-law conversions have been
 * corrected.
 * Borge Lindberg, Center for PersonKommunikation, Aalborg University.
 * bli@cpk.auc.dk
 *
 */
/*
 * Downloaded from comp.speech site in Cambridge.
 *
 */

#include "pcm_aulaw.h"

/*
 * pcm_aulaw.c
 *
 * u-law, A-law and linear PCM conversions.
 * Source: http://www.speech.kth.se/cost250/refsys/latest/src/g711.c
 */
#define	SIGN_BIT	(0x80)		/* Sign bit for a A-law byte. */
#define	QUANT_MASK	(0xf)		/* Quantization field mask. */
#define	NSEGS		(8)		/* Number of A-law segments. */
#define	SEG_SHIFT	(4)		/* Left shift for segment number. */
#define	SEG_MASK	(0x70)		/* Segment field mask. */

static short seg_aend[8] = {0x1F, 0x3F, 0x7F, 0xFF,
			    0x1FF, 0x3FF, 0x7FF, 0xFFF};
static short seg_uend[8] = {0x3F, 0x7F, 0xFF, 0x1FF,
			    0x3FF, 0x7FF, 0xFFF, 0x1FFF};

/* copy from CCITT G.711 specifications */
unsigned char _u2a[128] = {			/* u- to A-law conversions */
	1,	1,	2,	2,	3,	3,	4,	4,
	5,	5,	6,	6,	7,	7,	8,	8,
	9,	10,	11,	12,	13,	14,	15,	16,
	17,	18,	19,	20,	21,	22,	23,	24,
	25,	27,	29,	31,	33,	34,	35,	36,
	37,	38,	39,	40,	41,	42,	43,	44,
	46,	48,	49,	50,	51,	52,	53,	54,
	55,	56,	57,	58,	59,	60,	61,	62,
	64,	65,	66,	67,	68,	69,	70,	71,
	72,	73,	74,	75,	76,	77,	78,	79,
/* corrected:
	81,	82,	83,	84,	85,	86,	87,	88, 
   should be: */
	80,	82,	83,	84,	85,	86,	87,	88,
	89,	90,	91,	92,	93,	94,	95,	96,
	97,	98,	99,	100,	101,	102,	103,	104,
	105,	106,	107,	108,	109,	110,	111,	112,
	113,	114,	115,	116,	117,	118,	119,	120,
	121,	122,	123,	124,	125,	126,	127,	128};

unsigned char _a2u[128] = {			/* A- to u-law conversions */
	1,	3,	5,	7,	9,	11,	13,	15,
	16,	17,	18,	19,	20,	21,	22,	23,
	24,	25,	26,	27,	28,	29,	30,	31,
	32,	32,	33,	33,	34,	34,	35,	35,
	36,	37,	38,	39,	40,	41,	42,	43,
	44,	45,	46,	47,	48,	48,	49,	49,
	50,	51,	52,	53,	54,	55,	56,	57,
	58,	59,	60,	61,	62,	63,	64,	64,
	65,	66,	67,	68,	69,	70,	71,	72,
/* corrected:
	73,	74,	75,	76,	77,	78,	79,	79,
   should be: */
	73,	74,	75,	76,	77,	78,	79,	80,
	80,	81,	82,	83,	84,	85,	86,	87,
	88,	89,	90,	91,	92,	93,	94,	95,
	96,	97,	98,	99,	100,	101,	102,	103,
	104,	105,	106,	107,	108,	109,	110,	111,
	112,	113,	114,	115,	116,	117,	118,	119,
	120,	121,	122,	123,	124,	125,	126,	127};

static short search(
   short val,
   short *table,
   short size)
{
   short i;
   
   for (i = 0; i < size; i++) {
      if (val <= *table++)
	 return (i);
   }
   return (size);
}

/*
 * linear2alaw() - Convert a 16-bit linear PCM value to 8-bit A-law
 *
 * linear2alaw() accepts an 16-bit integer and encodes it as A-law data.
 *
 *		Linear Input Code	Compressed Code
 *	------------------------	---------------
 *	0000000wxyza			000wxyz
 *	0000001wxyza			001wxyz
 *	000001wxyzab			010wxyz
 *	00001wxyzabc			011wxyz
 *	0001wxyzabcd			100wxyz
 *	001wxyzabcde			101wxyz
 *	01wxyzabcdef			110wxyz
 *	1wxyzabcdefg			111wxyz
 *
 * For further information see John C. Bellamy's Digital Telephony, 1982,
 * John Wiley & Sons, pps 98-111 and 472-476.
 */
unsigned char
linear2alaw(short pcm_val)	/* 2's complement (16-bit range) */
{
   short	 mask;
   short	 seg;
   unsigned char aval;
   
   pcm_val = pcm_val >> 3;

   if (pcm_val >= 0) {
      mask = 0xD5;		/* sign (7th) bit = 1 */
   } else {
      mask = 0x55;		/* sign bit = 0 */
      pcm_val = -pcm_val - 1;
   }
   
   /* Convert the scaled magnitude to segment number. */
   seg = search(pcm_val, seg_aend, 8);
   
   /* Combine the sign, segment, and quantization bits. */
   
   if (seg >= 8)		/* out of range, return maximum value. */
      return (unsigned char) (0x7F ^ mask);
   else {
      aval = (unsigned char) seg << SEG_SHIFT;
      if (seg < 2)
	 aval |= (pcm_val >> 1) & QUANT_MASK;
      else
	 aval |= (pcm_val >> seg) & QUANT_MASK;
      return (aval ^ mask);
   }
}

/*
 * alaw2linear() - Convert an A-law value to 16-bit linear PCM
 *
 */
short
alaw2linear(
   unsigned char	a_val)
{
   short t;
   short seg;
   
   a_val ^= 0x55;
   
   t = (a_val & QUANT_MASK) << 4;
   seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
   switch (seg) {
   case 0:
      t += 8;
      break;
   case 1:
      t += 0x108;
      break;
   default:
      t += 0x108;
      t <<= seg - 1;
   }
   return ((a_val & SIGN_BIT) ? t : -t);
}

#define	BIAS		(0x84)		/* Bias for linear code. */
#define CLIP            8159

/*
* linear2ulaw() - Convert a linear PCM value to u-law
*
* In order to simplify the encoding process, the original linear magnitude
* is biased by adding 33 which shifts the encoding range from (0 - 8158) to
* (33 - 8191). The result can be seen in the following encoding table:
*
*	Biased Linear Input Code	Compressed Code
*	------------------------	---------------
*	00000001wxyza			000wxyz
*	0000001wxyzab			001wxyz
*	000001wxyzabc			010wxyz
*	00001wxyzabcd			011wxyz
*	0001wxyzabcde			100wxyz
*	001wxyzabcdef			101wxyz
*	01wxyzabcdefg			110wxyz
*	1wxyzabcdefgh			111wxyz
*
* Each biased linear code has a leading 1 which identifies the segment
* number. The value of the segment number is equal to 7 minus the number
* of leading 0's. The quantization interval is directly available as the
* four bits wxyz.  * The trailing bits (a - h) are ignored.
*
* Ordinarily the complement of the resulting code word is used for
* transmission, and so the code word is complemented before it is returned.
*
* For further information see John C. Bellamy's Digital Telephony, 1982,
* John Wiley & Sons, pps 98-111 and 472-476.
*/
unsigned char
linear2ulaw(
   short pcm_val)	/* 2's complement (16-bit range) */
{
   short         mask;
   short	 seg;
   unsigned char uval;
   
   /* Get the sign and the magnitude of the value. */
   pcm_val = pcm_val >> 2;
   if (pcm_val < 0) {
      pcm_val = -pcm_val;
      mask = 0x7F;
   } else {
      mask = 0xFF;
   }
   if ( pcm_val > CLIP ) pcm_val = CLIP;		/* clip the magnitude */
   pcm_val += (BIAS >> 2);
   
   /* Convert the scaled magnitude to segment number. */
   seg = search(pcm_val, seg_uend, 8);
   
   /*
   * Combine the sign, segment, quantization bits;
   * and complement the code word.
   */
   if (seg >= 8)		/* out of range, return maximum value. */
      return (unsigned char) (0x7F ^ mask);
   else {
      uval = (unsigned char) (seg << 4) | ((pcm_val >> (seg + 1)) & 0xF);
      return (uval ^ mask);
   }
   
}

/*
 * ulaw2linear() - Convert a u-law value to 16-bit linear PCM
 *
 * First, a biased linear code is derived from the code word. An unbiased
 * output can then be obtained by subtracting 33 from the biased code.
 *
 * Note that this function expects to be passed the complement of the
 * original code word. This is in keeping with ISDN conventions.
 */
short
ulaw2linear(
   unsigned char	u_val)
{
   short t;
   
   /* Complement to obtain normal u-law value. */
   u_val = ~u_val;
   
   /*
    * Extract and bias the quantization bits. Then
    * shift up by the segment number and subtract out the bias.
    */
   t = ((u_val & QUANT_MASK) << 3) + BIAS;
   t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT;
   
   return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS));
}

/* A-law to u-law conversion */
unsigned char
alaw2ulaw(
   unsigned char	aval)
{
   aval &= 0xff;
   return (unsigned char) ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) :
	   (0x7F ^ _a2u[aval ^ 0x55]));
}

/* u-law to A-law conversion */
unsigned char
ulaw2alaw(
   unsigned char	uval)
{
   uval &= 0xff;
   return (unsigned char) ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) :
			   (0x55 ^ (_u2a[0x7F ^ uval] - 1)));
}

/* ---------- end of pcm_aulaw.c ----------------------------------------------------- */
pcm_aulaw_wraper.c
#include "pcm_aulaw.h"
#include "pcm_aulaw_wraper.h"


void pcm_2_alaw(const short *src_16lepcm, unsigned char *dst_alaw, unsigned int sample_cnt)
{
	for (int i = 0; i < sample_cnt; i++)
	{
		dst_alaw[i] = linear2alaw(src_16lepcm[i]);
	}
}


void alaw_2_pcm(const unsigned char *src_alaw, short *dst_16lepcm, unsigned int sample_cnt)
{
	for (int i = 0; i < sample_cnt; i++)
	{
		dst_16lepcm[i] = alaw2linear(src_alaw[i]);
	}
}


void pcm_2_ulaw(const short *src_16lepcm, unsigned char *dst_ulaw, unsigned int sample_cnt)
{
	for (int i = 0; i < sample_cnt; i++)
	{
		dst_ulaw[i] = linear2ulaw(src_16lepcm[i]);
	}
}


void ulaw_2_pcm(const unsigned char *src_ulaw, short *dst_16lepcm, unsigned int sample_cnt)
{
	for (int i = 0; i < sample_cnt; i++)
	{
		dst_16lepcm[i] = ulaw2linear(src_ulaw[i]);
	}
}



void alaw_2_ulaw(const unsigned char *src_alaw, char *dst_ulaw, unsigned int sample_cnt)
{
	for (int i = 0; i < sample_cnt; i++)
	{
		dst_ulaw[i] = alaw2ulaw(src_alaw[i]);
	}
}


void ulaw_2_alaw(const unsigned char *src_ulaw, char *dst_alaw, unsigned int sample_cnt)
{
	for (int i = 0; i < sample_cnt; i++)
	{
		dst_alaw[i] = ulaw2alaw(src_ulaw[i]);
	}
}

main.c
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>

#include "pcm_aulaw_wraper.h"


void print_usage(const char *process)
{
	printf("examples: \n"
		   "\t %s -h\n"
		   "\t %s --help\n"
		   "\t %s -m pcm_2_alaw -i ./audio/test_8000_16_1.pcm -o ./test_8000_8_1.g711a\n"
		   "\t %s -m pcm_2_ulaw -i ./audio/test_8000_16_1.pcm -o ./test_8000_8_1.g711u\n"
		   "\t %s -m alaw_2_pcm -i ./audio/test_8000_8_1.g711a -o ./test_8000_16_1.pcm\n"
		   "\t %s -m ulaw_2_pcm -i ./audio/test_8000_8_1.g711u -o ./test_8000_16_1.pcm\n"
		   "\t %s -m alaw_2_ulaw -i ./audio/test_8000_8_1.g711a -o ./test_8000_8_1.g711u\n"
		   "\t %s -m ulaw_2_alaw -i ./audio/test_8000_8_1.g711u -o ./test_8000_8_1.g711a\n"
		   "\t %s --mode pcm_2_ulaw --input_file=./audio/test_8000_16_2.pcm --output_file=./test_8000_8_2.ulaw\n"
		   "\t %s --mode pcm_2_ulaw --input_file=./audio/test_22050_16_1.pcm --output_file=./test_22050_8_1.ulaw\n"
		   "\t %s --mode pcm_2_alaw --input_file=./audio/test_44100_16_2.pcm --output_file=./test_44100_8_2.alaw\n"
		   "\t ...\n"
		   "\t [mode: pcm_2_alaw | pcm_2_ulaw | alaw_2_pcm | ulaw_2_pcm | alaw_2_ulaw | ulaw_2_alaw]\n\n",
		   process, process, process, process, process, process, process, process, process, process, process);
}


#define 	BUF_LEN 	(160)


int main(int argc, char **argv)
{
	/* 输入/输出文件 */
	FILE *fpInput = NULL;
	FILE *fpOutput = NULL;
	char inputFileName[128] = {0};
	char outputFileName[128] = {0};	
	char inputBuf[BUF_LEN*2] = {0};
	char outputBuf[BUF_LEN*2] = {0};
	
	/* 输入文件与输出文件的转换模式 */	
	char convert_mode[128] = {0};	

	if (argc == 1)
	{
		print_usage(argv[0]);
		return 0;
	}


	/* 解析命令行参数 */
	char option = 0;
	int option_index = 0;
	char *short_options = "hm:i:o:";
	struct option long_options[] =
	{
		{"help",        no_argument,       NULL, 'h'},
		{"mode",        required_argument, NULL, 'm'},
		{"input_file",  required_argument, NULL, 'i'},
		{"output_file", required_argument, NULL, 'o'},
		{NULL,          0,                 NULL,  0 },
	};
	while((option = getopt_long_only(argc, argv, short_options, long_options, &option_index)) != -1)
	{
		switch(option)
		{
			case 'h':
				print_usage(argv[0]);
				return 0;
			case 'm':
				strncpy(convert_mode, optarg, 128);
				break;
			case 'i':
				strncpy(inputFileName, optarg, 128);
				break;
			case 'o':
				strncpy(outputFileName, optarg, 128);
				break;
			defalut:
				printf("Unknown argument!\n");
				break;
		}
	}

	fpInput = fopen(inputFileName, "rb");
	if (fpInput == NULL)
	{
		perror("Open input file error");
		return -1;
	}
	fpOutput = fopen(outputFileName, "wb");
	if (fpOutput == NULL)
	{
		perror("Open output file error");
		return -1;
	}



	while(1)
	{
		/* read data */
		int readBytes = fread(inputBuf, 1, BUF_LEN, fpInput);
		if (readBytes <= 0)
		{
			break;
		}

		/* convert and write data */
		if(0 == strcmp(convert_mode, "pcm_2_alaw"))
		{
			pcm_2_alaw((const short *)inputBuf, outputBuf, readBytes/2);
			fwrite(outputBuf, 1, readBytes/2, fpOutput);
		}
		else if(0 == strcmp(convert_mode, "pcm_2_ulaw"))
		{
			pcm_2_ulaw((const short *)inputBuf, outputBuf, readBytes/2);
			fwrite(outputBuf, 1, readBytes/2, fpOutput);
		}
		else if(0 == strcmp(convert_mode, "alaw_2_pcm"))
		{
			alaw_2_pcm(inputBuf, (short *)outputBuf, readBytes);
			fwrite(outputBuf, 1, readBytes*2, fpOutput);
		}
		else if(0 == strcmp(convert_mode, "ulaw_2_pcm"))
		{
			ulaw_2_pcm(inputBuf, (short *)outputBuf, readBytes);
			fwrite(outputBuf, 1, readBytes*2, fpOutput);
		}
		else if(0 == strcmp(convert_mode, "alaw_2_ulaw"))
		{
			alaw_2_ulaw(inputBuf, outputBuf, readBytes);
			fwrite(outputBuf, 1, readBytes, fpOutput);
		}
		else if(0 == strcmp(convert_mode, "ulaw_2_alaw"))
		{
			ulaw_2_alaw(inputBuf, outputBuf, readBytes);
			fwrite(outputBuf, 1, readBytes, fpOutput);
		}
		else
		{
			printf("The convert mode is not supported!\n");
			goto error_exit;
		}
	}

	printf("\033[32m %s ==> %s Success!\033[0m\n", inputFileName, outputFileName);

error_exit:
	fclose(fpInput);
	fclose(fpOutput);

	return 0;
}

3、demo下载地址(任选一个)

  • https://download.csdn.net/download/weixin_44498318/89525479

  • https://gitee.com/linriming/audio_pcm_alaw_ulaw_g711_convert.git

  • https://github.com/linriming20/audio_pcm_alaw_ulaw_g711_convert.git

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/787258.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

192.168.1.1路由器管理系统使用教程

节选自&#xff1a;192.168.1.1路由器管理系统-厂商有哪些-如何使用-无法登录原因-苏州稳联 什么是 192.168.1.1 路由器管理系统&#xff1f; 192.168.1.1 是大多数家庭路由器的默认 IP 地址&#xff0c;用于访问路由器的管理控制台。通过这个管理系统&#xff0c;用户可以配…

Redis数据类型和数据队列

一.Redis数据类型 参考资料&#xff1a;http://www.redis.cn/topics/data-types.html 相关命令参考: http://redisdoc.com/ Redis 是一种基于内存的开源数据结构存储系统&#xff0c;支持多种数据类型&#xff0c;每种数据类型都有自己特定的操作命令。 String&#xff08;字…

Python 数据容器的对比

五类数据容器 列表&#xff0c;元组&#xff0c;字符串&#xff0c;集合&#xff0c;字典 是否能下标索引 支持&#xff1a;列表&#xff0c;元组&#xff0c;字符串 不支持&#xff1a;集合&#xff0c;字典 是否能放重复元素 是&#xff1a;列表&#xff0c;元组&#…

HTML5 学习笔记总结

1.1 什么是网页 1.2 什么是 HTML 1.3 网页总结 2.常用浏览器 3.Web 标准 3.1 为什么需要Web 标准 3.2 Web 标准&#xff08;重点&#xff09;

互联网医院系统,开发互联网医院设计哪些功能?

随着科技的进步和数字化转型的推动&#xff0c;互联网医院系统已成为现代医疗服务的重要组成部分。这一系统通过整合信息技术与医疗资源&#xff0c;为用户提供便捷、高效的医疗服务。以下是互联网医院系统的主要功能介绍。 1、在线咨询与诊断 互联网医院系统允许患者通过网络平…

南航秋招指南,线上测评和线下考试

南航秋招简介 南航作为国内一流的航空公司&#xff0c;对人才的需求量非常旺盛&#xff0c;每年也有很多专业对口的工作提供给应届毕业生&#xff0c;对于应届毕业生而言&#xff0c;一定要抓住任何一个应聘机会&#xff0c;并且在规定的范围内进行简历的提交&#xff0c;以便…

C++基础知识:数组,数组是什么,数组的特点是什么?一维数组的三种定义方式,以及代码案例

1.数组的定义&#xff1a; 数组&#xff0c;就是一个集合&#xff0c;里面存放了相同类型的数据元素 2.数组的特点&#xff1a; 特点1:数组中的每个数据元素都是相同的数据类型 特点2:数组是由连续的内存位置组成的 3. 一维数组定义方式 维数组定义的三种方式: 1.数据类型 …

C++相关概念和易错语法(17)(适配器模式、仿函数)

1.stack和queue stack和queue的相关接口如下&#xff1a; stack queue 我们发现不管是stack还是queue&#xff0c;它们都有push和pop&#xff0c;不区分push_back和push_front&#xff0c;这是由它们的入栈特定顺序特性决定的&#xff0c;并且它们都没有迭代器&#xff0c;st…

倒计时1天!飞思实验室暑期公益培训,7月10日不见不散

01培训背景 很荣幸地向大家宣布&#xff1a;卓翼飞思实验室将于7月10日正式开启为期两个月的暑期公益培训&#xff01;本次培训为线上直播&#xff0c;由中南大学计算机学院特聘副教授&#xff0c;RflySim平台总研发负责人戴训华副教授主讲。 培训将基于“RflySim—智能无人集…

每日刷题(二分查找,匈牙利算法,逆序对)

目录 1.Sarumans Army 2.Catch That Cow 3.Drying 4.P3386 【模板】二分图最大匹配 5. Swap Dilemma 1.Sarumans Army 3069 -- Sarumans Army (poj.org) 这道题就是要求我们在给的的位置放入 palantir&#xff0c;每个 palantir有R大小的射程范围&#xff0c;要求求出最少…

jitsi 使用JWT验证用户身份

前言 Jitsi Meet是一个很棒的会议系统,但是默认他运行所有人创建会议,这样在某种程度上,我们会觉得他不安全,下面我们就来介绍下使用JWT来验证用户身份 方案 卸载旧的lua依赖性sudo apt-get purge lua5.1 liblua5.1-0 liblua5.1-dev luarocks添加ubuntu的依赖源,有则不需…

住宅代理、移动代理和数据中心代理之间的区别

如果您是一名认真的互联网用户&#xff0c;可能需要反复访问某个网站或服务器&#xff0c;可能是为了数据抓取、价格比较、SEO 监控等用例&#xff0c;而不会被 IP 列入黑名单或被 CAPTCHA 阻止。 代理的工作原理是将所有传出数据发送到代理服务器&#xff0c;然后代理服务器将…

UML 2.5图的分类

新书速览|《UML 2.5基础、建模与设计实践》新书速览|《UML 2.5基础、建模与设计实践 UML 2.5在UML 2.4.1的基础上进行了结构性的调整&#xff0c;简化和重新组织了 UML规范文档。UML规范被重新编写&#xff0c;使其“更易于阅读”&#xff0c;并且“尽可能减少前向引用”。 U…

Mock 测试技术

一、Mock 类框架的使用场景 在实际软件开发中&#xff0c;要进行测试的方法存在外部依赖&#xff08;如 db&#xff0c;redis&#xff0c;第三方接口调用等&#xff09;&#xff0c;这些外部依赖可能存在各种问题&#xff0c;例如不稳定、缺乏数据、难以模拟等等&#xff0c;所…

C++中的多重继承和虚继承:横向继承、纵向继承和联合继承;虚继承

多重继承 A.横向多重继承&#xff1a; B.纵向多重继承&#xff1a; C.联合多重继承&#xff1a; 因为 single 和 waiter 都继承了一个 worker 组件&#xff0c;因此 SingingWaiter 将包含两个 worker 组件&#xff0c;那么将派生类对象的地址赋给基类指针将出现二义性 那么如何…

使用F1C200S从零制作掌机之debian文件系统完善NES

一、模拟器源码 源码&#xff1a;https://files.cnblogs.com/files/twzy/arm-NES-linux-master.zip 二、文件系统 文件系统&#xff1a;debian bullseye 使用builtroot2018构建的文件系统&#xff0c;使用InfoNES模拟器存在bug&#xff0c;搞不定&#xff0c;所以放弃&…

Git 快速上手

这个文档适用于需要快速上手 Git 的用户&#xff0c;本文尽可能的做到简单易懂 ❤️❤️❤️ git 的详细讲解请看这篇博客 Git 详解&#xff08;原理、使用&#xff09; 1. 什么是 Git Git 是目前最主流的一个版本控制器&#xff0c;并且是分布式版本控制系统&#xff0c;可…

k8s中port,targetPort,nodePort,containerPort的区别

一、说明 在 Kubernetes 中&#xff0c;port、targetPort、nodePort 和 containerPort 是用于定义服务&#xff08;Service&#xff09;和容器之间网络通信的不同参数。 它们各自的作用和含义如下&#xff1a; 1. port 定义&#xff1a;这是服务对外暴露的端口号。作用&#x…

树莓派_Pytorch学习笔记20:初步认识深度学习框架

今日继续学习树莓派4B 4G&#xff1a;&#xff08;Raspberry Pi&#xff0c;简称RPi或RasPi&#xff09; 本人所用树莓派4B 装载的系统与版本如下: 版本可用命令 (lsb_release -a) 查询: ​ Python 版本3.7.3&#xff1a; ​ 本文很水&#xff0c;就介绍一下我以后的学习使用P…

【JavaEE】 简单认识CPU

&#x1f435;本篇文章将对cpu的相关知识进行讲解 一、认识CPU 下图是简略的冯诺依曼体系结构图 上图中&#xff0c;存储器用来存储数据&#xff0c;注意在存储器中都是以二进制的形式存储数据的&#xff0c;CPU就是中央处理器&#xff0c;其功能主要是进行各种算术运算和各种…