/** \fn addFile \brief Load or append a file. The file type is determined automatically and the ad-hoc video decoder is spawned @param name: filename @return 1 on success, 0 on failure */ bool ADM_Composer::addFile (const char *name) { uint8_t ret = 0; aviInfo info; uint32_t magic; _VIDEOS video; bool avisynth_used = false; if(!strcmp(name, AVS_PROXY_DUMMY_FILE)) { magic=0; avisynth_used = true; } else { FILE *f=ADM_fopen(name,"r"); uint8_t buffer[4]; if(!f) return 0; fread(buffer,4,1,f); fclose(f); magic=(buffer[3]<<24)+(buffer[2]<<16)+(buffer[1]<<8)+(buffer[0]); } // First find the demuxer.... video._aviheader=ADM_demuxerSpawn(magic,name); if(!video._aviheader) { char str[512+1]; snprintf(str,512,QT_TR_NOOP("Cannot find a demuxer for %s"), name); str[512] = '\0'; GUI_Error_HIG(str,NULL); return false; } // use "file name" to share the port number (using little endian) if(avisynth_used) { uint32_t portValue = 0; bool useCmdLine = A_getCommandLinePort(portValue); if (!useCmdLine) if(!prefs->get(AVISYNTH_AVISYNTH_DEFAULTPORT, &portValue)) portValue = 9999; bool askPortAvisynth = false; prefs->get(AVISYNTH_AVISYNTH_ALWAYS_ASK, &askPortAvisynth); if(askPortAvisynth) { uint32_t localPort = 0; if (useCmdLine || !prefs->get(AVISYNTH_AVISYNTH_LOCALPORT, &localPort) || localPort == 0) localPort = portValue; if (UI_askAvisynthPort(localPort)) { portValue = localPort; prefs->set(AVISYNTH_AVISYNTH_LOCALPORT, localPort); } } uint8_t dummy[] = { portValue , portValue >> 8}; ret = video._aviheader->open((char *)dummy); } else
/** \fn addFile \brief Load or append a file. The file type is determined automatically and the ad-hoc video decoder is spawned @param name: filename @return 1 on success, 0 on failure */ bool ADM_Composer::addFile (const char *name) { uint8_t ret = 0; aviInfo info; uint32_t magic; _VIDEOS video; if(!strcmp(name, AVS_PROXY_DUMMY_FILE)) magic=0; else { FILE *f=ADM_fopen(name,"r"); uint8_t buffer[4]; if(!f) return 0; fread(buffer,4,1,f); fclose(f); magic=(buffer[3]<<24)+(buffer[2]<<16)+(buffer[1]<<8)+(buffer[0]); } // First find the demuxer.... video._aviheader=ADM_demuxerSpawn(magic,name); if(!video._aviheader) { char str[512+1]; snprintf(str,512,QT_TR_NOOP("Cannot find a demuxer for %s"), name); str[512] = '\0'; GUI_Error_HIG(str,NULL); return false; } ret = video._aviheader->open(name); // check opening was successful if (ret == 0) { char str[512+1]; snprintf(str,512,QT_TR_NOOP("Attempt to open %s failed!"), name); str[512] = '\0'; GUI_Error_HIG(str,NULL); video._aviheader=NULL; return false; } /* check for resolution */ if( _segments.getNbRefVideos()) { /* append operation */ aviInfo info0, infox; _segments.getRefVideo(0)->_aviheader->getVideoInfo (&info0); video._aviheader->getVideoInfo (&infox); if( info0.width != infox.width || info0.height != infox.height ) { char str[512+1]; str[0] = '\0'; if( info0.width != infox.width ) strcpy(str,"width"); if( info0.height != infox.height ) snprintf(str+strlen(str),512-strlen(str), "%sheight%sdifferent between first and this video stream", (strlen(str)?" and ":""), (strlen(str)?" are ":" is ") ); str[512] = '\0'; GUI_Error_HIG(str,QT_TR_NOOP("You cannot mix different video dimensions yet. Using the partial video filter later, will not work around this problem. The workaround is:\n1.) \"resize\" / \"add border\" / \"crop\" each stream to the same resolution\n2.) concatinate them together")); delete video._aviheader; return false; } } // else update info video._aviheader->getVideoInfo (&info); video._aviheader->setMyName (name); // Printf some info about extradata uint32_t l=0; uint8_t *d=NULL; video._aviheader->getExtraHeaderData(&l,&d); if(l && d) { printf("[Editor]The video codec has some extradata (%d bytes)\n",l); mixDump(d,l); printf("\n"); } // 1st if it is our first video we update postproc if(!_segments.getNbRefVideos()) { uint32_t type=0,value=0; #if 0 if(!prefs->get(DEFAULT_POSTPROC_TYPE,&type)) type=3; if(!prefs->get(DEFAULT_POSTPROC_VALUE,&value)) value=3; #endif if(_pp) delete _pp; _pp=new ADM_PP(info.width,info.height); _pp->postProcType=type; _pp->postProcStrength=value; _pp->forcedQuant=0; _pp->update(); if(_imageBuffer) { if(_imageBuffer->quant) delete [] _imageBuffer->quant; _imageBuffer->quant=NULL; delete _imageBuffer; _imageBuffer=NULL; } _imageBuffer=new ADMImageDefault(info.width,info.height); _imageBuffer->_qSize= ((info.width+15)>>4)*((info.height+15)>>4); _imageBuffer->quant=new uint8_t[_imageBuffer->_qSize]; memset(_imageBuffer->quant,0,_imageBuffer->_qSize); _imageBuffer->_qStride=(info.width+15)>>4; // We also clear the filter queue... ADM_info("Clearing video filters\n"); ADM_vf_clearFilters(); }