MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / av_probe_input_format3

Function av_probe_input_format3

libavformat/format.c:156–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156const AVInputFormat *av_probe_input_format3(const AVProbeData *pd,
157 int is_opened, int *score_ret)
158{
159 AVProbeData lpd = *pd;
160 const AVInputFormat *fmt1 = NULL;
161 const AVInputFormat *fmt = NULL;
162 int score, score_max = 0;
163 void *i = 0;
164 const static uint8_t zerobuffer[AVPROBE_PADDING_SIZE];
165 enum nodat {
166 NO_ID3,
167 ID3_ALMOST_GREATER_PROBE,
168 ID3_GREATER_PROBE,
169 ID3_GREATER_MAX_PROBE,
170 } nodat = NO_ID3;
171
172 if (!lpd.buf)
173 lpd.buf = (unsigned char *) zerobuffer;
174
175 while (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) {
176 int id3len = ff_id3v2_tag_len(lpd.buf);
177 if (lpd.buf_size > id3len + 16) {
178 if (lpd.buf_size < 2LL*id3len + 16)
179 nodat = ID3_ALMOST_GREATER_PROBE;
180 lpd.buf += id3len;
181 lpd.buf_size -= id3len;
182 } else if (id3len >= PROBE_BUF_MAX) {
183 nodat = ID3_GREATER_MAX_PROBE;
184 break;
185 } else {
186 nodat = ID3_GREATER_PROBE;
187 break;
188 }
189 }
190
191 while ((fmt1 = av_demuxer_iterate(&i))) {
192 if (fmt1->flags & AVFMT_EXPERIMENTAL)
193 continue;
194 if (!is_opened == !(fmt1->flags & AVFMT_NOFILE) && strcmp(fmt1->name, "image2"))
195 continue;
196 score = 0;
197 if (ffifmt(fmt1)->read_probe) {
198 score = ffifmt(fmt1)->read_probe(&lpd);
199 if (score)
200 av_log(NULL, AV_LOG_TRACE, "Probing %s score:%d size:%d\n", fmt1->name, score, lpd.buf_size);
201 if (fmt1->extensions && av_match_ext(lpd.filename, fmt1->extensions)) {
202 switch (nodat) {
203 case NO_ID3:
204 score = FFMAX(score, 1);
205 break;
206 case ID3_GREATER_PROBE:
207 case ID3_ALMOST_GREATER_PROBE:
208 score = FFMAX(score, AVPROBE_SCORE_EXTENSION / 2 - 1);
209 break;
210 case ID3_GREATER_MAX_PROBE:
211 score = FFMAX(score, AVPROBE_SCORE_EXTENSION);
212 break;
213 }

Callers 3

av_probe_input_format2Function · 0.85
ff_img_read_packetFunction · 0.85

Calls 7

ff_id3v2_matchFunction · 0.85
ff_id3v2_tag_lenFunction · 0.85
av_demuxer_iterateFunction · 0.85
ffifmtFunction · 0.85
av_logFunction · 0.85
av_match_extFunction · 0.85
av_match_nameFunction · 0.85

Tested by

no test coverage detected