Right now, they are arrays of structs, reallocated when new streams/files are added. This makes storing pointers to those structs harder than necessary.
Unified · Split
| @@ -264,15 +264,15 @@ typedef struct OutputFile { · 263 unmodified lines | ||
| 264 | 264 | uint64_t limit_filesize; |
| 265 | 265 | } OutputFile; |
| 266 | 266 | |
| 267 | −static InputStream *input_streams = NULL; | |
| 268 | −static int nb_input_streams = 0; | |
| 269 | −static InputFile *input_files = NULL; | |
| 270 | −static int nb_input_files = 0; | |
| 267 | +static InputStream **input_streams = NULL; | |
| 268 | +static int nb_input_streams = 0; | |
| 269 | +static InputFile **input_files = NULL; | |
| 270 | +static int nb_input_files = 0; | |
| 271 | 271 | |
| 272 | −static OutputStream *output_streams = NULL; | |
| 273 | −static int nb_output_streams = 0; | |
| 274 | −static OutputFile *output_files = NULL; | |
| 275 | −static int nb_output_files = 0; | |
| 272 | +static OutputStream **output_streams = NULL; | |
| 273 | +static int nb_output_streams = 0; | |
| 274 | +static OutputFile **output_files = NULL; | |
| 275 | +static int nb_output_files = 0; | |
| 276 | 276 | |
| 277 | 277 | typedef struct OptionsContext { |
| 278 | 278 | /* input/output options */ |
| @@ -663,38 +663,42 @@ void exit_program(int ret) · 384 unmodified lines | ||
| 663 | 663 | |
| 664 | 664 | /* close files */ |
| 665 | 665 | for (i = 0; i < nb_output_files; i++) { |
| 666 | − AVFormatContext *s = output_files[i].ctx; | |
| 666 | + AVFormatContext *s = output_files[i]->ctx; | |
| 667 | 667 | if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb) |
| 668 | 668 | avio_close(s->pb); |
| 669 | 669 | avformat_free_context(s); |
| 670 | − av_dict_free(&output_files[i].opts); | |
| 670 | + av_dict_free(&output_files[i]->opts); | |
| 671 | + av_freep(&output_files[i]); | |
| 671 | 672 | } |
| 672 | 673 | for (i = 0; i < nb_output_streams; i++) { |
| 673 | − AVBitStreamFilterContext *bsfc = output_streams[i].bitstream_filters; | |
| 674 | + AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters; | |
| 674 | 675 | while (bsfc) { |
| 675 | 676 | AVBitStreamFilterContext *next = bsfc->next; |
| 676 | 677 | av_bitstream_filter_close(bsfc); |
| 677 | 678 | bsfc = next; |
| 678 | 679 | } |
| 679 | − output_streams[i].bitstream_filters = NULL; | |
| 680 | + output_streams[i]->bitstream_filters = NULL; | |
| 680 | 681 | |
| 681 | − if (output_streams[i].output_frame) { | |
| 682 | − AVFrame *frame = output_streams[i].output_frame; | |
| 682 | + if (output_streams[i]->output_frame) { | |
| 683 | + AVFrame *frame = output_streams[i]->output_frame; | |
| 683 | 684 | if (frame->extended_data != frame->data) |
| 684 | 685 | av_freep(&frame->extended_data); |
| 685 | 686 | av_freep(&frame); |
| 686 | 687 | } |
| 687 | 688 | |
| 688 | − av_freep(&output_streams[i].avfilter); | |
| 689 | + av_freep(&output_streams[i]->avfilter); | |
| 690 | + av_freep(&output_streams[i]); | |
| 689 | 691 | } |
| 690 | 692 | for (i = 0; i < nb_input_files; i++) { |
| 691 | − avformat_close_input(&input_files[i].ctx); | |
| 693 | + avformat_close_input(&input_files[i]->ctx); | |
| 694 | + av_freep(&input_files[i]); | |
| 692 | 695 | } |
| 693 | 696 | for (i = 0; i < nb_input_streams; i++) { |
| 694 | − av_freep(&input_streams[i].decoded_frame); | |
| 695 | − av_freep(&input_streams[i].filtered_frame); | |
| 696 | − av_dict_free(&input_streams[i].opts); | |
| 697 | − free_buffer_pool(&input_streams[i]); | |
| 697 | + av_freep(&input_streams[i]->decoded_frame); | |
| 698 | + av_freep(&input_streams[i]->filtered_frame); | |
| 699 | + av_dict_free(&input_streams[i]->opts); | |
| 700 | + free_buffer_pool(input_streams[i]); | |
| 701 | + av_freep(&input_streams[i]); | |
| 698 | 702 | } |
| 699 | 703 | |
| 700 | 704 | if (vstats_file) |
| @@ -860,7 +864,7 @@ static void choose_pixel_fmt(AVStream *st, AVCodec *codec) · 159 unmodified lines | ||
| 860 | 864 | static double |
| 861 | 865 | get_sync_ipts(const OutputStream *ost, int64_t pts) |
| 862 | 866 | { |
| 863 | − OutputFile *of = &output_files[ost->file_index]; | |
| 867 | + OutputFile *of = output_files[ost->file_index]; | |
| 864 | 868 | return (double)(pts - of->start_time) / AV_TIME_BASE; |
| 865 | 869 | } |
| 866 | 870 | |
| @@ -917,7 +921,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) · 50 unmodified lines | ||
| 917 | 921 | |
| 918 | 922 | static int check_recording_time(OutputStream *ost) |
| 919 | 923 | { |
| 920 | − OutputFile *of = &output_files[ost->file_index]; | |
| 924 | + OutputFile *of = output_files[ost->file_index]; | |
| 921 | 925 | |
| 922 | 926 | if (of->recording_time != INT64_MAX && |
| 923 | 927 | av_compare_ts(ost->sync_opts - ost->first_pts, ost->st->codec->time_base, of->recording_time, |
| @@ -1514,7 +1518,7 @@ static void print_report(int is_last_report, int64_t timer_start) · 590 unmodified lines | ||
| 1514 | 1518 | } |
| 1515 | 1519 | |
| 1516 | 1520 | |
| 1517 | − oc = output_files[0].ctx; | |
| 1521 | + oc = output_files[0]->ctx; | |
| 1518 | 1522 | |
| 1519 | 1523 | total_size = avio_size(oc->pb); |
| 1520 | 1524 | if (total_size < 0) // FIXME improve avio_size() so it works with non seekable output too |
| @@ -1525,7 +1529,7 @@ static void print_report(int is_last_report, int64_t timer_start) · 4 unmodified lines | ||
| 1525 | 1529 | vid = 0; |
| 1526 | 1530 | for (i = 0; i < nb_output_streams; i++) { |
| 1527 | 1531 | float q = -1; |
| 1528 | − ost = &output_streams[i]; | |
| 1532 | + ost = output_streams[i]; | |
| 1529 | 1533 | enc = ost->st->codec; |
| 1530 | 1534 | if (!ost->stream_copy && enc->coded_frame) |
| 1531 | 1535 | q = enc->coded_frame->quality / (float)FF_QP2LAMBDA; |
| @@ -1611,9 +1615,9 @@ static void flush_encoders(void) · 79 unmodified lines | ||
| 1611 | 1615 | int i, ret; |
| 1612 | 1616 | |
| 1613 | 1617 | for (i = 0; i < nb_output_streams; i++) { |
| 1614 | − OutputStream *ost = &output_streams[i]; | |
| 1618 | + OutputStream *ost = output_streams[i]; | |
| 1615 | 1619 | AVCodecContext *enc = ost->st->codec; |
| 1616 | − AVFormatContext *os = output_files[ost->file_index].ctx; | |
| 1620 | + AVFormatContext *os = output_files[ost->file_index]->ctx; | |
| 1617 | 1621 | int stop_encoding = 0; |
| 1618 | 1622 | |
| 1619 | 1623 | if (!ost->encoding_needed) |
| @@ -1692,8 +1696,8 @@ static void flush_encoders(void) · 72 unmodified lines | ||
| 1692 | 1696 | */ |
| 1693 | 1697 | static int check_output_constraints(InputStream *ist, OutputStream *ost) |
| 1694 | 1698 | { |
| 1695 | − OutputFile *of = &output_files[ost->file_index]; | |
| 1696 | − int ist_index = ist - input_streams; | |
| 1699 | + OutputFile *of = output_files[ost->file_index]; | |
| 1700 | + int ist_index = input_files[ist->file_index]->ist_index + ist->st->index; | |
| 1697 | 1701 | |
| 1698 | 1702 | if (ost->source_index != ist_index) |
| 1699 | 1703 | return 0; |
| @@ -1706,7 +1710,7 @@ static int check_output_constraints(InputStream *ist, OutputStream *ost) · 6 unmodified lines | ||
| 1706 | 1710 | |
| 1707 | 1711 | static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt) |
| 1708 | 1712 | { |
| 1709 | − OutputFile *of = &output_files[ost->file_index]; | |
| 1713 | + OutputFile *of = output_files[ost->file_index]; | |
| 1710 | 1714 | int64_t ost_tb_start_time = av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base); |
| 1711 | 1715 | AVPacket opkt; |
| 1712 | 1716 | |
| @@ -1764,7 +1768,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p · 51 unmodified lines | ||
| 1764 | 1768 | |
| 1765 | 1769 | static void rate_emu_sleep(InputStream *ist) |
| 1766 | 1770 | { |
| 1767 | − if (input_files[ist->file_index].rate_emu) { | |
| 1771 | + if (input_files[ist->file_index]->rate_emu) { | |
| 1768 | 1772 | int64_t pts = av_rescale(ist->last_dts, 1000000, AV_TIME_BASE); |
| 1769 | 1773 | int64_t now = av_gettime() - ist->start; |
| 1770 | 1774 | if (pts > now) |
| @@ -1866,11 +1870,11 @@ static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output) · 95 unmodified lines | ||
| 1866 | 1870 | rate_emu_sleep(ist); |
| 1867 | 1871 | |
| 1868 | 1872 | for (i = 0; i < nb_output_streams; i++) { |
| 1869 | − OutputStream *ost = &output_streams[i]; | |
| 1873 | + OutputStream *ost = output_streams[i]; | |
| 1870 | 1874 | |
| 1871 | 1875 | if (!check_output_constraints(ist, ost) || !ost->encoding_needed) |
| 1872 | 1876 | continue; |
| 1873 | − do_audio_out(output_files[ost->file_index].ctx, ost, ist, decoded_frame); | |
| 1877 | + do_audio_out(output_files[ost->file_index]->ctx, ost, ist, decoded_frame); | |
| 1874 | 1878 | } |
| 1875 | 1879 | |
| 1876 | 1880 | return ret; |
| @@ -1914,7 +1918,7 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int · 37 unmodified lines | ||
| 1914 | 1918 | decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio; |
| 1915 | 1919 | |
| 1916 | 1920 | for (i = 0; i < nb_output_streams; i++) { |
| 1917 | − OutputStream *ost = &output_streams[i]; | |
| 1921 | + OutputStream *ost = output_streams[i]; | |
| 1918 | 1922 | int frame_size, resample_changed; |
| 1919 | 1923 | |
| 1920 | 1924 | if (!check_output_constraints(ist, ost) || !ost->encoding_needed) |
| @@ -1978,10 +1982,10 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int · 57 unmodified lines | ||
| 1978 | 1982 | if (!ost->frame_aspect_ratio) |
| 1979 | 1983 | ost->st->codec->sample_aspect_ratio = picref->video->pixel_aspect; |
| 1980 | 1984 | |
| 1981 | − do_video_out(output_files[ost->file_index].ctx, ost, filtered_frame, &frame_size, | |
| 1985 | + do_video_out(output_files[ost->file_index]->ctx, ost, filtered_frame, &frame_size, | |
| 1982 | 1986 | same_quant ? quality : ost->st->codec->global_quality); |
| 1983 | 1987 | if (vstats_filename && frame_size) |
| 1984 | − do_video_stats(output_files[ost->file_index].ctx, ost, frame_size); | |
| 1988 | + do_video_stats(output_files[ost->file_index]->ctx, ost, frame_size); | |
| 1985 | 1989 | frame_available = ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]); |
| 1986 | 1990 | avfilter_unref_buffer(picref); |
| 1987 | 1991 | } |
| @@ -2005,12 +2009,12 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) · 17 unmodified lines | ||
| 2005 | 2009 | rate_emu_sleep(ist); |
| 2006 | 2010 | |
| 2007 | 2011 | for (i = 0; i < nb_output_streams; i++) { |
| 2008 | − OutputStream *ost = &output_streams[i]; | |
| 2012 | + OutputStream *ost = output_streams[i]; | |
| 2009 | 2013 | |
| 2010 | 2014 | if (!check_output_constraints(ist, ost) || !ost->encoding_needed) |
| 2011 | 2015 | continue; |
| 2012 | 2016 | |
| 2013 | − do_subtitle_out(output_files[ost->file_index].ctx, ost, ist, &subtitle, pkt->pts); | |
| 2017 | + do_subtitle_out(output_files[ost->file_index]->ctx, ost, ist, &subtitle, pkt->pts); | |
| 2014 | 2018 | } |
| 2015 | 2019 | |
| 2016 | 2020 | avsubtitle_free(&subtitle); |
| @@ -2113,7 +2117,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt) · 96 unmodified lines | ||
| 2113 | 2117 | } |
| 2114 | 2118 | } |
| 2115 | 2119 | for (i = 0; pkt && i < nb_output_streams; i++) { |
| 2116 | − OutputStream *ost = &output_streams[i]; | |
| 2120 | + OutputStream *ost = output_streams[i]; | |
| 2117 | 2121 | |
| 2118 | 2122 | if (!check_output_constraints(ist, ost) || ost->encoding_needed) |
| 2119 | 2123 | continue; |
| @@ -2133,7 +2137,7 @@ static void print_sdp(void) · 13 unmodified lines | ||
| 2133 | 2137 | if (!avc) |
| 2134 | 2138 | exit_program(1); |
| 2135 | 2139 | for (i = 0; i < nb_output_files; i++) |
| 2136 | − avc[i] = output_files[i].ctx; | |
| 2140 | + avc[i] = output_files[i]->ctx; | |
| 2137 | 2141 | |
| 2138 | 2142 | av_sdp_create(avc, nb_output_files, sdp, sizeof(sdp)); |
| 2139 | 2143 | printf("SDP:\n%s\n", sdp); |
| @@ -2189,7 +2193,7 @@ static void get_default_channel_layouts(OutputStream *ost, InputStream *ist) · 49 unmodified lines | ||
| 2189 | 2193 | static int init_input_stream(int ist_index, char *error, int error_len) |
| 2190 | 2194 | { |
| 2191 | 2195 | int i; |
| 2192 | − InputStream *ist = &input_streams[ist_index]; | |
| 2196 | + InputStream *ist = input_streams[ist_index]; | |
| 2193 | 2197 | if (ist->decoding_needed) { |
| 2194 | 2198 | AVCodec *codec = ist->dec; |
| 2195 | 2199 | if (!codec) { |
| @@ -2201,7 +2205,7 @@ static int init_input_stream(int ist_index, char *error, int error_len) · 5 unmodified lines | ||
| 2201 | 2205 | /* update requested sample format for the decoder based on the |
| 2202 | 2206 | corresponding encoder sample format */ |
| 2203 | 2207 | for (i = 0; i < nb_output_streams; i++) { |
| 2204 | − OutputStream *ost = &output_streams[i]; | |
| 2208 | + OutputStream *ost = output_streams[i]; | |
| 2205 | 2209 | if (ost->source_index == ist_index) { |
| 2206 | 2210 | update_sample_fmt(ist->st->codec, codec, ost->st->codec); |
| 2207 | 2211 | break; |
| @@ -2226,7 +2230,7 @@ static int init_input_stream(int ist_index, char *error, int error_len) · 18 unmodified lines | ||
| 2226 | 2230 | |
| 2227 | 2231 | if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { |
| 2228 | 2232 | for (i = 0; i < nb_output_streams; i++) { |
| 2229 | − OutputStream *ost = &output_streams[i]; | |
| 2233 | + OutputStream *ost = output_streams[i]; | |
| 2230 | 2234 | if (ost->source_index == ist_index) { |
| 2231 | 2235 | if (!ist->st->codec->channel_layout || !ost->st->codec->channel_layout) |
| 2232 | 2236 | get_default_channel_layouts(ost, ist); |
| @@ -2256,15 +2260,15 @@ static int transcode_init(void) · 23 unmodified lines | ||
| 2256 | 2260 | |
| 2257 | 2261 | /* init framerate emulation */ |
| 2258 | 2262 | for (i = 0; i < nb_input_files; i++) { |
| 2259 | − InputFile *ifile = &input_files[i]; | |
| 2263 | + InputFile *ifile = input_files[i]; | |
| 2260 | 2264 | if (ifile->rate_emu) |
| 2261 | 2265 | for (j = 0; j < ifile->nb_streams; j++) |
| 2262 | − input_streams[j + ifile->ist_index].start = av_gettime(); | |
| 2266 | + input_streams[j + ifile->ist_index]->start = av_gettime(); | |
| 2263 | 2267 | } |
| 2264 | 2268 | |
| 2265 | 2269 | /* output stream init */ |
| 2266 | 2270 | for (i = 0; i < nb_output_files; i++) { |
| 2267 | − oc = output_files[i].ctx; | |
| 2271 | + oc = output_files[i]->ctx; | |
| 2268 | 2272 | if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) { |
| 2269 | 2273 | av_dump_format(oc, i, oc->filename, 1); |
| 2270 | 2274 | av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", i); |
| @@ -2274,9 +2278,9 @@ static int transcode_init(void) · 3 unmodified lines | ||
| 2274 | 2278 | |
| 2275 | 2279 | /* for each output stream, we compute the right encoding parameters */ |
| 2276 | 2280 | for (i = 0; i < nb_output_streams; i++) { |
| 2277 | − ost = &output_streams[i]; | |
| 2278 | − oc = output_files[ost->file_index].ctx; | |
| 2279 | − ist = &input_streams[ost->source_index]; | |
| 2281 | + ost = output_streams[i]; | |
| 2282 | + oc = output_files[ost->file_index]->ctx; | |
| 2283 | + ist = input_streams[ost->source_index]; | |
| 2280 | 2284 | |
| 2281 | 2285 | if (ost->attachment_filename) |
| 2282 | 2286 | continue; |
| @@ -2495,10 +2499,10 @@ static int transcode_init(void) · 212 unmodified lines | ||
| 2495 | 2499 | |
| 2496 | 2500 | /* open each encoder */ |
| 2497 | 2501 | for (i = 0; i < nb_output_streams; i++) { |
| 2498 | − ost = &output_streams[i]; | |
| 2502 | + ost = output_streams[i]; | |
| 2499 | 2503 | if (ost->encoding_needed) { |
| 2500 | 2504 | AVCodec *codec = ost->enc; |
| 2501 | − AVCodecContext *dec = input_streams[ost->source_index].st->codec; | |
| 2505 | + AVCodecContext *dec = input_streams[ost->source_index]->st->codec; | |
| 2502 | 2506 | if (!codec) { |
| 2503 | 2507 | snprintf(error, sizeof(error), "Encoder (codec id %d) not found for output stream #%d:%d", |
| 2504 | 2508 | ost->st->codec->codec_id, ost->file_index, ost->index); |
| @@ -2530,7 +2534,7 @@ static int transcode_init(void) · 25 unmodified lines | ||
| 2530 | 2534 | extra_size += ost->st->codec->extradata_size; |
| 2531 | 2535 | |
| 2532 | 2536 | if (ost->st->codec->me_threshold) |
| 2533 | − input_streams[ost->source_index].st->codec->debug |= FF_DEBUG_MV; | |
| 2537 | + input_streams[ost->source_index]->st->codec->debug |= FF_DEBUG_MV; | |
| 2534 | 2538 | } |
| 2535 | 2539 | } |
| 2536 | 2540 | |
| @@ -2541,13 +2545,13 @@ static int transcode_init(void) · 4 unmodified lines | ||
| 2541 | 2545 | |
| 2542 | 2546 | /* discard unused programs */ |
| 2543 | 2547 | for (i = 0; i < nb_input_files; i++) { |
| 2544 | − InputFile *ifile = &input_files[i]; | |
| 2548 | + InputFile *ifile = input_files[i]; | |
| 2545 | 2549 | for (j = 0; j < ifile->ctx->nb_programs; j++) { |
| 2546 | 2550 | AVProgram *p = ifile->ctx->programs[j]; |
| 2547 | 2551 | int discard = AVDISCARD_ALL; |
| 2548 | 2552 | |
| 2549 | 2553 | for (k = 0; k < p->nb_stream_indexes; k++) |
| 2550 | − if (!input_streams[ifile->ist_index + p->stream_index[k]].discard) { | |
| 2554 | + if (!input_streams[ifile->ist_index + p->stream_index[k]]->discard) { | |
| 2551 | 2555 | discard = AVDISCARD_DEFAULT; |
| 2552 | 2556 | break; |
| 2553 | 2557 | } |
| @@ -2557,14 +2561,14 @@ static int transcode_init(void) · 3 unmodified lines | ||
| 2557 | 2561 | |
| 2558 | 2562 | /* open files and write file headers */ |
| 2559 | 2563 | for (i = 0; i < nb_output_files; i++) { |
| 2560 | − oc = output_files[i].ctx; | |
| 2564 | + oc = output_files[i]->ctx; | |
| 2561 | 2565 | oc->interrupt_callback = int_cb; |
| 2562 | − if (avformat_write_header(oc, &output_files[i].opts) < 0) { | |
| 2566 | + if (avformat_write_header(oc, &output_files[i]->opts) < 0) { | |
| 2563 | 2567 | snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i); |
| 2564 | 2568 | ret = AVERROR(EINVAL); |
| 2565 | 2569 | goto dump_format; |
| 2566 | 2570 | } |
| 2567 | − assert_avoptions(output_files[i].opts); | |
| 2571 | + assert_avoptions(output_files[i]->opts); | |
| 2568 | 2572 | if (strcmp(oc->oformat->name, "rtp")) { |
| 2569 | 2573 | want_sdp = 0; |
| 2570 | 2574 | } |
| @@ -2574,13 +2578,13 @@ static int transcode_init(void) · 3 unmodified lines | ||
| 2574 | 2578 | /* dump the file output parameters - cannot be done before in case |
| 2575 | 2579 | of stream copy */ |
| 2576 | 2580 | for (i = 0; i < nb_output_files; i++) { |
| 2577 | − av_dump_format(output_files[i].ctx, i, output_files[i].ctx->filename, 1); | |
| 2581 | + av_dump_format(output_files[i]->ctx, i, output_files[i]->ctx->filename, 1); | |
| 2578 | 2582 | } |
| 2579 | 2583 | |
| 2580 | 2584 | /* dump the stream mapping */ |
| 2581 | 2585 | av_log(NULL, AV_LOG_INFO, "Stream mapping:\n"); |
| 2582 | 2586 | for (i = 0; i < nb_output_streams; i++) { |
| 2583 | − ost = &output_streams[i]; | |
| 2587 | + ost = output_streams[i]; | |
| 2584 | 2588 | |
| 2585 | 2589 | if (ost->attachment_filename) { |
| 2586 | 2590 | /* an attached file */ |
| @@ -2589,19 +2593,19 @@ static int transcode_init(void) · 2 unmodified lines | ||
| 2589 | 2593 | continue; |
| 2590 | 2594 | } |
| 2591 | 2595 | av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d", |
| 2592 | − input_streams[ost->source_index].file_index, | |
| 2593 | − input_streams[ost->source_index].st->index, | |
| 2596 | + input_streams[ost->source_index]->file_index, | |
| 2597 | + input_streams[ost->source_index]->st->index, | |
| 2594 | 2598 | ost->file_index, |
| 2595 | 2599 | ost->index); |
| 2596 | − if (ost->sync_ist != &input_streams[ost->source_index]) | |
| 2600 | + if (ost->sync_ist != input_streams[ost->source_index]) | |
| 2597 | 2601 | av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]", |
| 2598 | 2602 | ost->sync_ist->file_index, |
| 2599 | 2603 | ost->sync_ist->st->index); |
| 2600 | 2604 | if (ost->stream_copy) |
| 2601 | 2605 | av_log(NULL, AV_LOG_INFO, " (copy)"); |
| 2602 | 2606 | else |
| 2603 | − av_log(NULL, AV_LOG_INFO, " (%s -> %s)", input_streams[ost->source_index].dec ? | |
| 2604 | − input_streams[ost->source_index].dec->name : "?", | |
| 2607 | + av_log(NULL, AV_LOG_INFO, " (%s -> %s)", input_streams[ost->source_index]->dec ? | |
| 2608 | + input_streams[ost->source_index]->dec->name : "?", | |
| 2605 | 2609 | ost->enc ? ost->enc->name : "?"); |
| 2606 | 2610 | av_log(NULL, AV_LOG_INFO, "\n"); |
| 2607 | 2611 | } |
| @@ -2659,16 +2663,16 @@ static int transcode(void) · 51 unmodified lines | ||
| 2659 | 2663 | OutputFile *of; |
| 2660 | 2664 | int64_t ipts; |
| 2661 | 2665 | double opts; |
| 2662 | − ost = &output_streams[i]; | |
| 2663 | − of = &output_files[ost->file_index]; | |
| 2664 | − os = output_files[ost->file_index].ctx; | |
| 2665 | − ist = &input_streams[ost->source_index]; | |
| 2666 | + ost = output_streams[i]; | |
| 2667 | + of = output_files[ost->file_index]; | |
| 2668 | + os = output_files[ost->file_index]->ctx; | |
| 2669 | + ist = input_streams[ost->source_index]; | |
| 2666 | 2670 | if (ost->is_past_recording_time || no_packet[ist->file_index] || |
| 2667 | 2671 | (os->pb && avio_tell(os->pb) >= of->limit_filesize)) |
| 2668 | 2672 | continue; |
| 2669 | 2673 | opts = ost->st->pts.val * av_q2d(ost->st->time_base); |
| 2670 | 2674 | ipts = ist->last_dts; |
| 2671 | − if (!input_files[ist->file_index].eof_reached) { | |
| 2675 | + if (!input_files[ist->file_index]->eof_reached) { | |
| 2672 | 2676 | if (ipts < ipts_min) { |
| 2673 | 2677 | ipts_min = ipts; |
| 2674 | 2678 | if (input_sync) |
| @@ -2682,7 +2686,7 @@ static int transcode(void) · 7 unmodified lines | ||
| 2682 | 2686 | if (ost->frame_number >= ost->max_frames) { |
| 2683 | 2687 | int j; |
| 2684 | 2688 | for (j = 0; j < of->ctx->nb_streams; j++) |
| 2685 | − output_streams[of->ost_index + j].is_past_recording_time = 1; | |
| 2689 | + output_streams[of->ost_index + j]->is_past_recording_time = 1; | |
| 2686 | 2690 | continue; |
| 2687 | 2691 | } |
| 2688 | 2692 | } |
| @@ -2698,7 +2702,7 @@ static int transcode(void) · 9 unmodified lines | ||
| 2698 | 2702 | } |
| 2699 | 2703 | |
| 2700 | 2704 | /* read a frame from it and output it in the fifo */ |
| 2701 | − is = input_files[file_index].ctx; | |
| 2705 | + is = input_files[file_index]->ctx; | |
| 2702 | 2706 | ret = av_read_frame(is, &pkt); |
| 2703 | 2707 | if (ret == AVERROR(EAGAIN)) { |
| 2704 | 2708 | no_packet[file_index] = 1; |
| @@ -2706,7 +2710,7 @@ static int transcode(void) · 1 unmodified line | ||
| 2706 | 2710 | continue; |
| 2707 | 2711 | } |
| 2708 | 2712 | if (ret < 0) { |
| 2709 | − input_files[file_index].eof_reached = 1; | |
| 2713 | + input_files[file_index]->eof_reached = 1; | |
| 2710 | 2714 | if (opt_shortest) |
| 2711 | 2715 | break; |
| 2712 | 2716 | else |
| @@ -2722,17 +2726,17 @@ static int transcode(void) · 9 unmodified lines | ||
| 2722 | 2726 | } |
| 2723 | 2727 | /* the following test is needed in case new streams appear |
| 2724 | 2728 | dynamically in stream : we ignore them */ |
| 2725 | − if (pkt.stream_index >= input_files[file_index].nb_streams) | |
| 2729 | + if (pkt.stream_index >= input_files[file_index]->nb_streams) | |
| 2726 | 2730 | goto discard_packet; |
| 2727 | − ist_index = input_files[file_index].ist_index + pkt.stream_index; | |
| 2728 | − ist = &input_streams[ist_index]; | |
| 2731 | + ist_index = input_files[file_index]->ist_index + pkt.stream_index; | |
| 2732 | + ist = input_streams[ist_index]; | |
| 2729 | 2733 | if (ist->discard) |
| 2730 | 2734 | goto discard_packet; |
| 2731 | 2735 | |
| 2732 | 2736 | if (pkt.dts != AV_NOPTS_VALUE) |
| 2733 | − pkt.dts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); | |
| 2737 | + pkt.dts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); | |
| 2734 | 2738 | if (pkt.pts != AV_NOPTS_VALUE) |
| 2735 | − pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); | |
| 2739 | + pkt.pts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); | |
| 2736 | 2740 | |
| 2737 | 2741 | if (pkt.pts != AV_NOPTS_VALUE) |
| 2738 | 2742 | pkt.pts *= ist->ts_scale; |
| @@ -2748,10 +2752,10 @@ static int transcode(void) · 9 unmodified lines | ||
| 2748 | 2752 | int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); |
| 2749 | 2753 | int64_t delta = pkt_dts - ist->next_dts; |
| 2750 | 2754 | if ((FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE || pkt_dts + 1 < ist->last_dts) && !copy_ts) { |
| 2751 | − input_files[ist->file_index].ts_offset -= delta; | |
| 2755 | + input_files[ist->file_index]->ts_offset -= delta; | |
| 2752 | 2756 | av_log(NULL, AV_LOG_DEBUG, |
| 2753 | 2757 | "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", |
| 2754 | − delta, input_files[ist->file_index].ts_offset); | |
| 2758 | + delta, input_files[ist->file_index]->ts_offset); | |
| 2755 | 2759 | pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); |
| 2756 | 2760 | if (pkt.pts != AV_NOPTS_VALUE) |
| 2757 | 2761 | pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); |
| @@ -2778,7 +2782,7 @@ static int transcode(void) · 20 unmodified lines | ||
| 2778 | 2782 | |
| 2779 | 2783 | /* at the end of stream, we must flush the decoder buffers */ |
| 2780 | 2784 | for (i = 0; i < nb_input_streams; i++) { |
| 2781 | − ist = &input_streams[i]; | |
| 2785 | + ist = input_streams[i]; | |
| 2782 | 2786 | if (ist->decoding_needed) { |
| 2783 | 2787 | output_packet(ist, NULL); |
| 2784 | 2788 | } |
| @@ -2789,7 +2793,7 @@ static int transcode(void) · 4 unmodified lines | ||
| 2789 | 2793 | |
| 2790 | 2794 | /* write the trailer if needed and close file */ |
| 2791 | 2795 | for (i = 0; i < nb_output_files; i++) { |
| 2792 | − os = output_files[i].ctx; | |
| 2796 | + os = output_files[i]->ctx; | |
| 2793 | 2797 | av_write_trailer(os); |
| 2794 | 2798 | } |
| 2795 | 2799 | |
| @@ -2798,7 +2802,7 @@ static int transcode(void) · 2 unmodified lines | ||
| 2798 | 2802 | |
| 2799 | 2803 | /* close each encoder */ |
| 2800 | 2804 | for (i = 0; i < nb_output_streams; i++) { |
| 2801 | − ost = &output_streams[i]; | |
| 2805 | + ost = output_streams[i]; | |
| 2802 | 2806 | if (ost->encoding_needed) { |
| 2803 | 2807 | av_freep(&ost->st->codec->stats_in); |
| 2804 | 2808 | avcodec_close(ost->st->codec); |
| @@ -2808,7 +2812,7 @@ static int transcode(void) · 3 unmodified lines | ||
| 2808 | 2812 | |
| 2809 | 2813 | /* close each decoder */ |
| 2810 | 2814 | for (i = 0; i < nb_input_streams; i++) { |
| 2811 | − ist = &input_streams[i]; | |
| 2815 | + ist = input_streams[i]; | |
| 2812 | 2816 | if (ist->decoding_needed) { |
| 2813 | 2817 | avcodec_close(ist->st->codec); |
| 2814 | 2818 | } |
| @@ -2822,7 +2826,7 @@ static int transcode(void) · 7 unmodified lines | ||
| 2822 | 2826 | |
| 2823 | 2827 | if (output_streams) { |
| 2824 | 2828 | for (i = 0; i < nb_output_streams; i++) { |
| 2825 | − ost = &output_streams[i]; | |
| 2829 | + ost = output_streams[i]; | |
| 2826 | 2830 | if (ost) { |
| 2827 | 2831 | if (ost->stream_copy) |
| 2828 | 2832 | av_freep(&ost->st->codec->extradata); |
| @@ -2913,13 +2917,13 @@ static int opt_map(OptionsContext *o, const char *opt, const char *arg) · 84 unmodified lines | ||
| 2913 | 2917 | } |
| 2914 | 2918 | if (*sync) |
| 2915 | 2919 | sync++; |
| 2916 | − for (i = 0; i < input_files[sync_file_idx].nb_streams; i++) | |
| 2917 | − if (check_stream_specifier(input_files[sync_file_idx].ctx, | |
| 2918 | − input_files[sync_file_idx].ctx->streams[i], sync) == 1) { | |
| 2920 | + for (i = 0; i < input_files[sync_file_idx]->nb_streams; i++) | |
| 2921 | + if (check_stream_specifier(input_files[sync_file_idx]->ctx, | |
| 2922 | + input_files[sync_file_idx]->ctx->streams[i], sync) == 1) { | |
| 2919 | 2923 | sync_stream_idx = i; |
| 2920 | 2924 | break; |
| 2921 | 2925 | } |
| 2922 | − if (i == input_files[sync_file_idx].nb_streams) { | |
| 2926 | + if (i == input_files[sync_file_idx]->nb_streams) { | |
| 2923 | 2927 | av_log(NULL, AV_LOG_FATAL, "Sync stream specification in map %s does not " |
| 2924 | 2928 | "match any streams.\n", arg); |
| 2925 | 2929 | exit_program(1); |
| @@ -2937,14 +2941,14 @@ static int opt_map(OptionsContext *o, const char *opt, const char *arg) · 11 unmodified lines | ||
| 2937 | 2941 | for (i = 0; i < o->nb_stream_maps; i++) { |
| 2938 | 2942 | m = &o->stream_maps[i]; |
| 2939 | 2943 | if (file_idx == m->file_index && |
| 2940 | − check_stream_specifier(input_files[m->file_index].ctx, | |
| 2941 | − input_files[m->file_index].ctx->streams[m->stream_index], | |
| 2944 | + check_stream_specifier(input_files[m->file_index]->ctx, | |
| 2945 | + input_files[m->file_index]->ctx->streams[m->stream_index], | |
| 2942 | 2946 | *p == ':' ? p + 1 : p) > 0) |
| 2943 | 2947 | m->disabled = 1; |
| 2944 | 2948 | } |
| 2945 | 2949 | else |
| 2946 | − for (i = 0; i < input_files[file_idx].nb_streams; i++) { | |
| 2947 | − if (check_stream_specifier(input_files[file_idx].ctx, input_files[file_idx].ctx->streams[i], | |
| 2950 | + for (i = 0; i < input_files[file_idx]->nb_streams; i++) { | |
| 2951 | + if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i], | |
| 2948 | 2952 | *p == ':' ? p + 1 : p) <= 0) |
| 2949 | 2953 | continue; |
| 2950 | 2954 | o->stream_maps = grow_array(o->stream_maps, sizeof(*o->stream_maps), |
| @@ -3129,10 +3133,14 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) · 178 unmodified lines | ||
| 3129 | 3133 | for (i = 0; i < ic->nb_streams; i++) { |
| 3130 | 3134 | AVStream *st = ic->streams[i]; |
| 3131 | 3135 | AVCodecContext *dec = st->codec; |
| 3132 | − InputStream *ist; | |
| 3136 | + InputStream *ist = av_mallocz(sizeof(*ist)); | |
| 3137 | + | |
| 3138 | + if (!ist) | |
| 3139 | + exit_program(1); | |
| 3133 | 3140 | |
| 3134 | 3141 | input_streams = grow_array(input_streams, sizeof(*input_streams), &nb_input_streams, nb_input_streams + 1); |
| 3135 | − ist = &input_streams[nb_input_streams - 1]; | |
| 3142 | + input_streams[nb_input_streams - 1] = ist; | |
| 3143 | + | |
| 3136 | 3144 | ist->st = st; |
| 3137 | 3145 | ist->file_index = nb_input_files; |
| 3138 | 3146 | ist->discard = 1; |
| @@ -3314,11 +3322,14 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena · 175 unmodified lines | ||
| 3314 | 3322 | av_dump_format(ic, nb_input_files, filename, 0); |
| 3315 | 3323 | |
| 3316 | 3324 | input_files = grow_array(input_files, sizeof(*input_files), &nb_input_files, nb_input_files + 1); |
| 3317 | − input_files[nb_input_files - 1].ctx = ic; | |
| 3318 | − input_files[nb_input_files - 1].ist_index = nb_input_streams - ic->nb_streams; | |
| 3319 | − input_files[nb_input_files - 1].ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp); | |
| 3320 | − input_files[nb_input_files - 1].nb_streams = ic->nb_streams; | |
| 3321 | − input_files[nb_input_files - 1].rate_emu = o->rate_emu; | |
| 3325 | + if (!(input_files[nb_input_files - 1] = av_mallocz(sizeof(*input_files[0])))) | |
| 3326 | + exit_program(1); | |
| 3327 | + | |
| 3328 | + input_files[nb_input_files - 1]->ctx = ic; | |
| 3329 | + input_files[nb_input_files - 1]->ist_index = nb_input_streams - ic->nb_streams; | |
| 3330 | + input_files[nb_input_files - 1]->ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp); | |
| 3331 | + input_files[nb_input_files - 1]->nb_streams = ic->nb_streams; | |
| 3332 | + input_files[nb_input_files - 1]->rate_emu = o->rate_emu; | |
| 3322 | 3333 | |
| 3323 | 3334 | for (i = 0; i < o->nb_dump_attachment; i++) { |
| 3324 | 3335 | int j; |
| @@ -3445,7 +3456,10 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e · 120 unmodified lines | ||
| 3445 | 3456 | |
| 3446 | 3457 | output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams, |
| 3447 | 3458 | nb_output_streams + 1); |
| 3448 | − ost = &output_streams[nb_output_streams - 1]; | |
| 3459 | + if (!(ost = av_mallocz(sizeof(*ost)))) | |
| 3460 | + exit_program(1); | |
| 3461 | + output_streams[nb_output_streams - 1] = ost; | |
| 3462 | + | |
| 3449 | 3463 | ost->file_index = nb_output_files; |
| 3450 | 3464 | ost->index = idx; |
| 3451 | 3465 | ost->st = st; |
| @@ -3825,16 +3839,16 @@ static void opt_output_file(void *optctx, const char *filename) · 373 unmodified lines | ||
| 3825 | 3839 | if (index >= 0) {\ |
| 3826 | 3840 | ost = new_ ## type ## _stream(o, oc);\ |
| 3827 | 3841 | ost->source_index = index;\ |
| 3828 | − ost->sync_ist = &input_streams[index];\ | |
| 3829 | − input_streams[index].discard = 0;\ | |
| 3830 | − input_streams[index].st->discard = AVDISCARD_NONE;\ | |
| 3842 | + ost->sync_ist = input_streams[index];\ | |
| 3843 | + input_streams[index]->discard = 0;\ | |
| 3844 | + input_streams[index]->st->discard = AVDISCARD_NONE;\ | |
| 3831 | 3845 | } |
| 3832 | 3846 | |
| 3833 | 3847 | /* video: highest resolution */ |
| 3834 | 3848 | if (!o->video_disable && oc->oformat->video_codec != CODEC_ID_NONE) { |
| 3835 | 3849 | int area = 0, idx = -1; |
| 3836 | 3850 | for (i = 0; i < nb_input_streams; i++) { |
| 3837 | − ist = &input_streams[i]; | |
| 3851 | + ist = input_streams[i]; | |
| 3838 | 3852 | if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && |
| 3839 | 3853 | ist->st->codec->width * ist->st->codec->height > area) { |
| 3840 | 3854 | area = ist->st->codec->width * ist->st->codec->height; |
| @@ -3848,7 +3862,7 @@ static void opt_output_file(void *optctx, const char *filename) · 7 unmodified lines | ||
| 3848 | 3862 | if (!o->audio_disable && oc->oformat->audio_codec != CODEC_ID_NONE) { |
| 3849 | 3863 | int channels = 0, idx = -1; |
| 3850 | 3864 | for (i = 0; i < nb_input_streams; i++) { |
| 3851 | − ist = &input_streams[i]; | |
| 3865 | + ist = input_streams[i]; | |
| 3852 | 3866 | if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && |
| 3853 | 3867 | ist->st->codec->channels > channels) { |
| 3854 | 3868 | channels = ist->st->codec->channels; |
| @@ -3861,7 +3875,7 @@ static void opt_output_file(void *optctx, const char *filename) · 6 unmodified lines | ||
| 3861 | 3875 | /* subtitles: pick first */ |
| 3862 | 3876 | if (!o->subtitle_disable && oc->oformat->subtitle_codec != CODEC_ID_NONE) { |
| 3863 | 3877 | for (i = 0; i < nb_input_streams; i++) |
| 3864 | − if (input_streams[i].st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { | |
| 3878 | + if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { | |
| 3865 | 3879 | NEW_STREAM(subtitle, i); |
| 3866 | 3880 | break; |
| 3867 | 3881 | } |
| @@ -3874,7 +3888,7 @@ static void opt_output_file(void *optctx, const char *filename) · 6 unmodified lines | ||
| 3874 | 3888 | if (map->disabled) |
| 3875 | 3889 | continue; |
| 3876 | 3890 | |
| 3877 | − ist = &input_streams[input_files[map->file_index].ist_index + map->stream_index]; | |
| 3891 | + ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index]; | |
| 3878 | 3892 | switch (ist->st->codec->codec_type) { |
| 3879 | 3893 | case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(o, oc); break; |
| 3880 | 3894 | case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(o, oc); break; |
| @@ -3887,8 +3901,8 @@ static void opt_output_file(void *optctx, const char *filename) · 6 unmodified lines | ||
| 3887 | 3901 | exit_program(1); |
| 3888 | 3902 | } |
| 3889 | 3903 | |
| 3890 | − ost->source_index = input_files[map->file_index].ist_index + map->stream_index; | |
| 3891 | − ost->sync_ist = &input_streams[input_files[map->sync_file_index].ist_index + | |
| 3904 | + ost->source_index = input_files[map->file_index]->ist_index + map->stream_index; | |
| 3905 | + ost->sync_ist = input_streams[input_files[map->sync_file_index]->ist_index + | |
| 3892 | 3906 | map->sync_stream_index]; |
| 3893 | 3907 | ist->discard = 0; |
| 3894 | 3908 | ist->st->discard = AVDISCARD_NONE; |
| @@ -3932,14 +3946,17 @@ static void opt_output_file(void *optctx, const char *filename) · 37 unmodified lines | ||
| 3932 | 3946 | } |
| 3933 | 3947 | |
| 3934 | 3948 | output_files = grow_array(output_files, sizeof(*output_files), &nb_output_files, nb_output_files + 1); |
| 3935 | − output_files[nb_output_files - 1].ctx = oc; | |
| 3936 | − output_files[nb_output_files - 1].ost_index = nb_output_streams - oc->nb_streams; | |
| 3937 | − output_files[nb_output_files - 1].recording_time = o->recording_time; | |
| 3949 | + if (!(output_files[nb_output_files - 1] = av_mallocz(sizeof(*output_files[0])))) | |
| 3950 | + exit_program(1); | |
| 3951 | + | |
| 3952 | + output_files[nb_output_files - 1]->ctx = oc; | |
| 3953 | + output_files[nb_output_files - 1]->ost_index = nb_output_streams - oc->nb_streams; | |
| 3954 | + output_files[nb_output_files - 1]->recording_time = o->recording_time; | |
| 3938 | 3955 | if (o->recording_time != INT64_MAX) |
| 3939 | 3956 | oc->duration = o->recording_time; |
| 3940 | − output_files[nb_output_files - 1].start_time = o->start_time; | |
| 3941 | − output_files[nb_output_files - 1].limit_filesize = o->limit_filesize; | |
| 3942 | − av_dict_copy(&output_files[nb_output_files - 1].opts, format_opts, 0); | |
| 3957 | + output_files[nb_output_files - 1]->start_time = o->start_time; | |
| 3958 | + output_files[nb_output_files - 1]->limit_filesize = o->limit_filesize; | |
| 3959 | + av_dict_copy(&output_files[nb_output_files - 1]->opts, format_opts, 0); | |
| 3943 | 3960 | |
| 3944 | 3961 | /* check filename in case of an image number is expected */ |
| 3945 | 3962 | if (oc->oformat->flags & AVFMT_NEEDNUMBER) { |
| @@ -3956,7 +3973,7 @@ static void opt_output_file(void *optctx, const char *filename) · 10 unmodified lines | ||
| 3956 | 3973 | /* open the file */ |
| 3957 | 3974 | if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE, |
| 3958 | 3975 | &oc->interrupt_callback, |
| 3959 | − &output_files[nb_output_files - 1].opts)) < 0) { | |
| 3976 | + &output_files[nb_output_files - 1]->opts)) < 0) { | |
| 3960 | 3977 | print_error(filename, err); |
| 3961 | 3978 | exit_program(1); |
| 3962 | 3979 | } |
| @@ -3965,7 +3982,7 @@ static void opt_output_file(void *optctx, const char *filename) · 2 unmodified lines | ||
| 3965 | 3982 | if (o->mux_preload) { |
| 3966 | 3983 | uint8_t buf[64]; |
| 3967 | 3984 | snprintf(buf, sizeof(buf), "%d", (int)(o->mux_preload*AV_TIME_BASE)); |
| 3968 | − av_dict_set(&output_files[nb_output_files - 1].opts, "preload", buf, 0); | |
| 3985 | + av_dict_set(&output_files[nb_output_files - 1]->opts, "preload", buf, 0); | |
| 3969 | 3986 | } |
| 3970 | 3987 | oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE); |
| 3971 | 3988 | oc->flags |= AVFMT_FLAG_NONBLOCK; |
| @@ -3981,7 +3998,7 @@ static void opt_output_file(void *optctx, const char *filename) · 9 unmodified lines | ||
| 3981 | 3998 | av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d while processing metadata maps\n", in_file_index); |
| 3982 | 3999 | exit_program(1); |
| 3983 | 4000 | } |
| 3984 | − copy_metadata(o->metadata_map[i].specifier, *p ? p + 1 : p, oc, input_files[in_file_index].ctx, o); | |
| 4001 | + copy_metadata(o->metadata_map[i].specifier, *p ? p + 1 : p, oc, input_files[in_file_index]->ctx, o); | |
| 3985 | 4002 | } |
| 3986 | 4003 | |
| 3987 | 4004 | /* copy chapters */ |
| @@ -3990,7 +4007,7 @@ static void opt_output_file(void *optctx, const char *filename) · 2 unmodified lines | ||
| 3990 | 4007 | /* copy chapters from the first input file that has them*/ |
| 3991 | 4008 | o->chapters_input_file = -1; |
| 3992 | 4009 | for (i = 0; i < nb_input_files; i++) |
| 3993 | − if (input_files[i].ctx->nb_chapters) { | |
| 4010 | + if (input_files[i]->ctx->nb_chapters) { | |
| 3994 | 4011 | o->chapters_input_file = i; |
| 3995 | 4012 | break; |
| 3996 | 4013 | } |
| @@ -4001,20 +4018,20 @@ static void opt_output_file(void *optctx, const char *filename) · 4 unmodified lines | ||
| 4001 | 4018 | } |
| 4002 | 4019 | } |
| 4003 | 4020 | if (o->chapters_input_file >= 0) |
| 4004 | − copy_chapters(&input_files[o->chapters_input_file], &output_files[nb_output_files - 1], | |
| 4021 | + copy_chapters(input_files[o->chapters_input_file], output_files[nb_output_files - 1], | |
| 4005 | 4022 | !o->metadata_chapters_manual); |
| 4006 | 4023 | |
| 4007 | 4024 | /* copy global metadata by default */ |
| 4008 | 4025 | if (!o->metadata_global_manual && nb_input_files) |
| 4009 | − av_dict_copy(&oc->metadata, input_files[0].ctx->metadata, | |
| 4026 | + av_dict_copy(&oc->metadata, input_files[0]->ctx->metadata, | |
| 4010 | 4027 | AV_DICT_DONT_OVERWRITE); |
| 4011 | 4028 | if (!o->metadata_streams_manual) |
| 4012 | − for (i = output_files[nb_output_files - 1].ost_index; i < nb_output_streams; i++) { | |
| 4029 | + for (i = output_files[nb_output_files - 1]->ost_index; i < nb_output_streams; i++) { | |
| 4013 | 4030 | InputStream *ist; |
| 4014 | − if (output_streams[i].source_index < 0) /* this is true e.g. for attached files */ | |
| 4031 | + if (output_streams[i]->source_index < 0) /* this is true e.g. for attached files */ | |
| 4015 | 4032 | continue; |
| 4016 | − ist = &input_streams[output_streams[i].source_index]; | |
| 4017 | − av_dict_copy(&output_streams[i].st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE); | |
| 4033 | + ist = input_streams[output_streams[i]->source_index]; | |
| 4034 | + av_dict_copy(&output_streams[i]->st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE); | |
| 4018 | 4035 | } |
| 4019 | 4036 | |
| 4020 | 4037 | /* process manually set metadata */ |
| @@ -4173,8 +4190,8 @@ static int opt_target(OptionsContext *o, const char *opt, const char *arg) · 152 unmodified lines | ||
| 4173 | 4190 | if (nb_input_files) { |
| 4174 | 4191 | int i, j, fr; |
| 4175 | 4192 | for (j = 0; j < nb_input_files; j++) { |
| 4176 | − for (i = 0; i < input_files[j].nb_streams; i++) { | |
| 4177 | − AVCodecContext *c = input_files[j].ctx->streams[i]->codec; | |
| 4193 | + for (i = 0; i < input_files[j]->nb_streams; i++) { | |
| 4194 | + AVCodecContext *c = input_files[j]->ctx->streams[i]->codec; | |
| 4178 | 4195 | if (c->codec_type != AVMEDIA_TYPE_VIDEO) |
| 4179 | 4196 | continue; |
| 4180 | 4197 | fr = c->time_base.den * 1000 / c->time_base.num; |