MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / do_deep_probe

Function do_deep_probe

libhb/stream.c:4125–4196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4123}
4124
4125static int
4126do_deep_probe(hb_stream_t *stream, hb_pes_stream_t *pes)
4127{
4128 int result = 0;
4129 const AVCodec *codec = avcodec_find_decoder(pes->codec_param);
4130
4131 if (codec == NULL)
4132 {
4133 return -1;
4134 }
4135
4136 AVCodecContext * context = avcodec_alloc_context3(codec);
4137 AVCodecParserContext * parser = av_parser_init(codec->id);
4138
4139 if (context == NULL)
4140 {
4141 return -1;
4142 }
4143 if (parser == NULL)
4144 {
4145 return -1;
4146 }
4147 if (hb_avcodec_open(context, codec, NULL, 0))
4148 {
4149 return -1;
4150 }
4151
4152 int pos = 0;
4153 while (pos < pes->probe_buf->size)
4154 {
4155 int len, out_size;
4156 uint8_t * out;
4157
4158 len = av_parser_parse2(parser, context, &out, &out_size,
4159 pes->probe_buf->data + pos,
4160 pes->probe_buf->size - pos, 0, 0, 0);
4161 pos += len;
4162 if (out_size == 0)
4163 {
4164 continue;
4165 }
4166 // Parser changes context->codec_id if it detects a different but
4167 // related stream type. E.g. AV_CODEC_ID_MPEG2VIDEO gets changed
4168 // to AV_CODEC_ID_MPEG1VIDEO when the stream is MPEG-1
4169 switch (context->codec_id)
4170 {
4171 case AV_CODEC_ID_MPEG1VIDEO:
4172 pes->codec_param = context->codec_id;
4173 pes->stream_type = 0x01;
4174 pes->stream_kind = V;
4175 result = 1;
4176 break;
4177
4178 case AV_CODEC_ID_MPEG2VIDEO:
4179 pes->codec_param = context->codec_id;
4180 pes->stream_type = 0x02;
4181 pes->stream_kind = V;
4182 result = 1;

Callers 1

do_probeFunction · 0.85

Calls 3

hb_avcodec_openFunction · 0.85
hb_errorFunction · 0.85
hb_avcodec_free_contextFunction · 0.85

Tested by

no test coverage detected