History

cmdutils: move exit_program() declaration to cmdutils from avconv

Allows cmdutils to call each tool's own cleanup function.

Anton Khirnov committed 15 years ago

Commit dad09ff1 parent 346ea9e7 files · +105 −83Browse files

Unified · Split

7 files
  1. avconv.c +3 −3
  2. avplay.c +5 −0
  3. avprobe.c +5 −0
  4. avserver.c +5 −0
  5. cmdutils.c +8 −7
  6. cmdutils.h +6 −0
  7. ffmpeg.c +73 −73
avconv.c+3−3
@@ -433,7 +433,7 @@ static int decode_interrupt_cb(void) · 432 unmodified lines
433433 return received_nb_signals > 1;
434434 }
435435
436−static int exit_program(int ret)
436+void exit_program(int ret)
437437 {
438438 int i;
439439
@@ -483,7 +483,6 @@ static int exit_program(int ret) · 43 unmodified lines
483483 }
484484
485485 exit(ret); /* not all OS-es handle main() return value */
486− return ret;
487486 }
488487
489488 static void assert_avoptions(AVDictionary *m)
@@ -4192,5 +4191,6 @@ int main(int argc, char **argv) · 3702 unmodified lines
41924191 printf("bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss);
41934192 }
41944193
4195− return exit_program(0);
4194+ exit_program(0);
4195+ return 0;
41964196 }
avplay.c+5−0
@@ -278,6 +278,11 @@ static AVPacket flush_pkt; · 277 unmodified lines
278278
279279 static SDL_Surface *screen;
280280
281+void exit_program(int ret)
282+{
283+ exit(ret);
284+}
285+
281286 static int packet_queue_put(PacketQueue *q, AVPacket *pkt);
282287
283288 /* packet queue handling */
avprobe.c+5−0
@@ -56,6 +56,11 @@ static const char *unit_hertz_str = "Hz" ; · 55 unmodified lines
5656 static const char *unit_byte_str = "byte" ;
5757 static const char *unit_bit_per_second_str = "bit/s";
5858
59+void exit_program(int ret)
60+{
61+ exit(ret);
62+}
63+
5964 static char *value_string(char *buf, int buf_size, double val, const char *unit)
6065 {
6166 if (unit == unit_second_str && use_value_sexagesimal_format) {
avserver.c+5−0
@@ -320,6 +320,11 @@ static AVLFG random_state; · 319 unmodified lines
320320
321321 static FILE *logfile = NULL;
322322
323+void exit_program(int ret)
324+{
325+ exit(ret);
326+}
327+
323328 /* FIXME: make avserver work with IPv6 */
324329 /* resolve host with also IP address parsing */
325330 static int resolve_host(struct in_addr *sin_addr, const char *hostname)
cmdutils.c+8−7
@@ -92,7 +92,8 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do · 91 unmodified lines
9292 else
9393 return d;
9494 fprintf(stderr, error, context, numstr, min, max);
95− exit(1);
95+ exit_program(1);
96+ return 0;
9697 }
9798
9899 int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
@@ -101,7 +102,7 @@ int64_t parse_time_or_die(const char *context, const char *timestr, int is_durat · 2 unmodified lines
101102 if (av_parse_time(&us, timestr, is_duration) < 0) {
102103 fprintf(stderr, "Invalid %s specification for %s: %s\n",
103104 is_duration ? "duration" : "date", context, timestr);
104− exit(1);
105+ exit_program(1);
105106 }
106107 return us;
107108 }
@@ -237,14 +238,14 @@ void parse_options(int argc, char **argv, const OptionDef *options, · 129 unmodified lines
237238 if (!po->name) {
238239 unknown_opt:
239240 fprintf(stderr, "%s: unrecognized option '%s'\n", argv[0], opt);
240− exit(1);
241+ exit_program(1);
241242 }
242243 arg = NULL;
243244 if (po->flags & HAS_ARG) {
244245 arg = argv[optindex++];
245246 if (!arg) {
246247 fprintf(stderr, "%s: missing argument for option '%s'\n", argv[0], opt);
247− exit(1);
248+ exit_program(1);
248249 }
249250 }
250251 if (po->flags & OPT_STRING) {
@@ -262,11 +263,11 @@ unknown_opt: · 11 unmodified lines
262263 } else if (po->u.func_arg) {
263264 if (po->u.func_arg(opt, arg) < 0) {
264265 fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt);
265− exit(1);
266+ exit_program(1);
266267 }
267268 }
268269 if(po->flags & OPT_EXIT)
269− exit(0);
270+ exit_program(0);
270271 } else {
271272 if (parse_arg_function)
272273 parse_arg_function(opt);
@@ -336,7 +337,7 @@ int opt_loglevel(const char *opt, const char *arg) · 63 unmodified lines
336337 "Possible levels are numbers or:\n", arg);
337338 for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
338339 fprintf(stderr, "\"%s\"\n", log_levels[i].name);
339− exit(1);
340+ exit_program(1);
340341 }
341342 av_log_set_level(level);
342343 return 0;
cmdutils.h+6−0
@@ -327,4 +327,10 @@ extern AVFilter ffsink; · 326 unmodified lines
327327 int get_filtered_video_frame(AVFilterContext *sink, AVFrame *frame,
328328 AVFilterBufferRef **picref, AVRational *pts_tb);
329329
330+/**
331+ * Do all the necessary cleanup and abort.
332+ * This function is implemented in the avtools, not cmdutils.
333+ */
334+void exit_program(int ret);
335+
330336 #endif /* LIBAV_CMDUTILS_H */
ffmpeg.c+73−73
@@ -445,7 +445,7 @@ static int decode_interrupt_cb(void) · 444 unmodified lines
445445 return received_nb_signals > 1;
446446 }
447447
448−static int ffmpeg_exit(int ret)
448+void exit_program(int ret)
449449 {
450450 int i;
451451
@@ -501,7 +501,6 @@ static int ffmpeg_exit(int ret) · 49 unmodified lines
501501 }
502502
503503 exit(ret); /* not all OS-es handle main() return value */
504− return ret;
505504 }
506505
507506 static void assert_avoptions(AVDictionary *m)
@@ -509,7 +508,7 @@ static void assert_avoptions(AVDictionary *m) · 1 unmodified line
509508 AVDictionaryEntry *t;
510509 if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
511510 av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
512− ffmpeg_exit(1);
511+ exit_program(1);
513512 }
514513 }
515514
@@ -526,7 +525,7 @@ static void assert_codec_experimental(AVCodecContext *c, int encoder) · 10 unmodified lines
526525 if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL))
527526 av_log(NULL, AV_LOG_ERROR, "Or use the non experimental %s '%s'.\n",
528527 codec_string, codec->name);
529− ffmpeg_exit(1);
528+ exit_program(1);
530529 }
531530 }
532531
@@ -535,13 +534,13 @@ static void *grow_array(void *array, int elem_size, int *size, int new_size) · 2 unmodified lines
535534 {
536535 if (new_size >= INT_MAX / elem_size) {
537536 fprintf(stderr, "Array too big.\n");
538− ffmpeg_exit(1);
537+ exit_program(1);
539538 }
540539 if (*size < new_size) {
541540 uint8_t *tmp = av_realloc(array, new_size*elem_size);
542541 if (!tmp) {
543542 fprintf(stderr, "Could not alloc buffer.\n");
544− ffmpeg_exit(1);
543+ exit_program(1);
545544 }
546545 memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
547546 *size = new_size;
@@ -664,7 +663,7 @@ static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx, AVCode · 116 unmodified lines
664663
665664 if (!st) {
666665 av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n");
667− ffmpeg_exit(1);
666+ exit_program(1);
668667 }
669668
670669 output_streams_for_file[file_idx] =
@@ -676,7 +675,7 @@ static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx, AVCode · 5 unmodified lines
676675 av_mallocz(sizeof(OutputStream));
677676 if (!ost) {
678677 fprintf(stderr, "Could not alloc output stream\n");
679− ffmpeg_exit(1);
678+ exit_program(1);
680679 }
681680 ost->file_index = file_idx;
682681 ost->index = idx;
@@ -756,7 +755,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx · 73 unmodified lines
756755 avctx->codec ? avctx->codec->name : "copy");
757756 print_error("", a);
758757 if (exit_on_error)
759− ffmpeg_exit(1);
758+ exit_program(1);
760759 }
761760 *pkt= new_pkt;
762761
@@ -766,7 +765,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx · 3 unmodified lines
766765 ret= av_interleaved_write_frame(s, pkt);
767766 if(ret < 0){
768767 print_error("av_interleaved_write_frame()", ret);
769− ffmpeg_exit(1);
768+ exit_program(1);
770769 }
771770 }
772771
@@ -802,14 +801,14 @@ need_realloc: · 29 unmodified lines
802801
803802 if(audio_out_size > INT_MAX || audio_buf_size > INT_MAX){
804803 fprintf(stderr, "Buffer sizes too large\n");
805− ffmpeg_exit(1);
804+ exit_program(1);
806805 }
807806
808807 av_fast_malloc(&audio_buf, &allocated_audio_buf_size, audio_buf_size);
809808 av_fast_malloc(&audio_out, &allocated_audio_out_size, audio_out_size);
810809 if (!audio_buf || !audio_out){
811810 fprintf(stderr, "Out of memory in do_audio_out\n");
812− ffmpeg_exit(1);
811+ exit_program(1);
813812 }
814813
815814 if (enc->channels != dec->channels || enc->sample_rate != dec->sample_rate)
@@ -849,7 +848,7 @@ need_realloc: · 33 unmodified lines
849848 fprintf(stderr, "Can not resample %d channels @ %d Hz to %d channels @ %d Hz\n",
850849 dec->channels, dec->sample_rate,
851850 enc->channels, enc->sample_rate);
852− ffmpeg_exit(1);
851+ exit_program(1);
853852 }
854853 }
855854 }
@@ -865,7 +864,7 @@ need_realloc: · 9 unmodified lines
865864 fprintf(stderr, "Cannot convert %s sample format to %s sample format\n",
866865 av_get_sample_fmt_name(dec->sample_fmt),
867866 av_get_sample_fmt_name(enc->sample_fmt));
868− ffmpeg_exit(1);
867+ exit_program(1);
869868 }
870869 ost->reformat_pair=MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt);
871870 }
@@ -938,7 +937,7 @@ need_realloc: · 66 unmodified lines
938937 if (av_audio_convert(ost->reformat_ctx, obuf, ostride, ibuf, istride, len)<0) {
939938 printf("av_audio_convert() failed\n");
940939 if (exit_on_error)
941− ffmpeg_exit(1);
940+ exit_program(1);
942941 return;
943942 }
944943 buftmp = audio_buf;
@@ -950,7 +949,7 @@ need_realloc: · 5 unmodified lines
950949 /* output resampled raw samples */
951950 if (av_fifo_realloc2(ost->fifo, av_fifo_size(ost->fifo) + size_out) < 0) {
952951 fprintf(stderr, "av_fifo_realloc2() failed\n");
953− ffmpeg_exit(1);
952+ exit_program(1);
954953 }
955954 av_fifo_generic_write(ost->fifo, buftmp, size_out, NULL);
956955
@@ -968,7 +967,7 @@ need_realloc: · 11 unmodified lines
968967 (short *)audio_buf);
969968 if (ret < 0) {
970969 fprintf(stderr, "Audio encoding failed\n");
971− ffmpeg_exit(1);
970+ exit_program(1);
972971 }
973972 audio_size += ret;
974973 pkt.stream_index= ost->index;
@@ -995,7 +994,7 @@ need_realloc: · 20 unmodified lines
995994
996995 if(size_out > audio_out_size){
997996 fprintf(stderr, "Internal error, buffer size too small\n");
998− ffmpeg_exit(1);
997+ exit_program(1);
999998 }
1000999
10011000 //FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
@@ -1003,7 +1002,7 @@ need_realloc: · 1 unmodified line
10031002 (short *)buftmp);
10041003 if (ret < 0) {
10051004 fprintf(stderr, "Audio encoding failed\n");
1006− ffmpeg_exit(1);
1005+ exit_program(1);
10071006 }
10081007 audio_size += ret;
10091008 pkt.stream_index= ost->index;
@@ -1073,7 +1072,7 @@ static void do_subtitle_out(AVFormatContext *s, · 63 unmodified lines
10731072 if (pts == AV_NOPTS_VALUE) {
10741073 fprintf(stderr, "Subtitle packets must have a pts\n");
10751074 if (exit_on_error)
1076− ffmpeg_exit(1);
1075+ exit_program(1);
10771076 return;
10781077 }
10791078
@@ -1101,7 +1100,7 @@ static void do_subtitle_out(AVFormatContext *s, · 21 unmodified lines
11011100 subtitle_out_max_size, sub);
11021101 if (subtitle_out_size < 0) {
11031102 fprintf(stderr, "Subtitle encoding failed\n");
1104− ffmpeg_exit(1);
1103+ exit_program(1);
11051104 }
11061105
11071106 av_init_packet(&pkt);
@@ -1188,7 +1187,7 @@ static void do_video_out(AVFormatContext *s, · 80 unmodified lines
11881187 ost->resample_width, ost->resample_height, av_get_pix_fmt_name(ost->resample_pix_fmt),
11891188 dec->width , dec->height , av_get_pix_fmt_name(dec->pix_fmt));
11901189 if(!ost->video_resample)
1191− ffmpeg_exit(1);
1190+ exit_program(1);
11921191 }
11931192
11941193 #if !CONFIG_AVFILTER
@@ -1207,7 +1206,7 @@ static void do_video_out(AVFormatContext *s, · 12 unmodified lines
12071206 ost->sws_flags, NULL, NULL, NULL);
12081207 if (ost->img_resample_ctx == NULL) {
12091208 fprintf(stderr, "Cannot get resampling context\n");
1210− ffmpeg_exit(1);
1209+ exit_program(1);
12111210 }
12121211 }
12131212 sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,
@@ -1267,7 +1266,7 @@ static void do_video_out(AVFormatContext *s, · 53 unmodified lines
12671266 &big_picture);
12681267 if (ret < 0) {
12691268 fprintf(stderr, "Video encoding failed\n");
1270− ffmpeg_exit(1);
1269+ exit_program(1);
12711270 }
12721271
12731272 if(ret>0){
@@ -1313,7 +1312,7 @@ static void do_video_stats(AVFormatContext *os, OutputStream *ost, · 39 unmodified lines
13131312 vstats_file = fopen(vstats_filename, "w");
13141313 if (!vstats_file) {
13151314 perror("fopen");
1316− ffmpeg_exit(1);
1315+ exit_program(1);
13171316 }
13181317 }
13191318
@@ -1818,7 +1817,7 @@ static int output_packet(InputStream *ist, int ist_index, · 498 unmodified lines
18181817 } else { /* pad */
18191818 int frame_bytes = enc->frame_size*osize*enc->channels;
18201819 if (allocated_audio_buf_size < frame_bytes)
1821− ffmpeg_exit(1);
1820+ exit_program(1);
18221821 generate_silence(audio_buf+fifo_bytes, enc->sample_fmt, frame_bytes - fifo_bytes);
18231822 }
18241823
@@ -1832,7 +1831,7 @@ static int output_packet(InputStream *ist, int ist_index, · 7 unmodified lines
18321831 }
18331832 if (ret < 0) {
18341833 fprintf(stderr, "Audio encoding failed\n");
1835− ffmpeg_exit(1);
1834+ exit_program(1);
18361835 }
18371836 audio_size += ret;
18381837 pkt.flags |= AV_PKT_FLAG_KEY;
@@ -1841,7 +1840,7 @@ static int output_packet(InputStream *ist, int ist_index, · 2 unmodified lines
18411840 ret = avcodec_encode_video(enc, bit_buffer, bit_buffer_size, NULL);
18421841 if (ret < 0) {
18431842 fprintf(stderr, "Video encoding failed\n");
1844− ffmpeg_exit(1);
1843+ exit_program(1);
18451844 }
18461845 video_size += ret;
18471846 if(enc->coded_frame && enc->coded_frame->key_frame)
@@ -1933,7 +1932,7 @@ static void parse_forced_key_frames(char *kf, OutputStream *ost, · 85 unmodified lines
19331932 ost->forced_kf_pts = av_malloc(sizeof(*ost->forced_kf_pts) * n);
19341933 if (!ost->forced_kf_pts) {
19351934 av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\n");
1936− ffmpeg_exit(1);
1935+ exit_program(1);
19371936 }
19381937 for (i = 0; i < n; i++) {
19391938 p = i ? strchr(p, ',') + 1 : kf;
@@ -2024,7 +2023,7 @@ static int transcode(AVFormatContext **output_files, · 84 unmodified lines
20242023 fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n",
20252024 stream_maps[n].file_index, stream_maps[n].stream_index,
20262025 ost->file_index, ost->index);
2027− ffmpeg_exit(1);
2026+ exit_program(1);
20282027 }
20292028
20302029 } else {
@@ -2074,7 +2073,7 @@ static int transcode(AVFormatContext **output_files, · 43 unmodified lines
20742073 av_dump_format(output_files[i], i, output_files[i]->filename, 1);
20752074 fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n",
20762075 ost->file_index, ost->index);
2077− ffmpeg_exit(1);
2076+ exit_program(1);
20782077 }
20792078 }
20802079 }
@@ -2139,7 +2138,7 @@ static int transcode(AVFormatContext **output_files, · 58 unmodified lines
21392138 case AVMEDIA_TYPE_AUDIO:
21402139 if(audio_volume != 256) {
21412140 fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n");
2142− ffmpeg_exit(1);
2141+ exit_program(1);
21432142 }
21442143 codec->channel_layout = icodec->channel_layout;
21452144 codec->sample_rate = icodec->sample_rate;
@@ -2213,7 +2212,7 @@ static int transcode(AVFormatContext **output_files, · 67 unmodified lines
22132212
22142213 if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
22152214 fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n");
2216− ffmpeg_exit(1);
2215+ exit_program(1);
22172216 }
22182217
22192218 if (!codec->width || !codec->height) {
@@ -2230,7 +2229,7 @@ static int transcode(AVFormatContext **output_files, · 10 unmodified lines
22302229 if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
22312230 codec->width, codec->height)) {
22322231 fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n");
2233− ffmpeg_exit(1);
2232+ exit_program(1);
22342233 }
22352234 ost->img_resample_ctx = sws_getContext(
22362235 icodec->width,
@@ -2242,7 +2241,7 @@ static int transcode(AVFormatContext **output_files, · 5 unmodified lines
22422241 ost->sws_flags, NULL, NULL, NULL);
22432242 if (ost->img_resample_ctx == NULL) {
22442243 fprintf(stderr, "Cannot get resampling context\n");
2245− ffmpeg_exit(1);
2244+ exit_program(1);
22462245 }
22472246 #endif
22482247 codec->bits_per_raw_sample= 0;
@@ -2290,7 +2289,7 @@ static int transcode(AVFormatContext **output_files, · 41 unmodified lines
22902289 f = fopen(logfilename, "wb");
22912290 if (!f) {
22922291 fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno));
2293− ffmpeg_exit(1);
2292+ exit_program(1);
22942293 }
22952294 ost->logfile = f;
22962295 } else {
@@ -2298,7 +2297,7 @@ static int transcode(AVFormatContext **output_files, · 1 unmodified line
22982297 size_t logbuffer_size;
22992298 if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
23002299 fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename);
2301− ffmpeg_exit(1);
2300+ exit_program(1);
23022301 }
23032302 codec->stats_in = logbuffer;
23042303 }
@@ -2670,7 +2669,7 @@ static int transcode(AVFormatContext **output_files, · 365 unmodified lines
26702669 fprintf(stderr, "Error while decoding stream #%d.%d\n",
26712670 ist->file_index, ist->st->index);
26722671 if (exit_on_error)
2673− ffmpeg_exit(1);
2672+ exit_program(1);
26742673 av_free_packet(&pkt);
26752674 goto redo;
26762675 }
@@ -2785,7 +2784,7 @@ static int opt_frame_rate(const char *opt, const char *arg) · 108 unmodified lines
27852784 {
27862785 if (av_parse_video_rate(&frame_rate, arg) < 0) {
27872786 fprintf(stderr, "Incorrect value for %s: %s\n", opt, arg);
2788− ffmpeg_exit(1);
2787+ exit_program(1);
27892788 }
27902789 return 0;
27912790 }
@@ -2820,7 +2819,7 @@ static int opt_frame_pix_fmt(const char *opt, const char *arg) · 28 unmodified lines
28202819 }
28212820 } else {
28222821 show_pix_fmts();
2823− ffmpeg_exit(0);
2822+ exit_program(0);
28242823 }
28252824 return 0;
28262825 }
@@ -2856,7 +2855,7 @@ static int opt_metadata(const char *opt, const char *arg) · 29 unmodified lines
28562855
28572856 if(!mid){
28582857 fprintf(stderr, "Missing =\n");
2859− ffmpeg_exit(1);
2858+ exit_program(1);
28602859 }
28612860 *mid++= 0;
28622861
@@ -2904,7 +2903,7 @@ static int opt_audio_sample_fmt(const char *opt, const char *arg) · 41 unmodified lines
29042903 char fmt_str[128];
29052904 for (i = -1; i < AV_SAMPLE_FMT_NB; i++)
29062905 printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i));
2907− ffmpeg_exit(0);
2906+ exit_program(0);
29082907 }
29092908 return 0;
29102909 }
@@ -3026,7 +3025,7 @@ static void parse_meta_type(char *arg, char *type, int *index, char **endptr) · 115 unmodified lines
30263025 break;
30273026 default:
30283027 fprintf(stderr, "Invalid metadata type %c.\n", *arg);
3029− ffmpeg_exit(1);
3028+ exit_program(1);
30303029 }
30313030 } else
30323031 *type = 'g';
@@ -3142,11 +3141,11 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder) · 109 unmodified lines
31423141 avcodec_find_decoder_by_name(name);
31433142 if(!codec) {
31443143 fprintf(stderr, "Unknown %s '%s'\n", codec_string, name);
3145− ffmpeg_exit(1);
3144+ exit_program(1);
31463145 }
31473146 if(codec->type != type) {
31483147 fprintf(stderr, "Invalid %s type '%s'\n", codec_string, name);
3149− ffmpeg_exit(1);
3148+ exit_program(1);
31503149 }
31513150 return codec->id;
31523151 }
@@ -3164,7 +3163,7 @@ static int opt_input_file(const char *opt, const char *filename) · 11 unmodified lines
31643163 if (last_asked_format) {
31653164 if (!(file_iformat = av_find_input_format(last_asked_format))) {
31663165 fprintf(stderr, "Unknown input format: '%s'\n", last_asked_format);
3167− ffmpeg_exit(1);
3166+ exit_program(1);
31683167 }
31693168 last_asked_format = NULL;
31703169 }
@@ -3179,7 +3178,7 @@ static int opt_input_file(const char *opt, const char *filename) · 8 unmodified lines
31793178 ic = avformat_alloc_context();
31803179 if (!ic) {
31813180 print_error(filename, AVERROR(ENOMEM));
3182− ffmpeg_exit(1);
3181+ exit_program(1);
31833182 }
31843183 if (audio_sample_rate) {
31853184 snprintf(buf, sizeof(buf), "%d", audio_sample_rate);
@@ -3212,7 +3211,7 @@ static int opt_input_file(const char *opt, const char *filename) · 26 unmodified lines
32123211 err = avformat_open_input(&ic, filename, file_iformat, &format_opts);
32133212 if (err < 0) {
32143213 print_error(filename, err);
3215− ffmpeg_exit(1);
3214+ exit_program(1);
32163215 }
32173216 assert_avoptions(format_opts);
32183217
@@ -3235,7 +3234,7 @@ static int opt_input_file(const char *opt, const char *filename) · 16 unmodified lines
32353234 }
32363235 if(!found){
32373236 fprintf(stderr, "Specified program id not found\n");
3238− ffmpeg_exit(1);
3237+ exit_program(1);
32393238 }
32403239 opt_programid=0;
32413240 }
@@ -3255,7 +3254,7 @@ static int opt_input_file(const char *opt, const char *filename) · 13 unmodified lines
32553254 if (ret < 0 && verbose >= 0) {
32563255 fprintf(stderr, "%s: could not find codec parameters\n", filename);
32573256 av_close_input_file(ic);
3258− ffmpeg_exit(1);
3257+ exit_program(1);
32593258 }
32603259
32613260 timestamp = start_time;
@@ -3491,7 +3490,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) · 229 unmodified lines
34913490 int e=sscanf(p, "%d,%d,%d", &start, &end, &q);
34923491 if(e!=3){
34933492 fprintf(stderr, "error parsing rc_override\n");
3494− ffmpeg_exit(1);
3493+ exit_program(1);
34953494 }
34963495 video_enc->rc_override=
34973496 av_realloc(video_enc->rc_override,
@@ -3615,7 +3614,7 @@ static void new_data_stream(AVFormatContext *oc, int file_idx) · 117 unmodified lines
36153614 data_enc = st->codec;
36163615 if (!data_stream_copy) {
36173616 fprintf(stderr, "Data stream encoding not supported yet (only streamcopy)\n");
3618− ffmpeg_exit(1);
3617+ exit_program(1);
36193618 }
36203619
36213620 data_enc->codec_type = AVMEDIA_TYPE_DATA;
@@ -3689,7 +3688,7 @@ static int opt_new_stream(const char *opt, const char *arg) · 67 unmodified lines
36893688 int file_idx = nb_output_files - 1;
36903689 if (nb_output_files <= 0) {
36913690 fprintf(stderr, "At least one output file must be specified\n");
3692− ffmpeg_exit(1);
3691+ exit_program(1);
36933692 }
36943693 oc = output_files[file_idx];
36953694
@@ -3714,7 +3713,7 @@ static int opt_streamid(const char *opt, const char *arg) · 18 unmodified lines
37143713 fprintf(stderr,
37153714 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
37163715 arg, opt);
3717− ffmpeg_exit(1);
3716+ exit_program(1);
37183717 }
37193718 *p++ = '\0';
37203719 idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, INT_MAX);
@@ -3736,14 +3735,14 @@ static void opt_output_file(const char *filename) · 15 unmodified lines
37363735 oc = avformat_alloc_context();
37373736 if (!oc) {
37383737 print_error(filename, AVERROR(ENOMEM));
3739− ffmpeg_exit(1);
3738+ exit_program(1);
37403739 }
37413740
37423741 if (last_asked_format) {
37433742 file_oformat = av_guess_format(last_asked_format, NULL, NULL);
37443743 if (!file_oformat) {
37453744 fprintf(stderr, "Requested output format '%s' is not a suitable output format\n", last_asked_format);
3746− ffmpeg_exit(1);
3745+ exit_program(1);
37473746 }
37483747 last_asked_format = NULL;
37493748 } else {
@@ -3751,7 +3750,7 @@ static void opt_output_file(const char *filename) · 1 unmodified line
37513750 if (!file_oformat) {
37523751 fprintf(stderr, "Unable to find a suitable output format for '%s'\n",
37533752 filename);
3754− ffmpeg_exit(1);
3753+ exit_program(1);
37553754 }
37563755 }
37573756
@@ -3765,7 +3764,7 @@ static void opt_output_file(const char *filename) · 7 unmodified lines
37653764 int err = read_avserver_streams(oc, filename);
37663765 if (err < 0) {
37673766 print_error(filename, err);
3768− ffmpeg_exit(1);
3767+ exit_program(1);
37693768 }
37703769 } else {
37713770 use_video = file_oformat->video_codec != CODEC_ID_NONE || video_stream_copy || video_codec_name;
@@ -3810,7 +3809,7 @@ static void opt_output_file(const char *filename) · 38 unmodified lines
38103809 if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
38113810 if (!av_filename_number_test(oc->filename)) {
38123811 print_error(oc->filename, AVERROR(EINVAL));
3813− ffmpeg_exit(1);
3812+ exit_program(1);
38143813 }
38153814 }
38163815
@@ -3826,12 +3825,12 @@ static void opt_output_file(const char *filename) · 9 unmodified lines
38263825 fflush(stderr);
38273826 if (!read_yesno()) {
38283827 fprintf(stderr, "Not overwriting - exiting\n");
3829− ffmpeg_exit(1);
3828+ exit_program(1);
38303829 }
38313830 }
38323831 else {
38333832 fprintf(stderr,"File '%s' already exists. Exiting.\n", filename);
3834− ffmpeg_exit(1);
3833+ exit_program(1);
38353834 }
38363835 }
38373836 }
@@ -3839,7 +3838,7 @@ static void opt_output_file(const char *filename) · 1 unmodified line
38393838 /* open the file */
38403839 if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {
38413840 print_error(filename, err);
3842− ffmpeg_exit(1);
3841+ exit_program(1);
38433842 }
38443843 }
38453844
@@ -3917,7 +3916,7 @@ static void parse_matrix_coeffs(uint16_t *dest, const char *str) · 71 unmodified lines
39173916 p = strchr(p, ',');
39183917 if(!p) {
39193918 fprintf(stderr, "Syntax error in matrix \"%s\" at coeff %d\n", str, i);
3920− ffmpeg_exit(1);
3919+ exit_program(1);
39213920 }
39223921 p++;
39233922 }
@@ -4065,7 +4064,7 @@ static int opt_target(const char *opt, const char *arg) · 141 unmodified lines
40654064 fprintf(stderr, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
40664065 fprintf(stderr, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
40674066 fprintf(stderr, "or set a framerate with \"-r xxx\".\n");
4068− ffmpeg_exit(1);
4067+ exit_program(1);
40694068 }
40704069
40714070 if(!strcmp(arg, "vcd")) {
@@ -4182,7 +4181,7 @@ static int opt_bsf(const char *opt, const char *arg) · 110 unmodified lines
41824181
41834182 if(!bsfc){
41844183 fprintf(stderr, "Unknown bitstream filter %s\n", arg);
4185− ffmpeg_exit(1);
4184+ exit_program(1);
41864185 }
41874186
41884187 bsfp= *opt == 'v' ? &video_bitstream_filters :
@@ -4206,7 +4205,7 @@ static int opt_preset(const char *opt, const char *arg) · 17 unmodified lines
42064205
42074206 if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) {
42084207 fprintf(stderr, "File for preset '%s' not found\n", arg);
4209− ffmpeg_exit(1);
4208+ exit_program(1);
42104209 }
42114210
42124211 while(!feof(f)){
@@ -4216,7 +4215,7 @@ static int opt_preset(const char *opt, const char *arg) · 3 unmodified lines
42164215 e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2;
42174216 if(e){
42184217 fprintf(stderr, "%s: Invalid syntax: '%s'\n", filename, line);
4219− ffmpeg_exit(1);
4218+ exit_program(1);
42204219 }
42214220 if(!strcmp(tmp, "acodec")){
42224221 opt_audio_codec(tmp, tmp2);
@@ -4228,7 +4227,7 @@ static int opt_preset(const char *opt, const char *arg) · 5 unmodified lines
42284227 opt_data_codec(tmp, tmp2);
42294228 }else if(opt_default(tmp, tmp2) < 0){
42304229 fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2);
4231− ffmpeg_exit(1);
4230+ exit_program(1);
42324231 }
42334232 }
42344233
@@ -4402,29 +4401,30 @@ int main(int argc, char **argv) · 167 unmodified lines
44024401 if(nb_output_files <= 0 && nb_input_files == 0) {
44034402 show_usage();
44044403 fprintf(stderr, "Use -h to get full help or, even better, run 'man ffmpeg'\n");
4405− ffmpeg_exit(1);
4404+ exit_program(1);
44064405 }
44074406
44084407 /* file converter / grab */
44094408 if (nb_output_files <= 0) {
44104409 fprintf(stderr, "At least one output file must be specified\n");
4411− ffmpeg_exit(1);
4410+ exit_program(1);
44124411 }
44134412
44144413 if (nb_input_files == 0) {
44154414 fprintf(stderr, "At least one input file must be specified\n");
4416− ffmpeg_exit(1);
4415+ exit_program(1);
44174416 }
44184417
44194418 ti = getutime();
44204419 if (transcode(output_files, nb_output_files, input_files, nb_input_files,
44214420 stream_maps, nb_stream_maps) < 0)
4422− ffmpeg_exit(1);
4421+ exit_program(1);
44234422 ti = getutime() - ti;
44244423 if (do_benchmark) {
44254424 int maxrss = getmaxrss() / 1024;
44264425 printf("bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss);
44274426 }
44284427
4429− return ffmpeg_exit(0);
4428+ exit_program(0);
4429+ return 0;
44304430 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t