static bool check_ffmpeg_hevc_dxva2() { avcodec_register_all(); AVHWAccel *hwa = av_hwaccel_next(0); while (hwa) { if (strncmp("hevc_dxva2", hwa->name, 10) == 0) return true; hwa = av_hwaccel_next(hwa); } return false; }
bool FFDecHWAccel::hasHWAccel(const char *hwaccelName) { AVHWAccel *avHWAccel = NULL; while ((avHWAccel = av_hwaccel_next(avHWAccel))) if (avHWAccel->id == codec_ctx->codec_id && strstr(avHWAccel->name, hwaccelName)) break; return avHWAccel; }
static AVHWAccel *find_hwaccel(enum AVCodecID codec_id, enum AVPixelFormat pix_fmt) { AVHWAccel *hwaccel = NULL; while ((hwaccel = av_hwaccel_next(hwaccel))) if (hwaccel->id == codec_id && hwaccel->pix_fmt == pix_fmt) return hwaccel; return NULL; }
static AVCodec *find_hardware_decoder(enum AVCodecID id) { AVHWAccel *hwa = av_hwaccel_next(NULL); AVCodec *c = NULL; while (hwa) { if (hwa->id == id) { if (hwa->pix_fmt == AV_PIX_FMT_VDA_VLD || hwa->pix_fmt == AV_PIX_FMT_DXVA2_VLD || hwa->pix_fmt == AV_PIX_FMT_VAAPI_VLD) { c = avcodec_find_decoder_by_name(hwa->name); if (c) break; } } hwa = av_hwaccel_next(hwa); } return c; }
AVHWAccel *find_hwaccel_codec(AVCodecContext *codec_context) { AVHWAccel *hwaccel = NULL; while ((hwaccel = av_hwaccel_next(hwaccel)) != NULL) { if (hwaccel->id == codec_context->codec_id && (hwaccel->pix_fmt == AV_PIX_FMT_VDA_VLD || hwaccel->pix_fmt == AV_PIX_FMT_DXVA2_VLD || hwaccel->pix_fmt == AV_PIX_FMT_VAAPI_VLD)) { return hwaccel; } } return NULL; }