=====================================================

ffdshow源代码分析系列文章列表:

ffdshow 源代码分析 1: 整体结构

ffdshow 源代码分析 2: 位图覆盖滤镜(对话框部分Dialog)

ffdshow 源代码分析 3: 位图覆盖滤镜(设置部分Settings)

ffdshow 源代码分析 4: 位图覆盖滤镜(滤镜部分Filter)

ffdshow 源代码分析 5: 位图覆盖滤镜(总结)

ffdshow 源代码分析 6: 对解码器的dll的封装(libavcodec)

ffdshow 源代码分析 7: libavcodec视频解码器类(TvideoCodecLibavcodec)

ffdshow 源代码分析 8: 视频解码器类(TvideoCodecDec)

ffdshow 源代码分析 9: 编解码器有关类的总结

=====================================================

上一篇文章介绍了ffdshow的位图覆盖滤镜的对话框(Dialog)部分:ffdshow 源代码分析2 : 位图覆盖滤镜(对话框部分Dialog)

在这里再介绍一下设置部分(Settings),此外还有一个滤镜部分(Filter)。这三个部分就可以组成一个ffdshow的滤镜功能了。

设置部分(Settings)

在ffdshow中滤镜的设置部分(Settings)主要用于存储滤镜运行过程中需要用到的各种变量。一般情况下通过读取注册表变量并赋值给该类当中的变量从而达到操作相应滤镜的功能。

与位图覆盖(Bitmap)滤镜的设置有关的类位于settings->filters->video目录下(隐藏的很深啊)的TbitmapSettings.cpp和TbitmapSettings.h文件中。

先来看看TbitmapSettings.h

该类的名字叫TbitmapSettings,从类的定义我们可以看出,

flnm[]存储了打开的位图的路径

posx,posy存储了位图在屏幕上显示的位置

mode存储了显示的方式

等等,所有跟该滤镜(Filter)相关的数据都存储在该类之中。

该类包含一个TfilterIDFF类型的结构体idffs,用于存储该滤镜的一些属性信息(名称,ID,属性对话框ID等等)

此外,有两个函数至关重要。createFilters()用于创建滤镜(Filter)。 createPages()用于创建滤镜的配置对话框(Dialog)。

#ifndef _TBITMAPSETTINGS_H_
#define _TBITMAPSETTINGS_H_
//各个Filter预设值
#include "TfilterSettings.h"
#include "Tfont.h"
//Bitmap的配置信息
struct TbitmapSettings : TfilterSettingsVideo {
private:
    static const TfilterIDFF idffs;
protected:
    virtual const int *getResets(unsigned int pageId);
public:
    TbitmapSettings(TintStrColl *Icoll = NULL, TfilterIDFFs *filters = NULL);
    //Bitmap文件路径
	char_t flnm[MAX_PATH];
	//x,y坐标,以及坐标的模式
    int posx, posy, posmode;
    int align;
	//叠加方式
    enum {
        MODE_BLEND = 0,
        MODE_DARKEN = 1,
        MODE_LIGHTEN = 2,
        MODE_ADD = 3,
        MODE_SOFTLIGHT = 4,
        MODE_EXCLUSION = 5
    };
    int mode;
    static const char_t *modes[];
    int strength;
	//创建Filter
    virtual void createFilters(size_t filtersorder, Tfilters *filters, TfilterQueue &queue) const;
	//创建属性页面
    virtual void createPages(TffdshowPageDec *parent) const;
    virtual bool getTip(unsigned int pageId, char_t *buf, size_t buflen);
};

#endif

再来看看TbitmapSettings.cpp

该类包含了TbitmapSettings类中函数方法的具体实现。首先看一下构造函数TbitmapSettings()。从构造函数中可以看出,绑定了类中的变量和注册表变量,使它们形成一一对应的关系。其他的函数就不再细说了,比较简单,理解起来比较容易。

