They are globals, no point in pretending they are not.
Unified · Split
| @@ -1485,9 +1485,7 @@ static void do_video_stats(AVFormatContext *os, OutputStream *ost, · 1484 unmodified lines | |||
| 1485 | } | 1485 | } |
| 1486 | } | 1486 | } |
| 1487 | 1487 | ||
| 1488 | static void print_report(OutputFile *output_files, | 1488 | static void print_report(int is_last_report, int64_t timer_start) |
| 1489 | OutputStream *ost_table, int nb_ostreams, | ||
| 1490 | int is_last_report, int64_t timer_start) | ||
| 1491 | { | 1489 | { |
| 1492 | char buf[1024]; | 1490 | char buf[1024]; |
| 1493 | OutputStream *ost; | 1491 | OutputStream *ost; |
| @@ -1525,9 +1523,9 @@ static void print_report(OutputFile *output_files, · 31 unmodified lines | |||
| 1525 | buf[0] = '\0'; | 1523 | buf[0] = '\0'; |
| 1526 | ti1 = 1e10; | 1524 | ti1 = 1e10; |
| 1527 | vid = 0; | 1525 | vid = 0; |
| 1528 | for (i = 0; i < nb_ostreams; i++) { | 1526 | for (i = 0; i < nb_output_streams; i++) { |
| 1529 | float q = -1; | 1527 | float q = -1; |
| 1530 | ost = &ost_table[i]; | 1528 | ost = &output_streams[i]; |
| 1531 | enc = ost->st->codec; | 1529 | enc = ost->st->codec; |
| 1532 | if (!ost->stream_copy && enc->coded_frame) | 1530 | if (!ost->stream_copy && enc->coded_frame) |
| 1533 | q = enc->coded_frame->quality / (float)FF_QP2LAMBDA; | 1531 | q = enc->coded_frame->quality / (float)FF_QP2LAMBDA; |
| @@ -1608,12 +1606,12 @@ static void print_report(OutputFile *output_files, · 74 unmodified lines | |||
| 1608 | } | 1606 | } |
| 1609 | } | 1607 | } |
| 1610 | 1608 | ||
| 1611 | static void flush_encoders(OutputStream *ost_table, int nb_ostreams) | 1609 | static void flush_encoders(void) |
| 1612 | { | 1610 | { |
| 1613 | int i, ret; | 1611 | int i, ret; |
| 1614 | 1612 | ||
| 1615 | for (i = 0; i < nb_ostreams; i++) { | 1613 | for (i = 0; i < nb_output_streams; i++) { |
| 1616 | OutputStream *ost = &ost_table[i]; | 1614 | OutputStream *ost = &output_streams[i]; |
| 1617 | AVCodecContext *enc = ost->st->codec; | 1615 | AVCodecContext *enc = ost->st->codec; |
| 1618 | AVFormatContext *os = output_files[ost->file_index].ctx; | 1616 | AVFormatContext *os = output_files[ost->file_index].ctx; |
| 1619 | int stop_encoding = 0; | 1617 | int stop_encoding = 0; |
| @@ -2020,9 +2018,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) · 400 unmodified lines | |||
| 2020 | } | 2018 | } |
| 2021 | 2019 | ||
| 2022 | /* pkt = NULL means EOF (needed to flush decoder buffers) */ | 2020 | /* pkt = NULL means EOF (needed to flush decoder buffers) */ |
| 2023 | static int output_packet(InputStream *ist, | 2021 | static int output_packet(InputStream *ist, const AVPacket *pkt) |
| 2024 | OutputStream *ost_table, int nb_ostreams, | ||
| 2025 | const AVPacket *pkt) | ||
| 2026 | { | 2022 | { |
| 2027 | int i; | 2023 | int i; |
| 2028 | int got_output; | 2024 | int got_output; |
| @@ -2116,8 +2112,8 @@ static int output_packet(InputStream *ist, · 87 unmodified lines | |||
| 2116 | break; | 2112 | break; |
| 2117 | } | 2113 | } |
| 2118 | } | 2114 | } |
| 2119 | for (i = 0; pkt && i < nb_ostreams; i++) { | 2115 | for (i = 0; pkt && i < nb_output_streams; i++) { |
| 2120 | OutputStream *ost = &ost_table[i]; | 2116 | OutputStream *ost = &output_streams[i]; |
| 2121 | 2117 | ||
| 2122 | if (!check_output_constraints(ist, ost) || ost->encoding_needed) | 2118 | if (!check_output_constraints(ist, ost) || ost->encoding_needed) |
| 2123 | continue; | 2119 | continue; |
| @@ -2128,18 +2124,18 @@ static int output_packet(InputStream *ist, · 4 unmodified lines | |||
| 2128 | return 0; | 2124 | return 0; |
| 2129 | } | 2125 | } |
| 2130 | 2126 | ||
| 2131 | static void print_sdp(OutputFile *output_files, int n) | 2127 | static void print_sdp(void) |
| 2132 | { | 2128 | { |
| 2133 | char sdp[2048]; | 2129 | char sdp[2048]; |
| 2134 | int i; | 2130 | int i; |
| 2135 | AVFormatContext **avc = av_malloc(sizeof(*avc) * n); | 2131 | AVFormatContext **avc = av_malloc(sizeof(*avc) * nb_output_files); |
| 2136 | 2132 | ||
| 2137 | if (!avc) | 2133 | if (!avc) |
| 2138 | exit_program(1); | 2134 | exit_program(1); |
| 2139 | for (i = 0; i < n; i++) | 2135 | for (i = 0; i < nb_output_files; i++) |
| 2140 | avc[i] = output_files[i].ctx; | 2136 | avc[i] = output_files[i].ctx; |
| 2141 | 2137 | ||
| 2142 | av_sdp_create(avc, n, sdp, sizeof(sdp)); | 2138 | av_sdp_create(avc, nb_output_files, sdp, sizeof(sdp)); |
| 2143 | printf("SDP:\n%s\n", sdp); | 2139 | printf("SDP:\n%s\n", sdp); |
| 2144 | fflush(stdout); | 2140 | fflush(stdout); |
| 2145 | av_freep(&avc); | 2141 | av_freep(&avc); |
| @@ -2190,8 +2186,7 @@ static void get_default_channel_layouts(OutputStream *ost, InputStream *ist) · 44 unmodified lines | |||
| 2190 | } | 2186 | } |
| 2191 | 2187 | ||
| 2192 | 2188 | ||
| 2193 | static int init_input_stream(int ist_index, OutputStream *output_streams, int nb_output_streams, | 2189 | static int init_input_stream(int ist_index, char *error, int error_len) |
| 2194 | char *error, int error_len) | ||
| 2195 | { | 2190 | { |
| 2196 | int i; | 2191 | int i; |
| 2197 | InputStream *ist = &input_streams[ist_index]; | 2192 | InputStream *ist = &input_streams[ist_index]; |
| @@ -2249,10 +2244,7 @@ static int init_input_stream(int ist_index, OutputStream *output_streams, int nb · 51 unmodified lines | |||
| 2249 | return 0; | 2244 | return 0; |
| 2250 | } | 2245 | } |
| 2251 | 2246 | ||
| 2252 | static int transcode_init(OutputFile *output_files, | 2247 | static int transcode_init(void) |
| 2253 | int nb_output_files, | ||
| 2254 | InputFile *input_files, | ||
| 2255 | int nb_input_files) | ||
| 2256 | { | 2248 | { |
| 2257 | int ret = 0, i, j, k; | 2249 | int ret = 0, i, j, k; |
| 2258 | AVFormatContext *oc; | 2250 | AVFormatContext *oc; |
| @@ -2544,7 +2536,7 @@ static int transcode_init(OutputFile *output_files, · 285 unmodified lines | |||
| 2544 | 2536 | ||
| 2545 | /* init input streams */ | 2537 | /* init input streams */ |
| 2546 | for (i = 0; i < nb_input_streams; i++) | 2538 | for (i = 0; i < nb_input_streams; i++) |
| 2547 | if ((ret = init_input_stream(i, output_streams, nb_output_streams, error, sizeof(error))) < 0) | 2539 | if ((ret = init_input_stream(i, error, sizeof(error))) < 0) |
| 2548 | goto dump_format; | 2540 | goto dump_format; |
| 2549 | 2541 | ||
| 2550 | /* discard unused programs */ | 2542 | /* discard unused programs */ |
| @@ -2620,7 +2612,7 @@ static int transcode_init(OutputFile *output_files, · 69 unmodified lines | |||
| 2620 | } | 2612 | } |
| 2621 | 2613 | ||
| 2622 | if (want_sdp) { | 2614 | if (want_sdp) { |
| 2623 | print_sdp(output_files, nb_output_files); | 2615 | print_sdp(); |
| 2624 | } | 2616 | } |
| 2625 | 2617 | ||
| 2626 | return 0; | 2618 | return 0; |
| @@ -2629,10 +2621,7 @@ static int transcode_init(OutputFile *output_files, · 2 unmodified lines | |||
| 2629 | /* | 2621 | /* |
| 2630 | * The following code is the main loop of the file converter | 2622 | * The following code is the main loop of the file converter |
| 2631 | */ | 2623 | */ |
| 2632 | static int transcode(OutputFile *output_files, | 2624 | static int transcode(void) |
| 2633 | int nb_output_files, | ||
| 2634 | InputFile *input_files, | ||
| 2635 | int nb_input_files) | ||
| 2636 | { | 2625 | { |
| 2637 | int ret, i; | 2626 | int ret, i; |
| 2638 | AVFormatContext *is, *os; | 2627 | AVFormatContext *is, *os; |
| @@ -2645,7 +2634,7 @@ static int transcode(OutputFile *output_files, · 6 unmodified lines | |||
| 2645 | if (!(no_packet = av_mallocz(nb_input_files))) | 2634 | if (!(no_packet = av_mallocz(nb_input_files))) |
| 2646 | exit_program(1); | 2635 | exit_program(1); |
| 2647 | 2636 | ||
| 2648 | ret = transcode_init(output_files, nb_output_files, input_files, nb_input_files); | 2637 | ret = transcode_init(); |
| 2649 | if (ret < 0) | 2638 | if (ret < 0) |
| 2650 | goto fail; | 2639 | goto fail; |
| 2651 | 2640 | ||
| @@ -2770,7 +2759,7 @@ static int transcode(OutputFile *output_files, · 118 unmodified lines | |||
| 2770 | } | 2759 | } |
| 2771 | 2760 | ||
| 2772 | // fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size); | 2761 | // fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size); |
| 2773 | if (output_packet(ist, output_streams, nb_output_streams, &pkt) < 0) { | 2762 | if (output_packet(ist, &pkt) < 0) { |
| 2774 | 2763 | ||
| 2775 | av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n", | 2764 | av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n", |
| 2776 | ist->file_index, ist->st->index); | 2765 | ist->file_index, ist->st->index); |
| @@ -2784,17 +2773,17 @@ static int transcode(OutputFile *output_files, · 7 unmodified lines | |||
| 2784 | av_free_packet(&pkt); | 2773 | av_free_packet(&pkt); |
| 2785 | 2774 | ||
| 2786 | /* dump report by using the output first video and audio streams */ | 2775 | /* dump report by using the output first video and audio streams */ |
| 2787 | print_report(output_files, output_streams, nb_output_streams, 0, timer_start); | 2776 | print_report(0, timer_start); |
| 2788 | } | 2777 | } |
| 2789 | 2778 | ||
| 2790 | /* at the end of stream, we must flush the decoder buffers */ | 2779 | /* at the end of stream, we must flush the decoder buffers */ |
| 2791 | for (i = 0; i < nb_input_streams; i++) { | 2780 | for (i = 0; i < nb_input_streams; i++) { |
| 2792 | ist = &input_streams[i]; | 2781 | ist = &input_streams[i]; |
| 2793 | if (ist->decoding_needed) { | 2782 | if (ist->decoding_needed) { |
| 2794 | output_packet(ist, output_streams, nb_output_streams, NULL); | 2783 | output_packet(ist, NULL); |
| 2795 | } | 2784 | } |
| 2796 | } | 2785 | } |
| 2797 | flush_encoders(output_streams, nb_output_streams); | 2786 | flush_encoders(); |
| 2798 | 2787 | ||
| 2799 | term_exit(); | 2788 | term_exit(); |
| 2800 | 2789 | ||
| @@ -2805,7 +2794,7 @@ static int transcode(OutputFile *output_files, · 4 unmodified lines | |||
| 2805 | } | 2794 | } |
| 2806 | 2795 | ||
| 2807 | /* dump report by using the first video and audio streams */ | 2796 | /* dump report by using the first video and audio streams */ |
| 2808 | print_report(output_files, output_streams, nb_output_streams, 1, timer_start); | 2797 | print_report(1, timer_start); |
| 2809 | 2798 | ||
| 2810 | /* close each encoder */ | 2799 | /* close each encoder */ |
| 2811 | for (i = 0; i < nb_output_streams; i++) { | 2800 | for (i = 0; i < nb_output_streams; i++) { |
| @@ -4622,7 +4611,7 @@ int main(int argc, char **argv) · 1810 unmodified lines | |||
| 4622 | } | 4611 | } |
| 4623 | 4612 | ||
| 4624 | ti = getutime(); | 4613 | ti = getutime(); |
| 4625 | if (transcode(output_files, nb_output_files, input_files, nb_input_files) < 0) | 4614 | if (transcode() < 0) |
| 4626 | exit_program(1); | 4615 | exit_program(1); |
| 4627 | ti = getutime() - ti; | 4616 | ti = getutime() - ti; |
| 4628 | if (do_benchmark) { | 4617 | if (do_benchmark) { |