コード例 #1
0
ファイル: VideoCapture.cpp プロジェクト: pics860/callcenter
HRESULT CVideoCapture::ConnnectTo(LPCWSTR lpszCapture)
{
	HRESULT hr = S_OK;
	
	// Capture
	
	CComPtr<IBaseFilter> pCapture;
	CreateFilter( lpszCapture, L"Video Capture", &pCapture );
	
	// Compressor
	
	CComPtr<IBaseFilter> pCompressor;
	CreateFilter( CLSID_H263Encoder, L"H.263 Encoder", &pCompressor );
	
	// Renderer
	
	CRtpSenderFilter* pSender = new CRtpSenderFilter(NULL, &hr);
	
	VIDEOINFOHEADER vih;
	ZeroMemory( &vih, sizeof( vih ) );
	vih.bmiHeader.biCompression	= MAKEFOURCC('H','2','6','3');
	pSender->SetupMediaType( &vih );
	
	CComPtr<IBaseFilter> pRenderer;
	pSender->QueryInterface( IID_IBaseFilter, (void**)&pRenderer );
	InstallFilter( pRenderer, L"Video Sender" );
	
	// RenderStream
	
	if ( SUCCEEDED(hr) ) hr =
	m_pCapGraphBuilder->RenderStream( &PIN_CATEGORY_CAPTURE,
		&MEDIATYPE_Video, pCapture, pCompressor, pRenderer );
	
	Run(); return hr;
}
コード例 #2
0
ファイル: image.c プロジェクト: Flameeyes/vlc
static picture_t *ImageFilter( image_handler_t *p_image, picture_t *p_pic,
                               video_format_t *p_fmt, const char *psz_module )
{
    /* Start a filter */
    if( !p_image->p_filter )
    {
        es_format_t fmt;
        es_format_Init( &fmt, VIDEO_ES, p_fmt->i_chroma );
        fmt.video = *p_fmt;

        p_image->p_filter =
            CreateFilter( p_image->p_parent, &fmt, &fmt.video, psz_module );

        if( !p_image->p_filter )
        {
            return NULL;
        }
    }
    else
    {
        /* Filters should handle on-the-fly size changes */
        p_image->p_filter->fmt_in.video = *p_fmt;
        p_image->p_filter->fmt_out.video = *p_fmt;
    }

    picture_Hold( p_pic );

    return p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );
}
コード例 #3
0
ファイル: RenderGraph.cpp プロジェクト: pics860/callcenter
HRESULT CGraphRender::RenderPreview(LPCWSTR lpszCapture, WAVEFORMATEX& pwfx, DWORD nReserved)
{
	HRESULT hr = S_OK;
	
	// Capture
	
	CComPtr<IBaseFilter> pCapture;
	hr = CreateFilter( lpszCapture, L"Audio Renderer", &pCapture );
	
	// Renderer
	
	CComPtr<IBaseFilter> pRenderer;
	
	if ( SUCCEEDED(hr) && pCapture && FAILED(
		hr = m_pGraphBuilder->FindFilterByName( L"Audio Receiver", &pRenderer )) )
	{
		hr = InstallRender( new CRtpReceiverFilter(Payload_Alaw, &pwfx, this), L"Audio Receiver", &pRenderer );
	}
	
	// RenderStream
	
	CComPtr<IPin> pPinOut;
	pRenderer->FindPin( L"Preview", &pPinOut );
	
	hr = m_pGraphBuilder->Render( pPinOut );
	return hr;
}
コード例 #4
0
static filter_t *FindResampler (vlc_object_t *obj,
                                const audio_sample_format_t *infmt,
                                const audio_sample_format_t *outfmt)
{
    return CreateFilter (obj, "audio resampler", "$audio-resampler", NULL,
                         infmt, outfmt);
}
コード例 #5
0
void CPPageExternalFilters::OnDoubleClickFilter()
{
    if (FilterOverride* f = GetCurFilter()) {
        CComPtr<IBaseFilter> pBF;
        CString name;

        if (f->type == FilterOverride::REGISTERED) {
            CStringW namew;
            if (CreateFilter(f->dispname, &pBF, namew)) {
                name = namew;
            }
        } else if (f->type == FilterOverride::EXTERNAL) {
            if (SUCCEEDED(LoadExternalFilter(f->path, f->clsid, &pBF))) {
                name = f->name;
            }
        }

        if (CComQIPtr<ISpecifyPropertyPages> pSPP = pBF) {
            CComPropertySheet ps(name, this);
            if (ps.AddPages(pSPP) > 0) {
                CComPtr<IFilterGraph> pFG;
                if (SUCCEEDED(pFG.CoCreateInstance(CLSID_FilterGraph))) {
                    pFG->AddFilter(pBF, L"");
                }

                ps.DoModal();
            }
        }
    }
}
コード例 #6
0
HRESULT __fastcall CreateAndInsertFilter(	IGraphBuilder *pFilterGraph,
											REFGUID clsidFilter, 
                                            IBaseFilter** ppBaseFilter,
                                            LPCWSTR lpcwstrName)
{
HRESULT hr=S_OK;

    if(!pFilterGraph || !ppBaseFilter )
    {
        return E_POINTER;
    }

    *ppBaseFilter = NULL;

	hr = CreateFilter(clsidFilter, ppBaseFilter);

    if(SUCCEEDED(hr))
    {
        hr = pFilterGraph->AddFilter(*ppBaseFilter, lpcwstrName);
        if(FAILED(hr))
        {   // all or nothing:
			(*ppBaseFilter)->Release();
			*ppBaseFilter = NULL;
        }
    }
    return hr;
}
コード例 #7
0
ファイル: ramwatch.cpp プロジェクト: DavideD/BizHawk
int Change_File_S(char *Dest, char *Dir, char *Titre, char *Filter, char *Ext, HWND hwnd)
{

	WCHAR filter[1024];
	OPENFILENAME ofn;

	CreateFilter(filter, 1024,
		"Watchlist", "*.wch",
		"All files (*.*)", "*.*", NULL);

	SetupOFN(&ofn, OFN_DEFAULTSAVE, hwnd, filter,
		watchfilename, sizeof(watchfilename)/sizeof(TCHAR));
	ofn.lpstrDefExt = (LPCWSTR)_16(Ext);

	if (GetSaveFileName(&ofn)) {

		char text[1024];

		WideCharToMultiByte(CP_ACP, 0, watchfilename, -1, text, sizeof(text), NULL, NULL);
		strcpy(Dest, text);

		return 1;
	}

	return 0;

	/*
	OPENFILENAME ofn;

	SetCurrentDirectory(Gens_Path);

	if (!strcmp(Dest, ""))
	{
	strcpy(Dest, "default.");
	strcat(Dest, Ext);
	}

	memset(&ofn, 0, sizeof(OPENFILENAME));

	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = hwnd;
	ofn.hInstance = y_hInstance;
	ofn.lpstrFile = Dest;
	ofn.nMaxFile = 2047;
	ofn.lpstrFilter = Filter;
	ofn.nFilterIndex = 1;
	ofn.lpstrInitialDir = Dir;
	ofn.lpstrTitle = Titre;
	ofn.lpstrDefExt = Ext;
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;

	if (GetSaveFileName(&ofn)) return 1;

	return 0;
	*/
}
コード例 #8
0
ファイル: firewall.c プロジェクト: Scruf/TestingFireWall
/// The main function. Creates a filter, configures it, launches the
/// filtering thread, handles user input, and cleans up resources when
/// exiting.  The intention is to run this program with a command line
/// argument specifying the configuration file to use.
/// @param argc Number of command line arguments
/// @param argv Command line arguments
/// @return EXIT_SUCCESS or EXIT_FAILURE
int main(int argc, char* argv[])
{
   // TODO: implement function

   char input[20];
   short mode;
   pthread_t filterThread;
   int rc;

   if (argc != 2){
       fprintf(stderr, "usage: firewall <config_file>\n");
       return EXIT_SUCCESS;
   }
   IpPktFilter filter = CreateFilter();
   if (!ConfigureFilter(filter, argv[1])){
       return EXIT_FAILURE;
   }

   rc = pthread_create(&filterThread, NULL, FilterThread, (void*) filter);

   if (rc){
      fprintf(stderr, "Could not create filter thread");
      return EXIT_FAILURE;
   }

   DisplayMenu();
   while(Mode){
      printf("> ");
      char* s = fgets(input, 20 , stdin);
      if (s){};
      mode = ((short) input[0]) -48;

      if (mode == MODE_BLOCK_ALL){
         Mode = MODE_BLOCK_ALL;
      }
      else if (mode == MODE_ALLOW_ALL){
         Mode = MODE_ALLOW_ALL;
      }
      else if (mode == MODE_FILTER){
         Mode = MODE_FILTER;
      }
      else if (mode == 0){
         Mode = 0;
         pthread_join(filterThread, NULL);
         break;
      }

   }

   DestroyFilter(filter);
   return EXIT_SUCCESS;
}
コード例 #9
0
ファイル: RenderGraph.cpp プロジェクト: pics860/callcenter
HRESULT CGraphRender::InstallCapture(LPCWSTR lpszCapture, LPCWSTR lpszName)
{
	HRESULT hr = S_OK;
	CComPtr<IBaseFilter> pCapture;
	
	hr = m_pGraphBuilder->FindFilterByName( lpszName, &pCapture );
	if ( SUCCEEDED( hr ) ) return S_OK;
	
	// Capture
	
	hr = CreateFilter( lpszCapture, lpszName, &pCapture );
	return hr;
}
コード例 #10
0
ファイル: MediaPlayerDlg.cpp プロジェクト: malpharo/AiPI
HRESULT CMediaPlayerDlg::RenderWMFile(LPCWSTR wFile)
{
    HRESULT hr=S_OK;
    IFileSourceFilter *pFS=NULL;
    IBaseFilter *pReader=NULL;

    // Load the improved ASF reader filter by CLSID
    hr = CreateFilter(CLSID_WMAsfReader, &pReader);
    if(FAILED(hr))
    {
        MPRetailOutput(TEXT("Failed to create WMAsfWriter filter!  hr=0x%x\n"), hr);
        return hr;
    }

    // Add the ASF reader filter to the graph.  For ASF/WMV/WMA content,
    // this filter is NOT the default and must be added explicitly.
    hr = pGB_MP->AddFilter(pReader, L"ASF Reader");
    if(FAILED(hr))
    {
        MPRetailOutput(TEXT("Failed to add ASF reader filter to graph!  hr=0x%x\n"), hr);
        pReader->Release();
        return hr;
    }

//
// Windows Media 9 Series (code named 'Corona') no longer requires
// a stub library.  If using WMF9, we don't need to provide a CKeyProvider
// implementation, and we don't need to link with the WMStub.lib library.
//
#ifndef TARGET_WMF9
    // Create the key provider that will be used to unlock the WM SDK
    JIF(AddKeyProvider(pGB_MP));
#endif

    // Set its source filename
    JIF(pReader->QueryInterface(IID_IFileSourceFilter, (void **) &pFS));
    JIF(pFS->Load(wFile, NULL));
    pFS->Release();


CLEANUP:
    // If there was a rendering error, make sure that the reader is released
    //
    // Otherwise, wince the graph is built and the filters are added to
    // the graph, the WM ASF reader interface can be released.
    SAFE_RELEASE(pReader);

    return hr;
}
コード例 #11
0
ファイル: DShowControl.cpp プロジェクト: enildne/zest
HRESULT CDShowControl::CreateMoviePlayGraph(HWND hWnd, CString fileName)
{
	HRESULT hr;
	CComPtr<IEnumPins> pEnumPins, pEnumPins2;
	IPin *pPin = NULL;
	PIN_DIRECTION direction;
	BOOL isSuccess = FALSE;
	CComPtr<IBaseFilter> pWMVReader;

	ReleaseMoviePlayGraph();
	RETURNIF(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
	RETURNIF(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&m_moviePlayGraph));
	CoUninitialize();

	RETURNIF(CreateFilter(L"WM ASF Reader",&pWMVReader,FILTERCG_DSHOW));
	CComQIPtr<IFileSourceFilter> pFileSrcFilter(pWMVReader);
	pFileSrcFilter->Load(fileName.AllocSysString(),NULL);	
	RETURNIF(m_moviePlayGraph->AddFilter(pWMVReader,L"WMVReader"));

	RETURNIF(pWMVReader->EnumPins(&pEnumPins));
	while (pEnumPins->Next(1, &pPin, 0) == S_OK)
	{
		RETURNIF(pPin->QueryDirection(&direction));
		if (direction == PINDIR_OUTPUT)
		{		
			m_moviePlayGraph->Render(pPin);	
		}
		SAFE_RELEASE(pPin);
	} 

	CComQIPtr<IVideoWindow>pVW(m_moviePlayGraph);
	if (pVW != NULL)
	{
		CComQIPtr<IBasicVideo> pBV(m_moviePlayGraph);
		CRect rect,videoRect;
		RETURNIF(pVW->put_Owner((OAHWND)hWnd));
		RETURNIF(pVW->put_WindowStyle(WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS));
		RETURNIF(pVW->put_MessageDrain((long)hWnd));

		CRect ClientRect;
		::GetClientRect(hWnd, &ClientRect);
		pVW->SetWindowPosition(0, 0, ClientRect.Width(), ClientRect.Height());
		pVW->put_AutoShow(OATRUE);
		pVW->put_Visible(OATRUE);
	}

	return S_OK;
}
コード例 #12
0
ファイル: filter.c プロジェクト: Saner2oo2/descrambler
cPidFilter *cAction::NewFilter(int IdleTime)
{
  Lock();
  cPidFilter *filter=CreateFilter(unique++,IdleTime);
  if(filter) {
    if(!Active()) {
      Start();
      PRINTF(L_CORE_ACTION,"%s: started",id);
      }
    filters.Add(filter);
    }
  else
    PRINTF(L_CORE_ACTION,"%s: failed to create filter",id);
  Unlock();
  return filter;
}
コード例 #13
0
ファイル: RenderGraph.cpp プロジェクト: pics860/callcenter
HRESULT CGraphRender::RenderPreview(LPCWSTR lpszCapture, WAVEFORMATEX& pwfx)
{
	HRESULT hr = S_OK;
	
	// Capture
	
	CComPtr<IBaseFilter> pCapture;
	hr = CreateFilter( lpszCapture, L"Audio Capture", &pCapture );
	
	// RenderStream
	
	if ( SUCCEEDED(hr) ) hr =
	m_pCapGraphBuilder->RenderStream( &PIN_CATEGORY_PREVIEW,
		&MEDIATYPE_Audio, pCapture, NULL, NULL );
	
	return hr;
}
コード例 #14
0
ファイル: PathGenerator.cpp プロジェクト: Remix99/Arena_TC
////////////////// PathGenerator //////////////////
PathGenerator::PathGenerator(const Unit* owner) :
    _polyLength(0), _type(PATHFIND_BLANK),
    _useStraightPath(false), _forceDestination(false), _pointPathLimit(MAX_POINT_PATH_LENGTH),
    _sourceUnit(owner), _navMesh(NULL), _navMeshQuery(NULL), _endPosition(Vector3::zero())
{
    sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::PathGenerator for %u \n", _sourceUnit->GetGUIDLow());

    uint32 mapId = _sourceUnit->GetMapId();
    if (MMAP::MMapFactory::IsPathfindingEnabled(mapId))
    {
        MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager();
        _navMesh = mmap->GetNavMesh(mapId);
        _navMeshQuery = mmap->GetNavMeshQuery(mapId, _sourceUnit->GetInstanceId());
    }

    CreateFilter();
}
コード例 #15
0
ファイル: RenderGraph.cpp プロジェクト: pics860/callcenter
HRESULT CGraphRender::RenderPreview(LPCWSTR lpszCapture, VIDEOINFOHEADER& pvih)
{
	HRESULT hr = S_OK;
	
	// Capture
	
	CComPtr<IBaseFilter> pCapture;
	hr = CreateFilter( lpszCapture, L"Video Capture", &pCapture );
	
	// RenderStream
	
	if ( SUCCEEDED(hr) ) hr =
	m_pCapGraphBuilder->RenderStream( &PIN_CATEGORY_PREVIEW,
		&MEDIATYPE_Video, pCapture, NULL, NULL );
	
	return hr;
}
コード例 #16
0
nsresult
nsBeckyFilters::ParseFilterFile(nsIFile *aFile, bool aIncoming)
{
  nsresult rv;
  nsCOMPtr<nsILineInputStream> lineStream;
  rv = nsBeckyUtils::CreateLineInputStream(aFile, getter_AddRefs(lineStream));
  NS_ENSURE_SUCCESS(rv, rv);

  bool more = true;
  nsAutoCString line;

  nsCOMPtr<nsIMsgFilter> filter;
  while (NS_SUCCEEDED(rv) && more) {
    rv = lineStream->ReadLine(line, &more);

    switch (line.CharAt(0)) {
      case ':':
        if (line.EqualsLiteral(":Begin \"\"")) {
          CreateFilter(aIncoming, getter_AddRefs(filter));
        } else if (line.EqualsLiteral(":End \"\"")) {
          if (filter)
            AppendFilter(filter);
          filter = nullptr;
        }
        break;
      case '!':
        SetRuleAction(line, filter);
        break;
      case '@':
        SetSearchTerm(line, filter);
        break;
      case '$': // $X: disabled
        if (StringBeginsWith(line, NS_LITERAL_CSTRING("$X")) && filter) {
          filter->SetEnabled(false);
        }
        break;
      default:
        break;
    }
  }

  return NS_OK;
}
コード例 #17
0
ファイル: filter.c プロジェクト: attuska/Sasc-ng
cPidFilter *cAction::NewFilter(int IdleTime)
{
  Lock();
  cPidFilter *filter=CreateFilter(id,unique++,dvbNum,IdleTime);
  if(filter && filter->Open()) {
    if(!Active()) {
      Start();
      PRINTF(L_CORE_ACTION,"%s: started",id);
      }
    filters.Add(filter);
    }
  else {
    PRINTF(L_CORE_ACTION,"%s: filter '%s' failed to open",id,filter?filter->id:"XxX");
    delete filter;
    filter=0;
    }
  Unlock();
  return filter;
}
コード例 #18
0
ファイル: PathGenerator.cpp プロジェクト: Adiss/wowserver
////////////////// PathGenerator //////////////////
PathGenerator::PathGenerator(const Unit* owner) :
    _polyLength(0), _type(PATHFIND_BLANK), _useStraightPath(false),
    _forceDestination(false), _pointPathLimit(MAX_POINT_PATH_LENGTH), _straightLine(false),
    _endPosition(G3D::Vector3::zero()), _sourceUnit(owner), _navMesh(NULL),
    _navMeshQuery(NULL)
{
    memset(_pathPolyRefs, 0, sizeof(_pathPolyRefs));

    TC_LOG_DEBUG("maps", "++ PathGenerator::PathGenerator for %u \n", _sourceUnit->GetGUIDLow());

    uint32 mapId = _sourceUnit->GetMapId();
    if (MMAP::MMapFactory::IsPathfindingEnabled(mapId))
    {
        MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager();
        _navMesh = mmap->GetNavMesh(mapId);
        _navMeshQuery = mmap->GetNavMeshQuery(mapId, _sourceUnit->GetInstanceId());
    }

    CreateFilter();
}
コード例 #19
0
CC_FILE_ERROR FileIOFilter::SaveToFile(ccHObject* entities, const char* filename, CC_FILE_TYPES fType)
{
    if (!entities || !filename || fType == UNKNOWN_FILE)
        return CC_FERR_BAD_ARGUMENT;

	FileIOFilter* fio = CreateFilter(fType);
	if (!fio)
        return CC_FERR_WRONG_FILE_TYPE;

    //if the file name has no extension, we had a default one!
    QString completeFileName(filename);
	if (QFileInfo(filename).suffix().isEmpty())
        completeFileName += QString(".%1").arg(CC_FILE_TYPE_DEFAULT_EXTENSION[fType]);

    CC_FILE_ERROR result = fio->saveToFile(entities, qPrintable(completeFileName));

    delete fio;
    fio = 0;

    return result;
}
コード例 #20
0
ファイル: VideoRenderer.cpp プロジェクト: pics860/callcenter
HRESULT CVideoRenderer::StartPreview(const RECT& rect, HWND hWnd)
{
	StopPreview();
	
	CComPtr<IBaseFilter> pSmartTee;
	m_pGraphBuilder->FindFilterByName( L"Smart Tee", &pSmartTee );
	
	// Compressor
	
	CComPtr<IBaseFilter> pCompressor;
	CreateFilter( CLSID_H263Decoder, L"H.263 Decoder", &pCompressor );
	
	CComPtr<IPin> pPinOut;
	pSmartTee->FindPin( L"Preview", &pPinOut );
	
	if ( SUCCEEDED( m_pGraphBuilder->Render( pPinOut ) ) )
	{
		PutIntoWindow( hWnd, rect, TRUE );
	}
	
	return Run();
}
コード例 #21
0
ファイル: VideoRenderer.cpp プロジェクト: pics860/callcenter
HRESULT CVideoRenderer::Connnect()
{
	HRESULT hr = S_OK;
	
	// Capture
	
	CRtpReceiverFilter* pReceiver = new CRtpReceiverFilter(NULL, &hr);
	
	VIDEOINFOHEADER vih;
	ZeroMemory( &vih, sizeof( vih ) );
	vih.bmiHeader.biCompression	= MAKEFOURCC('H','2','6','3');
	pReceiver->SetupMediaType( &vih );
	
	CComPtr<IBaseFilter> pCapture;
	pReceiver->QueryInterface( IID_IBaseFilter, (void**)&pCapture );
	InstallFilter( pCapture, L"Video Receiver" );
	
	// RenderStream
	
	CComPtr<IBaseFilter> pSmartTee;
	CreateFilter( CLSID_SmartTee, L"Smart Tee", &pSmartTee );
	
	return ConnectFilter( pCapture, pSmartTee );
}
コード例 #22
0
ファイル: RenderGraph.cpp プロジェクト: pics860/callcenter
HRESULT CGraphRender::RenderStream(LPCWSTR lpszCapture, WAVEFORMATEX& pwfx)
{
	HRESULT hr = S_OK;
	
	// Capture
	
	CComPtr<IBaseFilter> pCapture;
	hr = CreateFilter( lpszCapture, L"Audio Capture", &pCapture );
	
	// Renderer
	
	CComPtr<IBaseFilter> pRenderer;
	
	if ( SUCCEEDED(hr) && pCapture )
	hr = InstallRender( new CRtpSenderFilter(Payload_Alaw, &pwfx, &hr), L"Audio Sender", &pRenderer );
	
	// RenderStream
	
	if ( SUCCEEDED(hr) ) hr =
	m_pCapGraphBuilder->RenderStream( &PIN_CATEGORY_CAPTURE,
		&MEDIATYPE_Audio, pCapture, NULL, pRenderer );
	
	Run();return hr;
}
コード例 #23
0
ファイル: RenderGraph.cpp プロジェクト: pics860/callcenter
HRESULT CGraphRender::RenderStream(LPCWSTR lpszCapture, VIDEOINFOHEADER& pvih)
{
	HRESULT hr = S_OK;
	
	// Capture
	
	CComPtr<IBaseFilter> pCapture;
	hr = CreateFilter( lpszCapture, L"Video Capture", &pCapture );
	
	// Renderer
	
	CComPtr<IBaseFilter> pRenderer;
	
	if ( SUCCEEDED(hr) && pCapture )
	hr = InstallRender( new CRtpSenderFilter(Payload_H263, &pvih, &hr), L"Video Sender", &pRenderer );
	
	// RenderStream
	
	if ( SUCCEEDED(hr) ) hr =
	m_pCapGraphBuilder->RenderStream( &PIN_CATEGORY_CAPTURE,
		&MEDIATYPE_Video, pCapture, NULL, pRenderer );
	
	Run();return hr;
}
コード例 #24
0
ファイル: settings-log.c プロジェクト: DavideD/BizHawk
LRESULT CALLBACK LogSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
                                    LPARAM lParam)
{
   switch (uMsg)
   {
      case WM_INITDIALOG:
      {
         // Setup use log setting
         SendDlgItemMessage(hDlg, IDC_USELOGCB, BM_SETCHECK, uselog ? BST_CHECKED : BST_UNCHECKED, 0);
         SendMessage(hDlg, WM_COMMAND, IDC_USELOGCB, 0);

         // Setup log type setting
         SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_RESETCONTENT, 0, 0);
         SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_ADDSTRING, 0, (LPARAM)_16("Write to File"));
         SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_ADDSTRING, 0, (LPARAM)_16("Write to Window"));
         SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_SETCURSEL, logtype, 0);

         // Setup log filename setting
         SetDlgItemText(hDlg, IDC_LOGFILENAMEET, _16(logfilename));

         // mini18n log settings
         SendDlgItemMessage(hDlg, IDC_USEMINI18NLOG, BM_SETCHECK, usemini18nlog ? BST_CHECKED : BST_UNCHECKED, 0);

         return TRUE;
      }
      case WM_COMMAND:
      {
         switch (LOWORD(wParam))
         {
            case IDC_USELOGCB:
            {
               if (SendDlgItemMessage(hDlg, LOWORD(wParam), BM_GETCHECK, 0, 0) == BST_CHECKED)
               {
                  SendMessage(hDlg, WM_COMMAND, (CBN_SELCHANGE << 16) | IDC_LOGTYPECB, 0);
                  EnableWindow(GetDlgItem(hDlg, IDC_LOGTYPECB), TRUE);
               }
               else
               {
                  EnableWindow(GetDlgItem(hDlg, IDC_LOGTYPECB), FALSE);
                  EnableWindow(GetDlgItem(hDlg, IDC_LOGFILENAMEET), FALSE);
                  EnableWindow(GetDlgItem(hDlg, IDC_LOGBROWSEBT), FALSE);
               }

               return TRUE;
            }
            case IDC_LOGTYPECB:
            {
               switch(HIWORD(wParam))
               {
                  case CBN_SELCHANGE:
                  {
                     if (SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_GETCURSEL, 0, 0) == 0)
                     {
                        EnableWindow(GetDlgItem(hDlg, IDC_LOGFILENAMEET), TRUE);
                        EnableWindow(GetDlgItem(hDlg, IDC_LOGBROWSEBT), TRUE);
                     }
                     else
                     {
                        EnableWindow(GetDlgItem(hDlg, IDC_LOGFILENAMEET), FALSE);
                        EnableWindow(GetDlgItem(hDlg, IDC_LOGBROWSEBT), FALSE);
                     }

                     return TRUE;
                  }
                  default: break;
               }

               return TRUE;
            }
            case IDC_LOGBROWSEBT:
            {
               WCHAR tempwstr[MAX_PATH];
               WCHAR filter[1024];
               OPENFILENAME ofn;

               // setup ofn structure
               ZeroMemory(&ofn, sizeof(ofn));
               ofn.lStructSize = sizeof(ofn);
               ofn.hwndOwner = hDlg;

               CreateFilter(filter, 1024,
                  "Text Files", "*.txt",
                  "All Files", "*.*", NULL);

               ofn.lpstrFilter = filter;
               ofn.nFilterIndex = 1;
               GetDlgItemText(hDlg, IDC_LOGFILENAMEET, tempwstr, MAX_PATH);
               ofn.lpstrFile = tempwstr;
               ofn.nMaxFile = sizeof(tempwstr)/sizeof(WCHAR);
               ofn.Flags = OFN_OVERWRITEPROMPT;
               ofn.lpstrDefExt = _16("TXT");

               if (GetSaveFileName(&ofn))
               {
                  SetDlgItemText(hDlg, IDC_LOGFILENAMEET, tempwstr);
                  WideCharToMultiByte(CP_ACP, 0, tempwstr, -1, logfilename, MAX_PATH, NULL, NULL);
               }

               return TRUE;
            }
            case IDC_USEMINI18NLOG:
            {
               BOOL enabled;

               enabled = SendDlgItemMessage(hDlg, LOWORD(wParam), BM_GETCHECK, 0, 0) == BST_CHECKED ? TRUE : FALSE;

               EnableWindow(GetDlgItem(hDlg, IDC_MINI18NLOGFILENAME), enabled);
               EnableWindow(GetDlgItem(hDlg, IDC_MINI18NLOGBROWSE), enabled);

               return TRUE;
            }
            case IDC_MINI18NLOGBROWSE:
            {
               WCHAR tempwstr[MAX_PATH];
               WCHAR filter[1024];
               OPENFILENAME ofn;

               // setup ofn structure
               ZeroMemory(&ofn, sizeof(ofn));
               ofn.lStructSize = sizeof(ofn);
               ofn.hwndOwner = hDlg;

               CreateFilter(filter, 1024,
                  "Yabause Translation Files", "*.YTS",
                  "All Files", "*.*", NULL);

               ofn.lpstrFilter = filter;
               ofn.nFilterIndex = 1;
               GetDlgItemText(hDlg, IDC_MINI18NLOGFILENAME, tempwstr, MAX_PATH);
               ofn.lpstrFile = tempwstr;
               ofn.nMaxFile = sizeof(tempwstr)/sizeof(WCHAR);
               ofn.Flags = OFN_OVERWRITEPROMPT;
               ofn.lpstrDefExt = _16("YTS");

               if (GetSaveFileName(&ofn))
               {
                  SetDlgItemText(hDlg, IDC_MINI18NLOGFILENAME, tempwstr);
                  WideCharToMultiByte(CP_ACP, 0, tempwstr, -1, logfilename, MAX_PATH, NULL, NULL);
               }

               return TRUE;
            }
            default: break;
         }

         break;
      }
      case WM_NOTIFY:
     		switch (((NMHDR *) lParam)->code) 
    		{
				case PSN_SETACTIVE:
					break;

				case PSN_APPLY:
            {
               char tempstr[MAX_PATH];

               // Write use log setting
               if (SendDlgItemMessage(hDlg, IDC_USELOGCB, BM_GETCHECK, 0, 0) == BST_CHECKED)
                  uselog = 1;
               else
                  uselog = 0;

               sprintf(tempstr, "%d", uselog);
               WritePrivateProfileStringA("Log", "Enable", tempstr, inifilename);

               // Write log type setting
               logtype = (int)SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_GETCURSEL, 0, 0);
               sprintf(tempstr, "%d", logtype);
               WritePrivateProfileStringA("Log", "Type", tempstr, inifilename);

               // Write log filename
               WritePrivateProfileStringA("Log", "Filename", logfilename, inifilename);

               // Write use mini18n log setting
               if (SendDlgItemMessage(hDlg, IDC_USELOGCB, BM_GETCHECK, 0, 0) == BST_CHECKED)
                  usemini18nlog = 1;
               else
                  usemini18nlog = 0;

               sprintf(tempstr, "%d", usemini18nlog);
               WritePrivateProfileStringA("Mini18nLog", "Enable", tempstr, inifilename);

               // Write mini18n log filename
               WritePrivateProfileStringA("Mini18nLog", "Filename", mini18nlogfilename, inifilename);

          		SetWindowLong(hDlg,	DWL_MSGRESULT, PSNRET_NOERROR);
					break;
            }
				case PSN_KILLACTIVE:
	        		SetWindowLong(hDlg,	DWL_MSGRESULT, FALSE);
   				return 1;
					break;
				case PSN_RESET:
					break;
        	}
         break;
      case WM_DESTROY:
      {
         break;
      }
      default: break;
   }

   return FALSE;
}
コード例 #25
0
static filter_t *FindConverter (vlc_object_t *obj,
                                const audio_sample_format_t *infmt,
                                const audio_sample_format_t *outfmt)
{
    return CreateFilter (obj, "audio converter", NULL, NULL, infmt, outfmt);
}
コード例 #26
0
ファイル: image.c プロジェクト: BossKing/vlc
static picture_t *ImageConvert( image_handler_t *p_image, picture_t *p_pic,
                                video_format_t *p_fmt_in,
                                video_format_t *p_fmt_out )
{
    picture_t *p_pif;

    if( !p_fmt_out->i_width && !p_fmt_out->i_height &&
        p_fmt_out->i_sar_num && p_fmt_out->i_sar_den &&
        p_fmt_out->i_sar_num * p_fmt_in->i_sar_den !=
        p_fmt_out->i_sar_den * p_fmt_in->i_sar_num )
    {
        p_fmt_out->i_width =
            p_fmt_in->i_sar_num * (int64_t)p_fmt_out->i_sar_den *
            p_fmt_in->i_width / p_fmt_in->i_sar_den / p_fmt_out->i_sar_num;
        p_fmt_out->i_visible_width =
            p_fmt_in->i_sar_num * (int64_t)p_fmt_out->i_sar_den *
            p_fmt_in->i_visible_width / p_fmt_in->i_sar_den /
            p_fmt_out->i_sar_num;
    }

    if( !p_fmt_out->i_chroma ) p_fmt_out->i_chroma = p_fmt_in->i_chroma;
    if( !p_fmt_out->i_width )
        p_fmt_out->i_width = p_fmt_out->i_visible_width = p_fmt_in->i_width;
    if( !p_fmt_out->i_height )
        p_fmt_out->i_height = p_fmt_out->i_visible_height = p_fmt_in->i_height;
    if( !p_fmt_out->i_sar_num ) p_fmt_out->i_sar_num = p_fmt_in->i_sar_num;
    if( !p_fmt_out->i_sar_den ) p_fmt_out->i_sar_den = p_fmt_in->i_sar_den;

    if( p_image->p_filter )
    if( p_image->p_filter->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
        p_image->p_filter->fmt_out.video.i_chroma != p_fmt_out->i_chroma )
    {
        /* We need to restart a new filter */
        DeleteFilter( p_image->p_filter );
        p_image->p_filter = NULL;
    }

    /* Start a filter */
    if( !p_image->p_filter )
    {
        es_format_t fmt_in;
        es_format_Init( &fmt_in, VIDEO_ES, p_fmt_in->i_chroma );
        fmt_in.video = *p_fmt_in;

        p_image->p_filter =
            CreateFilter( p_image->p_parent, &fmt_in, p_fmt_out );

        if( !p_image->p_filter )
        {
            return NULL;
        }
    }
    else
    {
        /* Filters should handle on-the-fly size changes */
        p_image->p_filter->fmt_in.video = *p_fmt_in;
        p_image->p_filter->fmt_out.video = *p_fmt_out;
    }

    picture_Hold( p_pic );

    p_pif = p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );

    if( p_fmt_in->i_chroma == p_fmt_out->i_chroma &&
        p_fmt_in->i_width == p_fmt_out->i_width &&
        p_fmt_in->i_height == p_fmt_out->i_height )
    {
        /* Duplicate image */
        picture_Release( p_pif ); /* XXX: Better fix must be possible */
        p_pif = filter_NewPicture( p_image->p_filter );
        if( p_pif )
            picture_Copy( p_pif, p_pic );
    }

    return p_pif;
}
コード例 #27
0
ファイル: image.c プロジェクト: BossKing/vlc
static block_t *ImageWrite( image_handler_t *p_image, picture_t *p_pic,
                            video_format_t *p_fmt_in,
                            video_format_t *p_fmt_out )
{
    block_t *p_block;

    /* Check if we can reuse the current encoder */
    if( p_image->p_enc &&
        ( p_image->p_enc->fmt_out.i_codec != p_fmt_out->i_chroma ||
          p_image->p_enc->fmt_out.video.i_width != p_fmt_out->i_width ||
          p_image->p_enc->fmt_out.video.i_height != p_fmt_out->i_height ) )
    {
        DeleteEncoder( p_image->p_enc );
        p_image->p_enc = 0;
    }

    /* Start an encoder */
    if( !p_image->p_enc )
    {
        p_image->p_enc = CreateEncoder( p_image->p_parent,
                                        p_fmt_in, p_fmt_out );
        if( !p_image->p_enc ) return NULL;
    }

    /* Check if we need chroma conversion or resizing */
    if( p_image->p_enc->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
        p_image->p_enc->fmt_in.video.i_width != p_fmt_in->i_width ||
        p_image->p_enc->fmt_in.video.i_height != p_fmt_in->i_height )
    {
        picture_t *p_tmp_pic;

        if( p_image->p_filter )
        if( p_image->p_filter->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
            p_image->p_filter->fmt_out.video.i_chroma !=
            p_image->p_enc->fmt_in.video.i_chroma )
        {
            /* We need to restart a new filter */
            DeleteFilter( p_image->p_filter );
            p_image->p_filter = 0;
        }

        /* Start a filter */
        if( !p_image->p_filter )
        {
            es_format_t fmt_in;
            es_format_Init( &fmt_in, VIDEO_ES, p_fmt_in->i_chroma );
            fmt_in.video = *p_fmt_in;

            p_image->p_filter =
                CreateFilter( p_image->p_parent, &fmt_in,
                              &p_image->p_enc->fmt_in.video );

            if( !p_image->p_filter )
            {
                return NULL;
            }
        }
        else
        {
            /* Filters should handle on-the-fly size changes */
            p_image->p_filter->fmt_in.i_codec = p_fmt_in->i_chroma;
            p_image->p_filter->fmt_out.video = *p_fmt_in;
            p_image->p_filter->fmt_out.i_codec =p_image->p_enc->fmt_in.i_codec;
            p_image->p_filter->fmt_out.video = p_image->p_enc->fmt_in.video;
        }

        picture_Hold( p_pic );

        p_tmp_pic =
            p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );

        if( likely(p_tmp_pic != NULL) )
        {
            p_block = p_image->p_enc->pf_encode_video( p_image->p_enc,
                                                       p_tmp_pic );
            picture_Release( p_tmp_pic );
        }
        else
            p_block = NULL;
    }
    else
    {
        p_block = p_image->p_enc->pf_encode_video( p_image->p_enc, p_pic );
    }

    if( !p_block )
    {
        msg_Dbg( p_image->p_parent, "no image encoded" );
        return 0;
    }

    return p_block;
}
コード例 #28
0
ファイル: image.c プロジェクト: BossKing/vlc
static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
                             video_format_t *p_fmt_in,
                             video_format_t *p_fmt_out )
{
    picture_t *p_pic = NULL, *p_tmp;

    /* Check if we can reuse the current decoder */
    if( p_image->p_dec &&
        p_image->p_dec->fmt_in.i_codec != p_fmt_in->i_chroma )
    {
        DeleteDecoder( p_image->p_dec );
        p_image->p_dec = 0;
    }

    /* Start a decoder */
    if( !p_image->p_dec )
    {
        p_image->p_dec = CreateDecoder( p_image->p_parent, p_fmt_in );
        if( !p_image->p_dec )
        {
            block_Release(p_block);
            return NULL;
        }
    }

    p_block->i_pts = p_block->i_dts = mdate();
    while( (p_tmp = p_image->p_dec->pf_decode_video( p_image->p_dec, &p_block ))
             != NULL )
    {
        if( p_pic != NULL )
            picture_Release( p_pic );
        p_pic = p_tmp;
    }

    if( p_pic == NULL )
    {
        msg_Warn( p_image->p_parent, "no image decoded" );
        return 0;
    }

    if( !p_fmt_out->i_chroma )
        p_fmt_out->i_chroma = p_image->p_dec->fmt_out.video.i_chroma;
    if( !p_fmt_out->i_width && p_fmt_out->i_height )
        p_fmt_out->i_width = (int64_t)p_image->p_dec->fmt_out.video.i_width *
                             p_image->p_dec->fmt_out.video.i_sar_num *
                             p_fmt_out->i_height /
                             p_image->p_dec->fmt_out.video.i_height /
                             p_image->p_dec->fmt_out.video.i_sar_den;

    if( !p_fmt_out->i_height && p_fmt_out->i_width )
        p_fmt_out->i_height = (int64_t)p_image->p_dec->fmt_out.video.i_height *
                              p_image->p_dec->fmt_out.video.i_sar_den *
                              p_fmt_out->i_width /
                              p_image->p_dec->fmt_out.video.i_width /
                              p_image->p_dec->fmt_out.video.i_sar_num;
    if( !p_fmt_out->i_width )
        p_fmt_out->i_width = p_image->p_dec->fmt_out.video.i_width;
    if( !p_fmt_out->i_height )
        p_fmt_out->i_height = p_image->p_dec->fmt_out.video.i_height;
    if( !p_fmt_out->i_visible_width )
        p_fmt_out->i_visible_width = p_fmt_out->i_width;
    if( !p_fmt_out->i_visible_height )
        p_fmt_out->i_visible_height = p_fmt_out->i_height;

    /* Check if we need chroma conversion or resizing */
    if( p_image->p_dec->fmt_out.video.i_chroma != p_fmt_out->i_chroma ||
        p_image->p_dec->fmt_out.video.i_width != p_fmt_out->i_width ||
        p_image->p_dec->fmt_out.video.i_height != p_fmt_out->i_height )
    {
        if( p_image->p_filter )
        if( p_image->p_filter->fmt_in.video.i_chroma !=
            p_image->p_dec->fmt_out.video.i_chroma ||
            p_image->p_filter->fmt_out.video.i_chroma != p_fmt_out->i_chroma )
        {
            /* We need to restart a new filter */
            DeleteFilter( p_image->p_filter );
            p_image->p_filter = 0;
        }

        /* Start a filter */
        if( !p_image->p_filter )
        {
            p_image->p_filter =
                CreateFilter( p_image->p_parent, &p_image->p_dec->fmt_out,
                              p_fmt_out );

            if( !p_image->p_filter )
            {
                picture_Release( p_pic );
                return NULL;
            }
        }
        else
        {
            /* Filters should handle on-the-fly size changes */
            p_image->p_filter->fmt_in = p_image->p_dec->fmt_out;
            p_image->p_filter->fmt_out = p_image->p_dec->fmt_out;
            p_image->p_filter->fmt_out.i_codec = p_fmt_out->i_chroma;
            p_image->p_filter->fmt_out.video = *p_fmt_out;
        }

        p_pic = p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );
        *p_fmt_out = p_image->p_filter->fmt_out.video;
    }
    else *p_fmt_out = p_image->p_dec->fmt_out.video;

    return p_pic;
}
コード例 #29
0
ファイル: dxva2.c プロジェクト: joshkosh/vlc
static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
                const es_format_t *fmt, picture_sys_t *p_sys)
{
    int err = VLC_EGENERIC;
    directx_sys_t *dx_sys;

    if (pix_fmt != AV_PIX_FMT_DXVA2_VLD)
        return VLC_EGENERIC;

    vlc_va_sys_t *sys = calloc(1, sizeof (*sys));
    if (unlikely(sys == NULL))
        return VLC_ENOMEM;

    /* Load dll*/
    sys->hd3d9_dll = LoadLibrary(TEXT("D3D9.DLL"));
    if (!sys->hd3d9_dll) {
        msg_Warn(va, "cannot load d3d9.dll");
        goto error;
    }

    dx_sys = &sys->dx_sys;

    dx_sys->pf_check_device            = CheckDevice;
    dx_sys->pf_create_device           = D3dCreateDevice;
    dx_sys->pf_destroy_device          = D3dDestroyDevice;
    dx_sys->pf_create_device_manager   = D3dCreateDeviceManager;
    dx_sys->pf_destroy_device_manager  = D3dDestroyDeviceManager;
    dx_sys->pf_create_video_service    = DxCreateVideoService;
    dx_sys->pf_destroy_video_service   = DxDestroyVideoService;
    dx_sys->pf_create_decoder_surfaces = DxCreateVideoDecoder;
    dx_sys->pf_destroy_surfaces        = DxDestroyVideoDecoder;
    dx_sys->pf_setup_avcodec_ctx       = SetupAVCodecContext;
    dx_sys->pf_get_input_list          = DxGetInputList;
    dx_sys->pf_setup_output            = DxSetupOutput;
    dx_sys->pf_alloc_surface_pic       = DxAllocPicture;
    dx_sys->psz_decoder_dll            = TEXT("DXVA2.DLL");

    va->sys = sys;

    dx_sys->d3ddev = NULL;
    if (p_sys!=NULL)
        IDirect3DSurface9_GetDevice(p_sys->surface, (IDirect3DDevice9**) &dx_sys->d3ddev );

    err = directx_va_Open(va, &sys->dx_sys, ctx, fmt, true);
    if (err!=VLC_SUCCESS)
        goto error;

    if (p_sys == NULL)
    {
        sys->filter = CreateFilter( VLC_OBJECT(va), fmt, VLC_CODEC_YV12);
        if (sys->filter == NULL)
            goto error;
    }

    err = directx_va_Setup(va, &sys->dx_sys, ctx);
    if (err != VLC_SUCCESS)
        goto error;

    ctx->hwaccel_context = &sys->hw;

    /* TODO print the hardware name/vendor for debugging purposes */
    va->description = DxDescribe(sys);
    va->setup   = Setup;
    va->get     = Get;
    va->release = directx_va_Release;
    va->extract = Extract;
    return VLC_SUCCESS;

error:
    Close(va, ctx);
    return VLC_EGENERIC;
}
コード例 #30
0
ファイル: image.c プロジェクト: tguillem/vlc
static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
                             const video_format_t *p_fmt_in,
                             video_format_t *p_fmt_out )
{
    picture_t *p_pic = NULL;

    /* Check if we can reuse the current decoder */
    if( p_image->p_dec &&
        p_image->p_dec->fmt_in.i_codec != p_fmt_in->i_chroma )
    {
        DeleteDecoder( p_image->p_dec );
        p_image->p_dec = 0;
    }

    /* Start a decoder */
    if( !p_image->p_dec )
    {
        p_image->p_dec = CreateDecoder( p_image->p_parent, p_fmt_in );
        if( !p_image->p_dec )
        {
            block_Release(p_block);
            return NULL;
        }
        if( p_image->p_dec->fmt_out.i_cat != VIDEO_ES )
        {
            DeleteDecoder( p_image->p_dec );
            p_image->p_dec = NULL;
            block_Release(p_block);
            return NULL;
        }
        p_image->p_dec->pf_queue_video = ImageQueueVideo;
        p_image->p_dec->p_queue_ctx = p_image;
    }

    p_block->i_pts = p_block->i_dts = mdate();
    int ret = p_image->p_dec->pf_decode( p_image->p_dec, p_block );
    if( ret == VLCDEC_SUCCESS )
    {
        /* Drain */
        p_image->p_dec->pf_decode( p_image->p_dec, NULL );

        p_pic = picture_fifo_Pop( p_image->outfifo );

        unsigned lostcount = 0;
        picture_t *lostpic;
        while( ( lostpic = picture_fifo_Pop( p_image->outfifo ) ) != NULL )
        {
            picture_Release( lostpic );
            lostcount++;
        }
        if( lostcount > 0 )
            msg_Warn( p_image->p_parent, "Image decoder output more than one "
                      "picture (%d)", lostcount );
    }

    if( p_pic == NULL )
    {
        msg_Warn( p_image->p_parent, "no image decoded" );
        return 0;
    }

    if( !p_fmt_out->i_chroma )
        p_fmt_out->i_chroma = p_image->p_dec->fmt_out.video.i_chroma;
    if( !p_fmt_out->i_width && p_fmt_out->i_height )
        p_fmt_out->i_width = (int64_t)p_image->p_dec->fmt_out.video.i_width *
                             p_image->p_dec->fmt_out.video.i_sar_num *
                             p_fmt_out->i_height /
                             p_image->p_dec->fmt_out.video.i_height /
                             p_image->p_dec->fmt_out.video.i_sar_den;

    if( !p_fmt_out->i_height && p_fmt_out->i_width )
        p_fmt_out->i_height = (int64_t)p_image->p_dec->fmt_out.video.i_height *
                              p_image->p_dec->fmt_out.video.i_sar_den *
                              p_fmt_out->i_width /
                              p_image->p_dec->fmt_out.video.i_width /
                              p_image->p_dec->fmt_out.video.i_sar_num;
    if( !p_fmt_out->i_width )
        p_fmt_out->i_width = p_image->p_dec->fmt_out.video.i_width;
    if( !p_fmt_out->i_height )
        p_fmt_out->i_height = p_image->p_dec->fmt_out.video.i_height;
    if( !p_fmt_out->i_visible_width )
        p_fmt_out->i_visible_width = p_fmt_out->i_width;
    if( !p_fmt_out->i_visible_height )
        p_fmt_out->i_visible_height = p_fmt_out->i_height;

    /* Check if we need chroma conversion or resizing */
    if( p_image->p_dec->fmt_out.video.i_chroma != p_fmt_out->i_chroma ||
        p_image->p_dec->fmt_out.video.i_width != p_fmt_out->i_width ||
        p_image->p_dec->fmt_out.video.i_height != p_fmt_out->i_height )
    {
        if( p_image->p_filter )
        if( p_image->p_filter->fmt_in.video.i_chroma !=
            p_image->p_dec->fmt_out.video.i_chroma ||
            p_image->p_filter->fmt_out.video.i_chroma != p_fmt_out->i_chroma )
        {
            /* We need to restart a new filter */
            DeleteFilter( p_image->p_filter );
            p_image->p_filter = 0;
        }

        /* Start a filter */
        if( !p_image->p_filter )
        {
            p_image->p_filter =
                CreateFilter( p_image->p_parent, &p_image->p_dec->fmt_out,
                              p_fmt_out );

            if( !p_image->p_filter )
            {
                picture_Release( p_pic );
                return NULL;
            }
        }
        else
        {
            /* Filters should handle on-the-fly size changes */
            p_image->p_filter->fmt_in = p_image->p_dec->fmt_out;
            p_image->p_filter->fmt_out = p_image->p_dec->fmt_out;
            p_image->p_filter->fmt_out.i_codec = p_fmt_out->i_chroma;
            p_image->p_filter->fmt_out.video = *p_fmt_out;
        }

        p_pic = p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );

        video_format_Clean( p_fmt_out );
        video_format_Copy( p_fmt_out, &p_image->p_filter->fmt_out.video );
    }
    else
    {
        video_format_Clean( p_fmt_out );
        video_format_Copy( p_fmt_out, &p_image->p_dec->fmt_out.video );
    }

    return p_pic;
}