gpt4 book ai didi

ffmpeg - ffmpeg中的h264 intra4x4 pred模式解码

转载 作者:行者123 更新时间:2023-12-04 22:55:58 25 4
gpt4 key购买 nike

我对 libavcodec/h264_cavlc.c 中的以下代码感到困惑
这是ffmpeg的h264解码器的一部分。

int ff_h264_decode_mb_cavlc(const H264Context *h, H264SliceContext *sl)
.
.
.
if(IS_INTRA4x4(mb_type)){
int i;
int di = 1;
if(dct8x8_allowed && get_bits1(&sl->gb)){
mb_type |= MB_TYPE_8x8DCT;
di = 4;
}

// fill_intra4x4_pred_table(h);
for(i=0; i<16; i+=di){
int mode = pred_intra_mode(h, sl, i);

if(!get_bits1(&sl->gb)){
const int rem_mode= get_bits(&sl->gb, 3);
mode = rem_mode + (rem_mode >= mode);
}

if(di==4)
fill_rectangle(&sl->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1);
else
sl->intra4x4_pred_mode_cache[scan8[i]] = mode;
}
write_back_intra_pred_mode(h, sl);
if (ff_h264_check_intra4x4_pred_mode(h, sl) < 0)
return -1;
}

di == 4它只读取四种预测模式
比特流。我希望提取 16 个 pred 模式,因为
我们正在研究一个 INTRA4x4 宏 block 。

什么是函数 fill_rectangle()正在做?

最佳答案

di=4 表示我们对这个子 block 使用 8x8 DCT。仅当此宏 block 中的所有子 block 都使用 4x4 DCT 时,您最多有 16 种模式。如果您使用 8x8 DCT,则每个宏 block 最多可以有 4 个子 block 。每个 block 可以选择 8x8 或 4x4 DCT,因此每个宏 block 可以有 4(4x DCT8、0x DCT4)、7(3x DCT8、1x 2x2 DCT4)、10、13 或 16 个帧内模式编码。

对于宏 block 中的以下 4x4 矩形子 block :

a b c d
e f g h
i j k l
m n o p

scan8[] 在右下对齐的 8x5 数组中给出索引,如下所示:
x x x tl t1 t2 t3 t4
x x x l1 a b c d
x x x l2 e f g h
x x x l3 i j k l
x x x l4 m n o p

这使您可以出于上下文目的获取上方/左侧边缘,以预测当前 block 的帧内模式。 fill_rectangle 以相同的模式填充 2x2“矩形”,步幅为 8,例如a、b、e 和 f 用于左上角 8x8 DCT block 。

出于可视化目的,如果左上和右下 block 使用 8x8 DCT,则该 block 将基本上使用如下内部预测模式布局:
 A  c d
g h
i j K
m n

关于ffmpeg - ffmpeg中的h264 intra4x4 pred模式解码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34961251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com