我试图理解 ffmpeg 绘制运动 vector 的方式。
我浏览了 vf_codecview.c
文件并看到了函数 draw_arrow
它仅采用那些 source > 0
暗示仅来自 future 的 vector 。
有谁知道这是为什么吗?如果 ffmpeg 通过这个文件只计算 future ,那么计算过去和 future 有什么用呢?
最佳答案
事实并非如此
source
可以采用正值或负值。
/**
* Where the current macroblock comes from; negative value when it comes
* from the past, positive value when it comes from the future.
* XXX: set exact relative ref frame reference instead of a +/- 1 "direction".
*/
int32_t source;
在您链接到的通话中,我们有
if ((direction == 0 && (s->mv & MV_P_FOR) && frame->pict_type == AV_PICTURE_TYPE_P) ||
(direction == 0 && (s->mv & MV_B_FOR) && frame->pict_type == AV_PICTURE_TYPE_B) ||
(direction == 1 && (s->mv & MV_B_BACK) && frame->pict_type == AV_PICTURE_TYPE_B))
draw_arrow(frame->data[0], mv->dst_x, mv->dst_y, mv->src_x, mv->src_y,
frame->width, frame->height, frame->linesize[0],
100, 0, mv->source > 0);
如果宏 block 是根据过去的帧预测的,则最后一个表达式的计算结果为 0
并作为 0
传递,否则为 1
。
条件显然允许过去和 future 预测的宏 block 。
附注您正在查看版本 2.5
的源代码,此时该版本已经非常旧了。当前版本位于 https://ffmpeg.org/doxygen/trunk/vf__codecview_8c_source.html#l00256
关于c - vf_codecview.c 仅打印 'future' 中的运动 vector ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48902338/