AC-3 support gets back again in VLC for iOS

A year ago, VLC on iOS was forced to remove its support for AC3 codec. I found almost all my videos on iPad were muted.

Since then, I haven’t bothered to check other options. I don’t mind paying a few dollars but I’ve been using VLC since years on all of my computers and mobile phones. There’s simply no other comparable alternatives that works equally well on Windows, Linux, OS X as well as iOS.

Today, I opened VLC on my iPhone again and noticed that I can play my videos with sound again! I checked the official website for sure and got this:

https://forum.videolan.org/viewtopic.php?f=36&t=124115&sid=c0ad097c62e429e8e5fe5f68aa14fc54&start=20#p441786

The link on iTunes also confirmed this. However, nowhere did I find details how did the developers solved the patent issue. Let’s hope it’s fixed for good.

中国古诗文

正在考虑建立一个中国古诗文网站,目的是给孩子看,类似于《唐诗三百首》和《古文观止》,内容也多从其中来。特色在于:

  • 在内容上,以原文为本。不要译文,基本没有注释。
  • 在布局上,以内容为主,去除一切干扰因素。要求干净,大方。
  • 各古诗文名家作者就是blog作者,既直观有趣,又方便组织。

需要做的工作:

  1. 开发批量插入作者的功能——已完成;
  2. 开发批量插入帖子的功能——已完成;
  3. 建立分类目录:需要专业人员帮助。
  4. 开发新的数据结构以存储传统计时方式:朝代,年号,年号纪年,公元纪年,季节,时令,时辰。
  5. 扩展帖子属性,其中帖子发表时间采用新的数据结构。
  6. 扩展作者属性,其中作者生卒时间采用新的数据结构。
  7. 修改界面,使帖子能够显示传统计时(年号,天干地支)。

当前状态见这里:http://gushiwen.genglinxiao.com/

中国地图坐标(GCJ-02)偏移算法破解小史

2006年,Google开始与AutoNavi合作使用后者所提供的中国地图。这应该是外企首次接触到这个问题。

从2009年开始,中国地图的坐标偏移开始为外界所知。Garmin的用户发现在美国购买的GPS到了中国几乎无法使用,而在中国购买的Garmin产品则没有问题。Google Maps API的使用者发现兴趣点无法被准确标注在中国地图上。更有意思的是,有用户反复就此报告bug给Google,却从未得到任何回应。类似的,Garmin也声称自己没有解决方案,建议客户在需要的情况下在中国境内购买GPS设备。

于此同时,各路豪杰开始尝试破解这种偏移算法。其中有两条路径值得注意:

2010年1月,网友wuyongzheng发现:

I accidentally found the Chinese version of Google Map ditu.google.com to be able to correlate satellite image with map, and it gives the amount of deviation for any location in China. This URL queries the deviation of 34.29273N,108.94695E (Xi’an): http://ditu.google.com/maps/vp?spn=0.001,0.001&t=h&z=18&vp=$34.29273,108.94695 (seems it’ doesn’t work now)

有了足够的数据,wuyongzheng建议使用回归算法来逼近这个偏移算法:https://wuyongzheng.wordpress.com/2010/01/22/china-map-deviation-as-a-regression-problem/

在此之前的尝试都是零星的,针对个别城市的。wuongzheng的这个建议算是在全面系统地解决这个问题上迈出了第一步。

2013年5月,Maxime Guilbot根据这个建议得到4-5米精度的逼近:

https://github.com/maxime/ChinaMapDeviation

2013年10月,wuyongzheng自己进行了回归,得到如下结果:

http://wuyongzheng.github.io/china-map-deviation/paper.html

Maxime Guibot和wuyongzheng的回归结果基本代表了在黑暗中摸索的最佳结果,因此得到了广泛的注意和应用。

在另一条路径上,2010年4月,emq project增加了一个文件,Converter.java:

http://emq.googlecode.com/svn/emq/src/Algorithm/Coords/Converter.java

这段代码可以以很高的精度把WGS-84坐标转换到GCJ-02坐标。

2013年2月,这段代码被网友coolypf注意到,整理后用到了他自己的项目中:

https://on4wp7.codeplex.com/SourceControl/changeset/view/21483#353936

