[vlc-commits] [Git][videolan/vlc][master] 6 commits: mft: return a HRESULT from SetOutputType()
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Jan 12 14:08:25 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
8dfb9f87 by Steve Lhomme at 2024-01-12T13:52:10+00:00
mft: return a HRESULT from SetOutputType()
For consistency with SetInputType().
- - - - -
4b0a650f by Steve Lhomme at 2024-01-12T13:52:10+00:00
mft: log the reason startStream fails
- - - - -
cc5a9e3d by Steve Lhomme at 2024-01-12T13:52:10+00:00
mft: fix SetInputType() not returning a HRESULT properly
- - - - -
779a5af0 by Steve Lhomme at 2024-01-12T13:52:10+00:00
mft: set the output encoding bitrate we use
When it's not set.
- - - - -
e5fa7bc0 by Steve Lhomme at 2024-01-12T13:52:10+00:00
mft: set common video encoding parameters for all codecs
And H264 ones only for H264.
- - - - -
885e718c by Steve Lhomme at 2024-01-12T13:52:10+00:00
mft: set more output type parameters for video encoders
- - - - -
1 changed file:
- modules/codec/mft.cpp
Changes:
=====================================
modules/codec/mft.cpp
=====================================
@@ -139,7 +139,7 @@ public:
ComPtr<IMFSample> output_sample;
HRESULT AllocateOutputSample(es_format_category_e cat, ComPtr<IMFSample> & result);
- int SetOutputType(vlc_logger *, const GUID & req_subtype, es_format_t & fmt_out);
+ HRESULT SetOutputType(vlc_logger *, const GUID & req_subtype, es_format_t & fmt_out);
HRESULT SetInputType(const es_format_t & fmt_in, const MFT_REGISTER_TYPE_INFO &);
virtual void DoRelease() = 0;
@@ -452,7 +452,7 @@ HRESULT mft_sys_t::SetInputType(const es_format_t & fmt_in, const MFT_REGISTER_T
else if (hr == MF_E_TRANSFORM_TYPE_NOT_SET)
{
/* The output type must be set before setting the input type for this MFT. */
- return VLC_SUCCESS;
+ return hr;
}
else if (FAILED(hr))
goto error;
@@ -547,7 +547,7 @@ error:
return hr;
}
-int mft_sys_t::SetOutputType(vlc_logger *logger,
+HRESULT mft_sys_t::SetOutputType(vlc_logger *logger,
const GUID & req_subtype, es_format_t & fmt_out)
{
HRESULT hr;
@@ -579,7 +579,7 @@ int mft_sys_t::SetOutputType(vlc_logger *logger,
else if (hr == MF_E_TRANSFORM_TYPE_NOT_SET)
{
/* The input type must be set before setting the output type for this MFT. */
- return VLC_SUCCESS;
+ return hr;
}
else if (FAILED(hr))
goto error;
@@ -672,12 +672,11 @@ int mft_sys_t::SetOutputType(vlc_logger *logger,
}
}
- if (fmt_out.i_cat == VIDEO_ES && fmt_out.i_codec == VLC_CODEC_H264)
+ if (fmt_out.i_cat == VIDEO_ES && IsEncoder())
{
if (fmt_out.i_bitrate != 0)
- output_media_type->SetUINT32(MF_MT_AVG_BITRATE, fmt_out.i_bitrate);
- else
- output_media_type->SetUINT32(MF_MT_AVG_BITRATE, 1000000);
+ fmt_out.i_bitrate = 1'000'000;
+ output_media_type->SetUINT32(MF_MT_AVG_BITRATE, fmt_out.i_bitrate);
if (fmt_out.video.i_frame_rate && fmt_out.video.i_frame_rate_base)
{
@@ -690,18 +689,29 @@ int mft_sys_t::SetOutputType(vlc_logger *logger,
fmt_out.video.i_visible_width,
fmt_out.video.i_visible_height);
+ hr = MFSetAttributeRatio(output_media_type.Get(), MF_MT_PIXEL_ASPECT_RATIO, 1, 1);
+
hr = output_media_type->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
+ hr = output_media_type->SetUINT32(MF_MT_FIXED_SIZE_SAMPLES, 0);
+ hr = output_media_type->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1);
+ if (fmt_out.i_codec == VLC_CODEC_H264)
+ {
+ eAVEncH264VProfile profile;
#if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
- bool isWin81OrGreater = false;
- HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32.dll"));
- if (likely(hKernel32 != NULL))
- isWin81OrGreater = GetProcAddress(hKernel32, "IsProcessCritical") != NULL;
- eAVEncH264VProfile profile = isWin81OrGreater ? eAVEncH264VProfile_High : eAVEncH264VProfile_Main;
+ bool isWin81OrGreater = false;
+ HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32.dll"));
+ if (likely(hKernel32 != NULL))
+ isWin81OrGreater = GetProcAddress(hKernel32, "IsProcessCritical") != NULL;
+ profile = isWin81OrGreater ? eAVEncH264VProfile_High : eAVEncH264VProfile_Main;
#else
- eAVEncH264VProfile profile = eAVEncH264VProfile_High;
+ profile = eAVEncH264VProfile_High;
#endif
- hr = output_media_type->SetUINT32(MF_MT_MPEG2_PROFILE, profile);
+ hr = output_media_type->SetUINT32(MF_MT_MPEG2_PROFILE, profile);
+
+ //hr = output_media_type->SetUINT32(MF_MT_MPEG2_LEVEL, eAVEncH264VLevel4);
+ }
+
}
hr = mft->SetOutputType(output_stream_id, output_media_type.Get(), 0);
@@ -774,11 +784,11 @@ int mft_sys_t::SetOutputType(vlc_logger *logger,
}
}
- return VLC_SUCCESS;
+ return S_OK;
error:
vlc_error(logger, "Error in SetOutputType()");
- return VLC_EGENERIC;
+ return hr;
}
static HRESULT AllocateInputSample(struct vlc_logger *logger, ComPtr<IMFTransform> & mft, DWORD stream_id, ComPtr<IMFSample> & result, DWORD size)
@@ -1061,7 +1071,8 @@ static int ProcessOutputStream(decoder_t *p_dec, DWORD stream_id, bool & keep_re
video_format_Copy( &p_dec->fmt_out.video, &p_dec->fmt_in->video );
else
p_dec->fmt_out.audio = p_dec->fmt_in->audio;
- if (p_sys->SetOutputType(vlc_object_logger(p_dec), GUID_NULL, p_dec->fmt_out))
+ hr = p_sys->SetOutputType(vlc_object_logger(p_dec), GUID_NULL, p_dec->fmt_out);
+ if (FAILED(hr))
return VLC_EGENERIC;
/* Reallocate output sample. */
@@ -1564,7 +1575,8 @@ static int InitializeMFT(decoder_t *p_dec, const MFT_REGISTER_TYPE_INFO & type)
video_format_Copy( &p_dec->fmt_out.video, &p_dec->fmt_in->video );
else
p_dec->fmt_out.audio = p_dec->fmt_in->audio;
- if (p_sys->SetOutputType(vlc_object_logger(p_dec), GUID_NULL, p_dec->fmt_out))
+ hr = p_sys->SetOutputType(vlc_object_logger(p_dec), GUID_NULL, p_dec->fmt_out);
+ if (FAILED(hr))
goto error;
/*
@@ -1586,7 +1598,10 @@ static int InitializeMFT(decoder_t *p_dec, const MFT_REGISTER_TYPE_INFO & type)
/* This event is required for asynchronous MFTs, optional otherwise. */
hr = p_sys->startStream();
if (FAILED(hr))
+ {
+ msg_Err(p_dec, "Error in startStream(). (hr=0x%lX)", hr);
goto error;
+ }
if (p_dec->fmt_in->i_codec == VLC_CODEC_H264)
{
@@ -2368,10 +2383,13 @@ static int OpenMFTVideoEncoder(vlc_object_t *p_this)
p_enc->fmt_in.i_codec = MFFormatToChroma(input_type.guidSubtype);
p_enc->fmt_in.video.i_chroma = p_enc->fmt_in.i_codec;
- if (p_sys->SetOutputType(vlc_object_logger(p_this),
- output_type.guidSubtype, p_enc->fmt_out))
+ hr = p_sys->SetOutputType(vlc_object_logger(p_this),
+ output_type.guidSubtype, p_enc->fmt_out);
+ if (FAILED(hr))
+ {
+ msg_Err(p_enc, "Error in SetOutputType(). (hr=0x%lX)", hr);
goto error;
-
+ }
hr = p_sys->SetInputType(p_enc->fmt_in, input_type);
if (FAILED(hr))
{
@@ -2382,7 +2400,10 @@ static int OpenMFTVideoEncoder(vlc_object_t *p_this)
/* This event is required for asynchronous MFTs, optional otherwise. */
hr = p_sys->startStream();
if (FAILED(hr))
+ {
+ msg_Err(p_enc, "Error in startStream(). (hr=0x%lX)", hr);
goto error;
+ }
static const struct vlc_encoder_operations video_ops = []{
struct vlc_encoder_operations cbs{};
@@ -2524,7 +2545,10 @@ static int OpenMFTAudioEncoder(vlc_object_t *p_this)
/* This event is required for asynchronous MFTs, optional otherwise. */
hr = p_sys->startStream();
if (FAILED(hr))
+ {
+ msg_Err(p_enc, "Error in startStream(). (hr=0x%lX)", hr);
goto error;
+ }
static const struct vlc_encoder_operations audio_ops = []{
struct vlc_encoder_operations cbs{};
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d7e6b197c56d979a69293f09be89996e61458e9a...885e718c90cf9116d372ffcb42707d198a88a960
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d7e6b197c56d979a69293f09be89996e61458e9a...885e718c90cf9116d372ffcb42707d198a88a960
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list