History

examples: use die() on dec/enc_init() failure

rather than die_codec(). calling any api functions with an uninitialized codec context is undefined. this avoids a crash in a call to vpx_codec_error_detail(). BUG=webm:1688

James Zern committed 6 years ago

Commit cbc276a1 parent b130f7110 files · +12 −12Browse files

Unified · Split

10 files
  1. examples/decode_with_drops.c +1 −1
  2. examples/postproc.c +2 −2
  3. examples/set_maps.c +1 −1
  4. examples/simple_decoder.c +1 −1
  5. examples/simple_encoder.c +1 −1
  6. examples/twopass_encoder.c +2 −2
  7. examples/vp8cx_set_ref.c +1 −1
  8. examples/vp9_lossless_encoder.c +1 −1
  9. examples/vp9cx_set_ref.c +1 −1
  10. examples/vpx_temporal_svc_encoder.c +1 −1
examples/decode_with_drops.c+1−1
@@ -106,7 +106,7 @@ int main(int argc, char **argv) { · 105 unmodified lines
106 printf("Using %s\n", vpx_codec_iface_name(decoder->codec_interface()));106 printf("Using %s\n", vpx_codec_iface_name(decoder->codec_interface()));
107 107
108 if (vpx_codec_dec_init(&codec, decoder->codec_interface(), NULL, 0))108 if (vpx_codec_dec_init(&codec, decoder->codec_interface(), NULL, 0))
109 die_codec(&codec, "Failed to initialize decoder.");109 die("Failed to initialize decoder.");
110 110
111 while (vpx_video_reader_read_frame(reader)) {111 while (vpx_video_reader_read_frame(reader)) {
112 vpx_codec_iter_t iter = NULL;112 vpx_codec_iter_t iter = NULL;
examples/postproc.c+2−2
@@ -86,9 +86,9 @@ int main(int argc, char **argv) { · 85 unmodified lines
86 res = vpx_codec_dec_init(&codec, decoder->codec_interface(), NULL,86 res = vpx_codec_dec_init(&codec, decoder->codec_interface(), NULL,
87 VPX_CODEC_USE_POSTPROC);87 VPX_CODEC_USE_POSTPROC);
88 if (res == VPX_CODEC_INCAPABLE)88 if (res == VPX_CODEC_INCAPABLE)
89 die_codec(&codec, "Postproc not supported by this decoder.");89 die("Postproc not supported by this decoder.");
90 90
91 if (res) die_codec(&codec, "Failed to initialize decoder.");91 if (res) die("Failed to initialize decoder.");
92 92
93 while (vpx_video_reader_read_frame(reader)) {93 while (vpx_video_reader_read_frame(reader)) {
94 vpx_codec_iter_t iter = NULL;94 vpx_codec_iter_t iter = NULL;
examples/set_maps.c+1−1
@@ -209,7 +209,7 @@ int main(int argc, char **argv) { · 208 unmodified lines
209 die("Failed to open %s for reading.", argv[4]);209 die("Failed to open %s for reading.", argv[4]);
210 210
211 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))211 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
212 die_codec(&codec, "Failed to initialize encoder");212 die("Failed to initialize encoder");
213 213
214 // Encode frames.214 // Encode frames.
215 while (vpx_img_read(&raw, infile)) {215 while (vpx_img_read(&raw, infile)) {
examples/simple_decoder.c+1−1
@@ -118,7 +118,7 @@ int main(int argc, char **argv) { · 117 unmodified lines
118 printf("Using %s\n", vpx_codec_iface_name(decoder->codec_interface()));118 printf("Using %s\n", vpx_codec_iface_name(decoder->codec_interface()));
119 119
120 if (vpx_codec_dec_init(&codec, decoder->codec_interface(), NULL, 0))120 if (vpx_codec_dec_init(&codec, decoder->codec_interface(), NULL, 0))
121 die_codec(&codec, "Failed to initialize decoder.");121 die("Failed to initialize decoder.");
122 122
123 while (vpx_video_reader_read_frame(reader)) {123 while (vpx_video_reader_read_frame(reader)) {
124 vpx_codec_iter_t iter = NULL;124 vpx_codec_iter_t iter = NULL;
examples/simple_encoder.c+1−1
@@ -218,7 +218,7 @@ int main(int argc, char **argv) { · 217 unmodified lines
218 die("Failed to open %s for reading.", infile_arg);218 die("Failed to open %s for reading.", infile_arg);
219 219
220 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))220 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
221 die_codec(&codec, "Failed to initialize encoder");221 die("Failed to initialize encoder");
222 222
223 // Encode frames.223 // Encode frames.
224 while (vpx_img_read(&raw, infile)) {224 while (vpx_img_read(&raw, infile)) {
examples/twopass_encoder.c+2−2
@@ -128,7 +128,7 @@ static vpx_fixed_buf_t pass0(vpx_image_t *raw, FILE *infile, · 127 unmodified lines
128 vpx_fixed_buf_t stats = { NULL, 0 };128 vpx_fixed_buf_t stats = { NULL, 0 };
129 129
130 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), cfg, 0))130 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), cfg, 0))
131 die_codec(&codec, "Failed to initialize encoder");131 die("Failed to initialize encoder");
132 132
133 // Calculate frame statistics.133 // Calculate frame statistics.
134 while (vpx_img_read(raw, infile)) {134 while (vpx_img_read(raw, infile)) {
@@ -164,7 +164,7 @@ static void pass1(vpx_image_t *raw, FILE *infile, const char *outfile_name, · 29 unmodified lines
164 if (!writer) die("Failed to open %s for writing", outfile_name);164 if (!writer) die("Failed to open %s for writing", outfile_name);
165 165
166 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), cfg, 0))166 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), cfg, 0))
167 die_codec(&codec, "Failed to initialize encoder");167 die("Failed to initialize encoder");
168 168
169 // Encode frames.169 // Encode frames.
170 while (vpx_img_read(raw, infile)) {170 while (vpx_img_read(raw, infile)) {
examples/vp8cx_set_ref.c+1−1
@@ -155,7 +155,7 @@ int main(int argc, char **argv) { · 154 unmodified lines
155 die("Failed to open %s for reading.", argv[3]);155 die("Failed to open %s for reading.", argv[3]);
156 156
157 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))157 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
158 die_codec(&codec, "Failed to initialize encoder");158 die("Failed to initialize encoder");
159 159
160 // Encode frames.160 // Encode frames.
161 while (vpx_img_read(&raw, infile)) {161 while (vpx_img_read(&raw, infile)) {
examples/vp9_lossless_encoder.c+1−1
@@ -110,7 +110,7 @@ int main(int argc, char **argv) { · 109 unmodified lines
110 die("Failed to open %s for reading.", argv[3]);110 die("Failed to open %s for reading.", argv[3]);
111 111
112 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))112 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
113 die_codec(&codec, "Failed to initialize encoder");113 die("Failed to initialize encoder");
114 114
115 if (vpx_codec_control_(&codec, VP9E_SET_LOSSLESS, 1))115 if (vpx_codec_control_(&codec, VP9E_SET_LOSSLESS, 1))
116 die_codec(&codec, "Failed to use lossless mode");116 die_codec(&codec, "Failed to use lossless mode");
examples/vp9cx_set_ref.c+1−1
@@ -251,7 +251,7 @@ int main(int argc, char **argv) { · 250 unmodified lines
251 die("Failed to open %s for reading.", infile_arg);251 die("Failed to open %s for reading.", infile_arg);
252 252
253 if (vpx_codec_enc_init(&ecodec, encoder->codec_interface(), &cfg, 0))253 if (vpx_codec_enc_init(&ecodec, encoder->codec_interface(), &cfg, 0))
254 die_codec(&ecodec, "Failed to initialize encoder");254 die("Failed to initialize encoder");
255 255
256 // Disable alt_ref.256 // Disable alt_ref.
257 if (vpx_codec_control(&ecodec, VP8E_SET_ENABLEAUTOALTREF, 0))257 if (vpx_codec_control(&ecodec, VP8E_SET_ENABLEAUTOALTREF, 0))
examples/vpx_temporal_svc_encoder.c+1−1
@@ -815,7 +815,7 @@ int main(int argc, char **argv) { · 814 unmodified lines
815#else815#else
816 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))816 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
817#endif // CONFIG_VP9_HIGHBITDEPTH817#endif // CONFIG_VP9_HIGHBITDEPTH
818 die_codec(&codec, "Failed to initialize encoder");818 die("Failed to initialize encoder");
819 819
820 if (strncmp(encoder->name, "vp8", 3) == 0) {820 if (strncmp(encoder->name, "vp8", 3) == 0) {
821 vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed);821 vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t