From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 9B29540925 for ; Thu, 1 Sep 2022 00:26:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7770768B8CC; Thu, 1 Sep 2022 03:26:20 +0300 (EEST) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F261168B4CC for ; Thu, 1 Sep 2022 03:26:13 +0300 (EEST) Received: by mail-pj1-f41.google.com with SMTP id o4so15645565pjp.4 for ; Wed, 31 Aug 2022 17:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=kd5hKaww8CwfyExtLp428QwZj9BTOi9h3pu7zi/G4kU=; b=Y31n7qaLxccMmLIoOm2GhaaRWhfvXK/wT18QeaJ9Rcq9r50t/CithcKuVtLovaVNaK swDzO68sxo/e52ftplRfyjBBacKDluGeQEqYccryZK9xxDH7ql/6KN52sUNoVuFy1JK1 uwX6CNjlw7db8kNH6Zbj1y5Wve1P8n6dAAk7/tVkZw+kEiCH7eYoKwZ/K5W6yIZxmFgM rEjfh3lnSs82AKn9nEMOkSbLIYsPj7TIB2mc4KvEWGilse9l4FjGP7/FW6cNsS4F8tpv gQc/qCjyF85EzyEowdN2vWMC6IaacSsHxZeDjyhe+8vZBR2ZXPpOPK7eZQ2bSFJRxi/r mquA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=kd5hKaww8CwfyExtLp428QwZj9BTOi9h3pu7zi/G4kU=; b=oOpGweQ77eDBg7aJgEe+YXDwhg6yPj0M0FWm7tZ4khfLSsY/PEpTVm4Ddnfjy37Qyk 6dRX4Xg2AHpEzu0Zxe6NOtoR3M4ZOtfMkPNCQ3BOJPpRzXYzywHYpkFYqeT8wnhrdHvZ JamuHvSE6A0sRBuwHDKoLMh3BrBEnfEdfbYjb5m3UZW4jHOSmqLwkjIK0QYqljpwMC2M Dj9ke17g+HOSeX5pbefrnfdG9KV28YDQWgbAVjmxF5Mwb7kxHpTdQ/B0Tje+b4NXSqqV oVMDj/VcXHFT0S0449FXW25F2n6+iznGWjRtd04Ps6jaz9sb3fw8G9L1/n/BC9hZ8O/q tUnw== X-Gm-Message-State: ACgBeo31PTrXdvQFRUAf4Vv1v2SDsSWUuti66iCrd5MbjGS7Rz9R9hzg LXJK7JnCiZ0aNfblCgTtO3DxeSSLJAE= X-Google-Smtp-Source: AA6agR5MIxJmLPLWqN/QPVvA0rPXV12lATcB3CdUT26tBwZDzMwQxvkZ5vg1jLyxJVAiiHOp4dx7lw== X-Received: by 2002:a17:902:f80f:b0:174:e9a9:7b84 with SMTP id ix15-20020a170902f80f00b00174e9a97b84mr14057921plb.47.1661991971538; Wed, 31 Aug 2022 17:26:11 -0700 (PDT) Received: from wilferico.thefacebook.com ([2620:10d:c090:400::5:62d5]) by smtp.gmail.com with ESMTPSA id r15-20020aa7962f000000b0053674c0f9d2sm11924307pfg.116.2022.08.31.17.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 17:26:10 -0700 (PDT) From: Chema Gonzalez To: ffmpeg-devel@ffmpeg.org Date: Wed, 31 Aug 2022 17:26:08 -0700 Message-Id: <20220901002608.1763390-1-chemag@gmail.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/1] avcodec/mpegutils: add motion_vec debug mode X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Chema Gonzalez Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Add a new debug mode ("motion_vec") that prints the values of the motion vectors (MV). Note that, in order to give the same weight to MV from bigger blocks, we may print each MV pair more than once. Tested: ``` $ ./ffprobe -v quiet -show_frames -debug motion_vec /tmp/in.264 \ 2>&1 >/dev/null ... [h264 @ ...] nal_unit_type: 1(Coded slice of a non-IDR picture), ... [h264 @ ...] New frame, type: I [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] nal_unit_type: 1(Coded slice of a non-IDR picture), ... [h264 @ ...] nal_unit_type: 1(Coded slice of a non-IDR picture), ... [h264 @ ...] New frame, type: B [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] 0 0 0 0 0 0 0 0 0 0 0 0... [h264 @ ...] nal_unit_type: 1(Coded slice of a non-IDR picture), ... ... ``` --- libavcodec/avcodec.h | 1 + libavcodec/mpegutils.c | 45 +++++++++++++++++++++++++++++++++++++- libavcodec/options_table.h | 1 + 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 65c8535359..4287555a31 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1344,6 +1344,7 @@ typedef struct AVCodecContext { #define FF_DEBUG_THREADS 0x00010000 #define FF_DEBUG_GREEN_MD 0x00800000 #define FF_DEBUG_NOMC 0x01000000 +#define FF_DEBUG_MOTION_VEC 0x02000000 /** * Error recognition; may misdetect some more or less valid parts as errors. diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c index ff9418232b..d0a94784fb 100644 --- a/libavcodec/mpegutils.c +++ b/libavcodec/mpegutils.c @@ -246,8 +246,11 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, return; - if (avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) { + if (avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE | FF_DEBUG_MOTION_VEC)) { int x,y; + 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); av_log(avctx, AV_LOG_DEBUG, "New frame, type: %c\n", av_get_picture_type_char(pict->pict_type)); @@ -271,6 +274,46 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, get_segmentation_char(mb_type), get_interlacement_char(mb_type)); } + if (avctx->debug & FF_DEBUG_MOTION_VEC) { + int i, direction, mb_type = mbtype_table[x + y * mb_stride]; + if (IS_8X8(mb_type)) { + for (i = 0; i < 4; i++) { + int xy = (x * 2 + (i & 1) + + (y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1); + int mx = motion_val[direction][xy][0]; + int my = motion_val[direction][xy][1]; + av_log(avctx, AV_LOG_DEBUG, "%4d %4d", mx, my); + } + } else if (IS_16X8(mb_type)) { + for (i = 0; i < 2; i++) { + int xy = (x * 2 + (y * 2 + i) * mv_stride) << (mv_sample_log2 - 1); + int mx = motion_val[direction][xy][0]; + int my = motion_val[direction][xy][1]; + if (IS_INTERLACED(mb_type)) + my *= 2; + av_log(avctx, AV_LOG_DEBUG, "%4d %4d", mx, my); + av_log(avctx, AV_LOG_DEBUG, "%4d %4d", mx, my); + } + } else if (IS_8X16(mb_type)) { + for (i = 0; i < 2; i++) { + int xy = (x * 2 + i + y * 2 * mv_stride) << (mv_sample_log2 - 1); + int mx = motion_val[direction][xy][0]; + int my = motion_val[direction][xy][1]; + if (IS_INTERLACED(mb_type)) + my *= 2; + av_log(avctx, AV_LOG_DEBUG, "%4d %4d", mx, my); + av_log(avctx, AV_LOG_DEBUG, "%4d %4d", mx, my); + } + } else { + int xy = (x + y * mv_stride) << mv_sample_log2; + int mx = motion_val[direction][xy][0]; + int my = motion_val[direction][xy][1]; + av_log(avctx, AV_LOG_DEBUG, "%4d %4d", mx, my); + av_log(avctx, AV_LOG_DEBUG, "%4d %4d", mx, my); + av_log(avctx, AV_LOG_DEBUG, "%4d %4d", mx, my); + av_log(avctx, AV_LOG_DEBUG, "%4d %4d", mx, my); + } + } } av_log(avctx, AV_LOG_DEBUG, "\n"); } diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index cd02f5096f..0d100069e1 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -198,6 +198,7 @@ static const AVOption avcodec_options[] = { {"startcode", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_STARTCODE }, INT_MIN, INT_MAX, V|D, "debug"}, {"er", "error recognition", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_ER }, INT_MIN, INT_MAX, V|D, "debug"}, {"mmco", "memory management control operations (H.264)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_MMCO }, INT_MIN, INT_MAX, V|D, "debug"}, +{"motion_vec", "macroblock (MB) motion vector values", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_MOTION_VEC }, INT_MIN, INT_MAX, V|D, "debug"}, {"bugs", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_BUGS }, INT_MIN, INT_MAX, V|D, "debug"}, {"buffers", "picture buffer allocations", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_BUFFERS }, INT_MIN, INT_MAX, V|D, "debug"}, {"thread_ops", "threading operations", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_THREADS }, INT_MIN, INT_MAX, V|A|D, "debug"}, -- 2.37.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".