Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Side by Side Diff: source/libvpx/warnings.c

Issue 111463005: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/warnings.h ('k') | source/libvpx/webmdec.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "./warnings.h"
12
13 #include <assert.h>
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17
18 #include "vpx/vpx_encoder.h"
19
20 #include "./tools_common.h"
21 #include "./vpxenc.h"
22
23 static const char quantizer_warning_string[] =
24 "Bad quantizer values. Quantizer values should not be equal, and should "
25 "differ by at least 8.";
26 static const char lag_in_frames_with_realtime[] =
27 "Lag in frames is ignored when deadline is set to realtime.";
28
29 struct WarningListNode {
30 const char *warning_string;
31 struct WarningListNode *next_warning;
32 };
33
34 struct WarningList {
35 struct WarningListNode *warning_node;
36 };
37
38 static void add_warning(const char *warning_string,
39 struct WarningList *warning_list) {
40 struct WarningListNode **node = &warning_list->warning_node;
41
42 struct WarningListNode *new_node = malloc(sizeof(*new_node));
43 if (new_node == NULL) {
44 fatal("Unable to allocate warning node.");
45 }
46
47 new_node->warning_string = warning_string;
48 new_node->next_warning = NULL;
49
50 while (*node != NULL)
51 node = &(*node)->next_warning;
52
53 *node = new_node;
54 }
55
56 static void free_warning_list(struct WarningList *warning_list) {
57 struct WarningListNode *node = warning_list->warning_node;
58 while (warning_list->warning_node != NULL) {
59 node = warning_list->warning_node->next_warning;
60 free(warning_list->warning_node);
61 warning_list->warning_node = node;
62 }
63 }
64
65 static int continue_prompt(int num_warnings) {
66 int c;
67 fprintf(stderr,
68 "%d encoder configuration warning(s). Continue? (y to continue) ",
69 num_warnings);
70 c = getchar();
71 return c == 'y';
72 }
73
74 static void check_lag_in_frames_realtime_deadline(
75 int lag_in_frames,
76 int deadline,
77 struct WarningList *warning_list) {
78 if (deadline == VPX_DL_REALTIME && lag_in_frames != 0)
79 add_warning(lag_in_frames_with_realtime, warning_list);
80 }
81
82 static void check_quantizer(int min_q, int max_q,
83 struct WarningList *warning_list) {
84 const int lossless = min_q == 0 && max_q == 0;
85 if (!lossless && (min_q == max_q || abs(max_q - min_q) < 8))
86 add_warning(quantizer_warning_string, warning_list);
87 }
88
89 void check_encoder_config(int disable_prompt,
90 const struct VpxEncoderConfig *global_config,
91 const struct vpx_codec_enc_cfg *stream_config) {
92 int num_warnings = 0;
93 struct WarningListNode *warning = NULL;
94 struct WarningList warning_list = {0};
95
96 check_quantizer(stream_config->rc_min_quantizer,
97 stream_config->rc_max_quantizer,
98 &warning_list);
99 check_lag_in_frames_realtime_deadline(stream_config->g_lag_in_frames,
100 global_config->deadline,
101 &warning_list);
102
103 /* Count and print warnings. */
104 for (warning = warning_list.warning_node;
105 warning != NULL;
106 warning = warning->next_warning,
107 ++num_warnings) {
108 warn(warning->warning_string);
109 }
110
111 free_warning_list(&warning_list);
112
113 if (num_warnings) {
114 if (!disable_prompt && !continue_prompt(num_warnings))
115 exit(EXIT_FAILURE);
116 }
117 }
OLDNEW
« no previous file with comments | « source/libvpx/warnings.h ('k') | source/libvpx/webmdec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698