Add sse2/avx2 version of aom_dc_top_predictor_wxh()
[aom.git] / warnings.c
blob16d5c6c18a3cc1acd3df4148d43ded6e44a734a3
1 /*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
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.
12 #include "./warnings.h"
14 #include <assert.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
19 #include "aom/aom_encoder.h"
21 #include "./tools_common.h"
22 #include "./aomenc.h"
24 static const char quantizer_warning_string[] =
25 "Bad quantizer values. Quantizer values should not be equal, and should "
26 "differ by at least 8.";
28 struct WarningListNode {
29 const char *warning_string;
30 struct WarningListNode *next_warning;
33 struct WarningList {
34 struct WarningListNode *warning_node;
37 static void add_warning(const char *warning_string,
38 struct WarningList *warning_list) {
39 struct WarningListNode **node = &warning_list->warning_node;
41 struct WarningListNode *new_node = malloc(sizeof(*new_node));
42 if (new_node == NULL) {
43 fatal("Unable to allocate warning node.");
46 new_node->warning_string = warning_string;
47 new_node->next_warning = NULL;
49 while (*node != NULL) node = &(*node)->next_warning;
51 *node = new_node;
54 static void free_warning_list(struct WarningList *warning_list) {
55 while (warning_list->warning_node != NULL) {
56 struct WarningListNode *const node = warning_list->warning_node;
57 warning_list->warning_node = node->next_warning;
58 free(node);
62 static int continue_prompt(int num_warnings) {
63 int c;
64 fprintf(stderr,
65 "%d encoder configuration warning(s). Continue? (y to continue) ",
66 num_warnings);
67 c = getchar();
68 return c == 'y';
71 static void check_quantizer(int min_q, int max_q,
72 struct WarningList *warning_list) {
73 const int lossless = min_q == 0 && max_q == 0;
74 if (!lossless && (min_q == max_q || abs(max_q - min_q) < 8))
75 add_warning(quantizer_warning_string, warning_list);
78 void check_encoder_config(int disable_prompt,
79 const struct AvxEncoderConfig *global_config,
80 const struct aom_codec_enc_cfg *stream_config) {
81 int num_warnings = 0;
82 struct WarningListNode *warning = NULL;
83 struct WarningList warning_list = { 0 };
84 (void)global_config;
85 check_quantizer(stream_config->rc_min_quantizer,
86 stream_config->rc_max_quantizer, &warning_list);
87 /* Count and print warnings. */
88 for (warning = warning_list.warning_node; warning != NULL;
89 warning = warning->next_warning, ++num_warnings) {
90 warn(warning->warning_string);
93 free_warning_list(&warning_list);
95 if (num_warnings) {
96 if (!disable_prompt && !continue_prompt(num_warnings)) exit(EXIT_FAILURE);