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

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. FORM内置系统变量

    常用 和输入焦点有关: SYSTEM.CURSOR_ITEM:返回系统当前正在操作的项名. SYSTEM.CURSOR_RECORD:返回系统当前正在操作的记录行号. SYSTEM.CURSOR_BL ...

  2. [Flask]学习杂记一 Hello程序

    这几天买了本  <Flask Web开发:基于Python的Web应用开发实战>,之前也用过flask 但是不怎么系统,有时候需要搭建一些临时的测试服务,用falsk比较方面,一个文件就可 ...

  3. JSP简单隔行变色和日期格式化

    以前好像在找,都没找到简单点的,所以后面就自己写了一个,感觉超级简单又好理解,分享给大家 <%@ page language="java" import="java ...

  4. Dynamics CRM2015 页面导航栏顶部全局快速查找功能配置

    在CRM2015中微软加入了新的快速查找功能,让你的数据查找更加方便,功能栏如下图所示,直接可以框中输入搜索项进行搜索. 但该功能是需要进行些配置,具体的配置在设置-管理-系统设置中,默认的就是红框中 ...

  5. Python Skelve 库

    在Python中有一个简单的轻量级的类似于Key-value的存储型数据库,那就是Skelve.下面就来一起看一看这个库的简单的使用吧. 小例子 我本人比较喜欢从例子出发,然后再来研究这些内部的行为. ...

  6. TCP连接建立系列 — 客户端接收SYNACK和发送ACK

    主要内容:客户端接收SYNACK.发送ACK,完成连接的建立. 内核版本:3.15.2 我的博客:http://blog.csdn.net/zhangskd 接收入口 tcp_v4_rcv |--&g ...

  7. 【UNIX环境高级编程】文件 IO 操作 一 ( open | close | creat | lseek | write | read )

    博客地址 : http://blog.csdn.net/shulianghan/article/details/46980271 一. 文件打开关闭操作相关函数介绍 1. open 函数 (1) op ...

  8. Aandroid TV 基于Leanback支持最新MD设计的TV开发框架

    原文地址:http://blog.csdn.net/sk719887916 作者:skay 基于6.0最新的API 支持TV的框架 Android 6.0已完美支持TV开发,之前的5.0后Recycl ...

  9. SDL2源代码分析7:显示(SDL_RenderPresent())

    ===================================================== SDL源代码分析系列文章列表: SDL2源代码分析1:初始化(SDL_Init()) SDL ...

  10. iOS中崩溃调试的使用和技巧总结 韩俊强的博客

    每日更新关注:http://weibo.com/hanjunqiang  新浪微博 在iOS开发调试过程中以及上线之后,程序经常会出现崩溃的问题.简单的崩溃还好说,复杂的崩溃就需要我们通过解析Cras ...