/*
 * Copyright (c) 2004-2006 Milan Cutka
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "stdafx.h"
#include "TbitmapSettings.h"
#include "TimgFilterBitmap.h"
#include "Cbitmap.h"
#include "TffdshowPageDec.h"
#include "TsubtitlesSettings.h"
//几种叠加方式
const char_t* TbitmapSettings::modes[] = {
    _l("blend"),
    _l("darken"),
    _l("lighten"),
    _l("add"),
    _l("softlight"),
    _l("exclusion"),
    NULL
};
//Filter属性
const TfilterIDFF TbitmapSettings::idffs = {
    /*name*/      _l("Bitmap overlay"),
    /*id*/        IDFF_filterBitmap,
    /*is*/        IDFF_isBitmap,
    /*order*/     IDFF_orderBitmap,
    /*show*/      IDFF_showBitmap,
    /*full*/      IDFF_fullBitmap,
    /*half*/      0,
    /*dlgId*/     IDD_BITMAP,
};
//构造函数
TbitmapSettings::TbitmapSettings(TintStrColl *Icoll, TfilterIDFFs *filters): TfilterSettingsVideo(sizeof(*this), Icoll, filters, &idffs)
{
    half = 0;
    memset(flnm, 0, sizeof(flnm));
	//绑定变量
    static const TintOptionT<TbitmapSettings> iopts[] = {
        IDFF_isBitmap       , &TbitmapSettings::is        , 0, 0, _l(""), 1,
        _l("isBitmap"), 0,
        IDFF_showBitmap     , &TbitmapSettings::show      , 0, 0, _l(""), 1,
        _l("showBitmap"), 1,
        IDFF_orderBitmap    , &TbitmapSettings::order     , 1, 1, _l(""), 1,
        _l("orderBitmap"), 0,
        IDFF_fullBitmap     , &TbitmapSettings::full      , 0, 0, _l(""), 1,
        _l("fullBitmap"), 0,
        IDFF_bitmapPosx     , &TbitmapSettings::posx      , -4096, 4096, _l(""), 1,
        _l("bitmapPosX"), 50,
        IDFF_bitmapPosy     , &TbitmapSettings::posy      , -4096, 4096, _l(""), 1,
        _l("bitmapPosY"), 50,
        IDFF_bitmapPosmode  , &TbitmapSettings::posmode   , 0, 1, _l(""), 1,
        _l("bitmapPosMode"), 0,
        IDFF_bitmapAlign    , &TbitmapSettings::align     , 0, 3, _l(""), 1,
        _l("bitmapAlign"), ALIGN_CENTER,
        IDFF_bitmapMode     , &TbitmapSettings::mode      , 0, 5, _l(""), 1,
        _l("bitmapMode"), 0,
        IDFF_bitmapStrength , &TbitmapSettings::strength  , 0, 256, _l(""), 1,
        _l("bitmapStrength"), 128,
        0
    };
    addOptions(iopts);
    static const TstrOption sopts[] = {
        IDFF_bitmapFlnm     , (TstrVal)&TbitmapSettings::flnm  , MAX_PATH, 0, _l(""), 1,
        _l("bitmapFlnm"), _l(""),
        0
    };
    addOptions(sopts);

    static const TcreateParamList1 listMode(modes);
    setParamList(IDFF_bitmapMode, &listMode);
    static const TcreateParamList1 listAlign(TsubtitlesSettings::alignments);
    setParamList(IDFF_bitmapAlign, &listAlign);
}
//创建Filter
void TbitmapSettings::createFilters(size_t filtersorder, Tfilters *filters, TfilterQueue &queue) const
{
    idffOnChange(idffs, filters, queue.temporary);
    if (is && show) {
        queueFilter<TimgFilterBitmap>(filtersorder, filters, queue);
    }
}
//创建属性页面
void TbitmapSettings::createPages(TffdshowPageDec *parent) const
{
    parent->addFilterPage<TbitmapPage>(&idffs);
}

const int* TbitmapSettings::getResets(unsigned int pageId)
{
    static const int idResets[] = {
        IDFF_bitmapPosx, IDFF_bitmapPosy, IDFF_bitmapPosmode, IDFF_bitmapAlign, IDFF_bitmapMode, IDFF_bitmapStrength,
        0
    };
    return idResets;
}

bool TbitmapSettings::getTip(unsigned int pageId, char_t *tipS, size_t len)
{
    if (flnm[0]) {
        tsnprintf_s(tipS, len, _TRUNCATE, _l("%s %s"), modes[mode], flnm);
        tipS[len - 1] = '\0';
    } else {
        tipS[0] = '\0';
    }
    return true;
}

