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

Function choose_decoder

fftools/ffmpeg_demux.c:1143–1188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1141}
1142
1143static int choose_decoder(const OptionsContext *o, void *logctx,
1144 AVFormatContext *s, AVStream *st,
1145 enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type,
1146 const AVCodec **pcodec)
1147
1148{
1149 const char *codec_name = NULL;
1150
1151 opt_match_per_stream_str(logctx, &o->codec_names, s, st, &codec_name);
1152 if (codec_name) {
1153 int ret = find_codec(NULL, codec_name, st->codecpar->codec_type, 0, pcodec);
1154 if (ret < 0)
1155 return ret;
1156 st->codecpar->codec_id = (*pcodec)->id;
1157 if (recast_media && st->codecpar->codec_type != (*pcodec)->type)
1158 st->codecpar->codec_type = (*pcodec)->type;
1159 return 0;
1160 } else {
1161 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
1162 hwaccel_id == HWACCEL_GENERIC &&
1163 hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) {
1164 const AVCodec *c;
1165 void *i = NULL;
1166
1167 while ((c = av_codec_iterate(&i))) {
1168 const AVCodecHWConfig *config;
1169
1170 if (c->id != st->codecpar->codec_id ||
1171 !av_codec_is_decoder(c))
1172 continue;
1173
1174 for (int j = 0; config = avcodec_get_hw_config(c, j); j++) {
1175 if (config->device_type == hwaccel_device_type) {
1176 av_log(logctx, AV_LOG_VERBOSE, "Selecting decoder '%s' because of requested hwaccel method %s\n",
1177 c->name, av_hwdevice_get_type_name(hwaccel_device_type));
1178 *pcodec = c;
1179 return 0;
1180 }
1181 }
1182 }
1183 }
1184
1185 *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
1186 return 0;
1187 }
1188}
1189
1190static int guess_input_channel_layout(InputStream *ist, AVCodecParameters *par,
1191 int guess_layout_max)

Callers 2

ist_addFunction · 0.85
ifile_openFunction · 0.85

Calls 7

av_codec_iterateFunction · 0.85
av_codec_is_decoderFunction · 0.85
avcodec_get_hw_configFunction · 0.85
av_logFunction · 0.85
avcodec_find_decoderFunction · 0.85
find_codecFunction · 0.70

Tested by

no test coverage detected