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

Function ff_get_format

libavcodec/decode.c:1210–1346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1208}
1209
1210int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
1211{
1212 const AVPixFmtDescriptor *desc;
1213 enum AVPixelFormat *choices;
1214 enum AVPixelFormat ret, user_choice;
1215 const AVCodecHWConfigInternal *hw_config;
1216 const AVCodecHWConfig *config;
1217 int i, n, err;
1218
1219 // Find end of list.
1220 for (n = 0; fmt[n] != AV_PIX_FMT_NONE; n++);
1221 // Must contain at least one entry.
1222 av_assert0(n >= 1);
1223 // If a software format is available, it must be the last entry.
1224 desc = av_pix_fmt_desc_get(fmt[n - 1]);
1225 if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
1226 // No software format is available.
1227 } else {
1228 avctx->sw_pix_fmt = fmt[n - 1];
1229 }
1230
1231 choices = av_memdup(fmt, (n + 1) * sizeof(*choices));
1232 if (!choices)
1233 return AV_PIX_FMT_NONE;
1234
1235 for (;;) {
1236 // Remove the previous hwaccel, if there was one.
1237 ff_hwaccel_uninit(avctx);
1238
1239 user_choice = avctx->get_format(avctx, choices);
1240 if (user_choice == AV_PIX_FMT_NONE) {
1241 // Explicitly chose nothing, give up.
1242 ret = AV_PIX_FMT_NONE;
1243 break;
1244 }
1245
1246 desc = av_pix_fmt_desc_get(user_choice);
1247 if (!desc) {
1248 av_log(avctx, AV_LOG_ERROR, "Invalid format returned by "
1249 "get_format() callback.\n");
1250 ret = AV_PIX_FMT_NONE;
1251 break;
1252 }
1253 av_log(avctx, AV_LOG_DEBUG, "Format %s chosen by get_format().\n",
1254 desc->name);
1255
1256 for (i = 0; i < n; i++) {
1257 if (choices[i] == user_choice)
1258 break;
1259 }
1260 if (i == n) {
1261 av_log(avctx, AV_LOG_ERROR, "Invalid return from get_format(): "
1262 "%s not in possible list.\n", desc->name);
1263 ret = AV_PIX_FMT_NONE;
1264 break;
1265 }
1266
1267 if (ffcodec(avctx->codec)->hw_configs) {

Callers 15

qsv_decode_preinitFunction · 0.85
get_pixel_formatFunction · 0.85
get_pixel_formatFunction · 0.85
decode_frame_headerFunction · 0.85
h263_get_formatFunction · 0.85
dpx.cFile · 0.85
get_pixel_formatFunction · 0.85
prores_raw.cFile · 0.85
mpeg_get_pixelformatFunction · 0.85
update_sizeFunction · 0.85
vc1_get_formatFunction · 0.85

Calls 7

av_pix_fmt_desc_getFunction · 0.85
av_memdupFunction · 0.85
ff_hwaccel_uninitFunction · 0.85
av_logFunction · 0.85
ffcodecFunction · 0.85
hwaccel_initFunction · 0.85
av_freepFunction · 0.85

Tested by

no test coverage detected