mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
WIP: convert to CMake
This commit is contained in:
parent
6490471416
commit
90ba4b791c
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "SDL_kitchensink"]
|
||||
path = SDL_kitchensink
|
||||
url = https://github.com/Skywalker13/SDL_kitchensink.git
|
63
CMakeLists.txt
Normal file
63
CMakeLists.txt
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
cmake_minimum_required (VERSION 3.2)
|
||||
|
||||
include (${CMAKE_ROOT}/Modules/ExternalProject.cmake)
|
||||
|
||||
project (planetblupi)
|
||||
set (PB_VERSION_MAJOR 2)
|
||||
set (PB_VERSION_MINOR 0)
|
||||
set (PB_VERSION_PATCH 0)
|
||||
|
||||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
configure_file (
|
||||
"${PROJECT_SOURCE_DIR}/src/config.h.in"
|
||||
"${PROJECT_BINARY_DIR}/src/config.h"
|
||||
)
|
||||
|
||||
file (GLOB_RECURSE sources src/*.cpp src/*.h)
|
||||
file (GLOB_RECURSE data resources/data/*)
|
||||
file (GLOB_RECURSE image resources/image/*)
|
||||
file (GLOB_RECURSE movie resources/movie/*)
|
||||
file (GLOB_RECURSE sound resources/sound/*)
|
||||
|
||||
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_executable (planetblupi ${sources} ${data} ${image} ${movie} ${sound})
|
||||
|
||||
file (COPY ${data} DESTINATION data)
|
||||
file (COPY ${image} DESTINATION image)
|
||||
file (COPY ${movie} DESTINATION movie)
|
||||
file (COPY ${sound} DESTINATION sound)
|
||||
|
||||
# Dependencies
|
||||
|
||||
find_package (PkgConfig)
|
||||
find_package (Intl REQUIRED)
|
||||
find_package (SDL2 REQUIRED)
|
||||
|
||||
find_package (PkgConfig REQUIRED)
|
||||
pkg_search_module (SDL2_MIXER REQUIRED SDL2_mixer)
|
||||
|
||||
##################
|
||||
## SDL_kitchensink
|
||||
ExternalProject_Add (SDL_kitchensink
|
||||
GIT_REPOSITORY https://github.com/katajakasa/SDL_kitchensink.git
|
||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/SDL_kitchensink
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property (SDL_kitchensink install_dir)
|
||||
include_directories (${install_dir}/include)
|
||||
|
||||
add_dependencies (planetblupi SDL_kitchensink)
|
||||
## SDL_kitchensink
|
||||
## ##################
|
||||
|
||||
target_link_libraries (planetblupi PUBLIC
|
||||
${Intl_LIBRARIES}
|
||||
${SDL2_LIBRARIES}
|
||||
${SDL2_MIXER_LIBRARIES}
|
||||
${install_dir}/lib/libSDL_kitchensink.dll.a
|
||||
)
|
16
README.md
Normal file
16
README.md
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
# Development
|
||||
|
||||
```
|
||||
# Update your toolchain
|
||||
pacman -Syuu
|
||||
|
||||
# Install main development packages
|
||||
pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake pkg-config
|
||||
|
||||
# Install SDL2 development packages
|
||||
pacman -S --noconfirm --needed mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_mixer
|
||||
|
||||
# Install SDL_kitchensink dependencies
|
||||
pacman -S --noconfirm --needed mingw-w64-x86_64-libass mingw-w64-x86_64-ffmpeg
|
||||
```
|
@ -1,166 +0,0 @@
|
||||
2.0.1:
|
||||
Sam Lantinga - Tue Jul 7 11:40:33 PDT 2015
|
||||
* Added support for 'smpl' format loop points in music WAV files
|
||||
Sam Lantinga - Sat Aug 23 10:57:26 2014
|
||||
* Fixed floating point exception in Mix_Volume()
|
||||
David Ludwig - Mon Apr 14 22:15:36 2014
|
||||
* Added support for building for Windows RT and Windows Phone
|
||||
Isaac Burns - Sun Sep 15 21:50:27 PDT 2013
|
||||
* Added support for loading MP3 files as sound chunks
|
||||
|
||||
2.0.0:
|
||||
Sam Lantinga - Sun Jun 9 14:45:30 PDT 2013
|
||||
* Made libmodplug the default MOD player as it is now in the public domain
|
||||
Sam Lantinga - Sat Jun 1 19:11:08 PDT 2013
|
||||
* Updated for SDL 2.0 release
|
||||
* SDL_LoadMUS_RW() now takes an argument telling whether or not the data source should be freed when done.
|
||||
|
||||
1.2.13:
|
||||
Paul P Komkoff Jr - Sun Jul 22 16:12:28 PDT 2012
|
||||
* Fixed malloc/free mismatch in the MikMod driver
|
||||
|
||||
1.2.12:
|
||||
Sam Lantinga - Sat Jan 14 22:00:29 2012 -0500
|
||||
* Fixed seek offset with SMPEG (was relative, should be absolute)
|
||||
Sam Lantinga - Fri Jan 13 03:04:27 EST 2012
|
||||
* Fixed memory crash loading Ogg Vorbis files on Windows
|
||||
Sam Lantinga - Thu Jan 05 22:51:54 2012 -0500
|
||||
* Added an Xcode project for iOS
|
||||
Nikos Chantziaras - 2012-01-02 17:37:36 PST
|
||||
* Added Mix_LoadMUSType_RW() so you can tell SDL_mixer what type the music is
|
||||
Sam Lantinga - Sun Jan 01 16:45:58 2012 -0500
|
||||
* Fixed looping native MIDI on Mac OS X and Windows
|
||||
Sam Lantinga - Sun Jan 01 01:00:51 2012 -0500
|
||||
* Added /usr/local/share/timidity to the timidity data path
|
||||
Sam Lantinga - Sat Dec 31 21:26:46 2011 -0500
|
||||
* Fixed timidity loading of some MIDI files
|
||||
Sam Lantinga - Sat Dec 31 19:11:59 EST 2011
|
||||
* Fixed dropping audio in the FLAC audio decoding
|
||||
Sam Lantinga - Sat Dec 31 18:32:05 EST 2011
|
||||
* Fixed memory leak in SDL_LoadMUS()
|
||||
Sam Lantinga - Sat Dec 31 10:22:05 EST 2011
|
||||
* Removed GPL native MIDI code for new licensing
|
||||
Sam Lantinga - Sat Dec 31 10:22:05 EST 2011
|
||||
* SDL_mixer is now under the zlib license
|
||||
Manuel Montezelo - 2011-12-28 11:42:44 PST
|
||||
* Fixed drums playing on MIDI channel 16 with timidity
|
||||
Ryan C. Gordon - Wed Jun 15 03:41:31 2011 -0400
|
||||
* The music-finished hook can start a track immediately
|
||||
James Le Cuirot - Mon Mar 21 16:54:11 PDT 2011
|
||||
* Added support for FluidSynth
|
||||
Egor Suvorov - Tue Jan 18 11:06:47 PST 2011
|
||||
* Added support for native MIDI on Haiku
|
||||
Sam Lantinga - Tue Jan 11 01:29:19 2011 -0800
|
||||
* Added Android.mk to build on the Android platform
|
||||
Jon Atkins - Sat Nov 14 13:00:18 PST 2009
|
||||
* Added support for libmodplug (disabled by default)
|
||||
|
||||
1.2.11:
|
||||
Sam Lantinga - Sat Nov 14 12:38:01 PST 2009
|
||||
* Fixed initialization error and crashes if MikMod library isn't available
|
||||
Sam Lantinga - Sat Nov 14 11:22:14 PST 2009
|
||||
* Fixed bug loading multiple music files
|
||||
|
||||
1.2.10:
|
||||
Sam Lantinga - Sun Nov 8 08:34:48 PST 2009
|
||||
* Added Mix_Init()/Mix_Quit() to prevent constantly loading and unloading DLLs
|
||||
Mike Frysinger - 2009-11-05 09:11:43 PST
|
||||
* Check for fork/vfork on any platform, don't just assume it on UNIX
|
||||
Jon Atkins - Thu Nov 5 00:02:50 2009 UTC
|
||||
* Fixed export of Mix_GetNumChunkDecoders() and Mix_GetNumMusicDecoders()
|
||||
C.W. Betts - 2009-11-02 00:16:21 PST
|
||||
* Use newer MIDI API on Mac OS X 10.5+
|
||||
|
||||
1.2.9:
|
||||
Ryan Gordon - Sun Oct 18 11:42:31 PDT 2009
|
||||
* Updated native MIDI support on Mac OS X for 10.6
|
||||
Ryan Gordon - Sun Oct 11 05:29:55 2009 UTC
|
||||
* Reset channel volumes after a fade out interrupts a fade in.
|
||||
Ryan Gordon - Sun Oct 11 02:59:12 2009 UTC
|
||||
* Fixed crash race condition with position audio functions
|
||||
Ryan Gordon - Sat Oct 10 17:05:45 2009 UTC
|
||||
* Fixed stereo panning in 8-bit mode
|
||||
Sam Lantinga - Sat Oct 10 11:07:15 2009 UTC
|
||||
* Added /usr/share/timidity to the default timidity.cfg locations
|
||||
Sam Lantinga - Sat Oct 3 13:33:36 PDT 2009
|
||||
* MOD support uses libmikmod and is dynamically loaded by default
|
||||
* A patched version of libmikmod is included in libmikmod-3.1.12.zip
|
||||
* The libmikmod patches fix security issues CVE-2007-6720 and CVE-2009-0179.
|
||||
Sam Lantinga - Sat Oct 3 02:49:41 PDT 2009
|
||||
* Added TIMIDITY_CFG environment variable to fully locate timidity.cfg
|
||||
Sam Lantinga - Fri Oct 2 07:15:35 PDT 2009
|
||||
* Implemented seamless looping for music playback
|
||||
Forrest Voight - 2009-06-13 20:31:38 PDT
|
||||
* ID3 files are now recognized as MP3 format
|
||||
Steven Noonan - 2008-05-13 13:31:36 PDT
|
||||
* Fixed native MIDI crash on 64-bit Windows
|
||||
Ryan Gordon - Fri Jun 5 16:07:08 2009 UTC
|
||||
* Added decoder enumeration API:
|
||||
Mix_GetNumChunkDecoders(), Mix_GetChunkDecoder(),
|
||||
Mix_GetNumMusicDecoders(), Mix_GetMusicDecoder()
|
||||
Austen Dicken - Tue Feb 26 23:28:27 PST 2008
|
||||
* Added support for FLAC audio both as chunks and streaming
|
||||
Tilman Sauerbeck - Tue Feb 26 03:44:47 PST 2008
|
||||
* Added support for streaming WAV files with Mix_LoadMUS_RW()
|
||||
Ryan Gordon - Mon Feb 4 17:10:08 UTC 2008
|
||||
* Fixed crash caused by not resetting position_channels
|
||||
|
||||
1.2.8:
|
||||
Sam Lantinga - Wed Jul 18 09:45:54 PDT 2007
|
||||
* Improved detection of Ogg Vorbis and Tremor libraries
|
||||
Ryan Gordon - Sun Jul 15 12:03:54 EDT 2007
|
||||
* Fixed memory leaks in Effects API.
|
||||
David Rose - Sat Jul 14 22:16:09 PDT 2007
|
||||
* Added support for MP3 playback with libmad (for GPL projects only!)
|
||||
Sam Lantinga - Sat Jul 14 21:39:30 PDT 2007
|
||||
* Fixed the final loop of audio samples of a certain size
|
||||
Sam Lantinga - Sat Jul 14 21:05:09 PDT 2007
|
||||
* Fixed opening Ogg Vorbis files using different C runtimes on Windows
|
||||
Philippe Simons - Sat Jul 14 20:33:17 PDT 2007
|
||||
* Added support for Ogg Vorbis playback with Tremor (an integer decoder)
|
||||
Sam Lantinga - Sat Jul 14 07:02:09 PDT 2007
|
||||
* Fixed memory corruption in timidity resampling code
|
||||
Ryan Gordon - Tue Jul 3 10:44:29 2007 UTC
|
||||
* Fixed building SDL_mixer with SDL 1.3 pre-release
|
||||
Ryan Gordon - Tue Feb 13 08:11:54 2007 UTC
|
||||
* Fixed compiling both timidity and native midi in the same build
|
||||
Hans de Goede - Sun Aug 20 23:25:46 2006 UTC
|
||||
* Added volume control to playmus
|
||||
Jonathan Atkins - Thu Aug 10 15:06:40 2006 UTC
|
||||
* Fixed linking with system libmikmod
|
||||
David Ergo - Fri Jun 23 09:07:19 2006 UTC
|
||||
* Corrected no-op conditions in SetDistance(), SetPanning() and SetPosition()
|
||||
* Fixed copy/paste errors in channel amplitudes
|
||||
|
||||
1.2.7:
|
||||
Sam Lantinga - Fri May 12 00:04:32 PDT 2006
|
||||
* Added support for dynamically loading SMPEG library
|
||||
Sam Lantinga - Thu May 11 22:22:43 PDT 2006
|
||||
* Added support for dynamically loading Ogg Vorbis library
|
||||
Sam Lantinga - Sun Apr 30 09:01:44 PDT 2006
|
||||
* Removed automake dependency, to allow Universal binaries on Mac OS X
|
||||
* Added gcc-fat.sh for generating Universal binaries on Mac OS X
|
||||
Sam Lantinga - Sun Apr 30 01:48:40 PDT 2006
|
||||
* Updated libtool support to version 1.5.22
|
||||
Patrice Mandin - Sat Jul 16 16:43:24 UTC 2005
|
||||
* Use SDL_RWops also for native midi mac and win32
|
||||
Patrice Mandin - Sat Jul 9 14:40:09 UTC 2005
|
||||
* Use SDL_RWops also for native midi gpl (todo: mac and win32)
|
||||
Ryan C. Gordon - Sat Jul 9 01:54:03 EDT 2005
|
||||
* Tweaked Mix_Chunk's definition to make predeclaration easier.
|
||||
Patrice Mandin - Mon Jul 4 19:45:40 UTC 2005
|
||||
* Search timidity.cfg also in /etc
|
||||
* Fix memory leaks in timidity player
|
||||
* Use also SDL_RWops to read midifiles for timidity
|
||||
Ryan C. Gordon - Mon Jun 13 18:18:12 EDT 2005
|
||||
* Patch from Eric Wing to fix native midi compiling on MacOS/x86.
|
||||
Sam Lantinga - Wed Dec 22 17:14:32 PST 2004
|
||||
* Disabled support for the system version of libmikmod by default
|
||||
Sam Lantinga - Tue Dec 21 09:51:29 PST 2004
|
||||
* Fixed building mikmod support on UNIX
|
||||
* Always build SDL_RWops music support
|
||||
* Added SDL_RWops support for reading MP3 files
|
||||
|
||||
1.2.6:
|
||||
Jonathan Atkins - Wed, 15 Sep 2004 23:26:42 -0500
|
||||
* Added support for using the system version of libmikmod
|
@ -1,20 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
@ -1,43 +0,0 @@
|
||||
|
||||
SDL_mixer 2.0
|
||||
|
||||
The latest version of this library is available from:
|
||||
http://www.libsdl.org/projects/SDL_mixer/
|
||||
|
||||
Due to popular demand, here is a simple multi-channel audio mixer.
|
||||
It supports 8 channels of 16 bit stereo audio, plus a single channel
|
||||
of music, mixed by the popular MikMod MOD, Timidity MIDI and SMPEG MP3
|
||||
libraries.
|
||||
|
||||
See the header file SDL_mixer.h and the examples playwave.c and playmus.c
|
||||
for documentation on this mixer library.
|
||||
|
||||
The mixer can currently load Microsoft WAVE files and Creative Labs VOC
|
||||
files as audio samples, and can load MIDI files via Timidity and the
|
||||
following music formats via MikMod: .MOD .S3M .IT .XM. It can load
|
||||
Ogg Vorbis streams as music if built with Ogg Vorbis or Tremor libraries,
|
||||
and finally it can load MP3 music using the SMPEG or libmad libraries.
|
||||
|
||||
Tremor decoding is disabled by default; you can enable it by passing
|
||||
--enable-music-ogg-tremor
|
||||
to configure, or by defining OGG_MUSIC and OGG_USE_TREMOR.
|
||||
|
||||
libmad decoding is disabled by default; you can enable it by passing
|
||||
--enable-music-mp3-mad
|
||||
to configure, or by defining MP3_MAD_MUSIC
|
||||
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
WARNING: The license for libmad is GPL, which means that in order to
|
||||
use it your application must also be GPL!
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The process of mixing MIDI files to wave output is very CPU intensive,
|
||||
so if playing regular WAVE files sound great, but playing MIDI files
|
||||
sound choppy, try using 8-bit audio, mono audio, or lower frequencies.
|
||||
|
||||
To play MIDI files, you'll need to get a complete set of GUS patches
|
||||
from:
|
||||
http://www.libsdl.org/projects/mixer/timidity/timidity.tar.gz
|
||||
and unpack them in /usr/local/lib under UNIX, and C:\ under Win32.
|
||||
|
||||
This library is under the zlib license, see the file "COPYING.txt" for details.
|
||||
|
@ -1,631 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef _SDL_MIXER_H
|
||||
#define _SDL_MIXER_H
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_version.h"
|
||||
#include "begin_code.h"
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
||||
*/
|
||||
#define SDL_MIXER_MAJOR_VERSION 2
|
||||
#define SDL_MIXER_MINOR_VERSION 0
|
||||
#define SDL_MIXER_PATCHLEVEL 1
|
||||
|
||||
/* This macro can be used to fill a version structure with the compile-time
|
||||
* version of the SDL_mixer library.
|
||||
*/
|
||||
#define SDL_MIXER_VERSION(X) \
|
||||
{ \
|
||||
(X)->major = SDL_MIXER_MAJOR_VERSION; \
|
||||
(X)->minor = SDL_MIXER_MINOR_VERSION; \
|
||||
(X)->patch = SDL_MIXER_PATCHLEVEL; \
|
||||
}
|
||||
|
||||
/* Backwards compatibility */
|
||||
#define MIX_MAJOR_VERSION SDL_MIXER_MAJOR_VERSION
|
||||
#define MIX_MINOR_VERSION SDL_MIXER_MINOR_VERSION
|
||||
#define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL
|
||||
#define MIX_VERSION(X) SDL_MIXER_VERSION(X)
|
||||
|
||||
/* This function gets the version of the dynamically linked SDL_mixer library.
|
||||
it should NOT be used to fill a version structure, instead you should
|
||||
use the SDL_MIXER_VERSION() macro.
|
||||
*/
|
||||
extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MIX_INIT_FLAC = 0x00000001,
|
||||
MIX_INIT_MOD = 0x00000002,
|
||||
MIX_INIT_MODPLUG = 0x00000004,
|
||||
MIX_INIT_MP3 = 0x00000008,
|
||||
MIX_INIT_OGG = 0x00000010,
|
||||
MIX_INIT_FLUIDSYNTH = 0x00000020
|
||||
} MIX_InitFlags;
|
||||
|
||||
/* Loads dynamic libraries and prepares them for use. Flags should be
|
||||
one or more flags from MIX_InitFlags OR'd together.
|
||||
It returns the flags successfully initialized, or 0 on failure.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_Init(int flags);
|
||||
|
||||
/* Unloads libraries loaded with Mix_Init */
|
||||
extern DECLSPEC void SDLCALL Mix_Quit(void);
|
||||
|
||||
|
||||
/* The default mixer has 8 simultaneous mixing channels */
|
||||
#ifndef MIX_CHANNELS
|
||||
#define MIX_CHANNELS 8
|
||||
#endif
|
||||
|
||||
/* Good default values for a PC soundcard */
|
||||
#define MIX_DEFAULT_FREQUENCY 22050
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
#define MIX_DEFAULT_FORMAT AUDIO_S16LSB
|
||||
#else
|
||||
#define MIX_DEFAULT_FORMAT AUDIO_S16MSB
|
||||
#endif
|
||||
#define MIX_DEFAULT_CHANNELS 2
|
||||
#define MIX_MAX_VOLUME 128 /* Volume of a chunk */
|
||||
|
||||
/* The internal format for an audio chunk */
|
||||
typedef struct Mix_Chunk {
|
||||
int allocated;
|
||||
Uint8 *abuf;
|
||||
Uint32 alen;
|
||||
Uint8 volume; /* Per-sample volume, 0-128 */
|
||||
} Mix_Chunk;
|
||||
|
||||
/* The different fading types supported */
|
||||
typedef enum {
|
||||
MIX_NO_FADING,
|
||||
MIX_FADING_OUT,
|
||||
MIX_FADING_IN
|
||||
} Mix_Fading;
|
||||
|
||||
typedef enum {
|
||||
MUS_NONE,
|
||||
MUS_CMD,
|
||||
MUS_WAV,
|
||||
MUS_MOD,
|
||||
MUS_MID,
|
||||
MUS_OGG,
|
||||
MUS_MP3,
|
||||
MUS_MP3_MAD,
|
||||
MUS_FLAC,
|
||||
MUS_MODPLUG
|
||||
} Mix_MusicType;
|
||||
|
||||
/* The internal format for a music chunk interpreted via mikmod */
|
||||
typedef struct _Mix_Music Mix_Music;
|
||||
|
||||
/* Open the mixer with a certain audio format */
|
||||
extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize);
|
||||
|
||||
/* Dynamically change the number of channels managed by the mixer.
|
||||
If decreasing the number of channels, the upper channels are
|
||||
stopped.
|
||||
This function returns the new number of allocated channels.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans);
|
||||
|
||||
/* Find out what the actual audio device parameters are.
|
||||
This function returns 1 if the audio has been opened, 0 otherwise.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels);
|
||||
|
||||
/* Load a wave file or a music (.mod .s3m .it .xm) file */
|
||||
extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc);
|
||||
#define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
|
||||
extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
|
||||
|
||||
/* Load a music file from an SDL_RWop object (Ogg and MikMod specific currently)
|
||||
Matt Campbell (matt@campbellhome.dhs.org) April 2000 */
|
||||
extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc);
|
||||
|
||||
/* Load a music file from an SDL_RWop object assuming a specific format */
|
||||
extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc);
|
||||
|
||||
/* Load a wave file of the mixer format from a memory buffer */
|
||||
extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem);
|
||||
|
||||
/* Load raw audio data of the mixer format from a memory buffer */
|
||||
extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len);
|
||||
|
||||
/* Free an audio chunk previously loaded */
|
||||
extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
|
||||
extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);
|
||||
|
||||
/* Get a list of chunk/music decoders that this build of SDL_mixer provides.
|
||||
This list can change between builds AND runs of the program, if external
|
||||
libraries that add functionality become available.
|
||||
You must successfully call Mix_OpenAudio() before calling these functions.
|
||||
This API is only available in SDL_mixer 1.2.9 and later.
|
||||
|
||||
// usage...
|
||||
int i;
|
||||
const int total = Mix_GetNumChunkDecoders();
|
||||
for (i = 0; i < total; i++)
|
||||
printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i));
|
||||
|
||||
Appearing in this list doesn't promise your specific audio file will
|
||||
decode...but it's handy to know if you have, say, a functioning Timidity
|
||||
install.
|
||||
|
||||
These return values are static, read-only data; do not modify or free it.
|
||||
The pointers remain valid until you call Mix_CloseAudio().
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void);
|
||||
extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index);
|
||||
extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void);
|
||||
extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index);
|
||||
|
||||
/* Find out the music format of a mixer music, or the currently playing
|
||||
music, if 'music' is NULL.
|
||||
*/
|
||||
extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music);
|
||||
|
||||
/* Set a function that is called after all mixing is performed.
|
||||
This can be used to provide real-time visual display of the audio stream
|
||||
or add a custom mixer filter for the stream data.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL Mix_SetPostMix(void (*mix_func)(void *udata, Uint8 *stream, int len), void *arg);
|
||||
|
||||
/* Add your own music player or additional mixer function.
|
||||
If 'mix_func' is NULL, the default music player is re-enabled.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL Mix_HookMusic(void (*mix_func)(void *udata, Uint8 *stream, int len), void *arg);
|
||||
|
||||
/* Add your own callback for when the music has finished playing or when it is
|
||||
* stopped from a call to Mix_HaltMusic.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (*music_finished)(void));
|
||||
|
||||
/* Get a pointer to the user data for the current music hook */
|
||||
extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void);
|
||||
|
||||
/*
|
||||
* Add your own callback when a channel has finished playing. NULL
|
||||
* to disable callback. The callback may be called from the mixer's audio
|
||||
* callback or it could be called as a result of Mix_HaltChannel(), etc.
|
||||
* do not call SDL_LockAudio() from this callback; you will either be
|
||||
* inside the audio callback, or SDL_mixer will explicitly lock the audio
|
||||
* before calling your callback.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (*channel_finished)(int channel));
|
||||
|
||||
|
||||
/* Special Effects API by ryan c. gordon. (icculus@icculus.org) */
|
||||
|
||||
#define MIX_CHANNEL_POST -2
|
||||
|
||||
/* This is the format of a special effect callback:
|
||||
*
|
||||
* myeffect(int chan, void *stream, int len, void *udata);
|
||||
*
|
||||
* (chan) is the channel number that your effect is affecting. (stream) is
|
||||
* the buffer of data to work upon. (len) is the size of (stream), and
|
||||
* (udata) is a user-defined bit of data, which you pass as the last arg of
|
||||
* Mix_RegisterEffect(), and is passed back unmolested to your callback.
|
||||
* Your effect changes the contents of (stream) based on whatever parameters
|
||||
* are significant, or just leaves it be, if you prefer. You can do whatever
|
||||
* you like to the buffer, though, and it will continue in its changed state
|
||||
* down the mixing pipeline, through any other effect functions, then finally
|
||||
* to be mixed with the rest of the channels and music for the final output
|
||||
* stream.
|
||||
*
|
||||
* DO NOT EVER call SDL_LockAudio() from your callback function!
|
||||
*/
|
||||
typedef void (*Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata);
|
||||
|
||||
/*
|
||||
* This is a callback that signifies that a channel has finished all its
|
||||
* loops and has completed playback. This gets called if the buffer
|
||||
* plays out normally, or if you call Mix_HaltChannel(), implicitly stop
|
||||
* a channel via Mix_AllocateChannels(), or unregister a callback while
|
||||
* it's still playing.
|
||||
*
|
||||
* DO NOT EVER call SDL_LockAudio() from your callback function!
|
||||
*/
|
||||
typedef void (*Mix_EffectDone_t)(int chan, void *udata);
|
||||
|
||||
|
||||
/* Register a special effect function. At mixing time, the channel data is
|
||||
* copied into a buffer and passed through each registered effect function.
|
||||
* After it passes through all the functions, it is mixed into the final
|
||||
* output stream. The copy to buffer is performed once, then each effect
|
||||
* function performs on the output of the previous effect. Understand that
|
||||
* this extra copy to a buffer is not performed if there are no effects
|
||||
* registered for a given chunk, which saves CPU cycles, and any given
|
||||
* effect will be extra cycles, too, so it is crucial that your code run
|
||||
* fast. Also note that the data that your function is given is in the
|
||||
* format of the sound device, and not the format you gave to Mix_OpenAudio(),
|
||||
* although they may in reality be the same. This is an unfortunate but
|
||||
* necessary speed concern. Use Mix_QuerySpec() to determine if you can
|
||||
* handle the data before you register your effect, and take appropriate
|
||||
* actions.
|
||||
* You may also specify a callback (Mix_EffectDone_t) that is called when
|
||||
* the channel finishes playing. This gives you a more fine-grained control
|
||||
* than Mix_ChannelFinished(), in case you need to free effect-specific
|
||||
* resources, etc. If you don't need this, you can specify NULL.
|
||||
* You may set the callbacks before or after calling Mix_PlayChannel().
|
||||
* Things like Mix_SetPanning() are just internal special effect functions,
|
||||
* so if you are using that, you've already incurred the overhead of a copy
|
||||
* to a separate buffer, and that these effects will be in the queue with
|
||||
* any functions you've registered. The list of registered effects for a
|
||||
* channel is reset when a chunk finishes playing, so you need to explicitly
|
||||
* set them with each call to Mix_PlayChannel*().
|
||||
* You may also register a special effect function that is to be run after
|
||||
* final mixing occurs. The rules for these callbacks are identical to those
|
||||
* in Mix_RegisterEffect, but they are run after all the channels and the
|
||||
* music have been mixed into a single stream, whereas channel-specific
|
||||
* effects run on a given channel before any other mixing occurs. These
|
||||
* global effect callbacks are call "posteffects". Posteffects only have
|
||||
* their Mix_EffectDone_t function called when they are unregistered (since
|
||||
* the main output stream is never "done" in the same sense as a channel).
|
||||
* You must unregister them manually when you've had enough. Your callback
|
||||
* will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
|
||||
* processing is considered a posteffect.
|
||||
*
|
||||
* After all these effects have finished processing, the callback registered
|
||||
* through Mix_SetPostMix() runs, and then the stream goes to the audio
|
||||
* device.
|
||||
*
|
||||
* DO NOT EVER call SDL_LockAudio() from your callback function!
|
||||
*
|
||||
* returns zero if error (no such channel), nonzero if added.
|
||||
* Error messages can be retrieved from Mix_GetError().
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg);
|
||||
|
||||
|
||||
/* You may not need to call this explicitly, unless you need to stop an
|
||||
* effect from processing in the middle of a chunk's playback.
|
||||
* Posteffects are never implicitly unregistered as they are for channels,
|
||||
* but they may be explicitly unregistered through this function by
|
||||
* specifying MIX_CHANNEL_POST for a channel.
|
||||
* returns zero if error (no such channel or effect), nonzero if removed.
|
||||
* Error messages can be retrieved from Mix_GetError().
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f);
|
||||
|
||||
|
||||
/* You may not need to call this explicitly, unless you need to stop all
|
||||
* effects from processing in the middle of a chunk's playback. Note that
|
||||
* this will also shut off some internal effect processing, since
|
||||
* Mix_SetPanning() and others may use this API under the hood. This is
|
||||
* called internally when a channel completes playback.
|
||||
* Posteffects are never implicitly unregistered as they are for channels,
|
||||
* but they may be explicitly unregistered through this function by
|
||||
* specifying MIX_CHANNEL_POST for a channel.
|
||||
* returns zero if error (no such channel), nonzero if all effects removed.
|
||||
* Error messages can be retrieved from Mix_GetError().
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel);
|
||||
|
||||
|
||||
#define MIX_EFFECTSMAXSPEED "MIX_EFFECTSMAXSPEED"
|
||||
|
||||
/*
|
||||
* These are the internally-defined mixing effects. They use the same API that
|
||||
* effects defined in the application use, but are provided here as a
|
||||
* convenience. Some effects can reduce their quality or use more memory in
|
||||
* the name of speed; to enable this, make sure the environment variable
|
||||
* MIX_EFFECTSMAXSPEED (see above) is defined before you call
|
||||
* Mix_OpenAudio().
|
||||
*/
|
||||
|
||||
|
||||
/* Set the panning of a channel. The left and right channels are specified
|
||||
* as integers between 0 and 255, quietest to loudest, respectively.
|
||||
*
|
||||
* Technically, this is just individual volume control for a sample with
|
||||
* two (stereo) channels, so it can be used for more than just panning.
|
||||
* If you want real panning, call it like this:
|
||||
*
|
||||
* Mix_SetPanning(channel, left, 255 - left);
|
||||
*
|
||||
* ...which isn't so hard.
|
||||
*
|
||||
* Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
* the panning will be done to the final mixed stream before passing it on
|
||||
* to the audio device.
|
||||
*
|
||||
* This uses the Mix_RegisterEffect() API internally, and returns without
|
||||
* registering the effect function if the audio device is not configured
|
||||
* for stereo output. Setting both (left) and (right) to 255 causes this
|
||||
* effect to be unregistered, since that is the data's normal state.
|
||||
*
|
||||
* returns zero if error (no such channel or Mix_RegisterEffect() fails),
|
||||
* nonzero if panning effect enabled. Note that an audio device in mono
|
||||
* mode is a no-op, but this call will return successful in that case.
|
||||
* Error messages can be retrieved from Mix_GetError().
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right);
|
||||
|
||||
|
||||
/* Set the position of a channel. (angle) is an integer from 0 to 360, that
|
||||
* specifies the location of the sound in relation to the listener. (angle)
|
||||
* will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260).
|
||||
* Angle 0 is due north, and rotates clockwise as the value increases.
|
||||
* For efficiency, the precision of this effect may be limited (angles 1
|
||||
* through 7 might all produce the same effect, 8 through 15 are equal, etc).
|
||||
* (distance) is an integer between 0 and 255 that specifies the space
|
||||
* between the sound and the listener. The larger the number, the further
|
||||
* away the sound is. Using 255 does not guarantee that the channel will be
|
||||
* culled from the mixing process or be completely silent. For efficiency,
|
||||
* the precision of this effect may be limited (distance 0 through 5 might
|
||||
* all produce the same effect, 6 through 10 are equal, etc). Setting (angle)
|
||||
* and (distance) to 0 unregisters this effect, since the data would be
|
||||
* unchanged.
|
||||
*
|
||||
* If you need more precise positional audio, consider using OpenAL for
|
||||
* spatialized effects instead of SDL_mixer. This is only meant to be a
|
||||
* basic effect for simple "3D" games.
|
||||
*
|
||||
* If the audio device is configured for mono output, then you won't get
|
||||
* any effectiveness from the angle; however, distance attenuation on the
|
||||
* channel will still occur. While this effect will function with stereo
|
||||
* voices, it makes more sense to use voices with only one channel of sound,
|
||||
* so when they are mixed through this effect, the positioning will sound
|
||||
* correct. You can convert them to mono through SDL before giving them to
|
||||
* the mixer in the first place if you like.
|
||||
*
|
||||
* Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
* the positioning will be done to the final mixed stream before passing it
|
||||
* on to the audio device.
|
||||
*
|
||||
* This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning().
|
||||
*
|
||||
* returns zero if error (no such channel or Mix_RegisterEffect() fails),
|
||||
* nonzero if position effect is enabled.
|
||||
* Error messages can be retrieved from Mix_GetError().
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
|
||||
|
||||
|
||||
/* Set the "distance" of a channel. (distance) is an integer from 0 to 255
|
||||
* that specifies the location of the sound in relation to the listener.
|
||||
* Distance 0 is overlapping the listener, and 255 is as far away as possible
|
||||
* A distance of 255 does not guarantee silence; in such a case, you might
|
||||
* want to try changing the chunk's volume, or just cull the sample from the
|
||||
* mixing process with Mix_HaltChannel().
|
||||
* For efficiency, the precision of this effect may be limited (distances 1
|
||||
* through 7 might all produce the same effect, 8 through 15 are equal, etc).
|
||||
* (distance) is an integer between 0 and 255 that specifies the space
|
||||
* between the sound and the listener. The larger the number, the further
|
||||
* away the sound is.
|
||||
* Setting (distance) to 0 unregisters this effect, since the data would be
|
||||
* unchanged.
|
||||
* If you need more precise positional audio, consider using OpenAL for
|
||||
* spatialized effects instead of SDL_mixer. This is only meant to be a
|
||||
* basic effect for simple "3D" games.
|
||||
*
|
||||
* Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
* the distance attenuation will be done to the final mixed stream before
|
||||
* passing it on to the audio device.
|
||||
*
|
||||
* This uses the Mix_RegisterEffect() API internally.
|
||||
*
|
||||
* returns zero if error (no such channel or Mix_RegisterEffect() fails),
|
||||
* nonzero if position effect is enabled.
|
||||
* Error messages can be retrieved from Mix_GetError().
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance);
|
||||
|
||||
|
||||
/*
|
||||
* !!! FIXME : Haven't implemented, since the effect goes past the
|
||||
* end of the sound buffer. Will have to think about this.
|
||||
* --ryan.
|
||||
*/
|
||||
#if 0
|
||||
/* Causes an echo effect to be mixed into a sound. (echo) is the amount
|
||||
* of echo to mix. 0 is no echo, 255 is infinite (and probably not
|
||||
* what you want).
|
||||
*
|
||||
* Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
* the reverbing will be done to the final mixed stream before passing it on
|
||||
* to the audio device.
|
||||
*
|
||||
* This uses the Mix_RegisterEffect() API internally. If you specify an echo
|
||||
* of zero, the effect is unregistered, as the data is already in that state.
|
||||
*
|
||||
* returns zero if error (no such channel or Mix_RegisterEffect() fails),
|
||||
* nonzero if reversing effect is enabled.
|
||||
* Error messages can be retrieved from Mix_GetError().
|
||||
*/
|
||||
extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo);
|
||||
#endif
|
||||
|
||||
/* Causes a channel to reverse its stereo. This is handy if the user has his
|
||||
* speakers hooked up backwards, or you would like to have a minor bit of
|
||||
* psychedelia in your sound code. :) Calling this function with (flip)
|
||||
* set to non-zero reverses the chunks's usual channels. If (flip) is zero,
|
||||
* the effect is unregistered.
|
||||
*
|
||||
* This uses the Mix_RegisterEffect() API internally, and thus is probably
|
||||
* more CPU intensive than having the user just plug in his speakers
|
||||
* correctly. Mix_SetReverseStereo() returns without registering the effect
|
||||
* function if the audio device is not configured for stereo output.
|
||||
*
|
||||
* If you specify MIX_CHANNEL_POST for (channel), then this the effect is used
|
||||
* on the final mixed stream before sending it on to the audio device (a
|
||||
* posteffect).
|
||||
*
|
||||
* returns zero if error (no such channel or Mix_RegisterEffect() fails),
|
||||
* nonzero if reversing effect is enabled. Note that an audio device in mono
|
||||
* mode is a no-op, but this call will return successful in that case.
|
||||
* Error messages can be retrieved from Mix_GetError().
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip);
|
||||
|
||||
/* end of effects API. --ryan. */
|
||||
|
||||
|
||||
/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
|
||||
them dynamically to the next sample if requested with a -1 value below.
|
||||
Returns the number of reserved channels.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num);
|
||||
|
||||
/* Channel grouping functions */
|
||||
|
||||
/* Attach a tag to a channel. A tag can be assigned to several mixer
|
||||
channels, to form groups of channels.
|
||||
If 'tag' is -1, the tag is removed (actually -1 is the tag used to
|
||||
represent the group of all the channels).
|
||||
Returns true if everything was OK.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag);
|
||||
/* Assign several consecutive channels to a group */
|
||||
extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag);
|
||||
/* Finds the first available channel in a group of channels,
|
||||
returning -1 if none are available.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag);
|
||||
/* Returns the number of channels in a group. This is also a subtle
|
||||
way to get the total number of channels when 'tag' is -1
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_GroupCount(int tag);
|
||||
/* Finds the "oldest" sample playing in a group of channels */
|
||||
extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag);
|
||||
/* Finds the "most recent" (i.e. last) sample playing in a group of channels */
|
||||
extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag);
|
||||
|
||||
/* Play an audio chunk on a specific channel.
|
||||
If the specified channel is -1, play on the first free channel.
|
||||
If 'loops' is greater than zero, loop the sound that many times.
|
||||
If 'loops' is -1, loop inifinitely (~65000 times).
|
||||
Returns which channel was used to play the sound.
|
||||
*/
|
||||
#define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1)
|
||||
/* The same as above, but the sound is played at most 'ticks' milliseconds */
|
||||
extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks);
|
||||
extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops);
|
||||
|
||||
/* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */
|
||||
extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms);
|
||||
extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position);
|
||||
#define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1)
|
||||
extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks);
|
||||
|
||||
/* Set the volume in the range of 0-128 of a specific channel or chunk.
|
||||
If the specified channel is -1, set volume for all channels.
|
||||
Returns the original volume.
|
||||
If the specified volume is -1, just return the current volume.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume);
|
||||
extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume);
|
||||
extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume);
|
||||
|
||||
/* Halt playing of a particular channel */
|
||||
extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel);
|
||||
extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag);
|
||||
extern DECLSPEC int SDLCALL Mix_HaltMusic(void);
|
||||
|
||||
/* Change the expiration delay for a particular channel.
|
||||
The sample will stop playing after the 'ticks' milliseconds have elapsed,
|
||||
or remove the expiration if 'ticks' is -1
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks);
|
||||
|
||||
/* Halt a channel, fading it out progressively till it's silent
|
||||
The ms parameter indicates the number of milliseconds the fading
|
||||
will take.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms);
|
||||
extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms);
|
||||
extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms);
|
||||
|
||||
/* Query the fading status of a channel */
|
||||
extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void);
|
||||
extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which);
|
||||
|
||||
/* Pause/Resume a particular channel */
|
||||
extern DECLSPEC void SDLCALL Mix_Pause(int channel);
|
||||
extern DECLSPEC void SDLCALL Mix_Resume(int channel);
|
||||
extern DECLSPEC int SDLCALL Mix_Paused(int channel);
|
||||
|
||||
/* Pause/Resume the music stream */
|
||||
extern DECLSPEC void SDLCALL Mix_PauseMusic(void);
|
||||
extern DECLSPEC void SDLCALL Mix_ResumeMusic(void);
|
||||
extern DECLSPEC void SDLCALL Mix_RewindMusic(void);
|
||||
extern DECLSPEC int SDLCALL Mix_PausedMusic(void);
|
||||
|
||||
/* Set the current position in the music stream.
|
||||
This returns 0 if successful, or -1 if it failed or isn't implemented.
|
||||
This function is only implemented for MOD music formats (set pattern
|
||||
order number) and for OGG, FLAC, MP3_MAD, and MODPLUG music (set
|
||||
position in seconds), at the moment.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);
|
||||
|
||||
/* Check the status of a specific channel.
|
||||
If the specified channel is -1, check all channels.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL Mix_Playing(int channel);
|
||||
extern DECLSPEC int SDLCALL Mix_PlayingMusic(void);
|
||||
|
||||
/* Stop music and set external music playback command */
|
||||
extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);
|
||||
|
||||
/* Synchro value is set by MikMod from modules while playing */
|
||||
extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);
|
||||
extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);
|
||||
|
||||
/* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */
|
||||
extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths);
|
||||
extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void);
|
||||
extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (*function)(const char*, void*), void *data);
|
||||
|
||||
/* Get the Mix_Chunk currently associated with a mixer channel
|
||||
Returns NULL if it's an invalid channel, or there's no chunk associated.
|
||||
*/
|
||||
extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel);
|
||||
|
||||
/* Close the mixer, halting all playing audio */
|
||||
extern DECLSPEC void SDLCALL Mix_CloseAudio(void);
|
||||
|
||||
/* We'll use SDL for reporting errors */
|
||||
#define Mix_SetError SDL_SetError
|
||||
#define Mix_GetError SDL_GetError
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_MIXER_H */
|
@ -1,32 +0,0 @@
|
||||
The source code to this library used with SDL_mixer can be found here:
|
||||
http://www.libsdl.org/projects/SDL_mixer/libs/
|
||||
---
|
||||
|
||||
Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -1,486 +0,0 @@
|
||||
The source code to this library used with SDL_mixer can be found here:
|
||||
http://www.libsdl.org/projects/SDL_mixer/libs/
|
||||
---
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
@ -1 +0,0 @@
|
||||
ModPlug-XMMS and libmodplug are now in the public domain.
|
@ -1,32 +0,0 @@
|
||||
The source code to this library used with SDL_mixer can be found here:
|
||||
http://www.libsdl.org/projects/SDL_mixer/libs/
|
||||
---
|
||||
|
||||
Copyright (c) 2002-2008 Xiph.org Foundation
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -1,485 +0,0 @@
|
||||
The source code to this library used with SDL_mixer can be found here:
|
||||
http://www.libsdl.org/projects/SDL_mixer/libs/
|
||||
---
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,32 +0,0 @@
|
||||
The source code to this library used with SDL_mixer can be found here:
|
||||
http://www.libsdl.org/projects/SDL_mixer/libs/
|
||||
---
|
||||
|
||||
Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -1 +0,0 @@
|
||||
ModPlug-XMMS and libmodplug are now in the public domain.
|
@ -1,32 +0,0 @@
|
||||
The source code to this library used with SDL_mixer can be found here:
|
||||
http://www.libsdl.org/projects/SDL_mixer/libs/
|
||||
---
|
||||
|
||||
Copyright (c) 2002-2008 Xiph.org Foundation
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -1,485 +0,0 @@
|
||||
The source code to this library used with SDL_mixer can be found here:
|
||||
http://www.libsdl.org/projects/SDL_mixer/libs/
|
||||
---
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
Subproject commit 5136ef53dfaaf198c54ad336743cd6ee99b2bfc0
|
@ -1,106 +0,0 @@
|
||||
This is a FFmpeg win32 shared build by Kyle Schwarz.
|
||||
|
||||
Zeranoe's FFmpeg Builds Home Page: <http://ffmpeg.zeranoe.com/builds/>
|
||||
|
||||
FFmpeg version: 3.2.2
|
||||
|
||||
This FFmpeg build was configured with:
|
||||
--disable-static
|
||||
--enable-shared
|
||||
--enable-gpl
|
||||
--enable-version3
|
||||
--enable-dxva2
|
||||
--enable-libmfx
|
||||
--enable-nvenc
|
||||
--enable-avisynth
|
||||
--enable-bzlib
|
||||
--enable-fontconfig
|
||||
--enable-frei0r
|
||||
--enable-gnutls
|
||||
--enable-iconv
|
||||
--enable-libass
|
||||
--enable-libbluray
|
||||
--enable-libbs2b
|
||||
--enable-libcaca
|
||||
--enable-libfreetype
|
||||
--enable-libgme
|
||||
--enable-libgsm
|
||||
--enable-libilbc
|
||||
--enable-libmodplug
|
||||
--enable-libmp3lame
|
||||
--enable-libopencore-amrnb
|
||||
--enable-libopencore-amrwb
|
||||
--enable-libopenh264
|
||||
--enable-libopenjpeg
|
||||
--enable-libopus
|
||||
--enable-librtmp
|
||||
--enable-libsnappy
|
||||
--enable-libsoxr
|
||||
--enable-libspeex
|
||||
--enable-libtheora
|
||||
--enable-libtwolame
|
||||
--enable-libvidstab
|
||||
--enable-libvo-amrwbenc
|
||||
--enable-libvorbis
|
||||
--enable-libvpx
|
||||
--enable-libwavpack
|
||||
--enable-libwebp
|
||||
--enable-libx264
|
||||
--enable-libx265
|
||||
--enable-libxavs
|
||||
--enable-libxvid
|
||||
--enable-libzimg
|
||||
--enable-lzma
|
||||
--enable-decklink
|
||||
--enable-zlib
|
||||
|
||||
This build was compiled with the following external libraries:
|
||||
libmfx 1.19 <https://ffmpeg.zeranoe.com>
|
||||
bzip2 1.0.6 <http://bzip.org/>
|
||||
Fontconfig 2.12.1 <http://freedesktop.org/wiki/Software/fontconfig>
|
||||
Frei0r 20130909-git-10d8360 <http://frei0r.dyne.org/>
|
||||
GnuTLS 3.4.17 <http://gnutls.org/>
|
||||
libiconv 1.14 <http://gnu.org/software/libiconv/>
|
||||
libass 0.13.4 <https://github.com/libass/libass>
|
||||
libbluray 20161201-05c9fde <http://videolan.org/developers/libbluray.html>
|
||||
libbs2b 3.1.0 <http://bs2b.sourceforge.net/>
|
||||
libcaca 0.99.beta19 <http://caca.zoy.org/wiki/libcaca>
|
||||
FreeType 2.7 <http://freetype.sourceforge.net/>
|
||||
Game Music Emu 0.6.1 <https://bitbucket.org/mpyne/game-music-emu/wiki/Home>
|
||||
GSM 1.0.13-4 <http://packages.debian.org/source/squeeze/libgsm>
|
||||
iLBC 20160404-746f8e2 <https://github.com/dekkers/libilbc/>
|
||||
Modplug-XMMS 0.8.8.5 <http://modplug-xmms.sourceforge.net/>
|
||||
LAME 3.99.5 <http://lame.sourceforge.net/>
|
||||
OpenCORE AMR 0.1.3 <http://sourceforge.net/projects/opencore-amr/>
|
||||
OpenH264 1.6.0 <https://github.com/cisco/openh264>
|
||||
OpenJPEG 2.1.2 <https://github.com/uclouvain/openjpeg>
|
||||
Opus 1.1.3 <http://opus-codec.org/>
|
||||
RTMPDump 20151223-git-fa8646d <http://rtmpdump.mplayerhq.hu/>
|
||||
Snappy 20160523-32d6d7d <https://github.com/google/snappy>
|
||||
libsoxr 0.1.2 <http://sourceforge.net/projects/soxr/>
|
||||
Speex 1.2.0 <http://speex.org/>
|
||||
Theora 1.1.1 <http://theora.org/>
|
||||
TwoLAME 0.3.13 <http://twolame.org/>
|
||||
vid.stab 0.98 <http://public.hronopik.de/vid.stab/>
|
||||
VisualOn AMR-WB 0.1.2 <https://github.com/mstorsjo/vo-amrwbenc>
|
||||
Vorbis 1.3.5 <http://vorbis.com/>
|
||||
vpx 1.6.0 <http://webmproject.org/>
|
||||
WavPack 5.0.0 <http://wavpack.com/>
|
||||
WebP 0.5.1 <https://developers.google.com/speed/webp/>
|
||||
x264 20161201-b97ae06 <http://videolan.org/developers/x264.html>
|
||||
x265 2.1 <https://bitbucket.org/multicoreware/x265/wiki/Home>
|
||||
XAVS svn-r55 <http://xavs.sourceforge.net/>
|
||||
Xvid 1.3.4 <http://xvid.org/>
|
||||
z.lib 20161212-63bcfa0 <https://github.com/sekrit-twc/zimg>
|
||||
XZ Utils 5.2.2 <http://tukaani.org/xz>
|
||||
zlib 1.2.8 <http://zlib.net/>
|
||||
|
||||
The source code for this FFmpeg build can be found at: <http://ffmpeg.zeranoe.com/builds/source/>
|
||||
|
||||
This build was compiled on Debian 8.6 (64-bit): <http://www.debian.org/>
|
||||
|
||||
GCC 5.4.0 was used to compile this FFmpeg build: <http://gcc.gnu.org/>
|
||||
|
||||
This build was compiled using the MinGW-w64 toolchain: <http://mingw-w64.sourceforge.net/>
|
||||
|
||||
Licenses for each library can be found in the 'licenses' folder.
|
@ -1,865 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Developer Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
Developer Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Developers-Guide" href="#Developers-Guide">1 Developers Guide</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Notes-for-external-developers" href="#Notes-for-external-developers">1.1 Notes for external developers</a></li>
|
||||
<li><a name="toc-Contributing" href="#Contributing">1.2 Contributing</a></li>
|
||||
<li><a name="toc-Coding-Rules-1" href="#Coding-Rules-1">1.3 Coding Rules</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Code-formatting-conventions" href="#Code-formatting-conventions">1.3.1 Code formatting conventions</a></li>
|
||||
<li><a name="toc-Comments" href="#Comments">1.3.2 Comments</a></li>
|
||||
<li><a name="toc-C-language-features" href="#C-language-features">1.3.3 C language features</a></li>
|
||||
<li><a name="toc-Naming-conventions" href="#Naming-conventions">1.3.4 Naming conventions</a></li>
|
||||
<li><a name="toc-Miscellaneous-conventions" href="#Miscellaneous-conventions">1.3.5 Miscellaneous conventions</a></li>
|
||||
<li><a name="toc-Editor-configuration" href="#Editor-configuration">1.3.6 Editor configuration</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Development-Policy" href="#Development-Policy">1.4 Development Policy</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Patches_002fCommitting" href="#Patches_002fCommitting">1.4.1 Patches/Committing</a></li>
|
||||
<li><a name="toc-Code" href="#Code">1.4.2 Code</a></li>
|
||||
<li><a name="toc-Documentation_002fOther" href="#Documentation_002fOther">1.4.3 Documentation/Other</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Code-of-conduct" href="#Code-of-conduct">1.5 Code of conduct</a></li>
|
||||
<li><a name="toc-Submitting-patches-1" href="#Submitting-patches-1">1.6 Submitting patches</a></li>
|
||||
<li><a name="toc-New-codecs-or-formats-checklist" href="#New-codecs-or-formats-checklist">1.7 New codecs or formats checklist</a></li>
|
||||
<li><a name="toc-patch-submission-checklist" href="#patch-submission-checklist">1.8 patch submission checklist</a></li>
|
||||
<li><a name="toc-Patch-review-process" href="#Patch-review-process">1.9 Patch review process</a></li>
|
||||
<li><a name="toc-Regression-tests-1" href="#Regression-tests-1">1.10 Regression tests</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Adding-files-to-the-fate_002dsuite-dataset" href="#Adding-files-to-the-fate_002dsuite-dataset">1.10.1 Adding files to the fate-suite dataset</a></li>
|
||||
<li><a name="toc-Visualizing-Test-Coverage" href="#Visualizing-Test-Coverage">1.10.2 Visualizing Test Coverage</a></li>
|
||||
<li><a name="toc-Using-Valgrind" href="#Using-Valgrind">1.10.3 Using Valgrind</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Release-process-1" href="#Release-process-1">1.11 Release process</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Criteria-for-Point-Releases-1" href="#Criteria-for-Point-Releases-1">1.11.1 Criteria for Point Releases</a></li>
|
||||
<li><a name="toc-Release-Checklist" href="#Release-Checklist">1.11.2 Release Checklist</a></li>
|
||||
</ul></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Developers-Guide"></a>
|
||||
<h2 class="chapter">1 Developers Guide<span class="pull-right"><a class="anchor hidden-xs" href="#Developers-Guide" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Developers-Guide" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<a name="Notes-for-external-developers"></a>
|
||||
<h3 class="section">1.1 Notes for external developers<span class="pull-right"><a class="anchor hidden-xs" href="#Notes-for-external-developers" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Notes-for-external-developers" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>This document is mostly useful for internal FFmpeg developers.
|
||||
External developers who need to use the API in their application should
|
||||
refer to the API doxygen documentation in the public headers, and
|
||||
check the examples in <samp>doc/examples</samp> and in the source code to
|
||||
see how the public API is employed.
|
||||
</p>
|
||||
<p>You can use the FFmpeg libraries in your commercial program, but you
|
||||
are encouraged to <em>publish any patch you make</em>. In this case the
|
||||
best way to proceed is to send your patches to the ffmpeg-devel
|
||||
mailing list following the guidelines illustrated in the remainder of
|
||||
this document.
|
||||
</p>
|
||||
<p>For more detailed legal information about the use of FFmpeg in
|
||||
external programs read the <samp>LICENSE</samp> file in the source tree and
|
||||
consult <a href="https://ffmpeg.org/legal.html">https://ffmpeg.org/legal.html</a>.
|
||||
</p>
|
||||
<a name="Contributing"></a>
|
||||
<h3 class="section">1.2 Contributing<span class="pull-right"><a class="anchor hidden-xs" href="#Contributing" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Contributing" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>There are 3 ways by which code gets into FFmpeg.
|
||||
</p><ul>
|
||||
<li> Submitting patches to the main developer mailing list.
|
||||
See <a href="#Submitting-patches">Submitting patches</a> for details.
|
||||
</li><li> Directly committing changes to the main tree.
|
||||
</li><li> Committing changes to a git clone, for example on github.com or
|
||||
gitorious.org. And asking us to merge these changes.
|
||||
</li></ul>
|
||||
|
||||
<p>Whichever way, changes should be reviewed by the maintainer of the code
|
||||
before they are committed. And they should follow the <a href="#Coding-Rules">Coding Rules</a>.
|
||||
The developer making the commit and the author are responsible for their changes
|
||||
and should try to fix issues their commit causes.
|
||||
</p>
|
||||
<a name="Coding-Rules"></a><a name="Coding-Rules-1"></a>
|
||||
<h3 class="section">1.3 Coding Rules<span class="pull-right"><a class="anchor hidden-xs" href="#Coding-Rules-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Coding-Rules-1" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<a name="Code-formatting-conventions"></a>
|
||||
<h4 class="subsection">1.3.1 Code formatting conventions<span class="pull-right"><a class="anchor hidden-xs" href="#Code-formatting-conventions" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Code-formatting-conventions" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>There are the following guidelines regarding the indentation in files:
|
||||
</p>
|
||||
<ul>
|
||||
<li> Indent size is 4.
|
||||
|
||||
</li><li> The TAB character is forbidden outside of Makefiles as is any
|
||||
form of trailing whitespace. Commits containing either will be
|
||||
rejected by the git repository.
|
||||
|
||||
</li><li> You should try to limit your code lines to 80 characters; however, do so if
|
||||
and only if this improves readability.
|
||||
|
||||
</li><li> K&R coding style is used.
|
||||
</li></ul>
|
||||
<p>The presentation is one inspired by ’indent -i4 -kr -nut’.
|
||||
</p>
|
||||
<p>The main priority in FFmpeg is simplicity and small code size in order to
|
||||
minimize the bug count.
|
||||
</p>
|
||||
<a name="Comments"></a>
|
||||
<h4 class="subsection">1.3.2 Comments<span class="pull-right"><a class="anchor hidden-xs" href="#Comments" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Comments" aria-hidden="true">TOC</a></span></h4>
|
||||
<p>Use the JavaDoc/Doxygen format (see examples below) so that code documentation
|
||||
can be generated automatically. All nontrivial functions should have a comment
|
||||
above them explaining what the function does, even if it is just one sentence.
|
||||
All structures and their member variables should be documented, too.
|
||||
</p>
|
||||
<p>Avoid Qt-style and similar Doxygen syntax with <code>!</code> in it, i.e. replace
|
||||
<code>//!</code> with <code>///</code> and similar. Also @ syntax should be employed
|
||||
for markup commands, i.e. use <code>@param</code> and not <code>\param</code>.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">/**
|
||||
* @file
|
||||
* MPEG codec.
|
||||
* @author ...
|
||||
*/
|
||||
|
||||
/**
|
||||
* Summary sentence.
|
||||
* more text ...
|
||||
* ...
|
||||
*/
|
||||
typedef struct Foobar {
|
||||
int var1; /**< var1 description */
|
||||
int var2; ///< var2 description
|
||||
/** var3 description */
|
||||
int var3;
|
||||
} Foobar;
|
||||
|
||||
/**
|
||||
* Summary sentence.
|
||||
* more text ...
|
||||
* ...
|
||||
* @param my_parameter description of my_parameter
|
||||
* @return return value description
|
||||
*/
|
||||
int myfunc(int my_parameter)
|
||||
...
|
||||
</pre></div>
|
||||
|
||||
<a name="C-language-features"></a>
|
||||
<h4 class="subsection">1.3.3 C language features<span class="pull-right"><a class="anchor hidden-xs" href="#C-language-features" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-C-language-features" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>FFmpeg is programmed in the ISO C90 language with a few additional
|
||||
features from ISO C99, namely:
|
||||
</p>
|
||||
<ul>
|
||||
<li> the ‘<samp>inline</samp>’ keyword;
|
||||
|
||||
</li><li> ‘<samp>//</samp>’ comments;
|
||||
|
||||
</li><li> designated struct initializers (‘<samp>struct s x = { .i = 17 };</samp>’);
|
||||
|
||||
</li><li> compound literals (‘<samp>x = (struct s) { 17, 23 };</samp>’).
|
||||
</li></ul>
|
||||
|
||||
<p>These features are supported by all compilers we care about, so we will not
|
||||
accept patches to remove their use unless they absolutely do not impair
|
||||
clarity and performance.
|
||||
</p>
|
||||
<p>All code must compile with recent versions of GCC and a number of other
|
||||
currently supported compilers. To ensure compatibility, please do not use
|
||||
additional C99 features or GCC extensions. Especially watch out for:
|
||||
</p>
|
||||
<ul>
|
||||
<li> mixing statements and declarations;
|
||||
|
||||
</li><li> ‘<samp>long long</samp>’ (use ‘<samp>int64_t</samp>’ instead);
|
||||
|
||||
</li><li> ‘<samp>__attribute__</samp>’ not protected by ‘<samp>#ifdef __GNUC__</samp>’ or similar;
|
||||
|
||||
</li><li> GCC statement expressions (‘<samp>(x = ({ int y = 4; y; })</samp>’).
|
||||
</li></ul>
|
||||
|
||||
<a name="Naming-conventions"></a>
|
||||
<h4 class="subsection">1.3.4 Naming conventions<span class="pull-right"><a class="anchor hidden-xs" href="#Naming-conventions" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Naming-conventions" aria-hidden="true">TOC</a></span></h4>
|
||||
<p>All names should be composed with underscores (_), not CamelCase. For example,
|
||||
‘<samp>avfilter_get_video_buffer</samp>’ is an acceptable function name and
|
||||
‘<samp>AVFilterGetVideo</samp>’ is not. The exception from this are type names, like
|
||||
for example structs and enums; they should always be in CamelCase.
|
||||
</p>
|
||||
<p>There are the following conventions for naming variables and functions:
|
||||
</p>
|
||||
<ul>
|
||||
<li> For local variables no prefix is required.
|
||||
|
||||
</li><li> For file-scope variables and functions declared as <code>static</code>, no prefix
|
||||
is required.
|
||||
|
||||
</li><li> For variables and functions visible outside of file scope, but only used
|
||||
internally by a library, an <code>ff_</code> prefix should be used,
|
||||
e.g. ‘<samp>ff_w64_demuxer</samp>’.
|
||||
|
||||
</li><li> For variables and functions visible outside of file scope, used internally
|
||||
across multiple libraries, use <code>avpriv_</code> as prefix, for example,
|
||||
‘<samp>avpriv_aac_parse_header</samp>’.
|
||||
|
||||
</li><li> Each library has its own prefix for public symbols, in addition to the
|
||||
commonly used <code>av_</code> (<code>avformat_</code> for libavformat,
|
||||
<code>avcodec_</code> for libavcodec, <code>swr_</code> for libswresample, etc).
|
||||
Check the existing code and choose names accordingly.
|
||||
Note that some symbols without these prefixes are also exported for
|
||||
retro-compatibility reasons. These exceptions are declared in the
|
||||
<code>lib<name>/lib<name>.v</code> files.
|
||||
</li></ul>
|
||||
|
||||
<p>Furthermore, name space reserved for the system should not be invaded.
|
||||
Identifiers ending in <code>_t</code> are reserved by
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html#tag_02_02_02">POSIX</a>.
|
||||
Also avoid names starting with <code>__</code> or <code>_</code> followed by an uppercase
|
||||
letter as they are reserved by the C standard. Names starting with <code>_</code>
|
||||
are reserved at the file level and may not be used for externally visible
|
||||
symbols. If in doubt, just avoid names starting with <code>_</code> altogether.
|
||||
</p>
|
||||
<a name="Miscellaneous-conventions"></a>
|
||||
<h4 class="subsection">1.3.5 Miscellaneous conventions<span class="pull-right"><a class="anchor hidden-xs" href="#Miscellaneous-conventions" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Miscellaneous-conventions" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<ul>
|
||||
<li> fprintf and printf are forbidden in libavformat and libavcodec,
|
||||
please use av_log() instead.
|
||||
|
||||
</li><li> Casts should be used only when necessary. Unneeded parentheses
|
||||
should also be avoided if they don’t make the code easier to understand.
|
||||
</li></ul>
|
||||
|
||||
<a name="Editor-configuration"></a>
|
||||
<h4 class="subsection">1.3.6 Editor configuration<span class="pull-right"><a class="anchor hidden-xs" href="#Editor-configuration" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Editor-configuration" aria-hidden="true">TOC</a></span></h4>
|
||||
<p>In order to configure Vim to follow FFmpeg formatting conventions, paste
|
||||
the following snippet into your <samp>.vimrc</samp>:
|
||||
</p><div class="example">
|
||||
<pre class="example">" indentation rules for FFmpeg: 4 spaces, no tabs
|
||||
set expandtab
|
||||
set shiftwidth=4
|
||||
set softtabstop=4
|
||||
set cindent
|
||||
set cinoptions=(0
|
||||
" Allow tabs in Makefiles.
|
||||
autocmd FileType make,automake set noexpandtab shiftwidth=8 softtabstop=8
|
||||
" Trailing whitespace and tabs are forbidden, so highlight them.
|
||||
highlight ForbiddenWhitespace ctermbg=red guibg=red
|
||||
match ForbiddenWhitespace /\s\+$\|\t/
|
||||
" Do not highlight spaces at the end of line while typing on that line.
|
||||
autocmd InsertEnter * match ForbiddenWhitespace /\t\|\s\+\%#\@<!$/
|
||||
</pre></div>
|
||||
|
||||
<p>For Emacs, add these roughly equivalent lines to your <samp>.emacs.d/init.el</samp>:
|
||||
</p><div class="lisp">
|
||||
<pre class="lisp">(c-add-style "ffmpeg"
|
||||
'("k&r"
|
||||
(c-basic-offset . 4)
|
||||
(indent-tabs-mode . nil)
|
||||
(show-trailing-whitespace . t)
|
||||
(c-offsets-alist
|
||||
(statement-cont . (c-lineup-assignments +)))
|
||||
)
|
||||
)
|
||||
(setq c-default-style "ffmpeg")
|
||||
</pre></div>
|
||||
|
||||
<a name="Development-Policy"></a>
|
||||
<h3 class="section">1.4 Development Policy<span class="pull-right"><a class="anchor hidden-xs" href="#Development-Policy" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Development-Policy" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<a name="Patches_002fCommitting"></a>
|
||||
<h4 class="subsection">1.4.1 Patches/Committing<span class="pull-right"><a class="anchor hidden-xs" href="#Patches_002fCommitting" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Patches_002fCommitting" aria-hidden="true">TOC</a></span></h4>
|
||||
<a name="Licenses-for-patches-must-be-compatible-with-FFmpeg_002e"></a>
|
||||
<h4 class="subheading">Licenses for patches must be compatible with FFmpeg.</h4>
|
||||
<p>Contributions should be licensed under the
|
||||
<a href="http://www.gnu.org/licenses/lgpl-2.1.html">LGPL 2.1</a>,
|
||||
including an "or any later version" clause, or, if you prefer
|
||||
a gift-style license, the
|
||||
<a href="http://opensource.org/licenses/isc-license.txt">ISC</a> or
|
||||
<a href="http://mit-license.org/">MIT</a> license.
|
||||
<a href="http://www.gnu.org/licenses/gpl-2.0.html">GPL 2</a> including
|
||||
an "or any later version" clause is also acceptable, but LGPL is
|
||||
preferred.
|
||||
If you add a new file, give it a proper license header. Do not copy and
|
||||
paste it from a random place, use an existing file as template.
|
||||
</p>
|
||||
<a name="You-must-not-commit-code-which-breaks-FFmpeg_0021"></a>
|
||||
<h4 class="subheading">You must not commit code which breaks FFmpeg!</h4>
|
||||
<p>This means unfinished code which is enabled and breaks compilation,
|
||||
or compiles but does not work/breaks the regression tests. Code which
|
||||
is unfinished but disabled may be permitted under-circumstances, like
|
||||
missing samples or an implementation with a small subset of features.
|
||||
Always check the mailing list for any reviewers with issues and test
|
||||
FATE before you push.
|
||||
</p>
|
||||
<a name="Keep-the-main-commit-message-short-with-an-extended-description-below_002e"></a>
|
||||
<h4 class="subheading">Keep the main commit message short with an extended description below.</h4>
|
||||
<p>The commit message should have a short first line in the form of
|
||||
a ‘<samp>topic: short description</samp>’ as a header, separated by a newline
|
||||
from the body consisting of an explanation of why the change is necessary.
|
||||
If the commit fixes a known bug on the bug tracker, the commit message
|
||||
should include its bug ID. Referring to the issue on the bug tracker does
|
||||
not exempt you from writing an excerpt of the bug in the commit message.
|
||||
</p>
|
||||
<a name="Testing-must-be-adequate-but-not-excessive_002e"></a>
|
||||
<h4 class="subheading">Testing must be adequate but not excessive.</h4>
|
||||
<p>If it works for you, others, and passes FATE then it should be OK to commit
|
||||
it, provided it fits the other committing criteria. You should not worry about
|
||||
over-testing things. If your code has problems (portability, triggers
|
||||
compiler bugs, unusual environment etc) they will be reported and eventually
|
||||
fixed.
|
||||
</p>
|
||||
<a name="Do-not-commit-unrelated-changes-together_002e"></a>
|
||||
<h4 class="subheading">Do not commit unrelated changes together.</h4>
|
||||
<p>They should be split them into self-contained pieces. Also do not forget
|
||||
that if part B depends on part A, but A does not depend on B, then A can
|
||||
and should be committed first and separate from B. Keeping changes well
|
||||
split into self-contained parts makes reviewing and understanding them on
|
||||
the commit log mailing list easier. This also helps in case of debugging
|
||||
later on.
|
||||
Also if you have doubts about splitting or not splitting, do not hesitate to
|
||||
ask/discuss it on the developer mailing list.
|
||||
</p>
|
||||
<a name="Ask-before-you-change-the-build-system-_0028configure_002c-etc_0029_002e"></a>
|
||||
<h4 class="subheading">Ask before you change the build system (configure, etc).</h4>
|
||||
<p>Do not commit changes to the build system (Makefiles, configure script)
|
||||
which change behavior, defaults etc, without asking first. The same
|
||||
applies to compiler warning fixes, trivial looking fixes and to code
|
||||
maintained by other developers. We usually have a reason for doing things
|
||||
the way we do. Send your changes as patches to the ffmpeg-devel mailing
|
||||
list, and if the code maintainers say OK, you may commit. This does not
|
||||
apply to files you wrote and/or maintain.
|
||||
</p>
|
||||
<a name="Cosmetic-changes-should-be-kept-in-separate-patches_002e"></a>
|
||||
<h4 class="subheading">Cosmetic changes should be kept in separate patches.</h4>
|
||||
<p>We refuse source indentation and other cosmetic changes if they are mixed
|
||||
with functional changes, such commits will be rejected and removed. Every
|
||||
developer has his own indentation style, you should not change it. Of course
|
||||
if you (re)write something, you can use your own style, even though we would
|
||||
prefer if the indentation throughout FFmpeg was consistent (Many projects
|
||||
force a given indentation style - we do not.). If you really need to make
|
||||
indentation changes (try to avoid this), separate them strictly from real
|
||||
changes.
|
||||
</p>
|
||||
<p>NOTE: If you had to put if(){ .. } over a large (> 5 lines) chunk of code,
|
||||
then either do NOT change the indentation of the inner part within (do not
|
||||
move it to the right)! or do so in a separate commit
|
||||
</p>
|
||||
<a name="Commit-messages-should-always-be-filled-out-properly_002e"></a>
|
||||
<h4 class="subheading">Commit messages should always be filled out properly.</h4>
|
||||
<p>Always fill out the commit log message. Describe in a few lines what you
|
||||
changed and why. You can refer to mailing list postings if you fix a
|
||||
particular bug. Comments such as "fixed!" or "Changed it." are unacceptable.
|
||||
Recommended format:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">area changed: Short 1 line description
|
||||
|
||||
details describing what and why and giving references.
|
||||
</pre></div>
|
||||
|
||||
<a name="Credit-the-author-of-the-patch_002e"></a>
|
||||
<h4 class="subheading">Credit the author of the patch.</h4>
|
||||
<p>Make sure the author of the commit is set correctly. (see git commit –author)
|
||||
If you apply a patch, send an
|
||||
answer to ffmpeg-devel (or wherever you got the patch from) saying that
|
||||
you applied the patch.
|
||||
</p>
|
||||
<a name="Complex-patches-should-refer-to-discussion-surrounding-them_002e"></a>
|
||||
<h4 class="subheading">Complex patches should refer to discussion surrounding them.</h4>
|
||||
<p>When applying patches that have been discussed (at length) on the mailing
|
||||
list, reference the thread in the log message.
|
||||
</p>
|
||||
<a name="Always-wait-long-enough-before-pushing-changes"></a>
|
||||
<h4 class="subheading">Always wait long enough before pushing changes</h4>
|
||||
<p>Do NOT commit to code actively maintained by others without permission.
|
||||
Send a patch to ffmpeg-devel. If no one answers within a reasonable
|
||||
time-frame (12h for build failures and security fixes, 3 days small changes,
|
||||
1 week for big patches) then commit your patch if you think it is OK.
|
||||
Also note, the maintainer can simply ask for more time to review!
|
||||
</p>
|
||||
<a name="Code"></a>
|
||||
<h4 class="subsection">1.4.2 Code<span class="pull-right"><a class="anchor hidden-xs" href="#Code" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Code" aria-hidden="true">TOC</a></span></h4>
|
||||
<a name="API_002fABI-changes-should-be-discussed-before-they-are-made_002e"></a>
|
||||
<h4 class="subheading">API/ABI changes should be discussed before they are made.</h4>
|
||||
<p>Do not change behavior of the programs (renaming options etc) or public
|
||||
API or ABI without first discussing it on the ffmpeg-devel mailing list.
|
||||
Do not remove widely used functionality or features (redundant code can be removed).
|
||||
</p>
|
||||
<a name="Remember-to-check-if-you-need-to-bump-versions-for-libav_002a_002e"></a>
|
||||
<h4 class="subheading">Remember to check if you need to bump versions for libav*.</h4>
|
||||
<p>Depending on the change, you may need to change the version integer.
|
||||
Incrementing the first component means no backward compatibility to
|
||||
previous versions (e.g. removal of a function from the public API).
|
||||
Incrementing the second component means backward compatible change
|
||||
(e.g. addition of a function to the public API or extension of an
|
||||
existing data structure).
|
||||
Incrementing the third component means a noteworthy binary compatible
|
||||
change (e.g. encoder bug fix that matters for the decoder). The third
|
||||
component always starts at 100 to distinguish FFmpeg from Libav.
|
||||
</p>
|
||||
<a name="Warnings-for-correct-code-may-be-disabled-if-there-is-no-other-option_002e"></a>
|
||||
<h4 class="subheading">Warnings for correct code may be disabled if there is no other option.</h4>
|
||||
<p>Compiler warnings indicate potential bugs or code with bad style. If a type of
|
||||
warning always points to correct and clean code, that warning should
|
||||
be disabled, not the code changed.
|
||||
Thus the remaining warnings can either be bugs or correct code.
|
||||
If it is a bug, the bug has to be fixed. If it is not, the code should
|
||||
be changed to not generate a warning unless that causes a slowdown
|
||||
or obfuscates the code.
|
||||
</p>
|
||||
<a name="Check-untrusted-input-properly_002e"></a>
|
||||
<h4 class="subheading">Check untrusted input properly.</h4>
|
||||
<p>Never write to unallocated memory, never write over the end of arrays,
|
||||
always check values read from some untrusted source before using them
|
||||
as array index or other risky things.
|
||||
</p>
|
||||
<a name="Documentation_002fOther"></a>
|
||||
<h4 class="subsection">1.4.3 Documentation/Other<span class="pull-right"><a class="anchor hidden-xs" href="#Documentation_002fOther" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Documentation_002fOther" aria-hidden="true">TOC</a></span></h4>
|
||||
<a name="Subscribe-to-the-ffmpeg_002dcvslog-mailing-list_002e"></a>
|
||||
<h4 class="subheading">Subscribe to the ffmpeg-cvslog mailing list.</h4>
|
||||
<p>It is important to do this as the diffs of all commits are sent there and
|
||||
reviewed by all the other developers. Bugs and possible improvements or
|
||||
general questions regarding commits are discussed there. We expect you to
|
||||
react if problems with your code are uncovered.
|
||||
</p>
|
||||
<a name="Keep-the-documentation-up-to-date_002e"></a>
|
||||
<h4 class="subheading">Keep the documentation up to date.</h4>
|
||||
<p>Update the documentation if you change behavior or add features. If you are
|
||||
unsure how best to do this, send a patch to ffmpeg-devel, the documentation
|
||||
maintainer(s) will review and commit your stuff.
|
||||
</p>
|
||||
<a name="Important-discussions-should-be-accessible-to-all_002e"></a>
|
||||
<h4 class="subheading">Important discussions should be accessible to all.</h4>
|
||||
<p>Try to keep important discussions and requests (also) on the public
|
||||
developer mailing list, so that all developers can benefit from them.
|
||||
</p>
|
||||
<a name="Check-your-entries-in-MAINTAINERS_002e"></a>
|
||||
<h4 class="subheading">Check your entries in MAINTAINERS.</h4>
|
||||
<p>Make sure that no parts of the codebase that you maintain are missing from the
|
||||
<samp>MAINTAINERS</samp> file. If something that you want to maintain is missing add it with
|
||||
your name after it.
|
||||
If at some point you no longer want to maintain some code, then please help in
|
||||
finding a new maintainer and also don’t forget to update the <samp>MAINTAINERS</samp> file.
|
||||
</p>
|
||||
<p>We think our rules are not too hard. If you have comments, contact us.
|
||||
</p>
|
||||
<a name="Code-of-conduct"></a>
|
||||
<h3 class="section">1.5 Code of conduct<span class="pull-right"><a class="anchor hidden-xs" href="#Code-of-conduct" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Code-of-conduct" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Be friendly and respectful towards others and third parties.
|
||||
Treat others the way you yourself want to be treated.
|
||||
</p>
|
||||
<p>Be considerate. Not everyone shares the same viewpoint and priorities as you do.
|
||||
Different opinions and interpretations help the project.
|
||||
Looking at issues from a different perspective assists development.
|
||||
</p>
|
||||
<p>Do not assume malice for things that can be attributed to incompetence. Even if
|
||||
it is malice, it’s rarely good to start with that as initial assumption.
|
||||
</p>
|
||||
<p>Stay friendly even if someone acts contrarily. Everyone has a bad day
|
||||
once in a while.
|
||||
If you yourself have a bad day or are angry then try to take a break and reply
|
||||
once you are calm and without anger if you have to.
|
||||
</p>
|
||||
<p>Try to help other team members and cooperate if you can.
|
||||
</p>
|
||||
<p>The goal of software development is to create technical excellence, not for any
|
||||
individual to be better and "win" against the others. Large software projects
|
||||
are only possible and successful through teamwork.
|
||||
</p>
|
||||
<p>If someone struggles do not put them down. Give them a helping hand
|
||||
instead and point them in the right direction.
|
||||
</p>
|
||||
<p>Finally, keep in mind the immortal words of Bill and Ted,
|
||||
"Be excellent to each other."
|
||||
</p>
|
||||
<a name="Submitting-patches"></a><a name="Submitting-patches-1"></a>
|
||||
<h3 class="section">1.6 Submitting patches<span class="pull-right"><a class="anchor hidden-xs" href="#Submitting-patches-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Submitting-patches-1" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>First, read the <a href="#Coding-Rules">Coding Rules</a> above if you did not yet, in particular
|
||||
the rules regarding patch submission.
|
||||
</p>
|
||||
<p>When you submit your patch, please use <code>git format-patch</code> or
|
||||
<code>git send-email</code>. We cannot read other diffs :-).
|
||||
</p>
|
||||
<p>Also please do not submit a patch which contains several unrelated changes.
|
||||
Split it into separate, self-contained pieces. This does not mean splitting
|
||||
file by file. Instead, make the patch as small as possible while still
|
||||
keeping it as a logical unit that contains an individual change, even
|
||||
if it spans multiple files. This makes reviewing your patches much easier
|
||||
for us and greatly increases your chances of getting your patch applied.
|
||||
</p>
|
||||
<p>Use the patcheck tool of FFmpeg to check your patch.
|
||||
The tool is located in the tools directory.
|
||||
</p>
|
||||
<p>Run the <a href="#Regression-tests">Regression tests</a> before submitting a patch in order to verify
|
||||
it does not cause unexpected problems.
|
||||
</p>
|
||||
<p>It also helps quite a bit if you tell us what the patch does (for example
|
||||
’replaces lrint by lrintf’), and why (for example ’*BSD isn’t C99 compliant
|
||||
and has no lrint()’)
|
||||
</p>
|
||||
<p>Also please if you send several patches, send each patch as a separate mail,
|
||||
do not attach several unrelated patches to the same mail.
|
||||
</p>
|
||||
<p>Patches should be posted to the
|
||||
<a href="https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-devel">ffmpeg-devel</a>
|
||||
mailing list. Use <code>git send-email</code> when possible since it will properly
|
||||
send patches without requiring extra care. If you cannot, then send patches
|
||||
as base64-encoded attachments, so your patch is not trashed during
|
||||
transmission. Also ensure the correct mime type is used
|
||||
(text/x-diff or text/x-patch or at least text/plain) and that only one
|
||||
patch is inline or attached per mail.
|
||||
You can check <a href="https://patchwork.ffmpeg.org">https://patchwork.ffmpeg.org</a>, if your patch does not show up, its mime type
|
||||
likely was wrong.
|
||||
</p>
|
||||
<p>Your patch will be reviewed on the mailing list. You will likely be asked
|
||||
to make some changes and are expected to send in an improved version that
|
||||
incorporates the requests from the review. This process may go through
|
||||
several iterations. Once your patch is deemed good enough, some developer
|
||||
will pick it up and commit it to the official FFmpeg tree.
|
||||
</p>
|
||||
<p>Give us a few days to react. But if some time passes without reaction,
|
||||
send a reminder by email. Your patch should eventually be dealt with.
|
||||
</p>
|
||||
|
||||
<a name="New-codecs-or-formats-checklist"></a>
|
||||
<h3 class="section">1.7 New codecs or formats checklist<span class="pull-right"><a class="anchor hidden-xs" href="#New-codecs-or-formats-checklist" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-New-codecs-or-formats-checklist" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<ol>
|
||||
<li> Did you use av_cold for codec initialization and close functions?
|
||||
|
||||
</li><li> Did you add a long_name under NULL_IF_CONFIG_SMALL to the AVCodec or
|
||||
AVInputFormat/AVOutputFormat struct?
|
||||
|
||||
</li><li> Did you bump the minor version number (and reset the micro version
|
||||
number) in <samp>libavcodec/version.h</samp> or <samp>libavformat/version.h</samp>?
|
||||
|
||||
</li><li> Did you register it in <samp>allcodecs.c</samp> or <samp>allformats.c</samp>?
|
||||
|
||||
</li><li> Did you add the AVCodecID to <samp>avcodec.h</samp>?
|
||||
When adding new codec IDs, also add an entry to the codec descriptor
|
||||
list in <samp>libavcodec/codec_desc.c</samp>.
|
||||
|
||||
</li><li> If it has a FourCC, did you add it to <samp>libavformat/riff.c</samp>,
|
||||
even if it is only a decoder?
|
||||
|
||||
</li><li> Did you add a rule to compile the appropriate files in the Makefile?
|
||||
Remember to do this even if you’re just adding a format to a file that is
|
||||
already being compiled by some other rule, like a raw demuxer.
|
||||
|
||||
</li><li> Did you add an entry to the table of supported formats or codecs in
|
||||
<samp>doc/general.texi</samp>?
|
||||
|
||||
</li><li> Did you add an entry in the Changelog?
|
||||
|
||||
</li><li> If it depends on a parser or a library, did you add that dependency in
|
||||
configure?
|
||||
|
||||
</li><li> Did you <code>git add</code> the appropriate files before committing?
|
||||
|
||||
</li><li> Did you make sure it compiles standalone, i.e. with
|
||||
<code>configure --disable-everything --enable-decoder=foo</code>
|
||||
(or <code>--enable-demuxer</code> or whatever your component is)?
|
||||
</li></ol>
|
||||
|
||||
|
||||
<a name="patch-submission-checklist"></a>
|
||||
<h3 class="section">1.8 patch submission checklist<span class="pull-right"><a class="anchor hidden-xs" href="#patch-submission-checklist" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-patch-submission-checklist" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<ol>
|
||||
<li> Does <code>make fate</code> pass with the patch applied?
|
||||
|
||||
</li><li> Was the patch generated with git format-patch or send-email?
|
||||
|
||||
</li><li> Did you sign off your patch? (git commit -s)
|
||||
See <a href="http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob_plain;f=Documentation/SubmittingPatches">http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob_plain;f=Documentation/SubmittingPatches</a> for the meaning
|
||||
of sign off.
|
||||
|
||||
</li><li> Did you provide a clear git commit log message?
|
||||
|
||||
</li><li> Is the patch against latest FFmpeg git master branch?
|
||||
|
||||
</li><li> Are you subscribed to ffmpeg-devel?
|
||||
(the list is subscribers only due to spam)
|
||||
|
||||
</li><li> Have you checked that the changes are minimal, so that the same cannot be
|
||||
achieved with a smaller patch and/or simpler final code?
|
||||
|
||||
</li><li> If the change is to speed critical code, did you benchmark it?
|
||||
|
||||
</li><li> If you did any benchmarks, did you provide them in the mail?
|
||||
|
||||
</li><li> Have you checked that the patch does not introduce buffer overflows or
|
||||
other security issues?
|
||||
|
||||
</li><li> Did you test your decoder or demuxer against damaged data? If no, see
|
||||
tools/trasher, the noise bitstream filter, and
|
||||
<a href="http://caca.zoy.org/wiki/zzuf">zzuf</a>. Your decoder or demuxer
|
||||
should not crash, end in a (near) infinite loop, or allocate ridiculous
|
||||
amounts of memory when fed damaged data.
|
||||
|
||||
</li><li> Did you test your decoder or demuxer against sample files?
|
||||
Samples may be obtained at <a href="https://samples.ffmpeg.org">https://samples.ffmpeg.org</a>.
|
||||
|
||||
</li><li> Does the patch not mix functional and cosmetic changes?
|
||||
|
||||
</li><li> Did you add tabs or trailing whitespace to the code? Both are forbidden.
|
||||
|
||||
</li><li> Is the patch attached to the email you send?
|
||||
|
||||
</li><li> Is the mime type of the patch correct? It should be text/x-diff or
|
||||
text/x-patch or at least text/plain and not application/octet-stream.
|
||||
|
||||
</li><li> If the patch fixes a bug, did you provide a verbose analysis of the bug?
|
||||
|
||||
</li><li> If the patch fixes a bug, did you provide enough information, including
|
||||
a sample, so the bug can be reproduced and the fix can be verified?
|
||||
Note please do not attach samples >100k to mails but rather provide a
|
||||
URL, you can upload to ftp://upload.ffmpeg.org.
|
||||
|
||||
</li><li> Did you provide a verbose summary about what the patch does change?
|
||||
|
||||
</li><li> Did you provide a verbose explanation why it changes things like it does?
|
||||
|
||||
</li><li> Did you provide a verbose summary of the user visible advantages and
|
||||
disadvantages if the patch is applied?
|
||||
|
||||
</li><li> Did you provide an example so we can verify the new feature added by the
|
||||
patch easily?
|
||||
|
||||
</li><li> If you added a new file, did you insert a license header? It should be
|
||||
taken from FFmpeg, not randomly copied and pasted from somewhere else.
|
||||
|
||||
</li><li> You should maintain alphabetical order in alphabetically ordered lists as
|
||||
long as doing so does not break API/ABI compatibility.
|
||||
|
||||
</li><li> Lines with similar content should be aligned vertically when doing so
|
||||
improves readability.
|
||||
|
||||
</li><li> Consider adding a regression test for your code.
|
||||
|
||||
</li><li> If you added YASM code please check that things still work with –disable-yasm.
|
||||
|
||||
</li><li> Make sure you check the return values of function and return appropriate
|
||||
error codes. Especially memory allocation functions like <code>av_malloc()</code>
|
||||
are notoriously left unchecked, which is a serious problem.
|
||||
|
||||
</li><li> Test your code with valgrind and or Address Sanitizer to ensure it’s free
|
||||
of leaks, out of array accesses, etc.
|
||||
</li></ol>
|
||||
|
||||
<a name="Patch-review-process"></a>
|
||||
<h3 class="section">1.9 Patch review process<span class="pull-right"><a class="anchor hidden-xs" href="#Patch-review-process" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Patch-review-process" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>All patches posted to ffmpeg-devel will be reviewed, unless they contain a
|
||||
clear note that the patch is not for the git master branch.
|
||||
Reviews and comments will be posted as replies to the patch on the
|
||||
mailing list. The patch submitter then has to take care of every comment,
|
||||
that can be by resubmitting a changed patch or by discussion. Resubmitted
|
||||
patches will themselves be reviewed like any other patch. If at some point
|
||||
a patch passes review with no comments then it is approved, that can for
|
||||
simple and small patches happen immediately while large patches will generally
|
||||
have to be changed and reviewed many times before they are approved.
|
||||
After a patch is approved it will be committed to the repository.
|
||||
</p>
|
||||
<p>We will review all submitted patches, but sometimes we are quite busy so
|
||||
especially for large patches this can take several weeks.
|
||||
</p>
|
||||
<p>If you feel that the review process is too slow and you are willing to try to
|
||||
take over maintainership of the area of code you change then just clone
|
||||
git master and maintain the area of code there. We will merge each area from
|
||||
where its best maintained.
|
||||
</p>
|
||||
<p>When resubmitting patches, please do not make any significant changes
|
||||
not related to the comments received during review. Such patches will
|
||||
be rejected. Instead, submit significant changes or new features as
|
||||
separate patches.
|
||||
</p>
|
||||
<p>Everyone is welcome to review patches. Also if you are waiting for your patch
|
||||
to be reviewed, please consider helping to review other patches, that is a great
|
||||
way to get everyone’s patches reviewed sooner.
|
||||
</p>
|
||||
<a name="Regression-tests"></a><a name="Regression-tests-1"></a>
|
||||
<h3 class="section">1.10 Regression tests<span class="pull-right"><a class="anchor hidden-xs" href="#Regression-tests-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Regression-tests-1" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Before submitting a patch (or committing to the repository), you should at least
|
||||
test that you did not break anything.
|
||||
</p>
|
||||
<p>Running ’make fate’ accomplishes this, please see <a href="fate.html">fate.html</a> for details.
|
||||
</p>
|
||||
<p>[Of course, some patches may change the results of the regression tests. In
|
||||
this case, the reference results of the regression tests shall be modified
|
||||
accordingly].
|
||||
</p>
|
||||
<a name="Adding-files-to-the-fate_002dsuite-dataset"></a>
|
||||
<h4 class="subsection">1.10.1 Adding files to the fate-suite dataset<span class="pull-right"><a class="anchor hidden-xs" href="#Adding-files-to-the-fate_002dsuite-dataset" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Adding-files-to-the-fate_002dsuite-dataset" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>When there is no muxer or encoder available to generate test media for a
|
||||
specific test then the media has to be included in the fate-suite.
|
||||
First please make sure that the sample file is as small as possible to test the
|
||||
respective decoder or demuxer sufficiently. Large files increase network
|
||||
bandwidth and disk space requirements.
|
||||
Once you have a working fate test and fate sample, provide in the commit
|
||||
message or introductory message for the patch series that you post to
|
||||
the ffmpeg-devel mailing list, a direct link to download the sample media.
|
||||
</p>
|
||||
<a name="Visualizing-Test-Coverage"></a>
|
||||
<h4 class="subsection">1.10.2 Visualizing Test Coverage<span class="pull-right"><a class="anchor hidden-xs" href="#Visualizing-Test-Coverage" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Visualizing-Test-Coverage" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>The FFmpeg build system allows visualizing the test coverage in an easy
|
||||
manner with the coverage tools <code>gcov</code>/<code>lcov</code>. This involves
|
||||
the following steps:
|
||||
</p>
|
||||
<ol>
|
||||
<li> Configure to compile with instrumentation enabled:
|
||||
<code>configure --toolchain=gcov</code>.
|
||||
|
||||
</li><li> Run your test case, either manually or via FATE. This can be either
|
||||
the full FATE regression suite, or any arbitrary invocation of any
|
||||
front-end tool provided by FFmpeg, in any combination.
|
||||
|
||||
</li><li> Run <code>make lcov</code> to generate coverage data in HTML format.
|
||||
|
||||
</li><li> View <code>lcov/index.html</code> in your preferred HTML viewer.
|
||||
</li></ol>
|
||||
|
||||
<p>You can use the command <code>make lcov-reset</code> to reset the coverage
|
||||
measurements. You will need to rerun <code>make lcov</code> after running a
|
||||
new test.
|
||||
</p>
|
||||
<a name="Using-Valgrind"></a>
|
||||
<h4 class="subsection">1.10.3 Using Valgrind<span class="pull-right"><a class="anchor hidden-xs" href="#Using-Valgrind" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Using-Valgrind" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>The configure script provides a shortcut for using valgrind to spot bugs
|
||||
related to memory handling. Just add the option
|
||||
<code>--toolchain=valgrind-memcheck</code> or <code>--toolchain=valgrind-massif</code>
|
||||
to your configure line, and reasonable defaults will be set for running
|
||||
FATE under the supervision of either the <strong>memcheck</strong> or the
|
||||
<strong>massif</strong> tool of the valgrind suite.
|
||||
</p>
|
||||
<p>In case you need finer control over how valgrind is invoked, use the
|
||||
<code>--target-exec='valgrind <your_custom_valgrind_options></code> option in
|
||||
your configure line instead.
|
||||
</p>
|
||||
<a name="Release-process"></a><a name="Release-process-1"></a>
|
||||
<h3 class="section">1.11 Release process<span class="pull-right"><a class="anchor hidden-xs" href="#Release-process-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Release-process-1" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>FFmpeg maintains a set of <strong>release branches</strong>, which are the
|
||||
recommended deliverable for system integrators and distributors (such as
|
||||
Linux distributions, etc.). At regular times, a <strong>release
|
||||
manager</strong> prepares, tests and publishes tarballs on the
|
||||
<a href="https://ffmpeg.org">https://ffmpeg.org</a> website.
|
||||
</p>
|
||||
<p>There are two kinds of releases:
|
||||
</p>
|
||||
<ol>
|
||||
<li> <strong>Major releases</strong> always include the latest and greatest
|
||||
features and functionality.
|
||||
|
||||
</li><li> <strong>Point releases</strong> are cut from <strong>release</strong> branches,
|
||||
which are named <code>release/X</code>, with <code>X</code> being the release
|
||||
version number.
|
||||
</li></ol>
|
||||
|
||||
<p>Note that we promise to our users that shared libraries from any FFmpeg
|
||||
release never break programs that have been <strong>compiled</strong> against
|
||||
previous versions of <strong>the same release series</strong> in any case!
|
||||
</p>
|
||||
<p>However, from time to time, we do make API changes that require adaptations
|
||||
in applications. Such changes are only allowed in (new) major releases and
|
||||
require further steps such as bumping library version numbers and/or
|
||||
adjustments to the symbol versioning file. Please discuss such changes
|
||||
on the <strong>ffmpeg-devel</strong> mailing list in time to allow forward planning.
|
||||
</p>
|
||||
<a name="Criteria-for-Point-Releases"></a><a name="Criteria-for-Point-Releases-1"></a>
|
||||
<h4 class="subsection">1.11.1 Criteria for Point Releases<span class="pull-right"><a class="anchor hidden-xs" href="#Criteria-for-Point-Releases-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Criteria-for-Point-Releases-1" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>Changes that match the following criteria are valid candidates for
|
||||
inclusion into a point release:
|
||||
</p>
|
||||
<ol>
|
||||
<li> Fixes a security issue, preferably identified by a <strong>CVE
|
||||
number</strong> issued by <a href="http://cve.mitre.org/">http://cve.mitre.org/</a>.
|
||||
|
||||
</li><li> Fixes a documented bug in <a href="https://trac.ffmpeg.org">https://trac.ffmpeg.org</a>.
|
||||
|
||||
</li><li> Improves the included documentation.
|
||||
|
||||
</li><li> Retains both source code and binary compatibility with previous
|
||||
point releases of the same release branch.
|
||||
</li></ol>
|
||||
|
||||
<p>The order for checking the rules is (1 OR 2 OR 3) AND 4.
|
||||
</p>
|
||||
|
||||
<a name="Release-Checklist"></a>
|
||||
<h4 class="subsection">1.11.2 Release Checklist<span class="pull-right"><a class="anchor hidden-xs" href="#Release-Checklist" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Release-Checklist" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>The release process involves the following steps:
|
||||
</p>
|
||||
<ol>
|
||||
<li> Ensure that the <samp>RELEASE</samp> file contains the version number for
|
||||
the upcoming release.
|
||||
|
||||
</li><li> Add the release at <a href="https://trac.ffmpeg.org/admin/ticket/versions">https://trac.ffmpeg.org/admin/ticket/versions</a>.
|
||||
|
||||
</li><li> Announce the intent to do a release to the mailing list.
|
||||
|
||||
</li><li> Make sure all relevant security fixes have been backported. See
|
||||
<a href="https://ffmpeg.org/security.html">https://ffmpeg.org/security.html</a>.
|
||||
|
||||
</li><li> Ensure that the FATE regression suite still passes in the release
|
||||
branch on at least <strong>i386</strong> and <strong>amd64</strong>
|
||||
(cf. <a href="#Regression-tests">Regression tests</a>).
|
||||
|
||||
</li><li> Prepare the release tarballs in <code>bz2</code> and <code>gz</code> formats, and
|
||||
supplementing files that contain <code>gpg</code> signatures
|
||||
|
||||
</li><li> Publish the tarballs at <a href="https://ffmpeg.org/releases">https://ffmpeg.org/releases</a>. Create and
|
||||
push an annotated tag in the form <code>nX</code>, with <code>X</code>
|
||||
containing the version number.
|
||||
|
||||
</li><li> Propose and send a patch to the <strong>ffmpeg-devel</strong> mailing list
|
||||
with a news entry for the website.
|
||||
|
||||
</li><li> Publish the news entry.
|
||||
|
||||
</li><li> Send an announcement to the mailing list.
|
||||
</li></ol>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,46 +0,0 @@
|
||||
# use pkg-config for getting CFLAGS and LDLIBS
|
||||
FFMPEG_LIBS= libavdevice \
|
||||
libavformat \
|
||||
libavfilter \
|
||||
libavcodec \
|
||||
libswresample \
|
||||
libswscale \
|
||||
libavutil \
|
||||
|
||||
CFLAGS += -Wall -g
|
||||
CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
|
||||
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)
|
||||
|
||||
EXAMPLES= avio_dir_cmd \
|
||||
avio_reading \
|
||||
decoding_encoding \
|
||||
demuxing_decoding \
|
||||
extract_mvs \
|
||||
filtering_video \
|
||||
filtering_audio \
|
||||
http_multiclient \
|
||||
metadata \
|
||||
muxing \
|
||||
remuxing \
|
||||
resampling_audio \
|
||||
scaling_video \
|
||||
transcode_aac \
|
||||
transcoding \
|
||||
|
||||
OBJS=$(addsuffix .o,$(EXAMPLES))
|
||||
|
||||
# the following examples make explicit use of the math library
|
||||
avcodec: LDLIBS += -lm
|
||||
decoding_encoding: LDLIBS += -lm
|
||||
muxing: LDLIBS += -lm
|
||||
resampling_audio: LDLIBS += -lm
|
||||
|
||||
.phony: all clean-test clean
|
||||
|
||||
all: $(OBJS) $(EXAMPLES)
|
||||
|
||||
clean-test:
|
||||
$(RM) test*.pgm test.h264 test.mp2 test.sw test.mpg
|
||||
|
||||
clean: clean-test
|
||||
$(RM) $(EXAMPLES) $(OBJS)
|
@ -1,23 +0,0 @@
|
||||
FFmpeg examples README
|
||||
----------------------
|
||||
|
||||
Both following use cases rely on pkg-config and make, thus make sure
|
||||
that you have them installed and working on your system.
|
||||
|
||||
|
||||
Method 1: build the installed examples in a generic read/write user directory
|
||||
|
||||
Copy to a read/write user directory and just use "make", it will link
|
||||
to the libraries on your system, assuming the PKG_CONFIG_PATH is
|
||||
correctly configured.
|
||||
|
||||
Method 2: build the examples in-tree
|
||||
|
||||
Assuming you are in the source FFmpeg checkout directory, you need to build
|
||||
FFmpeg (no need to make install in any prefix). Then just run "make examples".
|
||||
This will build the examples using the FFmpeg build system. You can clean those
|
||||
examples using "make examplesclean"
|
||||
|
||||
If you want to try the dedicated Makefile examples (to emulate the first
|
||||
method), go into doc/examples and run a command such as
|
||||
PKG_CONFIG_PATH=pc-uninstalled make.
|
@ -1,180 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Lukasz Marek
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavformat/avio.h>
|
||||
|
||||
static const char *type_string(int type)
|
||||
{
|
||||
switch (type) {
|
||||
case AVIO_ENTRY_DIRECTORY:
|
||||
return "<DIR>";
|
||||
case AVIO_ENTRY_FILE:
|
||||
return "<FILE>";
|
||||
case AVIO_ENTRY_BLOCK_DEVICE:
|
||||
return "<BLOCK DEVICE>";
|
||||
case AVIO_ENTRY_CHARACTER_DEVICE:
|
||||
return "<CHARACTER DEVICE>";
|
||||
case AVIO_ENTRY_NAMED_PIPE:
|
||||
return "<PIPE>";
|
||||
case AVIO_ENTRY_SYMBOLIC_LINK:
|
||||
return "<LINK>";
|
||||
case AVIO_ENTRY_SOCKET:
|
||||
return "<SOCKET>";
|
||||
case AVIO_ENTRY_SERVER:
|
||||
return "<SERVER>";
|
||||
case AVIO_ENTRY_SHARE:
|
||||
return "<SHARE>";
|
||||
case AVIO_ENTRY_WORKGROUP:
|
||||
return "<WORKGROUP>";
|
||||
case AVIO_ENTRY_UNKNOWN:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "<UNKNOWN>";
|
||||
}
|
||||
|
||||
static int list_op(const char *input_dir)
|
||||
{
|
||||
AVIODirEntry *entry = NULL;
|
||||
AVIODirContext *ctx = NULL;
|
||||
int cnt, ret;
|
||||
char filemode[4], uid_and_gid[20];
|
||||
|
||||
if ((ret = avio_open_dir(&ctx, input_dir, NULL)) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot open directory: %s.\n", av_err2str(ret));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
cnt = 0;
|
||||
for (;;) {
|
||||
if ((ret = avio_read_dir(ctx, &entry)) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot list directory: %s.\n", av_err2str(ret));
|
||||
goto fail;
|
||||
}
|
||||
if (!entry)
|
||||
break;
|
||||
if (entry->filemode == -1) {
|
||||
snprintf(filemode, 4, "???");
|
||||
} else {
|
||||
snprintf(filemode, 4, "%3"PRIo64, entry->filemode);
|
||||
}
|
||||
snprintf(uid_and_gid, 20, "%"PRId64"(%"PRId64")", entry->user_id, entry->group_id);
|
||||
if (cnt == 0)
|
||||
av_log(NULL, AV_LOG_INFO, "%-9s %12s %30s %10s %s %16s %16s %16s\n",
|
||||
"TYPE", "SIZE", "NAME", "UID(GID)", "UGO", "MODIFIED",
|
||||
"ACCESSED", "STATUS_CHANGED");
|
||||
av_log(NULL, AV_LOG_INFO, "%-9s %12"PRId64" %30s %10s %s %16"PRId64" %16"PRId64" %16"PRId64"\n",
|
||||
type_string(entry->type),
|
||||
entry->size,
|
||||
entry->name,
|
||||
uid_and_gid,
|
||||
filemode,
|
||||
entry->modification_timestamp,
|
||||
entry->access_timestamp,
|
||||
entry->status_change_timestamp);
|
||||
avio_free_directory_entry(&entry);
|
||||
cnt++;
|
||||
};
|
||||
|
||||
fail:
|
||||
avio_close_dir(&ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int del_op(const char *url)
|
||||
{
|
||||
int ret = avpriv_io_delete(url);
|
||||
if (ret < 0)
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot delete '%s': %s.\n", url, av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int move_op(const char *src, const char *dst)
|
||||
{
|
||||
int ret = avpriv_io_move(src, dst);
|
||||
if (ret < 0)
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot move '%s' into '%s': %s.\n", src, dst, av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void usage(const char *program_name)
|
||||
{
|
||||
fprintf(stderr, "usage: %s OPERATION entry1 [entry2]\n"
|
||||
"API example program to show how to manipulate resources "
|
||||
"accessed through AVIOContext.\n"
|
||||
"OPERATIONS:\n"
|
||||
"list list content of the directory\n"
|
||||
"move rename content in directory\n"
|
||||
"del delete content in directory\n",
|
||||
program_name);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *op = NULL;
|
||||
int ret;
|
||||
|
||||
av_log_set_level(AV_LOG_DEBUG);
|
||||
|
||||
if (argc < 2) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* register codecs and formats and other lavf/lavc components*/
|
||||
av_register_all();
|
||||
avformat_network_init();
|
||||
|
||||
op = argv[1];
|
||||
if (strcmp(op, "list") == 0) {
|
||||
if (argc < 3) {
|
||||
av_log(NULL, AV_LOG_INFO, "Missing argument for list operation.\n");
|
||||
ret = AVERROR(EINVAL);
|
||||
} else {
|
||||
ret = list_op(argv[2]);
|
||||
}
|
||||
} else if (strcmp(op, "del") == 0) {
|
||||
if (argc < 3) {
|
||||
av_log(NULL, AV_LOG_INFO, "Missing argument for del operation.\n");
|
||||
ret = AVERROR(EINVAL);
|
||||
} else {
|
||||
ret = del_op(argv[2]);
|
||||
}
|
||||
} else if (strcmp(op, "move") == 0) {
|
||||
if (argc < 4) {
|
||||
av_log(NULL, AV_LOG_INFO, "Missing argument for move operation.\n");
|
||||
ret = AVERROR(EINVAL);
|
||||
} else {
|
||||
ret = move_op(argv[2], argv[3]);
|
||||
}
|
||||
} else {
|
||||
av_log(NULL, AV_LOG_INFO, "Invalid operation %s\n", op);
|
||||
ret = AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
avformat_network_deinit();
|
||||
|
||||
return ret < 0 ? 1 : 0;
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Stefano Sabatini
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* libavformat AVIOContext API example.
|
||||
*
|
||||
* Make libavformat demuxer access media content through a custom
|
||||
* AVIOContext read callback.
|
||||
* @example avio_reading.c
|
||||
*/
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavformat/avio.h>
|
||||
#include <libavutil/file.h>
|
||||
|
||||
struct buffer_data {
|
||||
uint8_t *ptr;
|
||||
size_t size; ///< size left in the buffer
|
||||
};
|
||||
|
||||
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
|
||||
{
|
||||
struct buffer_data *bd = (struct buffer_data *)opaque;
|
||||
buf_size = FFMIN(buf_size, bd->size);
|
||||
|
||||
printf("ptr:%p size:%zu\n", bd->ptr, bd->size);
|
||||
|
||||
/* copy internal buffer data to buf */
|
||||
memcpy(buf, bd->ptr, buf_size);
|
||||
bd->ptr += buf_size;
|
||||
bd->size -= buf_size;
|
||||
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
AVFormatContext *fmt_ctx = NULL;
|
||||
AVIOContext *avio_ctx = NULL;
|
||||
uint8_t *buffer = NULL, *avio_ctx_buffer = NULL;
|
||||
size_t buffer_size, avio_ctx_buffer_size = 4096;
|
||||
char *input_filename = NULL;
|
||||
int ret = 0;
|
||||
struct buffer_data bd = { 0 };
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: %s input_file\n"
|
||||
"API example program to show how to read from a custom buffer "
|
||||
"accessed through AVIOContext.\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
input_filename = argv[1];
|
||||
|
||||
/* register codecs and formats and other lavf/lavc components*/
|
||||
av_register_all();
|
||||
|
||||
/* slurp file content into buffer */
|
||||
ret = av_file_map(input_filename, &buffer, &buffer_size, 0, NULL);
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
|
||||
/* fill opaque structure used by the AVIOContext read callback */
|
||||
bd.ptr = buffer;
|
||||
bd.size = buffer_size;
|
||||
|
||||
if (!(fmt_ctx = avformat_alloc_context())) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
|
||||
avio_ctx_buffer = av_malloc(avio_ctx_buffer_size);
|
||||
if (!avio_ctx_buffer) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
avio_ctx = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size,
|
||||
0, &bd, &read_packet, NULL, NULL);
|
||||
if (!avio_ctx) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
fmt_ctx->pb = avio_ctx;
|
||||
|
||||
ret = avformat_open_input(&fmt_ctx, NULL, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not open input\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = avformat_find_stream_info(fmt_ctx, NULL);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not find stream information\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
av_dump_format(fmt_ctx, 0, input_filename, 0);
|
||||
|
||||
end:
|
||||
avformat_close_input(&fmt_ctx);
|
||||
/* note: the internal buffer could have changed, and be != avio_ctx_buffer */
|
||||
if (avio_ctx) {
|
||||
av_freep(&avio_ctx->buffer);
|
||||
av_freep(&avio_ctx);
|
||||
}
|
||||
av_file_unmap(buffer, buffer_size);
|
||||
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,665 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* libavcodec API use example.
|
||||
*
|
||||
* @example decoding_encoding.c
|
||||
* Note that libavcodec only handles codecs (MPEG, MPEG-4, etc...),
|
||||
* not file formats (AVI, VOB, MP4, MOV, MKV, MXF, FLV, MPEG-TS, MPEG-PS, etc...).
|
||||
* See library 'libavformat' for the format handling
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <libavutil/opt.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavutil/channel_layout.h>
|
||||
#include <libavutil/common.h>
|
||||
#include <libavutil/imgutils.h>
|
||||
#include <libavutil/mathematics.h>
|
||||
#include <libavutil/samplefmt.h>
|
||||
|
||||
#define INBUF_SIZE 4096
|
||||
#define AUDIO_INBUF_SIZE 20480
|
||||
#define AUDIO_REFILL_THRESH 4096
|
||||
|
||||
/* check that a given sample format is supported by the encoder */
|
||||
static int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt)
|
||||
{
|
||||
const enum AVSampleFormat *p = codec->sample_fmts;
|
||||
|
||||
while (*p != AV_SAMPLE_FMT_NONE) {
|
||||
if (*p == sample_fmt)
|
||||
return 1;
|
||||
p++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* just pick the highest supported samplerate */
|
||||
static int select_sample_rate(AVCodec *codec)
|
||||
{
|
||||
const int *p;
|
||||
int best_samplerate = 0;
|
||||
|
||||
if (!codec->supported_samplerates)
|
||||
return 44100;
|
||||
|
||||
p = codec->supported_samplerates;
|
||||
while (*p) {
|
||||
best_samplerate = FFMAX(*p, best_samplerate);
|
||||
p++;
|
||||
}
|
||||
return best_samplerate;
|
||||
}
|
||||
|
||||
/* select layout with the highest channel count */
|
||||
static int select_channel_layout(AVCodec *codec)
|
||||
{
|
||||
const uint64_t *p;
|
||||
uint64_t best_ch_layout = 0;
|
||||
int best_nb_channels = 0;
|
||||
|
||||
if (!codec->channel_layouts)
|
||||
return AV_CH_LAYOUT_STEREO;
|
||||
|
||||
p = codec->channel_layouts;
|
||||
while (*p) {
|
||||
int nb_channels = av_get_channel_layout_nb_channels(*p);
|
||||
|
||||
if (nb_channels > best_nb_channels) {
|
||||
best_ch_layout = *p;
|
||||
best_nb_channels = nb_channels;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return best_ch_layout;
|
||||
}
|
||||
|
||||
/*
|
||||
* Audio encoding example
|
||||
*/
|
||||
static void audio_encode_example(const char *filename)
|
||||
{
|
||||
AVCodec *codec;
|
||||
AVCodecContext *c= NULL;
|
||||
AVFrame *frame;
|
||||
AVPacket pkt;
|
||||
int i, j, k, ret, got_output;
|
||||
int buffer_size;
|
||||
FILE *f;
|
||||
uint16_t *samples;
|
||||
float t, tincr;
|
||||
|
||||
printf("Encode audio file %s\n", filename);
|
||||
|
||||
/* find the MP2 encoder */
|
||||
codec = avcodec_find_encoder(AV_CODEC_ID_MP2);
|
||||
if (!codec) {
|
||||
fprintf(stderr, "Codec not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
c = avcodec_alloc_context3(codec);
|
||||
if (!c) {
|
||||
fprintf(stderr, "Could not allocate audio codec context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* put sample parameters */
|
||||
c->bit_rate = 64000;
|
||||
|
||||
/* check that the encoder supports s16 pcm input */
|
||||
c->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
if (!check_sample_fmt(codec, c->sample_fmt)) {
|
||||
fprintf(stderr, "Encoder does not support sample format %s",
|
||||
av_get_sample_fmt_name(c->sample_fmt));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* select other audio parameters supported by the encoder */
|
||||
c->sample_rate = select_sample_rate(codec);
|
||||
c->channel_layout = select_channel_layout(codec);
|
||||
c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
|
||||
|
||||
/* open it */
|
||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||
fprintf(stderr, "Could not open codec\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Could not open %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* frame containing input raw audio */
|
||||
frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
fprintf(stderr, "Could not allocate audio frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
frame->nb_samples = c->frame_size;
|
||||
frame->format = c->sample_fmt;
|
||||
frame->channel_layout = c->channel_layout;
|
||||
|
||||
/* the codec gives us the frame size, in samples,
|
||||
* we calculate the size of the samples buffer in bytes */
|
||||
buffer_size = av_samples_get_buffer_size(NULL, c->channels, c->frame_size,
|
||||
c->sample_fmt, 0);
|
||||
if (buffer_size < 0) {
|
||||
fprintf(stderr, "Could not get sample buffer size\n");
|
||||
exit(1);
|
||||
}
|
||||
samples = av_malloc(buffer_size);
|
||||
if (!samples) {
|
||||
fprintf(stderr, "Could not allocate %d bytes for samples buffer\n",
|
||||
buffer_size);
|
||||
exit(1);
|
||||
}
|
||||
/* setup the data pointers in the AVFrame */
|
||||
ret = avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
|
||||
(const uint8_t*)samples, buffer_size, 0);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not setup audio frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* encode a single tone sound */
|
||||
t = 0;
|
||||
tincr = 2 * M_PI * 440.0 / c->sample_rate;
|
||||
for (i = 0; i < 200; i++) {
|
||||
av_init_packet(&pkt);
|
||||
pkt.data = NULL; // packet data will be allocated by the encoder
|
||||
pkt.size = 0;
|
||||
|
||||
for (j = 0; j < c->frame_size; j++) {
|
||||
samples[2*j] = (int)(sin(t) * 10000);
|
||||
|
||||
for (k = 1; k < c->channels; k++)
|
||||
samples[2*j + k] = samples[2*j];
|
||||
t += tincr;
|
||||
}
|
||||
/* encode the samples */
|
||||
ret = avcodec_encode_audio2(c, &pkt, frame, &got_output);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error encoding audio frame\n");
|
||||
exit(1);
|
||||
}
|
||||
if (got_output) {
|
||||
fwrite(pkt.data, 1, pkt.size, f);
|
||||
av_packet_unref(&pkt);
|
||||
}
|
||||
}
|
||||
|
||||
/* get the delayed frames */
|
||||
for (got_output = 1; got_output; i++) {
|
||||
ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error encoding frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (got_output) {
|
||||
fwrite(pkt.data, 1, pkt.size, f);
|
||||
av_packet_unref(&pkt);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
av_freep(&samples);
|
||||
av_frame_free(&frame);
|
||||
avcodec_close(c);
|
||||
av_free(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* Audio decoding.
|
||||
*/
|
||||
static void audio_decode_example(const char *outfilename, const char *filename)
|
||||
{
|
||||
AVCodec *codec;
|
||||
AVCodecContext *c= NULL;
|
||||
int len;
|
||||
FILE *f, *outfile;
|
||||
uint8_t inbuf[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
|
||||
AVPacket avpkt;
|
||||
AVFrame *decoded_frame = NULL;
|
||||
|
||||
av_init_packet(&avpkt);
|
||||
|
||||
printf("Decode audio file %s to %s\n", filename, outfilename);
|
||||
|
||||
/* find the MPEG audio decoder */
|
||||
codec = avcodec_find_decoder(AV_CODEC_ID_MP2);
|
||||
if (!codec) {
|
||||
fprintf(stderr, "Codec not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
c = avcodec_alloc_context3(codec);
|
||||
if (!c) {
|
||||
fprintf(stderr, "Could not allocate audio codec context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* open it */
|
||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||
fprintf(stderr, "Could not open codec\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
f = fopen(filename, "rb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Could not open %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
outfile = fopen(outfilename, "wb");
|
||||
if (!outfile) {
|
||||
av_free(c);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* decode until eof */
|
||||
avpkt.data = inbuf;
|
||||
avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);
|
||||
|
||||
while (avpkt.size > 0) {
|
||||
int i, ch;
|
||||
int got_frame = 0;
|
||||
|
||||
if (!decoded_frame) {
|
||||
if (!(decoded_frame = av_frame_alloc())) {
|
||||
fprintf(stderr, "Could not allocate audio frame\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);
|
||||
if (len < 0) {
|
||||
fprintf(stderr, "Error while decoding\n");
|
||||
exit(1);
|
||||
}
|
||||
if (got_frame) {
|
||||
/* if a frame has been decoded, output it */
|
||||
int data_size = av_get_bytes_per_sample(c->sample_fmt);
|
||||
if (data_size < 0) {
|
||||
/* This should not occur, checking just for paranoia */
|
||||
fprintf(stderr, "Failed to calculate data size\n");
|
||||
exit(1);
|
||||
}
|
||||
for (i=0; i<decoded_frame->nb_samples; i++)
|
||||
for (ch=0; ch<c->channels; ch++)
|
||||
fwrite(decoded_frame->data[ch] + data_size*i, 1, data_size, outfile);
|
||||
}
|
||||
avpkt.size -= len;
|
||||
avpkt.data += len;
|
||||
avpkt.dts =
|
||||
avpkt.pts = AV_NOPTS_VALUE;
|
||||
if (avpkt.size < AUDIO_REFILL_THRESH) {
|
||||
/* Refill the input buffer, to avoid trying to decode
|
||||
* incomplete frames. Instead of this, one could also use
|
||||
* a parser, or use a proper container format through
|
||||
* libavformat. */
|
||||
memmove(inbuf, avpkt.data, avpkt.size);
|
||||
avpkt.data = inbuf;
|
||||
len = fread(avpkt.data + avpkt.size, 1,
|
||||
AUDIO_INBUF_SIZE - avpkt.size, f);
|
||||
if (len > 0)
|
||||
avpkt.size += len;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(outfile);
|
||||
fclose(f);
|
||||
|
||||
avcodec_close(c);
|
||||
av_free(c);
|
||||
av_frame_free(&decoded_frame);
|
||||
}
|
||||
|
||||
/*
|
||||
* Video encoding example
|
||||
*/
|
||||
static void video_encode_example(const char *filename, int codec_id)
|
||||
{
|
||||
AVCodec *codec;
|
||||
AVCodecContext *c= NULL;
|
||||
int i, ret, x, y, got_output;
|
||||
FILE *f;
|
||||
AVFrame *frame;
|
||||
AVPacket pkt;
|
||||
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
|
||||
|
||||
printf("Encode video file %s\n", filename);
|
||||
|
||||
/* find the video encoder */
|
||||
codec = avcodec_find_encoder(codec_id);
|
||||
if (!codec) {
|
||||
fprintf(stderr, "Codec not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
c = avcodec_alloc_context3(codec);
|
||||
if (!c) {
|
||||
fprintf(stderr, "Could not allocate video codec context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* put sample parameters */
|
||||
c->bit_rate = 400000;
|
||||
/* resolution must be a multiple of two */
|
||||
c->width = 352;
|
||||
c->height = 288;
|
||||
/* frames per second */
|
||||
c->time_base = (AVRational){1,25};
|
||||
/* emit one intra frame every ten frames
|
||||
* check frame pict_type before passing frame
|
||||
* to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
|
||||
* then gop_size is ignored and the output of encoder
|
||||
* will always be I frame irrespective to gop_size
|
||||
*/
|
||||
c->gop_size = 10;
|
||||
c->max_b_frames = 1;
|
||||
c->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||
|
||||
if (codec_id == AV_CODEC_ID_H264)
|
||||
av_opt_set(c->priv_data, "preset", "slow", 0);
|
||||
|
||||
/* open it */
|
||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||
fprintf(stderr, "Could not open codec\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Could not open %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
fprintf(stderr, "Could not allocate video frame\n");
|
||||
exit(1);
|
||||
}
|
||||
frame->format = c->pix_fmt;
|
||||
frame->width = c->width;
|
||||
frame->height = c->height;
|
||||
|
||||
/* the image can be allocated by any means and av_image_alloc() is
|
||||
* just the most convenient way if av_malloc() is to be used */
|
||||
ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height,
|
||||
c->pix_fmt, 32);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not allocate raw picture buffer\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* encode 1 second of video */
|
||||
for (i = 0; i < 25; i++) {
|
||||
av_init_packet(&pkt);
|
||||
pkt.data = NULL; // packet data will be allocated by the encoder
|
||||
pkt.size = 0;
|
||||
|
||||
fflush(stdout);
|
||||
/* prepare a dummy image */
|
||||
/* Y */
|
||||
for (y = 0; y < c->height; y++) {
|
||||
for (x = 0; x < c->width; x++) {
|
||||
frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Cb and Cr */
|
||||
for (y = 0; y < c->height/2; y++) {
|
||||
for (x = 0; x < c->width/2; x++) {
|
||||
frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
|
||||
frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
|
||||
}
|
||||
}
|
||||
|
||||
frame->pts = i;
|
||||
|
||||
/* encode the image */
|
||||
ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error encoding frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (got_output) {
|
||||
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
|
||||
fwrite(pkt.data, 1, pkt.size, f);
|
||||
av_packet_unref(&pkt);
|
||||
}
|
||||
}
|
||||
|
||||
/* get the delayed frames */
|
||||
for (got_output = 1; got_output; i++) {
|
||||
fflush(stdout);
|
||||
|
||||
ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error encoding frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (got_output) {
|
||||
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
|
||||
fwrite(pkt.data, 1, pkt.size, f);
|
||||
av_packet_unref(&pkt);
|
||||
}
|
||||
}
|
||||
|
||||
/* add sequence end code to have a real MPEG file */
|
||||
fwrite(endcode, 1, sizeof(endcode), f);
|
||||
fclose(f);
|
||||
|
||||
avcodec_close(c);
|
||||
av_free(c);
|
||||
av_freep(&frame->data[0]);
|
||||
av_frame_free(&frame);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Video decoding example
|
||||
*/
|
||||
|
||||
static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
|
||||
char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
int i;
|
||||
|
||||
f = fopen(filename,"w");
|
||||
fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
|
||||
for (i = 0; i < ysize; i++)
|
||||
fwrite(buf + i * wrap, 1, xsize, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static int decode_write_frame(const char *outfilename, AVCodecContext *avctx,
|
||||
AVFrame *frame, int *frame_count, AVPacket *pkt, int last)
|
||||
{
|
||||
int len, got_frame;
|
||||
char buf[1024];
|
||||
|
||||
len = avcodec_decode_video2(avctx, frame, &got_frame, pkt);
|
||||
if (len < 0) {
|
||||
fprintf(stderr, "Error while decoding frame %d\n", *frame_count);
|
||||
return len;
|
||||
}
|
||||
if (got_frame) {
|
||||
printf("Saving %sframe %3d\n", last ? "last " : "", *frame_count);
|
||||
fflush(stdout);
|
||||
|
||||
/* the picture is allocated by the decoder, no need to free it */
|
||||
snprintf(buf, sizeof(buf), outfilename, *frame_count);
|
||||
pgm_save(frame->data[0], frame->linesize[0],
|
||||
frame->width, frame->height, buf);
|
||||
(*frame_count)++;
|
||||
}
|
||||
if (pkt->data) {
|
||||
pkt->size -= len;
|
||||
pkt->data += len;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void video_decode_example(const char *outfilename, const char *filename)
|
||||
{
|
||||
AVCodec *codec;
|
||||
AVCodecContext *c= NULL;
|
||||
int frame_count;
|
||||
FILE *f;
|
||||
AVFrame *frame;
|
||||
uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
|
||||
AVPacket avpkt;
|
||||
|
||||
av_init_packet(&avpkt);
|
||||
|
||||
/* set end of buffer to 0 (this ensures that no overreading happens for damaged MPEG streams) */
|
||||
memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
|
||||
printf("Decode video file %s to %s\n", filename, outfilename);
|
||||
|
||||
/* find the MPEG-1 video decoder */
|
||||
codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);
|
||||
if (!codec) {
|
||||
fprintf(stderr, "Codec not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
c = avcodec_alloc_context3(codec);
|
||||
if (!c) {
|
||||
fprintf(stderr, "Could not allocate video codec context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
|
||||
c->flags |= AV_CODEC_FLAG_TRUNCATED; // we do not send complete frames
|
||||
|
||||
/* For some codecs, such as msmpeg4 and mpeg4, width and height
|
||||
MUST be initialized there because this information is not
|
||||
available in the bitstream. */
|
||||
|
||||
/* open it */
|
||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||
fprintf(stderr, "Could not open codec\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
f = fopen(filename, "rb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Could not open %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
fprintf(stderr, "Could not allocate video frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
frame_count = 0;
|
||||
for (;;) {
|
||||
avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);
|
||||
if (avpkt.size == 0)
|
||||
break;
|
||||
|
||||
/* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)
|
||||
and this is the only method to use them because you cannot
|
||||
know the compressed data size before analysing it.
|
||||
|
||||
BUT some other codecs (msmpeg4, mpeg4) are inherently frame
|
||||
based, so you must call them with all the data for one
|
||||
frame exactly. You must also initialize 'width' and
|
||||
'height' before initializing them. */
|
||||
|
||||
/* NOTE2: some codecs allow the raw parameters (frame size,
|
||||
sample rate) to be changed at any frame. We handle this, so
|
||||
you should also take care of it */
|
||||
|
||||
/* here, we use a stream based decoder (mpeg1video), so we
|
||||
feed decoder and see if it could decode a frame */
|
||||
avpkt.data = inbuf;
|
||||
while (avpkt.size > 0)
|
||||
if (decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 0) < 0)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Some codecs, such as MPEG, transmit the I- and P-frame with a
|
||||
latency of one frame. You must do the following to have a
|
||||
chance to get the last frame of the video. */
|
||||
avpkt.data = NULL;
|
||||
avpkt.size = 0;
|
||||
decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 1);
|
||||
|
||||
fclose(f);
|
||||
|
||||
avcodec_close(c);
|
||||
av_free(c);
|
||||
av_frame_free(&frame);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *output_type;
|
||||
|
||||
/* register all the codecs */
|
||||
avcodec_register_all();
|
||||
|
||||
if (argc < 2) {
|
||||
printf("usage: %s output_type\n"
|
||||
"API example program to decode/encode a media stream with libavcodec.\n"
|
||||
"This program generates a synthetic stream and encodes it to a file\n"
|
||||
"named test.h264, test.mp2 or test.mpg depending on output_type.\n"
|
||||
"The encoded stream is then decoded and written to a raw data output.\n"
|
||||
"output_type must be chosen between 'h264', 'mp2', 'mpg'.\n",
|
||||
argv[0]);
|
||||
return 1;
|
||||
}
|
||||
output_type = argv[1];
|
||||
|
||||
if (!strcmp(output_type, "h264")) {
|
||||
video_encode_example("test.h264", AV_CODEC_ID_H264);
|
||||
} else if (!strcmp(output_type, "mp2")) {
|
||||
audio_encode_example("test.mp2");
|
||||
audio_decode_example("test.pcm", "test.mp2");
|
||||
} else if (!strcmp(output_type, "mpg")) {
|
||||
video_encode_example("test.mpg", AV_CODEC_ID_MPEG1VIDEO);
|
||||
video_decode_example("test%02d.pgm", "test.mpg");
|
||||
} else {
|
||||
fprintf(stderr, "Invalid output type '%s', choose between 'h264', 'mp2', or 'mpg'\n",
|
||||
output_type);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,393 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Stefano Sabatini
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Demuxing and decoding example.
|
||||
*
|
||||
* Show how to use the libavformat and libavcodec API to demux and
|
||||
* decode audio and video data.
|
||||
* @example demuxing_decoding.c
|
||||
*/
|
||||
|
||||
#include <libavutil/imgutils.h>
|
||||
#include <libavutil/samplefmt.h>
|
||||
#include <libavutil/timestamp.h>
|
||||
#include <libavformat/avformat.h>
|
||||
|
||||
static AVFormatContext *fmt_ctx = NULL;
|
||||
static AVCodecContext *video_dec_ctx = NULL, *audio_dec_ctx;
|
||||
static int width, height;
|
||||
static enum AVPixelFormat pix_fmt;
|
||||
static AVStream *video_stream = NULL, *audio_stream = NULL;
|
||||
static const char *src_filename = NULL;
|
||||
static const char *video_dst_filename = NULL;
|
||||
static const char *audio_dst_filename = NULL;
|
||||
static FILE *video_dst_file = NULL;
|
||||
static FILE *audio_dst_file = NULL;
|
||||
|
||||
static uint8_t *video_dst_data[4] = {NULL};
|
||||
static int video_dst_linesize[4];
|
||||
static int video_dst_bufsize;
|
||||
|
||||
static int video_stream_idx = -1, audio_stream_idx = -1;
|
||||
static AVFrame *frame = NULL;
|
||||
static AVPacket pkt;
|
||||
static int video_frame_count = 0;
|
||||
static int audio_frame_count = 0;
|
||||
|
||||
/* Enable or disable frame reference counting. You are not supposed to support
|
||||
* both paths in your application but pick the one most appropriate to your
|
||||
* needs. Look for the use of refcount in this example to see what are the
|
||||
* differences of API usage between them. */
|
||||
static int refcount = 0;
|
||||
|
||||
static int decode_packet(int *got_frame, int cached)
|
||||
{
|
||||
int ret = 0;
|
||||
int decoded = pkt.size;
|
||||
|
||||
*got_frame = 0;
|
||||
|
||||
if (pkt.stream_index == video_stream_idx) {
|
||||
/* decode video frame */
|
||||
ret = avcodec_decode_video2(video_dec_ctx, frame, got_frame, &pkt);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error decoding video frame (%s)\n", av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (*got_frame) {
|
||||
|
||||
if (frame->width != width || frame->height != height ||
|
||||
frame->format != pix_fmt) {
|
||||
/* To handle this change, one could call av_image_alloc again and
|
||||
* decode the following frames into another rawvideo file. */
|
||||
fprintf(stderr, "Error: Width, height and pixel format have to be "
|
||||
"constant in a rawvideo file, but the width, height or "
|
||||
"pixel format of the input video changed:\n"
|
||||
"old: width = %d, height = %d, format = %s\n"
|
||||
"new: width = %d, height = %d, format = %s\n",
|
||||
width, height, av_get_pix_fmt_name(pix_fmt),
|
||||
frame->width, frame->height,
|
||||
av_get_pix_fmt_name(frame->format));
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("video_frame%s n:%d coded_n:%d\n",
|
||||
cached ? "(cached)" : "",
|
||||
video_frame_count++, frame->coded_picture_number);
|
||||
|
||||
/* copy decoded frame to destination buffer:
|
||||
* this is required since rawvideo expects non aligned data */
|
||||
av_image_copy(video_dst_data, video_dst_linesize,
|
||||
(const uint8_t **)(frame->data), frame->linesize,
|
||||
pix_fmt, width, height);
|
||||
|
||||
/* write to rawvideo file */
|
||||
fwrite(video_dst_data[0], 1, video_dst_bufsize, video_dst_file);
|
||||
}
|
||||
} else if (pkt.stream_index == audio_stream_idx) {
|
||||
/* decode audio frame */
|
||||
ret = avcodec_decode_audio4(audio_dec_ctx, frame, got_frame, &pkt);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error decoding audio frame (%s)\n", av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
/* Some audio decoders decode only part of the packet, and have to be
|
||||
* called again with the remainder of the packet data.
|
||||
* Sample: fate-suite/lossless-audio/luckynight-partial.shn
|
||||
* Also, some decoders might over-read the packet. */
|
||||
decoded = FFMIN(ret, pkt.size);
|
||||
|
||||
if (*got_frame) {
|
||||
size_t unpadded_linesize = frame->nb_samples * av_get_bytes_per_sample(frame->format);
|
||||
printf("audio_frame%s n:%d nb_samples:%d pts:%s\n",
|
||||
cached ? "(cached)" : "",
|
||||
audio_frame_count++, frame->nb_samples,
|
||||
av_ts2timestr(frame->pts, &audio_dec_ctx->time_base));
|
||||
|
||||
/* Write the raw audio data samples of the first plane. This works
|
||||
* fine for packed formats (e.g. AV_SAMPLE_FMT_S16). However,
|
||||
* most audio decoders output planar audio, which uses a separate
|
||||
* plane of audio samples for each channel (e.g. AV_SAMPLE_FMT_S16P).
|
||||
* In other words, this code will write only the first audio channel
|
||||
* in these cases.
|
||||
* You should use libswresample or libavfilter to convert the frame
|
||||
* to packed data. */
|
||||
fwrite(frame->extended_data[0], 1, unpadded_linesize, audio_dst_file);
|
||||
}
|
||||
}
|
||||
|
||||
/* If we use frame reference counting, we own the data and need
|
||||
* to de-reference it when we don't use it anymore */
|
||||
if (*got_frame && refcount)
|
||||
av_frame_unref(frame);
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
static int open_codec_context(int *stream_idx,
|
||||
AVCodecContext **dec_ctx, AVFormatContext *fmt_ctx, enum AVMediaType type)
|
||||
{
|
||||
int ret, stream_index;
|
||||
AVStream *st;
|
||||
AVCodec *dec = NULL;
|
||||
AVDictionary *opts = NULL;
|
||||
|
||||
ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not find %s stream in input file '%s'\n",
|
||||
av_get_media_type_string(type), src_filename);
|
||||
return ret;
|
||||
} else {
|
||||
stream_index = ret;
|
||||
st = fmt_ctx->streams[stream_index];
|
||||
|
||||
/* find decoder for the stream */
|
||||
dec = avcodec_find_decoder(st->codecpar->codec_id);
|
||||
if (!dec) {
|
||||
fprintf(stderr, "Failed to find %s codec\n",
|
||||
av_get_media_type_string(type));
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
/* Allocate a codec context for the decoder */
|
||||
*dec_ctx = avcodec_alloc_context3(dec);
|
||||
if (!*dec_ctx) {
|
||||
fprintf(stderr, "Failed to allocate the %s codec context\n",
|
||||
av_get_media_type_string(type));
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/* Copy codec parameters from input stream to output codec context */
|
||||
if ((ret = avcodec_parameters_to_context(*dec_ctx, st->codecpar)) < 0) {
|
||||
fprintf(stderr, "Failed to copy %s codec parameters to decoder context\n",
|
||||
av_get_media_type_string(type));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Init the decoders, with or without reference counting */
|
||||
av_dict_set(&opts, "refcounted_frames", refcount ? "1" : "0", 0);
|
||||
if ((ret = avcodec_open2(*dec_ctx, dec, &opts)) < 0) {
|
||||
fprintf(stderr, "Failed to open %s codec\n",
|
||||
av_get_media_type_string(type));
|
||||
return ret;
|
||||
}
|
||||
*stream_idx = stream_index;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_format_from_sample_fmt(const char **fmt,
|
||||
enum AVSampleFormat sample_fmt)
|
||||
{
|
||||
int i;
|
||||
struct sample_fmt_entry {
|
||||
enum AVSampleFormat sample_fmt; const char *fmt_be, *fmt_le;
|
||||
} sample_fmt_entries[] = {
|
||||
{ AV_SAMPLE_FMT_U8, "u8", "u8" },
|
||||
{ AV_SAMPLE_FMT_S16, "s16be", "s16le" },
|
||||
{ AV_SAMPLE_FMT_S32, "s32be", "s32le" },
|
||||
{ AV_SAMPLE_FMT_FLT, "f32be", "f32le" },
|
||||
{ AV_SAMPLE_FMT_DBL, "f64be", "f64le" },
|
||||
};
|
||||
*fmt = NULL;
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(sample_fmt_entries); i++) {
|
||||
struct sample_fmt_entry *entry = &sample_fmt_entries[i];
|
||||
if (sample_fmt == entry->sample_fmt) {
|
||||
*fmt = AV_NE(entry->fmt_be, entry->fmt_le);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"sample format %s is not supported as output format\n",
|
||||
av_get_sample_fmt_name(sample_fmt));
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int ret = 0, got_frame;
|
||||
|
||||
if (argc != 4 && argc != 5) {
|
||||
fprintf(stderr, "usage: %s [-refcount] input_file video_output_file audio_output_file\n"
|
||||
"API example program to show how to read frames from an input file.\n"
|
||||
"This program reads frames from a file, decodes them, and writes decoded\n"
|
||||
"video frames to a rawvideo file named video_output_file, and decoded\n"
|
||||
"audio frames to a rawaudio file named audio_output_file.\n\n"
|
||||
"If the -refcount option is specified, the program use the\n"
|
||||
"reference counting frame system which allows keeping a copy of\n"
|
||||
"the data for longer than one decode call.\n"
|
||||
"\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
if (argc == 5 && !strcmp(argv[1], "-refcount")) {
|
||||
refcount = 1;
|
||||
argv++;
|
||||
}
|
||||
src_filename = argv[1];
|
||||
video_dst_filename = argv[2];
|
||||
audio_dst_filename = argv[3];
|
||||
|
||||
/* register all formats and codecs */
|
||||
av_register_all();
|
||||
|
||||
/* open input file, and allocate format context */
|
||||
if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
|
||||
fprintf(stderr, "Could not open source file %s\n", src_filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* retrieve stream information */
|
||||
if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {
|
||||
fprintf(stderr, "Could not find stream information\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (open_codec_context(&video_stream_idx, &video_dec_ctx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) {
|
||||
video_stream = fmt_ctx->streams[video_stream_idx];
|
||||
|
||||
video_dst_file = fopen(video_dst_filename, "wb");
|
||||
if (!video_dst_file) {
|
||||
fprintf(stderr, "Could not open destination file %s\n", video_dst_filename);
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* allocate image where the decoded image will be put */
|
||||
width = video_dec_ctx->width;
|
||||
height = video_dec_ctx->height;
|
||||
pix_fmt = video_dec_ctx->pix_fmt;
|
||||
ret = av_image_alloc(video_dst_data, video_dst_linesize,
|
||||
width, height, pix_fmt, 1);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not allocate raw video buffer\n");
|
||||
goto end;
|
||||
}
|
||||
video_dst_bufsize = ret;
|
||||
}
|
||||
|
||||
if (open_codec_context(&audio_stream_idx, &audio_dec_ctx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) {
|
||||
audio_stream = fmt_ctx->streams[audio_stream_idx];
|
||||
audio_dst_file = fopen(audio_dst_filename, "wb");
|
||||
if (!audio_dst_file) {
|
||||
fprintf(stderr, "Could not open destination file %s\n", audio_dst_filename);
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
/* dump input information to stderr */
|
||||
av_dump_format(fmt_ctx, 0, src_filename, 0);
|
||||
|
||||
if (!audio_stream && !video_stream) {
|
||||
fprintf(stderr, "Could not find audio or video stream in the input, aborting\n");
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
fprintf(stderr, "Could not allocate frame\n");
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* initialize packet, set data to NULL, let the demuxer fill it */
|
||||
av_init_packet(&pkt);
|
||||
pkt.data = NULL;
|
||||
pkt.size = 0;
|
||||
|
||||
if (video_stream)
|
||||
printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename);
|
||||
if (audio_stream)
|
||||
printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename);
|
||||
|
||||
/* read frames from the file */
|
||||
while (av_read_frame(fmt_ctx, &pkt) >= 0) {
|
||||
AVPacket orig_pkt = pkt;
|
||||
do {
|
||||
ret = decode_packet(&got_frame, 0);
|
||||
if (ret < 0)
|
||||
break;
|
||||
pkt.data += ret;
|
||||
pkt.size -= ret;
|
||||
} while (pkt.size > 0);
|
||||
av_packet_unref(&orig_pkt);
|
||||
}
|
||||
|
||||
/* flush cached frames */
|
||||
pkt.data = NULL;
|
||||
pkt.size = 0;
|
||||
do {
|
||||
decode_packet(&got_frame, 1);
|
||||
} while (got_frame);
|
||||
|
||||
printf("Demuxing succeeded.\n");
|
||||
|
||||
if (video_stream) {
|
||||
printf("Play the output video file with the command:\n"
|
||||
"ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n",
|
||||
av_get_pix_fmt_name(pix_fmt), width, height,
|
||||
video_dst_filename);
|
||||
}
|
||||
|
||||
if (audio_stream) {
|
||||
enum AVSampleFormat sfmt = audio_dec_ctx->sample_fmt;
|
||||
int n_channels = audio_dec_ctx->channels;
|
||||
const char *fmt;
|
||||
|
||||
if (av_sample_fmt_is_planar(sfmt)) {
|
||||
const char *packed = av_get_sample_fmt_name(sfmt);
|
||||
printf("Warning: the sample format the decoder produced is planar "
|
||||
"(%s). This example will output the first channel only.\n",
|
||||
packed ? packed : "?");
|
||||
sfmt = av_get_packed_sample_fmt(sfmt);
|
||||
n_channels = 1;
|
||||
}
|
||||
|
||||
if ((ret = get_format_from_sample_fmt(&fmt, sfmt)) < 0)
|
||||
goto end;
|
||||
|
||||
printf("Play the output audio file with the command:\n"
|
||||
"ffplay -f %s -ac %d -ar %d %s\n",
|
||||
fmt, n_channels, audio_dec_ctx->sample_rate,
|
||||
audio_dst_filename);
|
||||
}
|
||||
|
||||
end:
|
||||
avcodec_free_context(&video_dec_ctx);
|
||||
avcodec_free_context(&audio_dec_ctx);
|
||||
avformat_close_input(&fmt_ctx);
|
||||
if (video_dst_file)
|
||||
fclose(video_dst_file);
|
||||
if (audio_dst_file)
|
||||
fclose(audio_dst_file);
|
||||
av_frame_free(&frame);
|
||||
av_free(video_dst_data[0]);
|
||||
|
||||
return ret < 0;
|
||||
}
|
@ -1,185 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Stefano Sabatini
|
||||
* Copyright (c) 2014 Clément Bœsch
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <libavutil/motion_vector.h>
|
||||
#include <libavformat/avformat.h>
|
||||
|
||||
static AVFormatContext *fmt_ctx = NULL;
|
||||
static AVCodecContext *video_dec_ctx = NULL;
|
||||
static AVStream *video_stream = NULL;
|
||||
static const char *src_filename = NULL;
|
||||
|
||||
static int video_stream_idx = -1;
|
||||
static AVFrame *frame = NULL;
|
||||
static AVPacket pkt;
|
||||
static int video_frame_count = 0;
|
||||
|
||||
static int decode_packet(int *got_frame, int cached)
|
||||
{
|
||||
int decoded = pkt.size;
|
||||
|
||||
*got_frame = 0;
|
||||
|
||||
if (pkt.stream_index == video_stream_idx) {
|
||||
int ret = avcodec_decode_video2(video_dec_ctx, frame, got_frame, &pkt);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error decoding video frame (%s)\n", av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (*got_frame) {
|
||||
int i;
|
||||
AVFrameSideData *sd;
|
||||
|
||||
video_frame_count++;
|
||||
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS);
|
||||
if (sd) {
|
||||
const AVMotionVector *mvs = (const AVMotionVector *)sd->data;
|
||||
for (i = 0; i < sd->size / sizeof(*mvs); i++) {
|
||||
const AVMotionVector *mv = &mvs[i];
|
||||
printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64"\n",
|
||||
video_frame_count, mv->source,
|
||||
mv->w, mv->h, mv->src_x, mv->src_y,
|
||||
mv->dst_x, mv->dst_y, mv->flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
static int open_codec_context(int *stream_idx,
|
||||
AVFormatContext *fmt_ctx, enum AVMediaType type)
|
||||
{
|
||||
int ret;
|
||||
AVStream *st;
|
||||
AVCodecContext *dec_ctx = NULL;
|
||||
AVCodec *dec = NULL;
|
||||
AVDictionary *opts = NULL;
|
||||
|
||||
ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not find %s stream in input file '%s'\n",
|
||||
av_get_media_type_string(type), src_filename);
|
||||
return ret;
|
||||
} else {
|
||||
*stream_idx = ret;
|
||||
st = fmt_ctx->streams[*stream_idx];
|
||||
|
||||
/* find decoder for the stream */
|
||||
dec_ctx = st->codec;
|
||||
dec = avcodec_find_decoder(dec_ctx->codec_id);
|
||||
if (!dec) {
|
||||
fprintf(stderr, "Failed to find %s codec\n",
|
||||
av_get_media_type_string(type));
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
/* Init the video decoder */
|
||||
av_dict_set(&opts, "flags2", "+export_mvs", 0);
|
||||
if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 0) {
|
||||
fprintf(stderr, "Failed to open %s codec\n",
|
||||
av_get_media_type_string(type));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = 0, got_frame;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: %s <video>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
src_filename = argv[1];
|
||||
|
||||
av_register_all();
|
||||
|
||||
if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
|
||||
fprintf(stderr, "Could not open source file %s\n", src_filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {
|
||||
fprintf(stderr, "Could not find stream information\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (open_codec_context(&video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) {
|
||||
video_stream = fmt_ctx->streams[video_stream_idx];
|
||||
video_dec_ctx = video_stream->codec;
|
||||
}
|
||||
|
||||
av_dump_format(fmt_ctx, 0, src_filename, 0);
|
||||
|
||||
if (!video_stream) {
|
||||
fprintf(stderr, "Could not find video stream in the input, aborting\n");
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
fprintf(stderr, "Could not allocate frame\n");
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
|
||||
printf("framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,flags\n");
|
||||
|
||||
/* initialize packet, set data to NULL, let the demuxer fill it */
|
||||
av_init_packet(&pkt);
|
||||
pkt.data = NULL;
|
||||
pkt.size = 0;
|
||||
|
||||
/* read frames from the file */
|
||||
while (av_read_frame(fmt_ctx, &pkt) >= 0) {
|
||||
AVPacket orig_pkt = pkt;
|
||||
do {
|
||||
ret = decode_packet(&got_frame, 0);
|
||||
if (ret < 0)
|
||||
break;
|
||||
pkt.data += ret;
|
||||
pkt.size -= ret;
|
||||
} while (pkt.size > 0);
|
||||
av_packet_unref(&orig_pkt);
|
||||
}
|
||||
|
||||
/* flush cached frames */
|
||||
pkt.data = NULL;
|
||||
pkt.size = 0;
|
||||
do {
|
||||
decode_packet(&got_frame, 1);
|
||||
} while (got_frame);
|
||||
|
||||
end:
|
||||
avcodec_close(video_dec_ctx);
|
||||
avformat_close_input(&fmt_ctx);
|
||||
av_frame_free(&frame);
|
||||
return ret < 0;
|
||||
}
|
@ -1,365 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2013 Andrew Kelley
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* libavfilter API usage example.
|
||||
*
|
||||
* @example filter_audio.c
|
||||
* This example will generate a sine wave audio,
|
||||
* pass it through a simple filter chain, and then compute the MD5 checksum of
|
||||
* the output data.
|
||||
*
|
||||
* The filter chain it uses is:
|
||||
* (input) -> abuffer -> volume -> aformat -> abuffersink -> (output)
|
||||
*
|
||||
* abuffer: This provides the endpoint where you can feed the decoded samples.
|
||||
* volume: In this example we hardcode it to 0.90.
|
||||
* aformat: This converts the samples to the samplefreq, channel layout,
|
||||
* and sample format required by the audio device.
|
||||
* abuffersink: This provides the endpoint where you can read the samples after
|
||||
* they have passed through the filter chain.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "libavutil/md5.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/samplefmt.h"
|
||||
|
||||
#include "libavfilter/avfilter.h"
|
||||
#include "libavfilter/buffersink.h"
|
||||
#include "libavfilter/buffersrc.h"
|
||||
|
||||
#define INPUT_SAMPLERATE 48000
|
||||
#define INPUT_FORMAT AV_SAMPLE_FMT_FLTP
|
||||
#define INPUT_CHANNEL_LAYOUT AV_CH_LAYOUT_5POINT0
|
||||
|
||||
#define VOLUME_VAL 0.90
|
||||
|
||||
static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src,
|
||||
AVFilterContext **sink)
|
||||
{
|
||||
AVFilterGraph *filter_graph;
|
||||
AVFilterContext *abuffer_ctx;
|
||||
AVFilter *abuffer;
|
||||
AVFilterContext *volume_ctx;
|
||||
AVFilter *volume;
|
||||
AVFilterContext *aformat_ctx;
|
||||
AVFilter *aformat;
|
||||
AVFilterContext *abuffersink_ctx;
|
||||
AVFilter *abuffersink;
|
||||
|
||||
AVDictionary *options_dict = NULL;
|
||||
uint8_t options_str[1024];
|
||||
uint8_t ch_layout[64];
|
||||
|
||||
int err;
|
||||
|
||||
/* Create a new filtergraph, which will contain all the filters. */
|
||||
filter_graph = avfilter_graph_alloc();
|
||||
if (!filter_graph) {
|
||||
fprintf(stderr, "Unable to create filter graph.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/* Create the abuffer filter;
|
||||
* it will be used for feeding the data into the graph. */
|
||||
abuffer = avfilter_get_by_name("abuffer");
|
||||
if (!abuffer) {
|
||||
fprintf(stderr, "Could not find the abuffer filter.\n");
|
||||
return AVERROR_FILTER_NOT_FOUND;
|
||||
}
|
||||
|
||||
abuffer_ctx = avfilter_graph_alloc_filter(filter_graph, abuffer, "src");
|
||||
if (!abuffer_ctx) {
|
||||
fprintf(stderr, "Could not allocate the abuffer instance.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/* Set the filter options through the AVOptions API. */
|
||||
av_get_channel_layout_string(ch_layout, sizeof(ch_layout), 0, INPUT_CHANNEL_LAYOUT);
|
||||
av_opt_set (abuffer_ctx, "channel_layout", ch_layout, AV_OPT_SEARCH_CHILDREN);
|
||||
av_opt_set (abuffer_ctx, "sample_fmt", av_get_sample_fmt_name(INPUT_FORMAT), AV_OPT_SEARCH_CHILDREN);
|
||||
av_opt_set_q (abuffer_ctx, "time_base", (AVRational){ 1, INPUT_SAMPLERATE }, AV_OPT_SEARCH_CHILDREN);
|
||||
av_opt_set_int(abuffer_ctx, "sample_rate", INPUT_SAMPLERATE, AV_OPT_SEARCH_CHILDREN);
|
||||
|
||||
/* Now initialize the filter; we pass NULL options, since we have already
|
||||
* set all the options above. */
|
||||
err = avfilter_init_str(abuffer_ctx, NULL);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, "Could not initialize the abuffer filter.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Create volume filter. */
|
||||
volume = avfilter_get_by_name("volume");
|
||||
if (!volume) {
|
||||
fprintf(stderr, "Could not find the volume filter.\n");
|
||||
return AVERROR_FILTER_NOT_FOUND;
|
||||
}
|
||||
|
||||
volume_ctx = avfilter_graph_alloc_filter(filter_graph, volume, "volume");
|
||||
if (!volume_ctx) {
|
||||
fprintf(stderr, "Could not allocate the volume instance.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/* A different way of passing the options is as key/value pairs in a
|
||||
* dictionary. */
|
||||
av_dict_set(&options_dict, "volume", AV_STRINGIFY(VOLUME_VAL), 0);
|
||||
err = avfilter_init_dict(volume_ctx, &options_dict);
|
||||
av_dict_free(&options_dict);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, "Could not initialize the volume filter.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Create the aformat filter;
|
||||
* it ensures that the output is of the format we want. */
|
||||
aformat = avfilter_get_by_name("aformat");
|
||||
if (!aformat) {
|
||||
fprintf(stderr, "Could not find the aformat filter.\n");
|
||||
return AVERROR_FILTER_NOT_FOUND;
|
||||
}
|
||||
|
||||
aformat_ctx = avfilter_graph_alloc_filter(filter_graph, aformat, "aformat");
|
||||
if (!aformat_ctx) {
|
||||
fprintf(stderr, "Could not allocate the aformat instance.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/* A third way of passing the options is in a string of the form
|
||||
* key1=value1:key2=value2.... */
|
||||
snprintf(options_str, sizeof(options_str),
|
||||
"sample_fmts=%s:sample_rates=%d:channel_layouts=0x%"PRIx64,
|
||||
av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), 44100,
|
||||
(uint64_t)AV_CH_LAYOUT_STEREO);
|
||||
err = avfilter_init_str(aformat_ctx, options_str);
|
||||
if (err < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Could not initialize the aformat filter.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Finally create the abuffersink filter;
|
||||
* it will be used to get the filtered data out of the graph. */
|
||||
abuffersink = avfilter_get_by_name("abuffersink");
|
||||
if (!abuffersink) {
|
||||
fprintf(stderr, "Could not find the abuffersink filter.\n");
|
||||
return AVERROR_FILTER_NOT_FOUND;
|
||||
}
|
||||
|
||||
abuffersink_ctx = avfilter_graph_alloc_filter(filter_graph, abuffersink, "sink");
|
||||
if (!abuffersink_ctx) {
|
||||
fprintf(stderr, "Could not allocate the abuffersink instance.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/* This filter takes no options. */
|
||||
err = avfilter_init_str(abuffersink_ctx, NULL);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, "Could not initialize the abuffersink instance.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Connect the filters;
|
||||
* in this simple case the filters just form a linear chain. */
|
||||
err = avfilter_link(abuffer_ctx, 0, volume_ctx, 0);
|
||||
if (err >= 0)
|
||||
err = avfilter_link(volume_ctx, 0, aformat_ctx, 0);
|
||||
if (err >= 0)
|
||||
err = avfilter_link(aformat_ctx, 0, abuffersink_ctx, 0);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, "Error connecting filters\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Configure the graph. */
|
||||
err = avfilter_graph_config(filter_graph, NULL);
|
||||
if (err < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error configuring the filter graph\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
*graph = filter_graph;
|
||||
*src = abuffer_ctx;
|
||||
*sink = abuffersink_ctx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Do something useful with the filtered data: this simple
|
||||
* example just prints the MD5 checksum of each plane to stdout. */
|
||||
static int process_output(struct AVMD5 *md5, AVFrame *frame)
|
||||
{
|
||||
int planar = av_sample_fmt_is_planar(frame->format);
|
||||
int channels = av_get_channel_layout_nb_channels(frame->channel_layout);
|
||||
int planes = planar ? channels : 1;
|
||||
int bps = av_get_bytes_per_sample(frame->format);
|
||||
int plane_size = bps * frame->nb_samples * (planar ? 1 : channels);
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < planes; i++) {
|
||||
uint8_t checksum[16];
|
||||
|
||||
av_md5_init(md5);
|
||||
av_md5_sum(checksum, frame->extended_data[i], plane_size);
|
||||
|
||||
fprintf(stdout, "plane %d: 0x", i);
|
||||
for (j = 0; j < sizeof(checksum); j++)
|
||||
fprintf(stdout, "%02X", checksum[j]);
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Construct a frame of audio data to be filtered;
|
||||
* this simple example just synthesizes a sine wave. */
|
||||
static int get_input(AVFrame *frame, int frame_num)
|
||||
{
|
||||
int err, i, j;
|
||||
|
||||
#define FRAME_SIZE 1024
|
||||
|
||||
/* Set up the frame properties and allocate the buffer for the data. */
|
||||
frame->sample_rate = INPUT_SAMPLERATE;
|
||||
frame->format = INPUT_FORMAT;
|
||||
frame->channel_layout = INPUT_CHANNEL_LAYOUT;
|
||||
frame->nb_samples = FRAME_SIZE;
|
||||
frame->pts = frame_num * FRAME_SIZE;
|
||||
|
||||
err = av_frame_get_buffer(frame, 0);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
/* Fill the data for each channel. */
|
||||
for (i = 0; i < 5; i++) {
|
||||
float *data = (float*)frame->extended_data[i];
|
||||
|
||||
for (j = 0; j < frame->nb_samples; j++)
|
||||
data[j] = sin(2 * M_PI * (frame_num + j) * (i + 1) / FRAME_SIZE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct AVMD5 *md5;
|
||||
AVFilterGraph *graph;
|
||||
AVFilterContext *src, *sink;
|
||||
AVFrame *frame;
|
||||
uint8_t errstr[1024];
|
||||
float duration;
|
||||
int err, nb_frames, i;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s <duration>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
duration = atof(argv[1]);
|
||||
nb_frames = duration * INPUT_SAMPLERATE / FRAME_SIZE;
|
||||
if (nb_frames <= 0) {
|
||||
fprintf(stderr, "Invalid duration: %s\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
avfilter_register_all();
|
||||
|
||||
/* Allocate the frame we will be using to store the data. */
|
||||
frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
fprintf(stderr, "Error allocating the frame\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
md5 = av_md5_alloc();
|
||||
if (!md5) {
|
||||
fprintf(stderr, "Error allocating the MD5 context\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Set up the filtergraph. */
|
||||
err = init_filter_graph(&graph, &src, &sink);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, "Unable to init filter graph:");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* the main filtering loop */
|
||||
for (i = 0; i < nb_frames; i++) {
|
||||
/* get an input frame to be filtered */
|
||||
err = get_input(frame, i);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, "Error generating input frame:");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Send the frame to the input of the filtergraph. */
|
||||
err = av_buffersrc_add_frame(src, frame);
|
||||
if (err < 0) {
|
||||
av_frame_unref(frame);
|
||||
fprintf(stderr, "Error submitting the frame to the filtergraph:");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Get all the filtered output that is available. */
|
||||
while ((err = av_buffersink_get_frame(sink, frame)) >= 0) {
|
||||
/* now do something with our filtered frame */
|
||||
err = process_output(md5, frame);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, "Error processing the filtered frame:");
|
||||
goto fail;
|
||||
}
|
||||
av_frame_unref(frame);
|
||||
}
|
||||
|
||||
if (err == AVERROR(EAGAIN)) {
|
||||
/* Need to feed more frames in. */
|
||||
continue;
|
||||
} else if (err == AVERROR_EOF) {
|
||||
/* Nothing more to do, finish. */
|
||||
break;
|
||||
} else if (err < 0) {
|
||||
/* An error occurred. */
|
||||
fprintf(stderr, "Error filtering the data:");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
avfilter_graph_free(&graph);
|
||||
av_frame_free(&frame);
|
||||
av_freep(&md5);
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
av_strerror(err, errstr, sizeof(errstr));
|
||||
fprintf(stderr, "%s\n", errstr);
|
||||
return 1;
|
||||
}
|
@ -1,295 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Nicolas George
|
||||
* Copyright (c) 2011 Stefano Sabatini
|
||||
* Copyright (c) 2012 Clément Bœsch
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* API example for audio decoding and filtering
|
||||
* @example filtering_audio.c
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavfilter/avfiltergraph.h>
|
||||
#include <libavfilter/buffersink.h>
|
||||
#include <libavfilter/buffersrc.h>
|
||||
#include <libavutil/opt.h>
|
||||
|
||||
static const char *filter_descr = "aresample=8000,aformat=sample_fmts=s16:channel_layouts=mono";
|
||||
static const char *player = "ffplay -f s16le -ar 8000 -ac 1 -";
|
||||
|
||||
static AVFormatContext *fmt_ctx;
|
||||
static AVCodecContext *dec_ctx;
|
||||
AVFilterContext *buffersink_ctx;
|
||||
AVFilterContext *buffersrc_ctx;
|
||||
AVFilterGraph *filter_graph;
|
||||
static int audio_stream_index = -1;
|
||||
|
||||
static int open_input_file(const char *filename)
|
||||
{
|
||||
int ret;
|
||||
AVCodec *dec;
|
||||
|
||||
if ((ret = avformat_open_input(&fmt_ctx, filename, NULL, NULL)) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* select the audio stream */
|
||||
ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &dec, 0);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot find an audio stream in the input file\n");
|
||||
return ret;
|
||||
}
|
||||
audio_stream_index = ret;
|
||||
dec_ctx = fmt_ctx->streams[audio_stream_index]->codec;
|
||||
av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0);
|
||||
|
||||
/* init the audio decoder */
|
||||
if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot open audio decoder\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int init_filters(const char *filters_descr)
|
||||
{
|
||||
char args[512];
|
||||
int ret = 0;
|
||||
AVFilter *abuffersrc = avfilter_get_by_name("abuffer");
|
||||
AVFilter *abuffersink = avfilter_get_by_name("abuffersink");
|
||||
AVFilterInOut *outputs = avfilter_inout_alloc();
|
||||
AVFilterInOut *inputs = avfilter_inout_alloc();
|
||||
static const enum AVSampleFormat out_sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 };
|
||||
static const int64_t out_channel_layouts[] = { AV_CH_LAYOUT_MONO, -1 };
|
||||
static const int out_sample_rates[] = { 8000, -1 };
|
||||
const AVFilterLink *outlink;
|
||||
AVRational time_base = fmt_ctx->streams[audio_stream_index]->time_base;
|
||||
|
||||
filter_graph = avfilter_graph_alloc();
|
||||
if (!outputs || !inputs || !filter_graph) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* buffer audio source: the decoded frames from the decoder will be inserted here. */
|
||||
if (!dec_ctx->channel_layout)
|
||||
dec_ctx->channel_layout = av_get_default_channel_layout(dec_ctx->channels);
|
||||
snprintf(args, sizeof(args),
|
||||
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%"PRIx64,
|
||||
time_base.num, time_base.den, dec_ctx->sample_rate,
|
||||
av_get_sample_fmt_name(dec_ctx->sample_fmt), dec_ctx->channel_layout);
|
||||
ret = avfilter_graph_create_filter(&buffersrc_ctx, abuffersrc, "in",
|
||||
args, NULL, filter_graph);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer source\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* buffer audio sink: to terminate the filter chain. */
|
||||
ret = avfilter_graph_create_filter(&buffersink_ctx, abuffersink, "out",
|
||||
NULL, NULL, filter_graph);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer sink\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = av_opt_set_int_list(buffersink_ctx, "sample_fmts", out_sample_fmts, -1,
|
||||
AV_OPT_SEARCH_CHILDREN);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output sample format\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = av_opt_set_int_list(buffersink_ctx, "channel_layouts", out_channel_layouts, -1,
|
||||
AV_OPT_SEARCH_CHILDREN);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = av_opt_set_int_list(buffersink_ctx, "sample_rates", out_sample_rates, -1,
|
||||
AV_OPT_SEARCH_CHILDREN);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output sample rate\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the endpoints for the filter graph. The filter_graph will
|
||||
* be linked to the graph described by filters_descr.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The buffer source output must be connected to the input pad of
|
||||
* the first filter described by filters_descr; since the first
|
||||
* filter input label is not specified, it is set to "in" by
|
||||
* default.
|
||||
*/
|
||||
outputs->name = av_strdup("in");
|
||||
outputs->filter_ctx = buffersrc_ctx;
|
||||
outputs->pad_idx = 0;
|
||||
outputs->next = NULL;
|
||||
|
||||
/*
|
||||
* The buffer sink input must be connected to the output pad of
|
||||
* the last filter described by filters_descr; since the last
|
||||
* filter output label is not specified, it is set to "out" by
|
||||
* default.
|
||||
*/
|
||||
inputs->name = av_strdup("out");
|
||||
inputs->filter_ctx = buffersink_ctx;
|
||||
inputs->pad_idx = 0;
|
||||
inputs->next = NULL;
|
||||
|
||||
if ((ret = avfilter_graph_parse_ptr(filter_graph, filters_descr,
|
||||
&inputs, &outputs, NULL)) < 0)
|
||||
goto end;
|
||||
|
||||
if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0)
|
||||
goto end;
|
||||
|
||||
/* Print summary of the sink buffer
|
||||
* Note: args buffer is reused to store channel layout string */
|
||||
outlink = buffersink_ctx->inputs[0];
|
||||
av_get_channel_layout_string(args, sizeof(args), -1, outlink->channel_layout);
|
||||
av_log(NULL, AV_LOG_INFO, "Output: srate:%dHz fmt:%s chlayout:%s\n",
|
||||
(int)outlink->sample_rate,
|
||||
(char *)av_x_if_null(av_get_sample_fmt_name(outlink->format), "?"),
|
||||
args);
|
||||
|
||||
end:
|
||||
avfilter_inout_free(&inputs);
|
||||
avfilter_inout_free(&outputs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void print_frame(const AVFrame *frame)
|
||||
{
|
||||
const int n = frame->nb_samples * av_get_channel_layout_nb_channels(av_frame_get_channel_layout(frame));
|
||||
const uint16_t *p = (uint16_t*)frame->data[0];
|
||||
const uint16_t *p_end = p + n;
|
||||
|
||||
while (p < p_end) {
|
||||
fputc(*p & 0xff, stdout);
|
||||
fputc(*p>>8 & 0xff, stdout);
|
||||
p++;
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
AVPacket packet0, packet;
|
||||
AVFrame *frame = av_frame_alloc();
|
||||
AVFrame *filt_frame = av_frame_alloc();
|
||||
int got_frame;
|
||||
|
||||
if (!frame || !filt_frame) {
|
||||
perror("Could not allocate frame");
|
||||
exit(1);
|
||||
}
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: %s file | %s\n", argv[0], player);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
av_register_all();
|
||||
avfilter_register_all();
|
||||
|
||||
if ((ret = open_input_file(argv[1])) < 0)
|
||||
goto end;
|
||||
if ((ret = init_filters(filter_descr)) < 0)
|
||||
goto end;
|
||||
|
||||
/* read all packets */
|
||||
packet0.data = NULL;
|
||||
packet.data = NULL;
|
||||
while (1) {
|
||||
if (!packet0.data) {
|
||||
if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)
|
||||
break;
|
||||
packet0 = packet;
|
||||
}
|
||||
|
||||
if (packet.stream_index == audio_stream_index) {
|
||||
got_frame = 0;
|
||||
ret = avcodec_decode_audio4(dec_ctx, frame, &got_frame, &packet);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error decoding audio\n");
|
||||
continue;
|
||||
}
|
||||
packet.size -= ret;
|
||||
packet.data += ret;
|
||||
|
||||
if (got_frame) {
|
||||
/* push the audio data from decoded frame into the filtergraph */
|
||||
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, 0) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error while feeding the audio filtergraph\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* pull filtered audio from the filtergraph */
|
||||
while (1) {
|
||||
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
||||
break;
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
print_frame(filt_frame);
|
||||
av_frame_unref(filt_frame);
|
||||
}
|
||||
}
|
||||
|
||||
if (packet.size <= 0)
|
||||
av_packet_unref(&packet0);
|
||||
} else {
|
||||
/* discard non-wanted packets */
|
||||
av_packet_unref(&packet0);
|
||||
}
|
||||
}
|
||||
end:
|
||||
avfilter_graph_free(&filter_graph);
|
||||
avcodec_close(dec_ctx);
|
||||
avformat_close_input(&fmt_ctx);
|
||||
av_frame_free(&frame);
|
||||
av_frame_free(&filt_frame);
|
||||
|
||||
if (ret < 0 && ret != AVERROR_EOF) {
|
||||
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
@ -1,280 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Nicolas George
|
||||
* Copyright (c) 2011 Stefano Sabatini
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* API example for decoding and filtering
|
||||
* @example filtering_video.c
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600 /* for usleep */
|
||||
#include <unistd.h>
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavfilter/avfiltergraph.h>
|
||||
#include <libavfilter/buffersink.h>
|
||||
#include <libavfilter/buffersrc.h>
|
||||
#include <libavutil/opt.h>
|
||||
|
||||
const char *filter_descr = "scale=78:24,transpose=cclock";
|
||||
/* other way:
|
||||
scale=78:24 [scl]; [scl] transpose=cclock // assumes "[in]" and "[out]" to be input output pads respectively
|
||||
*/
|
||||
|
||||
static AVFormatContext *fmt_ctx;
|
||||
static AVCodecContext *dec_ctx;
|
||||
AVFilterContext *buffersink_ctx;
|
||||
AVFilterContext *buffersrc_ctx;
|
||||
AVFilterGraph *filter_graph;
|
||||
static int video_stream_index = -1;
|
||||
static int64_t last_pts = AV_NOPTS_VALUE;
|
||||
|
||||
static int open_input_file(const char *filename)
|
||||
{
|
||||
int ret;
|
||||
AVCodec *dec;
|
||||
|
||||
if ((ret = avformat_open_input(&fmt_ctx, filename, NULL, NULL)) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* select the video stream */
|
||||
ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &dec, 0);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot find a video stream in the input file\n");
|
||||
return ret;
|
||||
}
|
||||
video_stream_index = ret;
|
||||
dec_ctx = fmt_ctx->streams[video_stream_index]->codec;
|
||||
av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0);
|
||||
|
||||
/* init the video decoder */
|
||||
if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot open video decoder\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int init_filters(const char *filters_descr)
|
||||
{
|
||||
char args[512];
|
||||
int ret = 0;
|
||||
AVFilter *buffersrc = avfilter_get_by_name("buffer");
|
||||
AVFilter *buffersink = avfilter_get_by_name("buffersink");
|
||||
AVFilterInOut *outputs = avfilter_inout_alloc();
|
||||
AVFilterInOut *inputs = avfilter_inout_alloc();
|
||||
AVRational time_base = fmt_ctx->streams[video_stream_index]->time_base;
|
||||
enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE };
|
||||
|
||||
filter_graph = avfilter_graph_alloc();
|
||||
if (!outputs || !inputs || !filter_graph) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* buffer video source: the decoded frames from the decoder will be inserted here. */
|
||||
snprintf(args, sizeof(args),
|
||||
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
|
||||
dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt,
|
||||
time_base.num, time_base.den,
|
||||
dec_ctx->sample_aspect_ratio.num, dec_ctx->sample_aspect_ratio.den);
|
||||
|
||||
ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in",
|
||||
args, NULL, filter_graph);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer source\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* buffer video sink: to terminate the filter chain. */
|
||||
ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out",
|
||||
NULL, NULL, filter_graph);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer sink\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = av_opt_set_int_list(buffersink_ctx, "pix_fmts", pix_fmts,
|
||||
AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output pixel format\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the endpoints for the filter graph. The filter_graph will
|
||||
* be linked to the graph described by filters_descr.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The buffer source output must be connected to the input pad of
|
||||
* the first filter described by filters_descr; since the first
|
||||
* filter input label is not specified, it is set to "in" by
|
||||
* default.
|
||||
*/
|
||||
outputs->name = av_strdup("in");
|
||||
outputs->filter_ctx = buffersrc_ctx;
|
||||
outputs->pad_idx = 0;
|
||||
outputs->next = NULL;
|
||||
|
||||
/*
|
||||
* The buffer sink input must be connected to the output pad of
|
||||
* the last filter described by filters_descr; since the last
|
||||
* filter output label is not specified, it is set to "out" by
|
||||
* default.
|
||||
*/
|
||||
inputs->name = av_strdup("out");
|
||||
inputs->filter_ctx = buffersink_ctx;
|
||||
inputs->pad_idx = 0;
|
||||
inputs->next = NULL;
|
||||
|
||||
if ((ret = avfilter_graph_parse_ptr(filter_graph, filters_descr,
|
||||
&inputs, &outputs, NULL)) < 0)
|
||||
goto end;
|
||||
|
||||
if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0)
|
||||
goto end;
|
||||
|
||||
end:
|
||||
avfilter_inout_free(&inputs);
|
||||
avfilter_inout_free(&outputs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void display_frame(const AVFrame *frame, AVRational time_base)
|
||||
{
|
||||
int x, y;
|
||||
uint8_t *p0, *p;
|
||||
int64_t delay;
|
||||
|
||||
if (frame->pts != AV_NOPTS_VALUE) {
|
||||
if (last_pts != AV_NOPTS_VALUE) {
|
||||
/* sleep roughly the right amount of time;
|
||||
* usleep is in microseconds, just like AV_TIME_BASE. */
|
||||
delay = av_rescale_q(frame->pts - last_pts,
|
||||
time_base, AV_TIME_BASE_Q);
|
||||
if (delay > 0 && delay < 1000000)
|
||||
usleep(delay);
|
||||
}
|
||||
last_pts = frame->pts;
|
||||
}
|
||||
|
||||
/* Trivial ASCII grayscale display. */
|
||||
p0 = frame->data[0];
|
||||
puts("\033c");
|
||||
for (y = 0; y < frame->height; y++) {
|
||||
p = p0;
|
||||
for (x = 0; x < frame->width; x++)
|
||||
putchar(" .-+#"[*(p++) / 52]);
|
||||
putchar('\n');
|
||||
p0 += frame->linesize[0];
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
AVPacket packet;
|
||||
AVFrame *frame = av_frame_alloc();
|
||||
AVFrame *filt_frame = av_frame_alloc();
|
||||
int got_frame;
|
||||
|
||||
if (!frame || !filt_frame) {
|
||||
perror("Could not allocate frame");
|
||||
exit(1);
|
||||
}
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: %s file\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
av_register_all();
|
||||
avfilter_register_all();
|
||||
|
||||
if ((ret = open_input_file(argv[1])) < 0)
|
||||
goto end;
|
||||
if ((ret = init_filters(filter_descr)) < 0)
|
||||
goto end;
|
||||
|
||||
/* read all packets */
|
||||
while (1) {
|
||||
if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)
|
||||
break;
|
||||
|
||||
if (packet.stream_index == video_stream_index) {
|
||||
got_frame = 0;
|
||||
ret = avcodec_decode_video2(dec_ctx, frame, &got_frame, &packet);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error decoding video\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (got_frame) {
|
||||
frame->pts = av_frame_get_best_effort_timestamp(frame);
|
||||
|
||||
/* push the decoded frame into the filtergraph */
|
||||
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* pull filtered frames from the filtergraph */
|
||||
while (1) {
|
||||
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
||||
break;
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
display_frame(filt_frame, buffersink_ctx->inputs[0]->time_base);
|
||||
av_frame_unref(filt_frame);
|
||||
}
|
||||
av_frame_unref(frame);
|
||||
}
|
||||
}
|
||||
av_packet_unref(&packet);
|
||||
}
|
||||
end:
|
||||
avfilter_graph_free(&filter_graph);
|
||||
avcodec_close(dec_ctx);
|
||||
avformat_close_input(&fmt_ctx);
|
||||
av_frame_free(&frame);
|
||||
av_frame_free(&filt_frame);
|
||||
|
||||
if (ret < 0 && ret != AVERROR_EOF) {
|
||||
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
@ -1,155 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Stephan Holljes
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* libavformat multi-client network API usage example.
|
||||
*
|
||||
* @example http_multiclient.c
|
||||
* This example will serve a file without decoding or demuxing it over http.
|
||||
* Multiple clients can connect and will receive the same file.
|
||||
*/
|
||||
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/opt.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void process_client(AVIOContext *client, const char *in_uri)
|
||||
{
|
||||
AVIOContext *input = NULL;
|
||||
uint8_t buf[1024];
|
||||
int ret, n, reply_code;
|
||||
uint8_t *resource = NULL;
|
||||
while ((ret = avio_handshake(client)) > 0) {
|
||||
av_opt_get(client, "resource", AV_OPT_SEARCH_CHILDREN, &resource);
|
||||
// check for strlen(resource) is necessary, because av_opt_get()
|
||||
// may return empty string.
|
||||
if (resource && strlen(resource))
|
||||
break;
|
||||
}
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
av_log(client, AV_LOG_TRACE, "resource=%p\n", resource);
|
||||
if (resource && resource[0] == '/' && !strcmp((resource + 1), in_uri)) {
|
||||
reply_code = 200;
|
||||
} else {
|
||||
reply_code = AVERROR_HTTP_NOT_FOUND;
|
||||
}
|
||||
if ((ret = av_opt_set_int(client, "reply_code", reply_code, AV_OPT_SEARCH_CHILDREN)) < 0) {
|
||||
av_log(client, AV_LOG_ERROR, "Failed to set reply_code: %s.\n", av_err2str(ret));
|
||||
goto end;
|
||||
}
|
||||
av_log(client, AV_LOG_TRACE, "Set reply code to %d\n", reply_code);
|
||||
|
||||
while ((ret = avio_handshake(client)) > 0);
|
||||
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
|
||||
fprintf(stderr, "Handshake performed.\n");
|
||||
if (reply_code != 200)
|
||||
goto end;
|
||||
fprintf(stderr, "Opening input file.\n");
|
||||
if ((ret = avio_open2(&input, in_uri, AVIO_FLAG_READ, NULL, NULL)) < 0) {
|
||||
av_log(input, AV_LOG_ERROR, "Failed to open input: %s: %s.\n", in_uri,
|
||||
av_err2str(ret));
|
||||
goto end;
|
||||
}
|
||||
for(;;) {
|
||||
n = avio_read(input, buf, sizeof(buf));
|
||||
if (n < 0) {
|
||||
if (n == AVERROR_EOF)
|
||||
break;
|
||||
av_log(input, AV_LOG_ERROR, "Error reading from input: %s.\n",
|
||||
av_err2str(n));
|
||||
break;
|
||||
}
|
||||
avio_write(client, buf, n);
|
||||
avio_flush(client);
|
||||
}
|
||||
end:
|
||||
fprintf(stderr, "Flushing client\n");
|
||||
avio_flush(client);
|
||||
fprintf(stderr, "Closing client\n");
|
||||
avio_close(client);
|
||||
fprintf(stderr, "Closing input\n");
|
||||
avio_close(input);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
AVDictionary *options = NULL;
|
||||
AVIOContext *client = NULL, *server = NULL;
|
||||
const char *in_uri, *out_uri;
|
||||
int ret, pid;
|
||||
av_log_set_level(AV_LOG_TRACE);
|
||||
if (argc < 3) {
|
||||
printf("usage: %s input http://hostname[:port]\n"
|
||||
"API example program to serve http to multiple clients.\n"
|
||||
"\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uri = argv[1];
|
||||
out_uri = argv[2];
|
||||
|
||||
av_register_all();
|
||||
avformat_network_init();
|
||||
|
||||
if ((ret = av_dict_set(&options, "listen", "2", 0)) < 0) {
|
||||
fprintf(stderr, "Failed to set listen mode for server: %s\n", av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
if ((ret = avio_open2(&server, out_uri, AVIO_FLAG_WRITE, NULL, &options)) < 0) {
|
||||
fprintf(stderr, "Failed to open server: %s\n", av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
fprintf(stderr, "Entering main loop.\n");
|
||||
for(;;) {
|
||||
if ((ret = avio_accept(server, &client)) < 0)
|
||||
goto end;
|
||||
fprintf(stderr, "Accepted client, forking process.\n");
|
||||
// XXX: Since we don't reap our children and don't ignore signals
|
||||
// this produces zombie processes.
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
perror("Fork failed");
|
||||
ret = AVERROR(errno);
|
||||
goto end;
|
||||
}
|
||||
if (pid == 0) {
|
||||
fprintf(stderr, "In child.\n");
|
||||
process_client(client, in_uri);
|
||||
avio_close(server);
|
||||
exit(0);
|
||||
}
|
||||
if (pid > 0)
|
||||
avio_close(client);
|
||||
}
|
||||
end:
|
||||
avio_close(server);
|
||||
if (ret < 0 && ret != AVERROR_EOF) {
|
||||
fprintf(stderr, "Some errors occurred: %s\n", av_err2str(ret));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Reinhard Tartler
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Shows how the metadata API can be used in application programs.
|
||||
* @example metadata.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/dict.h>
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
AVFormatContext *fmt_ctx = NULL;
|
||||
AVDictionaryEntry *tag = NULL;
|
||||
int ret;
|
||||
|
||||
if (argc != 2) {
|
||||
printf("usage: %s <input_file>\n"
|
||||
"example program to demonstrate the use of the libavformat metadata API.\n"
|
||||
"\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
av_register_all();
|
||||
if ((ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL)))
|
||||
return ret;
|
||||
|
||||
while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
|
||||
printf("%s=%s\n", tag->key, tag->value);
|
||||
|
||||
avformat_close_input(&fmt_ctx);
|
||||
return 0;
|
||||
}
|
@ -1,673 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* libavformat API example.
|
||||
*
|
||||
* Output a media file in any supported libavformat format. The default
|
||||
* codecs are used.
|
||||
* @example muxing.c
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <libavutil/avassert.h>
|
||||
#include <libavutil/channel_layout.h>
|
||||
#include <libavutil/opt.h>
|
||||
#include <libavutil/mathematics.h>
|
||||
#include <libavutil/timestamp.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libswscale/swscale.h>
|
||||
#include <libswresample/swresample.h>
|
||||
|
||||
#define STREAM_DURATION 10.0
|
||||
#define STREAM_FRAME_RATE 25 /* 25 images/s */
|
||||
#define STREAM_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */
|
||||
|
||||
#define SCALE_FLAGS SWS_BICUBIC
|
||||
|
||||
// a wrapper around a single output AVStream
|
||||
typedef struct OutputStream {
|
||||
AVStream *st;
|
||||
AVCodecContext *enc;
|
||||
|
||||
/* pts of the next frame that will be generated */
|
||||
int64_t next_pts;
|
||||
int samples_count;
|
||||
|
||||
AVFrame *frame;
|
||||
AVFrame *tmp_frame;
|
||||
|
||||
float t, tincr, tincr2;
|
||||
|
||||
struct SwsContext *sws_ctx;
|
||||
struct SwrContext *swr_ctx;
|
||||
} OutputStream;
|
||||
|
||||
static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt)
|
||||
{
|
||||
AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base;
|
||||
|
||||
printf("pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n",
|
||||
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
|
||||
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
|
||||
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base),
|
||||
pkt->stream_index);
|
||||
}
|
||||
|
||||
static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt)
|
||||
{
|
||||
/* rescale output packet timestamp values from codec to stream timebase */
|
||||
av_packet_rescale_ts(pkt, *time_base, st->time_base);
|
||||
pkt->stream_index = st->index;
|
||||
|
||||
/* Write the compressed frame to the media file. */
|
||||
log_packet(fmt_ctx, pkt);
|
||||
return av_interleaved_write_frame(fmt_ctx, pkt);
|
||||
}
|
||||
|
||||
/* Add an output stream. */
|
||||
static void add_stream(OutputStream *ost, AVFormatContext *oc,
|
||||
AVCodec **codec,
|
||||
enum AVCodecID codec_id)
|
||||
{
|
||||
AVCodecContext *c;
|
||||
int i;
|
||||
|
||||
/* find the encoder */
|
||||
*codec = avcodec_find_encoder(codec_id);
|
||||
if (!(*codec)) {
|
||||
fprintf(stderr, "Could not find encoder for '%s'\n",
|
||||
avcodec_get_name(codec_id));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ost->st = avformat_new_stream(oc, NULL);
|
||||
if (!ost->st) {
|
||||
fprintf(stderr, "Could not allocate stream\n");
|
||||
exit(1);
|
||||
}
|
||||
ost->st->id = oc->nb_streams-1;
|
||||
c = avcodec_alloc_context3(*codec);
|
||||
if (!c) {
|
||||
fprintf(stderr, "Could not alloc an encoding context\n");
|
||||
exit(1);
|
||||
}
|
||||
ost->enc = c;
|
||||
|
||||
switch ((*codec)->type) {
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
c->sample_fmt = (*codec)->sample_fmts ?
|
||||
(*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
|
||||
c->bit_rate = 64000;
|
||||
c->sample_rate = 44100;
|
||||
if ((*codec)->supported_samplerates) {
|
||||
c->sample_rate = (*codec)->supported_samplerates[0];
|
||||
for (i = 0; (*codec)->supported_samplerates[i]; i++) {
|
||||
if ((*codec)->supported_samplerates[i] == 44100)
|
||||
c->sample_rate = 44100;
|
||||
}
|
||||
}
|
||||
c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
|
||||
c->channel_layout = AV_CH_LAYOUT_STEREO;
|
||||
if ((*codec)->channel_layouts) {
|
||||
c->channel_layout = (*codec)->channel_layouts[0];
|
||||
for (i = 0; (*codec)->channel_layouts[i]; i++) {
|
||||
if ((*codec)->channel_layouts[i] == AV_CH_LAYOUT_STEREO)
|
||||
c->channel_layout = AV_CH_LAYOUT_STEREO;
|
||||
}
|
||||
}
|
||||
c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
|
||||
ost->st->time_base = (AVRational){ 1, c->sample_rate };
|
||||
break;
|
||||
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
c->codec_id = codec_id;
|
||||
|
||||
c->bit_rate = 400000;
|
||||
/* Resolution must be a multiple of two. */
|
||||
c->width = 352;
|
||||
c->height = 288;
|
||||
/* timebase: This is the fundamental unit of time (in seconds) in terms
|
||||
* of which frame timestamps are represented. For fixed-fps content,
|
||||
* timebase should be 1/framerate and timestamp increments should be
|
||||
* identical to 1. */
|
||||
ost->st->time_base = (AVRational){ 1, STREAM_FRAME_RATE };
|
||||
c->time_base = ost->st->time_base;
|
||||
|
||||
c->gop_size = 12; /* emit one intra frame every twelve frames at most */
|
||||
c->pix_fmt = STREAM_PIX_FMT;
|
||||
if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
|
||||
/* just for testing, we also add B-frames */
|
||||
c->max_b_frames = 2;
|
||||
}
|
||||
if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
|
||||
/* Needed to avoid using macroblocks in which some coeffs overflow.
|
||||
* This does not happen with normal video, it just happens here as
|
||||
* the motion of the chroma plane does not match the luma plane. */
|
||||
c->mb_decision = 2;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Some formats want stream headers to be separate. */
|
||||
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
|
||||
c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/* audio output */
|
||||
|
||||
static AVFrame *alloc_audio_frame(enum AVSampleFormat sample_fmt,
|
||||
uint64_t channel_layout,
|
||||
int sample_rate, int nb_samples)
|
||||
{
|
||||
AVFrame *frame = av_frame_alloc();
|
||||
int ret;
|
||||
|
||||
if (!frame) {
|
||||
fprintf(stderr, "Error allocating an audio frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
frame->format = sample_fmt;
|
||||
frame->channel_layout = channel_layout;
|
||||
frame->sample_rate = sample_rate;
|
||||
frame->nb_samples = nb_samples;
|
||||
|
||||
if (nb_samples) {
|
||||
ret = av_frame_get_buffer(frame, 0);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error allocating an audio buffer\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
|
||||
{
|
||||
AVCodecContext *c;
|
||||
int nb_samples;
|
||||
int ret;
|
||||
AVDictionary *opt = NULL;
|
||||
|
||||
c = ost->enc;
|
||||
|
||||
/* open it */
|
||||
av_dict_copy(&opt, opt_arg, 0);
|
||||
ret = avcodec_open2(c, codec, &opt);
|
||||
av_dict_free(&opt);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not open audio codec: %s\n", av_err2str(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* init signal generator */
|
||||
ost->t = 0;
|
||||
ost->tincr = 2 * M_PI * 110.0 / c->sample_rate;
|
||||
/* increment frequency by 110 Hz per second */
|
||||
ost->tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate;
|
||||
|
||||
if (c->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
|
||||
nb_samples = 10000;
|
||||
else
|
||||
nb_samples = c->frame_size;
|
||||
|
||||
ost->frame = alloc_audio_frame(c->sample_fmt, c->channel_layout,
|
||||
c->sample_rate, nb_samples);
|
||||
ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout,
|
||||
c->sample_rate, nb_samples);
|
||||
|
||||
/* copy the stream parameters to the muxer */
|
||||
ret = avcodec_parameters_from_context(ost->st->codecpar, c);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not copy the stream parameters\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* create resampler context */
|
||||
ost->swr_ctx = swr_alloc();
|
||||
if (!ost->swr_ctx) {
|
||||
fprintf(stderr, "Could not allocate resampler context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* set options */
|
||||
av_opt_set_int (ost->swr_ctx, "in_channel_count", c->channels, 0);
|
||||
av_opt_set_int (ost->swr_ctx, "in_sample_rate", c->sample_rate, 0);
|
||||
av_opt_set_sample_fmt(ost->swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);
|
||||
av_opt_set_int (ost->swr_ctx, "out_channel_count", c->channels, 0);
|
||||
av_opt_set_int (ost->swr_ctx, "out_sample_rate", c->sample_rate, 0);
|
||||
av_opt_set_sample_fmt(ost->swr_ctx, "out_sample_fmt", c->sample_fmt, 0);
|
||||
|
||||
/* initialize the resampling context */
|
||||
if ((ret = swr_init(ost->swr_ctx)) < 0) {
|
||||
fprintf(stderr, "Failed to initialize the resampling context\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
|
||||
* 'nb_channels' channels. */
|
||||
static AVFrame *get_audio_frame(OutputStream *ost)
|
||||
{
|
||||
AVFrame *frame = ost->tmp_frame;
|
||||
int j, i, v;
|
||||
int16_t *q = (int16_t*)frame->data[0];
|
||||
|
||||
/* check if we want to generate more frames */
|
||||
if (av_compare_ts(ost->next_pts, ost->enc->time_base,
|
||||
STREAM_DURATION, (AVRational){ 1, 1 }) >= 0)
|
||||
return NULL;
|
||||
|
||||
for (j = 0; j <frame->nb_samples; j++) {
|
||||
v = (int)(sin(ost->t) * 10000);
|
||||
for (i = 0; i < ost->enc->channels; i++)
|
||||
*q++ = v;
|
||||
ost->t += ost->tincr;
|
||||
ost->tincr += ost->tincr2;
|
||||
}
|
||||
|
||||
frame->pts = ost->next_pts;
|
||||
ost->next_pts += frame->nb_samples;
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
/*
|
||||
* encode one audio frame and send it to the muxer
|
||||
* return 1 when encoding is finished, 0 otherwise
|
||||
*/
|
||||
static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
|
||||
{
|
||||
AVCodecContext *c;
|
||||
AVPacket pkt = { 0 }; // data and size must be 0;
|
||||
AVFrame *frame;
|
||||
int ret;
|
||||
int got_packet;
|
||||
int dst_nb_samples;
|
||||
|
||||
av_init_packet(&pkt);
|
||||
c = ost->enc;
|
||||
|
||||
frame = get_audio_frame(ost);
|
||||
|
||||
if (frame) {
|
||||
/* convert samples from native format to destination codec format, using the resampler */
|
||||
/* compute destination number of samples */
|
||||
dst_nb_samples = av_rescale_rnd(swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples,
|
||||
c->sample_rate, c->sample_rate, AV_ROUND_UP);
|
||||
av_assert0(dst_nb_samples == frame->nb_samples);
|
||||
|
||||
/* when we pass a frame to the encoder, it may keep a reference to it
|
||||
* internally;
|
||||
* make sure we do not overwrite it here
|
||||
*/
|
||||
ret = av_frame_make_writable(ost->frame);
|
||||
if (ret < 0)
|
||||
exit(1);
|
||||
|
||||
/* convert to destination format */
|
||||
ret = swr_convert(ost->swr_ctx,
|
||||
ost->frame->data, dst_nb_samples,
|
||||
(const uint8_t **)frame->data, frame->nb_samples);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error while converting\n");
|
||||
exit(1);
|
||||
}
|
||||
frame = ost->frame;
|
||||
|
||||
frame->pts = av_rescale_q(ost->samples_count, (AVRational){1, c->sample_rate}, c->time_base);
|
||||
ost->samples_count += dst_nb_samples;
|
||||
}
|
||||
|
||||
ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (got_packet) {
|
||||
ret = write_frame(oc, &c->time_base, ost->st, &pkt);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error while writing audio frame: %s\n",
|
||||
av_err2str(ret));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
return (frame || got_packet) ? 0 : 1;
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/* video output */
|
||||
|
||||
static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
|
||||
{
|
||||
AVFrame *picture;
|
||||
int ret;
|
||||
|
||||
picture = av_frame_alloc();
|
||||
if (!picture)
|
||||
return NULL;
|
||||
|
||||
picture->format = pix_fmt;
|
||||
picture->width = width;
|
||||
picture->height = height;
|
||||
|
||||
/* allocate the buffers for the frame data */
|
||||
ret = av_frame_get_buffer(picture, 32);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not allocate frame data.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return picture;
|
||||
}
|
||||
|
||||
static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
|
||||
{
|
||||
int ret;
|
||||
AVCodecContext *c = ost->enc;
|
||||
AVDictionary *opt = NULL;
|
||||
|
||||
av_dict_copy(&opt, opt_arg, 0);
|
||||
|
||||
/* open the codec */
|
||||
ret = avcodec_open2(c, codec, &opt);
|
||||
av_dict_free(&opt);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* allocate and init a re-usable frame */
|
||||
ost->frame = alloc_picture(c->pix_fmt, c->width, c->height);
|
||||
if (!ost->frame) {
|
||||
fprintf(stderr, "Could not allocate video frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* If the output format is not YUV420P, then a temporary YUV420P
|
||||
* picture is needed too. It is then converted to the required
|
||||
* output format. */
|
||||
ost->tmp_frame = NULL;
|
||||
if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
|
||||
ost->tmp_frame = alloc_picture(AV_PIX_FMT_YUV420P, c->width, c->height);
|
||||
if (!ost->tmp_frame) {
|
||||
fprintf(stderr, "Could not allocate temporary picture\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* copy the stream parameters to the muxer */
|
||||
ret = avcodec_parameters_from_context(ost->st->codecpar, c);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not copy the stream parameters\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepare a dummy image. */
|
||||
static void fill_yuv_image(AVFrame *pict, int frame_index,
|
||||
int width, int height)
|
||||
{
|
||||
int x, y, i, ret;
|
||||
|
||||
/* when we pass a frame to the encoder, it may keep a reference to it
|
||||
* internally;
|
||||
* make sure we do not overwrite it here
|
||||
*/
|
||||
ret = av_frame_make_writable(pict);
|
||||
if (ret < 0)
|
||||
exit(1);
|
||||
|
||||
i = frame_index;
|
||||
|
||||
/* Y */
|
||||
for (y = 0; y < height; y++)
|
||||
for (x = 0; x < width; x++)
|
||||
pict->data[0][y * pict->linesize[0] + x] = x + y + i * 3;
|
||||
|
||||
/* Cb and Cr */
|
||||
for (y = 0; y < height / 2; y++) {
|
||||
for (x = 0; x < width / 2; x++) {
|
||||
pict->data[1][y * pict->linesize[1] + x] = 128 + y + i * 2;
|
||||
pict->data[2][y * pict->linesize[2] + x] = 64 + x + i * 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static AVFrame *get_video_frame(OutputStream *ost)
|
||||
{
|
||||
AVCodecContext *c = ost->enc;
|
||||
|
||||
/* check if we want to generate more frames */
|
||||
if (av_compare_ts(ost->next_pts, c->time_base,
|
||||
STREAM_DURATION, (AVRational){ 1, 1 }) >= 0)
|
||||
return NULL;
|
||||
|
||||
if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
|
||||
/* as we only generate a YUV420P picture, we must convert it
|
||||
* to the codec pixel format if needed */
|
||||
if (!ost->sws_ctx) {
|
||||
ost->sws_ctx = sws_getContext(c->width, c->height,
|
||||
AV_PIX_FMT_YUV420P,
|
||||
c->width, c->height,
|
||||
c->pix_fmt,
|
||||
SCALE_FLAGS, NULL, NULL, NULL);
|
||||
if (!ost->sws_ctx) {
|
||||
fprintf(stderr,
|
||||
"Could not initialize the conversion context\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
fill_yuv_image(ost->tmp_frame, ost->next_pts, c->width, c->height);
|
||||
sws_scale(ost->sws_ctx,
|
||||
(const uint8_t * const *)ost->tmp_frame->data, ost->tmp_frame->linesize,
|
||||
0, c->height, ost->frame->data, ost->frame->linesize);
|
||||
} else {
|
||||
fill_yuv_image(ost->frame, ost->next_pts, c->width, c->height);
|
||||
}
|
||||
|
||||
ost->frame->pts = ost->next_pts++;
|
||||
|
||||
return ost->frame;
|
||||
}
|
||||
|
||||
/*
|
||||
* encode one video frame and send it to the muxer
|
||||
* return 1 when encoding is finished, 0 otherwise
|
||||
*/
|
||||
static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
|
||||
{
|
||||
int ret;
|
||||
AVCodecContext *c;
|
||||
AVFrame *frame;
|
||||
int got_packet = 0;
|
||||
AVPacket pkt = { 0 };
|
||||
|
||||
c = ost->enc;
|
||||
|
||||
frame = get_video_frame(ost);
|
||||
|
||||
av_init_packet(&pkt);
|
||||
|
||||
/* encode the image */
|
||||
ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (got_packet) {
|
||||
ret = write_frame(oc, &c->time_base, ost->st, &pkt);
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return (frame || got_packet) ? 0 : 1;
|
||||
}
|
||||
|
||||
static void close_stream(AVFormatContext *oc, OutputStream *ost)
|
||||
{
|
||||
avcodec_free_context(&ost->enc);
|
||||
av_frame_free(&ost->frame);
|
||||
av_frame_free(&ost->tmp_frame);
|
||||
sws_freeContext(ost->sws_ctx);
|
||||
swr_free(&ost->swr_ctx);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/* media file output */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
OutputStream video_st = { 0 }, audio_st = { 0 };
|
||||
const char *filename;
|
||||
AVOutputFormat *fmt;
|
||||
AVFormatContext *oc;
|
||||
AVCodec *audio_codec, *video_codec;
|
||||
int ret;
|
||||
int have_video = 0, have_audio = 0;
|
||||
int encode_video = 0, encode_audio = 0;
|
||||
AVDictionary *opt = NULL;
|
||||
int i;
|
||||
|
||||
/* Initialize libavcodec, and register all codecs and formats. */
|
||||
av_register_all();
|
||||
|
||||
if (argc < 2) {
|
||||
printf("usage: %s output_file\n"
|
||||
"API example program to output a media file with libavformat.\n"
|
||||
"This program generates a synthetic audio and video stream, encodes and\n"
|
||||
"muxes them into a file named output_file.\n"
|
||||
"The output format is automatically guessed according to the file extension.\n"
|
||||
"Raw images can also be output by using '%%d' in the filename.\n"
|
||||
"\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
filename = argv[1];
|
||||
for (i = 2; i+1 < argc; i+=2) {
|
||||
if (!strcmp(argv[i], "-flags") || !strcmp(argv[i], "-fflags"))
|
||||
av_dict_set(&opt, argv[i]+1, argv[i+1], 0);
|
||||
}
|
||||
|
||||
/* allocate the output media context */
|
||||
avformat_alloc_output_context2(&oc, NULL, NULL, filename);
|
||||
if (!oc) {
|
||||
printf("Could not deduce output format from file extension: using MPEG.\n");
|
||||
avformat_alloc_output_context2(&oc, NULL, "mpeg", filename);
|
||||
}
|
||||
if (!oc)
|
||||
return 1;
|
||||
|
||||
fmt = oc->oformat;
|
||||
|
||||
/* Add the audio and video streams using the default format codecs
|
||||
* and initialize the codecs. */
|
||||
if (fmt->video_codec != AV_CODEC_ID_NONE) {
|
||||
add_stream(&video_st, oc, &video_codec, fmt->video_codec);
|
||||
have_video = 1;
|
||||
encode_video = 1;
|
||||
}
|
||||
if (fmt->audio_codec != AV_CODEC_ID_NONE) {
|
||||
add_stream(&audio_st, oc, &audio_codec, fmt->audio_codec);
|
||||
have_audio = 1;
|
||||
encode_audio = 1;
|
||||
}
|
||||
|
||||
/* Now that all the parameters are set, we can open the audio and
|
||||
* video codecs and allocate the necessary encode buffers. */
|
||||
if (have_video)
|
||||
open_video(oc, video_codec, &video_st, opt);
|
||||
|
||||
if (have_audio)
|
||||
open_audio(oc, audio_codec, &audio_st, opt);
|
||||
|
||||
av_dump_format(oc, 0, filename, 1);
|
||||
|
||||
/* open the output file, if needed */
|
||||
if (!(fmt->flags & AVFMT_NOFILE)) {
|
||||
ret = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not open '%s': %s\n", filename,
|
||||
av_err2str(ret));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write the stream header, if any. */
|
||||
ret = avformat_write_header(oc, &opt);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error occurred when opening output file: %s\n",
|
||||
av_err2str(ret));
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (encode_video || encode_audio) {
|
||||
/* select the stream to encode */
|
||||
if (encode_video &&
|
||||
(!encode_audio || av_compare_ts(video_st.next_pts, video_st.enc->time_base,
|
||||
audio_st.next_pts, audio_st.enc->time_base) <= 0)) {
|
||||
encode_video = !write_video_frame(oc, &video_st);
|
||||
} else {
|
||||
encode_audio = !write_audio_frame(oc, &audio_st);
|
||||
}
|
||||
}
|
||||
|
||||
/* Write the trailer, if any. The trailer must be written before you
|
||||
* close the CodecContexts open when you wrote the header; otherwise
|
||||
* av_write_trailer() may try to use memory that was freed on
|
||||
* av_codec_close(). */
|
||||
av_write_trailer(oc);
|
||||
|
||||
/* Close each codec. */
|
||||
if (have_video)
|
||||
close_stream(oc, &video_st);
|
||||
if (have_audio)
|
||||
close_stream(oc, &audio_st);
|
||||
|
||||
if (!(fmt->flags & AVFMT_NOFILE))
|
||||
/* Close the output file. */
|
||||
avio_closep(&oc->pb);
|
||||
|
||||
/* free the stream */
|
||||
avformat_free_context(oc);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,487 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Anton Khirnov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Intel QSV-accelerated H.264 decoding example.
|
||||
*
|
||||
* @example qsvdec.c
|
||||
* This example shows how to do QSV-accelerated H.264 decoding with output
|
||||
* frames in the VA-API video surfaces.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <mfx/mfxvideo.h>
|
||||
|
||||
#include <va/va.h>
|
||||
#include <va/va_x11.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavformat/avio.h"
|
||||
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavcodec/qsv.h"
|
||||
|
||||
#include "libavutil/error.h"
|
||||
#include "libavutil/mem.h"
|
||||
|
||||
typedef struct DecodeContext {
|
||||
mfxSession mfx_session;
|
||||
VADisplay va_dpy;
|
||||
|
||||
VASurfaceID *surfaces;
|
||||
mfxMemId *surface_ids;
|
||||
int *surface_used;
|
||||
int nb_surfaces;
|
||||
|
||||
mfxFrameInfo frame_info;
|
||||
} DecodeContext;
|
||||
|
||||
static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req,
|
||||
mfxFrameAllocResponse *resp)
|
||||
{
|
||||
DecodeContext *decode = pthis;
|
||||
int err, i;
|
||||
|
||||
if (decode->surfaces) {
|
||||
fprintf(stderr, "Multiple allocation requests.\n");
|
||||
return MFX_ERR_MEMORY_ALLOC;
|
||||
}
|
||||
if (!(req->Type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)) {
|
||||
fprintf(stderr, "Unsupported surface type: %d\n", req->Type);
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
if (req->Info.BitDepthLuma != 8 || req->Info.BitDepthChroma != 8 ||
|
||||
req->Info.Shift || req->Info.FourCC != MFX_FOURCC_NV12 ||
|
||||
req->Info.ChromaFormat != MFX_CHROMAFORMAT_YUV420) {
|
||||
fprintf(stderr, "Unsupported surface properties.\n");
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
decode->surfaces = av_malloc_array (req->NumFrameSuggested, sizeof(*decode->surfaces));
|
||||
decode->surface_ids = av_malloc_array (req->NumFrameSuggested, sizeof(*decode->surface_ids));
|
||||
decode->surface_used = av_mallocz_array(req->NumFrameSuggested, sizeof(*decode->surface_used));
|
||||
if (!decode->surfaces || !decode->surface_ids || !decode->surface_used)
|
||||
goto fail;
|
||||
|
||||
err = vaCreateSurfaces(decode->va_dpy, VA_RT_FORMAT_YUV420,
|
||||
req->Info.Width, req->Info.Height,
|
||||
decode->surfaces, req->NumFrameSuggested,
|
||||
NULL, 0);
|
||||
if (err != VA_STATUS_SUCCESS) {
|
||||
fprintf(stderr, "Error allocating VA surfaces\n");
|
||||
goto fail;
|
||||
}
|
||||
decode->nb_surfaces = req->NumFrameSuggested;
|
||||
|
||||
for (i = 0; i < decode->nb_surfaces; i++)
|
||||
decode->surface_ids[i] = &decode->surfaces[i];
|
||||
|
||||
resp->mids = decode->surface_ids;
|
||||
resp->NumFrameActual = decode->nb_surfaces;
|
||||
|
||||
decode->frame_info = req->Info;
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
fail:
|
||||
av_freep(&decode->surfaces);
|
||||
av_freep(&decode->surface_ids);
|
||||
av_freep(&decode->surface_used);
|
||||
|
||||
return MFX_ERR_MEMORY_ALLOC;
|
||||
}
|
||||
|
||||
static mfxStatus frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp)
|
||||
{
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
static mfxStatus frame_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
|
||||
{
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static mfxStatus frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
|
||||
{
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl)
|
||||
{
|
||||
*hdl = mid;
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
static void free_surfaces(DecodeContext *decode)
|
||||
{
|
||||
if (decode->surfaces)
|
||||
vaDestroySurfaces(decode->va_dpy, decode->surfaces, decode->nb_surfaces);
|
||||
av_freep(&decode->surfaces);
|
||||
av_freep(&decode->surface_ids);
|
||||
av_freep(&decode->surface_used);
|
||||
decode->nb_surfaces = 0;
|
||||
}
|
||||
|
||||
static void free_buffer(void *opaque, uint8_t *data)
|
||||
{
|
||||
int *used = opaque;
|
||||
*used = 0;
|
||||
av_freep(&data);
|
||||
}
|
||||
|
||||
static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
|
||||
{
|
||||
DecodeContext *decode = avctx->opaque;
|
||||
|
||||
mfxFrameSurface1 *surf;
|
||||
AVBufferRef *surf_buf;
|
||||
int idx;
|
||||
|
||||
for (idx = 0; idx < decode->nb_surfaces; idx++) {
|
||||
if (!decode->surface_used[idx])
|
||||
break;
|
||||
}
|
||||
if (idx == decode->nb_surfaces) {
|
||||
fprintf(stderr, "No free surfaces\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
surf = av_mallocz(sizeof(*surf));
|
||||
if (!surf)
|
||||
return AVERROR(ENOMEM);
|
||||
surf_buf = av_buffer_create((uint8_t*)surf, sizeof(*surf), free_buffer,
|
||||
&decode->surface_used[idx], AV_BUFFER_FLAG_READONLY);
|
||||
if (!surf_buf) {
|
||||
av_freep(&surf);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
surf->Info = decode->frame_info;
|
||||
surf->Data.MemId = &decode->surfaces[idx];
|
||||
|
||||
frame->buf[0] = surf_buf;
|
||||
frame->data[3] = (uint8_t*)surf;
|
||||
|
||||
decode->surface_used[idx] = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts)
|
||||
{
|
||||
while (*pix_fmts != AV_PIX_FMT_NONE) {
|
||||
if (*pix_fmts == AV_PIX_FMT_QSV) {
|
||||
if (!avctx->hwaccel_context) {
|
||||
DecodeContext *decode = avctx->opaque;
|
||||
AVQSVContext *qsv = av_qsv_alloc_context();
|
||||
if (!qsv)
|
||||
return AV_PIX_FMT_NONE;
|
||||
|
||||
qsv->session = decode->mfx_session;
|
||||
qsv->iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
|
||||
|
||||
avctx->hwaccel_context = qsv;
|
||||
}
|
||||
|
||||
return AV_PIX_FMT_QSV;
|
||||
}
|
||||
|
||||
pix_fmts++;
|
||||
}
|
||||
|
||||
fprintf(stderr, "The QSV pixel format not offered in get_format()\n");
|
||||
|
||||
return AV_PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
static int decode_packet(DecodeContext *decode, AVCodecContext *decoder_ctx,
|
||||
AVFrame *frame, AVPacket *pkt,
|
||||
AVIOContext *output_ctx)
|
||||
{
|
||||
int ret = 0;
|
||||
int got_frame = 1;
|
||||
|
||||
while (pkt->size > 0 || (!pkt->data && got_frame)) {
|
||||
ret = avcodec_decode_video2(decoder_ctx, frame, &got_frame, pkt);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error during decoding\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
pkt->data += ret;
|
||||
pkt->size -= ret;
|
||||
|
||||
/* A real program would do something useful with the decoded frame here.
|
||||
* We just retrieve the raw data and write it to a file, which is rather
|
||||
* useless but pedagogic. */
|
||||
if (got_frame) {
|
||||
mfxFrameSurface1 *surf = (mfxFrameSurface1*)frame->data[3];
|
||||
VASurfaceID surface = *(VASurfaceID*)surf->Data.MemId;
|
||||
|
||||
VAImageFormat img_fmt = {
|
||||
.fourcc = VA_FOURCC_NV12,
|
||||
.byte_order = VA_LSB_FIRST,
|
||||
.bits_per_pixel = 8,
|
||||
.depth = 8,
|
||||
};
|
||||
|
||||
VAImage img;
|
||||
|
||||
VAStatus err;
|
||||
uint8_t *data;
|
||||
int i, j;
|
||||
|
||||
img.buf = VA_INVALID_ID;
|
||||
img.image_id = VA_INVALID_ID;
|
||||
|
||||
err = vaCreateImage(decode->va_dpy, &img_fmt,
|
||||
frame->width, frame->height, &img);
|
||||
if (err != VA_STATUS_SUCCESS) {
|
||||
fprintf(stderr, "Error creating an image: %s\n",
|
||||
vaErrorStr(err));
|
||||
ret = AVERROR_UNKNOWN;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
err = vaGetImage(decode->va_dpy, surface, 0, 0,
|
||||
frame->width, frame->height,
|
||||
img.image_id);
|
||||
if (err != VA_STATUS_SUCCESS) {
|
||||
fprintf(stderr, "Error getting an image: %s\n",
|
||||
vaErrorStr(err));
|
||||
ret = AVERROR_UNKNOWN;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
err = vaMapBuffer(decode->va_dpy, img.buf, (void**)&data);
|
||||
if (err != VA_STATUS_SUCCESS) {
|
||||
fprintf(stderr, "Error mapping the image buffer: %s\n",
|
||||
vaErrorStr(err));
|
||||
ret = AVERROR_UNKNOWN;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (i = 0; i < img.num_planes; i++)
|
||||
for (j = 0; j < (img.height >> (i > 0)); j++)
|
||||
avio_write(output_ctx, data + img.offsets[i] + j * img.pitches[i], img.width);
|
||||
|
||||
fail:
|
||||
if (img.buf != VA_INVALID_ID)
|
||||
vaUnmapBuffer(decode->va_dpy, img.buf);
|
||||
if (img.image_id != VA_INVALID_ID)
|
||||
vaDestroyImage(decode->va_dpy, img.image_id);
|
||||
av_frame_unref(frame);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
AVFormatContext *input_ctx = NULL;
|
||||
AVStream *video_st = NULL;
|
||||
AVCodecContext *decoder_ctx = NULL;
|
||||
const AVCodec *decoder;
|
||||
|
||||
AVPacket pkt = { 0 };
|
||||
AVFrame *frame = NULL;
|
||||
|
||||
DecodeContext decode = { NULL };
|
||||
|
||||
Display *dpy = NULL;
|
||||
int va_ver_major, va_ver_minor;
|
||||
|
||||
mfxIMPL mfx_impl = MFX_IMPL_AUTO_ANY;
|
||||
mfxVersion mfx_ver = { { 1, 1 } };
|
||||
|
||||
mfxFrameAllocator frame_allocator = {
|
||||
.pthis = &decode,
|
||||
.Alloc = frame_alloc,
|
||||
.Lock = frame_lock,
|
||||
.Unlock = frame_unlock,
|
||||
.GetHDL = frame_get_hdl,
|
||||
.Free = frame_free,
|
||||
};
|
||||
|
||||
AVIOContext *output_ctx = NULL;
|
||||
|
||||
int ret, i, err;
|
||||
|
||||
av_register_all();
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* open the input file */
|
||||
ret = avformat_open_input(&input_ctx, argv[1], NULL, NULL);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Cannot open input file '%s': ", argv[1]);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
/* find the first H.264 video stream */
|
||||
for (i = 0; i < input_ctx->nb_streams; i++) {
|
||||
AVStream *st = input_ctx->streams[i];
|
||||
|
||||
if (st->codecpar->codec_id == AV_CODEC_ID_H264 && !video_st)
|
||||
video_st = st;
|
||||
else
|
||||
st->discard = AVDISCARD_ALL;
|
||||
}
|
||||
if (!video_st) {
|
||||
fprintf(stderr, "No H.264 video stream in the input file\n");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
/* initialize VA-API */
|
||||
dpy = XOpenDisplay(NULL);
|
||||
if (!dpy) {
|
||||
fprintf(stderr, "Cannot open the X display\n");
|
||||
goto finish;
|
||||
}
|
||||
decode.va_dpy = vaGetDisplay(dpy);
|
||||
if (!decode.va_dpy) {
|
||||
fprintf(stderr, "Cannot open the VA display\n");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
err = vaInitialize(decode.va_dpy, &va_ver_major, &va_ver_minor);
|
||||
if (err != VA_STATUS_SUCCESS) {
|
||||
fprintf(stderr, "Cannot initialize VA: %s\n", vaErrorStr(err));
|
||||
goto finish;
|
||||
}
|
||||
fprintf(stderr, "Initialized VA v%d.%d\n", va_ver_major, va_ver_minor);
|
||||
|
||||
/* initialize an MFX session */
|
||||
err = MFXInit(mfx_impl, &mfx_ver, &decode.mfx_session);
|
||||
if (err != MFX_ERR_NONE) {
|
||||
fprintf(stderr, "Error initializing an MFX session\n");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
MFXVideoCORE_SetHandle(decode.mfx_session, MFX_HANDLE_VA_DISPLAY, decode.va_dpy);
|
||||
MFXVideoCORE_SetFrameAllocator(decode.mfx_session, &frame_allocator);
|
||||
|
||||
/* initialize the decoder */
|
||||
decoder = avcodec_find_decoder_by_name("h264_qsv");
|
||||
if (!decoder) {
|
||||
fprintf(stderr, "The QSV decoder is not present in libavcodec\n");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
decoder_ctx = avcodec_alloc_context3(decoder);
|
||||
if (!decoder_ctx) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto finish;
|
||||
}
|
||||
decoder_ctx->codec_id = AV_CODEC_ID_H264;
|
||||
if (video_st->codecpar->extradata_size) {
|
||||
decoder_ctx->extradata = av_mallocz(video_st->codecpar->extradata_size +
|
||||
AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!decoder_ctx->extradata) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto finish;
|
||||
}
|
||||
memcpy(decoder_ctx->extradata, video_st->codecpar->extradata,
|
||||
video_st->codecpar->extradata_size);
|
||||
decoder_ctx->extradata_size = video_st->codecpar->extradata_size;
|
||||
}
|
||||
decoder_ctx->refcounted_frames = 1;
|
||||
|
||||
decoder_ctx->opaque = &decode;
|
||||
decoder_ctx->get_buffer2 = get_buffer;
|
||||
decoder_ctx->get_format = get_format;
|
||||
|
||||
ret = avcodec_open2(decoder_ctx, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error opening the decoder: ");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
/* open the output stream */
|
||||
ret = avio_open(&output_ctx, argv[2], AVIO_FLAG_WRITE);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error opening the output context: ");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
/* actual decoding */
|
||||
while (ret >= 0) {
|
||||
ret = av_read_frame(input_ctx, &pkt);
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
if (pkt.stream_index == video_st->index)
|
||||
ret = decode_packet(&decode, decoder_ctx, frame, &pkt, output_ctx);
|
||||
|
||||
av_packet_unref(&pkt);
|
||||
}
|
||||
|
||||
/* flush the decoder */
|
||||
pkt.data = NULL;
|
||||
pkt.size = 0;
|
||||
ret = decode_packet(&decode, decoder_ctx, frame, &pkt, output_ctx);
|
||||
|
||||
finish:
|
||||
if (ret < 0) {
|
||||
char buf[1024];
|
||||
av_strerror(ret, buf, sizeof(buf));
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
}
|
||||
|
||||
avformat_close_input(&input_ctx);
|
||||
|
||||
av_frame_free(&frame);
|
||||
|
||||
if (decoder_ctx)
|
||||
av_freep(&decoder_ctx->hwaccel_context);
|
||||
avcodec_free_context(&decoder_ctx);
|
||||
|
||||
free_surfaces(&decode);
|
||||
|
||||
if (decode.mfx_session)
|
||||
MFXClose(decode.mfx_session);
|
||||
if (decode.va_dpy)
|
||||
vaTerminate(decode.va_dpy);
|
||||
if (dpy)
|
||||
XCloseDisplay(dpy);
|
||||
|
||||
avio_close(output_ctx);
|
||||
|
||||
return ret;
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Stefano Sabatini
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* libavformat/libavcodec demuxing and muxing API example.
|
||||
*
|
||||
* Remux streams from one container format to another.
|
||||
* @example remuxing.c
|
||||
*/
|
||||
|
||||
#include <libavutil/timestamp.h>
|
||||
#include <libavformat/avformat.h>
|
||||
|
||||
static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt, const char *tag)
|
||||
{
|
||||
AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base;
|
||||
|
||||
printf("%s: pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n",
|
||||
tag,
|
||||
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
|
||||
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
|
||||
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base),
|
||||
pkt->stream_index);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
AVOutputFormat *ofmt = NULL;
|
||||
AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
|
||||
AVPacket pkt;
|
||||
const char *in_filename, *out_filename;
|
||||
int ret, i;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("usage: %s input output\n"
|
||||
"API example program to remux a media file with libavformat and libavcodec.\n"
|
||||
"The output format is guessed according to the file extension.\n"
|
||||
"\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_filename = argv[1];
|
||||
out_filename = argv[2];
|
||||
|
||||
av_register_all();
|
||||
|
||||
if ((ret = avformat_open_input(&ifmt_ctx, in_filename, 0, 0)) < 0) {
|
||||
fprintf(stderr, "Could not open input file '%s'", in_filename);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((ret = avformat_find_stream_info(ifmt_ctx, 0)) < 0) {
|
||||
fprintf(stderr, "Failed to retrieve input stream information");
|
||||
goto end;
|
||||
}
|
||||
|
||||
av_dump_format(ifmt_ctx, 0, in_filename, 0);
|
||||
|
||||
avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, out_filename);
|
||||
if (!ofmt_ctx) {
|
||||
fprintf(stderr, "Could not create output context\n");
|
||||
ret = AVERROR_UNKNOWN;
|
||||
goto end;
|
||||
}
|
||||
|
||||
ofmt = ofmt_ctx->oformat;
|
||||
|
||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
||||
AVStream *in_stream = ifmt_ctx->streams[i];
|
||||
AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec);
|
||||
if (!out_stream) {
|
||||
fprintf(stderr, "Failed allocating output stream\n");
|
||||
ret = AVERROR_UNKNOWN;
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = avcodec_copy_context(out_stream->codec, in_stream->codec);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Failed to copy context from input to output stream codec context\n");
|
||||
goto end;
|
||||
}
|
||||
out_stream->codec->codec_tag = 0;
|
||||
if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
|
||||
out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
}
|
||||
av_dump_format(ofmt_ctx, 0, out_filename, 1);
|
||||
|
||||
if (!(ofmt->flags & AVFMT_NOFILE)) {
|
||||
ret = avio_open(&ofmt_ctx->pb, out_filename, AVIO_FLAG_WRITE);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not open output file '%s'", out_filename);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
ret = avformat_write_header(ofmt_ctx, NULL);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error occurred when opening output file\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
AVStream *in_stream, *out_stream;
|
||||
|
||||
ret = av_read_frame(ifmt_ctx, &pkt);
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
in_stream = ifmt_ctx->streams[pkt.stream_index];
|
||||
out_stream = ofmt_ctx->streams[pkt.stream_index];
|
||||
|
||||
log_packet(ifmt_ctx, &pkt, "in");
|
||||
|
||||
/* copy packet */
|
||||
pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||
pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||
pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);
|
||||
pkt.pos = -1;
|
||||
log_packet(ofmt_ctx, &pkt, "out");
|
||||
|
||||
ret = av_interleaved_write_frame(ofmt_ctx, &pkt);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error muxing packet\n");
|
||||
break;
|
||||
}
|
||||
av_packet_unref(&pkt);
|
||||
}
|
||||
|
||||
av_write_trailer(ofmt_ctx);
|
||||
end:
|
||||
|
||||
avformat_close_input(&ifmt_ctx);
|
||||
|
||||
/* close output */
|
||||
if (ofmt_ctx && !(ofmt->flags & AVFMT_NOFILE))
|
||||
avio_closep(&ofmt_ctx->pb);
|
||||
avformat_free_context(ofmt_ctx);
|
||||
|
||||
if (ret < 0 && ret != AVERROR_EOF) {
|
||||
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,214 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Stefano Sabatini
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example resampling_audio.c
|
||||
* libswresample API use example.
|
||||
*/
|
||||
|
||||
#include <libavutil/opt.h>
|
||||
#include <libavutil/channel_layout.h>
|
||||
#include <libavutil/samplefmt.h>
|
||||
#include <libswresample/swresample.h>
|
||||
|
||||
static int get_format_from_sample_fmt(const char **fmt,
|
||||
enum AVSampleFormat sample_fmt)
|
||||
{
|
||||
int i;
|
||||
struct sample_fmt_entry {
|
||||
enum AVSampleFormat sample_fmt; const char *fmt_be, *fmt_le;
|
||||
} sample_fmt_entries[] = {
|
||||
{ AV_SAMPLE_FMT_U8, "u8", "u8" },
|
||||
{ AV_SAMPLE_FMT_S16, "s16be", "s16le" },
|
||||
{ AV_SAMPLE_FMT_S32, "s32be", "s32le" },
|
||||
{ AV_SAMPLE_FMT_FLT, "f32be", "f32le" },
|
||||
{ AV_SAMPLE_FMT_DBL, "f64be", "f64le" },
|
||||
};
|
||||
*fmt = NULL;
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(sample_fmt_entries); i++) {
|
||||
struct sample_fmt_entry *entry = &sample_fmt_entries[i];
|
||||
if (sample_fmt == entry->sample_fmt) {
|
||||
*fmt = AV_NE(entry->fmt_be, entry->fmt_le);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"Sample format %s not supported as output format\n",
|
||||
av_get_sample_fmt_name(sample_fmt));
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill dst buffer with nb_samples, generated starting from t.
|
||||
*/
|
||||
static void fill_samples(double *dst, int nb_samples, int nb_channels, int sample_rate, double *t)
|
||||
{
|
||||
int i, j;
|
||||
double tincr = 1.0 / sample_rate, *dstp = dst;
|
||||
const double c = 2 * M_PI * 440.0;
|
||||
|
||||
/* generate sin tone with 440Hz frequency and duplicated channels */
|
||||
for (i = 0; i < nb_samples; i++) {
|
||||
*dstp = sin(c * *t);
|
||||
for (j = 1; j < nb_channels; j++)
|
||||
dstp[j] = dstp[0];
|
||||
dstp += nb_channels;
|
||||
*t += tincr;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int64_t src_ch_layout = AV_CH_LAYOUT_STEREO, dst_ch_layout = AV_CH_LAYOUT_SURROUND;
|
||||
int src_rate = 48000, dst_rate = 44100;
|
||||
uint8_t **src_data = NULL, **dst_data = NULL;
|
||||
int src_nb_channels = 0, dst_nb_channels = 0;
|
||||
int src_linesize, dst_linesize;
|
||||
int src_nb_samples = 1024, dst_nb_samples, max_dst_nb_samples;
|
||||
enum AVSampleFormat src_sample_fmt = AV_SAMPLE_FMT_DBL, dst_sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
const char *dst_filename = NULL;
|
||||
FILE *dst_file;
|
||||
int dst_bufsize;
|
||||
const char *fmt;
|
||||
struct SwrContext *swr_ctx;
|
||||
double t;
|
||||
int ret;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: %s output_file\n"
|
||||
"API example program to show how to resample an audio stream with libswresample.\n"
|
||||
"This program generates a series of audio frames, resamples them to a specified "
|
||||
"output format and rate and saves them to an output file named output_file.\n",
|
||||
argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
dst_filename = argv[1];
|
||||
|
||||
dst_file = fopen(dst_filename, "wb");
|
||||
if (!dst_file) {
|
||||
fprintf(stderr, "Could not open destination file %s\n", dst_filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* create resampler context */
|
||||
swr_ctx = swr_alloc();
|
||||
if (!swr_ctx) {
|
||||
fprintf(stderr, "Could not allocate resampler context\n");
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* set options */
|
||||
av_opt_set_int(swr_ctx, "in_channel_layout", src_ch_layout, 0);
|
||||
av_opt_set_int(swr_ctx, "in_sample_rate", src_rate, 0);
|
||||
av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", src_sample_fmt, 0);
|
||||
|
||||
av_opt_set_int(swr_ctx, "out_channel_layout", dst_ch_layout, 0);
|
||||
av_opt_set_int(swr_ctx, "out_sample_rate", dst_rate, 0);
|
||||
av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", dst_sample_fmt, 0);
|
||||
|
||||
/* initialize the resampling context */
|
||||
if ((ret = swr_init(swr_ctx)) < 0) {
|
||||
fprintf(stderr, "Failed to initialize the resampling context\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* allocate source and destination samples buffers */
|
||||
|
||||
src_nb_channels = av_get_channel_layout_nb_channels(src_ch_layout);
|
||||
ret = av_samples_alloc_array_and_samples(&src_data, &src_linesize, src_nb_channels,
|
||||
src_nb_samples, src_sample_fmt, 0);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not allocate source samples\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* compute the number of converted samples: buffering is avoided
|
||||
* ensuring that the output buffer will contain at least all the
|
||||
* converted input samples */
|
||||
max_dst_nb_samples = dst_nb_samples =
|
||||
av_rescale_rnd(src_nb_samples, dst_rate, src_rate, AV_ROUND_UP);
|
||||
|
||||
/* buffer is going to be directly written to a rawaudio file, no alignment */
|
||||
dst_nb_channels = av_get_channel_layout_nb_channels(dst_ch_layout);
|
||||
ret = av_samples_alloc_array_and_samples(&dst_data, &dst_linesize, dst_nb_channels,
|
||||
dst_nb_samples, dst_sample_fmt, 0);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not allocate destination samples\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
t = 0;
|
||||
do {
|
||||
/* generate synthetic audio */
|
||||
fill_samples((double *)src_data[0], src_nb_samples, src_nb_channels, src_rate, &t);
|
||||
|
||||
/* compute destination number of samples */
|
||||
dst_nb_samples = av_rescale_rnd(swr_get_delay(swr_ctx, src_rate) +
|
||||
src_nb_samples, dst_rate, src_rate, AV_ROUND_UP);
|
||||
if (dst_nb_samples > max_dst_nb_samples) {
|
||||
av_freep(&dst_data[0]);
|
||||
ret = av_samples_alloc(dst_data, &dst_linesize, dst_nb_channels,
|
||||
dst_nb_samples, dst_sample_fmt, 1);
|
||||
if (ret < 0)
|
||||
break;
|
||||
max_dst_nb_samples = dst_nb_samples;
|
||||
}
|
||||
|
||||
/* convert to destination format */
|
||||
ret = swr_convert(swr_ctx, dst_data, dst_nb_samples, (const uint8_t **)src_data, src_nb_samples);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error while converting\n");
|
||||
goto end;
|
||||
}
|
||||
dst_bufsize = av_samples_get_buffer_size(&dst_linesize, dst_nb_channels,
|
||||
ret, dst_sample_fmt, 1);
|
||||
if (dst_bufsize < 0) {
|
||||
fprintf(stderr, "Could not get sample buffer size\n");
|
||||
goto end;
|
||||
}
|
||||
printf("t:%f in:%d out:%d\n", t, src_nb_samples, ret);
|
||||
fwrite(dst_data[0], 1, dst_bufsize, dst_file);
|
||||
} while (t < 10);
|
||||
|
||||
if ((ret = get_format_from_sample_fmt(&fmt, dst_sample_fmt)) < 0)
|
||||
goto end;
|
||||
fprintf(stderr, "Resampling succeeded. Play the output file with the command:\n"
|
||||
"ffplay -f %s -channel_layout %"PRId64" -channels %d -ar %d %s\n",
|
||||
fmt, dst_ch_layout, dst_nb_channels, dst_rate, dst_filename);
|
||||
|
||||
end:
|
||||
fclose(dst_file);
|
||||
|
||||
if (src_data)
|
||||
av_freep(&src_data[0]);
|
||||
av_freep(&src_data);
|
||||
|
||||
if (dst_data)
|
||||
av_freep(&dst_data[0]);
|
||||
av_freep(&dst_data);
|
||||
|
||||
swr_free(&swr_ctx);
|
||||
return ret < 0;
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Stefano Sabatini
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* libswscale API use example.
|
||||
* @example scaling_video.c
|
||||
*/
|
||||
|
||||
#include <libavutil/imgutils.h>
|
||||
#include <libavutil/parseutils.h>
|
||||
#include <libswscale/swscale.h>
|
||||
|
||||
static void fill_yuv_image(uint8_t *data[4], int linesize[4],
|
||||
int width, int height, int frame_index)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
/* Y */
|
||||
for (y = 0; y < height; y++)
|
||||
for (x = 0; x < width; x++)
|
||||
data[0][y * linesize[0] + x] = x + y + frame_index * 3;
|
||||
|
||||
/* Cb and Cr */
|
||||
for (y = 0; y < height / 2; y++) {
|
||||
for (x = 0; x < width / 2; x++) {
|
||||
data[1][y * linesize[1] + x] = 128 + y + frame_index * 2;
|
||||
data[2][y * linesize[2] + x] = 64 + x + frame_index * 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
uint8_t *src_data[4], *dst_data[4];
|
||||
int src_linesize[4], dst_linesize[4];
|
||||
int src_w = 320, src_h = 240, dst_w, dst_h;
|
||||
enum AVPixelFormat src_pix_fmt = AV_PIX_FMT_YUV420P, dst_pix_fmt = AV_PIX_FMT_RGB24;
|
||||
const char *dst_size = NULL;
|
||||
const char *dst_filename = NULL;
|
||||
FILE *dst_file;
|
||||
int dst_bufsize;
|
||||
struct SwsContext *sws_ctx;
|
||||
int i, ret;
|
||||
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "Usage: %s output_file output_size\n"
|
||||
"API example program to show how to scale an image with libswscale.\n"
|
||||
"This program generates a series of pictures, rescales them to the given "
|
||||
"output_size and saves them to an output file named output_file\n."
|
||||
"\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
dst_filename = argv[1];
|
||||
dst_size = argv[2];
|
||||
|
||||
if (av_parse_video_size(&dst_w, &dst_h, dst_size) < 0) {
|
||||
fprintf(stderr,
|
||||
"Invalid size '%s', must be in the form WxH or a valid size abbreviation\n",
|
||||
dst_size);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dst_file = fopen(dst_filename, "wb");
|
||||
if (!dst_file) {
|
||||
fprintf(stderr, "Could not open destination file %s\n", dst_filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* create scaling context */
|
||||
sws_ctx = sws_getContext(src_w, src_h, src_pix_fmt,
|
||||
dst_w, dst_h, dst_pix_fmt,
|
||||
SWS_BILINEAR, NULL, NULL, NULL);
|
||||
if (!sws_ctx) {
|
||||
fprintf(stderr,
|
||||
"Impossible to create scale context for the conversion "
|
||||
"fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n",
|
||||
av_get_pix_fmt_name(src_pix_fmt), src_w, src_h,
|
||||
av_get_pix_fmt_name(dst_pix_fmt), dst_w, dst_h);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* allocate source and destination image buffers */
|
||||
if ((ret = av_image_alloc(src_data, src_linesize,
|
||||
src_w, src_h, src_pix_fmt, 16)) < 0) {
|
||||
fprintf(stderr, "Could not allocate source image\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* buffer is going to be written to rawvideo file, no alignment */
|
||||
if ((ret = av_image_alloc(dst_data, dst_linesize,
|
||||
dst_w, dst_h, dst_pix_fmt, 1)) < 0) {
|
||||
fprintf(stderr, "Could not allocate destination image\n");
|
||||
goto end;
|
||||
}
|
||||
dst_bufsize = ret;
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
/* generate synthetic video */
|
||||
fill_yuv_image(src_data, src_linesize, src_w, src_h, i);
|
||||
|
||||
/* convert to destination format */
|
||||
sws_scale(sws_ctx, (const uint8_t * const*)src_data,
|
||||
src_linesize, 0, src_h, dst_data, dst_linesize);
|
||||
|
||||
/* write scaled image to file */
|
||||
fwrite(dst_data[0], 1, dst_bufsize, dst_file);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Scaling succeeded. Play the output file with the command:\n"
|
||||
"ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n",
|
||||
av_get_pix_fmt_name(dst_pix_fmt), dst_w, dst_h, dst_filename);
|
||||
|
||||
end:
|
||||
fclose(dst_file);
|
||||
av_freep(&src_data[0]);
|
||||
av_freep(&dst_data[0]);
|
||||
sws_freeContext(sws_ctx);
|
||||
return ret < 0;
|
||||
}
|
@ -1,802 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* simple audio converter
|
||||
*
|
||||
* @example transcode_aac.c
|
||||
* Convert an input audio file to AAC in an MP4 container using FFmpeg.
|
||||
* @author Andreas Unterweger (dustsigns@gmail.com)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavformat/avio.h"
|
||||
|
||||
#include "libavcodec/avcodec.h"
|
||||
|
||||
#include "libavutil/audio_fifo.h"
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/avstring.h"
|
||||
#include "libavutil/frame.h"
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
#include "libswresample/swresample.h"
|
||||
|
||||
/** The output bit rate in kbit/s */
|
||||
#define OUTPUT_BIT_RATE 96000
|
||||
/** The number of output channels */
|
||||
#define OUTPUT_CHANNELS 2
|
||||
|
||||
/**
|
||||
* Convert an error code into a text message.
|
||||
* @param error Error code to be converted
|
||||
* @return Corresponding error text (not thread-safe)
|
||||
*/
|
||||
static const char *get_error_text(const int error)
|
||||
{
|
||||
static char error_buffer[255];
|
||||
av_strerror(error, error_buffer, sizeof(error_buffer));
|
||||
return error_buffer;
|
||||
}
|
||||
|
||||
/** Open an input file and the required decoder. */
|
||||
static int open_input_file(const char *filename,
|
||||
AVFormatContext **input_format_context,
|
||||
AVCodecContext **input_codec_context)
|
||||
{
|
||||
AVCodecContext *avctx;
|
||||
AVCodec *input_codec;
|
||||
int error;
|
||||
|
||||
/** Open the input file to read from it. */
|
||||
if ((error = avformat_open_input(input_format_context, filename, NULL,
|
||||
NULL)) < 0) {
|
||||
fprintf(stderr, "Could not open input file '%s' (error '%s')\n",
|
||||
filename, get_error_text(error));
|
||||
*input_format_context = NULL;
|
||||
return error;
|
||||
}
|
||||
|
||||
/** Get information on the input file (number of streams etc.). */
|
||||
if ((error = avformat_find_stream_info(*input_format_context, NULL)) < 0) {
|
||||
fprintf(stderr, "Could not open find stream info (error '%s')\n",
|
||||
get_error_text(error));
|
||||
avformat_close_input(input_format_context);
|
||||
return error;
|
||||
}
|
||||
|
||||
/** Make sure that there is only one stream in the input file. */
|
||||
if ((*input_format_context)->nb_streams != 1) {
|
||||
fprintf(stderr, "Expected one audio input stream, but found %d\n",
|
||||
(*input_format_context)->nb_streams);
|
||||
avformat_close_input(input_format_context);
|
||||
return AVERROR_EXIT;
|
||||
}
|
||||
|
||||
/** Find a decoder for the audio stream. */
|
||||
if (!(input_codec = avcodec_find_decoder((*input_format_context)->streams[0]->codecpar->codec_id))) {
|
||||
fprintf(stderr, "Could not find input codec\n");
|
||||
avformat_close_input(input_format_context);
|
||||
return AVERROR_EXIT;
|
||||
}
|
||||
|
||||
/** allocate a new decoding context */
|
||||
avctx = avcodec_alloc_context3(input_codec);
|
||||
if (!avctx) {
|
||||
fprintf(stderr, "Could not allocate a decoding context\n");
|
||||
avformat_close_input(input_format_context);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/** initialize the stream parameters with demuxer information */
|
||||
error = avcodec_parameters_to_context(avctx, (*input_format_context)->streams[0]->codecpar);
|
||||
if (error < 0) {
|
||||
avformat_close_input(input_format_context);
|
||||
avcodec_free_context(&avctx);
|
||||
return error;
|
||||
}
|
||||
|
||||
/** Open the decoder for the audio stream to use it later. */
|
||||
if ((error = avcodec_open2(avctx, input_codec, NULL)) < 0) {
|
||||
fprintf(stderr, "Could not open input codec (error '%s')\n",
|
||||
get_error_text(error));
|
||||
avcodec_free_context(&avctx);
|
||||
avformat_close_input(input_format_context);
|
||||
return error;
|
||||
}
|
||||
|
||||
/** Save the decoder context for easier access later. */
|
||||
*input_codec_context = avctx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open an output file and the required encoder.
|
||||
* Also set some basic encoder parameters.
|
||||
* Some of these parameters are based on the input file's parameters.
|
||||
*/
|
||||
static int open_output_file(const char *filename,
|
||||
AVCodecContext *input_codec_context,
|
||||
AVFormatContext **output_format_context,
|
||||
AVCodecContext **output_codec_context)
|
||||
{
|
||||
AVCodecContext *avctx = NULL;
|
||||
AVIOContext *output_io_context = NULL;
|
||||
AVStream *stream = NULL;
|
||||
AVCodec *output_codec = NULL;
|
||||
int error;
|
||||
|
||||
/** Open the output file to write to it. */
|
||||
if ((error = avio_open(&output_io_context, filename,
|
||||
AVIO_FLAG_WRITE)) < 0) {
|
||||
fprintf(stderr, "Could not open output file '%s' (error '%s')\n",
|
||||
filename, get_error_text(error));
|
||||
return error;
|
||||
}
|
||||
|
||||
/** Create a new format context for the output container format. */
|
||||
if (!(*output_format_context = avformat_alloc_context())) {
|
||||
fprintf(stderr, "Could not allocate output format context\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/** Associate the output file (pointer) with the container format context. */
|
||||
(*output_format_context)->pb = output_io_context;
|
||||
|
||||
/** Guess the desired container format based on the file extension. */
|
||||
if (!((*output_format_context)->oformat = av_guess_format(NULL, filename,
|
||||
NULL))) {
|
||||
fprintf(stderr, "Could not find output file format\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
av_strlcpy((*output_format_context)->filename, filename,
|
||||
sizeof((*output_format_context)->filename));
|
||||
|
||||
/** Find the encoder to be used by its name. */
|
||||
if (!(output_codec = avcodec_find_encoder(AV_CODEC_ID_AAC))) {
|
||||
fprintf(stderr, "Could not find an AAC encoder.\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/** Create a new audio stream in the output file container. */
|
||||
if (!(stream = avformat_new_stream(*output_format_context, NULL))) {
|
||||
fprintf(stderr, "Could not create new stream\n");
|
||||
error = AVERROR(ENOMEM);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
avctx = avcodec_alloc_context3(output_codec);
|
||||
if (!avctx) {
|
||||
fprintf(stderr, "Could not allocate an encoding context\n");
|
||||
error = AVERROR(ENOMEM);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the basic encoder parameters.
|
||||
* The input file's sample rate is used to avoid a sample rate conversion.
|
||||
*/
|
||||
avctx->channels = OUTPUT_CHANNELS;
|
||||
avctx->channel_layout = av_get_default_channel_layout(OUTPUT_CHANNELS);
|
||||
avctx->sample_rate = input_codec_context->sample_rate;
|
||||
avctx->sample_fmt = output_codec->sample_fmts[0];
|
||||
avctx->bit_rate = OUTPUT_BIT_RATE;
|
||||
|
||||
/** Allow the use of the experimental AAC encoder */
|
||||
avctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
|
||||
|
||||
/** Set the sample rate for the container. */
|
||||
stream->time_base.den = input_codec_context->sample_rate;
|
||||
stream->time_base.num = 1;
|
||||
|
||||
/**
|
||||
* Some container formats (like MP4) require global headers to be present
|
||||
* Mark the encoder so that it behaves accordingly.
|
||||
*/
|
||||
if ((*output_format_context)->oformat->flags & AVFMT_GLOBALHEADER)
|
||||
avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
|
||||
/** Open the encoder for the audio stream to use it later. */
|
||||
if ((error = avcodec_open2(avctx, output_codec, NULL)) < 0) {
|
||||
fprintf(stderr, "Could not open output codec (error '%s')\n",
|
||||
get_error_text(error));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
error = avcodec_parameters_from_context(stream->codecpar, avctx);
|
||||
if (error < 0) {
|
||||
fprintf(stderr, "Could not initialize stream parameters\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/** Save the encoder context for easier access later. */
|
||||
*output_codec_context = avctx;
|
||||
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
avcodec_free_context(&avctx);
|
||||
avio_closep(&(*output_format_context)->pb);
|
||||
avformat_free_context(*output_format_context);
|
||||
*output_format_context = NULL;
|
||||
return error < 0 ? error : AVERROR_EXIT;
|
||||
}
|
||||
|
||||
/** Initialize one data packet for reading or writing. */
|
||||
static void init_packet(AVPacket *packet)
|
||||
{
|
||||
av_init_packet(packet);
|
||||
/** Set the packet data and size so that it is recognized as being empty. */
|
||||
packet->data = NULL;
|
||||
packet->size = 0;
|
||||
}
|
||||
|
||||
/** Initialize one audio frame for reading from the input file */
|
||||
static int init_input_frame(AVFrame **frame)
|
||||
{
|
||||
if (!(*frame = av_frame_alloc())) {
|
||||
fprintf(stderr, "Could not allocate input frame\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the audio resampler based on the input and output codec settings.
|
||||
* If the input and output sample formats differ, a conversion is required
|
||||
* libswresample takes care of this, but requires initialization.
|
||||
*/
|
||||
static int init_resampler(AVCodecContext *input_codec_context,
|
||||
AVCodecContext *output_codec_context,
|
||||
SwrContext **resample_context)
|
||||
{
|
||||
int error;
|
||||
|
||||
/**
|
||||
* Create a resampler context for the conversion.
|
||||
* Set the conversion parameters.
|
||||
* Default channel layouts based on the number of channels
|
||||
* are assumed for simplicity (they are sometimes not detected
|
||||
* properly by the demuxer and/or decoder).
|
||||
*/
|
||||
*resample_context = swr_alloc_set_opts(NULL,
|
||||
av_get_default_channel_layout(output_codec_context->channels),
|
||||
output_codec_context->sample_fmt,
|
||||
output_codec_context->sample_rate,
|
||||
av_get_default_channel_layout(input_codec_context->channels),
|
||||
input_codec_context->sample_fmt,
|
||||
input_codec_context->sample_rate,
|
||||
0, NULL);
|
||||
if (!*resample_context) {
|
||||
fprintf(stderr, "Could not allocate resample context\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
/**
|
||||
* Perform a sanity check so that the number of converted samples is
|
||||
* not greater than the number of samples to be converted.
|
||||
* If the sample rates differ, this case has to be handled differently
|
||||
*/
|
||||
av_assert0(output_codec_context->sample_rate == input_codec_context->sample_rate);
|
||||
|
||||
/** Open the resampler with the specified parameters. */
|
||||
if ((error = swr_init(*resample_context)) < 0) {
|
||||
fprintf(stderr, "Could not open resample context\n");
|
||||
swr_free(resample_context);
|
||||
return error;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Initialize a FIFO buffer for the audio samples to be encoded. */
|
||||
static int init_fifo(AVAudioFifo **fifo, AVCodecContext *output_codec_context)
|
||||
{
|
||||
/** Create the FIFO buffer based on the specified output sample format. */
|
||||
if (!(*fifo = av_audio_fifo_alloc(output_codec_context->sample_fmt,
|
||||
output_codec_context->channels, 1))) {
|
||||
fprintf(stderr, "Could not allocate FIFO\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Write the header of the output file container. */
|
||||
static int write_output_file_header(AVFormatContext *output_format_context)
|
||||
{
|
||||
int error;
|
||||
if ((error = avformat_write_header(output_format_context, NULL)) < 0) {
|
||||
fprintf(stderr, "Could not write output file header (error '%s')\n",
|
||||
get_error_text(error));
|
||||
return error;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Decode one audio frame from the input file. */
|
||||
static int decode_audio_frame(AVFrame *frame,
|
||||
AVFormatContext *input_format_context,
|
||||
AVCodecContext *input_codec_context,
|
||||
int *data_present, int *finished)
|
||||
{
|
||||
/** Packet used for temporary storage. */
|
||||
AVPacket input_packet;
|
||||
int error;
|
||||
init_packet(&input_packet);
|
||||
|
||||
/** Read one audio frame from the input file into a temporary packet. */
|
||||
if ((error = av_read_frame(input_format_context, &input_packet)) < 0) {
|
||||
/** If we are at the end of the file, flush the decoder below. */
|
||||
if (error == AVERROR_EOF)
|
||||
*finished = 1;
|
||||
else {
|
||||
fprintf(stderr, "Could not read frame (error '%s')\n",
|
||||
get_error_text(error));
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode the audio frame stored in the temporary packet.
|
||||
* The input audio stream decoder is used to do this.
|
||||
* If we are at the end of the file, pass an empty packet to the decoder
|
||||
* to flush it.
|
||||
*/
|
||||
if ((error = avcodec_decode_audio4(input_codec_context, frame,
|
||||
data_present, &input_packet)) < 0) {
|
||||
fprintf(stderr, "Could not decode frame (error '%s')\n",
|
||||
get_error_text(error));
|
||||
av_packet_unref(&input_packet);
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the decoder has not been flushed completely, we are not finished,
|
||||
* so that this function has to be called again.
|
||||
*/
|
||||
if (*finished && *data_present)
|
||||
*finished = 0;
|
||||
av_packet_unref(&input_packet);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a temporary storage for the specified number of audio samples.
|
||||
* The conversion requires temporary storage due to the different format.
|
||||
* The number of audio samples to be allocated is specified in frame_size.
|
||||
*/
|
||||
static int init_converted_samples(uint8_t ***converted_input_samples,
|
||||
AVCodecContext *output_codec_context,
|
||||
int frame_size)
|
||||
{
|
||||
int error;
|
||||
|
||||
/**
|
||||
* Allocate as many pointers as there are audio channels.
|
||||
* Each pointer will later point to the audio samples of the corresponding
|
||||
* channels (although it may be NULL for interleaved formats).
|
||||
*/
|
||||
if (!(*converted_input_samples = calloc(output_codec_context->channels,
|
||||
sizeof(**converted_input_samples)))) {
|
||||
fprintf(stderr, "Could not allocate converted input sample pointers\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate memory for the samples of all channels in one consecutive
|
||||
* block for convenience.
|
||||
*/
|
||||
if ((error = av_samples_alloc(*converted_input_samples, NULL,
|
||||
output_codec_context->channels,
|
||||
frame_size,
|
||||
output_codec_context->sample_fmt, 0)) < 0) {
|
||||
fprintf(stderr,
|
||||
"Could not allocate converted input samples (error '%s')\n",
|
||||
get_error_text(error));
|
||||
av_freep(&(*converted_input_samples)[0]);
|
||||
free(*converted_input_samples);
|
||||
return error;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the input audio samples into the output sample format.
|
||||
* The conversion happens on a per-frame basis, the size of which is specified
|
||||
* by frame_size.
|
||||
*/
|
||||
static int convert_samples(const uint8_t **input_data,
|
||||
uint8_t **converted_data, const int frame_size,
|
||||
SwrContext *resample_context)
|
||||
{
|
||||
int error;
|
||||
|
||||
/** Convert the samples using the resampler. */
|
||||
if ((error = swr_convert(resample_context,
|
||||
converted_data, frame_size,
|
||||
input_data , frame_size)) < 0) {
|
||||
fprintf(stderr, "Could not convert input samples (error '%s')\n",
|
||||
get_error_text(error));
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Add converted input audio samples to the FIFO buffer for later processing. */
|
||||
static int add_samples_to_fifo(AVAudioFifo *fifo,
|
||||
uint8_t **converted_input_samples,
|
||||
const int frame_size)
|
||||
{
|
||||
int error;
|
||||
|
||||
/**
|
||||
* Make the FIFO as large as it needs to be to hold both,
|
||||
* the old and the new samples.
|
||||
*/
|
||||
if ((error = av_audio_fifo_realloc(fifo, av_audio_fifo_size(fifo) + frame_size)) < 0) {
|
||||
fprintf(stderr, "Could not reallocate FIFO\n");
|
||||
return error;
|
||||
}
|
||||
|
||||
/** Store the new samples in the FIFO buffer. */
|
||||
if (av_audio_fifo_write(fifo, (void **)converted_input_samples,
|
||||
frame_size) < frame_size) {
|
||||
fprintf(stderr, "Could not write data to FIFO\n");
|
||||
return AVERROR_EXIT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read one audio frame from the input file, decodes, converts and stores
|
||||
* it in the FIFO buffer.
|
||||
*/
|
||||
static int read_decode_convert_and_store(AVAudioFifo *fifo,
|
||||
AVFormatContext *input_format_context,
|
||||
AVCodecContext *input_codec_context,
|
||||
AVCodecContext *output_codec_context,
|
||||
SwrContext *resampler_context,
|
||||
int *finished)
|
||||
{
|
||||
/** Temporary storage of the input samples of the frame read from the file. */
|
||||
AVFrame *input_frame = NULL;
|
||||
/** Temporary storage for the converted input samples. */
|
||||
uint8_t **converted_input_samples = NULL;
|
||||
int data_present;
|
||||
int ret = AVERROR_EXIT;
|
||||
|
||||
/** Initialize temporary storage for one input frame. */
|
||||
if (init_input_frame(&input_frame))
|
||||
goto cleanup;
|
||||
/** Decode one frame worth of audio samples. */
|
||||
if (decode_audio_frame(input_frame, input_format_context,
|
||||
input_codec_context, &data_present, finished))
|
||||
goto cleanup;
|
||||
/**
|
||||
* If we are at the end of the file and there are no more samples
|
||||
* in the decoder which are delayed, we are actually finished.
|
||||
* This must not be treated as an error.
|
||||
*/
|
||||
if (*finished && !data_present) {
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
/** If there is decoded data, convert and store it */
|
||||
if (data_present) {
|
||||
/** Initialize the temporary storage for the converted input samples. */
|
||||
if (init_converted_samples(&converted_input_samples, output_codec_context,
|
||||
input_frame->nb_samples))
|
||||
goto cleanup;
|
||||
|
||||
/**
|
||||
* Convert the input samples to the desired output sample format.
|
||||
* This requires a temporary storage provided by converted_input_samples.
|
||||
*/
|
||||
if (convert_samples((const uint8_t**)input_frame->extended_data, converted_input_samples,
|
||||
input_frame->nb_samples, resampler_context))
|
||||
goto cleanup;
|
||||
|
||||
/** Add the converted input samples to the FIFO buffer for later processing. */
|
||||
if (add_samples_to_fifo(fifo, converted_input_samples,
|
||||
input_frame->nb_samples))
|
||||
goto cleanup;
|
||||
ret = 0;
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (converted_input_samples) {
|
||||
av_freep(&converted_input_samples[0]);
|
||||
free(converted_input_samples);
|
||||
}
|
||||
av_frame_free(&input_frame);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize one input frame for writing to the output file.
|
||||
* The frame will be exactly frame_size samples large.
|
||||
*/
|
||||
static int init_output_frame(AVFrame **frame,
|
||||
AVCodecContext *output_codec_context,
|
||||
int frame_size)
|
||||
{
|
||||
int error;
|
||||
|
||||
/** Create a new frame to store the audio samples. */
|
||||
if (!(*frame = av_frame_alloc())) {
|
||||
fprintf(stderr, "Could not allocate output frame\n");
|
||||
return AVERROR_EXIT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the frame's parameters, especially its size and format.
|
||||
* av_frame_get_buffer needs this to allocate memory for the
|
||||
* audio samples of the frame.
|
||||
* Default channel layouts based on the number of channels
|
||||
* are assumed for simplicity.
|
||||
*/
|
||||
(*frame)->nb_samples = frame_size;
|
||||
(*frame)->channel_layout = output_codec_context->channel_layout;
|
||||
(*frame)->format = output_codec_context->sample_fmt;
|
||||
(*frame)->sample_rate = output_codec_context->sample_rate;
|
||||
|
||||
/**
|
||||
* Allocate the samples of the created frame. This call will make
|
||||
* sure that the audio frame can hold as many samples as specified.
|
||||
*/
|
||||
if ((error = av_frame_get_buffer(*frame, 0)) < 0) {
|
||||
fprintf(stderr, "Could allocate output frame samples (error '%s')\n",
|
||||
get_error_text(error));
|
||||
av_frame_free(frame);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Global timestamp for the audio frames */
|
||||
static int64_t pts = 0;
|
||||
|
||||
/** Encode one frame worth of audio to the output file. */
|
||||
static int encode_audio_frame(AVFrame *frame,
|
||||
AVFormatContext *output_format_context,
|
||||
AVCodecContext *output_codec_context,
|
||||
int *data_present)
|
||||
{
|
||||
/** Packet used for temporary storage. */
|
||||
AVPacket output_packet;
|
||||
int error;
|
||||
init_packet(&output_packet);
|
||||
|
||||
/** Set a timestamp based on the sample rate for the container. */
|
||||
if (frame) {
|
||||
frame->pts = pts;
|
||||
pts += frame->nb_samples;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the audio frame and store it in the temporary packet.
|
||||
* The output audio stream encoder is used to do this.
|
||||
*/
|
||||
if ((error = avcodec_encode_audio2(output_codec_context, &output_packet,
|
||||
frame, data_present)) < 0) {
|
||||
fprintf(stderr, "Could not encode frame (error '%s')\n",
|
||||
get_error_text(error));
|
||||
av_packet_unref(&output_packet);
|
||||
return error;
|
||||
}
|
||||
|
||||
/** Write one audio frame from the temporary packet to the output file. */
|
||||
if (*data_present) {
|
||||
if ((error = av_write_frame(output_format_context, &output_packet)) < 0) {
|
||||
fprintf(stderr, "Could not write frame (error '%s')\n",
|
||||
get_error_text(error));
|
||||
av_packet_unref(&output_packet);
|
||||
return error;
|
||||
}
|
||||
|
||||
av_packet_unref(&output_packet);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load one audio frame from the FIFO buffer, encode and write it to the
|
||||
* output file.
|
||||
*/
|
||||
static int load_encode_and_write(AVAudioFifo *fifo,
|
||||
AVFormatContext *output_format_context,
|
||||
AVCodecContext *output_codec_context)
|
||||
{
|
||||
/** Temporary storage of the output samples of the frame written to the file. */
|
||||
AVFrame *output_frame;
|
||||
/**
|
||||
* Use the maximum number of possible samples per frame.
|
||||
* If there is less than the maximum possible frame size in the FIFO
|
||||
* buffer use this number. Otherwise, use the maximum possible frame size
|
||||
*/
|
||||
const int frame_size = FFMIN(av_audio_fifo_size(fifo),
|
||||
output_codec_context->frame_size);
|
||||
int data_written;
|
||||
|
||||
/** Initialize temporary storage for one output frame. */
|
||||
if (init_output_frame(&output_frame, output_codec_context, frame_size))
|
||||
return AVERROR_EXIT;
|
||||
|
||||
/**
|
||||
* Read as many samples from the FIFO buffer as required to fill the frame.
|
||||
* The samples are stored in the frame temporarily.
|
||||
*/
|
||||
if (av_audio_fifo_read(fifo, (void **)output_frame->data, frame_size) < frame_size) {
|
||||
fprintf(stderr, "Could not read data from FIFO\n");
|
||||
av_frame_free(&output_frame);
|
||||
return AVERROR_EXIT;
|
||||
}
|
||||
|
||||
/** Encode one frame worth of audio samples. */
|
||||
if (encode_audio_frame(output_frame, output_format_context,
|
||||
output_codec_context, &data_written)) {
|
||||
av_frame_free(&output_frame);
|
||||
return AVERROR_EXIT;
|
||||
}
|
||||
av_frame_free(&output_frame);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Write the trailer of the output file container. */
|
||||
static int write_output_file_trailer(AVFormatContext *output_format_context)
|
||||
{
|
||||
int error;
|
||||
if ((error = av_write_trailer(output_format_context)) < 0) {
|
||||
fprintf(stderr, "Could not write output file trailer (error '%s')\n",
|
||||
get_error_text(error));
|
||||
return error;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Convert an audio file to an AAC file in an MP4 container. */
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
AVFormatContext *input_format_context = NULL, *output_format_context = NULL;
|
||||
AVCodecContext *input_codec_context = NULL, *output_codec_context = NULL;
|
||||
SwrContext *resample_context = NULL;
|
||||
AVAudioFifo *fifo = NULL;
|
||||
int ret = AVERROR_EXIT;
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/** Register all codecs and formats so that they can be used. */
|
||||
av_register_all();
|
||||
/** Open the input file for reading. */
|
||||
if (open_input_file(argv[1], &input_format_context,
|
||||
&input_codec_context))
|
||||
goto cleanup;
|
||||
/** Open the output file for writing. */
|
||||
if (open_output_file(argv[2], input_codec_context,
|
||||
&output_format_context, &output_codec_context))
|
||||
goto cleanup;
|
||||
/** Initialize the resampler to be able to convert audio sample formats. */
|
||||
if (init_resampler(input_codec_context, output_codec_context,
|
||||
&resample_context))
|
||||
goto cleanup;
|
||||
/** Initialize the FIFO buffer to store audio samples to be encoded. */
|
||||
if (init_fifo(&fifo, output_codec_context))
|
||||
goto cleanup;
|
||||
/** Write the header of the output file container. */
|
||||
if (write_output_file_header(output_format_context))
|
||||
goto cleanup;
|
||||
|
||||
/**
|
||||
* Loop as long as we have input samples to read or output samples
|
||||
* to write; abort as soon as we have neither.
|
||||
*/
|
||||
while (1) {
|
||||
/** Use the encoder's desired frame size for processing. */
|
||||
const int output_frame_size = output_codec_context->frame_size;
|
||||
int finished = 0;
|
||||
|
||||
/**
|
||||
* Make sure that there is one frame worth of samples in the FIFO
|
||||
* buffer so that the encoder can do its work.
|
||||
* Since the decoder's and the encoder's frame size may differ, we
|
||||
* need to FIFO buffer to store as many frames worth of input samples
|
||||
* that they make up at least one frame worth of output samples.
|
||||
*/
|
||||
while (av_audio_fifo_size(fifo) < output_frame_size) {
|
||||
/**
|
||||
* Decode one frame worth of audio samples, convert it to the
|
||||
* output sample format and put it into the FIFO buffer.
|
||||
*/
|
||||
if (read_decode_convert_and_store(fifo, input_format_context,
|
||||
input_codec_context,
|
||||
output_codec_context,
|
||||
resample_context, &finished))
|
||||
goto cleanup;
|
||||
|
||||
/**
|
||||
* If we are at the end of the input file, we continue
|
||||
* encoding the remaining audio samples to the output file.
|
||||
*/
|
||||
if (finished)
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* If we have enough samples for the encoder, we encode them.
|
||||
* At the end of the file, we pass the remaining samples to
|
||||
* the encoder.
|
||||
*/
|
||||
while (av_audio_fifo_size(fifo) >= output_frame_size ||
|
||||
(finished && av_audio_fifo_size(fifo) > 0))
|
||||
/**
|
||||
* Take one frame worth of audio samples from the FIFO buffer,
|
||||
* encode it and write it to the output file.
|
||||
*/
|
||||
if (load_encode_and_write(fifo, output_format_context,
|
||||
output_codec_context))
|
||||
goto cleanup;
|
||||
|
||||
/**
|
||||
* If we are at the end of the input file and have encoded
|
||||
* all remaining samples, we can exit this loop and finish.
|
||||
*/
|
||||
if (finished) {
|
||||
int data_written;
|
||||
/** Flush the encoder as it may have delayed frames. */
|
||||
do {
|
||||
if (encode_audio_frame(NULL, output_format_context,
|
||||
output_codec_context, &data_written))
|
||||
goto cleanup;
|
||||
} while (data_written);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Write the trailer of the output file container. */
|
||||
if (write_output_file_trailer(output_format_context))
|
||||
goto cleanup;
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (fifo)
|
||||
av_audio_fifo_free(fifo);
|
||||
swr_free(&resample_context);
|
||||
if (output_codec_context)
|
||||
avcodec_free_context(&output_codec_context);
|
||||
if (output_format_context) {
|
||||
avio_closep(&output_format_context->pb);
|
||||
avformat_free_context(output_format_context);
|
||||
}
|
||||
if (input_codec_context)
|
||||
avcodec_free_context(&input_codec_context);
|
||||
if (input_format_context)
|
||||
avformat_close_input(&input_format_context);
|
||||
|
||||
return ret;
|
||||
}
|
@ -1,585 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Nicolas George
|
||||
* Copyright (c) 2011 Stefano Sabatini
|
||||
* Copyright (c) 2014 Andrey Utkin
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* API example for demuxing, decoding, filtering, encoding and muxing
|
||||
* @example transcoding.c
|
||||
*/
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavfilter/avfiltergraph.h>
|
||||
#include <libavfilter/buffersink.h>
|
||||
#include <libavfilter/buffersrc.h>
|
||||
#include <libavutil/opt.h>
|
||||
#include <libavutil/pixdesc.h>
|
||||
|
||||
static AVFormatContext *ifmt_ctx;
|
||||
static AVFormatContext *ofmt_ctx;
|
||||
typedef struct FilteringContext {
|
||||
AVFilterContext *buffersink_ctx;
|
||||
AVFilterContext *buffersrc_ctx;
|
||||
AVFilterGraph *filter_graph;
|
||||
} FilteringContext;
|
||||
static FilteringContext *filter_ctx;
|
||||
|
||||
static int open_input_file(const char *filename)
|
||||
{
|
||||
int ret;
|
||||
unsigned int i;
|
||||
|
||||
ifmt_ctx = NULL;
|
||||
if ((ret = avformat_open_input(&ifmt_ctx, filename, NULL, NULL)) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = avformat_find_stream_info(ifmt_ctx, NULL)) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
||||
AVStream *stream;
|
||||
AVCodecContext *codec_ctx;
|
||||
stream = ifmt_ctx->streams[i];
|
||||
codec_ctx = stream->codec;
|
||||
/* Reencode video & audio and remux subtitles etc. */
|
||||
if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
|
||||
|| codec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
/* Open decoder */
|
||||
ret = avcodec_open2(codec_ctx,
|
||||
avcodec_find_decoder(codec_ctx->codec_id), NULL);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to open decoder for stream #%u\n", i);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
av_dump_format(ifmt_ctx, 0, filename, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int open_output_file(const char *filename)
|
||||
{
|
||||
AVStream *out_stream;
|
||||
AVStream *in_stream;
|
||||
AVCodecContext *dec_ctx, *enc_ctx;
|
||||
AVCodec *encoder;
|
||||
int ret;
|
||||
unsigned int i;
|
||||
|
||||
ofmt_ctx = NULL;
|
||||
avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, filename);
|
||||
if (!ofmt_ctx) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Could not create output context\n");
|
||||
return AVERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
||||
out_stream = avformat_new_stream(ofmt_ctx, NULL);
|
||||
if (!out_stream) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed allocating output stream\n");
|
||||
return AVERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
in_stream = ifmt_ctx->streams[i];
|
||||
dec_ctx = in_stream->codec;
|
||||
enc_ctx = out_stream->codec;
|
||||
|
||||
if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
|
||||
|| dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
/* in this example, we choose transcoding to same codec */
|
||||
encoder = avcodec_find_encoder(dec_ctx->codec_id);
|
||||
if (!encoder) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* In this example, we transcode to same properties (picture size,
|
||||
* sample rate etc.). These properties can be changed for output
|
||||
* streams easily using filters */
|
||||
if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
enc_ctx->height = dec_ctx->height;
|
||||
enc_ctx->width = dec_ctx->width;
|
||||
enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
|
||||
/* take first format from list of supported formats */
|
||||
if (encoder->pix_fmts)
|
||||
enc_ctx->pix_fmt = encoder->pix_fmts[0];
|
||||
else
|
||||
enc_ctx->pix_fmt = dec_ctx->pix_fmt;
|
||||
/* video time_base can be set to whatever is handy and supported by encoder */
|
||||
enc_ctx->time_base = dec_ctx->time_base;
|
||||
} else {
|
||||
enc_ctx->sample_rate = dec_ctx->sample_rate;
|
||||
enc_ctx->channel_layout = dec_ctx->channel_layout;
|
||||
enc_ctx->channels = av_get_channel_layout_nb_channels(enc_ctx->channel_layout);
|
||||
/* take first format from list of supported formats */
|
||||
enc_ctx->sample_fmt = encoder->sample_fmts[0];
|
||||
enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate};
|
||||
}
|
||||
|
||||
/* Third parameter can be used to pass settings to encoder */
|
||||
ret = avcodec_open2(enc_ctx, encoder, NULL);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot open video encoder for stream #%u\n", i);
|
||||
return ret;
|
||||
}
|
||||
} else if (dec_ctx->codec_type == AVMEDIA_TYPE_UNKNOWN) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Elementary stream #%d is of unknown type, cannot proceed\n", i);
|
||||
return AVERROR_INVALIDDATA;
|
||||
} else {
|
||||
/* if this stream must be remuxed */
|
||||
ret = avcodec_copy_context(ofmt_ctx->streams[i]->codec,
|
||||
ifmt_ctx->streams[i]->codec);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Copying stream context failed\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
|
||||
enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
|
||||
}
|
||||
av_dump_format(ofmt_ctx, 0, filename, 1);
|
||||
|
||||
if (!(ofmt_ctx->oformat->flags & AVFMT_NOFILE)) {
|
||||
ret = avio_open(&ofmt_ctx->pb, filename, AVIO_FLAG_WRITE);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Could not open output file '%s'", filename);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* init muxer, write output file header */
|
||||
ret = avformat_write_header(ofmt_ctx, NULL);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error occurred when opening output file\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
|
||||
AVCodecContext *enc_ctx, const char *filter_spec)
|
||||
{
|
||||
char args[512];
|
||||
int ret = 0;
|
||||
AVFilter *buffersrc = NULL;
|
||||
AVFilter *buffersink = NULL;
|
||||
AVFilterContext *buffersrc_ctx = NULL;
|
||||
AVFilterContext *buffersink_ctx = NULL;
|
||||
AVFilterInOut *outputs = avfilter_inout_alloc();
|
||||
AVFilterInOut *inputs = avfilter_inout_alloc();
|
||||
AVFilterGraph *filter_graph = avfilter_graph_alloc();
|
||||
|
||||
if (!outputs || !inputs || !filter_graph) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
buffersrc = avfilter_get_by_name("buffer");
|
||||
buffersink = avfilter_get_by_name("buffersink");
|
||||
if (!buffersrc || !buffersink) {
|
||||
av_log(NULL, AV_LOG_ERROR, "filtering source or sink element not found\n");
|
||||
ret = AVERROR_UNKNOWN;
|
||||
goto end;
|
||||
}
|
||||
|
||||
snprintf(args, sizeof(args),
|
||||
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
|
||||
dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt,
|
||||
dec_ctx->time_base.num, dec_ctx->time_base.den,
|
||||
dec_ctx->sample_aspect_ratio.num,
|
||||
dec_ctx->sample_aspect_ratio.den);
|
||||
|
||||
ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in",
|
||||
args, NULL, filter_graph);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer source\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out",
|
||||
NULL, NULL, filter_graph);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer sink\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = av_opt_set_bin(buffersink_ctx, "pix_fmts",
|
||||
(uint8_t*)&enc_ctx->pix_fmt, sizeof(enc_ctx->pix_fmt),
|
||||
AV_OPT_SEARCH_CHILDREN);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output pixel format\n");
|
||||
goto end;
|
||||
}
|
||||
} else if (dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
buffersrc = avfilter_get_by_name("abuffer");
|
||||
buffersink = avfilter_get_by_name("abuffersink");
|
||||
if (!buffersrc || !buffersink) {
|
||||
av_log(NULL, AV_LOG_ERROR, "filtering source or sink element not found\n");
|
||||
ret = AVERROR_UNKNOWN;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!dec_ctx->channel_layout)
|
||||
dec_ctx->channel_layout =
|
||||
av_get_default_channel_layout(dec_ctx->channels);
|
||||
snprintf(args, sizeof(args),
|
||||
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%"PRIx64,
|
||||
dec_ctx->time_base.num, dec_ctx->time_base.den, dec_ctx->sample_rate,
|
||||
av_get_sample_fmt_name(dec_ctx->sample_fmt),
|
||||
dec_ctx->channel_layout);
|
||||
ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in",
|
||||
args, NULL, filter_graph);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer source\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out",
|
||||
NULL, NULL, filter_graph);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer sink\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = av_opt_set_bin(buffersink_ctx, "sample_fmts",
|
||||
(uint8_t*)&enc_ctx->sample_fmt, sizeof(enc_ctx->sample_fmt),
|
||||
AV_OPT_SEARCH_CHILDREN);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output sample format\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = av_opt_set_bin(buffersink_ctx, "channel_layouts",
|
||||
(uint8_t*)&enc_ctx->channel_layout,
|
||||
sizeof(enc_ctx->channel_layout), AV_OPT_SEARCH_CHILDREN);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = av_opt_set_bin(buffersink_ctx, "sample_rates",
|
||||
(uint8_t*)&enc_ctx->sample_rate, sizeof(enc_ctx->sample_rate),
|
||||
AV_OPT_SEARCH_CHILDREN);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output sample rate\n");
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
ret = AVERROR_UNKNOWN;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Endpoints for the filter graph. */
|
||||
outputs->name = av_strdup("in");
|
||||
outputs->filter_ctx = buffersrc_ctx;
|
||||
outputs->pad_idx = 0;
|
||||
outputs->next = NULL;
|
||||
|
||||
inputs->name = av_strdup("out");
|
||||
inputs->filter_ctx = buffersink_ctx;
|
||||
inputs->pad_idx = 0;
|
||||
inputs->next = NULL;
|
||||
|
||||
if (!outputs->name || !inputs->name) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((ret = avfilter_graph_parse_ptr(filter_graph, filter_spec,
|
||||
&inputs, &outputs, NULL)) < 0)
|
||||
goto end;
|
||||
|
||||
if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0)
|
||||
goto end;
|
||||
|
||||
/* Fill FilteringContext */
|
||||
fctx->buffersrc_ctx = buffersrc_ctx;
|
||||
fctx->buffersink_ctx = buffersink_ctx;
|
||||
fctx->filter_graph = filter_graph;
|
||||
|
||||
end:
|
||||
avfilter_inout_free(&inputs);
|
||||
avfilter_inout_free(&outputs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int init_filters(void)
|
||||
{
|
||||
const char *filter_spec;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
filter_ctx = av_malloc_array(ifmt_ctx->nb_streams, sizeof(*filter_ctx));
|
||||
if (!filter_ctx)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
||||
filter_ctx[i].buffersrc_ctx = NULL;
|
||||
filter_ctx[i].buffersink_ctx = NULL;
|
||||
filter_ctx[i].filter_graph = NULL;
|
||||
if (!(ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO
|
||||
|| ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO))
|
||||
continue;
|
||||
|
||||
|
||||
if (ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
filter_spec = "null"; /* passthrough (dummy) filter for video */
|
||||
else
|
||||
filter_spec = "anull"; /* passthrough (dummy) filter for audio */
|
||||
ret = init_filter(&filter_ctx[i], ifmt_ctx->streams[i]->codec,
|
||||
ofmt_ctx->streams[i]->codec, filter_spec);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int encode_write_frame(AVFrame *filt_frame, unsigned int stream_index, int *got_frame) {
|
||||
int ret;
|
||||
int got_frame_local;
|
||||
AVPacket enc_pkt;
|
||||
int (*enc_func)(AVCodecContext *, AVPacket *, const AVFrame *, int *) =
|
||||
(ifmt_ctx->streams[stream_index]->codec->codec_type ==
|
||||
AVMEDIA_TYPE_VIDEO) ? avcodec_encode_video2 : avcodec_encode_audio2;
|
||||
|
||||
if (!got_frame)
|
||||
got_frame = &got_frame_local;
|
||||
|
||||
av_log(NULL, AV_LOG_INFO, "Encoding frame\n");
|
||||
/* encode filtered frame */
|
||||
enc_pkt.data = NULL;
|
||||
enc_pkt.size = 0;
|
||||
av_init_packet(&enc_pkt);
|
||||
ret = enc_func(ofmt_ctx->streams[stream_index]->codec, &enc_pkt,
|
||||
filt_frame, got_frame);
|
||||
av_frame_free(&filt_frame);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (!(*got_frame))
|
||||
return 0;
|
||||
|
||||
/* prepare packet for muxing */
|
||||
enc_pkt.stream_index = stream_index;
|
||||
av_packet_rescale_ts(&enc_pkt,
|
||||
ofmt_ctx->streams[stream_index]->codec->time_base,
|
||||
ofmt_ctx->streams[stream_index]->time_base);
|
||||
|
||||
av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n");
|
||||
/* mux encoded frame */
|
||||
ret = av_interleaved_write_frame(ofmt_ctx, &enc_pkt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)
|
||||
{
|
||||
int ret;
|
||||
AVFrame *filt_frame;
|
||||
|
||||
av_log(NULL, AV_LOG_INFO, "Pushing decoded frame to filters\n");
|
||||
/* push the decoded frame into the filtergraph */
|
||||
ret = av_buffersrc_add_frame_flags(filter_ctx[stream_index].buffersrc_ctx,
|
||||
frame, 0);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* pull filtered frames from the filtergraph */
|
||||
while (1) {
|
||||
filt_frame = av_frame_alloc();
|
||||
if (!filt_frame) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
break;
|
||||
}
|
||||
av_log(NULL, AV_LOG_INFO, "Pulling filtered frame from filters\n");
|
||||
ret = av_buffersink_get_frame(filter_ctx[stream_index].buffersink_ctx,
|
||||
filt_frame);
|
||||
if (ret < 0) {
|
||||
/* if no more frames for output - returns AVERROR(EAGAIN)
|
||||
* if flushed and no more frames for output - returns AVERROR_EOF
|
||||
* rewrite retcode to 0 to show it as normal procedure completion
|
||||
*/
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
||||
ret = 0;
|
||||
av_frame_free(&filt_frame);
|
||||
break;
|
||||
}
|
||||
|
||||
filt_frame->pict_type = AV_PICTURE_TYPE_NONE;
|
||||
ret = encode_write_frame(filt_frame, stream_index, NULL);
|
||||
if (ret < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int flush_encoder(unsigned int stream_index)
|
||||
{
|
||||
int ret;
|
||||
int got_frame;
|
||||
|
||||
if (!(ofmt_ctx->streams[stream_index]->codec->codec->capabilities &
|
||||
AV_CODEC_CAP_DELAY))
|
||||
return 0;
|
||||
|
||||
while (1) {
|
||||
av_log(NULL, AV_LOG_INFO, "Flushing stream #%u encoder\n", stream_index);
|
||||
ret = encode_write_frame(NULL, stream_index, &got_frame);
|
||||
if (ret < 0)
|
||||
break;
|
||||
if (!got_frame)
|
||||
return 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
AVPacket packet = { .data = NULL, .size = 0 };
|
||||
AVFrame *frame = NULL;
|
||||
enum AVMediaType type;
|
||||
unsigned int stream_index;
|
||||
unsigned int i;
|
||||
int got_frame;
|
||||
int (*dec_func)(AVCodecContext *, AVFrame *, int *, const AVPacket *);
|
||||
|
||||
if (argc != 3) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Usage: %s <input file> <output file>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
av_register_all();
|
||||
avfilter_register_all();
|
||||
|
||||
if ((ret = open_input_file(argv[1])) < 0)
|
||||
goto end;
|
||||
if ((ret = open_output_file(argv[2])) < 0)
|
||||
goto end;
|
||||
if ((ret = init_filters()) < 0)
|
||||
goto end;
|
||||
|
||||
/* read all packets */
|
||||
while (1) {
|
||||
if ((ret = av_read_frame(ifmt_ctx, &packet)) < 0)
|
||||
break;
|
||||
stream_index = packet.stream_index;
|
||||
type = ifmt_ctx->streams[packet.stream_index]->codec->codec_type;
|
||||
av_log(NULL, AV_LOG_DEBUG, "Demuxer gave frame of stream_index %u\n",
|
||||
stream_index);
|
||||
|
||||
if (filter_ctx[stream_index].filter_graph) {
|
||||
av_log(NULL, AV_LOG_DEBUG, "Going to reencode&filter the frame\n");
|
||||
frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
break;
|
||||
}
|
||||
av_packet_rescale_ts(&packet,
|
||||
ifmt_ctx->streams[stream_index]->time_base,
|
||||
ifmt_ctx->streams[stream_index]->codec->time_base);
|
||||
dec_func = (type == AVMEDIA_TYPE_VIDEO) ? avcodec_decode_video2 :
|
||||
avcodec_decode_audio4;
|
||||
ret = dec_func(ifmt_ctx->streams[stream_index]->codec, frame,
|
||||
&got_frame, &packet);
|
||||
if (ret < 0) {
|
||||
av_frame_free(&frame);
|
||||
av_log(NULL, AV_LOG_ERROR, "Decoding failed\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (got_frame) {
|
||||
frame->pts = av_frame_get_best_effort_timestamp(frame);
|
||||
ret = filter_encode_write_frame(frame, stream_index);
|
||||
av_frame_free(&frame);
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
} else {
|
||||
av_frame_free(&frame);
|
||||
}
|
||||
} else {
|
||||
/* remux this frame without reencoding */
|
||||
av_packet_rescale_ts(&packet,
|
||||
ifmt_ctx->streams[stream_index]->time_base,
|
||||
ofmt_ctx->streams[stream_index]->time_base);
|
||||
|
||||
ret = av_interleaved_write_frame(ofmt_ctx, &packet);
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
}
|
||||
av_packet_unref(&packet);
|
||||
}
|
||||
|
||||
/* flush filters and encoders */
|
||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
||||
/* flush filter */
|
||||
if (!filter_ctx[i].filter_graph)
|
||||
continue;
|
||||
ret = filter_encode_write_frame(NULL, i);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Flushing filter failed\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* flush encoder */
|
||||
ret = flush_encoder(i);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Flushing encoder failed\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
av_write_trailer(ofmt_ctx);
|
||||
end:
|
||||
av_packet_unref(&packet);
|
||||
av_frame_free(&frame);
|
||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
||||
avcodec_close(ifmt_ctx->streams[i]->codec);
|
||||
if (ofmt_ctx && ofmt_ctx->nb_streams > i && ofmt_ctx->streams[i] && ofmt_ctx->streams[i]->codec)
|
||||
avcodec_close(ofmt_ctx->streams[i]->codec);
|
||||
if (filter_ctx && filter_ctx[i].filter_graph)
|
||||
avfilter_graph_free(&filter_ctx[i].filter_graph);
|
||||
}
|
||||
av_free(filter_ctx);
|
||||
avformat_close_input(&ifmt_ctx);
|
||||
if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE))
|
||||
avio_closep(&ofmt_ctx->pb);
|
||||
avformat_free_context(ofmt_ctx);
|
||||
|
||||
if (ret < 0)
|
||||
av_log(NULL, AV_LOG_ERROR, "Error occurred: %s\n", av_err2str(ret));
|
||||
|
||||
return ret ? 1 : 0;
|
||||
}
|
@ -1,756 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
FFmpeg FAQ
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
FFmpeg FAQ
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-General-Questions" href="#General-Questions">1 General Questions</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Why-doesn_0027t-FFmpeg-support-feature-_005bxyz_005d_003f" href="#Why-doesn_0027t-FFmpeg-support-feature-_005bxyz_005d_003f">1.1 Why doesn’t FFmpeg support feature [xyz]?</a></li>
|
||||
<li><a name="toc-FFmpeg-does-not-support-codec-XXX_002e-Can-you-include-a-Windows-DLL-loader-to-support-it_003f" href="#FFmpeg-does-not-support-codec-XXX_002e-Can-you-include-a-Windows-DLL-loader-to-support-it_003f">1.2 FFmpeg does not support codec XXX. Can you include a Windows DLL loader to support it?</a></li>
|
||||
<li><a name="toc-I-cannot-read-this-file-although-this-format-seems-to-be-supported-by-ffmpeg_002e" href="#I-cannot-read-this-file-although-this-format-seems-to-be-supported-by-ffmpeg_002e">1.3 I cannot read this file although this format seems to be supported by ffmpeg.</a></li>
|
||||
<li><a name="toc-Which-codecs-are-supported-by-Windows_003f" href="#Which-codecs-are-supported-by-Windows_003f">1.4 Which codecs are supported by Windows?</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Compilation" href="#Compilation">2 Compilation</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027" href="#error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027">2.1 <code>error: can't find a register in class 'GENERAL_REGS' while reloading 'asm'</code></a></li>
|
||||
<li><a name="toc-I-have-installed-this-library-with-my-distro_0027s-package-manager_002e-Why-does-configure-not-see-it_003f" href="#I-have-installed-this-library-with-my-distro_0027s-package-manager_002e-Why-does-configure-not-see-it_003f">2.2 I have installed this library with my distro’s package manager. Why does <code>configure</code> not see it?</a></li>
|
||||
<li><a name="toc-How-do-I-make-pkg_002dconfig-find-my-libraries_003f" href="#How-do-I-make-pkg_002dconfig-find-my-libraries_003f">2.3 How do I make <code>pkg-config</code> find my libraries?</a></li>
|
||||
<li><a name="toc-How-do-I-use-pkg_002dconfig-when-cross_002dcompiling_003f" href="#How-do-I-use-pkg_002dconfig-when-cross_002dcompiling_003f">2.4 How do I use <code>pkg-config</code> when cross-compiling?</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Usage" href="#Usage">3 Usage</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-ffmpeg-does-not-work_003b-what-is-wrong_003f" href="#ffmpeg-does-not-work_003b-what-is-wrong_003f">3.1 ffmpeg does not work; what is wrong?</a></li>
|
||||
<li><a name="toc-How-do-I-encode-single-pictures-into-movies_003f" href="#How-do-I-encode-single-pictures-into-movies_003f">3.2 How do I encode single pictures into movies?</a></li>
|
||||
<li><a name="toc-How-do-I-encode-movie-to-single-pictures_003f" href="#How-do-I-encode-movie-to-single-pictures_003f">3.3 How do I encode movie to single pictures?</a></li>
|
||||
<li><a name="toc-Why-do-I-see-a-slight-quality-degradation-with-multithreaded-MPEG_002a-encoding_003f" href="#Why-do-I-see-a-slight-quality-degradation-with-multithreaded-MPEG_002a-encoding_003f">3.4 Why do I see a slight quality degradation with multithreaded MPEG* encoding?</a></li>
|
||||
<li><a name="toc-How-can-I-read-from-the-standard-input-or-write-to-the-standard-output_003f" href="#How-can-I-read-from-the-standard-input-or-write-to-the-standard-output_003f">3.5 How can I read from the standard input or write to the standard output?</a></li>
|
||||
<li><a name="toc-_002df-jpeg-doesn_0027t-work_002e" href="#g_t_002df-jpeg-doesn_0027t-work_002e">3.6 -f jpeg doesn’t work.</a></li>
|
||||
<li><a name="toc-Why-can-I-not-change-the-frame-rate_003f" href="#Why-can-I-not-change-the-frame-rate_003f">3.7 Why can I not change the frame rate?</a></li>
|
||||
<li><a name="toc-How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f" href="#How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f">3.8 How do I encode Xvid or DivX video with ffmpeg?</a></li>
|
||||
<li><a name="toc-Which-are-good-parameters-for-encoding-high-quality-MPEG_002d4_003f" href="#Which-are-good-parameters-for-encoding-high-quality-MPEG_002d4_003f">3.9 Which are good parameters for encoding high quality MPEG-4?</a></li>
|
||||
<li><a name="toc-Which-are-good-parameters-for-encoding-high-quality-MPEG_002d1_002fMPEG_002d2_003f" href="#Which-are-good-parameters-for-encoding-high-quality-MPEG_002d1_002fMPEG_002d2_003f">3.10 Which are good parameters for encoding high quality MPEG-1/MPEG-2?</a></li>
|
||||
<li><a name="toc-Interlaced-video-looks-very-bad-when-encoded-with-ffmpeg_002c-what-is-wrong_003f" href="#Interlaced-video-looks-very-bad-when-encoded-with-ffmpeg_002c-what-is-wrong_003f">3.11 Interlaced video looks very bad when encoded with ffmpeg, what is wrong?</a></li>
|
||||
<li><a name="toc-How-can-I-read-DirectShow-files_003f" href="#How-can-I-read-DirectShow-files_003f">3.12 How can I read DirectShow files?</a></li>
|
||||
<li><a name="toc-How-can-I-join-video-files_003f" href="#How-can-I-join-video-files_003f">3.13 How can I join video files?</a></li>
|
||||
<li><a name="toc-How-can-I-concatenate-video-files_003f" href="#How-can-I-concatenate-video-files_003f">3.14 How can I concatenate video files?</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Concatenating-using-the-concat-filter" href="#Concatenating-using-the-concat-filter">3.14.1 Concatenating using the concat <em>filter</em></a></li>
|
||||
<li><a name="toc-Concatenating-using-the-concat-demuxer" href="#Concatenating-using-the-concat-demuxer">3.14.2 Concatenating using the concat <em>demuxer</em></a></li>
|
||||
<li><a name="toc-Concatenating-using-the-concat-protocol-_0028file-level_0029" href="#Concatenating-using-the-concat-protocol-_0028file-level_0029">3.14.3 Concatenating using the concat <em>protocol</em> (file level)</a></li>
|
||||
<li><a name="toc-Concatenating-using-raw-audio-and-video" href="#Concatenating-using-raw-audio-and-video">3.14.4 Concatenating using raw audio and video</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Using-_002df-lavfi_002c-audio-becomes-mono-for-no-apparent-reason_002e" href="#Using-_002df-lavfi_002c-audio-becomes-mono-for-no-apparent-reason_002e">3.15 Using <samp>-f lavfi</samp>, audio becomes mono for no apparent reason.</a></li>
|
||||
<li><a name="toc-Why-does-FFmpeg-not-see-the-subtitles-in-my-VOB-file_003f" href="#Why-does-FFmpeg-not-see-the-subtitles-in-my-VOB-file_003f">3.16 Why does FFmpeg not see the subtitles in my VOB file?</a></li>
|
||||
<li><a name="toc-Why-was-the-ffmpeg-_002dsameq-option-removed_003f-What-to-use-instead_003f" href="#Why-was-the-ffmpeg-_002dsameq-option-removed_003f-What-to-use-instead_003f">3.17 Why was the <code>ffmpeg</code> <samp>-sameq</samp> option removed? What to use instead?</a></li>
|
||||
<li><a name="toc-I-have-a-stretched-video_002c-why-does-scaling-does-not-fix-it_003f" href="#I-have-a-stretched-video_002c-why-does-scaling-does-not-fix-it_003f">3.18 I have a stretched video, why does scaling does not fix it?</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Development" href="#Development">4 Development</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Are-there-examples-illustrating-how-to-use-the-FFmpeg-libraries_002c-particularly-libavcodec-and-libavformat_003f" href="#Are-there-examples-illustrating-how-to-use-the-FFmpeg-libraries_002c-particularly-libavcodec-and-libavformat_003f">4.1 Are there examples illustrating how to use the FFmpeg libraries, particularly libavcodec and libavformat?</a></li>
|
||||
<li><a name="toc-Can-you-support-my-C-compiler-XXX_003f" href="#Can-you-support-my-C-compiler-XXX_003f">4.2 Can you support my C compiler XXX?</a></li>
|
||||
<li><a name="toc-Is-Microsoft-Visual-C_002b_002b-supported_003f" href="#Is-Microsoft-Visual-C_002b_002b-supported_003f">4.3 Is Microsoft Visual C++ supported?</a></li>
|
||||
<li><a name="toc-Can-you-add-automake_002c-libtool-or-autoconf-support_003f" href="#Can-you-add-automake_002c-libtool-or-autoconf-support_003f">4.4 Can you add automake, libtool or autoconf support?</a></li>
|
||||
<li><a name="toc-Why-not-rewrite-FFmpeg-in-object_002doriented-C_002b_002b_003f" href="#Why-not-rewrite-FFmpeg-in-object_002doriented-C_002b_002b_003f">4.5 Why not rewrite FFmpeg in object-oriented C++?</a></li>
|
||||
<li><a name="toc-Why-are-the-ffmpeg-programs-devoid-of-debugging-symbols_003f" href="#Why-are-the-ffmpeg-programs-devoid-of-debugging-symbols_003f">4.6 Why are the ffmpeg programs devoid of debugging symbols?</a></li>
|
||||
<li><a name="toc-I-do-not-like-the-LGPL_002c-can-I-contribute-code-under-the-GPL-instead_003f" href="#I-do-not-like-the-LGPL_002c-can-I-contribute-code-under-the-GPL-instead_003f">4.7 I do not like the LGPL, can I contribute code under the GPL instead?</a></li>
|
||||
<li><a name="toc-I_0027m-using-FFmpeg-from-within-my-C-application-but-the-linker-complains-about-missing-symbols-from-the-libraries-themselves_002e" href="#I_0027m-using-FFmpeg-from-within-my-C-application-but-the-linker-complains-about-missing-symbols-from-the-libraries-themselves_002e">4.8 I’m using FFmpeg from within my C application but the linker complains about missing symbols from the libraries themselves.</a></li>
|
||||
<li><a name="toc-I_0027m-using-FFmpeg-from-within-my-C_002b_002b-application-but-the-linker-complains-about-missing-symbols-which-seem-to-be-available_002e" href="#I_0027m-using-FFmpeg-from-within-my-C_002b_002b-application-but-the-linker-complains-about-missing-symbols-which-seem-to-be-available_002e">4.9 I’m using FFmpeg from within my C++ application but the linker complains about missing symbols which seem to be available.</a></li>
|
||||
<li><a name="toc-I_0027m-using-libavutil-from-within-my-C_002b_002b-application-but-the-compiler-complains-about-_0027UINT64_005fC_0027-was-not-declared-in-this-scope" href="#I_0027m-using-libavutil-from-within-my-C_002b_002b-application-but-the-compiler-complains-about-_0027UINT64_005fC_0027-was-not-declared-in-this-scope">4.10 I’m using libavutil from within my C++ application but the compiler complains about ’UINT64_C’ was not declared in this scope</a></li>
|
||||
<li><a name="toc-I-have-a-file-in-memory-_002f-a-API-different-from-_002aopen_002f_002aread_002f-libc-how-do-I-use-it-with-libavformat_003f" href="#I-have-a-file-in-memory-_002f-a-API-different-from-_002aopen_002f_002aread_002f-libc-how-do-I-use-it-with-libavformat_003f">4.11 I have a file in memory / a API different from *open/*read/ libc how do I use it with libavformat?</a></li>
|
||||
<li><a name="toc-Where-is-the-documentation-about-ffv1_002c-msmpeg4_002c-asv1_002c-4xm_003f" href="#Where-is-the-documentation-about-ffv1_002c-msmpeg4_002c-asv1_002c-4xm_003f">4.12 Where is the documentation about ffv1, msmpeg4, asv1, 4xm?</a></li>
|
||||
<li><a name="toc-How-do-I-feed-H_002e263_002dRTP-_0028and-other-codecs-in-RTP_0029-to-libavcodec_003f" href="#How-do-I-feed-H_002e263_002dRTP-_0028and-other-codecs-in-RTP_0029-to-libavcodec_003f">4.13 How do I feed H.263-RTP (and other codecs in RTP) to libavcodec?</a></li>
|
||||
<li><a name="toc-AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e" href="#AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e">4.14 AVStream.r_frame_rate is wrong, it is much larger than the frame rate.</a></li>
|
||||
<li><a name="toc-Why-is-make-fate-not-running-all-tests_003f" href="#Why-is-make-fate-not-running-all-tests_003f">4.15 Why is <code>make fate</code> not running all tests?</a></li>
|
||||
<li><a name="toc-Why-is-make-fate-not-finding-the-samples_003f" href="#Why-is-make-fate-not-finding-the-samples_003f">4.16 Why is <code>make fate</code> not finding the samples?</a></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="General-Questions"></a>
|
||||
<h2 class="chapter">1 General Questions<span class="pull-right"><a class="anchor hidden-xs" href="#General-Questions" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-General-Questions" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<a name="Why-doesn_0027t-FFmpeg-support-feature-_005bxyz_005d_003f"></a>
|
||||
<h3 class="section">1.1 Why doesn’t FFmpeg support feature [xyz]?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-doesn_0027t-FFmpeg-support-feature-_005bxyz_005d_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-doesn_0027t-FFmpeg-support-feature-_005bxyz_005d_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Because no one has taken on that task yet. FFmpeg development is
|
||||
driven by the tasks that are important to the individual developers.
|
||||
If there is a feature that is important to you, the best way to get
|
||||
it implemented is to undertake the task yourself or sponsor a developer.
|
||||
</p>
|
||||
<a name="FFmpeg-does-not-support-codec-XXX_002e-Can-you-include-a-Windows-DLL-loader-to-support-it_003f"></a>
|
||||
<h3 class="section">1.2 FFmpeg does not support codec XXX. Can you include a Windows DLL loader to support it?<span class="pull-right"><a class="anchor hidden-xs" href="#FFmpeg-does-not-support-codec-XXX_002e-Can-you-include-a-Windows-DLL-loader-to-support-it_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-FFmpeg-does-not-support-codec-XXX_002e-Can-you-include-a-Windows-DLL-loader-to-support-it_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>No. Windows DLLs are not portable, bloated and often slow.
|
||||
Moreover FFmpeg strives to support all codecs natively.
|
||||
A DLL loader is not conducive to that goal.
|
||||
</p>
|
||||
<a name="I-cannot-read-this-file-although-this-format-seems-to-be-supported-by-ffmpeg_002e"></a>
|
||||
<h3 class="section">1.3 I cannot read this file although this format seems to be supported by ffmpeg.<span class="pull-right"><a class="anchor hidden-xs" href="#I-cannot-read-this-file-although-this-format-seems-to-be-supported-by-ffmpeg_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I-cannot-read-this-file-although-this-format-seems-to-be-supported-by-ffmpeg_002e" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Even if ffmpeg can read the container format, it may not support all its
|
||||
codecs. Please consult the supported codec list in the ffmpeg
|
||||
documentation.
|
||||
</p>
|
||||
<a name="Which-codecs-are-supported-by-Windows_003f"></a>
|
||||
<h3 class="section">1.4 Which codecs are supported by Windows?<span class="pull-right"><a class="anchor hidden-xs" href="#Which-codecs-are-supported-by-Windows_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Which-codecs-are-supported-by-Windows_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Windows does not support standard formats like MPEG very well, unless you
|
||||
install some additional codecs.
|
||||
</p>
|
||||
<p>The following list of video codecs should work on most Windows systems:
|
||||
</p><dl compact="compact">
|
||||
<dt><samp>msmpeg4v2</samp></dt>
|
||||
<dd><p>.avi/.asf
|
||||
</p></dd>
|
||||
<dt><samp>msmpeg4</samp></dt>
|
||||
<dd><p>.asf only
|
||||
</p></dd>
|
||||
<dt><samp>wmv1</samp></dt>
|
||||
<dd><p>.asf only
|
||||
</p></dd>
|
||||
<dt><samp>wmv2</samp></dt>
|
||||
<dd><p>.asf only
|
||||
</p></dd>
|
||||
<dt><samp>mpeg4</samp></dt>
|
||||
<dd><p>Only if you have some MPEG-4 codec like ffdshow or Xvid installed.
|
||||
</p></dd>
|
||||
<dt><samp>mpeg1video</samp></dt>
|
||||
<dd><p>.mpg only
|
||||
</p></dd>
|
||||
</dl>
|
||||
<p>Note, ASF files often have .wmv or .wma extensions in Windows. It should also
|
||||
be mentioned that Microsoft claims a patent on the ASF format, and may sue
|
||||
or threaten users who create ASF files with non-Microsoft software. It is
|
||||
strongly advised to avoid ASF where possible.
|
||||
</p>
|
||||
<p>The following list of audio codecs should work on most Windows systems:
|
||||
</p><dl compact="compact">
|
||||
<dt><samp>adpcm_ima_wav</samp></dt>
|
||||
<dt><samp>adpcm_ms</samp></dt>
|
||||
<dt><samp>pcm_s16le</samp></dt>
|
||||
<dd><p>always
|
||||
</p></dd>
|
||||
<dt><samp>libmp3lame</samp></dt>
|
||||
<dd><p>If some MP3 codec like LAME is installed.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<a name="Compilation"></a>
|
||||
<h2 class="chapter">2 Compilation<span class="pull-right"><a class="anchor hidden-xs" href="#Compilation" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Compilation" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<a name="error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027"></a>
|
||||
<h3 class="section">2.1 <code>error: can't find a register in class 'GENERAL_REGS' while reloading 'asm'</code><span class="pull-right"><a class="anchor hidden-xs" href="#error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>This is a bug in gcc. Do not report it to us. Instead, please report it to
|
||||
the gcc developers. Note that we will not add workarounds for gcc bugs.
|
||||
</p>
|
||||
<p>Also note that (some of) the gcc developers believe this is not a bug or
|
||||
not a bug they should fix:
|
||||
<a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11203">http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11203</a>.
|
||||
Then again, some of them do not know the difference between an undecidable
|
||||
problem and an NP-hard problem...
|
||||
</p>
|
||||
<a name="I-have-installed-this-library-with-my-distro_0027s-package-manager_002e-Why-does-configure-not-see-it_003f"></a>
|
||||
<h3 class="section">2.2 I have installed this library with my distro’s package manager. Why does <code>configure</code> not see it?<span class="pull-right"><a class="anchor hidden-xs" href="#I-have-installed-this-library-with-my-distro_0027s-package-manager_002e-Why-does-configure-not-see-it_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I-have-installed-this-library-with-my-distro_0027s-package-manager_002e-Why-does-configure-not-see-it_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Distributions usually split libraries in several packages. The main package
|
||||
contains the files necessary to run programs using the library. The
|
||||
development package contains the files necessary to build programs using the
|
||||
library. Sometimes, docs and/or data are in a separate package too.
|
||||
</p>
|
||||
<p>To build FFmpeg, you need to install the development package. It is usually
|
||||
called <samp>libfoo-dev</samp> or <samp>libfoo-devel</samp>. You can remove it after the
|
||||
build is finished, but be sure to keep the main package.
|
||||
</p>
|
||||
<a name="How-do-I-make-pkg_002dconfig-find-my-libraries_003f"></a>
|
||||
<h3 class="section">2.3 How do I make <code>pkg-config</code> find my libraries?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-make-pkg_002dconfig-find-my-libraries_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-make-pkg_002dconfig-find-my-libraries_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Somewhere along with your libraries, there is a <samp>.pc</samp> file (or several)
|
||||
in a <samp>pkgconfig</samp> directory. You need to set environment variables to
|
||||
point <code>pkg-config</code> to these files.
|
||||
</p>
|
||||
<p>If you need to <em>add</em> directories to <code>pkg-config</code>’s search list
|
||||
(typical use case: library installed separately), add it to
|
||||
<code>$PKG_CONFIG_PATH</code>:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">export PKG_CONFIG_PATH=/opt/x264/lib/pkgconfig:/opt/opus/lib/pkgconfig
|
||||
</pre></div>
|
||||
|
||||
<p>If you need to <em>replace</em> <code>pkg-config</code>’s search list
|
||||
(typical use case: cross-compiling), set it in
|
||||
<code>$PKG_CONFIG_LIBDIR</code>:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">export PKG_CONFIG_LIBDIR=/home/me/cross/usr/lib/pkgconfig:/home/me/cross/usr/local/lib/pkgconfig
|
||||
</pre></div>
|
||||
|
||||
<p>If you need to know the library’s internal dependencies (typical use: static
|
||||
linking), add the <code>--static</code> option to <code>pkg-config</code>:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">./configure --pkg-config-flags=--static
|
||||
</pre></div>
|
||||
|
||||
<a name="How-do-I-use-pkg_002dconfig-when-cross_002dcompiling_003f"></a>
|
||||
<h3 class="section">2.4 How do I use <code>pkg-config</code> when cross-compiling?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-use-pkg_002dconfig-when-cross_002dcompiling_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-use-pkg_002dconfig-when-cross_002dcompiling_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>The best way is to install <code>pkg-config</code> in your cross-compilation
|
||||
environment. It will automatically use the cross-compilation libraries.
|
||||
</p>
|
||||
<p>You can also use <code>pkg-config</code> from the host environment by
|
||||
specifying explicitly <code>--pkg-config=pkg-config</code> to <code>configure</code>.
|
||||
In that case, you must point <code>pkg-config</code> to the correct directories
|
||||
using the <code>PKG_CONFIG_LIBDIR</code>, as explained in the previous entry.
|
||||
</p>
|
||||
<p>As an intermediate solution, you can place in your cross-compilation
|
||||
environment a script that calls the host <code>pkg-config</code> with
|
||||
<code>PKG_CONFIG_LIBDIR</code> set. That script can look like that:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">#!/bin/sh
|
||||
PKG_CONFIG_LIBDIR=/path/to/cross/lib/pkgconfig
|
||||
export PKG_CONFIG_LIBDIR
|
||||
exec /usr/bin/pkg-config "$@"
|
||||
</pre></div>
|
||||
|
||||
<a name="Usage"></a>
|
||||
<h2 class="chapter">3 Usage<span class="pull-right"><a class="anchor hidden-xs" href="#Usage" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Usage" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<a name="ffmpeg-does-not-work_003b-what-is-wrong_003f"></a>
|
||||
<h3 class="section">3.1 ffmpeg does not work; what is wrong?<span class="pull-right"><a class="anchor hidden-xs" href="#ffmpeg-does-not-work_003b-what-is-wrong_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-ffmpeg-does-not-work_003b-what-is-wrong_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Try a <code>make distclean</code> in the ffmpeg source directory before the build.
|
||||
If this does not help see
|
||||
(<a href="https://ffmpeg.org/bugreports.html">https://ffmpeg.org/bugreports.html</a>).
|
||||
</p>
|
||||
<a name="How-do-I-encode-single-pictures-into-movies_003f"></a>
|
||||
<h3 class="section">3.2 How do I encode single pictures into movies?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-encode-single-pictures-into-movies_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-encode-single-pictures-into-movies_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>First, rename your pictures to follow a numerical sequence.
|
||||
For example, img1.jpg, img2.jpg, img3.jpg,...
|
||||
Then you may run:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -f image2 -i img%d.jpg /tmp/a.mpg
|
||||
</pre></div>
|
||||
|
||||
<p>Notice that ‘<samp>%d</samp>’ is replaced by the image number.
|
||||
</p>
|
||||
<p><samp>img%03d.jpg</samp> means the sequence <samp>img001.jpg</samp>, <samp>img002.jpg</samp>, etc.
|
||||
</p>
|
||||
<p>Use the <samp>-start_number</samp> option to declare a starting number for
|
||||
the sequence. This is useful if your sequence does not start with
|
||||
<samp>img001.jpg</samp> but is still in a numerical order. The following
|
||||
example will start with <samp>img100.jpg</samp>:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -f image2 -start_number 100 -i img%d.jpg /tmp/a.mpg
|
||||
</pre></div>
|
||||
|
||||
<p>If you have large number of pictures to rename, you can use the
|
||||
following command to ease the burden. The command, using the bourne
|
||||
shell syntax, symbolically links all files in the current directory
|
||||
that match <code>*jpg</code> to the <samp>/tmp</samp> directory in the sequence of
|
||||
<samp>img001.jpg</samp>, <samp>img002.jpg</samp> and so on.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">x=1; for i in *jpg; do counter=$(printf %03d $x); ln -s "$i" /tmp/img"$counter".jpg; x=$(($x+1)); done
|
||||
</pre></div>
|
||||
|
||||
<p>If you want to sequence them by oldest modified first, substitute
|
||||
<code>$(ls -r -t *jpg)</code> in place of <code>*jpg</code>.
|
||||
</p>
|
||||
<p>Then run:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -f image2 -i /tmp/img%03d.jpg /tmp/a.mpg
|
||||
</pre></div>
|
||||
|
||||
<p>The same logic is used for any image format that ffmpeg reads.
|
||||
</p>
|
||||
<p>You can also use <code>cat</code> to pipe images to ffmpeg:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">cat *.jpg | ffmpeg -f image2pipe -c:v mjpeg -i - output.mpg
|
||||
</pre></div>
|
||||
|
||||
<a name="How-do-I-encode-movie-to-single-pictures_003f"></a>
|
||||
<h3 class="section">3.3 How do I encode movie to single pictures?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-encode-movie-to-single-pictures_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-encode-movie-to-single-pictures_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Use:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -i movie.mpg movie%d.jpg
|
||||
</pre></div>
|
||||
|
||||
<p>The <samp>movie.mpg</samp> used as input will be converted to
|
||||
<samp>movie1.jpg</samp>, <samp>movie2.jpg</samp>, etc...
|
||||
</p>
|
||||
<p>Instead of relying on file format self-recognition, you may also use
|
||||
</p><dl compact="compact">
|
||||
<dt><samp>-c:v ppm</samp></dt>
|
||||
<dt><samp>-c:v png</samp></dt>
|
||||
<dt><samp>-c:v mjpeg</samp></dt>
|
||||
</dl>
|
||||
<p>to force the encoding.
|
||||
</p>
|
||||
<p>Applying that to the previous example:
|
||||
</p><div class="example">
|
||||
<pre class="example">ffmpeg -i movie.mpg -f image2 -c:v mjpeg menu%d.jpg
|
||||
</pre></div>
|
||||
|
||||
<p>Beware that there is no "jpeg" codec. Use "mjpeg" instead.
|
||||
</p>
|
||||
<a name="Why-do-I-see-a-slight-quality-degradation-with-multithreaded-MPEG_002a-encoding_003f"></a>
|
||||
<h3 class="section">3.4 Why do I see a slight quality degradation with multithreaded MPEG* encoding?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-do-I-see-a-slight-quality-degradation-with-multithreaded-MPEG_002a-encoding_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-do-I-see-a-slight-quality-degradation-with-multithreaded-MPEG_002a-encoding_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>For multithreaded MPEG* encoding, the encoded slices must be independent,
|
||||
otherwise thread n would practically have to wait for n-1 to finish, so it’s
|
||||
quite logical that there is a small reduction of quality. This is not a bug.
|
||||
</p>
|
||||
<a name="How-can-I-read-from-the-standard-input-or-write-to-the-standard-output_003f"></a>
|
||||
<h3 class="section">3.5 How can I read from the standard input or write to the standard output?<span class="pull-right"><a class="anchor hidden-xs" href="#How-can-I-read-from-the-standard-input-or-write-to-the-standard-output_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-can-I-read-from-the-standard-input-or-write-to-the-standard-output_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Use <samp>-</samp> as file name.
|
||||
</p>
|
||||
<a name="g_t_002df-jpeg-doesn_0027t-work_002e"></a>
|
||||
<h3 class="section">3.6 -f jpeg doesn’t work.<span class="pull-right"><a class="anchor hidden-xs" href="#_002df-jpeg-doesn_0027t-work_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-_002df-jpeg-doesn_0027t-work_002e" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Try ’-f image2 test%d.jpg’.
|
||||
</p>
|
||||
<a name="Why-can-I-not-change-the-frame-rate_003f"></a>
|
||||
<h3 class="section">3.7 Why can I not change the frame rate?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-can-I-not-change-the-frame-rate_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-can-I-not-change-the-frame-rate_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Some codecs, like MPEG-1/2, only allow a small number of fixed frame rates.
|
||||
Choose a different codec with the -c:v command line option.
|
||||
</p>
|
||||
<a name="How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f"></a>
|
||||
<h3 class="section">3.8 How do I encode Xvid or DivX video with ffmpeg?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Both Xvid and DivX (version 4+) are implementations of the ISO MPEG-4
|
||||
standard (note that there are many other coding formats that use this
|
||||
same standard). Thus, use ’-c:v mpeg4’ to encode in these formats. The
|
||||
default fourcc stored in an MPEG-4-coded file will be ’FMP4’. If you want
|
||||
a different fourcc, use the ’-vtag’ option. E.g., ’-vtag xvid’ will
|
||||
force the fourcc ’xvid’ to be stored as the video fourcc rather than the
|
||||
default.
|
||||
</p>
|
||||
<a name="Which-are-good-parameters-for-encoding-high-quality-MPEG_002d4_003f"></a>
|
||||
<h3 class="section">3.9 Which are good parameters for encoding high quality MPEG-4?<span class="pull-right"><a class="anchor hidden-xs" href="#Which-are-good-parameters-for-encoding-high-quality-MPEG_002d4_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Which-are-good-parameters-for-encoding-high-quality-MPEG_002d4_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>’-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -pass 1/2’,
|
||||
things to try: ’-bf 2’, ’-flags qprd’, ’-flags mv0’, ’-flags skiprd’.
|
||||
</p>
|
||||
<a name="Which-are-good-parameters-for-encoding-high-quality-MPEG_002d1_002fMPEG_002d2_003f"></a>
|
||||
<h3 class="section">3.10 Which are good parameters for encoding high quality MPEG-1/MPEG-2?<span class="pull-right"><a class="anchor hidden-xs" href="#Which-are-good-parameters-for-encoding-high-quality-MPEG_002d1_002fMPEG_002d2_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Which-are-good-parameters-for-encoding-high-quality-MPEG_002d1_002fMPEG_002d2_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>’-mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -pass 1/2’
|
||||
but beware the ’-g 100’ might cause problems with some decoders.
|
||||
Things to try: ’-bf 2’, ’-flags qprd’, ’-flags mv0’, ’-flags skiprd.
|
||||
</p>
|
||||
<a name="Interlaced-video-looks-very-bad-when-encoded-with-ffmpeg_002c-what-is-wrong_003f"></a>
|
||||
<h3 class="section">3.11 Interlaced video looks very bad when encoded with ffmpeg, what is wrong?<span class="pull-right"><a class="anchor hidden-xs" href="#Interlaced-video-looks-very-bad-when-encoded-with-ffmpeg_002c-what-is-wrong_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Interlaced-video-looks-very-bad-when-encoded-with-ffmpeg_002c-what-is-wrong_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>You should use ’-flags +ilme+ildct’ and maybe ’-flags +alt’ for interlaced
|
||||
material, and try ’-top 0/1’ if the result looks really messed-up.
|
||||
</p>
|
||||
<a name="How-can-I-read-DirectShow-files_003f"></a>
|
||||
<h3 class="section">3.12 How can I read DirectShow files?<span class="pull-right"><a class="anchor hidden-xs" href="#How-can-I-read-DirectShow-files_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-can-I-read-DirectShow-files_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>If you have built FFmpeg with <code>./configure --enable-avisynth</code>
|
||||
(only possible on MinGW/Cygwin platforms),
|
||||
then you may use any file that DirectShow can read as input.
|
||||
</p>
|
||||
<p>Just create an "input.avs" text file with this single line ...
|
||||
</p><div class="example">
|
||||
<pre class="example">DirectShowSource("C:\path to your file\yourfile.asf")
|
||||
</pre></div>
|
||||
<p>... and then feed that text file to ffmpeg:
|
||||
</p><div class="example">
|
||||
<pre class="example">ffmpeg -i input.avs
|
||||
</pre></div>
|
||||
|
||||
<p>For ANY other help on AviSynth, please visit the
|
||||
<a href="http://www.avisynth.org/">AviSynth homepage</a>.
|
||||
</p>
|
||||
<a name="How-can-I-join-video-files_003f"></a>
|
||||
<h3 class="section">3.13 How can I join video files?<span class="pull-right"><a class="anchor hidden-xs" href="#How-can-I-join-video-files_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-can-I-join-video-files_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>To "join" video files is quite ambiguous. The following list explains the
|
||||
different kinds of "joining" and points out how those are addressed in
|
||||
FFmpeg. To join video files may mean:
|
||||
</p>
|
||||
<ul>
|
||||
<li> To put them one after the other: this is called to <em>concatenate</em> them
|
||||
(in short: concat) and is addressed
|
||||
<a href="#How-can-I-concatenate-video-files">in this very faq</a>.
|
||||
|
||||
</li><li> To put them together in the same file, to let the user choose between the
|
||||
different versions (example: different audio languages): this is called to
|
||||
<em>multiplex</em> them together (in short: mux), and is done by simply
|
||||
invoking ffmpeg with several <samp>-i</samp> options.
|
||||
|
||||
</li><li> For audio, to put all channels together in a single stream (example: two
|
||||
mono streams into one stereo stream): this is sometimes called to
|
||||
<em>merge</em> them, and can be done using the
|
||||
<a href="ffmpeg-filters.html#amerge"><code>amerge</code></a> filter.
|
||||
|
||||
</li><li> For audio, to play one on top of the other: this is called to <em>mix</em>
|
||||
them, and can be done by first merging them into a single stream and then
|
||||
using the <a href="ffmpeg-filters.html#pan"><code>pan</code></a> filter to mix
|
||||
the channels at will.
|
||||
|
||||
</li><li> For video, to display both together, side by side or one on top of a part of
|
||||
the other; it can be done using the
|
||||
<a href="ffmpeg-filters.html#overlay"><code>overlay</code></a> video filter.
|
||||
|
||||
</li></ul>
|
||||
|
||||
<a name="How-can-I-concatenate-video-files"></a><a name="How-can-I-concatenate-video-files_003f"></a>
|
||||
<h3 class="section">3.14 How can I concatenate video files?<span class="pull-right"><a class="anchor hidden-xs" href="#How-can-I-concatenate-video-files_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-can-I-concatenate-video-files_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>There are several solutions, depending on the exact circumstances.
|
||||
</p>
|
||||
<a name="Concatenating-using-the-concat-filter"></a>
|
||||
<h4 class="subsection">3.14.1 Concatenating using the concat <em>filter</em><span class="pull-right"><a class="anchor hidden-xs" href="#Concatenating-using-the-concat-filter" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Concatenating-using-the-concat-filter" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>FFmpeg has a <a href="ffmpeg-filters.html#concat"><code>concat</code></a> filter designed specifically for that, with examples in the
|
||||
documentation. This operation is recommended if you need to re-encode.
|
||||
</p>
|
||||
<a name="Concatenating-using-the-concat-demuxer"></a>
|
||||
<h4 class="subsection">3.14.2 Concatenating using the concat <em>demuxer</em><span class="pull-right"><a class="anchor hidden-xs" href="#Concatenating-using-the-concat-demuxer" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Concatenating-using-the-concat-demuxer" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>FFmpeg has a <a href="ffmpeg-formats.html#concat"><code>concat</code></a> demuxer which you can use when you want to avoid a re-encode and
|
||||
your format doesn’t support file level concatenation.
|
||||
</p>
|
||||
<a name="Concatenating-using-the-concat-protocol-_0028file-level_0029"></a>
|
||||
<h4 class="subsection">3.14.3 Concatenating using the concat <em>protocol</em> (file level)<span class="pull-right"><a class="anchor hidden-xs" href="#Concatenating-using-the-concat-protocol-_0028file-level_0029" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Concatenating-using-the-concat-protocol-_0028file-level_0029" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>FFmpeg has a <a href="ffmpeg-protocols.html#concat"><code>concat</code></a> protocol designed specifically for that, with examples in the
|
||||
documentation.
|
||||
</p>
|
||||
<p>A few multimedia containers (MPEG-1, MPEG-2 PS, DV) allow one to concatenate
|
||||
video by merely concatenating the files containing them.
|
||||
</p>
|
||||
<p>Hence you may concatenate your multimedia files by first transcoding them to
|
||||
these privileged formats, then using the humble <code>cat</code> command (or the
|
||||
equally humble <code>copy</code> under Windows), and finally transcoding back to your
|
||||
format of choice.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -i input1.avi -qscale:v 1 intermediate1.mpg
|
||||
ffmpeg -i input2.avi -qscale:v 1 intermediate2.mpg
|
||||
cat intermediate1.mpg intermediate2.mpg > intermediate_all.mpg
|
||||
ffmpeg -i intermediate_all.mpg -qscale:v 2 output.avi
|
||||
</pre></div>
|
||||
|
||||
<p>Additionally, you can use the <code>concat</code> protocol instead of <code>cat</code> or
|
||||
<code>copy</code> which will avoid creation of a potentially huge intermediate file.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -i input1.avi -qscale:v 1 intermediate1.mpg
|
||||
ffmpeg -i input2.avi -qscale:v 1 intermediate2.mpg
|
||||
ffmpeg -i concat:"intermediate1.mpg|intermediate2.mpg" -c copy intermediate_all.mpg
|
||||
ffmpeg -i intermediate_all.mpg -qscale:v 2 output.avi
|
||||
</pre></div>
|
||||
|
||||
<p>Note that you may need to escape the character "|" which is special for many
|
||||
shells.
|
||||
</p>
|
||||
<p>Another option is usage of named pipes, should your platform support it:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">mkfifo intermediate1.mpg
|
||||
mkfifo intermediate2.mpg
|
||||
ffmpeg -i input1.avi -qscale:v 1 -y intermediate1.mpg < /dev/null &
|
||||
ffmpeg -i input2.avi -qscale:v 1 -y intermediate2.mpg < /dev/null &
|
||||
cat intermediate1.mpg intermediate2.mpg |\
|
||||
ffmpeg -f mpeg -i - -c:v mpeg4 -acodec libmp3lame output.avi
|
||||
</pre></div>
|
||||
|
||||
<a name="Concatenating-using-raw-audio-and-video"></a>
|
||||
<h4 class="subsection">3.14.4 Concatenating using raw audio and video<span class="pull-right"><a class="anchor hidden-xs" href="#Concatenating-using-raw-audio-and-video" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Concatenating-using-raw-audio-and-video" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>Similarly, the yuv4mpegpipe format, and the raw video, raw audio codecs also
|
||||
allow concatenation, and the transcoding step is almost lossless.
|
||||
When using multiple yuv4mpegpipe(s), the first line needs to be discarded
|
||||
from all but the first stream. This can be accomplished by piping through
|
||||
<code>tail</code> as seen below. Note that when piping through <code>tail</code> you
|
||||
must use command grouping, <code>{ ;}</code>, to background properly.
|
||||
</p>
|
||||
<p>For example, let’s say we want to concatenate two FLV files into an
|
||||
output.flv file:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">mkfifo temp1.a
|
||||
mkfifo temp1.v
|
||||
mkfifo temp2.a
|
||||
mkfifo temp2.v
|
||||
mkfifo all.a
|
||||
mkfifo all.v
|
||||
ffmpeg -i input1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null &
|
||||
ffmpeg -i input2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null &
|
||||
ffmpeg -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &
|
||||
{ ffmpeg -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; } &
|
||||
cat temp1.a temp2.a > all.a &
|
||||
cat temp1.v temp2.v > all.v &
|
||||
ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \
|
||||
-f yuv4mpegpipe -i all.v \
|
||||
-y output.flv
|
||||
rm temp[12].[av] all.[av]
|
||||
</pre></div>
|
||||
|
||||
<a name="Using-_002df-lavfi_002c-audio-becomes-mono-for-no-apparent-reason_002e"></a>
|
||||
<h3 class="section">3.15 Using <samp>-f lavfi</samp>, audio becomes mono for no apparent reason.<span class="pull-right"><a class="anchor hidden-xs" href="#Using-_002df-lavfi_002c-audio-becomes-mono-for-no-apparent-reason_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Using-_002df-lavfi_002c-audio-becomes-mono-for-no-apparent-reason_002e" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Use <samp>-dumpgraph -</samp> to find out exactly where the channel layout is
|
||||
lost.
|
||||
</p>
|
||||
<p>Most likely, it is through <code>auto-inserted aresample</code>. Try to understand
|
||||
why the converting filter was needed at that place.
|
||||
</p>
|
||||
<p>Just before the output is a likely place, as <samp>-f lavfi</samp> currently
|
||||
only support packed S16.
|
||||
</p>
|
||||
<p>Then insert the correct <code>aformat</code> explicitly in the filtergraph,
|
||||
specifying the exact format.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">aformat=sample_fmts=s16:channel_layouts=stereo
|
||||
</pre></div>
|
||||
|
||||
<a name="Why-does-FFmpeg-not-see-the-subtitles-in-my-VOB-file_003f"></a>
|
||||
<h3 class="section">3.16 Why does FFmpeg not see the subtitles in my VOB file?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-does-FFmpeg-not-see-the-subtitles-in-my-VOB-file_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-does-FFmpeg-not-see-the-subtitles-in-my-VOB-file_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>VOB and a few other formats do not have a global header that describes
|
||||
everything present in the file. Instead, applications are supposed to scan
|
||||
the file to see what it contains. Since VOB files are frequently large, only
|
||||
the beginning is scanned. If the subtitles happen only later in the file,
|
||||
they will not be initially detected.
|
||||
</p>
|
||||
<p>Some applications, including the <code>ffmpeg</code> command-line tool, can only
|
||||
work with streams that were detected during the initial scan; streams that
|
||||
are detected later are ignored.
|
||||
</p>
|
||||
<p>The size of the initial scan is controlled by two options: <code>probesize</code>
|
||||
(default ~5 Mo) and <code>analyzeduration</code> (default 5,000,000 µs = 5 s). For
|
||||
the subtitle stream to be detected, both values must be large enough.
|
||||
</p>
|
||||
<a name="Why-was-the-ffmpeg-_002dsameq-option-removed_003f-What-to-use-instead_003f"></a>
|
||||
<h3 class="section">3.17 Why was the <code>ffmpeg</code> <samp>-sameq</samp> option removed? What to use instead?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-was-the-ffmpeg-_002dsameq-option-removed_003f-What-to-use-instead_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-was-the-ffmpeg-_002dsameq-option-removed_003f-What-to-use-instead_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>The <samp>-sameq</samp> option meant "same quantizer", and made sense only in a
|
||||
very limited set of cases. Unfortunately, a lot of people mistook it for
|
||||
"same quality" and used it in places where it did not make sense: it had
|
||||
roughly the expected visible effect, but achieved it in a very inefficient
|
||||
way.
|
||||
</p>
|
||||
<p>Each encoder has its own set of options to set the quality-vs-size balance,
|
||||
use the options for the encoder you are using to set the quality level to a
|
||||
point acceptable for your tastes. The most common options to do that are
|
||||
<samp>-qscale</samp> and <samp>-qmax</samp>, but you should peruse the documentation
|
||||
of the encoder you chose.
|
||||
</p>
|
||||
<a name="I-have-a-stretched-video_002c-why-does-scaling-does-not-fix-it_003f"></a>
|
||||
<h3 class="section">3.18 I have a stretched video, why does scaling does not fix it?<span class="pull-right"><a class="anchor hidden-xs" href="#I-have-a-stretched-video_002c-why-does-scaling-does-not-fix-it_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I-have-a-stretched-video_002c-why-does-scaling-does-not-fix-it_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>A lot of video codecs and formats can store the <em>aspect ratio</em> of the
|
||||
video: this is the ratio between the width and the height of either the full
|
||||
image (DAR, display aspect ratio) or individual pixels (SAR, sample aspect
|
||||
ratio). For example, EGA screens at resolution 640×350 had 4:3 DAR and 35:48
|
||||
SAR.
|
||||
</p>
|
||||
<p>Most still image processing work with square pixels, i.e. 1:1 SAR, but a lot
|
||||
of video standards, especially from the analogic-numeric transition era, use
|
||||
non-square pixels.
|
||||
</p>
|
||||
<p>Most processing filters in FFmpeg handle the aspect ratio to avoid
|
||||
stretching the image: cropping adjusts the DAR to keep the SAR constant,
|
||||
scaling adjusts the SAR to keep the DAR constant.
|
||||
</p>
|
||||
<p>If you want to stretch, or “unstretch”, the image, you need to override the
|
||||
information with the
|
||||
<a href="ffmpeg-filters.html#setdar_002c-setsar"><code>setdar or setsar filters</code></a>.
|
||||
</p>
|
||||
<p>Do not forget to examine carefully the original video to check whether the
|
||||
stretching comes from the image or from the aspect ratio information.
|
||||
</p>
|
||||
<p>For example, to fix a badly encoded EGA capture, use the following commands,
|
||||
either the first one to upscale to square pixels or the second one to set
|
||||
the correct aspect ratio or the third one to avoid transcoding (may not work
|
||||
depending on the format / codec / player / phase of the moon):
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -i ega_screen.nut -vf scale=640:480,setsar=1 ega_screen_scaled.nut
|
||||
ffmpeg -i ega_screen.nut -vf setdar=4/3 ega_screen_anamorphic.nut
|
||||
ffmpeg -i ega_screen.nut -aspect 4/3 -c copy ega_screen_overridden.nut
|
||||
</pre></div>
|
||||
|
||||
<a name="Development"></a>
|
||||
<h2 class="chapter">4 Development<span class="pull-right"><a class="anchor hidden-xs" href="#Development" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Development" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<a name="Are-there-examples-illustrating-how-to-use-the-FFmpeg-libraries_002c-particularly-libavcodec-and-libavformat_003f"></a>
|
||||
<h3 class="section">4.1 Are there examples illustrating how to use the FFmpeg libraries, particularly libavcodec and libavformat?<span class="pull-right"><a class="anchor hidden-xs" href="#Are-there-examples-illustrating-how-to-use-the-FFmpeg-libraries_002c-particularly-libavcodec-and-libavformat_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Are-there-examples-illustrating-how-to-use-the-FFmpeg-libraries_002c-particularly-libavcodec-and-libavformat_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Yes. Check the <samp>doc/examples</samp> directory in the source
|
||||
repository, also available online at:
|
||||
<a href="https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples">https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples</a>.
|
||||
</p>
|
||||
<p>Examples are also installed by default, usually in
|
||||
<code>$PREFIX/share/ffmpeg/examples</code>.
|
||||
</p>
|
||||
<p>Also you may read the Developers Guide of the FFmpeg documentation. Alternatively,
|
||||
examine the source code for one of the many open source projects that
|
||||
already incorporate FFmpeg at (<a href="projects.html">projects.html</a>).
|
||||
</p>
|
||||
<a name="Can-you-support-my-C-compiler-XXX_003f"></a>
|
||||
<h3 class="section">4.2 Can you support my C compiler XXX?<span class="pull-right"><a class="anchor hidden-xs" href="#Can-you-support-my-C-compiler-XXX_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Can-you-support-my-C-compiler-XXX_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>It depends. If your compiler is C99-compliant, then patches to support
|
||||
it are likely to be welcome if they do not pollute the source code
|
||||
with <code>#ifdef</code>s related to the compiler.
|
||||
</p>
|
||||
<a name="Is-Microsoft-Visual-C_002b_002b-supported_003f"></a>
|
||||
<h3 class="section">4.3 Is Microsoft Visual C++ supported?<span class="pull-right"><a class="anchor hidden-xs" href="#Is-Microsoft-Visual-C_002b_002b-supported_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Is-Microsoft-Visual-C_002b_002b-supported_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Yes. Please see the <a href="platform.html">Microsoft Visual C++</a>
|
||||
section in the FFmpeg documentation.
|
||||
</p>
|
||||
<a name="Can-you-add-automake_002c-libtool-or-autoconf-support_003f"></a>
|
||||
<h3 class="section">4.4 Can you add automake, libtool or autoconf support?<span class="pull-right"><a class="anchor hidden-xs" href="#Can-you-add-automake_002c-libtool-or-autoconf-support_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Can-you-add-automake_002c-libtool-or-autoconf-support_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>No. These tools are too bloated and they complicate the build.
|
||||
</p>
|
||||
<a name="Why-not-rewrite-FFmpeg-in-object_002doriented-C_002b_002b_003f"></a>
|
||||
<h3 class="section">4.5 Why not rewrite FFmpeg in object-oriented C++?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-not-rewrite-FFmpeg-in-object_002doriented-C_002b_002b_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-not-rewrite-FFmpeg-in-object_002doriented-C_002b_002b_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>FFmpeg is already organized in a highly modular manner and does not need to
|
||||
be rewritten in a formal object language. Further, many of the developers
|
||||
favor straight C; it works for them. For more arguments on this matter,
|
||||
read <a href="http://www.tux.org/lkml/#s15">"Programming Religion"</a>.
|
||||
</p>
|
||||
<a name="Why-are-the-ffmpeg-programs-devoid-of-debugging-symbols_003f"></a>
|
||||
<h3 class="section">4.6 Why are the ffmpeg programs devoid of debugging symbols?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-are-the-ffmpeg-programs-devoid-of-debugging-symbols_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-are-the-ffmpeg-programs-devoid-of-debugging-symbols_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>The build process creates <code>ffmpeg_g</code>, <code>ffplay_g</code>, etc. which
|
||||
contain full debug information. Those binaries are stripped to create
|
||||
<code>ffmpeg</code>, <code>ffplay</code>, etc. If you need the debug information, use
|
||||
the *_g versions.
|
||||
</p>
|
||||
<a name="I-do-not-like-the-LGPL_002c-can-I-contribute-code-under-the-GPL-instead_003f"></a>
|
||||
<h3 class="section">4.7 I do not like the LGPL, can I contribute code under the GPL instead?<span class="pull-right"><a class="anchor hidden-xs" href="#I-do-not-like-the-LGPL_002c-can-I-contribute-code-under-the-GPL-instead_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I-do-not-like-the-LGPL_002c-can-I-contribute-code-under-the-GPL-instead_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Yes, as long as the code is optional and can easily and cleanly be placed
|
||||
under #if CONFIG_GPL without breaking anything. So, for example, a new codec
|
||||
or filter would be OK under GPL while a bug fix to LGPL code would not.
|
||||
</p>
|
||||
<a name="I_0027m-using-FFmpeg-from-within-my-C-application-but-the-linker-complains-about-missing-symbols-from-the-libraries-themselves_002e"></a>
|
||||
<h3 class="section">4.8 I’m using FFmpeg from within my C application but the linker complains about missing symbols from the libraries themselves.<span class="pull-right"><a class="anchor hidden-xs" href="#I_0027m-using-FFmpeg-from-within-my-C-application-but-the-linker-complains-about-missing-symbols-from-the-libraries-themselves_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I_0027m-using-FFmpeg-from-within-my-C-application-but-the-linker-complains-about-missing-symbols-from-the-libraries-themselves_002e" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>FFmpeg builds static libraries by default. In static libraries, dependencies
|
||||
are not handled. That has two consequences. First, you must specify the
|
||||
libraries in dependency order: <code>-lavdevice</code> must come before
|
||||
<code>-lavformat</code>, <code>-lavutil</code> must come after everything else, etc.
|
||||
Second, external libraries that are used in FFmpeg have to be specified too.
|
||||
</p>
|
||||
<p>An easy way to get the full list of required libraries in dependency order
|
||||
is to use <code>pkg-config</code>.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">c99 -o program program.c $(pkg-config --cflags --libs libavformat libavcodec)
|
||||
</pre></div>
|
||||
|
||||
<p>See <samp>doc/example/Makefile</samp> and <samp>doc/example/pc-uninstalled</samp> for
|
||||
more details.
|
||||
</p>
|
||||
<a name="I_0027m-using-FFmpeg-from-within-my-C_002b_002b-application-but-the-linker-complains-about-missing-symbols-which-seem-to-be-available_002e"></a>
|
||||
<h3 class="section">4.9 I’m using FFmpeg from within my C++ application but the linker complains about missing symbols which seem to be available.<span class="pull-right"><a class="anchor hidden-xs" href="#I_0027m-using-FFmpeg-from-within-my-C_002b_002b-application-but-the-linker-complains-about-missing-symbols-which-seem-to-be-available_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I_0027m-using-FFmpeg-from-within-my-C_002b_002b-application-but-the-linker-complains-about-missing-symbols-which-seem-to-be-available_002e" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>FFmpeg is a pure C project, so to use the libraries within your C++ application
|
||||
you need to explicitly state that you are using a C library. You can do this by
|
||||
encompassing your FFmpeg includes using <code>extern "C"</code>.
|
||||
</p>
|
||||
<p>See <a href="http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html#faq-32.3">http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html#faq-32.3</a>
|
||||
</p>
|
||||
<a name="I_0027m-using-libavutil-from-within-my-C_002b_002b-application-but-the-compiler-complains-about-_0027UINT64_005fC_0027-was-not-declared-in-this-scope"></a>
|
||||
<h3 class="section">4.10 I’m using libavutil from within my C++ application but the compiler complains about ’UINT64_C’ was not declared in this scope<span class="pull-right"><a class="anchor hidden-xs" href="#I_0027m-using-libavutil-from-within-my-C_002b_002b-application-but-the-compiler-complains-about-_0027UINT64_005fC_0027-was-not-declared-in-this-scope" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I_0027m-using-libavutil-from-within-my-C_002b_002b-application-but-the-compiler-complains-about-_0027UINT64_005fC_0027-was-not-declared-in-this-scope" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>FFmpeg is a pure C project using C99 math features, in order to enable C++
|
||||
to use them you have to append -D__STDC_CONSTANT_MACROS to your CXXFLAGS
|
||||
</p>
|
||||
<a name="I-have-a-file-in-memory-_002f-a-API-different-from-_002aopen_002f_002aread_002f-libc-how-do-I-use-it-with-libavformat_003f"></a>
|
||||
<h3 class="section">4.11 I have a file in memory / a API different from *open/*read/ libc how do I use it with libavformat?<span class="pull-right"><a class="anchor hidden-xs" href="#I-have-a-file-in-memory-_002f-a-API-different-from-_002aopen_002f_002aread_002f-libc-how-do-I-use-it-with-libavformat_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I-have-a-file-in-memory-_002f-a-API-different-from-_002aopen_002f_002aread_002f-libc-how-do-I-use-it-with-libavformat_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>You have to create a custom AVIOContext using <code>avio_alloc_context</code>,
|
||||
see <samp>libavformat/aviobuf.c</samp> in FFmpeg and <samp>libmpdemux/demux_lavf.c</samp> in MPlayer or MPlayer2 sources.
|
||||
</p>
|
||||
<a name="Where-is-the-documentation-about-ffv1_002c-msmpeg4_002c-asv1_002c-4xm_003f"></a>
|
||||
<h3 class="section">4.12 Where is the documentation about ffv1, msmpeg4, asv1, 4xm?<span class="pull-right"><a class="anchor hidden-xs" href="#Where-is-the-documentation-about-ffv1_002c-msmpeg4_002c-asv1_002c-4xm_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Where-is-the-documentation-about-ffv1_002c-msmpeg4_002c-asv1_002c-4xm_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>see <a href="https://www.ffmpeg.org/~michael/">https://www.ffmpeg.org/~michael/</a>
|
||||
</p>
|
||||
<a name="How-do-I-feed-H_002e263_002dRTP-_0028and-other-codecs-in-RTP_0029-to-libavcodec_003f"></a>
|
||||
<h3 class="section">4.13 How do I feed H.263-RTP (and other codecs in RTP) to libavcodec?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-feed-H_002e263_002dRTP-_0028and-other-codecs-in-RTP_0029-to-libavcodec_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-feed-H_002e263_002dRTP-_0028and-other-codecs-in-RTP_0029-to-libavcodec_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Even if peculiar since it is network oriented, RTP is a container like any
|
||||
other. You have to <em>demux</em> RTP before feeding the payload to libavcodec.
|
||||
In this specific case please look at RFC 4629 to see how it should be done.
|
||||
</p>
|
||||
<a name="AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e"></a>
|
||||
<h3 class="section">4.14 AVStream.r_frame_rate is wrong, it is much larger than the frame rate.<span class="pull-right"><a class="anchor hidden-xs" href="#AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p><code>r_frame_rate</code> is NOT the average frame rate, it is the smallest frame rate
|
||||
that can accurately represent all timestamps. So no, it is not
|
||||
wrong if it is larger than the average!
|
||||
For example, if you have mixed 25 and 30 fps content, then <code>r_frame_rate</code>
|
||||
will be 150 (it is the least common multiple).
|
||||
If you are looking for the average frame rate, see <code>AVStream.avg_frame_rate</code>.
|
||||
</p>
|
||||
<a name="Why-is-make-fate-not-running-all-tests_003f"></a>
|
||||
<h3 class="section">4.15 Why is <code>make fate</code> not running all tests?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-is-make-fate-not-running-all-tests_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-is-make-fate-not-running-all-tests_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Make sure you have the fate-suite samples and the <code>SAMPLES</code> Make variable
|
||||
or <code>FATE_SAMPLES</code> environment variable or the <code>--samples</code>
|
||||
<code>configure</code> option is set to the right path.
|
||||
</p>
|
||||
<a name="Why-is-make-fate-not-finding-the-samples_003f"></a>
|
||||
<h3 class="section">4.16 Why is <code>make fate</code> not finding the samples?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-is-make-fate-not-finding-the-samples_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-is-make-fate-not-finding-the-samples_003f" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Do you happen to have a <code>~</code> character in the samples path to indicate a
|
||||
home directory? The value is used in ways where the shell cannot expand it,
|
||||
causing FATE to not find files. Just replace <code>~</code> by the full path.
|
||||
</p>
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,288 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
FFmpeg Automated Testing Environment
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
FFmpeg Automated Testing Environment
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Top"></a>
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Introduction" href="#Introduction">1 Introduction</a></li>
|
||||
<li><a name="toc-Using-FATE-from-your-FFmpeg-source-directory" href="#Using-FATE-from-your-FFmpeg-source-directory">2 Using FATE from your FFmpeg source directory</a></li>
|
||||
<li><a name="toc-Submitting-the-results-to-the-FFmpeg-result-aggregation-server" href="#Submitting-the-results-to-the-FFmpeg-result-aggregation-server">3 Submitting the results to the FFmpeg result aggregation server</a></li>
|
||||
<li><a name="toc-FATE-makefile-targets-and-variables" href="#FATE-makefile-targets-and-variables">4 FATE makefile targets and variables</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Makefile-targets" href="#Makefile-targets">4.1 Makefile targets</a></li>
|
||||
<li><a name="toc-Makefile-variables" href="#Makefile-variables">4.2 Makefile variables</a></li>
|
||||
<li><a name="toc-Examples" href="#Examples">4.3 Examples</a></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Introduction"></a>
|
||||
<h2 class="chapter">1 Introduction<span class="pull-right"><a class="anchor hidden-xs" href="#Introduction" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Introduction" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>FATE is an extended regression suite on the client-side and a means
|
||||
for results aggregation and presentation on the server-side.
|
||||
</p>
|
||||
<p>The first part of this document explains how you can use FATE from
|
||||
your FFmpeg source directory to test your ffmpeg binary. The second
|
||||
part describes how you can run FATE to submit the results to FFmpeg’s
|
||||
FATE server.
|
||||
</p>
|
||||
<p>In any way you can have a look at the publicly viewable FATE results
|
||||
by visiting this website:
|
||||
</p>
|
||||
<p><a href="http://fate.ffmpeg.org/">http://fate.ffmpeg.org/</a>
|
||||
</p>
|
||||
<p>This is especially recommended for all people contributing source
|
||||
code to FFmpeg, as it can be seen if some test on some platform broke
|
||||
with their recent contribution. This usually happens on the platforms
|
||||
the developers could not test on.
|
||||
</p>
|
||||
<p>The second part of this document describes how you can run FATE to
|
||||
submit your results to FFmpeg’s FATE server. If you want to submit your
|
||||
results be sure to check that your combination of CPU, OS and compiler
|
||||
is not already listed on the above mentioned website.
|
||||
</p>
|
||||
<p>In the third part you can find a comprehensive listing of FATE makefile
|
||||
targets and variables.
|
||||
</p>
|
||||
|
||||
<a name="Using-FATE-from-your-FFmpeg-source-directory"></a>
|
||||
<h2 class="chapter">2 Using FATE from your FFmpeg source directory<span class="pull-right"><a class="anchor hidden-xs" href="#Using-FATE-from-your-FFmpeg-source-directory" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Using-FATE-from-your-FFmpeg-source-directory" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>If you want to run FATE on your machine you need to have the samples
|
||||
in place. You can get the samples via the build target fate-rsync.
|
||||
Use this command from the top-level source directory:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">make fate-rsync SAMPLES=fate-suite/
|
||||
make fate SAMPLES=fate-suite/
|
||||
</pre></div>
|
||||
|
||||
<p>The above commands set the samples location by passing a makefile
|
||||
variable via command line. It is also possible to set the samples
|
||||
location at source configuration time by invoking configure with
|
||||
<samp>--samples=<path to the samples directory></samp>. Afterwards you can
|
||||
invoke the makefile targets without setting the <var>SAMPLES</var> makefile
|
||||
variable. This is illustrated by the following commands:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">./configure --samples=fate-suite/
|
||||
make fate-rsync
|
||||
make fate
|
||||
</pre></div>
|
||||
|
||||
<p>Yet another way to tell FATE about the location of the sample
|
||||
directory is by making sure the environment variable FATE_SAMPLES
|
||||
contains the path to your samples directory. This can be achieved
|
||||
by e.g. putting that variable in your shell profile or by setting
|
||||
it in your interactive session.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">FATE_SAMPLES=fate-suite/ make fate
|
||||
</pre></div>
|
||||
|
||||
<div class="info">
|
||||
<p>Do not put a ’~’ character in the samples path to indicate a home
|
||||
directory. Because of shell nuances, this will cause FATE to fail.
|
||||
</p></div>
|
||||
<p>To use a custom wrapper to run the test, pass <samp>--target-exec</samp> to
|
||||
<code>configure</code> or set the <var>TARGET_EXEC</var> Make variable.
|
||||
</p>
|
||||
|
||||
<a name="Submitting-the-results-to-the-FFmpeg-result-aggregation-server"></a>
|
||||
<h2 class="chapter">3 Submitting the results to the FFmpeg result aggregation server<span class="pull-right"><a class="anchor hidden-xs" href="#Submitting-the-results-to-the-FFmpeg-result-aggregation-server" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Submitting-the-results-to-the-FFmpeg-result-aggregation-server" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>To submit your results to the server you should run fate through the
|
||||
shell script <samp>tests/fate.sh</samp> from the FFmpeg sources. This script needs
|
||||
to be invoked with a configuration file as its first argument.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">tests/fate.sh /path/to/fate_config
|
||||
</pre></div>
|
||||
|
||||
<p>A configuration file template with comments describing the individual
|
||||
configuration variables can be found at <samp>doc/fate_config.sh.template</samp>.
|
||||
</p>
|
||||
<p>The mentioned configuration template is also available here:
|
||||
</p><pre class="verbatim">slot= # some unique identifier
|
||||
repo=git://source.ffmpeg.org/ffmpeg.git # the source repository
|
||||
#branch=release/2.6 # the branch to test
|
||||
samples= # path to samples directory
|
||||
workdir= # directory in which to do all the work
|
||||
#fate_recv="ssh -T fate@fate.ffmpeg.org" # command to submit report
|
||||
comment= # optional description
|
||||
build_only= # set to "yes" for a compile-only instance that skips tests
|
||||
|
||||
# the following are optional and map to configure options
|
||||
arch=
|
||||
cpu=
|
||||
cross_prefix=
|
||||
as=
|
||||
cc=
|
||||
ld=
|
||||
target_os=
|
||||
sysroot=
|
||||
target_exec=
|
||||
target_path=
|
||||
target_samples=
|
||||
extra_cflags=
|
||||
extra_ldflags=
|
||||
extra_libs=
|
||||
extra_conf= # extra configure options not covered above
|
||||
|
||||
#make= # name of GNU make if not 'make'
|
||||
makeopts= # extra options passed to 'make'
|
||||
#tar= # command to create a tar archive from its arguments on stdout,
|
||||
# defaults to 'tar c'
|
||||
</pre>
|
||||
<p>Create a configuration that suits your needs, based on the configuration
|
||||
template. The <code>slot</code> configuration variable can be any string that is not
|
||||
yet used, but it is suggested that you name it adhering to the following
|
||||
pattern ‘<samp><var>arch</var>-<var>os</var>-<var>compiler</var>-<var>compiler version</var></samp>’. The
|
||||
configuration file itself will be sourced in a shell script, therefore all
|
||||
shell features may be used. This enables you to setup the environment as you
|
||||
need it for your build.
|
||||
</p>
|
||||
<p>For your first test runs the <code>fate_recv</code> variable should be empty or
|
||||
commented out. This will run everything as normal except that it will omit
|
||||
the submission of the results to the server. The following files should be
|
||||
present in $workdir as specified in the configuration file:
|
||||
</p>
|
||||
<ul>
|
||||
<li> configure.log
|
||||
</li><li> compile.log
|
||||
</li><li> test.log
|
||||
</li><li> report
|
||||
</li><li> version
|
||||
</li></ul>
|
||||
|
||||
<p>When you have everything working properly you can create an SSH key pair
|
||||
and send the public key to the FATE server administrator who can be contacted
|
||||
at the email address <a href="mailto:fate-admin@ffmpeg.org">fate-admin@ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Configure your SSH client to use public key authentication with that key
|
||||
when connecting to the FATE server. Also do not forget to check the identity
|
||||
of the server and to accept its host key. This can usually be achieved by
|
||||
running your SSH client manually and killing it after you accepted the key.
|
||||
The FATE server’s fingerprint is:
|
||||
</p>
|
||||
<dl compact="compact">
|
||||
<dt>‘<samp>RSA</samp>’</dt>
|
||||
<dd><p>d3:f1:83:97:a4:75:2b:a6:fb:d6:e8:aa:81:93:97:51
|
||||
</p></dd>
|
||||
<dt>‘<samp>ECDSA</samp>’</dt>
|
||||
<dd><p>76:9f:68:32:04:1e:d5:d4:ec:47:3f:dc:fc:18:17:86
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<p>If you have problems connecting to the FATE server, it may help to try out
|
||||
the <code>ssh</code> command with one or more <samp>-v</samp> options. You should
|
||||
get detailed output concerning your SSH configuration and the authentication
|
||||
process.
|
||||
</p>
|
||||
<p>The only thing left is to automate the execution of the fate.sh script and
|
||||
the synchronisation of the samples directory.
|
||||
</p>
|
||||
|
||||
<a name="FATE-makefile-targets-and-variables"></a>
|
||||
<h2 class="chapter">4 FATE makefile targets and variables<span class="pull-right"><a class="anchor hidden-xs" href="#FATE-makefile-targets-and-variables" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-FATE-makefile-targets-and-variables" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<a name="Makefile-targets"></a>
|
||||
<h3 class="section">4.1 Makefile targets<span class="pull-right"><a class="anchor hidden-xs" href="#Makefile-targets" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Makefile-targets" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<dl compact="compact">
|
||||
<dt><samp>fate-rsync</samp></dt>
|
||||
<dd><p>Download/synchronize sample files to the configured samples directory.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>fate-list</samp></dt>
|
||||
<dd><p>Will list all fate/regression test targets.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>fate</samp></dt>
|
||||
<dd><p>Run the FATE test suite (requires the fate-suite dataset).
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<a name="Makefile-variables"></a>
|
||||
<h3 class="section">4.2 Makefile variables<span class="pull-right"><a class="anchor hidden-xs" href="#Makefile-variables" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Makefile-variables" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<dl compact="compact">
|
||||
<dt><code>V</code></dt>
|
||||
<dd><p>Verbosity level, can be set to 0, 1 or 2.
|
||||
</p><ul>
|
||||
<li> 0: show just the test arguments
|
||||
</li><li> 1: show just the command used in the test
|
||||
</li><li> 2: show everything
|
||||
</li></ul>
|
||||
|
||||
</dd>
|
||||
<dt><code>SAMPLES</code></dt>
|
||||
<dd><p>Specify or override the path to the FATE samples at make time, it has a
|
||||
meaning only while running the regression tests.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><code>THREADS</code></dt>
|
||||
<dd><p>Specify how many threads to use while running regression tests, it is
|
||||
quite useful to detect thread-related regressions.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><code>THREAD_TYPE</code></dt>
|
||||
<dd><p>Specify which threading strategy test, either ‘<samp>slice</samp>’ or ‘<samp>frame</samp>’,
|
||||
by default ‘<samp>slice+frame</samp>’
|
||||
</p>
|
||||
</dd>
|
||||
<dt><code>CPUFLAGS</code></dt>
|
||||
<dd><p>Specify CPU flags.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><code>TARGET_EXEC</code></dt>
|
||||
<dd><p>Specify or override the wrapper used to run the tests.
|
||||
The <code>TARGET_EXEC</code> option provides a way to run FATE wrapped in
|
||||
<code>valgrind</code>, <code>qemu-user</code> or <code>wine</code> or on remote targets
|
||||
through <code>ssh</code>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><code>GEN</code></dt>
|
||||
<dd><p>Set to ‘<samp>1</samp>’ to generate the missing or mismatched references.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<a name="Examples"></a>
|
||||
<h3 class="section">4.3 Examples<span class="pull-right"><a class="anchor hidden-xs" href="#Examples" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Examples" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">make V=1 SAMPLES=/var/fate/samples THREADS=2 CPUFLAGS=mmx fate
|
||||
</pre></div>
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
@ -1,290 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
FFmpeg Bitstream Filters Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
FFmpeg Bitstream Filters Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Description" href="#Description">1 Description</a></li>
|
||||
<li><a name="toc-Bitstream-Filters" href="#Bitstream-Filters">2 Bitstream Filters</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-aac_005fadtstoasc" href="#aac_005fadtstoasc">2.1 aac_adtstoasc</a></li>
|
||||
<li><a name="toc-chomp" href="#chomp">2.2 chomp</a></li>
|
||||
<li><a name="toc-dump_005fextra" href="#dump_005fextra">2.3 dump_extra</a></li>
|
||||
<li><a name="toc-dca_005fcore" href="#dca_005fcore">2.4 dca_core</a></li>
|
||||
<li><a name="toc-h264_005fmp4toannexb" href="#h264_005fmp4toannexb">2.5 h264_mp4toannexb</a></li>
|
||||
<li><a name="toc-imxdump" href="#imxdump">2.6 imxdump</a></li>
|
||||
<li><a name="toc-mjpeg2jpeg" href="#mjpeg2jpeg">2.7 mjpeg2jpeg</a></li>
|
||||
<li><a name="toc-mjpega_005fdump_005fheader" href="#mjpega_005fdump_005fheader">2.8 mjpega_dump_header</a></li>
|
||||
<li><a name="toc-movsub" href="#movsub">2.9 movsub</a></li>
|
||||
<li><a name="toc-mp3_005fheader_005fdecompress" href="#mp3_005fheader_005fdecompress">2.10 mp3_header_decompress</a></li>
|
||||
<li><a name="toc-mpeg4_005funpack_005fbframes" href="#mpeg4_005funpack_005fbframes">2.11 mpeg4_unpack_bframes</a></li>
|
||||
<li><a name="toc-noise" href="#noise">2.12 noise</a></li>
|
||||
<li><a name="toc-remove_005fextra" href="#remove_005fextra">2.13 remove_extra</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-See-Also" href="#See-Also">3 See Also</a></li>
|
||||
<li><a name="toc-Authors" href="#Authors">4 Authors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">1 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>This document describes the bitstream filters provided by the
|
||||
libavcodec library.
|
||||
</p>
|
||||
<p>A bitstream filter operates on the encoded stream data, and performs
|
||||
bitstream level modifications without performing decoding.
|
||||
</p>
|
||||
|
||||
<a name="Bitstream-Filters"></a>
|
||||
<h2 class="chapter">2 Bitstream Filters<span class="pull-right"><a class="anchor hidden-xs" href="#Bitstream-Filters" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Bitstream-Filters" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>When you configure your FFmpeg build, all the supported bitstream
|
||||
filters are enabled by default. You can list all available ones using
|
||||
the configure option <code>--list-bsfs</code>.
|
||||
</p>
|
||||
<p>You can disable all the bitstream filters using the configure option
|
||||
<code>--disable-bsfs</code>, and selectively enable any bitstream filter using
|
||||
the option <code>--enable-bsf=BSF</code>, or you can disable a particular
|
||||
bitstream filter using the option <code>--disable-bsf=BSF</code>.
|
||||
</p>
|
||||
<p>The option <code>-bsfs</code> of the ff* tools will display the list of
|
||||
all the supported bitstream filters included in your build.
|
||||
</p>
|
||||
<p>The ff* tools have a -bsf option applied per stream, taking a
|
||||
comma-separated list of filters, whose parameters follow the filter
|
||||
name after a ’=’.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1:opt2=str2][,filter2] OUTPUT
|
||||
</pre></div>
|
||||
|
||||
<p>Below is a description of the currently available bitstream filters,
|
||||
with their parameters, if any.
|
||||
</p>
|
||||
<a name="aac_005fadtstoasc"></a>
|
||||
<h3 class="section">2.1 aac_adtstoasc<span class="pull-right"><a class="anchor hidden-xs" href="#aac_005fadtstoasc" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-aac_005fadtstoasc" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Convert MPEG-2/4 AAC ADTS to MPEG-4 Audio Specific Configuration
|
||||
bitstream filter.
|
||||
</p>
|
||||
<p>This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
|
||||
ADTS header and removes the ADTS header.
|
||||
</p>
|
||||
<p>This is required for example when copying an AAC stream from a raw
|
||||
ADTS AAC container to a FLV or a MOV/MP4 file.
|
||||
</p>
|
||||
<a name="chomp"></a>
|
||||
<h3 class="section">2.2 chomp<span class="pull-right"><a class="anchor hidden-xs" href="#chomp" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-chomp" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Remove zero padding at the end of a packet.
|
||||
</p>
|
||||
<a name="dump_005fextra"></a>
|
||||
<h3 class="section">2.3 dump_extra<span class="pull-right"><a class="anchor hidden-xs" href="#dump_005fextra" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-dump_005fextra" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Add extradata to the beginning of the filtered packets.
|
||||
</p>
|
||||
<p>The additional argument specifies which packets should be filtered.
|
||||
It accepts the values:
|
||||
</p><dl compact="compact">
|
||||
<dt>‘<samp>a</samp>’</dt>
|
||||
<dd><p>add extradata to all key packets, but only if <var>local_header</var> is
|
||||
set in the <samp>flags2</samp> codec context field
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>k</samp>’</dt>
|
||||
<dd><p>add extradata to all key packets
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>e</samp>’</dt>
|
||||
<dd><p>add extradata to all packets
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<p>If not specified it is assumed ‘<samp>k</samp>’.
|
||||
</p>
|
||||
<p>For example the following <code>ffmpeg</code> command forces a global
|
||||
header (thus disabling individual packet headers) in the H.264 packets
|
||||
generated by the <code>libx264</code> encoder, but corrects them by adding
|
||||
the header stored in extradata to the key packets:
|
||||
</p><div class="example">
|
||||
<pre class="example">ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
|
||||
</pre></div>
|
||||
|
||||
<a name="dca_005fcore"></a>
|
||||
<h3 class="section">2.4 dca_core<span class="pull-right"><a class="anchor hidden-xs" href="#dca_005fcore" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-dca_005fcore" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Extract DCA core from DTS-HD streams.
|
||||
</p>
|
||||
<a name="h264_005fmp4toannexb"></a>
|
||||
<h3 class="section">2.5 h264_mp4toannexb<span class="pull-right"><a class="anchor hidden-xs" href="#h264_005fmp4toannexb" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-h264_005fmp4toannexb" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Convert an H.264 bitstream from length prefixed mode to start code
|
||||
prefixed mode (as defined in the Annex B of the ITU-T H.264
|
||||
specification).
|
||||
</p>
|
||||
<p>This is required by some streaming formats, typically the MPEG-2
|
||||
transport stream format ("mpegts").
|
||||
</p>
|
||||
<p>For example to remux an MP4 file containing an H.264 stream to mpegts
|
||||
format with <code>ffmpeg</code>, you can use the command:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
|
||||
</pre></div>
|
||||
|
||||
<a name="imxdump"></a>
|
||||
<h3 class="section">2.6 imxdump<span class="pull-right"><a class="anchor hidden-xs" href="#imxdump" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-imxdump" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Modifies the bitstream to fit in MOV and to be usable by the Final Cut
|
||||
Pro decoder. This filter only applies to the mpeg2video codec, and is
|
||||
likely not needed for Final Cut Pro 7 and newer with the appropriate
|
||||
<samp>-tag:v</samp>.
|
||||
</p>
|
||||
<p>For example, to remux 30 MB/sec NTSC IMX to MOV:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
|
||||
</pre></div>
|
||||
|
||||
<a name="mjpeg2jpeg"></a>
|
||||
<h3 class="section">2.7 mjpeg2jpeg<span class="pull-right"><a class="anchor hidden-xs" href="#mjpeg2jpeg" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-mjpeg2jpeg" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
|
||||
</p>
|
||||
<p>MJPEG is a video codec wherein each video frame is essentially a
|
||||
JPEG image. The individual frames can be extracted without loss,
|
||||
e.g. by
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
|
||||
</pre></div>
|
||||
|
||||
<p>Unfortunately, these chunks are incomplete JPEG images, because
|
||||
they lack the DHT segment required for decoding. Quoting from
|
||||
<a href="http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml">http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml</a>:
|
||||
</p>
|
||||
<p>Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
|
||||
commented that "MJPEG, or at least the MJPEG in AVIs having the
|
||||
MJPG fourcc, is restricted JPEG with a fixed – and *omitted* –
|
||||
Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
|
||||
and it must use basic Huffman encoding, not arithmetic or
|
||||
progressive. . . . You can indeed extract the MJPEG frames and
|
||||
decode them with a regular JPEG decoder, but you have to prepend
|
||||
the DHT segment to them, or else the decoder won’t have any idea
|
||||
how to decompress the data. The exact table necessary is given in
|
||||
the OpenDML spec."
|
||||
</p>
|
||||
<p>This bitstream filter patches the header of frames extracted from an MJPEG
|
||||
stream (carrying the AVI1 header ID and lacking a DHT segment) to
|
||||
produce fully qualified JPEG images.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
|
||||
exiftran -i -9 frame*.jpg
|
||||
ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
|
||||
</pre></div>
|
||||
|
||||
<a name="mjpega_005fdump_005fheader"></a>
|
||||
<h3 class="section">2.8 mjpega_dump_header<span class="pull-right"><a class="anchor hidden-xs" href="#mjpega_005fdump_005fheader" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-mjpega_005fdump_005fheader" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<a name="movsub"></a>
|
||||
<h3 class="section">2.9 movsub<span class="pull-right"><a class="anchor hidden-xs" href="#movsub" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-movsub" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<a name="mp3_005fheader_005fdecompress"></a>
|
||||
<h3 class="section">2.10 mp3_header_decompress<span class="pull-right"><a class="anchor hidden-xs" href="#mp3_005fheader_005fdecompress" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-mp3_005fheader_005fdecompress" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<a name="mpeg4_005funpack_005fbframes"></a>
|
||||
<h3 class="section">2.11 mpeg4_unpack_bframes<span class="pull-right"><a class="anchor hidden-xs" href="#mpeg4_005funpack_005fbframes" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-mpeg4_005funpack_005fbframes" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Unpack DivX-style packed B-frames.
|
||||
</p>
|
||||
<p>DivX-style packed B-frames are not valid MPEG-4 and were only a
|
||||
workaround for the broken Video for Windows subsystem.
|
||||
They use more space, can cause minor AV sync issues, require more
|
||||
CPU power to decode (unless the player has some decoded picture queue
|
||||
to compensate the 2,0,2,0 frame per packet style) and cause
|
||||
trouble if copied into a standard container like mp4 or mpeg-ps/ts,
|
||||
because MPEG-4 decoders may not be able to decode them, since they are
|
||||
not valid MPEG-4.
|
||||
</p>
|
||||
<p>For example to fix an AVI file containing an MPEG-4 stream with
|
||||
DivX-style packed B-frames using <code>ffmpeg</code>, you can use the command:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
|
||||
</pre></div>
|
||||
|
||||
<a name="noise"></a>
|
||||
<h3 class="section">2.12 noise<span class="pull-right"><a class="anchor hidden-xs" href="#noise" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-noise" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Damages the contents of packets without damaging the container. Can be
|
||||
used for fuzzing or testing error resilience/concealment.
|
||||
</p>
|
||||
<p>Parameters:
|
||||
A numeral string, whose value is related to how often output bytes will
|
||||
be modified. Therefore, values below or equal to 0 are forbidden, and
|
||||
the lower the more frequent bytes will be modified, with 1 meaning
|
||||
every byte is modified.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
|
||||
</pre></div>
|
||||
<p>applies the modification to every byte.
|
||||
</p>
|
||||
<a name="remove_005fextra"></a>
|
||||
<h3 class="section">2.13 remove_extra<span class="pull-right"><a class="anchor hidden-xs" href="#remove_005fextra" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-remove_005fextra" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
|
||||
<a name="See-Also"></a>
|
||||
<h2 class="chapter">3 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
|
||||
<a href="libavcodec.html">libavcodec</a>
|
||||
</p>
|
||||
|
||||
<a name="Authors"></a>
|
||||
<h2 class="chapter">4 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg developers.
|
||||
</p>
|
||||
<p>For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
<code>git log</code> in the FFmpeg source directory, or browsing the
|
||||
online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Maintainers for the specific components are listed in the file
|
||||
<samp>MAINTAINERS</samp> in the source code tree.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,364 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
FFmpeg Resampler Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
FFmpeg Resampler Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Description" href="#Description">1 Description</a></li>
|
||||
<li><a name="toc-Resampler-Options" href="#Resampler-Options">2 Resampler Options</a></li>
|
||||
<li><a name="toc-See-Also" href="#See-Also">3 See Also</a></li>
|
||||
<li><a name="toc-Authors" href="#Authors">4 Authors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">1 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg resampler provides a high-level interface to the
|
||||
libswresample library audio resampling utilities. In particular it
|
||||
allows one to perform audio resampling, audio channel layout rematrixing,
|
||||
and convert audio format and packing layout.
|
||||
</p>
|
||||
|
||||
<a name="Resampler-Options"></a>
|
||||
<h2 class="chapter">2 Resampler Options<span class="pull-right"><a class="anchor hidden-xs" href="#Resampler-Options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Resampler-Options" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The audio resampler supports the following named options.
|
||||
</p>
|
||||
<p>Options may be set by specifying -<var>option</var> <var>value</var> in the
|
||||
FFmpeg tools, <var>option</var>=<var>value</var> for the aresample filter,
|
||||
by setting the value explicitly in the
|
||||
<code>SwrContext</code> options or using the <samp>libavutil/opt.h</samp> API for
|
||||
programmatic use.
|
||||
</p>
|
||||
<dl compact="compact">
|
||||
<dt><samp>ich, in_channel_count</samp></dt>
|
||||
<dd><p>Set the number of input channels. Default value is 0. Setting this
|
||||
value is not mandatory if the corresponding channel layout
|
||||
<samp>in_channel_layout</samp> is set.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>och, out_channel_count</samp></dt>
|
||||
<dd><p>Set the number of output channels. Default value is 0. Setting this
|
||||
value is not mandatory if the corresponding channel layout
|
||||
<samp>out_channel_layout</samp> is set.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>uch, used_channel_count</samp></dt>
|
||||
<dd><p>Set the number of used input channels. Default value is 0. This option is
|
||||
only used for special remapping.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>isr, in_sample_rate</samp></dt>
|
||||
<dd><p>Set the input sample rate. Default value is 0.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>osr, out_sample_rate</samp></dt>
|
||||
<dd><p>Set the output sample rate. Default value is 0.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>isf, in_sample_fmt</samp></dt>
|
||||
<dd><p>Specify the input sample format. It is set by default to <code>none</code>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>osf, out_sample_fmt</samp></dt>
|
||||
<dd><p>Specify the output sample format. It is set by default to <code>none</code>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>tsf, internal_sample_fmt</samp></dt>
|
||||
<dd><p>Set the internal sample format. Default value is <code>none</code>.
|
||||
This will automatically be chosen when it is not explicitly set.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>icl, in_channel_layout</samp></dt>
|
||||
<dt><samp>ocl, out_channel_layout</samp></dt>
|
||||
<dd><p>Set the input/output channel layout.
|
||||
</p>
|
||||
<p>See <a href="ffmpeg-utils.html#channel-layout-syntax">(ffmpeg-utils)the Channel Layout section in the ffmpeg-utils(1) manual</a>
|
||||
for the required syntax.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>clev, center_mix_level</samp></dt>
|
||||
<dd><p>Set the center mix level. It is a value expressed in deciBel, and must be
|
||||
in the interval [-32,32].
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>slev, surround_mix_level</samp></dt>
|
||||
<dd><p>Set the surround mix level. It is a value expressed in deciBel, and must
|
||||
be in the interval [-32,32].
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>lfe_mix_level</samp></dt>
|
||||
<dd><p>Set LFE mix into non LFE level. It is used when there is a LFE input but no
|
||||
LFE output. It is a value expressed in deciBel, and must
|
||||
be in the interval [-32,32].
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>rmvol, rematrix_volume</samp></dt>
|
||||
<dd><p>Set rematrix volume. Default value is 1.0.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>rematrix_maxval</samp></dt>
|
||||
<dd><p>Set maximum output value for rematrixing.
|
||||
This can be used to prevent clipping vs. preventing volume reduction.
|
||||
A value of 1.0 prevents clipping.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>flags, swr_flags</samp></dt>
|
||||
<dd><p>Set flags used by the converter. Default value is 0.
|
||||
</p>
|
||||
<p>It supports the following individual flags:
|
||||
</p><dl compact="compact">
|
||||
<dt><samp>res</samp></dt>
|
||||
<dd><p>force resampling, this flag forces resampling to be used even when the
|
||||
input and output sample rates match.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
</dd>
|
||||
<dt><samp>dither_scale</samp></dt>
|
||||
<dd><p>Set the dither scale. Default value is 1.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>dither_method</samp></dt>
|
||||
<dd><p>Set dither method. Default value is 0.
|
||||
</p>
|
||||
<p>Supported values:
|
||||
</p><dl compact="compact">
|
||||
<dt>‘<samp>rectangular</samp>’</dt>
|
||||
<dd><p>select rectangular dither
|
||||
</p></dd>
|
||||
<dt>‘<samp>triangular</samp>’</dt>
|
||||
<dd><p>select triangular dither
|
||||
</p></dd>
|
||||
<dt>‘<samp>triangular_hp</samp>’</dt>
|
||||
<dd><p>select triangular dither with high pass
|
||||
</p></dd>
|
||||
<dt>‘<samp>lipshitz</samp>’</dt>
|
||||
<dd><p>select Lipshitz noise shaping dither.
|
||||
</p></dd>
|
||||
<dt>‘<samp>shibata</samp>’</dt>
|
||||
<dd><p>select Shibata noise shaping dither.
|
||||
</p></dd>
|
||||
<dt>‘<samp>low_shibata</samp>’</dt>
|
||||
<dd><p>select low Shibata noise shaping dither.
|
||||
</p></dd>
|
||||
<dt>‘<samp>high_shibata</samp>’</dt>
|
||||
<dd><p>select high Shibata noise shaping dither.
|
||||
</p></dd>
|
||||
<dt>‘<samp>f_weighted</samp>’</dt>
|
||||
<dd><p>select f-weighted noise shaping dither
|
||||
</p></dd>
|
||||
<dt>‘<samp>modified_e_weighted</samp>’</dt>
|
||||
<dd><p>select modified-e-weighted noise shaping dither
|
||||
</p></dd>
|
||||
<dt>‘<samp>improved_e_weighted</samp>’</dt>
|
||||
<dd><p>select improved-e-weighted noise shaping dither
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
</dd>
|
||||
<dt><samp>resampler</samp></dt>
|
||||
<dd><p>Set resampling engine. Default value is swr.
|
||||
</p>
|
||||
<p>Supported values:
|
||||
</p><dl compact="compact">
|
||||
<dt>‘<samp>swr</samp>’</dt>
|
||||
<dd><p>select the native SW Resampler; filter options precision and cheby are not
|
||||
applicable in this case.
|
||||
</p></dd>
|
||||
<dt>‘<samp>soxr</samp>’</dt>
|
||||
<dd><p>select the SoX Resampler (where available); compensation, and filter options
|
||||
filter_size, phase_shift, exact_rational, filter_type & kaiser_beta, are not
|
||||
applicable in this case.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
</dd>
|
||||
<dt><samp>filter_size</samp></dt>
|
||||
<dd><p>For swr only, set resampling filter size, default value is 32.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>phase_shift</samp></dt>
|
||||
<dd><p>For swr only, set resampling phase shift, default value is 10, and must be in
|
||||
the interval [0,30].
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>linear_interp</samp></dt>
|
||||
<dd><p>Use linear interpolation if set to 1, default value is 0.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>exact_rational</samp></dt>
|
||||
<dd><p>For swr only, when enabled, try to use exact phase_count based on input and
|
||||
output sample rate. However, if it is larger than <code>1 << phase_shift</code>,
|
||||
the phase_count will be <code>1 << phase_shift</code> as fallback. Default is disabled.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>cutoff</samp></dt>
|
||||
<dd><p>Set cutoff frequency (swr: 6dB point; soxr: 0dB point) ratio; must be a float
|
||||
value between 0 and 1. Default value is 0.97 with swr, and 0.91 with soxr
|
||||
(which, with a sample-rate of 44100, preserves the entire audio band to 20kHz).
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>precision</samp></dt>
|
||||
<dd><p>For soxr only, the precision in bits to which the resampled signal will be
|
||||
calculated. The default value of 20 (which, with suitable dithering, is
|
||||
appropriate for a destination bit-depth of 16) gives SoX’s ’High Quality’; a
|
||||
value of 28 gives SoX’s ’Very High Quality’.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>cheby</samp></dt>
|
||||
<dd><p>For soxr only, selects passband rolloff none (Chebyshev) & higher-precision
|
||||
approximation for ’irrational’ ratios. Default value is 0.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>async</samp></dt>
|
||||
<dd><p>For swr only, simple 1 parameter audio sync to timestamps using stretching,
|
||||
squeezing, filling and trimming. Setting this to 1 will enable filling and
|
||||
trimming, larger values represent the maximum amount in samples that the data
|
||||
may be stretched or squeezed for each second.
|
||||
Default value is 0, thus no compensation is applied to make the samples match
|
||||
the audio timestamps.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>first_pts</samp></dt>
|
||||
<dd><p>For swr only, assume the first pts should be this value. The time unit is 1 / sample rate.
|
||||
This allows for padding/trimming at the start of stream. By default, no
|
||||
assumption is made about the first frame’s expected pts, so no padding or
|
||||
trimming is done. For example, this could be set to 0 to pad the beginning with
|
||||
silence if an audio stream starts after the video stream or to trim any samples
|
||||
with a negative pts due to encoder delay.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>min_comp</samp></dt>
|
||||
<dd><p>For swr only, set the minimum difference between timestamps and audio data (in
|
||||
seconds) to trigger stretching/squeezing/filling or trimming of the
|
||||
data to make it match the timestamps. The default is that
|
||||
stretching/squeezing/filling and trimming is disabled
|
||||
(<samp>min_comp</samp> = <code>FLT_MAX</code>).
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>min_hard_comp</samp></dt>
|
||||
<dd><p>For swr only, set the minimum difference between timestamps and audio data (in
|
||||
seconds) to trigger adding/dropping samples to make it match the
|
||||
timestamps. This option effectively is a threshold to select between
|
||||
hard (trim/fill) and soft (squeeze/stretch) compensation. Note that
|
||||
all compensation is by default disabled through <samp>min_comp</samp>.
|
||||
The default is 0.1.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>comp_duration</samp></dt>
|
||||
<dd><p>For swr only, set duration (in seconds) over which data is stretched/squeezed
|
||||
to make it match the timestamps. Must be a non-negative double float value,
|
||||
default value is 1.0.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>max_soft_comp</samp></dt>
|
||||
<dd><p>For swr only, set maximum factor by which data is stretched/squeezed to make it
|
||||
match the timestamps. Must be a non-negative double float value, default value
|
||||
is 0.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>matrix_encoding</samp></dt>
|
||||
<dd><p>Select matrixed stereo encoding.
|
||||
</p>
|
||||
<p>It accepts the following values:
|
||||
</p><dl compact="compact">
|
||||
<dt>‘<samp>none</samp>’</dt>
|
||||
<dd><p>select none
|
||||
</p></dd>
|
||||
<dt>‘<samp>dolby</samp>’</dt>
|
||||
<dd><p>select Dolby
|
||||
</p></dd>
|
||||
<dt>‘<samp>dplii</samp>’</dt>
|
||||
<dd><p>select Dolby Pro Logic II
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<p>Default value is <code>none</code>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>filter_type</samp></dt>
|
||||
<dd><p>For swr only, select resampling filter type. This only affects resampling
|
||||
operations.
|
||||
</p>
|
||||
<p>It accepts the following values:
|
||||
</p><dl compact="compact">
|
||||
<dt>‘<samp>cubic</samp>’</dt>
|
||||
<dd><p>select cubic
|
||||
</p></dd>
|
||||
<dt>‘<samp>blackman_nuttall</samp>’</dt>
|
||||
<dd><p>select Blackman Nuttall windowed sinc
|
||||
</p></dd>
|
||||
<dt>‘<samp>kaiser</samp>’</dt>
|
||||
<dd><p>select Kaiser windowed sinc
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
</dd>
|
||||
<dt><samp>kaiser_beta</samp></dt>
|
||||
<dd><p>For swr only, set Kaiser window beta value. Must be a double float value in the
|
||||
interval [2,16], default value is 9.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>output_sample_bits</samp></dt>
|
||||
<dd><p>For swr only, set number of used output sample bits for dithering. Must be an integer in the
|
||||
interval [0,64], default value is 0, which means it’s not used.
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<a name="See-Also"></a>
|
||||
<h2 class="chapter">3 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
|
||||
<a href="libswresample.html">libswresample</a>
|
||||
</p>
|
||||
|
||||
<a name="Authors"></a>
|
||||
<h2 class="chapter">4 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg developers.
|
||||
</p>
|
||||
<p>For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
<code>git log</code> in the FFmpeg source directory, or browsing the
|
||||
online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Maintainers for the specific components are listed in the file
|
||||
<samp>MAINTAINERS</samp> in the source code tree.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,252 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
FFmpeg Scaler Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
FFmpeg Scaler Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Description" href="#Description">1 Description</a></li>
|
||||
<li><a name="toc-Scaler-Options" href="#Scaler-Options">2 Scaler Options</a></li>
|
||||
<li><a name="toc-See-Also" href="#See-Also">3 See Also</a></li>
|
||||
<li><a name="toc-Authors" href="#Authors">4 Authors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">1 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg rescaler provides a high-level interface to the libswscale
|
||||
library image conversion utilities. In particular it allows one to perform
|
||||
image rescaling and pixel format conversion.
|
||||
</p>
|
||||
|
||||
<a name="scaler_005foptions"></a><a name="Scaler-Options"></a>
|
||||
<h2 class="chapter">2 Scaler Options<span class="pull-right"><a class="anchor hidden-xs" href="#Scaler-Options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Scaler-Options" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The video scaler supports the following named options.
|
||||
</p>
|
||||
<p>Options may be set by specifying -<var>option</var> <var>value</var> in the
|
||||
FFmpeg tools. For programmatic use, they can be set explicitly in the
|
||||
<code>SwsContext</code> options or through the <samp>libavutil/opt.h</samp> API.
|
||||
</p>
|
||||
<dl compact="compact">
|
||||
<dd>
|
||||
<a name="sws_005fflags"></a></dd>
|
||||
<dt><samp>sws_flags</samp></dt>
|
||||
<dd><p>Set the scaler flags. This is also used to set the scaling
|
||||
algorithm. Only a single algorithm should be selected.
|
||||
</p>
|
||||
<p>It accepts the following values:
|
||||
</p><dl compact="compact">
|
||||
<dt>‘<samp>fast_bilinear</samp>’</dt>
|
||||
<dd><p>Select fast bilinear scaling algorithm.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>bilinear</samp>’</dt>
|
||||
<dd><p>Select bilinear scaling algorithm.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>bicubic</samp>’</dt>
|
||||
<dd><p>Select bicubic scaling algorithm.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>experimental</samp>’</dt>
|
||||
<dd><p>Select experimental scaling algorithm.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>neighbor</samp>’</dt>
|
||||
<dd><p>Select nearest neighbor rescaling algorithm.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>area</samp>’</dt>
|
||||
<dd><p>Select averaging area rescaling algorithm.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>bicublin</samp>’</dt>
|
||||
<dd><p>Select bicubic scaling algorithm for the luma component, bilinear for
|
||||
chroma components.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>gauss</samp>’</dt>
|
||||
<dd><p>Select Gaussian rescaling algorithm.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>sinc</samp>’</dt>
|
||||
<dd><p>Select sinc rescaling algorithm.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>lanczos</samp>’</dt>
|
||||
<dd><p>Select Lanczos rescaling algorithm.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>spline</samp>’</dt>
|
||||
<dd><p>Select natural bicubic spline rescaling algorithm.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>print_info</samp>’</dt>
|
||||
<dd><p>Enable printing/debug logging.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>accurate_rnd</samp>’</dt>
|
||||
<dd><p>Enable accurate rounding.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>full_chroma_int</samp>’</dt>
|
||||
<dd><p>Enable full chroma interpolation.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>full_chroma_inp</samp>’</dt>
|
||||
<dd><p>Select full chroma input.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>bitexact</samp>’</dt>
|
||||
<dd><p>Enable bitexact output.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
</dd>
|
||||
<dt><samp>srcw</samp></dt>
|
||||
<dd><p>Set source width.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>srch</samp></dt>
|
||||
<dd><p>Set source height.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>dstw</samp></dt>
|
||||
<dd><p>Set destination width.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>dsth</samp></dt>
|
||||
<dd><p>Set destination height.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>src_format</samp></dt>
|
||||
<dd><p>Set source pixel format (must be expressed as an integer).
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>dst_format</samp></dt>
|
||||
<dd><p>Set destination pixel format (must be expressed as an integer).
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>src_range</samp></dt>
|
||||
<dd><p>Select source range.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>dst_range</samp></dt>
|
||||
<dd><p>Select destination range.
|
||||
</p>
|
||||
<a name="sws_005fparams"></a></dd>
|
||||
<dt><samp>param0, param1</samp></dt>
|
||||
<dd><p>Set scaling algorithm parameters. The specified values are specific of
|
||||
some scaling algorithms and ignored by others. The specified values
|
||||
are floating point number values.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>sws_dither</samp></dt>
|
||||
<dd><p>Set the dithering algorithm. Accepts one of the following
|
||||
values. Default value is ‘<samp>auto</samp>’.
|
||||
</p>
|
||||
<dl compact="compact">
|
||||
<dt>‘<samp>auto</samp>’</dt>
|
||||
<dd><p>automatic choice
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>none</samp>’</dt>
|
||||
<dd><p>no dithering
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>bayer</samp>’</dt>
|
||||
<dd><p>bayer dither
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>ed</samp>’</dt>
|
||||
<dd><p>error diffusion dither
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>a_dither</samp>’</dt>
|
||||
<dd><p>arithmetic dither, based using addition
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>x_dither</samp>’</dt>
|
||||
<dd><p>arithmetic dither, based using xor (more random/less apparent patterning that
|
||||
a_dither).
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
</dd>
|
||||
<dt><samp>alphablend</samp></dt>
|
||||
<dd><p>Set the alpha blending to use when the input has alpha but the output does not.
|
||||
Default value is ‘<samp>none</samp>’.
|
||||
</p>
|
||||
<dl compact="compact">
|
||||
<dt>‘<samp>uniform_color</samp>’</dt>
|
||||
<dd><p>Blend onto a uniform background color
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>checkerboard</samp>’</dt>
|
||||
<dd><p>Blend onto a checkerboard
|
||||
</p>
|
||||
</dd>
|
||||
<dt>‘<samp>none</samp>’</dt>
|
||||
<dd><p>No blending
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<a name="See-Also"></a>
|
||||
<h2 class="chapter">3 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
|
||||
<a href="libswscale.html">libswscale</a>
|
||||
</p>
|
||||
|
||||
<a name="Authors"></a>
|
||||
<h2 class="chapter">4 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg developers.
|
||||
</p>
|
||||
<p>For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
<code>git log</code> in the FFmpeg source directory, or browsing the
|
||||
online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Maintainers for the specific components are listed in the file
|
||||
<samp>MAINTAINERS</samp> in the source code tree.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,822 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
ffplay Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
ffplay Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Synopsis" href="#Synopsis">1 Synopsis</a></li>
|
||||
<li><a name="toc-Description" href="#Description">2 Description</a></li>
|
||||
<li><a name="toc-Options" href="#Options">3 Options</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Stream-specifiers-1" href="#Stream-specifiers-1">3.1 Stream specifiers</a></li>
|
||||
<li><a name="toc-Generic-options" href="#Generic-options">3.2 Generic options</a></li>
|
||||
<li><a name="toc-AVOptions" href="#AVOptions">3.3 AVOptions</a></li>
|
||||
<li><a name="toc-Main-options" href="#Main-options">3.4 Main options</a></li>
|
||||
<li><a name="toc-Advanced-options" href="#Advanced-options">3.5 Advanced options</a></li>
|
||||
<li><a name="toc-While-playing" href="#While-playing">3.6 While playing</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-See-Also" href="#See-Also">4 See Also</a></li>
|
||||
<li><a name="toc-Authors" href="#Authors">5 Authors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Synopsis"></a>
|
||||
<h2 class="chapter">1 Synopsis<span class="pull-right"><a class="anchor hidden-xs" href="#Synopsis" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Synopsis" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>ffplay [<var>options</var>] [<samp>input_url</samp>]
|
||||
</p>
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">2 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>FFplay is a very simple and portable media player using the FFmpeg
|
||||
libraries and the SDL library. It is mostly used as a testbed for the
|
||||
various FFmpeg APIs.
|
||||
</p>
|
||||
<a name="Options"></a>
|
||||
<h2 class="chapter">3 Options<span class="pull-right"><a class="anchor hidden-xs" href="#Options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Options" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>All the numerical options, if not specified otherwise, accept a string
|
||||
representing a number as input, which may be followed by one of the SI
|
||||
unit prefixes, for example: ’K’, ’M’, or ’G’.
|
||||
</p>
|
||||
<p>If ’i’ is appended to the SI unit prefix, the complete prefix will be
|
||||
interpreted as a unit prefix for binary multiples, which are based on
|
||||
powers of 1024 instead of powers of 1000. Appending ’B’ to the SI unit
|
||||
prefix multiplies the value by 8. This allows using, for example:
|
||||
’KB’, ’MiB’, ’G’ and ’B’ as number suffixes.
|
||||
</p>
|
||||
<p>Options which do not take arguments are boolean options, and set the
|
||||
corresponding value to true. They can be set to false by prefixing
|
||||
the option name with "no". For example using "-nofoo"
|
||||
will set the boolean option with name "foo" to false.
|
||||
</p>
|
||||
<a name="Stream-specifiers"></a><a name="Stream-specifiers-1"></a>
|
||||
<h3 class="section">3.1 Stream specifiers<span class="pull-right"><a class="anchor hidden-xs" href="#Stream-specifiers-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Stream-specifiers-1" aria-hidden="true">TOC</a></span></h3>
|
||||
<p>Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers
|
||||
are used to precisely specify which stream(s) a given option belongs to.
|
||||
</p>
|
||||
<p>A stream specifier is a string generally appended to the option name and
|
||||
separated from it by a colon. E.g. <code>-codec:a:1 ac3</code> contains the
|
||||
<code>a:1</code> stream specifier, which matches the second audio stream. Therefore, it
|
||||
would select the ac3 codec for the second audio stream.
|
||||
</p>
|
||||
<p>A stream specifier can match several streams, so that the option is applied to all
|
||||
of them. E.g. the stream specifier in <code>-b:a 128k</code> matches all audio
|
||||
streams.
|
||||
</p>
|
||||
<p>An empty stream specifier matches all streams. For example, <code>-codec copy</code>
|
||||
or <code>-codec: copy</code> would copy all the streams without reencoding.
|
||||
</p>
|
||||
<p>Possible forms of stream specifiers are:
|
||||
</p><dl compact="compact">
|
||||
<dt><samp><var>stream_index</var></samp></dt>
|
||||
<dd><p>Matches the stream with this index. E.g. <code>-threads:1 4</code> would set the
|
||||
thread count for the second stream to 4.
|
||||
</p></dd>
|
||||
<dt><samp><var>stream_type</var>[:<var>stream_index</var>]</samp></dt>
|
||||
<dd><p><var>stream_type</var> is one of following: ’v’ or ’V’ for video, ’a’ for audio, ’s’
|
||||
for subtitle, ’d’ for data, and ’t’ for attachments. ’v’ matches all video
|
||||
streams, ’V’ only matches video streams which are not attached pictures, video
|
||||
thumbnails or cover arts. If <var>stream_index</var> is given, then it matches
|
||||
stream number <var>stream_index</var> of this type. Otherwise, it matches all
|
||||
streams of this type.
|
||||
</p></dd>
|
||||
<dt><samp>p:<var>program_id</var>[:<var>stream_index</var>]</samp></dt>
|
||||
<dd><p>If <var>stream_index</var> is given, then it matches the stream with number <var>stream_index</var>
|
||||
in the program with the id <var>program_id</var>. Otherwise, it matches all streams in the
|
||||
program.
|
||||
</p></dd>
|
||||
<dt><samp>#<var>stream_id</var> or i:<var>stream_id</var></samp></dt>
|
||||
<dd><p>Match the stream by stream id (e.g. PID in MPEG-TS container).
|
||||
</p></dd>
|
||||
<dt><samp>m:<var>key</var>[:<var>value</var>]</samp></dt>
|
||||
<dd><p>Matches streams with the metadata tag <var>key</var> having the specified value. If
|
||||
<var>value</var> is not given, matches streams that contain the given tag with any
|
||||
value.
|
||||
</p></dd>
|
||||
<dt><samp>u</samp></dt>
|
||||
<dd><p>Matches streams with usable configuration, the codec must be defined and the
|
||||
essential information such as video dimension or audio sample rate must be present.
|
||||
</p>
|
||||
<p>Note that in <code>ffmpeg</code>, matching by metadata will only work properly for
|
||||
input files.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<a name="Generic-options"></a>
|
||||
<h3 class="section">3.2 Generic options<span class="pull-right"><a class="anchor hidden-xs" href="#Generic-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Generic-options" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>These options are shared amongst the ff* tools.
|
||||
</p>
|
||||
<dl compact="compact">
|
||||
<dt><samp>-L</samp></dt>
|
||||
<dd><p>Show license.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-h, -?, -help, --help [<var>arg</var>]</samp></dt>
|
||||
<dd><p>Show help. An optional parameter may be specified to print help about a specific
|
||||
item. If no argument is specified, only basic (non advanced) tool
|
||||
options are shown.
|
||||
</p>
|
||||
<p>Possible values of <var>arg</var> are:
|
||||
</p><dl compact="compact">
|
||||
<dt><samp>long</samp></dt>
|
||||
<dd><p>Print advanced tool options in addition to the basic tool options.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>full</samp></dt>
|
||||
<dd><p>Print complete list of options, including shared and private options
|
||||
for encoders, decoders, demuxers, muxers, filters, etc.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>decoder=<var>decoder_name</var></samp></dt>
|
||||
<dd><p>Print detailed information about the decoder named <var>decoder_name</var>. Use the
|
||||
<samp>-decoders</samp> option to get a list of all decoders.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>encoder=<var>encoder_name</var></samp></dt>
|
||||
<dd><p>Print detailed information about the encoder named <var>encoder_name</var>. Use the
|
||||
<samp>-encoders</samp> option to get a list of all encoders.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>demuxer=<var>demuxer_name</var></samp></dt>
|
||||
<dd><p>Print detailed information about the demuxer named <var>demuxer_name</var>. Use the
|
||||
<samp>-formats</samp> option to get a list of all demuxers and muxers.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>muxer=<var>muxer_name</var></samp></dt>
|
||||
<dd><p>Print detailed information about the muxer named <var>muxer_name</var>. Use the
|
||||
<samp>-formats</samp> option to get a list of all muxers and demuxers.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>filter=<var>filter_name</var></samp></dt>
|
||||
<dd><p>Print detailed information about the filter name <var>filter_name</var>. Use the
|
||||
<samp>-filters</samp> option to get a list of all filters.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
</dd>
|
||||
<dt><samp>-version</samp></dt>
|
||||
<dd><p>Show version.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-formats</samp></dt>
|
||||
<dd><p>Show available formats (including devices).
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-devices</samp></dt>
|
||||
<dd><p>Show available devices.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-codecs</samp></dt>
|
||||
<dd><p>Show all codecs known to libavcodec.
|
||||
</p>
|
||||
<p>Note that the term ’codec’ is used throughout this documentation as a shortcut
|
||||
for what is more correctly called a media bitstream format.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-decoders</samp></dt>
|
||||
<dd><p>Show available decoders.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-encoders</samp></dt>
|
||||
<dd><p>Show all available encoders.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-bsfs</samp></dt>
|
||||
<dd><p>Show available bitstream filters.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-protocols</samp></dt>
|
||||
<dd><p>Show available protocols.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-filters</samp></dt>
|
||||
<dd><p>Show available libavfilter filters.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-pix_fmts</samp></dt>
|
||||
<dd><p>Show available pixel formats.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-sample_fmts</samp></dt>
|
||||
<dd><p>Show available sample formats.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-layouts</samp></dt>
|
||||
<dd><p>Show channel names and standard channel layouts.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-colors</samp></dt>
|
||||
<dd><p>Show recognized color names.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-sources <var>device</var>[,<var>opt1</var>=<var>val1</var>[,<var>opt2</var>=<var>val2</var>]...]</samp></dt>
|
||||
<dd><p>Show autodetected sources of the intput device.
|
||||
Some devices may provide system-dependent source names that cannot be autodetected.
|
||||
The returned list cannot be assumed to be always complete.
|
||||
</p><div class="example">
|
||||
<pre class="example">ffmpeg -sources pulse,server=192.168.0.4
|
||||
</pre></div>
|
||||
|
||||
</dd>
|
||||
<dt><samp>-sinks <var>device</var>[,<var>opt1</var>=<var>val1</var>[,<var>opt2</var>=<var>val2</var>]...]</samp></dt>
|
||||
<dd><p>Show autodetected sinks of the output device.
|
||||
Some devices may provide system-dependent sink names that cannot be autodetected.
|
||||
The returned list cannot be assumed to be always complete.
|
||||
</p><div class="example">
|
||||
<pre class="example">ffmpeg -sinks pulse,server=192.168.0.4
|
||||
</pre></div>
|
||||
|
||||
</dd>
|
||||
<dt><samp>-loglevel [repeat+]<var>loglevel</var> | -v [repeat+]<var>loglevel</var></samp></dt>
|
||||
<dd><p>Set the logging level used by the library.
|
||||
Adding "repeat+" indicates that repeated log output should not be compressed
|
||||
to the first line and the "Last message repeated n times" line will be
|
||||
omitted. "repeat" can also be used alone.
|
||||
If "repeat" is used alone, and with no prior loglevel set, the default
|
||||
loglevel will be used. If multiple loglevel parameters are given, using
|
||||
’repeat’ will not change the loglevel.
|
||||
<var>loglevel</var> is a string or a number containing one of the following values:
|
||||
</p><dl compact="compact">
|
||||
<dt>‘<samp>quiet, -8</samp>’</dt>
|
||||
<dd><p>Show nothing at all; be silent.
|
||||
</p></dd>
|
||||
<dt>‘<samp>panic, 0</samp>’</dt>
|
||||
<dd><p>Only show fatal errors which could lead the process to crash, such as
|
||||
an assertion failure. This is not currently used for anything.
|
||||
</p></dd>
|
||||
<dt>‘<samp>fatal, 8</samp>’</dt>
|
||||
<dd><p>Only show fatal errors. These are errors after which the process absolutely
|
||||
cannot continue.
|
||||
</p></dd>
|
||||
<dt>‘<samp>error, 16</samp>’</dt>
|
||||
<dd><p>Show all errors, including ones which can be recovered from.
|
||||
</p></dd>
|
||||
<dt>‘<samp>warning, 24</samp>’</dt>
|
||||
<dd><p>Show all warnings and errors. Any message related to possibly
|
||||
incorrect or unexpected events will be shown.
|
||||
</p></dd>
|
||||
<dt>‘<samp>info, 32</samp>’</dt>
|
||||
<dd><p>Show informative messages during processing. This is in addition to
|
||||
warnings and errors. This is the default value.
|
||||
</p></dd>
|
||||
<dt>‘<samp>verbose, 40</samp>’</dt>
|
||||
<dd><p>Same as <code>info</code>, except more verbose.
|
||||
</p></dd>
|
||||
<dt>‘<samp>debug, 48</samp>’</dt>
|
||||
<dd><p>Show everything, including debugging information.
|
||||
</p></dd>
|
||||
<dt>‘<samp>trace, 56</samp>’</dt>
|
||||
</dl>
|
||||
|
||||
<p>By default the program logs to stderr. If coloring is supported by the
|
||||
terminal, colors are used to mark errors and warnings. Log coloring
|
||||
can be disabled setting the environment variable
|
||||
<code>AV_LOG_FORCE_NOCOLOR</code> or <code>NO_COLOR</code>, or can be forced setting
|
||||
the environment variable <code>AV_LOG_FORCE_COLOR</code>.
|
||||
The use of the environment variable <code>NO_COLOR</code> is deprecated and
|
||||
will be dropped in a future FFmpeg version.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-report</samp></dt>
|
||||
<dd><p>Dump full command line and console output to a file named
|
||||
<code><var>program</var>-<var>YYYYMMDD</var>-<var>HHMMSS</var>.log</code> in the current
|
||||
directory.
|
||||
This file can be useful for bug reports.
|
||||
It also implies <code>-loglevel verbose</code>.
|
||||
</p>
|
||||
<p>Setting the environment variable <code>FFREPORT</code> to any value has the
|
||||
same effect. If the value is a ’:’-separated key=value sequence, these
|
||||
options will affect the report; option values must be escaped if they
|
||||
contain special characters or the options delimiter ’:’ (see the
|
||||
“Quoting and escaping” section in the ffmpeg-utils manual).
|
||||
</p>
|
||||
<p>The following options are recognized:
|
||||
</p><dl compact="compact">
|
||||
<dt><samp>file</samp></dt>
|
||||
<dd><p>set the file name to use for the report; <code>%p</code> is expanded to the name
|
||||
of the program, <code>%t</code> is expanded to a timestamp, <code>%%</code> is expanded
|
||||
to a plain <code>%</code>
|
||||
</p></dd>
|
||||
<dt><samp>level</samp></dt>
|
||||
<dd><p>set the log verbosity level using a numerical value (see <code>-loglevel</code>).
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<p>For example, to output a report to a file named <samp>ffreport.log</samp>
|
||||
using a log level of <code>32</code> (alias for log level <code>info</code>):
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">FFREPORT=file=ffreport.log:level=32 ffmpeg -i input output
|
||||
</pre></div>
|
||||
|
||||
<p>Errors in parsing the environment variable are not fatal, and will not
|
||||
appear in the report.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-hide_banner</samp></dt>
|
||||
<dd><p>Suppress printing banner.
|
||||
</p>
|
||||
<p>All FFmpeg tools will normally show a copyright notice, build options
|
||||
and library versions. This option can be used to suppress printing
|
||||
this information.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-cpuflags flags (<em>global</em>)</samp></dt>
|
||||
<dd><p>Allows setting and clearing cpu flags. This option is intended
|
||||
for testing. Do not use it unless you know what you’re doing.
|
||||
</p><div class="example">
|
||||
<pre class="example">ffmpeg -cpuflags -sse+mmx ...
|
||||
ffmpeg -cpuflags mmx ...
|
||||
ffmpeg -cpuflags 0 ...
|
||||
</pre></div>
|
||||
<p>Possible flags for this option are:
|
||||
</p><dl compact="compact">
|
||||
<dt>‘<samp>x86</samp>’</dt>
|
||||
<dd><dl compact="compact">
|
||||
<dt>‘<samp>mmx</samp>’</dt>
|
||||
<dt>‘<samp>mmxext</samp>’</dt>
|
||||
<dt>‘<samp>sse</samp>’</dt>
|
||||
<dt>‘<samp>sse2</samp>’</dt>
|
||||
<dt>‘<samp>sse2slow</samp>’</dt>
|
||||
<dt>‘<samp>sse3</samp>’</dt>
|
||||
<dt>‘<samp>sse3slow</samp>’</dt>
|
||||
<dt>‘<samp>ssse3</samp>’</dt>
|
||||
<dt>‘<samp>atom</samp>’</dt>
|
||||
<dt>‘<samp>sse4.1</samp>’</dt>
|
||||
<dt>‘<samp>sse4.2</samp>’</dt>
|
||||
<dt>‘<samp>avx</samp>’</dt>
|
||||
<dt>‘<samp>avx2</samp>’</dt>
|
||||
<dt>‘<samp>xop</samp>’</dt>
|
||||
<dt>‘<samp>fma3</samp>’</dt>
|
||||
<dt>‘<samp>fma4</samp>’</dt>
|
||||
<dt>‘<samp>3dnow</samp>’</dt>
|
||||
<dt>‘<samp>3dnowext</samp>’</dt>
|
||||
<dt>‘<samp>bmi1</samp>’</dt>
|
||||
<dt>‘<samp>bmi2</samp>’</dt>
|
||||
<dt>‘<samp>cmov</samp>’</dt>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>‘<samp>ARM</samp>’</dt>
|
||||
<dd><dl compact="compact">
|
||||
<dt>‘<samp>armv5te</samp>’</dt>
|
||||
<dt>‘<samp>armv6</samp>’</dt>
|
||||
<dt>‘<samp>armv6t2</samp>’</dt>
|
||||
<dt>‘<samp>vfp</samp>’</dt>
|
||||
<dt>‘<samp>vfpv3</samp>’</dt>
|
||||
<dt>‘<samp>neon</samp>’</dt>
|
||||
<dt>‘<samp>setend</samp>’</dt>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>‘<samp>AArch64</samp>’</dt>
|
||||
<dd><dl compact="compact">
|
||||
<dt>‘<samp>armv8</samp>’</dt>
|
||||
<dt>‘<samp>vfp</samp>’</dt>
|
||||
<dt>‘<samp>neon</samp>’</dt>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>‘<samp>PowerPC</samp>’</dt>
|
||||
<dd><dl compact="compact">
|
||||
<dt>‘<samp>altivec</samp>’</dt>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>‘<samp>Specific Processors</samp>’</dt>
|
||||
<dd><dl compact="compact">
|
||||
<dt>‘<samp>pentium2</samp>’</dt>
|
||||
<dt>‘<samp>pentium3</samp>’</dt>
|
||||
<dt>‘<samp>pentium4</samp>’</dt>
|
||||
<dt>‘<samp>k6</samp>’</dt>
|
||||
<dt>‘<samp>k62</samp>’</dt>
|
||||
<dt>‘<samp>athlon</samp>’</dt>
|
||||
<dt>‘<samp>athlonxp</samp>’</dt>
|
||||
<dt>‘<samp>k8</samp>’</dt>
|
||||
</dl>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
</dd>
|
||||
<dt><samp>-opencl_bench</samp></dt>
|
||||
<dd><p>This option is used to benchmark all available OpenCL devices and print the
|
||||
results. This option is only available when FFmpeg has been compiled with
|
||||
<code>--enable-opencl</code>.
|
||||
</p>
|
||||
<p>When FFmpeg is configured with <code>--enable-opencl</code>, the options for the
|
||||
global OpenCL context are set via <samp>-opencl_options</samp>. See the
|
||||
"OpenCL Options" section in the ffmpeg-utils manual for the complete list of
|
||||
supported options. Amongst others, these options include the ability to select
|
||||
a specific platform and device to run the OpenCL code on. By default, FFmpeg
|
||||
will run on the first device of the first platform. While the options for the
|
||||
global OpenCL context provide flexibility to the user in selecting the OpenCL
|
||||
device of their choice, most users would probably want to select the fastest
|
||||
OpenCL device for their system.
|
||||
</p>
|
||||
<p>This option assists the selection of the most efficient configuration by
|
||||
identifying the appropriate device for the user’s system. The built-in
|
||||
benchmark is run on all the OpenCL devices and the performance is measured for
|
||||
each device. The devices in the results list are sorted based on their
|
||||
performance with the fastest device listed first. The user can subsequently
|
||||
invoke <code>ffmpeg</code> using the device deemed most appropriate via
|
||||
<samp>-opencl_options</samp> to obtain the best performance for the OpenCL
|
||||
accelerated code.
|
||||
</p>
|
||||
<p>Typical usage to use the fastest OpenCL device involve the following steps.
|
||||
</p>
|
||||
<p>Run the command:
|
||||
</p><div class="example">
|
||||
<pre class="example">ffmpeg -opencl_bench
|
||||
</pre></div>
|
||||
<p>Note down the platform ID (<var>pidx</var>) and device ID (<var>didx</var>) of the first
|
||||
i.e. fastest device in the list.
|
||||
Select the platform and device using the command:
|
||||
</p><div class="example">
|
||||
<pre class="example">ffmpeg -opencl_options platform_idx=<var>pidx</var>:device_idx=<var>didx</var> ...
|
||||
</pre></div>
|
||||
|
||||
</dd>
|
||||
<dt><samp>-opencl_options options (<em>global</em>)</samp></dt>
|
||||
<dd><p>Set OpenCL environment options. This option is only available when
|
||||
FFmpeg has been compiled with <code>--enable-opencl</code>.
|
||||
</p>
|
||||
<p><var>options</var> must be a list of <var>key</var>=<var>value</var> option pairs
|
||||
separated by ’:’. See the “OpenCL Options” section in the
|
||||
ffmpeg-utils manual for the list of supported options.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<a name="AVOptions"></a>
|
||||
<h3 class="section">3.3 AVOptions<span class="pull-right"><a class="anchor hidden-xs" href="#AVOptions" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-AVOptions" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>These options are provided directly by the libavformat, libavdevice and
|
||||
libavcodec libraries. To see the list of available AVOptions, use the
|
||||
<samp>-help</samp> option. They are separated into two categories:
|
||||
</p><dl compact="compact">
|
||||
<dt><samp>generic</samp></dt>
|
||||
<dd><p>These options can be set for any container, codec or device. Generic options
|
||||
are listed under AVFormatContext options for containers/devices and under
|
||||
AVCodecContext options for codecs.
|
||||
</p></dd>
|
||||
<dt><samp>private</samp></dt>
|
||||
<dd><p>These options are specific to the given container, device or codec. Private
|
||||
options are listed under their corresponding containers/devices/codecs.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<p>For example to write an ID3v2.3 header instead of a default ID3v2.4 to
|
||||
an MP3 file, use the <samp>id3v2_version</samp> private option of the MP3
|
||||
muxer:
|
||||
</p><div class="example">
|
||||
<pre class="example">ffmpeg -i input.flac -id3v2_version 3 out.mp3
|
||||
</pre></div>
|
||||
|
||||
<p>All codec AVOptions are per-stream, and thus a stream specifier
|
||||
should be attached to them.
|
||||
</p>
|
||||
<p>Note: the <samp>-nooption</samp> syntax cannot be used for boolean
|
||||
AVOptions, use <samp>-option 0</samp>/<samp>-option 1</samp>.
|
||||
</p>
|
||||
<p>Note: the old undocumented way of specifying per-stream AVOptions by
|
||||
prepending v/a/s to the options name is now obsolete and will be
|
||||
removed soon.
|
||||
</p>
|
||||
<a name="Main-options"></a>
|
||||
<h3 class="section">3.4 Main options<span class="pull-right"><a class="anchor hidden-xs" href="#Main-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Main-options" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<dl compact="compact">
|
||||
<dt><samp>-x <var>width</var></samp></dt>
|
||||
<dd><p>Force displayed width.
|
||||
</p></dd>
|
||||
<dt><samp>-y <var>height</var></samp></dt>
|
||||
<dd><p>Force displayed height.
|
||||
</p></dd>
|
||||
<dt><samp>-s <var>size</var></samp></dt>
|
||||
<dd><p>Set frame size (WxH or abbreviation), needed for videos which do
|
||||
not contain a header with the frame size like raw YUV. This option
|
||||
has been deprecated in favor of private options, try -video_size.
|
||||
</p></dd>
|
||||
<dt><samp>-fs</samp></dt>
|
||||
<dd><p>Start in fullscreen mode.
|
||||
</p></dd>
|
||||
<dt><samp>-an</samp></dt>
|
||||
<dd><p>Disable audio.
|
||||
</p></dd>
|
||||
<dt><samp>-vn</samp></dt>
|
||||
<dd><p>Disable video.
|
||||
</p></dd>
|
||||
<dt><samp>-sn</samp></dt>
|
||||
<dd><p>Disable subtitles.
|
||||
</p></dd>
|
||||
<dt><samp>-ss <var>pos</var></samp></dt>
|
||||
<dd><p>Seek to <var>pos</var>. Note that in most formats it is not possible to seek
|
||||
exactly, so <code>ffplay</code> will seek to the nearest seek point to
|
||||
<var>pos</var>.
|
||||
</p>
|
||||
<p><var>pos</var> must be a time duration specification,
|
||||
see <a href="ffmpeg-utils.html#time-duration-syntax">(ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual</a>.
|
||||
</p></dd>
|
||||
<dt><samp>-t <var>duration</var></samp></dt>
|
||||
<dd><p>Play <var>duration</var> seconds of audio/video.
|
||||
</p>
|
||||
<p><var>duration</var> must be a time duration specification,
|
||||
see <a href="ffmpeg-utils.html#time-duration-syntax">(ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual</a>.
|
||||
</p></dd>
|
||||
<dt><samp>-bytes</samp></dt>
|
||||
<dd><p>Seek by bytes.
|
||||
</p></dd>
|
||||
<dt><samp>-nodisp</samp></dt>
|
||||
<dd><p>Disable graphical display.
|
||||
</p></dd>
|
||||
<dt><samp>-f <var>fmt</var></samp></dt>
|
||||
<dd><p>Force format.
|
||||
</p></dd>
|
||||
<dt><samp>-window_title <var>title</var></samp></dt>
|
||||
<dd><p>Set window title (default is the input filename).
|
||||
</p></dd>
|
||||
<dt><samp>-loop <var>number</var></samp></dt>
|
||||
<dd><p>Loops movie playback <number> times. 0 means forever.
|
||||
</p></dd>
|
||||
<dt><samp>-showmode <var>mode</var></samp></dt>
|
||||
<dd><p>Set the show mode to use.
|
||||
Available values for <var>mode</var> are:
|
||||
</p><dl compact="compact">
|
||||
<dt>‘<samp>0, video</samp>’</dt>
|
||||
<dd><p>show video
|
||||
</p></dd>
|
||||
<dt>‘<samp>1, waves</samp>’</dt>
|
||||
<dd><p>show audio waves
|
||||
</p></dd>
|
||||
<dt>‘<samp>2, rdft</samp>’</dt>
|
||||
<dd><p>show audio frequency band using RDFT ((Inverse) Real Discrete Fourier Transform)
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<p>Default value is "video", if video is not present or cannot be played
|
||||
"rdft" is automatically selected.
|
||||
</p>
|
||||
<p>You can interactively cycle through the available show modes by
|
||||
pressing the key <tt class="key">w</tt>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-vf <var>filtergraph</var></samp></dt>
|
||||
<dd><p>Create the filtergraph specified by <var>filtergraph</var> and use it to
|
||||
filter the video stream.
|
||||
</p>
|
||||
<p><var>filtergraph</var> is a description of the filtergraph to apply to
|
||||
the stream, and must have a single video input and a single video
|
||||
output. In the filtergraph, the input is associated to the label
|
||||
<code>in</code>, and the output to the label <code>out</code>. See the
|
||||
ffmpeg-filters manual for more information about the filtergraph
|
||||
syntax.
|
||||
</p>
|
||||
<p>You can specify this parameter multiple times and cycle through the specified
|
||||
filtergraphs along with the show modes by pressing the key <tt class="key">w</tt>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-af <var>filtergraph</var></samp></dt>
|
||||
<dd><p><var>filtergraph</var> is a description of the filtergraph to apply to
|
||||
the input audio.
|
||||
Use the option "-filters" to show all the available filters (including
|
||||
sources and sinks).
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-i <var>input_url</var></samp></dt>
|
||||
<dd><p>Read <var>input_url</var>.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<a name="Advanced-options"></a>
|
||||
<h3 class="section">3.5 Advanced options<span class="pull-right"><a class="anchor hidden-xs" href="#Advanced-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Advanced-options" aria-hidden="true">TOC</a></span></h3>
|
||||
<dl compact="compact">
|
||||
<dt><samp>-pix_fmt <var>format</var></samp></dt>
|
||||
<dd><p>Set pixel format.
|
||||
This option has been deprecated in favor of private options, try -pixel_format.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-stats</samp></dt>
|
||||
<dd><p>Print several playback statistics, in particular show the stream
|
||||
duration, the codec parameters, the current position in the stream and
|
||||
the audio/video synchronisation drift. It is on by default, to
|
||||
explicitly disable it you need to specify <code>-nostats</code>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-fast</samp></dt>
|
||||
<dd><p>Non-spec-compliant optimizations.
|
||||
</p></dd>
|
||||
<dt><samp>-genpts</samp></dt>
|
||||
<dd><p>Generate pts.
|
||||
</p></dd>
|
||||
<dt><samp>-sync <var>type</var></samp></dt>
|
||||
<dd><p>Set the master clock to audio (<code>type=audio</code>), video
|
||||
(<code>type=video</code>) or external (<code>type=ext</code>). Default is audio. The
|
||||
master clock is used to control audio-video synchronization. Most media
|
||||
players use audio as master clock, but in some cases (streaming or high
|
||||
quality broadcast) it is necessary to change that. This option is mainly
|
||||
used for debugging purposes.
|
||||
</p></dd>
|
||||
<dt><samp>-ast <var>audio_stream_specifier</var></samp></dt>
|
||||
<dd><p>Select the desired audio stream using the given stream specifier. The stream
|
||||
specifiers are described in the <a href="#Stream-specifiers">Stream specifiers</a> chapter. If this option
|
||||
is not specified, the "best" audio stream is selected in the program of the
|
||||
already selected video stream.
|
||||
</p></dd>
|
||||
<dt><samp>-vst <var>video_stream_specifier</var></samp></dt>
|
||||
<dd><p>Select the desired video stream using the given stream specifier. The stream
|
||||
specifiers are described in the <a href="#Stream-specifiers">Stream specifiers</a> chapter. If this option
|
||||
is not specified, the "best" video stream is selected.
|
||||
</p></dd>
|
||||
<dt><samp>-sst <var>subtitle_stream_specifier</var></samp></dt>
|
||||
<dd><p>Select the desired subtitle stream using the given stream specifier. The stream
|
||||
specifiers are described in the <a href="#Stream-specifiers">Stream specifiers</a> chapter. If this option
|
||||
is not specified, the "best" subtitle stream is selected in the program of the
|
||||
already selected video or audio stream.
|
||||
</p></dd>
|
||||
<dt><samp>-autoexit</samp></dt>
|
||||
<dd><p>Exit when video is done playing.
|
||||
</p></dd>
|
||||
<dt><samp>-exitonkeydown</samp></dt>
|
||||
<dd><p>Exit if any key is pressed.
|
||||
</p></dd>
|
||||
<dt><samp>-exitonmousedown</samp></dt>
|
||||
<dd><p>Exit if any mouse button is pressed.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-codec:<var>media_specifier</var> <var>codec_name</var></samp></dt>
|
||||
<dd><p>Force a specific decoder implementation for the stream identified by
|
||||
<var>media_specifier</var>, which can assume the values <code>a</code> (audio),
|
||||
<code>v</code> (video), and <code>s</code> subtitle.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-acodec <var>codec_name</var></samp></dt>
|
||||
<dd><p>Force a specific audio decoder.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-vcodec <var>codec_name</var></samp></dt>
|
||||
<dd><p>Force a specific video decoder.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-scodec <var>codec_name</var></samp></dt>
|
||||
<dd><p>Force a specific subtitle decoder.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-autorotate</samp></dt>
|
||||
<dd><p>Automatically rotate the video according to file metadata. Enabled by
|
||||
default, use <samp>-noautorotate</samp> to disable it.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-framedrop</samp></dt>
|
||||
<dd><p>Drop video frames if video is out of sync. Enabled by default if the master
|
||||
clock is not set to video. Use this option to enable frame dropping for all
|
||||
master clock sources, use <samp>-noframedrop</samp> to disable it.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><samp>-infbuf</samp></dt>
|
||||
<dd><p>Do not limit the input buffer size, read as much data as possible from the
|
||||
input as soon as possible. Enabled by default for realtime streams, where data
|
||||
may be dropped if not read in time. Use this option to enable infinite buffers
|
||||
for all inputs, use <samp>-noinfbuf</samp> to disable it.
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<a name="While-playing"></a>
|
||||
<h3 class="section">3.6 While playing<span class="pull-right"><a class="anchor hidden-xs" href="#While-playing" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-While-playing" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<dl compact="compact">
|
||||
<dt><tt class="key">q, ESC</tt></dt>
|
||||
<dd><p>Quit.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">f</tt></dt>
|
||||
<dd><p>Toggle full screen.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">p, SPC</tt></dt>
|
||||
<dd><p>Pause.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">m</tt></dt>
|
||||
<dd><p>Toggle mute.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">9, 0</tt></dt>
|
||||
<dd><p>Decrease and increase volume respectively.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">/, *</tt></dt>
|
||||
<dd><p>Decrease and increase volume respectively.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">a</tt></dt>
|
||||
<dd><p>Cycle audio channel in the current program.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">v</tt></dt>
|
||||
<dd><p>Cycle video channel.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">t</tt></dt>
|
||||
<dd><p>Cycle subtitle channel in the current program.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">c</tt></dt>
|
||||
<dd><p>Cycle program.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">w</tt></dt>
|
||||
<dd><p>Cycle video filters or show modes.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">s</tt></dt>
|
||||
<dd><p>Step to the next frame.
|
||||
</p>
|
||||
<p>Pause if the stream is not already paused, step to the next video
|
||||
frame, and pause.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">left/right</tt></dt>
|
||||
<dd><p>Seek backward/forward 10 seconds.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">down/up</tt></dt>
|
||||
<dd><p>Seek backward/forward 1 minute.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">page down/page up</tt></dt>
|
||||
<dd><p>Seek to the previous/next chapter.
|
||||
or if there are no chapters
|
||||
Seek backward/forward 10 minutes.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">right mouse click</tt></dt>
|
||||
<dd><p>Seek to percentage in file corresponding to fraction of width.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><tt class="key">left mouse double-click</tt></dt>
|
||||
<dd><p>Toggle full screen.
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<a name="See-Also"></a>
|
||||
<h2 class="chapter">4 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p><a href="ffplay-all.html">ffmpeg-all</a>,
|
||||
<a href="ffmpeg.html">ffmpeg</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
|
||||
<a href="ffmpeg-utils.html">ffmpeg-utils</a>,
|
||||
<a href="ffmpeg-scaler.html">ffmpeg-scaler</a>,
|
||||
<a href="ffmpeg-resampler.html">ffmpeg-resampler</a>,
|
||||
<a href="ffmpeg-codecs.html">ffmpeg-codecs</a>,
|
||||
<a href="ffmpeg-bitstream-filters.html">ffmpeg-bitstream-filters</a>,
|
||||
<a href="ffmpeg-formats.html">ffmpeg-formats</a>,
|
||||
<a href="ffmpeg-devices.html">ffmpeg-devices</a>,
|
||||
<a href="ffmpeg-protocols.html">ffmpeg-protocols</a>,
|
||||
<a href="ffmpeg-filters.html">ffmpeg-filters</a>
|
||||
</p>
|
||||
|
||||
<a name="Authors"></a>
|
||||
<h2 class="chapter">5 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg developers.
|
||||
</p>
|
||||
<p>For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
<code>git log</code> in the FFmpeg source directory, or browsing the
|
||||
online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Maintainers for the specific components are listed in the file
|
||||
<samp>MAINTAINERS</samp> in the source code tree.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,512 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Using Git to develop FFmpeg
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
Using Git to develop FFmpeg
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Introduction" href="#Introduction">1 Introduction</a></li>
|
||||
<li><a name="toc-Basics-Usage" href="#Basics-Usage">2 Basics Usage</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Get-Git" href="#Get-Git">2.1 Get Git</a></li>
|
||||
<li><a name="toc-Cloning-the-source-tree" href="#Cloning-the-source-tree">2.2 Cloning the source tree</a></li>
|
||||
<li><a name="toc-Updating-the-source-tree-to-the-latest-revision-1" href="#Updating-the-source-tree-to-the-latest-revision-1">2.3 Updating the source tree to the latest revision</a></li>
|
||||
<li><a name="toc-Rebasing-your-local-branches" href="#Rebasing-your-local-branches">2.4 Rebasing your local branches</a></li>
|
||||
<li><a name="toc-Adding_002fremoving-files_002fdirectories" href="#Adding_002fremoving-files_002fdirectories">2.5 Adding/removing files/directories</a></li>
|
||||
<li><a name="toc-Showing-modifications" href="#Showing-modifications">2.6 Showing modifications</a></li>
|
||||
<li><a name="toc-Inspecting-the-changelog" href="#Inspecting-the-changelog">2.7 Inspecting the changelog</a></li>
|
||||
<li><a name="toc-Checking-source-tree-status" href="#Checking-source-tree-status">2.8 Checking source tree status</a></li>
|
||||
<li><a name="toc-Committing" href="#Committing">2.9 Committing</a></li>
|
||||
<li><a name="toc-Preparing-a-patchset" href="#Preparing-a-patchset">2.10 Preparing a patchset</a></li>
|
||||
<li><a name="toc-Sending-patches-for-review" href="#Sending-patches-for-review">2.11 Sending patches for review</a></li>
|
||||
<li><a name="toc-Renaming_002fmoving_002fcopying-files-or-contents-of-files" href="#Renaming_002fmoving_002fcopying-files-or-contents-of-files">2.12 Renaming/moving/copying files or contents of files</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Git-configuration" href="#Git-configuration">3 Git configuration</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Personal-Git-installation" href="#Personal-Git-installation">3.1 Personal Git installation</a></li>
|
||||
<li><a name="toc-Repository-configuration" href="#Repository-configuration">3.2 Repository configuration</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-FFmpeg-specific" href="#FFmpeg-specific">4 FFmpeg specific</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Reverting-broken-commits" href="#Reverting-broken-commits">4.1 Reverting broken commits</a></li>
|
||||
<li><a name="toc-Pushing-changes-to-remote-trees" href="#Pushing-changes-to-remote-trees">4.2 Pushing changes to remote trees</a></li>
|
||||
<li><a name="toc-Finding-a-specific-svn-revision" href="#Finding-a-specific-svn-revision">4.3 Finding a specific svn revision</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Pre_002dpush-checklist" href="#Pre_002dpush-checklist">5 Pre-push checklist</a></li>
|
||||
<li><a name="toc-Server-Issues" href="#Server-Issues">6 Server Issues</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Introduction"></a>
|
||||
<h2 class="chapter">1 Introduction<span class="pull-right"><a class="anchor hidden-xs" href="#Introduction" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Introduction" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>This document aims in giving some quick references on a set of useful Git
|
||||
commands. You should always use the extensive and detailed documentation
|
||||
provided directly by Git:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git --help
|
||||
man git
|
||||
</pre></div>
|
||||
|
||||
<p>shows you the available subcommands,
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git <command> --help
|
||||
man git-<command>
|
||||
</pre></div>
|
||||
|
||||
<p>shows information about the subcommand <command>.
|
||||
</p>
|
||||
<p>Additional information could be found on the
|
||||
<a href="http://gitref.org">Git Reference</a> website.
|
||||
</p>
|
||||
<p>For more information about the Git project, visit the
|
||||
<a href="http://git-scm.com/">Git website</a>.
|
||||
</p>
|
||||
<p>Consult these resources whenever you have problems, they are quite exhaustive.
|
||||
</p>
|
||||
<p>What follows now is a basic introduction to Git and some FFmpeg-specific
|
||||
guidelines to ease the contribution to the project.
|
||||
</p>
|
||||
<a name="Basics-Usage"></a>
|
||||
<h2 class="chapter">2 Basics Usage<span class="pull-right"><a class="anchor hidden-xs" href="#Basics-Usage" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Basics-Usage" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<a name="Get-Git"></a>
|
||||
<h3 class="section">2.1 Get Git<span class="pull-right"><a class="anchor hidden-xs" href="#Get-Git" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Get-Git" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>You can get Git from <a href="http://git-scm.com/">http://git-scm.com/</a>
|
||||
Most distribution and operating system provide a package for it.
|
||||
</p>
|
||||
|
||||
<a name="Cloning-the-source-tree"></a>
|
||||
<h3 class="section">2.2 Cloning the source tree<span class="pull-right"><a class="anchor hidden-xs" href="#Cloning-the-source-tree" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Cloning-the-source-tree" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git clone git://source.ffmpeg.org/ffmpeg <target>
|
||||
</pre></div>
|
||||
|
||||
<p>This will put the FFmpeg sources into the directory <var><target></var>.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git clone git@source.ffmpeg.org:ffmpeg <target>
|
||||
</pre></div>
|
||||
|
||||
<p>This will put the FFmpeg sources into the directory <var><target></var> and let
|
||||
you push back your changes to the remote repository.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git clone gil@ffmpeg.org:ffmpeg-web <target>
|
||||
</pre></div>
|
||||
|
||||
<p>This will put the source of the FFmpeg website into the directory
|
||||
<var><target></var> and let you push back your changes to the remote repository.
|
||||
(Note that <var>gil</var> stands for GItoLite and is not a typo of <var>git</var>.)
|
||||
</p>
|
||||
<p>If you don’t have write-access to the ffmpeg-web repository, you can
|
||||
create patches after making a read-only ffmpeg-web clone:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git clone git://ffmpeg.org/ffmpeg-web <target>
|
||||
</pre></div>
|
||||
|
||||
<p>Make sure that you do not have Windows line endings in your checkouts,
|
||||
otherwise you may experience spurious compilation failures. One way to
|
||||
achieve this is to run
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git config --global core.autocrlf false
|
||||
</pre></div>
|
||||
|
||||
|
||||
<a name="Updating-the-source-tree-to-the-latest-revision"></a><a name="Updating-the-source-tree-to-the-latest-revision-1"></a>
|
||||
<h3 class="section">2.3 Updating the source tree to the latest revision<span class="pull-right"><a class="anchor hidden-xs" href="#Updating-the-source-tree-to-the-latest-revision-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Updating-the-source-tree-to-the-latest-revision-1" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git pull (--rebase)
|
||||
</pre></div>
|
||||
|
||||
<p>pulls in the latest changes from the tracked branch. The tracked branch
|
||||
can be remote. By default the master branch tracks the branch master in
|
||||
the remote origin.
|
||||
</p>
|
||||
<div class="warning">
|
||||
<p><code>--rebase</code> (see below) is recommended.
|
||||
</p></div>
|
||||
<a name="Rebasing-your-local-branches"></a>
|
||||
<h3 class="section">2.4 Rebasing your local branches<span class="pull-right"><a class="anchor hidden-xs" href="#Rebasing-your-local-branches" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Rebasing-your-local-branches" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git pull --rebase
|
||||
</pre></div>
|
||||
|
||||
<p>fetches the changes from the main repository and replays your local commits
|
||||
over it. This is required to keep all your local changes at the top of
|
||||
FFmpeg’s master tree. The master tree will reject pushes with merge commits.
|
||||
</p>
|
||||
|
||||
<a name="Adding_002fremoving-files_002fdirectories"></a>
|
||||
<h3 class="section">2.5 Adding/removing files/directories<span class="pull-right"><a class="anchor hidden-xs" href="#Adding_002fremoving-files_002fdirectories" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Adding_002fremoving-files_002fdirectories" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git add [-A] <filename/dirname>
|
||||
git rm [-r] <filename/dirname>
|
||||
</pre></div>
|
||||
|
||||
<p>Git needs to get notified of all changes you make to your working
|
||||
directory that makes files appear or disappear.
|
||||
Line moves across files are automatically tracked.
|
||||
</p>
|
||||
|
||||
<a name="Showing-modifications"></a>
|
||||
<h3 class="section">2.6 Showing modifications<span class="pull-right"><a class="anchor hidden-xs" href="#Showing-modifications" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Showing-modifications" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git diff <filename(s)>
|
||||
</pre></div>
|
||||
|
||||
<p>will show all local modifications in your working directory as unified diff.
|
||||
</p>
|
||||
|
||||
<a name="Inspecting-the-changelog"></a>
|
||||
<h3 class="section">2.7 Inspecting the changelog<span class="pull-right"><a class="anchor hidden-xs" href="#Inspecting-the-changelog" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Inspecting-the-changelog" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git log <filename(s)>
|
||||
</pre></div>
|
||||
|
||||
<p>You may also use the graphical tools like <code>gitview</code> or <code>gitk</code>
|
||||
or the web interface available at <a href="http://source.ffmpeg.org/">http://source.ffmpeg.org/</a>.
|
||||
</p>
|
||||
<a name="Checking-source-tree-status"></a>
|
||||
<h3 class="section">2.8 Checking source tree status<span class="pull-right"><a class="anchor hidden-xs" href="#Checking-source-tree-status" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Checking-source-tree-status" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git status
|
||||
</pre></div>
|
||||
|
||||
<p>detects all the changes you made and lists what actions will be taken in case
|
||||
of a commit (additions, modifications, deletions, etc.).
|
||||
</p>
|
||||
|
||||
<a name="Committing"></a>
|
||||
<h3 class="section">2.9 Committing<span class="pull-right"><a class="anchor hidden-xs" href="#Committing" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Committing" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git diff --check
|
||||
</pre></div>
|
||||
|
||||
<p>to double check your changes before committing them to avoid trouble later
|
||||
on. All experienced developers do this on each and every commit, no matter
|
||||
how small.
|
||||
</p>
|
||||
<p>Every one of them has been saved from looking like a fool by this many times.
|
||||
It’s very easy for stray debug output or cosmetic modifications to slip in,
|
||||
please avoid problems through this extra level of scrutiny.
|
||||
</p>
|
||||
<p>For cosmetics-only commits you should get (almost) empty output from
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git diff -w -b <filename(s)>
|
||||
</pre></div>
|
||||
|
||||
<p>Also check the output of
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git status
|
||||
</pre></div>
|
||||
|
||||
<p>to make sure you don’t have untracked files or deletions.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git add [-i|-p|-A] <filenames/dirnames>
|
||||
</pre></div>
|
||||
|
||||
<p>Make sure you have told Git your name and email address
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git config --global user.name "My Name"
|
||||
git config --global user.email my@email.invalid
|
||||
</pre></div>
|
||||
|
||||
<p>Use <samp>--global</samp> to set the global configuration for all your Git checkouts.
|
||||
</p>
|
||||
<p>Git will select the changes to the files for commit. Optionally you can use
|
||||
the interactive or the patch mode to select hunk by hunk what should be
|
||||
added to the commit.
|
||||
</p>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git commit
|
||||
</pre></div>
|
||||
|
||||
<p>Git will commit the selected changes to your current local branch.
|
||||
</p>
|
||||
<p>You will be prompted for a log message in an editor, which is either
|
||||
set in your personal configuration file through
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git config --global core.editor
|
||||
</pre></div>
|
||||
|
||||
<p>or set by one of the following environment variables:
|
||||
<var>GIT_EDITOR</var>, <var>VISUAL</var> or <var>EDITOR</var>.
|
||||
</p>
|
||||
<p>Log messages should be concise but descriptive. Explain why you made a change,
|
||||
what you did will be obvious from the changes themselves most of the time.
|
||||
Saying just "bug fix" or "10l" is bad. Remember that people of varying skill
|
||||
levels look at and educate themselves while reading through your code. Don’t
|
||||
include filenames in log messages, Git provides that information.
|
||||
</p>
|
||||
<p>Possibly make the commit message have a terse, descriptive first line, an
|
||||
empty line and then a full description. The first line will be used to name
|
||||
the patch by <code>git format-patch</code>.
|
||||
</p>
|
||||
<a name="Preparing-a-patchset"></a>
|
||||
<h3 class="section">2.10 Preparing a patchset<span class="pull-right"><a class="anchor hidden-xs" href="#Preparing-a-patchset" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Preparing-a-patchset" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git format-patch <commit> [-o directory]
|
||||
</pre></div>
|
||||
|
||||
<p>will generate a set of patches for each commit between <var><commit></var> and
|
||||
current <var>HEAD</var>. E.g.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git format-patch origin/master
|
||||
</pre></div>
|
||||
|
||||
<p>will generate patches for all commits on current branch which are not
|
||||
present in upstream.
|
||||
A useful shortcut is also
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git format-patch -n
|
||||
</pre></div>
|
||||
|
||||
<p>which will generate patches from last <var>n</var> commits.
|
||||
By default the patches are created in the current directory.
|
||||
</p>
|
||||
<a name="Sending-patches-for-review"></a>
|
||||
<h3 class="section">2.11 Sending patches for review<span class="pull-right"><a class="anchor hidden-xs" href="#Sending-patches-for-review" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Sending-patches-for-review" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git send-email <commit list|directory>
|
||||
</pre></div>
|
||||
|
||||
<p>will send the patches created by <code>git format-patch</code> or directly
|
||||
generates them. All the email fields can be configured in the global/local
|
||||
configuration or overridden by command line.
|
||||
Note that this tool must often be installed separately (e.g. <var>git-email</var>
|
||||
package on Debian-based distros).
|
||||
</p>
|
||||
|
||||
<a name="Renaming_002fmoving_002fcopying-files-or-contents-of-files"></a>
|
||||
<h3 class="section">2.12 Renaming/moving/copying files or contents of files<span class="pull-right"><a class="anchor hidden-xs" href="#Renaming_002fmoving_002fcopying-files-or-contents-of-files" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Renaming_002fmoving_002fcopying-files-or-contents-of-files" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Git automatically tracks such changes, making those normal commits.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">mv/cp path/file otherpath/otherfile
|
||||
git add [-A] .
|
||||
git commit
|
||||
</pre></div>
|
||||
|
||||
|
||||
<a name="Git-configuration"></a>
|
||||
<h2 class="chapter">3 Git configuration<span class="pull-right"><a class="anchor hidden-xs" href="#Git-configuration" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Git-configuration" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>In order to simplify a few workflows, it is advisable to configure both
|
||||
your personal Git installation and your local FFmpeg repository.
|
||||
</p>
|
||||
<a name="Personal-Git-installation"></a>
|
||||
<h3 class="section">3.1 Personal Git installation<span class="pull-right"><a class="anchor hidden-xs" href="#Personal-Git-installation" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Personal-Git-installation" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Add the following to your <samp>~/.gitconfig</samp> to help <code>git send-email</code>
|
||||
and <code>git format-patch</code> detect renames:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">[diff]
|
||||
renames = copy
|
||||
</pre></div>
|
||||
|
||||
<a name="Repository-configuration"></a>
|
||||
<h3 class="section">3.2 Repository configuration<span class="pull-right"><a class="anchor hidden-xs" href="#Repository-configuration" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Repository-configuration" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>In order to have <code>git send-email</code> automatically send patches
|
||||
to the ffmpeg-devel mailing list, add the following stanza
|
||||
to <samp>/path/to/ffmpeg/repository/.git/config</samp>:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">[sendemail]
|
||||
to = ffmpeg-devel@ffmpeg.org
|
||||
</pre></div>
|
||||
|
||||
<a name="FFmpeg-specific"></a>
|
||||
<h2 class="chapter">4 FFmpeg specific<span class="pull-right"><a class="anchor hidden-xs" href="#FFmpeg-specific" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-FFmpeg-specific" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<a name="Reverting-broken-commits"></a>
|
||||
<h3 class="section">4.1 Reverting broken commits<span class="pull-right"><a class="anchor hidden-xs" href="#Reverting-broken-commits" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Reverting-broken-commits" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git reset <commit>
|
||||
</pre></div>
|
||||
|
||||
<p><code>git reset</code> will uncommit the changes till <var><commit></var> rewriting
|
||||
the current branch history.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git commit --amend
|
||||
</pre></div>
|
||||
|
||||
<p>allows one to amend the last commit details quickly.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git rebase -i origin/master
|
||||
</pre></div>
|
||||
|
||||
<p>will replay local commits over the main repository allowing to edit, merge
|
||||
or remove some of them in the process.
|
||||
</p>
|
||||
<div class="info">
|
||||
<p><code>git reset</code>, <code>git commit --amend</code> and <code>git rebase</code>
|
||||
rewrite history, so you should use them ONLY on your local or topic branches.
|
||||
The main repository will reject those changes.
|
||||
</p></div>
|
||||
<div class="example">
|
||||
<pre class="example">git revert <commit>
|
||||
</pre></div>
|
||||
|
||||
<p><code>git revert</code> will generate a revert commit. This will not make the
|
||||
faulty commit disappear from the history.
|
||||
</p>
|
||||
<a name="Pushing-changes-to-remote-trees"></a>
|
||||
<h3 class="section">4.2 Pushing changes to remote trees<span class="pull-right"><a class="anchor hidden-xs" href="#Pushing-changes-to-remote-trees" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Pushing-changes-to-remote-trees" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">git push origin master --dry-run
|
||||
</pre></div>
|
||||
|
||||
<p>Will simulate a push of the local master branch to the default remote
|
||||
(<var>origin</var>). And list which branches and ranges or commits would have been
|
||||
pushed.
|
||||
Git will prevent you from pushing changes if the local and remote trees are
|
||||
out of sync. Refer to <a href="#Updating-the-source-tree-to-the-latest-revision">Updating the source tree to the latest revision</a>.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git remote add <name> <url>
|
||||
</pre></div>
|
||||
|
||||
<p>Will add additional remote with a name reference, it is useful if you want
|
||||
to push your local branch for review on a remote host.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git push <remote> <refspec>
|
||||
</pre></div>
|
||||
|
||||
<p>Will push the changes to the <var><remote></var> repository.
|
||||
Omitting <var><refspec></var> makes <code>git push</code> update all the remote
|
||||
branches matching the local ones.
|
||||
</p>
|
||||
<a name="Finding-a-specific-svn-revision"></a>
|
||||
<h3 class="section">4.3 Finding a specific svn revision<span class="pull-right"><a class="anchor hidden-xs" href="#Finding-a-specific-svn-revision" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Finding-a-specific-svn-revision" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Since version 1.7.1 Git supports ‘<samp>:/foo</samp>’ syntax for specifying commits
|
||||
based on a regular expression. see man gitrevisions
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git show :/'as revision 23456'
|
||||
</pre></div>
|
||||
|
||||
<p>will show the svn changeset ‘<samp>r23456</samp>’. With older Git versions searching in
|
||||
the <code>git log</code> output is the easiest option (especially if a pager with
|
||||
search capabilities is used).
|
||||
</p>
|
||||
<p>This commit can be checked out with
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git checkout -b svn_23456 :/'as revision 23456'
|
||||
</pre></div>
|
||||
|
||||
<p>or for Git < 1.7.1 with
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">git checkout -b svn_23456 $SHA1
|
||||
</pre></div>
|
||||
|
||||
<p>where <var>$SHA1</var> is the commit hash from the <code>git log</code> output.
|
||||
</p>
|
||||
|
||||
<a name="Pre_002dpush-checklist"></a>
|
||||
<h2 class="chapter">5 Pre-push checklist<span class="pull-right"><a class="anchor hidden-xs" href="#Pre_002dpush-checklist" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Pre_002dpush-checklist" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>Once you have a set of commits that you feel are ready for pushing,
|
||||
work through the following checklist to doublecheck everything is in
|
||||
proper order. This list tries to be exhaustive. In case you are just
|
||||
pushing a typo in a comment, some of the steps may be unnecessary.
|
||||
Apply your common sense, but if in doubt, err on the side of caution.
|
||||
</p>
|
||||
<p>First, make sure that the commits and branches you are going to push
|
||||
match what you want pushed and that nothing is missing, extraneous or
|
||||
wrong. You can see what will be pushed by running the git push command
|
||||
with <samp>--dry-run</samp> first. And then inspecting the commits listed with
|
||||
<code>git log -p 1234567..987654</code>. The <code>git status</code> command
|
||||
may help in finding local changes that have been forgotten to be added.
|
||||
</p>
|
||||
<p>Next let the code pass through a full run of our test suite.
|
||||
</p>
|
||||
<ul>
|
||||
<li> <code>make distclean</code>
|
||||
</li><li> <code>/path/to/ffmpeg/configure</code>
|
||||
</li><li> <code>make fate</code>
|
||||
</li><li> if fate fails due to missing samples run <code>make fate-rsync</code> and retry
|
||||
</li></ul>
|
||||
|
||||
<p>Make sure all your changes have been checked before pushing them, the
|
||||
test suite only checks against regressions and that only to some extend. It does
|
||||
obviously not check newly added features/code to be working unless you have
|
||||
added a test for that (which is recommended).
|
||||
</p>
|
||||
<p>Also note that every single commit should pass the test suite, not just
|
||||
the result of a series of patches.
|
||||
</p>
|
||||
<p>Once everything passed, push the changes to your public ffmpeg clone and post a
|
||||
merge request to ffmpeg-devel. You can also push them directly but this is not
|
||||
recommended.
|
||||
</p>
|
||||
<a name="Server-Issues"></a>
|
||||
<h2 class="chapter">6 Server Issues<span class="pull-right"><a class="anchor hidden-xs" href="#Server-Issues" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Server-Issues" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>Contact the project admins at <a href="mailto:root@ffmpeg.org">root@ffmpeg.org</a> if you have technical
|
||||
problems with the Git server.
|
||||
</p>
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,77 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Libavcodec Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
Libavcodec Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Description" href="#Description">1 Description</a></li>
|
||||
<li><a name="toc-See-Also" href="#See-Also">2 See Also</a></li>
|
||||
<li><a name="toc-Authors" href="#Authors">3 Authors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">1 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The libavcodec library provides a generic encoding/decoding framework
|
||||
and contains multiple decoders and encoders for audio, video and
|
||||
subtitle streams, and several bitstream filters.
|
||||
</p>
|
||||
<p>The shared architecture provides various services ranging from bit
|
||||
stream I/O to DSP optimizations, and makes it suitable for
|
||||
implementing robust and fast codecs as well as for experimentation.
|
||||
</p>
|
||||
|
||||
<a name="See-Also"></a>
|
||||
<h2 class="chapter">2 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
|
||||
<a href="ffmpeg-codecs.html">ffmpeg-codecs</a>, <a href="ffmpeg-bitstream-filters.html">bitstream-filters</a>,
|
||||
<a href="libavutil.html">libavutil</a>
|
||||
</p>
|
||||
|
||||
<a name="Authors"></a>
|
||||
<h2 class="chapter">3 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg developers.
|
||||
</p>
|
||||
<p>For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
<code>git log</code> in the FFmpeg source directory, or browsing the
|
||||
online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Maintainers for the specific components are listed in the file
|
||||
<samp>MAINTAINERS</samp> in the source code tree.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,74 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Libavdevice Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
Libavdevice Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Description" href="#Description">1 Description</a></li>
|
||||
<li><a name="toc-See-Also" href="#See-Also">2 See Also</a></li>
|
||||
<li><a name="toc-Authors" href="#Authors">3 Authors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">1 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The libavdevice library provides a generic framework for grabbing from
|
||||
and rendering to many common multimedia input/output devices, and
|
||||
supports several input and output devices, including Video4Linux2,
|
||||
VfW, DShow, and ALSA.
|
||||
</p>
|
||||
|
||||
<a name="See-Also"></a>
|
||||
<h2 class="chapter">2 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
|
||||
<a href="ffmpeg-devices.html">ffmpeg-devices</a>,
|
||||
<a href="libavutil.html">libavutil</a>, <a href="libavcodec.html">libavcodec</a>, <a href="libavformat.html">libavformat</a>
|
||||
</p>
|
||||
|
||||
<a name="Authors"></a>
|
||||
<h2 class="chapter">3 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg developers.
|
||||
</p>
|
||||
<p>For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
<code>git log</code> in the FFmpeg source directory, or browsing the
|
||||
online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Maintainers for the specific components are listed in the file
|
||||
<samp>MAINTAINERS</samp> in the source code tree.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,73 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Libavfilter Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
Libavfilter Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Description" href="#Description">1 Description</a></li>
|
||||
<li><a name="toc-See-Also" href="#See-Also">2 See Also</a></li>
|
||||
<li><a name="toc-Authors" href="#Authors">3 Authors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">1 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The libavfilter library provides a generic audio/video filtering
|
||||
framework containing several filters, sources and sinks.
|
||||
</p>
|
||||
|
||||
<a name="See-Also"></a>
|
||||
<h2 class="chapter">2 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
|
||||
<a href="ffmpeg-filters.html">ffmpeg-filters</a>,
|
||||
<a href="libavutil.html">libavutil</a>, <a href="libswscale.html">libswscale</a>, <a href="libswresample.html">libswresample</a>,
|
||||
<a href="libavcodec.html">libavcodec</a>, <a href="libavformat.html">libavformat</a>, <a href="libavdevice.html">libavdevice</a>
|
||||
</p>
|
||||
|
||||
<a name="Authors"></a>
|
||||
<h2 class="chapter">3 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg developers.
|
||||
</p>
|
||||
<p>For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
<code>git log</code> in the FFmpeg source directory, or browsing the
|
||||
online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Maintainers for the specific components are listed in the file
|
||||
<samp>MAINTAINERS</samp> in the source code tree.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,77 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Libavformat Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
Libavformat Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Description" href="#Description">1 Description</a></li>
|
||||
<li><a name="toc-See-Also" href="#See-Also">2 See Also</a></li>
|
||||
<li><a name="toc-Authors" href="#Authors">3 Authors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">1 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The libavformat library provides a generic framework for multiplexing
|
||||
and demultiplexing (muxing and demuxing) audio, video and subtitle
|
||||
streams. It encompasses multiple muxers and demuxers for multimedia
|
||||
container formats.
|
||||
</p>
|
||||
<p>It also supports several input and output protocols to access a media
|
||||
resource.
|
||||
</p>
|
||||
|
||||
<a name="See-Also"></a>
|
||||
<h2 class="chapter">2 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
|
||||
<a href="ffmpeg-formats.html">ffmpeg-formats</a>, <a href="ffmpeg-protocols.html">ffmpeg-protocols</a>,
|
||||
<a href="libavutil.html">libavutil</a>, <a href="libavcodec.html">libavcodec</a>
|
||||
</p>
|
||||
|
||||
<a name="Authors"></a>
|
||||
<h2 class="chapter">3 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg developers.
|
||||
</p>
|
||||
<p>For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
<code>git log</code> in the FFmpeg source directory, or browsing the
|
||||
online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Maintainers for the specific components are listed in the file
|
||||
<samp>MAINTAINERS</samp> in the source code tree.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,96 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Libavutil Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
Libavutil Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Description" href="#Description">1 Description</a></li>
|
||||
<li><a name="toc-See-Also" href="#See-Also">2 See Also</a></li>
|
||||
<li><a name="toc-Authors" href="#Authors">3 Authors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">1 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The libavutil library is a utility library to aid portable
|
||||
multimedia programming. It contains safe portable string functions,
|
||||
random number generators, data structures, additional mathematics
|
||||
functions, cryptography and multimedia related functionality (like
|
||||
enumerations for pixel and sample formats). It is not a library for
|
||||
code needed by both libavcodec and libavformat.
|
||||
</p>
|
||||
<p>The goals for this library is to be:
|
||||
</p>
|
||||
<dl compact="compact">
|
||||
<dt><strong>Modular</strong></dt>
|
||||
<dd><p>It should have few interdependencies and the possibility of disabling individual
|
||||
parts during <code>./configure</code>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><strong>Small</strong></dt>
|
||||
<dd><p>Both sources and objects should be small.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><strong>Efficient</strong></dt>
|
||||
<dd><p>It should have low CPU and memory usage.
|
||||
</p>
|
||||
</dd>
|
||||
<dt><strong>Useful</strong></dt>
|
||||
<dd><p>It should avoid useless features that almost no one needs.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<a name="See-Also"></a>
|
||||
<h2 class="chapter">2 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
|
||||
<a href="ffmpeg-utils.html">ffmpeg-utils</a>
|
||||
</p>
|
||||
|
||||
<a name="Authors"></a>
|
||||
<h2 class="chapter">3 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg developers.
|
||||
</p>
|
||||
<p>For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
<code>git log</code> in the FFmpeg source directory, or browsing the
|
||||
online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Maintainers for the specific components are listed in the file
|
||||
<samp>MAINTAINERS</samp> in the source code tree.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,96 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Libswresample Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
Libswresample Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Description" href="#Description">1 Description</a></li>
|
||||
<li><a name="toc-See-Also" href="#See-Also">2 See Also</a></li>
|
||||
<li><a name="toc-Authors" href="#Authors">3 Authors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">1 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The libswresample library performs highly optimized audio resampling,
|
||||
rematrixing and sample format conversion operations.
|
||||
</p>
|
||||
<p>Specifically, this library performs the following conversions:
|
||||
</p>
|
||||
<ul>
|
||||
<li> <em>Resampling</em>: is the process of changing the audio rate, for
|
||||
example from a high sample rate of 44100Hz to 8000Hz. Audio
|
||||
conversion from high to low sample rate is a lossy process. Several
|
||||
resampling options and algorithms are available.
|
||||
|
||||
</li><li> <em>Format conversion</em>: is the process of converting the type of
|
||||
samples, for example from 16-bit signed samples to unsigned 8-bit or
|
||||
float samples. It also handles packing conversion, when passing from
|
||||
packed layout (all samples belonging to distinct channels interleaved
|
||||
in the same buffer), to planar layout (all samples belonging to the
|
||||
same channel stored in a dedicated buffer or "plane").
|
||||
|
||||
</li><li> <em>Rematrixing</em>: is the process of changing the channel layout, for
|
||||
example from stereo to mono. When the input channels cannot be mapped
|
||||
to the output streams, the process is lossy, since it involves
|
||||
different gain factors and mixing.
|
||||
</li></ul>
|
||||
|
||||
<p>Various other audio conversions (e.g. stretching and padding) are
|
||||
enabled through dedicated options.
|
||||
</p>
|
||||
|
||||
<a name="See-Also"></a>
|
||||
<h2 class="chapter">2 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
|
||||
<a href="ffmpeg-resampler.html">ffmpeg-resampler</a>,
|
||||
<a href="libavutil.html">libavutil</a>
|
||||
</p>
|
||||
|
||||
<a name="Authors"></a>
|
||||
<h2 class="chapter">3 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg developers.
|
||||
</p>
|
||||
<p>For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
<code>git log</code> in the FFmpeg source directory, or browsing the
|
||||
online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Maintainers for the specific components are listed in the file
|
||||
<samp>MAINTAINERS</samp> in the source code tree.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,90 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Libswscale Documentation
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
Libswscale Documentation
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Description" href="#Description">1 Description</a></li>
|
||||
<li><a name="toc-See-Also" href="#See-Also">2 See Also</a></li>
|
||||
<li><a name="toc-Authors" href="#Authors">3 Authors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">1 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The libswscale library performs highly optimized image scaling and
|
||||
colorspace and pixel format conversion operations.
|
||||
</p>
|
||||
<p>Specifically, this library performs the following conversions:
|
||||
</p>
|
||||
<ul>
|
||||
<li> <em>Rescaling</em>: is the process of changing the video size. Several
|
||||
rescaling options and algorithms are available. This is usually a
|
||||
lossy process.
|
||||
|
||||
</li><li> <em>Pixel format conversion</em>: is the process of converting the image
|
||||
format and colorspace of the image, for example from planar YUV420P to
|
||||
RGB24 packed. It also handles packing conversion, that is converts
|
||||
from packed layout (all pixels belonging to distinct planes
|
||||
interleaved in the same buffer), to planar layout (all samples
|
||||
belonging to the same plane stored in a dedicated buffer or "plane").
|
||||
|
||||
<p>This is usually a lossy process in case the source and destination
|
||||
colorspaces differ.
|
||||
</p></li></ul>
|
||||
|
||||
|
||||
<a name="See-Also"></a>
|
||||
<h2 class="chapter">2 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
|
||||
<a href="ffmpeg-scaler.html">ffmpeg-scaler</a>,
|
||||
<a href="libavutil.html">libavutil</a>
|
||||
</p>
|
||||
|
||||
<a name="Authors"></a>
|
||||
<h2 class="chapter">3 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The FFmpeg developers.
|
||||
</p>
|
||||
<p>For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
<code>git log</code> in the FFmpeg source directory, or browsing the
|
||||
online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
|
||||
</p>
|
||||
<p>Maintainers for the specific components are listed in the file
|
||||
<samp>MAINTAINERS</samp> in the source code tree.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,212 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
NUT
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
NUT
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Description" href="#Description">1 Description</a></li>
|
||||
<li><a name="toc-Modes" href="#Modes">2 Modes</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-BROADCAST" href="#BROADCAST">2.1 BROADCAST</a></li>
|
||||
<li><a name="toc-PIPE" href="#PIPE">2.2 PIPE</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Container_002dspecific-codec-tags" href="#Container_002dspecific-codec-tags">3 Container-specific codec tags</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Generic-raw-YUVA-formats" href="#Generic-raw-YUVA-formats">3.1 Generic raw YUVA formats</a></li>
|
||||
<li><a name="toc-Raw-Audio" href="#Raw-Audio">3.2 Raw Audio</a></li>
|
||||
<li><a name="toc-Subtitles" href="#Subtitles">3.3 Subtitles</a></li>
|
||||
<li><a name="toc-Raw-Data" href="#Raw-Data">3.4 Raw Data</a></li>
|
||||
<li><a name="toc-Codecs" href="#Codecs">3.5 Codecs</a></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2 class="chapter">1 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
|
||||
<p>NUT is a low overhead generic container format. It stores audio, video,
|
||||
subtitle and user-defined streams in a simple, yet efficient, way.
|
||||
</p>
|
||||
<p>It was created by a group of FFmpeg and MPlayer developers in 2003
|
||||
and was finalized in 2008.
|
||||
</p>
|
||||
<p>The official nut specification is at svn://svn.mplayerhq.hu/nut
|
||||
In case of any differences between this text and the official specification,
|
||||
the official specification shall prevail.
|
||||
</p>
|
||||
<a name="Modes"></a>
|
||||
<h2 class="chapter">2 Modes<span class="pull-right"><a class="anchor hidden-xs" href="#Modes" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Modes" aria-hidden="true">TOC</a></span></h2>
|
||||
<p>NUT has some variants signaled by using the flags field in its main header.
|
||||
</p>
|
||||
<table>
|
||||
<tr><td width="40%">BROADCAST</td><td width="40%">Extend the syncpoint to report the sender wallclock</td></tr>
|
||||
<tr><td width="40%">PIPE</td><td width="40%">Omit completely the syncpoint</td></tr>
|
||||
</table>
|
||||
|
||||
<a name="BROADCAST"></a>
|
||||
<h3 class="section">2.1 BROADCAST<span class="pull-right"><a class="anchor hidden-xs" href="#BROADCAST" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-BROADCAST" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>The BROADCAST variant provides a secondary time reference to facilitate
|
||||
detecting endpoint latency and network delays.
|
||||
It assumes all the endpoint clocks are synchronized.
|
||||
To be used in real-time scenarios.
|
||||
</p>
|
||||
<a name="PIPE"></a>
|
||||
<h3 class="section">2.2 PIPE<span class="pull-right"><a class="anchor hidden-xs" href="#PIPE" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-PIPE" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>The PIPE variant assumes NUT is used as non-seekable intermediate container,
|
||||
by not using syncpoint removes unneeded overhead and reduces the overall
|
||||
memory usage.
|
||||
</p>
|
||||
<a name="Container_002dspecific-codec-tags"></a>
|
||||
<h2 class="chapter">3 Container-specific codec tags<span class="pull-right"><a class="anchor hidden-xs" href="#Container_002dspecific-codec-tags" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Container_002dspecific-codec-tags" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<a name="Generic-raw-YUVA-formats"></a>
|
||||
<h3 class="section">3.1 Generic raw YUVA formats<span class="pull-right"><a class="anchor hidden-xs" href="#Generic-raw-YUVA-formats" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Generic-raw-YUVA-formats" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Since many exotic planar YUVA pixel formats are not considered by
|
||||
the AVI/QuickTime FourCC lists, the following scheme is adopted for
|
||||
representing them.
|
||||
</p>
|
||||
<p>The first two bytes can contain the values:
|
||||
Y1 = only Y
|
||||
Y2 = Y+A
|
||||
Y3 = YUV
|
||||
Y4 = YUVA
|
||||
</p>
|
||||
<p>The third byte represents the width and height chroma subsampling
|
||||
values for the UV planes, that is the amount to shift the luma
|
||||
width/height right to find the chroma width/height.
|
||||
</p>
|
||||
<p>The fourth byte is the number of bits used (8, 16, ...).
|
||||
</p>
|
||||
<p>If the order of bytes is inverted, that means that each component has
|
||||
to be read big-endian.
|
||||
</p>
|
||||
<a name="Raw-Audio"></a>
|
||||
<h3 class="section">3.2 Raw Audio<span class="pull-right"><a class="anchor hidden-xs" href="#Raw-Audio" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Raw-Audio" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<table>
|
||||
<tr><td width="40%">ALAW</td><td width="40%">A-LAW</td></tr>
|
||||
<tr><td width="40%">ULAW</td><td width="40%">MU-LAW</td></tr>
|
||||
<tr><td width="40%">P<type><interleaving><bits></td><td width="40%">little-endian PCM</td></tr>
|
||||
<tr><td width="40%"><bits><interleaving><type>P</td><td width="40%">big-endian PCM</td></tr>
|
||||
</table>
|
||||
|
||||
<p><type> is S for signed integer, U for unsigned integer, F for IEEE float
|
||||
<interleaving> is D for default, P is for planar.
|
||||
<bits> is 8/16/24/32
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">PFD[32] would for example be signed 32 bit little-endian IEEE float
|
||||
</pre></div>
|
||||
|
||||
<a name="Subtitles"></a>
|
||||
<h3 class="section">3.3 Subtitles<span class="pull-right"><a class="anchor hidden-xs" href="#Subtitles" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Subtitles" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<table>
|
||||
<tr><td width="40%">UTF8</td><td width="40%">Raw UTF-8</td></tr>
|
||||
<tr><td width="40%">SSA[0]</td><td width="40%">SubStation Alpha</td></tr>
|
||||
<tr><td width="40%">DVDS</td><td width="40%">DVD subtitles</td></tr>
|
||||
<tr><td width="40%">DVBS</td><td width="40%">DVB subtitles</td></tr>
|
||||
</table>
|
||||
|
||||
<a name="Raw-Data"></a>
|
||||
<h3 class="section">3.4 Raw Data<span class="pull-right"><a class="anchor hidden-xs" href="#Raw-Data" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Raw-Data" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<table>
|
||||
<tr><td width="40%">UTF8</td><td width="40%">Raw UTF-8</td></tr>
|
||||
</table>
|
||||
|
||||
<a name="Codecs"></a>
|
||||
<h3 class="section">3.5 Codecs<span class="pull-right"><a class="anchor hidden-xs" href="#Codecs" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Codecs" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<table>
|
||||
<tr><td width="40%">3IV1</td><td width="40%">non-compliant MPEG-4 generated by old 3ivx</td></tr>
|
||||
<tr><td width="40%">ASV1</td><td width="40%">Asus Video</td></tr>
|
||||
<tr><td width="40%">ASV2</td><td width="40%">Asus Video 2</td></tr>
|
||||
<tr><td width="40%">CVID</td><td width="40%">Cinepak</td></tr>
|
||||
<tr><td width="40%">CYUV</td><td width="40%">Creative YUV</td></tr>
|
||||
<tr><td width="40%">DIVX</td><td width="40%">non-compliant MPEG-4 generated by old DivX</td></tr>
|
||||
<tr><td width="40%">DUCK</td><td width="40%">Truemotion 1</td></tr>
|
||||
<tr><td width="40%">FFV1</td><td width="40%">FFmpeg video 1</td></tr>
|
||||
<tr><td width="40%">FFVH</td><td width="40%">FFmpeg Huffyuv</td></tr>
|
||||
<tr><td width="40%">H261</td><td width="40%">ITU H.261</td></tr>
|
||||
<tr><td width="40%">H262</td><td width="40%">ITU H.262</td></tr>
|
||||
<tr><td width="40%">H263</td><td width="40%">ITU H.263</td></tr>
|
||||
<tr><td width="40%">H264</td><td width="40%">ITU H.264</td></tr>
|
||||
<tr><td width="40%">HFYU</td><td width="40%">Huffyuv</td></tr>
|
||||
<tr><td width="40%">I263</td><td width="40%">Intel H.263</td></tr>
|
||||
<tr><td width="40%">IV31</td><td width="40%">Indeo 3.1</td></tr>
|
||||
<tr><td width="40%">IV32</td><td width="40%">Indeo 3.2</td></tr>
|
||||
<tr><td width="40%">IV50</td><td width="40%">Indeo 5.0</td></tr>
|
||||
<tr><td width="40%">LJPG</td><td width="40%">ITU JPEG (lossless)</td></tr>
|
||||
<tr><td width="40%">MJLS</td><td width="40%">ITU JPEG-LS</td></tr>
|
||||
<tr><td width="40%">MJPG</td><td width="40%">ITU JPEG</td></tr>
|
||||
<tr><td width="40%">MPG4</td><td width="40%">MS MPEG-4v1 (not ISO MPEG-4)</td></tr>
|
||||
<tr><td width="40%">MP42</td><td width="40%">MS MPEG-4v2</td></tr>
|
||||
<tr><td width="40%">MP43</td><td width="40%">MS MPEG-4v3</td></tr>
|
||||
<tr><td width="40%">MP4V</td><td width="40%">ISO MPEG-4 Part 2 Video (from old encoders)</td></tr>
|
||||
<tr><td width="40%">mpg1</td><td width="40%">ISO MPEG-1 Video</td></tr>
|
||||
<tr><td width="40%">mpg2</td><td width="40%">ISO MPEG-2 Video</td></tr>
|
||||
<tr><td width="40%">MRLE</td><td width="40%">MS RLE</td></tr>
|
||||
<tr><td width="40%">MSVC</td><td width="40%">MS Video 1</td></tr>
|
||||
<tr><td width="40%">RT21</td><td width="40%">Indeo 2.1</td></tr>
|
||||
<tr><td width="40%">RV10</td><td width="40%">RealVideo 1.0</td></tr>
|
||||
<tr><td width="40%">RV20</td><td width="40%">RealVideo 2.0</td></tr>
|
||||
<tr><td width="40%">RV30</td><td width="40%">RealVideo 3.0</td></tr>
|
||||
<tr><td width="40%">RV40</td><td width="40%">RealVideo 4.0</td></tr>
|
||||
<tr><td width="40%">SNOW</td><td width="40%">FFmpeg Snow</td></tr>
|
||||
<tr><td width="40%">SVQ1</td><td width="40%">Sorenson Video 1</td></tr>
|
||||
<tr><td width="40%">SVQ3</td><td width="40%">Sorenson Video 3</td></tr>
|
||||
<tr><td width="40%">theo</td><td width="40%">Xiph Theora</td></tr>
|
||||
<tr><td width="40%">TM20</td><td width="40%">Truemotion 2.0</td></tr>
|
||||
<tr><td width="40%">UMP4</td><td width="40%">non-compliant MPEG-4 generated by UB Video MPEG-4</td></tr>
|
||||
<tr><td width="40%">VCR1</td><td width="40%">ATI VCR1</td></tr>
|
||||
<tr><td width="40%">VP30</td><td width="40%">VP 3.0</td></tr>
|
||||
<tr><td width="40%">VP31</td><td width="40%">VP 3.1</td></tr>
|
||||
<tr><td width="40%">VP50</td><td width="40%">VP 5.0</td></tr>
|
||||
<tr><td width="40%">VP60</td><td width="40%">VP 6.0</td></tr>
|
||||
<tr><td width="40%">VP61</td><td width="40%">VP 6.1</td></tr>
|
||||
<tr><td width="40%">VP62</td><td width="40%">VP 6.2</td></tr>
|
||||
<tr><td width="40%">VP70</td><td width="40%">VP 7.0</td></tr>
|
||||
<tr><td width="40%">WMV1</td><td width="40%">MS WMV7</td></tr>
|
||||
<tr><td width="40%">WMV2</td><td width="40%">MS WMV8</td></tr>
|
||||
<tr><td width="40%">WMV3</td><td width="40%">MS WMV9</td></tr>
|
||||
<tr><td width="40%">WV1F</td><td width="40%">non-compliant MPEG-4 generated by ?</td></tr>
|
||||
<tr><td width="40%">WVC1</td><td width="40%">VC-1</td></tr>
|
||||
<tr><td width="40%">XVID</td><td width="40%">non-compliant MPEG-4 generated by old Xvid</td></tr>
|
||||
<tr><td width="40%">XVIX</td><td width="40%">non-compliant MPEG-4 generated by old Xvid with interlacing bug</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,469 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Platform Specific Information
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>
|
||||
Platform Specific Information
|
||||
</h1>
|
||||
<div align="center">
|
||||
</div>
|
||||
|
||||
|
||||
<a name="SEC_Top"></a>
|
||||
|
||||
<a name="SEC_Contents"></a>
|
||||
<h2 class="contents-heading">Table of Contents</h2>
|
||||
|
||||
<div class="contents">
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Unix_002dlike" href="#Unix_002dlike">1 Unix-like</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Advanced-linking-configuration" href="#Advanced-linking-configuration">1.1 Advanced linking configuration</a></li>
|
||||
<li><a name="toc-BSD" href="#BSD">1.2 BSD</a></li>
|
||||
<li><a name="toc-_0028Open_0029Solaris" href="#g_t_0028Open_0029Solaris">1.3 (Open)Solaris</a></li>
|
||||
<li><a name="toc-Darwin-_0028Mac-OS-X_002c-iPhone_0029" href="#Darwin-_0028Mac-OS-X_002c-iPhone_0029">1.4 Darwin (Mac OS X, iPhone)</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-DOS" href="#DOS">2 DOS</a></li>
|
||||
<li><a name="toc-OS_002f2" href="#OS_002f2">3 OS/2</a></li>
|
||||
<li><a name="toc-Windows" href="#Windows">4 Windows</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Native-Windows-compilation-using-MinGW-or-MinGW_002dw64" href="#Native-Windows-compilation-using-MinGW-or-MinGW_002dw64">4.1 Native Windows compilation using MinGW or MinGW-w64</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Native-Windows-compilation-using-MSYS2" href="#Native-Windows-compilation-using-MSYS2">4.1.1 Native Windows compilation using MSYS2</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows" href="#Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows">4.2 Microsoft Visual C++ or Intel C++ Compiler for Windows</a>
|
||||
<ul class="no-bullet">
|
||||
<li><a name="toc-Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b" href="#Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b">4.2.1 Linking to FFmpeg with Microsoft Visual C++</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Cross-compilation-for-Windows-with-Linux-1" href="#Cross-compilation-for-Windows-with-Linux-1">4.3 Cross compilation for Windows with Linux</a></li>
|
||||
<li><a name="toc-Compilation-under-Cygwin" href="#Compilation-under-Cygwin">4.4 Compilation under Cygwin</a></li>
|
||||
<li><a name="toc-Crosscompilation-for-Windows-under-Cygwin" href="#Crosscompilation-for-Windows-under-Cygwin">4.5 Crosscompilation for Windows under Cygwin</a></li>
|
||||
</ul></li>
|
||||
<li><a name="toc-Plan-9" href="#Plan-9">5 Plan 9</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="Unix_002dlike"></a>
|
||||
<h2 class="chapter">1 Unix-like<span class="pull-right"><a class="anchor hidden-xs" href="#Unix_002dlike" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Unix_002dlike" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>Some parts of FFmpeg cannot be built with version 2.15 of the GNU
|
||||
assembler which is still provided by a few AMD64 distributions. To
|
||||
make sure your compiler really uses the required version of gas
|
||||
after a binutils upgrade, run:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">$(gcc -print-prog-name=as) --version
|
||||
</pre></div>
|
||||
|
||||
<p>If not, then you should install a different compiler that has no
|
||||
hard-coded path to gas. In the worst case pass <code>--disable-asm</code>
|
||||
to configure.
|
||||
</p>
|
||||
<a name="Advanced-linking-configuration"></a>
|
||||
<h3 class="section">1.1 Advanced linking configuration<span class="pull-right"><a class="anchor hidden-xs" href="#Advanced-linking-configuration" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Advanced-linking-configuration" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>If you compiled FFmpeg libraries statically and you want to use them to
|
||||
build your own shared library, you may need to force PIC support (with
|
||||
<code>--enable-pic</code> during FFmpeg configure) and add the following option
|
||||
to your project LDFLAGS:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">-Wl,-Bsymbolic
|
||||
</pre></div>
|
||||
|
||||
<p>If your target platform requires position independent binaries, you should
|
||||
pass the correct linking flag (e.g. <code>-pie</code>) to <code>--extra-ldexeflags</code>.
|
||||
</p>
|
||||
<a name="BSD"></a>
|
||||
<h3 class="section">1.2 BSD<span class="pull-right"><a class="anchor hidden-xs" href="#BSD" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-BSD" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>BSD make will not build FFmpeg, you need to install and use GNU Make
|
||||
(<code>gmake</code>).
|
||||
</p>
|
||||
<a name="g_t_0028Open_0029Solaris"></a>
|
||||
<h3 class="section">1.3 (Open)Solaris<span class="pull-right"><a class="anchor hidden-xs" href="#_0028Open_0029Solaris" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-_0028Open_0029Solaris" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>GNU Make is required to build FFmpeg, so you have to invoke (<code>gmake</code>),
|
||||
standard Solaris Make will not work. When building with a non-c99 front-end
|
||||
(gcc, generic suncc) add either <code>--extra-libs=/usr/lib/values-xpg6.o</code>
|
||||
or <code>--extra-libs=/usr/lib/64/values-xpg6.o</code> to the configure options
|
||||
since the libc is not c99-compliant by default. The probes performed by
|
||||
configure may raise an exception leading to the death of configure itself
|
||||
due to a bug in the system shell. Simply invoke a different shell such as
|
||||
bash directly to work around this:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">bash ./configure
|
||||
</pre></div>
|
||||
|
||||
<a name="Darwin"></a><a name="Darwin-_0028Mac-OS-X_002c-iPhone_0029"></a>
|
||||
<h3 class="section">1.4 Darwin (Mac OS X, iPhone)<span class="pull-right"><a class="anchor hidden-xs" href="#Darwin-_0028Mac-OS-X_002c-iPhone_0029" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Darwin-_0028Mac-OS-X_002c-iPhone_0029" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>The toolchain provided with Xcode is sufficient to build the basic
|
||||
unaccelerated code.
|
||||
</p>
|
||||
<p>Mac OS X on PowerPC or ARM (iPhone) requires a preprocessor from
|
||||
<a href="https://github.com/FFmpeg/gas-preprocessor">https://github.com/FFmpeg/gas-preprocessor</a> or
|
||||
<a href="https://github.com/yuvi/gas-preprocessor">https://github.com/yuvi/gas-preprocessor</a>(currently outdated) to build the optimized
|
||||
assembly functions. Put the Perl script somewhere
|
||||
in your PATH, FFmpeg’s configure will pick it up automatically.
|
||||
</p>
|
||||
<p>Mac OS X on amd64 and x86 requires <code>yasm</code> to build most of the
|
||||
optimized assembly functions. <a href="http://www.finkproject.org/">Fink</a>,
|
||||
<a href="http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml">Gentoo Prefix</a>,
|
||||
<a href="https://mxcl.github.com/homebrew/">Homebrew</a>
|
||||
or <a href="http://www.macports.org">MacPorts</a> can easily provide it.
|
||||
</p>
|
||||
|
||||
<a name="DOS"></a>
|
||||
<h2 class="chapter">2 DOS<span class="pull-right"><a class="anchor hidden-xs" href="#DOS" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-DOS" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>Using a cross-compiler is preferred for various reasons.
|
||||
<a href="http://www.delorie.com/howto/djgpp/linux-x-djgpp.html">http://www.delorie.com/howto/djgpp/linux-x-djgpp.html</a>
|
||||
</p>
|
||||
|
||||
<a name="OS_002f2"></a>
|
||||
<h2 class="chapter">3 OS/2<span class="pull-right"><a class="anchor hidden-xs" href="#OS_002f2" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-OS_002f2" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>For information about compiling FFmpeg on OS/2 see
|
||||
<a href="http://www.edm2.com/index.php/FFmpeg">http://www.edm2.com/index.php/FFmpeg</a>.
|
||||
</p>
|
||||
|
||||
<a name="Windows"></a>
|
||||
<h2 class="chapter">4 Windows<span class="pull-right"><a class="anchor hidden-xs" href="#Windows" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Windows" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>To get help and instructions for building FFmpeg under Windows, check out
|
||||
the FFmpeg Windows Help Forum at <a href="http://ffmpeg.zeranoe.com/forum/">http://ffmpeg.zeranoe.com/forum/</a>.
|
||||
</p>
|
||||
<a name="Native-Windows-compilation-using-MinGW-or-MinGW_002dw64"></a>
|
||||
<h3 class="section">4.1 Native Windows compilation using MinGW or MinGW-w64<span class="pull-right"><a class="anchor hidden-xs" href="#Native-Windows-compilation-using-MinGW-or-MinGW_002dw64" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Native-Windows-compilation-using-MinGW-or-MinGW_002dw64" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>FFmpeg can be built to run natively on Windows using the MinGW-w64
|
||||
toolchain. Install the latest versions of MSYS2 and MinGW-w64 from
|
||||
<a href="http://msys2.github.io/">http://msys2.github.io/</a> and/or <a href="http://mingw-w64.sourceforge.net/">http://mingw-w64.sourceforge.net/</a>.
|
||||
You can find detailed installation instructions in the download section and
|
||||
the FAQ.
|
||||
</p>
|
||||
<p>Notes:
|
||||
</p>
|
||||
<ul>
|
||||
<li> Building for the MSYS environment is discouraged, MSYS2 provides a full
|
||||
MinGW-w64 environment through <samp>mingw64_shell.bat</samp> or
|
||||
<samp>mingw32_shell.bat</samp> that should be used instead of the environment
|
||||
provided by <samp>msys2_shell.bat</samp>.
|
||||
|
||||
</li><li> Building using MSYS2 can be sped up by disabling implicit rules in the
|
||||
Makefile by calling <code>make -r</code> instead of plain <code>make</code>. This
|
||||
speed up is close to non-existent for normal one-off builds and is only
|
||||
noticeable when running make for a second time (for example during
|
||||
<code>make install</code>).
|
||||
|
||||
</li><li> In order to compile FFplay, you must have the MinGW development library
|
||||
of <a href="http://www.libsdl.org/">SDL</a> and <code>pkg-config</code> installed.
|
||||
|
||||
</li><li> By using <code>./configure --enable-shared</code> when configuring FFmpeg,
|
||||
you can build the FFmpeg libraries (e.g. libavutil, libavcodec,
|
||||
libavformat) as DLLs.
|
||||
|
||||
</li></ul>
|
||||
|
||||
<a name="Native-Windows-compilation-using-MSYS2"></a>
|
||||
<h4 class="subsection">4.1.1 Native Windows compilation using MSYS2<span class="pull-right"><a class="anchor hidden-xs" href="#Native-Windows-compilation-using-MSYS2" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Native-Windows-compilation-using-MSYS2" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>The MSYS2 MinGW-w64 environment provides ready to use toolchains and dependencies
|
||||
through <code>pacman</code>.
|
||||
</p>
|
||||
<p>Make sure to use <samp>mingw64_shell.bat</samp> or <samp>mingw32_shell.bat</samp> to have
|
||||
the correct MinGW-w64 environment. The default install provides shortcuts to
|
||||
them under <code>MinGW-w64 Win64 Shell</code> and <code>MinGW-w64 Win32 Shell</code>.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example"># normal msys2 packages
|
||||
pacman -S make pkgconf diffutils
|
||||
|
||||
# mingw-w64 packages and toolchains
|
||||
pacman -S mingw-w64-x86_64-yasm mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL
|
||||
</pre></div>
|
||||
|
||||
<p>To target 32 bits replace <code>x86_64</code> with <code>i686</code> in the command above.
|
||||
</p>
|
||||
<a name="Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows"></a>
|
||||
<h3 class="section">4.2 Microsoft Visual C++ or Intel C++ Compiler for Windows<span class="pull-right"><a class="anchor hidden-xs" href="#Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>FFmpeg can be built with MSVC 2012 or earlier using a C99-to-C89 conversion utility
|
||||
and wrapper, or with MSVC 2013 and ICL natively.
|
||||
</p>
|
||||
<p>You will need the following prerequisites:
|
||||
</p>
|
||||
<ul>
|
||||
<li> <a href="https://github.com/libav/c99-to-c89/">C99-to-C89 Converter & Wrapper</a>
|
||||
(if using MSVC 2012 or earlier)
|
||||
</li><li> <a href="http://code.google.com/p/msinttypes/">msinttypes</a>
|
||||
(if using MSVC 2012 or earlier)
|
||||
</li><li> <a href="http://msys2.github.io/">MSYS2</a>
|
||||
</li><li> <a href="http://yasm.tortall.net/">YASM</a>
|
||||
(Also available via MSYS2’s package manager.)
|
||||
</li></ul>
|
||||
|
||||
<p>To set up a proper environment in MSYS2, you need to run <code>msys_shell.bat</code> from
|
||||
the Visual Studio or Intel Compiler command prompt.
|
||||
</p>
|
||||
<p>Place <code>yasm.exe</code> somewhere in your <code>PATH</code>. If using MSVC 2012 or
|
||||
earlier, place <code>c99wrap.exe</code> and <code>c99conv.exe</code> somewhere in your
|
||||
<code>PATH</code> as well.
|
||||
</p>
|
||||
<p>Next, make sure any other headers and libs you want to use, such as zlib, are
|
||||
located in a spot that the compiler can see. Do so by modifying the <code>LIB</code>
|
||||
and <code>INCLUDE</code> environment variables to include the <strong>Windows-style</strong>
|
||||
paths to these directories. Alternatively, you can try to use the
|
||||
<code>--extra-cflags</code>/<code>--extra-ldflags</code> configure options. If using MSVC
|
||||
2012 or earlier, place <code>inttypes.h</code> somewhere the compiler can see too.
|
||||
</p>
|
||||
<p>Finally, run:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">For MSVC:
|
||||
./configure --toolchain=msvc
|
||||
|
||||
For ICL:
|
||||
./configure --toolchain=icl
|
||||
|
||||
make
|
||||
make install
|
||||
</pre></div>
|
||||
|
||||
<p>If you wish to compile shared libraries, add <code>--enable-shared</code> to your
|
||||
configure options. Note that due to the way MSVC and ICL handle DLL imports and
|
||||
exports, you cannot compile static and shared libraries at the same time, and
|
||||
enabling shared libraries will automatically disable the static ones.
|
||||
</p>
|
||||
<p>Notes:
|
||||
</p>
|
||||
<ul>
|
||||
<li> If you wish to build with zlib support, you will have to grab a compatible
|
||||
zlib binary from somewhere, with an MSVC import lib, or if you wish to link
|
||||
statically, you can follow the instructions below to build a compatible
|
||||
<code>zlib.lib</code> with MSVC. Regardless of which method you use, you must still
|
||||
follow step 3, or compilation will fail.
|
||||
<ol>
|
||||
<li> Grab the <a href="http://zlib.net/">zlib sources</a>.
|
||||
</li><li> Edit <code>win32/Makefile.msc</code> so that it uses -MT instead of -MD, since
|
||||
this is how FFmpeg is built as well.
|
||||
</li><li> Edit <code>zconf.h</code> and remove its inclusion of <code>unistd.h</code>. This gets
|
||||
erroneously included when building FFmpeg.
|
||||
</li><li> Run <code>nmake -f win32/Makefile.msc</code>.
|
||||
</li><li> Move <code>zlib.lib</code>, <code>zconf.h</code>, and <code>zlib.h</code> to somewhere MSVC
|
||||
can see.
|
||||
</li></ol>
|
||||
|
||||
</li><li> FFmpeg has been tested with the following on i686 and x86_64:
|
||||
<ul>
|
||||
<li> Visual Studio 2010 Pro and Express
|
||||
</li><li> Visual Studio 2012 Pro and Express
|
||||
</li><li> Visual Studio 2013 Pro and Express
|
||||
</li><li> Intel Composer XE 2013
|
||||
</li><li> Intel Composer XE 2013 SP1
|
||||
</li></ul>
|
||||
<p>Anything else is not officially supported.
|
||||
</p>
|
||||
</li></ul>
|
||||
|
||||
<a name="Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b"></a>
|
||||
<h4 class="subsection">4.2.1 Linking to FFmpeg with Microsoft Visual C++<span class="pull-right"><a class="anchor hidden-xs" href="#Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b" aria-hidden="true">TOC</a></span></h4>
|
||||
|
||||
<p>If you plan to link with MSVC-built static libraries, you will need
|
||||
to make sure you have <code>Runtime Library</code> set to
|
||||
<code>Multi-threaded (/MT)</code> in your project’s settings.
|
||||
</p>
|
||||
<p>You will need to define <code>inline</code> to something MSVC understands:
|
||||
</p><div class="example">
|
||||
<pre class="example">#define inline __inline
|
||||
</pre></div>
|
||||
|
||||
<p>Also note, that as stated in <strong>Microsoft Visual C++</strong>, you will need
|
||||
an MSVC-compatible <a href="http://code.google.com/p/msinttypes/">inttypes.h</a>.
|
||||
</p>
|
||||
<p>If you plan on using import libraries created by dlltool, you must
|
||||
set <code>References</code> to <code>No (/OPT:NOREF)</code> under the linker optimization
|
||||
settings, otherwise the resulting binaries will fail during runtime.
|
||||
This is not required when using import libraries generated by <code>lib.exe</code>.
|
||||
This issue is reported upstream at
|
||||
<a href="http://sourceware.org/bugzilla/show_bug.cgi?id=12633">http://sourceware.org/bugzilla/show_bug.cgi?id=12633</a>.
|
||||
</p>
|
||||
<p>To create import libraries that work with the <code>/OPT:REF</code> option
|
||||
(which is enabled by default in Release mode), follow these steps:
|
||||
</p>
|
||||
<ol>
|
||||
<li> Open the <em>Visual Studio Command Prompt</em>.
|
||||
|
||||
<p>Alternatively, in a normal command line prompt, call <samp>vcvars32.bat</samp>
|
||||
which sets up the environment variables for the Visual C++ tools
|
||||
(the standard location for this file is something like
|
||||
<samp>C:\Program Files (x86_\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat</samp>).
|
||||
</p>
|
||||
</li><li> Enter the <samp>bin</samp> directory where the created LIB and DLL files
|
||||
are stored.
|
||||
|
||||
</li><li> Generate new import libraries with <code>lib.exe</code>:
|
||||
|
||||
<div class="example">
|
||||
<pre class="example">lib /machine:i386 /def:..\lib\foo-version.def /out:foo.lib
|
||||
</pre></div>
|
||||
|
||||
<p>Replace <code>foo-version</code> and <code>foo</code> with the respective library names.
|
||||
</p>
|
||||
</li></ol>
|
||||
|
||||
<a name="Cross-compilation-for-Windows-with-Linux"></a><a name="Cross-compilation-for-Windows-with-Linux-1"></a>
|
||||
<h3 class="section">4.3 Cross compilation for Windows with Linux<span class="pull-right"><a class="anchor hidden-xs" href="#Cross-compilation-for-Windows-with-Linux-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Cross-compilation-for-Windows-with-Linux-1" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>You must use the MinGW cross compilation tools available at
|
||||
<a href="http://www.mingw.org/">http://www.mingw.org/</a>.
|
||||
</p>
|
||||
<p>Then configure FFmpeg with the following options:
|
||||
</p><div class="example">
|
||||
<pre class="example">./configure --target-os=mingw32 --cross-prefix=i386-mingw32msvc-
|
||||
</pre></div>
|
||||
<p>(you can change the cross-prefix according to the prefix chosen for the
|
||||
MinGW tools).
|
||||
</p>
|
||||
<p>Then you can easily test FFmpeg with <a href="http://www.winehq.com/">Wine</a>.
|
||||
</p>
|
||||
<a name="Compilation-under-Cygwin"></a>
|
||||
<h3 class="section">4.4 Compilation under Cygwin<span class="pull-right"><a class="anchor hidden-xs" href="#Compilation-under-Cygwin" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Compilation-under-Cygwin" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>Please use Cygwin 1.7.x as the obsolete 1.5.x Cygwin versions lack
|
||||
llrint() in its C library.
|
||||
</p>
|
||||
<p>Install your Cygwin with all the "Base" packages, plus the
|
||||
following "Devel" ones:
|
||||
</p><div class="example">
|
||||
<pre class="example">binutils, gcc4-core, make, git, mingw-runtime, texinfo
|
||||
</pre></div>
|
||||
|
||||
<p>In order to run FATE you will also need the following "Utils" packages:
|
||||
</p><div class="example">
|
||||
<pre class="example">diffutils
|
||||
</pre></div>
|
||||
|
||||
<p>If you want to build FFmpeg with additional libraries, download Cygwin
|
||||
"Devel" packages for Ogg and Vorbis from any Cygwin packages repository:
|
||||
</p><div class="example">
|
||||
<pre class="example">libogg-devel, libvorbis-devel
|
||||
</pre></div>
|
||||
|
||||
<p>These library packages are only available from
|
||||
<a href="http://sourceware.org/cygwinports/">Cygwin Ports</a>:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">yasm, libSDL-devel, libgsm-devel, libmp3lame-devel,
|
||||
libschroedinger1.0-devel, speex-devel, libtheora-devel, libxvidcore-devel
|
||||
</pre></div>
|
||||
|
||||
<p>The recommendation for x264 is to build it from source, as it evolves too
|
||||
quickly for Cygwin Ports to be up to date.
|
||||
</p>
|
||||
<a name="Crosscompilation-for-Windows-under-Cygwin"></a>
|
||||
<h3 class="section">4.5 Crosscompilation for Windows under Cygwin<span class="pull-right"><a class="anchor hidden-xs" href="#Crosscompilation-for-Windows-under-Cygwin" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Crosscompilation-for-Windows-under-Cygwin" aria-hidden="true">TOC</a></span></h3>
|
||||
|
||||
<p>With Cygwin you can create Windows binaries that do not need the cygwin1.dll.
|
||||
</p>
|
||||
<p>Just install your Cygwin as explained before, plus these additional
|
||||
"Devel" packages:
|
||||
</p><div class="example">
|
||||
<pre class="example">gcc-mingw-core, mingw-runtime, mingw-zlib
|
||||
</pre></div>
|
||||
|
||||
<p>and add some special flags to your configure invocation.
|
||||
</p>
|
||||
<p>For a static build run
|
||||
</p><div class="example">
|
||||
<pre class="example">./configure --target-os=mingw32 --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
|
||||
</pre></div>
|
||||
|
||||
<p>and for a build with shared libraries
|
||||
</p><div class="example">
|
||||
<pre class="example">./configure --target-os=mingw32 --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
|
||||
</pre></div>
|
||||
|
||||
<a name="Plan-9"></a>
|
||||
<h2 class="chapter">5 Plan 9<span class="pull-right"><a class="anchor hidden-xs" href="#Plan-9" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Plan-9" aria-hidden="true">TOC</a></span></h2>
|
||||
|
||||
<p>The native <a href="http://plan9.bell-labs.com/plan9/">Plan 9</a> compiler
|
||||
does not implement all the C99 features needed by FFmpeg so the gcc
|
||||
port must be used. Furthermore, a few items missing from the C
|
||||
library and shell environment need to be fixed.
|
||||
</p>
|
||||
<ul>
|
||||
<li> GNU awk, grep, make, and sed
|
||||
|
||||
<p>Working packages of these tools can be found at
|
||||
<a href="http://code.google.com/p/ports2plan9/downloads/list">ports2plan9</a>.
|
||||
They can be installed with <a href="http://9front.org/">9front’s</a> <code>pkg</code>
|
||||
utility by setting <code>pkgpath</code> to
|
||||
<code>http://ports2plan9.googlecode.com/files/</code>.
|
||||
</p>
|
||||
</li><li> Missing/broken <code>head</code> and <code>printf</code> commands
|
||||
|
||||
<p>Replacements adequate for building FFmpeg can be found in the
|
||||
<code>compat/plan9</code> directory. Place these somewhere they will be
|
||||
found by the shell. These are not full implementations of the
|
||||
commands and are <em>not</em> suitable for general use.
|
||||
</p>
|
||||
</li><li> Missing C99 <code>stdint.h</code> and <code>inttypes.h</code>
|
||||
|
||||
<p>Replacement headers are available from
|
||||
<a href="http://code.google.com/p/plan9front/issues/detail?id=152">http://code.google.com/p/plan9front/issues/detail?id=152</a>.
|
||||
</p>
|
||||
</li><li> Missing or non-standard library functions
|
||||
|
||||
<p>Some functions in the C library are missing or incomplete. The
|
||||
<code><a href="http://ports2plan9.googlecode.com/files/gcc-apelibs-1207.tbz">gcc-apelibs-1207</a></code> package from
|
||||
<a href="http://code.google.com/p/ports2plan9/downloads/list">ports2plan9</a>
|
||||
includes an updated C library, but installing the full package gives
|
||||
unusable executables. Instead, keep the files from <code>gccbin.tgz</code>
|
||||
under <code>/386/lib/gnu</code>. From the <code>libc.a</code> archive in the
|
||||
<code>gcc-apelibs-1207</code> package, extract the following object files and
|
||||
turn them into a library:
|
||||
</p>
|
||||
<ul>
|
||||
<li> <code>strerror.o</code>
|
||||
</li><li> <code>strtoll.o</code>
|
||||
</li><li> <code>snprintf.o</code>
|
||||
</li><li> <code>vsnprintf.o</code>
|
||||
</li><li> <code>vfprintf.o</code>
|
||||
</li><li> <code>_IO_getc.o</code>
|
||||
</li><li> <code>_IO_putc.o</code>
|
||||
</li></ul>
|
||||
|
||||
<p>Use the <code>--extra-libs</code> option of <code>configure</code> to inform the
|
||||
build system of this library.
|
||||
</p>
|
||||
</li><li> FPU exceptions enabled by default
|
||||
|
||||
<p>Unlike most other systems, Plan 9 enables FPU exceptions by default.
|
||||
These must be disabled before calling any FFmpeg functions. While the
|
||||
included tools will do this automatically, other users of the
|
||||
libraries must do it themselves.
|
||||
</p>
|
||||
</li></ul>
|
||||
|
||||
|
||||
<p style="font-size: small;">
|
||||
This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AVDCT_H
|
||||
#define AVCODEC_AVDCT_H
|
||||
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
/**
|
||||
* AVDCT context.
|
||||
* @note function pointers can be NULL if the specific features have been
|
||||
* disabled at build time.
|
||||
*/
|
||||
typedef struct AVDCT {
|
||||
const AVClass *av_class;
|
||||
|
||||
void (*idct)(int16_t *block /* align 16 */);
|
||||
|
||||
/**
|
||||
* IDCT input permutation.
|
||||
* Several optimized IDCTs need a permutated input (relative to the
|
||||
* normal order of the reference IDCT).
|
||||
* This permutation must be performed before the idct_put/add.
|
||||
* Note, normally this can be merged with the zigzag/alternate scan<br>
|
||||
* An example to avoid confusion:
|
||||
* - (->decode coeffs -> zigzag reorder -> dequant -> reference IDCT -> ...)
|
||||
* - (x -> reference DCT -> reference IDCT -> x)
|
||||
* - (x -> reference DCT -> simple_mmx_perm = idct_permutation
|
||||
* -> simple_idct_mmx -> x)
|
||||
* - (-> decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant
|
||||
* -> simple_idct_mmx -> ...)
|
||||
*/
|
||||
uint8_t idct_permutation[64];
|
||||
|
||||
void (*fdct)(int16_t *block /* align 16 */);
|
||||
|
||||
|
||||
/**
|
||||
* DCT algorithm.
|
||||
* must use AVOptions to set this field.
|
||||
*/
|
||||
int dct_algo;
|
||||
|
||||
/**
|
||||
* IDCT algorithm.
|
||||
* must use AVOptions to set this field.
|
||||
*/
|
||||
int idct_algo;
|
||||
|
||||
void (*get_pixels)(int16_t *block /* align 16 */,
|
||||
const uint8_t *pixels /* align 8 */,
|
||||
ptrdiff_t line_size);
|
||||
|
||||
int bits_per_sample;
|
||||
} AVDCT;
|
||||
|
||||
/**
|
||||
* Allocates a AVDCT context.
|
||||
* This needs to be initialized with avcodec_dct_init() after optionally
|
||||
* configuring it with AVOptions.
|
||||
*
|
||||
* To free it use av_free()
|
||||
*/
|
||||
AVDCT *avcodec_dct_alloc(void);
|
||||
int avcodec_dct_init(AVDCT *);
|
||||
|
||||
const AVClass *avcodec_dct_get_class(void);
|
||||
|
||||
#endif /* AVCODEC_AVDCT_H */
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AVFFT_H
|
||||
#define AVCODEC_AVFFT_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_fft
|
||||
* FFT functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavc_fft FFT functions
|
||||
* @ingroup lavc_misc
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef float FFTSample;
|
||||
|
||||
typedef struct FFTComplex {
|
||||
FFTSample re, im;
|
||||
} FFTComplex;
|
||||
|
||||
typedef struct FFTContext FFTContext;
|
||||
|
||||
/**
|
||||
* Set up a complex FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param inverse if 0 perform the forward transform, if 1 perform the inverse
|
||||
*/
|
||||
FFTContext *av_fft_init(int nbits, int inverse);
|
||||
|
||||
/**
|
||||
* Do the permutation needed BEFORE calling ff_fft_calc().
|
||||
*/
|
||||
void av_fft_permute(FFTContext *s, FFTComplex *z);
|
||||
|
||||
/**
|
||||
* Do a complex FFT with the parameters defined in av_fft_init(). The
|
||||
* input data must be permuted before. No 1.0/sqrt(n) normalization is done.
|
||||
*/
|
||||
void av_fft_calc(FFTContext *s, FFTComplex *z);
|
||||
|
||||
void av_fft_end(FFTContext *s);
|
||||
|
||||
FFTContext *av_mdct_init(int nbits, int inverse, double scale);
|
||||
void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_mdct_end(FFTContext *s);
|
||||
|
||||
/* Real Discrete Fourier Transform */
|
||||
|
||||
enum RDFTransformType {
|
||||
DFT_R2C,
|
||||
IDFT_C2R,
|
||||
IDFT_R2C,
|
||||
DFT_C2R,
|
||||
};
|
||||
|
||||
typedef struct RDFTContext RDFTContext;
|
||||
|
||||
/**
|
||||
* Set up a real FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param trans the type of transform
|
||||
*/
|
||||
RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
|
||||
void av_rdft_calc(RDFTContext *s, FFTSample *data);
|
||||
void av_rdft_end(RDFTContext *s);
|
||||
|
||||
/* Discrete Cosine Transform */
|
||||
|
||||
typedef struct DCTContext DCTContext;
|
||||
|
||||
enum DCTTransformType {
|
||||
DCT_II = 0,
|
||||
DCT_III,
|
||||
DCT_I,
|
||||
DST_I,
|
||||
};
|
||||
|
||||
/**
|
||||
* Set up DCT.
|
||||
*
|
||||
* @param nbits size of the input array:
|
||||
* (1 << nbits) for DCT-II, DCT-III and DST-I
|
||||
* (1 << nbits) + 1 for DCT-I
|
||||
* @param type the type of transform
|
||||
*
|
||||
* @note the first element of the input of DST-I is ignored
|
||||
*/
|
||||
DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
|
||||
void av_dct_calc(DCTContext *s, FFTSample *data);
|
||||
void av_dct_end (DCTContext *s);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_AVFFT_H */
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Direct3D11 HW acceleration
|
||||
*
|
||||
* copyright (c) 2009 Laurent Aimar
|
||||
* copyright (c) 2015 Steve Lhomme
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_D3D11VA_H
|
||||
#define AVCODEC_D3D11VA_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_d3d11va
|
||||
* Public libavcodec D3D11VA header.
|
||||
*/
|
||||
|
||||
#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0602
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0602
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <d3d11.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_d3d11va Direct3D11
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for Direct3D11 and old UVD/UVD+ ATI video cards
|
||||
#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2 ///< Work around for Direct3D11 and old Intel GPUs with ClearVideo interface
|
||||
|
||||
/**
|
||||
* This structure is used to provides the necessary configurations and data
|
||||
* to the Direct3D11 FFmpeg HWAccel implementation.
|
||||
*
|
||||
* The application must make it available as AVCodecContext.hwaccel_context.
|
||||
*
|
||||
* Use av_d3d11va_alloc_context() exclusively to allocate an AVD3D11VAContext.
|
||||
*/
|
||||
typedef struct AVD3D11VAContext {
|
||||
/**
|
||||
* D3D11 decoder object
|
||||
*/
|
||||
ID3D11VideoDecoder *decoder;
|
||||
|
||||
/**
|
||||
* D3D11 VideoContext
|
||||
*/
|
||||
ID3D11VideoContext *video_context;
|
||||
|
||||
/**
|
||||
* D3D11 configuration used to create the decoder
|
||||
*/
|
||||
D3D11_VIDEO_DECODER_CONFIG *cfg;
|
||||
|
||||
/**
|
||||
* The number of surface in the surface array
|
||||
*/
|
||||
unsigned surface_count;
|
||||
|
||||
/**
|
||||
* The array of Direct3D surfaces used to create the decoder
|
||||
*/
|
||||
ID3D11VideoDecoderOutputView **surface;
|
||||
|
||||
/**
|
||||
* A bit field configuring the workarounds needed for using the decoder
|
||||
*/
|
||||
uint64_t workaround;
|
||||
|
||||
/**
|
||||
* Private to the FFmpeg AVHWAccel implementation
|
||||
*/
|
||||
unsigned report_id;
|
||||
|
||||
/**
|
||||
* Mutex to access video_context
|
||||
*/
|
||||
HANDLE context_mutex;
|
||||
} AVD3D11VAContext;
|
||||
|
||||
/**
|
||||
* Allocate an AVD3D11VAContext.
|
||||
*
|
||||
* @return Newly-allocated AVD3D11VAContext or NULL on failure.
|
||||
*/
|
||||
AVD3D11VAContext *av_d3d11va_alloc_context(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_D3D11VA_H */
|
@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007 Marco Gerards <marco@gnu.org>
|
||||
* Copyright (C) 2009 David Conrad
|
||||
* Copyright (C) 2011 Jordi Ortiz
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_DIRAC_H
|
||||
#define AVCODEC_DIRAC_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Interface to Dirac Decoder/Encoder
|
||||
* @author Marco Gerards <marco@gnu.org>
|
||||
* @author David Conrad
|
||||
* @author Jordi Ortiz
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
|
||||
/**
|
||||
* The spec limits the number of wavelet decompositions to 4 for both
|
||||
* level 1 (VC-2) and 128 (long-gop default).
|
||||
* 5 decompositions is the maximum before >16-bit buffers are needed.
|
||||
* Schroedinger allows this for DD 9,7 and 13,7 wavelets only, limiting
|
||||
* the others to 4 decompositions (or 3 for the fidelity filter).
|
||||
*
|
||||
* We use this instead of MAX_DECOMPOSITIONS to save some memory.
|
||||
*/
|
||||
#define MAX_DWT_LEVELS 5
|
||||
|
||||
/**
|
||||
* Parse code values:
|
||||
*
|
||||
* Dirac Specification ->
|
||||
* 9.6.1 Table 9.1
|
||||
*
|
||||
* VC-2 Specification ->
|
||||
* 10.4.1 Table 10.1
|
||||
*/
|
||||
|
||||
enum DiracParseCodes {
|
||||
DIRAC_PCODE_SEQ_HEADER = 0x00,
|
||||
DIRAC_PCODE_END_SEQ = 0x10,
|
||||
DIRAC_PCODE_AUX = 0x20,
|
||||
DIRAC_PCODE_PAD = 0x30,
|
||||
DIRAC_PCODE_PICTURE_CODED = 0x08,
|
||||
DIRAC_PCODE_PICTURE_RAW = 0x48,
|
||||
DIRAC_PCODE_PICTURE_LOW_DEL = 0xC8,
|
||||
DIRAC_PCODE_PICTURE_HQ = 0xE8,
|
||||
DIRAC_PCODE_INTER_NOREF_CO1 = 0x0A,
|
||||
DIRAC_PCODE_INTER_NOREF_CO2 = 0x09,
|
||||
DIRAC_PCODE_INTER_REF_CO1 = 0x0D,
|
||||
DIRAC_PCODE_INTER_REF_CO2 = 0x0E,
|
||||
DIRAC_PCODE_INTRA_REF_CO = 0x0C,
|
||||
DIRAC_PCODE_INTRA_REF_RAW = 0x4C,
|
||||
DIRAC_PCODE_INTRA_REF_PICT = 0xCC,
|
||||
DIRAC_PCODE_MAGIC = 0x42424344,
|
||||
};
|
||||
|
||||
typedef struct DiracVersionInfo {
|
||||
int major;
|
||||
int minor;
|
||||
} DiracVersionInfo;
|
||||
|
||||
typedef struct AVDiracSeqHeader {
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
uint8_t chroma_format; ///< 0: 444 1: 422 2: 420
|
||||
|
||||
uint8_t interlaced;
|
||||
uint8_t top_field_first;
|
||||
|
||||
uint8_t frame_rate_index; ///< index into dirac_frame_rate[]
|
||||
uint8_t aspect_ratio_index; ///< index into dirac_aspect_ratio[]
|
||||
|
||||
uint16_t clean_width;
|
||||
uint16_t clean_height;
|
||||
uint16_t clean_left_offset;
|
||||
uint16_t clean_right_offset;
|
||||
|
||||
uint8_t pixel_range_index; ///< index into dirac_pixel_range_presets[]
|
||||
uint8_t color_spec_index; ///< index into dirac_color_spec_presets[]
|
||||
|
||||
int profile;
|
||||
int level;
|
||||
|
||||
AVRational framerate;
|
||||
AVRational sample_aspect_ratio;
|
||||
|
||||
enum AVPixelFormat pix_fmt;
|
||||
enum AVColorRange color_range;
|
||||
enum AVColorPrimaries color_primaries;
|
||||
enum AVColorTransferCharacteristic color_trc;
|
||||
enum AVColorSpace colorspace;
|
||||
|
||||
DiracVersionInfo version;
|
||||
int bit_depth;
|
||||
} AVDiracSeqHeader;
|
||||
|
||||
/**
|
||||
* Parse a Dirac sequence header.
|
||||
*
|
||||
* @param dsh this function will allocate and fill an AVDiracSeqHeader struct
|
||||
* and write it into this pointer. The caller must free it with
|
||||
* av_free().
|
||||
* @param buf the data buffer
|
||||
* @param buf_size the size of the data buffer in bytes
|
||||
* @param log_ctx if non-NULL, this function will log errors here
|
||||
* @return 0 on success, a negative AVERROR code on failure
|
||||
*/
|
||||
int av_dirac_parse_sequence_header(AVDiracSeqHeader **dsh,
|
||||
const uint8_t *buf, size_t buf_size,
|
||||
void *log_ctx);
|
||||
|
||||
#endif /* AVCODEC_DIRAC_H */
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_DV_PROFILE_H
|
||||
#define AVCODEC_DV_PROFILE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/pixfmt.h"
|
||||
#include "libavutil/rational.h"
|
||||
#include "avcodec.h"
|
||||
|
||||
/* minimum number of bytes to read from a DV stream in order to
|
||||
* determine the profile */
|
||||
#define DV_PROFILE_BYTES (6 * 80) /* 6 DIF blocks */
|
||||
|
||||
|
||||
/*
|
||||
* AVDVProfile is used to express the differences between various
|
||||
* DV flavors. For now it's primarily used for differentiating
|
||||
* 525/60 and 625/50, but the plans are to use it for various
|
||||
* DV specs as well (e.g. SMPTE314M vs. IEC 61834).
|
||||
*/
|
||||
typedef struct AVDVProfile {
|
||||
int dsf; /* value of the dsf in the DV header */
|
||||
int video_stype; /* stype for VAUX source pack */
|
||||
int frame_size; /* total size of one frame in bytes */
|
||||
int difseg_size; /* number of DIF segments per DIF channel */
|
||||
int n_difchan; /* number of DIF channels per frame */
|
||||
AVRational time_base; /* 1/framerate */
|
||||
int ltc_divisor; /* FPS from the LTS standpoint */
|
||||
int height; /* picture height in pixels */
|
||||
int width; /* picture width in pixels */
|
||||
AVRational sar[2]; /* sample aspect ratios for 4:3 and 16:9 */
|
||||
enum AVPixelFormat pix_fmt; /* picture pixel format */
|
||||
int bpm; /* blocks per macroblock */
|
||||
const uint8_t *block_sizes; /* AC block sizes, in bits */
|
||||
int audio_stride; /* size of audio_shuffle table */
|
||||
int audio_min_samples[3]; /* min amount of audio samples */
|
||||
/* for 48kHz, 44.1kHz and 32kHz */
|
||||
int audio_samples_dist[5]; /* how many samples are supposed to be */
|
||||
/* in each frame in a 5 frames window */
|
||||
const uint8_t (*audio_shuffle)[9]; /* PCM shuffling table */
|
||||
} AVDVProfile;
|
||||
|
||||
/**
|
||||
* Get a DV profile for the provided compressed frame.
|
||||
*
|
||||
* @param sys the profile used for the previous frame, may be NULL
|
||||
* @param frame the compressed data buffer
|
||||
* @param buf_size size of the buffer in bytes
|
||||
* @return the DV profile for the supplied data or NULL on failure
|
||||
*/
|
||||
const AVDVProfile *av_dv_frame_profile(const AVDVProfile *sys,
|
||||
const uint8_t *frame, unsigned buf_size);
|
||||
|
||||
/**
|
||||
* Get a DV profile for the provided stream parameters.
|
||||
*/
|
||||
const AVDVProfile *av_dv_codec_profile(int width, int height, enum AVPixelFormat pix_fmt);
|
||||
|
||||
/**
|
||||
* Get a DV profile for the provided stream parameters.
|
||||
* The frame rate is used as a best-effort parameter.
|
||||
*/
|
||||
const AVDVProfile *av_dv_codec_profile2(int width, int height, enum AVPixelFormat pix_fmt, AVRational frame_rate);
|
||||
|
||||
#endif /* AVCODEC_DV_PROFILE_H */
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
* DXVA2 HW acceleration
|
||||
*
|
||||
* copyright (c) 2009 Laurent Aimar
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_DXVA2_H
|
||||
#define AVCODEC_DXVA2_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_dxva2
|
||||
* Public libavcodec DXVA2 header.
|
||||
*/
|
||||
|
||||
#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0602
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0602
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <d3d9.h>
|
||||
#include <dxva2api.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_dxva2 DXVA2
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards
|
||||
#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2 ///< Work around for DXVA2 and old Intel GPUs with ClearVideo interface
|
||||
|
||||
/**
|
||||
* This structure is used to provides the necessary configurations and data
|
||||
* to the DXVA2 FFmpeg HWAccel implementation.
|
||||
*
|
||||
* The application must make it available as AVCodecContext.hwaccel_context.
|
||||
*/
|
||||
struct dxva_context {
|
||||
/**
|
||||
* DXVA2 decoder object
|
||||
*/
|
||||
IDirectXVideoDecoder *decoder;
|
||||
|
||||
/**
|
||||
* DXVA2 configuration used to create the decoder
|
||||
*/
|
||||
const DXVA2_ConfigPictureDecode *cfg;
|
||||
|
||||
/**
|
||||
* The number of surface in the surface array
|
||||
*/
|
||||
unsigned surface_count;
|
||||
|
||||
/**
|
||||
* The array of Direct3D surfaces used to create the decoder
|
||||
*/
|
||||
LPDIRECT3DSURFACE9 *surface;
|
||||
|
||||
/**
|
||||
* A bit field configuring the workarounds needed for using the decoder
|
||||
*/
|
||||
uint64_t workaround;
|
||||
|
||||
/**
|
||||
* Private to the FFmpeg AVHWAccel implementation
|
||||
*/
|
||||
unsigned report_id;
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_DXVA2_H */
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* JNI public API functions
|
||||
*
|
||||
* Copyright (c) 2015-2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_JNI_H
|
||||
#define AVCODEC_JNI_H
|
||||
|
||||
/*
|
||||
* Manually set a Java virtual machine which will be used to retrieve the JNI
|
||||
* environment. Once a Java VM is set it cannot be changed afterwards, meaning
|
||||
* you can call multiple times av_jni_set_java_vm with the same Java VM pointer
|
||||
* however it will error out if you try to set a different Java VM.
|
||||
*
|
||||
* @param vm Java virtual machine
|
||||
* @param log_ctx context used for logging, can be NULL
|
||||
* @return 0 on success, < 0 otherwise
|
||||
*/
|
||||
int av_jni_set_java_vm(void *vm, void *log_ctx);
|
||||
|
||||
/*
|
||||
* Get the Java virtual machine which has been set with av_jni_set_java_vm.
|
||||
*
|
||||
* @param vm Java virtual machine
|
||||
* @return a pointer to the Java virtual machine
|
||||
*/
|
||||
void *av_jni_get_java_vm(void *log_ctx);
|
||||
|
||||
#endif /* AVCODEC_JNI_H */
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Android MediaCodec public API
|
||||
*
|
||||
* Copyright (c) 2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_MEDIACODEC_H
|
||||
#define AVCODEC_MEDIACODEC_H
|
||||
|
||||
#include "libavcodec/avcodec.h"
|
||||
|
||||
/**
|
||||
* This structure holds a reference to a android/view/Surface object that will
|
||||
* be used as output by the decoder.
|
||||
*
|
||||
*/
|
||||
typedef struct AVMediaCodecContext {
|
||||
|
||||
/**
|
||||
* android/view/Surface object reference.
|
||||
*/
|
||||
void *surface;
|
||||
|
||||
} AVMediaCodecContext;
|
||||
|
||||
/**
|
||||
* Allocate and initialize a MediaCodec context.
|
||||
*
|
||||
* When decoding with MediaCodec is finished, the caller must free the
|
||||
* MediaCodec context with av_mediacodec_default_free.
|
||||
*
|
||||
* @return a pointer to a newly allocated AVMediaCodecContext on success, NULL otherwise
|
||||
*/
|
||||
AVMediaCodecContext *av_mediacodec_alloc_context(void);
|
||||
|
||||
/**
|
||||
* Convenience function that sets up the MediaCodec context.
|
||||
*
|
||||
* @param avctx codec context
|
||||
* @param ctx MediaCodec context to initialize
|
||||
* @param surface reference to an android/view/Surface
|
||||
* @return 0 on success, < 0 otherwise
|
||||
*/
|
||||
int av_mediacodec_default_init(AVCodecContext *avctx, AVMediaCodecContext *ctx, void *surface);
|
||||
|
||||
/**
|
||||
* This function must be called to free the MediaCodec context initialized with
|
||||
* av_mediacodec_default_init().
|
||||
*
|
||||
* @param avctx codec context
|
||||
*/
|
||||
void av_mediacodec_default_free(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* Opaque structure representing a MediaCodec buffer to render.
|
||||
*/
|
||||
typedef struct MediaCodecBuffer AVMediaCodecBuffer;
|
||||
|
||||
/**
|
||||
* Release a MediaCodec buffer and render it to the surface that is associated
|
||||
* with the decoder. This function should only be called once on a given
|
||||
* buffer, once released the underlying buffer returns to the codec, thus
|
||||
* subsequent calls to this function will have no effect.
|
||||
*
|
||||
* @param buffer the buffer to render
|
||||
* @param render 1 to release and render the buffer to the surface or 0 to
|
||||
* discard the buffer
|
||||
* @return 0 on success, < 0 otherwise
|
||||
*/
|
||||
int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render);
|
||||
|
||||
#endif /* AVCODEC_MEDIACODEC_H */
|
@ -1,107 +0,0 @@
|
||||
/*
|
||||
* Intel MediaSDK QSV public API
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_QSV_H
|
||||
#define AVCODEC_QSV_H
|
||||
|
||||
#include <mfx/mfxvideo.h>
|
||||
|
||||
#include "libavutil/buffer.h"
|
||||
|
||||
/**
|
||||
* This struct is used for communicating QSV parameters between libavcodec and
|
||||
* the caller. It is managed by the caller and must be assigned to
|
||||
* AVCodecContext.hwaccel_context.
|
||||
* - decoding: hwaccel_context must be set on return from the get_format()
|
||||
* callback
|
||||
* - encoding: hwaccel_context must be set before avcodec_open2()
|
||||
*/
|
||||
typedef struct AVQSVContext {
|
||||
/**
|
||||
* If non-NULL, the session to use for encoding or decoding.
|
||||
* Otherwise, libavcodec will try to create an internal session.
|
||||
*/
|
||||
mfxSession session;
|
||||
|
||||
/**
|
||||
* The IO pattern to use.
|
||||
*/
|
||||
int iopattern;
|
||||
|
||||
/**
|
||||
* Extra buffers to pass to encoder or decoder initialization.
|
||||
*/
|
||||
mfxExtBuffer **ext_buffers;
|
||||
int nb_ext_buffers;
|
||||
|
||||
/**
|
||||
* Encoding only. If this field is set to non-zero by the caller, libavcodec
|
||||
* will create an mfxExtOpaqueSurfaceAlloc extended buffer and pass it to
|
||||
* the encoder initialization. This only makes sense if iopattern is also
|
||||
* set to MFX_IOPATTERN_IN_OPAQUE_MEMORY.
|
||||
*
|
||||
* The number of allocated opaque surfaces will be the sum of the number
|
||||
* required by the encoder and the user-provided value nb_opaque_surfaces.
|
||||
* The array of the opaque surfaces will be exported to the caller through
|
||||
* the opaque_surfaces field.
|
||||
*/
|
||||
int opaque_alloc;
|
||||
|
||||
/**
|
||||
* Encoding only, and only if opaque_alloc is set to non-zero. Before
|
||||
* calling avcodec_open2(), the caller should set this field to the number
|
||||
* of extra opaque surfaces to allocate beyond what is required by the
|
||||
* encoder.
|
||||
*
|
||||
* On return from avcodec_open2(), this field will be set by libavcodec to
|
||||
* the total number of allocated opaque surfaces.
|
||||
*/
|
||||
int nb_opaque_surfaces;
|
||||
|
||||
/**
|
||||
* Encoding only, and only if opaque_alloc is set to non-zero. On return
|
||||
* from avcodec_open2(), this field will be used by libavcodec to export the
|
||||
* array of the allocated opaque surfaces to the caller, so they can be
|
||||
* passed to other parts of the pipeline.
|
||||
*
|
||||
* The buffer reference exported here is owned and managed by libavcodec,
|
||||
* the callers should make their own reference with av_buffer_ref() and free
|
||||
* it with av_buffer_unref() when it is no longer needed.
|
||||
*
|
||||
* The buffer data is an nb_opaque_surfaces-sized array of mfxFrameSurface1.
|
||||
*/
|
||||
AVBufferRef *opaque_surfaces;
|
||||
|
||||
/**
|
||||
* Encoding only, and only if opaque_alloc is set to non-zero. On return
|
||||
* from avcodec_open2(), this field will be set to the surface type used in
|
||||
* the opaque allocation request.
|
||||
*/
|
||||
int opaque_alloc_type;
|
||||
} AVQSVContext;
|
||||
|
||||
/**
|
||||
* Allocate a new context.
|
||||
*
|
||||
* It must be freed by the caller with av_free().
|
||||
*/
|
||||
AVQSVContext *av_qsv_alloc_context(void);
|
||||
|
||||
#endif /* AVCODEC_QSV_H */
|
@ -1,189 +0,0 @@
|
||||
/*
|
||||
* Video Acceleration API (shared data between FFmpeg and the video player)
|
||||
* HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1
|
||||
*
|
||||
* Copyright (C) 2008-2009 Splitted-Desktop Systems
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VAAPI_H
|
||||
#define AVCODEC_VAAPI_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_vaapi
|
||||
* Public libavcodec VA API header.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libavutil/attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_vaapi VA API Decoding
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* This structure is used to share data between the FFmpeg library and
|
||||
* the client video application.
|
||||
* This shall be zero-allocated and available as
|
||||
* AVCodecContext.hwaccel_context. All user members can be set once
|
||||
* during initialization or through each AVCodecContext.get_buffer()
|
||||
* function call. In any case, they must be valid prior to calling
|
||||
* decoding functions.
|
||||
*/
|
||||
struct vaapi_context {
|
||||
/**
|
||||
* Window system dependent data
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by user
|
||||
*/
|
||||
void *display;
|
||||
|
||||
/**
|
||||
* Configuration ID
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by user
|
||||
*/
|
||||
uint32_t config_id;
|
||||
|
||||
/**
|
||||
* Context ID (video decode pipeline)
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by user
|
||||
*/
|
||||
uint32_t context_id;
|
||||
|
||||
#if FF_API_VAAPI_CONTEXT
|
||||
/**
|
||||
* VAPictureParameterBuffer ID
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
uint32_t pic_param_buf_id;
|
||||
|
||||
/**
|
||||
* VAIQMatrixBuffer ID
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
uint32_t iq_matrix_buf_id;
|
||||
|
||||
/**
|
||||
* VABitPlaneBuffer ID (for VC-1 decoding)
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
uint32_t bitplane_buf_id;
|
||||
|
||||
/**
|
||||
* Slice parameter/data buffer IDs
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
uint32_t *slice_buf_ids;
|
||||
|
||||
/**
|
||||
* Number of effective slice buffer IDs to send to the HW
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
unsigned int n_slice_buf_ids;
|
||||
|
||||
/**
|
||||
* Size of pre-allocated slice_buf_ids
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
unsigned int slice_buf_ids_alloc;
|
||||
|
||||
/**
|
||||
* Pointer to VASliceParameterBuffers
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
void *slice_params;
|
||||
|
||||
/**
|
||||
* Size of a VASliceParameterBuffer element
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
unsigned int slice_param_size;
|
||||
|
||||
/**
|
||||
* Size of pre-allocated slice_params
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
unsigned int slice_params_alloc;
|
||||
|
||||
/**
|
||||
* Number of slices currently filled in
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
unsigned int slice_count;
|
||||
|
||||
/**
|
||||
* Pointer to slice data buffer base
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
const uint8_t *slice_data;
|
||||
|
||||
/**
|
||||
* Current size of slice data
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
uint32_t slice_data_size;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* @} */
|
||||
|
||||
#endif /* AVCODEC_VAAPI_H */
|
@ -1,230 +0,0 @@
|
||||
/*
|
||||
* VDA HW acceleration
|
||||
*
|
||||
* copyright (c) 2011 Sebastien Zwickert
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VDA_H
|
||||
#define AVCODEC_VDA_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_vda
|
||||
* Public libavcodec VDA header.
|
||||
*/
|
||||
|
||||
#include "libavcodec/avcodec.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
|
||||
// http://openradar.appspot.com/8026390
|
||||
#undef __GNUC_STDC_INLINE__
|
||||
|
||||
#define Picture QuickdrawPicture
|
||||
#include <VideoDecodeAcceleration/VDADecoder.h>
|
||||
#undef Picture
|
||||
|
||||
#include "libavcodec/version.h"
|
||||
|
||||
// extra flags not defined in VDADecoder.h
|
||||
enum {
|
||||
kVDADecodeInfo_Asynchronous = 1UL << 0,
|
||||
kVDADecodeInfo_FrameDropped = 1UL << 1
|
||||
};
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_vda VDA
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* This structure is used to provide the necessary configurations and data
|
||||
* to the VDA FFmpeg HWAccel implementation.
|
||||
*
|
||||
* The application must make it available as AVCodecContext.hwaccel_context.
|
||||
*/
|
||||
struct vda_context {
|
||||
/**
|
||||
* VDA decoder object.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
VDADecoder decoder;
|
||||
|
||||
/**
|
||||
* The Core Video pixel buffer that contains the current image data.
|
||||
*
|
||||
* encoding: unused
|
||||
* decoding: Set by libavcodec. Unset by user.
|
||||
*/
|
||||
CVPixelBufferRef cv_buffer;
|
||||
|
||||
/**
|
||||
* Use the hardware decoder in synchronous mode.
|
||||
*
|
||||
* encoding: unused
|
||||
* decoding: Set by user.
|
||||
*/
|
||||
int use_sync_decoding;
|
||||
|
||||
/**
|
||||
* The frame width.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int width;
|
||||
|
||||
/**
|
||||
* The frame height.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int height;
|
||||
|
||||
/**
|
||||
* The frame format.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int format;
|
||||
|
||||
/**
|
||||
* The pixel format for output image buffers.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
OSType cv_pix_fmt_type;
|
||||
|
||||
/**
|
||||
* unused
|
||||
*/
|
||||
uint8_t *priv_bitstream;
|
||||
|
||||
/**
|
||||
* unused
|
||||
*/
|
||||
int priv_bitstream_size;
|
||||
|
||||
/**
|
||||
* unused
|
||||
*/
|
||||
int priv_allocated_size;
|
||||
|
||||
/**
|
||||
* Use av_buffer to manage buffer.
|
||||
* When the flag is set, the CVPixelBuffers returned by the decoder will
|
||||
* be released automatically, so you have to retain them if necessary.
|
||||
* Not setting this flag may cause memory leak.
|
||||
*
|
||||
* encoding: unused
|
||||
* decoding: Set by user.
|
||||
*/
|
||||
int use_ref_buffer;
|
||||
};
|
||||
|
||||
/** Create the video decoder. */
|
||||
int ff_vda_create_decoder(struct vda_context *vda_ctx,
|
||||
uint8_t *extradata,
|
||||
int extradata_size);
|
||||
|
||||
/** Destroy the video decoder. */
|
||||
int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
|
||||
|
||||
/**
|
||||
* This struct holds all the information that needs to be passed
|
||||
* between the caller and libavcodec for initializing VDA decoding.
|
||||
* Its size is not a part of the public ABI, it must be allocated with
|
||||
* av_vda_alloc_context() and freed with av_free().
|
||||
*/
|
||||
typedef struct AVVDAContext {
|
||||
/**
|
||||
* VDA decoder object. Created and freed by the caller.
|
||||
*/
|
||||
VDADecoder decoder;
|
||||
|
||||
/**
|
||||
* The output callback that must be passed to VDADecoderCreate.
|
||||
* Set by av_vda_alloc_context().
|
||||
*/
|
||||
VDADecoderOutputCallback output_callback;
|
||||
|
||||
/**
|
||||
* CVPixelBuffer Format Type that VDA will use for decoded frames; set by
|
||||
* the caller.
|
||||
*/
|
||||
OSType cv_pix_fmt_type;
|
||||
} AVVDAContext;
|
||||
|
||||
/**
|
||||
* Allocate and initialize a VDA context.
|
||||
*
|
||||
* This function should be called from the get_format() callback when the caller
|
||||
* selects the AV_PIX_FMT_VDA format. The caller must then create the decoder
|
||||
* object (using the output callback provided by libavcodec) that will be used
|
||||
* for VDA-accelerated decoding.
|
||||
*
|
||||
* When decoding with VDA is finished, the caller must destroy the decoder
|
||||
* object and free the VDA context using av_free().
|
||||
*
|
||||
* @return the newly allocated context or NULL on failure
|
||||
*/
|
||||
AVVDAContext *av_vda_alloc_context(void);
|
||||
|
||||
/**
|
||||
* This is a convenience function that creates and sets up the VDA context using
|
||||
* an internal implementation.
|
||||
*
|
||||
* @param avctx the corresponding codec context
|
||||
*
|
||||
* @return >= 0 on success, a negative AVERROR code on failure
|
||||
*/
|
||||
int av_vda_default_init(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* This is a convenience function that creates and sets up the VDA context using
|
||||
* an internal implementation.
|
||||
*
|
||||
* @param avctx the corresponding codec context
|
||||
* @param vdactx the VDA context to use
|
||||
*
|
||||
* @return >= 0 on success, a negative AVERROR code on failure
|
||||
*/
|
||||
int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx);
|
||||
|
||||
/**
|
||||
* This function must be called to free the VDA context initialized with
|
||||
* av_vda_default_init().
|
||||
*
|
||||
* @param avctx the corresponding codec context
|
||||
*/
|
||||
void av_vda_default_free(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_VDA_H */
|
@ -1,253 +0,0 @@
|
||||
/*
|
||||
* The Video Decode and Presentation API for UNIX (VDPAU) is used for
|
||||
* hardware-accelerated decoding of MPEG-1/2, H.264 and VC-1.
|
||||
*
|
||||
* Copyright (C) 2008 NVIDIA
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VDPAU_H
|
||||
#define AVCODEC_VDPAU_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_vdpau
|
||||
* Public libavcodec VDPAU header.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_vdpau VDPAU Decoder and Renderer
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* VDPAU hardware acceleration has two modules
|
||||
* - VDPAU decoding
|
||||
* - VDPAU presentation
|
||||
*
|
||||
* The VDPAU decoding module parses all headers using FFmpeg
|
||||
* parsing mechanisms and uses VDPAU for the actual decoding.
|
||||
*
|
||||
* As per the current implementation, the actual decoding
|
||||
* and rendering (API calls) are done as part of the VDPAU
|
||||
* presentation (vo_vdpau.c) module.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <vdpau/vdpau.h>
|
||||
#include <vdpau/vdpau_x11.h>
|
||||
#include "libavutil/avconfig.h"
|
||||
#include "libavutil/attributes.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "version.h"
|
||||
|
||||
#if FF_API_BUFS_VDPAU
|
||||
union AVVDPAUPictureInfo {
|
||||
VdpPictureInfoH264 h264;
|
||||
VdpPictureInfoMPEG1Or2 mpeg;
|
||||
VdpPictureInfoVC1 vc1;
|
||||
VdpPictureInfoMPEG4Part2 mpeg4;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct AVCodecContext;
|
||||
struct AVFrame;
|
||||
|
||||
typedef int (*AVVDPAU_Render2)(struct AVCodecContext *, struct AVFrame *,
|
||||
const VdpPictureInfo *, uint32_t,
|
||||
const VdpBitstreamBuffer *);
|
||||
|
||||
/**
|
||||
* This structure is used to share data between the libavcodec library and
|
||||
* the client video application.
|
||||
* The user shall allocate the structure via the av_alloc_vdpau_hwaccel
|
||||
* function and make it available as
|
||||
* AVCodecContext.hwaccel_context. Members can be set by the user once
|
||||
* during initialization or through each AVCodecContext.get_buffer()
|
||||
* function call. In any case, they must be valid prior to calling
|
||||
* decoding functions.
|
||||
*
|
||||
* The size of this structure is not a part of the public ABI and must not
|
||||
* be used outside of libavcodec. Use av_vdpau_alloc_context() to allocate an
|
||||
* AVVDPAUContext.
|
||||
*/
|
||||
typedef struct AVVDPAUContext {
|
||||
/**
|
||||
* VDPAU decoder handle
|
||||
*
|
||||
* Set by user.
|
||||
*/
|
||||
VdpDecoder decoder;
|
||||
|
||||
/**
|
||||
* VDPAU decoder render callback
|
||||
*
|
||||
* Set by the user.
|
||||
*/
|
||||
VdpDecoderRender *render;
|
||||
|
||||
#if FF_API_BUFS_VDPAU
|
||||
/**
|
||||
* VDPAU picture information
|
||||
*
|
||||
* Set by libavcodec.
|
||||
*/
|
||||
attribute_deprecated
|
||||
union AVVDPAUPictureInfo info;
|
||||
|
||||
/**
|
||||
* Allocated size of the bitstream_buffers table.
|
||||
*
|
||||
* Set by libavcodec.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int bitstream_buffers_allocated;
|
||||
|
||||
/**
|
||||
* Useful bitstream buffers in the bitstream buffers table.
|
||||
*
|
||||
* Set by libavcodec.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int bitstream_buffers_used;
|
||||
|
||||
/**
|
||||
* Table of bitstream buffers.
|
||||
* The user is responsible for freeing this buffer using av_freep().
|
||||
*
|
||||
* Set by libavcodec.
|
||||
*/
|
||||
attribute_deprecated
|
||||
VdpBitstreamBuffer *bitstream_buffers;
|
||||
#endif
|
||||
AVVDPAU_Render2 render2;
|
||||
} AVVDPAUContext;
|
||||
|
||||
/**
|
||||
* @brief allocation function for AVVDPAUContext
|
||||
*
|
||||
* Allows extending the struct without breaking API/ABI
|
||||
*/
|
||||
AVVDPAUContext *av_alloc_vdpaucontext(void);
|
||||
|
||||
AVVDPAU_Render2 av_vdpau_hwaccel_get_render2(const AVVDPAUContext *);
|
||||
void av_vdpau_hwaccel_set_render2(AVVDPAUContext *, AVVDPAU_Render2);
|
||||
|
||||
/**
|
||||
* Associate a VDPAU device with a codec context for hardware acceleration.
|
||||
* This function is meant to be called from the get_format() codec callback,
|
||||
* or earlier. It can also be called after avcodec_flush_buffers() to change
|
||||
* the underlying VDPAU device mid-stream (e.g. to recover from non-transparent
|
||||
* display preemption).
|
||||
*
|
||||
* @note get_format() must return AV_PIX_FMT_VDPAU if this function completes
|
||||
* successfully.
|
||||
*
|
||||
* @param avctx decoding context whose get_format() callback is invoked
|
||||
* @param device VDPAU device handle to use for hardware acceleration
|
||||
* @param get_proc_address VDPAU device driver
|
||||
* @param flags zero of more OR'd AV_HWACCEL_FLAG_* flags
|
||||
*
|
||||
* @return 0 on success, an AVERROR code on failure.
|
||||
*/
|
||||
int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device,
|
||||
VdpGetProcAddress *get_proc_address, unsigned flags);
|
||||
|
||||
/**
|
||||
* Gets the parameters to create an adequate VDPAU video surface for the codec
|
||||
* context using VDPAU hardware decoding acceleration.
|
||||
*
|
||||
* @note Behavior is undefined if the context was not successfully bound to a
|
||||
* VDPAU device using av_vdpau_bind_context().
|
||||
*
|
||||
* @param avctx the codec context being used for decoding the stream
|
||||
* @param type storage space for the VDPAU video surface chroma type
|
||||
* (or NULL to ignore)
|
||||
* @param width storage space for the VDPAU video surface pixel width
|
||||
* (or NULL to ignore)
|
||||
* @param height storage space for the VDPAU video surface pixel height
|
||||
* (or NULL to ignore)
|
||||
*
|
||||
* @return 0 on success, a negative AVERROR code on failure.
|
||||
*/
|
||||
int av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type,
|
||||
uint32_t *width, uint32_t *height);
|
||||
|
||||
/**
|
||||
* Allocate an AVVDPAUContext.
|
||||
*
|
||||
* @return Newly-allocated AVVDPAUContext or NULL on failure.
|
||||
*/
|
||||
AVVDPAUContext *av_vdpau_alloc_context(void);
|
||||
|
||||
#if FF_API_VDPAU_PROFILE
|
||||
/**
|
||||
* Get a decoder profile that should be used for initializing a VDPAU decoder.
|
||||
* Should be called from the AVCodecContext.get_format() callback.
|
||||
*
|
||||
* @deprecated Use av_vdpau_bind_context() instead.
|
||||
*
|
||||
* @param avctx the codec context being used for decoding the stream
|
||||
* @param profile a pointer into which the result will be written on success.
|
||||
* The contents of profile are undefined if this function returns
|
||||
* an error.
|
||||
*
|
||||
* @return 0 on success (non-negative), a negative AVERROR on failure.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_vdpau_get_profile(AVCodecContext *avctx, VdpDecoderProfile *profile);
|
||||
#endif
|
||||
|
||||
#if FF_API_CAP_VDPAU
|
||||
/** @brief The videoSurface is used for rendering. */
|
||||
#define FF_VDPAU_STATE_USED_FOR_RENDER 1
|
||||
|
||||
/**
|
||||
* @brief The videoSurface is needed for reference/prediction.
|
||||
* The codec manipulates this.
|
||||
*/
|
||||
#define FF_VDPAU_STATE_USED_FOR_REFERENCE 2
|
||||
|
||||
/**
|
||||
* @brief This structure is used as a callback between the FFmpeg
|
||||
* decoder (vd_) and presentation (vo_) module.
|
||||
* This is used for defining a video frame containing surface,
|
||||
* picture parameter, bitstream information etc which are passed
|
||||
* between the FFmpeg decoder and its clients.
|
||||
*/
|
||||
struct vdpau_render_state {
|
||||
VdpVideoSurface surface; ///< Used as rendered surface, never changed.
|
||||
|
||||
int state; ///< Holds FF_VDPAU_STATE_* values.
|
||||
|
||||
/** picture parameter information for all supported codecs */
|
||||
union AVVDPAUPictureInfo info;
|
||||
|
||||
/** Describe size/location of the compressed video data.
|
||||
Set to 0 when freeing bitstream_buffers. */
|
||||
int bitstream_buffers_allocated;
|
||||
int bitstream_buffers_used;
|
||||
/** The user is responsible for freeing this buffer using av_freep(). */
|
||||
VdpBitstreamBuffer *bitstream_buffers;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* @}*/
|
||||
|
||||
#endif /* AVCODEC_VDPAU_H */
|
@ -1,230 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VERSION_H
|
||||
#define AVCODEC_VERSION_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup libavc
|
||||
* Libavcodec version macros.
|
||||
*/
|
||||
|
||||
#include "libavutil/version.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 57
|
||||
#define LIBAVCODEC_VERSION_MINOR 64
|
||||
#define LIBAVCODEC_VERSION_MICRO 101
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
LIBAVCODEC_VERSION_MICRO)
|
||||
#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
LIBAVCODEC_VERSION_MICRO)
|
||||
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
|
||||
|
||||
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
* dropped at a future version bump. The defines themselves are not part of
|
||||
* the public API and may change, break or disappear at any time.
|
||||
*
|
||||
* @note, when bumping the major version it is recommended to manually
|
||||
* disable each FF_API_* in its own commit instead of disabling them all
|
||||
* at once through the bump. This improves the git bisect-ability of the change.
|
||||
*/
|
||||
|
||||
#ifndef FF_API_VIMA_DECODER
|
||||
#define FF_API_VIMA_DECODER (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_AUDIO_CONVERT
|
||||
#define FF_API_AUDIO_CONVERT (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_AVCODEC_RESAMPLE
|
||||
#define FF_API_AVCODEC_RESAMPLE FF_API_AUDIO_CONVERT
|
||||
#endif
|
||||
#ifndef FF_API_GETCHROMA
|
||||
#define FF_API_GETCHROMA (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_MISSING_SAMPLE
|
||||
#define FF_API_MISSING_SAMPLE (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_LOWRES
|
||||
#define FF_API_LOWRES (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_CAP_VDPAU
|
||||
#define FF_API_CAP_VDPAU (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_BUFS_VDPAU
|
||||
#define FF_API_BUFS_VDPAU (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_VOXWARE
|
||||
#define FF_API_VOXWARE (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_SET_DIMENSIONS
|
||||
#define FF_API_SET_DIMENSIONS (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_DEBUG_MV
|
||||
#define FF_API_DEBUG_MV (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_AC_VLC
|
||||
#define FF_API_AC_VLC (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_MSMPEG4
|
||||
#define FF_API_OLD_MSMPEG4 (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_ASPECT_EXTENDED
|
||||
#define FF_API_ASPECT_EXTENDED (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_ARCH_ALPHA
|
||||
#define FF_API_ARCH_ALPHA (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_XVMC
|
||||
#define FF_API_XVMC (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_ERROR_RATE
|
||||
#define FF_API_ERROR_RATE (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_QSCALE_TYPE
|
||||
#define FF_API_QSCALE_TYPE (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_MB_TYPE
|
||||
#define FF_API_MB_TYPE (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_MAX_BFRAMES
|
||||
#define FF_API_MAX_BFRAMES (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_NEG_LINESIZES
|
||||
#define FF_API_NEG_LINESIZES (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_EMU_EDGE
|
||||
#define FF_API_EMU_EDGE (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_ARCH_SH4
|
||||
#define FF_API_ARCH_SH4 (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_ARCH_SPARC
|
||||
#define FF_API_ARCH_SPARC (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_UNUSED_MEMBERS
|
||||
#define FF_API_UNUSED_MEMBERS (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_IDCT_XVIDMMX
|
||||
#define FF_API_IDCT_XVIDMMX (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_INPUT_PRESERVED
|
||||
#define FF_API_INPUT_PRESERVED (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_NORMALIZE_AQP
|
||||
#define FF_API_NORMALIZE_AQP (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_GMC
|
||||
#define FF_API_GMC (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_MV0
|
||||
#define FF_API_MV0 (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_CODEC_NAME
|
||||
#define FF_API_CODEC_NAME (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_AFD
|
||||
#define FF_API_AFD (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_VISMV
|
||||
/* XXX: don't forget to drop the -vismv documentation */
|
||||
#define FF_API_VISMV (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_AUDIOENC_DELAY
|
||||
#define FF_API_AUDIOENC_DELAY (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_VAAPI_CONTEXT
|
||||
#define FF_API_VAAPI_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||
#endif
|
||||
#ifndef FF_API_AVCTX_TIMEBASE
|
||||
#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_MPV_OPT
|
||||
#define FF_API_MPV_OPT (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_STREAM_CODEC_TAG
|
||||
#define FF_API_STREAM_CODEC_TAG (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_QUANT_BIAS
|
||||
#define FF_API_QUANT_BIAS (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_RC_STRATEGY
|
||||
#define FF_API_RC_STRATEGY (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_CODED_FRAME
|
||||
#define FF_API_CODED_FRAME (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_MOTION_EST
|
||||
#define FF_API_MOTION_EST (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_WITHOUT_PREFIX
|
||||
#define FF_API_WITHOUT_PREFIX (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_SIDEDATA_ONLY_PKT
|
||||
#define FF_API_SIDEDATA_ONLY_PKT (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_VDPAU_PROFILE
|
||||
#define FF_API_VDPAU_PROFILE (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_CONVERGENCE_DURATION
|
||||
#define FF_API_CONVERGENCE_DURATION (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_AVPICTURE
|
||||
#define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_AVPACKET_OLD_API
|
||||
#define FF_API_AVPACKET_OLD_API (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_RTP_CALLBACK
|
||||
#define FF_API_RTP_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_VBV_DELAY
|
||||
#define FF_API_VBV_DELAY (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_CODER_TYPE
|
||||
#define FF_API_CODER_TYPE (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_STAT_BITS
|
||||
#define FF_API_STAT_BITS (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_PRIVATE_OPT
|
||||
#define FF_API_PRIVATE_OPT (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_ASS_TIMING
|
||||
#define FF_API_ASS_TIMING (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_BSF
|
||||
#define FF_API_OLD_BSF (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_COPY_CONTEXT
|
||||
#define FF_API_COPY_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_GET_CONTEXT_DEFAULTS
|
||||
#define FF_API_GET_CONTEXT_DEFAULTS (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_NVENC_OLD_NAME
|
||||
#define FF_API_NVENC_OLD_NAME (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
|
||||
#endif /* AVCODEC_VERSION_H */
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Videotoolbox hardware acceleration
|
||||
*
|
||||
* copyright (c) 2012 Sebastien Zwickert
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VIDEOTOOLBOX_H
|
||||
#define AVCODEC_VIDEOTOOLBOX_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_videotoolbox
|
||||
* Public libavcodec Videotoolbox header.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define Picture QuickdrawPicture
|
||||
#include <VideoToolbox/VideoToolbox.h>
|
||||
#undef Picture
|
||||
|
||||
#include "libavcodec/avcodec.h"
|
||||
|
||||
/**
|
||||
* This struct holds all the information that needs to be passed
|
||||
* between the caller and libavcodec for initializing Videotoolbox decoding.
|
||||
* Its size is not a part of the public ABI, it must be allocated with
|
||||
* av_videotoolbox_alloc_context() and freed with av_free().
|
||||
*/
|
||||
typedef struct AVVideotoolboxContext {
|
||||
/**
|
||||
* Videotoolbox decompression session object.
|
||||
* Created and freed the caller.
|
||||
*/
|
||||
VTDecompressionSessionRef session;
|
||||
|
||||
/**
|
||||
* The output callback that must be passed to the session.
|
||||
* Set by av_videottoolbox_default_init()
|
||||
*/
|
||||
VTDecompressionOutputCallback output_callback;
|
||||
|
||||
/**
|
||||
* CVPixelBuffer Format Type that Videotoolbox will use for decoded frames.
|
||||
* set by the caller.
|
||||
*/
|
||||
OSType cv_pix_fmt_type;
|
||||
|
||||
/**
|
||||
* CoreMedia Format Description that Videotoolbox will use to create the decompression session.
|
||||
* Set by the caller.
|
||||
*/
|
||||
CMVideoFormatDescriptionRef cm_fmt_desc;
|
||||
|
||||
/**
|
||||
* CoreMedia codec type that Videotoolbox will use to create the decompression session.
|
||||
* Set by the caller.
|
||||
*/
|
||||
int cm_codec_type;
|
||||
} AVVideotoolboxContext;
|
||||
|
||||
/**
|
||||
* Allocate and initialize a Videotoolbox context.
|
||||
*
|
||||
* This function should be called from the get_format() callback when the caller
|
||||
* selects the AV_PIX_FMT_VIDETOOLBOX format. The caller must then create
|
||||
* the decoder object (using the output callback provided by libavcodec) that
|
||||
* will be used for Videotoolbox-accelerated decoding.
|
||||
*
|
||||
* When decoding with Videotoolbox is finished, the caller must destroy the decoder
|
||||
* object and free the Videotoolbox context using av_free().
|
||||
*
|
||||
* @return the newly allocated context or NULL on failure
|
||||
*/
|
||||
AVVideotoolboxContext *av_videotoolbox_alloc_context(void);
|
||||
|
||||
/**
|
||||
* This is a convenience function that creates and sets up the Videotoolbox context using
|
||||
* an internal implementation.
|
||||
*
|
||||
* @param avctx the corresponding codec context
|
||||
*
|
||||
* @return >= 0 on success, a negative AVERROR code on failure
|
||||
*/
|
||||
int av_videotoolbox_default_init(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* This is a convenience function that creates and sets up the Videotoolbox context using
|
||||
* an internal implementation.
|
||||
*
|
||||
* @param avctx the corresponding codec context
|
||||
* @param vtctx the Videotoolbox context to use
|
||||
*
|
||||
* @return >= 0 on success, a negative AVERROR code on failure
|
||||
*/
|
||||
int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx);
|
||||
|
||||
/**
|
||||
* This function must be called to free the Videotoolbox context initialized with
|
||||
* av_videotoolbox_default_init().
|
||||
*
|
||||
* @param avctx the corresponding codec context
|
||||
*/
|
||||
void av_videotoolbox_default_free(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_VIDEOTOOLBOX_H */
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* A public API for Vorbis parsing
|
||||
*
|
||||
* Determines the duration for each packet.
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VORBIS_PARSER_H
|
||||
#define AVCODEC_VORBIS_PARSER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct AVVorbisParseContext AVVorbisParseContext;
|
||||
|
||||
/**
|
||||
* Allocate and initialize the Vorbis parser using headers in the extradata.
|
||||
*
|
||||
* @param avctx codec context
|
||||
* @param s Vorbis parser context
|
||||
*/
|
||||
AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata,
|
||||
int extradata_size);
|
||||
|
||||
/**
|
||||
* Free the parser and everything associated with it.
|
||||
*/
|
||||
void av_vorbis_parse_free(AVVorbisParseContext **s);
|
||||
|
||||
#define VORBIS_FLAG_HEADER 0x00000001
|
||||
#define VORBIS_FLAG_COMMENT 0x00000002
|
||||
#define VORBIS_FLAG_SETUP 0x00000004
|
||||
|
||||
/**
|
||||
* Get the duration for a Vorbis packet.
|
||||
*
|
||||
* If @p flags is @c NULL,
|
||||
* special frames are considered invalid.
|
||||
*
|
||||
* @param s Vorbis parser context
|
||||
* @param buf buffer containing a Vorbis frame
|
||||
* @param buf_size size of the buffer
|
||||
* @param flags flags for special frames
|
||||
*/
|
||||
int av_vorbis_parse_frame_flags(AVVorbisParseContext *s, const uint8_t *buf,
|
||||
int buf_size, int *flags);
|
||||
|
||||
/**
|
||||
* Get the duration for a Vorbis packet.
|
||||
*
|
||||
* @param s Vorbis parser context
|
||||
* @param buf buffer containing a Vorbis frame
|
||||
* @param buf_size size of the buffer
|
||||
*/
|
||||
int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf,
|
||||
int buf_size);
|
||||
|
||||
void av_vorbis_parse_reset(AVVorbisParseContext *s);
|
||||
|
||||
#endif /* AVCODEC_VORBIS_PARSER_H */
|
@ -1,170 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003 Ivan Kalvachev
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_XVMC_H
|
||||
#define AVCODEC_XVMC_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_xvmc
|
||||
* Public libavcodec XvMC header.
|
||||
*/
|
||||
|
||||
#include <X11/extensions/XvMC.h>
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "version.h"
|
||||
#include "avcodec.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_xvmc XvMC
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_XVMC_ID 0x1DC711C0 /**< special value to ensure that regular pixel routines haven't corrupted the struct
|
||||
the number is 1337 speak for the letters IDCT MCo (motion compensation) */
|
||||
|
||||
struct attribute_deprecated xvmc_pix_fmt {
|
||||
/** The field contains the special constant value AV_XVMC_ID.
|
||||
It is used as a test that the application correctly uses the API,
|
||||
and that there is no corruption caused by pixel routines.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int xvmc_id;
|
||||
|
||||
/** Pointer to the block array allocated by XvMCCreateBlocks().
|
||||
The array has to be freed by XvMCDestroyBlocks().
|
||||
Each group of 64 values represents one data block of differential
|
||||
pixel information (in MoCo mode) or coefficients for IDCT.
|
||||
- application - set the pointer during initialization
|
||||
- libavcodec - fills coefficients/pixel data into the array
|
||||
*/
|
||||
short* data_blocks;
|
||||
|
||||
/** Pointer to the macroblock description array allocated by
|
||||
XvMCCreateMacroBlocks() and freed by XvMCDestroyMacroBlocks().
|
||||
- application - set the pointer during initialization
|
||||
- libavcodec - fills description data into the array
|
||||
*/
|
||||
XvMCMacroBlock* mv_blocks;
|
||||
|
||||
/** Number of macroblock descriptions that can be stored in the mv_blocks
|
||||
array.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int allocated_mv_blocks;
|
||||
|
||||
/** Number of blocks that can be stored at once in the data_blocks array.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int allocated_data_blocks;
|
||||
|
||||
/** Indicate that the hardware would interpret data_blocks as IDCT
|
||||
coefficients and perform IDCT on them.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int idct;
|
||||
|
||||
/** In MoCo mode it indicates that intra macroblocks are assumed to be in
|
||||
unsigned format; same as the XVMC_INTRA_UNSIGNED flag.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int unsigned_intra;
|
||||
|
||||
/** Pointer to the surface allocated by XvMCCreateSurface().
|
||||
It has to be freed by XvMCDestroySurface() on application exit.
|
||||
It identifies the frame and its state on the video hardware.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
XvMCSurface* p_surface;
|
||||
|
||||
/** Set by the decoder before calling ff_draw_horiz_band(),
|
||||
needed by the XvMCRenderSurface function. */
|
||||
//@{
|
||||
/** Pointer to the surface used as past reference
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
XvMCSurface* p_past_surface;
|
||||
|
||||
/** Pointer to the surface used as future reference
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
XvMCSurface* p_future_surface;
|
||||
|
||||
/** top/bottom field or frame
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
unsigned int picture_structure;
|
||||
|
||||
/** XVMC_SECOND_FIELD - 1st or 2nd field in the sequence
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
unsigned int flags;
|
||||
//}@
|
||||
|
||||
/** Number of macroblock descriptions in the mv_blocks array
|
||||
that have already been passed to the hardware.
|
||||
- application - zeroes it on get_buffer().
|
||||
A successful ff_draw_horiz_band() may increment it
|
||||
with filled_mb_block_num or zero both.
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int start_mv_blocks_num;
|
||||
|
||||
/** Number of new macroblock descriptions in the mv_blocks array (after
|
||||
start_mv_blocks_num) that are filled by libavcodec and have to be
|
||||
passed to the hardware.
|
||||
- application - zeroes it on get_buffer() or after successful
|
||||
ff_draw_horiz_band().
|
||||
- libavcodec - increment with one of each stored MB
|
||||
*/
|
||||
int filled_mv_blocks_num;
|
||||
|
||||
/** Number of the next free data block; one data block consists of
|
||||
64 short values in the data_blocks array.
|
||||
All blocks before this one have already been claimed by placing their
|
||||
position into the corresponding block description structure field,
|
||||
that are part of the mv_blocks array.
|
||||
- application - zeroes it on get_buffer().
|
||||
A successful ff_draw_horiz_band() may zero it together
|
||||
with start_mb_blocks_num.
|
||||
- libavcodec - each decoded macroblock increases it by the number
|
||||
of coded blocks it contains.
|
||||
*/
|
||||
int next_free_data_block_num;
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_XVMC_H */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user