Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/third_party/aom/av1/common/debugmodes.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3
 *
4
 * This source code is subject to the terms of the BSD 2 Clause License and
5
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6
 * was not distributed with this source code in the LICENSE file, you can
7
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8
 * Media Patent License 1.0 was not distributed with this source code in the
9
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10
 */
11
12
#include <stdio.h>
13
14
#include "av1/common/blockd.h"
15
#include "av1/common/enums.h"
16
#include "av1/common/onyxc_int.h"
17
18
0
static void log_frame_info(AV1_COMMON *cm, const char *str, FILE *f) {
19
0
  fprintf(f, "%s", str);
20
0
  fprintf(f, "(Frame %d, Show:%d, Q:%d): \n", cm->current_video_frame,
21
0
          cm->show_frame, cm->base_qindex);
22
0
}
23
/* This function dereferences a pointer to the mbmi structure
24
 * and uses the passed in member offset to print out the value of an integer
25
 * for each mbmi member value in the mi structure.
26
 */
27
static void print_mi_data(AV1_COMMON *cm, FILE *file, const char *descriptor,
28
0
                          size_t member_offset) {
29
0
  int mi_row, mi_col;
30
0
  MB_MODE_INFO **mi = cm->mi_grid_visible;
31
0
  int rows = cm->mi_rows;
32
0
  int cols = cm->mi_cols;
33
0
  char prefix = descriptor[0];
34
0
35
0
  log_frame_info(cm, descriptor, file);
36
0
  for (mi_row = 0; mi_row < rows; mi_row++) {
37
0
    fprintf(file, "%c ", prefix);
38
0
    for (mi_col = 0; mi_col < cols; mi_col++) {
39
0
      fprintf(file, "%2d ", *((char *)((char *)(mi[0]) + member_offset)));
40
0
      mi++;
41
0
    }
42
0
    fprintf(file, "\n");
43
0
    mi += MAX_MIB_SIZE;
44
0
  }
45
0
  fprintf(file, "\n");
46
0
}
47
48
0
void av1_print_modes_and_motion_vectors(AV1_COMMON *cm, const char *file) {
49
0
  int mi_row;
50
0
  int mi_col;
51
0
  FILE *mvs = fopen(file, "a");
52
0
  MB_MODE_INFO **mi = cm->mi_grid_visible;
53
0
  int rows = cm->mi_rows;
54
0
  int cols = cm->mi_cols;
55
0
56
0
  print_mi_data(cm, mvs, "Partitions:", offsetof(MB_MODE_INFO, sb_type));
57
0
  print_mi_data(cm, mvs, "Modes:", offsetof(MB_MODE_INFO, mode));
58
0
  print_mi_data(cm, mvs, "Ref frame:", offsetof(MB_MODE_INFO, ref_frame[0]));
59
0
  print_mi_data(cm, mvs, "Transform:", offsetof(MB_MODE_INFO, tx_size));
60
0
  print_mi_data(cm, mvs, "UV Modes:", offsetof(MB_MODE_INFO, uv_mode));
61
0
62
0
  // output skip infomation.
63
0
  log_frame_info(cm, "Skips:", mvs);
64
0
  for (mi_row = 0; mi_row < rows; mi_row++) {
65
0
    fprintf(mvs, "S ");
66
0
    for (mi_col = 0; mi_col < cols; mi_col++) {
67
0
      fprintf(mvs, "%2d ", mi[0]->skip);
68
0
      mi++;
69
0
    }
70
0
    fprintf(mvs, "\n");
71
0
    mi += MAX_MIB_SIZE;
72
0
  }
73
0
  fprintf(mvs, "\n");
74
0
75
0
  // output motion vectors.
76
0
  log_frame_info(cm, "Vectors ", mvs);
77
0
  mi = cm->mi_grid_visible;
78
0
  for (mi_row = 0; mi_row < rows; mi_row++) {
79
0
    fprintf(mvs, "V ");
80
0
    for (mi_col = 0; mi_col < cols; mi_col++) {
81
0
      fprintf(mvs, "%4d:%4d ", mi[0]->mv[0].as_mv.row, mi[0]->mv[0].as_mv.col);
82
0
      mi++;
83
0
    }
84
0
    fprintf(mvs, "\n");
85
0
    mi += MAX_MIB_SIZE;
86
0
  }
87
0
  fprintf(mvs, "\n");
88
0
89
0
  fclose(mvs);
90
0
}
91
92
void av1_print_uncompressed_frame_header(const uint8_t *data, int size,
93
0
                                         const char *filename) {
94
0
  FILE *hdrFile = fopen(filename, "w");
95
0
  fwrite(data, size, sizeof(uint8_t), hdrFile);
96
0
  fclose(hdrFile);
97
0
}
98
99
0
void av1_print_frame_contexts(const FRAME_CONTEXT *fc, const char *filename) {
100
0
  FILE *fcFile = fopen(filename, "w");
101
0
  const uint16_t *fcp = (uint16_t *)fc;
102
0
  const unsigned int n_contexts = sizeof(FRAME_CONTEXT) / sizeof(uint16_t);
103
0
  unsigned int i;
104
0
105
0
  for (i = 0; i < n_contexts; ++i) fprintf(fcFile, "%d ", *fcp++);
106
0
  fclose(fcFile);
107
0
}