日历

« 2008-12-05  
 123456
78910111213
14151617181920
21222324252627
28293031   

最新来客

我的好友

统计信息

  • 访问量: 2329
  • 日志数: 26
  • 图片数: 3
  • 建立时间: 2006-12-11
  • 更新时间: 2008-10-21

RSS订阅

我的最新日志

  • Aspect Ratio

    2008-10-21

    Aspect Ratio Concept

    Use the parameters of Aspect Ratio provided by specifications.

      • For MPEG2, please use aspect_ratio_information (Refer to ISO-13818-2 (MPEG2 Specification) page 45)
      • For H264, please use aspect_ratio_idc (Refer to T-REC-H.264-200711-I!!PDF-E.pdf Page 346).
        • aspect_ratio_idc specifies the value of the sample aspect ratio of the luma samples. Table E-1 shows the meaning of the code. When aspect_ratio_idc indicates Extended_SAR, the sample aspect ratio is represented by sar_width and sar_height. When the aspect_ratio_idc syntax element is not present, aspect_ratio_idc value shall be inferred to be equal to 0.  

    Aspect Ratio of a Shape

    The aspect ratio of a shape is the ratio of its longer dimension to its shorter dimension. It may be applied to two characteristic dimensions of a three-dimensional shape, such as the ratio of the longest and shortest axis, or for symmetrical objects that are described by just two measurements, such as the length and diameter of a rod.

    For more detailed information, please refer to http://en.wikipedia.org/wiki/Aspect_ratio.

     

    Pixel Aspect Ratio (PAR)

    Pixel aspect ratio (PAR), in computer graphics terminology, is a mathematical ratio that describes how the horizonal length of a pixel in an imaging system compares to its vertical height.

    Most digital imaging systems describe an image as a grid of very small but nontheless square pixels. However, some imaging systems, especially those which must maintain compatibility with analog standard-definition, define image as a grid of rectangular pixels in which the width of the pixel is different that of its height. To describe this proportion, we state it in form of Pixel Aspect Ratio. For more detailed information, please refer to http://en.wikipedia.org/wiki/Pixel_aspect_ratio.

     

    Image Aspect Ratio

    Image aspect ratio: The aspect ratio of an image is its width divided by its height.

    Aspect ratios are mathematically expressed as x :y (pronounced "x-to-y") and x×y (pronounced "x-by-y"). The most common aspect ratios used today in the presentation of films in movie theaters are 1.85:1 and 2.39:1. Two common videographic aspect ratios are 4:3 (1.33:1), universal for standard-definition video formats, and 16:9 (1.78:1), universal to high-definition television and European digital television. Other cinema and video aspect ratios exist, but are used infrequently. In still camera photography, the most common aspect ratios are 4:3 and 3:2, though other aspect ratios, such as 5:4, 7:5, and 1:1 (square format), are used.
    For more detailed information, please refer to
    http://en.wikipedia.org/wiki/Aspect_ratio_(image).

     

    Computer display standard

    Computer display standard: Various computer display standards or display modes have been used in the history of the personal computer. They are often a combination of display resolution (specified as the width and height in pixels), color depth (measured in bits), and refresh rate (expressed in hertz). Associated with the screen resolution and refresh rate is a display adapter. Earlier display adapters were simple frame-buffers, but later display standards also specified a more extensive set of display functions and software controlled interface.

    Until about 2003, most computer monitors had a 4:3 aspect ratio and some had 5:4. Between 2003 and 2006, monitors with 16:10 aspect ratios have become commonly available, first in laptops and later also in standalone monitors. Productive uses for such monitors, i.e. besides widescreen movie viewing and computer game play, are the wordprocessor display of two standard letter pages side by side, as well as CAD displays of large-size drawings and CAD application menus at the same time. The VESA industry organization has defined several standards related to power management and device identification. Ergonomy standards are set by the TCO.
    For more detailed information, please refer to
    http://en.wikipedia.org/wiki/Computer_display_standard.

     

     

    Reference:

  • OpenMax Info

    2008-10-21

    OpenMax

    http://www.khronos.org/openmax/

    OpenMAX Overview

    OpenMAX - The Standard for Media Library Portability

    OpenMAX™ is a royalty-free, cross-platform API that provides comprehensive streaming media codec and application portability by enabling accelerated multimedia components to be developed, integrated and programmed across multiple operating systems and silicon platforms. The OpenMAX API will be shipped with processors to enable library and codec implementers to rapidly and effectively make use of the full acceleration potential of new silicon - regardless of the underlying hardware architecture.

    OpenMAX - 便携设备媒体库标准

    OpenMAX™ 是无授权费的,跨平台的应用程序接口API,通过使媒体加速组件能够在开发、集成和编程环节中实现跨多操作系统和处理器硬件平台,提供全面的流媒体编解码器和应用程序便携化。OpenMAX API将会与处理器一同提供,以使库和编解码器开发者能够高速有效地利用新器件的完整加速潜能 - 无需担心其底层的硬件结构。 

    Background

    Development of multimedia hardware platforms is gathering pace as consumer demand grows for improved functionality from applications such as video, audio, voice, and 3D on platforms such as diverse as smartphones, audio and video media players and games consoles. In general, this class of product requires high-performance processing and high data throughput capabilities. Consequently, a variety of solutions has evolved, each designed to accelerate multimedia applications. Examples include:

    • General purpose processors with specific multimedia extensions
    • Low level hardware accelerators,
    • Multiple processor architectures including DSPs
    • Dedicated hardware video decoders

    One of the key challenges with all of these architectural variants is to develop efficient code. Even though compilers are generally provided, it is rare to be able to exploit the full potential of the entire architecture from a high-level programming language. The outcome is that large portions of the application are often written in assembly language to specifically target the hardware platform. The proliferation of different multimedia hardware solutions means that software must be re-written and optimized for each new platform that it is ported to.

    The effect of this inefficiency in implementation is to delay the introduction of new products, increase development costs and reduce product quality, which ultimately slows down innovation in the multimedia domain at a time when market demand is growing.

    A New Open Standard

    To address this issue, the OpenMAX Working Group has been formed by the Khronos Group, to define a set of standard, open Application Programming Interfaces (APIs) for multimedia applications. The goal of this open standard is to reduce the cost and complexity of porting multimedia software to new processors and architectures.

    By agreeing a common specification for middleware applications such as multimedia codecs, graphics libraries and other functions for video, image, audio, voice and speech, it will be possible for the developer community to focus on differentiating their products rather than the repeated implementation of common functionality. This will ensure that new products can be brought to market sooner, and will support a broader range of hardware platforms.

    1. OpenMAX IL (Integration Layer)
      OpenMAX IL serves as a low-level interface for audio, video, and imaging codecs used in embedded and/or mobile devices. It gives applications and media frameworks the ability to interface with multimedia codecs and supporting components (i.e., sources and sinks) in a unified manner. The codecs themselves may be any combination of hardware or software and are completely transparent to the user. Without a standardized interface of this nature, codec vendors must write to proprietary or closed interfaces to integrate into mobile devices. The principal goal of the IL is to give codecs a degree of system abstraction using a specialized arsenal of features, honed to combat the problem of portability among many vastly different media systems.
    2. OpenMAX DL (Development Layer)
      OpenMAX DL defines an API which contains a comprehensive set of audio, video and imaging functions that can be implemented and optimized on new processors by silicon vendors and then used by codec vendors to code a wide range of codec functionality. It includes audio signal processing functions such as FFTs and filters, imaging processing primitives such as color space conversion and video processing primitives to enable the optimized implementation of codecs such as MPEG-4, H.264, MP3, AAC and JPEG. OpenMAX supports acceleration concurrency via both iDL, which uses OpenMAX IL constructs, and aDL which adds asynchronous interfaces to the OpenMAX DL API.
    3. OpenMAX AL (Application Layer)
      The OpenMAX AL API defines a set of APIs providing a standardized interface between an application and multimedia middleware where multimedia middleware provides the services needed to perform expected API functionality. The AL provides application portability with regards to the multimedia interface.

    Driving Collaboration

    OpenMAX is a non-proprietary, royalty-free standard, primarily targeted at middleware developers producing multimedia codecs, games engines and graphics libraries. OpenMAX is widely applicable to all applications where multimedia performance is a critical issue, including smartphones, games consoles, digital televisions and set-top boxes. Through collaboration and support from a growing number of leading stakeholders, the standard will be developed and promoted, with wide industry support and adoption encouraged.

    The working group welcomes the input and experience of existing Khronos members, and encourages new members with multimedia knowledge to join and help ensure that the specifications deliver benefits that are relevant to the entire industry. This includes semiconductor manufacturers, independent software vendors, intellectual property vendors, operating system companies and the OEM or product development companies that supply end users.

  • 代码覆盖率分析(gcov)(转)

    2008-8-11

    为什么需要代码覆盖率分析?

    在发布代码的时候,我们常常会对其进行一系列的测试来协调软件的性能和功能,使他们和预计的相同。但是检验通常都是相当的困难,即使程序相当的简单。开发者常常会借助一些测试工具(test suite)来模拟或者重建执行脚本。如果测试程序组是彻底的,那么程序的各个功能都将被测试到并且都可以证明是可以工作的。

    但是怎样才算彻底呢?简单点说就是测试程序的每一条路径,验证每一个结果,执行每一条语句,证明没一句语句是没用的。gcov就是一个用来检验你的每一句语句是否都执行了的工具。

    什么是代码覆盖率分析?
    代码覆盖率分析就是找到定位没用的或者不执行的代码的过程。没用的代码不会存在什么问题,但是他们会影响程序的可读性;不执行的代码则可能是未来bug的所在。所以找到他们,把他们从你的程序中移处是大有裨益的。
    覆盖率分析主要有下面的几个过程:
        通过测试程序组找到不执行的程序段;
        添加额外测试程序组,以便增加代码覆盖率;
        决定代码覆盖率的定量测度,他也是程序质量的间接测度。

    代码覆盖率分析的缺陷
    代码覆盖率分析不能找出程序的逻辑错误。考虑一下下面的代码
    10:  rc = call_to_xx ();
    11:  if (rc == ERROR_FATAL)
    12:    exit(2);    /* exit with error code 2 */
    13:  else
    14:    /* continue on */
    当测试程序段运行到11行时,11行始终都不能为真。call_to_xx返回了另外的一个错误比如ERROR_HANDLE,除非我们加入这种错误的处理方式的代码。
    代码覆盖测试工具不会告诉你什么是必须的,他们只能显示已经存在的代码的覆盖率。

    代码覆盖率的类型
    gcov可以用来测量各种形式的代码覆盖率。最常见最有用的两种是分支覆盖(branch coverage)和循环覆盖(loop coverage)
    分支覆盖证明各个方向的每一条分支都被执行到了。循环覆盖试图证明循环内部的每一条路径都被测试到了。循环覆盖似乎非常的复杂,但基本上只要满足下面的三个状况,就可以作了。
        1。循环条件不满足,循环没有内部没有执行;
        2。循环条件就满足了一次,循环内部就执行了一次;
        3。循环条件至少满足了两次,循环至少执行了两次。
    举个例子
    void  function(int number)
    {
      if (number % 2) == 0)
        printf("even \n");
      for (;number < 9; number++){
        printf("number is %d\n", number);
      }
    }

    function(11);   满足状况一
    function(8);    满足状况二
    function(6);    满足状况三   

    代码覆盖率工具gcov的使用
    要使用gcov,需要在我们用gcc编译程序时加入两个参数fprofile-arcsftest-coverage.
    fprofile-arcs参数使gcc创建一个程序的流图,之后找到适合图的生成树。只有不在生成树中的弧被操纵(instrumented):gcc添加了代码来清点这些弧执行的次数。当这段弧是一个块的唯一出口或入口时,操纵工具代码(instrumentation code)将会添加到块中,否则创建一个基础块来包含操纵工具代码。
    gcov主要使用.gcno和.gcda两个文件
    .gcno是由-ftest-coverage产生的,它包含了重建基本块图和相应的块的源码的行号的信息。
    .gcda是由加了-fprofile-arcs编译参数的编译后的文件运行所产生的,它包含了弧跳变的次数和其他的概要信息。

    下面是一个简要的范例:
      1 #include <stdlib.h>
      2 #include <stdio.h>
      3
      4 int main(int argc,char** argv)
      5 {
      6     int x,y;
      7     int arraysize;
      8     int **array;
      9
     10     if(argc!=2)
     11     {
     12         printf("Usage: %s Enter arraysize value\n;",argv[0]);
     13         exit(-1);
     14     }
     15     else
     16     {
     17         arraysize = atoi(argv[1]);
     18         if(arraysize <=0)
     19         {
     20             printf("Array size must be larger than 0\n;");
     21             exit(-1);
     22         }
     23     }
     24
     25     array = (int**) malloc( arraysize*sizeof(int*));
     26
     27     printf("Creating an %d by %d array \n",arraysize,arraysize);
     28
     29     if(array == NULL)
     30     {
     31         printf("Malloc failed for array size %d \n",arraysize);
     32         exit(-1);
     33     }
     34
     35     for (x=0;x<arraysize;x++)
     36     {
     37         array[x] = (int*) malloc (arraysize*sizeof(int));
     38
     39         if(array[x] == NULL)
     40         {
     41             printf("Failed malloc for array size %d\n",arraysize);
     42             exit(-1);
     43         }
     44     }
     45
     46     exit(0);
     47 }

    $ gcc -fprofile-arcs -ftest-coverage -g -o sample test.c
    $ ./sample 10
    Creating an 10 by 10 array
     $ gcov test.c
    File ''/usr/include/sys/sysmacros.h''
    Lines executed:0.00% of 6
    /usr/include/sys/sysmacros.h:creating ''sysmacros.h.gcov''

    File ''test.c''
    Lines executed:57.89% of 19
    test.c:creating ''test.c.gcov''
    $ cat test.c.gcov
            -:    0:Source:test.c
            -:    0:Graph:test.gcno
            -:    0:Data:test.gcda
            -:    0:Runs:1
            -:    0:Programs:1

    -:    1:#include <stdlib.h>
            -:    2:#include <stdio.h>
            -:    3:
            -:    4:int main(int argc,char** argv)
            1:    5:{
            -:    6:        int x,y;
            -:    7:        int arraysize;
            -:    8:        int **array;
            -:    9:
            1:   10:        if(argc!=2)
            -:   11:        {
        #####:   12:                printf("Usage: %s Enter arraysize value;\n",argv[0]);
        #####:   13:                exit(-1);
            -:   14:        }
            -:   15:        else
            -:   16:        {
            1:   17:                arraysize = atoi(argv[1]);
            1:   18:                if(arraysize <=0)
            -:   19:                {
        #####:   20:                        printf("Array size must be larger than 0;\n");
        #####:   21:                        exit(-1);
            -:   22:                }
            -:   23:        }
            -:   24:
            1:   25:        array = (int**) malloc( arraysize*sizeof(int*));
            -:   26:
            1:   27:        printf("Creating an %d by %d array \n",arraysize,arraysize);
            -:   28:
            1:   29:        if(array == NULL)
            -:   30:        {
        #####:   31:                printf("Malloc failed for array size %d \n",arraysize);
        #####:   32:                exit(-1);
            -:   33:        }
            -:   34:
           11:   35:        for (x=0;x<arraysize;x++)
            -:   36:        {
           10:   37:                array[x] = (int*) malloc (arraysize*sizeof(int));
            -:   38:
           10:   39:                if(array[x] == NULL)
            -:   40:                {
        #####:   41:                        printf("Failed malloc for array size %d\n",arraysize);
        #####:   42:                        exit(-1);
            -:   43:                }
            -:   44:        }
            -:   45:
            1:   46:&n
         

    bsp;       exit(0);
            -:   47:}

    正如我们看到的,我们现在的覆盖率是57.89%,#####后面的语句是现在没有够执行到的。

    $ ./sample
    Usage: ./sample Enter arraysize value;
    $ gcov test.c
    File ''/usr/include/sys/sysmacros.h''
    Lines executed:0.00% of 6
    /usr/include/sys/sysmacros.h:creating ''sysmacros.h.gcov''

    File ''test.c''
    Lines executed:68.42% of 19
    test.c:creating ''test.c.gcov''
    现在运行了没有参数的情况,这种情况占了10.53%(68.42-57.89)

    $ ./sample 0
    Array size must be larger than 0;
    $ gcov test.c
    File ''/usr/include/sys/sysmacros.h''
    Lines executed:0.00% of 6
    /usr/include/sys/sysmacros.h:creating ''sysmacros.h.gcov''

    File ''test.c''
    Lines executed:78.95% of 19
    test.c:creating ''test.c.gcov''
    有测试了一种情况,那就是arraysize=0现在的覆盖率已经达到了78.95%

    还有两种情况,那就是二维数组的第一维和第二维内存空间的申请了。在现在的状况下,malloc()不太可能分配失败,所以我们借助工具gdb来模拟malloc失败时的情况。
    $ gdb sample
    GNU gdb Red Hat Linux (6.6-16.fc7rh)
    Copyright (C) 2006 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for details.
    This GDB was configured as "i386-redhat-linux-gnu"...
    Using host libthread_db library "/lib/libthread_db.so.1".
    (gdb) l
    1       #include <stdlib.h>
    2       #include <stdio.h>
    3
    4       int main(int argc,char** argv)
    5       {
    6               int x,y;
    7               int arraysize;
    8               int **array;
    9
    10              if(argc!=2)
    (gdb) l
    11              {
    12                      printf("Usage: %s Enter arraysize value\n;",argv[0]);
    13                      exit(-1);
    14              }
    15              else
    16              {
    17                      arraysize = atoi(argv[1]);
    18                      if(arraysize <=0)
    19                      {
    20                              printf("Array size must be larger than 0\n;");
    (gdb) l
    21                              exit(-1);
    22                      }
    23              }
    24
    25              array = (int**) malloc( arraysize*sizeof(int*));
    26
    27              printf("Creating an %d by %d array \n",arraysize,arraysize);
    28
    29              if(array == NULL)
    30              {
    (gdb) b 29
    Breakpoint 1 at 0x8048ada: file test.c, line 29.
    (gdb) r 10
    Starting program: /home/secularbird/Templates/test/sample 10
    Creating an 10 by 10 array

    Breakpoint 1, main (argc=2, argv=0xbf9b59f4) at test.c:29
    29              if(array == NULL)
    (gdb) print array
    $1 = (int **) 0x90af008
    (gdb) set array=0
    (gdb) print array
    $2 = (int **) 0x0
    (gdb) step
    31                      printf("Malloc failed for array size %d \n",arraysize);
    (gdb) cont
    Continuing.
    Malloc failed for array size 10

    Program exited with code 0377.
    (gdb) quit
    l命令是list的简写,显示了程序的源代码。
    b 29是在29行设置一个断点,之所以这样设置是因为array空间申请过了,我们为了模拟需要改变它的值。
    r 10是run 10,也就是运行程序,10是传递的命令行参数。
    print array打印array的地址
    set array=0将array指向空地址
    step一步一步的运行程序,简写是s
    cont继续运行程序
    quit退出gdb。

    接下来做类似的工作产生另一个malloc fail。
    $ gdb sample
    GNU gdb Red Hat Linux (6.6-16.fc7rh)
    Copyright (C) 2006 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "sh ow copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for details.
    This GDB was configured as "i386-redhat-linux-gnu"...
    Using host libthread_db library "/lib/libthread_db.so.1".
    (gdb) l
    1       #include <stdlib.h>
    2       #include <stdio.h>
    3
    4       int main(int argc,char** argv)
    5       {
    6               int x,y;
    7               int arraysize;
    8               int **array;
    9
    10              if(argc!=2)
    (gdb) l
    11              {
    12                      printf("Usage: %s Enter arraysize value\n;",argv[0]);
    13                      exit(-1);
    14              }
    15              else
    16              {
    17                      arraysize = atoi(argv[1]);
    18                      if(arraysize <=0)
    19                      {
    20                              printf("Array size must be larger than 0\n;");
    (gdb) l
    21                              exit(-1);
    22                      }
    23              }
    24
    25              array = (int**) malloc( arraysize*sizeof(int*));
    26
    27              printf("Creating an %d by %d array \n",arraysize,arraysize);
    28
    29              if(array == NULL)
    30              {
    (gdb) l
    31                      printf("Malloc failed for array size %d \n",arraysize);
    32                      exit(-1);
    33              }
    34
    35              for (x=0;x<arraysize;x++)
    36              {
    37                      array[x] = (int*) malloc (arraysize*sizeof(int));
    38
    39                      if(array[x] == NULL)
    40                      {
    (gdb) b 39
    Breakpoint 1 at 0x8048b7a: file test.c, line 39.
    (gdb) r 10
    Starting program: /home/secularbird/Templates/test/sample 10
    Creating an 10 by 10 array

    Breakpoint 1, main (argc=2, argv=0xbfdcae04) at test.c:39
    39                      if(array[x] == NULL)
    (gdb) print array[0]
    $1 = (int *) 0x9bc2038
    (gdb) set array[0]=0
    (gdb) step
    41                              printf("Failed malloc for array size %d\n",arraysize);
    (gdb) cont
    Continuing.
    Failed malloc for array size 10

    Program exited with code 0377.
    (gdb) quit

    $ gcov test.c
    File ''/usr/include/sys/sysmacros.h''
    Lines executed:0.00% of 6
    /usr/include/sys/sysmacros.h:creating ''sysmacros.h.gcov''

    File ''test.c''
    Lines executed:100.00% of 19
    test.c:creating ''test.c.gcov''
    到现在为止每条路径都测试过了,代码覆盖率也已经达到了100%,也可以查看一下test.c.gcov文件
    里面已经没有#####了。

    参考资料:
    Linux® Debugging and Performance Tuning: Tips and Techniques By Steve Best
    man gcov
    http://gcc.gnu.org/onlinedocs/gcc/Gcov-Data-Files.html#Gcov-Data-Files

  • H.264简单总结(如霜的天空)(严重参考的是毕厚杰的书)

    2008-7-28

    一、视频信息和信号的特点

    11 直观性

           利用人的视觉系统,直接获取视频信息

    12 确定性

           视频信息只管具体,不易与其他内容混淆

    13 高效性

           利用视觉系统,人们可以并行的观察图像的各个象素,因此具有高效性。

    14 广泛性

           视觉系统占外界信息总量的70

    15视频信号的高带宽性

           视频信息包含大量的变化的信息,信息量极大,传输网络所需要的带宽相对较大。

    二、视频压缩的要求和可能性

    21视频压缩编码的目标

    由于视频信息量大,传输带宽高,就要求先对视频源压缩,然后传输,以便节约带宽和存储空间。

                    1       视频必须压缩在一定的带宽内,要保证足够的压缩比。

                    2       视频压缩后,经恢复要保证一定的视频质量

                    3       视频编码器的实现方式应力求简单、易实现、低成本、可靠性高。

    22视频压缩的可能行

                     1)时间相关行

                         在一组视频序列中,相邻两帧只有极少的不同之处,这便是时间相关性。

                    2)空间相关性

                         在同一帧中,相邻象素之间有很大的相关性,两象素越近,侧相关性越强。

    三、视频编码技术

    31基本结构

           视频编码方式与采用的信源有关。根据采用的信源的模型,视频编码可以分为两大类:基于波形的编码和基于内容的编码。

    32 基于波形的编码

           如果采用一幅图像由许多象素构成的信源模型,这种信源模型的参数就是象素的亮度和色度的幅度值,对这些参数进行编码的技术即为基于波形编码。

           利用象素空间的相关性和帧间的时间相关性,采用预测编码和变化编码技术,减少视频信号的相关性,从而显著降低视频序列的码率,实现压缩编码的目标。

    33 基于内容的编码

            如果采用一个分量有几个物体构成的信源模型,这种信源模型的参数事各个物体的形状,纹理,运动,对这些参数进行编码的技术就是基于内容的编码。

    四、h264的应用

    41 H. 264的技术特点可以归纳为三个方面

    1)注重实用;

    2)注重对移动和IP网络的适应;

    3)在混合编码器的基本框架下,对其主要关键部件都做了重大改进,如多模式运动估计、帧内预测、多帧预测、基于内容的变长编码、4X4二维整数变换等。

    4)在关注H. 264的优越性能的同时必然需要衡量其实现难度。从总体上说,H. 264性能的改进是以增加复杂性为代价而获得的。据估计,H. 264 编码的计算复杂度大约相当于H. 2633倍,解码复杂度大约相当于H. 2632.

    42 h264应用可分为3个级别:

            (1) 基本档次: (简单版本, 应用面广, 支持帧内和帧间编码, 基于可变程度的熵编码.)

                                     应用领域: 视频会话, 会议电视, 无线通信等实时通信.

             (2) 主要档次: ( 采用了多项提高图像质量和增加压缩比的技术措施, 支持隔行视频, 支持基于上下文的自适应的算术编码.)

                                      应用领域: 数字广播与数字视频存储.

           3)扩展档次: 应用领域: 可用于各种网络的视频流传输,视频点播

    五、视频编码原理

    51基本概念

    1)视频编码器能够对一个图像或者一个视频序列进行压缩,产生码流。

         

    在上图中,编码器输入的帧或场Fn,以宏块为单位被编码器处理 (图上传不上啊!)。

    如果采用帧间预测编码:其预测值P,是由已编码的图像做参考,经运动补偿得到的。预测图像P和当前帧Fn相减,得到两图像的残差值DnDn在经过转换T,量化Q,去处空间冗余,得到系数X,将X重排(使数据更加紧凑),熵编码(加入运动矢量。一些图像相关得信息),得到nal数据。

    在编码器中有个重构的过程(解码的过程),量化系数X,反量化,反变换,得到Dn’Dn’和预测图像P相加,得到uFn’,再滤波得到Fn’Fn’就是Fn编码再解码后得图像。

    如果采用帧内预测编码:预测值P,是由当前片中,己编码的宏块预测得到的(亮度4×4或者16×16预测,色度8×8预测)。当前待处理的块,减去预测值P,得残差值DnDn在经过转换T,量化Q,得到系数X,将X重排(使数据更加紧凑),熵编码,得到nal数据。

    在重构的过程中,量化系数X,反量化,反变换,得到Dn’Dn’和预测图像P相加得到当前宏块编码解码后得值,该值可以用来做帧内预测的参考宏块。

    编码器要有重构机制的原因:重构过程,实质上是个解码的过程,解码后的图像和源图肯定有差别,我门利用解码后的图像做参考,就能够和解码器中保值一致,就能够提高图像的预测精度。(在解码器中,是利用己解码的图像做参考,是从解码的图像预测出下一副图像)

                  2)视频解码器: 能够对一个码流解码,产生和源图或源视频序列相近的图像或视频序列。如果解码出的图像和源图是一样的,这个编解码过程是无损的,否则是有损。

                         解码器的实现和编码器的重构机制,是一样的。

                  3)场 、帧、图像

                         场:隔行扫描的图像,偶数行成为顶场行。奇数行成为底场行。所有顶场行称为顶场。所有底场行称为底场。

                         帧:逐行扫描的图像。

                         图像:场和帧都可认为是图像。

                  4)宏块、片:

                         宏块:一个宏块由一个16×16亮度块、一个8×8Cb和一个8×8Cr组成。

                         片:一个图像可以划分成一个或多个片,一个片由一个或多个宏块组成。

    52编码数据格式

                 521 h264支持420的连续或隔行视频编码解码。

            522 h264的编码格式

    制定h264的主要目标有两个:

    1)得到高的视频压缩比

    2)具有良好的网络亲和性,即可适应于各种传输网络。

    为此,h264的功能分为两层,视频编码层VCL)和网络提取层NAL

    VCL数据即被压缩编码后的视频数据序列。在VCL数据要封装到NAL单元中之后,才可以用来传输或存储。NAL单元格式如下图:

    Nal

    Rbsp

    Nal

    Rbsp

    Nal

    Rbsp

                 523         h264码流结构

    查看(19) 评论(0)

  • H.264解码器中参考图像的管理(转自 李世平)

    2008-7-28

    【写在前面】
    由于H.264采用了多参考帧预测技术,所以其参考图象的管理比较复杂。GO50只是说明了怎么用,没有讲明为什么这么用,大家看过之后往往会有很多疑惑。本文比较细致的讲解了参考图象管理的问题,旨在进一步揭开其朦胧的面纱:)
    NOTE:为了便于从宏观角度讲解参考图象的管理,本文没有考虑B帧和场模式。
    PS:在H.264中,编解码器要维护参考图像列表的同步,所以在编码器和解码器中参考图像的管理是基本一致。在看此篇之前,大家可以先看看我以前写的《JM85中的多参考帧问题》: http://blog.csdn.net/sunshine1314/archive/2004/11/08/172498.aspx
     
    【outline】
    一、相关变量含义
    二、解码流程(突出参考图像管理部分)
    三、参考图像的标记
    四、参考图像的初始化
    五、参考图像的重排序
     
    一、相关变量含义
    DPB(Decoded Picture Buffer): 保存所有的重建图像,
    ListX[i]: 参考帧列表,其包含的参考帧指向dpb中的重建图像,而且是经过排序的。ListX[0]是前向参考帧列表,P、B帧都会用到;ListX[1]是后向参考帧列表,只有B帧都会用到,
    MaxFrameNum: 1 << (active_sps->log2_max_frame_num_minus4 + 4);
    frame_num:表示参考帧的序号(指的是解码顺序)。具体见图1的例子。
    图1 frame_num取值示例
    note:
    B帧不作参考时,我们可以忽略B帧,然后I/P帧按排列顺序是依次递增得。
    B帧作参考时,frame_num就完全等同与编解码得顺序。
    PicNum: 短期参考图像的序号,其计算过程如下:
    //note: frame_num为当前图象的序号
    if(listX[i]->frame_num > frame_num)
    {
           FrameNumWrap=listX[i]->frame_num - frame_num;
    }
    else
           FrameNumWrap=listX[i]->frame_num;
     
    listX[i]->PicNum=FrameNumWrap;