]> git.sesse.net Git - ffmpeg/blobdiff - avprobe.c
dfa: check for invalid access in decode_wdlt().
[ffmpeg] / avprobe.c
index b20c78cd344e7bbe9d99c399c760c33aa2328bc8..2f15d5ce2a8e539f019a9bb8240b9dade8fc5d90 100644 (file)
--- a/avprobe.c
+++ b/avprobe.c
@@ -23,6 +23,7 @@
 
 #include "libavformat/avformat.h"
 #include "libavcodec/avcodec.h"
+#include "libavutil/avstring.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/dict.h"
@@ -59,10 +60,9 @@ static const char unit_hertz_str[]          = "Hz"   ;
 static const char unit_byte_str[]           = "byte" ;
 static const char unit_bit_per_second_str[] = "bit/s";
 
-void exit_program(int ret)
+static void exit_program(void)
 {
     av_dict_free(&fmt_entries_to_show);
-    exit(ret);
 }
 
 /*
@@ -303,7 +303,7 @@ static void old_print_object_header(const char *name)
 
     str = p = av_strdup(name);
     while (*p) {
-        *p = toupper(*p);
+        *p = av_toupper(*p);
         p++;
     }
 
@@ -320,7 +320,7 @@ static void old_print_object_footer(const char *name)
 
     str = p = av_strdup(name);
     while (*p) {
-        *p = toupper(*p);
+        *p = av_toupper(*p);
         p++;
     }
 
@@ -584,7 +584,8 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
     const AVCodec *dec;
     const char *profile;
     char val_str[128];
-    AVRational display_aspect_ratio;
+    AVRational display_aspect_ratio, *sar = NULL;
+    const AVPixFmtDescriptor *desc;
 
     probe_object_header("stream");
 
@@ -618,21 +619,23 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
             probe_int("width", dec_ctx->width);
             probe_int("height", dec_ctx->height);
             probe_int("has_b_frames", dec_ctx->has_b_frames);
-            if (dec_ctx->sample_aspect_ratio.num) {
+            if (dec_ctx->sample_aspect_ratio.num)
+                sar = &dec_ctx->sample_aspect_ratio;
+            else if (stream->sample_aspect_ratio.num)
+                sar = &stream->sample_aspect_ratio;
+
+            if (sar) {
                 probe_str("sample_aspect_ratio",
-                          rational_string(val_str, sizeof(val_str), ":",
-                          &dec_ctx->sample_aspect_ratio));
+                          rational_string(val_str, sizeof(val_str), ":", sar));
                 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
-                          dec_ctx->width  * dec_ctx->sample_aspect_ratio.num,
-                          dec_ctx->height * dec_ctx->sample_aspect_ratio.den,
+                          dec_ctx->width  * sar->num, dec_ctx->height * sar->den,
                           1024*1024);
                 probe_str("display_aspect_ratio",
                           rational_string(val_str, sizeof(val_str), ":",
                           &display_aspect_ratio));
             }
-            probe_str("pix_fmt",
-                      dec_ctx->pix_fmt != PIX_FMT_NONE ? av_pix_fmt_descriptors[dec_ctx->pix_fmt].name
-                                                    : "unknown");
+            desc = av_pix_fmt_desc_get(dec_ctx->pix_fmt);
+            probe_str("pix_fmt", desc ? desc->name : "unknown");
             probe_int("level", dec_ctx->level);
             break;
 
@@ -655,6 +658,10 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
     probe_str("avg_frame_rate",
               rational_string(val_str, sizeof(val_str), "/",
               &stream->avg_frame_rate));
+    if (dec_ctx->bit_rate)
+        probe_str("bit_rate",
+                  value_string(val_str, sizeof(val_str),
+                               dec_ctx->bit_rate, unit_bit_per_second_str));
     probe_str("time_base",
               rational_string(val_str, sizeof(val_str), "/",
               &stream->time_base));
@@ -926,6 +933,8 @@ int main(int argc, char **argv)
     if (!buffer)
         exit(1);
 
+    atexit(exit_program);
+
     options = real_options;
     parse_loglevel(argc, argv, options);
     av_register_all();