⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpeg2enc.doc

📁 MPEG2视频编解码算法方面的源代码(包括编码和解码)
💻 DOC
📖 第 1 页 / 共 2 页
字号:

 /* transfer_characteristics */

  Specifies the opto-electronic transfer characteristic of the source picture.

  Code   Meaning
  ----   -------
  1      ITU-R Rec. 709 (1990)
  2      unspecified
  4      ITU-R Rec. 624-4 System M
  5      ITU-R Rec. 624-4 System B, G
  6      SMPTE 170M
  7      SMPTE 240M (1987)
  8      linear transfer characteristics

 /* matrix_coefficients */

  Specifies the matrix coefficients used in deriving luminance and chrominance
  signals from the green, blue, and red primaries.

  Code   Meaning
  ----   -------
  1      ITU-R Rec. 709 (1990)
  2      unspecified
  4      FCC
  5      ITU-R Rec. 624-4 System B, G
  6      SMPTE 170M
  7      SMPTE 240M (1987)


 /* display_horizontal_size */

 /* display_vertical_size */

  Display_horizontal_size and display_vertical_size specify the "intended
  display's" active region (which may be smaller or larger than the
  encoded frame size).

 /* intra_dc_precision */

  Specifies the effective precision of the DC coefficient in MPEG-2 
  intra coded macroblocks. 10-bits usually achieves quality saturation.

  Code    Meaning
  ----    -----------------
  0       8 bit
  1       9 bit
  2       10 bit
  3       11 bit

 /* top_field_first */

  Specifies which of the two fields of an interlaced frame comes earlier.
  The top field corresponds to what is often called the "odd field," and 
  the bottom field is also sometimes called the "even field."   

  Code  Meaning
  ----  -----------------
  0     bottom field first
  1     top field first

 /* frame_pred_frame_dct (I P B) */

  Setting this parameter to 1 restricts motion compensation to frame 
  prediction and DCT to frame DCT. You have to specify this separately for 
  I, P and B picture types.

 /* concealment_motion_vectors (I P B) */
  
  Setting these three flags informs encoder whether or not to generate 
  concealment motion vectors for intra coded macroblocks in the 
  three respective coded picture types.  This feature is mostly useful
  in Intra-coded pictures, but may also be used in low-delay applications
  (which attempts to exclusively use P pictures for video signal refresh, 
  saving the time it takes to download a coded Intra picture across a 
  channel). concealment_motion_vectors in B pictures are rather pointless 
  since there is no error propagation from B pictures. This feature is 
  currently not implemented.  Please leave values at zero.

 /* q_scale_type (I P B) */
  
  These flag sets linear (0) or non-linear (1) quantization scale type 
  for the three respective picture types.

 /* intra_vlc_format (I P B) */

  Selects one of the two variable length coding tables for intra coded blocks.
  Table 1 is considered to be statistically optimized for Intra coded 
  pictures coded within the sweet spot range (e.g. 0.3 to 0.6 bit/pixel)
  of MPEG-2.
  
  Code  Meaning
  ----  -----------------
  0     table 0 (= MPEG-1) 
  1     table 1

 /* alternate_scan (I P B) */

  Selects one of two entropy scanning patterns defining the order in 
  which quantized DCT coefficients are run-length coded.  The alternate 
  scanning pattern is considered to be better suited for interlaced video 
  where the encoder does not employ sophisticated forward quantization 
  (as is the case in our current encoder).
  
  Code  Meaning
  ----  -----------------
  0     Zig-Zag scan (= MPEG-1)
  1     Alternate scan 

 /* repeat_first_field */

  If set to one, the first field of a frame is repeated after the second by
  the display process. The exact function depends on progressive_sequence
  and top_field_first.  repeat_first_field is mainly intended to serve as 
  a signal for the Decoder's Display Process to perform 3:2 pulldown.
 
 /* progressive_frame */

  Specifies whether the frames are interlaced (0) or progressive (1).
  MPEG-2 permits mixing of interlaced and progressive video. The encoder
  currently only supports either interlaced or progressive video.
  progressive_frame is therefore constant for all frames and usually
  set identical to progressive_sequence.

 /* intra_slice refresh picture period (P factor) */
   
   This value indicates the number of successive P pictures in which  
   all slices (macroblock rows in our encoder model) are refreshed 
   with intra coded macroblocks.  This feature assists low delay mode
   coding.  It is currently not implemented.

 /* rate control: r (reaction parameter) */
 /* rate control: avg_act (initial average activity) */
 /* rate control: Xi (initial I frame global complexity measure) */
 /* rate control: Xp (initial P frame global complexity measure) */
 /* rate control: Xb (initial B frame global complexity measure) */
 /* rate control: d0i (initial I frame virtual buffer fullness) */
 /* rate control: d0p (initial P frame virtual buffer fullness) */
 /* rate control: d0b (initial B frame virtual buffer fullness) */

  These parameters modify the behavior of the rate control scheme. Usually
  set them to 0, in which case default values are computed by the encoder.

 /* P:  forw_hor_f_code forw_vert_f_code search_width/height */
 /* B1: forw_hor_f_code forw_vert_f_code search_width/height */
 /* B1: back_hor_f_code back_vert_f_code search_width/height */
 /* B2: forw_hor_f_code forw_vert_f_code search_width/height */
 /* B2: back_hor_f_code back_vert_f_code search_width/height */

  This set of parameters specifies the maximum length of the motion
  vectors. If this length is set smaller than the actual movement
  of objects in the picture, motion compensation becomes ineffective
  and picture quality drops. If it is set too large, an excessive
  number of bits is allocated for motion vector transmission, indirectly
  reducing picture quality, too.

  All f_code values have to be in the range 1 to 9 (1 to 7 for MPEG-1),
  which translate into maximum motion vector lengths as follows:

  code  range (inclusive)  max search width/height
  ================================================
  1        -8 ...    +7.5       7
  2       -16 ...   +15.5      15
  3       -32 ...   +31.5      31
  4       -64 ...   +63.5      63
  5      -128 ...  +127.5     127
  6      -256 ...  +255.5     255
  7      -512 ...  +511.5     511
  8     -1024 ... +1023.5    1023
  9     -2048 ... +2047.5    2047

  f_code is specified individually for each picture type (P,Bn), direction
  (forward prediction, backward prediction) and component (horizontal,
  vertical). Bn is the n'th B frame surrounded by I or P frames
  (e.g.: I B1 B2 B3 P B1 B2 B3 P ...).

  For MPEG-1 sequences, horizontal and vertical f_code have to be
  identical and the range is restricted to 1...7.

  P frame values have to be specified if N (N = # of frames in GOP) is
  greater than 1 (otherwise the sequences contains only I frames).

  M - 1 (M = distance between I/P frames) sets (two lines each) of values
  have to specified for B frames. The first line of each set defines
  values for forward prediction (i.e. from a past frame), the second
  line those for backward prediction (from a future frame).

  search_width and search_height set the (half) width of the window used
  for motion estimation. The encoder currently employs exhaustive
  integer vector block matching. Execution time for this algorithm depends
  on the product of search_width and search_height and, too a large extent,
  determines the speed of the encoder. Therefore these values have to be
  chosen carefully.

  Here is an example of how to set these values, assuming a maximum
  motion of 10 pels per frame in horizontal and 5 pels per frame in
  vertical direction and M=3 (I B1 B2 P):

  search width / height:

  forward  hor.  vert.     backward  hor.  vert.
  I -> B1  10     5        B1 <- P   20    10
  I -> B2  20    10        B2 <- P   10     5
  I -> P   30    15

  f_code values are then selected as the smallest ones resulting in a range
  larger than the search widths / heights:

  3 2  30 15 /* P:  forw_hor_f_code forw_vert_f_code search_width/height */
  2 1  10  5 /* B1: forw_hor_f_code forw_vert_f_code search_width/height */
  3 2  20 10 /* B1: back_hor_f_code back_vert_f_code search_width/height */
  3 2  20 10 /* B2: forw_hor_f_code forw_vert_f_code search_width/height */
  2 1  10  5 /* B2: back_hor_f_code back_vert_f_code search_width/height */


4. Interpreting the status information 
======================================

 4.1 Description of the macroblock_type map

  The status information routine prints a two-character code for 
  each macroblock in the picture currently being coded:

  First character:

 S: skipped
 I: intra coded
 0: forward prediction without motion compensation
 F: forward frame/16x8 prediction (in frame/field pictures resp.)
 f: forward field prediction
 p: dual prime prediction
 B: backward frame/16x8 prediction
 b: backward field prediction
 D: frame/16x8 interpolation
 d: field interpolation

 Second character:

 space: coded, no quantization change
 Q:     coded, quantization change
 N:     not coded (only predicted)

 4.2 Description of the mquant map

  The mquant map displays the dynamically changing quantization
  parameter as determined by the rate control algorithm. Larger
  values correspond to coarser quantization. Not displayed values
  indicate same quantization as in the previous macroblock.

  Note that for for MPEG-1 sequences the displayed values are twice
  as large as the quant_scale parameter defined in ISO 11172-2.

5. Encoder model
================

  The encoder model describes the "algorithm" or "intelligence" of the 
  encoder.

 5.1 Motion estimation
 
  Exhaustive search pattern with L1 (Minimum Absolute Difference) matching
  criteria on the original (non-coded) reference frame.  Performed only
  on luminance samples.  Half pel search is done on a neighborhood of 8
  bi-linearly interpolated luminance samples from the reconstructed 
  reference frame.

 5.2 Rate control and adaptive quantization

  The encoder adheres to a single-pass coding philosophy (no a priori
  measurements guide the allocation of bits at the global layers).
  Target bit allocation for the current picture being encoded is based
  on global bit budget for the Group of Pictures (dependently coded
  sequence of pictures), and a ratio of weighted relative coding
  complexities of the three picture types.  Coding complexity (X) is
  estimated as a picture's product of: average macroblock quantization
  step size (Q) and the number of bits (S) generated by coding the picture
  (e.g.   X = Q*S).

  Local bit allocation is based on two measurements: 
  1. deviancy from estimated buffer fullness for the Nth macroblock
  2. normalized spatial activity

  The picture is approximated and estimated to have a uniform distribution 
  of bits. If the local trend of generated bits begin to stray from this 
  estimation, a compensation factor emerges to modulate the macroblock 
  quantization scale (mquant). The compensation factor is the difference 
  between where the buffer fullness was predicted at the Nth macroblock 
  and where the buffer fullness truly is) 


  Local spatial activity is estimated as the minimum variance of the 
  four luminance 8x8 frame blocks and the corresponding four luminance 8x8
  field blocks of the original picture being coded.  The variance measure
  is then normalized against the average variance of the most recently coded
  picture.  The scaled product of the local activity measure and the buffer
  compensation factor are combined to modify the final mquant value which
  will be used in the quantization stage of the subsequent block coding
  processes.

 5.3 Decision

  The macroblock decision process selects the various prediction
  switches (yes/no coding of prediction error, yes/no motion 
  compensation) which provide the best quality for the relative coding 
  bit cost.  The decision process follows the piecewise path of least 
  distortion, approximating that the decision stages (whether to use 
  forwards, backwards compensation or none at all..., etc.) are mostly 
  uncorrelated (i.e. can be independently decided).

 5.4 Macroblock coding
  
  The forward DCT is based on the fast Chen-Wang 1984 algorithm.

  Quantization is a mirror of the normative inverse quantizer, as
  specified in the MPEG-2 Test Model.  No special dithering or
  entropy-constrained methods are currently employed.


6. References
=============

[1] ISO/IEC 13818 Draft International Standard: Generic Coding of
    Moving Pictures and Associated Audio, Part 2: video


[2] Test Model 5, ISO/IEC JTC1/SC29/WG11/ N0400, MPEG93/457, April 1993.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -