Commit ca8064d2 authored by Aurelien Jacobs's avatar Aurelien Jacobs

fix bitstream filter option mapping when using -newvideo and friends

There was an off-by-one when addressing bitstream_filters[] in this situation.

Originally committed as revision 25398 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 6c214280
...@@ -3390,7 +3390,7 @@ static void check_audio_video_sub_inputs(int *has_video_ptr, int *has_audio_ptr, ...@@ -3390,7 +3390,7 @@ static void check_audio_video_sub_inputs(int *has_video_ptr, int *has_audio_ptr,
*has_subtitle_ptr = has_subtitle; *has_subtitle_ptr = has_subtitle;
} }
static void new_video_stream(AVFormatContext *oc) static void new_video_stream(AVFormatContext *oc, int file_idx)
{ {
AVStream *st; AVStream *st;
AVCodecContext *video_enc; AVCodecContext *video_enc;
...@@ -3417,11 +3417,11 @@ static void new_video_stream(AVFormatContext *oc) ...@@ -3417,11 +3417,11 @@ static void new_video_stream(AVFormatContext *oc)
} }
avcodec_get_context_defaults3(st->codec, codec); avcodec_get_context_defaults3(st->codec, codec);
bitstream_filters[nb_output_files] = bitstream_filters[file_idx] =
grow_array(bitstream_filters[nb_output_files], grow_array(bitstream_filters[file_idx],
sizeof(*bitstream_filters[nb_output_files]), sizeof(*bitstream_filters[file_idx]),
&nb_bitstream_filters[nb_output_files], oc->nb_streams); &nb_bitstream_filters[file_idx], oc->nb_streams);
bitstream_filters[nb_output_files][oc->nb_streams - 1]= video_bitstream_filters; bitstream_filters[file_idx][oc->nb_streams - 1]= video_bitstream_filters;
video_bitstream_filters= NULL; video_bitstream_filters= NULL;
avcodec_thread_init(st->codec, thread_count); avcodec_thread_init(st->codec, thread_count);
...@@ -3534,7 +3534,7 @@ static void new_video_stream(AVFormatContext *oc) ...@@ -3534,7 +3534,7 @@ static void new_video_stream(AVFormatContext *oc)
frame_pix_fmt = PIX_FMT_NONE; frame_pix_fmt = PIX_FMT_NONE;
} }
static void new_audio_stream(AVFormatContext *oc) static void new_audio_stream(AVFormatContext *oc, int file_idx)
{ {
AVStream *st; AVStream *st;
AVCodec *codec= NULL; AVCodec *codec= NULL;
...@@ -3562,11 +3562,11 @@ static void new_audio_stream(AVFormatContext *oc) ...@@ -3562,11 +3562,11 @@ static void new_audio_stream(AVFormatContext *oc)
avcodec_get_context_defaults3(st->codec, codec); avcodec_get_context_defaults3(st->codec, codec);
bitstream_filters[nb_output_files] = bitstream_filters[file_idx] =
grow_array(bitstream_filters[nb_output_files], grow_array(bitstream_filters[file_idx],
sizeof(*bitstream_filters[nb_output_files]), sizeof(*bitstream_filters[file_idx]),
&nb_bitstream_filters[nb_output_files], oc->nb_streams); &nb_bitstream_filters[file_idx], oc->nb_streams);
bitstream_filters[nb_output_files][oc->nb_streams - 1]= audio_bitstream_filters; bitstream_filters[file_idx][oc->nb_streams - 1]= audio_bitstream_filters;
audio_bitstream_filters= NULL; audio_bitstream_filters= NULL;
avcodec_thread_init(st->codec, thread_count); avcodec_thread_init(st->codec, thread_count);
...@@ -3614,7 +3614,7 @@ static void new_audio_stream(AVFormatContext *oc) ...@@ -3614,7 +3614,7 @@ static void new_audio_stream(AVFormatContext *oc)
audio_stream_copy = 0; audio_stream_copy = 0;
} }
static void new_subtitle_stream(AVFormatContext *oc) static void new_subtitle_stream(AVFormatContext *oc, int file_idx)
{ {
AVStream *st; AVStream *st;
AVCodec *codec=NULL; AVCodec *codec=NULL;
...@@ -3634,11 +3634,11 @@ static void new_subtitle_stream(AVFormatContext *oc) ...@@ -3634,11 +3634,11 @@ static void new_subtitle_stream(AVFormatContext *oc)
} }
avcodec_get_context_defaults3(st->codec, codec); avcodec_get_context_defaults3(st->codec, codec);
bitstream_filters[nb_output_files] = bitstream_filters[file_idx] =
grow_array(bitstream_filters[nb_output_files], grow_array(bitstream_filters[file_idx],
sizeof(*bitstream_filters[nb_output_files]), sizeof(*bitstream_filters[file_idx]),
&nb_bitstream_filters[nb_output_files], oc->nb_streams); &nb_bitstream_filters[file_idx], oc->nb_streams);
bitstream_filters[nb_output_files][oc->nb_streams - 1]= subtitle_bitstream_filters; bitstream_filters[file_idx][oc->nb_streams - 1]= subtitle_bitstream_filters;
subtitle_bitstream_filters= NULL; subtitle_bitstream_filters= NULL;
subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE; subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
...@@ -3665,15 +3665,16 @@ static void new_subtitle_stream(AVFormatContext *oc) ...@@ -3665,15 +3665,16 @@ static void new_subtitle_stream(AVFormatContext *oc)
static int opt_new_stream(const char *opt, const char *arg) static int opt_new_stream(const char *opt, const char *arg)
{ {
AVFormatContext *oc; AVFormatContext *oc;
int file_idx = nb_output_files - 1;
if (nb_output_files <= 0) { if (nb_output_files <= 0) {
fprintf(stderr, "At least one output file must be specified\n"); fprintf(stderr, "At least one output file must be specified\n");
ffmpeg_exit(1); ffmpeg_exit(1);
} }
oc = output_files[nb_output_files - 1]; oc = output_files[file_idx];
if (!strcmp(opt, "newvideo" )) new_video_stream (oc); if (!strcmp(opt, "newvideo" )) new_video_stream (oc, file_idx);
else if (!strcmp(opt, "newaudio" )) new_audio_stream (oc); else if (!strcmp(opt, "newaudio" )) new_audio_stream (oc, file_idx);
else if (!strcmp(opt, "newsubtitle")) new_subtitle_stream(oc); else if (!strcmp(opt, "newsubtitle")) new_subtitle_stream(oc, file_idx);
else av_assert0(0); else av_assert0(0);
return 0; return 0;
} }
...@@ -3776,15 +3777,15 @@ static void opt_output_file(const char *filename) ...@@ -3776,15 +3777,15 @@ static void opt_output_file(const char *filename)
} }
if (use_video) { if (use_video) {
new_video_stream(oc); new_video_stream(oc, nb_output_files);
} }
if (use_audio) { if (use_audio) {
new_audio_stream(oc); new_audio_stream(oc, nb_output_files);
} }
if (use_subtitle) { if (use_subtitle) {
new_subtitle_stream(oc); new_subtitle_stream(oc, nb_output_files);
} }
oc->timestamp = recording_timestamp; oc->timestamp = recording_timestamp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment