Source file notes
This section of the documentation is designed to help outside (and inside) code writers quickly figure out where a patch or feature needs to be written for, as well as generally provide an overview of the source files and their purposes. Files in Avidemux tend to do more than just one task, so most information here will not always describe the full range of a file's functions.
General notes
Avidemux is written using the C++ programming language, but it does not use the STL, though this is not a very big deal in general. Avidemux is built with the GTK+ graphical libraries. Lastly Avidemux also has the SpiderMonkey ECMAScript scripting engine built into it for project handling. As of yet, this cannot be directly called by Avidemux. If you want to add code or edit code for Avidemux, you will need to understand these languages and libraries. The ECMAScript is rarely used outside of a few specific functions, so most people do not need to know it if they want to modify code. However C/C++ and GTK+ are usually necessary knowledge.
Avidemux makes heavy use of polymorphism and class derivation.
General architecture
Any processing can be seen as having 3 working parts:
The demuxer: All demuxers are derived from the vidHeader class and provide information and access capabilities. Among the capabilities, there is the ability to retrieve any frame and the associated flags with no need for sequential seeking.
The editor: The editor's job is to associate codecs to the streams present in the demuxer's output. The editor also handles editing (append, cut, etc…) and the B-frame reordering logic. The
GUI asks for a frame from the editor, and the editor manages all the logic by itself. Normally adding a new file format does NOT modify the editor.
The output muxer: All output muxers are in directories beginning with oplug_ and each one deals with one file output format.
Directory: /avidemux/
ADM_3gp
Contains QuickTime, MP4, 3GPP input handling
ADM_3gp.cpp: Among other things, this handles the QuickTime, MP4, 3GPP input formats (demuxing, variants).
ADM_3gp.h: Among other things, this handles the QuickTime, MP4, 3GPP input formats (demuxing, variants).
ADM_audiofilter
Contains audio filter files (generally not the source code for the audio codecs themselves), including the mixer.
Encoding is seen as a filter so interfaces to audio encoders are in that directory too.
audioencoder.cpp: Code for the general audio processing within Avidemux
audioencoder.h: Header code for audioencoder.cpp
audioencoder_faac.cpp: FAAC audio encoder source code
audioencoder_faac.h: Header code for the FAAC encoder
audioencoder_lame.cpp: LAME audio encoder source code
audioencoder_lame_param.h: Parameter header file for the LAME audio encoder, #included and used in ADM_dialog/DIA_lame.cpp
audioencoder_lavcodec.cpp:
audioencoder_lavcodec.h:
audioencoder_pcm.cpp: PCM audio encoder source code
audioencoder_pcm.cpp: Header code for the PCM audio encoder source code
audioencoder_twolame.cpp: TwoLAME audio encoder source code
audioencoder_twolame.h: Header code for TwoLAME encoder
audioencoder_vorbis.cpp: Vorbis audio encoder source code
audioencoder_vorbis.h: Header code for the Vorbis audio encoder source code
audioencoder_vorbis_param.h: Parameter header file for the Vorbis audio encoder, probably #included and used in ADM_dialog/DIA_vorbis.cpp
audiofilter_mixer.cpp: The audio filter mixer
ADM_audiocodec
Files for encoding to various (audio) codecs (decoder only, see this page's link list for encoders)
ADM_codecac3.cpp:
AC3 audio handling, including Dolby
ADM_codecwma.cpp:
WMA audio handling
ADM_codecs
Files for encoding with various (video) codecs
ADM_codecs.cpp: Store some of the FourCC code for use with encoding/decoding video via the libavcodec
ADM_ffmpeg.cpp: The FFmpeg codecs source codes themselves
ADM_x264.cpp: The x264 encoder
ADM_x264.h: A header file for the x264 encoder
ADM_xvid4.cpp: The Xvid encoder
ADM_xvid4.h: A header file for the Xvid encoder
ADM_ffmp43.cpp : Decoders related to the FFmpeg libavcodec library
ADM_dialog
GUI dialogs and windows for filters, codec configs, preferences, etc. Mostly everyting with a GUI can be found in this directory.
DIA_calculator.cpp: Bitrate calculator dialog
DIA_crop.cpp:
Crop video filter dialog
DIA_defaultAudio.cpp: Default user interface dialog for audio codecs
DIA_DVDff.cpp: FFmpeg MPEG-2 DVD dialog
DIA_encoding.cpp: Encoding information dialog/window
DIA_jobs_save.cpp: “Save to Joblist” dialog
DIA_jobs.cpp: “Joblist” dialog
DIA_lame.cpp: LAME audio encoder dialog
DIA_mcdeint.cpp: mcDeinterlace video filter dialog
DIA_ocr.cpp: “
OCR (VobSub -> srt)” subtitles dialog window
DIA_prefs.cpp: Preferences dialog
DIA_preview.cpp: Video preview dialog
DIA_properties.cpp: Video properties dialog
DIA_srt.cpp: Subtitle filter dialog
DIA_vcodec.cpp: Appears to be the old encoding codec list pulldown menu. May be obsolete.
DIA_vobsub.cpp: VobSub subtitle dialog
DIA_vorbis.cpp: Vorbis audio codec pulldown menu
DIA_working.cpp: Video encoding status window
DIA_x264.cpp: x264 configuration dialog
DIA_xvid4.cpp: Xvid configuration dialog
ADM_encoder
Contains source files that handle the high level video encoders. The high level encoders offer the same interface to core whatever the codec used. They also handle internally the setup for 2-pass encoding. They can be seen as an abstraction layer.
ADM_encCodecDesc.h: Contains default codec value settings (for
GUI dialogs) that are loaded on startup.
ADM_vidEncode.hxx: Codec dialog options (like 2-pass file size, 2-pass bitrate, quantizer). Contains codec names for use when passing as parameters to other functions.
adm_encffmpeg1.cpp: FFmpeg MPEG-1 encoder
adm_encx264.cpp: C++ implementation of the x264 encoder, contains all the internal Avidemux function calls to other functions, including encode, logging, and computing bitrate.
ADM_filter
Contains the management code (loading and GUI's) for the video filters. For actual video filter files see ADM_video.
filter_declaration.cpp: Handles some of the loading and declaring of files.
video_filter.h: Handles some of the loading and declaring of video filter names, descriptions, configurations.
ADM_lavcodec
Contains lots of various codecs handled by libavcodec and associated codecs.
It is the file format library from FFmpeg. It is only used actually to save as MP4. There is some dead code to use it to output MPEG(nbsp)TS also.
mov.c: The reading part for QuickTime/MP4/3GP/… Not used by Avidemux but some code is shared with movenc.c which is used.
movenc.c: Most of the MP4 writing code is here, with very little modifications concerning the way MP3 is stored.
ADM_library
Contains a miscellanious collection of files for various small and a large tasks, including frames, images, file IO, FourCC information, RIFF parser
ADM_mplex
Contains files for audio muxing and demuxing, audio stream information and handling, and various pieces of code relating to general audio management.
ADM_script
Contains ECMAScript/JavaScript scripting files and source code.
Contains some useful functions, mostly GTK+ related. There are also some code to emulate UNIX functions on win32.
ADM_threads.cpp: Uncertain multithreading code
ADM_threads.h: Uncertain multithreading code
eggtray_win32.c: Animated icon for Win32
TLK_filesel.cpp: File selection functions (read/write)
ADM_script
Controls the scripts (most specifically the ECMAScript .js scripts).
ADM_video
Contains most of the actual source files for video filters.
Each filter is declared as a C++ class. They are all derived from the same class. They all use one input and one output and are chained together.
They exchange their configuration with the outside world through the Couples class that does the translation between a parameter name and its value. Most of the filters are ported from MPlayer or Avisynth. The internals of Avidemux are close to both of them. There is also some code to provide a C emulation layer to Avisynth so that porting code is easier.