winegstreamer: Generate H264 timestamps using the input type frame rate.

And remove h264parse element requirement.
This commit is contained in:
Rémi Bernon 2023-05-25 14:42:28 +02:00 committed by Alexandre Julliard
parent 8caaca177e
commit 52387aa1a4
4 changed files with 18 additions and 22 deletions

View file

@ -95,7 +95,6 @@ struct sample_desc
DWORD repeat_count;
BOOL todo_length;
BOOL todo_duration;
LONGLONG todo_time;
};
#define check_mf_sample_collection(a, b, c) check_mf_sample_collection_(__FILE__, __LINE__, a, b, c)

View file

@ -1205,7 +1205,6 @@ static DWORD check_mf_sample_(const char *file, int line, IMFSample *sample, con
timestamp = 0xdeadbeef;
hr = IMFSample_GetSampleTime(sample, &timestamp);
ok_(file, line)(hr == S_OK, "GetSampleTime returned %#lx\n", hr);
todo_wine_if(expect->todo_time && (timestamp == expect->todo_time || expect->todo_time == -1))
ok_(file, line)(llabs(timestamp - expect->sample_time) <= 50,
"got sample time %I64d\n", timestamp);
@ -3711,7 +3710,7 @@ static void test_h264_decoder(void)
const struct sample_desc expect_output_sample_i420 =
{
.attributes = output_sample_attributes,
.sample_time = 333667, .sample_duration = 333667, .todo_time = 1334666 /* with VA-API */,
.sample_time = 333667, .sample_duration = 333667,
.buffer_count = 1, .buffers = &output_buffer_desc_i420,
};
@ -4037,26 +4036,13 @@ static void test_h264_decoder_concat_streams(void)
{
.attributes = output_sample_attributes + 0,
.sample_time = 0, .sample_duration = 400000,
.todo_duration = 333666,
.buffer_count = 1, .buffers = output_buffer_desc + 0,
},
{
.attributes = output_sample_attributes + 0,
.sample_time = 400000, .sample_duration = 400000,
.buffer_count = 1, .buffers = output_buffer_desc + 0, .repeat_count = 26,
.todo_time = -1, .todo_duration = 333666,
},
{
.attributes = output_sample_attributes + 0,
.sample_time = 11200000, .sample_duration = 400000,
.buffer_count = 1, .buffers = output_buffer_desc + 0, .repeat_count = 1,
.todo_time = -1, .todo_duration = 333666,
.buffer_count = 1, .buffers = output_buffer_desc + 0, .repeat_count = 29,
},
{
.attributes = output_sample_attributes + 0,
.sample_time = 12000000, .sample_duration = 400000,
.buffer_count = 1, .buffers = output_buffer_desc + 2, .repeat_count = 29,
.todo_time = -1, .todo_duration = 333666, .todo_length = TRUE,
.todo_length = TRUE,
},
{
.attributes = output_sample_attributes + 0,

View file

@ -53,6 +53,7 @@ struct h264_decoder
IMFAttributes *attributes;
IMFAttributes *output_attributes;
UINT64 sample_time;
IMFMediaType *input_type;
MFT_INPUT_STREAM_INFO input_info;
IMFMediaType *output_type;
@ -700,8 +701,9 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
struct h264_decoder *decoder = impl_from_IMFTransform(iface);
struct wg_format wg_format;
UINT32 sample_size;
LONGLONG duration;
IMFSample *sample;
UINT64 frame_size;
UINT64 frame_size, frame_rate;
GUID subtype;
DWORD size;
HRESULT hr;
@ -748,8 +750,20 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, sample,
sample_size, &wg_format, &samples->dwStatus)))
{
wg_sample_queue_flush(decoder->wg_sample_queue, false);
if (FAILED(IMFMediaType_GetUINT64(decoder->input_type, &MF_MT_FRAME_RATE, &frame_rate)))
frame_rate = (UINT64)30000 << 32 | 1001;
duration = (UINT64)10000000 * (UINT32)frame_rate / (frame_rate >> 32);
if (FAILED(IMFSample_SetSampleTime(sample, decoder->sample_time)))
WARN("Failed to set sample time\n");
if (FAILED(IMFSample_SetSampleDuration(sample, duration)))
WARN("Failed to set sample duration\n");
decoder->sample_time += duration;
}
if (hr == MF_E_TRANSFORM_STREAM_CHANGE)
{
samples[0].dwStatus |= MFT_OUTPUT_DATA_BUFFER_FORMAT_CHANGE;

View file

@ -342,9 +342,6 @@ NTSTATUS wg_transform_create(void *args)
*/
transform->input_max_length = 16;
transform->output_plane_align = 15;
if (!(element = create_element("h264parse", "base"))
|| !append_element(transform->container, element, &first, &last))
goto out;
/* fallthrough */
case WG_MAJOR_TYPE_AUDIO_MPEG1:
case WG_MAJOR_TYPE_AUDIO_MPEG4: