H264 Profiles

Baseline Profile (BP)

Primarily for lower-cost applications with limited computing resources, this profile is used widely in videoconferencing and mobile applications.

Main Profile (MP)

Originally intended as the mainstream consumer profile for broadcast and storage applications, the importance of this profile faded when the High profile was developed for those applications.

Extended Profile (XP)

Intended as the streaming video profile, this profile has relatively high compression capability and some extra tricks for robustness to data losses and server stream switching.

High Profile (HiP)

The primary profile for broadcast and disc storage applications, particularly for high-definition television applications (this is the profile adopted into HD DVD and Blu-ray Disc, for example).

High 10 Profile (Hi10P)

Going beyond today’s mainstream consumer product capabilities, this profile builds on top of the High Profile—adding support for up to 10 bits per sample of decoded picture precision.

High 4:2:2 Profile (Hi422P)

Primarily targeting professional applications that use interlaced video, this profile builds on top of the High 10 Profile—adding support for the 4:2:2 chroma subsampling format while using up to 10 bits per sample of decoded picture precision.

High 4:4:4 Predictive Profile (Hi444PP)

This profile builds on top of the High 4:2:2 Profile—supporting up to 4:4:4 chroma sampling, up to 14 bits per sample, and additionally supporting efficient lossless region coding and the coding of each picture as three separate color planes.

H.264 Levels

Levelnumber Max macroblocksper second Max frame size (macroblocks) Max video bit rate (VCL)for Baseline,Extended and Main Profiles Max video bit rate (VCL)for High Profile Max video bit rate (VCL) for High 10 Profile Max video bit rate(VCL)for High 4:2:2 and High 4:4:4 Predictive Profiles Examples for high resolution @frame rate(max stored frames)in Level
1 1485 99 64 kbit/s 80 kbit/s 192 kbit/s 256 kbit/s 128×[email protected] (8)176×[email protected] (4)
1b 1485 99 128 kbit/s 160 kbit/s 384 kbit/s 512 kbit/s 128×[email protected] (8)176×[email protected] (4)
1.1 3000 396 192 kbit/s 240 kbit/s 576 kbit/s 768 kbit/s 176×[email protected] (9)320×[email protected] (3)352×[email protected] (2)
1.2 6000 396 384 kbit/s 480 kbit/s 1152 kbit/s 1536 kbit/s 320×[email protected] (7)352×[email protected] (6)
1.3 11880 396 768 kbit/s 960 kbit/s 2304 kbit/s 3072 kbit/s 320×[email protected] (7)352×[email protected] (6)
2 11880 396 2 Mbit/s 2.5 Mbit/s 6 Mbit/s 8 Mbit/s 320×[email protected] (7)352×[email protected] (6)
2.1 19800 792 4 Mbit/s 5 Mbit/s 12 Mbit/s 16 Mbit/s 352×[email protected] (7)352×[email protected] (6)
2.2 20250 1620 4 Mbit/s 5 Mbit/s 12 Mbit/s 16 Mbit/s 352×[email protected](10)352×[email protected] (7)720×[email protected] (6)720×[email protected] (5)
3 40500 1620 10 Mbit/s 12.5 Mbit/s 30 Mbit/s 40 Mbit/s 352×[email protected](12)352×[email protected] (10)720×[email protected] (6)720×[email protected] (5)
3.1 108000 3600 14 Mbit/s 17.5 Mbit/s 42 Mbit/s 56 Mbit/s 720×[email protected](13)720×[email protected](11)1280×[email protected](5)
3.2 216000 5120 20 Mbit/s 25 Mbit/s 60 Mbit/s 80 Mbit/s 1280×[email protected](5)1280×[email protected](4)
4 245760 8192 20 Mbit/s 25 Mbit/s 60 Mbit/s 80 Mbit/s 1280×[email protected](9)1920×[email protected](4)2048×[email protected](4)
4.1 245760 8192 50 Mbit/s 50 Mbit/s 150 Mbit/s 200 Mbit/s 1280×[email protected](9)1920×[email protected](4)2048×[email protected](4)
4.2 522240 8704 50 Mbit/s 50 Mbit/s 150 Mbit/s 200 Mbit/s 1920×[email protected](4)2048×[email protected](4)
5 589824 22080 135 Mbit/s 168.75 Mbit/s 405 Mbit/s 540 Mbit/s 1920×[email protected](13)2048×[email protected](13)2048×[email protected](12)2560×[email protected](5)3680×1536/26.7 (5)
5.1 983040 36864 240 Mbit/s 300 Mbit/s 720 Mbit/s 960 Mbit/s 1920×[email protected](16)4096×[email protected](5)4096×[email protected](5)

MBP vs RMBP

1

2

3

4

5

6

7

8

9

10

11

12

13

结论:

  • rmbp和mbp基本不属于同一个时代的东西
  • rmbp轻、薄、质感
  • rmbp的屏幕细腻,非常舒服
  • i7 + 512GB SSD + 16GB MEM 的结果就是各种快~~
  • 感谢“土豪”兄弟提供的“豪配版rmbp” ^_^

部署 servlet

OS : ubuntu 12.04

Tomcat : tomcat7

  • 进入Tomcat7默认安装目录为/var/lib/tomcat7

  • cd /var/lib/tomcat7
    
  • 进入webapps,并在该目录下新建一个自己的项目名称

  • cd webapps
    mkdir streamserver #这里自己取的项目名为streamserver
    
  • 进入streamserver,新建WEB-INF目录

  • cd streamserver
    mkdir WEB-INF
    
  • 在WEB-INF目录中需要建立一些固定的目录和web.xml文件

  • cd WEB-INF
    mkdir classes #所有要用到的java类都要放到这里
    touch web.xml
    
  • 拷贝项目的类文件到classes目录

  • classes中的目录结构需要跟项目的目录结构一致,这里假设类名为net.lnmcc.streamserver.StreamServer

  • cp  -av projectpath/bin/net/lnmcc/streamserver/*  /var/lib/tomcat7/webapps/streamserver/WEB-INF/classes/net/lnmcc/streamserver/ 
    
  • 编写web.xml文件

  • <?xml version="1.0" encoding="utf-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0"
      metadata-complete="true">
              
             <display-name>Welcome to StreamServer</display-name>
                <description>
                 Welcome to StreamServer
              </description>
    
            <servlet>
                      
                    <servlet-name>StreamServer</servlet-name>
                      
                    <servlet-class>net.lnmcc.streamserver.StreamServer</servlet-class>
                      
                    <load-on-startup>1</load-on-startup>
            </servlet>
            <servlet-mapping>
                 <servlet-name>StreamServer</servlet-name>
                   
                 <url-pattern>/streamserver</url-pattern>
            </servlet-mapping>
    </web-app>
    
  • 重启Tomcat

  • /etc/init.d/tomcat7 restart
    
  • 访问servlet

  • http://localhost:8080/streamserver/streamserver
    #第一个streamserver是项目路径
    #第二个streamserver对应web.xml中设置的url
    

Android Binder IPC

AndroidBinderIPC

定制 operator new 记录分配的内存大小

调用operator new的时候在所分配的内存的第一个字节中记录本次new分配的内存大小。

void* operator new(size_t size) throw(bad_alloc){
    
    if(size == 0)
        size = 1;

    void* address = NULL;
    size_t *p = NULL;
    
    while(true) {
        p = (size_t*)malloc(size + sizeof(size_t));
        if(p)
            break;
        new_handler oldHandler = set_new_handler(0);
        set_new_handler(oldHandler);
        
        if(oldHandler)
            (*oldHandler)();
        else
            throw bad_alloc();
    }
    p[0] = size;
    address = (void*)(&p[1]);
	
    return address;
}

对应的operator delete

void operator delete(void* address) {
    if (NULL == address)
	return;
    
    size_t* p = (size_t*)address;

    /* Get the size and do something else */
    /* size_t size = p[-1];               */

    void* p2 = (void*)(&p[-1]); 

    free(p2);
}

github: MemoryMonitor