aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-11 16:46:22 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-11 16:46:30 +0100
commit48fb5294d03f1d25ec8ba370a0cb4258fc21e88e (patch)
tree23de73100a257878069ed0cf9875fb99dfaca128
parent9d48aa6d7df6fa50a8a2c30f5c1774af8a083db0 (diff)
parent567d6d5f9d1400f00445183b3477391f58979aa3 (diff)
downloadffmpeg-48fb5294d03f1d25ec8ba370a0cb4258fc21e88e.tar.gz
Merge commit '567d6d5f9d1400f00445183b3477391f58979aa3'
* commit '567d6d5f9d1400f00445183b3477391f58979aa3': avprobe: add local per-stream state Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
-rw-r--r--ffprobe.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/ffprobe.c b/ffprobe.c
index fca60b81ea..4481621a34 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -49,8 +49,15 @@
#include "libpostproc/postprocess.h"
#include "cmdutils.h"
+typedef struct InputStream {
+ AVStream *st;
+} InputStream;
+
typedef struct InputFile {
AVFormatContext *fmt_ctx;
+
+ InputStream *streams;
+ int nb_streams;
} InputFile;
const char program_name[] = "ffprobe";
@@ -2541,11 +2548,20 @@ static int open_input_file(InputFile *ifile, const char *filename)
av_dump_format(fmt_ctx, 0, filename, 0);
+ ifile->streams = av_mallocz_array(fmt_ctx->nb_streams,
+ sizeof(*ifile->streams));
+ if (!ifile->streams)
+ exit(1);
+ ifile->nb_streams = fmt_ctx->nb_streams;
+
/* bind a decoder to each input stream */
for (i = 0; i < fmt_ctx->nb_streams; i++) {
+ InputStream *ist = &ifile->streams[i];
AVStream *stream = fmt_ctx->streams[i];
AVCodec *codec;
+ ist->st = stream;
+
if (stream->codec->codec_id == AV_CODEC_ID_PROBE) {
av_log(NULL, AV_LOG_WARNING,
"Failed to probe codec for input stream %d\n",
@@ -2583,6 +2599,9 @@ static void close_input_file(InputFile *ifile)
if (fmt_ctx->streams[i]->codec->codec_id != AV_CODEC_ID_NONE)
avcodec_close(fmt_ctx->streams[i]->codec);
+ av_freep(&ifile->streams);
+ ifile->nb_streams = 0;
+
avformat_close_input(&ifile->fmt_ctx);
}