1 /*
2  * Copyright 2016 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef GUETZLI_DEBUG_PRINT_H_
18 #define GUETZLI_DEBUG_PRINT_H_
19 
20 #include "guetzli/stats.h"
21 
22 namespace guetzli {
23 
24 void PrintDebug(ProcessStats* stats, std::string s);
25 
26 }  // namespace guetzli
27 
28 #define GUETZLI_LOG(stats, ...)                                    \
29   do {                                                             \
30     char debug_string[1024];                                       \
31     snprintf(debug_string, sizeof(debug_string), __VA_ARGS__);     \
32     debug_string[sizeof(debug_string) - 1] = '\0';                 \
33     ::guetzli::PrintDebug(                      \
34          stats, std::string(debug_string));        \
35   } while (0)
36 #define GUETZLI_LOG_QUANT(stats, q)                    \
37   for (int y = 0; y < 8; ++y) {                        \
38     for (int c = 0; c < 3; ++c) {                      \
39       for (int x = 0; x < 8; ++x)                      \
40         GUETZLI_LOG(stats, " %2d", (q)[c][8 * y + x]); \
41       GUETZLI_LOG(stats, "   ");                       \
42     }                                                  \
43     GUETZLI_LOG(stats, "\n");                          \
44   }
45 
46 #endif  // GUETZLI_DEBUG_PRINT_H_
47