Allows cmdutils to call each tool's own cleanup function.
| ... | ... |
@@ -433,7 +433,7 @@ static int decode_interrupt_cb(void) |
| 433 | 433 |
return received_nb_signals > 1; |
| 434 | 434 |
} |
| 435 | 435 |
|
| 436 |
-static int exit_program(int ret) |
|
| 436 |
+void exit_program(int ret) |
|
| 437 | 437 |
{
|
| 438 | 438 |
int i; |
| 439 | 439 |
|
| ... | ... |
@@ -483,7 +483,6 @@ static int exit_program(int ret) |
| 483 | 483 |
} |
| 484 | 484 |
|
| 485 | 485 |
exit(ret); /* not all OS-es handle main() return value */ |
| 486 |
- return ret; |
|
| 487 | 486 |
} |
| 488 | 487 |
|
| 489 | 488 |
static void assert_avoptions(AVDictionary *m) |
| ... | ... |
@@ -4192,5 +4191,6 @@ int main(int argc, char **argv) |
| 4192 | 4192 |
printf("bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss);
|
| 4193 | 4193 |
} |
| 4194 | 4194 |
|
| 4195 |
- return exit_program(0); |
|
| 4195 |
+ exit_program(0); |
|
| 4196 |
+ return 0; |
|
| 4196 | 4197 |
} |
| ... | ... |
@@ -56,6 +56,11 @@ static const char *unit_hertz_str = "Hz" ; |
| 56 | 56 |
static const char *unit_byte_str = "byte" ; |
| 57 | 57 |
static const char *unit_bit_per_second_str = "bit/s"; |
| 58 | 58 |
|
| 59 |
+void exit_program(int ret) |
|
| 60 |
+{
|
|
| 61 |
+ exit(ret); |
|
| 62 |
+} |
|
| 63 |
+ |
|
| 59 | 64 |
static char *value_string(char *buf, int buf_size, double val, const char *unit) |
| 60 | 65 |
{
|
| 61 | 66 |
if (unit == unit_second_str && use_value_sexagesimal_format) {
|
| ... | ... |
@@ -320,6 +320,11 @@ static AVLFG random_state; |
| 320 | 320 |
|
| 321 | 321 |
static FILE *logfile = NULL; |
| 322 | 322 |
|
| 323 |
+void exit_program(int ret) |
|
| 324 |
+{
|
|
| 325 |
+ exit(ret); |
|
| 326 |
+} |
|
| 327 |
+ |
|
| 323 | 328 |
/* FIXME: make avserver work with IPv6 */ |
| 324 | 329 |
/* resolve host with also IP address parsing */ |
| 325 | 330 |
static int resolve_host(struct in_addr *sin_addr, const char *hostname) |
| ... | ... |
@@ -92,7 +92,8 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do |
| 92 | 92 |
else |
| 93 | 93 |
return d; |
| 94 | 94 |
fprintf(stderr, error, context, numstr, min, max); |
| 95 |
- exit(1); |
|
| 95 |
+ exit_program(1); |
|
| 96 |
+ return 0; |
|
| 96 | 97 |
} |
| 97 | 98 |
|
| 98 | 99 |
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 |
| 101 | 101 |
if (av_parse_time(&us, timestr, is_duration) < 0) {
|
| 102 | 102 |
fprintf(stderr, "Invalid %s specification for %s: %s\n", |
| 103 | 103 |
is_duration ? "duration" : "date", context, timestr); |
| 104 |
- exit(1); |
|
| 104 |
+ exit_program(1); |
|
| 105 | 105 |
} |
| 106 | 106 |
return us; |
| 107 | 107 |
} |
| ... | ... |
@@ -237,14 +238,14 @@ void parse_options(int argc, char **argv, const OptionDef *options, |
| 237 | 237 |
if (!po->name) {
|
| 238 | 238 |
unknown_opt: |
| 239 | 239 |
fprintf(stderr, "%s: unrecognized option '%s'\n", argv[0], opt); |
| 240 |
- exit(1); |
|
| 240 |
+ exit_program(1); |
|
| 241 | 241 |
} |
| 242 | 242 |
arg = NULL; |
| 243 | 243 |
if (po->flags & HAS_ARG) {
|
| 244 | 244 |
arg = argv[optindex++]; |
| 245 | 245 |
if (!arg) {
|
| 246 | 246 |
fprintf(stderr, "%s: missing argument for option '%s'\n", argv[0], opt); |
| 247 |
- exit(1); |
|
| 247 |
+ exit_program(1); |
|
| 248 | 248 |
} |
| 249 | 249 |
} |
| 250 | 250 |
if (po->flags & OPT_STRING) {
|
| ... | ... |
@@ -262,11 +263,11 @@ unknown_opt: |
| 262 | 262 |
} else if (po->u.func_arg) {
|
| 263 | 263 |
if (po->u.func_arg(opt, arg) < 0) {
|
| 264 | 264 |
fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt); |
| 265 |
- exit(1); |
|
| 265 |
+ exit_program(1); |
|
| 266 | 266 |
} |
| 267 | 267 |
} |
| 268 | 268 |
if(po->flags & OPT_EXIT) |
| 269 |
- exit(0); |
|
| 269 |
+ exit_program(0); |
|
| 270 | 270 |
} else {
|
| 271 | 271 |
if (parse_arg_function) |
| 272 | 272 |
parse_arg_function(opt); |
| ... | ... |
@@ -336,7 +337,7 @@ int opt_loglevel(const char *opt, const char *arg) |
| 336 | 336 |
"Possible levels are numbers or:\n", arg); |
| 337 | 337 |
for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) |
| 338 | 338 |
fprintf(stderr, "\"%s\"\n", log_levels[i].name); |
| 339 |
- exit(1); |
|
| 339 |
+ exit_program(1); |
|
| 340 | 340 |
} |
| 341 | 341 |
av_log_set_level(level); |
| 342 | 342 |
return 0; |
| ... | ... |
@@ -327,4 +327,10 @@ extern AVFilter ffsink; |
| 327 | 327 |
int get_filtered_video_frame(AVFilterContext *sink, AVFrame *frame, |
| 328 | 328 |
AVFilterBufferRef **picref, AVRational *pts_tb); |
| 329 | 329 |
|
| 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 |
+ |
|
| 330 | 336 |
#endif /* LIBAV_CMDUTILS_H */ |
| ... | ... |
@@ -445,7 +445,7 @@ static int decode_interrupt_cb(void) |
| 445 | 445 |
return received_nb_signals > 1; |
| 446 | 446 |
} |
| 447 | 447 |
|
| 448 |
-static int ffmpeg_exit(int ret) |
|
| 448 |
+void exit_program(int ret) |
|
| 449 | 449 |
{
|
| 450 | 450 |
int i; |
| 451 | 451 |
|
| ... | ... |
@@ -501,7 +501,6 @@ static int ffmpeg_exit(int ret) |
| 501 | 501 |
} |
| 502 | 502 |
|
| 503 | 503 |
exit(ret); /* not all OS-es handle main() return value */ |
| 504 |
- return ret; |
|
| 505 | 504 |
} |
| 506 | 505 |
|
| 507 | 506 |
static void assert_avoptions(AVDictionary *m) |
| ... | ... |
@@ -509,7 +508,7 @@ static void assert_avoptions(AVDictionary *m) |
| 509 | 509 |
AVDictionaryEntry *t; |
| 510 | 510 |
if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
|
| 511 | 511 |
av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); |
| 512 |
- ffmpeg_exit(1); |
|
| 512 |
+ exit_program(1); |
|
| 513 | 513 |
} |
| 514 | 514 |
} |
| 515 | 515 |
|
| ... | ... |
@@ -526,7 +525,7 @@ static void assert_codec_experimental(AVCodecContext *c, int encoder) |
| 526 | 526 |
if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL)) |
| 527 | 527 |
av_log(NULL, AV_LOG_ERROR, "Or use the non experimental %s '%s'.\n", |
| 528 | 528 |
codec_string, codec->name); |
| 529 |
- ffmpeg_exit(1); |
|
| 529 |
+ exit_program(1); |
|
| 530 | 530 |
} |
| 531 | 531 |
} |
| 532 | 532 |
|
| ... | ... |
@@ -535,13 +534,13 @@ static void *grow_array(void *array, int elem_size, int *size, int new_size) |
| 535 | 535 |
{
|
| 536 | 536 |
if (new_size >= INT_MAX / elem_size) {
|
| 537 | 537 |
fprintf(stderr, "Array too big.\n"); |
| 538 |
- ffmpeg_exit(1); |
|
| 538 |
+ exit_program(1); |
|
| 539 | 539 |
} |
| 540 | 540 |
if (*size < new_size) {
|
| 541 | 541 |
uint8_t *tmp = av_realloc(array, new_size*elem_size); |
| 542 | 542 |
if (!tmp) {
|
| 543 | 543 |
fprintf(stderr, "Could not alloc buffer.\n"); |
| 544 |
- ffmpeg_exit(1); |
|
| 544 |
+ exit_program(1); |
|
| 545 | 545 |
} |
| 546 | 546 |
memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size); |
| 547 | 547 |
*size = new_size; |
| ... | ... |
@@ -664,7 +663,7 @@ static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx, AVCode |
| 664 | 664 |
|
| 665 | 665 |
if (!st) {
|
| 666 | 666 |
av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n"); |
| 667 |
- ffmpeg_exit(1); |
|
| 667 |
+ exit_program(1); |
|
| 668 | 668 |
} |
| 669 | 669 |
|
| 670 | 670 |
output_streams_for_file[file_idx] = |
| ... | ... |
@@ -676,7 +675,7 @@ static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx, AVCode |
| 676 | 676 |
av_mallocz(sizeof(OutputStream)); |
| 677 | 677 |
if (!ost) {
|
| 678 | 678 |
fprintf(stderr, "Could not alloc output stream\n"); |
| 679 |
- ffmpeg_exit(1); |
|
| 679 |
+ exit_program(1); |
|
| 680 | 680 |
} |
| 681 | 681 |
ost->file_index = file_idx; |
| 682 | 682 |
ost->index = idx; |
| ... | ... |
@@ -756,7 +755,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx |
| 756 | 756 |
avctx->codec ? avctx->codec->name : "copy"); |
| 757 | 757 |
print_error("", a);
|
| 758 | 758 |
if (exit_on_error) |
| 759 |
- ffmpeg_exit(1); |
|
| 759 |
+ exit_program(1); |
|
| 760 | 760 |
} |
| 761 | 761 |
*pkt= new_pkt; |
| 762 | 762 |
|
| ... | ... |
@@ -766,7 +765,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx |
| 766 | 766 |
ret= av_interleaved_write_frame(s, pkt); |
| 767 | 767 |
if(ret < 0){
|
| 768 | 768 |
print_error("av_interleaved_write_frame()", ret);
|
| 769 |
- ffmpeg_exit(1); |
|
| 769 |
+ exit_program(1); |
|
| 770 | 770 |
} |
| 771 | 771 |
} |
| 772 | 772 |
|
| ... | ... |
@@ -802,14 +801,14 @@ need_realloc: |
| 802 | 802 |
|
| 803 | 803 |
if(audio_out_size > INT_MAX || audio_buf_size > INT_MAX){
|
| 804 | 804 |
fprintf(stderr, "Buffer sizes too large\n"); |
| 805 |
- ffmpeg_exit(1); |
|
| 805 |
+ exit_program(1); |
|
| 806 | 806 |
} |
| 807 | 807 |
|
| 808 | 808 |
av_fast_malloc(&audio_buf, &allocated_audio_buf_size, audio_buf_size); |
| 809 | 809 |
av_fast_malloc(&audio_out, &allocated_audio_out_size, audio_out_size); |
| 810 | 810 |
if (!audio_buf || !audio_out){
|
| 811 | 811 |
fprintf(stderr, "Out of memory in do_audio_out\n"); |
| 812 |
- ffmpeg_exit(1); |
|
| 812 |
+ exit_program(1); |
|
| 813 | 813 |
} |
| 814 | 814 |
|
| 815 | 815 |
if (enc->channels != dec->channels || enc->sample_rate != dec->sample_rate) |
| ... | ... |
@@ -849,7 +848,7 @@ need_realloc: |
| 849 | 849 |
fprintf(stderr, "Can not resample %d channels @ %d Hz to %d channels @ %d Hz\n", |
| 850 | 850 |
dec->channels, dec->sample_rate, |
| 851 | 851 |
enc->channels, enc->sample_rate); |
| 852 |
- ffmpeg_exit(1); |
|
| 852 |
+ exit_program(1); |
|
| 853 | 853 |
} |
| 854 | 854 |
} |
| 855 | 855 |
} |
| ... | ... |
@@ -865,7 +864,7 @@ need_realloc: |
| 865 | 865 |
fprintf(stderr, "Cannot convert %s sample format to %s sample format\n", |
| 866 | 866 |
av_get_sample_fmt_name(dec->sample_fmt), |
| 867 | 867 |
av_get_sample_fmt_name(enc->sample_fmt)); |
| 868 |
- ffmpeg_exit(1); |
|
| 868 |
+ exit_program(1); |
|
| 869 | 869 |
} |
| 870 | 870 |
ost->reformat_pair=MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt); |
| 871 | 871 |
} |
| ... | ... |
@@ -938,7 +937,7 @@ need_realloc: |
| 938 | 938 |
if (av_audio_convert(ost->reformat_ctx, obuf, ostride, ibuf, istride, len)<0) {
|
| 939 | 939 |
printf("av_audio_convert() failed\n");
|
| 940 | 940 |
if (exit_on_error) |
| 941 |
- ffmpeg_exit(1); |
|
| 941 |
+ exit_program(1); |
|
| 942 | 942 |
return; |
| 943 | 943 |
} |
| 944 | 944 |
buftmp = audio_buf; |
| ... | ... |
@@ -950,7 +949,7 @@ need_realloc: |
| 950 | 950 |
/* output resampled raw samples */ |
| 951 | 951 |
if (av_fifo_realloc2(ost->fifo, av_fifo_size(ost->fifo) + size_out) < 0) {
|
| 952 | 952 |
fprintf(stderr, "av_fifo_realloc2() failed\n"); |
| 953 |
- ffmpeg_exit(1); |
|
| 953 |
+ exit_program(1); |
|
| 954 | 954 |
} |
| 955 | 955 |
av_fifo_generic_write(ost->fifo, buftmp, size_out, NULL); |
| 956 | 956 |
|
| ... | ... |
@@ -968,7 +967,7 @@ need_realloc: |
| 968 | 968 |
(short *)audio_buf); |
| 969 | 969 |
if (ret < 0) {
|
| 970 | 970 |
fprintf(stderr, "Audio encoding failed\n"); |
| 971 |
- ffmpeg_exit(1); |
|
| 971 |
+ exit_program(1); |
|
| 972 | 972 |
} |
| 973 | 973 |
audio_size += ret; |
| 974 | 974 |
pkt.stream_index= ost->index; |
| ... | ... |
@@ -995,7 +994,7 @@ need_realloc: |
| 995 | 995 |
|
| 996 | 996 |
if(size_out > audio_out_size){
|
| 997 | 997 |
fprintf(stderr, "Internal error, buffer size too small\n"); |
| 998 |
- ffmpeg_exit(1); |
|
| 998 |
+ exit_program(1); |
|
| 999 | 999 |
} |
| 1000 | 1000 |
|
| 1001 | 1001 |
//FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio() |
| ... | ... |
@@ -1003,7 +1002,7 @@ need_realloc: |
| 1003 | 1003 |
(short *)buftmp); |
| 1004 | 1004 |
if (ret < 0) {
|
| 1005 | 1005 |
fprintf(stderr, "Audio encoding failed\n"); |
| 1006 |
- ffmpeg_exit(1); |
|
| 1006 |
+ exit_program(1); |
|
| 1007 | 1007 |
} |
| 1008 | 1008 |
audio_size += ret; |
| 1009 | 1009 |
pkt.stream_index= ost->index; |
| ... | ... |
@@ -1073,7 +1072,7 @@ static void do_subtitle_out(AVFormatContext *s, |
| 1073 | 1073 |
if (pts == AV_NOPTS_VALUE) {
|
| 1074 | 1074 |
fprintf(stderr, "Subtitle packets must have a pts\n"); |
| 1075 | 1075 |
if (exit_on_error) |
| 1076 |
- ffmpeg_exit(1); |
|
| 1076 |
+ exit_program(1); |
|
| 1077 | 1077 |
return; |
| 1078 | 1078 |
} |
| 1079 | 1079 |
|
| ... | ... |
@@ -1101,7 +1100,7 @@ static void do_subtitle_out(AVFormatContext *s, |
| 1101 | 1101 |
subtitle_out_max_size, sub); |
| 1102 | 1102 |
if (subtitle_out_size < 0) {
|
| 1103 | 1103 |
fprintf(stderr, "Subtitle encoding failed\n"); |
| 1104 |
- ffmpeg_exit(1); |
|
| 1104 |
+ exit_program(1); |
|
| 1105 | 1105 |
} |
| 1106 | 1106 |
|
| 1107 | 1107 |
av_init_packet(&pkt); |
| ... | ... |
@@ -1188,7 +1187,7 @@ static void do_video_out(AVFormatContext *s, |
| 1188 | 1188 |
ost->resample_width, ost->resample_height, av_get_pix_fmt_name(ost->resample_pix_fmt), |
| 1189 | 1189 |
dec->width , dec->height , av_get_pix_fmt_name(dec->pix_fmt)); |
| 1190 | 1190 |
if(!ost->video_resample) |
| 1191 |
- ffmpeg_exit(1); |
|
| 1191 |
+ exit_program(1); |
|
| 1192 | 1192 |
} |
| 1193 | 1193 |
|
| 1194 | 1194 |
#if !CONFIG_AVFILTER |
| ... | ... |
@@ -1207,7 +1206,7 @@ static void do_video_out(AVFormatContext *s, |
| 1207 | 1207 |
ost->sws_flags, NULL, NULL, NULL); |
| 1208 | 1208 |
if (ost->img_resample_ctx == NULL) {
|
| 1209 | 1209 |
fprintf(stderr, "Cannot get resampling context\n"); |
| 1210 |
- ffmpeg_exit(1); |
|
| 1210 |
+ exit_program(1); |
|
| 1211 | 1211 |
} |
| 1212 | 1212 |
} |
| 1213 | 1213 |
sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize, |
| ... | ... |
@@ -1267,7 +1266,7 @@ static void do_video_out(AVFormatContext *s, |
| 1267 | 1267 |
&big_picture); |
| 1268 | 1268 |
if (ret < 0) {
|
| 1269 | 1269 |
fprintf(stderr, "Video encoding failed\n"); |
| 1270 |
- ffmpeg_exit(1); |
|
| 1270 |
+ exit_program(1); |
|
| 1271 | 1271 |
} |
| 1272 | 1272 |
|
| 1273 | 1273 |
if(ret>0){
|
| ... | ... |
@@ -1313,7 +1312,7 @@ static void do_video_stats(AVFormatContext *os, OutputStream *ost, |
| 1313 | 1313 |
vstats_file = fopen(vstats_filename, "w"); |
| 1314 | 1314 |
if (!vstats_file) {
|
| 1315 | 1315 |
perror("fopen");
|
| 1316 |
- ffmpeg_exit(1); |
|
| 1316 |
+ exit_program(1); |
|
| 1317 | 1317 |
} |
| 1318 | 1318 |
} |
| 1319 | 1319 |
|
| ... | ... |
@@ -1818,7 +1817,7 @@ static int output_packet(InputStream *ist, int ist_index, |
| 1818 | 1818 |
} else { /* pad */
|
| 1819 | 1819 |
int frame_bytes = enc->frame_size*osize*enc->channels; |
| 1820 | 1820 |
if (allocated_audio_buf_size < frame_bytes) |
| 1821 |
- ffmpeg_exit(1); |
|
| 1821 |
+ exit_program(1); |
|
| 1822 | 1822 |
generate_silence(audio_buf+fifo_bytes, enc->sample_fmt, frame_bytes - fifo_bytes); |
| 1823 | 1823 |
} |
| 1824 | 1824 |
|
| ... | ... |
@@ -1832,7 +1831,7 @@ static int output_packet(InputStream *ist, int ist_index, |
| 1832 | 1832 |
} |
| 1833 | 1833 |
if (ret < 0) {
|
| 1834 | 1834 |
fprintf(stderr, "Audio encoding failed\n"); |
| 1835 |
- ffmpeg_exit(1); |
|
| 1835 |
+ exit_program(1); |
|
| 1836 | 1836 |
} |
| 1837 | 1837 |
audio_size += ret; |
| 1838 | 1838 |
pkt.flags |= AV_PKT_FLAG_KEY; |
| ... | ... |
@@ -1841,7 +1840,7 @@ static int output_packet(InputStream *ist, int ist_index, |
| 1841 | 1841 |
ret = avcodec_encode_video(enc, bit_buffer, bit_buffer_size, NULL); |
| 1842 | 1842 |
if (ret < 0) {
|
| 1843 | 1843 |
fprintf(stderr, "Video encoding failed\n"); |
| 1844 |
- ffmpeg_exit(1); |
|
| 1844 |
+ exit_program(1); |
|
| 1845 | 1845 |
} |
| 1846 | 1846 |
video_size += ret; |
| 1847 | 1847 |
if(enc->coded_frame && enc->coded_frame->key_frame) |
| ... | ... |
@@ -1933,7 +1932,7 @@ static void parse_forced_key_frames(char *kf, OutputStream *ost, |
| 1933 | 1933 |
ost->forced_kf_pts = av_malloc(sizeof(*ost->forced_kf_pts) * n); |
| 1934 | 1934 |
if (!ost->forced_kf_pts) {
|
| 1935 | 1935 |
av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\n"); |
| 1936 |
- ffmpeg_exit(1); |
|
| 1936 |
+ exit_program(1); |
|
| 1937 | 1937 |
} |
| 1938 | 1938 |
for (i = 0; i < n; i++) {
|
| 1939 | 1939 |
p = i ? strchr(p, ',') + 1 : kf; |
| ... | ... |
@@ -2024,7 +2023,7 @@ static int transcode(AVFormatContext **output_files, |
| 2024 | 2024 |
fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n", |
| 2025 | 2025 |
stream_maps[n].file_index, stream_maps[n].stream_index, |
| 2026 | 2026 |
ost->file_index, ost->index); |
| 2027 |
- ffmpeg_exit(1); |
|
| 2027 |
+ exit_program(1); |
|
| 2028 | 2028 |
} |
| 2029 | 2029 |
|
| 2030 | 2030 |
} else {
|
| ... | ... |
@@ -2074,7 +2073,7 @@ static int transcode(AVFormatContext **output_files, |
| 2074 | 2074 |
av_dump_format(output_files[i], i, output_files[i]->filename, 1); |
| 2075 | 2075 |
fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n", |
| 2076 | 2076 |
ost->file_index, ost->index); |
| 2077 |
- ffmpeg_exit(1); |
|
| 2077 |
+ exit_program(1); |
|
| 2078 | 2078 |
} |
| 2079 | 2079 |
} |
| 2080 | 2080 |
} |
| ... | ... |
@@ -2139,7 +2138,7 @@ static int transcode(AVFormatContext **output_files, |
| 2139 | 2139 |
case AVMEDIA_TYPE_AUDIO: |
| 2140 | 2140 |
if(audio_volume != 256) {
|
| 2141 | 2141 |
fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n"); |
| 2142 |
- ffmpeg_exit(1); |
|
| 2142 |
+ exit_program(1); |
|
| 2143 | 2143 |
} |
| 2144 | 2144 |
codec->channel_layout = icodec->channel_layout; |
| 2145 | 2145 |
codec->sample_rate = icodec->sample_rate; |
| ... | ... |
@@ -2213,7 +2212,7 @@ static int transcode(AVFormatContext **output_files, |
| 2213 | 2213 |
|
| 2214 | 2214 |
if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
|
| 2215 | 2215 |
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n"); |
| 2216 |
- ffmpeg_exit(1); |
|
| 2216 |
+ exit_program(1); |
|
| 2217 | 2217 |
} |
| 2218 | 2218 |
|
| 2219 | 2219 |
if (!codec->width || !codec->height) {
|
| ... | ... |
@@ -2230,7 +2229,7 @@ static int transcode(AVFormatContext **output_files, |
| 2230 | 2230 |
if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt, |
| 2231 | 2231 |
codec->width, codec->height)) {
|
| 2232 | 2232 |
fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n"); |
| 2233 |
- ffmpeg_exit(1); |
|
| 2233 |
+ exit_program(1); |
|
| 2234 | 2234 |
} |
| 2235 | 2235 |
ost->img_resample_ctx = sws_getContext( |
| 2236 | 2236 |
icodec->width, |
| ... | ... |
@@ -2242,7 +2241,7 @@ static int transcode(AVFormatContext **output_files, |
| 2242 | 2242 |
ost->sws_flags, NULL, NULL, NULL); |
| 2243 | 2243 |
if (ost->img_resample_ctx == NULL) {
|
| 2244 | 2244 |
fprintf(stderr, "Cannot get resampling context\n"); |
| 2245 |
- ffmpeg_exit(1); |
|
| 2245 |
+ exit_program(1); |
|
| 2246 | 2246 |
} |
| 2247 | 2247 |
#endif |
| 2248 | 2248 |
codec->bits_per_raw_sample= 0; |
| ... | ... |
@@ -2290,7 +2289,7 @@ static int transcode(AVFormatContext **output_files, |
| 2290 | 2290 |
f = fopen(logfilename, "wb"); |
| 2291 | 2291 |
if (!f) {
|
| 2292 | 2292 |
fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); |
| 2293 |
- ffmpeg_exit(1); |
|
| 2293 |
+ exit_program(1); |
|
| 2294 | 2294 |
} |
| 2295 | 2295 |
ost->logfile = f; |
| 2296 | 2296 |
} else {
|
| ... | ... |
@@ -2298,7 +2297,7 @@ static int transcode(AVFormatContext **output_files, |
| 2298 | 2298 |
size_t logbuffer_size; |
| 2299 | 2299 |
if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
|
| 2300 | 2300 |
fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename); |
| 2301 |
- ffmpeg_exit(1); |
|
| 2301 |
+ exit_program(1); |
|
| 2302 | 2302 |
} |
| 2303 | 2303 |
codec->stats_in = logbuffer; |
| 2304 | 2304 |
} |
| ... | ... |
@@ -2670,7 +2669,7 @@ static int transcode(AVFormatContext **output_files, |
| 2670 | 2670 |
fprintf(stderr, "Error while decoding stream #%d.%d\n", |
| 2671 | 2671 |
ist->file_index, ist->st->index); |
| 2672 | 2672 |
if (exit_on_error) |
| 2673 |
- ffmpeg_exit(1); |
|
| 2673 |
+ exit_program(1); |
|
| 2674 | 2674 |
av_free_packet(&pkt); |
| 2675 | 2675 |
goto redo; |
| 2676 | 2676 |
} |
| ... | ... |
@@ -2785,7 +2784,7 @@ static int opt_frame_rate(const char *opt, const char *arg) |
| 2785 | 2785 |
{
|
| 2786 | 2786 |
if (av_parse_video_rate(&frame_rate, arg) < 0) {
|
| 2787 | 2787 |
fprintf(stderr, "Incorrect value for %s: %s\n", opt, arg); |
| 2788 |
- ffmpeg_exit(1); |
|
| 2788 |
+ exit_program(1); |
|
| 2789 | 2789 |
} |
| 2790 | 2790 |
return 0; |
| 2791 | 2791 |
} |
| ... | ... |
@@ -2820,7 +2819,7 @@ static int opt_frame_pix_fmt(const char *opt, const char *arg) |
| 2820 | 2820 |
} |
| 2821 | 2821 |
} else {
|
| 2822 | 2822 |
show_pix_fmts(); |
| 2823 |
- ffmpeg_exit(0); |
|
| 2823 |
+ exit_program(0); |
|
| 2824 | 2824 |
} |
| 2825 | 2825 |
return 0; |
| 2826 | 2826 |
} |
| ... | ... |
@@ -2856,7 +2855,7 @@ static int opt_metadata(const char *opt, const char *arg) |
| 2856 | 2856 |
|
| 2857 | 2857 |
if(!mid){
|
| 2858 | 2858 |
fprintf(stderr, "Missing =\n"); |
| 2859 |
- ffmpeg_exit(1); |
|
| 2859 |
+ exit_program(1); |
|
| 2860 | 2860 |
} |
| 2861 | 2861 |
*mid++= 0; |
| 2862 | 2862 |
|
| ... | ... |
@@ -2904,7 +2903,7 @@ static int opt_audio_sample_fmt(const char *opt, const char *arg) |
| 2904 | 2904 |
char fmt_str[128]; |
| 2905 | 2905 |
for (i = -1; i < AV_SAMPLE_FMT_NB; i++) |
| 2906 | 2906 |
printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i));
|
| 2907 |
- ffmpeg_exit(0); |
|
| 2907 |
+ exit_program(0); |
|
| 2908 | 2908 |
} |
| 2909 | 2909 |
return 0; |
| 2910 | 2910 |
} |
| ... | ... |
@@ -3026,7 +3025,7 @@ static void parse_meta_type(char *arg, char *type, int *index, char **endptr) |
| 3026 | 3026 |
break; |
| 3027 | 3027 |
default: |
| 3028 | 3028 |
fprintf(stderr, "Invalid metadata type %c.\n", *arg); |
| 3029 |
- ffmpeg_exit(1); |
|
| 3029 |
+ exit_program(1); |
|
| 3030 | 3030 |
} |
| 3031 | 3031 |
} else |
| 3032 | 3032 |
*type = 'g'; |
| ... | ... |
@@ -3142,11 +3141,11 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder) |
| 3142 | 3142 |
avcodec_find_decoder_by_name(name); |
| 3143 | 3143 |
if(!codec) {
|
| 3144 | 3144 |
fprintf(stderr, "Unknown %s '%s'\n", codec_string, name); |
| 3145 |
- ffmpeg_exit(1); |
|
| 3145 |
+ exit_program(1); |
|
| 3146 | 3146 |
} |
| 3147 | 3147 |
if(codec->type != type) {
|
| 3148 | 3148 |
fprintf(stderr, "Invalid %s type '%s'\n", codec_string, name); |
| 3149 |
- ffmpeg_exit(1); |
|
| 3149 |
+ exit_program(1); |
|
| 3150 | 3150 |
} |
| 3151 | 3151 |
return codec->id; |
| 3152 | 3152 |
} |
| ... | ... |
@@ -3164,7 +3163,7 @@ static int opt_input_file(const char *opt, const char *filename) |
| 3164 | 3164 |
if (last_asked_format) {
|
| 3165 | 3165 |
if (!(file_iformat = av_find_input_format(last_asked_format))) {
|
| 3166 | 3166 |
fprintf(stderr, "Unknown input format: '%s'\n", last_asked_format); |
| 3167 |
- ffmpeg_exit(1); |
|
| 3167 |
+ exit_program(1); |
|
| 3168 | 3168 |
} |
| 3169 | 3169 |
last_asked_format = NULL; |
| 3170 | 3170 |
} |
| ... | ... |
@@ -3179,7 +3178,7 @@ static int opt_input_file(const char *opt, const char *filename) |
| 3179 | 3179 |
ic = avformat_alloc_context(); |
| 3180 | 3180 |
if (!ic) {
|
| 3181 | 3181 |
print_error(filename, AVERROR(ENOMEM)); |
| 3182 |
- ffmpeg_exit(1); |
|
| 3182 |
+ exit_program(1); |
|
| 3183 | 3183 |
} |
| 3184 | 3184 |
if (audio_sample_rate) {
|
| 3185 | 3185 |
snprintf(buf, sizeof(buf), "%d", audio_sample_rate); |
| ... | ... |
@@ -3212,7 +3211,7 @@ static int opt_input_file(const char *opt, const char *filename) |
| 3212 | 3212 |
err = avformat_open_input(&ic, filename, file_iformat, &format_opts); |
| 3213 | 3213 |
if (err < 0) {
|
| 3214 | 3214 |
print_error(filename, err); |
| 3215 |
- ffmpeg_exit(1); |
|
| 3215 |
+ exit_program(1); |
|
| 3216 | 3216 |
} |
| 3217 | 3217 |
assert_avoptions(format_opts); |
| 3218 | 3218 |
|
| ... | ... |
@@ -3235,7 +3234,7 @@ static int opt_input_file(const char *opt, const char *filename) |
| 3235 | 3235 |
} |
| 3236 | 3236 |
if(!found){
|
| 3237 | 3237 |
fprintf(stderr, "Specified program id not found\n"); |
| 3238 |
- ffmpeg_exit(1); |
|
| 3238 |
+ exit_program(1); |
|
| 3239 | 3239 |
} |
| 3240 | 3240 |
opt_programid=0; |
| 3241 | 3241 |
} |
| ... | ... |
@@ -3255,7 +3254,7 @@ static int opt_input_file(const char *opt, const char *filename) |
| 3255 | 3255 |
if (ret < 0 && verbose >= 0) {
|
| 3256 | 3256 |
fprintf(stderr, "%s: could not find codec parameters\n", filename); |
| 3257 | 3257 |
av_close_input_file(ic); |
| 3258 |
- ffmpeg_exit(1); |
|
| 3258 |
+ exit_program(1); |
|
| 3259 | 3259 |
} |
| 3260 | 3260 |
|
| 3261 | 3261 |
timestamp = start_time; |
| ... | ... |
@@ -3491,7 +3490,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) |
| 3491 | 3491 |
int e=sscanf(p, "%d,%d,%d", &start, &end, &q); |
| 3492 | 3492 |
if(e!=3){
|
| 3493 | 3493 |
fprintf(stderr, "error parsing rc_override\n"); |
| 3494 |
- ffmpeg_exit(1); |
|
| 3494 |
+ exit_program(1); |
|
| 3495 | 3495 |
} |
| 3496 | 3496 |
video_enc->rc_override= |
| 3497 | 3497 |
av_realloc(video_enc->rc_override, |
| ... | ... |
@@ -3615,7 +3614,7 @@ static void new_data_stream(AVFormatContext *oc, int file_idx) |
| 3615 | 3615 |
data_enc = st->codec; |
| 3616 | 3616 |
if (!data_stream_copy) {
|
| 3617 | 3617 |
fprintf(stderr, "Data stream encoding not supported yet (only streamcopy)\n"); |
| 3618 |
- ffmpeg_exit(1); |
|
| 3618 |
+ exit_program(1); |
|
| 3619 | 3619 |
} |
| 3620 | 3620 |
|
| 3621 | 3621 |
data_enc->codec_type = AVMEDIA_TYPE_DATA; |
| ... | ... |
@@ -3689,7 +3688,7 @@ static int opt_new_stream(const char *opt, const char *arg) |
| 3689 | 3689 |
int file_idx = nb_output_files - 1; |
| 3690 | 3690 |
if (nb_output_files <= 0) {
|
| 3691 | 3691 |
fprintf(stderr, "At least one output file must be specified\n"); |
| 3692 |
- ffmpeg_exit(1); |
|
| 3692 |
+ exit_program(1); |
|
| 3693 | 3693 |
} |
| 3694 | 3694 |
oc = output_files[file_idx]; |
| 3695 | 3695 |
|
| ... | ... |
@@ -3714,7 +3713,7 @@ static int opt_streamid(const char *opt, const char *arg) |
| 3714 | 3714 |
fprintf(stderr, |
| 3715 | 3715 |
"Invalid value '%s' for option '%s', required syntax is 'index:value'\n", |
| 3716 | 3716 |
arg, opt); |
| 3717 |
- ffmpeg_exit(1); |
|
| 3717 |
+ exit_program(1); |
|
| 3718 | 3718 |
} |
| 3719 | 3719 |
*p++ = '\0'; |
| 3720 | 3720 |
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) |
| 3736 | 3736 |
oc = avformat_alloc_context(); |
| 3737 | 3737 |
if (!oc) {
|
| 3738 | 3738 |
print_error(filename, AVERROR(ENOMEM)); |
| 3739 |
- ffmpeg_exit(1); |
|
| 3739 |
+ exit_program(1); |
|
| 3740 | 3740 |
} |
| 3741 | 3741 |
|
| 3742 | 3742 |
if (last_asked_format) {
|
| 3743 | 3743 |
file_oformat = av_guess_format(last_asked_format, NULL, NULL); |
| 3744 | 3744 |
if (!file_oformat) {
|
| 3745 | 3745 |
fprintf(stderr, "Requested output format '%s' is not a suitable output format\n", last_asked_format); |
| 3746 |
- ffmpeg_exit(1); |
|
| 3746 |
+ exit_program(1); |
|
| 3747 | 3747 |
} |
| 3748 | 3748 |
last_asked_format = NULL; |
| 3749 | 3749 |
} else {
|
| ... | ... |
@@ -3751,7 +3750,7 @@ static void opt_output_file(const char *filename) |
| 3751 | 3751 |
if (!file_oformat) {
|
| 3752 | 3752 |
fprintf(stderr, "Unable to find a suitable output format for '%s'\n", |
| 3753 | 3753 |
filename); |
| 3754 |
- ffmpeg_exit(1); |
|
| 3754 |
+ exit_program(1); |
|
| 3755 | 3755 |
} |
| 3756 | 3756 |
} |
| 3757 | 3757 |
|
| ... | ... |
@@ -3765,7 +3764,7 @@ static void opt_output_file(const char *filename) |
| 3765 | 3765 |
int err = read_avserver_streams(oc, filename); |
| 3766 | 3766 |
if (err < 0) {
|
| 3767 | 3767 |
print_error(filename, err); |
| 3768 |
- ffmpeg_exit(1); |
|
| 3768 |
+ exit_program(1); |
|
| 3769 | 3769 |
} |
| 3770 | 3770 |
} else {
|
| 3771 | 3771 |
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) |
| 3810 | 3810 |
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
|
| 3811 | 3811 |
if (!av_filename_number_test(oc->filename)) {
|
| 3812 | 3812 |
print_error(oc->filename, AVERROR(EINVAL)); |
| 3813 |
- ffmpeg_exit(1); |
|
| 3813 |
+ exit_program(1); |
|
| 3814 | 3814 |
} |
| 3815 | 3815 |
} |
| 3816 | 3816 |
|
| ... | ... |
@@ -3826,12 +3825,12 @@ static void opt_output_file(const char *filename) |
| 3826 | 3826 |
fflush(stderr); |
| 3827 | 3827 |
if (!read_yesno()) {
|
| 3828 | 3828 |
fprintf(stderr, "Not overwriting - exiting\n"); |
| 3829 |
- ffmpeg_exit(1); |
|
| 3829 |
+ exit_program(1); |
|
| 3830 | 3830 |
} |
| 3831 | 3831 |
} |
| 3832 | 3832 |
else {
|
| 3833 | 3833 |
fprintf(stderr,"File '%s' already exists. Exiting.\n", filename); |
| 3834 |
- ffmpeg_exit(1); |
|
| 3834 |
+ exit_program(1); |
|
| 3835 | 3835 |
} |
| 3836 | 3836 |
} |
| 3837 | 3837 |
} |
| ... | ... |
@@ -3839,7 +3838,7 @@ static void opt_output_file(const char *filename) |
| 3839 | 3839 |
/* open the file */ |
| 3840 | 3840 |
if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {
|
| 3841 | 3841 |
print_error(filename, err); |
| 3842 |
- ffmpeg_exit(1); |
|
| 3842 |
+ exit_program(1); |
|
| 3843 | 3843 |
} |
| 3844 | 3844 |
} |
| 3845 | 3845 |
|
| ... | ... |
@@ -3917,7 +3916,7 @@ static void parse_matrix_coeffs(uint16_t *dest, const char *str) |
| 3917 | 3917 |
p = strchr(p, ','); |
| 3918 | 3918 |
if(!p) {
|
| 3919 | 3919 |
fprintf(stderr, "Syntax error in matrix \"%s\" at coeff %d\n", str, i); |
| 3920 |
- ffmpeg_exit(1); |
|
| 3920 |
+ exit_program(1); |
|
| 3921 | 3921 |
} |
| 3922 | 3922 |
p++; |
| 3923 | 3923 |
} |
| ... | ... |
@@ -4065,7 +4064,7 @@ static int opt_target(const char *opt, const char *arg) |
| 4065 | 4065 |
fprintf(stderr, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n"); |
| 4066 | 4066 |
fprintf(stderr, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n"); |
| 4067 | 4067 |
fprintf(stderr, "or set a framerate with \"-r xxx\".\n"); |
| 4068 |
- ffmpeg_exit(1); |
|
| 4068 |
+ exit_program(1); |
|
| 4069 | 4069 |
} |
| 4070 | 4070 |
|
| 4071 | 4071 |
if(!strcmp(arg, "vcd")) {
|
| ... | ... |
@@ -4182,7 +4181,7 @@ static int opt_bsf(const char *opt, const char *arg) |
| 4182 | 4182 |
|
| 4183 | 4183 |
if(!bsfc){
|
| 4184 | 4184 |
fprintf(stderr, "Unknown bitstream filter %s\n", arg); |
| 4185 |
- ffmpeg_exit(1); |
|
| 4185 |
+ exit_program(1); |
|
| 4186 | 4186 |
} |
| 4187 | 4187 |
|
| 4188 | 4188 |
bsfp= *opt == 'v' ? &video_bitstream_filters : |
| ... | ... |
@@ -4206,7 +4205,7 @@ static int opt_preset(const char *opt, const char *arg) |
| 4206 | 4206 |
|
| 4207 | 4207 |
if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) {
|
| 4208 | 4208 |
fprintf(stderr, "File for preset '%s' not found\n", arg); |
| 4209 |
- ffmpeg_exit(1); |
|
| 4209 |
+ exit_program(1); |
|
| 4210 | 4210 |
} |
| 4211 | 4211 |
|
| 4212 | 4212 |
while(!feof(f)){
|
| ... | ... |
@@ -4216,7 +4215,7 @@ static int opt_preset(const char *opt, const char *arg) |
| 4216 | 4216 |
e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2; |
| 4217 | 4217 |
if(e){
|
| 4218 | 4218 |
fprintf(stderr, "%s: Invalid syntax: '%s'\n", filename, line); |
| 4219 |
- ffmpeg_exit(1); |
|
| 4219 |
+ exit_program(1); |
|
| 4220 | 4220 |
} |
| 4221 | 4221 |
if(!strcmp(tmp, "acodec")){
|
| 4222 | 4222 |
opt_audio_codec(tmp, tmp2); |
| ... | ... |
@@ -4228,7 +4227,7 @@ static int opt_preset(const char *opt, const char *arg) |
| 4228 | 4228 |
opt_data_codec(tmp, tmp2); |
| 4229 | 4229 |
}else if(opt_default(tmp, tmp2) < 0){
|
| 4230 | 4230 |
fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2); |
| 4231 |
- ffmpeg_exit(1); |
|
| 4231 |
+ exit_program(1); |
|
| 4232 | 4232 |
} |
| 4233 | 4233 |
} |
| 4234 | 4234 |
|
| ... | ... |
@@ -4402,29 +4401,30 @@ int main(int argc, char **argv) |
| 4402 | 4402 |
if(nb_output_files <= 0 && nb_input_files == 0) {
|
| 4403 | 4403 |
show_usage(); |
| 4404 | 4404 |
fprintf(stderr, "Use -h to get full help or, even better, run 'man ffmpeg'\n"); |
| 4405 |
- ffmpeg_exit(1); |
|
| 4405 |
+ exit_program(1); |
|
| 4406 | 4406 |
} |
| 4407 | 4407 |
|
| 4408 | 4408 |
/* file converter / grab */ |
| 4409 | 4409 |
if (nb_output_files <= 0) {
|
| 4410 | 4410 |
fprintf(stderr, "At least one output file must be specified\n"); |
| 4411 |
- ffmpeg_exit(1); |
|
| 4411 |
+ exit_program(1); |
|
| 4412 | 4412 |
} |
| 4413 | 4413 |
|
| 4414 | 4414 |
if (nb_input_files == 0) {
|
| 4415 | 4415 |
fprintf(stderr, "At least one input file must be specified\n"); |
| 4416 |
- ffmpeg_exit(1); |
|
| 4416 |
+ exit_program(1); |
|
| 4417 | 4417 |
} |
| 4418 | 4418 |
|
| 4419 | 4419 |
ti = getutime(); |
| 4420 | 4420 |
if (transcode(output_files, nb_output_files, input_files, nb_input_files, |
| 4421 | 4421 |
stream_maps, nb_stream_maps) < 0) |
| 4422 |
- ffmpeg_exit(1); |
|
| 4422 |
+ exit_program(1); |
|
| 4423 | 4423 |
ti = getutime() - ti; |
| 4424 | 4424 |
if (do_benchmark) {
|
| 4425 | 4425 |
int maxrss = getmaxrss() / 1024; |
| 4426 | 4426 |
printf("bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss);
|
| 4427 | 4427 |
} |
| 4428 | 4428 |
|
| 4429 |
- return ffmpeg_exit(0); |
|
| 4429 |
+ exit_program(0); |
|
| 4430 |
+ return 0; |
|
| 4430 | 4431 |
} |