[Avidemux-svn-commit] r5130 - branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi
mean at BerliOS
mean at mail.berlios.de
Thu Jul 23 20:18:43 CEST 2009
Author: mean
Date: 2009-07-23 20:18:42 +0200 (Thu, 23 Jul 2009)
New Revision: 5130
Removed:
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisave.cpp
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisave.h
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy.cpp
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy_pack.cpp
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy_unpack.cpp
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavedual.cpp
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savecopy.h
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_saveprocess.cpp
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_saveprocess.h
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savesmart.cpp
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savesmart.hxx
Modified:
branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/CMakeLists.txt
Log:
[avi/muxer] cleanup
Modified: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/CMakeLists.txt
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/CMakeLists.txt 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/CMakeLists.txt 2009-07-23 18:18:42 UTC (rev 5130)
@@ -6,8 +6,6 @@
op_aviwrite.cpp
avilist.cpp
-# avilist.cpp op_avisavecopy_pack.cpp op_avisave.cpp op_aviwrite.cpp op_savesmart.cpp
-# op_avisavecopy.cpp op_avisavecopy_unpack.cpp op_avisavedual.cpp op_saveprocess.cpp
)
INCLUDE_DIRECTORIES("${AVIDEMUX_SOURCE_DIR}/avidemux/ADM_coreDemuxer/include")
Deleted: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisave.cpp
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisave.cpp 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisave.cpp 2009-07-23 18:18:42 UTC (rev 5130)
@@ -1,457 +0,0 @@
-/***************************************************************************
- op_avisave.cpp - description
- -------------------
- begin : Fri May 3 2002
- copyright : (C) 2002 by mean
- email : fixounet at free.fr
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-
- /*
-* MODIFIED BY GMV 30.1.05: prepared for ODML
-*/
-
-
-
-#include "ADM_default.h"
-#include "ADM_threads.h"
-
-#include "fourcc.h"
-
-#include "DIA_coreToolkit.h"
-
-//#include "avilist.h"
-
-#include "ADM_videoFilter.h"
-
-#include "ADM_videoFilter.h"
-
-
-
-
-#include "op_aviwrite.hxx"
-#include "op_avisave.h"
-#include "GUI_mux.h"
-#include <math.h>
-uint32_t muxSize=4090;
-extern PARAM_MUX muxMode;
-extern int muxParam;
-
-
-
-#include "audioeng_buildfilters.h"
-#include "ADM_coreUI/include/DIA_factory.h"
-const char *getStrFromAudioCodec( uint32_t codec);
-//_________________________
-uint8_t ADM_aviUISetMuxer( void )
-{
-
-// return DIA_setUserMuxParam ((int *) &muxMode, (int *) &muxParam, (int *) &muxSize);
- uint32_t mux_n_frame=muxParam;
- uint32_t mux_size_block=muxParam;
- uint32_t mux_mode=(uint32_t)muxMode;
-
-
- diaMenuEntry muxingType[]={
- {MUX_REGULAR,QT_TR_NOOP("Normal")},
- {MUX_N_FRAMES,QT_TR_NOOP("Mux every N video frames")},
- {MUX_N_BYTES,QT_TR_NOOP("Mux by packet size")}
- };
-
- diaElemMenu mux(&(mux_mode),QT_TR_NOOP("Muxing _type:"),3,muxingType);
- diaElemUInteger blockSize(&(muxSize),QT_TR_NOOP("_Split every MB:"),1,9000);
-
- diaElemUInteger n_frames(&(mux_n_frame),QT_TR_NOOP("Mux _every x video frames:"),1,100);
- diaElemUInteger n_block(&(mux_size_block),QT_TR_NOOP("Mux in _blocks of x bytes:"),1,50000);
-
-
- mux.link(&(muxingType[1]),1,&n_frames);
- mux.link(&(muxingType[2]),1,&n_block);
-
- diaElem *elems[4]={&mux,&n_frames,&n_block,&blockSize};
- if( diaFactoryRun(QT_TR_NOOP("AVI Muxer Options"),4,elems))
- {
- muxMode=(PARAM_MUX)mux_mode;
- switch(muxMode)
- {
- case MUX_REGULAR: muxParam=1;break;
- case MUX_N_FRAMES: muxParam=mux_n_frame;break;
- case MUX_N_BYTES: muxParam=mux_size_block;break;
- default: ADM_assert(0);
- }
- return 1;
- }
- return 0;
-};
-
-
-//_______ set the autosplit size
-uint8_t ADM_aviSetSplitSize(uint32_t size)
-{
- muxSize=size;
- return 1;
-}
-
-GenericAviSave::GenericAviSave ()
-{
-
- has_audio_track = has_audio_vbr = 0;
- vbuffer = new uint8_t[MAXIMUM_SIZE * MAXIMUM_SIZE * 3];
-// vbuffer=new ADMImage(MAXIMUM_SIZE,MAXIMUM_SIZE);
- abuffer = new uint8_t[96000];
-
- ADM_assert (vbuffer);
- ADM_assert (abuffer);
-
- audio_filter=NULL;
- audio_filter2=NULL;
- _part=0;
- dialog_work=NULL;
- _lastIPFrameSent=0xffffff;
- _incoming=NULL;
- encoding_gui=NULL;
- _videoProcess=0;
- _audioCurrent=_audioTarget=0;
- _audioTotal=0;
- _file=NULL;
- _pq=NULL;
- memset(&_context,0,sizeof(_context));
- _context.audioDone=1;
-}
-
-GenericAviSave::~GenericAviSave ()
-{
- cleanupAudio();
- delete[] vbuffer;
- delete[] abuffer;
- _incoming=NULL;
- ADM_assert(!_file);
-}
-uint8_t GenericAviSave::cleanupAudio (void)
-{
- printf("[AVI] Cleaning audio\n");
- if(_pq)
- {
- _pq->Abort();
- while(!_context.audioDone)
- {
- printf("Waiting Audio thread\n");
- ADM_usleep(500000);
- }
- if(_pq) delete _pq;
- _pq=NULL;
- }
- if(audio_filter)
- {
-// deleteAudioFilter (audio_filter);
- audio_filter=NULL;
- }
- return 1;
-}
-//___________________________________________________________
-// Generic Save Avi loop
-//
-//___________________________________________________________
-//
-uint8_t GenericAviSave::saveAvi (const char *name)
-{
-uint32_t size;
-uint8_t ret=0;
- strcpy(_name,name);
- //frametogo = frameEnd - frameStart + 1;
- frametogo=0;
-
- writter = new aviWrite ();
- // 1- setup audio
- guiStart();
- if (!setupAudio ())
- {
- guiStop();
- GUI_Error_HIG (QT_TR_NOOP("Error initalizing audio filters"), NULL);
- delete writter;
- writter = NULL;
- return 0;
- }
-
- if (!setupVideo (_name))
- {
- guiStop();
- GUI_Error_HIG (QT_TR_NOOP("Error initalizing video filters"), NULL);
- delete writter;
- writter = NULL;
- // guiStop();
- return 0;
- }
-
- // 3- setup video
- frametogo=_incoming->getInfo()->nb_frames;
- fps1000=_incoming->getInfo()->fps1000;
- printf ("\n writing %lu frames\n", frametogo);
-
- //__________________________________
- // now go to main loop.....
- //__________________________________
- for (uint32_t cf = 0; cf < frametogo; cf++)
- {
-
-
-
- if (guiUpdate (cf, frametogo))
- goto abortme;
- // printf("\n %lu / %lu",cf,frametogo);
- writeVideoChunk (cf);
- writeAudioChunk (cf);
- //writter->sync();
-
-
- }; // end for
- ret=1;
-abortme:
- guiStop ();
- //__________________________________
- // and end save
- //__________________________________
- writter->setEnd ();
- delete writter;
- writter = NULL;
- // resync GUI
- printf ("\n Saving AVI (v_engine)... done\n");
- return ret;
-}
-
-//_________________________________________________________________
-//
-// Set up audio system
-//_________________________________________________________________
-uint8_t
-GenericAviSave::setupAudio (void)
-{
-// 1- Prepare audio filter
-//__________________________
-
- _audioInBuffer = 0;
- _audioTarget=_audioCurrent=0;
- _audioTotal=0;
- audio_filter=NULL;
- if(!currentaudiostream)
- {
- encoding_gui->setAudioCodec(QT_TR_NOOP("None"));
- return 1;
- }
- printf (" mux mode : %d mux param %d\n", muxMode, muxParam);
-
- if (audioProcessMode()) // else Raw copy mode
- {
-// audio_filter = buildAudioFilter (currentaudiostream,video_body->getTime (frameStart));
- if(!audio_filter) return 0;
- encoding_gui->setAudioCodec(getStrFromAudioCodec(audio_filter->getInfo()->encoding));
- }
- else // copymode
- {
- // else prepare the incoming raw stream
- // audio copy mode here
- encoding_gui->setAudioCodec(QT_TR_NOOP("Copy"));
-// audio_filter=buildAudioFilter( currentaudiostream,video_body->getTime (frameStart));
- if(!audio_filter) return 0;
- }
- /* Setup audioQ */
- pthread_t audioThread;
- _pq=new PacketQueue("AVI audioQ",5000,2*1024*1024);
- memset(&_context,0,sizeof(_context));
- // _context.audioEncoder=audio_filter;
- _context.audioTargetSample=0xFFFF0000; ; //FIXME
- _context.packetQueue=_pq;
- // start audio thread
- ADM_assert(!pthread_create(&audioThread,NULL,(THRINP)defaultAudioQueueSlave,&_context));
- ADM_usleep(4000);
- return 1;
-}
-//---------------------------------------------------------------------------
-uint8_t
-GenericAviSave::writeAudioChunk (uint32_t frame)
-{
- uint32_t len;
- // if there is no audio, we do nothing
- if (!audio_filter)
- return 1;
-
- double t;
-
- t=frame+1;
- t=t/fps1000;
- t=t*1000*audio_filter->getInfo()->frequency;
- _audioTarget=(uint32_t )floor(t);
-
- uint32_t sample,packetLen,packets=0;
-
-
-
- sample=0;
- // _audioTarget is the # of sample we want
- while(_audioCurrent<_audioTarget)
- {
- if(!_pq->Pop(abuffer+_audioInBuffer,&packetLen,&sample))
- {
- printf("AVIWR:Could not read packet\n");
- break;
- }
- _audioInBuffer+=packetLen;
- _audioTotal+=packetLen;
- _audioCurrent+=sample;
- packets++;
- }
- switch (muxMode)
- {
- case MUX_N_FRAMES:
- stored_audio_frame++;
- if (stored_audio_frame < muxParam)
- return 1;
- stored_audio_frame = 0;
- case MUX_REGULAR:
- break;
- case MUX_N_BYTES:
- if(_audioInBuffer<muxParam) return 1;
- break;
- break;
- default:
- ADM_assert (0);
- }
- if (_audioInBuffer)
- {
- writter->saveAudioFrame (_audioInBuffer, abuffer);
- encoding_gui->setAudioSize(_audioTotal);
- _audioInBuffer=0;
- }
- return 1;
-
-}
-
-void
-GenericAviSave::guiStart (void)
-{
- encoding_gui=new DIA_encoding(25000);
- encoding_gui->setCodec(QT_TR_NOOP("Copy"));
- encoding_gui->setFrame (0,0,2 ,100); // FXMe
- encoding_gui->setContainer(QT_TR_NOOP("AVI"));
-
-}
-
-void
-GenericAviSave::guiStop (void)
-{
- ADM_assert(encoding_gui);
- delete encoding_gui;
- encoding_gui=NULL;
-
-}
-void GenericAviSave::guiSetPhasis(const char *str)
-{
- ADM_assert(encoding_gui);
- encoding_gui->setPhasis(str);
-
-}
-uint8_t
-GenericAviSave::guiUpdate (uint32_t nb, uint32_t total)
-{
- ADM_assert(encoding_gui);
- //encoding_gui->setFrame (nb, 0,0, total); //FXMe
- if ( encoding_gui->isAlive () == 1)
- return 0;
- return 1;
-
-
-}
-// Return 1 if we exceed the chunk limit
-//
-uint8_t GenericAviSave::handleMuxSize ( void )
-{
- uint32_t pos;
-
- pos=writter->getPos();
- if(pos>=muxSize*1024*1024)
- {
- return 1 ;
-
- }
- return 0;
-
-
-}
-//
-// Finish the current avi and start a new one
-//
-uint8_t GenericAviSave::reigniteChunk( uint32_t dataLen, uint8_t *data )
-{
- // MOD Feb 2005 by GMV: ODML exit
- if(writter->doODML!=aviWrite::NO)return 1; // exit if odml has to be used
- // END MOD Feb 2005 by GMV
-
- // first end up the current chunk
- writter->setEnd ();
- delete writter;
- writter = NULL;
- // then create a new one
- writter = new aviWrite ();
-
- _part++;
- char n[500];
-
- sprintf(n,"%s%02d",_name,_part);
-
- printf("\n *** writing a new avi part :%s\n",n);
-
- if (!writter->saveBegin (n,
- &_mainaviheader,
- frameEnd - frameStart + 1,
- &_videostreamheader,
- &_bih,
- data,dataLen,
- audio_filter,
- audio_filter2))
- {
- GUI_Error_HIG (QT_TR_NOOP("Cannot initiate save"), NULL);
-
- return 0;
- }
- return 1;
-}
-
-/**
- Search Forward Reference frame from the current B frame
-*/
-uint32_t GenericAviSave::searchForward(uint32_t startframe)
-{
-uint32_t fw=startframe;
-uint32_t flags;
-uint8_t r;
-
- while(1)
- {
- fw++;
- r=video_body->getFlags (fw, &flags);
- if(!(flags & AVI_B_FRAME))
- {
- return fw;
-
- }
- ADM_assert(r);
- if(!r)
- {
- printf("\n Could not locate last non B frame \n");
- return 0;
- }
-
- }
-}
-
-//---------------------------------------
-
-// EOF
Deleted: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisave.h
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisave.h 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisave.h 2009-07-23 18:18:42 UTC (rev 5130)
@@ -1,86 +0,0 @@
-/***************************************************************************
- op_avisave.h - description
- -------------------
- begin : Fri May 3 2002
- copyright : (C) 2002 by mean
- email : fixounet at free.fr
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
- #ifndef __AVI_SAVE__
- #define __AVI_SAVE__
-
-#include "ADM_default.h"
-
-
-#include "ADM_image.h"
-#include "ADM_fileio.h"
-#include "ADM_toolkit/ADM_audioQueue.h"
-
- class GenericAviSave
- {
- protected :
- ADMFile *_file;
-
- uint32_t _audioTarget;
- uint32_t _audioCurrent;
- uint64_t _audioTotal;
-
- DIA_encoding *encoding_gui;
- AVDMGenericVideoStream *_incoming;
- DIA_working *dialog_work;
- uint8_t has_audio_track;
- uint8_t stored_audio_frame;
- uint8_t has_audio_vbr;
- uint32_t fps1000;
- uint32_t frametogo;
- char _name[500];
- uint32_t _videoProcess;
- uint8_t _part;
- ADM_audioStream *audio_filter;
- ADM_audioStream *audio_filter2;
-
- uint8_t computeAudioCBR (void) ;
- aviWrite *writter;
- uint8_t *vbuffer;
- uint8_t *abuffer;
- uint32_t _audioInBuffer;
- uint32_t _videoFlag;
- uint32_t _lastIPFrameSent;
- PacketQueue *_pq;
- audioQueueMT _context;
- uint8_t cleanupAudio();
-
- virtual uint8_t setupAudio( void);
- virtual uint8_t setupVideo( char *name )=0;
- virtual uint8_t writeAudioChunk(uint32_t f);
- virtual uint8_t writeVideoChunk(uint32_t frame )=0;
- virtual void guiStart(void);
- virtual void guiStop(void);
- void guiSetPhasis(const char *str);
- virtual uint8_t guiUpdate(uint32_t nb,uint32_t total);
- uint8_t handleMuxSize(void ) ; // auto chop
- uint8_t reigniteChunk( uint32_t len, uint8_t *data );
- uint32_t searchForward(uint32_t startframe);
-
- //
- AVIStreamHeader _videostreamheader;
- ADM_BITMAPINFOHEADER _bih;
- MainAVIHeader _mainaviheader;
- public:
- GenericAviSave( void );
- virtual ~GenericAviSave( void );
- virtual uint8_t saveAvi(const char *name );
- };
-extern uint32_t muxSize;
-uint8_t ADM_aviSetSplitSize(uint32_t size);
-uint8_t ADM_aviUISetMuxer( void );
- #endif
-
Deleted: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy.cpp
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy.cpp 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy.cpp 2009-07-23 18:18:42 UTC (rev 5130)
@@ -1,196 +0,0 @@
-/***************************************************************************
- op_avisavecopy.cpp - description
- -------------------
-
- We bypass the use of _incoming to have easy access to furure
- frame.
- In fact only the getflags is necessary, other stuff will be done throught
- incoming.
-
- begin : Fri May 3 2002
- copyright : (C) 2002 by mean
- email : fixounet at free.fr
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-#include "config.h"
-#include "ADM_default.h"
-#include "ADM_threads.h"
-
-#include "fourcc.h"
-#include "avi_vars.h"
-#include "DIA_coreToolkit.h"
-
-//#include "avilist.h"
-
-#include "ADM_videoFilter.h"
-#include "ADM_videoFilter_internal.h"
-
-#include "ADM_encoder/ADM_vidEncode.hxx"
-
-#include "ADM_audio/aviaudio.hxx"
-#include "ADM_audiofilter/audioprocess.hxx"
-#include "op_aviwrite.hxx"
-#include "op_avisave.h"
-#include "op_savecopy.h"
-
-#include "ADM_osSupport/ADM_debugID.h"
-#define MODULE_NAME MODULE_SAVE_AVI
-#include "ADM_osSupport/ADM_debug.h"
-
-
-/**
- \fn ~GenericAviSaveCopyUnpack
- \brief destructor
-*/
-GenericAviSaveCopy::~GenericAviSaveCopy ()
-{
- if(copy) delete copy;
- copy=NULL;
-}
-
-uint8_t GenericAviSaveCopy::setupVideo (char *name)
-{
- // Setup avi file output, all is coming from original avi
- // since we are inc copy mode
- memcpy(&_bih,video_body->getBIH (),sizeof(_bih));
- _bih.biSize=sizeof(_bih); //fix old version of avidemux
- _bih.biXPelsPerMeter=_bih.biClrUsed=_bih.biYPelsPerMeter=0;
- //
- memcpy(&_videostreamheader,video_body->getVideoStreamHeader (),sizeof( _videostreamheader));
- memcpy(&_mainaviheader,video_body->getMainHeader (),sizeof(_mainaviheader));
-
-
- /* update to fix earlier bug */
- _mainaviheader.dwWidth=_bih.biWidth;
- _mainaviheader.dwHeight=_bih.biHeight;
-
- uint8_t *extraData;
- uint32_t extraLen;
- _lastIPFrameSent=0xfffffff;
- video_body->getExtraHeaderData(&extraLen,&extraData);
-
- if (!writter->saveBegin (name,
- &_mainaviheader,
- frameEnd - frameStart + 1,
- &_videostreamheader,
- &_bih,
- extraData,extraLen,
- audio_filter,
- audio_filter2
- ))
- {
- GUI_Error_HIG (QT_TR_NOOP("Cannot initiate save"), NULL);
- return 0;
- }
- if(audio_filter2)
- {
- printf("Second audio track present\n");
- }
- else
- {
- printf("Second audio track absent\n");
- }
- _incoming = getFirstVideoFilter (frameStart,frameEnd-frameStart);
- encoding_gui->setFps(_incoming->getInfo()->fps1000);
- encoding_gui->setPhasis(QT_TR_NOOP("Saving"));
- // Set up our copy codec ...
- copy=new EncoderCopy(NULL);
- if(!copy->configure(_incoming, 0))
- {
- printf("Copy cannot [configure] \n");
- return 0;
- }
- return 1;
-}
-
-
-// copy mode
-// Basically ask a video frame and send it to writter
-// If it contains b frame and frames have been re-ordered
-// reorder them back ...
-uint8_t
-GenericAviSaveCopy::writeVideoChunk (uint32_t frame)
-{
-
- uint8_t ret1;
- ADMCompressedImage img;
- ADMBitstream bitstream;
- uint8_t seq;
- img.data=vbuffer;
- bitstream.bufferSize=_incoming->getInfo ()->width * _incoming->getInfo ()->height * 3;
- bitstream.data=vbuffer;
-
-
- if(!video_body->isReordered(frameStart+frame))
- {
- ret1 = video_body->getFrame (frameStart + frame,&img,&seq);// vbuffer, &len, &_videoFlag);
- _videoFlag=img.flags;
- }
- else
- {
- ret1=copy->encode(frame,&bitstream);
- img.dataLength=bitstream.len;
- _videoFlag=img.flags=bitstream.flags;
- }
-
- if (!ret1)
- return 0;
-
- // check for split
- // check for auto split
- // if so, we re-write the last I frame
- if(muxSize)
- {
- // we overshot the limit and it is a key frame
- // start a new chunk
- if(handleMuxSize() && (_videoFlag & AVI_KEY_FRAME))
- {
- uint8_t *extraData;
- uint32_t extraLen;
-
- video_body->getExtraHeaderData(&extraLen,&extraData);
-
- if(!reigniteChunk(extraLen,extraData)) return 0;
- }
- }
-
- if(_videoFlag==AVI_KEY_FRAME)
- newFile();
- encoding_gui->setFrame(frame,img.dataLength,0,frametogo);
- return writter->saveVideoFrame (img.dataLength, img.flags, img.data);
-
-
-}
-/**
- \fn newFile
- \brief start a new file, for example if the muxer was setup to split every 700 Meg. Call only on intra!
-
-
-*/
-uint8_t GenericAviSaveCopy::newFile(void)
-{
- if(muxSize)
- {
- // we overshot the limit and it is a key frame
- // start a new chunk
- if(handleMuxSize() )
- {
- uint8_t *extraData;
- uint32_t extraLen;
-
- video_body->getExtraHeaderData(&extraLen,&extraData);
-
- if(!reigniteChunk(extraLen,extraData)) return 0;
- }
- }
- return 1;
-}
-// EOF
Deleted: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy_pack.cpp
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy_pack.cpp 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy_pack.cpp 2009-07-23 18:18:42 UTC (rev 5130)
@@ -1 +0,0 @@
-// RMED
Deleted: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy_unpack.cpp
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy_unpack.cpp 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavecopy_unpack.cpp 2009-07-23 18:18:42 UTC (rev 5130)
@@ -1,217 +0,0 @@
-/***************************************************************************
- op_avisavecopy.cpp - description
- -------------------
-
- We bypass the use of _incoming to have easy access to furure
- frame.
- In fact only the getflags is necessary, other stuff will be done throught
- incoming.
-
- begin : Fri May 3 2002
- copyright : (C) 2002 by mean
- email : fixounet at free.fr
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-#include "config.h"
-#include "ADM_default.h"
-#include "ADM_threads.h"
-
-#include "fourcc.h"
-#include "avi_vars.h"
-#include "DIA_coreToolkit.h"
-
-//#include "avilist.h"
-
-#include "ADM_videoFilter.h"
-#include "ADM_videoFilter_internal.h"
-
-#include "ADM_encoder/ADM_vidEncode.hxx"
-
-#include "ADM_audio/aviaudio.hxx"
-#include "ADM_audiofilter/audioprocess.hxx"
-#include "op_aviwrite.hxx"
-#include "op_avisave.h"
-#include "op_savecopy.h"
-
-#include "ADM_osSupport/ADM_debugID.h"
-#define MODULE_NAME MODULE_SAVE_AVI
-#include "ADM_osSupport/ADM_debug.h"
-
-
-static void updateUserData(uint8_t *start, uint32_t len);
-uint8_t ADM_findMpegStartCode(uint8_t *start, uint8_t *end,uint8_t *outstartcode,uint32_t *offset);
-
-
-
-/**
- \fn GenericAviSaveCopyUnpack::setupVideo
- \brief init for unpacker code
-
-*/
-uint8_t GenericAviSaveCopyUnpack::setupVideo (char *name)
-{
- // Setup avi file output, all is coming from original avi
- // since we are inc copy mode
- memcpy(&_bih,video_body->getBIH (),sizeof(_bih));
- _bih.biSize=sizeof(_bih); //fix old version of avidemux
- _bih.biXPelsPerMeter=_bih.biClrUsed=_bih.biYPelsPerMeter=0;
- //
- memcpy(&_videostreamheader,video_body->getVideoStreamHeader (),sizeof( _videostreamheader));
- memcpy(&_mainaviheader,video_body->getMainHeader (),sizeof(_mainaviheader));
-
- // Change both to divx/DX50
- _videostreamheader.fccHandler=fourCC::get((uint8_t *)"divx");
- _bih.biCompression=fourCC::get((uint8_t *)"DX50");
- /* update to fix earlier bug */
- _mainaviheader.dwWidth=_bih.biWidth;
- _mainaviheader.dwHeight=_bih.biHeight;
-
- uint8_t *extraData;
- uint32_t extraLen;
- _lastIPFrameSent=0xfffffff;
- video_body->getExtraHeaderData(&extraLen,&extraData);
-
- if (!writter->saveBegin (name,
- &_mainaviheader,
- frameEnd - frameStart + 1,
- &_videostreamheader,
- &_bih,
- extraData,extraLen,
- audio_filter,
- audio_filter2
- ))
- {
- GUI_Error_HIG (QT_TR_NOOP("Cannot initiate save"), NULL);
- return 0;
- }
- if(audio_filter2)
- {
- printf("Second audio track present\n");
- }
- else
- {
- printf("Second audio track absent\n");
- }
- _incoming = getFirstVideoFilter (frameStart,frameEnd-frameStart);
- encoding_gui->setFps(_incoming->getInfo()->fps1000);
- encoding_gui->setPhasis(QT_TR_NOOP("Saving"));
-
- // Set up our copy codec ...
- copy=new EncoderCopy(NULL);
- if(!copy->configure(_incoming, 0))
- {
- printf("Copy cannot [configure] \n");
- return 0;
- }
- return 1;
-}
-
-
-// copy mode
-// Basically ask a video frame and send it to writter
-// If it contains b frame and frames have been re-ordered
-// reorder them back ...
-/**
- \fn GenericAviSaveCopyUnpack::setupVideo
- \brief init for unpacker code
-
-*/
-uint8_t GenericAviSaveCopyUnpack::writeVideoChunk (uint32_t frame)
-{
-
- uint8_t ret1;
- ADMCompressedImage img;
- ADMBitstream bitstream;
- uint8_t seq;
- img.data=vbuffer;
- bitstream.bufferSize=_incoming->getInfo ()->width * _incoming->getInfo ()->height * 3;
- bitstream.data=vbuffer;
-
-
- if(!video_body->isReordered(frameStart+frame))
- {
- ret1 = video_body->getFrame (frameStart + frame,&img,&seq);// vbuffer, &len, &_videoFlag);
- _videoFlag=img.flags;
- }
- else
- {
- ret1=copy->encode(frame,&bitstream);
- img.dataLength=bitstream.len;
- _videoFlag=img.flags=bitstream.flags;
- if(bitstream.flags==AVI_KEY_FRAME)
- {
- updateUserData(bitstream.data,bitstream.len);
- }
- }
-
- if (!ret1)
- return 0;
-
- if(_videoFlag==AVI_KEY_FRAME)
- newFile();
-
-
- encoding_gui->setFrame(frame,img.dataLength,0,frametogo);
- return writter->saveVideoFrame (img.dataLength, img.flags, img.data);
-
-}
-
-//_____________________________________________________
-// Update the user data field that is used to
-// detect in windows world if it is packed or not
-//_____________________________________________________
-void updateUserData(uint8_t *start, uint32_t len)
-{
- // lookup startcode
- uint32_t sync,off,rlen;
- uint8_t code;
- uint8_t *end=start+len;
- while(ADM_findMpegStartCode(start, end,&code,&off))
- {
- // update
- start+=off;
- rlen=end-start;
- if(code!=0xb2 || rlen<4)
- continue;
-
- printf("User data found\n");
- // looks ok ?
- if(!strncmp((char *)start,"DivX",4))
- {
-
- //
- start+=4;
- rlen-=4; // skip "DivX"
- // looks for a p while not null
- // if there isnt we will reach a new startcode
- // and it will stop
- while((*start!='p') && rlen)
- {
- if(!*start)
- {
- rlen=0;
- break;
- }
- rlen--;
- start++;
- }
- if(!rlen)
- {
- printf("Unpacketizer:packed marker not found!\n");
- }
- else
- *start='n'; // remove 'p'
- return;
- }
- }
-}
-
-//EOF
Deleted: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavedual.cpp
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavedual.cpp 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_avisavedual.cpp 2009-07-23 18:18:42 UTC (rev 5130)
@@ -1,142 +0,0 @@
-/***************************************************************************
- op_avisavedual.cpp - description
- -------------------
-
- Save avi in copy mode for audio & video but with 2 tracks
-
- begin : Wed Sep 11 2002
- copyright : (C) 2002 by mean
- email : fixounet at free.fr
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-#include <math.h>
-#include "config.h"
-#include "ADM_default.h"
-#include "ADM_threads.h"
-
-#include "fourcc.h"
-#include "avi_vars.h"
-
-
-//#include "avilist.h"
-
-#include "ADM_videoFilter.h"
-#include "ADM_videoFilter_internal.h"
-#include "ADM_encoder/ADM_vidEncode.hxx"
-
-#include "ADM_audio/aviaudio.hxx"
-#include "audioprocess.hxx"
-#include "op_aviwrite.hxx"
-#include "op_avisave.h"
-#include "op_savecopy.h"
-
-#include "audioprocess.hxx"
-#include "ADM_audio/audioex.h"
-#include "audioeng_buildfilters.h"
-
-GenericAviSaveCopyDualAudio::GenericAviSaveCopyDualAudio (void *track)
- : GenericAviSaveCopy()
-{
- printf("**********************************\n");
- printf("second audio track set\n");
-// audio_filter2= track;
- _audioCurrent2=0;
-}
-
-//
-// Just to keep gcc happy....
-//
-
-uint8_t GenericAviSaveCopyDualAudio::setupAudio (void)
-{
- int32_t shift=0;
- if(!audio_filter2) return 0;
- if(!currentaudiostream) return 0;
-
- audio_filter=buildAudioFilter( currentaudiostream,video_body->getTime (frameStart));
- audio_filter2->goToTime(0);
- return 1;
-}
-//---------------------------------------------------------------------------
-uint8_t GenericAviSaveCopyDualAudio::doOneTrack (uint32_t index,void *stream,uint32_t target,uint32_t *current)
-{
- uint32_t len;
- uint32_t sample,packetLen,packets=0;
-
- _audioInBuffer=0;
- // VBR mode, one packet per frame
-#if 0
- if(stream->packetPerFrame() || stream->isVBR() )
- {
- while(*current<target)
- {
- if(!stream->getPacket(abuffer,&packetLen,&sample))
- {
- printf("AVIWR:Could not read packet\n");
- return 0;
- }
- *current+=sample;
- if(!index)
- writter->saveAudioFrame (packetLen,abuffer);
- else
- writter->saveAudioFrameDual (packetLen,abuffer);
-// encoding_gui->feedAudioFrame(packetLen);
- }
-
- }
- else // CBR mode, pack them
- {
- sample=0;
- // _audioTarget is the # of sample we want
- while(*current<target)
- {
- if(!stream->getPacket(abuffer+_audioInBuffer,&packetLen,&sample))
- {
- printf("AVIWR:Could not read packet\n");
- break;
- }
- _audioInBuffer+=packetLen;
- *current+=sample;
- packets++;
- }
- if (_audioInBuffer)
- {
- if(!index)
- writter->saveAudioFrame (_audioInBuffer, abuffer);
- else
- writter->saveAudioFrameDual (_audioInBuffer,abuffer);
-// encoding_gui->feedAudioFrame(_audioInBuffer);
- }
- }
-#endif
- return 1;
-}
-// **************************************************************
-uint8_t
-GenericAviSaveCopyDualAudio::writeAudioChunk (uint32_t frame)
-{
- uint32_t len;
- // if there is no audio, we do nothing
- if (!audio_filter)
- return 0;
-
- double t;
-
- t=frame+1;
- t=t/fps1000;
- t=t*1000*audio_filter->getInfo()->frequency;
- _audioTarget=(uint32_t )floor(t);
-
-// if(!doOneTrack(0,audio_filter,_audioTarget,&_audioCurrent)) return 0;
-// if(!doOneTrack(1,audio_filter2,_audioTarget,&_audioCurrent2)) return 0;
- return 1;
-}
-//____________
Deleted: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savecopy.h
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savecopy.h 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savecopy.h 2009-07-23 18:18:42 UTC (rev 5130)
@@ -1,82 +0,0 @@
-/***************************************************************************
- op_savecopy.h - description
- -------------------
- begin : Fri May 3 2002
- copyright : (C) 2002 by mean
- email : fixounet at free.fr
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
- #ifndef __AVI_SAVECPY__
- #define __AVI_SAVECPY__
-#include "ADM_encoder/adm_encCopy.h"
- class GenericAviSaveCopy : public GenericAviSave
- {
- protected :
- EncoderCopy *copy;
- virtual uint8_t setupVideo( char *name );
- virtual uint8_t writeVideoChunk(uint32_t frame );
- uint8_t newFile(void);
-
- public:
- GenericAviSaveCopy() : GenericAviSave()
- {
- copy=NULL;
- };
- virtual ~GenericAviSaveCopy();
- };
-
- class GenericAviSaveCopyDualAudio : public GenericAviSaveCopy
- {
- protected :
-
-
- char *_trackname;
- uint32_t _audioCurrent2;
-
- uint8_t doOneTrack (uint32_t index,void *stream,uint32_t target,uint32_t *current);
- virtual uint8_t setupAudio( void);
- virtual uint8_t writeAudioChunk(uint32_t frame );
-
- public:
- GenericAviSaveCopyDualAudio(void *track);
-
- };
-/* Pack /unpack */
-class GenericAviSaveCopyUnpack : public GenericAviSaveCopy
- {
- protected :
- virtual uint8_t setupVideo( char *name );
- virtual uint8_t writeVideoChunk(uint32_t frame );
- public:
-
- };
-class GenericAviSaveCopyPack : public GenericAviSaveCopy
- {
- protected :
- EncoderCopy *copy;
- ADMBitstream *lookAhead[2];
- uint32_t curToggle;
- uint32_t time_inc;
- virtual uint8_t setupVideo( char *name );
- virtual uint8_t writeVideoChunk(uint32_t frame );
- uint8_t prefetch(uint32_t buffer,uint32_t frame);
- public:
- virtual ~GenericAviSaveCopyPack();
- GenericAviSaveCopyPack() : GenericAviSaveCopy()
- {
- lookAhead[0]=NULL;
- lookAhead[1]=NULL;
- curToggle=0;
- time_inc=0;
- };
-
- };
- #endif
Deleted: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_saveprocess.cpp
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_saveprocess.cpp 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_saveprocess.cpp 2009-07-23 18:18:42 UTC (rev 5130)
@@ -1,286 +0,0 @@
-/***************************************************************************
- op_saveprocess.cpp - description
- -------------------
- begin : Fri May 3 2002
- copyright : (C) 2002 by mean
- email : fixounet at free.fr
-
-
-
-
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-#include "config.h"
-#include "ADM_default.h"
-#include "ADM_threads.h"
-
-
-#include "fourcc.h"
-#include "avi_vars.h"
-#include "DIA_coreToolkit.h"
-
-//#include "avilist.h"
-
-#include "ADM_audio/aviaudio.hxx"
-#include "ADM_audiofilter/audioprocess.hxx"
-
-#include "ADM_videoFilter.h"
-//#include "ADM_gui/GUI_encoder.h"
-#include "ADM_videoFilter_internal.h"
-#include "ADM_encoder/ADM_vidEncode.hxx"
-
-#include "op_aviwrite.hxx"
-#include "op_avisave.h"
-
-#include "ADM_encoder/adm_encoder.h"
-#include "op_saveprocess.h"
-
-#include "ADM_osSupport/ADM_debugID.h"
-#define MODULE_NAME MODULE_SAVE_AVI
-#include "ADM_osSupport/ADM_debug.h"
-
-GenericAviSaveProcess::GenericAviSaveProcess( void )
-{
- TwoPassLogFile=NULL;
- _incoming=NULL;
- _encode=NULL;
- _videoProcess=1;
-};
-
-uint8_t
-GenericAviSaveProcess::setupVideo (char *name)
-{
- _notnull=0;
- _incoming = getLastVideoFilter (frameStart,frameEnd-frameStart);
- frametogo=_incoming->getInfo()->nb_frames;
- encoding_gui->setFps(_incoming->getInfo()->fps1000);
- // anish
- if(_incoming->getInfo()->width%8)
- {
- if(!GUI_Question(QT_TR_NOOP("Width is not a multiple of 8\n continue anyway ?")))
- return 0;
-
- }
-
- _encode = getVideoEncoder (_incoming->getInfo()->width,_incoming->getInfo()->height);
- if (!_encode)
- return 0;
-
- // init compressor
- TwoPassLogFile=new char[strlen(name)+6];
- strcpy(TwoPassLogFile,name);
- strcat(TwoPassLogFile,".stat");
- _encode->setLogFile(TwoPassLogFile,frametogo);
-
- int reuse = 0;
-
- if (_encode->isDualPass())
- {
- FILE *tmp;
-
- if ((tmp = fopen(TwoPassLogFile,"rt")))
- {
- fclose(tmp);
-
- if (GUI_Question(QT_TR_NOOP("Reuse the existing log file?")))
- reuse = 1;
- }
- }
-
- if (!_encode->configure (_incoming, reuse))
- {
- delete _encode;
- _encode = NULL;
- GUI_Error_HIG (QT_TR_NOOP("Filter init failed"), NULL);
- return 0;
- };
-
- memcpy (&_bih, video_body->getBIH (), sizeof (_bih));
- _bih.biWidth = _incoming->getInfo ()->width;
- _bih.biHeight = _incoming->getInfo ()->height;
- _bih.biSize=sizeof(_bih);
- _bih.biXPelsPerMeter=_bih.biClrUsed=_bih.biYPelsPerMeter=0;
-
- _mainaviheader.dwTotalFrames= _incoming->getInfo ()->nb_frames;
-_mainaviheader.dwMicroSecPerFrame=0;
-
- printf("\n Saved as %ld x %ld\n",_bih.biWidth,_bih.biHeight);
- _bih.biCompression=fourCC::get((uint8_t *)_encode->getCodecName());
-
- encoding_gui->setCodec(_encode->getDisplayName());
-
- // init save avi
-//-----------------------2 Pass--------------------------------------
- if (_encode->isDualPass ())
- {
- uint8_t *buffer;
- uint32_t len, flag;
-
- aprintf("\n** Dual pass encoding**\n");
-
- if(!reuse)
- {
-
- guiSetPhasis (QT_TR_NOOP("1st Pass"));
- aprintf("**Pass 1:%lu\n",frametogo);
- buffer = new uint8_t[_incoming->getInfo ()->width *
- _incoming->getInfo ()->height * 3];
-
- _encode->startPass1 ();
- //__________________________________
- // now go to main loop.....
- //__________________________________
- bitstream.bufferSize=_incoming->getInfo ()->width * _incoming->getInfo ()->height * 3;
- bitstream.data=buffer;
- for (uint32_t cf = 0; cf < frametogo; cf++)
- {
- if (guiUpdate (cf, frametogo))
- {
- abt:
- GUI_Error_HIG (QT_TR_NOOP("Aborting"), NULL);
- delete[]buffer;
- return 0;
- }
-
- bitstream.cleanup(cf);
- if (!_encode->encode (cf, &bitstream))
- {
- printf("\n Encoding of frame %lu failed !\n",cf);
- goto abt;
- }
- encoding_gui->setFrame(cf,bitstream.len,bitstream.out_quantizer,frametogo);
-
- }
-
- encoding_gui->reset();
- delete[]buffer;
- aprintf("**Pass 1:done\n");
- }// End of reuse
-
- if(!_encode->startPass2 ())
- {
- printf("Pass2 ignition failed\n");
- return 0;
- }
- } //-------------------------/VBR-----------------------------------
- // init save avi
-
-// now we build the new stream !
- aprintf("**main pass:\n");
-
- memcpy(&_videostreamheader,video_body->getVideoStreamHeader (),sizeof(_videostreamheader));
- memcpy(&_videostreamheader.fccHandler ,_encode->getFCCHandler(),4);
- _videostreamheader.fccType =fourCC::get((uint8_t *)"vids");
- _videostreamheader.dwScale=1000;
- _videostreamheader.dwRate= _incoming->getInfo ()->fps1000;
-
- memcpy(&_mainaviheader ,video_body->getMainHeader (),sizeof(_mainaviheader));
-
-
- _mainaviheader.dwWidth=_bih.biWidth;
- _mainaviheader.dwHeight=_bih.biHeight;
- _videostreamheader.dwQuality=10000;
-
- uint8_t *data;
- uint32_t dataLen=0;
-
- _encode->hasExtraHeaderData( &dataLen,&data);
-#if 0
- if (!writter->saveBegin (name,
- &_mainaviheader,
- frameEnd - frameStart + 1,
- &_videostreamheader,
- &_bih,
- data,dataLen,
- (AVDMGenericAudioStream *) audio_filter,
- NULL))
- {
- return 0;
- }
-#endif
- aprintf("Setup video done\n");
- bitstream.data=vbuffer;
- bitstream.bufferSize=MAXIMUM_SIZE * MAXIMUM_SIZE * 3;
- return 1;
- //---------------------
-}
-
-//
-// Just to keep gcc happy....
-//
-GenericAviSaveProcess::~GenericAviSaveProcess ()
-{
- cleanupAudio();
- if (_encode)
- delete _encode;
- _encode=NULL;
- if(TwoPassLogFile)
- {
- delete [] TwoPassLogFile;
- TwoPassLogFile=NULL;
- }
-}
-
-// copy mode
-// Basically ask a video frame and send it to writter
-uint8_t
-GenericAviSaveProcess::writeVideoChunk (uint32_t frame)
-{
- uint8_t ret1;
- // CBR or CQ
- if (frame == 0)
- {
- encoding_gui->setCodec(_encode->getDisplayName()) ;
- if (!_encode->isDualPass ())
- {
- guiSetPhasis (QT_TR_NOOP("Encoding"));
- }
- else
- {
- guiSetPhasis (QT_TR_NOOP("2nd Pass"));
- }
- }
- // first read
- bitstream.cleanup(frame);
- ret1 = _encode->encode ( frame,&bitstream);// &len1, vbuffer, &_videoFlag);
- _videoFlag=bitstream.flags;
- if (!ret1)
- return 0;
- // check for split
- // check for auto split
- // if so, we re-write the last I frame
- if(muxSize)
- {
- // we overshot the limit and it is a key frame
- // start a new chunk
- if(handleMuxSize() && (_videoFlag & AVI_KEY_FRAME))
- {
- uint8_t *data;
- uint32_t dataLen=0;
-
- _encode->hasExtraHeaderData( &dataLen,&data);
- if(!reigniteChunk(dataLen,data)) return 0;
- }
- }
- encoding_gui->setFrame(frame,bitstream.len,bitstream.out_quantizer,frametogo);
- // If we have several null B frames dont write them
- if(bitstream.len) _notnull=1;
- else if( !_notnull)
- {
- printf("Frame : %lu dropped\n",frame);
- return 1;
- }
- return writter->saveVideoFrame (bitstream.len, _videoFlag, vbuffer);
-
-}
-
-
-// EOF
Deleted: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_saveprocess.h
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_saveprocess.h 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_saveprocess.h 2009-07-23 18:18:42 UTC (rev 5130)
@@ -1,41 +0,0 @@
-/***************************************************************************
- op_saveprocess.h - description
- -------------------
- begin : Fri May 3 2002
- copyright : (C) 2002 by mean
- email : fixounet at free.fr
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
- #ifndef __AVI_SAVEPRC__
- #define __AVI_SAVEPRC__
-
-
-
-
- class GenericAviSaveProcess : public GenericAviSave
- {
- protected :
-
- Encoder *_encode;
- uint8_t _notnull;
- char *TwoPassLogFile;
- ADMBitstream bitstream;
-
- virtual uint8_t setupVideo( char *name );
- virtual uint8_t writeVideoChunk(uint32_t frame );
-
- public:
- GenericAviSaveProcess( void ) ;
- virtual ~GenericAviSaveProcess();
- };
-
-
- #endif
Deleted: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savesmart.cpp
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savesmart.cpp 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savesmart.cpp 2009-07-23 18:18:42 UTC (rev 5130)
@@ -1,436 +0,0 @@
-/***************************************************************************
- op_savesmart.cpp - description
- -------------------
- begin : Mon May 6 2002
- copyright : (C) 2002 by mean
- email : fixounet at free.fr
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-
-#include "config.h"
-#include "ADM_default.h"
-#include "ADM_threads.h"
-
-#ifdef USE_FFMPEG
-extern "C" {
- #include "ADM_lavcodec.h"
-};
-#endif
-
-#include "fourcc.h"
-#include "avi_vars.h"
-#ifdef HAVE_ENCODER
-
-
-#include "ADM_audio/aviaudio.hxx"
-#include "ADM_audiofilter/audioprocess.hxx"
-
-#include "ADM_videoFilter.h"
-#include "ADM_videoFilter_internal.h"
-
-#include "ADM_encoder/ADM_vidEncode.hxx"
-
-#include "op_aviwrite.hxx"
-#include "op_avisave.h"
-#include "op_savesmart.hxx"
-
-#ifdef USE_FFMPEG
-#include "ADM_codecs/ADM_ffmpeg.h"
-#endif
-
-#include "ADM_osSupport/ADM_debugID.h"
-#define MODULE_NAME MODULE_SAVE_AVI
-#include "ADM_osSupport/ADM_debug.h"
-
-GenericAviSaveSmart::GenericAviSaveSmart(uint32_t qf) : GenericAviSave()
-{
- _cqReenc=qf;
- ADM_assert(qf>=2 && qf<32);
- _nextip=0;
- encoderReady=0;
- _hasBframe=0;
-}
-uint8_t GenericAviSaveSmart::setupVideo (char *name)
-{
-
-int value=4;;
-
-
- printf("\n Q: %u",_cqReenc);
- // init save avi
- memcpy(&_bih,video_body->getBIH (),sizeof(_bih));
- memcpy(&_videostreamheader,video_body->getVideoStreamHeader (),sizeof( _videostreamheader));
- memcpy(&_mainaviheader,video_body->getMainHeader (),sizeof(_mainaviheader));
-
- uint8_t *extraData;
- uint32_t extraLen;
- _lastIPFrameSent=0xfffffff;
- video_body->getExtraHeaderData(&extraLen,&extraData);
-
- if (!writter->saveBegin (name,
- &_mainaviheader,
- frameEnd - frameStart + 1,
- &_videostreamheader,
- &_bih,
- extraData,extraLen,
- audio_filter,
- NULL
- ))
- {
-
- return 0;
- }
- compEngaged = 0;
- encoderReady = 0;
- _encoder = NULL;
- aImage=new ADMImage(_mainaviheader.dwWidth,_mainaviheader.dwHeight);
- _incoming = getFirstVideoFilter (frameStart,frameEnd-frameStart);
- encoding_gui->setFps(_incoming->getInfo()->fps1000);
- encoding_gui->setPhasis(QT_TR_NOOP("Smart Copy"));
- // B frame ?
- for(int i=frameStart;i<frameEnd;i++)
- {
- if(!video_body->getFlags ( i, &_videoFlag)) break;
- if(_videoFlag & AVI_B_FRAME) _hasBframe=1;
- }
- if(_hasBframe) printf("The original file has bframe, expect a shift of 1 frame\n");
- //
- return 1;
- //---------------------
-}
-
-//
-// Just to keep gcc happy....
-//
-GenericAviSaveSmart::~GenericAviSaveSmart ()
-{
- cleanupAudio();
- if (encoderReady && _encoder)
- {
- _encoder->stopEncoder ();
- }
- if (_encoder)
- delete _encoder;
- if(aImage)
- {
- delete aImage;
- aImage=NULL;
- }
-}
-
-// copy mode
-// Basically ask a video frame and send it to writter
-uint8_t
-GenericAviSaveSmart::writeVideoChunk (uint32_t frame)
-{
- uint32_t len;
- uint8_t ret1, seq;
-
- frame+=frameStart;
- if (compEngaged) // we were re-encoding
- {
- return writeVideoChunk_recode(frame);
- }
- return writeVideoChunk_copy(frame);
-}
-//_________________________________________________________
-uint8_t GenericAviSaveSmart::writeVideoChunk_recode (uint32_t frame)
-{
-uint32_t len;
-ADMBitstream bitstream(MAXIMUM_SIZE * MAXIMUM_SIZE * 3);
- aprintf("Frame %lu encoding\n",frame);
- video_body->getFlags ( frame, &_videoFlag);
- if (_videoFlag & AVI_KEY_FRAME)
- {
- aprintf("Smart: Stopping encoder\n");
- // It is a kf, go back to copy mode
- compEngaged = 0;
- stopEncoder (); // Tobias F
- delete _encoder;
- _encoder = NULL;
- return writeVideoChunk_copy(frame,1);
- }
- // Else encode it ....
- //1-Read it
- if (! video_body->getUncompressedFrame (frame, aImage))
- return 0;
- // 2-encode it
- bitstream.data=vbuffer;
- bitstream.cleanup(frame);
- if (!_encoder->encode (aImage, &bitstream))//vbuffer, &len, &_videoFlag))
- return 0;
- _videoFlag=bitstream.flags;
- // 3-write it
- encoding_gui->setFrame(frame-frameStart,bitstream.len,bitstream.out_quantizer,frametogo);
- return writter->saveVideoFrame (bitstream.len, _videoFlag, vbuffer);
-}
-//_________________________________________________________
-uint8_t GenericAviSaveSmart::writeVideoChunk_copy (uint32_t frame,uint32_t first)
-{
- // Check flags and seq
- uint32_t myseq=0;
- uint32_t nextip;
- uint8_t seq;
- ADMCompressedImage img;
-
- img.data=vbuffer;
-
- aprintf("Frame %lu copying\n",frame);
-
- // all gop should be closed, so it should be safe to do it here
- if(muxSize)
- {
- // we overshot the limit and it is a key frame
- // start a new chunk
- if(handleMuxSize() && (_videoFlag & AVI_KEY_FRAME))
- {
- uint8_t *extraData;
- uint32_t extraLen;
-
- video_body->getExtraHeaderData(&extraLen,&extraData);
-
- if(!reigniteChunk(extraLen,extraData)) return 0;
- }
- }
-
- video_body->getFlags( frame,&_videoFlag);
- if(frame==frameStart)
- {
- if(!(_videoFlag & AVI_KEY_FRAME))
- {
- aprintf("1st frame is not a kef:There is a broken reference, encoding\n");
- compEngaged = 1;
- initEncoder (_cqReenc);
- return writeVideoChunk_recode(frame);
-
- }
- }
-
- if(_videoFlag & AVI_B_FRAME) // lookup next I/P frame
- {
- if(_nextip<frame) // new forward frame
- {
- aprintf("Smart:New forward frame\n");
- if(!seekNextRef(frame,&nextip))
- {
- aprintf("Smart:B Frame without reference frame\n");
- return 1;
- }
- // check if that the frame -1,....,next forward ref are all sequential
- if(!video_body->sequentialFramesB(frame-1,nextip)&&!(_videoFlag &AVI_KEY_FRAME ))
- {
- aprintf("Smart:There is a broken reference, encoding\n");
- compEngaged = 1;
- initEncoder (_cqReenc);
- return writeVideoChunk_recode(frame);
- }
-
- aprintf("Smart : using %lu as next\n",nextip);
- // Seems ok, write it and mark it
- if (! video_body->getFrame (nextip,&img,&seq))// vbuffer, &len, &_videoFlag, &seq))
- return 0;
- _videoFlag=img.flags;
- _nextip=nextip;
- encoding_gui->setFrame(frame-frameStart,img.dataLength,0,frametogo);
- return writter->saveVideoFrame (img.dataLength, img.flags, img.data);
- }
- else
- { // Nth B frame
- aprintf("Smart:Next B frame\n");
- if (!video_body->getFrame (frame-1, &img, &seq))
- return 0;
- _videoFlag=img.flags;
- encoding_gui->setFrame(frame-frameStart,img.dataLength,0,frametogo);
- return writter->saveVideoFrame (img.dataLength, img.flags, img.data);
- }
- }
- // Not a bframe
- // Is it the frame we sent previously ?
- if(frame==_nextip && _nextip)
- {
- // Send the last B frame instead
- aprintf("Smart finishing B frame %lu\n",frame-1);
- if (! video_body->getFrame(frame-1, &img, &seq))// (frame-1, vbuffer, &len, &_videoFlag, &seq))
- return 0;
- _videoFlag=img.flags;
- encoding_gui->setFrame(frame-frameStart,img.dataLength,0,frametogo);
- return writter->saveVideoFrame (img.dataLength, img.flags, img.data);;
-
- }
- // Regular frame
- // just copy it
- if(frame)
- if(!video_body->sequentialFramesB(_nextip,frame)&&!(_videoFlag &AVI_KEY_FRAME )) // Need to re-encode
- {
- aprintf("Seq broken..\n");
- compEngaged = 1;
- initEncoder (_cqReenc);
- encoding_gui->setFrame(frame-frameStart,img.dataLength,0,frametogo);
- return writeVideoChunk_recode(frame);
- }
- _nextip=frame;
- aprintf("Smart: regular\n");
- if(! video_body->getFrame (frame, &img, &seq)) return 0;
- _videoFlag=img.flags;
-
- encoding_gui->setFrame(frame-frameStart,img.dataLength,0,frametogo);
- if(first)
- {
- ADM_assert(_videoFlag == AVI_KEY_FRAME);
- // Grab extra data ..
- uint8_t *extraData;
- uint32_t extraLen;
- uint8_t r;
- video_body->getExtraHeaderData(&extraLen,&extraData);
- if(extraLen)
- {
- //********************************************************************
- // If we have global headers we have to duplicate the old headers as they were replaced
- // by the new headers from the section we re-encoded
- //********************************************************************
- printf("[Smart] Duplicating vop header (%d bytes)\n",extraLen);
- uint8_t *buffer=new uint8_t[extraLen+img.dataLength];
- memcpy(buffer,extraData,extraLen);
- memcpy(buffer+extraLen,img.data,img.dataLength);
- r=writter->saveVideoFrame (img.dataLength+extraLen, img.flags, buffer);;
- delete [] buffer;
- return r;
-
- }
- }
- return writter->saveVideoFrame (img.dataLength, img.flags, img.data);;
-}
-//_________________________________________________________
-uint8_t GenericAviSaveSmart::seekNextRef(uint32_t frame,uint32_t *nextip)
-{
-uint32_t flags;
- for(uint32_t i=frame+1;i<frameEnd;i++)
- {
- video_body->getFlags( i,&flags);
- if(!(flags & AVI_B_FRAME))
- {
- *nextip=i;
- return 1;
- }
-
- }
- return 0;
-}
- //
- //
-uint8_t
-GenericAviSaveSmart::initEncoder (uint32_t qz)
-{
- aviInfo
- info;
- video_body->getVideoInfo (&info);
- ADM_assert (0 == encoderReady);
- encoderReady = 1;
- uint8_t ret=0;
- FFcodecSetting myConfig=
- {
- ME_EPZS,// ME
- 0, // GMC
- 0, // 4MV
- 0,// _QPEL;
- 0,// _TREILLIS_QUANT
- 2,// qmin;
- 31,// qmax;
- 3,// max_qdiff;
- 1,// max_b_frames;
- 0, // mpeg_quant;
- 1, //
- -2, // luma_elim_threshold;
- 1,//
- -5, // chroma_elim_threshold;
- 0.05, //lumi_masking;
- 1, // is lumi
- 0.01, //dark_masking;
- 1, // is dark
- 0.5, // qcompress amount of qscale change between easy & hard scenes (0.0-1.0
- 0.5, // qblur; amount of qscale smoothing over time (0.0-1.0)
- 0, // min bitrate in kB/S
- 0, // max bitrate
- 0, // default matrix
- 0, // no gop size
- NULL,
- NULL,
- 0, // interlaced
- 0, // WLA: bottom-field-first
- 0, // wide screen
- 2, // mb eval = distortion
- 8000, // vratetol 8Meg
- 0, // is temporal
- 0.0, // temporal masking
- 0, // is spatial
- 0.0, // spatial masking
- 0, // NAQ
- 0 // DUMMY
- } ;
-
-
- if( isMpeg4Compatible(info.fcc) )
- {
-/*
-#ifdef USE_DIVX
- _encoder = new divxEncoderCQ (info.width, info.height);
-
-#else
-*/
-// uint8_t setConfig(FFcodecSetting *set);
- ffmpegEncoderCQ *tmp;
- tmp = new ffmpegEncoderCQ (info.width, info.height,FF_MPEG4);
- myConfig.max_b_frames=_hasBframe; // In fact does the original have b frame ?
- tmp->setConfig(&myConfig);
- printf("\n init qz %ld\n",qz);
- ret= tmp->init (qz,25000);
- _encoder=tmp;
-/*
-#endif
-*/
-
-#warning 25 fps hardcoded
-
- }
- else
- {
-#ifdef USE_FFMPEG
- if(isMSMpeg4Compatible(info.fcc) ) // DIV3
- {
- ffmpegEncoderCQ *tmp;
- tmp = new ffmpegEncoderCQ (info.width, info.height,FF_MSMP4V3);
- myConfig.max_b_frames=0;
- tmp->setConfig(&myConfig);
- ret= tmp->init (qz,25000);
- _encoder=tmp;
- }
- else
- {
- ADM_assert(0);
- }
- }
-#else
- ADM_assert(0);
- }
-#endif
-
- return ret;
-}
-
-uint8_t
-GenericAviSaveSmart::stopEncoder (void)
-{
- ADM_assert (1 == encoderReady);
- encoderReady = 0;
- return (_encoder->stopEncoder ());
-}
-
-#endif
Deleted: branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savesmart.hxx
===================================================================
--- branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savesmart.hxx 2009-07-23 18:18:41 UTC (rev 5129)
+++ branches/avidemux_2.6_branch_mean/avidemux_plugins/ADM_muxers/muxerAvi/op_savesmart.hxx 2009-07-23 18:18:42 UTC (rev 5130)
@@ -1,47 +0,0 @@
-/***************************************************************************
- op_savesmart.hxx - description
- -------------------
- begin : Mon May 6 2002
- copyright : (C) 2002 by mean
- email : fixounet at free.fr
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
- #ifndef __AVI_SAVESMT__
- #define __AVI_SAVESMT__
-
- class GenericAviSaveSmart : public GenericAviSave
- {
- protected :
- uint32_t _hasBframe;
- #warning HARDCODED MAX IMAGE SIZE
-
- ADMImage *aImage;
- uint32_t _nextip;
- uint8_t initEncoder(uint32_t qz );
- uint8_t stopEncoder(void );
- uint32_t encoderReady;
- uint32_t compEngaged;
- virtual uint8_t setupVideo( char *name );
- virtual uint8_t writeVideoChunk(uint32_t frame );
- uint8_t writeVideoChunk_recode (uint32_t frame);
- uint8_t writeVideoChunk_copy (uint32_t frame,uint32_t first=0);
- encoder *_encoder;
- uint8_t _cqReenc ;
-
- public:
-
- GenericAviSaveSmart(uint32_t qfactor);
- virtual ~GenericAviSaveSmart();
- uint8_t seekNextRef(uint32_t frame,uint32_t *nextip);
- };
-
-
- #endif
More information about the Avidemux-svn-commit
mailing list