| 153 | } |
| 154 | |
| 155 | void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, |
| 156 | const uint32_t *mbtype_table, |
| 157 | const int8_t *qscale_table, int16_t (*const motion_val[2])[2], |
| 158 | int mb_width, int mb_height, int mb_stride, int quarter_sample) |
| 159 | { |
| 160 | const int is_h264 = avctx->codec_id == AV_CODEC_ID_H264; |
| 161 | const int mb_type_mv_flags[2] = { is_h264 ? MB_TYPE_L0 : MB_TYPE_FORWARD_MV, |
| 162 | is_h264 ? MB_TYPE_L1 : MB_TYPE_BACKWARD_MV }; |
| 163 | |
| 164 | if ((avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS) && mbtype_table && motion_val[0]) { |
| 165 | const int shift = 1 + quarter_sample; |
| 166 | const int scale = 1 << shift; |
| 167 | const int mv_sample_log2 = is_h264 ? 2 : 1; |
| 168 | const int mv_stride = (mb_width << mv_sample_log2) + !is_h264; |
| 169 | int mb_x, mb_y, mbcount = 0; |
| 170 | |
| 171 | /* size is width * height * 2 * 4 where 2 is for directions and 4 is |
| 172 | * for the maximum number of MB (4 MB in case of IS_8x8) */ |
| 173 | AVMotionVector *mvs = av_malloc_array(mb_width * mb_height, 2 * 4 * sizeof(AVMotionVector)); |
| 174 | if (!mvs) |
| 175 | return; |
| 176 | |
| 177 | for (mb_y = 0; mb_y < mb_height; mb_y++) { |
| 178 | for (mb_x = 0; mb_x < mb_width; mb_x++) { |
| 179 | int i, direction, mb_type = mbtype_table[mb_x + mb_y * mb_stride]; |
| 180 | for (direction = 0; direction < 2; direction++) { |
| 181 | if (!HAS_MV_EXT(mb_type, direction, mb_type_mv_flags)) |
| 182 | continue; |
| 183 | if (IS_8X8(mb_type)) { |
| 184 | for (i = 0; i < 4; i++) { |
| 185 | int sx = mb_x * 16 + 4 + 8 * (i & 1); |
| 186 | int sy = mb_y * 16 + 4 + 8 * (i >> 1); |
| 187 | int xy = (mb_x * 2 + (i & 1) + |
| 188 | (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1); |
| 189 | int mx = motion_val[direction][xy][0]; |
| 190 | int my = motion_val[direction][xy][1]; |
| 191 | mbcount += add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, scale, direction); |
| 192 | } |
| 193 | } else if (IS_16X8(mb_type)) { |
| 194 | for (i = 0; i < 2; i++) { |
| 195 | int sx = mb_x * 16 + 8; |
| 196 | int sy = mb_y * 16 + 4 + 8 * i; |
| 197 | int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1); |
| 198 | int mx = motion_val[direction][xy][0]; |
| 199 | int my = motion_val[direction][xy][1]; |
| 200 | |
| 201 | if (IS_INTERLACED(mb_type)) |
| 202 | my *= 2; |
| 203 | |
| 204 | mbcount += add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, scale, direction); |
| 205 | } |
| 206 | } else if (IS_8X16(mb_type)) { |
| 207 | for (i = 0; i < 2; i++) { |
| 208 | int sx = mb_x * 16 + 4 + 8 * i; |
| 209 | int sy = mb_y * 16 + 8; |
| 210 | int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1); |
| 211 | int mx = motion_val[direction][xy][0]; |
| 212 | int my = motion_val[direction][xy][1]; |
no test coverage detected