ffdshow 源代码分析 3: 位图覆盖滤镜(设置部分Settings)的更多相关文章

  1. ffdshow 源代码分析 5: 位图覆盖滤镜(总结)

    ===================================================== ffdshow源代码分析系列文章列表: ffdshow 源代码分析 1: 整体结构 ffds ...

  2. ffdshow 源代码分析 4: 位图覆盖滤镜(滤镜部分Filter)

    ===================================================== ffdshow源代码分析系列文章列表: ffdshow 源代码分析 1: 整体结构 ffds ...

  3. ffdshow 源代码分析 2: 位图覆盖滤镜(对话框部分Dialog)

    ===================================================== ffdshow源代码分析系列文章列表: ffdshow 源代码分析 1: 整体结构 ffds ...

  4. 转:ffdshow 源代码分析

    ffdshow神奇的功能:视频播放时显示运动矢量和QP FFDShow可以称得上是全能的解码.编码器.最初FFDShow只是mpeg视频解码器,不过现在他能做到的远不止于此.它能够解码的视频格式已经远 ...

  5. ffdshow 源代码分析 9: 编解码器有关类的总结

    ===================================================== ffdshow源代码分析系列文章列表: ffdshow 源代码分析 1: 整体结构 ffds ...

  6. ffdshow 源代码分析 8: 视频解码器类(TvideoCodecDec)

    ===================================================== ffdshow源代码分析系列文章列表: ffdshow 源代码分析 1: 整体结构 ffds ...

  7. ffdshow 源代码分析 7: libavcodec视频解码器类(TvideoCodecLibavcodec)

    ===================================================== ffdshow源代码分析系列文章列表: ffdshow 源代码分析 1: 整体结构 ffds ...

  8. ffdshow 源代码分析 6: 对解码器的dll的封装(libavcodec)

    ===================================================== ffdshow源代码分析系列文章列表: ffdshow 源代码分析 1: 整体结构 ffds ...

  9. ffdshow 源代码分析1 : 整体结构

    ffdshow是一个非常强大的DirectShow解码器,封装了ffmpeg,libmpeg2等解码库.它也提供了丰富的加工处理选项,可以锐化画面,调节画面的亮度等等.不止是视频,FFDShow现在同 ...

随机推荐

  1. github pages + Hexo + 域名绑定搭建个人博客

    环境 Windows 10(64 位) Git-2.7.4-64-bit node-v4.4.7-x64 如果上述软件已经安装的,跳过,没有安装的下载安装. 1,git下载安装(https://git ...

  2. Makefile自动生成

    automake/autoconf入门作为Linux下的程序开发人员,大家一定都遇到过Makefile,用make命令来编译自己写的程序确实是很方便.一般情况下,大家都是手工写一个简单Makefile ...

  3. Android简易实战教程--第二十话《通过广播接收者,对拨打电话外加ip号》

    没睡着觉,起来更篇文章吧哈哈!首先祝贺李宗伟击败我丹,虽然我是支持我丹的,但是他也不容易哈哈,值得尊敬的人!切入正题:这一篇来介绍个自定义广播接收者. 通常我们在外拨电话的时候,一般为使用网络电话.如 ...

  4. 安卓开发过程中空指针的问题Java.lang.NullPointerException

    最近做一个新闻客户端的应用,经常出现空指针的问题,我想一方面可能是自己水平有限,二是开发过程中有一些遗漏的地方.一般情况下新手出现空指针的概率较高.下面来总结一下经常出现的问题. 1.所谓的指针,就是 ...

  5. maven隐式依赖引起的包冲突

    包冲突 使用maven管理项目时可能会遇到包冲突的情况比如:log4j-over-slf4j.jar 和 slf4j-log4j12.jar这两个包同时一起运行时就会有问题. 这种冲突可能是显式依赖导 ...

  6. View绘制流程

    1. View 树的绘图流程 当 Activity 接收到焦点的时候,它会被请求绘制布局,该请求由 Android framework 处理.绘制是从根节点开始,对布局树进行 measure 和 dr ...

  7. was unable to start within 45 seconds. If the server requires more time, try increasing the timeout

    在eclipse启动tomcat时遇到超时45秒的问题: Server Tomcat v7.0 Server at localhost was unable to startwithin 45 sec ...

  8. Android进阶(六)文件读操作

    Android中文件的读写操作与Java中文件的读写操作是有区别的.在Java中,读文件操作如以下代码所示: public class FileRead { private static final  ...

  9. WIP完工入库及完工退回的几个重要问题

    1.必须向CST_COMP_SNAP_INTERFACE表中插入此工单所有工序的数据(也就是说同样的工单插入多条,只是工序号不一样) 标准文档: Note: If there are multiple ...

  10. 海量数据挖掘MMDS week6: 决策树Decision Trees

    http://blog.csdn.net/pipisorry/article/details/49445465 海量数据挖掘Mining Massive Datasets(MMDs) -Jure Le ...