Start by reading
HWAccelIntro – FFmpeg[
^].
For usage with the API check if an appropriate decoder is available and select that for decoding (requires that the library has been built with support for that decoder):
AVCodec* decoder = avcodec_find_decoder_by_name ("h264_dxva2");
avcodec_open2 (decoder_ctx, decoder, NULL);