| 4196 | } |
| 4197 | |
| 4198 | static int do_probe(hb_stream_t *stream, hb_pes_stream_t *pes, hb_buffer_t *buf) |
| 4199 | { |
| 4200 | int result = 0; |
| 4201 | |
| 4202 | // Check upper limit of per stream data to probe |
| 4203 | if ( pes->probe_buf == NULL ) |
| 4204 | { |
| 4205 | pes->probe_buf = hb_buffer_init( 0 ); |
| 4206 | pes->probe_next_size = 0; |
| 4207 | pes->probe_count = 0; |
| 4208 | } |
| 4209 | |
| 4210 | if ( pes->probe_buf->size > HB_MAX_PROBE_SIZE ) |
| 4211 | { |
| 4212 | // Max size reached before finding anything. Try again from |
| 4213 | // another start PES |
| 4214 | pes->probe_count++; |
| 4215 | hb_buffer_close( &pes->probe_buf ); |
| 4216 | if (pes->probe_count >= HB_MAX_PROBES) |
| 4217 | { |
| 4218 | return -1; |
| 4219 | } |
| 4220 | pes->probe_buf = hb_buffer_init( 0 ); |
| 4221 | pes->probe_next_size = 0; |
| 4222 | } |
| 4223 | |
| 4224 | // Add this stream buffer to probe buffer and perform probe |
| 4225 | int size = pes->probe_buf->size + buf->size; |
| 4226 | |
| 4227 | hb_buffer_realloc(pes->probe_buf, size + AVPROBE_PADDING_SIZE ); |
| 4228 | memcpy( pes->probe_buf->data + pes->probe_buf->size, buf->data, buf->size ); |
| 4229 | pes->probe_buf->size = size; |
| 4230 | |
| 4231 | if ( pes->codec == HB_ACODEC_DCA_HD ) |
| 4232 | { |
| 4233 | // We need to probe for the profile of DTS audio in this stream. |
| 4234 | return probe_dts_profile( stream, pes ); |
| 4235 | } |
| 4236 | |
| 4237 | // Probing is slow, so we don't want to re-probe the probe |
| 4238 | // buffer for every packet we add to it. Grow the buffer |
| 4239 | // by a factor of 2 before probing again. |
| 4240 | if ( pes->probe_buf->size < pes->probe_next_size ) |
| 4241 | return 0; |
| 4242 | pes->probe_next_size = pes->probe_buf->size * 2; |
| 4243 | |
| 4244 | if (pes->codec_param != AV_CODEC_ID_NONE) |
| 4245 | { |
| 4246 | // Already did a format probe, but some stream types require a |
| 4247 | // deeper parser probe. E.g. MPEG-1/2, av_probe_input_format2 |
| 4248 | // resolves to AV_CODEC_ID_MPEG2VIDEO for both MPEG-1 and MPEG-2 |
| 4249 | result = do_deep_probe(stream, pes); |
| 4250 | if (result) |
| 4251 | { |
| 4252 | hb_buffer_close(&pes->probe_buf); |
| 4253 | } |
| 4254 | return result; |
| 4255 | } |
no test coverage detected