1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | void nv212Yv12(char *nv21, char *yv12, int width, int height) { int frameSize = width * height; memcpy(yv12, nv21, frameSize); nv21 += frameSize; yv12 += frameSize; int halfWidth = width / 2; int halfHeight = height / 2; int quadFrame = halfWidth * halfHeight; for (int i = 0; i < halfHeight; i++) { for (int j = 0; j < halfWidth; j++) { *(yv12 + i * halfWidth + j) = *nv21++; *(yv12 + quadFrame + i * halfWidth + j) = *nv21++; } } } void yv122Nv21(char *yv12, char *nv21, int width, int height) { int frameSize = width * height; memcpy(nv21, yv12, frameSize); nv21 += frameSize; yv12 += frameSize; int halfWidth = width / 2; int halfHeight = height / 2; int quadFrame = halfWidth * halfHeight; for (int i = 0; i < halfHeight; i++) { for (int j = 0; j < halfWidth; j++) { *nv21++ = *(yv12 + i * halfWidth + j); *nv21++ = *(yv12 + quadFrame + i * halfWidth + j); } } } |
Month: October 2018
NDK硬解h264
有几点须注意,
- 不要让硬解码器自已绘制表面,也就是AMediaCodec_configure传入的surface应设为空。否则运行时间长了,会出现“weak global reference table overflow”的崩机错误。
- 我之前文章里也说过了,不要静态链编libmediandk.so,老的安卓机上没有这个库,要动态检测加载,详细过程见之后代码。
- AMediaCodec_dequeueInputBuffer不是每一次都返回成功,如果失败了而丢弃h264数据帧,则最终的播放效果就时不时出现花屏,正确处理见之后代码。
- 硬解码器解出的数据默认可能是NV12格式也可能是YV12格式,不同的手机不一样,预先配置解码器的"color-format"为19,也没用。为了与ffmpeg解出的数据一致为YU12格式,统一地我们自已转。
以下是源码,摘选自EuhatRtsp开源软件,经历过长时间拷机运行没问题。其网址是:http://euhat.com/rtsp.html
DecoderHard.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #pragma once #include "DecodeOp.h" class AMediaCodec; class EuhatDecoderHard : public EuhatDecoderBase { int updateSpsAndPps(); int spsChanged_; int ppsChanged_; char *sps_; char *pps_; int width_; int height_; int oriHeight_; int colorFormat_; int stride_; int sliceHeight_; int cropTop_; int cropBottom_; int cropLeft_; int cropRight_; int isCodecInited_; void *surface_; int surfaceChanged_; public: EuhatDecoderHard(); virtual ~EuhatDecoderHard(); virtual int init(EuhatDecoderCallback callback, void *context); virtual int fini(); virtual int updateSps(const char *sps); virtual int updatePps(const char *pps); virtual int updateWH(int width, int height); virtual int updateSurface(void *surface); virtual int decode(char *frame, int frameLen); static int canWork(); AMediaCodec *mediaCodec_; }; |
数据结构好文推荐
红黑树演示 https://sandbox.runjs.cn/show/2nngvn8w 有哪些最新的机器学习可视化工具? https://www.toutiao.com/a6567983574299967757/ NDK-FFmpeg视频解码 http://www.imooc.com/article/80058 RSA加密原理 http://blog.jobbole.com/42699/ |
学英语之来自巴菲特
A simple rule dictates my buying: Be fearful when others are greedy, and be greedy when others are fearful. And most certainly, fear is now widespread, gripping even seasoned investors. To be sure, investors are right to be wary of highly leveraged entities or businesses in weak competitive positions. But fears regarding the long-term prosperity of the nation's many sound companies make no sense. These businesses will indeed suffer earnings hiccups, as they always have. But most major companies will be setting new profit records 5, 10 and 20 years from now.
U.S. Corporate Debt Outstanding as a % of GDP
for a spin
IBM’s acquisition of Red Hat is huge news for the Linux world
We are devastated to learn of the tragic passing of a member of our Googler family. On Monday night, our colleague Emily Hong passed away after being struck by a shuttle bus on our Mountain View campus. Emily worked in the finance organization and was beloved by her colleagues -- she brought an incredible spark to Google. She was inquisitive, creative, analytical, positive, generous and kind -- our deepest condolences are with
why ea is committed to the amiga.
As illustrated in below, draw rays from 0 through Z(t) and Z(t+1), together with circular arcs (centred at 0) through those points.
Recovering from our feigned bout of amnesia concerning complex numbers and their geometric interpretation, Cotes' result becomes simple to understand and to prove.
striped triangle
However, not any old mapping qualifies as motion, for we must also capture the idea of the sheet remaining rigid while it moves.
Armed with this precise concept of motion, our final definition of geometric equality becomes...
buf for the moment we wish only to explain how Klein was able to generalize the above ideas so as to embrace such new geometries.
But will this type of equality behave in the way we would like and expect?
If M and N are members of G then so is the composite transformation.
If two transformations do not alter distances, then applying them in succession will not alter distances either.
Pythons kill by tightening their coils so that their victim cannot breathe.
Many private colleges are coining it.
Jaron Lanier coined the term 'virtual reality' and pioneered its early development.
These findings are a reminder that low pay is the other side of the coin of falling unemployment.
Plant them in a coarse, well-draining soil mix with lots of coir and sphagnum moss.
In a full-throated defence of America’s forward-leaning stance abroad, John F. Kerry, US Secretary of State, hit back at critics who have claimed that the United States is disengaging from world affairs. “I want to make it clear that nothing could be further from the truth,” said Kerry.
produce the two segments till they meet at M.
the chord AA' subtends the same angle at every point of the circular arc.
They are just two examples of hapless mathematicians who would have been dismayed to examine the notebooks.
The image f(z) of a point z may be described by its distance |f(z)| from the origin, and the angle arg[f(z)] it makes with the real axis.
This readily comprehensible result is illustrated in below, ignore the shaded disc for the time being.
it would smack of circular reasoning if we were to assume it while following our new approach.
empirically, appeal to the familiar reflection property of the conic sections.
if n is an integer then the branch point is (n - 1), More generally, the same is true for any fraction.
Notice, incidentally, that all three branches display the by now ubiquitous (yet mysterious) preservation of small squares.
Provisionally, we now take S to be the plane with the points of C removed.
the branch cut C is the work of man - the multifunction is oblivious to our desire to dissect it into three functions.
rays go due west.
intimadate
intimate
he first studied the transformations that now bear his name, it is fair to say that the rich vein of knowledge which he thereby exposed is still far from being exhausted. For this reason, we shall investigate the transformations in considerably greater depth than is customary.
Check for yourself that the order in which we apply these mappings is immaterial.
the result is true without qualification.
We should explain that this is not generalization for its own sake; soon we will see how this three-dimensional inversion sheds new light on two-dimensional inversion.
If the conformality of an otherwise conformal mapping breaks down at a particular point p, then p is called a critical point of the mapping.
Thus instead of merely saying that f(z) "dies away to zero like (1/(z^2)) as z tends to infinity", we can now say (more precisely) that f(z) has a double root at z = infinity.
From the similarity of the illustrated right triangles with hypotenuses Nz1 and Nz, we immediately deduce that.
beside oneself
how is it that you can't count?
Android Handler and Runnable
Runnable并不是一个线程,它是Thread运行过程中的一个片断。
以下例子是创建子线程获取图片后发送给UI线程显示,第一个Runnable运行在子线程中,第二个Runnable运行在UI线程中:
1 2 3 4 5 6 7 8 9 10 11 12 | public void onClick(View v) { new Thread(new Runnable() { // 第一个Runnable public void run() { final Bitmap bitmap = loadImageFromNetwork("http://example.com/image.png"); mImageView.post(new Runnable() { // 第二个Runnable public void run() { mImageView.setImageBitmap(bitmap); } }); } }).start(); } |
而Handler与线程的绑定有两种方式。
第一种是与当前线程绑定:
1 | public Handler handler = new Handler(); |
第二种是指定线程绑定:
1 | handler = new Handler(thread.getLooper()); |
临时改网卡mac地址
linux下:
1 | ifconfig eth0 hw ether 3a:30:34:3a:34:44 |
MFC重绘控件
举个按钮简单重绘的例子。
头文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | class CMyButton : public CButton { public: virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); }; class CMFCApplication1Dlg : public CDialogEx { ... protected: virtual void DoDataExchange(CDataExchange* pDX); CMyButton m_myButton; ... }; |
ultraiso虚拟光驱总是删除不干净
用regedit查找ultraiso,找到PropertyStore结点下有个结点中含有
Users\euhat\AppData\Local\Temp\UltraISO\UltraISO.exe
在资源管理器中找到相应目录,发现如下文件删不掉。
C:\Users\euhat\AppData\Local\Temp\UltraISO\drivers\ISODrv64.sys
则,再次运行ultraiso程序,选项->配置->虚拟光驱->设备数量设为0,保存。退出ultraiso程序。
再regedit查找ultraiso,找到
1 | 计算机\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\ISODrive |
删除此键,退出regedit,重启电脑就能看到在资源管理器里,烦人的虚拟光驱盘符去掉了。
记得上面提到的ISODrv64.sys现在可以删掉。