高度な検索
Developer Connection
Member Login ログイン | ご入会 ADC連絡先

Technical Q&A QA1157
Base-Derived async image codecs must implement ImageCodecQueueStarting and ImageCodecQueueStopping


Q:Base Image Decompressor を使うコーデックを書きました。このデコンプレッサは非同期に実行する必要があり(DrawBand 関数は安全でない呼び出しを一切しません)、ImageCodecInitialize の実行時にサブコーデック機能のレコードに canAsync フラグを確実にセットするようにしました。しかし、コーデックは非同期に実行していないようです。何かが足りないのでしょうか。

A: ベースコーデックに基づく非同期コーデックは、canAsync フラグのセットに加えて、ImageCodecQueueStarting および ImageCodecQueueStopping ルーチンを実装する必要があります。コーデックに、これらの呼び出しを実装しないと、ベースコーデックは同期再生に戻ってしまいます。

これらの呼び出し時にコーデックが何もする必要がない場合は、単に noErr を戻すようにします。

リスト 1 は、ディスパッチファイルを設定し、2 つのセレクタを実装する方法を示します。

リスト 2 は、QueueStarting と QueueStopping の呼び出し時にコーデックが何もする必要がない場合に、ComponentDispatchHelper に作業を実行させる方法を示します。


// MySubCodecDispatch.h
 ...

    ComponentRangeBegin (3)
        ComponentCall     (Preflight)
        ComponentCall     (Initialize)
        ComponentCall     (BeginBand)
        ComponentCall     (DrawBand)
        ComponentCall     (EndBand)
        ComponentCall     (QueueStarting)
        ComponentCall     (QueueStopping)
        ComponentDelegate (DroppingFrame)
        ComponentDelegate (ScheduleFrame)
        ComponentDelegate (CancelTrigger)
    ComponentRangeEnd (3)
 ...

// MySubCodec.c
 ...

// ImageCodecQueueStarting
//     Base Image Decompressor は、キューにあるフレームを伸長する前に、
// イメージデコンプレッサコンポーネントの ImageCodecQueueStarting 
// 関数を呼び出します。Base Image Decompressor は、割り込み時に 
// ImageCodecQueueStarting 関数を呼び出すことはない。
// コーデックが非同期の定期伸長をサポートする場合、このセレクタを実装
// する必要がある。このとき、コーデックが何もする必要がなければ、
// 単に noErr を戻す。
pascal ComponentResult EI_ImageCodecQueueStarting(EI_Globals glob)
{
 #pragma unused(glob)

    return noErr;
}

// ImageCodecQueueStopping
//     Base Image Decompressor は、ImageCodecQueueStopping 関数を
// 呼び出し、 キューにあるフレームが伸長されたことをコーデックに通知する。
// Image Decompressor コンポーネントは、ImageCodecQueueStopping の
// 呼び出しを処理した後、不要となったデータ構造体の破棄など、フレームの
// 伸長が完了するときに必要な任意のタスクを実行できる。
// コーデックが非同期の定期伸長をサポートする場合、このセレクタを実装する
// 必要がある。このとき、コーデックが何も作業する必要がなければ、
// 単に noErr を戻す。
// Base Image Decompressor は、割り込み時に ImageCodecQueueStopping 
// 関数を呼び出すことはない。
pascal ComponentResult EI_ImageCodecQueueStopping(EI_Globals glob)
{
 #pragma unused(glob)

    return noErr;
}
 ...

リスト 1 QueueStarting と QueueStopping の実装


// コーデックが、QueueStarting と QueueStopping で作業を行う必要がない場合は、
// ディスパッチャで ComponentNoError を使い、ComponentDispatchHelper 
// に作業を実行させることができる。そうすれば ComponentDispatchHelper は、 
// この 2 つのセレクタについては、badComponentSelector ではなく
// noErr を戻す。

// MySubCodecDispatch.h
 ...
    ComponentRangeBegin (3)
        ComponentCall     (Preflight)
        ComponentCall     (Initialize)
        ComponentCall     (BeginBand)
        ComponentCall     (DrawBand)
        ComponentCall     (EndBand)
        ComponentNoError  (QueueStarting)
        ComponentNoError  (QueueStopping)
        ComponentDelegate (DroppingFrame)
        ComponentDelegate (ScheduleFrame)
        ComponentDelegate (CancelTrigger)
    ComponentRangeEnd (3)
 ...

リスト 2 ComponentNoError を使った QueueStarting と QueueStopping の実装


参考文献

QuickTime Codec Components

Base Image Decompressor Functions


[2002 年 7 月 9 日]