在DirectShow中处理动态格式更改 [英] Handling Dynamic Format Changes in DirectShow

查看:110
本文介绍了在DirectShow中处理动态格式更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只有一个简单的图形:

I just have simple graph:

SourceFilter ---> CustomTransformFilter --> VideoRendererFilter

在我的 CustomTranformFilter 中,我动态地更改视频属性:即,我重新缩放视频

In my CustomTranformFilter i change video properties dynamically:i.e i rescale video into new dimensions.

Input Video[1024,720]-->|CustomTransformFilter|--->Output Video[640,480] 

但是我的渲染器看到的视频仍保持原始大小([1024,720]重新缩放[640,480])
而且我在视频渲染器上收到损坏的图像:由于渲染器尝试根据旧尺寸绘制新图像...

But my renderer see the video as still in its original size ( [1024,720] not rescaled [640,480] ) And i get corrupted images at video renderer:Since renderer try to draw new image based on old dimensions...

我怎么能修复它吗?

最美好的祝愿

更新:

据我从戴维斯了解,答案:

As i understand from Davies answer :

Given: The graph is active, but the filters in question do not support dynamic 
pin reconnections

Possible mechanisms for changing the format: (MSDN DirectShow Doc)
a. QueryAccept (Downstream)
b. QueryAccept (Upstream) 
c. ReceiveConnection 

戴维斯建议使用ReceiveConnection。
ReceiveConnection:在输出引脚建议将其下游对等点的格式更改为
时使用,并且新格式需要更大的缓冲区。 (MSDN DirectShow文档)。

Davies suggest ReceiveConnection. ReceiveConnection:is used when an output pin proposes a format change to its downstream peer, and the new format requires a larger buffer. ( MSDN DirectShow Doc).

对于我来说,gmfbridge示例太复杂了,无法弄清楚如何使用 ReceiveConnection。

有人能使用ReceiveConnection机制响应动态格式更改的简单代码示例吗?

推荐答案

在DirectShow中进行动态类型更改的通常方法是将媒体类型附加到您提供的样品上。由于它正在分配样本,因此不适用于视频渲染器。从分配器获取示例之前,需要请求类型更改。

The normal way to do a dynamic type change in DirectShow is to attach a Media Type to the sample that you deliver. This won't work with the video renderer, since it is allocating the samples. You need to request a change in type before you get the sample from the allocator.

您可以使用ReceiveConnection进行此操作。您必须确保在该分配器上没有未完成的缓冲区,然后可以调用IPin :: ReceiveConnection(无需先断开连接)。在www.gdcl.co.uk/gmfbridge的gmfbridge代码中,在BridgeSourceOutput :: SwitchTo()中有此示例。

You do this using ReceiveConnection. You must make sure that there are no buffers outstanding on that allocator, and then you can call IPin::ReceiveConnection (without disconnecting first). There is an example of this in the gmfbridge code at www.gdcl.co.uk/gmfbridge, in BridgeSourceOutput::SwitchTo().

G

这篇关于在DirectShow中处理动态格式更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