Will be used in the following patch. With hw_config we can get avctx->hw_frames_ctx, and with avctx->hw_frames_ctx we get sw_pix_fmt. Otherwise sw_pix_fmt is none. I need sw_pix_fmt before get the first frame to set hevc encoder profile.
Unified · Split
| @@ -37,6 +37,7 @@ · 36 unmodified lines | ||
| 37 | 37 | #include "encode.h" |
| 38 | 38 | #include "h264.h" |
| 39 | 39 | #include "h264_sei.h" |
| 40 | +#include "hwconfig.h" | |
| 40 | 41 | #include <dlfcn.h> |
| 41 | 42 | |
| 42 | 43 | #if !HAVE_KCMVIDEOCODECTYPE_HEVC |
| @@ -2830,6 +2831,11 @@ static const enum AVPixelFormat prores_pix_fmts[] = { · 2787 unmodified lines | ||
| 2830 | 2831 | "Sets the maximum number of reference frames. This only has an effect when the value is less than the maximum allowed by the profile/level.", \ |
| 2831 | 2832 | OFFSET(max_ref_frames), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, |
| 2832 | 2833 | |
| 2834 | +static const AVCodecHWConfigInternal *const vt_encode_hw_configs[] = { | |
| 2835 | + HW_CONFIG_ENCODER_FRAMES(VIDEOTOOLBOX, VIDEOTOOLBOX), | |
| 2836 | + NULL, | |
| 2837 | +}; | |
| 2838 | + | |
| 2833 | 2839 | #define OFFSET(x) offsetof(VTEncContext, x) |
| 2834 | 2840 | static const AVOption h264_options[] = { |
| 2835 | 2841 | { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = AV_PROFILE_UNKNOWN }, AV_PROFILE_UNKNOWN, INT_MAX, VE, "profile" }, |
| @@ -2886,6 +2892,7 @@ const FFCodec ff_h264_videotoolbox_encoder = { · 50 unmodified lines | ||
| 2886 | 2892 | .close = vtenc_close, |
| 2887 | 2893 | .p.priv_class = &h264_videotoolbox_class, |
| 2888 | 2894 | .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, |
| 2895 | + .hw_configs = vt_encode_hw_configs, | |
| 2889 | 2896 | }; |
| 2890 | 2897 | |
| 2891 | 2898 | static const AVOption hevc_options[] = { |
| @@ -2923,6 +2930,7 @@ const FFCodec ff_hevc_videotoolbox_encoder = { · 31 unmodified lines | ||
| 2923 | 2930 | .p.priv_class = &hevc_videotoolbox_class, |
| 2924 | 2931 | .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, |
| 2925 | 2932 | .p.wrapper_name = "videotoolbox", |
| 2933 | + .hw_configs = vt_encode_hw_configs, | |
| 2926 | 2934 | }; |
| 2927 | 2935 | |
| 2928 | 2936 | static const AVOption prores_options[] = { |
| @@ -2961,4 +2969,5 @@ const FFCodec ff_prores_videotoolbox_encoder = { · 32 unmodified lines | ||
| 2961 | 2969 | .p.priv_class = &prores_videotoolbox_class, |
| 2962 | 2970 | .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, |
| 2963 | 2971 | .p.wrapper_name = "videotoolbox", |
| 2972 | + .hw_configs = vt_encode_hw_configs, | |
| 2964 | 2973 | }; |