]> granicus.if.org Git - libvpx/commitdiff
examples: use die() on dec/enc_init() failure
authorJames Zern <jzern@google.com>
Wed, 6 May 2020 20:01:57 +0000 (13:01 -0700)
committerJames Zern <jzern@google.com>
Fri, 8 May 2020 00:15:42 +0000 (17:15 -0700)
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

Change-Id: I4a4feeabc1cafa44c8d2f24587fad79e313dba6d

examples/decode_with_drops.c
examples/postproc.c
examples/set_maps.c
examples/simple_decoder.c
examples/simple_encoder.c
examples/twopass_encoder.c
examples/vp8cx_set_ref.c
examples/vp9_lossless_encoder.c
examples/vp9cx_set_ref.c
examples/vpx_temporal_svc_encoder.c

index e69e2a9f9b3a119d75489285d5a2f0b937e36536..03c79a456161858fa7affbe0203add51cda2f8ae 100644 (file)
@@ -106,7 +106,7 @@ int main(int argc, char **argv) {
   printf("Using %s\n", vpx_codec_iface_name(decoder->codec_interface()));
 
   if (vpx_codec_dec_init(&codec, decoder->codec_interface(), NULL, 0))
-    die_codec(&codec, "Failed to initialize decoder.");
+    die("Failed to initialize decoder.");
 
   while (vpx_video_reader_read_frame(reader)) {
     vpx_codec_iter_t iter = NULL;
index 15713b946a968b331411711f38a6fd3571c3d313..be999b429e7c20f12f27773f31ce4de750ba59cb 100644 (file)
@@ -86,9 +86,9 @@ int main(int argc, char **argv) {
   res = vpx_codec_dec_init(&codec, decoder->codec_interface(), NULL,
                            VPX_CODEC_USE_POSTPROC);
   if (res == VPX_CODEC_INCAPABLE)
-    die_codec(&codec, "Postproc not supported by this decoder.");
+    die("Postproc not supported by this decoder.");
 
-  if (res) die_codec(&codec, "Failed to initialize decoder.");
+  if (res) die("Failed to initialize decoder.");
 
   while (vpx_video_reader_read_frame(reader)) {
     vpx_codec_iter_t iter = NULL;
index c0c7d10e72a72cf632191bf87ef02d7077dbaf15..867e473aea4bbb984b627a90136b543d8fe005ac 100644 (file)
@@ -209,7 +209,7 @@ int main(int argc, char **argv) {
     die("Failed to open %s for reading.", argv[4]);
 
   if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
-    die_codec(&codec, "Failed to initialize encoder");
+    die("Failed to initialize encoder");
 
   // Encode frames.
   while (vpx_img_read(&raw, infile)) {
index 2bb1a05245bd3abe27fa2e46cc061ba822b0a7eb..d089e826d5b8ea4cd243460d3a0adab4de4f2f56 100644 (file)
@@ -118,7 +118,7 @@ int main(int argc, char **argv) {
   printf("Using %s\n", vpx_codec_iface_name(decoder->codec_interface()));
 
   if (vpx_codec_dec_init(&codec, decoder->codec_interface(), NULL, 0))
-    die_codec(&codec, "Failed to initialize decoder.");
+    die("Failed to initialize decoder.");
 
   while (vpx_video_reader_read_frame(reader)) {
     vpx_codec_iter_t iter = NULL;
index dde6344f8d632487b1212f23e44f98d460b0f956..dffdd6d7da3e552bda28e42aebfb1d260e6d857c 100644 (file)
@@ -218,7 +218,7 @@ int main(int argc, char **argv) {
     die("Failed to open %s for reading.", infile_arg);
 
   if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
-    die_codec(&codec, "Failed to initialize encoder");
+    die("Failed to initialize encoder");
 
   // Encode frames.
   while (vpx_img_read(&raw, infile)) {
index 4e63a7a6c9742913d6e519a96e3c05227e515fe8..3d950b2c4b9815e36950729f1aba698532579bd2 100644 (file)
@@ -128,7 +128,7 @@ static vpx_fixed_buf_t pass0(vpx_image_t *raw, FILE *infile,
   vpx_fixed_buf_t stats = { NULL, 0 };
 
   if (vpx_codec_enc_init(&codec, encoder->codec_interface(), cfg, 0))
-    die_codec(&codec, "Failed to initialize encoder");
+    die("Failed to initialize encoder");
 
   // Calculate frame statistics.
   while (vpx_img_read(raw, infile)) {
@@ -164,7 +164,7 @@ static void pass1(vpx_image_t *raw, FILE *infile, const char *outfile_name,
   if (!writer) die("Failed to open %s for writing", outfile_name);
 
   if (vpx_codec_enc_init(&codec, encoder->codec_interface(), cfg, 0))
-    die_codec(&codec, "Failed to initialize encoder");
+    die("Failed to initialize encoder");
 
   // Encode frames.
   while (vpx_img_read(raw, infile)) {
index 846477c61ef2a3c9dcac523fc71b17f7e37257f7..ca528f9e90ac9d5e21773407e8a116c275758012 100644 (file)
@@ -155,7 +155,7 @@ int main(int argc, char **argv) {
     die("Failed to open %s for reading.", argv[3]);
 
   if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
-    die_codec(&codec, "Failed to initialize encoder");
+    die("Failed to initialize encoder");
 
   // Encode frames.
   while (vpx_img_read(&raw, infile)) {
index cb5ca6bfe0b76343726ed119a9bfc01102227829..c4eb3a8b171f557a1447ed90b5ce7a6f373a76e3 100644 (file)
@@ -110,7 +110,7 @@ int main(int argc, char **argv) {
     die("Failed to open %s for reading.", argv[3]);
 
   if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
-    die_codec(&codec, "Failed to initialize encoder");
+    die("Failed to initialize encoder");
 
   if (vpx_codec_control_(&codec, VP9E_SET_LOSSLESS, 1))
     die_codec(&codec, "Failed to use lossless mode");
index 911ad38630c651ddf4249aa5d40792e2c9b02dcf..1a0823153bd0c92edd9d0ee78716a6ff9d633cfe 100644 (file)
@@ -251,7 +251,7 @@ int main(int argc, char **argv) {
     die("Failed to open %s for reading.", infile_arg);
 
   if (vpx_codec_enc_init(&ecodec, encoder->codec_interface(), &cfg, 0))
-    die_codec(&ecodec, "Failed to initialize encoder");
+    die("Failed to initialize encoder");
 
   // Disable alt_ref.
   if (vpx_codec_control(&ecodec, VP8E_SET_ENABLEAUTOALTREF, 0))
index 925043d10667257d8464e1336ed089b566d0e733..872751cefeeac54c358661aaff8de416064638cd 100644 (file)
@@ -815,7 +815,7 @@ int main(int argc, char **argv) {
 #else
   if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
 #endif  // CONFIG_VP9_HIGHBITDEPTH
-    die_codec(&codec, "Failed to initialize encoder");
+    die("Failed to initialize encoder");
 
   if (strncmp(encoder->name, "vp8", 3) == 0) {
     vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed);