H.264编解码实验

一、将.264文件转换为YUV文件

#define DECOUTPUT_TEST      0

#define PRINT_OUTPUT_POC    0
#define BITSTREAM_FILENAME  "miao.264"
#define DECRECON_FILENAME   "miao.yuv"
#define ENCRECON_FILENAME   "test_rec.yuv"
#define FCFR_DEBUG_FILENAME "fcfr_dec_rpu_stats.txt"
#define DECOUTPUT_VIEW0_FILENAME  "H264_Decoder_Output_View0.yuv"
#define DECOUTPUT_VIEW1_FILENAME  "H264_Decoder_Output_View1.yuv"

在这里插入图片描述
在这里插入图片描述

二、将视频序列编码为.264文件

1.固定码率,以不同的GOP长度及形状编码

在这里插入图片描述
因为一个GOP组只拥有一个I帧,所以I帧之间的间隔就可以看作GOP组的长度。所以可以通过设置IntraPeriod 的值确定GOP组的长度。

修改下列参数:

InputFile             = "miao.yuv"       # Input sequence
FramesToBeEncoded     = 30      # Number of frames to be coded
SourceWidth           = 960    # Source frame width
SourceHeight          = 464    # Source frame height
OutputWidth           = 960    # Output frame width
OutputHeight          = 464    # Output frame height

ReconFile             = "miao_rec_400.yuv"       # Reconstruction YUV file
OutputFile            = "miao_400.264"           # Bitstream

IntraPeriod           = 10   # Period of I-pictures   (0=only first)
IDRPeriod             = 0   # Period of IDR pictures (0=only first)
NumberBFrames          = 0  # Number of B coded frames inserted (0=not used)
RateControlEnable       = 0     # 0 Disable, 1 Enable

获得上述不同GOP长度及编码形状编码后的.264文件
GOP=15,2B帧:
在这里插入图片描述
GOP=12,2B帧:
在这里插入图片描述

2.相同GOP长度,不同码率

在这里插入图片描述

InputFile             = "miao.yuv"       # Input sequence
FramesToBeEncoded     = 30      # Number of frames to be coded
SourceWidth           = 960    # Source frame width
SourceHeight          = 464    # Source frame height
OutputWidth           = 960    # Output frame width
OutputHeight          = 464    # Output frame height

ReconFile             = "miao_rec_400.yuv"       # Reconstruction YUV file
OutputFile            = "miao_400.264"           # Bitstream

IntraPeriod           = 10   # Period of I-pictures   (0=only first)
IDRPeriod             = 0   # Period of IDR pictures (0=only first)
NumberBFrames          = 0  # Number of B coded frames inserted (0=not used)

RateControlEnable       = 1     # 0 Disable, 1 Enable
Bitrate                 = 400000     # Bitrate(bps)
RCUpdateMode            = 2     # Rate Control type. Modes supported :
                                # 0 = original JM rate control,
                                # 1 = rate control that is applied to all frames regardless of the slice type,
                                # 2 = original plus intelligent QP selection for I and B slices (including Hierarchical),
                                # 3 = original + hybrid quadratic rate control for I and B slice using bit rate statistics

1000kb/s,GOP=10,无B帧
在这里插入图片描述
800kb/s,GOP=10,无B帧
在这里插入图片描述
400kb/s,GOP=10,无B帧
在这里插入图片描述

三、用码流分析软件检查所生成的码流中各种编码模式和运动矢量等信息

在这里插入图片描述
该帧为视频码流最后一帧,帧内类型为P帧。
在这里插入图片描述
紫色代表I宏块,绿色代表P宏块。由于不同宏块所在的图像细节不同,采用的宏块大小也不同,可以看出在平坦区域
在这里插入图片描述
该图表示运动矢量,因为该帧为P帧,所以只有前向预测。

四、用播放器观看生成码流的质量

1000kb/s:
在这里插入图片描述
800kb/s:
在这里插入图片描述
400kb/s:
在这里插入图片描述
由于比特率相差不大,视频清晰程度差不多,但仔细对比1000kb/s与400kb/s的视频图像,可以看出1000kb/s的视频图像较为清晰。

生成率失真曲线

在这里插入图片描述
横坐标为不同的比特率,纵坐标为Y分量的PSNR
通过上图可以看出,GOP15-无B质量最高,GOP15-2B与GOP15-1B相差不大,GOP15-2B质量高于GOP9-2B。因此,一个GOP组内B帧越少质量越好,GOP长度越长质量越好。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值