Skip to content

Commit

Permalink
libhb: add an helper function to check if an encoder supports two pas…
Browse files Browse the repository at this point in the history
…ses or not. Enable two passes on VideoToolbox H.265 on Monterey on M1.
  • Loading branch information
galad87 committed Dec 27, 2021
1 parent 87aec08 commit 6e2a48d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
27 changes: 27 additions & 0 deletions libhb/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,33 @@ int hb_video_quality_is_supported(uint32_t codec)
}
}

int hb_video_twopass_is_supported(uint32_t codec)
{
switch (codec)
{
#ifdef __APPLE__
case HB_VCODEC_VT_H264:
case HB_VCODEC_VT_H265:
case HB_VCODEC_VT_H265_10BIT:
return hb_vt_is_two_pass_available(codec);
#endif

case HB_VCODEC_FFMPEG_MF_H264:
case HB_VCODEC_FFMPEG_MF_H265:
case HB_VCODEC_FFMPEG_VCE_H264:
case HB_VCODEC_FFMPEG_VCE_H265:
case HB_VCODEC_FFMPEG_NVENC_H264:
case HB_VCODEC_FFMPEG_NVENC_H265:
case HB_VCODEC_QSV_H264:
case HB_VCODEC_QSV_H265:
case HB_VCODEC_QSV_H265_10BIT:
return 0;

default:
return 1;
}
}

int hb_video_encoder_is_supported(int encoder)
{
const hb_encoder_t *video_encoder = NULL;
Expand Down
2 changes: 2 additions & 0 deletions libhb/handbrake/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ void hb_video_quality_get_limits(uint32_t codec, float *low, float *high,
const char* hb_video_quality_get_name(uint32_t codec);
int hb_video_quality_is_supported(uint32_t codec);

int hb_video_twopass_is_supported(uint32_t codec);

int hb_video_encoder_is_supported(int encoder);
int hb_video_encoder_pix_fmt_is_supported(int encoder, int pix_fmt);
int hb_video_encoder_get_depth (int encoder);
Expand Down
24 changes: 24 additions & 0 deletions libhb/platform/macosx/vt_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,30 @@ int hb_vt_is_constant_quality_available(int encoder)
return 0;
}

int hb_vt_is_two_pass_available(int encoder)
{
switch (encoder)
{
case HB_VCODEC_VT_H264:
{
return 1;
}
case HB_VCODEC_VT_H265:
case HB_VCODEC_VT_H265_10BIT:
{
#if defined(__aarch64__)
if (__builtin_available (macOS 12, *))
{
return 1;
}
#endif
return 0;
}
}
return 0;

}

#pragma mark - Settings

static const char * const vt_h26x_preset_name[] =
Expand Down
1 change: 1 addition & 0 deletions libhb/platform/macosx/vt_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

int hb_vt_is_encoder_available(int encoder);
int hb_vt_is_constant_quality_available(int encoder);
int hb_vt_is_two_pass_available(int encoder);

const int* hb_vt_get_pix_fmts(int encoder);

Expand Down

0 comments on commit 6e2a48d

Please sign in to comment.