XDecode
XDecode.h
Send 函数用于向解码器发送编码数据包。
Recv 函数用于从解码器接收解码后的帧数据。
InitHW 函数用于初始化硬件加速设备。
End 函数用于获取解码器中剩余的所有帧数据。
123456789101112131415#pragma once#include "xcodec.h"struct AVBufferRef;class XDecode :public XCodec{public: bool Send(const AVPacket* pkt); bool Recv(AVFrame* frame); std::vector<AVFrame*> End(); // 初始化硬件加速 // 默认AV_HWDEVICE_TYPE_DXVA2 值为4 bool InitHW(int type = 4); };
AVHWDeviceType:int type = 4代表AV_HWDEVICE_TYPE_DXVA2
123456789101112131415enum AVHWDeviceType { ...
XEncode
XEncode.h
作用:继承于XCodec,用于编码
12345678910#pragma once#include "xcodec.h"class XEncode:public XCodec{public: AVPacket *Encode(const AVFrame* frame); std::vector<AVPacket *> End();};
AVPacket
是 FFmpeg 库中的一个数据结构,主要用于存储编码后的音频或视频数据包。
在多媒体处理中,数据包通常包含一个完整的编码帧或部分编码帧的比特流数据。
这些数据包可以用于传输、存储或进一步处理,如解码。
123456789101112131415161718typedef struct AVPacket { uint8_t *data; // 指向实际存储编码数据的缓冲区 int size; // 缓冲区中数据的大小,以字节为单位 int64_t pts; // 显示时间戳 int64_t dts; // 解码时间 ...
XCodec
XCodec
作用:编码和解码的基类
1234567891011121314151617181920212223242526272829303132#pragma once#include <mutex>#include <vector>extern "C" {#include <libavcodec/avcodec.h>#include <libavutil/avutil.h>}struct AVCodecContext;struct AVPacket;struct AVFrame;class XCodec{public: static AVCodecContext* Create(int codec_id, bool is_encode); void set_c(AVCodecContext* c); bool SetOpt(const char* key, const char* val); bool SetOpt(const char* key, int val); bool Op ...
XSDL
SDL介绍
SDL(Simple DirectMedia Layer)是一个跨平台的多媒体开发库,广泛用于游戏开发和多媒体应用的创建。它提供了对音频、键盘、鼠标、游戏控制器、图形和窗口的底层访问,从而使开发者能够编写高性能的多媒体应用程序。SDL被许多流行的游戏和软件项目所使用。
SDL的主要特点
跨平台支持: SDL支持多个操作系统,包括Windows、Mac OS、Linux、iOS和Android等,使得开发者能够编写一次代码,运行在多个平台上。
简化多媒体处理: SDL提供了对音频、视频、输入设备、计时器等多媒体功能的简化接口,使开发者不需要处理底层系统的细节。
硬件加速: SDL支持使用OpenGL、Direct3D等图形库进行硬件加速,从而提高图形渲染的性能。
模块化设计: SDL的功能被划分为多个模块,如视频、音频、事件处理、线程、文件I/O等,开发者可以按需使用。
XSDL.h
12345678910111213141516171819202122232425262728293031#pragma once#include "xvideo_view.h&q ...
XVideoView
XVideoView.h
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182#ifndef XVIDEO_VIEW_H#define XVIDEO_VIEW_H#include <mutex>#include <fstream>#include "xtools.h"struct AVFrame;class XVideoView{public: enum Format { YUV420P = 0, NV12 = 23, ARGB = 25, RGBA = 26, BGRA = 28 }; enum RenderType { SDL = 0 }; static XVideoView* Create(RenderType type= ...
ffmpeg
基础配置
头文件 include
库文件 lib lib/x86 x64
动态库文件 dll bin/x86 x64
调式执行和pdb路径 bin/x86 x64
源码项目路径 src/first_ffmpeg
ffmpeg源码 tools
将文件配置进入项目中
(以Visual Studio 2017为例)
YUV格式
YUV444
表示$4:4:4$的YUV取样。
每个像素都有独立的Y、U、V分量。
每一个像素Y占一个字节,U占一个字节,V占一个字节,因此每个像素占:
$$1 (Y)×8 bits+1 (U)×8 bits+1 (V)×8 bits=24 bits/pixel (bpp)$$
以$2\times 2$的图像为例
1234像素1:Y1, U1, V1像素2:Y2, U2, V2像素3:Y3, U3, V3像素4:Y4, U4, V4
YUV422
表示$4:2:2$的YUV取样。
每相邻两个像素每个像素占一个Y,共享一个U和一个V,因此两个像素占:
$$2 (Y)×8 bits+1 (U)×8 bits+1 (V)×8 bits=32 bits$$
每个 ...
英语作文
小作文
开头
This is Li Ming. I am writing this letter with my full heart for the purpose of putting forward some suggestion
我是李明,我写此信的目的是为了提一些建议
As one ordinary resident living here for more than twenty years, I feel obligated to write this very letter to state my concern over the increasingly deteriorating environmental situation.
作为一个在这里生活了二十来年的普通居民,我觉得有必要写下此信来陈述我的担心,关于日益恶化的环境现状。
On behalf of the Postgraduate Association, we are formally announcing that volunteers are needed.
谨代表研究生协会,我们正式宣布,招聘志愿者 ...
AcWing Web课
html基础标签
有疑问查询MDN:https://developer.mozilla.org/zh-CN/
html文件结构
文档结构
html的所有标签为树形结构,例如:
1234567891011<!DOCTYPE html><html lang="zh-CN"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Web应用课</title></head><body> <h1>第一讲</h1></body></html>
<html></html>:类似于根节点。
<body></body>、<title> ...
AcWing.3765 表达式树
请设计一个算法,将给定的表达式树(二叉树)转换为等价的中缀表达式(通过括号反映操作符的计算次序)并输出。
例如,当下列两棵表达式树作为算法的输入时:
输出的等价中缀表达式分别为 (a+b)*(c*(-d)) 和 (a*b)+(-(c-d))。
注意:
树中至少包含一个运算符。
当运算符是负号时,左儿子为空,右儿子为需要取反的表达式。
树中所有叶节点的值均为非负整数。
样例:
输入:二叉树[+, 12, *, null, null, 6, 4, null, null, null, null]如下图所示:
+
/ \
12 *
/ \
6 4
输出:12+(6*4)
数据范围
给定二叉树的非空结点数量保证不超过 $1000$。
给定二叉树保证能够转化为合法的中缀表达式。
时间复杂度
为$O(n^2)$
因为C++中字符串return并不是直接返回,而是先复制一遍再返回。
为了优化,可以不适用return进行返回,而是定义一个全局变量ans来记录最终的答案。
Code
未优化的,时间复杂度:$O(n^2)$
1234567891011121 ...
AcWing.18 重建二叉树
输入一棵二叉树前序遍历和中序遍历的结果,请重建该二叉树。
注意:
二叉树中每个节点的值都互不相同;
输入的前序遍历和中序遍历一定合法;
数据范围
树中节点数量范围 $[0,100]$。
样例
给定:
前序遍历是:[3, 9, 20, 15, 7]
中序遍历是:[9, 3, 15, 20, 7]
返回:[3, 9, 20, null, null, 15, 7, null, null, null, null]
返回的二叉树如下所示:
3
/ \
9 20
/ \
15 7
Code
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 /*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left; ...