http://blog.sina.com.cn/wangsu820[订阅][手机订阅]
字体大小: 正文
FFmpeg中MPEG-4编码程序追踪 [原创](2009-03-30 03:24:02)

FFmpeg中与MPEG-4编码相关的主要文件有mpegvideo.c,h263.c等。

在mpegvideo.c中,
AVCodec mpeg4_encoder = {
    "mpeg4",
    CODEC_TYPE_VIDEO,
    CODEC_ID_MPEG4,
    sizeof(MpegEncContext),
    MPV_encode_init,
    MPV_encode_picture,
    MPV_encode_end,
    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
    .capabilities= CODEC_CAP_DELAY,
};

MPV_encode_picture()
{
 encode_picture();
}

encode_picture()
{
 //对每个宏块MB进行运动估计
 estimate_motion_thread();

 encode_thread();
}

encode_thread()
{
 encode_mb_hq();
}

encode_mb_hq()
{
 encode_mb();
}

encode_mb()
{
 encode_mb_internal();
}

encode_mb_internal()
{
 //对单一的宏块进行运动补偿
 MPV_motion();

 //DCT & quantize
 dct_quantize_c();

 //huffman encode
 mpeg4_encode_mb();
}

帧内和帧间的量化矩阵在mpeg4data.h中
const int16_t ff_mpeg4_default_intra_matrix[64] = {
  8, 17, 18, 19, 21, 23, 25, 27,
 17, 18, 19, 21, 23, 25, 27, 28,
 20, 21, 22, 23, 24, 26, 28, 30,
 21, 22, 23, 24, 26, 28, 30, 32,
 22, 23, 24, 26, 28, 30, 32, 35,
 23, 24, 26, 28, 30, 32, 35, 38,
 25, 26, 28, 30, 32, 35, 38, 41,
 27, 28, 30, 32, 35, 38, 41, 45,
};

const int16_t ff_mpeg4_default_non_intra_matrix[64] = {
 16, 17, 18, 19, 20, 21, 22, 23,
 17, 18, 19, 20, 21, 22, 23, 24,
 18, 19, 20, 21, 22, 23, 24, 25,
 19, 20, 21, 22, 23, 24, 26, 27,
 20, 21, 22, 23, 25, 26, 27, 28,
 21, 22, 23, 24, 26, 27, 28, 30,
 22, 23, 24, 26, 27, 28, 30, 31,
 23, 24, 25, 27, 28, 30, 31, 33,
};

加载中,请稍候...
  • 评论加载中,请稍候...

验证码:请点击后输入验证码  收听验证码

发评论

以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

相关博文
读取中...
推荐博文
读取中...