其中的关键代码值得贴在这里:

        const double pi = 3.14159265358979324;

        //
        // Krasovsky 1940
        //
        // a = 6378245.0, 1/f = 298.3
        // b = a * (1 - f)
        // ee = (a^2 - b^2) / a^2;
        const double a = 6378245.0;
        const double ee = 0.00669342162296594323;

        //
        // World Geodetic System ==> Mars Geodetic System
        public static void transform(double wgLat, double wgLon, out double mgLat, out double mgLon)
        {
            if (outOfChina(wgLat, wgLon))
            {
                mgLat = wgLat;
                mgLon = wgLon;
                return;
            }
            double dLat = transformLat(wgLon - 105.0, wgLat - 35.0);
            double dLon = transformLon(wgLon - 105.0, wgLat - 35.0);
            double radLat = wgLat / 180.0 * pi;
            double magic = Math.Sin(radLat);
            magic = 1 - ee * magic * magic;
            double sqrtMagic = Math.Sqrt(magic);
            dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
            dLon = (dLon * 180.0) / (a / sqrtMagic * Math.Cos(radLat) * pi);
            mgLat = wgLat + dLat;
            mgLon = wgLon + dLon;
        }

2013年3月,coolypf在自己的博客中介绍了这一段代码:

http://blog.csdn.net/coolypf/article/details/8686588

2014年9月,wuyongzheng注意到了coolypf的项目。至此,两条路径合流,坐标偏移问题基本得到了完美解决。

从上面的代码可以看出,相对于WGS-84,GCJ-02一方面采用了不同的参考椭球体(SK-42, Krasovsky。应该属于前苏联影响的遗留),另一方面引入了高频非线性偏移。

笔记

搜索神经网络的最新进展,看到wiki上说:

Between 2009 and 2012, the recurrent neural networks and deep feedforward neural networks developed in the research group of Jürgen Schmidhuber at the Swiss AI Lab IDSIA have won eight international competitions in pattern recognition and machine learning.[12][13] For example, the bi-directional and multi-dimensional long short term memory (LSTM)[14][15][16][17] of Alex Graves et al. won three competitions in connected handwriting recognition at the 2009 International Conference on Document Analysis and Recognition (ICDAR), without any prior knowledge about the three different languages to be learned.

http://en.wikipedia.org/wiki/Artificial_neural_network#Improvements_since_2006

赶快搜索了Jürgen Schmidhuber,然后看了一些视频,居然又联系到了Kolmogorov complexity,深度学习,可计算宇宙,智能,创造力,以及Gödel。。。。现在脑子还是一团浆糊,不过隐隐感觉到Jürgen可能会改变历史。。。。至少他的演讲很有趣:

心肺停止的紧急救治

早上听BBC Reith Lecture,Doctor Atul Gawande提到一个紧急救治的案例:奥地利一个三岁的小女孩在跟父母散步的时候跑到结冰的池塘上,然后落入开裂的冰面了。父母紧跟过去,但是也只是在30分钟之后才找到她。把她打捞上来时她已经完全失去知觉了——体温非常低,没有呼吸,没有心跳,瞳孔散开,对光线没有反应。

Consider a case report in The Annals of Thoracic Surgery of a three-year-old girl who fell into an icy fishpond in a small Austrian town in the Alps. She was lost beneath the surface for thirty minutes before her parents found her on the pond bottom and pulled her up. Following instructions from an emergency physician on the phone, they began cardiopulmonary resuscitation. A rescue team arrived eight minutes later. The girl had a body temperature of sixty-six degrees, and no pulse. Her pupils were dilated and did not react to light, indicating that her brain was no longer working.

但是救助团队坚持继续救治:

But the emergency technicians continued CPR anyway. A helicopter took her to a nearby hospital, where she was wheeled directly to an operating room. A surgical team put her on a heart-lung bypass machine. Between the transport time and the time it took to plug the inflow and outflow lines into the femoral vessels of her right leg, she had been lifeless for an hour and a half. By the two-hour mark, however, her body temperature had risen almost ten degrees, and her heart began to beat. It was her first organ to come back.

