| 77 | } |
| 78 | |
| 79 | const AVOutputFormat *av_guess_format(const char *short_name, const char *filename, |
| 80 | const char *mime_type) |
| 81 | { |
| 82 | const AVOutputFormat *fmt = NULL; |
| 83 | const AVOutputFormat *fmt_found = NULL; |
| 84 | void *i = 0; |
| 85 | int score_max, score; |
| 86 | |
| 87 | /* specific test for image sequences */ |
| 88 | #if CONFIG_IMAGE2_MUXER |
| 89 | if (!short_name && filename && |
| 90 | av_filename_number_test(filename) && |
| 91 | ff_guess_image2_codec(filename) != AV_CODEC_ID_NONE) { |
| 92 | return av_guess_format("image2", NULL, NULL); |
| 93 | } |
| 94 | #endif |
| 95 | /* Find the proper file type. */ |
| 96 | score_max = 0; |
| 97 | while ((fmt = av_muxer_iterate(&i))) { |
| 98 | if (fmt->flags & AVFMT_EXPERIMENTAL && !short_name) |
| 99 | continue; |
| 100 | score = 0; |
| 101 | if (fmt->name && short_name && av_match_name(short_name, fmt->name)) |
| 102 | score += 100; |
| 103 | if (fmt->mime_type && mime_type && !strcmp(fmt->mime_type, mime_type)) |
| 104 | score += 10; |
| 105 | if (filename && fmt->extensions && |
| 106 | av_match_ext(filename, fmt->extensions)) { |
| 107 | score += 5; |
| 108 | } |
| 109 | if (score > score_max) { |
| 110 | score_max = score; |
| 111 | fmt_found = fmt; |
| 112 | } |
| 113 | } |
| 114 | return fmt_found; |
| 115 | } |
| 116 | |
| 117 | enum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name, |
| 118 | const char *filename, const char *mime_type, |