Instead store output streams in the same way as input streams.
---
avconv.c | 97 -
1 files changed, 38 insertions(+), 59 deletions(-)
diff --git a/avconv.c b/avconv.c
index eaa79a0..af55d2f 100644
--- a/avconv.c
+++ b/avconv.c
@@ -276,9 +276,6 @@ typedef struct OutputStream {
AVDictionary *opts;
} OutputStream;
-static OutputStream **output_streams_for_file[MAX_FILES] = { NULL };
-static int nb_output_streams_for_file[MAX_FILES] = { 0 };
-
typedef struct InputStream {
int file_index;
AVStream *st;
@@ -309,6 +306,7 @@ typedef struct InputFile {
typedef struct OutputFile {
AVFormatContext *ctx;
AVDictionary *opts;
+int ost_index; /* index of the first stream in output_streams */
} OutputFile;
static InputStream *input_streams = NULL;
@@ -316,6 +314,8 @@ static int nb_input_streams = 0;
static InputFile *input_files = NULL;
static int nb_input_files = 0;
+static OutputStream *output_streams = NULL;
+static intnb_output_streams = 0;
static OutputFile *output_files = NULL;
static intnb_output_files = 0;
@@ -445,7 +445,6 @@ static int exit_program(int ret)
if (!(s-oformat-flags AVFMT_NOFILE) s-pb)
avio_close(s-pb);
avformat_free_context(s);
-av_free(output_streams_for_file[i]);
av_dict_free(output_files[i].opts);
}
for(i=0;inb_input_files;i++) {
@@ -466,6 +465,7 @@ static int exit_program(int ret)
av_freep(input_streams);
av_freep(input_files);
+av_freep(output_streams);
av_freep(output_files);
uninit_opts();
@@ -1262,7 +1262,7 @@ static void do_video_stats(AVFormatContext *os,
OutputStream *ost,
}
static void print_report(OutputFile *output_files,
- OutputStream **ost_table, int nb_ostreams,
+ OutputStream *ost_table, int nb_ostreams,
int is_last_report)
{
char buf[1024];
@@ -1300,7 +1300,7 @@ static void print_report(OutputFile *output_files,
vid = 0;
for(i=0;inb_ostreams;i++) {
float q = -1;
-ost = ost_table[i];
+ost = ost_table[i];
enc = ost-st-codec;
if (!ost-st-stream_copy enc-coded_frame)
q = enc-coded_frame-quality/(float)FF_QP2LAMBDA;
@@ -1393,7 +1393,7 @@ static void generate_silence(uint8_t* buf, enum
AVSampleFormat sample_fmt, size_
/* pkt = NULL means EOF (needed to flush decoder buffers) */
static int output_packet(InputStream *ist, int ist_index,
- OutputStream **ost_table, int nb_ostreams,
+ OutputStream *ost_table, int nb_ostreams,
const AVPacket *pkt)
{
AVFormatContext *os;
@@ -1543,7 +1543,7 @@ static int output_packet(InputStream *ist, int ist_index,
#if CONFIG_AVFILTER
if (ist-st-codec-codec_type == AVMEDIA_TYPE_VIDEO) {
for (i = 0; i nb_ostreams; i++) {
-ost = ost_table[i];
+ost = ost_table[i];
if (ost-input_video_filter ost-source_index == ist_index)
{
AVRational sar;
if (ist-st-sample_aspect_ratio.num)
@@ -1586,7 +1586,7 @@ static int output_packet(InputStream *ist, int ist_index,
for(i=0;inb_ostreams;i++) {
int frame_size;
-ost = ost_table[i];
+ost = ost_table[i];
if (ost-source_index == ist_index) {
#if CONFIG_AVFILTER
frame_available = ist-st-codec-codec_type !=
AVMEDIA_TYPE_VIDEO ||
@@ -1709,7 +1709,7 @@ static int output_packet(InputStream *ist, int ist_index,
/* EOF handling */
for(i=0;inb_ostreams;i++) {
-ost = ost_table[i];
+ost = ost_table[i];
if (ost-source_index == ist_index) {
AVCodecContext *enc= ost-st-codec;
os = output_files[ost-file_index].ctx;
@@ -1818,10 +1818,10 @@ static int transcode(OutputFile *output_files,
InputFile *input_files,
int nb_input_files)
{
-int ret = 0, i, j, k, n, nb_ostreams = 0;
+int ret = 0, i, j;
AVFormatContext *is, *os;
AVCodecContext *codec, *icodec;
-OutputStream *ost, **ost_table = NULL;
+OutputStream *ost;
InputStream *ist;
char error[1024];
int want_sdp = 1;
@@ -1833,7 +1833,6 @@ static int transcode(OutputFile *output_files,
input_streams[i].start = av_gettime();
/* output stream init */
-nb_ostreams = 0;
for(i=0;inb_output_files;i++) {
os = output_files[i].ctx;
if (!os-nb_streams !(os-oformat-flags AVFMT_NOSTREAMS)) {
@@ -1842,22 +1841,11 @@ static int transcode(OutputFile *output_files,
ret = AVERROR(EINVAL);
goto fail;
}
-nb_ostreams += os-nb_streams;
-}
-
-ost_table =