avconv: use a local variable for OutputFile in open_output_file().
This is shorter and more readable.
This commit is contained in:
27
avconv_opt.c
27
avconv_opt.c
@@ -1173,6 +1173,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
|||||||
AVFormatContext *oc;
|
AVFormatContext *oc;
|
||||||
int i, j, err;
|
int i, j, err;
|
||||||
AVOutputFormat *file_oformat;
|
AVOutputFormat *file_oformat;
|
||||||
|
OutputFile *of;
|
||||||
OutputStream *ost;
|
OutputStream *ost;
|
||||||
InputStream *ist;
|
InputStream *ist;
|
||||||
|
|
||||||
@@ -1365,18 +1366,20 @@ loop_end:
|
|||||||
}
|
}
|
||||||
|
|
||||||
GROW_ARRAY(output_files, nb_output_files);
|
GROW_ARRAY(output_files, nb_output_files);
|
||||||
if (!(output_files[nb_output_files - 1] = av_mallocz(sizeof(*output_files[0]))))
|
of = av_mallocz(sizeof(*of));
|
||||||
|
if (!of)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
output_files[nb_output_files - 1] = of;
|
||||||
|
|
||||||
output_files[nb_output_files - 1]->ctx = oc;
|
of->ctx = oc;
|
||||||
output_files[nb_output_files - 1]->ost_index = nb_output_streams - oc->nb_streams;
|
of->ost_index = nb_output_streams - oc->nb_streams;
|
||||||
output_files[nb_output_files - 1]->recording_time = o->recording_time;
|
of->recording_time = o->recording_time;
|
||||||
if (o->recording_time != INT64_MAX)
|
if (o->recording_time != INT64_MAX)
|
||||||
oc->duration = o->recording_time;
|
oc->duration = o->recording_time;
|
||||||
output_files[nb_output_files - 1]->start_time = o->start_time;
|
of->start_time = o->start_time;
|
||||||
output_files[nb_output_files - 1]->limit_filesize = o->limit_filesize;
|
of->limit_filesize = o->limit_filesize;
|
||||||
output_files[nb_output_files - 1]->shortest = o->shortest;
|
of->shortest = o->shortest;
|
||||||
av_dict_copy(&output_files[nb_output_files - 1]->opts, o->g->format_opts, 0);
|
av_dict_copy(&of->opts, o->g->format_opts, 0);
|
||||||
|
|
||||||
/* check filename in case of an image number is expected */
|
/* check filename in case of an image number is expected */
|
||||||
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
|
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
|
||||||
@@ -1393,7 +1396,7 @@ loop_end:
|
|||||||
/* open the file */
|
/* open the file */
|
||||||
if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE,
|
if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE,
|
||||||
&oc->interrupt_callback,
|
&oc->interrupt_callback,
|
||||||
&output_files[nb_output_files - 1]->opts)) < 0) {
|
&of->opts)) < 0) {
|
||||||
print_error(filename, err);
|
print_error(filename, err);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -1402,7 +1405,7 @@ loop_end:
|
|||||||
if (o->mux_preload) {
|
if (o->mux_preload) {
|
||||||
uint8_t buf[64];
|
uint8_t buf[64];
|
||||||
snprintf(buf, sizeof(buf), "%d", (int)(o->mux_preload*AV_TIME_BASE));
|
snprintf(buf, sizeof(buf), "%d", (int)(o->mux_preload*AV_TIME_BASE));
|
||||||
av_dict_set(&output_files[nb_output_files - 1]->opts, "preload", buf, 0);
|
av_dict_set(&of->opts, "preload", buf, 0);
|
||||||
}
|
}
|
||||||
oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE);
|
oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE);
|
||||||
oc->flags |= AVFMT_FLAG_NONBLOCK;
|
oc->flags |= AVFMT_FLAG_NONBLOCK;
|
||||||
@@ -1438,7 +1441,7 @@ loop_end:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (o->chapters_input_file >= 0)
|
if (o->chapters_input_file >= 0)
|
||||||
copy_chapters(input_files[o->chapters_input_file], output_files[nb_output_files - 1],
|
copy_chapters(input_files[o->chapters_input_file], of,
|
||||||
!o->metadata_chapters_manual);
|
!o->metadata_chapters_manual);
|
||||||
|
|
||||||
/* copy global metadata by default */
|
/* copy global metadata by default */
|
||||||
@@ -1446,7 +1449,7 @@ loop_end:
|
|||||||
av_dict_copy(&oc->metadata, input_files[0]->ctx->metadata,
|
av_dict_copy(&oc->metadata, input_files[0]->ctx->metadata,
|
||||||
AV_DICT_DONT_OVERWRITE);
|
AV_DICT_DONT_OVERWRITE);
|
||||||
if (!o->metadata_streams_manual)
|
if (!o->metadata_streams_manual)
|
||||||
for (i = output_files[nb_output_files - 1]->ost_index; i < nb_output_streams; i++) {
|
for (i = of->ost_index; i < nb_output_streams; i++) {
|
||||||
InputStream *ist;
|
InputStream *ist;
|
||||||
if (output_streams[i]->source_index < 0) /* this is true e.g. for attached files */
|
if (output_streams[i]->source_index < 0) /* this is true e.g. for attached files */
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user