vf_codecview.c 仅在 'future' 中打印运动矢量

vf_codecview.c printing motion vectors in 'future' only

我正在尝试了解 ffmpeg 绘制运动矢量的方式。

我浏览了 vf_codecview.c 文件并看到了函数 draw_arrow,它只接受那些向量,其中 source > 0 仅暗示来自未来的向量。

有人知道这是为什么吗?如果ffmpeg通过这个文件只取未来,计算过去和未来有什么用?

似乎并非如此

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);

如果宏块是根据过去的帧预测的,则最后一个表达式的计算结果为 0 并作为 0 传递,否则 1.

条件显然允许过去和未来预测的宏块。

P.S。此时您正在查看版本 2.5 的源代码,它非常旧。当前版本在 https://ffmpeg.org/doxygen/trunk/vf__codecview_8c_source.html#l00256