After six hours, her core temperature reached 98.6 degrees. The team tried to put her on a breathing machine, but the pond water had damaged her lungs too severely for oxygen to reach her blood. So they switched her to an artificial-lung system known as ECMO—extracorporeal membrane oxygenation. The surgeons opened her chest down the middle with a power saw and sewed lines to and from the ECMO unit into her aorta and her beating heart. The team moved the girl into intensive care, with her chest still open and covered with plastic foil. A day later, her lungs had recovered sufficiently for the team to switch her from ECMO to a mechanical ventilator and close her chest. Over the next two days, all her organs recovered except her brain. A CT scan showed global brain swelling, which is a sign of diffuse damage, but no actual dead zones. So the team drilled a hole into the girl’s skull, threaded in a probe to monitor her cerebral pressure, and kept that pressure tightly controlled by constantly adjusting her fluids and medications. For more than a week, she lay comatose. Then, slowly, she came back to life.

First, her pupils started to react to light. Next, she began to breathe on her own. And, one day, she simply awoke. Two weeks after her accident, she went home. Her right leg and left arm were partially paralyzed. Her speech was thick and slurry. But by age five, after extensive outpatient therapy, she had recovered her faculties completely. She was like any little girl again.

from: http://www.newyorker.com/magazine/2007/12/10/the-checklist

我就搜索了一下,这样的案例还不止一例,还有更有名的:

http://en.wikipedia.org/wiki/Anna_B%C3%A5genholm

大概看了一下,有几个要点:

  • 坚持CPR非常重要
  • 体温低,这使得各脏器,尤其是大脑不必消耗太多氧气,这样即使呼吸停止,脏器和大脑也不会被破坏;
  • 救治过程首先上体外循环机,逐步升高体温(体温升高太快会破坏红细胞)。心脏恢复搏动则循环系统恢复;
  • 然后上人工肺和呼吸机,确保氧能够进入循环系统;
  • 心肺都恢复之后可以恢复其他脏器;
  • 大脑没有因为缺氧而坏死,恢复的希望也很大,只是需要时间。

所以,其实冬天落水比夏天落水存活概率更高。只是不知道这次“东方之星”的救助能不能从中得到启发。。。

 

Office Open XML小试

尝试了一下微软的Office Open XML,发现功能是挺全面了,很多之前用Word宏实现的自动化操作,可以用Office Open XML实现了,微软的Office总算在开放性方面迈出了一大步。

顺便仔细看了一下docx的实现,这xml可是够复杂的,不知道为什么微软要设计成这样样子:-(。

即使使用Office Open XML,要想插入一个脚注格式,需要增加三层xml elements:

XmlElement element1 = xd1.CreateElement(“w”, “r”, Class1.namespaceURI);
XmlElement element2 = xd1.CreateElement(“w”, “rPr”, Class1.namespaceURI);
XmlElement element3 = xd1.CreateElement(“w”, “vertAlign”, Class1.namespaceURI);
element3.SetAttribute(“val”, Class1.namespaceURI, “superscript”);
element2.AppendChild((XmlNode) element3);
element1.AppendChild((XmlNode) element2);

这三个元素分别是run,就是一段格式一致的文字;rPr是run property,代表这一段文字的格式属性集合;vertAlign就是Vertical Alignment垂直方向的对齐属性。。。

有时间考虑用Linux + Mono处理word文件,就比Windows灵巧的多了。

泊松分布在容量管理中的应用

其实是泊松分布的经典应用:

已知某呼叫中心每小时会进ci个电话,每个电话平均时长为tp,则在任意给定时刻,并发电话的为x的概率服从泊松分布。此处假设不同的电话是完全独立事件。

并发电话为x的概率,等同于在tp时长内,进入x路电话的概率。在tp时长内,平均会进的电话数为tp*ci。因此,并发电话小于或等于x的概率为(excel公式):

POISSON(x,tp*ci,TRUE)

其中最后一个参数TRUE,表明这里计算的是并发电话小于或者等于x的概率;如果用FALSE,则只计算等于x的概率。

此公式可用于呼叫中心容量规划,比如:如果已知呼叫量和平均通话时长,则要确保容量在99%的情况下够用,则只需求x,使得POISSON(x,tp*ci,TRUE)>0.99。

在某呼叫中心,把历史数据应用了一下,符合度很高:

call_vol_verification

其中横轴是时间,黄色为实际并发量,蓝色为按照0.999计算出的并发量上限。

如果把横轴改成按照实际并发量排序,则得到:

call_vol_verification_2

可以看到实际并发量几乎总是在预计容量之下。几个实际并发量高于预计容量的情况,后来证实都是系统出了故障,导致客户竞相反复拨打,意味着不仅原来的参数不再适用,独立同分布的假设也不再适用。