信源编码作业【04】H.264编码器调试

实验内容

0,jm_vc10解决方案lencod项目
1,找出第一帧第二行第三个宏块的mode(编码模式)
2,找出第二帧第二行第三个宏块的mode(编码模式)和MV(运动矢量)

相关知识

宏块(MB)类型

PSKIP        =  0,
BSKIP_DIRECT =  0,
P16x16       =  1,
P16x8        =  2,
P8x16        =  3,
SMB8x8       =  4,
SMB8x4       =  5,
SMB4x8       =  6,
SMB4x4       =  7,
P8x8         =  8,
I4MB         =  9,
I16MB        = 10,
IBLOCK       = 11,
SI4MB        = 12,
I8MB         = 13,
IPCM         = 14,
MAXMODE      = 15

帧内预测

亮度样点的Intra_4x4预测

在这里插入图片描述
Intra4x4PredMode[ luma4x4BlkIdx ]的值为 0、1、2、3、4、5、6、7 和 8,这些值分别代表不同预测方向

VERT_PRED            = 0,
HOR_PRED             = 1,
DC_PRED              = 2,
DIAG_DOWN_LEFT_PRED  = 3,
DIAG_DOWN_RIGHT_PRED = 4,
VERT_RIGHT_PRED      = 5,
HOR_DOWN_PRED        = 6,
VERT_LEFT_PRED       = 7,
HOR_UP_PRED          = 8

亮度样点的Intra_16x16预测同理

一、编码器命令参数设置

lencode属性

JM编码器的参数通过cfg文件设置,工作目录为当前目录下的bin文件夹。
在这里插入图片描述

encoder.cfg

查看配置文件encoder.cfg的关键参数为:

InputFile             = "foreman_part_qcif.yuv"       # Input sequence 输入序列,为420采样的YUV文件
StartFrame            = 0      # Start frame for encoding. (0-N)
                               # 起始帧号
FramesToBeEncoded     = 3      # Number of frames to be coded
                               # 编码的帧数
FrameRate             = 30.0   # Frame Rate per second (0.1-100.0)
SourceWidth           = 176    # Source frame width
SourceHeight          = 144    # Source frame height
                               # 输入图像尺寸
SourceResize          = 0      # Resize source size for output
OutputWidth           = 176    # Output frame width
OutputHeight          = 144    # Output frame height
                               # 输出图像尺寸

TraceFile             = "trace_enc.txt"      # Trace file 帮助跟踪编码的的进程
ReconFile             = "test_rec.yuv"       # Recontruction YUV file解码文件
OutputFile            = "test.264"           # Bitstream压缩比特流
StatsFile             = "stats.dat"          # Coding statistics file

IntraPeriod           = 0   # Period of I-pictures   (0=only first)
                            # Intra帧周期(I帧,不表示一个GOP结束)
IDRPeriod             = 0   # Period of IDR pictures (0=only first)
                            # Intra IDR帧周期(I帧,表示一个GOP结束)
                            # 该选项确定了一个GOP的长度                            
EnableIDRGOP          = 1   # Support for IDR closed GOPs (0: disabled, 1: enabled)
                            # 使用对IDR封闭的GOP

QPISlice              = 28  # Quant. param for I Slices (0-51)
QPPSlice              = 28  # Quant. param for P Slices (0-51)
                            # 在不启用码率控制时,该选项指定
                            # I帧与P帧的QP

NumberBFrames          = 1  # Number of B coded frames inserted (0=not used)多视角编码视角立体
                            # B帧数,与IntraPeriod、IDRPeriod共同确定GOP结构
QPBSlice               = 30 # Quant. param for B slices (0-51)
                            # B帧的QP

RateControlEnable       = 0     # 0 Disable, 1 Enable
                                # 禁用码率控制 

二、编码器调试

1.打开trace

在cfg配置文件中TraceFile指定输出的文件名trace_enc.txt ;

TraceFile  = "trace_enc.txt"      # Trace file 帮助跟踪编码的进程

在defines.h中设置 TRACE 为 1,以生成 trace_enc.txt 文件。

#if defined _DEBUG
# define TRACE           1      //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
#else
# define TRACE           1     //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
#endif

2.调试lencode:

将Iencode设置为启动项目,直接运行(不调试)编码器,编码器配置在encoder_cfg文件中

