次の方法で共有


CVideoTransformFilter Class (Compact 2013)

3/26/2014

CVideoTransformFilter Class

This class is designed primarily as a base class for AVI decompressor filters. It is based on a "copying" transform class and assumes that the output buffer will likely be a video buffer or DirectDraw buffer, although this could be used as a base class for other types of transform filters.

The main feature of this class is that it enables quality-control management in a transform filter. This means that it decides to drop frames based on receiving a quality notification from the renderer, and taking into account other factors about the media stream it is processing and the filter's own behavior.

Every time the CVideoTransformFilter::Receive member function is called, it calls CVideoTransformFilter::ShouldSkipFrame to determine whether to start, continue, or stop skipping frames.

This member function starts skipping samples only if all of the following are true.

  • The average time to decode is more than one fourth of the frame time.
  • The filter is running at least one frame late.
  • The next anticipated key frame is estimated to be no more than one frame early.
  • The occurrence of key frames is sufficiently frequent.

When the class starts to skip frames, it skips all frames until a key frame appears, at which time it resets the m_bSkipping flag and processes the sample.

Key frames are defined as AVI key frames or MPEG I frames. These require no history to decode and, if they are skipped, no other frames can be decoded until the next key frame.

Non-key frames include AVI non-key frames, MPEG P frames, and MPEG B frames.

MPEG B frames are treated the same as other non-key frames by this class. (MPEG B frames can be dropped without the need to skip further frames; however, because this class is aimed primarily at AVI decompressors, it does not allow for this.

When any frame is skipped, all frames are skipped up to the next key frame.)

Protected Data Members

Member

Description

m_bNoSkip

Set to TRUE to prevent skipping to the next key frame (for debugging the filter).

m_bQualityChanged

Status flag that indicates if the stream has degraded.

This is set to TRUE in CVideoTransformFilter::Receive if the call to the derived class Transform member function fails.

(Receive returns NOERROR in this case because returning S_FALSE indicates that end-of-stream has arrived.)

m_bSkipping

Set to TRUE if the filter is skipping to the next key frame.

m_idFrameType

Performance-measuring frame type identifier (available if PERF is defined).

Logs 1 for key frames; logs 2 for nonkey frames.

m_idLate

Performance identifier for measuring lateness (available if PERF is defined).

m_idSkip

Performance identifier for measuring frame skipping (available if PERF is defined).

m_idTimeTillKey

Performance identifier that represents an estimate of the time in milliseconds until the next key frame arrives (available if PERF is defined).

m_itrAvgDecode

Average time required to decode (transform) the sample.

If this is less than one-fourth of the frame time, it is assumed the quality problems are not being generated by this filter and no frames are dropped.

m_itrLate

Amount of time that the current frame is late.

This is originally set to the value of the Quality structure's Late member passed in the quality control message from the renderer filter.

It is decremented by the frame time of each frame that is skipped.

m_nFramesSinceKeyFrame

Used to count frames since the last key frame.

m_nKeyFramePeriod

The largest observed interval between key frames.

m_nWaitForKey

Used to ensure output after a format change before getting the first key frame.

When nonzero, frames are not passed to the renderer.

Set to 30 when format is changed and decremented on each non-key frame.

m_tDecodeStart

Time since the start of the decoding.

Member Functions

Member function

Description

AlterQuality

Receives a quality-control notification from the output pin and provides an opportunity to alter the quality of the media stream.

CVideoTransformFilter

Constructs a CVideoTransformFilter object.

ShouldSkipFrame

Determines if the filter should start, continue, or stop skipping frames.

Overrideable Member Functions

Member function

Description

EndFlush

Receives notification of leaving the flushing state and passes it downstream.

Receive

Receives the media sample and either skips the sample or transforms and delivers the media sample.

RegisterPerfId

Registers a performance measurement identifier.

StartStreaming

Overrides CTransformFilter::StartStreaming to reset the quality control information when streaming starts or flushing starts.

Requirements

Header

dshow.h,
Streams.h

Library

ole32.lib,
Ole32auth.lib,
Strmbase.lib,
Strmiids.lib,
uuid.lib

See Also

Reference

DirectShow Classes