|
|
@@ -1418,134 +1418,6 @@ void ff_mpv_frame_end(MpegEncContext *s) |
|
|
|
ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if FF_API_VISMV |
|
|
|
static int clip_line(int *sx, int *sy, int *ex, int *ey, int maxx) |
|
|
|
{ |
|
|
|
if(*sx > *ex) |
|
|
|
return clip_line(ex, ey, sx, sy, maxx); |
|
|
|
|
|
|
|
if (*sx < 0) { |
|
|
|
if (*ex < 0) |
|
|
|
return 1; |
|
|
|
*sy = *ey + (*sy - *ey) * (int64_t)*ex / (*ex - *sx); |
|
|
|
*sx = 0; |
|
|
|
} |
|
|
|
|
|
|
|
if (*ex > maxx) { |
|
|
|
if (*sx > maxx) |
|
|
|
return 1; |
|
|
|
*ey = *sy + (*ey - *sy) * (int64_t)(maxx - *sx) / (*ex - *sx); |
|
|
|
*ex = maxx; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Draw a line from (ex, ey) -> (sx, sy). |
|
|
|
* @param w width of the image |
|
|
|
* @param h height of the image |
|
|
|
* @param stride stride/linesize of the image |
|
|
|
* @param color color of the arrow |
|
|
|
*/ |
|
|
|
static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, |
|
|
|
int w, int h, int stride, int color) |
|
|
|
{ |
|
|
|
int x, y, fr, f; |
|
|
|
|
|
|
|
if (clip_line(&sx, &sy, &ex, &ey, w - 1)) |
|
|
|
return; |
|
|
|
if (clip_line(&sy, &sx, &ey, &ex, h - 1)) |
|
|
|
return; |
|
|
|
|
|
|
|
sx = av_clip(sx, 0, w - 1); |
|
|
|
sy = av_clip(sy, 0, h - 1); |
|
|
|
ex = av_clip(ex, 0, w - 1); |
|
|
|
ey = av_clip(ey, 0, h - 1); |
|
|
|
|
|
|
|
buf[sy * stride + sx] += color; |
|
|
|
|
|
|
|
if (FFABS(ex - sx) > FFABS(ey - sy)) { |
|
|
|
if (sx > ex) { |
|
|
|
FFSWAP(int, sx, ex); |
|
|
|
FFSWAP(int, sy, ey); |
|
|
|
} |
|
|
|
buf += sx + sy * stride; |
|
|
|
ex -= sx; |
|
|
|
f = ((ey - sy) << 16) / ex; |
|
|
|
for (x = 0; x <= ex; x++) { |
|
|
|
y = (x * f) >> 16; |
|
|
|
fr = (x * f) & 0xFFFF; |
|
|
|
buf[y * stride + x] += (color * (0x10000 - fr)) >> 16; |
|
|
|
if(fr) buf[(y + 1) * stride + x] += (color * fr ) >> 16; |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (sy > ey) { |
|
|
|
FFSWAP(int, sx, ex); |
|
|
|
FFSWAP(int, sy, ey); |
|
|
|
} |
|
|
|
buf += sx + sy * stride; |
|
|
|
ey -= sy; |
|
|
|
if (ey) |
|
|
|
f = ((ex - sx) << 16) / ey; |
|
|
|
else |
|
|
|
f = 0; |
|
|
|
for(y= 0; y <= ey; y++){ |
|
|
|
x = (y*f) >> 16; |
|
|
|
fr = (y*f) & 0xFFFF; |
|
|
|
buf[y * stride + x] += (color * (0x10000 - fr)) >> 16; |
|
|
|
if(fr) buf[y * stride + x + 1] += (color * fr ) >> 16; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Draw an arrow from (ex, ey) -> (sx, sy). |
|
|
|
* @param w width of the image |
|
|
|
* @param h height of the image |
|
|
|
* @param stride stride/linesize of the image |
|
|
|
* @param color color of the arrow |
|
|
|
*/ |
|
|
|
static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, |
|
|
|
int ey, int w, int h, int stride, int color, int tail, int direction) |
|
|
|
{ |
|
|
|
int dx,dy; |
|
|
|
|
|
|
|
if (direction) { |
|
|
|
FFSWAP(int, sx, ex); |
|
|
|
FFSWAP(int, sy, ey); |
|
|
|
} |
|
|
|
|
|
|
|
sx = av_clip(sx, -100, w + 100); |
|
|
|
sy = av_clip(sy, -100, h + 100); |
|
|
|
ex = av_clip(ex, -100, w + 100); |
|
|
|
ey = av_clip(ey, -100, h + 100); |
|
|
|
|
|
|
|
dx = ex - sx; |
|
|
|
dy = ey - sy; |
|
|
|
|
|
|
|
if (dx * dx + dy * dy > 3 * 3) { |
|
|
|
int rx = dx + dy; |
|
|
|
int ry = -dx + dy; |
|
|
|
int length = ff_sqrt((rx * rx + ry * ry) << 8); |
|
|
|
|
|
|
|
// FIXME subpixel accuracy |
|
|
|
rx = ROUNDED_DIV(rx * 3 << 4, length); |
|
|
|
ry = ROUNDED_DIV(ry * 3 << 4, length); |
|
|
|
|
|
|
|
if (tail) { |
|
|
|
rx = -rx; |
|
|
|
ry = -ry; |
|
|
|
} |
|
|
|
|
|
|
|
draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color); |
|
|
|
draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color); |
|
|
|
} |
|
|
|
draw_line(buf, sx, sy, ex, ey, w, h, stride, color); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
static int add_mb(AVMotionVector *mb, uint32_t mb_type, |
|
|
|
int dst_x, int dst_y, |
|
|
|
int motion_x, int motion_y, int motion_scale, |
|
|
@@ -1737,12 +1609,6 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_ |
|
|
|
int mb_y; |
|
|
|
int i; |
|
|
|
int h_chroma_shift, v_chroma_shift, block_height; |
|
|
|
#if FF_API_VISMV |
|
|
|
const int shift = 1 + quarter_sample; |
|
|
|
uint8_t *ptr; |
|
|
|
const int width = avctx->width; |
|
|
|
const int height = avctx->height; |
|
|
|
#endif |
|
|
|
const int mv_sample_log2 = avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_SVQ3 ? 2 : 1; |
|
|
|
const int mv_stride = (mb_width << mv_sample_log2) + |
|
|
|
(avctx->codec->id == AV_CODEC_ID_H264 ? 0 : 1); |
|
|
@@ -1755,96 +1621,12 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_ |
|
|
|
av_frame_make_writable(pict); |
|
|
|
|
|
|
|
pict->opaque = NULL; |
|
|
|
#if FF_API_VISMV |
|
|
|
ptr = pict->data[0]; |
|
|
|
#endif |
|
|
|
block_height = 16 >> v_chroma_shift; |
|
|
|
|
|
|
|
for (mb_y = 0; mb_y < mb_height; mb_y++) { |
|
|
|
int mb_x; |
|
|
|
for (mb_x = 0; mb_x < mb_width; mb_x++) { |
|
|
|
const int mb_index = mb_x + mb_y * mb_stride; |
|
|
|
#if FF_API_VISMV |
|
|
|
if ((avctx->debug_mv) && motion_val[0]) { |
|
|
|
int type; |
|
|
|
for (type = 0; type < 3; type++) { |
|
|
|
int direction = 0; |
|
|
|
switch (type) { |
|
|
|
case 0: |
|
|
|
if ((!(avctx->debug_mv & FF_DEBUG_VIS_MV_P_FOR)) || |
|
|
|
(pict->pict_type!= AV_PICTURE_TYPE_P)) |
|
|
|
continue; |
|
|
|
direction = 0; |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
if ((!(avctx->debug_mv & FF_DEBUG_VIS_MV_B_FOR)) || |
|
|
|
(pict->pict_type!= AV_PICTURE_TYPE_B)) |
|
|
|
continue; |
|
|
|
direction = 0; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
if ((!(avctx->debug_mv & FF_DEBUG_VIS_MV_B_BACK)) || |
|
|
|
(pict->pict_type!= AV_PICTURE_TYPE_B)) |
|
|
|
continue; |
|
|
|
direction = 1; |
|
|
|
break; |
|
|
|
} |
|
|
|
if (!USES_LIST(mbtype_table[mb_index], direction)) |
|
|
|
continue; |
|
|
|
|
|
|
|
if (IS_8X8(mbtype_table[mb_index])) { |
|
|
|
int i; |
|
|
|
for (i = 0; i < 4; i++) { |
|
|
|
int sx = mb_x * 16 + 4 + 8 * (i & 1); |
|
|
|
int sy = mb_y * 16 + 4 + 8 * (i >> 1); |
|
|
|
int xy = (mb_x * 2 + (i & 1) + |
|
|
|
(mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1); |
|
|
|
int mx = (motion_val[direction][xy][0] >> shift) + sx; |
|
|
|
int my = (motion_val[direction][xy][1] >> shift) + sy; |
|
|
|
draw_arrow(ptr, sx, sy, mx, my, width, |
|
|
|
height, pict->linesize[0], 100, 0, direction); |
|
|
|
} |
|
|
|
} else if (IS_16X8(mbtype_table[mb_index])) { |
|
|
|
int i; |
|
|
|
for (i = 0; i < 2; i++) { |
|
|
|
int sx = mb_x * 16 + 8; |
|
|
|
int sy = mb_y * 16 + 4 + 8 * i; |
|
|
|
int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1); |
|
|
|
int mx = (motion_val[direction][xy][0] >> shift); |
|
|
|
int my = (motion_val[direction][xy][1] >> shift); |
|
|
|
|
|
|
|
if (IS_INTERLACED(mbtype_table[mb_index])) |
|
|
|
my *= 2; |
|
|
|
|
|
|
|
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width, |
|
|
|
height, pict->linesize[0], 100, 0, direction); |
|
|
|
} |
|
|
|
} else if (IS_8X16(mbtype_table[mb_index])) { |
|
|
|
int i; |
|
|
|
for (i = 0; i < 2; i++) { |
|
|
|
int sx = mb_x * 16 + 4 + 8 * i; |
|
|
|
int sy = mb_y * 16 + 8; |
|
|
|
int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1); |
|
|
|
int mx = motion_val[direction][xy][0] >> shift; |
|
|
|
int my = motion_val[direction][xy][1] >> shift; |
|
|
|
|
|
|
|
if (IS_INTERLACED(mbtype_table[mb_index])) |
|
|
|
my *= 2; |
|
|
|
|
|
|
|
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width, |
|
|
|
height, pict->linesize[0], 100, 0, direction); |
|
|
|
} |
|
|
|
} else { |
|
|
|
int sx= mb_x * 16 + 8; |
|
|
|
int sy= mb_y * 16 + 8; |
|
|
|
int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2; |
|
|
|
int mx= (motion_val[direction][xy][0]>>shift) + sx; |
|
|
|
int my= (motion_val[direction][xy][1]>>shift) + sy; |
|
|
|
draw_arrow(ptr, sx, sy, mx, my, width, height, pict->linesize[0], 100, 0, direction); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
if ((avctx->debug & FF_DEBUG_VIS_QP)) { |
|
|
|
uint64_t c = (qscale_table[mb_index] * 128 / 31) * |
|
|
|
0x0101010101010101ULL; |
|
|
|