输入:foreman_part_qcif.yuv
输出:test.264、test_rec.yuv、trace_enc.txt

使用eseye_u.exe打开生成的test.264文件。

第一帧I帧

在这里插入图片描述
第一帧编码帧序为1,显示帧序为1。获取第一帧第二行第三个宏块的mode(编码模式)通过计算得该宏块编号为13,在trace_enc.txt中找的第一帧和第二帧中该宏块信息。

*********** Pic: 0 (I/P) MB: 13 Slice: 0 **********
 
@4638  mb_type (I_SLICE) ( 2, 1) =   9                                 (  0) # # mb_type字段表明该宏块使用的mode;
#Intra 4x4 mode字段表明对于4x4宏块使用的帧内预测mode选择为4*4
@4638  transform_size_8x8_flag =   0                                   (  0) 
@4638  Intra 4x4 mode  =   7 (context: 0)                              (  7) 
@4640  Intra 4x4 mode  =   7 (context: 1)                              (  7) 
@4641  Intra 4x4 mode  =   7 (context: 2)                              (  7) 
@4643  Intra 4x4 mode  = predicted (context: 3) 
#predicted模式表明该块的预测模式由相邻块预测得到                       ( -1) 
@4645  Intra 4x4 mode  =   5 (context: 4)                              (  5) 
@4648  Intra 4x4 mode  =   7 (context: 5)                              (  7) 
@4650  Intra 4x4 mode  =   7 (context: 6)                              (  7) 
@4651  Intra 4x4 mode  =   2 (context: 7)                              (  2) 
@4657  Intra 4x4 mode  = predicted (context: 8)                        ( -1) 
@4659  Intra 4x4 mode  = predicted (context: 9)                        ( -1) 
@4661  Intra 4x4 mode  = predicted (context: 10)                       ( -1) 
@4663  Intra 4x4 mode  = predicted (context: 11)                       ( -1) 
@4664  Intra 4x4 mode  = predicted (context: 12)                       ( -1) 
@4666  Intra 4x4 mode  = predicted (context: 13)                       ( -1) 
@4667  Intra 4x4 mode  =   3 (context: 14)                             (  3) 
@4671  Intra 4x4 mode  = predicted (context: 15)                       ( -1) 
@4672  intra_chroma_pred_mode                                          (  0) 
@4673  CBP ( 2, 1) =  35                                               ( 35) 
@4681  Delta QP ( 2, 1) =   0                                          (  0) 
@4681  Luma4x4 sng( 0) level = -1 run = 0                              ( -1) 
@4681  Luma4x4 sng( 1) level =  1 run = 1                              (  1) 
@4681  Luma4x4 sng( 2) level = -1 run = 5                              ( -1) 
@4681  Luma4x4 sng( 3) level = -1 run = 1                              ( -1) 
@4681  Luma4x4 sng( 4) level =  0 run = 0                              (  0) 
@4698  Luma4x4 sng( 0) level = -3 run = 0                              ( -3) 
@4698  Luma4x4 sng( 1) level =  2 run = 1                              (  2) 
@4698  Luma4x4 sng( 2) level = -1 run = 0                              ( -1) 
@4698  Luma4x4 sng( 3) level = -1 run = 4                              ( -1) 
@4698  Luma4x4 sng( 4) level =  2 run = 1                              (  2) 
@4698  Luma4x4 sng( 5) level =  1 run = 0                              (  1) 
@4698  Luma4x4 sng( 6) level =  0 run = 0                              (  0) 
@4725  Luma4x4 sng( 0) level =  5 run = 0                              (  5) 
@4725  Luma4x4 sng( 1) level = -2 run = 0                              ( -2) 
@4725  Luma4x4 sng( 2) level = -7 run = 0                              ( -7) 
@4725  Luma4x4 sng( 3) level =  2 run = 0                              (  2) 
@4725  Luma4x4 sng( 4) level =  3 run = 0                              (  3) 
@4725  Luma4x4 sng( 5) level =  2 run = 3                              (  2) 
@4725  Luma4x4 sng( 6) level = -1 run = 1                              ( -1) 
@4725  Luma4x4 sng( 7) level = -1 run = 0                              ( -1) 
@4725  Luma4x4 sng( 8) level =  0 run = 1                              (  0) 
@4762  Luma4x4 sng( 0) level =  1 run = 2                              (  1) 
@4762  Luma4x4 sng( 1) level = -1 run = 0                              ( -1) 
@4762  Luma4x4 sng( 2) level = -1 run = 0                              ( -1) 
@4762  Luma4x4 sng( 3) level = -1 run = 3                              ( -1) 
@4762  Luma4x4 sng( 4) level =  0 run = 0                              (  0) 
@4778  Luma4x4 sng( 0) level =  2 run = 0                              (  2) 
@4778  Luma4x4 sng( 1) level = -2 run = 0                              ( -2) 
@4778  Luma4x4 sng( 2) level = -7 run = 0                              ( -7) 
@4778  Luma4x4 sng( 3) level =  5 run = 0                              (  5) 
@4778  Luma4x4 sng( 4) level =  4 run = 0                              (  4) 
@4778  Luma4x4 sng( 5) level =  1 run = 3                              (  1) 
@4778  Luma4x4 sng( 6) level = -2 run = 1                              ( -2) 
@4778  Luma4x4 sng( 7) level = -1 run = 0                              ( -1) 
@4778  Luma4x4 sng( 8) level =  0 run = 0                              (  0) 
@4817  Luma4x4 sng( 0) level = -1 run = 3                              ( -1) 
@4817  Luma4x4 sng( 1) level =  0 run = 1                              (  0) 
@4830  Luma4x4 sng( 0) level = -1 run = 2                              ( -1) 
@4830  Luma4x4 sng( 1) level =  1 run = 5                              (  1) 
@4830  Luma4x4 sng( 2) level =  0 run = 1                              (  0) 
@4842  Luma4x4 sng( 0) level =  0 run = 0                              (  0) 
@4844  DC Chroma  0: level =  1 run = 0                                (  1) 
@4844  DC Chroma  1: level =  0 run = 1                                (  0) 
@4848  DC Chroma  0: level =  0 run = 0                                (  0) 
@4850  AC Chroma  0: level = -1 run = 1                                ( -1) 
@4850  AC Chroma  1: level =  0 run = 0                                (  0) 
@4857  AC Chroma  0: level =  0 run = 1                                (  0) 
@4858  AC Chroma  0: level =  0 run = 1                                (  0) 
@4858  AC Chroma  0: level =  0 run = 0                                (  0) 
@4859  AC Chroma  0: level =  0 run = 0                                (  0) 
@4859  AC Chroma  0: level =  0 run = 1                                (  0) 
@4860  AC Chroma  0: level =  0 run = 0                                (  0) 
@4860  AC Chroma  0: level =  0 run = 0                                (  0) 
      CABAC terminating bit = 0

