]> git.sesse.net Git - ffmpeg/blobdiff - avprobe.c
configure: Add proper weak dependency of drawtext filter on libfontconfig
[ffmpeg] / avprobe.c
index abaaee137456883ccfc5ed59c268d89652ef1c04..a24e6440eb6138f744ae218268c08b95a8c41342 100644 (file)
--- a/avprobe.c
+++ b/avprobe.c
@@ -27,6 +27,7 @@
 #include "libavutil/display.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/spherical.h"
 #include "libavutil/stereo3d.h"
 #include "libavutil/dict.h"
 #include "libavutil/libm.h"
@@ -54,6 +55,11 @@ static AVDictionary *fmt_entries_to_show = NULL;
 static int nb_fmt_entries_to_show;
 static int do_show_packets = 0;
 static int do_show_streams = 0;
+static AVDictionary *stream_entries_to_show = NULL;
+static int nb_stream_entries_to_show;
+
+/* key used to print when probe_{int,str}(NULL, ..) is invoked */
+static const char *header_key;
 
 static int show_value_unit              = 0;
 static int use_value_prefix             = 0;
@@ -78,6 +84,7 @@ static const char unit_bit_per_second_str[] = "bit/s";
 static void avprobe_cleanup(int ret)
 {
     av_dict_free(&fmt_entries_to_show);
+    av_dict_free(&stream_entries_to_show);
 }
 
 /*
@@ -402,6 +409,37 @@ static void show_format_entry_string(const char *key, const char *value)
     }
 }
 
+static void show_stream_entry_header(const char *key, int value)
+{
+    header_key = key;
+}
+
+static void show_stream_entry_footer(const char *key, int value)
+{
+    header_key = NULL;
+}
+
+static void show_stream_entry_integer(const char *key, int64_t value)
+{
+    if (!key)
+        key = header_key;
+
+    if (key && av_dict_get(stream_entries_to_show, key, NULL, 0)) {
+        if (nb_stream_entries_to_show > 1)
+            avio_printf(probe_out, "%s=", key);
+        avio_printf(probe_out, "%"PRId64"\n", value);
+    }
+}
+
+static void show_stream_entry_string(const char *key, const char *value)
+{
+    if (key && av_dict_get(stream_entries_to_show, key, NULL, 0)) {
+        if (nb_stream_entries_to_show > 1)
+            avio_printf(probe_out, "%s=", key);
+        avio_printf(probe_out, "%s\n", value);
+    }
+}
+
 static void probe_group_enter(const char *name, int type)
 {
     int64_t count = -1;
@@ -729,6 +767,7 @@ static void show_stream(InputFile *ifile, InputStream *ist)
         for (i = 0; i < stream->nb_side_data; i++) {
             const AVPacketSideData* sd = &stream->side_data[i];
             AVStereo3D *stereo;
+            AVSphericalMapping *spherical;
 
             switch (sd->type) {
             case AV_PKT_DATA_DISPLAYMATRIX:
@@ -749,6 +788,25 @@ static void show_stream(InputFile *ifile, InputStream *ist)
                           !!(stereo->flags & AV_STEREO3D_FLAG_INVERT));
                 probe_object_footer("stereo3d");
                 break;
+            case AV_PKT_DATA_SPHERICAL:
+                spherical = (AVSphericalMapping *)sd->data;
+                probe_object_header("spherical");
+
+                if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR)
+                    probe_str("projection", "equirectangular");
+                else if (spherical->projection == AV_SPHERICAL_CUBEMAP)
+                    probe_str("projection", "cubemap");
+                else
+                    probe_str("projection", "unknown");
+
+                probe_object_header("orientation");
+                probe_int("yaw", (double) spherical->yaw / (1 << 16));
+                probe_int("pitch", (double) spherical->pitch / (1 << 16));
+                probe_int("roll", (double) spherical->roll / (1 << 16));
+                probe_object_footer("orientation");
+
+                probe_object_footer("spherical");
+                break;
             }
         }
         probe_object_footer("sidedata");
@@ -973,6 +1031,37 @@ static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
     return 0;
 }
 
+static int opt_show_stream_entry(void *optctx, const char *opt, const char *arg)
+{
+    const char *p = arg;
+
+    do_show_streams = 1;
+    nb_stream_entries_to_show++;
+    octx.print_header        = NULL;
+    octx.print_footer        = NULL;
+    octx.print_array_header  = show_stream_entry_header;
+    octx.print_array_footer  = show_stream_entry_footer;
+    octx.print_object_header = NULL;
+    octx.print_object_footer = NULL;
+
+    octx.print_integer = show_stream_entry_integer;
+    octx.print_string  = show_stream_entry_string;
+
+    while (*p) {
+        char *val = av_get_token(&p, ",");
+        if (!val)
+            return AVERROR(ENOMEM);
+
+        av_dict_set(&stream_entries_to_show, val, "", 0);
+
+        av_free(val);
+        if (*p)
+            p++;
+    }
+
+    return 0;
+}
+
 static void opt_input_file(void *optctx, const char *arg)
 {
     if (input_filename) {
@@ -1005,7 +1094,7 @@ static int opt_pretty(void *optctx, const char *opt, const char *arg)
 }
 
 static const OptionDef real_options[] = {
-#include "cmdutils_common_opts.h"
+    CMDUTILS_COMMON_OPTIONS
     { "f", HAS_ARG, {.func_arg = opt_format}, "force format", "format" },
     { "of", HAS_ARG, {.func_arg = opt_output_format}, "output the document either as ini or json", "output_format" },
     { "unit", OPT_BOOL, {&show_value_unit},
@@ -1023,6 +1112,8 @@ static const OptionDef real_options[] = {
       "show a particular entry from the format/container info", "entry" },
     { "show_packets", OPT_BOOL, {&do_show_packets}, "show packets info" },
     { "show_streams", OPT_BOOL, {&do_show_streams}, "show streams info" },
+    { "show_stream_entry", HAS_ARG, {.func_arg = opt_show_stream_entry},
+      "show a particular entry from all streams (comma separated)", "entry" },
     { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = opt_default},
       "generic catch all option", "" },
     { NULL, },
@@ -1089,7 +1180,7 @@ int main(int argc, char **argv)
     avio_flush(probe_out);
     av_freep(&probe_out);
     av_freep(&buffer);
-
+    uninit_opts();
     avformat_network_deinit();
 
     return ret;