int AVIWrapper::init(char* filename, bool debug_flag) { this->debug_flag = debug_flag; if (!debug_flag) avm::out.resetDebugLevels(-1); i_avi = CreateIAviReadFile(filename); if (i_avi == NULL || i_avi->IsValid() == false) { fprintf(stderr, "can't CreateIAviReadFile from %s\n", filename); return -1; } v_stream = i_avi->GetStream(0, AviStream::Video); if (v_stream == NULL) { fprintf(stderr, "Video Stream is NULL\n"); return -1; } width = v_stream->GetStreamInfo()->GetVideoWidth(); height = v_stream->GetStreamInfo()->GetVideoHeight(); if (debug_flag) fprintf(stderr, "width %d height %d\n", width, height); return 0; }
bool AviLayer::open(char *file) { func("AviLayer::open(%s)",file); if(_avi) close(); try { _avi = CreateIAviReadFile(file); } //catch(FatalError &e) { catch(void *p) { error("AviLayer::open(%s)",file); return(false); } if(!_avi) { error("AviLayer::open(%s) - can't open file",file); return (false); } _stream = _avi->GetStream(0, AviStream::Video); if(!_stream) { /* check if here we got to free something */ error("AviLayer::open(%s) - video stream not detected",file); return(false); } /* this crashes on .37 avifile verified with shezzan on 14 july 2003 _stream->SetDirection(true); */ if(!_avi->IsOpened()) { /* check if here we got to free something */ error("Avilayer::open(%s) - can't open file",file); return(false); } if(!_avi->IsValid()) { /* check if here we got to free something */ error("AviLayer::open(%s) - invalid file",file); return(false); } notice("AVI Layer :: %s",file); if(_avi->IsRedirector()) act("supplied url is a network redirector"); try { /* * SetDestFmt() sets desired bit depth and color space of output picture. * Returns zero on success, -1 if format is unsupported and * +1 if there was no 'native' support for the depth and library * is going to perform internal conversion of format. Most decoders * support depths 15, 16, 24 or 32. Many of them also allow to use * YUV formats. You can check if your particular decoder is able to decode * into the particular YUV format by calling GetCapabilities(), * which returns bitwise OR of supported formats. */ if(_stream->StartStreaming()!=0) { /* check if here we got to free something */ error("AviLayer::open(%s) - failed to initialize decoder object",file); return(false); } // _stream->GetDecoder()->SetDestFmt('YUY2'); // _stream->GetDecoder()->SetDestFmt(12,'I420'); _stream->GetDecoder()->SetDestFmt(32); _stream->ReadFrame(false); bh = _stream->GetDecoder()->GetDestFmt(); } //catch(FatalError &e) { catch(void *p) { error("Avilib fatal error"); // e.Print(); return(false); } set_filename(file); return(true); }