第二帧P帧

该帧编码顺序为第2帧,显示顺序为第3帧!

*********** Pic: 2 (I/P) MB: 13 Slice: 0 **********
@22400 mb_skip_flag                                                    (  1) 
@22400 mb_type (P_SLICE) ( 2, 1) =   3                                 (  3) 
@22404 mvd_l0 (0) =   0  (org_mv  -1 pred_mv  -1)                      (  0) 
@22404 mvd_l0 (1) =   0  (org_mv  -1 pred_mv  -1)                      (  0) 
@22405 mvd_l0 (0) =  -2  (org_mv  -3 pred_mv  -1)                      ( -2) 
@22411 mvd_l0 (1) =   1  (org_mv   0 pred_mv  -1)                      (  1) 
@22414 CBP ( 2, 1) =   9                                               (  9) 
@22419 transform_size_8x8_flag =   1                                   (  1) 
@22420 Delta QP ( 2, 1) =   0                                          (  0) 
@22420 Luma8x8 sng( 0) level =  1 run = 8                              (  1) 
@22420 Luma8x8 sng( 1) level =  0 run = 0                              (  0) 
@22431 Luma8x8 sng( 0) level = -1 run = 0                              ( -1) 
@22431 Luma8x8 sng( 1) level =  0 run = 0                              (  0) 
      CABAC terminating bit = 0

第三帧B帧

编码顺序为3,显示顺序为2

*********** Pic: 1 (I/P) MB: 13 Slice: 0 **********
@29408 mb_skip_flag                                                    (  0) 
      CABAC terminating bit = 0
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值