rough in support for ffmpeg 3.4
parent
5ab4414b11
commit
a44631a59d
|
@ -57,6 +57,32 @@ static enum AVPixelFormat get_hw_format(
|
|||
Error("Failed to get HW surface format.");
|
||||
return AV_PIX_FMT_NONE;
|
||||
}
|
||||
#if !LIBAVUTIL_VERSION_CHECK(56, 22, 0, 14, 0)
|
||||
static enum AVPixelFormat find_fmt_by_hw_type(const enum AVHWDeviceType type) {
|
||||
enum AVPixelFormat fmt;
|
||||
switch (type) {
|
||||
case AV_HWDEVICE_TYPE_VAAPI:
|
||||
fmt = AV_PIX_FMT_VAAPI;
|
||||
break;
|
||||
case AV_HWDEVICE_TYPE_DXVA2:
|
||||
fmt = AV_PIX_FMT_DXVA2_VLD;
|
||||
break;
|
||||
case AV_HWDEVICE_TYPE_D3D11VA:
|
||||
fmt = AV_PIX_FMT_D3D11;
|
||||
break;
|
||||
case AV_HWDEVICE_TYPE_VDPAU:
|
||||
fmt = AV_PIX_FMT_VDPAU;
|
||||
break;
|
||||
case AV_HWDEVICE_TYPE_VIDEOTOOLBOX:
|
||||
fmt = AV_PIX_FMT_VIDEOTOOLBOX;
|
||||
break;
|
||||
default:
|
||||
fmt = AV_PIX_FMT_NONE;
|
||||
break;
|
||||
}
|
||||
return fmt;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
FfmpegCamera::FfmpegCamera(
|
||||
|
@ -392,22 +418,6 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
mVideoCodecContext->flags2 |= CODEC_FLAG2_FAST | CODEC_FLAG_LOW_DELAY;
|
||||
#endif
|
||||
|
||||
AVHWAccel *first_hwaccel = av_hwaccel_next(NULL);
|
||||
AVHWAccel *temp_hwaccel = first_hwaccel;
|
||||
AVHWAccel *h264 = NULL;
|
||||
const char * h264_name = "h264_vaapi";
|
||||
while ( temp_hwaccel != NULL ) {
|
||||
Debug(1,"%s ", temp_hwaccel->name);
|
||||
if ( strcmp(temp_hwaccel->name, h264_name) == 0 ) {
|
||||
h264=temp_hwaccel;
|
||||
}
|
||||
temp_hwaccel = av_hwaccel_next(temp_hwaccel);
|
||||
|
||||
if ( temp_hwaccel == first_hwaccel ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( mVideoCodecContext->codec_id == AV_CODEC_ID_H264 ) {
|
||||
if ( (mVideoCodec = avcodec_find_decoder_by_name("h264_mmal")) == NULL ) {
|
||||
Debug(1, "Failed to find decoder (h264_mmal)" );
|
||||
|
@ -439,6 +449,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
Debug(1, "Found hwdevice %s", av_hwdevice_get_type_name(type));
|
||||
}
|
||||
|
||||
#if LIBAVUTIL_VERSION_CHECK(56, 22, 0, 14, 0)
|
||||
// Get h_pix_fmt
|
||||
for ( int i = 0;; i++ ) {
|
||||
const AVCodecHWConfig *config = avcodec_get_hw_config(mVideoCodec, i);
|
||||
|
@ -454,6 +465,9 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
break;
|
||||
}
|
||||
} // end foreach hwconfig
|
||||
#else
|
||||
hw_pix_fmt = find_fmt_by_hw_type(type);
|
||||
#endif
|
||||
|
||||
mVideoCodecContext->get_format = get_hw_format;
|
||||
|
||||
|
|
Loading…
Reference in New Issue