diff --git a/mplayer/Changelog b/mplayer/Changelog
index 98b9a7ff..b822ae25 100644
--- a/mplayer/Changelog
+++ b/mplayer/Changelog
@@ -3,7 +3,8 @@ MPlayer (1.0)
rc5:
Decoders:
- * FFmpeg AAC decoder is now preferred over libfaad2
+ * FFmpeg AAC decoder is now preferred over libfaad2 and the internal
+ libfaad2 forked copy has been removed in its favor
Demuxers:
* experimental support for using binary Quicktime codecs with -demuxer lavf.
diff --git a/mplayer/Copyright b/mplayer/Copyright
index aefcc134..1c816c25 100644
--- a/mplayer/Copyright
+++ b/mplayer/Copyright
@@ -21,14 +21,6 @@ License: GNU Lesser General Public License, some parts GNU General Public
License, GNU General Public License when combined
-Name: FAAD2
-Version: 2.1 beta (20040915 CVS snapshot) + fixes and portability patches
-URL: http://www.audiocoding.com
-Directory: libfaad2
-Copyright: 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-License: GNU General Public License
-
-
Name: libdvdcss
Version: Subversion r237 + local changes
URL: http://developers.videolan.org/libdvdcss/
diff --git a/mplayer/DOCS/codecs-status.html b/mplayer/DOCS/codecs-status.html
index 0fd72888..96e85992 100644
--- a/mplayer/DOCS/codecs-status.html
+++ b/mplayer/DOCS/codecs-status.html
@@ -674,7 +674,7 @@
Status of codecs support
FFmpeg H.264
- H264 h264 X264 x264 avc1 AVC1 davc DAVC vvvc
+ H264 h264 X264 x264 avc1 AVC1 davc DAVC vvvc ai55 ai15 ai1q ai5q
h264
YV12 I420 IYUV
-
@@ -682,7 +682,7 @@ Status of codecs support
FFmpeg H.264 (VDPAU)
- H264 h264 X264 x264 avc1 AVC1 davc DAVC
+ H264 h264 X264 x264 avc1 AVC1 davc DAVC ai55 ai15 ai1q ai5q
h264_vdpau
VDPAU_H264
-
@@ -690,7 +690,7 @@ Status of codecs support
CoreAVC H.264 for x86 - http://corecodec.org/
- H264 h264 X264 x264 avc1 davc DAVC VSSH
+ H264 h264 X264 x264 avc1 davc DAVC VSSH ai55 ai15 ai1q ai5q
CoreAVCDecoder.ax
YV12 IYUV I420 YUY2
this codec will only work after purchasing it
@@ -1906,7 +1906,7 @@ Status of codecs support
Apple ProRes 422 (HQ) decoder
- apch apcn apcs
+ apch apcn apcs apco ap4h
AppleProResDecoder.qtx
YUY2
-
@@ -2087,6 +2087,14 @@ Status of codecs support
BGR24 BGR15 BGR8
-
+
+
+ FFmpeg XAN wc4
+ Xxan
+ xan_wc4
+ YV12
+ -
+
FFmpeg Electronic Arts TGV
@@ -3240,9 +3248,9 @@ Status of codecs support
FFmpeg XAN DPCM audio
- 0x6E617841
+ 0x6E617841 0x594A
xan_dpcm
- only works with libavformat demuxer
+ Wing Commander 4 files only work with libavformat demuxer
@@ -3552,6 +3560,13 @@ Status of codecs support
pcm_bluray
-
+
+
+ Leitch/Harris PCM
+ 0x46584C50
+ pcm_lxf
+ -
+
FFmpeg AC-3
diff --git a/mplayer/DOCS/man/cs/mplayer.1 b/mplayer/DOCS/man/cs/mplayer.1
index 8c8e9377..559c5727 100644
--- a/mplayer/DOCS/man/cs/mplayer.1
+++ b/mplayer/DOCS/man/cs/mplayer.1
@@ -365,30 +365,6 @@ Převíjení zpět/\:vpřed o 1 minutu.
.PD 1
.PP
.RS
-(Následující klávesy jsou platné, pokud jste zakompilovali podporu GUI
-a dostanou přednost před výše uvedenými definicemi tlačítek.)
-.RE
-.PP
-.PD 0
-.RS
-.IPs "ENTER"
-Start přehrávání.
-.IPs "ESC\ \ "
-Stop přehrávání.
-.IPs "l\ \ \ \ "
-Načtení souboru.
-.IPs "t\ \ \ \ "
-Načtení titulků.
-.IPs "c\ \ \ \ "
-Otevře volič skinů.
-.IPs "p\ \ \ \ "
-Otevře playlist.
-.IPs "r\ \ \ \ "
-Otevře předvolby.
-.RE
-.PD 1
-.PP
-.RS
(Následující klávesy jsou platné, pokud jste zakompilovali podporu vstupu z TV
nebo DVB a dostanou přednost před výše uvedenými definicemi tlačítek.)
.RE
diff --git a/mplayer/DOCS/man/de/mplayer.1 b/mplayer/DOCS/man/de/mplayer.1
index ebfecdde..a2cd58a6 100644
--- a/mplayer/DOCS/man/de/mplayer.1
+++ b/mplayer/DOCS/man/de/mplayer.1
@@ -377,30 +377,6 @@ Im Minutenschritt zur
.PD 1
.PP
.RS
-(Die folgenden Tasten sind nur gltig, falls MPlayer mit GUI-Untersttzung
-bersetzt wurde und haben Vorrang vor den oben definierten Tasten.)
-.RE
-.PP
-.PD 0
-.RSs
-.IPs ENTER
-Startet Wiedergabe.
-.IPs "ESC\ \ "
-Beendet die Wiedergabe.
-.IPs "l\ \ \ \ "
-Datei laden.
-.IPs "t\ \ \ \ "
-Untertitel laden.
-.IPs "c\ \ \ \ "
-Skinbrowser ffnen.
-.IPs "p\ \ \ \ "
-Playlist ffnen.
-.IPs "r\ \ \ \ "
-Konfigurationsdialog ffnen.
-.RE
-.PD 1
-.PP
-.RS
(Die folgenden Tasten sind nur gltig, falls MPlayer mit Untersttzung
fr TV-Karten oder DVB-Input bersetzt wurde und haben Vorrang vor den oben
definierten Tasten.)
@@ -2416,6 +2392,24 @@ Deaktiviert das automatische Laden von Untertiteln.
Setzt die Anzeigedauer der OSD-Meldungen in ms (Standard: 1000).
.
.TP
+.B \-osd\-fractions <0\-2>
+Setzt die Art der Anzeige von Nachkommastellen des aktuellen Zeitstempels im
+OSD:
+.PD 0
+.RSs
+.IPs 0
+Keine Anzeige der Nachkommastellen (Standard).
+.IPs 1
+Zeige die ersten beiden Nachkommastellen.
+.IPs 2
+Zeige genherte Framezahl an.
+Die angezeigte Framezahl ist nicht exakt, sondern nur genhert.
+Fr variable FPS ist die Nherung weit von der tatschlichen Framezahl
+entfernt.
+.RE
+.PD 1
+.
+.TP
.B \-osdlevel <0\-3> (nur bei MPlayer)
Gibt den Modus an, in dem das OSD startet:
.PD 0
@@ -11265,10 +11259,22 @@ Eingabebelegungen (siehe '\-input keylist' f
aller Tastennamen)
.
.TP
+~/.mplayer/\:gui.conf
+Konfigurationsdatei fr die GUI
+.
+.TP
+~/.mplayer/\:gui.history
+Verzeichnis-Verlaufsdatei fr die GUI
+.
+.TP
~/.mplayer/\:gui.pl
Playlist fr die GUI
.
.TP
+~/.mplayer/\:gui.url
+URL-Liste fr die GUI
+.
+.TP
~/.mplayer/\:font/
Schriftartenverzeichnis (es mssen sich eine Datei font.desc und Dateien mit
der Erweiterung .RAW in dem Verzeichnis befinden)
diff --git a/mplayer/DOCS/man/en/mplayer.1 b/mplayer/DOCS/man/en/mplayer.1
index 5b0fbb77..799b366f 100644
--- a/mplayer/DOCS/man/en/mplayer.1
+++ b/mplayer/DOCS/man/en/mplayer.1
@@ -1,4 +1,4 @@
-.\" $Revision: 32699 $
+.\" $Revision: 32946 $
.\" MPlayer (C) 2000-2010 MPlayer Team
.\" This man page was/is done by Gabucino, Diego Biurrun, Jonas Jermann
.
@@ -374,30 +374,6 @@ Seek backward/\:forward 1 minute.
.PD 1
.PP
.RS
-(The following keys are only valid if GUI support is compiled in
-and will take precedence over the keys defined above.)
-.RE
-.PP
-.PD 0
-.RS
-.IPs ENTER
-Start playing.
-.IPs "ESC\ \ "
-Stop playing.
-.IPs "l\ \ \ \ "
-Load file.
-.IPs "t\ \ \ \ "
-Load subtitle.
-.IPs "c\ \ \ \ "
-Open skin browser.
-.IPs "p\ \ \ \ "
-Open playlist.
-.IPs "r\ \ \ \ "
-Open preferences.
-.RE
-.PD 1
-.PP
-.RS
(The following keys are only valid if you compiled with TV or DVB input
support and will take precedence over the keys defined above.)
.RE
@@ -1552,8 +1528,7 @@ on how to use this.
Stop at given time or byte position.
.br
.I NOTE:
-Byte position is enabled only for MEncoder and will not be accurate, as it can
-only stop at a frame boundary.
+Byte position may not be accurate, as it can only stop at a frame boundary.
When used in conjunction with \-ss option, \-endpos time will shift forward by
seconds specified with \-ss.
.sp 1
@@ -2427,6 +2402,23 @@ Turns off automatic subtitle file loading.
Set the duration of the OSD messages in ms (default: 1000).
.
.TP
+.B \-osd\-fractions <0\-2>
+Set how fractions of seconds of the current timestamp are printed on the OSD:
+.PD 0
+.RSs
+.IPs 0
+Do not display fractions (default).
+.IPs 1
+Show the first two decimals.
+.IPs 2
+Show approximated frame count within current second.
+This frame count is not accurate but only an approximation.
+For variable fps, the approximation is known to be far off the correct frame
+count.
+.RE
+.PD 1
+.
+.TP
.B \-osdlevel <0\-3> (MPlayer only)
Specifies which mode the OSD should start in.
.PD 0
@@ -2558,7 +2550,7 @@ exact match
.IPs 1
Load all subs containing movie name.
.IPs 2
-Load all subs in the current directory.
+Load all subs in the current and \-sub\-paths directories.
.RE
.PD 1
.
@@ -2625,6 +2617,27 @@ Guess the encoding for Polish, fall back on cp1250.
.PD 1
.
.TP
+.B \-sub\-paths
+Specify extra subtitle paths to track in the media directory.
+.sp 1
+.I EXAMPLE:
+Assuming that /path/\:to/\:movie/\:movie.avi is played and \-sub\-paths
+sub,subtitles,/tmp/subs is specified, MPlayer searches for subtitle files in
+these directories:
+.RSs
+/path/\:to/\:movie/
+.br
+/path/\:to/\:movie/\:sub/
+.br
+/path/\:to/\:movie/\:subtitles/
+.br
+/tmp/\:subs/
+.br
+~/.mplayer/\:sub/
+.RE
+.PD 1
+.
+.TP
.B \-subdelay
Delays subtitles by seconds.
Can be negative.
@@ -4593,6 +4606,8 @@ Specifies the compression level.
0 is no compression, 9 is maximum compression.
.IPs outdir=
Specify the directory to save the PNG files to (default: ./).
+.IPs prefix=
+Specify the prefix to be used for the PNG filenames (default: no prefix).
.IPs alpha (default: noalpha)
Create PNG files with an alpha channel.
Note that MPlayer in general does not support alpha, so this will only
@@ -10341,6 +10356,8 @@ Note that quantization in H.264 works differently from MPEG-1/2/4:
H.264's quantization parameter (QP) is on a logarithmic scale.
The mapping is approximately H264QP = 12 + 6*log2(MPEGQP).
For example, MPEG at QP=2 is equivalent to H.264 at QP=18.
+Generally, this option should be avoided and crf should be used instead
+as crf will yield better visual results for the same size.
.
.TP
.B crf=<1.0\-50.0>
@@ -10348,6 +10365,7 @@ Enables constant quality mode, and selects the quality.
The scale is similar to QP.
Like the bitrate-based modes, this allows each frame to use a
different QP based on the frame's complexity.
+This option should generally be used instead of qp.
.
.TP
.B pass=<1\-3>
@@ -11727,24 +11745,24 @@ input bindings (see '\-input keylist' for the full list)
GUI configuration file
.
.TP
+~/.mplayer/\:gui.history
+GUI directory history
+.
+.TP
~/.mplayer/\:gui.pl
GUI playlist
.
.TP
+~/.mplayer/\:gui.url
+GUI URL list
+.
+.TP
~/.mplayer/\:font/
font directory (There must be a font.desc file and files with .RAW extension.)
.
.TP
~/.mplayer/\:DVDkeys/
cached CSS keys
-.
-.TP
-Assuming that /path/\:to/\:movie.avi is played, MPlayer searches for sub files
-in this order:
-.RS
-/path/\:to/\:movie.sub
-.br
-~/.mplayer/\:sub/\:movie.sub
.RE
.PD 1
.
diff --git a/mplayer/DOCS/man/en/mplayer.1.html b/mplayer/DOCS/man/en/mplayer.1.html
index aa9fb4b9..799ed4fe 100644
--- a/mplayer/DOCS/man/en/mplayer.1.html
+++ b/mplayer/DOCS/man/en/mplayer.1.html
@@ -1,5 +1,5 @@
-
+
@@ -479,37 +479,6 @@ INTERACTIVE CONTROL
Seek backward/forward 1
minute.
-(The following
-keys are only valid if GUI support is compiled in and will
-take precedence over the keys defined above.)
-ENTER
-
-Start playing.
-
-ESC
-
-Stop playing.
-
-l
-
-Load file.
-
-t
-
-Load subtitle.
-
-c
-
-Open skin browser.
-
-p
-
-Open playlist.
-
-r
-
-Open preferences.
-
(The following
keys are only valid if you compiled with TV or DVB input
support and will take precedence over the keys defined
@@ -3410,6 +3379,52 @@
OSD/SUBTITLE OPTIONS
Set the duration of the OSD
messages in ms (default: 1000).
+−osd−fractions
+<0−2>
+
+Set how fractions of seconds of
+the current timestamp are printed on the OSD:
+
+
+
+
+
+
+
+0
+
+
+
+
+Do not display fractions (default).
+
+
+
+
+
+1
+
+
+
+
+Show the first two decimals.
+
+
+
+
+
+2
+
+
+
+
+Show approximated frame count within current second.
+This frame count is not accurate but only an approximation.
+For variable fps, the approximation is known to be far off
+the correct frame count.
+
+
−osdlevel
<0−3> (MPlayer only)
@@ -3709,12 +3724,10 @@ OSD/SUBTITLE OPTIONS
0
-
+
-exact match
-
-
+exact match
@@ -3722,12 +3735,10 @@ OSD/SUBTITLE OPTIONS
1
-
+
-Load all subs containing movie name.
-
-
+Load all subs containing movie name.
@@ -3735,12 +3746,11 @@ OSD/SUBTITLE OPTIONS
2
-
+
-Load all subs in the current directory.
-
-
+Load all subs in the current and −sub−paths
+directories.
@@ -3842,6 +3852,25 @@ OSD/SUBTITLE OPTIONS
Guess the encoding for Polish,
fall back on cp1250.
+−sub−paths
+<path1,path2,...>
+
+Specify extra subtitle paths to
+track in the media directory.
+
+
+EXAMPLE:
+Assuming that /path/to/movie/movie.avi is played and
+−sub−paths sub,subtitles,/tmp/subs is specified,
+MPlayer searches for subtitle files in these
+directories:
+
+/path/to/movie/
+/path/to/movie/sub/
+/path/to/movie/subtitles/
+/tmp/subs/
+~/.mplayer/sub/
+
−subdelay
<sec>
@@ -6759,6 +6788,11 @@ VIDEO OUTPUT DRIVERS (MPLAYER ONLY)
Specify the directory to save
the PNG files to (default: ./).
+prefix=<prefix>
+
+Specify the prefix to be used
+for the PNG filenames (default: no prefix).
+
alpha
Create PNG files with an alpha
@@ -17689,10 +17723,18 @@
FILES
GUI configuration file
+~/.mplayer/gui.history
+
+GUI directory history
+
~/.mplayer/gui.pl
GUI playlist
+~/.mplayer/gui.url
+
+GUI URL list
+
~/.mplayer/font/
font directory (There must be a
@@ -17702,14 +17744,6 @@
FILES
cached CSS keys
-Assuming that
-/path/to/movie.avi is played, MPlayer searches for sub
-files
-
-in this order:
-/path/to/movie.sub
-~/.mplayer/sub/movie.sub
-
EXAMPLES OF MPLAYER USAGE
diff --git a/mplayer/DOCS/man/es/mplayer.1 b/mplayer/DOCS/man/es/mplayer.1
index cdd9a7bd..b7cebbc2 100644
--- a/mplayer/DOCS/man/es/mplayer.1
+++ b/mplayer/DOCS/man/es/mplayer.1
@@ -350,24 +350,6 @@ Detiene la reproducci
Posiciona atrs/\:adelante 1 minuto.
.PD 1
.PP
-(Las siguientes teclas son vlidas nicamente cuando se ha compilado con soporte
- para la interfaz grfica y tienen precedencia sobre las anteriores)
-.PP
-.PD 0
-.IPs "ENTER"
-Comienza la reproduccin.
-.IPs "ESC\ \ \ \ "
-Detiene la reproduccin.
-.IPs "l\ \ \ \ "
-Carga un fichero.
-.IPs "t\ \ \ \ "
-Carga los subttulos.
-.IPs "c\ \ \ \ "
-Abre el navegador de temas.
-.IPs "r\ \ \ \ "
-Abre el dilogo de preferencias.
-.PD 1
-.PP
(Las siguientes teclas son vlidas nicamente cuando se ha compilado con soporte
para la TV o DVB y tienen precedencia sobre las anteriores)
.PP
diff --git a/mplayer/DOCS/man/fr/mplayer.1 b/mplayer/DOCS/man/fr/mplayer.1
index 25db3bf0..ef205713 100644
--- a/mplayer/DOCS/man/fr/mplayer.1
+++ b/mplayer/DOCS/man/fr/mplayer.1
@@ -384,32 +384,6 @@ Navigue en arri
.
.PP
.RS
-(Les touches suivantes sont valides uniquement si MPlayer a t
-compil avec le support de la GUI et si elles ont une priorit suprieure celles
-dfinies plus haut dans ce document.)
-.RE
-.PP
-.PD 0
-.RS
-.IPs "ENTRE"
-Dmarre la lecture.
-.IPs "ESC\ \ "
-Stoppe la lecture.
-.IPs "l\ \ \ \ "
-Charge un fichier.
-.IPs "t\ \ \ \ "
-Charge un sous-titre.
-.IPs "c\ \ \ \ "
-Ouvre le navigateur de skins.
-.IPs "p\ \ \ \ "
-Ouvre la liste de lecture (playlist).
-.IPs "r\ \ \ \ "
-Ouvre la fentre de prfrences.
-.RE
-.PD 1
-.
-.PP
-.RS
(Les touches suivantes ne sont valides que si MPlayer a t
compil avec le support de l'entre TV ou DVB et si elles ont une priorit
suprieure celles dfinies plus haut dans ce document.)
diff --git a/mplayer/DOCS/man/hu/mplayer.1 b/mplayer/DOCS/man/hu/mplayer.1
index 692c0d63..19b00014 100644
--- a/mplayer/DOCS/man/hu/mplayer.1
+++ b/mplayer/DOCS/man/hu/mplayer.1
@@ -372,30 +372,6 @@ L
.PD 1
.PP
.RS
-(A kvetkez gombok csak akkor mkdnek, ha GUI tmogats be van fordtva
-s elsbbsget lveznek a fenti gomb-defincikkal szemben.)
-.RE
-.PP
-.PD 0
-.RS
-.IPs ENTER
-Lejtszs elindtsa.
-.IPs "ESC\ \ "
-Lejtszs meglltsa.
-.IPs "l\ \ \ \ "
-Fjl betltse.
-.IPs "t\ \ \ \ "
-Felirat betltse.
-.IPs "c\ \ \ \ "
-Skin bngsz megnyitsa.
-.IPs "p\ \ \ \ "
-Lejtszsi lista megnyitsa.
-.IPs "r\ \ \ \ "
-Belltsok megnyitsa.
-.RE
-.PD 1
-.PP
-.RS
(A kvetkez gombok csak akkor mkdnek, ha TV vagy DVB bemenet tmogatssal
fordtottl s elsbbsget lveznek a fenti gomb-defincikkal szemben.)
.RE
diff --git a/mplayer/DOCS/man/it/mplayer.1 b/mplayer/DOCS/man/it/mplayer.1
index 6732e679..370eb8b7 100644
--- a/mplayer/DOCS/man/it/mplayer.1
+++ b/mplayer/DOCS/man/it/mplayer.1
@@ -383,30 +383,6 @@ Ricerca indietro/\:avanti di 1 minuto.
.PP
.RS
(I seguenti tasti sono validi solo se MPlayer stato compilato col supporto
-GUI e hanno precedenza su quelli definiti precedentemente.)
-.RE
-.PP
-.PD 0
-.RS
-.IPs ENTER
-Inizia la riproduzione.
-.IPs "ESC\ \ "
-Ferma la riproduzione.
-.IPs "l\ \ \ \ "
-Carica file.
-.IPs "t\ \ \ \ "
-Carica sottotitoli.
-.IPs "c\ \ \ \ "
-Apre il selezionatore di skin.
-.IPs "p\ \ \ \ "
-Apre la playlist.
-.IPs "r\ \ \ \ "
-Apre le preferenze.
-.RE
-.PD 1
-.PP
-.RS
-(I seguenti tasti sono validi solo se MPlayer stato compilato col supporto
di ingresso TV o DVB e hanno precedenza su quelli definiti precedentemente.)
.RE
.PP
diff --git a/mplayer/DOCS/man/pl/mplayer.1 b/mplayer/DOCS/man/pl/mplayer.1
index e22fafbe..5b30245c 100644
--- a/mplayer/DOCS/man/pl/mplayer.1
+++ b/mplayer/DOCS/man/pl/mplayer.1
@@ -350,24 +350,6 @@ Prze
Ustawia przezroczysto okna filmu.
.RE
.PD 1
-
-.
-.TP
-.B Kontrola GUI klawiatur
-.PD 0
-.RSs
-.IPs ENTER
-Zaczyna odtwarzanie.
-.IPs "ESC\ \ "
-Zatrzymuje odtwarzanie.
-.IPs "l\ \ \ \ "
-Wczytuje zbir.
-.IPs "c\ \ \ \ "
-Przegldarka skrek.
-.IPs "p\ \ \ \ "
-Przecza list odtwarzania.
-.RE
-.PD 1
.
.TP
.B Kontrola wejcia TV
diff --git a/mplayer/DOCS/man/ru/mplayer.1 b/mplayer/DOCS/man/ru/mplayer.1
index bde08a9e..8c05a826 100644
--- a/mplayer/DOCS/man/ru/mplayer.1
+++ b/mplayer/DOCS/man/ru/mplayer.1
@@ -347,30 +347,6 @@ Stop playing (and quit if \-idle is not used).
.PD 1
.PP
.RS
-( MPlayer GUI
- .)
-.RE
-.PP
-.PD 0
-.RS
-.IPs ENTER
- .
-.IPs "ESC\ \ "
- .
-.IPs "l\ \ \ \ "
- .
-.IPs "t\ \ \ \ "
- .
-.IPs "c\ \ \ \ "
- .
-.IPs "p\ \ \ \ "
- .
-.IPs "r\ \ \ \ "
- .
-.RE
-.PD 1
-.PP
-.RS
( , MPlayer TV
.)
.RE
diff --git a/mplayer/DOCS/man/zh_CN/mplayer.1 b/mplayer/DOCS/man/zh_CN/mplayer.1
index e7930d93..1356534f 100644
--- a/mplayer/DOCS/man/zh_CN/mplayer.1
+++ b/mplayer/DOCS/man/zh_CN/mplayer.1
@@ -1,4 +1,4 @@
-.\" sync with en/mplayer.1 rev. 32699
+.\" sync with en/mplayer.1 rev. 32880
.\" Encoding: UTF-8
.\"
.\" MPlayer (C) 2000-2010 MPlayer 团队
@@ -1450,10 +1450,10 @@ MPlayer在关闭时将驱动器的速度重置至默认值。
.
.TP
.B \-endpos <[[hh:]mm:]ss[.ms]|size[b|kb|mb]> (也请参见 \-ss 和 \-sb)
-停止在给定的时间或字节位置。
+停止在给定的时间或以字节计的位置。
.br
-.I 注意:
-字节位置仅为了 MEncoder 而启用但不精确, 因为它只会停在帧的边缘。
+.I 注意:
+以字节计的位置可能不精确,因为只能暂停在帧数据块的边界上。
当与 \-ss 选项组合使用时, \-endpos 的时间会向前移动 \-ss 指定的秒数。
.sp 1
.I 示例:
@@ -2255,6 +2255,22 @@ SSA/ASS 提供器能在那里放置字幕 (与 \-ass\-use\-margins 组合用)。
设置 OSD 信息的停留时间(以毫秒 ms 为单位) (默认是: 1000)。
.
.TP
+.B \-osd\-fractions <0\-2>
+设置 OSD 中当前时间的秒数的小数部分如何显示:
+.PD 0
+.RSs
+.IPs 0
+不显示小数部分(默认行为)。
+.IPs 1
+显示头两位十进制数字。
+.IPs 2
+显示当前秒钟内大致的帧计数值。
+该帧计数值并不精确而只是一个近似值。
+在可变帧数编码的情况下,发现这个近似值远远偏离实际的帧计数值。
+.RE
+.PD 1
+.
+.TP
.B \-osdlevel <0\-3> (仅用于 MPlayer)
指定 OSD 的启始模式。
.PD 0
@@ -2378,7 +2394,7 @@ MPlayer 在 verbose (\-v) 模式下会打印可用的语言。
.IPs 1
装载所有包含电影名称的字幕。
.IPs 2
-装载当前目录的所有字幕。
+装载当前目录以及 \-sub\-paths 目录中的所有字幕。
.RE
.PD 1
.
@@ -2440,8 +2456,28 @@ CC 字幕到目前为止还没有在其它地区码的 DVD 中发现。
.PD 1
.
.TP
-.B \-subdelay <数>
-字幕延迟 <数> 秒。可以是负数。
+.B \-sub\-paths <路径1,路径2,...>
+指定媒体文件的目录额外需要追踪的字幕路径。
+.sp 1
+.I 示例:
+假设播放 /path/\:to/\:movie/\:movie.avi,并且指定了 \-sub\-paths
+sub,subtitles,/tmp/subs,那么 MPlayer 将在这些目录下搜索字幕文件:
+.RSs
+/path/\:to/\:movie/
+.br
+/path/\:to/\:movie/\:sub/
+.br
+/path/\:to/\:movie/\:subtitles/
+.br
+/tmp/\:subs/
+.br
+~/.mplayer/\:sub/
+.RE
+.PD 1
+.
+.TP
+.B \-subdelay <秒数>
+字幕延迟 <秒数> 秒。可以是负数。
.
.TP
.B \-subfile <文件名> (BETA 代码)
@@ -4286,6 +4322,9 @@ PGMYUV 像 PGM, 但也包含 U 和 V 平面, 添加在图像的底部。
0 没压缩, 9 最强压缩。
.IPs outdir=<目录名>
指定保存 PNG 文件的目录(默认值:./)。
+.IPs prefix=<前缀字符串>
+指定用于 PNG 文件名的前缀。(默认:无前缀)。
+Specify the prefix to be used for the PNG filenames (default: no prefix).
.IPs alpha(默认值:noalpha)
创建使用 alpha 通道的 PNG 文件。
注意 MPlayer 通常不支持 alpha 通道,所以该选项只在极少数情况下才有用。
@@ -9667,12 +9706,15 @@ I与B帧的话分别是该值加上ip_factor与pb_factor后得到的值。
H.264的量化参数是基于对数尺度的。
两者之间的映射关系大至是H264QP = 12 + 6*log2(MPEGQP)。
例如,MPEG的QP=2与H.264的QP=18是等价的。
+通常情况下,应避免使用该选项,而是使用 crf,因为 crf 在相同数据量下
+能产生更好的视觉效果。
.
.TP
.B crf=<1.0\-50.0>
启用恒定质量模式,并选择质量值。
该质量值的尺度与QP的相类似。
就像基于比特率的模式一样,该模式允许每个帧根据帧的复杂度使用不同的QP。
+通常情况下应使用该选项而非 qp。
.
.TP
.B pass=<1\-3>
@@ -10957,13 +10999,6 @@ GUI 播放列表
.TP
~/.mplayer/\:DVDkeys/
缓存的 CSS 钥匙
-.
-.TP
-假如播放文件是 /path/\:to/\:movie.avi, MPlayer 按以下顺序搜索字幕文件:
-.RS
-/path/\:to/\:movie.sub
-.br
-~/.mplayer/\:sub/\:movie.sub
.RE
.PD 1
.
diff --git a/mplayer/DOCS/tech/MAINTAINERS b/mplayer/DOCS/tech/MAINTAINERS
index 8765ba3c..a0884b8d 100644
--- a/mplayer/DOCS/tech/MAINTAINERS
+++ b/mplayer/DOCS/tech/MAINTAINERS
@@ -84,8 +84,8 @@ MPlayer code:
* playtree, input layer: Alban Bedel
* libswscale: Michael Niedermayer, Luca Abeni
* DVB support: Nico Sabbi
- * GUI: None
- * GUI skins: Diego Biurrun
+ * GUI: Ingo Brückl
+ * GUI skins: Ingo Brückl
* EDL code: Oded Shimon
Imported libs/projects:
@@ -96,7 +96,6 @@ Imported libs/projects:
* libmpeg2: None
* libdvdcss: Diego Biurrun
* libdvdread: Diego Biurrun
- * libfaad2: None
* realrtsp: Roberto Togni
* librtsp: Benjamin Zores
* freesdp: Benjamin Zores
diff --git a/mplayer/DOCS/tech/TODO b/mplayer/DOCS/tech/TODO
index d5e10ceb..cfa7ff73 100644
--- a/mplayer/DOCS/tech/TODO
+++ b/mplayer/DOCS/tech/TODO
@@ -39,9 +39,6 @@ FOR THE NEXT RELEASE:
FOR THE v1.00 RELEASE:
~~~~~~~~~~~~~~~~~~~~~~
-cruft removal:
-- remove support for skins directories using the obsolete name 'Skin'
-
DVB:
- display OSD and subtitles using DVB card's OSD
@@ -90,4 +87,3 @@ remove externals:
- remove tremor when ffvorbis has integer-only decoder.
- remove libmpeg2 when ffmpeg12 is faster
- remove mp3lib when ffmp3 is faster
-- remove libfaad2 after soc aac is 100%
diff --git a/mplayer/DOCS/tech/binary-packaging.txt b/mplayer/DOCS/tech/binary-packaging.txt
index e9097d81..7b29dcf1 100644
--- a/mplayer/DOCS/tech/binary-packaging.txt
+++ b/mplayer/DOCS/tech/binary-packaging.txt
@@ -43,7 +43,6 @@ the following features MUST be included in any official binary package:
- X11/Xvideo
* codecs
- - FAAD(internal)
- libavcodec(internal)
- native codecs (libmpeg2/mp3lib)
- Vorbis Tremor codec(internal)
diff --git a/mplayer/DOCS/tech/codecs.conf.txt b/mplayer/DOCS/tech/codecs.conf.txt
index d2ec8e09..40d306d0 100644
--- a/mplayer/DOCS/tech/codecs.conf.txt
+++ b/mplayer/DOCS/tech/codecs.conf.txt
@@ -189,7 +189,11 @@ file.
The "out" colorspace can be found in the codec source file in the PIX_FMT
struct. Note that some codecs may have several pix_fmt structs.
The pix_fmt can be converted to the codecs.conf "out" format by reading
-the fmt_conversion.c file.
+the fmt-conversion.c file.
+
+If there are BE and LE versions of a pix_fmt, ignore them and use the short
+native format instead. e.g. 422P16_LE becomes out 422P16. also to note that
+underscores cause parse errors, so 422P16_LE becomes out 422P16LE.
libmpdemux/mp_taglists.c
--------------
diff --git a/mplayer/DOCS/tech/dvdnav-howto.txt b/mplayer/DOCS/tech/dvdnav-howto.txt
deleted file mode 100644
index 4588f4b6..00000000
--- a/mplayer/DOCS/tech/dvdnav-howto.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-How to compile MPlayer with support for dvdnav:
-
-Since the versions of dvdnav and dvdread generally shipped with most Linux
-distributions are outdated and unmaintained remove any traces of dvdnav and
-dvdread from your computer (something like the command below should suffice):
-$ rm -rf /usr/lib/libdvdnav* /usr/lib/libdvdread* /usr/include/dvdnav* \
- /usr/include/dvdread* /usr/local/lib/libdvdnav* \
- /usr/local/lib/libdvdread* /usr/local/include/dvdnav* \
- /usr/local/include/dvdread* /usr/bin/dvdnav-config \
- /usr/local/bin/dvdnav-config
-
-Now download dvdnav from MPHQ libdvdread and libdvdnav (in this order) :
-$ svn co svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdread libdvdread
-$ cd libdvdread
-$ ./autogen.sh && ./configure && make
-(or, if you feel brave and want to help us improve the new build system)
-$ ./configure2 && make
-install it as root with
-$ make install
-
-$ svn co svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdnav libdvdnav
-$ cd libdvdnav
-$ ./autogen.sh && ./configure && make
-(or, if you feel brave and want to help us improve the new build system)
-$ ./configure2 && make
-install it as root with
-$ make install
-
-From within the MPlayer source tree run
-$ ./configure --disable-dvdread-internal
-followed by your preferred parameters.
-Be warned that you *MUST* disable MPlayer's internal copy of dvdread or something
-- most likely - won't work as expected (if at all).
-After configure is run it should say that support for dvdnav and dvdread was
-enabled. If not, investigate the dvdnav and dvdread sections in config.log
-and try to understand what went wrong. If you can't solve the problem yourself
-post the two sections to mplayer-users.
-
-Notice: Audio and subtitle language selection by means of menus doesn't work yet.
-Nonetheless they can be switched as usual at any time during
-playback by pressing '#' and 'j' (or the keys you chose to override those two
-bindings).
diff --git a/mplayer/DOCS/tech/mingw-crosscompile.txt b/mplayer/DOCS/tech/mingw-crosscompile.txt
index 62e901a0..40579373 100644
--- a/mplayer/DOCS/tech/mingw-crosscompile.txt
+++ b/mplayer/DOCS/tech/mingw-crosscompile.txt
@@ -15,8 +15,8 @@ After extracting this package into the MPlayer source-tree,
you only need to run the included linux-mingw.sh to configure (it just runs
./configure --host-cc=cc --target=i686-mingw32msvc --cc=i586-mingw32msvc-cc
--windres=i586-mingw32msvc-windres --ranlib=i586-mingw32msvc-ranlib
---with-extraincdir="$PWD/osdep/mingw32"
---with-extralibdir="$PWD/osdep/mingw32"
+--extra-cflags="-I$PWD/osdep/mingw32"
+--extra-ldflags="-L$PWD/osdep/mingw32"
--with-freetype-config="$PWD/osdep/mingw32/ftconf") and then run make.
You should be able to run the generated binary with Wine, if you want to.
diff --git a/mplayer/DOCS/xml/cs/bugreports.xml b/mplayer/DOCS/xml/cs/bugreports.xml
index cbdf3c20..ce119407 100644
--- a/mplayer/DOCS/xml/cs/bugreports.xml
+++ b/mplayer/DOCS/xml/cs/bugreports.xml
@@ -232,7 +232,7 @@ obdrželi svou odpověď.
Bude potřeba připojit log, konfiguraci nebo vzorky souborů ke svému hlášení chyb.
Pokud jsou některé z nich opravdu velké, pak je raději nahrajte na náš
-FTP server
+FTP server
v komprimovaném formátu (preferujeme gzip a bzip2) a do zprávy zahrňte pouze
cestu a název souboru. Naše konference mají limit velikosti zprávy 80k, pokud
máte něco většího, musíte to zkomprimovat a nahrát na FTP.
@@ -386,7 +386,7 @@ mplayer -v volby film >
Pokud se problém vztahuje k jednomu nebo více souborům, pak prosím nahrajte
potížisty na:
-
+
diff --git a/mplayer/DOCS/xml/cs/install.xml b/mplayer/DOCS/xml/cs/install.xml
index 2acaf2b2..15a4f4b1 100644
--- a/mplayer/DOCS/xml/cs/install.xml
+++ b/mplayer/DOCS/xml/cs/install.xml
@@ -432,43 +432,6 @@ Now rerun ./configure for
-
-Kodek AAC
-
-
-AAC (Advanced Audio Coding) je audio kodek, který lze občas nalézt v MOV a
-MP4 souborech. Open source dekodér jménem FAAD je k dispozici na
- .
-MPlayer obsahuje CVS obraz libfaad 2.1 beta,
-takže jej nemusíte stahovat dodatečně.
-
-
-
-Pokud používáte gcc 3.2 které nedokáže zkompilovat naši zabudovanou FAAD,
-nebo chcete použít externí knihovnu z jiných důvodů, stáhněte si ji z
-download stránky
-a předejte volbu --enable-faad-external skriptu
-./configure .
-Pro dekódování AAC souborů nepotřebujete celou faad2, libfaad stačí.
-Zkompilujete ji takto:
-
-cd faad2/
-sh bootstrap
-./configure
-cd libfaad
-make
-make install
-
-Binárky na audiocoding.com nenajdete, ale můžete si je opatřit v balíčcích pro
-Debian z
-domácí stránky Christiana Marillata ,
-Mandrake/Mandriva RPM z P.L.F
-a Fedora RPM ze stránek Livna .
-
-
-
-
-
AMR kodeky
diff --git a/mplayer/DOCS/xml/cs/ports.xml b/mplayer/DOCS/xml/cs/ports.xml
index 8657248e..af0e0c42 100644
--- a/mplayer/DOCS/xml/cs/ports.xml
+++ b/mplayer/DOCS/xml/cs/ports.xml
@@ -417,7 +417,7 @@ Níže uvádíme řešení některých běžných problémů:
Řešení: Použijte volbu extralibdir v configure
- --with-extralibdir="/usr/lib -lrt"
+ --extra-ldflags="/usr/lib -lrt"
diff --git a/mplayer/DOCS/xml/de/bugreports.xml b/mplayer/DOCS/xml/de/bugreports.xml
index a0d7e84e..8875ae0e 100644
--- a/mplayer/DOCS/xml/de/bugreports.xml
+++ b/mplayer/DOCS/xml/de/bugreports.xml
@@ -194,7 +194,7 @@ make
Du wirst wahrscheinlich Logdateien, Konfigurationsinformationen und Beispieldateien
in deinen Fehlerbericht aufnehmen müssen. Werden einige von ihnen ziemlich groß,
ist es besser, wenn du sie auf unseren
- FTP-Server
+ FTP-Server
hochlädst, und zwar in komprimierter Form (gzip und bzip2 bevorzugt). Gib dann in deinem
Fehlerbericht nur den Pfad- und den Dateinamen an. Unsere Mailinglisten haben ein
Nachrichten-Größenlimit von 80k, wenn du etwas größeres hast, musst du es
@@ -363,7 +363,7 @@ ld -v
Wenn dein Problem speziell mit einer oder mehreren Dateien zu tun hat, lade diese bitte hoch nach:
-
+
diff --git a/mplayer/DOCS/xml/de/install.xml b/mplayer/DOCS/xml/de/install.xml
index d63e8dbf..6eac56ec 100644
--- a/mplayer/DOCS/xml/de/install.xml
+++ b/mplayer/DOCS/xml/de/install.xml
@@ -472,43 +472,6 @@ make install
-
- AAC Codec
-
- AAC (Advanced Audio Coding) ist ein Audiocodec, der vorwiegend
- in MOV- und MP4-Dateien vorkommt. Ein Open-Source-Decoder namens
- FAAD ist auf
- verfügbar. MPlayer enthält
- eine CVS Version von libfaad 2.1 beta, so dass es nicht extra
- installiert werden muss.
-
-
-
- Um die externe FAAD-Bibliothek verwenden zu können (z.B. um mit gcc 3.2
- compilieren zu können, der die interne Version nicht übersetzt), muss
- die Bibliothek von der
- Download Seite
- heruntergeladen und installiert werden. Anschließend muss die Option
- --enable-faad-external an ./configure
- übergeben werden, damit die externe Bibliothek erkannt wird.
- Es ist lediglich erforderlich, vorher libfaad zu installieren, und zwar so:
-
-cd faad2/
-sh bootstrap
-./configure
-cd libfaad
-make
-make install
- Binärpakete sind auf audiocoding.com nicht erhältlich, Debian-Pakete
- können aber mit (apt-)get von
- Christian Marillat's Homepage , Mandrake/Mandriva RPMs von
- P.L.F und RedHat RPMs
- von Grey Sector
- heruntergeladen werden.
-
-
-
AMR Codecs
diff --git a/mplayer/DOCS/xml/de/ports.xml b/mplayer/DOCS/xml/de/ports.xml
index 6e6c85a5..a746ed89 100644
--- a/mplayer/DOCS/xml/de/ports.xml
+++ b/mplayer/DOCS/xml/de/ports.xml
@@ -391,7 +391,7 @@ ctl 1 8/16/5.7.0 sctl CLAIMED DEVICE
Lösung: Benutze die Option extralibdir von configure
- --with-extralibdir="/usr/lib -lrt"
+ --extra-ldflags="/usr/lib -lrt"
diff --git a/mplayer/DOCS/xml/de/skin.xml b/mplayer/DOCS/xml/de/skin.xml
index 60d78819..aef288e0 100644
--- a/mplayer/DOCS/xml/de/skin.xml
+++ b/mplayer/DOCS/xml/de/skin.xml
@@ -20,7 +20,7 @@
- $(DATADIR)/skins/
+ ~/.mplayer/skins/
@@ -28,16 +28,11 @@
$(PREFIX)/share/mplayer/skins/
-
-
- ~/.mplayer/skins/
-
-
- Beachte, dass der erste Pfad je nach Art der
+ Beachte, dass der zweite Pfad je nach Art der
MPlayer -Konfiguration variieren kann
(siehe Argumente --prefix und --datadir
des configure -Scripts).
@@ -77,17 +72,17 @@
Zur Zeit sind vier Fenster zu dekorieren: das
Hauptfenster, das
Unterfenster, die
- Abspielleitse und das
- Skin-Menü (das durch einen
- Rechtsklick aktiviert werden kann).
+ Abspielleiste und das
+ Skin-Menü.
- Das Hauptfenster und/oder die
- Abspielleiste befindet sich dort, wo du
- MPlayer kontrollieren kannst. Der Hintergrund
- des Fensters ist eine Grafik.
+ Mit dem Hauptfenster kontrolliert
+ man den MPlayer .
+ Die Abspielleiste erscheint im
+ Vollbild-Modus, sobald man die Maus unten an den Bildschirm bewegt.
+ Der Hintergrund der Fenster ist eine Grafik.
Ins Fenster können (und müssen) diverse Elemente platziert werden:
Buttons , Potentiometer (Schieberegler)
und Labels .
@@ -145,8 +140,9 @@
Das Skin-Menü ist ganz einfach ein
- Weg, MPlayer mittels der Menüeinträge zu
- kontrollieren. Zwei Grafiken sind für das Menü erforderlich:
+ Weg, MPlayer mittels Menüeinträgen zu
+ kontrollieren. Es wird durch die mittlere Maustaste aktiviert.
+ Zwei Grafiken sind für das Menü erforderlich:
eine davon ist die Basisgrafik, die den Normalzustand des Menüs darstellt,
die andere wird zur Anzeige der gewählten Einträge verwendet.
Wenn du das Menü aufklappst, wird die erste Grafik angezeigt. Bewegst du
@@ -259,14 +255,16 @@ end
main - für das Hauptfenster
sub - für das Unterfenster
+ playbar - für die Abspielleiste
menu - für das Skin-Menü
- playbar - Abspielleiste
- (Die sub- und menu-Blöcke sind optional - du musst kein Menü erzeugen oder
- das Unterfenster dekorieren.)
+ (Die sub-, playbar- und menu-Blöcke sind optional - es ist nicht
+ nötig, das Unterfenster zu dekorieren, eine Abspielleiste zu haben
+ oder ein Menü zu erzeugen. Ein Standard-Menü steht immer über die
+ rechte Maustaste zur Verfügung.)
@@ -547,15 +545,15 @@ end
- font = fontfile, fontid
+ font = fontfile
Definiert eine Schrift. fontfile ist der Name der
Schrift-Beschreibungsdatei mit der Erweiterung .fnt
- (gieb hier keine Erweiterung an).
- fontid wird verwendet, um auf die Schrift zu verweisen
+ (gib hier keine Erweiterung an) und
+ wird verwendet, um auf die Schrift zu verweisen
(siehe dlabel
und slabel). Bis zu 25 Schriften können
definiert werden.
@@ -566,18 +564,18 @@ end
- slabel = X, Y, fontid, "text"
+ slabel = X, Y, fontfile, "text"
Platziere ein statisches Label an Position X,Y .
text wird mittels der identifizierten
- fontid angezeigt. Der Text ist einfach ein
+ fontfile angezeigt. Der Text ist einfach ein
eine Ausgangszeichenkette ($x -Variablen funktionieren nicht),
eingeschlossen von doppelten Anführungszeichen (das "-Zeichen kann jedoch
nicht Teil des Textes sein).
- Das Label wird mittels der über die fontid identifizierten
+ Das Label wird mittels der über die fontfile identifizierten
Schrift angezeigt.
@@ -586,19 +584,19 @@ end
- dlabel = X, Y, length, align, fontid, "text"
+ dlabel = X, Y, width, align, fontfile, "text"
Platziere ein dynamisches Label an Position X,Y .
Das Label wird als dynamisch bezeichnet, weil sein Text periodisch
- aktualisiert wird. Die Maximallänge des Labels wird mit dem
- Wert length vorgegeben (seine Höhe ist die der
+ aktualisiert wird. Die maximale Breite des Labels wird mit dem
+ Wert width vorgegeben (seine Höhe ist die der
Zeichen).
Wird der anzuzeigende Text breiter als dieser Wert, wird er gescrollt,
- andernfalls wird er innerhalb des Mittels des Wertes des vom
- align -Parameter festgelegten Zwischenraums ausgerichtet:
+ andernfalls wird er innerhalb des angegebenen Bereichs gemäß des
+ align -Parameters ausgerichtet:
0 steht für rechts,
1 steht für zentriert,
2 steht für links.
@@ -607,7 +605,7 @@ end
Der anzuzeigende Text wird mit text festgelegt:
Er muss zwischen doppelten Anführungszeichen stehen (das "-Zeichen kann jedoch
nicht Teil des Textes sein).
- Das Label wird mittels der über die fontid identifizierten
+ Das Label wird mittels der über die fontfile identifizierten
Schrift angezeigt.
Du kannst folgende Variablen im Text verwenden:
@@ -882,7 +880,7 @@ end
char -Zeichens innerhalb der Grafik fest
(0,0 steht für die obere linke Ecke).
width und height sind die Maße der
- Zeichen in Pixel.
+ Zeichen in Pixel. Das Zeichen kann in UTF-8-Kodierung angegeben werden.
diff --git a/mplayer/DOCS/xml/en/bugreports.xml b/mplayer/DOCS/xml/en/bugreports.xml
index 5b0e9432..072c11ef 100644
--- a/mplayer/DOCS/xml/en/bugreports.xml
+++ b/mplayer/DOCS/xml/en/bugreports.xml
@@ -1,5 +1,5 @@
-
+
How to report bugs
@@ -237,7 +237,7 @@ to subscribe to actually receive your answer.
You may need to include log, configuration or sample files in your bug report.
If some of them are quite big then it is better to upload them to our
-FTP server in a
+FTP server in a
compressed format (gzip and bzip2 preferred) and include only the path and file
name in your bug report. Our mailing lists have a message size limit of 80k, if
you have something bigger you have to compress or upload it.
@@ -391,7 +391,7 @@ mplayer -v options filename
If your problem is specific to one or more files,
then please upload the offender(s) to:
-
+
diff --git a/mplayer/DOCS/xml/en/install.xml b/mplayer/DOCS/xml/en/install.xml
index fe7c5ae4..5e140ccf 100644
--- a/mplayer/DOCS/xml/en/install.xml
+++ b/mplayer/DOCS/xml/en/install.xml
@@ -1,5 +1,5 @@
-
+
Installation
@@ -431,40 +431,6 @@ Now rerun ./configure for
-
-AAC
-
-
-An open source AAC decoder called FAAD2 is available from
- .
-MPlayer includes a copy of it in its source tree.
-If you want to use the external library instead, install it and pass
---enable-faad-external to ./configure .
-
-
-
-FAAD2 binaries are not available from audiocoding.com, but you can (apt-)get
-Debian packages from
-Christian Marillat ,
-Mandrake/Mandriva RPMs from the P.L.F
-and Fedora/CentOS/RHEL RPMs from RPMFusion .
-
-
-If you choose to build from source, you do not need all of FAAD2 to decode
-AAC files, libfaad is enough. Build it like this:
-
-cd faad2/
-sh bootstrap
-./configure
-cd libfaad
-make
-make install
-
-
-
-
-
-
AMR
diff --git a/mplayer/DOCS/xml/en/ports.xml b/mplayer/DOCS/xml/en/ports.xml
index 52a49cdf..f26c8151 100644
--- a/mplayer/DOCS/xml/en/ports.xml
+++ b/mplayer/DOCS/xml/en/ports.xml
@@ -1,5 +1,5 @@
-
+
Ports
@@ -394,7 +394,7 @@ Below are solutions for some common problems:
Solution: Use the extralibdir option of configure
- --with-extralibdir="/usr/lib -lrt"
+ --extra-ldflags="/usr/lib -lrt"
diff --git a/mplayer/DOCS/xml/en/skin.xml b/mplayer/DOCS/xml/en/skin.xml
index 749e1938..f887cfbb 100644
--- a/mplayer/DOCS/xml/en/skin.xml
+++ b/mplayer/DOCS/xml/en/skin.xml
@@ -1,5 +1,5 @@
-
+
MPlayer skin format
@@ -22,15 +22,15 @@ Currently there are four windows to be decorated: the
main window, the
subwindow, the
playbar, and the
- skin menu (which can be activated
-by a right click).
+ skin menu.
- The main window and/or the
- playbar is where you can control
- MPlayer . The background of the window is an image.
+ The main window is where you can control
+ MPlayer . The playbar
+ shows up in fullscreen mode when moving the mouse to the bottom of
+ the screen. The background of the windows is an image.
Various items can (and must) be placed in the window:
buttons , potmeters (sliders) and
labels .
@@ -82,7 +82,8 @@ by a right click).
The skin menu is just a way to control
- MPlayer by means of menu entries. Two images
+ MPlayer by means of menu entries (which can be
+ activated by a middle mouse button click). Two images
are required for the menu: one of them is the base image that shows the
menu in its normal state, the other one is used to display the selected
entries. When you pop up the menu, the first image is shown. If you move
@@ -206,17 +207,18 @@ where window name can be one of these strings:
sub - for the subwindow
- menu - for the skin menu
+ playbar - for the playbar
- playbar - playbar
+ menu - for the skin menu
-(The sub and menu blocks are optional - you do not need to create a menu or
-decorate the subwindow.)
+(The sub, playbar and menu blocks are optional - you do not need to decorate
+the subwindow, have a playbar or create a menu. A default menu is always
+available by a right mouse button click.)
@@ -446,12 +448,12 @@ blocks.
- font = fontfile, fontid
+ font = fontfile
Defines a font. fontfile is the name of a font description
file with a .fnt extension (do not specify the extension
- here). fontid is used to refer to the font
+ here) and is used to refer to the font
(see dlabel
and slabel). Up to 25 fonts can be defined.
@@ -459,27 +461,27 @@ blocks.
- slabel = X, Y, fontid, "text"
+ slabel = X, Y, fontfile, "text"
Place a static label at the position X,Y .
text is displayed using the font identified by
- fontid . The text is just a raw string
+ fontfile . The text is just a raw string
($x variables do not work) that must be enclosed between
double quotes (but the " character cannot be part of the text). The
- label is displayed using the font identified by fontid .
+ label is displayed using the font identified by fontfile .
- dlabel = X, Y, length, align, fontid, "text"
+ dlabel = X, Y, width, align, fontfile, "text"
Place a dynamic label at the position X,Y . The label is
- called dynamic because its text is refreshed periodically. The maximum length
- of the label is given by length (its height is the height
+ called dynamic because its text is refreshed periodically. The maximum width
+ of the label is given by width (its height is the height
of a character). If the text to be displayed is wider than that, it will be
scrolled,
otherwise it is aligned within the specified space by the value of the
@@ -490,7 +492,7 @@ blocks.
The text to be displayed is given by text : It must be
written between double quotes (but the " character cannot be part of the
text). The label is displayed using the font identified by
- fontid . You can use the following variables in the text:
+ fontfile . You can use the following variables in the text:
@@ -742,7 +744,8 @@ image file to be used for the font (you do not have to specify the extension).
Here X and Y specify the position of the
char character in the image (0,0 is the
upper left corner). width and height are
-the dimensions of the character in pixels.
+the dimensions of the character in pixels. The character may be in UTF-8
+encoding.
diff --git a/mplayer/DOCS/xml/es/bugreports.xml b/mplayer/DOCS/xml/es/bugreports.xml
index 5d190f68..4afa92cf 100644
--- a/mplayer/DOCS/xml/es/bugreports.xml
+++ b/mplayer/DOCS/xml/es/bugreports.xml
@@ -104,7 +104,7 @@ una respuesta.
Necesita incluir un historial, archivos de configuración o muestras en su informe
de error. Si alguno de estos es muy grande entonces es mejor subirlos a nuestro
-servidor FTP en un
+servidor FTP en un
formato comprimido (gzip y bzip2 preferentemente) e incluir solo la ruta al nombre
del archivo en su informe de error. Nuestras listas de correo tienen un límite
en el tamaño del mensaje de 80k, si tiene algo más grande entonces deberá comprimirlo
@@ -253,7 +253,7 @@ así:
Si su problema es específico con uno o más archivos, suba las víctimas a:
-
+
diff --git a/mplayer/DOCS/xml/es/install.xml b/mplayer/DOCS/xml/es/install.xml
index 23bafebb..b17e17a3 100644
--- a/mplayer/DOCS/xml/es/install.xml
+++ b/mplayer/DOCS/xml/es/install.xml
@@ -648,41 +648,6 @@ tengan el mismo origen.
-
-
-
-AAC
-
-AAC (Codificación Avanzada de Audio) es un codec de audio que algunas veces
-se encuentra en archivos MOV y MP4. Un decodificador llamado FAAD de código
-abierto está disponible en
- .
-MPlayer incluye libfaad 2.0RC1, por lo que no
-necesita obtenerlo por separado.
-
-
-
-Si usa gcc 3.2 y falla al compilar nuestro FAAD interno o desea usar la
-biblioteca externa por alguna otra razón, descargue la biblioteca desde la
-página de descargas
-y pase la opción --enable-external-faad a configure .
-No necesita todo el faad2 para decodificar archivos AAC, libfaad es suficiente.
-Constrúyalo como sigue:
-cd faad2/
-chmod +x bootstrap
-./bootstrap
-./configure
-cd libfaad
-make
-make install
-
-No hay binarios disponibles en audiocoding.com, pero puede apetegetear paquetes Debian
-desde la página personal de Christian Marillat ,
-paquetes RPM para Mandrake desde la P.L.F. y RPMs
-para Red Hat en Grey Sector .
-
-
-
diff --git a/mplayer/DOCS/xml/es/skin.xml b/mplayer/DOCS/xml/es/skin.xml
index bc51205a..2fee4216 100644
--- a/mplayer/DOCS/xml/es/skin.xml
+++ b/mplayer/DOCS/xml/es/skin.xml
@@ -484,13 +484,13 @@ La etiqueta es mostrada usando la tipografía identificada por fontid
- dlabel = X, Y, length, align, fontid, "text"
+ dlabel = X, Y, width, align, fontid, "text"
Coloca una etiqueta dinámica en la posición X,Y . La etiqueta se
llama dinámica porque su texto es refrescado periódicamente. La longitud máxima de la
-etiqueta viene dada por length (su altura es la altura de un caracter).
+etiqueta viene dada por width (su altura es la altura de un caracter).
Si el texto que ha de ser mostrado es más ancho que esta, será desplazado,
si no será alineado dentro del espacio especificado por el valor del parámetro
align : 0 es para derecha,
diff --git a/mplayer/DOCS/xml/fr/bugreports.xml b/mplayer/DOCS/xml/fr/bugreports.xml
index 6299cb9d..5aa27538 100644
--- a/mplayer/DOCS/xml/fr/bugreports.xml
+++ b/mplayer/DOCS/xml/fr/bugreports.xml
@@ -248,7 +248,7 @@ et que c'est donc une bonne idée de souscrire pour recevoir votre réponse.
Vous pouvez avoir besoin d'inclure des fichiers de log, de configuration
ou d'échantillon. Si certains sont très gros alors il vaut mieux les uploader
-sur notre serveur FTP
+sur notre serveur FTP
en format compressé (gzip et bzip2 préférés) et indiquer uniquement leur
chemin et nom dans le rapport de bogue.
Nos listes de diffusion ont une taille de message limite de 80k, si vous
@@ -398,7 +398,7 @@ dans un fichier comme ceci :
Si votre problème est spécifique à un ou plusieurs fichiers, alors merci d'uploader
le(s) fautif(s) sur :
-
+
diff --git a/mplayer/DOCS/xml/fr/install.xml b/mplayer/DOCS/xml/fr/install.xml
index c8ef67b6..0fceba1f 100644
--- a/mplayer/DOCS/xml/fr/install.xml
+++ b/mplayer/DOCS/xml/fr/install.xml
@@ -422,34 +422,6 @@ Now rerun ./configure for
x264 support.
-
-
-
-Codec AAC
-
-Un décodeur open source appelé FAAD est disponible sur
- .
-MPlayer inclus une copie, vous n'avez donc pas
-à l'obtenir séparemment.
-Si vous voulez utiliser une librairie externe, passez
---enable-faad-external à ./configure .
-Vous n'avez pas besoin de tout faad2 pour décoder les fichiers AAC, libfaad suffit.
-Construisez comme ceci :
-
-cd faad2/
-sh bootstrap
-./configure
-cd libfaad
-make
-make install
-
-Les binaires ne sont pas disponibles sur audiocoding.com, mais vous pouvez
-obtenir les paquets Debian sur la
-page web de Christian Marillat ,
-les RPMs Mandrake/Mandriva sur le P.L.F et les RPMS
-Fedora sur Livna .
-
-
diff --git a/mplayer/DOCS/xml/fr/ports.xml b/mplayer/DOCS/xml/fr/ports.xml
index 5fa71163..9282fd4d 100644
--- a/mplayer/DOCS/xml/fr/ports.xml
+++ b/mplayer/DOCS/xml/fr/ports.xml
@@ -433,7 +433,7 @@ Plante à la lecture avec le message d'erreur suivant :
Solution : Utiliser l'option extralibdir lors de configure
---with-extralibdir="/usr/lib -lrt"
+--extra-ldflags="/usr/lib -lrt"
diff --git a/mplayer/DOCS/xml/hu/bugreports.xml b/mplayer/DOCS/xml/hu/bugreports.xml
index c4952683..31d93d94 100644
--- a/mplayer/DOCS/xml/hu/bugreports.xml
+++ b/mplayer/DOCS/xml/hu/bugreports.xml
@@ -237,7 +237,7 @@ feliratkozol, hogy megkapd te is a választ.
A hibajelentésedhez csatolnod kell a log-ot, konfigurációs vagy minta fájlokat.
Ha ezek közül valamelyik nagy, jobb ha feltöltöd az
-FTP szerverünkre tömörített
+FTP szerverünkre tömörített
formátumban (gzip és bzip2 a javasolt) és csak az elérési utat és a fájl nevet írod
bele a hiba jelentésedbe. A levelezési listáinkon az üzenet mérete maximum 80k lehet,
ha ennél nagyobb fájlod van, tömörítened kell, vagy feltöltened.
@@ -390,7 +390,7 @@ mplayer -v options filename
Ha a probléma egy vagy több fájl esetén specifikus, kérlek töltsd fel ide:
-
+
diff --git a/mplayer/DOCS/xml/hu/install.xml b/mplayer/DOCS/xml/hu/install.xml
index e9fcca02..3499ae39 100644
--- a/mplayer/DOCS/xml/hu/install.xml
+++ b/mplayer/DOCS/xml/hu/install.xml
@@ -434,39 +434,6 @@ az MPlayer be belekerüljön az
-
-AAC
-
-
-Egy FAAD2-nek hívott nyílt forráskódú AAC dekódoló elérhető itt:
- .
-Az MPlayer tartalmaz egy másolatot a forrásfájában.
-Ha inkább a külső függvénykönyvtárat használnád, telepítsd és add meg a
---enable-faad-external kapcsolót a ./configure -nak.
-
-
-
-FAAD2 binárisok nem tölthetőek le az audiocoding.com-ról, de (apt-)get-tel
-telepítheted Christian Marillat Debian csomagjait,
-vagy Mandrake/Mandriva RPM-et a P.L.F -ről,
-Fedora/CentOS/RHEL RPM-et pedig az RPMFusion -ról.
-
-
-Ha úgy döntesz, hogy forrásból fordítasz, nem kell a teljes FAAD2 az AAC fájlok
-dekódolásához, elég a libfaad. Így készítsd el:
-
-cd faad2/
-sh bootstrap
-./configure
-cd libfaad
-make
-make install
-
-
-
-
-
-
AMR
diff --git a/mplayer/DOCS/xml/hu/ports.xml b/mplayer/DOCS/xml/hu/ports.xml
index 1f1b5ee2..1cdb937e 100644
--- a/mplayer/DOCS/xml/hu/ports.xml
+++ b/mplayer/DOCS/xml/hu/ports.xml
@@ -394,7 +394,7 @@ Itt van pár gyakori probléma megoldása:
Megoldás: Használd a configure extralibdir opcióját
- --with-extralibdir="/usr/lib -lrt"
+ --extra-ldflags="/usr/lib -lrt"
diff --git a/mplayer/DOCS/xml/hu/skin.xml b/mplayer/DOCS/xml/hu/skin.xml
index 0d6a738a..9fa7f25a 100644
--- a/mplayer/DOCS/xml/hu/skin.xml
+++ b/mplayer/DOCS/xml/hu/skin.xml
@@ -473,13 +473,13 @@ blokkokban.
- dlabel = X, Y, length, align, fontid, "text"
+ dlabel = X, Y, width, align, fontid, "text"
Egy dinamikus címkét tesz ki az X, Y pozícióba. A
címke azért dinamikus, mert a szövege periódikusan frissül. A címke
- maximum hosszát a length szabályozza (a magassága
+ maximum hosszát a width szabályozza (a magassága
egy karakter magasságával egyezik meg). Ha a megjelenítendő szöveg
szélesebb ennél, scrollozva lesz,
különben az align paraméter által megadott módon
diff --git a/mplayer/DOCS/xml/it/bugreports.xml b/mplayer/DOCS/xml/it/bugreports.xml
index 690d09ae..066df02a 100644
--- a/mplayer/DOCS/xml/it/bugreports.xml
+++ b/mplayer/DOCS/xml/it/bugreports.xml
@@ -242,7 +242,7 @@ una buona idea iscriversi per poter effettivamente ricevere la risposta.
Potrebbe servire che tu includa nel tuo rapporto sul bug registrazioni,
configurazioni o file di esempio. Se alcune di queste cose sono abbastanza
grandi, è meglio caricarle sul nostro
-server FTP in
+server FTP in
un formato compresso (si preferiscono gzip e bzip2) e inserisci nel rapporto
solo il nome e il percorso del file. Le nostre mailing list hanno un limite
sulla dimensione di 80k, se hai qualcosa di più grande devi comprimerlo o
@@ -398,7 +398,7 @@ mplayer -v options filename
Se il tuo problema è specifico per uno o più file,
allora per favore carica quello/i incriminato/i in:
-
+
diff --git a/mplayer/DOCS/xml/it/install.xml b/mplayer/DOCS/xml/it/install.xml
index a237d6da..5dcc1a59 100644
--- a/mplayer/DOCS/xml/it/install.xml
+++ b/mplayer/DOCS/xml/it/install.xml
@@ -435,40 +435,6 @@ Poi riesegui ./configure affinché
-
-AAC
-
-
-E' disponibile da un
-decodificatore open source che si chiama FAAD2.
-MPlayer ne include una copia nei suoi sorgenti.
-Se vuoi usare la libreria esterna per qualche altra ragione, installala e passa
---enable-faad-external a ./configure .
-
-
-
-Gli eseguibili di FAAD2 non sono disponibili da audiocoding.com, ma puoi
-ottenere con apt(-get) i pacchetti Debian da
-Christian Marillat ,
-gli RPM per Mandrake/Mandriva da P.L.F
-e quelli per Fedora da Livna .
-
-
-Se decidi di compilarli dai sorgenti, non ti serve tutto di faad2 per
-decodificare i file AAC, ti basta libfaad. Compilala così:
-
-cd faad2/
-sh bootstrap
-./configure
-cd libfaad
-make
-make install
-
-
-
-
-
-
AMR
diff --git a/mplayer/DOCS/xml/pl/bugreports.xml b/mplayer/DOCS/xml/pl/bugreports.xml
index 9ebfc086..f56a484c 100644
--- a/mplayer/DOCS/xml/pl/bugreports.xml
+++ b/mplayer/DOCS/xml/pl/bugreports.xml
@@ -252,7 +252,7 @@ odpowiedzi.
Może zajść potrzeba dołączenia logu, konfiguracji lub przykładowego
pliku w Twoim
zgłoszeniu błędu. Jeżeli któryś z nich ma duży rozmiar, lepiej załadować go na
-nasz serwer FTP
+nasz serwer FTP
w skompresowanej postaci (gzip i bzip2 są preferowanymi formatami) i załączyć
tylko ścieżkę i nazwę pliku do zgłoszenia błędu. Nasza lista ma ustawiony limit
rozmiaru każdej wiadomości na 80k. Jeżeli potrzebujesz wysłać coś większego,
@@ -411,7 +411,7 @@ do pliku w ten sposób:
Jeżeli Twój problem jest specyficzny dla jednego albo wielu plików, załaduj
winowajcę(ów) na:
-
+
diff --git a/mplayer/DOCS/xml/pl/install.xml b/mplayer/DOCS/xml/pl/install.xml
index 7299f02c..03d62f17 100644
--- a/mplayer/DOCS/xml/pl/install.xml
+++ b/mplayer/DOCS/xml/pl/install.xml
@@ -462,44 +462,6 @@ Now rerun ./configure for
-
-Kodek AAC
-
-
-AAC (Advanced Audio Coding) jest kodekiem audio spotykanym czasami w plikach
-MOV i MP4. Otwarty dekoder nazywany FAAD dostępny jest na stronie
- .
-MPlayer zawiera migawkę CVS z
-libfaad 2.1beta, więc nie musisz ściągać go oddzielnie.
-
-
-
-Jeżeli używasz gcc 3.2, który ma kłopoty z kompilacją wbudowanej wersji
-FAAD lub chcesz z jakichś powodów użyć zewnętrznej biblioteki,
-ściągnij ją z
-tej strony
-i dodaj opcję --enable-external-faad do
-./configure . Nie potrzebujesz całego faad2 do dekodowanie
-plików AAC. Wystarczy użyć samej biblioteki libfaad. Zbudujesz ją w następujący
-sposób
-
-cd faad2/
-sh bootstrap
-./configure
-cd libfaad
-make
-make install
-
-Wersje binarne nie są dostępne na stronie audiocoding.com, ale możesz
-ściągnąć (apt-getem) Debianowe paczki ze
-strony domowej Christiana Marillata ,
-RPM-y dla Mandrake/Mandriva ze strony P.L.F ,
-a RPM-y dla Fedory z Livna .
-
-
-
-
-
Kodeki AMR
diff --git a/mplayer/DOCS/xml/pl/ports.xml b/mplayer/DOCS/xml/pl/ports.xml
index 7c9dd7a5..70294916 100644
--- a/mplayer/DOCS/xml/pl/ports.xml
+++ b/mplayer/DOCS/xml/pl/ports.xml
@@ -393,7 +393,7 @@ Wysypanie się programu przy odtwarzaniu z komunikatem:
Rozwiązanie: Skorzystaj z opcji extralibdir skryptu configure
---with-extralibdir="/usr/lib -lrt"
+--extra-ldflags="/usr/lib -lrt"
diff --git a/mplayer/DOCS/xml/ru/bugreports.xml b/mplayer/DOCS/xml/ru/bugreports.xml
index 8738ad73..18b99854 100644
--- a/mplayer/DOCS/xml/ru/bugreports.xml
+++ b/mplayer/DOCS/xml/ru/bugreports.xml
@@ -235,7 +235,7 @@ HTML почта и почему это — зло, прочтите
Вам необходимо включить лог, конфигурацию или примеры файлов в сообщение
об ошибке. Если что-то из этого большое, то лучше загрузить это на наш
-FTP сервер
+FTP сервер
в сжатом виде (предпочтительно gzip или bzip2) и включить в сообщение
об ошибке только путь и имя файла. На наших рассылках стоит ограничение размера
сообщения в 80КБ. Если у Вас что-то большее, то сожмите или загрузите это.
@@ -384,7 +384,7 @@ mplayer -v опции имя-файла<
Если проблема специфична для одного или нескольких файлов,
пожалуйста, загрузите проблемные файлы на:
-
+
diff --git a/mplayer/DOCS/xml/ru/install.xml b/mplayer/DOCS/xml/ru/install.xml
index baabf02e..ccb7769f 100644
--- a/mplayer/DOCS/xml/ru/install.xml
+++ b/mplayer/DOCS/xml/ru/install.xml
@@ -436,40 +436,6 @@ Now rerun ./configure for
-
-AAC кодек
-
-AAC (Advanced Audio Coding) - это кодек, иногда обнаруживаемый в MOV и MP4
-файлах. Декодер с открытым исходным кодом, называемый FAAD, доступен с
- .
-MPlayer включает в себя CVS версию libfaad 2.1 beta, поэтому
-Вам ничего не нужно дополнительно скачивать.
-
-
-
-Если Вы используете gcc 3.2, который не может скомпилировать встроенный FAAD,
-или просто хотите использовать внешнюю библиотеку, скачаете её с
-страницы загрузок
-и укажите ./configure --enable-faad-external .
-Вам не нужен весь faad2, чтобы декодировать AAC файлы, достаточно libfaad.
-Вот как Вы можете её собрать:
-
-cd faad2/
-sh bootstrap
-./configure
-cd libfaad
-make
-make install
-
-Бинарники отсутствуют на audiocoding.com, но вы можете скачать (apt-get) Debian
-пакеты с домашней страницы Christian Marillat ,
-Mandrake RPM'ники с P.L.F и RedHat RPM'ники
-с Livna .
-
-
-
-
-
AMR кодеки
diff --git a/mplayer/DOCS/xml/ru/ports.xml b/mplayer/DOCS/xml/ru/ports.xml
index 4a9830df..210b5e5c 100644
--- a/mplayer/DOCS/xml/ru/ports.xml
+++ b/mplayer/DOCS/xml/ru/ports.xml
@@ -410,7 +410,7 @@ ln -s /dev/rdsk/c<SCSI bus instance> t
Решение: Используйте опцию extralibdir программы configure
- --with-extralibdir="/usr/lib -lrt"
+ --extra-ldflags="/usr/lib -lrt"
diff --git a/mplayer/DOCS/xml/ru/skin.xml b/mplayer/DOCS/xml/ru/skin.xml
index 402ec3be..ce479951 100644
--- a/mplayer/DOCS/xml/ru/skin.xml
+++ b/mplayer/DOCS/xml/ru/skin.xml
@@ -505,13 +505,13 @@ end
- dlabel = X, Y, length, align, fontid, "text"
+ dlabel = X, Y, width, align, fontid, "text"
Размещает динамическую метку на позиции X,Y . Метка зовется
динамической, потому что ее текст периодически обновляется. Максимальная длина
- метки задается параметром length (ее высота равна высоте символа).
+ метки задается параметром width (ее высота равна высоте символа).
Если отображаемый текст шире этого значения, он будет скроллироваться,
иначе он выравнивается в пределах указанного пространства в соответствии со
значением параметра
diff --git a/mplayer/DOCS/xml/zh_CN/bugreports.xml b/mplayer/DOCS/xml/zh_CN/bugreports.xml
index 01100d20..f4faf2e4 100644
--- a/mplayer/DOCS/xml/zh_CN/bugreports.xml
+++ b/mplayer/DOCS/xml/zh_CN/bugreports.xml
@@ -210,7 +210,7 @@ README文件中。如果这未能提供帮助,请查询 已知错误
你可能要在你的错误报告中包含日志,配置或例子文件。如果他们中一些非常大,
最好把它压缩(请尽量使用gzip或bzip2)并提交到我们的
-FTP服务器
+FTP服务器
上并且在你的错误报告中只包含路径及文件名称。我们的邮件列表有80k的信息限制,
如果你有更大的附件,你不得不压缩后提交。
@@ -359,7 +359,7 @@ mplayer -v options filename
如果你的问题只针对一个或更多文件,请把他们上传到:
-
+
diff --git a/mplayer/Makefile b/mplayer/Makefile
index 2a77c0f1..bc311268 100644
--- a/mplayer/Makefile
+++ b/mplayer/Makefile
@@ -58,45 +58,6 @@ SRCS_COMMON-$(DVDREAD_INTERNAL) += libdvdread4/bitreader.c \
libdvdread4/nav_read.c \
SRCS_COMMON-$(FAAD) += libmpcodecs/ad_faad.c
-SRCS_COMMON-$(FAAD_INTERNAL) += libfaad2/bits.c \
- libfaad2/cfft.c \
- libfaad2/common.c \
- libfaad2/decoder.c \
- libfaad2/drc.c \
- libfaad2/drm_dec.c \
- libfaad2/error.c \
- libfaad2/filtbank.c \
- libfaad2/hcr.c \
- libfaad2/huffman.c \
- libfaad2/ic_predict.c \
- libfaad2/is.c \
- libfaad2/lt_predict.c \
- libfaad2/mdct.c \
- libfaad2/mp4.c \
- libfaad2/ms.c \
- libfaad2/output.c \
- libfaad2/pns.c \
- libfaad2/ps_dec.c \
- libfaad2/ps_syntax.c \
- libfaad2/pulse.c \
- libfaad2/rvlc.c \
- libfaad2/sbr_dct.c \
- libfaad2/sbr_dec.c \
- libfaad2/sbr_e_nf.c \
- libfaad2/sbr_fbt.c \
- libfaad2/sbr_hfadj.c \
- libfaad2/sbr_hfgen.c \
- libfaad2/sbr_huff.c \
- libfaad2/sbr_qmf.c \
- libfaad2/sbr_syntax.c \
- libfaad2/sbr_tf_grid.c \
- libfaad2/specrec.c \
- libfaad2/ssr.c \
- libfaad2/ssr_fb.c \
- libfaad2/ssr_ipqf.c \
- libfaad2/syntax.c \
- libfaad2/tns.c \
-
SRCS_COMMON-$(FASTMEMCPY) += libvo/aclib.c
SRCS_COMMON-$(FFMPEG) += av_opts.c \
libaf/af_lavcresample.c \
@@ -340,6 +301,7 @@ SRCS_COMMON = asxparser.c \
m_option.c \
m_struct.c \
mp_msg.c \
+ mp_strings.c \
mpcommon.c \
parser-cfg.c \
path.c \
@@ -741,7 +703,6 @@ SRCS_MENCODER = mencoder.c \
COMMON_LIBS-$(FFMPEG_A) += ffmpeg/libavformat/libavformat.a \
ffmpeg/libavcodec/libavcodec.a \
- ffmpeg/libavcore/libavcore.a \
ffmpeg/libavutil/libavutil.a \
ffmpeg/libpostproc/libpostproc.a \
ffmpeg/libswscale/libswscale.a
@@ -777,7 +738,6 @@ DIRS = . \
ffmpeg/libavcodec/sh4 \
ffmpeg/libavcodec/sparc \
ffmpeg/libavcodec/x86 \
- ffmpeg/libavcore \
ffmpeg/libavformat \
ffmpeg/libavutil \
ffmpeg/libavutil/arm \
@@ -807,7 +767,6 @@ DIRS = . \
libdvdnav \
libdvdnav/vm \
libdvdread4 \
- libfaad2 \
libmenu \
libmpcodecs \
libmpcodecs/native \
@@ -836,7 +795,6 @@ ADD_ALL_DIRS = $(call ADDSUFFIXES,$(1),$(DIRS))
ADD_ALL_EXESUFS = $(1) $(call ADDSUFFIXES,$(EXESUFS_ALL),$(1))
FFMPEGPARTS = libavcodec \
- libavcore \
libavformat \
libavutil \
libpostproc \
@@ -883,13 +841,6 @@ mencoder$(EXESUF) mplayer$(EXESUF):
codec-cfg$(EXESUF): codec-cfg.c codec-cfg.h help_mp.h
$(HOST_CC) -O -DCODECS2HTML -I. -Iffmpeg -o $@ $<
-#TOOLS/netstream$(EXESUF) TOOLS/vivodump$(EXESUF): $(subst mplayer.o,mplayer-nomain.o,$(OBJS_MPLAYER)) $(filter-out %mencoder.o,$(OBJS_MENCODER)) $(OBJS_COMMON) $(COMMON_LIBS)
-# $(CC) $(CFLAGS) -o $@ $^ $(EXTRALIBS_MPLAYER) $(EXTRALIBS_MENCODER) $(COMMON_LDFLAGS)
-
-
-#codec-cfg$(EXESUF): codec-cfg.c help_mp.h
-# $(HOST_CC) -O -DCODECS2HTML -I. -o $@ $<
-
#codecs.conf.h: codec-cfg$(EXESUF) etc/codecs.conf
# ./$^ > $@
@@ -933,7 +884,6 @@ gui/%: CFLAGS += -Wno-strict-prototypes
libdvdcss/%: CFLAGS := -Ilibdvdcss -D_GNU_SOURCE -DVERSION=\"1.2.10\" $(CFLAGS_LIBDVDCSS) $(CFLAGS)
libdvdnav/%: CFLAGS := -Ilibdvdnav -D_GNU_SOURCE -DHAVE_CONFIG_H -DVERSION=\"MPlayer-custom\" $(CFLAGS)
libdvdread4/%: CFLAGS := -Ilibdvdread4 -D_GNU_SOURCE $(CFLAGS_LIBDVDCSS_DVDREAD) $(CFLAGS)
-libfaad2/%: CFLAGS := -Ilibfaad2 -DHAVE_CONFIG_H $(CFLAGS_FAAD_FIXED) $(CFLAGS)
loader/%: CFLAGS += -fno-omit-frame-pointer $(CFLAGS_NO_OMIT_LEAF_FRAME_POINTER)
#loader/%: CFLAGS += -Ddbg_printf=__vprintf -DTRACE=__vprintf -DDETAILED_OUT
diff --git a/mplayer/TOOLS/asfinfo.c b/mplayer/TOOLS/asfinfo.c
index 33cdab76..70dde28e 100644
--- a/mplayer/TOOLS/asfinfo.c
+++ b/mplayer/TOOLS/asfinfo.c
@@ -155,7 +155,7 @@ static void print_video_header(BITMAPINFOHEADER *h){
printf(" biHeight %ld\n", h->biHeight);
printf(" biPlanes %d\n", h->biPlanes);
printf(" biBitCount %d\n", h->biBitCount);
- printf(" biCompression %ld='%.4s'\n", h->biCompression, &h->biCompression);
+ printf(" biCompression %ld='%.4s'\n", h->biCompression, (const char*)&h->biCompression);
printf(" biSizeImage %ld\n", h->biSizeImage);
printf("===========================\n");
}
@@ -284,5 +284,6 @@ int main(int argc, char* argv[]){
fseek(f, pos + objh.size - sizeof(objh), SEEK_SET);
}
+ fclose(f);
return 0;
}
diff --git a/mplayer/TOOLS/avisubdump.c b/mplayer/TOOLS/avisubdump.c
index e2d1f195..b2d02b75 100644
--- a/mplayer/TOOLS/avisubdump.c
+++ b/mplayer/TOOLS/avisubdump.c
@@ -180,8 +180,12 @@ int main(int argc,char* argv[])
exit(1);
}
- if (strcmp(argv[argc-1], "-") == 0) f=stdin;
- else f=fopen(argv[argc-1],"rb");
+ if (strcmp(argv[argc-1], "-") == 0) {
+ dump(stdin);
+ return 0;
+ }
+
+ f=fopen(argv[argc-1],"rb");
if (!f) {
fprintf(stderr, "Could not open '%s': %s\n",
@@ -190,6 +194,7 @@ int main(int argc,char* argv[])
}
dump(f);
+ fclose(f);
return 0;
}
diff --git a/mplayer/TOOLS/mp-uncrustify-style.cfg b/mplayer/TOOLS/mp-uncrustify-style.cfg
new file mode 100644
index 00000000..e68e6f6b
--- /dev/null
+++ b/mplayer/TOOLS/mp-uncrustify-style.cfg
@@ -0,0 +1,1397 @@
+# Uncrustify 0.57
+
+###
+###### TODO/FIXME ###
+###
+### - Align comments?
+###
+### - New line after function
+###
+### nl_after_func_body force one blank line after each function, but it should
+### not when surrounded with #ifdef:
+###
+### #ifdef CONFIG_DVDNAV
+### static void mp_dvdnav_context_free(MPContext *ctx)
+### {
+### // [...]
+### }
+###
+### #endif
+###
+### void uninit_player(unsigned int mask)
+###
+
+#
+# General options
+#
+
+# The type of line endings
+newlines = lf # auto/lf/crlf/cr
+
+# The original size of tabs in the input
+input_tab_size = 8 # number
+
+# The size of tabs in the output (only used if align_with_tabs=true)
+output_tab_size = 8 # number
+
+# The ASCII value of the string escape char, usually 92 (\) or 94 (^). (Pawn)
+string_escape_char = 92 # number
+
+# Alternate string escape char for Pawn. Only works right before the quote char.
+string_escape_char2 = 0 # number
+
+#
+# Indenting
+#
+
+# The number of columns to indent per level.
+# Usually 2, 3, 4, or 8.
+indent_columns = 4 # number
+
+# The continuation indent. If non-zero, this overrides the indent of '(' and '=' continuation indents.
+# For FreeBSD, this is set to 4.
+indent_continue = 0 # number
+
+# How to use tabs when indenting code
+# 0=spaces only
+# 1=indent with tabs to brace level, align with spaces
+# 2=indent and align with tabs, using spaces when not on a tabstop
+indent_with_tabs = 0 # number
+
+# Comments that are not a brace level are indented with tabs on a tabstop.
+# Requires indent_with_tabs=2. If false, will use spaces.
+indent_cmt_with_tabs = false # false/true
+
+# Whether to indent strings broken by '\' so that they line up
+indent_align_string = true # false/true
+
+# The number of spaces to indent multi-line XML strings.
+# Requires indent_align_string=True
+indent_xml_string = 0 # number
+
+# Spaces to indent '{' from level
+indent_brace = 0 # number
+
+# Whether braces are indented to the body level
+indent_braces = false # false/true
+
+# Disabled indenting function braces if indent_braces is true
+indent_braces_no_func = false # false/true
+
+# Disabled indenting class braces if indent_braces is true
+indent_braces_no_class = false # false/true
+
+# Disabled indenting struct braces if indent_braces is true
+indent_braces_no_struct = false # false/true
+
+# Indent based on the size of the brace parent, i.e. 'if' => 3 spaces, 'for' => 4 spaces, etc.
+indent_brace_parent = false # false/true
+
+# Whether the 'namespace' body is indented
+indent_namespace = false # false/true
+
+# The number of spaces to indent a namespace block
+indent_namespace_level = 0 # number
+
+# If the body of the namespace is longer than this number, it won't be indented.
+# Requires indent_namespace=true. Default=0 (no limit)
+indent_namespace_limit = 0 # number
+
+# Whether the 'extern "C"' body is indented
+indent_extern = false # false/true
+
+# Whether the 'class' body is indented
+indent_class = false # false/true
+
+# Whether to indent the stuff after a leading class colon
+indent_class_colon = false # false/true
+
+# False=treat 'else\nif' as 'else if' for indenting purposes
+# True=indent the 'if' one level
+indent_else_if = false # false/true
+
+# Amount to indent variable declarations after a open brace. neg=relative, pos=absolute
+indent_var_def_blk = 0 # number
+
+# Indent continued variable declarations instead of aligning.
+indent_var_def_cont = false # false/true
+
+# True: indent continued function call parameters one indent level
+# False: align parameters under the open paren
+indent_func_call_param = false # false/true
+
+# Same as indent_func_call_param, but for function defs
+indent_func_def_param = false # false/true
+
+# Same as indent_func_call_param, but for function protos
+indent_func_proto_param = false # false/true
+
+# Same as indent_func_call_param, but for class declarations
+indent_func_class_param = false # false/true
+
+# Same as indent_func_call_param, but for class variable constructors
+indent_func_ctor_var_param = false # false/true
+
+# Same as indent_func_call_param, but for templates
+indent_template_param = false # false/true
+
+# Double the indent for indent_func_xxx_param options
+indent_func_param_double = false # false/true
+
+# Indentation column for standalone 'const' function decl/proto qualifier
+indent_func_const = 0 # number
+
+# Indentation column for standalone 'throw' function decl/proto qualifier
+indent_func_throw = 0 # number
+
+# The number of spaces to indent a continued '->' or '.'
+# Usually set to 0, 1, or indent_columns.
+indent_member = 0 # number
+
+# Spaces to indent single line ('//') comments on lines before code
+indent_sing_line_comments = 0 # number
+
+# If set, will indent trailing single line ('//') comments relative
+# to the code instead of trying to keep the same absolute column
+indent_relative_single_line_comments = false # false/true
+
+# Spaces to indent 'case' from 'switch'
+# Usually 0 or indent_columns.
+indent_switch_case = 0 # number
+
+# Spaces to shift the 'case' line, without affecting any other lines
+# Usually 0.
+indent_case_shift = 0 # number
+
+# Spaces to indent '{' from 'case'.
+# By default, the brace will appear under the 'c' in case.
+# Usually set to 0 or indent_columns.
+indent_case_brace = 0 # number
+
+# Whether to indent comments found in first column
+indent_col1_comment = false # false/true
+
+# How to indent goto labels
+# >0 : absolute column where 1 is the leftmost column
+# <=0 : subtract from brace indent
+indent_label = 1 # number
+
+# Same as indent_label, but for access specifiers that are followed by a colon
+indent_access_spec = 1 # number
+
+# Indent the code after an access specifier by one level.
+# If set, this option forces 'indent_access_spec=0'
+indent_access_spec_body = false # false/true
+
+# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended)
+indent_paren_nl = false # false/true
+
+# Controls the indent of a close paren after a newline.
+# 0: Indent to body level
+# 1: Align under the open paren
+# 2: Indent to the brace level
+indent_paren_close = 0 # number
+
+# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren
+indent_comma_paren = false # false/true
+
+# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren
+indent_bool_paren = false # false/true
+
+# If 'indent_bool_paren' is true, controls the indent of the first expression. If TRUE, aligns the first expression to the following ones
+indent_first_bool_expr = false # false/true
+
+# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended)
+indent_square_nl = false # false/true
+
+# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies
+indent_preserve_sql = false # false/true
+
+# Align continued statements at the '='. Default=True
+# If FALSE or the '=' is followed by a newline, the next line is indent one tab.
+indent_align_assign = true # false/true
+
+#
+# Spacing options
+#
+
+# Add or remove space around arithmetic operator '+', '-', '/', '*', etc
+sp_arith = force # ignore/add/remove/force
+
+# Add or remove space around assignment operator '=', '+=', etc
+sp_assign = force # ignore/add/remove/force
+
+# Add or remove space around assignment operator '=' in a prototype
+sp_assign_default = ignore # ignore/add/remove/force
+
+# Add or remove space before assignment operator '=', '+=', etc. Overrides sp_assign.
+sp_before_assign = ignore # ignore/add/remove/force
+
+# Add or remove space after assignment operator '=', '+=', etc. Overrides sp_assign.
+sp_after_assign = ignore # ignore/add/remove/force
+
+# Add or remove space around assignment '=' in enum
+sp_enum_assign = force # ignore/add/remove/force
+
+# Add or remove space before assignment '=' in enum. Overrides sp_enum_assign.
+sp_enum_before_assign = ignore # ignore/add/remove/force
+
+# Add or remove space after assignment '=' in enum. Overrides sp_enum_assign.
+sp_enum_after_assign = ignore # ignore/add/remove/force
+
+# Add or remove space around preprocessor '##' concatenation operator. Default=Add
+sp_pp_concat = add # ignore/add/remove/force
+
+# Add or remove space after preprocessor '#' stringify operator. Also affects the '#@' charizing operator. Default=Add
+sp_pp_stringify = add # ignore/add/remove/force
+
+# Add or remove space around boolean operators '&&' and '||'
+sp_bool = force # ignore/add/remove/force
+
+# Add or remove space around compare operator '<', '>', '==', etc
+sp_compare = force # ignore/add/remove/force
+
+# Add or remove space inside '(' and ')'
+sp_inside_paren = remove # ignore/add/remove/force
+
+# Add or remove space between nested parens
+sp_paren_paren = remove # ignore/add/remove/force
+
+# Whether to balance spaces inside nested parens
+sp_balance_nested_parens = false # false/true
+
+# Add or remove space between ')' and '{'
+sp_paren_brace = force # ignore/add/remove/force
+
+# Add or remove space before pointer star '*'
+sp_before_ptr_star = force # ignore/add/remove/force
+
+# Add or remove space before pointer star '*' that isn't followed by a variable name
+# If set to 'ignore', sp_before_ptr_star is used instead.
+sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force
+
+# Add or remove space between pointer stars '*'
+sp_between_ptr_star = remove # ignore/add/remove/force
+
+# Add or remove space after pointer star '*', if followed by a word.
+sp_after_ptr_star = remove # ignore/add/remove/force
+
+# Add or remove space after a pointer star '*', if followed by a func proto/def.
+sp_after_ptr_star_func = remove # ignore/add/remove/force
+
+# Add or remove space before a pointer star '*', if followed by a func proto/def.
+sp_before_ptr_star_func = ignore # ignore/add/remove/force
+
+# Add or remove space before a reference sign '&'
+sp_before_byref = force # ignore/add/remove/force
+
+# Add or remove space before a reference sign '&' that isn't followed by a variable name
+# If set to 'ignore', sp_before_byref is used instead.
+sp_before_unnamed_byref = force # ignore/add/remove/force
+
+# Add or remove space after reference sign '&', if followed by a word.
+sp_after_byref = ignore # ignore/add/remove/force
+
+# Add or remove space after a reference sign '&', if followed by a func proto/def.
+sp_after_byref_func = ignore # ignore/add/remove/force
+
+# Add or remove space before a reference sign '&', if followed by a func proto/def.
+sp_before_byref_func = ignore # ignore/add/remove/force
+
+# Add or remove space between type and word. Default=Force
+sp_after_type = force # ignore/add/remove/force
+
+# Add or remove space in 'template <' vs 'template<'.
+# If set to ignore, sp_before_angle is used.
+sp_template_angle = ignore # ignore/add/remove/force
+
+# Add or remove space before '<>'
+sp_before_angle = ignore # ignore/add/remove/force
+
+# Add or remove space inside '<' and '>'
+sp_inside_angle = ignore # ignore/add/remove/force
+
+# Add or remove space after '<>'
+sp_after_angle = ignore # ignore/add/remove/force
+
+# Add or remove space between '<>' and '(' as found in 'new List();'
+sp_angle_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between '<>' and a word as in 'List m;'
+sp_angle_word = ignore # ignore/add/remove/force
+
+# Add or remove space between '>' and '>' in '>>' (template stuff C++/C# only). Default=Add
+sp_angle_shift = add # ignore/add/remove/force
+
+# Add or remove space before '(' of 'if', 'for', 'switch', and 'while'
+sp_before_sparen = force # ignore/add/remove/force
+
+# Add or remove space inside if-condition '(' and ')'
+sp_inside_sparen = remove # ignore/add/remove/force
+
+# Add or remove space before if-condition ')'. Overrides sp_inside_sparen.
+sp_inside_sparen_close = ignore # ignore/add/remove/force
+
+# Add or remove space after ')' of 'if', 'for', 'switch', and 'while'
+sp_after_sparen = ignore # ignore/add/remove/force
+
+# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while'
+sp_sparen_brace = force # ignore/add/remove/force
+
+# Add or remove space between 'invariant' and '(' in the D language.
+sp_invariant_paren = ignore # ignore/add/remove/force
+
+# Add or remove space after the ')' in 'invariant (C) c' in the D language.
+sp_after_invariant_paren = ignore # ignore/add/remove/force
+
+# Add or remove space before empty statement ';' on 'if', 'for' and 'while'
+sp_special_semi = ignore # ignore/add/remove/force
+
+# Add or remove space before ';'. Default=Remove
+sp_before_semi = remove # ignore/add/remove/force
+
+# Add or remove space before ';' in non-empty 'for' statements
+sp_before_semi_for = ignore # ignore/add/remove/force
+
+# Add or remove space before a semicolon of an empty part of a for statement.
+sp_before_semi_for_empty = ignore # ignore/add/remove/force
+
+# Add or remove space after ';', except when followed by a comment. Default=Add
+sp_after_semi = force # ignore/add/remove/force
+
+# Add or remove space after ';' in non-empty 'for' statements. Default=Force
+sp_after_semi_for = force # ignore/add/remove/force
+
+# Add or remove space after the final semicolon of an empty part of a for statement: for ( ; ; ).
+sp_after_semi_for_empty = ignore # ignore/add/remove/force
+
+# Add or remove space before '[' (except '[]')
+sp_before_square = remove # ignore/add/remove/force
+
+# Add or remove space before '[]'
+sp_before_squares = ignore # ignore/add/remove/force
+
+# Add or remove space inside '[' and ']'
+sp_inside_square = ignore # ignore/add/remove/force
+
+# Add or remove space after ','
+sp_after_comma = force # ignore/add/remove/force
+
+# Add or remove space before ','
+sp_before_comma = remove # ignore/add/remove/force
+
+# Add or remove space between an open paren and comma: '(,' vs '( ,'
+sp_paren_comma = force # ignore/add/remove/force
+
+# Add or remove space before the variadic '...' when preceded by a non-punctuator
+sp_before_ellipsis = ignore # ignore/add/remove/force
+
+# Add or remove space after class ':'
+sp_after_class_colon = ignore # ignore/add/remove/force
+
+# Add or remove space before class ':'
+sp_before_class_colon = ignore # ignore/add/remove/force
+
+# Add or remove space before case ':'. Default=Remove
+sp_before_case_colon = remove # ignore/add/remove/force
+
+# Add or remove space between 'operator' and operator sign
+sp_after_operator = ignore # ignore/add/remove/force
+
+# Add or remove space between the operator symbol and the open paren, as in 'operator ++('
+sp_after_operator_sym = ignore # ignore/add/remove/force
+
+# Add or remove space after C/D cast, i.e. 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a'
+sp_after_cast = remove # ignore/add/remove/force
+
+# Add or remove spaces inside cast parens
+sp_inside_paren_cast = ignore # ignore/add/remove/force
+
+# Add or remove space between the type and open paren in a C++ cast, i.e. 'int(exp)' vs 'int (exp)'
+sp_cpp_cast_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'sizeof' and '('
+sp_sizeof_paren = remove # ignore/add/remove/force
+
+# Add or remove space after the tag keyword (Pawn)
+sp_after_tag = ignore # ignore/add/remove/force
+
+# Add or remove space inside enum '{' and '}'
+sp_inside_braces_enum = remove # ignore/add/remove/force
+
+# Add or remove space inside struct/union '{' and '}'
+sp_inside_braces_struct = force # ignore/add/remove/force
+
+# Add or remove space inside '{' and '}'
+sp_inside_braces = force # ignore/add/remove/force
+
+# Add or remove space inside '{}'
+sp_inside_braces_empty = remove # ignore/add/remove/force
+
+# Add or remove space between return type and function name
+# A minimum of 1 is forced except for pointer return types.
+sp_type_func = remove # ignore/add/remove/force
+
+# Add or remove space between function name and '(' on function declaration
+sp_func_proto_paren = remove # ignore/add/remove/force
+
+# Add or remove space between function name and '(' on function definition
+sp_func_def_paren = remove # ignore/add/remove/force
+
+# Add or remove space inside empty function '()'
+sp_inside_fparens = remove # ignore/add/remove/force
+
+# Add or remove space inside function '(' and ')'
+sp_inside_fparen = remove # ignore/add/remove/force
+
+# Add or remove space between ']' and '(' when part of a function call.
+sp_square_fparen = ignore # ignore/add/remove/force
+
+# Add or remove space between ')' and '{' of function
+sp_fparen_brace = ignore # ignore/add/remove/force
+
+# Add or remove space between function name and '(' on function calls
+sp_func_call_paren = remove # ignore/add/remove/force
+
+# Add or remove space between function name and '()' on function calls without parameters.
+# If set to 'ignore' (the default), sp_func_call_paren is used.
+sp_func_call_paren_empty = ignore # ignore/add/remove/force
+
+# Add or remove space between the user function name and '(' on function calls
+# You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file.
+sp_func_call_user_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between a constructor/destructor and the open paren
+sp_func_class_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'return' and '('
+sp_return_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between '__attribute__' and '('
+sp_attribute_paren = remove # ignore/add/remove/force
+
+# Add or remove space between 'defined' and '(' in '#if defined (FOO)'
+sp_defined_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'throw' and '(' in 'throw (something)'
+sp_throw_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between macro and value
+sp_macro = ignore # ignore/add/remove/force
+
+# Add or remove space between macro function ')' and value
+sp_macro_func = ignore # ignore/add/remove/force
+
+# Add or remove space between 'else' and '{' if on the same line
+sp_else_brace = force # ignore/add/remove/force
+
+# Add or remove space between '}' and 'else' if on the same line
+sp_brace_else = force # ignore/add/remove/force
+
+# Add or remove space between '}' and the name of a typedef on the same line
+sp_brace_typedef = force # ignore/add/remove/force
+
+# Add or remove space between 'catch' and '{' if on the same line
+sp_catch_brace = ignore # ignore/add/remove/force
+
+# Add or remove space between '}' and 'catch' if on the same line
+sp_brace_catch = ignore # ignore/add/remove/force
+
+# Add or remove space between 'finally' and '{' if on the same line
+sp_finally_brace = ignore # ignore/add/remove/force
+
+# Add or remove space between '}' and 'finally' if on the same line
+sp_brace_finally = ignore # ignore/add/remove/force
+
+# Add or remove space between 'try' and '{' if on the same line
+sp_try_brace = ignore # ignore/add/remove/force
+
+# Add or remove space between get/set and '{' if on the same line
+sp_getset_brace = ignore # ignore/add/remove/force
+
+# Add or remove space before the '::' operator
+sp_before_dc = ignore # ignore/add/remove/force
+
+# Add or remove space after the '::' operator
+sp_after_dc = ignore # ignore/add/remove/force
+
+# Add or remove around the D named array initializer ':' operator
+sp_d_array_colon = ignore # ignore/add/remove/force
+
+# Add or remove space after the '!' (not) operator. Default=Remove
+sp_not = remove # ignore/add/remove/force
+
+# Add or remove space after the '~' (invert) operator. Default=Remove
+sp_inv = remove # ignore/add/remove/force
+
+# Add or remove space after the '&' (address-of) operator. Default=Remove
+# This does not affect the spacing after a '&' that is part of a type.
+sp_addr = remove # ignore/add/remove/force
+
+# Add or remove space around the '.' or '->' operators. Default=Remove
+sp_member = remove # ignore/add/remove/force
+
+# Add or remove space after the '*' (dereference) operator. Default=Remove
+# This does not affect the spacing after a '*' that is part of a type.
+sp_deref = remove # ignore/add/remove/force
+
+# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'. Default=Remove
+sp_sign = remove # ignore/add/remove/force
+
+# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;'. Default=Remove
+sp_incdec = remove # ignore/add/remove/force
+
+# Add or remove space before a backslash-newline at the end of a line. Default=Add
+sp_before_nl_cont = add # ignore/add/remove/force
+
+# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;'
+sp_after_oc_scope = ignore # ignore/add/remove/force
+
+# Add or remove space after the colon in message specs
+# '-(int) f:(int) x;' vs '-(int) f: (int) x;'
+sp_after_oc_colon = ignore # ignore/add/remove/force
+
+# Add or remove space before the colon in message specs
+# '-(int) f: (int) x;' vs '-(int) f : (int) x;'
+sp_before_oc_colon = ignore # ignore/add/remove/force
+
+# Add or remove space after the colon in message specs
+# '[object setValue:1];' vs '[object setValue: 1];'
+sp_after_send_oc_colon = ignore # ignore/add/remove/force
+
+# Add or remove space before the colon in message specs
+# '[object setValue:1];' vs '[object setValue :1];'
+sp_before_send_oc_colon = ignore # ignore/add/remove/force
+
+# Add or remove space after the (type) in message specs
+# '-(int)f: (int) x;' vs '-(int)f: (int)x;'
+sp_after_oc_type = ignore # ignore/add/remove/force
+
+# Add or remove space after the first (type) in message specs
+# '-(int) f:(int)x;' vs '-(int)f:(int)x;'
+sp_after_oc_return_type = ignore # ignore/add/remove/force
+
+# Add or remove space between '@selector' and '('
+# '@selector(msgName)' vs '@selector (msgName)'
+# Also applies to @protocol() constructs
+sp_after_oc_at_sel = ignore # ignore/add/remove/force
+
+# Add or remove space between '@selector(x)' and the following word
+# '@selector(foo) a:' vs '@selector(foo)a:'
+sp_after_oc_at_sel_parens = ignore # ignore/add/remove/force
+
+# Add or remove space inside '@selector' parens
+# '@selector(foo)' vs '@selector( foo )'
+# Also applies to @protocol() constructs
+sp_inside_oc_at_sel_parens = ignore # ignore/add/remove/force
+
+# Add or remove space before a block pointer caret
+# '^int (int arg){...}' vs. ' ^int (int arg){...}'
+sp_before_oc_block_caret = ignore # ignore/add/remove/force
+
+# Add or remove space after a block pointer caret
+# '^int (int arg){...}' vs. '^ int (int arg){...}'
+sp_after_oc_block_caret = ignore # ignore/add/remove/force
+
+# Add or remove space around the ':' in 'b ? t : f'
+sp_cond_colon = force # ignore/add/remove/force
+
+# Add or remove space around the '?' in 'b ? t : f'
+sp_cond_question = force # ignore/add/remove/force
+
+# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here.
+sp_case_label = ignore # ignore/add/remove/force
+
+# Control the space around the D '..' operator.
+sp_range = ignore # ignore/add/remove/force
+
+# Control the space after the opening of a C++ comment '// A' vs '//A'
+sp_cmt_cpp_start = force # ignore/add/remove/force
+
+# Controls the spaces between #else or #endif and a trailing comment
+sp_endif_cmt = ignore # ignore/add/remove/force
+
+#
+# Code alignment (not left column spaces/tabs)
+#
+
+# Whether to keep non-indenting tabs
+align_keep_tabs = false # false/true
+
+# Whether to use tabs for aligning
+align_with_tabs = false # false/true
+
+# Whether to bump out to the next tab when aligning
+align_on_tabstop = false # false/true
+
+# Whether to left-align numbers
+align_number_left = false # false/true
+
+# Align variable definitions in prototypes and functions
+align_func_params = false # false/true
+
+# Align parameters in single-line functions that have the same name.
+# The function names must already be aligned with each other.
+align_same_func_call_params = false # false/true
+
+# The span for aligning variable definitions (0=don't align)
+align_var_def_span = 0 # number
+
+# How to align the star in variable definitions.
+# 0=Part of the type 'void * foo;'
+# 1=Part of the variable 'void *foo;'
+# 2=Dangling 'void *foo;'
+align_var_def_star_style = 2 # number
+
+# How to align the '&' in variable definitions.
+# 0=Part of the type
+# 1=Part of the variable
+# 2=Dangling
+align_var_def_amp_style = 0 # number
+
+# The threshold for aligning variable definitions (0=no limit)
+align_var_def_thresh = 0 # number
+
+# The gap for aligning variable definitions
+align_var_def_gap = 0 # number
+
+# Whether to align the colon in struct bit fields
+align_var_def_colon = false # false/true
+
+# Whether to align any attribute after the variable name
+align_var_def_attribute = false # false/true
+
+# Whether to align inline struct/enum/union variable definitions
+align_var_def_inline = false # false/true
+
+# The span for aligning on '=' in assignments (0=don't align)
+align_assign_span = 1 # number
+
+# The threshold for aligning on '=' in assignments (0=no limit)
+align_assign_thresh = 6 # number
+
+# The span for aligning on '=' in enums (0=don't align)
+align_enum_equ_span = 1 # number
+
+# The threshold for aligning on '=' in enums (0=no limit)
+align_enum_equ_thresh = 0 # number
+
+# The span for aligning struct/union (0=don't align)
+align_var_struct_span = 0 # number
+
+# The threshold for aligning struct/union member definitions (0=no limit)
+align_var_struct_thresh = 0 # number
+
+# The gap for aligning struct/union member definitions
+align_var_struct_gap = 0 # number
+
+# The span for aligning struct initializer values (0=don't align)
+align_struct_init_span = 1 # number
+
+# The minimum space between the type and the synonym of a typedef
+align_typedef_gap = 0 # number
+
+# The span for aligning single-line typedefs (0=don't align)
+align_typedef_span = 0 # number
+
+# How to align typedef'd functions with other typedefs
+# 0: Don't mix them at all
+# 1: align the open paren with the types
+# 2: align the function type name with the other type names
+align_typedef_func = 0 # number
+
+# Controls the positioning of the '*' in typedefs. Just try it.
+# 0: Align on typedef type, ignore '*'
+# 1: The '*' is part of type name: typedef int *pint;
+# 2: The '*' is part of the type, but dangling: typedef int *pint;
+align_typedef_star_style = 0 # number
+
+# Controls the positioning of the '&' in typedefs. Just try it.
+# 0: Align on typedef type, ignore '&'
+# 1: The '&' is part of type name: typedef int &pint;
+# 2: The '&' is part of the type, but dangling: typedef int &pint;
+align_typedef_amp_style = 0 # number
+
+# The span for aligning comments that end lines (0=don't align)
+align_right_cmt_span = 0 # number
+
+# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment
+align_right_cmt_mix = false # false/true
+
+# If a trailing comment is more than this number of columns away from the text it follows,
+# it will qualify for being aligned. This has to be > 0 to do anything.
+align_right_cmt_gap = 0 # number
+
+# Align trailing comment at or beyond column N; 'pulls in' comments as a bonus side effect (0=ignore)
+align_right_cmt_at_col = 0 # number
+
+# The span for aligning function prototypes (0=don't align)
+align_func_proto_span = 0 # number
+
+# Minimum gap between the return type and the function name.
+align_func_proto_gap = 0 # number
+
+# Align function protos on the 'operator' keyword instead of what follows
+align_on_operator = false # false/true
+
+# Whether to mix aligning prototype and variable declarations.
+# If true, align_var_def_XXX options are used instead of align_func_proto_XXX options.
+align_mix_var_proto = false # false/true
+
+# Align single-line functions with function prototypes, uses align_func_proto_span
+align_single_line_func = false # false/true
+
+# Aligning the open brace of single-line functions.
+# Requires align_single_line_func=true, uses align_func_proto_span
+align_single_line_brace = false # false/true
+
+# Gap for align_single_line_brace.
+align_single_line_brace_gap = 0 # number
+
+# The span for aligning ObjC msg spec (0=don't align)
+align_oc_msg_spec_span = 0 # number
+
+# Whether to align macros wrapped with a backslash and a newline.
+# This will not work right if the macro contains a multi-line comment.
+align_nl_cont = false # false/true
+
+# The minimum space between label and value of a preprocessor define
+align_pp_define_gap = 0 # number
+
+# The span for aligning on '#define' bodies (0=don't align)
+align_pp_define_span = 0 # number
+
+# Align lines that start with '<<' with previous '<<'. Default=true
+align_left_shift = true # false/true
+
+# Span for aligning parameters in an Obj-C message call on the ':' (0=don't align)
+align_oc_msg_colon_span = 0 # number
+
+# Aligning parameters in an Obj-C '+' or '-' declaration on the ':'
+align_oc_decl_colon = false # false/true
+
+#
+# Newline adding and removing options
+#
+
+# Whether to collapse empty blocks between '{' and '}'
+nl_collapse_empty_body = false # false/true
+
+# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };'
+nl_assign_leave_one_liners = false # false/true
+
+# Don't split one-line braced statements inside a class xx { } body
+nl_class_leave_one_liners = false # false/true
+
+# Don't split one-line enums: 'enum foo { BAR = 15 };'
+nl_enum_leave_one_liners = false # false/true
+
+# Don't split one-line get or set functions
+nl_getset_leave_one_liners = false # false/true
+
+# Don't split one-line function definitions - 'int foo() { return 0; }'
+nl_func_leave_one_liners = false # false/true
+
+# Don't split one-line if/else statements - 'if(a) b++;'
+nl_if_leave_one_liners = false # false/true
+
+# Add or remove newlines at the start of the file
+nl_start_of_file = remove # ignore/add/remove/force
+
+# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force'
+nl_start_of_file_min = 0 # number
+
+# Add or remove newline at the end of the file
+nl_end_of_file = force # ignore/add/remove/force
+
+# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force')
+nl_end_of_file_min = 1 # number
+
+# Add or remove newline between '=' and '{'
+nl_assign_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between '=' and '[' (D only)
+nl_assign_square = ignore # ignore/add/remove/force
+
+# Add or remove newline after '= [' (D only). Will also affect the newline before the ']'
+nl_after_square_assign = ignore # ignore/add/remove/force
+
+# The number of blank lines after a block of variable definitions
+nl_func_var_def_blk = 0 # number
+
+# Add or remove newline between a function call's ')' and '{', as in:
+# list_for_each(item, &list) { }
+nl_fcall_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'enum' and '{'
+nl_enum_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between 'struct and '{'
+nl_struct_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between 'union' and '{'
+nl_union_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between 'if' and '{'
+nl_if_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'else'
+nl_brace_else = remove # ignore/add/remove/force
+
+# Add or remove newline between 'else if' and '{'
+# If set to ignore, nl_if_brace is used instead
+nl_elseif_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'else' and '{'
+nl_else_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between 'else' and 'if'
+nl_else_if = remove # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'finally'
+nl_brace_finally = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'finally' and '{'
+nl_finally_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'try' and '{'
+nl_try_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between get/set and '{'
+nl_getset_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'for' and '{'
+nl_for_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between 'catch' and '{'
+nl_catch_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'catch'
+nl_brace_catch = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'while' and '{'
+nl_while_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between 'using' and '{'
+nl_using_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between two open or close braces.
+# Due to general newline/brace handling, REMOVE may not work.
+nl_brace_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'do' and '{'
+nl_do_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'while' of 'do' statement
+nl_brace_while = remove # ignore/add/remove/force
+
+# Add or remove newline between 'switch' and '{'
+nl_switch_brace = remove # ignore/add/remove/force
+
+# Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc.
+# Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch, and nl_catch_brace.
+nl_multi_line_cond = false # false/true
+
+# Force a newline in a define after the macro name for multi-line defines.
+nl_multi_line_define = false # false/true
+
+# Whether to put a newline before 'case' statement
+nl_before_case = false # false/true
+
+# Add or remove newline between ')' and 'throw'
+nl_before_throw = ignore # ignore/add/remove/force
+
+# Whether to put a newline after 'case' statement
+nl_after_case = false # false/true
+
+# Newline between namespace and {
+nl_namespace_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'template<>' and whatever follows.
+nl_template_class = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'class' and '{'
+nl_class_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline after each ',' in the constructor member initialization
+nl_class_init_args = ignore # ignore/add/remove/force
+
+# Add or remove newline between return type and function name in a function definition
+nl_func_type_name = remove # ignore/add/remove/force
+
+# Add or remove newline between return type and function name inside a class {}
+# Uses nl_func_type_name or nl_func_proto_type_name if set to ignore.
+nl_func_type_name_class = ignore # ignore/add/remove/force
+
+# Add or remove newline between function scope and name in a definition
+# Controls the newline after '::' in 'void A::f() { }'
+nl_func_scope_name = ignore # ignore/add/remove/force
+
+# Add or remove newline between return type and function name in a prototype
+nl_func_proto_type_name = remove # ignore/add/remove/force
+
+# Add or remove newline between a function name and the opening '('
+nl_func_paren = remove # ignore/add/remove/force
+
+# Add or remove newline between a function name and the opening '(' in the definition
+nl_func_def_paren = remove # ignore/add/remove/force
+
+# Add or remove newline after '(' in a function declaration
+nl_func_decl_start = remove # ignore/add/remove/force
+
+# Add or remove newline after '(' in a function definition
+nl_func_def_start = ignore # ignore/add/remove/force
+
+# Overrides nl_func_decl_start when there is only one parameter.
+nl_func_decl_start_single = ignore # ignore/add/remove/force
+
+# Overrides nl_func_def_start when there is only one parameter.
+nl_func_def_start_single = ignore # ignore/add/remove/force
+
+# Add or remove newline after each ',' in a function declaration
+nl_func_decl_args = ignore # ignore/add/remove/force
+
+# Add or remove newline after each ',' in a function definition
+nl_func_def_args = ignore # ignore/add/remove/force
+
+# Add or remove newline before the ')' in a function declaration
+nl_func_decl_end = remove # ignore/add/remove/force
+
+# Add or remove newline before the ')' in a function definition
+nl_func_def_end = ignore # ignore/add/remove/force
+
+# Overrides nl_func_decl_end when there is only one parameter.
+nl_func_decl_end_single = ignore # ignore/add/remove/force
+
+# Overrides nl_func_def_end when there is only one parameter.
+nl_func_def_end_single = ignore # ignore/add/remove/force
+
+# Add or remove newline between '()' in a function declaration.
+nl_func_decl_empty = ignore # ignore/add/remove/force
+
+# Add or remove newline between '()' in a function definition.
+nl_func_def_empty = ignore # ignore/add/remove/force
+
+# Add or remove newline between function signature and '{'
+nl_fdef_brace = force # ignore/add/remove/force
+
+# Whether to put a newline after 'return' statement
+nl_after_return = false # false/true
+
+# Add or remove a newline between the return keyword and return expression.
+nl_return_expr = ignore # ignore/add/remove/force
+
+# Whether to put a newline after semicolons, except in 'for' statements
+nl_after_semicolon = true # false/true
+
+# Whether to put a newline after brace open.
+# This also adds a newline before the matching brace close.
+nl_after_brace_open = false # false/true
+
+# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is
+# placed between the open brace and a trailing single-line comment.
+nl_after_brace_open_cmt = false # false/true
+
+# Whether to put a newline after a virtual brace open with a non-empty body.
+# These occur in un-braced if/while/do/for statement bodies.
+nl_after_vbrace_open = true # false/true
+
+# Whether to put a newline after a virtual brace open with an empty body.
+# These occur in un-braced if/while/do/for statement bodies.
+nl_after_vbrace_open_empty = false # false/true
+
+# Whether to put a newline after a brace close.
+# Does not apply if followed by a necessary ';'.
+nl_after_brace_close = false # false/true
+
+# Whether to put a newline after a virtual brace close.
+# Would add a newline before return in: 'if (foo) a++; return;'
+nl_after_vbrace_close = false # false/true
+
+# Whether to alter newlines in '#define' macros
+nl_define_macro = false # false/true
+
+# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif'
+nl_squeeze_ifdef = false # false/true
+
+# Add or remove blank line before 'if'
+nl_before_if = ignore # ignore/add/remove/force
+
+# Add or remove blank line after 'if' statement
+nl_after_if = ignore # ignore/add/remove/force
+
+# Add or remove blank line before 'for'
+nl_before_for = ignore # ignore/add/remove/force
+
+# Add or remove blank line after 'for' statement
+nl_after_for = ignore # ignore/add/remove/force
+
+# Add or remove blank line before 'while'
+nl_before_while = ignore # ignore/add/remove/force
+
+# Add or remove blank line after 'while' statement
+nl_after_while = ignore # ignore/add/remove/force
+
+# Add or remove blank line before 'switch'
+nl_before_switch = ignore # ignore/add/remove/force
+
+# Add or remove blank line after 'switch' statement
+nl_after_switch = ignore # ignore/add/remove/force
+
+# Add or remove blank line before 'do'
+nl_before_do = ignore # ignore/add/remove/force
+
+# Add or remove blank line after 'do/while' statement
+nl_after_do = ignore # ignore/add/remove/force
+
+# Whether to double-space commented-entries in struct/enum
+nl_ds_struct_enum_cmt = false # false/true
+
+# Whether to double-space before the close brace of a struct/union/enum
+# (lower priority than 'eat_blanks_before_close_brace')
+nl_ds_struct_enum_close_brace = false # false/true
+
+# Add or remove a newline around a class colon.
+# Related to pos_class_colon, nl_class_init_args, and pos_comma.
+nl_class_colon = ignore # ignore/add/remove/force
+
+# Change simple unbraced if statements into a one-liner
+# 'if(b)\n i++;' => 'if(b) i++;'
+nl_create_if_one_liner = false # false/true
+
+# Change simple unbraced for statements into a one-liner
+# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);'
+nl_create_for_one_liner = false # false/true
+
+# Change simple unbraced while statements into a one-liner
+# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);'
+nl_create_while_one_liner = false # false/true
+
+#
+# Positioning options
+#
+
+# The position of arithmetic operators in wrapped expressions
+pos_arith = ignore # ignore/lead/lead_break/lead_force/trail/trail_break/trail_force
+
+# The position of assignment in wrapped expressions.
+# Do not affect '=' followed by '{'
+pos_assign = ignore # ignore/lead/lead_break/lead_force/trail/trail_break/trail_force
+
+# The position of boolean operators in wrapped expressions
+pos_bool = ignore # ignore/lead/lead_break/lead_force/trail/trail_break/trail_force
+
+# The position of comparison operators in wrapped expressions
+pos_compare = ignore # ignore/lead/lead_break/lead_force/trail/trail_break/trail_force
+
+# The position of conditional (b ? t : f) operators in wrapped expressions
+pos_conditional = ignore # ignore/lead/lead_break/lead_force/trail/trail_break/trail_force
+
+# The position of the comma in wrapped expressions
+pos_comma = ignore # ignore/lead/lead_break/lead_force/trail/trail_break/trail_force
+
+# The position of the comma in the constructor initialization list
+pos_class_comma = ignore # ignore/lead/lead_break/lead_force/trail/trail_break/trail_force
+
+# The position of colons between constructor and member initialization
+pos_class_colon = ignore # ignore/lead/lead_break/lead_force/trail/trail_break/trail_force
+
+#
+# Line Splitting options
+#
+
+# Try to limit code width to N number of columns
+code_width = 0 # number
+
+# Whether to fully split long 'for' statements at semi-colons
+ls_for_split_full = false # false/true
+
+# Whether to fully split long function protos/calls at commas
+ls_func_split_full = false # false/true
+
+#
+# Blank line options
+#
+
+# The maximum consecutive newlines
+nl_max = 2 # number
+
+# The number of newlines after a function prototype, if followed by another function prototype
+nl_after_func_proto = 0 # number
+
+# The number of newlines after a function prototype, if not followed by another function prototype
+nl_after_func_proto_group = 0 # number
+
+# The number of newlines after '}' of a multi-line function body
+nl_after_func_body = 2 # number
+
+# The number of newlines after '}' of a single line function body
+nl_after_func_body_one_liner = 2 # number
+
+# The minimum number of newlines before a multi-line comment.
+# Doesn't apply if after a brace open or another multi-line comment.
+nl_before_block_comment = 0 # number
+
+# The minimum number of newlines before a single-line C comment.
+# Doesn't apply if after a brace open or other single-line C comments.
+nl_before_c_comment = 0 # number
+
+# The minimum number of newlines before a CPP comment.
+# Doesn't apply if after a brace open or other CPP comments.
+nl_before_cpp_comment = 0 # number
+
+# Whether to force a newline after a multi-line comment.
+nl_after_multiline_comment = false # false/true
+
+# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label.
+# Will not change the newline count if after a brace open.
+# 0 = No change.
+nl_before_access_spec = 0 # number
+
+# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label.
+# 0 = No change.
+nl_after_access_spec = 0 # number
+
+# The number of newlines between a function def and the function comment.
+# 0 = No change.
+nl_comment_func_def = 0 # number
+
+# The number of newlines after a try-catch-finally block that isn't followed by a brace close.
+# 0 = No change.
+nl_after_try_catch_finally = 0 # number
+
+# The number of newlines before and after a property, indexer or event decl.
+# 0 = No change.
+nl_around_cs_property = 0 # number
+
+# The number of newlines between the get/set/add/remove handlers in C#.
+# 0 = No change.
+nl_between_get_set = 0 # number
+
+# Whether to remove blank lines after '{'
+eat_blanks_after_open_brace = true # false/true
+
+# Whether to remove blank lines before '}'
+eat_blanks_before_close_brace = true # false/true
+
+#
+# Code modifying options (non-whitespace)
+#
+
+# Add or remove braces on single-line 'do' statement
+mod_full_brace_do = remove # ignore/add/remove/force
+
+# Add or remove braces on single-line 'for' statement
+mod_full_brace_for = remove # ignore/add/remove/force
+
+# Add or remove braces on single-line function definitions. (Pawn)
+mod_full_brace_function = ignore # ignore/add/remove/force
+
+# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'.
+mod_full_brace_if = ignore # ignore/add/remove/force
+
+# Make all if/elseif/else statements in a chain be braced or not. Overrides mod_full_brace_if.
+# If any must be braced, they are all braced. If all can be unbraced, then the braces are removed.
+mod_full_brace_if_chain = false # false/true
+
+# Don't remove braces around statements that span N newlines
+mod_full_brace_nl = 0 # number
+
+# Add or remove braces on single-line 'while' statement
+mod_full_brace_while = remove # ignore/add/remove/force
+
+# Add or remove braces on single-line 'using ()' statement
+mod_full_brace_using = remove # ignore/add/remove/force
+
+# Add or remove unnecessary paren on 'return' statement
+mod_paren_on_return = remove # ignore/add/remove/force
+
+# Whether to change optional semicolons to real semicolons
+mod_pawn_semicolon = false # false/true
+
+# Add parens on 'while' and 'if' statement around bools
+mod_full_paren_if_bool = false # false/true
+
+# Whether to remove superfluous semicolons
+mod_remove_extra_semicolon = true # false/true
+
+# If a function body exceeds the specified number of newlines and doesn't have a comment after
+# the close brace, a comment will be added.
+mod_add_long_function_closebrace_comment = 0 # number
+
+# If a switch body exceeds the specified number of newlines and doesn't have a comment after
+# the close brace, a comment will be added.
+mod_add_long_switch_closebrace_comment = 0 # number
+
+# If an #ifdef body exceeds the specified number of newlines and doesn't have a comment after
+# the #else, a comment will be added.
+mod_add_long_ifdef_endif_comment = 0 # number
+
+# If an #ifdef or #else body exceeds the specified number of newlines and doesn't have a comment after
+# the #endif, a comment will be added.
+mod_add_long_ifdef_else_comment = 0 # number
+
+# If TRUE, will sort consecutive single-line 'import' statements [Java, D]
+mod_sort_import = false # false/true
+
+# If TRUE, will sort consecutive single-line 'using' statements [C#]
+mod_sort_using = false # false/true
+
+# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C]
+# This is generally a bad idea, as it may break your code.
+mod_sort_include = false # false/true
+
+# If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace.
+mod_move_case_break = false # false/true
+
+# Will add or remove the braces around a fully braced case statement.
+# Will only remove the braces if there are no variable declarations in the block.
+mod_case_brace = ignore # ignore/add/remove/force
+
+# If TRUE, it will remove a void 'return;' that appears as the last statement in a function.
+mod_remove_empty_return = false # false/true
+
+#
+# Comment modifications
+#
+
+# Try to wrap comments at cmt_width columns
+cmt_width = 0 # number
+
+# Set the comment reflow mode (default: 0)
+# 0: no reflowing (apart from the line wrapping due to cmt_width)
+# 1: no touching at all
+# 2: full reflow
+cmt_reflow_mode = 0 # number
+
+# If false, disable all multi-line comment changes, including cmt_width. keyword substitution, and leading chars.
+# Default is true.
+cmt_indent_multi = true # false/true
+
+# Whether to group c-comments that look like they are in a block
+cmt_c_group = false # false/true
+
+# Whether to put an empty '/*' on the first line of the combined c-comment
+cmt_c_nl_start = false # false/true
+
+# Whether to put a newline before the closing '*/' of the combined c-comment
+cmt_c_nl_end = false # false/true
+
+# Whether to group cpp-comments that look like they are in a block
+cmt_cpp_group = false # false/true
+
+# Whether to put an empty '/*' on the first line of the combined cpp-comment
+cmt_cpp_nl_start = false # false/true
+
+# Whether to put a newline before the closing '*/' of the combined cpp-comment
+cmt_cpp_nl_end = false # false/true
+
+# Whether to change cpp-comments into c-comments
+cmt_cpp_to_c = false # false/true
+
+# Whether to put a star on subsequent comment lines
+cmt_star_cont = true # false/true
+
+# The number of spaces to insert at the start of subsequent comment lines
+cmt_sp_before_star_cont = 0 # number
+
+# The number of spaces to insert after the star on subsequent comment lines
+cmt_sp_after_star_cont = 0 # number
+
+# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of
+# the comment are the same length. Default=True
+cmt_multi_check_last = false # false/true
+
+# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment.
+# Will substitute $(filename) with the current file's name.
+cmt_insert_file_header = "" # string
+
+# The filename that contains text to insert at the end of a file if the file doesn't end with a C/C++ comment.
+# Will substitute $(filename) with the current file's name.
+cmt_insert_file_footer = "" # string
+
+# The filename that contains text to insert before a function implementation if the function isn't preceded with a C/C++ comment.
+# Will substitute $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff.
+# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... }
+cmt_insert_func_header = "" # string
+
+# The filename that contains text to insert before a class if the class isn't preceded with a C/C++ comment.
+# Will substitute $(class) with the class name.
+cmt_insert_class_header = "" # string
+
+# If a preprocessor is encountered when stepping backwards from a function name, then
+# this option decides whether the comment should be inserted.
+# Affects cmt_insert_func_header and cmt_insert_class_header.
+cmt_insert_before_preproc = false # false/true
+
+#
+# Preprocessor options
+#
+
+# Control indent of preprocessors inside #if blocks at brace level 0
+pp_indent = remove # ignore/add/remove/force
+
+# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false)
+pp_indent_at_level = false # false/true
+
+# If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1.
+pp_indent_count = 1 # number
+
+# Add or remove space after # based on pp_level of #if blocks
+pp_space = remove # ignore/add/remove/force
+
+# Sets the number of spaces added with pp_space
+pp_space_count = 0 # number
+
+# The indent for #region and #endregion in C# and '#pragma region' in C/C++
+pp_indent_region = 0 # number
+
+# Whether to indent the code between #region and #endregion
+pp_region_indent_code = false # false/true
+
+# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level
+pp_indent_if = 0 # number
+
+# Control whether to indent the code between #if, #else and #endif when not at file-level
+pp_if_indent_code = false # false/true
+
+# Whether to indent '#define' at the brace level (true) or from column 1 (false)
+pp_define_at_level = false # false/true
+
+# You can force a token to be a type with the 'type' option.
+# Example:
+# type myfoo1 myfoo2
+#
+# You can create custom macro-based indentation using macro-open,
+# macro-else and macro-close.
+# Example:
+# macro-open BEGIN_TEMPLATE_MESSAGE_MAP
+# macro-open BEGIN_MESSAGE_MAP
+# macro-close END_MESSAGE_MAP
+#
+# You can assign any keyword to any type with the set option.
+# set func_call_user _ N_
+#
+# The full syntax description of all custom definition config entries
+# is shown below:
+#
+# define custom tokens as:
+# - embed whitespace in token using '' escape character, or
+# put token in quotes
+# - these: ' " and ` are recognized as quote delimiters
+#
+# type token1 token2 token3 ...
+# ^ optionally specify multiple tokens on a single line
+# define def_token output_token
+# ^ output_token is optional, then NULL is assumed
+# macro-open token
+# macro-close token
+# macro-else token
+# set id token1 token2 ...
+# ^ optionally specify multiple tokens on a single line
+# ^ id is one of the names in token_enum.h sans the CT_ prefix,
+# e.g. PP_PRAGMA
+#
+# all tokens are separated by any mix of ',' commas, '=' equal signs
+# and whitespace (space, tab)
+#
diff --git a/mplayer/av_opts.c b/mplayer/av_opts.c
index 04c35f18..7da41b29 100644
--- a/mplayer/av_opts.c
+++ b/mplayer/av_opts.c
@@ -38,7 +38,7 @@ int parse_avopts(void *v, char *str){
arg = strchr(str, '=');
if(arg) *arg++= 0;
- if(!av_set_string(v, str, arg)){
+ if(av_set_string3(v, str, arg, 0, NULL) < 0){
free(start);
return -1;
}
diff --git a/mplayer/cfg-common.h b/mplayer/cfg-common.h
index 0ebbed91..5641f308 100644
--- a/mplayer/cfg-common.h
+++ b/mplayer/cfg-common.h
@@ -564,6 +564,7 @@ const m_option_t common_opts[] = {
// ------------------------- subtitles options --------------------
{"sub", &sub_name, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
+ {"sub-paths", &sub_paths, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
#ifdef CONFIG_FRIBIDI
{"fribidi-charset", &fribidi_charset, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"flip-hebrew", &flip_hebrew, CONF_TYPE_FLAG, 0, 0, 1, NULL},
diff --git a/mplayer/cfg-mplayer.h b/mplayer/cfg-mplayer.h
index a5dd73a1..3f359802 100644
--- a/mplayer/cfg-mplayer.h
+++ b/mplayer/cfg-mplayer.h
@@ -235,6 +235,7 @@ const m_option_t mplayer_opts[]={
#endif
{"osdlevel", &osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 4, NULL},
{"osd-duration", &osd_duration, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
+ {"osd-fractions", &osd_fractions, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL},
#ifdef CONFIG_MENU
{"menu", &use_menu, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"nomenu", &use_menu, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
diff --git a/mplayer/codecs.conf.h b/mplayer/codecs.conf.h
index d12e2d3b..37757c47 100644
--- a/mplayer/codecs.conf.h
+++ b/mplayer/codecs.conf.h
@@ -1280,8 +1280,8 @@ NULL, /* comment */
{ 0x00000000, 0, 0,{ 0, 0, 0, 0, 0, 0, 0, 0 } }, /* GUID */
0 /* flags */, 0 /* status */, 0 /* cpuflags */ }
,
-{{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31637661, 0x31435641, 0x63766164, 0x43564144, 0x63767676, 0x10000005, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
-{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31637661, 0x31435641, 0x63766164, 0x43564144, 0x63767676, 0x10000005, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
+{{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31637661, 0x31435641, 0x63766164, 0x43564144, 0x63767676, 0x35356961, 0x35316961, 0x71316961, 0x71356961, 0x10000005, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
+{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31637661, 0x31435641, 0x63766164, 0x43564144, 0x63767676, 0x35356961, 0x35316961, 0x71316961, 0x71356961, 0x10000005, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
{ 0x32315659, 0x30323449, 0x56555949, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* outfmt */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* outflags */
{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* infmt */
@@ -1294,8 +1294,8 @@ NULL, /* comment */
{ 0x00000000, 0, 0,{ 0, 0, 0, 0, 0, 0, 0, 0 } }, /* GUID */
0 /* flags */, 1 /* status */, 0 /* cpuflags */ }
,
-{{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31637661, 0x31435641, 0x63766164, 0x43564144, 0x10000005, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
-{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31637661, 0x31435641, 0x63766164, 0x43564144, 0x10000005, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
+{{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31637661, 0x31435641, 0x63766164, 0x43564144, 0x35356961, 0x35316961, 0x71316961, 0x71356961, 0x10000005, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
+{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31637661, 0x31435641, 0x63766164, 0x43564144, 0x35356961, 0x35316961, 0x71316961, 0x71356961, 0x10000005, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
{ 0x1DC80003, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* outfmt */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* outflags */
{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* infmt */
@@ -1308,8 +1308,8 @@ NULL, /* comment */
{ 0x00000000, 0, 0,{ 0, 0, 0, 0, 0, 0, 0, 0 } }, /* GUID */
0 /* flags */, 1 /* status */, 0 /* cpuflags */ }
,
-{{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31637661, 0x63766164, 0x43564144, 0x48535356, 0x10000005, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
-{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31435641, 0x63766164, 0x43564144, 0x48535356, 0x10000005, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
+{{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31637661, 0x63766164, 0x43564144, 0x48535356, 0x35356961, 0x35316961, 0x71316961, 0x71356961, 0x10000005, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
+{ 0x34363248, 0x34363268, 0x34363258, 0x34363278, 0x31435641, 0x63766164, 0x43564144, 0x48535356, 0x35356961, 0x35316961, 0x71316961, 0x71356961, 0x10000005, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
{ 0x32315659, 0x56555949, 0x30323449, 0x32595559, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* outfmt */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* outflags */
{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* infmt */
@@ -3954,8 +3954,8 @@ NULL, /* comment */
{ 0x00000000, 0, 0,{ 0, 0, 0, 0, 0, 0, 0, 0 } }, /* GUID */
0 /* flags */, 2 /* status */, 0 /* cpuflags */ }
,
-{{ 0x68637061, 0x6E637061, 0x73637061, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
-{ 0x68637061, 0x6E637061, 0x73637061, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
+{{ 0x68637061, 0x6E637061, 0x73637061, 0x6F637061, 0x68347061, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
+{ 0x68637061, 0x6E637061, 0x73637061, 0x6F637061, 0x68347061, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
{ 0x32595559, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* outfmt */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* outflags */
{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* infmt */
@@ -4332,6 +4332,20 @@ NULL, /* comment */
{ 0x00000000, 0, 0,{ 0, 0, 0, 0, 0, 0, 0, 0 } }, /* GUID */
0 /* flags */, 1 /* status */, 0 /* cpuflags */ }
,
+{{ 0x6E617858, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
+{ 0x6E617858, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
+{ 0x32315659, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* outfmt */
+{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* outflags */
+{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* infmt */
+{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* inflags */
+"ffwc4", /* name */
+"FFmpeg XAN wc4", /* info */
+NULL, /* comment */
+"xan_wc4", /* dll */
+"ffmpeg", /* drv */
+{ 0x00000000, 0, 0,{ 0, 0, 0, 0, 0, 0, 0, 0 } }, /* GUID */
+0 /* flags */, 1 /* status */, 0 /* cpuflags */ }
+,
{{ 0x56334357, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
{ 0x56334357, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
{ 0x42475208, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* outfmt */
@@ -5763,15 +5777,15 @@ NULL, /* comment */
{ 0x00000000, 0, 0,{ 0, 0, 0, 0, 0, 0, 0, 0 } }, /* GUID */
0 /* flags */, 1 /* status */, 0 /* cpuflags */ }
,
-{{ 0x6E617841, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
-{ 0x6E617841, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
+{{ 0x6E617841, 0x594A, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
+{ 0x6E617841, 0x594A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* outfmt */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* outflags */
{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* infmt */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* inflags */
"ffxandpcm", /* name */
"FFmpeg XAN DPCM audio", /* info */
-"only works with libavformat demuxer", /* comment */
+"Wing Commander 4 files only work with libavformat demuxer", /* comment */
"xan_dpcm", /* dll */
"ffmpeg", /* drv */
{ 0x00000000, 0, 0,{ 0, 0, 0, 0, 0, 0, 0, 0 } }, /* GUID */
@@ -6505,6 +6519,20 @@ NULL, /* comment */
{ 0x00000000, 0, 0,{ 0, 0, 0, 0, 0, 0, 0, 0 } }, /* GUID */
0 /* flags */, 1 /* status */, 0 /* cpuflags */ }
,
+{{ 0x46584C50, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
+{ 0x46584C50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
+{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* outfmt */
+{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* outflags */
+{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* infmt */
+{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* inflags */
+"ffpcmlxf", /* name */
+"Leitch/Harris PCM", /* info */
+NULL, /* comment */
+"pcm_lxf", /* dll */
+"ffmpeg", /* drv */
+{ 0x00000000, 0, 0,{ 0, 0, 0, 0, 0, 0, 0, 0 } }, /* GUID */
+0 /* flags */, 1 /* status */, 0 /* cpuflags */ }
+,
{{ 0x2000, 0x332D6361, 0x332D4341, 0x20736D, 0x74656E64, 0x33636173, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* fourcc */
{ 0x2000, 0x332D6361, 0x332D4341, 0x20736D, 0x74656E64, 0x33636173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fourccmap */
{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* outfmt */
diff --git a/mplayer/command.c b/mplayer/command.c
index b1c88252..c74ff9d7 100644
--- a/mplayer/command.c
+++ b/mplayer/command.c
@@ -70,8 +70,6 @@
#include "libavutil/avstring.h"
#include "edl.h"
-#define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
-
static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy)
{
//remove the borders, if any, and rescale to the range [0,1],[0,1]
@@ -1942,6 +1940,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
#endif
text_font_scale_factor = *(float *) arg;
force_load_font = 1;
+ vo_osd_changed(OSDTYPE_SUBTITLE);
return M_PROPERTY_OK;
case M_PROPERTY_STEP_UP:
case M_PROPERTY_STEP_DOWN:
@@ -1957,6 +1956,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
(action == M_PROPERTY_STEP_UP ? 1.0 : -1.0);
M_PROPERTY_CLAMP(prop, text_font_scale_factor);
force_load_font = 1;
+ vo_osd_changed(OSDTYPE_SUBTITLE);
return M_PROPERTY_OK;
default:
#ifdef CONFIG_ASS
diff --git a/mplayer/config.gc.h b/mplayer/config.gc.h
index 557a5a7d..db5a805f 100644
--- a/mplayer/config.gc.h
+++ b/mplayer/config.gc.h
@@ -45,17 +45,11 @@ char MPLAYER_LIBDIR[100];
#define HAVE_ERRNO_H 1
/* libdvdcss + libdvdread */
#define HAVE_LIMITS_H 1
-/* libdvdcss + libfaad2 */
+/* libdvdcss */
#define HAVE_UNISTD_H 1
-/* libfaad2 + libdvdread */
+/* libdvdread */
#define STDC_HEADERS 1
#define HAVE_MEMCPY 1
-/* libfaad2 */
-#define HAVE_STDLIB_H 1
-#define HAVE_STRING_H 1
-#undef HAVE_STRINGS_H
-#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TYPES_H 1
/* libdvdnav */
#define READ_CACHE_TRACE 0
/* libdvdread */
@@ -72,9 +66,9 @@ char MPLAYER_LIBDIR[100];
#undef HAVE_SOUNDCARD_H
#undef HAVE_SYS_ASOUNDLIB_H
-#define HAVE_SYS_SOUNDCARD_H 1
+#undef HAVE_SYS_SOUNDCARD_H
#undef HAVE_SYS_SYSINFO_H
-#define HAVE_TERMIOS_H 1
+#undef HAVE_TERMIOS_H
#undef HAVE_SYS_TERMIOS_H
#define HAVE_WINSOCK2_H 0
@@ -86,25 +80,25 @@ char MPLAYER_LIBDIR[100];
#define HAVE_LANGINFO 1
#define HAVE_MEMALIGN 1
-#undef HAVE_NANOSLEEP
+#define HAVE_NANOSLEEP 1
#undef HAVE_POSIX_SELECT
-#define HAVE_AUDIO_SELECT 1
+#undef HAVE_AUDIO_SELECT
#define HAVE_SETENV 1
#define HAVE_SETMODE 0
-#define HAVE_SHM 1
+#undef HAVE_SHM
#define HAVE_STRSEP 1
#define HAVE_SWAB 1
#undef HAVE_TERMCAP
-#define HAVE_TERMIOS 1
+#undef HAVE_TERMIOS
#define HAVE_VSSCANF 1
/* system-specific features */
#define HAVE_BUILTIN_EXPECT 1
-#define HAVE_LIBDL 1
+#undef HAVE_LIBDL
#define HAVE_DOS_PATHS 0
#define EXTERN_ASM
#define EXTERN_PREFIX ""
@@ -133,7 +127,7 @@ char MPLAYER_LIBDIR[100];
#define CONFIG_SIGHANDLER 1
#define CONFIG_SORTSUB 1
#define CONFIG_STREAM_CACHE 1
-#define PTHREAD_CACHE 1
+#undef PTHREAD_CACHE
/* CPU stuff */
@@ -211,7 +205,6 @@ char MPLAYER_LIBDIR[100];
/* codec libraries */
#undef CONFIG_FAAC
#undef CONFIG_FAAD
-#undef CONFIG_FAAD_INTERNAL
#undef CONFIG_LIBA52
#undef CONFIG_LIBDCA
#undef CONFIG_LIBDV095
@@ -329,7 +322,7 @@ char MPLAYER_LIBDIR[100];
#define HAVE_SOCKLEN_T 1
#define HAVE_STRUCT_IPV6_MREQ 0
#define HAVE_STRUCT_SOCKADDR_IN6 0
-#define HAVE_STRUCT_SOCKADDR_SA_LEN 0
+#define HAVE_STRUCT_SOCKADDR_SA_LEN 1
#undef CONFIG_VSTREAM
#define HAVE_STRUCT_ADDRINFO 0
#define HAVE_GETADDRINFO 0
@@ -381,7 +374,7 @@ char MPLAYER_LIBDIR[100];
#undef CONFIG_XVR100
#undef CONFIG_TGA
#undef CONFIG_V4L2_DECODER
-#undef CONFIG_VDPAU
+#define CONFIG_VDPAU 0
#undef CONFIG_VESA
#undef CONFIG_VIDIX
#undef CONFIG_VIDIX_DRV_CYBERBLADE
@@ -407,7 +400,7 @@ char MPLAYER_LIBDIR[100];
#undef CONFIG_XMGA
#undef CONFIG_XSS
#undef CONFIG_XV
-#undef CONFIG_XVMC
+#define CONFIG_XVMC 0
#undef CONFIG_YUV4MPEG
#undef CONFIG_ZR
@@ -450,11 +443,11 @@ char MPLAYER_LIBDIR[100];
#define CONFIG_NETWORK 0
#define CONFIG_PIC 0
#define HAVE_POSIX_MEMALIGN 0
-#undef HAVE_PTHREADS
+#define HAVE_PTHREADS 0
#define HAVE_ROUND 1
#define HAVE_ROUNDF 1
#define HAVE_TEN_OPERANDS 0
-#define HAVE_THREADS 1
+#define HAVE_THREADS 0
#define HAVE_TRUNCF 1
#define HAVE_XFORM_ASM 1
#define HAVE_XMM_CLOBBERS 0
@@ -478,7 +471,7 @@ char MPLAYER_LIBDIR[100];
#define HAVE_LDBRX 0
#define HAVE_POLL_H 0
#define HAVE_PPC4XX 0
-#define HAVE_STRERROR_R 0
+#define HAVE_STRERROR_R 1
#define HAVE_SYMVER_ASM_LABEL 0
#define HAVE_SYMVER_GNU_ASM 0
#define HAVE_SYS_SELECT_H 0
@@ -667,12 +660,13 @@ char MPLAYER_LIBDIR[100];
#define CONFIG_WMV3_VDPAU_DECODER 0
#define CONFIG_WNV1_DECODER 0
#define CONFIG_XAN_WC3_DECODER 0
+#define CONFIG_XAN_WC4_DECODER 0
#define CONFIG_XL_DECODER 0
#define CONFIG_YOP_DECODER 0
#define CONFIG_ZLIB_DECODER 0
#define CONFIG_ZMBV_DECODER 0
#define CONFIG_AAC_DECODER 1
-#define CONFIG_AAC_LATM_DECODER 1
+#define CONFIG_AAC_LATM_DECODER 0
#define CONFIG_AC3_DECODER 1
#define CONFIG_ALAC_DECODER 0
#define CONFIG_ALS_DECODER 0
@@ -694,15 +688,15 @@ char MPLAYER_LIBDIR[100];
#define CONFIG_MACE3_DECODER 0
#define CONFIG_MACE6_DECODER 0
#define CONFIG_MLP_DECODER 0
-#define CONFIG_MP1_DECODER 1
+#define CONFIG_MP1_DECODER 0
#define CONFIG_MP1FLOAT_DECODER 0
#define CONFIG_MP2_DECODER 1
#define CONFIG_MP2FLOAT_DECODER 0
#define CONFIG_MP3_DECODER 1
#define CONFIG_MP3FLOAT_DECODER 0
-#define CONFIG_MP3ADU_DECODER 1
+#define CONFIG_MP3ADU_DECODER 0
#define CONFIG_MP3ADUFLOAT_DECODER 0
-#define CONFIG_MP3ON4_DECODER 1
+#define CONFIG_MP3ON4_DECODER 0
#define CONFIG_MP3ON4FLOAT_DECODER 0
#define CONFIG_MPC7_DECODER 0
#define CONFIG_MPC8_DECODER 0
@@ -908,7 +902,7 @@ char MPLAYER_LIBDIR[100];
#define CONFIG_LIBXAVS_ENCODER 0
#define CONFIG_LIBXVID_ENCODER 0
#define CONFIG_AAC_PARSER 1
-#define CONFIG_AAC_LATM_PARSER 1
+#define CONFIG_AAC_LATM_PARSER 0
#define CONFIG_AC3_PARSER 1
#define CONFIG_CAVSVIDEO_PARSER 0
#define CONFIG_DCA_PARSER 1
diff --git a/mplayer/config.gc.mak b/mplayer/config.gc.mak
index f5d2f40f..626a99a9 100644
--- a/mplayer/config.gc.mak
+++ b/mplayer/config.gc.mak
@@ -32,7 +32,6 @@ CXXFLAGS = -Wundef -Wall -Wno-switch -Wno-parentheses -Wpointer-arith -Wredundan
CC_DEPFLAGS = -MD -MP -O2 -meabi -mogc -mcpu=750 -mtune=750 -mhard-float -mdouble-float -mpaired -pipe -g -ffast-math -fomit-frame-pointer
CFLAGS_DHAHELPER =
-CFLAGS_FAAD_FIXED =
CFLAGS_LIBDVDCSS =
CFLAGS_LIBDVDCSS_DVDREAD =
CFLAGS_LIBDVDNAV =
@@ -106,7 +105,6 @@ ESD = no
FAAC=no
GEKKO = yes
FAAD = no
-FAAD_INTERNAL = no
FASTMEMCPY = yes
FBDEV = no
FREETYPE = yes
@@ -293,9 +291,8 @@ CONFIG_ZLIB = no
HAVE_GNU_AS = no
HAVE_PTHREADS = no
-HAVE_SHM = yes
+HAVE_SHM = no
HAVE_W32THREADS = no
-HAVE_GEKKOTHREADS = yes
HAVE_YASM = no
CONFIG_AASC_DECODER=no
@@ -437,12 +434,13 @@ CONFIG_WMV2_DECODER=no
CONFIG_WMV3_DECODER=yes
CONFIG_WNV1_DECODER=no
CONFIG_XAN_WC3_DECODER=no
+CONFIG_XAN_WC4_DECODER=no
CONFIG_XL_DECODER=no
CONFIG_YOP_DECODER=no
CONFIG_ZLIB_DECODER=no
CONFIG_ZMBV_DECODER=no
CONFIG_AAC_DECODER=yes
-CONFIG_AAC_LATM_DECODER=yes
+CONFIG_AAC_LATM_DECODER=no
CONFIG_AC3_DECODER=yes
CONFIG_ALAC_DECODER=no
CONFIG_ALS_DECODER=no
@@ -464,15 +462,15 @@ CONFIG_IMC_DECODER=no
CONFIG_MACE3_DECODER=no
CONFIG_MACE6_DECODER=no
CONFIG_MLP_DECODER=no
-CONFIG_MP1_DECODER=yes
+CONFIG_MP1_DECODER=no
CONFIG_MP1FLOAT_DECODER=no
CONFIG_MP2_DECODER=yes
CONFIG_MP2FLOAT_DECODER=no
CONFIG_MP3_DECODER=yes
CONFIG_MP3FLOAT_DECODER=no
-CONFIG_MP3ADU_DECODER=yes
+CONFIG_MP3ADU_DECODER=no
CONFIG_MP3ADUFLOAT_DECODER=no
-CONFIG_MP3ON4_DECODER=yes
+CONFIG_MP3ON4_DECODER=no
CONFIG_MP3ON4FLOAT_DECODER=no
CONFIG_MPC7_DECODER=no
CONFIG_MPC8_DECODER=no
@@ -656,7 +654,7 @@ CONFIG_DVBSUB_ENCODER=no
CONFIG_DVDSUB_ENCODER=no
CONFIG_XSUB_ENCODER=no
CONFIG_AAC_PARSER=yes
-CONFIG_AAC_LATM_PARSER=yes
+CONFIG_AAC_LATM_PARSER=no
CONFIG_AC3_PARSER=yes
CONFIG_CAVSVIDEO_PARSER=no
CONFIG_DCA_PARSER=yes
diff --git a/mplayer/config.h b/mplayer/config.h
index 737c1214..dcc2889a 100644
--- a/mplayer/config.h
+++ b/mplayer/config.h
@@ -45,17 +45,11 @@ char MPLAYER_LIBDIR[100];
#define HAVE_ERRNO_H 1
/* libdvdcss + libdvdread */
#define HAVE_LIMITS_H 1
-/* libdvdcss + libfaad2 */
+/* libdvdcss */
#define HAVE_UNISTD_H 1
-/* libfaad2 + libdvdread */
+/* libdvdread */
#define STDC_HEADERS 1
#define HAVE_MEMCPY 1
-/* libfaad2 */
-#define HAVE_STDLIB_H 1
-#define HAVE_STRING_H 1
-#undef HAVE_STRINGS_H
-#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TYPES_H 1
/* libdvdnav */
#define READ_CACHE_TRACE 0
/* libdvdread */
@@ -72,9 +66,9 @@ char MPLAYER_LIBDIR[100];
#undef HAVE_SOUNDCARD_H
#undef HAVE_SYS_ASOUNDLIB_H
-#define HAVE_SYS_SOUNDCARD_H 1
+#undef HAVE_SYS_SOUNDCARD_H
#undef HAVE_SYS_SYSINFO_H
-#define HAVE_TERMIOS_H 1
+#undef HAVE_TERMIOS_H
#undef HAVE_SYS_TERMIOS_H
#define HAVE_WINSOCK2_H 0
@@ -86,25 +80,25 @@ char MPLAYER_LIBDIR[100];
#define HAVE_LANGINFO 1
#define HAVE_MEMALIGN 1
-#undef HAVE_NANOSLEEP
+#define HAVE_NANOSLEEP 1
#undef HAVE_POSIX_SELECT
-#define HAVE_AUDIO_SELECT 1
+#undef HAVE_AUDIO_SELECT
#define HAVE_SETENV 1
#define HAVE_SETMODE 0
-#define HAVE_SHM 1
+#undef HAVE_SHM
#define HAVE_STRSEP 1
#define HAVE_SWAB 1
#undef HAVE_TERMCAP
-#define HAVE_TERMIOS 1
+#undef HAVE_TERMIOS
#define HAVE_VSSCANF 1
/* system-specific features */
#define HAVE_BUILTIN_EXPECT 1
-#define HAVE_LIBDL 1
+#undef HAVE_LIBDL
#define HAVE_DOS_PATHS 0
#define EXTERN_ASM
#define EXTERN_PREFIX ""
@@ -133,7 +127,7 @@ char MPLAYER_LIBDIR[100];
#define CONFIG_SIGHANDLER 1
#define CONFIG_SORTSUB 1
#define CONFIG_STREAM_CACHE 1
-#define PTHREAD_CACHE 1
+#undef PTHREAD_CACHE
/* CPU stuff */
@@ -211,7 +205,6 @@ char MPLAYER_LIBDIR[100];
/* codec libraries */
#undef CONFIG_FAAC
#undef CONFIG_FAAD
-#undef CONFIG_FAAD_INTERNAL
#undef CONFIG_LIBA52
#undef CONFIG_LIBDCA
#undef CONFIG_LIBDV095
@@ -317,7 +310,7 @@ char MPLAYER_LIBDIR[100];
/* networking */
-#define HAVE_CLOSESOCKET 0
+#define HAVE_CLOSESOCKET 1
#define CONFIG_FTP 1
#undef HAVE_AF_INET6
#define HAVE_INET_ATON 1
@@ -329,7 +322,7 @@ char MPLAYER_LIBDIR[100];
#define HAVE_SOCKLEN_T 1
#define HAVE_STRUCT_IPV6_MREQ 0
#define HAVE_STRUCT_SOCKADDR_IN6 0
-#define HAVE_STRUCT_SOCKADDR_SA_LEN 0
+#define HAVE_STRUCT_SOCKADDR_SA_LEN 1
#undef CONFIG_VSTREAM
#define HAVE_STRUCT_ADDRINFO 0
#define HAVE_GETADDRINFO 0
@@ -367,7 +360,7 @@ char MPLAYER_LIBDIR[100];
#undef CONFIG_IVTV
#undef CONFIG_JPEG
-#undef CONFIG_MD5SUM
+#define CONFIG_MD5SUM 1
#undef CONFIG_MGA
#undef CONFIG_MNG
#undef CONFIG_PNG
@@ -381,7 +374,7 @@ char MPLAYER_LIBDIR[100];
#undef CONFIG_XVR100
#undef CONFIG_TGA
#undef CONFIG_V4L2_DECODER
-#undef CONFIG_VDPAU
+#define CONFIG_VDPAU 0
#undef CONFIG_VESA
#undef CONFIG_VIDIX
#undef CONFIG_VIDIX_DRV_CYBERBLADE
@@ -407,7 +400,7 @@ char MPLAYER_LIBDIR[100];
#undef CONFIG_XMGA
#undef CONFIG_XSS
#undef CONFIG_XV
-#undef CONFIG_XVMC
+#define CONFIG_XVMC 0
#undef CONFIG_YUV4MPEG
#undef CONFIG_ZR
@@ -450,11 +443,11 @@ char MPLAYER_LIBDIR[100];
#define CONFIG_NETWORK 1
#define CONFIG_PIC 0
#define HAVE_POSIX_MEMALIGN 0
-#undef HAVE_PTHREADS
+#define HAVE_PTHREADS 0
#define HAVE_ROUND 1
#define HAVE_ROUNDF 1
#define HAVE_TEN_OPERANDS 0
-#define HAVE_THREADS 1
+#define HAVE_THREADS 0
#define HAVE_TRUNCF 1
#define HAVE_XFORM_ASM 1
#define HAVE_XMM_CLOBBERS 0
@@ -478,7 +471,7 @@ char MPLAYER_LIBDIR[100];
#define HAVE_LDBRX 0
#define HAVE_POLL_H 0
#define HAVE_PPC4XX 0
-#define HAVE_STRERROR_R 0
+#define HAVE_STRERROR_R 1
#define HAVE_SYMVER_ASM_LABEL 0
#define HAVE_SYMVER_GNU_ASM 0
#define HAVE_SYS_SELECT_H 0
@@ -667,6 +660,7 @@ char MPLAYER_LIBDIR[100];
#define CONFIG_WMV3_VDPAU_DECODER 0
#define CONFIG_WNV1_DECODER 1
#define CONFIG_XAN_WC3_DECODER 1
+#define CONFIG_XAN_WC4_DECODER 1
#define CONFIG_XL_DECODER 1
#define CONFIG_YOP_DECODER 1
#define CONFIG_ZLIB_DECODER 1
@@ -1041,7 +1035,7 @@ char MPLAYER_LIBDIR[100];
#define CONFIG_RSO_DEMUXER 1
#define CONFIG_RTP_DEMUXER 0
#define CONFIG_RTSP_DEMUXER 0
-#define CONFIG_SAP_DEMUXER 1
+#define CONFIG_SAP_DEMUXER 0
#define CONFIG_SDP_DEMUXER 0
#define CONFIG_SEGAFILM_DEMUXER 1
#define CONFIG_SHORTEN_DEMUXER 1
@@ -1194,19 +1188,19 @@ char MPLAYER_LIBDIR[100];
#define CONFIG_RTP_PROTOCOL 0
#define CONFIG_TCP_PROTOCOL 1
#define CONFIG_UDP_PROTOCOL 0
-#define CONFIG_AAC_ADTSTOASC_BSF 1
-#define CONFIG_CHOMP_BSF 1
-#define CONFIG_DUMP_EXTRADATA_BSF 1
-#define CONFIG_H264_MP4TOANNEXB_BSF 1
-#define CONFIG_IMX_DUMP_HEADER_BSF 1
-#define CONFIG_MJPEG2JPEG_BSF 1
-#define CONFIG_MJPEGA_DUMP_HEADER_BSF 1
-#define CONFIG_MP3_HEADER_COMPRESS_BSF 1
-#define CONFIG_MP3_HEADER_DECOMPRESS_BSF 1
-#define CONFIG_MOV2TEXTSUB_BSF 1
-#define CONFIG_NOISE_BSF 1
-#define CONFIG_REMOVE_EXTRADATA_BSF 1
-#define CONFIG_TEXT2MOVSUB_BSF 1
+#define CONFIG_AAC_ADTSTOASC_BSF 0
+#define CONFIG_CHOMP_BSF 0
+#define CONFIG_DUMP_EXTRADATA_BSF 0
+#define CONFIG_H264_MP4TOANNEXB_BSF 0
+#define CONFIG_IMX_DUMP_HEADER_BSF 0
+#define CONFIG_MJPEG2JPEG_BSF 0
+#define CONFIG_MJPEGA_DUMP_HEADER_BSF 0
+#define CONFIG_MP3_HEADER_COMPRESS_BSF 0
+#define CONFIG_MP3_HEADER_DECOMPRESS_BSF 0
+#define CONFIG_MOV2TEXTSUB_BSF 0
+#define CONFIG_NOISE_BSF 0
+#define CONFIG_REMOVE_EXTRADATA_BSF 0
+#define CONFIG_TEXT2MOVSUB_BSF 0
#define CONFIG_H263_VAAPI_HWACCEL 0
#define CONFIG_H264_DXVA2_HWACCEL 0
#define CONFIG_H264_VAAPI_HWACCEL 0
diff --git a/mplayer/config.mak b/mplayer/config.mak
index 81825390..fbdc1ab0 100644
--- a/mplayer/config.mak
+++ b/mplayer/config.mak
@@ -32,7 +32,6 @@ CXXFLAGS = -Wundef -Wall -Wno-switch -Wno-parentheses -Wpointer-arith -Wredundan
CC_DEPFLAGS = -MD -MP -O3 -meabi -mrvl -mcpu=750 -mtune=750 -mhard-float -mdouble-float -mpaired -pipe -g -ffast-math
CFLAGS_DHAHELPER =
-CFLAGS_FAAD_FIXED =
CFLAGS_LIBDVDCSS =
CFLAGS_LIBDVDCSS_DVDREAD = -Ilibdvdcss
CFLAGS_LIBDVDNAV = -Ilibdvdnav
@@ -106,7 +105,6 @@ ESD = no
FAAC=no
GEKKO = yes
FAAD = no
-FAAD_INTERNAL = no
FASTMEMCPY = yes
FBDEV = no
FREETYPE = yes
@@ -152,7 +150,7 @@ LIBTHEORA = no
LIRC = no
LIVE555 = no
MACOSX_FINDER = no
-MD5SUM = no
+MD5SUM = yes
MGA = no
MNG = no
MP3LAME = no
@@ -293,9 +291,8 @@ CONFIG_ZLIB = yes
HAVE_GNU_AS = no
HAVE_PTHREADS = no
-HAVE_SHM = yes
+HAVE_SHM = no
HAVE_W32THREADS = no
-HAVE_GEKKOTHREADS = yes
HAVE_YASM = no
CONFIG_AASC_DECODER=yes
@@ -437,6 +434,7 @@ CONFIG_WMV2_DECODER=yes
CONFIG_WMV3_DECODER=yes
CONFIG_WNV1_DECODER=yes
CONFIG_XAN_WC3_DECODER=yes
+CONFIG_XAN_WC4_DECODER=yes
CONFIG_XL_DECODER=yes
CONFIG_YOP_DECODER=yes
CONFIG_ZLIB_DECODER=yes
@@ -788,7 +786,7 @@ CONFIG_RPL_DEMUXER=yes
CONFIG_RSO_DEMUXER=yes
CONFIG_RTP_DEMUXER=no
CONFIG_RTSP_DEMUXER=no
-CONFIG_SAP_DEMUXER=yes
+CONFIG_SAP_DEMUXER=no
CONFIG_SDP_DEMUXER=no
CONFIG_SEGAFILM_DEMUXER=yes
CONFIG_SHORTEN_DEMUXER=yes
@@ -937,17 +935,17 @@ CONFIG_RTMPS_PROTOCOL=yes
CONFIG_RTP_PROTOCOL=no
CONFIG_TCP_PROTOCOL=yes
CONFIG_UDP_PROTOCOL=no
-CONFIG_AAC_ADTSTOASC_BSF=yes
-CONFIG_CHOMP_BSF=yes
-CONFIG_DUMP_EXTRADATA_BSF=yes
-CONFIG_H264_MP4TOANNEXB_BSF=yes
-CONFIG_IMX_DUMP_HEADER_BSF=yes
-CONFIG_MJPEG2JPEG_BSF=yes
-CONFIG_MJPEGA_DUMP_HEADER_BSF=yes
-CONFIG_MP3_HEADER_COMPRESS_BSF=yes
-CONFIG_MP3_HEADER_DECOMPRESS_BSF=yes
-CONFIG_MOV2TEXTSUB_BSF=yes
-CONFIG_NOISE_BSF=yes
-CONFIG_REMOVE_EXTRADATA_BSF=yes
-CONFIG_TEXT2MOVSUB_BSF=yes
+CONFIG_AAC_ADTSTOASC_BSF=no
+CONFIG_CHOMP_BSF=no
+CONFIG_DUMP_EXTRADATA_BSF=no
+CONFIG_H264_MP4TOANNEXB_BSF=no
+CONFIG_IMX_DUMP_HEADER_BSF=no
+CONFIG_MJPEG2JPEG_BSF=no
+CONFIG_MJPEGA_DUMP_HEADER_BSF=no
+CONFIG_MP3_HEADER_COMPRESS_BSF=no
+CONFIG_MP3_HEADER_DECOMPRESS_BSF=no
+CONFIG_MOV2TEXTSUB_BSF=no
+CONFIG_NOISE_BSF=no
+CONFIG_REMOVE_EXTRADATA_BSF=no
+CONFIG_TEXT2MOVSUB_BSF=no
CONFIG_=yes
diff --git a/mplayer/configure b/mplayer/configure
index c748276f..670133f1 100644
--- a/mplayer/configure
+++ b/mplayer/configure
@@ -35,6 +35,29 @@
#
#############################################################################
+if test -e ffmpeg/.svn ; then
+ echo "You have an outdated FFmpeg SVN checkout in ffmpeg/, please (re)move or replace it"
+ exit 1
+fi
+
+if test -e ffmpeg/mp_auto_pull ; then
+ if ! (cd ffmpeg && git pull --rebase --ff-only) ; then
+ echo "git pull failed, (re)move ffmpeg/mp_auto_pull to disable pulling"
+ exit 1
+ fi
+fi
+
+if ! test -e ffmpeg ; then
+ echo "No FFmpeg checkout, press enter to download one with git or CTRL+C to abort"
+ read tmp
+ if ! git clone --depth 1 git://git.videolan.org/ffmpeg.git ffmpeg ; then
+ rm -rf ffmpeg
+ echo "Failed to get a FFmpeg checkout"
+ exit 1
+ fi
+ touch ffmpeg/mp_auto_pull
+fi
+
# Prevent locale nonsense from breaking basic text processing utils
export LC_ALL=C
@@ -73,6 +96,24 @@ EOF
compile_check $TMPC $@
}
+header_check() {
+ cat > $TMPC << EOF
+#include <$1>
+int main(void) { return 0; }
+EOF
+ shift
+ compile_check $TMPC $@
+}
+
+return_check() {
+ cat > $TMPC << EOF
+#include <$1>
+int main(void) { return $2; }
+EOF
+ shift 2
+ compile_check $TMPC $@
+}
+
statement_check() {
cat > $TMPC << EOF
#include <$1>
@@ -83,12 +124,22 @@ EOF
compile_check $TMPC $@
}
-header_check() {
+define_statement_check() {
+ cat > $TMPC << EOF
+#define $1
+#include <$2>
+int main(void) { $3; return 0; }
+EOF
+ shift 3
+ compile_check $TMPC $@
+}
+
+return_statement_check() {
cat > $TMPC << EOF
#include <$1>
-int main(void) { return 0; }
+int main(void) { $2; return $3; }
EOF
- shift
+ shift 3
compile_check $TMPC $@
}
@@ -358,9 +409,7 @@ Codecs:
--disable-speex disable Speex support [autodetect]
--disable-libgsm disable libgsm support [autodetect]
--enable-theora enable OggTheora libraries [autodetect]
- --enable-faad enable external FAAD2 (AAC) [autodetect]
- --disable-faad-internal disable internal FAAD2 (AAC) [autodetect]
- --enable-faad-fixed enable fixed-point mode in internal FAAD2 [disabled]
+ --enable-faad enable FAAD2 (AAC) [autodetect]
--disable-faac disable support for FAAC (AAC encoder) [autodetect]
--disable-faac-lavc disable support for FAAC in libavcodec [autodetect]
--disable-ladspa disable LADSPA plugin support [autodetect]
@@ -378,7 +427,7 @@ Codecs:
--disable-liba52 disable liba52 [autodetect]
--disable-libmpeg2 disable libmpeg2 [autodetect]
--disable-libmpeg2-internal disable builtin libmpeg2 [autodetect]
- --disable-musepack disable musepack support [autodetect]
+ --enable-musepack enable libmpcdec support (deprecated in favour of libavcodec) [disabled]
--disable-libopencore_amrnb disable libopencore_amr narrowband [autodetect]
--disable-libopencore_amrwb disable libopencore_amr wideband [autodetect]
--disable-libopenjpeg disable OpenJPEG (JPEG2000) input/output support [autodetect]
@@ -669,8 +718,6 @@ _libdca=auto
_libmpeg2=auto
_libmpeg2_internal=auto
_faad=auto
-_faad_internal=auto
-_faad_fixed=no
_faac=auto
_faac_lavc=auto
_ladspa=auto
@@ -782,7 +829,7 @@ _enca=auto
_inet6=auto
_gethostbyname2=auto
_ftp=auto
-_musepack=auto
+_musepack=no
_vstream=auto
_pthreads=auto
_w32threads=auto
@@ -796,7 +843,7 @@ def_dos_paths="#define HAVE_DOS_PATHS 0"
def_stream_cache="#define CONFIG_STREAM_CACHE 1"
def_priority="#undef CONFIG_PRIORITY"
def_pthread_cache="#undef PTHREAD_CACHE"
-_need_shmem=yes
+need_shmem=yes
for ac_option do
case "$ac_option" in
--help|-help|-h)
@@ -1076,10 +1123,6 @@ for ac_option do
--disable-musepack) _musepack=no ;;
--enable-faad) _faad=yes ;;
--disable-faad) _faad=no ;;
- --enable-faad-internal) _faad_internal=yes ;;
- --disable-faad-internal) _faad_internal=no ;;
- --enable-faad-fixed) _faad_fixed=yes ;;
- --disable-faad-fixed) _faad_fixed=no ;;
--enable-faac) _faac=yes ;;
--disable-faac) _faac=no ;;
--enable-faac-lavc) _faac_lavc=yes ;;
@@ -1519,15 +1562,9 @@ if win32 ; then
def_priority="#define CONFIG_PRIORITY 1"
fi
-if cygwin ; then
- # e.g. priority.c needs _WIN32 define, but
- # latest cygwin no longer defines it
- extra_cflags="-D_WIN32 $extra_cflags"
-fi
-
if mingw32 ; then
_getch=getch2-win.c
- _need_shmem=no
+ need_shmem=no
fi
if amigaos ; then
@@ -1545,7 +1582,7 @@ fi
if os2 ; then
_exesuf=".exe"
_getch=getch2-os2.c
- _need_shmem=no
+ need_shmem=no
_priority=yes
def_dos_paths="#define HAVE_DOS_PATHS 1"
def_priority="#define CONFIG_PRIORITY 1"
@@ -2518,8 +2555,8 @@ __attribute__((noinline)) static int foo3(int i1, int i2, int i3) { return i3; }
int main(void) { return foo3(1, 2, 3) == 3 ? 0 : 1; }
EOF
cc_check -O4 -mstackrealign && tmp_run && cflags_stackrealign=-mstackrealign
- test -z "$cflags_stackrealign" && cc_check -O4 -mstackrealign -fno-unit-at-a-time \
- && tmp_run && cflags_stackrealign="-mstackrealign -fno-unit-at-a-time"
+ test -z "$cflags_stackrealign" && cc_check -O4 -mstackrealign -fno-unit-at-a-time &&
+ tmp_run && cflags_stackrealign="-mstackrealign -fno-unit-at-a-time"
test -n "$cflags_stackrealign" && echores "yes" || echores "no"
fi # if darwin && test "$cc_vendor" = "gnu" ; then
@@ -2562,7 +2599,7 @@ else
fi
cflag_check -mno-omit-leaf-frame-pointer && cflags_no_omit_leaf_frame_pointer="-mno-omit-leaf-frame-pointer"
-cflag_check -MD -MP && DEPFLAGS="-MD -MP $CFLAGS"
+cflag_check -MD -MP && DEPFLAGS="-MD -MP"
if test -n "$LDFLAGS" ; then
@@ -2856,7 +2893,7 @@ if arm ; then
_armv6t2=no
inline_asm_check '"movt r0, #0"' && _armv6t2=yes
fi
- echores "$_armv6"
+ echores "$_armv6t2"
echocheck "ARM VFP"
if test $_armvfp = "auto" ; then
@@ -3096,13 +3133,8 @@ done
echocheck "mkstemp"
-cat > $TMPC << EOF
-#define _XOPEN_SOURCE 500
-#include
-int main(void) { mkstemp(""); return 0; }
-EOF
_mkstemp=no
-cc_check && _mkstemp=yes
+define_statement_check "_XOPEN_SOURCE 600" "stdlib.h" 'mkstemp("")' && _mkstemp=yes
if test "$_mkstemp" = yes ; then
def_mkstemp='#define HAVE_MKSTEMP 1'
else
@@ -3257,7 +3289,7 @@ cat > $TMPC << EOF
#endif
int main(void) { const void *p = &((struct sockaddr *)0)->sa_len; return 0; }
EOF
-cc_check $cc_check_winsock2_h && _struct_sockaddr_sa_len=yes && \
+cc_check $cc_check_winsock2_h && _struct_sockaddr_sa_len=yes &&
def_struct_sockaddr_sa_len="#define HAVE_STRUCT_SOCKADDR_SA_LEN 1"
echores "$_struct_sockaddr_sa_len"
@@ -3344,7 +3376,7 @@ echocheck "inet6"
if test "$_inet6" = auto ; then
cat > $TMPC << EOF
#include
-#if !defined(_WIN32) || defined(__CYGWIN__)
+#if !defined(_WIN32)
#include
#include
#else
@@ -3386,6 +3418,14 @@ fi
echores "$_gethostbyname2"
+echocheck "sys/poll.h"
+poll_h=no
+def_poll_h='#define HAVE_POLL_H 0'
+header_check sys/poll.h && poll_h=yes &&
+ def_poll_h='#define HAVE_POLL_H 1'
+echores "$poll_h"
+
+
echocheck "inttypes.h (required)"
_inttypes=no
header_check inttypes.h && _inttypes=yes
@@ -3403,12 +3443,8 @@ fi
echocheck "int_fastXY_t in inttypes.h"
-cat > $TMPC << EOF
-#include
-int main(void) { volatile int_fast16_t v = 0; return v; }
-EOF
_fast_inttypes=no
-cc_check && _fast_inttypes=yes
+statement_check "inttypes.h" 'volatile int_fast16_t v = 0' && _fast_inttypes=yes
if test "$_fast_inttypes" = no ; then
def_fast_inttypes='
typedef signed char int_fast8_t;
@@ -3452,12 +3488,8 @@ echores "$_memalign"
echocheck "posix_memalign()"
posix_memalign=no
def_posix_memalign='#define HAVE_POSIX_MEMALIGN 0'
-cat > $TMPC << EOF
-#define _XOPEN_SOURCE 600
-#include
-int main(void) { posix_memalign(NULL, 0, 0); }
-EOF
-cc_check && posix_memalign=yes && def_posix_memalign='#define HAVE_POSIX_MEMALIGN 1'
+define_statement_check "_XOPEN_SOURCE 600" "stdlib.h" 'posix_memalign(NULL, 0, 0)' &&
+ posix_memalign=yes && def_posix_memalign='#define HAVE_POSIX_MEMALIGN 1'
echores "$posix_memalign"
@@ -3495,10 +3527,12 @@ echocheck "mman.h"
_mman=no
statement_check sys/mman.h 'mmap(0, 0, 0, 0, 0, 0)' && _mman=yes
if test "$_mman" = yes ; then
+ def_mmap='#define HAVE_MMAP 1'
def_mman_h='#define HAVE_SYS_MMAN_H 1'
else
+ def_mmap='#define HAVE_MMAP 0'
def_mman_h='#undef HAVE_SYS_MMAN_H'
- os2 && _need_mmap=yes
+ os2 && need_mmap=yes
fi
echores "$_mman"
@@ -3564,7 +3598,7 @@ if test "$_pthreads" = yes ; then
extra_cflags="$extra_cflags $THREAD_CFLAGS"
else
res_comment="v4l, v4l2, ao_nas, win32 loader disabled"
- def_pthreads='#undef HAVE_PTHREADS'
+ def_pthreads='#define HAVE_PTHREADS 0'
_nas=no ; _tv_v4l1=no ; _tv_v4l2=no
mingw32 || _win32dll=no
fi
@@ -3636,7 +3670,7 @@ int main(void) {
EOF
_iconv=no
for _ld_tmp in "" "-liconv" "-liconv $_ld_dl" ; do
- cc_check $_ld_lm $_ld_tmp && extra_ldflags="$extra_ldflags $_ld_tmp" && \
+ cc_check $_ld_lm $_ld_tmp && extra_ldflags="$extra_ldflags $_ld_tmp" &&
_iconv=yes && break
done
fi
@@ -3797,12 +3831,8 @@ echores "$_termios"
echocheck "shm"
if test "$_shm" = auto ; then
- cat > $TMPC << EOF
-#include
-int main(void) { shmget(0, 0, 0); shmat(0, 0, 0); shmctl(0, 0, 0); return 0; }
-EOF
_shm=no
- cc_check && _shm=yes
+ statement_check sys/shm.h 'shmget(0, 0, 0); shmat(0, 0, 0); shmctl(0, 0, 0)' && _shm=yes
fi
if test "$_shm" = yes ; then
def_shm='#define HAVE_SHM 1'
@@ -3813,18 +3843,14 @@ echores "$_shm"
echocheck "strsep()"
-cat > $TMPC << EOF
-#include
-int main(void) { char *s = "Hello, world!"; strsep(&s, ","); return 0; }
-EOF
_strsep=no
-cc_check && _strsep=yes
+statement_check string.h 'char *s = "Hello, world!"; strsep(&s, ",")' && _strsep=yes
if test "$_strsep" = yes ; then
def_strsep='#define HAVE_STRSEP 1'
- _need_strsep=no
+ need_strsep=no
else
def_strsep='#undef HAVE_STRSEP'
- _need_strsep=yes
+ need_strsep=yes
fi
echores "$_strsep"
@@ -3834,34 +3860,29 @@ cat > $TMPC << EOF
#define _ISOC99_SOURCE
#include
#include
-int main(void) { va_list ap = NULL; vsscanf("foo", "bar", ap); return 0; }
+int main(void) { va_list ap = { 0 }; vsscanf("foo", "bar", ap); return 0; }
EOF
_vsscanf=no
cc_check && _vsscanf=yes
if test "$_vsscanf" = yes ; then
def_vsscanf='#define HAVE_VSSCANF 1'
- _need_vsscanf=no
+ need_vsscanf=no
else
def_vsscanf='#undef HAVE_VSSCANF'
- _need_vsscanf=yes
+ need_vsscanf=yes
fi
echores "$_vsscanf"
echocheck "swab()"
-cat > $TMPC << EOF
-#define _XOPEN_SOURCE 600
-#include
-int main(void) { int a, b; swab(&a, &b, 0); return 0; }
-EOF
_swab=no
-cc_check && _swab=yes
+define_statement_check "_XOPEN_SOURCE 600" "unistd.h" 'int a, b; swab(&a, &b, 0)' && _swab=yes
if test "$_swab" = yes ; then
def_swab='#define HAVE_SWAB 1'
- _need_swab=no
+ need_swab=no
else
def_swab='#undef HAVE_SWAB'
- _need_swab=yes
+ need_swab=yes
fi
echores "$_swab"
@@ -3878,8 +3899,8 @@ EOF
_posix_select=no
def_posix_select='#undef HAVE_POSIX_SELECT'
#select() of kLIBC (OS/2) supports socket only
-! os2 && cc_check && _posix_select=yes \
- && def_posix_select='#define HAVE_POSIX_SELECT 1'
+! os2 && cc_check && _posix_select=yes &&
+ def_posix_select='#define HAVE_POSIX_SELECT 1'
echores "$_posix_select"
@@ -3893,18 +3914,14 @@ echores "$_select"
echocheck "gettimeofday()"
-cat > $TMPC << EOF
-#include
-int main(void) {struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); return 0; }
-EOF
_gettimeofday=no
-cc_check && _gettimeofday=yes
+statement_check sys/time.h 'struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz)' && _gettimeofday=yes
if test "$_gettimeofday" = yes ; then
def_gettimeofday='#define HAVE_GETTIMEOFDAY 1'
- _need_gettimeofday=no
+ need_gettimeofday=no
else
def_gettimeofday='#undef HAVE_GETTIMEOFDAY'
- _need_gettimeofday=yes
+ need_gettimeofday=yes
fi
echores "$_gettimeofday"
@@ -3914,10 +3931,10 @@ _glob=no
statement_check glob.h 'glob("filename", 0, 0, 0)' && _glob=yes
if test "$_glob" = yes ; then
def_glob='#define HAVE_GLOB 1'
- _need_glob=no
+ need_glob=no
else
def_glob='#undef HAVE_GLOB'
- _need_glob=yes
+ need_glob=yes
fi
echores "$_glob"
@@ -3927,10 +3944,10 @@ _setenv=no
statement_check stdlib.h 'setenv("", "", 0)' && _setenv=yes
if test "$_setenv" = yes ; then
def_setenv='#define HAVE_SETENV 1'
- _need_setenv=no
+ need_setenv=no
else
def_setenv='#undef HAVE_SETENV'
- _need_setenv=yes
+ need_setenv=yes
fi
echores "$_setenv"
@@ -3948,11 +3965,7 @@ _sysi86=no
statement_check sys/sysi86.h 'sysi86(0)' && _sysi86=yes
if test "$_sysi86" = yes ; then
def_sysi86='#define HAVE_SYSI86 1'
- cat > $TMPC << EOF
-#include
-int main(void) { int sysi86(int, void*); sysi86(0); return 0; }
-EOF
- cc_check && def_sysi86_iv='#define HAVE_SYSI86_iv 1'
+ statement_check sys/sysi86.h 'int sysi86(int, void*); sysi86(0)' && def_sysi86_iv='#define HAVE_SYSI86_iv 1'
else
def_sysi86='#undef HAVE_SYSI86'
fi
@@ -3961,12 +3974,8 @@ fi #if sunos
echocheck "sys/sysinfo.h"
-cat > $TMPC << EOF
-#include
-int main(void) { struct sysinfo s_info; sysinfo(&s_info); return 0; }
-EOF
_sys_sysinfo=no
-cc_check && _sys_sysinfo=yes
+statement_check sys/sysinfo.h 'struct sysinfo s_info; sysinfo(&s_info)' && _sys_sysinfo=yes
if test "$_sys_sysinfo" = yes ; then
def_sys_sysinfo_h='#define HAVE_SYS_SYSINFO_H 1'
else
@@ -4038,11 +4047,7 @@ if linux; then
echocheck "Apple IR"
if test "$_apple_ir" = auto ; then
_apple_ir=no
- cat > $TMPC <
-int main(void) { struct input_event ev; struct input_id id; return 0; }
-EOF
- cc_check && _apple_ir=yes
+ statement_check linux/input.h 'struct input_event ev; struct input_id id' && _apple_ir=yes
fi
if test "$_apple_ir" = yes ; then
def_apple_ir='#define CONFIG_APPLE_IR 1'
@@ -4297,13 +4302,8 @@ echores "$_x11"
echocheck "Xss screensaver extensions"
if test "$_xss" = auto ; then
- cat > $TMPC << EOF
-#include
-#include
-int main(void) { XScreenSaverSuspend(NULL, True); return 0; }
-EOF
_xss=no
- cc_check -lXss && _xss=yes
+ statement_check "X11/extensions/scrnsaver.h" 'XScreenSaverSuspend(NULL, True)' -lXss && _xss=yes
fi
if test "$_xss" = yes ; then
def_xss='#define CONFIG_XSS 1'
@@ -4393,13 +4393,7 @@ echocheck "VDPAU"
if test "$_vdpau" = auto ; then
_vdpau=no
if test "$_dl" = yes ; then
- cat > $TMPC <
-int main(void) {
- vdp_device_create_x11(0, 0, 0, 0);
- return VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1; }
-EOF
- cc_check -lvdpau && _vdpau=yes
+ return_statement_check vdpau/vdpau_x11.h 'vdp_device_create_x11(0, 0, 0, 0)' VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 -lvdpau && _vdpau=yes
fi
fi
if test "$_vdpau" = yes ; then
@@ -4454,11 +4448,7 @@ echores "$_vm"
echocheck "XF86keysym"
if test "$_xf86keysym" = auto; then
_xf86keysym=no
- cat > $TMPC <
-int main(void) { return XF86XK_AudioPause; }
-EOF
- cc_check && _xf86keysym=yes
+ return_check X11/XF86keysym.h XF86XK_AudioPause && _xf86keysym=yes
fi
if test "$_xf86keysym" = yes ; then
def_xf86keysym='#define CONFIG_XF86XK 1'
@@ -4558,8 +4548,8 @@ def_vidix_drv_unichrome='#undef CONFIG_VIDIX_DRV_UNICHROME'
_vidix_drv_unichrome=no
if test "$_vidix" = auto ; then
_vidix=no
- x86 && (linux || freebsd || netbsd || openbsd || dragonfly || sunos || win32) \
- && _vidix=yes
+ x86 && (linux || freebsd || netbsd || openbsd || dragonfly || sunos || win32) && _vidix=yes
+ win32 && ! header_check ddk/ntddk.h && _vidix=no
x86_64 && ! linux && _vidix=no
(ppc || alpha) && linux && _vidix=yes
fi
@@ -4754,7 +4744,7 @@ cat >$TMPC << EOF
int main(void) {return 0;}
EOF
for _inc_tmp in "" "-I/usr/src/DVB/include" ; do
- cc_check $_inc_tmp && _dvb=yes && \
+ cc_check $_inc_tmp && _dvb=yes &&
extra_cflags="$extra_cflags $_inc_tmp" && break
done
fi
@@ -4780,17 +4770,8 @@ if darwin; then
echocheck "QuickTime"
if test "$quicktime" = auto ; then
- cat > $TMPC <
-int main(void) {
- ImageDescription *desc;
- EnterMovies();
- ExitMovies();
- return 0;
-}
-EOF
quicktime=no
- cc_check -framework QuickTime && quicktime=yes
+ statement_check QuickTime/QuickTime.h 'ImageDescription *desc; EnterMovies(); ExitMovies()' -framework QuickTime && quicktime=yes
fi
if test "$quicktime" = yes ; then
extra_ldflags="$extra_ldflags -framework QuickTime"
@@ -4873,16 +4854,7 @@ fi
echocheck "MNG support"
if test "$_mng" = auto ; then
_mng=no
- cat > $TMPC << EOF
-#include
-int main(void) {
- const char * p_ver = mng_version_text();
- return !p_ver || p_ver[0] == 0;
-}
-EOF
- if cc_check -lmng -lz $_ld_lm ; then
- _mng=yes
- fi
+ return_statement_check libmng.h 'const char * p_ver = mng_version_text()' '!p_ver || p_ver[0] == 0' -lmng -lz $_ld_lm && _mng=yes
fi
echores "$_mng"
if test "$_mng" = yes ; then
@@ -4912,12 +4884,7 @@ fi
echocheck "OpenJPEG (JPEG2000) support"
if test "$libopenjpeg" = auto ; then
libopenjpeg=no
-cat > $TMPC << EOF
-#define OPJ_STATIC
-#include
-int main(void) { opj_dparameters_t dec_params; opj_set_default_decoder_parameters(&dec_params); return 0; }
-EOF
- cc_check -lopenjpeg $_ld_lm && libopenjpeg=yes
+ define_statement_check OPJ_STATIC openjpeg.h 'opj_dparameters_t dec_params; opj_set_default_decoder_parameters(&dec_params)' -lopenjpeg $_ld_lm && libopenjpeg=yes
fi
echores "$libopenjpeg"
if test "$libopenjpeg" = yes ; then
@@ -5342,6 +5309,7 @@ echores "$_dxr3"
echocheck "IVTV TV-Out (pre linux-2.6.24)"
if test "$_ivtv" = auto ; then
cat > $TMPC << EOF
+#include
#include
#include
#include
@@ -5370,6 +5338,7 @@ echores "$_ivtv"
echocheck "V4L2 MPEG Decoder"
if test "$_v4l2" = auto ; then
cat > $TMPC << EOF
+#include
#include
#include
int main(void) {
@@ -5404,12 +5373,8 @@ echores "$_v4l2"
echocheck "OSS Audio"
if test "$_ossaudio" = auto ; then
- cat > $TMPC << EOF
-#include <$_soundcard_header>
-int main(void) { return SNDCTL_DSP_SETFRAGMENT; }
-EOF
_ossaudio=no
- cc_check && _ossaudio=yes
+ return_check $_soundcard_header SNDCTL_DSP_SETFRAGMENT && _ossaudio=yes
fi
if test "$_ossaudio" = yes ; then
def_ossaudio='#define CONFIG_OSS_AUDIO 1'
@@ -5856,10 +5821,10 @@ echocheck "dvdread"
if test "$_dvdread_internal" = auto ; then
_dvdread_internal=no
_dvdread=no
- if (linux || freebsd || netbsd || openbsd || dragonfly || sunos || hpux) \
- && (test "$_dvd" = yes || test "$_cdrom" = yes || test "$_cdio" = yes || \
- test "$_dvdio" = yes || test "$_bsdi_dvd" = yes) \
- || darwin || win32 || os2; then
+ if (linux || freebsd || netbsd || openbsd || dragonfly || sunos || hpux) &&
+ (test "$_dvd" = yes || test "$_cdrom" = yes || test "$_cdio" = yes ||
+ test "$_dvdio" = yes || test "$_bsdi_dvd" = yes) ||
+ darwin || win32 || os2; then
_dvdread_internal=yes
_dvdread=yes
extra_cflags="-Ilibdvdread4 $extra_cflags"
@@ -5938,7 +5903,7 @@ int main(void) { void *test = cdda_verbose_set; return test == (void *)1; }
EOF
_cdparanoia=no
for _inc_tmp in "" "-I/usr/include/cdda" "-I/usr/local/include/cdda" ; do
- cc_check $_inc_tmp -lcdda_interface -lcdda_paranoia $_ld_lm && \
+ cc_check $_inc_tmp -lcdda_interface -lcdda_paranoia $_ld_lm &&
_cdparanoia=yes && extra_cflags="$extra_cflags $_inc_tmp" && break
done
fi
@@ -5966,14 +5931,14 @@ EOF
_libcdio=no
for _ld_tmp in "" "-lwinmm" ; do
_ld_tmp="-lcdio_cdda -lcdio -lcdio_paranoia $_ld_tmp"
- cc_check $_ld_tmp $_ld_lm \
- && _libcdio=yes && extra_ldflags="$extra_ldflags $_ld_tmp" && break
+ cc_check $_ld_tmp $_ld_lm && _libcdio=yes &&
+ extra_ldflags="$extra_ldflags $_ld_tmp" && break
done
if test "$_libcdio" = no && $_pkg_config --exists libcdio_paranoia ; then
_inc_tmp=$($_pkg_config --cflags libcdio_paranoia)
_ld_tmp=$($_pkg_config --libs libcdio_paranoia)
- cc_check $_inc_tmp $_ld_tmp $_ld_lm && _libcdio=yes \
- && extra_ldflags="$extra_ldflags $_ld_tmp" && extra_cflags="$extra_cflags $_inc_tmp"
+ cc_check $_inc_tmp $_ld_tmp $_ld_lm && _libcdio=yes &&
+ extra_ldflags="$extra_ldflags $_ld_tmp" && extra_cflags="$extra_cflags $_inc_tmp"
fi
fi
if test "$_libcdio" = yes && test "$_cdparanoia" = no ; then
@@ -6084,8 +6049,8 @@ EOF
if test "$_fontconfig" = no && $_pkg_config --exists fontconfig ; then
_inc_tmp=$($_pkg_config --cflags fontconfig)
_ld_tmp=$($_pkg_config --libs fontconfig)
- cc_check $_inc_tmp $_ld_tmp && _fontconfig=yes \
- && extra_ldflags="$extra_ldflags $_ld_tmp" && extra_cflags="$extra_cflags $_inc_tmp"
+ cc_check $_inc_tmp $_ld_tmp && _fontconfig=yes &&
+ extra_ldflags="$extra_ldflags $_ld_tmp" && extra_cflags="$extra_cflags $_inc_tmp"
fi
fi
if test "$_fontconfig" = yes ; then
@@ -6330,7 +6295,9 @@ elif test "$_tremor" = auto; then
fi
if test "$_libvorbis" = auto; then
_libvorbis=no
- statement_check vorbis/codec.h 'vorbis_packet_blocksize(0, 0)' -lvorbis -logg $_ld_lm && _libvorbis=yes
+ for vorbislibs in '-lvorbis -logg' '-lvorbis -lvorbisenc -logg' ; do
+ statement_check vorbis/vorbisenc.h 'vorbis_encode_ctl(0, 0, 0)' $vorbislibs $_ld_lm && _libvorbis=yes && break
+ done
fi
if test "$_tremor_internal" = yes ; then
_vorbis=yes
@@ -6354,7 +6321,7 @@ elif test "$_libvorbis" = yes ; then
def_vorbis='#define CONFIG_OGGVORBIS 1'
codecmodules="libvorbis $codecmodules"
res_comment="libvorbis"
- extra_ldflags="$extra_ldflags -lvorbis -logg"
+ extra_ldflags="$extra_ldflags $vorbislibs"
libavencoders="$libavencoders LIBVORBIS_ENCODER"
else
_vorbis=no
@@ -6569,7 +6536,7 @@ fi
echores "$_libdca"
echocheck "libmpcdec (musepack, version >= 1.2.1 required)"
-if test "$_musepack" = auto ; then
+if test "$_musepack" = yes ; then
_musepack=no
cat > $TMPC << EOF
#include
@@ -6627,27 +6594,8 @@ echores "$_faac"
echocheck "FAAD2 support"
-if test "$_faad_internal" = auto ; then
- if cygwin ; then
- _faad_internal=no
- res_comment="does not compile on cygwin"
- elif x86_32 && test cc_vendor=gnu; then
- case $cc_version in
- 3.1*|3.2) # ICE/insn with these versions
- _faad_internal=no
- res_comment="broken gcc"
- ;;
- *)
- _faad=yes
- _faad_internal=yes
- ;;
- esac
- else
- _faad=yes
- _faad_internal=yes
- fi
-fi
if test "$_faad" = auto ; then
+ _faad=no
cat > $TMPC << EOF
#include
#ifndef FAAD_MIN_STREAMSIZE
@@ -6660,29 +6608,11 @@ EOF
fi
def_faad='#undef CONFIG_FAAD'
-def_faad_internal="#undef CONFIG_FAAD_INTERNAL"
-if test "$_faad_internal" = yes ; then
- def_faad_internal="#define CONFIG_FAAD_INTERNAL 1"
- res_comment="internal floating-point"
- if test "$_faad_fixed" = yes ; then
- # The FIXED_POINT implementation of FAAD2 improves performance
- # on some platforms, especially for SBR files.
- cflags_faad_fixed="-DFIXED_POINT"
- res_comment="internal fixed-point"
- fi
-elif test "$_faad" = yes ; then
- extra_ldflags="$extra_ldflags -lfaad"
-fi
-
if test "$_faad" = yes ; then
def_faad='#define CONFIG_FAAD 1'
- if test "$_faad_internal" = yes ; then
- codecmodules="faad2(internal) $codecmodules"
- else
- codecmodules="faad2 $codecmodules"
- fi
+ extra_ldflags="$extra_ldflags -lfaad"
+ codecmodules="faad2 $codecmodules"
else
- _faad=no
nocodecmodules="faad2 $nocodecmodules"
fi
echores "$_faad"
@@ -6866,8 +6796,8 @@ EOF
_live=no
for I in $extra_cflags "-I$_libdir/live" "-I/usr/lib/live" "-I/usr/lib64/live" "-I/usr/local/live" "-I/usr/local/lib/live" ; do
- cxx_check $I/liveMedia/include $I/UsageEnvironment/include \
- $I/groupsock/include && _livelibdir=$(echo $I| sed s/-I//) && \
+ cxx_check $I/liveMedia/include $I/UsageEnvironment/include $I/groupsock/include &&
+ _livelibdir=$(echo $I| sed s/-I//) &&
extra_ldflags="$_livelibdir/liveMedia/libliveMedia.a \
$_livelibdir/groupsock/libgroupsock.a \
$_livelibdir/UsageEnvironment/libUsageEnvironment.a \
@@ -6876,7 +6806,7 @@ EOF
extra_cxxflags="-I$_livelibdir/liveMedia/include \
-I$_livelibdir/UsageEnvironment/include \
-I$_livelibdir/BasicUsageEnvironment/include \
- -I$_livelibdir/groupsock/include" && \
+ -I$_livelibdir/groupsock/include" &&
_live=yes && break
done
if test "$_live" != yes ; then
@@ -6895,8 +6825,7 @@ elif test "$_live_dist" = yes && test "$networking" = yes; then
_live="yes"
def_live='#define CONFIG_LIVE555 1'
extra_ldflags="$extra_ldflags $ld_tmp"
- extra_cxxflags="-I/usr/include/liveMedia -I/usr/include/UsageEnvironment \
- -I/usr/include/BasicUsageEnvironment -I/usr/include/groupsock"
+ extra_cxxflags="-I/usr/include/liveMedia -I/usr/include/UsageEnvironment -I/usr/include/BasicUsageEnvironment -I/usr/include/groupsock"
inputmodules="live555 $inputmodules"
else
_live=no
@@ -6912,8 +6841,8 @@ if test "$_librtmp" = auto && test "$networking" = yes ; then
if test "$_librtmp" != yes && $_pkg_config --exists librtmp ; then
_inc_tmp=$($_pkg_config --cflags librtmp)
_ld_tmp=$($_pkg_config --libs librtmp)
- cc_check $_inc_tmp $_ld_tmp && _librtmp=yes && \
- extra_ldflags="$extra_ldflags $_ld_tmp" && \
+ cc_check $_inc_tmp $_ld_tmp && _librtmp=yes &&
+ extra_ldflags="$extra_ldflags $_ld_tmp" &&
extra_cflags="$extra_cflags $_inc_tmp"
fi
fi
@@ -6935,16 +6864,16 @@ test -d ffmpeg/libavutil ||
die "MPlayer will not compile without libavutil in the source tree."
ffmpeg=no
if test "$ffmpeg_a" = auto ; then
- test -d ffmpeg/libavcore && ffmpeg_a=yes && ffmpeg=yes
+ test -d ffmpeg/libavutil && ffmpeg_a=yes && ffmpeg=yes && extra_cflags="$extra_cflags -DFF_API_MAX_STREAMS=0"
elif test "$ffmpeg_so" = auto ; then
ffmpeg_so=no
- if $_pkg_config --exists libavcore ; then
- inc_ffmpeg=$($_pkg_config --cflags libpostproc libswscale libavformat libavcodec libavutil libavcore)
- _ld_tmp=$($_pkg_config --libs libpostproc libswscale libavformat libavcodec libavutil libavcore)
- header_check libavcore/avcore.h $inc_ffmpeg $_ld_tmp &&
+ if $_pkg_config --exists libavutil ; then
+ inc_ffmpeg=$($_pkg_config --cflags libpostproc libswscale libavformat libavcodec libavutil)
+ _ld_tmp=$($_pkg_config --libs libpostproc libswscale libavformat libavcodec libavutil)
+ header_check libavutil/avutil.h $inc_ffmpeg $_ld_tmp &&
extra_ldflags="$extra_ldflags $_ld_tmp" && ffmpeg_so=yes && ffmpeg=yes
- elif header_check libavcore/avcore.h -lpostproc -lswscale -lavformat -lavcodec -lavutil -lavcore $_ld_lm ; then
- extra_ldflags="$extra_ldflags -lpostproc -lswscale -lavformat -lavcodec -lavutil -lavcore"
+ elif header_check libavutil/avutil.h -lpostproc -lswscale -lavformat -lavcodec -lavutil $_ld_lm ; then
+ extra_ldflags="$extra_ldflags -lpostproc -lswscale -lavformat -lavcodec -lavutil"
ffmpeg_so=yes
ffmpeg=yes
fi
@@ -6966,9 +6895,9 @@ else
def_ffmpeg_so='#undef CONFIG_FFMPEG_SO'
nocodecmodules="ffmpeg $nocodecmodules"
fi
-test "$_libavcodec_mpegaudio_hp" = yes \
- && def_libavcodec_mpegaudio_hp='#define CONFIG_MPEGAUDIO_HP 1' \
- && mak_libavcodec_mpegaudio_hp='CONFIG_MPEGAUDIO_HP = yes'
+test "$_libavcodec_mpegaudio_hp" = yes &&
+ def_libavcodec_mpegaudio_hp='#define CONFIG_MPEGAUDIO_HP 1' &&
+ mak_libavcodec_mpegaudio_hp='CONFIG_MPEGAUDIO_HP = yes'
echores "$ffmpeg"
@@ -7053,11 +6982,7 @@ echores "$_xvid"
echocheck "Xvid two pass plugin"
if test "$_mencoder" = yes && test "$_xvid" = yes && test "$_xvid_lavc" = auto ; then
- cat > $TMPC << EOF
-#include
-int main(void) { xvid_plugin_2pass2_t s; s.vbv_size=0; return 0; }
-EOF
- cc_check && _xvid_lavc=yes
+ statement_check xvid.h 'xvid_plugin_2pass2_t s; s.vbv_size = 0' && _xvid_lavc=yes
fi
if test "$_xvid_lavc" = yes ; then
def_xvid_lavc='#define CONFIG_LIBXVID 1'
@@ -7211,13 +7136,8 @@ echores "$_libvpx_lavc"
echocheck "libnut"
if test "$_libnut" = auto ; then
- cat > $TMPC << EOF
-#include
-nut_context_tt * nut;
-int main(void) { nut_error(0); return 0; }
-EOF
_libnut=no
- cc_check -lnut && _libnut=yes
+ statement_check libnut.h 'nut_context_tt * nut; nut_error(0)' -lnut && _libnut=yes
fi
if test "$_libnut" = yes ; then
@@ -7351,23 +7271,13 @@ EOF
echocheck "*BSD ioctl_meteor.h"
_ioctl_meteor_h=no
- for file in "machine/ioctl_meteor.h" \
- "dev/bktr/ioctl_meteor.h" \
- "dev/video/bktr/ioctl_meteor.h" ; do
- cat > $TMPC <
-#include <$file>
-int main(void) { ioctl(0, METEORSINPUT, 0); return 0; }
-EOF
- if cc_check ; then
- _ioctl_meteor_h=yes
- _ioctl_meteor_h_name="$file"
- break;
- fi
+ for ioctl_meteor_h_path in "machine/ioctl_meteor.h" "dev/bktr/ioctl_meteor.h" "dev/video/bktr/ioctl_meteor.h" ; do
+ statement_check_broken "sys/types.h" "$ioctl_meteor_h_path" 'ioctl(0, METEORSINPUT, 0)' &&
+ _ioctl_meteor_h=yes && break
done
if test "$_ioctl_meteor_h" = yes ; then
- def_ioctl_meteor_h_name="#define IOCTL_METEOR_H_NAME <$_ioctl_meteor_h_name>"
- res_comment="using $_ioctl_meteor_h_name"
+ def_ioctl_meteor_h_name="#define IOCTL_METEOR_H_NAME <$ioctl_meteor_h_path>"
+ res_comment="using $ioctl_meteor_h_path"
else
def_ioctl_meteor_h_name="#undef IOCTL_METEOR_H_NAME"
fi
@@ -7411,15 +7321,7 @@ echocheck "DirectShow TV interface"
if test "$_tv_dshow" = auto ; then
_tv_dshow=no
if test "$_tv" = yes && win32 ; then
- cat > $TMPC <
-int main(void) {
- void* p;
- CoCreateInstance((GUID*)&GUID_NULL, NULL, CLSCTX_INPROC_SERVER, &GUID_NULL, &p);
- return 0;
-}
-EOF
- cc_check -lole32 -luuid && _tv_dshow=yes
+ statement_check ole2.h 'void* p; CoCreateInstance((GUID*)&GUID_NULL, NULL, CLSCTX_INPROC_SERVER, &GUID_NULL, &p)' -lole32 -luuid && _tv_dshow=yes
fi
fi
if test "$_tv_dshow" = yes ; then
@@ -7437,7 +7339,7 @@ echocheck "Video 4 Linux TV interface"
if test "$_tv_v4l1" = auto ; then
_tv_v4l1=no
if test "$_tv" = yes && linux ; then
- header_check linux/videodev.h && _tv_v4l1=yes
+ header_check_broken sys/time.h linux/videodev.h && _tv_v4l1=yes
fi
fi
if test "$_tv_v4l1" = yes ; then
@@ -7457,7 +7359,7 @@ echocheck "Video 4 Linux 2 TV interface"
if test "$_tv_v4l2" = auto ; then
_tv_v4l2=no
if test "$_tv" = yes && linux ; then
- header_check linux/videodev2.h && _tv_v4l2=yes
+ header_check_broken sys/time.h linux/videodev2.h && _tv_v4l2=yes
fi
fi
if test "$_tv_v4l2" = yes ; then
@@ -7524,8 +7426,8 @@ else
fi
echores "$_radio_v4l"
-if freebsd || netbsd || openbsd || dragonfly || bsdos \
- && test "$_radio" = yes && test "$_radio_bsdbt848" = auto ; then
+if freebsd || netbsd || openbsd || dragonfly || bsdos &&
+ test "$_radio" = yes && test "$_radio_bsdbt848" = auto ; then
echocheck "*BSD BrookTree 848 Radio interface"
_radio_bsdbt848=no
cat > $TMPC < $TMPC <
#include
int main(void) { struct v4l2_ext_controls ext; return ext.controls->value; }
EOF
@@ -7658,7 +7561,7 @@ if test "$_gui" = yes ; then
! echo $libavdecoders | grep -q PNG_DECODER ; then
die "The GUI requires libavcodec with PNG support (needs zlib)."
fi
- test "$_freetype" = no && test "$_bitmap_font" = no && \
+ test "$_freetype" = no && test "$_bitmap_font" = no &&
die "The GUI requires either FreeType or bitmap font support."
if ! win32 ; then
_gui_gtk=yes
@@ -8023,7 +7926,6 @@ CXXFLAGS = $WARNFLAGS $CXXFLAGS $extra_cflags $extra_cxxflags
CC_DEPFLAGS = $DEPFLAGS
CFLAGS_DHAHELPER = $cflags_dhahelper
-CFLAGS_FAAD_FIXED = $cflags_faad_fixed
CFLAGS_LIBDVDCSS = $cflags_libdvdcss
CFLAGS_LIBDVDCSS_DVDREAD = $cflags_libdvdcss_dvdread
CFLAGS_LIBDVDNAV = $cflags_libdvdnav
@@ -8051,14 +7953,14 @@ $(mak_enable "$cpuexts_all" "$cpuexts" HAVE)
MENCODER = $_mencoder
MPLAYER = $_mplayer
-NEED_GETTIMEOFDAY = $_need_gettimeofday
-NEED_GLOB = $_need_glob
-NEED_MMAP = $_need_mmap
-NEED_SETENV = $_need_setenv
-NEED_SHMEM = $_need_shmem
-NEED_STRSEP = $_need_strsep
-NEED_SWAB = $_need_swab
-NEED_VSSCANF = $_need_vsscanf
+NEED_GETTIMEOFDAY = $need_gettimeofday
+NEED_GLOB = $need_glob
+NEED_MMAP = $need_mmap
+NEED_SETENV = $need_setenv
+NEED_SHMEM = $need_shmem
+NEED_STRSEP = $need_strsep
+NEED_SWAB = $need_swab
+NEED_VSSCANF = $need_vsscanf
# features
3DFX = $_3dfx
@@ -8092,7 +7994,6 @@ DXR3 = $_dxr3
ESD = $_esd
FAAC=$_faac
FAAD = $_faad
-FAAD_INTERNAL = $_faad_internal
FASTMEMCPY = $_fastmemcpy
FBDEV = $_fbdev
FREETYPE = $_freetype
@@ -8297,13 +8198,14 @@ EOF
ff_config_enable () {
list=$(echo $1 | tr '[a-z]' '[A-Z]')
item=$(echo $2 | tr '[a-z]' '[A-Z]')
-_nprefix=$3;
+_nprefix=$4;
+_defineprefix=$3;
test -z "$_nprefix" && _nprefix='CONFIG'
for part in $list; do
if $(echo $item | grep -q -E "(^| )$part($| )"); then
- echo "#define ${_nprefix}_$part 1"
+ echo "${_defineprefix}define ${_nprefix}_$part 1"
else
- echo "#define ${_nprefix}_$part 0"
+ echo "${_defineprefix}define ${_nprefix}_$part 0"
fi
done
}
@@ -8357,17 +8259,11 @@ $def_fast_inttypes
#define HAVE_ERRNO_H 1
/* libdvdcss + libdvdread */
#define HAVE_LIMITS_H 1
-/* libdvdcss + libfaad2 */
+/* libdvdcss */
#define HAVE_UNISTD_H 1
-/* libfaad2 + libdvdread */
+/* libdvdread */
#define STDC_HEADERS 1
#define HAVE_MEMCPY 1
-/* libfaad2 */
-#define HAVE_STDLIB_H 1
-#define HAVE_STRING_H 1
-#define HAVE_STRINGS_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TYPES_H 1
/* libdvdnav */
#define READ_CACHE_TRACE 0
/* libdvdread */
@@ -8453,9 +8349,9 @@ $def_pthread_cache
$def_ebx_available
$def_words_endian
$def_bigendian
-$(ff_config_enable "$arch_all" "$arch" "ARCH")
-$(ff_config_enable "$subarch_all" "$subarch" "ARCH")
-$(ff_config_enable "$cpuexts_all" "$cpuexts" "HAVE")
+$(ff_config_enable "$arch_all" "$arch" "#" "ARCH")
+$(ff_config_enable "$subarch_all" "$subarch" "#" "ARCH")
+$(ff_config_enable "$cpuexts_all" "$cpuexts" "#" "HAVE")
/* Blu-ray/DVD/VCD/CD */
@@ -8484,7 +8380,6 @@ $def_vcd
/* codec libraries */
$def_faac
$def_faad
-$def_faad_internal
$def_liba52
$def_libdca
$def_libdv
@@ -8717,8 +8612,10 @@ $def_lrint
$def_lrintf
$def_mlib
$def_mkstemp
+$def_mmap
$def_network
$def_pic
+$def_poll_h
$def_posix_memalign
$def_pthreads
$def_round
@@ -8746,7 +8643,6 @@ $def_yasm
#define HAVE_INLINE_ASM 1
#define HAVE_ISATTY 0
#define HAVE_LDBRX 0
-#define HAVE_POLL_H 1
#define HAVE_PPC4XX 0
#define HAVE_STRERROR_R 0
#define HAVE_SYMVER_ASM_LABEL 0
@@ -8791,14 +8687,14 @@ $def_mp3lame_lavc
$def_x264_lavc
$def_xvid_lavc
-$(ff_config_enable "$libavdecoders_all" "$libavdecoders")
-$(ff_config_enable "$libavencoders_all" "$libavencoders")
-$(ff_config_enable "$libavparsers_all" "$libavparsers")
-$(ff_config_enable "$libavdemuxers_all" "$libavdemuxers")
-$(ff_config_enable "$libavmuxers_all" "$libavmuxers")
-$(ff_config_enable "$libavprotocols_all" "$libavprotocols")
-$(ff_config_enable "$libavbsfs_all" "$libavbsfs")
-$(ff_config_enable "$libavhwaccels_all" "$libavhwaccels")
+$(ff_config_enable "$libavdecoders_all" "$libavdecoders" "#")
+$(ff_config_enable "$libavencoders_all" "$libavencoders" "#")
+$(ff_config_enable "$libavparsers_all" "$libavparsers" "#")
+$(ff_config_enable "$libavdemuxers_all" "$libavdemuxers" "#")
+$(ff_config_enable "$libavmuxers_all" "$libavmuxers" "#")
+$(ff_config_enable "$libavprotocols_all" "$libavprotocols" "#")
+$(ff_config_enable "$libavbsfs_all" "$libavbsfs" "#")
+$(ff_config_enable "$libavhwaccels_all" "$libavhwaccels" "#")
#endif /* MPLAYER_CONFIG_H */
EOF
@@ -8825,10 +8721,12 @@ cmp -s "$TMPH" ffmpeg/libavutil/avconfig.h || mv -f "$TMPH" ffmpeg/libavutil/avc
if x86; then
# Create a skeleton config.asm with just the ARCH_ definitions for FFmpeg.
> "$TMPS"
+echo "%define CONFIG_GPL" >> "$TMPS"
for part in $arch $subarch; do
part=$(echo $part | tr '[a-z]' '[A-Z]')
echo "%define ARCH_${part}" >> "$TMPS"
done
+echo "$(ff_config_enable "$cpuexts_all" "$cpuexts" "%" "HAVE")" >> "$TMPS"
cmp -s "$TMPS" config.asm || mv -f "$TMPS" config.asm
fi
diff --git a/mplayer/debian/control b/mplayer/debian/control
index 43aee1f5..a88cf8ef 100644
--- a/mplayer/debian/control
+++ b/mplayer/debian/control
@@ -15,6 +15,7 @@ Build-Depends: debhelper (>= 7),
libaudio-dev,
libcaca-dev,
libcdparanoia-dev | libcdparanoia0-dev,
+ libbluray-dev,
libdirectfb-dev,
libdts-dev,
libesd0-dev,
diff --git a/mplayer/debian/copyright b/mplayer/debian/copyright
index 0b13283e..926eef29 100644
--- a/mplayer/debian/copyright
+++ b/mplayer/debian/copyright
@@ -62,64 +62,6 @@ Copyright (c) The ffmpeg Project
License: GNU Lesser General Public License, some parts GNU General Public
License, GNU General Public License when combined
-Name: FAAD2
-Version: 2.1 beta (20040915 CVS snapshot) + fixes and portability patches
-Homepage: http://www.audiocoding.com
-Directory: libfaad2
-Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-License: GNU General Public License
-
-Name: GSM 06.10 library
-Version: patchlevel 10
-Homepage: http://kbs.cs.tu-berlin.de/~jutta/toast.html
-Copyright 1992 by Jutta Degener and Carsten Bormann, Technische Universitaet Berlin
-Directory: libmpcodecs/native/
-License:
- Any use of this software is permitted provided that this notice is
- not removed and that neither the authors nor the Technische
- Universitaet Berlin are deemed to have made any representations as to
- the suitability of this software for any purpose nor are held
- responsible for any defects of this software. THERE IS ABSOLUTELY NO
- WARRANTY FOR THIS SOFTWARE.
- As a matter of courtesy, the authors request to be informed about
- uses this software has found, about bugs in this software, and about
- any improvements that may be of general interest.
- .
- As of the libgsm debian package version 1.0.13-1, the following
- copyright addition has been made to the libgsm package:
- .
- Since the original terms of 15 years ago maybe do not make our
- intentions completely clear given today's refined usage of the legal
- terms, we append this additional permission:
- .
- Permission to use, copy, modify, and distribute this software
- for any purpose with or without fee is hereby granted,
- provided that this notice is not removed and that neither
- the authors nor the Technische Universitaet Berlin are
- deemed to have made any representations as to the suitability
- of this software for any purpose nor are held responsible
- for any defects of this software. THERE IS ABSOLUTELY NO
- WARRANTY FOR THIS SOFTWARE.
- .
- Berkeley/Bremen, 05.04.2009
- Jutta Degener
- Carsten Bormann
-
-Name: miniLZO
-Version: 1.07
-Homepage: http://www.oberhumer.com/opensource/lzo/#minilzo
-File: libmpcodecs/native/minilzo.c libmpcodecs/native/minilzo.h
-Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer
-License: GNU General Public License
-
-Name: liba52
-Version: 0.7.4 + patches
-Homepage: http://liba52.sourceforge.net/
-Directory: liba52
-Copyright (C) 2000-2001 Michel Lespinasse
-Copyright (C) 1999-2000 Aaron Holtzman
-License: GNU General Public License
-
Name: libmpeg2
Version: 0.4.0b + patches
Homepage: http://libmpeg2.sourceforge.net/
@@ -209,12 +151,6 @@ Directory: libmpdemux/genres.h
Copyright (C) 2001 Jason Carter
License: GNU General Public License
-Name: matroxset
-Version: 0.3
-Homepage: ftp://platan.vc.cvut.cz/pub/linux/matrox-latest/
-Directory: TOOLS/TVout/matroxset/
-License: GNU General Public License
-
Name: unrarlib
Version: 0.4.0 + patches
Homepage: http://www.unrarlib.org/
diff --git a/mplayer/debian/rules b/mplayer/debian/rules
index 3c5eb747..25548400 100644
--- a/mplayer/debian/rules
+++ b/mplayer/debian/rules
@@ -154,7 +154,7 @@ clean:
dh_testroot
-test ! -f config.mak || ( $(MAKE) -C DOCS/xml releaseclean ; $(MAKE) distclean )
# in case the previous command fails for some reason, remove 'svn ignored' files
- rm -rf DOCS/HTML DOCS/HTML-single DOCS/codecs-status.html
+ rm -rf DOCS/HTML DOCS/codecs-status.html
# Build architecture-independent packages
binary-indep: install-indep
diff --git a/mplayer/etc/codecs.conf b/mplayer/etc/codecs.conf
index 9ee2fd86..72e5f600 100644
--- a/mplayer/etc/codecs.conf
+++ b/mplayer/etc/codecs.conf
@@ -986,6 +986,8 @@ videocodec ffh264
fourcc avc1,AVC1
fourcc davc,DAVC
fourcc vvvc ; only one sample using this fourcc
+ fourcc ai55,ai15 ; flip4mac avc intra
+ fourcc ai1q,ai5q ; flip4mac avc intra
format 0x10000005
driver ffmpeg
dll h264
@@ -998,6 +1000,8 @@ videocodec ffh264vdpau
fourcc X264,x264
fourcc avc1,AVC1
fourcc davc,DAVC
+ fourcc ai55,ai15 ; flip4mac avc intra
+ fourcc ai1q,ai5q ; flip4mac avc intra
format 0x10000005
driver ffmpeg
dll h264_vdpau
@@ -1012,6 +1016,8 @@ videocodec coreavcwindows
fourcc avc1 AVC1,AVC1
fourcc davc,DAVC
fourcc VSSH
+ fourcc ai55,ai15 ; flip4mac avc intra
+ fourcc ai1q,ai5q ; flip4mac avc intra
format 0x10000005
driver dshow
dll "CoreAVCDecoder.ax"
@@ -2894,6 +2900,8 @@ videocodec qtprores
fourcc apch
fourcc apcn
fourcc apcs
+ fourcc apco
+ fourcc ap4h
driver qtvideo
dll "AppleProResDecoder.qtx"
out YUY2
@@ -3130,6 +3138,14 @@ videocodec xan
dll "xanlib.dll"
out BGR24,BGR15,BGR8 query,flip
+videocodec ffwc4
+ info "FFmpeg XAN wc4"
+ status working
+ fourcc Xxan
+ driver ffmpeg
+ dll "xan_wc4"
+ out YV12
+
videocodec ffwc3
info "FFmpeg XAN wc3"
status buggy
@@ -3992,9 +4008,10 @@ audiocodec ffadpcmxa
audiocodec ffxandpcm
info "FFmpeg XAN DPCM audio"
- comment "only works with libavformat demuxer"
+ comment "Wing Commander 4 files only work with libavformat demuxer"
status working
fourcc Axan
+ format 0x594A
driver ffmpeg
dll xan_dpcm
@@ -4471,6 +4488,13 @@ audiocodec fflpcm
driver ffmpeg
dll pcm_bluray
+audiocodec ffpcmlxf
+ info "Leitch/Harris PCM"
+ status working
+ fourcc PLXF ; internal MPlayer FourCC
+ driver ffmpeg
+ dll pcm_lxf
+
; add every new fourcc also to allocate_parser()
; in libmpdemux/demuxer.c
audiocodec ffac3
diff --git a/mplayer/etc/example.conf b/mplayer/etc/example.conf
index 9895cfc0..6be7a346 100644
--- a/mplayer/etc/example.conf
+++ b/mplayer/etc/example.conf
@@ -2,7 +2,7 @@
# MPlayer configuration file
#
# Configuration files are read system-wide from /usr/local/etc/mplayer.conf
-# and per user from ~/.mplayer/config, where per-user settings override
+# and per-user from ~/.mplayer/config, where per-user settings override
# system-wide settings, all of which are overrriden by the command line.
#
# The configuration file settings are the same as the command line
@@ -11,23 +11,14 @@
# See the CONFIGURATION FILES section in the man page
# for a detailed description of the syntax.
#
-# Profiles should be at the bottom of the config file to ensure you dont
-# put default options under profiles accidentally.
+# Profiles should be placed at the bottom of the configuration file to ensure
+# that settings wanted as defaults are not restricted to specific profiles.
##################
# video settings #
##################
-# Specify vdpau codecs when using -vo vdpau.
-#[vo.vdpau]
-#vc=ffmpeg12vdpau,ffwmv3vdpau,ffvc1vdpau,ffh264vdpau,ffodivxvdpau,
-# Most video filters do not work with vdpau.
-#vf-clr=yes
-
-# Make sure options under vo.vdpau profile are counted when vdpau is not used
-#[default]
-
# Specify default video driver (see -vo help for a list).
#vo=xv
@@ -98,6 +89,7 @@
#ao=alsa:device=spdif
#ac=hwac3,hwdts,hwmpa,
+
##################
# other settings #
##################
@@ -149,13 +141,25 @@
# DVD: Play English audio tracks if available.
#alang = en
-###################
-# DVDNAV Settings #
-###################
+
+############
+# Profiles #
+############
+
+# The options declared as part of profiles override global default settings,
+# but only take effect when the profile is active.
+
[protocol.dvdnav]
#vc=ffmpeg12,
#mouse-movements=yes
#nocache=yes
+#[vo.vdpau]
+#vc=ffmpeg12vdpau,ffwmv3vdpau,ffvc1vdpau,ffh264vdpau,ffodivxvdpau,
+# Most video filters do not work with vdpau.
+#vf-clr=yes
+
+
+
# You can also include other configuration files.
#include = /path/to/the/file/you/want/to/include
diff --git a/mplayer/ffmpeg/Changelog b/mplayer/ffmpeg/Changelog
index 8b7efb61..dc47dabd 100644
--- a/mplayer/ffmpeg/Changelog
+++ b/mplayer/ffmpeg/Changelog
@@ -55,7 +55,7 @@ version :
- Win64 support for optimized asm functions
- MJPEG/AVI1 to JPEG/JFIF bitstream filter
- ASS subtitle encoder and decoder
-- IEC 61937 encapsulation for E-AC3 and TrueHD (for HDMI passthrough)
+- IEC 61937 encapsulation for E-AC3, TrueHD, DTS-HD (for HDMI passthrough)
- overlay filter added
- rename aspect filter to setdar, and pixelaspect to setsar
- IEC 61937 demuxer
@@ -74,6 +74,9 @@ version :
- Lagarith decoder
- ffmpeg -copytb option added
- IVF muxer added
+- Wing Commander IV movies decoder added
+- movie source added
+- Bink version 'b' audio and video decoder
version 0.6:
diff --git a/mplayer/ffmpeg/Makefile b/mplayer/ffmpeg/Makefile
index 2658a30d..ad1f737e 100644
--- a/mplayer/ffmpeg/Makefile
+++ b/mplayer/ffmpeg/Makefile
@@ -15,7 +15,7 @@ OBJS = $(PROGS-yes:%=%.o) cmdutils.o
MANPAGES = $(PROGS-yes:%=doc/%.1)
PODPAGES = $(PROGS-yes:%=doc/%.pod)
HTMLPAGES = $(PROGS-yes:%=doc/%.html)
-TOOLS = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws pktdumper probetest qt-faststart trasher))
+TOOLS = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher))
TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
HOSTPROGS := $(TESTTOOLS:%=tests/%)
@@ -23,7 +23,6 @@ BASENAMES = ffmpeg ffplay ffprobe ffserver
ALLPROGS = $(BASENAMES:%=%$(EXESUF))
ALLPROGS_G = $(BASENAMES:%=%_g$(EXESUF))
ALLMANPAGES = $(BASENAMES:%=%.1)
-ALLHTMLPAGES= $(BASENAMES:%=%.html)
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
FFLIBS-$(CONFIG_AVFILTER) += avfilter
@@ -31,7 +30,6 @@ FFLIBS-$(CONFIG_AVFORMAT) += avformat
FFLIBS-$(CONFIG_AVCODEC) += avcodec
FFLIBS-$(CONFIG_POSTPROC) += postproc
FFLIBS-$(CONFIG_SWSCALE) += swscale
-FFLIBS-$(CONFIG_AVCORE) += avcore
FFLIBS := avutil
@@ -67,7 +65,7 @@ config.h: .config
SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
- HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS
+ HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS ARMV6-OBJS
define RESET
$(1) :=
@@ -94,6 +92,8 @@ tools/%$(EXESUF): tools/%.o
tools/%.o: tools/%.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
+-include $(wildcard tools/*.d)
+
ffplay.o: CFLAGS += $(SDL_CFLAGS)
VERSION_SH = $(SRC_PATH_BARE)/version.sh
@@ -112,22 +112,22 @@ version.h .version:
alltools: $(TOOLS)
-documentation: $(addprefix doc/, developer.html faq.html general.html libavfilter.html \
- $(ALLHTMLPAGES) $(ALLMANPAGES))
+DOCS = $(addprefix doc/, developer.html faq.html general.html libavfilter.html) $(HTMLPAGES) $(MANPAGES) $(PODPAGES)
+
+documentation: $(DOCS)
-$(HTMLPAGES) $(PODPAGES): doc/fftools-common-opts.texi
+-include $(wildcard $(DOCS:%=%.d))
-doc/ffmpeg.pod doc/ffmpeg.html: doc/demuxers.texi doc/bitstream_filters.texi doc/eval.texi doc/indevs.texi doc/filters.texi doc/outdevs.texi doc/protocols.texi doc/metadata.texi
-doc/ffplay.pod doc/ffplay.html: doc/demuxers.texi doc/eval.texi doc/indevs.texi doc/filters.texi doc/outdevs.texi doc/protocols.texi
-doc/ffprobe.pod doc/ffprobe.html: doc/demuxers.texi doc/indevs.texi doc/protocols.texi
-doc/libavfilter.html: doc/filters.texi
+TEXIDEP = awk '/^@include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d)
doc/%.html: TAG = HTML
doc/%.html: doc/%.texi $(SRC_PATH_BARE)/doc/t2h.init
+ $(Q)$(TEXIDEP)
$(M)cd doc && texi2html -monolithic --init-file $(SRC_PATH_BARE)/doc/t2h.init $(<:doc/%=%)
doc/%.pod: TAG = POD
doc/%.pod: doc/%.texi
+ $(Q)$(TEXIDEP)
$(M)doc/texi2pod.pl $< $@
doc/%.1: TAG = MAN
@@ -170,6 +170,7 @@ clean:: testclean
$(RM) $(CLEANSUFFIXES)
$(RM) doc/*.html doc/*.pod doc/*.1
$(RM) $(TOOLS)
+ $(RM) $(CLEANSUFFIXES:%=tools/%)
distclean::
$(RM) $(DISTCLEANSUFFIXES)
diff --git a/mplayer/ffmpeg/cmdutils.c b/mplayer/ffmpeg/cmdutils.c
index 58fe85cf..514ebadb 100644
--- a/mplayer/ffmpeg/cmdutils.c
+++ b/mplayer/ffmpeg/cmdutils.c
@@ -35,10 +35,10 @@
#include "libswscale/swscale.h"
#include "libpostproc/postprocess.h"
#include "libavutil/avstring.h"
+#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/eval.h"
#include "libavcodec/opt.h"
-#include "libavcore/avcore.h"
#include "cmdutils.h"
#include "version.h"
#if CONFIG_NETWORK
@@ -78,6 +78,16 @@ void uninit_opts(void)
#if CONFIG_SWSCALE
av_freep(&sws_opts);
#endif
+ for (i = 0; i < opt_name_count; i++) {
+ //opt_values are only stored for codec-specific options in which case
+ //both the name and value are dup'd
+ if (opt_values[i]) {
+ av_freep(&opt_names[i]);
+ av_freep(&opt_values[i]);
+ }
+ }
+ av_freep(&opt_names);
+ av_freep(&opt_values);
}
void log_callback_help(void* ptr, int level, const char* fmt, va_list vl)
@@ -104,8 +114,8 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do
int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
{
- int64_t us = parse_date(timestr, is_duration);
- if (us == INT64_MIN) {
+ int64_t us;
+ if (av_parse_time(&us, timestr, is_duration) < 0) {
fprintf(stderr, "Invalid %s specification for %s: %s\n",
is_duration ? "duration" : "date", context, timestr);
exit(1);
@@ -268,9 +278,9 @@ int opt_default(const char *opt, const char *arg){
//FIXME we should always use avcodec_opts, ... for storing options so there will not be any need to keep track of what i set over this
opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1));
- opt_values[opt_name_count]= o ? NULL : arg;
+ opt_values[opt_name_count]= o ? NULL : av_strdup(arg);
opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
- opt_names[opt_name_count++]= o ? o->name : opt;
+ opt_names[opt_name_count++]= o ? o->name : av_strdup(opt);
if ((*avcodec_opts && avcodec_opts[0]->debug) || (avformat_opts && avformat_opts->debug))
av_log_set_level(AV_LOG_DEBUG);
@@ -403,7 +413,6 @@ static int warned_cfg = 0;
static void print_all_libs_info(FILE* outstream, int flags)
{
PRINT_LIB_INFO(outstream, avutil, AVUTIL, flags);
- PRINT_LIB_INFO(outstream, avcore, AVCORE, flags);
PRINT_LIB_INFO(outstream, avcodec, AVCODEC, flags);
PRINT_LIB_INFO(outstream, avformat, AVFORMAT, flags);
PRINT_LIB_INFO(outstream, avdevice, AVDEVICE, flags);
diff --git a/mplayer/ffmpeg/common.mak b/mplayer/ffmpeg/common.mak
index 110f5056..3d1a1293 100644
--- a/mplayer/ffmpeg/common.mak
+++ b/mplayer/ffmpeg/common.mak
@@ -31,7 +31,7 @@ $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
endif
-ALLFFLIBS = avcodec avcore avdevice avfilter avformat avutil postproc swscale
+ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
IFLAGS := -I$(BUILD_ROOT_REL) -I$(SRC_PATH)
CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
diff --git a/mplayer/ffmpeg/configure b/mplayer/ffmpeg/configure
index 46f4e441..04f6e132 100644
--- a/mplayer/ffmpeg/configure
+++ b/mplayer/ffmpeg/configure
@@ -86,7 +86,6 @@ Configuration options:
--disable-ffserver disable ffserver build
--disable-avdevice disable libavdevice build
--disable-avcodec disable libavcodec build
- --disable-avcore disable libavcore build
--disable-avformat disable libavformat build
--disable-swscale disable libswscale build
--enable-postproc enable GPLed postprocessing support [no]
@@ -223,6 +222,7 @@ Advanced options (experts only):
--disable-mmx2 disable MMX2 optimizations
--disable-sse disable SSE optimizations
--disable-ssse3 disable SSSE3 optimizations
+ --disable-avx disable AVX optimizations
--disable-armv5te disable armv5te optimizations
--disable-armv6 disable armv6 optimizations
--disable-armv6t2 disable armv6t2 optimizations
@@ -243,7 +243,8 @@ Developer options (useful when working on FFmpeg itself):
--disable-optimizations disable compiler optimizations
--enable-extra-warnings enable more compiler warnings
--disable-stripping disable stripping of executables and shared libraries
- --samples=PATH location of test samples for FATE
+ --samples=PATH location of test samples for FATE, if not set use
+ \$FATE_SAMPLES at make invocation time.
NOTE: Object files are built at the place where configure is launched.
EOF
@@ -313,6 +314,10 @@ sh_quote(){
echo "$v"
}
+cleanws(){
+ echo "$@" | sed 's/^ *//;s/ */ /g;s/ *$//'
+}
+
filter(){
pat=$1
shift
@@ -867,7 +872,6 @@ CONFIG_LIST="
$COMPONENT_LIST
aandct
avcodec
- avcore
avdevice
avfilter
avformat
@@ -973,6 +977,7 @@ ARCH_EXT_LIST='
armv6
armv6t2
armvfp
+ avx
iwmmxt
mmi
mmx
@@ -1181,6 +1186,7 @@ mmx_deps="x86"
mmx2_deps="mmx"
sse_deps="mmx"
ssse3_deps="sse"
+avx_deps="ssse3"
aligned_stack_if_any="ppc x86"
fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
@@ -1585,7 +1591,6 @@ host_os=$target_os_default
# configurable options
enable avcodec
-enable avcore
enable avdevice
enable avfilter
enable avformat
@@ -1861,8 +1866,11 @@ if $cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
elif $cc -v 2>&1 | grep -qi ^gcc; then
cc_type=gcc
cc_version=__VERSION__
- gcc_extra_ver=$(expr "$($cc --version | head -n1)" : '.*\((.*)\)')
- cc_ident="gcc $($cc -dumpversion) $gcc_extra_ver"
+ gcc_version=$($cc --version | head -n1)
+ gcc_basever=$($cc -dumpversion)
+ gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
+ gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
+ cc_ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
if ! $cc -dumpversion | grep -q '^2\.'; then
CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
@@ -2038,7 +2046,7 @@ add_asflags $extra_cflags
if test -n "$sysroot"; then
case "$cc_type" in
- gcc|llvm_gcc)
+ gcc|llvm_gcc|clang)
add_cppflags --sysroot="$sysroot"
add_ldflags --sysroot="$sysroot"
;;
@@ -2046,10 +2054,6 @@ if test -n "$sysroot"; then
add_cppflags -I"$sysinclude"
add_ldflags --sysroot="$sysroot"
;;
- clang)
- add_cppflags -isysroot "$sysroot"
- add_ldflags -isysroot "$sysroot"
- ;;
esac
fi
@@ -2305,6 +2309,7 @@ case $target_os in
haiku)
prefix_default="/boot/common"
network_extralibs="-lnetwork"
+ host_libs=
;;
sunos)
FFSERVERLDFLAGS=""
@@ -2420,7 +2425,7 @@ case $target_os in
ranlib="echo ignoring ranlib"
;;
os/2*)
- strip="lxlite"
+ strip="lxlite -CS"
ln_s="cp -f"
add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
@@ -2493,8 +2498,6 @@ die_license_disabled version3 libopencore_amrwb
enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
-check_deps $ARCH_EXT_LIST
-
disabled optimizations || check_cflags -fomit-frame-pointer
enable_pic() {
@@ -2671,8 +2674,9 @@ EOF
elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
esac
- check_yasm "pabsw xmm0, xmm0" && enable yasm ||
+ check_yasm "pextrd [eax], xmm0, 1" && enable yasm ||
die "yasm not found, use --disable-yasm for a crippled build"
+ check_yasm "vpaddw xmm0, xmm0, xmm0" || disable avx
fi
case "$cpu" in
@@ -2927,7 +2931,7 @@ enabled extra_warnings && check_cflags -Winline
# add some linker flags
check_ldflags -Wl,--warn-common
check_ldflags -Wl,--as-needed
-check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavcore -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
+check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
echo "X{};" > $TMPV
@@ -3137,7 +3141,6 @@ if enabled source_path_used; then
doc
libavcodec
libavcodec/$arch
- libavcore
libavdevice
libavfilter
libavfilter/$arch
@@ -3157,7 +3160,6 @@ if enabled source_path_used; then
doc/texi2pod.pl
libavcodec/Makefile
libavcodec/${arch}/Makefile
- libavcore/Makefile
libavdevice/Makefile
libavfilter/Makefile
libavfilter/${arch}/Makefile
@@ -3244,7 +3246,7 @@ SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
-SAMPLES=$samples
+SAMPLES=${samples:-\$(FATE_SAMPLES)}
EOF
get_version(){
@@ -3260,7 +3262,6 @@ get_version(){
get_version LIBSWSCALE libswscale/swscale.h
get_version LIBPOSTPROC libpostproc/postprocess.h
get_version LIBAVCODEC libavcodec/avcodec.h
-get_version LIBAVCORE libavcore/avcore.h
get_version LIBAVDEVICE libavdevice/avdevice.h
get_version LIBAVFORMAT libavformat/version.h
get_version LIBAVUTIL libavutil/avutil.h
@@ -3388,10 +3389,9 @@ EOF
}
pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
-pkgconfig_generate libavcore "FFmpeg multimedia shared core utilities library" "$LIBAVCORE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
-pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION"
+pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs"
pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
-pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION"
+pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs"
pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
diff --git a/mplayer/ffmpeg/doc/APIchanges b/mplayer/ffmpeg/doc/APIchanges
index aa1221df..3a8543ed 100644
--- a/mplayer/ffmpeg/doc/APIchanges
+++ b/mplayer/ffmpeg/doc/APIchanges
@@ -2,7 +2,6 @@ Never assume the API of libav* to be stable unless at least 1 week has passed si
the last major version increase.
The last version increases were:
libavcodec: ?
-libavcore: 2010-07-21
libavdevice: ?
libavfilter: 2009-10-18
libavformat: ?
@@ -13,6 +12,67 @@ libavutil: 2009-03-08
API changes, most recent first:
+2011-02-20 - e731b8d - lavf 52.102.0 - avio.h
+ * e731b8d - rename init_put_byte() to ffio_init_context(), deprecating the
+ original, and move it to a private header so it is no longer
+ part of our public API. Instead, use av_alloc_put_byte().
+ * ae628ec - rename ByteIOContext to AVIOContext.
+
+2011-02-16 - 09d171b - lavf 52.101.0 - avformat.h
+ lavu 52.39.0 - parseutils.h
+ * 610219a - Add av_ prefix to dump_format().
+ * f6c7375 - Replace parse_date() in lavf with av_parse_time() in lavu.
+ * ab0287f - Move find_info_tag from lavf to lavu and add av_prefix to it.
+
+2011-02-15 - lavu 52.38.0 - merge libavcore
+ libavcore is merged back completely into libavutil
+
+2011-02-10 - 55bad0c - lavc 52.113.0 - vbv_delay
+ Add vbv_delay field to AVCodecContext
+
+2011-02-14 - 24a83bd - lavf 52.100.0 - AV_DISPOSITION_CLEAN_EFFECTS
+ Add AV_DISPOSITION_CLEAN_EFFECTS disposition flag.
+
+2011-02-14 - 910b5b8 - lavfi 1.76.0 - AVFilterLink sample_aspect_ratio
+ Add sample_aspect_ratio field to AVFilterLink.
+
+2011-02-10 - 12c14cd - lavf 52.99.0 - AVStream.disposition
+ Add AV_DISPOSITION_HEARING_IMPAIRED and AV_DISPOSITION_VISUAL_IMPAIRED.
+
+2011-02-09 - 5592734 - lavc 52.112.0 - avcodec_thread_init()
+ Deprecate avcodec_thread_init()/avcodec_thread_free() use; instead
+ set thread_count before calling avcodec_open.
+
+2011-02-09 - 778b08a - lavc 52.111.0 - threading API
+ Add CODEC_CAP_FRAME_THREADS with new restrictions on get_buffer()/
+ release_buffer()/draw_horiz_band() callbacks for appropriate codecs.
+ Add thread_type and active_thread_type fields to AVCodecContext.
+
+2011-02-08 - 3940caa - lavf 52.98.0 - av_probe_input_buffer
+ Add av_probe_input_buffer() to avformat.h for probing format from a
+ ByteIOContext.
+
+2011-02-06 - fe174fc - lavf 52.97.0 - avio.h
+ Add flag for non-blocking protocols: URL_FLAG_NONBLOCK
+
+2011-02-04 - f124b08 - lavf 52.96.0 - avformat_free_context()
+ Add avformat_free_context() in avformat.h.
+
+2011-02-03 - f5b82f4 - lavc 52.109.0 - add CODEC_ID_PRORES
+ Add CODEC_ID_PRORES to avcodec.h.
+
+2011-02-03 - fe9a3fb - lavc 52.109.0 - H.264 profile defines
+ Add defines for H.264 * Constrained Baseline and Intra profiles
+
+2011-02-02 - lavf 52.95.0
+ * 50196a9 - add a new installed header version.h.
+ * 4efd5cf, dccbd97, 93b78d1 - add several variants of public
+ avio_{put,get}_str* functions. Deprecate corresponding semi-public
+ {put,get}_str*.
+
+2011-02-02 - dfd2a00 - lavu 50.37.0 - log.h
+ Make av_dlog public.
+
2011-01-15 - r26374 - lavfi 1.74.0 - AVFilterBufferRefAudioProps
Rename AVFilterBufferRefAudioProps.samples_nb to nb_samples.
diff --git a/mplayer/ffmpeg/doc/TODO b/mplayer/ffmpeg/doc/TODO
index 747eee4a..8ff8a6b3 100644
--- a/mplayer/ffmpeg/doc/TODO
+++ b/mplayer/ffmpeg/doc/TODO
@@ -69,7 +69,7 @@ unassigned TODO: (unordered)
- JPEG2000 decoder & encoder
- MPEG4 GMC encoding support
- macroblock based pixel format (better cache locality, somewhat complex, one paper claimed it faster for high res)
-- regression tests for codecs which do not have an encoder (I+P-frame bitstream in svn)
+- regression tests for codecs which do not have an encoder (I+P-frame bitstream in the 'master' branch)
- add support for using mplayers video filters to ffmpeg
- H264 encoder
- per MB ratecontrol (so VCD and such do work better)
diff --git a/mplayer/ffmpeg/doc/build_system.txt b/mplayer/ffmpeg/doc/build_system.txt
index b22ff848..8a200695 100644
--- a/mplayer/ffmpeg/doc/build_system.txt
+++ b/mplayer/ffmpeg/doc/build_system.txt
@@ -4,6 +4,8 @@ some of its obscure features and options.
Options to make:
make V=1
Build target with verbosity 1, instead of 1, 2 can be used too
+make SAMPLES=
+ specify the path to the fate samples at make time
Useful standard make commands:
@@ -31,4 +33,5 @@ fate
Setting up local fate:
use the following command to get the fate test samples
rsync -aL rsync://rsync.mplayerhq.hu:/samples/fate-suite/ fate/fate-suite
-pass --samples= to configure
+pass --samples= to configure or pass the path with the
+SAMPLES variable to make
diff --git a/mplayer/ffmpeg/doc/developer.texi b/mplayer/ffmpeg/doc/developer.texi
index b9e246f2..acffbe67 100644
--- a/mplayer/ffmpeg/doc/developer.texi
+++ b/mplayer/ffmpeg/doc/developer.texi
@@ -312,7 +312,7 @@ send a reminder by email. Your patch should eventually be dealt with.
If it depends on a parser or a library, did you add that dependency in
configure?
@item
- Did you "svn add" the appropriate files before commiting?
+ Did you "git add" the appropriate files before committing?
@end enumerate
@section patch submission checklist
@@ -325,7 +325,7 @@ send a reminder by email. Your patch should eventually be dealt with.
@item
Is the patch a unified diff?
@item
- Is the patch against latest FFmpeg SVN?
+ Is the patch against latest FFmpeg git master branch?
@item
Are you subscribed to ffmpeg-dev?
(the list is subscribers only due to spam)
@@ -388,7 +388,7 @@ send a reminder by email. Your patch should eventually be dealt with.
@section Patch review process
All patches posted to ffmpeg-devel will be reviewed, unless they contain a
-clear note that the patch is not for SVN.
+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
diff --git a/mplayer/ffmpeg/doc/encoders.texi b/mplayer/ffmpeg/doc/encoders.texi
new file mode 100644
index 00000000..cab98fb0
--- /dev/null
+++ b/mplayer/ffmpeg/doc/encoders.texi
@@ -0,0 +1,20 @@
+@chapter Encoders
+@c man begin ENCODERS
+
+Encoders are configured elements in FFmpeg which allow the encoding of
+multimedia streams.
+
+When you configure your FFmpeg build, all the supported native encoders
+are enabled by default. Encoders requiring an external library must be enabled
+manually via the corresponding @code{--enable-lib} option. You can list all
+available encoders using the configure option @code{--list-encoders}.
+
+You can disable all the encoders with the configure option
+@code{--disable-encoders} and selectively enable / disable single encoders
+with the options @code{--enable-encoder=@var{ENCODER}} /
+@code{--disable-encoder=@var{ENCODER}}.
+
+The option @code{-codecs} of the ff* tools will display the list of
+enabled encoders.
+
+@c man end ENCODERS
diff --git a/mplayer/ffmpeg/doc/faq.texi b/mplayer/ffmpeg/doc/faq.texi
index 100adff3..b8a13b79 100644
--- a/mplayer/ffmpeg/doc/faq.texi
+++ b/mplayer/ffmpeg/doc/faq.texi
@@ -147,7 +147,7 @@ that match @code{*jpg} to the @file{/tmp} directory in the sequence of
@file{img001.jpg}, @file{img002.jpg} and so on.
@example
- x=1; for i in *jpg; do counter=$(printf %03d $x); ln "$i" /tmp/img"$counter".jpg; x=$(($x+1)); done
+ x=1; for i in *jpg; do counter=$(printf %03d $x); ln -s "$i" /tmp/img"$counter".jpg; x=$(($x+1)); done
@end example
If you want to sequence them by oldest modified first, substitute
@@ -423,7 +423,7 @@ read "Programming Religion" at (@url{http://www.tux.org/lkml/#s15}).
The build process creates ffmpeg_g, ffplay_g, etc. which contain full debug
information. Those binaries are stripped to create ffmpeg, ffplay, etc. If
-you need the debug information, used the *_g versions.
+you need the debug information, use the *_g versions.
@section I do not like the LGPL, can I contribute code under the GPL instead?
diff --git a/mplayer/ffmpeg/doc/ffmpeg.texi b/mplayer/ffmpeg/doc/ffmpeg.texi
index 047444ab..f0f3b650 100644
--- a/mplayer/ffmpeg/doc/ffmpeg.texi
+++ b/mplayer/ffmpeg/doc/ffmpeg.texi
@@ -628,7 +628,10 @@ Just enumerate the input streams in the order you want them in the output.
@var{sync_stream_id} if specified sets the input stream to sync
against.
@item -map_meta_data @var{outfile}[,@var{metadata}]:@var{infile}[,@var{metadata}]
-Set meta data information of @var{outfile} from @var{infile}. Note that those
+Deprecated, use @var{-map_metadata} instead.
+
+@item -map_metadata @var{outfile}[,@var{metadata}]:@var{infile}[,@var{metadata}]
+Set metadata information of @var{outfile} from @var{infile}. Note that those
are file indices (zero-based), not filenames.
Optional @var{metadata} parameters specify, which metadata to copy - (g)lobal
(i.e. metadata that applies to the whole file), per-(s)tream, per-(c)hapter or
@@ -644,7 +647,7 @@ file index can be used to create a dummy mapping that just disables automatic co
For example to copy metadata from the first stream of the input file to global metadata
of the output file:
@example
-ffmpeg -i in.ogg -map_meta_data 0:0,s0 out.mp3
+ffmpeg -i in.ogg -map_metadata 0:0,s0 out.mp3
@end example
@item -map_chapters @var{outfile}:@var{infile}
Copy chapters from @var{infile} to @var{outfile}. If no chapter mapping is specified,
@@ -978,6 +981,7 @@ file to which you want to add them.
@c man end EXAMPLES
@include eval.texi
+@include encoders.texi
@include demuxers.texi
@include muxers.texi
@include indevs.texi
diff --git a/mplayer/ffmpeg/doc/filters.texi b/mplayer/ffmpeg/doc/filters.texi
index 38428865..042ea132 100644
--- a/mplayer/ffmpeg/doc/filters.texi
+++ b/mplayer/ffmpeg/doc/filters.texi
@@ -657,13 +657,13 @@ Follow some examples:
overlay=main_w-overlay_w-10:main_h-overlay_h-10
# insert a transparent PNG logo in the bottom left corner of the input
-movie=0:png:logo.png [logo];
+movie=logo.png [logo];
[in][logo] overlay=10:main_h-overlay_h-10 [out]
# insert 2 different transparent PNG logos (second logo on bottom
# right corner):
-movie=0:png:logo1.png [logo1];
-movie=0:png:logo2.png [logo2];
+movie=logo1.png [logo1];
+movie=logo2.png [logo2];
[in][logo1] overlay=10:H-h-10 [in+logo1];
[in+logo1][logo2] overlay=W-w-10:H-h-10 [out]
@@ -1088,6 +1088,61 @@ to the pad with identifier "in".
"color=red@@0.2:qcif:10 [color]; [in][color] overlay [out]"
@end example
+@section movie
+
+Read a video stream from a movie container.
+
+It accepts the syntax: @var{movie_name}[:@var{options}] where
+@var{movie_name} is the name of the resource to read (not necessarily
+a file but also a device or a stream accessed through some protocol),
+and @var{options} is an optional sequence of @var{key}=@var{value}
+pairs, separated by ":".
+
+The description of the accepted options follows.
+
+@table @option
+
+@item format_name, f
+Specifies the format assumed for the movie to read, and can be either
+the name of a container or an input device. If not specified the
+format is guessed from @var{movie_name} or by probing.
+
+@item seek_point, sp
+Specifies the seek point in seconds, the frames will be output
+starting from this seek point, the parameter is evaluated with
+@code{av_strtod} so the numerical value may be suffixed by an IS
+postfix. Default value is "0".
+
+@item stream_index, si
+Specifies the index of the video stream to read. If the value is -1,
+the best suited video stream will be automatically selected. Default
+value is "-1".
+
+@end table
+
+This filter allows to overlay a second video on top of main input of
+a filtergraph as shown in this graph:
+@example
+input -----------> deltapts0 --> overlay --> output
+ ^
+ |
+movie --> scale--> deltapts1 -------+
+@end example
+
+Some examples follow:
+@example
+# skip 3.2 seconds from the start of the avi file in.avi, and overlay it
+# on top of the input labelled as "in".
+movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
+[in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
+
+# read from a video4linux2 device, and overlay it on top of the input
+# labelled as "in"
+movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
+[in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
+
+@end example
+
@section nullsrc
Null video source, never return images. It is mainly useful as a
diff --git a/mplayer/ffmpeg/doc/general.texi b/mplayer/ffmpeg/doc/general.texi
index 950159f1..cd126f98 100644
--- a/mplayer/ffmpeg/doc/general.texi
+++ b/mplayer/ffmpeg/doc/general.texi
@@ -352,7 +352,6 @@ following image formats are supported:
@item Bethesda VID video @tab @tab X
@tab Used in some games from Bethesda Softworks.
@item Bink Video @tab @tab X
- @tab Support for version 'b' is missing.
@item Brute Force & Ignorance @tab @tab X
@tab Used in the game Flash Traffic: City of Angels.
@item C93 video @tab @tab X
@@ -511,6 +510,8 @@ following image formats are supported:
@tab not completely working
@item Wing Commander III / Xan @tab @tab X
@tab Used in Wing Commander III .MVE files.
+@item Wing Commander IV / Xan @tab @tab X
+ @tab Used in Wing Commander IV.
@item Winnov WNV1 @tab @tab X
@item WMV7 @tab X @tab X
@item YAMAHA SMAF @tab X @tab X
@@ -985,7 +986,7 @@ you should only need to add the directory where the LIB files are installed
(i.e. @file{c:\msys\usr\local\bin}). This is not a typo, the LIB files are
installed in the @file{bin} directory. And instead of adding the static
libraries (@file{libxxx.a} files) you should add the MSVC import libraries
-(@file{avcodec.lib}, @file{avformat.lib}, @file{avcore.lib}, and
+(@file{avcodec.lib}, @file{avformat.lib}, and
@file{avutil.lib}). Note that you should not use the GCC import
libraries (@file{libxxx.dll.a} files), as these will give you undefined
reference errors. There should be no need for @file{libmingwex.a},
diff --git a/mplayer/ffmpeg/doc/multithreading.txt b/mplayer/ffmpeg/doc/multithreading.txt
new file mode 100644
index 00000000..a1068425
--- /dev/null
+++ b/mplayer/ffmpeg/doc/multithreading.txt
@@ -0,0 +1,65 @@
+FFmpeg multithreading methods
+==============================================
+
+FFmpeg provides two methods for multithreading codecs.
+
+Slice threading decodes multiple parts of a frame at the same time, using
+AVCodecContext execute() and execute2().
+
+Frame threading decodes multiple frames at the same time.
+It accepts N future frames and delays decoded pictures by N-1 frames.
+The later frames are decoded in separate threads while the user is
+displaying the current one.
+
+Restrictions on clients
+==============================================
+
+Slice threading -
+* The client's draw_horiz_band() must be thread-safe according to the comment
+ in avcodec.h.
+
+Frame threading -
+* Restrictions with slice threading also apply.
+* For best performance, the client should set thread_safe_callbacks if it
+ provides a thread-safe get_buffer() callback.
+* There is one frame of delay added for every thread beyond the first one.
+ Clients must be able to handle this; the pkt_dts and pkt_pts fields in
+ AVFrame will work as usual.
+
+Restrictions on codec implementations
+==============================================
+
+Slice threading -
+ None except that there must be something worth executing in parallel.
+
+Frame threading -
+* Codecs can only accept entire pictures per packet.
+* Codecs similar to ffv1, whose streams don't reset across frames,
+ will not work because their bitstreams cannot be decoded in parallel.
+
+* The contents of buffers must not be read before ff_thread_await_progress()
+ has been called on them. reget_buffer() and buffer age optimizations no longer work.
+* The contents of buffers must not be written to after ff_thread_report_progress()
+ has been called on them. This includes draw_edges().
+
+Porting codecs to frame threading
+==============================================
+
+Find all context variables that are needed by the next frame. Move all
+code changing them, as well as code calling get_buffer(), up to before
+the decode process starts. Call ff_thread_finish_setup() afterwards. If
+some code can't be moved, have update_thread_context() run it in the next
+thread.
+
+If the codec allocates writable tables in its init(), add an init_thread_copy()
+which re-allocates them for other threads.
+
+Add CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little
+speed gain at this point but it should work.
+
+Call ff_thread_report_progress() after some part of the current picture has decoded.
+A good place to put this is where draw_horiz_band() is called - add this if it isn't
+called anywhere, as it's useful too and the implementation is trivial when you're
+doing this. Note that draw_edges() needs to be called before reporting progress.
+
+Before accessing a reference frame or its MVs, call ff_thread_await_progress().
diff --git a/mplayer/ffmpeg/doc/muxers.texi b/mplayer/ffmpeg/doc/muxers.texi
index c3dcf117..e7cfc4a9 100644
--- a/mplayer/ffmpeg/doc/muxers.texi
+++ b/mplayer/ffmpeg/doc/muxers.texi
@@ -18,4 +18,190 @@ enabled muxers.
A description of some of the currently available muxers follows.
+@anchor{crc}
+@section crc
+
+CRC (Cyclic Redundancy Check) testing format.
+
+This muxer computes and prints the Adler-32 CRC of all the input audio
+and video frames. By default audio frames are converted to signed
+16-bit raw audio and video frames to raw video before computing the
+CRC.
+
+The output of the muxer consists of a single line of the form:
+CRC=0x@var{CRC}, where @var{CRC} is a hexadecimal number 0-padded to
+8 digits containing the CRC for all the decoded input frames.
+
+For example to compute the CRC of the input, and store it in the file
+@file{out.crc}:
+@example
+ffmpeg -i INPUT -f crc out.crc
+@end example
+
+You can print the CRC to stdout with the command:
+@example
+ffmpeg -i INPUT -f crc -
+@end example
+
+You can select the output format of each frame with @file{ffmpeg} by
+specifying the audio and video codec and format. For example to
+compute the CRC of the input audio converted to PCM unsigned 8-bit
+and the input video converted to MPEG-2 video, use the command:
+@example
+ffmpeg -i INPUT -acodec pcm_u8 -vcodec mpeg2video -f crc -
+@end example
+
+See also the @code{framecrc} muxer (@pxref{framecrc}).
+
+@anchor{framecrc}
+@section framecrc
+
+Per-frame CRC (Cyclic Redundancy Check) testing format.
+
+This muxer computes and prints the Adler-32 CRC for each decoded audio
+and video frame. By default audio frames are converted to signed
+16-bit raw audio and video frames to raw video before computing the
+CRC.
+
+The output of the muxer consists of a line for each audio and video
+frame of the form: @var{stream_index}, @var{frame_dts},
+@var{frame_size}, 0x@var{CRC}, where @var{CRC} is a hexadecimal
+number 0-padded to 8 digits containing the CRC of the decoded frame.
+
+For example to compute the CRC of each decoded frame in the input, and
+store it in the file @file{out.crc}:
+@example
+ffmpeg -i INPUT -f framecrc out.crc
+@end example
+
+You can print the CRC of each decoded frame to stdout with the command:
+@example
+ffmpeg -i INPUT -f framecrc -
+@end example
+
+You can select the output format of each frame with @file{ffmpeg} by
+specifying the audio and video codec and format. For example, to
+compute the CRC of each decoded input audio frame converted to PCM
+unsigned 8-bit and of each decoded input video frame converted to
+MPEG-2 video, use the command:
+@example
+ffmpeg -i INPUT -acodec pcm_u8 -vcodec mpeg2video -f framecrc -
+@end example
+
+See also the @code{crc} muxer (@pxref{crc}).
+
+@section image2
+
+Image file muxer.
+
+The image file muxer writes video frames to image files.
+
+The output filenames are specified by a pattern, which can be used to
+produce sequentially numbered series of files.
+The pattern may contain the string "%d" or "%0@var{N}d", this string
+specifies the position of the characters representing a numbering in
+the filenames. If the form "%0@var{N}d" is used, the string
+representing the number in each filename is 0-padded to @var{N}
+digits. The literal character '%' can be specified in the pattern with
+the string "%%".
+
+If the pattern contains "%d" or "%0@var{N}d", the first filename of
+the file list specified will contain the number 1, all the following
+numbers will be sequential.
+
+The pattern may contain a suffix which is used to automatically
+determine the format of the image files to write.
+
+For example the pattern "img-%03d.bmp" will specify a sequence of
+filenames of the form @file{img-001.bmp}, @file{img-002.bmp}, ...,
+@file{img-010.bmp}, etc.
+The pattern "img%%-%d.jpg" will specify a sequence of filenames of the
+form @file{img%-1.jpg}, @file{img%-2.jpg}, ..., @file{img%-10.jpg},
+etc.
+
+The following example shows how to use @file{ffmpeg} for creating a
+sequence of files @file{img-001.jpeg}, @file{img-002.jpeg}, ...,
+taking one image every second from the input video:
+@example
+ffmpeg -i in.avi -r 1 -f image2 'img-%03d.jpeg'
+@end example
+
+Note that with @file{ffmpeg}, if the format is not specified with the
+@code{-f} option and the output filename specifies an image file
+format, the image2 muxer is automatically selected, so the previous
+command can be written as:
+@example
+ffmpeg -i in.avi -r 1 'img-%03d.jpeg'
+@end example
+
+Note also that the pattern must not necessarily contain "%d" or
+"%0@var{N}d", for example to create a single image file
+@file{img.jpeg} from the input video you can employ the command:
+@example
+ffmpeg -i in.avi -f image2 -vframes 1 img.jpeg
+@end example
+
+@section mpegts
+
+MPEG transport stream muxer.
+
+This muxer implements ISO 13818-1 and part of ETSI EN 300 468.
+
+The muxer options are:
+
+@table @option
+@item -mpegts_original_network_id @var{number}
+Set the original_network_id (default 0x0001). This is unique identifier
+of a network in DVB. Its main use is in the unique identification of a
+service through the path Original_Network_ID, Transport_Stream_ID.
+@item -mpegts_transport_stream_id @var{number}
+Set the transport_stream_id (default 0x0001). This identifies a
+transponder in DVB.
+@item -mpegts_service_id @var{number}
+Set the service_id (default 0x0001) also known as program in DVB.
+@item -mpegts_pmt_start_pid @var{number}
+Set the first PID for PMT (default 0x1000, max 0x1f00).
+@item -mpegts_start_pid @var{number}
+Set the first PID for data packets (default 0x0100, max 0x0f00).
+@end table
+
+The recognized metadata settings in mpegts muxer are @code{service_provider}
+and @code{service_name}. If they are not set the default for
+@code{service_provider} is "FFmpeg" and the default for
+@code{service_name} is "Service01".
+
+@example
+ffmpeg -i file.mpg -acodec copy -vcodec copy \
+ -mpegts_original_network_id 0x1122 \
+ -mpegts_transport_stream_id 0x3344 \
+ -mpegts_service_id 0x5566 \
+ -mpegts_pmt_start_pid 0x1500 \
+ -mpegts_start_pid 0x150 \
+ -metadata service_provider="Some provider" \
+ -metadata service_name="Some Channel" \
+ -y out.ts
+@end example
+
+@section null
+
+Null muxer.
+
+This muxer does not generate any output file, it is mainly useful for
+testing or benchmarking purposes.
+
+For example to benchmark decoding with @file{ffmpeg} you can use the
+command:
+@example
+ffmpeg -benchmark -i INPUT -f null out.null
+@end example
+
+Note that the above command does not read or write the @file{out.null}
+file, but specifying the output file is required by the @file{ffmpeg}
+syntax.
+
+Alternatively you can write the command as:
+@example
+ffmpeg -benchmark -i INPUT -f null -
+@end example
+
@c man end MUXERS
diff --git a/mplayer/ffmpeg/doc/optimization.txt b/mplayer/ffmpeg/doc/optimization.txt
index 5d512359..08954f99 100644
--- a/mplayer/ffmpeg/doc/optimization.txt
+++ b/mplayer/ffmpeg/doc/optimization.txt
@@ -17,8 +17,8 @@ Understanding these overoptimized functions:
As many functions tend to be a bit difficult to understand because
of optimizations, it can be hard to optimize them further, or write
architecture-specific versions. It is recommended to look at older
-revisions of the interesting files (for a web frontend try ViewVC at
-http://svn.ffmpeg.org/ffmpeg/trunk/).
+revisions of the interesting files (web frontends for the various FFmpeg
+branches are listed at http://ffmpeg.org/download.html).
Alternatively, look into the other architecture-specific versions in
the x86/, ppc/, alpha/ subdirectories. Even if you don't exactly
comprehend the instructions, it could help understanding the functions
diff --git a/mplayer/ffmpeg/doc/soc.txt b/mplayer/ffmpeg/doc/soc.txt
index 8b4a86db..79d77d1c 100644
--- a/mplayer/ffmpeg/doc/soc.txt
+++ b/mplayer/ffmpeg/doc/soc.txt
@@ -9,14 +9,14 @@ it's a little late for this year's soc (2006).
The Goal:
Our goal in respect to soc is and must be of course exactly one thing and
that is to improve FFmpeg, to reach this goal, code must
-* conform to the svn policy and patch submission guidelines
+* conform to the development policy and patch submission guidelines
* must improve FFmpeg somehow (faster, smaller, "better",
more codecs supported, fewer bugs, cleaner, ...)
for mentors and other developers to help students to reach that goal it is
essential that changes to their codebase are publicly visible, clean and
easy reviewable that again leads us to:
-* use of a revision control system like svn
+* use of a revision control system like git
* separation of cosmetic from non-cosmetic changes (this is almost entirely
ignored by mentors and students in soc 2006 which might lead to a suprise
when the code will be reviewed at the end before a possible inclusion in
diff --git a/mplayer/ffmpeg/ffmpeg.c b/mplayer/ffmpeg/ffmpeg.c
index 691b73e1..e3dda9de 100644
--- a/mplayer/ffmpeg/ffmpeg.c
+++ b/mplayer/ffmpeg/ffmpeg.c
@@ -36,9 +36,9 @@
#include "libswscale/swscale.h"
#include "libavcodec/opt.h"
#include "libavcodec/audioconvert.h"
-#include "libavcore/audioconvert.h"
-#include "libavcore/parseutils.h"
-#include "libavcore/samplefmt.h"
+#include "libavutil/audioconvert.h"
+#include "libavutil/parseutils.h"
+#include "libavutil/samplefmt.h"
#include "libavutil/colorspace.h"
#include "libavutil/fifo.h"
#include "libavutil/intreadwrite.h"
@@ -505,25 +505,11 @@ static int ffmpeg_exit(int ret)
/* close files */
for(i=0;ioformat->flags & AVFMT_NOFILE) && s->pb)
- url_fclose(s->pb);
- for(j=0;jnb_streams;j++) {
- av_metadata_free(&s->streams[j]->metadata);
- av_free(s->streams[j]->codec);
- av_free(s->streams[j]->info);
- av_free(s->streams[j]);
- }
- for(j=0;jnb_programs;j++) {
- av_metadata_free(&s->programs[j]->metadata);
- }
- for(j=0;jnb_chapters;j++) {
- av_metadata_free(&s->chapters[j]->metadata);
- }
- av_metadata_free(&s->metadata);
- av_free(s);
+ avio_close(s->pb);
+ avformat_free_context(s);
av_free(output_streams_for_file[i]);
}
for(i=0;icodec->sample_fmt)
break;
}
- if(*p == -1)
+ if (*p == -1) {
+ av_log(NULL, AV_LOG_WARNING,
+ "Incompatible sample format '%s' for codec '%s', auto-selecting format '%s'\n",
+ av_get_sample_fmt_name(st->codec->sample_fmt),
+ codec->name,
+ av_get_sample_fmt_name(codec->sample_fmts[0]));
st->codec->sample_fmt = codec->sample_fmts[0];
+ }
}
}
@@ -707,11 +698,6 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename)
choose_pixel_fmt(st, codec);
}
- if(!st->codec->thread_count)
- st->codec->thread_count = 1;
- if(st->codec->thread_count>1)
- avcodec_thread_init(st->codec, st->codec->thread_count);
-
if(st->codec->flags & CODEC_FLAG_BITEXACT)
nopts = 1;
@@ -1547,7 +1533,8 @@ static int output_packet(AVInputStream *ist, int ist_index,
decoded_data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
/* XXX: allocate picture correctly */
avcodec_get_frame_defaults(&picture);
- ist->st->codec->reordered_opaque = pkt_pts;
+ avpkt.pts = pkt_pts;
+ avpkt.dts = ist->pts;
pkt_pts = AV_NOPTS_VALUE;
ret = avcodec_decode_video2(ist->st->codec,
@@ -1559,7 +1546,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
/* no picture yet */
goto discard_packet;
}
- ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, picture.reordered_opaque, ist->pts);
+ ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, picture.pkt_pts, picture.pkt_dts);
if (ist->st->codec->time_base.num != 0) {
int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
ist->next_pts += ((int64_t)AV_TIME_BASE *
@@ -1990,7 +1977,7 @@ static int transcode(AVFormatContext **output_files,
for(i=0;inb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {
- dump_format(output_files[i], i, output_files[i]->filename, 1);
+ av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Output file #%d does not contain any stream\n", i);
ret = AVERROR(EINVAL);
goto fail;
@@ -2041,7 +2028,7 @@ static int transcode(AVFormatContext **output_files,
/* Sanity check that the stream types match */
if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) {
int i= ost->file_index;
- dump_format(output_files[i], i, output_files[i]->filename, 1);
+ av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n",
stream_maps[n].file_index, stream_maps[n].stream_index,
ost->file_index, ost->index);
@@ -2092,7 +2079,7 @@ static int transcode(AVFormatContext **output_files,
}
if (!found) {
int i= ost->file_index;
- dump_format(output_files[i], i, output_files[i]->filename, 1);
+ av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n",
ost->file_index, ost->index);
ffmpeg_exit(1);
@@ -2472,7 +2459,7 @@ static int transcode(AVFormatContext **output_files,
/* dump the file output parameters - cannot be done before in case
of stream copy */
for(i=0;ifilename, 1);
+ av_dump_format(output_files[i], i, output_files[i]->filename, 1);
}
/* dump the stream mapping */
@@ -2591,7 +2578,8 @@ static int transcode(AVFormatContext **output_files,
memset(no_packet, 0, sizeof(no_packet));
if (do_pkt_dump) {
- av_pkt_dump_log(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump);
+ av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
+ is->streams[pkt.stream_index]);
}
/* the following test is needed in case new streams appear
dynamically in stream : we ignore them */
@@ -2692,10 +2680,7 @@ static int transcode(AVFormatContext **output_files,
}
}
#if CONFIG_AVFILTER
- if (graph) {
- avfilter_graph_free(graph);
- av_freep(&graph);
- }
+ avfilter_graph_free(&graph);
#endif
/* finished ! */
@@ -3007,7 +2992,7 @@ static void parse_meta_type(char *arg, char *type, int *index, char **endptr)
*type = 'g';
}
-static void opt_map_meta_data(const char *arg)
+static void opt_map_metadata(const char *arg)
{
AVMetaDataMap *m, *m1;
char *p;
@@ -3033,6 +3018,13 @@ static void opt_map_meta_data(const char *arg)
metadata_chapters_autocopy = 0;
}
+static void opt_map_meta_data(const char *arg)
+{
+ fprintf(stderr, "-map_meta_data is deprecated and will be removed soon. "
+ "Use -map_metadata instead.\n");
+ opt_map_metadata(arg);
+}
+
static void opt_map_chapters(const char *arg)
{
AVChapterMap *c;
@@ -3240,7 +3232,7 @@ static void opt_input_file(const char *filename)
for(i=0;inb_streams;i++) {
AVStream *st = ic->streams[i];
AVCodecContext *dec = st->codec;
- avcodec_thread_init(dec, thread_count);
+ dec->thread_count = thread_count;
input_codecs = grow_array(input_codecs, sizeof(*input_codecs), &nb_input_codecs, nb_input_codecs + 1);
switch (dec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
@@ -3318,7 +3310,7 @@ static void opt_input_file(const char *filename)
input_files_ts_offset[nb_input_files] = input_ts_offset - (copy_ts ? 0 : timestamp);
/* dump the file content */
if (verbose >= 0)
- dump_format(ic, nb_input_files, filename, 0);
+ av_dump_format(ic, nb_input_files, filename, 0);
nb_input_files++;
@@ -3398,7 +3390,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx)
ost->bitstream_filters = video_bitstream_filters;
video_bitstream_filters= NULL;
- avcodec_thread_init(st->codec, thread_count);
+ st->codec->thread_count= thread_count;
video_enc = st->codec;
@@ -3545,7 +3537,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx)
ost->bitstream_filters = audio_bitstream_filters;
audio_bitstream_filters= NULL;
- avcodec_thread_init(st->codec, thread_count);
+ st->codec->thread_count= thread_count;
audio_enc = st->codec;
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -3798,7 +3790,7 @@ static void opt_output_file(const char *filename)
}
/* open the file */
- if ((err = url_fopen(&oc->pb, filename, URL_WRONLY)) < 0) {
+ if ((err = avio_open(&oc->pb, filename, URL_WRONLY)) < 0) {
print_error(filename, err);
ffmpeg_exit(1);
}
@@ -4191,7 +4183,10 @@ static const OptionDef options[] = {
{ "i", HAS_ARG, {(void*)opt_input_file}, "input file name", "filename" },
{ "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" },
{ "map", HAS_ARG | OPT_EXPERT, {(void*)opt_map}, "set input stream mapping", "file:stream[:syncfile:syncstream]" },
- { "map_meta_data", HAS_ARG | OPT_EXPERT, {(void*)opt_map_meta_data}, "set meta data information of outfile from infile", "outfile[,metadata]:infile[,metadata]" },
+ { "map_meta_data", HAS_ARG | OPT_EXPERT, {(void*)opt_map_meta_data}, "DEPRECATED set meta data information of outfile from infile",
+ "outfile[,metadata]:infile[,metadata]" },
+ { "map_metadata", HAS_ARG | OPT_EXPERT, {(void*)opt_map_metadata}, "set metadata information of outfile from infile",
+ "outfile[,metadata]:infile[,metadata]" },
{ "map_chapters", HAS_ARG | OPT_EXPERT, {(void*)opt_map_chapters}, "set chapters mapping", "outfile:infile" },
{ "t", OPT_FUNC2 | HAS_ARG, {(void*)opt_recording_time}, "record or transcode \"duration\" seconds of audio/video", "duration" },
{ "fs", HAS_ARG | OPT_INT64, {(void*)&limit_filesize}, "set the limit file size in bytes", "limit_size" }, //
diff --git a/mplayer/ffmpeg/ffplay.c b/mplayer/ffmpeg/ffplay.c
index 840df666..e71c9c93 100644
--- a/mplayer/ffmpeg/ffplay.c
+++ b/mplayer/ffmpeg/ffplay.c
@@ -28,9 +28,9 @@
#include "libavutil/avstring.h"
#include "libavutil/colorspace.h"
#include "libavutil/pixdesc.h"
-#include "libavcore/imgutils.h"
-#include "libavcore/parseutils.h"
-#include "libavcore/samplefmt.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/parseutils.h"
+#include "libavutil/samplefmt.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
@@ -58,6 +58,7 @@
const char program_name[] = "FFplay";
const int program_birth_year = 2003;
+//#define DEBUG
//#define DEBUG_SYNC
#define MAX_QUEUE_SIZE (15 * 1024 * 1024)
@@ -711,40 +712,6 @@ static void video_image_display(VideoState *is)
if (aspect_ratio <= 0.0)
aspect_ratio = 1.0;
aspect_ratio *= (float)vp->width / (float)vp->height;
- /* if an active format is indicated, then it overrides the
- mpeg format */
-#if 0
- if (is->video_st->codec->dtg_active_format != is->dtg_active_format) {
- is->dtg_active_format = is->video_st->codec->dtg_active_format;
- printf("dtg_active_format=%d\n", is->dtg_active_format);
- }
-#endif
-#if 0
- switch(is->video_st->codec->dtg_active_format) {
- case FF_DTG_AFD_SAME:
- default:
- /* nothing to do */
- break;
- case FF_DTG_AFD_4_3:
- aspect_ratio = 4.0 / 3.0;
- break;
- case FF_DTG_AFD_16_9:
- aspect_ratio = 16.0 / 9.0;
- break;
- case FF_DTG_AFD_14_9:
- aspect_ratio = 14.0 / 9.0;
- break;
- case FF_DTG_AFD_4_3_SP_14_9:
- aspect_ratio = 14.0 / 9.0;
- break;
- case FF_DTG_AFD_16_9_SP_14_9:
- aspect_ratio = 14.0 / 9.0;
- break;
- case FF_DTG_AFD_SP_4_3:
- aspect_ratio = 4.0 / 3.0;
- break;
- }
-#endif
if (is->subtitle_st)
{
@@ -1569,18 +1536,17 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke
return 0;
}
- is->video_st->codec->reordered_opaque = pkt->pts;
len1 = avcodec_decode_video2(is->video_st->codec,
frame, &got_picture,
pkt);
if (got_picture) {
if (decoder_reorder_pts == -1) {
- *pts = guess_correct_pts(&is->pts_ctx, frame->reordered_opaque, pkt->dts);
+ *pts = guess_correct_pts(&is->pts_ctx, frame->pkt_pts, frame->pkt_dts);
} else if (decoder_reorder_pts) {
- *pts = frame->reordered_opaque;
+ *pts = frame->pkt_pts;
} else {
- *pts = pkt->dts;
+ *pts = frame->pkt_dts;
}
if (*pts == AV_NOPTS_VALUE) {
@@ -1694,6 +1660,7 @@ static int input_init(AVFilterContext *ctx, const char *args, void *opaque)
codec->get_buffer = input_get_buffer;
codec->release_buffer = input_release_buffer;
codec->reget_buffer = input_reget_buffer;
+ codec->thread_safe_callbacks = 1;
}
priv->frame = avcodec_alloc_frame();
@@ -1782,30 +1749,20 @@ static AVFilter input_filter =
{ .name = NULL }},
};
-#endif /* CONFIG_AVFILTER */
-
-static int video_thread(void *arg)
+static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters)
{
- VideoState *is = arg;
- AVFrame *frame= avcodec_alloc_frame();
- int64_t pts_int;
- double pts;
- int ret;
-
-#if CONFIG_AVFILTER
- int64_t pos;
char sws_flags_str[128];
+ int ret;
FFSinkContext ffsink_ctx = { .pix_fmt = PIX_FMT_YUV420P };
AVFilterContext *filt_src = NULL, *filt_out = NULL;
- AVFilterGraph *graph = avfilter_graph_alloc();
snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
graph->scale_sws_opts = av_strdup(sws_flags_str);
- if (avfilter_graph_create_filter(&filt_src, &input_filter, "src",
- NULL, is, graph) < 0)
+ if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src",
+ NULL, is, graph)) < 0)
goto the_end;
- if (avfilter_graph_create_filter(&filt_out, &ffsink, "out",
- NULL, &ffsink_ctx, graph) < 0)
+ if ((ret = avfilter_graph_create_filter(&filt_out, &ffsink, "out",
+ NULL, &ffsink_ctx, graph)) < 0)
goto the_end;
if(vfilters) {
@@ -1822,17 +1779,40 @@ static int video_thread(void *arg)
inputs->pad_idx = 0;
inputs->next = NULL;
- if (avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL) < 0)
+ if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
goto the_end;
av_freep(&vfilters);
} else {
- if(avfilter_link(filt_src, 0, filt_out, 0) < 0) goto the_end;
+ if ((ret = avfilter_link(filt_src, 0, filt_out, 0)) < 0)
+ goto the_end;
}
- if (avfilter_graph_config(graph, NULL) < 0)
+ if ((ret = avfilter_graph_config(graph, NULL)) < 0)
goto the_end;
is->out_video_filter = filt_out;
+the_end:
+ return ret;
+}
+
+#endif /* CONFIG_AVFILTER */
+
+static int video_thread(void *arg)
+{
+ VideoState *is = arg;
+ AVFrame *frame= avcodec_alloc_frame();
+ int64_t pts_int;
+ double pts;
+ int ret;
+
+#if CONFIG_AVFILTER
+ AVFilterGraph *graph = avfilter_graph_alloc();
+ AVFilterContext *filt_out = NULL;
+ int64_t pos;
+
+ if ((ret = configure_video_filters(graph, is, vfilters)) < 0)
+ goto the_end;
+ filt_out = is->out_video_filter;
#endif
for(;;) {
@@ -1853,12 +1833,12 @@ static int video_thread(void *arg)
}
if (av_cmp_q(tb, is->video_st->time_base)) {
- int64_t pts1 = pts_int;
+ av_unused int64_t pts1 = pts_int;
pts_int = av_rescale_q(pts_int, tb, is->video_st->time_base);
- av_log(NULL, AV_LOG_DEBUG, "video_thread(): "
- "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n",
- tb.num, tb.den, pts1,
- is->video_st->time_base.num, is->video_st->time_base.den, pts_int);
+ av_dlog(NULL, "video_thread(): "
+ "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n",
+ tb.num, tb.den, pts1,
+ is->video_st->time_base.num, is->video_st->time_base.den, pts_int);
}
#else
ret = get_video_frame(is, frame, &pts_int, &pkt);
@@ -1886,8 +1866,7 @@ static int video_thread(void *arg)
}
the_end:
#if CONFIG_AVFILTER
- avfilter_graph_free(graph);
- av_freep(&graph);
+ avfilter_graph_free(&graph);
#endif
av_free(frame);
return 0;
@@ -2247,7 +2226,7 @@ static int stream_component_open(VideoState *is, int stream_index)
avctx->skip_loop_filter= skip_loop_filter;
avctx->error_recognition= error_recognition;
avctx->error_concealment= error_concealment;
- avcodec_thread_init(avctx, thread_count);
+ avctx->thread_count= thread_count;
set_context_opts(avctx, avcodec_opts[avctx->codec_type], 0, codec);
@@ -2485,7 +2464,7 @@ static int decode_thread(void *arg)
st_index[AVMEDIA_TYPE_VIDEO]),
NULL, 0);
if (show_status) {
- dump_format(ic, 0, is->filename, 0);
+ av_dump_format(ic, 0, is->filename, 0);
}
/* open the streams */
diff --git a/mplayer/ffmpeg/ffpresets/libx264-fast.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-fast.ffpreset
index cac6534e..0fc1f224 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-fast.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-fast.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=2
diff --git a/mplayer/ffmpeg/ffpresets/libx264-fast_firstpass.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-fast_firstpass.ffpreset
index 65ec0112..cdcbbbf2 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-fast_firstpass.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-fast_firstpass.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-faster.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-faster.ffpreset
index a32eed3c..3156cd80 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-faster.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-faster.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=2
diff --git a/mplayer/ffmpeg/ffpresets/libx264-faster_firstpass.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-faster_firstpass.ffpreset
index c777eb4e..9bcf18ae 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-faster_firstpass.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-faster_firstpass.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-lossless_fast.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-lossless_fast.ffpreset
index ea08d3c0..b7696b5b 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-lossless_fast.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-lossless_fast.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
directpred=1
flags2=+fastpskip
diff --git a/mplayer/ffmpeg/ffpresets/libx264-lossless_max.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-lossless_max.ffpreset
index 8c049c9c..75c387f1 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-lossless_max.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-lossless_max.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
refs=16
directpred=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-lossless_medium.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-lossless_medium.ffpreset
index 558be6c9..116e3343 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-lossless_medium.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-lossless_medium.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
directpred=1
flags2=+fastpskip
diff --git a/mplayer/ffmpeg/ffpresets/libx264-lossless_slow.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-lossless_slow.ffpreset
index ff641cf4..0d496f6e 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-lossless_slow.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-lossless_slow.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
refs=2
directpred=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-lossless_slower.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-lossless_slower.ffpreset
index 854f74b2..672e0cd6 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-lossless_slower.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-lossless_slower.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
refs=4
directpred=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-lossless_ultrafast.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-lossless_ultrafast.ffpreset
index 1c429f21..a2eda65e 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-lossless_ultrafast.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-lossless_ultrafast.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
directpred=1
flags2=+fastpskip
diff --git a/mplayer/ffmpeg/ffpresets/libx264-medium.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-medium.ffpreset
index 039f1d60..3c90ec5d 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-medium.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-medium.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=3
diff --git a/mplayer/ffmpeg/ffpresets/libx264-medium_firstpass.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-medium_firstpass.ffpreset
index e4159892..2ad0a9cc 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-medium_firstpass.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-medium_firstpass.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-placebo.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-placebo.ffpreset
index fae2222d..9f4719f7 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-placebo.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-placebo.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=2
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=16
refs=16
diff --git a/mplayer/ffmpeg/ffpresets/libx264-placebo_firstpass.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-placebo_firstpass.ffpreset
index fae2222d..9f4719f7 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-placebo_firstpass.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-placebo_firstpass.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=2
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=16
refs=16
diff --git a/mplayer/ffmpeg/ffpresets/libx264-slow.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-slow.ffpreset
index 0f3f4d4b..dabe0ae1 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-slow.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-slow.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=2
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=5
diff --git a/mplayer/ffmpeg/ffpresets/libx264-slow_firstpass.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-slow_firstpass.ffpreset
index 89e74e45..4af64dbe 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-slow_firstpass.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-slow_firstpass.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=2
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-slower.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-slower.ffpreset
index f3a412c0..239ee68c 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-slower.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-slower.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=2
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=8
diff --git a/mplayer/ffmpeg/ffpresets/libx264-slower_firstpass.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-slower_firstpass.ffpreset
index aa1eb1e9..4b5b420c 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-slower_firstpass.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-slower_firstpass.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=2
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-superfast.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-superfast.ffpreset
index bcd45993..fb2ab8c4 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-superfast.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-superfast.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-superfast_firstpass.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-superfast_firstpass.ffpreset
index ef06b1d5..55ff9a2b 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-superfast_firstpass.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-superfast_firstpass.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-ultrafast.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-ultrafast.ffpreset
index b6d20808..28dc0eb8 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-ultrafast.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-ultrafast.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=0
i_qfactor=0.71
b_strategy=0
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=0
refs=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-ultrafast_firstpass.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-ultrafast_firstpass.ffpreset
index b6d20808..28dc0eb8 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-ultrafast_firstpass.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-ultrafast_firstpass.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=0
i_qfactor=0.71
b_strategy=0
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=0
refs=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-veryfast.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-veryfast.ffpreset
index 16ca594a..bfa3d8fa 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-veryfast.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-veryfast.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-veryfast_firstpass.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-veryfast_firstpass.ffpreset
index 39eaf3e2..ac2332df 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-veryfast_firstpass.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-veryfast_firstpass.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=3
refs=1
diff --git a/mplayer/ffmpeg/ffpresets/libx264-veryslow.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-veryslow.ffpreset
index a0606255..e07aeb82 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-veryslow.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-veryslow.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=2
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=8
refs=16
diff --git a/mplayer/ffmpeg/ffpresets/libx264-veryslow_firstpass.ffpreset b/mplayer/ffmpeg/ffpresets/libx264-veryslow_firstpass.ffpreset
index 6e7079bb..e17c04b2 100644
--- a/mplayer/ffmpeg/ffpresets/libx264-veryslow_firstpass.ffpreset
+++ b/mplayer/ffmpeg/ffpresets/libx264-veryslow_firstpass.ffpreset
@@ -11,8 +11,8 @@ sc_threshold=40
i_qfactor=0.71
b_strategy=2
qcomp=0.6
-qmin=10
-qmax=51
+qmin=0
+qmax=69
qdiff=4
bf=8
refs=1
diff --git a/mplayer/ffmpeg/ffprobe.c b/mplayer/ffmpeg/ffprobe.c
index 2c99e5a6..94b1d9b2 100644
--- a/mplayer/ffmpeg/ffprobe.c
+++ b/mplayer/ffmpeg/ffprobe.c
@@ -277,7 +277,7 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
return err;
}
- dump_format(fmt_ctx, 0, filename, 0);
+ av_dump_format(fmt_ctx, 0, filename, 0);
/* bind a decoder to each input stream */
for (i = 0; i < fmt_ctx->nb_streams; i++) {
diff --git a/mplayer/ffmpeg/ffserver.c b/mplayer/ffmpeg/ffserver.c
index 9a324080..e5c4ac23 100644
--- a/mplayer/ffmpeg/ffserver.c
+++ b/mplayer/ffmpeg/ffserver.c
@@ -36,7 +36,7 @@
#include "libavutil/avstring.h"
#include "libavutil/lfg.h"
#include "libavutil/random_seed.h"
-#include "libavcore/parseutils.h"
+#include "libavutil/parseutils.h"
#include "libavcodec/opt.h"
#include
#include
@@ -163,7 +163,7 @@ typedef struct HTTPContext {
/* RTSP state specific */
uint8_t *pb_buffer; /* XXX: use that in all the code */
- ByteIOContext *pb;
+ AVIOContext *pb;
int seq; /* RTSP sequence number */
/* RTP state specific */
@@ -692,8 +692,8 @@ static int http_server(void)
second to handle timeouts */
do {
ret = poll(poll_table, poll_entry - poll_table, delay);
- if (ret < 0 && ff_neterrno() != FF_NETERROR(EAGAIN) &&
- ff_neterrno() != FF_NETERROR(EINTR))
+ if (ret < 0 && ff_neterrno() != AVERROR(EAGAIN) &&
+ ff_neterrno() != AVERROR(EINTR))
return -1;
} while (ret < 0);
@@ -916,8 +916,8 @@ static int handle_connection(HTTPContext *c)
read_loop:
len = recv(c->fd, c->buffer_ptr, 1, 0);
if (len < 0) {
- if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
- ff_neterrno() != FF_NETERROR(EINTR))
+ if (ff_neterrno() != AVERROR(EAGAIN) &&
+ ff_neterrno() != AVERROR(EINTR))
return -1;
} else if (len == 0) {
return -1;
@@ -952,8 +952,8 @@ static int handle_connection(HTTPContext *c)
return 0;
len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
if (len < 0) {
- if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
- ff_neterrno() != FF_NETERROR(EINTR)) {
+ if (ff_neterrno() != AVERROR(EAGAIN) &&
+ ff_neterrno() != AVERROR(EINTR)) {
/* error : close connection */
av_freep(&c->pb_buffer);
return -1;
@@ -1022,8 +1022,8 @@ static int handle_connection(HTTPContext *c)
return 0;
len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
if (len < 0) {
- if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
- ff_neterrno() != FF_NETERROR(EINTR)) {
+ if (ff_neterrno() != AVERROR(EAGAIN) &&
+ ff_neterrno() != AVERROR(EINTR)) {
/* error : close connection */
av_freep(&c->pb_buffer);
return -1;
@@ -1049,8 +1049,8 @@ static int handle_connection(HTTPContext *c)
len = send(c->fd, c->packet_buffer_ptr,
c->packet_buffer_end - c->packet_buffer_ptr, 0);
if (len < 0) {
- if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
- ff_neterrno() != FF_NETERROR(EINTR)) {
+ if (ff_neterrno() != AVERROR(EAGAIN) &&
+ ff_neterrno() != AVERROR(EINTR)) {
/* error : close connection */
av_freep(&c->packet_buffer);
return -1;
@@ -1854,7 +1854,7 @@ static int http_parse_request(HTTPContext *c)
return 0;
}
-static void fmt_bytecount(ByteIOContext *pb, int64_t count)
+static void fmt_bytecount(AVIOContext *pb, int64_t count)
{
static const char *suffix = " kMGTP";
const char *s;
@@ -1871,7 +1871,7 @@ static void compute_status(HTTPContext *c)
char *p;
time_t ti;
int i, len;
- ByteIOContext *pb;
+ AVIOContext *pb;
if (url_open_dyn_buf(&pb) < 0) {
/* XXX: return an error ? */
@@ -2135,11 +2135,10 @@ static int open_input_stream(HTTPContext *c, const char *info)
strcpy(input_filename, c->stream->feed->feed_filename);
buf_size = FFM_PACKET_SIZE;
/* compute position (absolute time) */
- if (find_info_tag(buf, sizeof(buf), "date", info)) {
- stream_pos = parse_date(buf, 0);
- if (stream_pos == INT64_MIN)
- return -1;
- } else if (find_info_tag(buf, sizeof(buf), "buffer", info)) {
+ if (av_find_info_tag(buf, sizeof(buf), "date", info)) {
+ if ((ret = av_parse_time(&stream_pos, buf, 0)) < 0)
+ return ret;
+ } else if (av_find_info_tag(buf, sizeof(buf), "buffer", info)) {
int prebuffer = strtol(buf, 0, 10);
stream_pos = av_gettime() - prebuffer * (int64_t)1000000;
} else
@@ -2148,10 +2147,9 @@ static int open_input_stream(HTTPContext *c, const char *info)
strcpy(input_filename, c->stream->feed_filename);
buf_size = 0;
/* compute position (relative time) */
- if (find_info_tag(buf, sizeof(buf), "date", info)) {
- stream_pos = parse_date(buf, 1);
- if (stream_pos == INT64_MIN)
- return -1;
+ if (av_find_info_tag(buf, sizeof(buf), "date", info)) {
+ if ((ret = av_parse_time(&stream_pos, buf, 1)) < 0)
+ return ret;
} else
stream_pos = 0;
}
@@ -2493,7 +2491,7 @@ static int http_send_data(HTTPContext *c)
if (c->rtp_protocol == RTSP_LOWER_TRANSPORT_TCP) {
/* RTP packets are sent inside the RTSP TCP connection */
- ByteIOContext *pb;
+ AVIOContext *pb;
int interleaved_index, size;
uint8_t header[4];
HTTPContext *rtsp_c;
@@ -2516,10 +2514,10 @@ static int http_send_data(HTTPContext *c)
header[1] = interleaved_index;
header[2] = len >> 8;
header[3] = len;
- put_buffer(pb, header, 4);
+ avio_write(pb, header, 4);
/* write RTP packet data */
c->buffer_ptr += 4;
- put_buffer(pb, c->buffer_ptr, len);
+ avio_write(pb, c->buffer_ptr, len);
size = url_close_dyn_buf(pb, &c->packet_buffer);
/* prepare asynchronous TCP sending */
rtsp_c->packet_buffer_ptr = c->packet_buffer;
@@ -2552,8 +2550,8 @@ static int http_send_data(HTTPContext *c)
/* TCP data output */
len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
if (len < 0) {
- if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
- ff_neterrno() != FF_NETERROR(EINTR))
+ if (ff_neterrno() != AVERROR(EAGAIN) &&
+ ff_neterrno() != AVERROR(EINTR))
/* error : close connection */
return -1;
else
@@ -2626,8 +2624,8 @@ static int http_receive_data(HTTPContext *c)
len = recv(c->fd, c->buffer_ptr, 1, 0);
if (len < 0) {
- if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
- ff_neterrno() != FF_NETERROR(EINTR))
+ if (ff_neterrno() != AVERROR(EAGAIN) &&
+ ff_neterrno() != AVERROR(EINTR))
/* error : close connection */
goto fail;
return 0;
@@ -2653,8 +2651,8 @@ static int http_receive_data(HTTPContext *c)
len = recv(c->fd, c->buffer_ptr,
FFMIN(c->chunk_size, c->buffer_end - c->buffer_ptr), 0);
if (len < 0) {
- if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
- ff_neterrno() != FF_NETERROR(EINTR))
+ if (ff_neterrno() != AVERROR(EAGAIN) &&
+ ff_neterrno() != AVERROR(EINTR))
/* error : close connection */
goto fail;
} else if (len == 0)
@@ -2714,7 +2712,7 @@ static int http_receive_data(HTTPContext *c)
} else {
/* We have a header in our hands that contains useful data */
AVFormatContext *s = NULL;
- ByteIOContext *pb;
+ AVIOContext *pb;
AVInputFormat *fmt_in;
int i;
@@ -3020,7 +3018,7 @@ static void rtsp_cmd_describe(HTTPContext *c, const char *url)
url_fprintf(c->pb, "Content-Type: application/sdp\r\n");
url_fprintf(c->pb, "Content-Length: %d\r\n", content_length);
url_fprintf(c->pb, "\r\n");
- put_buffer(c->pb, content, content_length);
+ avio_write(c->pb, content, content_length);
av_free(content);
}
@@ -3201,7 +3199,7 @@ static HTTPContext *find_rtp_session_with_url(const char *url,
char path1[1024];
const char *path;
char buf[1024];
- int s;
+ int s, len;
rtp_c = find_rtp_session(session_id);
if (!rtp_c)
@@ -3221,6 +3219,10 @@ static HTTPContext *find_rtp_session_with_url(const char *url,
return rtp_c;
}
}
+ len = strlen(path);
+ if (len > 0 && path[len - 1] == '/' &&
+ !strncmp(path, rtp_c->stream->filename, len - 1))
+ return rtp_c;
return NULL;
}
@@ -3487,7 +3489,7 @@ static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec, int cop
fst->priv_data = av_mallocz(sizeof(FeedData));
fst->index = stream->nb_streams;
av_set_pts_info(fst, 33, 1, 90000);
- fst->sample_aspect_ratio = (AVRational){0,1};
+ fst->sample_aspect_ratio = codec->sample_aspect_ratio;
stream->streams[stream->nb_streams++] = fst;
return fst;
}
@@ -3762,7 +3764,7 @@ static void build_feed_streams(void)
}
/* only write the header of the ffm file */
- if (url_fopen(&s->pb, feed->feed_filename, URL_WRONLY) < 0) {
+ if (avio_open(&s->pb, feed->feed_filename, URL_WRONLY) < 0) {
http_log("Could not open output feed file '%s'\n",
feed->feed_filename);
exit(1);
@@ -3781,7 +3783,7 @@ static void build_feed_streams(void)
}
/* XXX: need better api */
av_freep(&s->priv_data);
- url_fclose(s->pb);
+ avio_close(s->pb);
}
/* get feed size and write index */
fd = open(feed->feed_filename, O_RDONLY);
diff --git a/mplayer/ffmpeg/libavcodec/Makefile b/mplayer/ffmpeg/libavcodec/Makefile
index 847036f9..930affbb 100644
--- a/mplayer/ffmpeg/libavcodec/Makefile
+++ b/mplayer/ffmpeg/libavcodec/Makefile
@@ -1,7 +1,7 @@
include $(SUBDIR)../config.mak
NAME = avcodec
-FFLIBS = avcore avutil
+FFLIBS = avutil
HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h
@@ -12,6 +12,7 @@ OBJS = allcodecs.o \
bitstream_filter.o \
dsputil.o \
faanidct.o \
+ fmtconvert.o \
imgconvert.o \
jrevdct.o \
opt.o \
@@ -54,8 +55,10 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \
mpeg4audio.o
OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o
OBJS-$(CONFIG_AC3_DECODER) += ac3dec.o ac3dec_data.o ac3.o
-OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3tab.o ac3.o
-OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3tab.o ac3.o
+OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3tab.o ac3.o \
+ ac3dsp.o
+OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3tab.o ac3.o \
+ ac3dsp.o
OBJS-$(CONFIG_ALAC_DECODER) += alac.o
OBJS-$(CONFIG_ALAC_ENCODER) += alacenc.o
OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o
@@ -414,7 +417,7 @@ OBJS-$(CONFIG_WNV1_DECODER) += wnv1.o
OBJS-$(CONFIG_WS_SND1_DECODER) += ws-snd1.o
OBJS-$(CONFIG_XAN_DPCM_DECODER) += dpcm.o
OBJS-$(CONFIG_XAN_WC3_DECODER) += xan.o
-OBJS-$(CONFIG_XAN_WC4_DECODER) += xan.o
+OBJS-$(CONFIG_XAN_WC4_DECODER) += xxan.o
OBJS-$(CONFIG_XL_DECODER) += xl.o
OBJS-$(CONFIG_XSUB_DECODER) += xsubdec.o
OBJS-$(CONFIG_XSUB_ENCODER) += xsubenc.o
@@ -630,7 +633,6 @@ OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o
# thread libraries
OBJS-$(HAVE_PTHREADS) += pthread.o
OBJS-$(HAVE_W32THREADS) += w32thread.o
-OBJS-$(HAVE_GEKKOTHREADS) += gekkothread.o
OBJS-$(CONFIG_MLIB) += mlib/dsputil_mlib.o \
diff --git a/mplayer/ffmpeg/libavcodec/aac.h b/mplayer/ffmpeg/libavcodec/aac.h
index 714e314c..73bc4084 100644
--- a/mplayer/ffmpeg/libavcodec/aac.h
+++ b/mplayer/ffmpeg/libavcodec/aac.h
@@ -35,6 +35,7 @@
#include "fft.h"
#include "mpeg4audio.h"
#include "sbr.h"
+#include "fmtconvert.h"
#include
@@ -42,6 +43,7 @@
#define MAX_ELEM_ID 16
#define TNS_MAX_ORDER 20
+#define MAX_LTP_LONG_SFB 40
enum RawDataBlockType {
TYPE_SCE,
@@ -129,6 +131,16 @@ typedef struct {
#define SCALE_MAX_DIFF 60 ///< maximum scalefactor difference allowed by standard
#define SCALE_DIFF_ZERO 60 ///< codebook index corresponding to zero scalefactor indices difference
+/**
+ * Long Term Prediction
+ */
+typedef struct {
+ int8_t present;
+ int16_t lag;
+ float coef;
+ int8_t used[MAX_LTP_LONG_SFB];
+} LongTermPrediction;
+
/**
* Individual Channel Stream
*/
@@ -138,6 +150,7 @@ typedef struct {
uint8_t use_kb_window[2]; ///< If set, use Kaiser-Bessel window, otherwise use a sinus window.
int num_window_groups;
uint8_t group_len[8];
+ LongTermPrediction ltp;
const uint16_t *swb_offset; ///< table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular window
const uint8_t *swb_sizes; ///< table of scalefactor band sizes for a particular window
int num_swb; ///< number of scalefactor window bands
@@ -205,14 +218,15 @@ typedef struct {
IndividualChannelStream ics;
TemporalNoiseShaping tns;
Pulse pulse;
- enum BandType band_type[128]; ///< band types
- int band_type_run_end[120]; ///< band type run end points
- float sf[120]; ///< scalefactors
- int sf_idx[128]; ///< scalefactor indices (used by encoder)
- uint8_t zeroes[128]; ///< band is not coded (used by encoder)
- DECLARE_ALIGNED(16, float, coeffs)[1024]; ///< coefficients for IMDCT
- DECLARE_ALIGNED(16, float, saved)[1024]; ///< overlap
- DECLARE_ALIGNED(16, float, ret)[2048]; ///< PCM output
+ enum BandType band_type[128]; ///< band types
+ int band_type_run_end[120]; ///< band type run end points
+ float sf[120]; ///< scalefactors
+ int sf_idx[128]; ///< scalefactor indices (used by encoder)
+ uint8_t zeroes[128]; ///< band is not coded (used by encoder)
+ DECLARE_ALIGNED(16, float, coeffs)[1024]; ///< coefficients for IMDCT
+ DECLARE_ALIGNED(16, float, saved)[1024]; ///< overlap
+ DECLARE_ALIGNED(16, float, ret)[2048]; ///< PCM output
+ DECLARE_ALIGNED(16, int16_t, ltp_state)[3072]; ///< time signal for LTP
PredictorState predictor_state[MAX_PREDICTORS];
} SingleChannelElement;
@@ -267,7 +281,9 @@ typedef struct {
*/
FFTContext mdct;
FFTContext mdct_small;
+ FFTContext mdct_ltp;
DSPContext dsp;
+ FmtConvertContext fmt_conv;
int random_state;
/** @} */
diff --git a/mplayer/ffmpeg/libavcodec/aacdec.c b/mplayer/ffmpeg/libavcodec/aacdec.c
index 21270994..81a94f2f 100644
--- a/mplayer/ffmpeg/libavcodec/aacdec.c
+++ b/mplayer/ffmpeg/libavcodec/aacdec.c
@@ -42,7 +42,7 @@
* Y filterbank - standard
* N (code in SoC repo) filterbank - Scalable Sample Rate
* Y Temporal Noise Shaping
- * N (code in SoC repo) Long Term Prediction
+ * Y Long Term Prediction
* Y intensity stereo
* Y channel coupling
* Y frequency domain prediction
@@ -85,6 +85,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
#include "lpc.h"
#include "aac.h"
@@ -477,6 +478,7 @@ static int decode_audio_specific_config(AACContext *ac,
switch (m4ac->object_type) {
case AOT_AAC_MAIN:
case AOT_AAC_LC:
+ case AOT_AAC_LTP:
if (decode_ga_specific_config(ac, avctx, &gb, m4ac, m4ac->chan_config))
return -1;
break;
@@ -562,6 +564,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
ff_aac_sbr_init();
dsputil_init(&ac->dsp, avctx);
+ ff_fmt_convert_init(&ac->fmt_conv, avctx);
ac->random_state = 0x1f2e3d4c;
@@ -578,8 +581,9 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
ff_aac_scalefactor_code, sizeof(ff_aac_scalefactor_code[0]), sizeof(ff_aac_scalefactor_code[0]),
352);
- ff_mdct_init(&ac->mdct, 11, 1, 1.0);
- ff_mdct_init(&ac->mdct_small, 8, 1, 1.0);
+ ff_mdct_init(&ac->mdct, 11, 1, 1.0);
+ ff_mdct_init(&ac->mdct_small, 8, 1, 1.0);
+ ff_mdct_init(&ac->mdct_ltp, 11, 0, 1.0);
// window initialization
ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
@@ -628,6 +632,20 @@ static int decode_prediction(AACContext *ac, IndividualChannelStream *ics,
return 0;
}
+/**
+ * Decode Long Term Prediction data; reference: table 4.xx.
+ */
+static void decode_ltp(AACContext *ac, LongTermPrediction *ltp,
+ GetBitContext *gb, uint8_t max_sfb)
+{
+ int sfb;
+
+ ltp->lag = get_bits(gb, 11);
+ ltp->coef = ltp_coef[get_bits(gb, 3)] * ac->sf_scale;
+ for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
+ ltp->used[sfb] = get_bits1(gb);
+}
+
/**
* Decode Individual Channel Stream info; reference: table 4.6.
*
@@ -682,9 +700,8 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
memset(ics, 0, sizeof(IndividualChannelStream));
return -1;
} else {
- av_log_missing_feature(ac->avctx, "Predictor bit set but LTP is", 1);
- memset(ics, 0, sizeof(IndividualChannelStream));
- return -1;
+ if ((ics->ltp.present = get_bits(gb, 1)))
+ decode_ltp(ac, &ics->ltp, gb, ics->max_sfb);
}
}
}
@@ -1369,13 +1386,13 @@ static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe)
* [1] mask is decoded from bitstream; [2] mask is all 1s;
* [3] reserved for scalable AAC
*/
-static void apply_intensity_stereo(ChannelElement *cpe, int ms_present)
+static void apply_intensity_stereo(AACContext *ac, ChannelElement *cpe, int ms_present)
{
const IndividualChannelStream *ics = &cpe->ch[1].ics;
SingleChannelElement *sce1 = &cpe->ch[1];
float *coef0 = cpe->ch[0].coeffs, *coef1 = cpe->ch[1].coeffs;
const uint16_t *offsets = ics->swb_offset;
- int g, group, i, k, idx = 0;
+ int g, group, i, idx = 0;
int c;
float scale;
for (g = 0; g < ics->num_window_groups; g++) {
@@ -1388,8 +1405,10 @@ static void apply_intensity_stereo(ChannelElement *cpe, int ms_present)
c *= 1 - 2 * cpe->ms_mask[idx];
scale = c * sce1->sf[idx];
for (group = 0; group < ics->group_len[g]; group++)
- for (k = offsets[i]; k < offsets[i + 1]; k++)
- coef1[group * 128 + k] = scale * coef0[group * 128 + k];
+ ac->dsp.vector_fmul_scalar(coef1 + group * 128 + offsets[i],
+ coef0 + group * 128 + offsets[i],
+ scale,
+ offsets[i + 1] - offsets[i]);
}
} else {
int bt_run_end = sce1->band_type_run_end[idx];
@@ -1418,6 +1437,9 @@ static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe)
i = cpe->ch[1].ics.use_kb_window[0];
cpe->ch[1].ics = cpe->ch[0].ics;
cpe->ch[1].ics.use_kb_window[1] = i;
+ if (cpe->ch[1].ics.predictor_present && (ac->m4ac.object_type != AOT_AAC_MAIN))
+ if ((cpe->ch[1].ics.ltp.present = get_bits(gb, 1)))
+ decode_ltp(ac, &cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb);
ms_present = get_bits(gb, 2);
if (ms_present == 3) {
av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");
@@ -1439,7 +1461,7 @@ static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe)
}
}
- apply_intensity_stereo(cpe, ms_present);
+ apply_intensity_stereo(ac, cpe, ms_present);
return 0;
}
@@ -1657,6 +1679,7 @@ static void apply_tns(float coef[1024], TemporalNoiseShaping *tns,
int w, filt, m, i;
int bottom, top, order, start, end, size, inc;
float lpc[TNS_MAX_ORDER];
+ float tmp[TNS_MAX_ORDER];
for (w = 0; w < ics->num_windows; w++) {
bottom = ics->num_swb;
@@ -1682,14 +1705,121 @@ static void apply_tns(float coef[1024], TemporalNoiseShaping *tns,
}
start += w * 128;
- // ar filter
- for (m = 0; m < size; m++, start += inc)
- for (i = 1; i <= FFMIN(m, order); i++)
- coef[start] -= coef[start - i * inc] * lpc[i - 1];
+ if (decode) {
+ // ar filter
+ for (m = 0; m < size; m++, start += inc)
+ for (i = 1; i <= FFMIN(m, order); i++)
+ coef[start] -= coef[start - i * inc] * lpc[i - 1];
+ } else {
+ // ma filter
+ for (m = 0; m < size; m++, start += inc) {
+ tmp[0] = coef[start];
+ for (i = 1; i <= FFMIN(m, order); i++)
+ coef[start] += tmp[i] * lpc[i - 1];
+ for (i = order; i > 0; i--)
+ tmp[i] = tmp[i - 1];
+ }
+ }
}
}
}
+/**
+ * Apply windowing and MDCT to obtain the spectral
+ * coefficient from the predicted sample by LTP.
+ */
+static void windowing_and_mdct_ltp(AACContext *ac, float *out,
+ float *in, IndividualChannelStream *ics)
+{
+ const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024;
+ const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;
+ const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024;
+ const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;
+
+ if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) {
+ ac->dsp.vector_fmul(in, in, lwindow_prev, 1024);
+ } else {
+ memset(in, 0, 448 * sizeof(float));
+ ac->dsp.vector_fmul(in + 448, in + 448, swindow_prev, 128);
+ memcpy(in + 576, in + 576, 448 * sizeof(float));
+ }
+ if (ics->window_sequence[0] != LONG_START_SEQUENCE) {
+ ac->dsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024);
+ } else {
+ memcpy(in + 1024, in + 1024, 448 * sizeof(float));
+ ac->dsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128);
+ memset(in + 1024 + 576, 0, 448 * sizeof(float));
+ }
+ ff_mdct_calc(&ac->mdct_ltp, out, in);
+}
+
+/**
+ * Apply the long term prediction
+ */
+static void apply_ltp(AACContext *ac, SingleChannelElement *sce)
+{
+ const LongTermPrediction *ltp = &sce->ics.ltp;
+ const uint16_t *offsets = sce->ics.swb_offset;
+ int i, sfb;
+
+ if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
+ float *predTime = sce->ret;
+ float *predFreq = ac->buf_mdct;
+ int16_t num_samples = 2048;
+
+ if (ltp->lag < 1024)
+ num_samples = ltp->lag + 1024;
+ for (i = 0; i < num_samples; i++)
+ predTime[i] = sce->ltp_state[i + 2048 - ltp->lag] * ltp->coef;
+ memset(&predTime[i], 0, (2048 - i) * sizeof(float));
+
+ windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics);
+
+ if (sce->tns.present)
+ apply_tns(predFreq, &sce->tns, &sce->ics, 0);
+
+ for (sfb = 0; sfb < FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB); sfb++)
+ if (ltp->used[sfb])
+ for (i = offsets[sfb]; i < offsets[sfb + 1]; i++)
+ sce->coeffs[i] += predFreq[i];
+ }
+}
+
+/**
+ * Update the LTP buffer for next frame
+ */
+static void update_ltp(AACContext *ac, SingleChannelElement *sce)
+{
+ IndividualChannelStream *ics = &sce->ics;
+ float *saved = sce->saved;
+ float *saved_ltp = sce->coeffs;
+ const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024;
+ const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;
+ int i;
+
+ if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
+ memcpy(saved_ltp, saved, 512 * sizeof(float));
+ memset(saved_ltp + 576, 0, 448 * sizeof(float));
+ ac->dsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64);
+ for (i = 0; i < 64; i++)
+ saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i];
+ } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) {
+ memcpy(saved_ltp, ac->buf_mdct + 512, 448 * sizeof(float));
+ memset(saved_ltp + 576, 0, 448 * sizeof(float));
+ ac->dsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64);
+ for (i = 0; i < 64; i++)
+ saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i];
+ } else { // LONG_STOP or ONLY_LONG
+ ac->dsp.vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512);
+ for (i = 0; i < 512; i++)
+ saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * lwindow[511 - i];
+ }
+
+ memcpy(sce->ltp_state, &sce->ltp_state[1024], 1024 * sizeof(int16_t));
+ ac->fmt_conv.float_to_int16(&(sce->ltp_state[1024]), sce->ret, 1024);
+ ac->fmt_conv.float_to_int16(&(sce->ltp_state[2048]), saved_ltp, 1024);
+}
+
/**
* Conduct IMDCT and windowing.
*/
@@ -1721,19 +1851,19 @@ static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce)
*/
if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) &&
(ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) {
- ac->dsp.vector_fmul_window( out, saved, buf, lwindow_prev, 0, 512);
+ ac->dsp.vector_fmul_window( out, saved, buf, lwindow_prev, 512);
} else {
memcpy( out, saved, 448 * sizeof(float));
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
- ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 0, 64);
- ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 0, 64);
- ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 0, 64);
- ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 0, 64);
- ac->dsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 0, 64);
+ ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 64);
+ ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 64);
+ ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 64);
+ ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 64);
+ ac->dsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 64);
memcpy( out + 448 + 4*128, temp, 64 * sizeof(float));
} else {
- ac->dsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 0, 64);
+ ac->dsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64);
memcpy( out + 576, buf + 64, 448 * sizeof(float));
}
}
@@ -1741,9 +1871,9 @@ static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce)
// buffer update
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
memcpy( saved, temp + 64, 64 * sizeof(float));
- ac->dsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 0, 64);
- ac->dsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 0, 64);
- ac->dsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 0, 64);
+ ac->dsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64);
+ ac->dsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64);
+ ac->dsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64);
memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
} else if (ics->window_sequence[0] == LONG_START_SEQUENCE) {
memcpy( saved, buf + 512, 448 * sizeof(float));
@@ -1855,6 +1985,14 @@ static void spectral_to_sample(AACContext *ac)
if (che) {
if (type <= TYPE_CPE)
apply_channel_coupling(ac, che, type, i, BEFORE_TNS, apply_dependent_coupling);
+ if (ac->m4ac.object_type == AOT_AAC_LTP) {
+ if (che->ch[0].ics.predictor_present) {
+ if (che->ch[0].ics.ltp.present)
+ apply_ltp(ac, &che->ch[0]);
+ if (che->ch[1].ics.ltp.present && type == TYPE_CPE)
+ apply_ltp(ac, &che->ch[1]);
+ }
+ }
if (che->ch[0].tns.present)
apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1);
if (che->ch[1].tns.present)
@@ -1863,8 +2001,12 @@ static void spectral_to_sample(AACContext *ac)
apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling);
if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) {
imdct_and_windowing(ac, &che->ch[0]);
+ if (ac->m4ac.object_type == AOT_AAC_LTP)
+ update_ltp(ac, &che->ch[0]);
if (type == TYPE_CPE) {
imdct_and_windowing(ac, &che->ch[1]);
+ if (ac->m4ac.object_type == AOT_AAC_LTP)
+ update_ltp(ac, &che->ch[1]);
}
if (ac->m4ac.sbr > 0) {
ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret);
@@ -2032,7 +2174,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
*data_size = data_size_tmp;
if (samples)
- ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avctx->channels);
+ ac->fmt_conv.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avctx->channels);
if (ac->output_configured)
ac->output_configured = OC_LOCKED;
@@ -2078,6 +2220,7 @@ static av_cold int aac_decode_close(AVCodecContext *avctx)
ff_mdct_end(&ac->mdct);
ff_mdct_end(&ac->mdct_small);
+ ff_mdct_end(&ac->mdct_ltp);
return 0;
}
@@ -2361,7 +2504,7 @@ AVCodec ff_aac_decoder = {
*/
AVCodec ff_aac_latm_decoder = {
.name = "aac_latm",
- .type = CODEC_TYPE_AUDIO,
+ .type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_AAC_LATM,
.priv_data_size = sizeof(struct LATMContext),
.init = latm_decode_init,
diff --git a/mplayer/ffmpeg/libavcodec/aacdectab.h b/mplayer/ffmpeg/libavcodec/aacdectab.h
index b4307f13..0bccb84c 100644
--- a/mplayer/ffmpeg/libavcodec/aacdectab.h
+++ b/mplayer/ffmpeg/libavcodec/aacdectab.h
@@ -30,11 +30,19 @@
#ifndef AVCODEC_AACDECTAB_H
#define AVCODEC_AACDECTAB_H
-#include "libavcore/audioconvert.h"
+#include "libavutil/audioconvert.h"
#include "aac.h"
#include
+/* @name ltp_coef
+ * Table of the LTP coefficient (multiplied by 2)
+ */
+static const float ltp_coef[8] = {
+ 1.141658, 1.393232, 1.626008, 1.822608,
+ 1.969800, 2.135788, 2.2389202, 2.739066,
+};
+
/* @name tns_tmp2_map
* Tables of the tmp2[] arrays of LPC coefficients used for TNS.
* The suffix _M_N[] indicate the values of coef_compress and coef_res
diff --git a/mplayer/ffmpeg/libavcodec/aacsbr.c b/mplayer/ffmpeg/libavcodec/aacsbr.c
index 9b10bf25..237d51a3 100644
--- a/mplayer/ffmpeg/libavcodec/aacsbr.c
+++ b/mplayer/ffmpeg/libavcodec/aacsbr.c
@@ -1134,16 +1134,12 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
* @param W array of complex-valued samples split into subbands
*/
static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, const float *in, float *x,
- float z[320], float W[2][32][32][2],
- float scale)
+ float z[320], float W[2][32][32][2])
{
int i, k;
memcpy(W[0], W[1], sizeof(W[0]));
memcpy(x , x+1024, (320-32)*sizeof(x[0]));
- if (scale != 1.0f)
- dsp->vector_fmul_scalar(x+288, in, scale, 1024);
- else
- memcpy(x+288, in, 1024*sizeof(*x));
+ memcpy(x+288, in, 1024*sizeof(x[0]));
for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames
// are not supported
dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320);
@@ -1722,7 +1718,7 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
/* decode channel */
sbr_qmf_analysis(&ac->dsp, &sbr->mdct_ana, ch ? R : L, sbr->data[ch].analysis_filterbank_samples,
(float*)sbr->qmf_filter_scratch,
- sbr->data[ch].W, 1/(-1024 * ac->sf_scale));
+ sbr->data[ch].W);
sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W);
if (sbr->start) {
sbr_hf_inverse_filter(sbr->alpha0, sbr->alpha1, sbr->X_low, sbr->k[0]);
diff --git a/mplayer/ffmpeg/libavcodec/ac3_parser.c b/mplayer/ffmpeg/libavcodec/ac3_parser.c
index 4737d6f8..301aadcd 100644
--- a/mplayer/ffmpeg/libavcodec/ac3_parser.c
+++ b/mplayer/ffmpeg/libavcodec/ac3_parser.c
@@ -24,6 +24,7 @@
#include "ac3_parser.h"
#include "aac_ac3_parser.h"
#include "get_bits.h"
+#include "libavutil/audioconvert.h"
#define AC3_HEADER_SIZE 7
@@ -123,7 +124,7 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
}
hdr->channel_layout = ff_ac3_channel_layout_tab[hdr->channel_mode];
if (hdr->lfe_on)
- hdr->channel_layout |= CH_LOW_FREQUENCY;
+ hdr->channel_layout |= AV_CH_LOW_FREQUENCY;
return 0;
}
diff --git a/mplayer/ffmpeg/libavcodec/ac3dec.c b/mplayer/ffmpeg/libavcodec/ac3dec.c
index ab738771..5ebee190 100644
--- a/mplayer/ffmpeg/libavcodec/ac3dec.c
+++ b/mplayer/ffmpeg/libavcodec/ac3dec.c
@@ -193,6 +193,7 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
ff_mdct_init(&s->imdct_512, 9, 1, 1.0);
ff_kbd_window_init(s->window, 5.0, 256);
dsputil_init(&s->dsp, avctx);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
av_lfg_init(&s->dith_state, 0);
/* set scale value for float to int16 conversion */
@@ -628,13 +629,13 @@ static inline void do_imdct(AC3DecodeContext *s, int channels)
for(i=0; i<128; i++)
x[i] = s->transform_coeffs[ch][2*i];
ff_imdct_half(&s->imdct_256, s->tmp_output, x);
- s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 0, 128);
+ s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128);
for(i=0; i<128; i++)
x[i] = s->transform_coeffs[ch][2*i+1];
ff_imdct_half(&s->imdct_256, s->delay[ch-1], x);
} else {
ff_imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]);
- s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 0, 128);
+ s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128);
memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float));
}
}
@@ -1255,7 +1256,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
} else {
gain *= s->dynamic_range[0];
}
- s->dsp.int32_to_float_fmul_scalar(s->transform_coeffs[ch], s->fixed_coeffs[ch], gain, 256);
+ s->fmt_conv.int32_to_float_fmul_scalar(s->transform_coeffs[ch], s->fixed_coeffs[ch], gain, 256);
}
/* apply spectral extension to high frequency bins */
@@ -1407,7 +1408,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");
err = 1;
}
- s->dsp.float_to_int16_interleave(out_samples, output, 256, s->out_channels);
+ s->fmt_conv.float_to_int16_interleave(out_samples, output, 256, s->out_channels);
out_samples += 256 * s->out_channels;
}
*data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t);
diff --git a/mplayer/ffmpeg/libavcodec/ac3dec.h b/mplayer/ffmpeg/libavcodec/ac3dec.h
index 55520cdc..147e5e59 100644
--- a/mplayer/ffmpeg/libavcodec/ac3dec.h
+++ b/mplayer/ffmpeg/libavcodec/ac3dec.h
@@ -55,6 +55,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
/* override ac3.h to include coupling channel */
#undef AC3_MAX_CHANNELS
@@ -190,6 +191,7 @@ typedef struct {
///@defgroup opt optimization
DSPContext dsp; ///< for optimization
+ FmtConvertContext fmt_conv; ///< optimized conversion functions
float mul_bias; ///< scaling for float_to_int16 conversion
///@}
diff --git a/mplayer/ffmpeg/libavcodec/ac3dsp.c b/mplayer/ffmpeg/libavcodec/ac3dsp.c
new file mode 100644
index 00000000..da3a123e
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/ac3dsp.c
@@ -0,0 +1,60 @@
+/*
+ * AC-3 DSP utils
+ * Copyright (c) 2011 Justin Ruggles
+ *
+ * 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
+ */
+
+#include "avcodec.h"
+#include "ac3dsp.h"
+
+static void ac3_exponent_min_c(uint8_t *exp, int num_reuse_blocks, int nb_coefs)
+{
+ int blk, i;
+
+ if (!num_reuse_blocks)
+ return;
+
+ for (i = 0; i < nb_coefs; i++) {
+ uint8_t min_exp = *exp;
+ uint8_t *exp1 = exp + 256;
+ for (blk = 0; blk < num_reuse_blocks; blk++) {
+ uint8_t next_exp = *exp1;
+ if (next_exp < min_exp)
+ min_exp = next_exp;
+ exp1 += 256;
+ }
+ *exp++ = min_exp;
+ }
+}
+
+static int ac3_max_msb_abs_int16_c(const int16_t *src, int len)
+{
+ int i, v = 0;
+ for (i = 0; i < len; i++)
+ v |= abs(src[i]);
+ return v;
+}
+
+av_cold void ff_ac3dsp_init(AC3DSPContext *c)
+{
+ c->ac3_exponent_min = ac3_exponent_min_c;
+ c->ac3_max_msb_abs_int16 = ac3_max_msb_abs_int16_c;
+
+ if (HAVE_MMX)
+ ff_ac3dsp_init_x86(c);
+}
diff --git a/mplayer/ffmpeg/libavcodec/ac3dsp.h b/mplayer/ffmpeg/libavcodec/ac3dsp.h
new file mode 100644
index 00000000..a4f141f2
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/ac3dsp.h
@@ -0,0 +1,54 @@
+/*
+ * AC-3 DSP utils
+ * Copyright (c) 2011 Justin Ruggles
+ *
+ * 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_AC3DSP_H
+#define AVCODEC_AC3DSP_H
+
+#include
+
+typedef struct AC3DSPContext {
+ /**
+ * Set each encoded exponent in a block to the minimum of itself and the
+ * exponents in the same frequency bin of up to 5 following blocks.
+ * @param exp pointer to the start of the current block of exponents.
+ * constraints: align 16
+ * @param num_reuse_blocks number of blocks that will reuse exponents from the current block.
+ * constraints: range 0 to 5
+ * @param nb_coefs number of frequency coefficients.
+ */
+ void (*ac3_exponent_min)(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
+
+ /**
+ * Calculate the maximum MSB of the absolute value of each element in an
+ * array of int16_t.
+ * @param src input array
+ * constraints: align 16. values must be in range [-32767,32767]
+ * @param len number of values in the array
+ * constraints: multiple of 16 greater than 0
+ * @return a value with the same MSB as max(abs(src[]))
+ */
+ int (*ac3_max_msb_abs_int16)(const int16_t *src, int len);
+} AC3DSPContext;
+
+void ff_ac3dsp_init (AC3DSPContext *c);
+void ff_ac3dsp_init_x86(AC3DSPContext *c);
+
+#endif /* AVCODEC_AC3DSP_H */
diff --git a/mplayer/ffmpeg/libavcodec/ac3enc.c b/mplayer/ffmpeg/libavcodec/ac3enc.c
index ed7a171a..02bc403f 100644
--- a/mplayer/ffmpeg/libavcodec/ac3enc.c
+++ b/mplayer/ffmpeg/libavcodec/ac3enc.c
@@ -28,11 +28,12 @@
//#define DEBUG
-#include "libavcore/audioconvert.h"
+#include "libavutil/audioconvert.h"
#include "libavutil/crc.h"
#include "avcodec.h"
#include "put_bits.h"
#include "dsputil.h"
+#include "ac3dsp.h"
#include "ac3.h"
#include "audioconvert.h"
@@ -86,6 +87,7 @@ typedef struct AC3Block {
typedef struct AC3EncodeContext {
PutBitContext pb; ///< bitstream writer context
DSPContext dsp;
+ AC3DSPContext ac3dsp; ///< AC-3 optimized functions
AC3MDCTContext mdct; ///< MDCT context
AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info
@@ -308,9 +310,9 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
nb_coefs = FFMIN(s->nb_coefs[0], s->nb_coefs[1]);
- s->blocks[0].new_rematrixing_strategy = 1;
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
block = &s->blocks[blk];
+ block->new_rematrixing_strategy = !blk;
for (bnd = 0; bnd < 4; bnd++) {
/* calculate calculate sum of squared coeffs for one band in one block */
int start = ff_ac3_rematrix_band_tab[bnd];
@@ -335,7 +337,6 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
/* determine if new rematrixing flags will be sent */
if (blk &&
- !block->new_rematrixing_strategy &&
block->rematrixing_flags[bnd] != block0->rematrixing_flags[bnd]) {
block->new_rematrixing_strategy = 1;
}
@@ -434,7 +435,7 @@ static void extract_exponents(AC3EncodeContext *s)
* Exponent Difference Threshold.
* New exponents are sent if their SAD exceed this number.
*/
-#define EXP_DIFF_THRESHOLD 1000
+#define EXP_DIFF_THRESHOLD 500
/**
@@ -458,7 +459,6 @@ static void compute_exp_strategy_ch(AC3EncodeContext *s, uint8_t *exp_strategy,
exp_strategy[blk] = EXP_REUSE;
exp += AC3_MAX_COEFS;
}
- emms_c();
/* now select the encoding strategy type : if exponents are often
recoded, we use a coarse encoding */
@@ -498,31 +498,6 @@ static void compute_exp_strategy(AC3EncodeContext *s)
}
-/**
- * Set each encoded exponent in a block to the minimum of itself and the
- * exponents in the same frequency bin of up to 5 following blocks.
- */
-static void exponent_min(uint8_t *exp, int num_reuse_blocks, int nb_coefs)
-{
- int blk, i;
-
- if (!num_reuse_blocks)
- return;
-
- for (i = 0; i < nb_coefs; i++) {
- uint8_t min_exp = *exp;
- uint8_t *exp1 = exp + AC3_MAX_COEFS;
- for (blk = 0; blk < num_reuse_blocks; blk++) {
- uint8_t next_exp = *exp1;
- if (next_exp < min_exp)
- min_exp = next_exp;
- exp1 += AC3_MAX_COEFS;
- }
- *exp++ = min_exp;
- }
-}
-
-
/**
* Update the exponents so that they are the ones the decoder will decode.
*/
@@ -616,7 +591,7 @@ static void encode_exponents(AC3EncodeContext *s)
num_reuse_blocks = blk1 - blk - 1;
/* for the EXP_REUSE case we select the min of the exponents */
- exponent_min(exp, num_reuse_blocks, nb_coefs);
+ s->ac3dsp.ac3_exponent_min(exp, num_reuse_blocks, nb_coefs);
encode_exponents_blk_ch(exp, nb_coefs, exp_strategy[blk]);
@@ -704,6 +679,8 @@ static void process_exponents(AC3EncodeContext *s)
encode_exponents(s);
group_exponents(s);
+
+ emms_c();
}
@@ -774,7 +751,7 @@ static void bit_alloc_init(AC3EncodeContext *s)
s->fast_decay_code = 1;
s->slow_gain_code = 1;
s->db_per_bit_code = 3;
- s->floor_code = 4;
+ s->floor_code = 7;
for (ch = 0; ch < s->channels; ch++)
s->fast_gain_code[ch] = 4;
@@ -1856,6 +1833,7 @@ static av_cold int ac3_encode_init(AVCodecContext *avctx)
avctx->coded_frame= avcodec_alloc_frame();
dsputil_init(&s->dsp, avctx);
+ ff_ac3dsp_init(&s->ac3dsp);
return 0;
init_fail:
diff --git a/mplayer/ffmpeg/libavcodec/ac3enc_fixed.c b/mplayer/ffmpeg/libavcodec/ac3enc_fixed.c
index 90e148b9..3de00ee4 100644
--- a/mplayer/ffmpeg/libavcodec/ac3enc_fixed.c
+++ b/mplayer/ffmpeg/libavcodec/ac3enc_fixed.c
@@ -270,14 +270,9 @@ static void apply_window(DSPContext *dsp, int16_t *output, const int16_t *input,
* @param n number of values in the array
* @return log2(max(abs(tab[])))
*/
-static int log2_tab(int16_t *tab, int n)
+static int log2_tab(AC3EncodeContext *s, int16_t *src, int len)
{
- int i, v;
-
- v = 0;
- for (i = 0; i < n; i++)
- v |= abs(tab[i]);
-
+ int v = s->ac3dsp.ac3_max_msb_abs_int16(src, len);
return av_log2(v);
}
@@ -286,19 +281,15 @@ static int log2_tab(int16_t *tab, int n)
* Left-shift each value in an array by a specified amount.
* @param tab input array
* @param n number of values in the array
- * @param lshift left shift amount. a negative value means right shift.
+ * @param lshift left shift amount
*/
-static void lshift_tab(int16_t *tab, int n, int lshift)
+static void lshift_tab(int16_t *tab, int n, unsigned int lshift)
{
int i;
if (lshift > 0) {
for (i = 0; i < n; i++)
tab[i] <<= lshift;
- } else if (lshift < 0) {
- lshift = -lshift;
- for (i = 0; i < n; i++)
- tab[i] >>= lshift;
}
}
@@ -312,8 +303,7 @@ static void lshift_tab(int16_t *tab, int n, int lshift)
*/
static int normalize_samples(AC3EncodeContext *s)
{
- int v = 14 - log2_tab(s->windowed_samples, AC3_WINDOW_SIZE);
- v = FFMAX(0, v);
+ int v = 14 - log2_tab(s, s->windowed_samples, AC3_WINDOW_SIZE);
lshift_tab(s->windowed_samples, AC3_WINDOW_SIZE, v);
return v - 9;
}
diff --git a/mplayer/ffmpeg/libavcodec/ac3tab.c b/mplayer/ffmpeg/libavcodec/ac3tab.c
index 7c0ebcdc..f7b03020 100644
--- a/mplayer/ffmpeg/libavcodec/ac3tab.c
+++ b/mplayer/ffmpeg/libavcodec/ac3tab.c
@@ -24,7 +24,7 @@
* tables taken directly from the AC-3 spec.
*/
-#include "libavcore/audioconvert.h"
+#include "libavutil/audioconvert.h"
#include "avcodec.h"
#include "ac3tab.h"
diff --git a/mplayer/ffmpeg/libavcodec/adpcm.c b/mplayer/ffmpeg/libavcodec/adpcm.c
index fb5bdc7f..826c5886 100644
--- a/mplayer/ffmpeg/libavcodec/adpcm.c
+++ b/mplayer/ffmpeg/libavcodec/adpcm.c
@@ -1719,7 +1719,7 @@ AVCodec ff_ ## name ## _encoder = { \
NULL, \
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, \
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
-};
+}
#else
#define ADPCM_ENCODER(id,name,long_name_)
#endif
@@ -1736,13 +1736,13 @@ AVCodec ff_ ## name ## _decoder = { \
NULL, \
adpcm_decode_frame, \
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
-};
+}
#else
#define ADPCM_DECODER(id,name,long_name_)
#endif
#define ADPCM_CODEC(id,name,long_name_) \
- ADPCM_ENCODER(id,name,long_name_) ADPCM_DECODER(id,name,long_name_)
+ ADPCM_ENCODER(id,name,long_name_); ADPCM_DECODER(id,name,long_name_)
/* Note: Do not forget to add new entries to the Makefile as well. */
ADPCM_DECODER(CODEC_ID_ADPCM_4XM, adpcm_4xm, "ADPCM 4X Movie");
diff --git a/mplayer/ffmpeg/libavcodec/allcodecs.c b/mplayer/ffmpeg/libavcodec/allcodecs.c
index 04c5c6aa..108a3ab7 100644
--- a/mplayer/ffmpeg/libavcodec/allcodecs.c
+++ b/mplayer/ffmpeg/libavcodec/allcodecs.c
@@ -214,6 +214,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (WMV3_VDPAU, wmv3_vdpau);
REGISTER_DECODER (WNV1, wnv1);
REGISTER_DECODER (XAN_WC3, xan_wc3);
+ REGISTER_DECODER (XAN_WC4, xan_wc4);
REGISTER_DECODER (XL, xl);
REGISTER_DECODER (YOP, yop);
REGISTER_ENCDEC (ZLIB, zlib);
diff --git a/mplayer/ffmpeg/libavcodec/alsdec.c b/mplayer/ffmpeg/libavcodec/alsdec.c
index bfc589d2..41b3f0ca 100644
--- a/mplayer/ffmpeg/libavcodec/alsdec.c
+++ b/mplayer/ffmpeg/libavcodec/alsdec.c
@@ -36,7 +36,7 @@
#include "bytestream.h"
#include "bgmc.h"
#include "dsputil.h"
-#include "libavcore/samplefmt.h"
+#include "libavutil/samplefmt.h"
#include "libavutil/crc.h"
#include
diff --git a/mplayer/ffmpeg/libavcodec/amrnbdec.c b/mplayer/ffmpeg/libavcodec/amrnbdec.c
index ec896c7d..2883b9c3 100644
--- a/mplayer/ffmpeg/libavcodec/amrnbdec.c
+++ b/mplayer/ffmpeg/libavcodec/amrnbdec.c
@@ -255,7 +255,7 @@ static void lsf2lsp_for_mode12k2(AMRContext *p, double lsp[LP_FILTER_ORDER],
}
if (update)
- memcpy(p->prev_lsf_r, lsf_r, LP_FILTER_ORDER * sizeof(float));
+ memcpy(p->prev_lsf_r, lsf_r, LP_FILTER_ORDER * sizeof(*lsf_r));
for (i = 0; i < LP_FILTER_ORDER; i++)
lsf_q[i] = lsf_r[i] * (LSF_R_FAC / 8000.0) + lsf_no_r[i] * (1.0 / 8000.0);
diff --git a/mplayer/ffmpeg/libavcodec/amrwbdec.c b/mplayer/ffmpeg/libavcodec/amrwbdec.c
index 8bf02a2b..90bf1d5f 100644
--- a/mplayer/ffmpeg/libavcodec/amrwbdec.c
+++ b/mplayer/ffmpeg/libavcodec/amrwbdec.c
@@ -89,7 +89,7 @@ static av_cold int amrwb_decode_init(AVCodecContext *avctx)
AMRWBContext *ctx = avctx->priv_data;
int i;
- avctx->sample_fmt = SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
av_lfg_init(&ctx->prng, 1);
@@ -1227,11 +1227,11 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVCodec ff_amrwb_decoder = {
.name = "amrwb",
- .type = CODEC_TYPE_AUDIO,
+ .type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_AMR_WB,
.priv_data_size = sizeof(AMRWBContext),
.init = amrwb_decode_init,
.decode = amrwb_decode_frame,
.long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate WideBand"),
- .sample_fmts = (enum AVSampleFormat[]){SAMPLE_FMT_FLT,SAMPLE_FMT_NONE},
+ .sample_fmts = (enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
};
diff --git a/mplayer/ffmpeg/libavcodec/apedec.c b/mplayer/ffmpeg/libavcodec/apedec.c
index b6d6f9d9..05498777 100644
--- a/mplayer/ffmpeg/libavcodec/apedec.c
+++ b/mplayer/ffmpeg/libavcodec/apedec.c
@@ -25,6 +25,7 @@
#include "dsputil.h"
#include "get_bits.h"
#include "bytestream.h"
+#include "libavutil/audioconvert.h"
/**
* @file
@@ -199,7 +200,7 @@ static av_cold int ape_decode_init(AVCodecContext * avctx)
dsputil_init(&s->dsp, avctx);
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
- avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
+ avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
return 0;
}
diff --git a/mplayer/ffmpeg/libavcodec/arm/Makefile b/mplayer/ffmpeg/libavcodec/arm/Makefile
index 4c30e0ab..d223703c 100644
--- a/mplayer/ffmpeg/libavcodec/arm/Makefile
+++ b/mplayer/ffmpeg/libavcodec/arm/Makefile
@@ -2,6 +2,8 @@ OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_init_arm.o \
OBJS-$(CONFIG_VP5_DECODER) += arm/vp56dsp_init_arm.o
OBJS-$(CONFIG_VP6_DECODER) += arm/vp56dsp_init_arm.o
+OBJS-$(CONFIG_VP8_DECODER) += arm/vp8dsp_init_arm.o
+ARMV6-OBJS-$(CONFIG_VP8_DECODER) += arm/vp8_armv6.o
OBJS-$(CONFIG_H264DSP) += arm/h264dsp_init_arm.o
OBJS-$(CONFIG_H264PRED) += arm/h264pred_init_arm.o
@@ -9,6 +11,7 @@ OBJS-$(CONFIG_H264PRED) += arm/h264pred_init_arm.o
OBJS += arm/dsputil_init_arm.o \
arm/dsputil_arm.o \
arm/fft_init_arm.o \
+ arm/fmtconvert_init_arm.o \
arm/jrevdct_arm.o \
arm/mpegvideo_arm.o \
arm/simple_idct_arm.o \
@@ -21,9 +24,13 @@ OBJS-$(HAVE_ARMV5TE) += arm/dsputil_init_armv5te.o \
OBJS-$(HAVE_ARMV6) += arm/dsputil_init_armv6.o \
arm/dsputil_armv6.o \
arm/simple_idct_armv6.o \
+ $(ARMV6-OBJS-yes)
+
+VFP-OBJS-$(HAVE_ARMV6) += arm/fmtconvert_vfp.o \
OBJS-$(HAVE_ARMVFP) += arm/dsputil_vfp.o \
arm/dsputil_init_vfp.o \
+ $(VFP-OBJS-yes)
OBJS-$(HAVE_IWMMXT) += arm/dsputil_iwmmxt.o \
arm/mpegvideo_iwmmxt.o \
@@ -50,8 +57,11 @@ NEON-OBJS-$(CONFIG_VP5_DECODER) += arm/vp56dsp_neon.o \
NEON-OBJS-$(CONFIG_VP6_DECODER) += arm/vp56dsp_neon.o \
arm/vp3dsp_neon.o \
+NEON-OBJS-$(CONFIG_VP8_DECODER) += arm/vp8dsp_neon.o
+
OBJS-$(HAVE_NEON) += arm/dsputil_init_neon.o \
arm/dsputil_neon.o \
+ arm/fmtconvert_neon.o \
arm/int_neon.o \
arm/mpegvideo_neon.o \
arm/simple_idct_neon.o \
diff --git a/mplayer/ffmpeg/libavcodec/arm/asm.S b/mplayer/ffmpeg/libavcodec/arm/asm.S
index e0507834..cf73a776 100644
--- a/mplayer/ffmpeg/libavcodec/arm/asm.S
+++ b/mplayer/ffmpeg/libavcodec/arm/asm.S
@@ -50,6 +50,16 @@ ELF .type \name, %function
\name:
.endm
+.macro const name, align=2
+ .macro endconst
+ELF .size \name, . - \name
+ .purgem endconst
+ .endm
+ .section .rodata
+ .align \align
+\name:
+.endm
+
.macro mov32 rd, val
#if HAVE_ARMV6T2
movw \rd, #(\val) & 0xffff
diff --git a/mplayer/ffmpeg/libavcodec/arm/dcadsp_init_arm.c b/mplayer/ffmpeg/libavcodec/arm/dcadsp_init_arm.c
index 816718d4..5663cd7f 100644
--- a/mplayer/ffmpeg/libavcodec/arm/dcadsp_init_arm.c
+++ b/mplayer/ffmpeg/libavcodec/arm/dcadsp_init_arm.c
@@ -23,7 +23,7 @@
#include "libavcodec/dcadsp.h"
void ff_dca_lfe_fir_neon(float *out, const float *in, const float *coefs,
- int decifactor, float scale, float bias);
+ int decifactor, float scale);
void av_cold ff_dcadsp_init_arm(DCADSPContext *s)
{
diff --git a/mplayer/ffmpeg/libavcodec/arm/dcadsp_neon.S b/mplayer/ffmpeg/libavcodec/arm/dcadsp_neon.S
index 19960ab1..c3bddd3e 100644
--- a/mplayer/ffmpeg/libavcodec/arm/dcadsp_neon.S
+++ b/mplayer/ffmpeg/libavcodec/arm/dcadsp_neon.S
@@ -29,7 +29,7 @@ function ff_dca_lfe_fir_neon, export=1
cmp r3, #32
moveq r6, #256/32
movne r6, #256/64
-NOVFP vldr d0, [sp, #16] @ scale, bias
+NOVFP vldr s0, [sp, #16] @ scale
mov lr, #-16
1:
vmov.f32 q2, #0.0 @ v0
@@ -51,8 +51,7 @@ NOVFP vldr d0, [sp, #16] @ scale, bias
vadd.f32 d4, d4, d5
vadd.f32 d6, d6, d7
vpadd.f32 d4, d4, d6
- vdup.32 d5, d0[1]
- vmla.f32 d5, d4, d0[0]
+ vmul.f32 d5, d4, d0[0]
vst1.32 {d5[0]}, [r0,:32]!
vst1.32 {d5[1]}, [r4,:32]!
bne 1b
diff --git a/mplayer/ffmpeg/libavcodec/arm/dsputil_init_neon.c b/mplayer/ffmpeg/libavcodec/arm/dsputil_init_neon.c
index 221183ce..76ae6322 100644
--- a/mplayer/ffmpeg/libavcodec/arm/dsputil_init_neon.c
+++ b/mplayer/ffmpeg/libavcodec/arm/dsputil_init_neon.c
@@ -140,8 +140,7 @@ void ff_vp3_h_loop_filter_neon(uint8_t *, int, int *);
void ff_vector_fmul_neon(float *dst, const float *src0, const float *src1, int len);
void ff_vector_fmul_window_neon(float *dst, const float *src0,
- const float *src1, const float *win,
- float add_bias, int len);
+ const float *src1, const float *win, int len);
void ff_vector_fmul_scalar_neon(float *dst, const float *src, float mul,
int len);
void ff_vector_fmul_sv_scalar_2_neon(float *dst, const float *src,
@@ -154,8 +153,6 @@ void ff_sv_fmul_scalar_4_neon(float *dst, const float **vp, float mul,
int len);
void ff_butterflies_float_neon(float *v1, float *v2, int len);
float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);
-void ff_int32_to_float_fmul_scalar_neon(float *dst, const int *src,
- float mul, int len);
void ff_vector_fmul_reverse_neon(float *dst, const float *src0,
const float *src1, int len);
void ff_vector_fmul_add_neon(float *dst, const float *src0, const float *src1,
@@ -163,8 +160,6 @@ void ff_vector_fmul_add_neon(float *dst, const float *src0, const float *src1,
void ff_vector_clipf_neon(float *dst, const float *src, float min, float max,
int len);
-void ff_float_to_int16_neon(int16_t *, const float *, long);
-void ff_float_to_int16_interleave_neon(int16_t *, const float **, long, int);
void ff_vorbis_inverse_coupling_neon(float *mag, float *ang, int blocksize);
@@ -309,7 +304,6 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
c->vector_fmul_scalar = ff_vector_fmul_scalar_neon;
c->butterflies_float = ff_butterflies_float_neon;
c->scalarproduct_float = ff_scalarproduct_float_neon;
- c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_neon;
c->vector_fmul_reverse = ff_vector_fmul_reverse_neon;
c->vector_fmul_add = ff_vector_fmul_add_neon;
c->vector_clipf = ff_vector_clipf_neon;
@@ -320,11 +314,6 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
c->sv_fmul_scalar[0] = ff_sv_fmul_scalar_2_neon;
c->sv_fmul_scalar[1] = ff_sv_fmul_scalar_4_neon;
- if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
- c->float_to_int16 = ff_float_to_int16_neon;
- c->float_to_int16_interleave = ff_float_to_int16_interleave_neon;
- }
-
if (CONFIG_VORBIS_DECODER)
c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_neon;
diff --git a/mplayer/ffmpeg/libavcodec/arm/dsputil_init_vfp.c b/mplayer/ffmpeg/libavcodec/arm/dsputil_init_vfp.c
index 76ef6b41..bd523159 100644
--- a/mplayer/ffmpeg/libavcodec/arm/dsputil_init_vfp.c
+++ b/mplayer/ffmpeg/libavcodec/arm/dsputil_init_vfp.c
@@ -25,13 +25,9 @@ void ff_vector_fmul_vfp(float *dst, const float *src0,
const float *src1, int len);
void ff_vector_fmul_reverse_vfp(float *dst, const float *src0,
const float *src1, int len);
-void ff_float_to_int16_vfp(int16_t *dst, const float *src, long len);
void ff_dsputil_init_vfp(DSPContext* c, AVCodecContext *avctx)
{
c->vector_fmul = ff_vector_fmul_vfp;
c->vector_fmul_reverse = ff_vector_fmul_reverse_vfp;
-#if HAVE_ARMV6
- c->float_to_int16 = ff_float_to_int16_vfp;
-#endif
}
diff --git a/mplayer/ffmpeg/libavcodec/arm/dsputil_neon.S b/mplayer/ffmpeg/libavcodec/arm/dsputil_neon.S
index 42fb38de..05a91150 100644
--- a/mplayer/ffmpeg/libavcodec/arm/dsputil_neon.S
+++ b/mplayer/ffmpeg/libavcodec/arm/dsputil_neon.S
@@ -400,343 +400,6 @@ function ff_add_pixels_clamped_neon, export=1
bx lr
endfunc
-function ff_float_to_int16_neon, export=1
- subs r2, r2, #8
- vld1.64 {d0-d1}, [r1,:128]!
- vcvt.s32.f32 q8, q0, #16
- vld1.64 {d2-d3}, [r1,:128]!
- vcvt.s32.f32 q9, q1, #16
- beq 3f
- bics ip, r2, #15
- beq 2f
-1: subs ip, ip, #16
- vshrn.s32 d4, q8, #16
- vld1.64 {d0-d1}, [r1,:128]!
- vcvt.s32.f32 q0, q0, #16
- vshrn.s32 d5, q9, #16
- vld1.64 {d2-d3}, [r1,:128]!
- vcvt.s32.f32 q1, q1, #16
- vshrn.s32 d6, q0, #16
- vst1.64 {d4-d5}, [r0,:128]!
- vshrn.s32 d7, q1, #16
- vld1.64 {d16-d17},[r1,:128]!
- vcvt.s32.f32 q8, q8, #16
- vld1.64 {d18-d19},[r1,:128]!
- vcvt.s32.f32 q9, q9, #16
- vst1.64 {d6-d7}, [r0,:128]!
- bne 1b
- ands r2, r2, #15
- beq 3f
-2: vld1.64 {d0-d1}, [r1,:128]!
- vshrn.s32 d4, q8, #16
- vcvt.s32.f32 q0, q0, #16
- vld1.64 {d2-d3}, [r1,:128]!
- vshrn.s32 d5, q9, #16
- vcvt.s32.f32 q1, q1, #16
- vshrn.s32 d6, q0, #16
- vst1.64 {d4-d5}, [r0,:128]!
- vshrn.s32 d7, q1, #16
- vst1.64 {d6-d7}, [r0,:128]!
- bx lr
-3: vshrn.s32 d4, q8, #16
- vshrn.s32 d5, q9, #16
- vst1.64 {d4-d5}, [r0,:128]!
- bx lr
-endfunc
-
-function ff_float_to_int16_interleave_neon, export=1
- cmp r3, #2
- ldrlt r1, [r1]
- blt ff_float_to_int16_neon
- bne 4f
-
- ldr r3, [r1]
- ldr r1, [r1, #4]
-
- subs r2, r2, #8
- vld1.64 {d0-d1}, [r3,:128]!
- vcvt.s32.f32 q8, q0, #16
- vld1.64 {d2-d3}, [r3,:128]!
- vcvt.s32.f32 q9, q1, #16
- vld1.64 {d20-d21},[r1,:128]!
- vcvt.s32.f32 q10, q10, #16
- vld1.64 {d22-d23},[r1,:128]!
- vcvt.s32.f32 q11, q11, #16
- beq 3f
- bics ip, r2, #15
- beq 2f
-1: subs ip, ip, #16
- vld1.64 {d0-d1}, [r3,:128]!
- vcvt.s32.f32 q0, q0, #16
- vsri.32 q10, q8, #16
- vld1.64 {d2-d3}, [r3,:128]!
- vcvt.s32.f32 q1, q1, #16
- vld1.64 {d24-d25},[r1,:128]!
- vcvt.s32.f32 q12, q12, #16
- vld1.64 {d26-d27},[r1,:128]!
- vsri.32 q11, q9, #16
- vst1.64 {d20-d21},[r0,:128]!
- vcvt.s32.f32 q13, q13, #16
- vst1.64 {d22-d23},[r0,:128]!
- vsri.32 q12, q0, #16
- vld1.64 {d16-d17},[r3,:128]!
- vsri.32 q13, q1, #16
- vst1.64 {d24-d25},[r0,:128]!
- vcvt.s32.f32 q8, q8, #16
- vld1.64 {d18-d19},[r3,:128]!
- vcvt.s32.f32 q9, q9, #16
- vld1.64 {d20-d21},[r1,:128]!
- vcvt.s32.f32 q10, q10, #16
- vld1.64 {d22-d23},[r1,:128]!
- vcvt.s32.f32 q11, q11, #16
- vst1.64 {d26-d27},[r0,:128]!
- bne 1b
- ands r2, r2, #15
- beq 3f
-2: vsri.32 q10, q8, #16
- vld1.64 {d0-d1}, [r3,:128]!
- vcvt.s32.f32 q0, q0, #16
- vld1.64 {d2-d3}, [r3,:128]!
- vcvt.s32.f32 q1, q1, #16
- vld1.64 {d24-d25},[r1,:128]!
- vcvt.s32.f32 q12, q12, #16
- vsri.32 q11, q9, #16
- vld1.64 {d26-d27},[r1,:128]!
- vcvt.s32.f32 q13, q13, #16
- vst1.64 {d20-d21},[r0,:128]!
- vsri.32 q12, q0, #16
- vst1.64 {d22-d23},[r0,:128]!
- vsri.32 q13, q1, #16
- vst1.64 {d24-d27},[r0,:128]!
- bx lr
-3: vsri.32 q10, q8, #16
- vsri.32 q11, q9, #16
- vst1.64 {d20-d23},[r0,:128]!
- bx lr
-
-4: push {r4-r8,lr}
- cmp r3, #4
- lsl ip, r3, #1
- blt 4f
-
- @ 4 channels
-5: ldmia r1!, {r4-r7}
- mov lr, r2
- mov r8, r0
- vld1.64 {d16-d17},[r4,:128]!
- vcvt.s32.f32 q8, q8, #16
- vld1.64 {d18-d19},[r5,:128]!
- vcvt.s32.f32 q9, q9, #16
- vld1.64 {d20-d21},[r6,:128]!
- vcvt.s32.f32 q10, q10, #16
- vld1.64 {d22-d23},[r7,:128]!
- vcvt.s32.f32 q11, q11, #16
-6: subs lr, lr, #8
- vld1.64 {d0-d1}, [r4,:128]!
- vcvt.s32.f32 q0, q0, #16
- vsri.32 q9, q8, #16
- vld1.64 {d2-d3}, [r5,:128]!
- vcvt.s32.f32 q1, q1, #16
- vsri.32 q11, q10, #16
- vld1.64 {d4-d5}, [r6,:128]!
- vcvt.s32.f32 q2, q2, #16
- vzip.32 d18, d22
- vld1.64 {d6-d7}, [r7,:128]!
- vcvt.s32.f32 q3, q3, #16
- vzip.32 d19, d23
- vst1.64 {d18}, [r8], ip
- vsri.32 q1, q0, #16
- vst1.64 {d22}, [r8], ip
- vsri.32 q3, q2, #16
- vst1.64 {d19}, [r8], ip
- vzip.32 d2, d6
- vst1.64 {d23}, [r8], ip
- vzip.32 d3, d7
- beq 7f
- vld1.64 {d16-d17},[r4,:128]!
- vcvt.s32.f32 q8, q8, #16
- vst1.64 {d2}, [r8], ip
- vld1.64 {d18-d19},[r5,:128]!
- vcvt.s32.f32 q9, q9, #16
- vst1.64 {d6}, [r8], ip
- vld1.64 {d20-d21},[r6,:128]!
- vcvt.s32.f32 q10, q10, #16
- vst1.64 {d3}, [r8], ip
- vld1.64 {d22-d23},[r7,:128]!
- vcvt.s32.f32 q11, q11, #16
- vst1.64 {d7}, [r8], ip
- b 6b
-7: vst1.64 {d2}, [r8], ip
- vst1.64 {d6}, [r8], ip
- vst1.64 {d3}, [r8], ip
- vst1.64 {d7}, [r8], ip
- subs r3, r3, #4
- popeq {r4-r8,pc}
- cmp r3, #4
- add r0, r0, #8
- bge 5b
-
- @ 2 channels
-4: cmp r3, #2
- blt 4f
- ldmia r1!, {r4-r5}
- mov lr, r2
- mov r8, r0
- tst lr, #8
- vld1.64 {d16-d17},[r4,:128]!
- vcvt.s32.f32 q8, q8, #16
- vld1.64 {d18-d19},[r5,:128]!
- vcvt.s32.f32 q9, q9, #16
- vld1.64 {d20-d21},[r4,:128]!
- vcvt.s32.f32 q10, q10, #16
- vld1.64 {d22-d23},[r5,:128]!
- vcvt.s32.f32 q11, q11, #16
- beq 6f
- subs lr, lr, #8
- beq 7f
- vsri.32 d18, d16, #16
- vsri.32 d19, d17, #16
- vld1.64 {d16-d17},[r4,:128]!
- vcvt.s32.f32 q8, q8, #16
- vst1.32 {d18[0]}, [r8], ip
- vsri.32 d22, d20, #16
- vst1.32 {d18[1]}, [r8], ip
- vsri.32 d23, d21, #16
- vst1.32 {d19[0]}, [r8], ip
- vst1.32 {d19[1]}, [r8], ip
- vld1.64 {d18-d19},[r5,:128]!
- vcvt.s32.f32 q9, q9, #16
- vst1.32 {d22[0]}, [r8], ip
- vst1.32 {d22[1]}, [r8], ip
- vld1.64 {d20-d21},[r4,:128]!
- vcvt.s32.f32 q10, q10, #16
- vst1.32 {d23[0]}, [r8], ip
- vst1.32 {d23[1]}, [r8], ip
- vld1.64 {d22-d23},[r5,:128]!
- vcvt.s32.f32 q11, q11, #16
-6: subs lr, lr, #16
- vld1.64 {d0-d1}, [r4,:128]!
- vcvt.s32.f32 q0, q0, #16
- vsri.32 d18, d16, #16
- vld1.64 {d2-d3}, [r5,:128]!
- vcvt.s32.f32 q1, q1, #16
- vsri.32 d19, d17, #16
- vld1.64 {d4-d5}, [r4,:128]!
- vcvt.s32.f32 q2, q2, #16
- vld1.64 {d6-d7}, [r5,:128]!
- vcvt.s32.f32 q3, q3, #16
- vst1.32 {d18[0]}, [r8], ip
- vsri.32 d22, d20, #16
- vst1.32 {d18[1]}, [r8], ip
- vsri.32 d23, d21, #16
- vst1.32 {d19[0]}, [r8], ip
- vsri.32 d2, d0, #16
- vst1.32 {d19[1]}, [r8], ip
- vsri.32 d3, d1, #16
- vst1.32 {d22[0]}, [r8], ip
- vsri.32 d6, d4, #16
- vst1.32 {d22[1]}, [r8], ip
- vsri.32 d7, d5, #16
- vst1.32 {d23[0]}, [r8], ip
- vst1.32 {d23[1]}, [r8], ip
- beq 6f
- vld1.64 {d16-d17},[r4,:128]!
- vcvt.s32.f32 q8, q8, #16
- vst1.32 {d2[0]}, [r8], ip
- vst1.32 {d2[1]}, [r8], ip
- vld1.64 {d18-d19},[r5,:128]!
- vcvt.s32.f32 q9, q9, #16
- vst1.32 {d3[0]}, [r8], ip
- vst1.32 {d3[1]}, [r8], ip
- vld1.64 {d20-d21},[r4,:128]!
- vcvt.s32.f32 q10, q10, #16
- vst1.32 {d6[0]}, [r8], ip
- vst1.32 {d6[1]}, [r8], ip
- vld1.64 {d22-d23},[r5,:128]!
- vcvt.s32.f32 q11, q11, #16
- vst1.32 {d7[0]}, [r8], ip
- vst1.32 {d7[1]}, [r8], ip
- bgt 6b
-6: vst1.32 {d2[0]}, [r8], ip
- vst1.32 {d2[1]}, [r8], ip
- vst1.32 {d3[0]}, [r8], ip
- vst1.32 {d3[1]}, [r8], ip
- vst1.32 {d6[0]}, [r8], ip
- vst1.32 {d6[1]}, [r8], ip
- vst1.32 {d7[0]}, [r8], ip
- vst1.32 {d7[1]}, [r8], ip
- b 8f
-7: vsri.32 d18, d16, #16
- vsri.32 d19, d17, #16
- vst1.32 {d18[0]}, [r8], ip
- vsri.32 d22, d20, #16
- vst1.32 {d18[1]}, [r8], ip
- vsri.32 d23, d21, #16
- vst1.32 {d19[0]}, [r8], ip
- vst1.32 {d19[1]}, [r8], ip
- vst1.32 {d22[0]}, [r8], ip
- vst1.32 {d22[1]}, [r8], ip
- vst1.32 {d23[0]}, [r8], ip
- vst1.32 {d23[1]}, [r8], ip
-8: subs r3, r3, #2
- add r0, r0, #4
- popeq {r4-r8,pc}
-
- @ 1 channel
-4: ldr r4, [r1],#4
- tst r2, #8
- mov lr, r2
- mov r5, r0
- vld1.64 {d0-d1}, [r4,:128]!
- vcvt.s32.f32 q0, q0, #16
- vld1.64 {d2-d3}, [r4,:128]!
- vcvt.s32.f32 q1, q1, #16
- bne 8f
-6: subs lr, lr, #16
- vld1.64 {d4-d5}, [r4,:128]!
- vcvt.s32.f32 q2, q2, #16
- vld1.64 {d6-d7}, [r4,:128]!
- vcvt.s32.f32 q3, q3, #16
- vst1.16 {d0[1]}, [r5,:16], ip
- vst1.16 {d0[3]}, [r5,:16], ip
- vst1.16 {d1[1]}, [r5,:16], ip
- vst1.16 {d1[3]}, [r5,:16], ip
- vst1.16 {d2[1]}, [r5,:16], ip
- vst1.16 {d2[3]}, [r5,:16], ip
- vst1.16 {d3[1]}, [r5,:16], ip
- vst1.16 {d3[3]}, [r5,:16], ip
- beq 7f
- vld1.64 {d0-d1}, [r4,:128]!
- vcvt.s32.f32 q0, q0, #16
- vld1.64 {d2-d3}, [r4,:128]!
- vcvt.s32.f32 q1, q1, #16
-7: vst1.16 {d4[1]}, [r5,:16], ip
- vst1.16 {d4[3]}, [r5,:16], ip
- vst1.16 {d5[1]}, [r5,:16], ip
- vst1.16 {d5[3]}, [r5,:16], ip
- vst1.16 {d6[1]}, [r5,:16], ip
- vst1.16 {d6[3]}, [r5,:16], ip
- vst1.16 {d7[1]}, [r5,:16], ip
- vst1.16 {d7[3]}, [r5,:16], ip
- bgt 6b
- pop {r4-r8,pc}
-8: subs lr, lr, #8
- vst1.16 {d0[1]}, [r5,:16], ip
- vst1.16 {d0[3]}, [r5,:16], ip
- vst1.16 {d1[1]}, [r5,:16], ip
- vst1.16 {d1[3]}, [r5,:16], ip
- vst1.16 {d2[1]}, [r5,:16], ip
- vst1.16 {d2[3]}, [r5,:16], ip
- vst1.16 {d3[1]}, [r5,:16], ip
- vst1.16 {d3[3]}, [r5,:16], ip
- popeq {r4-r8,pc}
- vld1.64 {d0-d1}, [r4,:128]!
- vcvt.s32.f32 q0, q0, #16
- vld1.64 {d2-d3}, [r4,:128]!
- vcvt.s32.f32 q1, q1, #16
- b 6b
-endfunc
-
function ff_vector_fmul_neon, export=1
subs r3, r3, #8
vld1.64 {d0-d3}, [r1,:128]!
@@ -777,11 +440,8 @@ function ff_vector_fmul_neon, export=1
endfunc
function ff_vector_fmul_window_neon, export=1
-VFP vdup.32 q8, d0[0]
-NOVFP vld1.32 {d16[],d17[]}, [sp,:32]
push {r4,r5,lr}
-VFP ldr lr, [sp, #12]
-NOVFP ldr lr, [sp, #16]
+ ldr lr, [sp, #12]
sub r2, r2, #8
sub r5, lr, #2
add r2, r2, r5, lsl #2
@@ -793,14 +453,12 @@ NOVFP ldr lr, [sp, #16]
vld1.64 {d4,d5}, [r3,:128]!
vld1.64 {d6,d7}, [r4,:128], r5
1: subs lr, lr, #4
- vmov q11, q8
- vmla.f32 d22, d0, d4
- vmov q10, q8
- vmla.f32 d23, d1, d5
+ vmul.f32 d22, d0, d4
vrev64.32 q3, q3
- vmla.f32 d20, d0, d7
+ vmul.f32 d23, d1, d5
vrev64.32 q1, q1
- vmla.f32 d21, d1, d6
+ vmul.f32 d20, d0, d7
+ vmul.f32 d21, d1, d6
beq 2f
vmla.f32 d22, d3, d7
vld1.64 {d0,d1}, [r1,:128]!
@@ -1055,34 +713,6 @@ NOVFP vmov.32 r0, d0[0]
bx lr
endfunc
-function ff_int32_to_float_fmul_scalar_neon, export=1
-VFP vdup.32 q0, d0[0]
-VFP len .req r2
-NOVFP vdup.32 q0, r2
-NOVFP len .req r3
-
- vld1.32 {q1},[r1,:128]!
- vcvt.f32.s32 q3, q1
- vld1.32 {q2},[r1,:128]!
- vcvt.f32.s32 q8, q2
-1: subs len, len, #8
- pld [r1, #16]
- vmul.f32 q9, q3, q0
- vmul.f32 q10, q8, q0
- beq 2f
- vld1.32 {q1},[r1,:128]!
- vcvt.f32.s32 q3, q1
- vld1.32 {q2},[r1,:128]!
- vcvt.f32.s32 q8, q2
- vst1.32 {q9}, [r0,:128]!
- vst1.32 {q10},[r0,:128]!
- b 1b
-2: vst1.32 {q9}, [r0,:128]!
- vst1.32 {q10},[r0,:128]!
- bx lr
- .unreq len
-endfunc
-
function ff_vector_fmul_reverse_neon, export=1
add r2, r2, r3, lsl #2
sub r2, r2, #32
diff --git a/mplayer/ffmpeg/libavcodec/arm/dsputil_vfp.S b/mplayer/ffmpeg/libavcodec/arm/dsputil_vfp.S
index a65b69e2..197d5008 100644
--- a/mplayer/ffmpeg/libavcodec/arm/dsputil_vfp.S
+++ b/mplayer/ffmpeg/libavcodec/arm/dsputil_vfp.S
@@ -131,58 +131,3 @@ function ff_vector_fmul_reverse_vfp, export=1
vpop {d8-d15}
bx lr
endfunc
-
-#if HAVE_ARMV6
-/**
- * ARM VFP optimized float to int16 conversion.
- * Assume that len is a positive number and is multiple of 8, destination
- * buffer is at least 4 bytes aligned (8 bytes alignment is better for
- * performance), little endian byte sex
- */
-@ void ff_float_to_int16_vfp(int16_t *dst, const float *src, int len)
-function ff_float_to_int16_vfp, export=1
- push {r4-r8,lr}
- vpush {d8-d11}
- vldmia r1!, {s16-s23}
- vcvt.s32.f32 s0, s16
- vcvt.s32.f32 s1, s17
- vcvt.s32.f32 s2, s18
- vcvt.s32.f32 s3, s19
- vcvt.s32.f32 s4, s20
- vcvt.s32.f32 s5, s21
- vcvt.s32.f32 s6, s22
- vcvt.s32.f32 s7, s23
-1:
- subs r2, r2, #8
- vmov r3, r4, s0, s1
- vmov r5, r6, s2, s3
- vmov r7, r8, s4, s5
- vmov ip, lr, s6, s7
- vldmiagt r1!, {s16-s23}
- ssat r4, #16, r4
- ssat r3, #16, r3
- ssat r6, #16, r6
- ssat r5, #16, r5
- pkhbt r3, r3, r4, lsl #16
- pkhbt r4, r5, r6, lsl #16
- vcvtgt.s32.f32 s0, s16
- vcvtgt.s32.f32 s1, s17
- vcvtgt.s32.f32 s2, s18
- vcvtgt.s32.f32 s3, s19
- vcvtgt.s32.f32 s4, s20
- vcvtgt.s32.f32 s5, s21
- vcvtgt.s32.f32 s6, s22
- vcvtgt.s32.f32 s7, s23
- ssat r8, #16, r8
- ssat r7, #16, r7
- ssat lr, #16, lr
- ssat ip, #16, ip
- pkhbt r5, r7, r8, lsl #16
- pkhbt r6, ip, lr, lsl #16
- stmia r0!, {r3-r6}
- bgt 1b
-
- vpop {d8-d11}
- pop {r4-r8,pc}
-endfunc
-#endif
diff --git a/mplayer/ffmpeg/libavcodec/arm/fft_init_arm.c b/mplayer/ffmpeg/libavcodec/arm/fft_init_arm.c
index bde12400..dff06895 100644
--- a/mplayer/ffmpeg/libavcodec/arm/fft_init_arm.c
+++ b/mplayer/ffmpeg/libavcodec/arm/fft_init_arm.c
@@ -34,7 +34,7 @@ void ff_synth_filter_float_neon(FFTContext *imdct,
float *synth_buf_ptr, int *synth_buf_offset,
float synth_buf2[32], const float window[512],
float out[32], const float in[32],
- float scale, float bias);
+ float scale);
av_cold void ff_fft_init_arm(FFTContext *s)
{
@@ -44,7 +44,7 @@ av_cold void ff_fft_init_arm(FFTContext *s)
s->imdct_calc = ff_imdct_calc_neon;
s->imdct_half = ff_imdct_half_neon;
s->mdct_calc = ff_mdct_calc_neon;
- s->permutation = FF_MDCT_PERM_INTERLEAVE;
+ s->mdct_permutation = FF_MDCT_PERM_INTERLEAVE;
}
}
diff --git a/mplayer/ffmpeg/libavcodec/arm/fmtconvert_init_arm.c b/mplayer/ffmpeg/libavcodec/arm/fmtconvert_init_arm.c
new file mode 100644
index 00000000..4b6e3939
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/arm/fmtconvert_init_arm.c
@@ -0,0 +1,48 @@
+/*
+ * ARM optimized Format Conversion Utils
+ *
+ * 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
+ */
+
+#include
+
+#include "libavcodec/avcodec.h"
+#include "libavcodec/fmtconvert.h"
+
+void ff_int32_to_float_fmul_scalar_neon(float *dst, const int *src,
+ float mul, int len);
+
+void ff_float_to_int16_neon(int16_t *dst, const float *src, long len);
+void ff_float_to_int16_interleave_neon(int16_t *, const float **, long, int);
+
+void ff_float_to_int16_vfp(int16_t *dst, const float *src, long len);
+
+void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx)
+{
+ if (HAVE_ARMVFP && HAVE_ARMV6) {
+ c->float_to_int16 = ff_float_to_int16_vfp;
+ }
+
+ if (HAVE_NEON) {
+ c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_neon;
+
+ if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
+ c->float_to_int16 = ff_float_to_int16_neon;
+ c->float_to_int16_interleave = ff_float_to_int16_interleave_neon;
+ }
+ }
+}
diff --git a/mplayer/ffmpeg/libavcodec/arm/fmtconvert_neon.S b/mplayer/ffmpeg/libavcodec/arm/fmtconvert_neon.S
new file mode 100644
index 00000000..359e57e4
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/arm/fmtconvert_neon.S
@@ -0,0 +1,391 @@
+/*
+ * ARM NEON optimised Format Conversion Utils
+ * Copyright (c) 2008 Mans Rullgard
+ *
+ * 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
+ */
+
+#include "config.h"
+#include "asm.S"
+
+ preserve8
+ .text
+
+function ff_float_to_int16_neon, export=1
+ subs r2, r2, #8
+ vld1.64 {d0-d1}, [r1,:128]!
+ vcvt.s32.f32 q8, q0, #16
+ vld1.64 {d2-d3}, [r1,:128]!
+ vcvt.s32.f32 q9, q1, #16
+ beq 3f
+ bics ip, r2, #15
+ beq 2f
+1: subs ip, ip, #16
+ vshrn.s32 d4, q8, #16
+ vld1.64 {d0-d1}, [r1,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vshrn.s32 d5, q9, #16
+ vld1.64 {d2-d3}, [r1,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ vshrn.s32 d6, q0, #16
+ vst1.64 {d4-d5}, [r0,:128]!
+ vshrn.s32 d7, q1, #16
+ vld1.64 {d16-d17},[r1,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vld1.64 {d18-d19},[r1,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vst1.64 {d6-d7}, [r0,:128]!
+ bne 1b
+ ands r2, r2, #15
+ beq 3f
+2: vld1.64 {d0-d1}, [r1,:128]!
+ vshrn.s32 d4, q8, #16
+ vcvt.s32.f32 q0, q0, #16
+ vld1.64 {d2-d3}, [r1,:128]!
+ vshrn.s32 d5, q9, #16
+ vcvt.s32.f32 q1, q1, #16
+ vshrn.s32 d6, q0, #16
+ vst1.64 {d4-d5}, [r0,:128]!
+ vshrn.s32 d7, q1, #16
+ vst1.64 {d6-d7}, [r0,:128]!
+ bx lr
+3: vshrn.s32 d4, q8, #16
+ vshrn.s32 d5, q9, #16
+ vst1.64 {d4-d5}, [r0,:128]!
+ bx lr
+endfunc
+
+function ff_float_to_int16_interleave_neon, export=1
+ cmp r3, #2
+ ldrlt r1, [r1]
+ blt ff_float_to_int16_neon
+ bne 4f
+
+ ldr r3, [r1]
+ ldr r1, [r1, #4]
+
+ subs r2, r2, #8
+ vld1.64 {d0-d1}, [r3,:128]!
+ vcvt.s32.f32 q8, q0, #16
+ vld1.64 {d2-d3}, [r3,:128]!
+ vcvt.s32.f32 q9, q1, #16
+ vld1.64 {d20-d21},[r1,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vld1.64 {d22-d23},[r1,:128]!
+ vcvt.s32.f32 q11, q11, #16
+ beq 3f
+ bics ip, r2, #15
+ beq 2f
+1: subs ip, ip, #16
+ vld1.64 {d0-d1}, [r3,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vsri.32 q10, q8, #16
+ vld1.64 {d2-d3}, [r3,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ vld1.64 {d24-d25},[r1,:128]!
+ vcvt.s32.f32 q12, q12, #16
+ vld1.64 {d26-d27},[r1,:128]!
+ vsri.32 q11, q9, #16
+ vst1.64 {d20-d21},[r0,:128]!
+ vcvt.s32.f32 q13, q13, #16
+ vst1.64 {d22-d23},[r0,:128]!
+ vsri.32 q12, q0, #16
+ vld1.64 {d16-d17},[r3,:128]!
+ vsri.32 q13, q1, #16
+ vst1.64 {d24-d25},[r0,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vld1.64 {d18-d19},[r3,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vld1.64 {d20-d21},[r1,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vld1.64 {d22-d23},[r1,:128]!
+ vcvt.s32.f32 q11, q11, #16
+ vst1.64 {d26-d27},[r0,:128]!
+ bne 1b
+ ands r2, r2, #15
+ beq 3f
+2: vsri.32 q10, q8, #16
+ vld1.64 {d0-d1}, [r3,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vld1.64 {d2-d3}, [r3,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ vld1.64 {d24-d25},[r1,:128]!
+ vcvt.s32.f32 q12, q12, #16
+ vsri.32 q11, q9, #16
+ vld1.64 {d26-d27},[r1,:128]!
+ vcvt.s32.f32 q13, q13, #16
+ vst1.64 {d20-d21},[r0,:128]!
+ vsri.32 q12, q0, #16
+ vst1.64 {d22-d23},[r0,:128]!
+ vsri.32 q13, q1, #16
+ vst1.64 {d24-d27},[r0,:128]!
+ bx lr
+3: vsri.32 q10, q8, #16
+ vsri.32 q11, q9, #16
+ vst1.64 {d20-d23},[r0,:128]!
+ bx lr
+
+4: push {r4-r8,lr}
+ cmp r3, #4
+ lsl ip, r3, #1
+ blt 4f
+
+ @ 4 channels
+5: ldmia r1!, {r4-r7}
+ mov lr, r2
+ mov r8, r0
+ vld1.64 {d16-d17},[r4,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vld1.64 {d18-d19},[r5,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vld1.64 {d20-d21},[r6,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vld1.64 {d22-d23},[r7,:128]!
+ vcvt.s32.f32 q11, q11, #16
+6: subs lr, lr, #8
+ vld1.64 {d0-d1}, [r4,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vsri.32 q9, q8, #16
+ vld1.64 {d2-d3}, [r5,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ vsri.32 q11, q10, #16
+ vld1.64 {d4-d5}, [r6,:128]!
+ vcvt.s32.f32 q2, q2, #16
+ vzip.32 d18, d22
+ vld1.64 {d6-d7}, [r7,:128]!
+ vcvt.s32.f32 q3, q3, #16
+ vzip.32 d19, d23
+ vst1.64 {d18}, [r8], ip
+ vsri.32 q1, q0, #16
+ vst1.64 {d22}, [r8], ip
+ vsri.32 q3, q2, #16
+ vst1.64 {d19}, [r8], ip
+ vzip.32 d2, d6
+ vst1.64 {d23}, [r8], ip
+ vzip.32 d3, d7
+ beq 7f
+ vld1.64 {d16-d17},[r4,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vst1.64 {d2}, [r8], ip
+ vld1.64 {d18-d19},[r5,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vst1.64 {d6}, [r8], ip
+ vld1.64 {d20-d21},[r6,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vst1.64 {d3}, [r8], ip
+ vld1.64 {d22-d23},[r7,:128]!
+ vcvt.s32.f32 q11, q11, #16
+ vst1.64 {d7}, [r8], ip
+ b 6b
+7: vst1.64 {d2}, [r8], ip
+ vst1.64 {d6}, [r8], ip
+ vst1.64 {d3}, [r8], ip
+ vst1.64 {d7}, [r8], ip
+ subs r3, r3, #4
+ popeq {r4-r8,pc}
+ cmp r3, #4
+ add r0, r0, #8
+ bge 5b
+
+ @ 2 channels
+4: cmp r3, #2
+ blt 4f
+ ldmia r1!, {r4-r5}
+ mov lr, r2
+ mov r8, r0
+ tst lr, #8
+ vld1.64 {d16-d17},[r4,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vld1.64 {d18-d19},[r5,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vld1.64 {d20-d21},[r4,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vld1.64 {d22-d23},[r5,:128]!
+ vcvt.s32.f32 q11, q11, #16
+ beq 6f
+ subs lr, lr, #8
+ beq 7f
+ vsri.32 d18, d16, #16
+ vsri.32 d19, d17, #16
+ vld1.64 {d16-d17},[r4,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vst1.32 {d18[0]}, [r8], ip
+ vsri.32 d22, d20, #16
+ vst1.32 {d18[1]}, [r8], ip
+ vsri.32 d23, d21, #16
+ vst1.32 {d19[0]}, [r8], ip
+ vst1.32 {d19[1]}, [r8], ip
+ vld1.64 {d18-d19},[r5,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vst1.32 {d22[0]}, [r8], ip
+ vst1.32 {d22[1]}, [r8], ip
+ vld1.64 {d20-d21},[r4,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vst1.32 {d23[0]}, [r8], ip
+ vst1.32 {d23[1]}, [r8], ip
+ vld1.64 {d22-d23},[r5,:128]!
+ vcvt.s32.f32 q11, q11, #16
+6: subs lr, lr, #16
+ vld1.64 {d0-d1}, [r4,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vsri.32 d18, d16, #16
+ vld1.64 {d2-d3}, [r5,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ vsri.32 d19, d17, #16
+ vld1.64 {d4-d5}, [r4,:128]!
+ vcvt.s32.f32 q2, q2, #16
+ vld1.64 {d6-d7}, [r5,:128]!
+ vcvt.s32.f32 q3, q3, #16
+ vst1.32 {d18[0]}, [r8], ip
+ vsri.32 d22, d20, #16
+ vst1.32 {d18[1]}, [r8], ip
+ vsri.32 d23, d21, #16
+ vst1.32 {d19[0]}, [r8], ip
+ vsri.32 d2, d0, #16
+ vst1.32 {d19[1]}, [r8], ip
+ vsri.32 d3, d1, #16
+ vst1.32 {d22[0]}, [r8], ip
+ vsri.32 d6, d4, #16
+ vst1.32 {d22[1]}, [r8], ip
+ vsri.32 d7, d5, #16
+ vst1.32 {d23[0]}, [r8], ip
+ vst1.32 {d23[1]}, [r8], ip
+ beq 6f
+ vld1.64 {d16-d17},[r4,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vst1.32 {d2[0]}, [r8], ip
+ vst1.32 {d2[1]}, [r8], ip
+ vld1.64 {d18-d19},[r5,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vst1.32 {d3[0]}, [r8], ip
+ vst1.32 {d3[1]}, [r8], ip
+ vld1.64 {d20-d21},[r4,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vst1.32 {d6[0]}, [r8], ip
+ vst1.32 {d6[1]}, [r8], ip
+ vld1.64 {d22-d23},[r5,:128]!
+ vcvt.s32.f32 q11, q11, #16
+ vst1.32 {d7[0]}, [r8], ip
+ vst1.32 {d7[1]}, [r8], ip
+ bgt 6b
+6: vst1.32 {d2[0]}, [r8], ip
+ vst1.32 {d2[1]}, [r8], ip
+ vst1.32 {d3[0]}, [r8], ip
+ vst1.32 {d3[1]}, [r8], ip
+ vst1.32 {d6[0]}, [r8], ip
+ vst1.32 {d6[1]}, [r8], ip
+ vst1.32 {d7[0]}, [r8], ip
+ vst1.32 {d7[1]}, [r8], ip
+ b 8f
+7: vsri.32 d18, d16, #16
+ vsri.32 d19, d17, #16
+ vst1.32 {d18[0]}, [r8], ip
+ vsri.32 d22, d20, #16
+ vst1.32 {d18[1]}, [r8], ip
+ vsri.32 d23, d21, #16
+ vst1.32 {d19[0]}, [r8], ip
+ vst1.32 {d19[1]}, [r8], ip
+ vst1.32 {d22[0]}, [r8], ip
+ vst1.32 {d22[1]}, [r8], ip
+ vst1.32 {d23[0]}, [r8], ip
+ vst1.32 {d23[1]}, [r8], ip
+8: subs r3, r3, #2
+ add r0, r0, #4
+ popeq {r4-r8,pc}
+
+ @ 1 channel
+4: ldr r4, [r1],#4
+ tst r2, #8
+ mov lr, r2
+ mov r5, r0
+ vld1.64 {d0-d1}, [r4,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vld1.64 {d2-d3}, [r4,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ bne 8f
+6: subs lr, lr, #16
+ vld1.64 {d4-d5}, [r4,:128]!
+ vcvt.s32.f32 q2, q2, #16
+ vld1.64 {d6-d7}, [r4,:128]!
+ vcvt.s32.f32 q3, q3, #16
+ vst1.16 {d0[1]}, [r5,:16], ip
+ vst1.16 {d0[3]}, [r5,:16], ip
+ vst1.16 {d1[1]}, [r5,:16], ip
+ vst1.16 {d1[3]}, [r5,:16], ip
+ vst1.16 {d2[1]}, [r5,:16], ip
+ vst1.16 {d2[3]}, [r5,:16], ip
+ vst1.16 {d3[1]}, [r5,:16], ip
+ vst1.16 {d3[3]}, [r5,:16], ip
+ beq 7f
+ vld1.64 {d0-d1}, [r4,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vld1.64 {d2-d3}, [r4,:128]!
+ vcvt.s32.f32 q1, q1, #16
+7: vst1.16 {d4[1]}, [r5,:16], ip
+ vst1.16 {d4[3]}, [r5,:16], ip
+ vst1.16 {d5[1]}, [r5,:16], ip
+ vst1.16 {d5[3]}, [r5,:16], ip
+ vst1.16 {d6[1]}, [r5,:16], ip
+ vst1.16 {d6[3]}, [r5,:16], ip
+ vst1.16 {d7[1]}, [r5,:16], ip
+ vst1.16 {d7[3]}, [r5,:16], ip
+ bgt 6b
+ pop {r4-r8,pc}
+8: subs lr, lr, #8
+ vst1.16 {d0[1]}, [r5,:16], ip
+ vst1.16 {d0[3]}, [r5,:16], ip
+ vst1.16 {d1[1]}, [r5,:16], ip
+ vst1.16 {d1[3]}, [r5,:16], ip
+ vst1.16 {d2[1]}, [r5,:16], ip
+ vst1.16 {d2[3]}, [r5,:16], ip
+ vst1.16 {d3[1]}, [r5,:16], ip
+ vst1.16 {d3[3]}, [r5,:16], ip
+ popeq {r4-r8,pc}
+ vld1.64 {d0-d1}, [r4,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vld1.64 {d2-d3}, [r4,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ b 6b
+endfunc
+
+function ff_int32_to_float_fmul_scalar_neon, export=1
+VFP vdup.32 q0, d0[0]
+VFP len .req r2
+NOVFP vdup.32 q0, r2
+NOVFP len .req r3
+
+ vld1.32 {q1},[r1,:128]!
+ vcvt.f32.s32 q3, q1
+ vld1.32 {q2},[r1,:128]!
+ vcvt.f32.s32 q8, q2
+1: subs len, len, #8
+ pld [r1, #16]
+ vmul.f32 q9, q3, q0
+ vmul.f32 q10, q8, q0
+ beq 2f
+ vld1.32 {q1},[r1,:128]!
+ vcvt.f32.s32 q3, q1
+ vld1.32 {q2},[r1,:128]!
+ vcvt.f32.s32 q8, q2
+ vst1.32 {q9}, [r0,:128]!
+ vst1.32 {q10},[r0,:128]!
+ b 1b
+2: vst1.32 {q9}, [r0,:128]!
+ vst1.32 {q10},[r0,:128]!
+ bx lr
+ .unreq len
+endfunc
diff --git a/mplayer/ffmpeg/libavcodec/arm/fmtconvert_vfp.S b/mplayer/ffmpeg/libavcodec/arm/fmtconvert_vfp.S
new file mode 100644
index 00000000..1d19e775
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/arm/fmtconvert_vfp.S
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2008 Siarhei Siamashka
+ *
+ * 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
+ */
+
+#include "config.h"
+#include "asm.S"
+
+ .syntax unified
+
+/**
+ * ARM VFP optimized float to int16 conversion.
+ * Assume that len is a positive number and is multiple of 8, destination
+ * buffer is at least 4 bytes aligned (8 bytes alignment is better for
+ * performance), little endian byte sex
+ */
+@ void ff_float_to_int16_vfp(int16_t *dst, const float *src, int len)
+function ff_float_to_int16_vfp, export=1
+ push {r4-r8,lr}
+ vpush {d8-d11}
+ vldmia r1!, {s16-s23}
+ vcvt.s32.f32 s0, s16
+ vcvt.s32.f32 s1, s17
+ vcvt.s32.f32 s2, s18
+ vcvt.s32.f32 s3, s19
+ vcvt.s32.f32 s4, s20
+ vcvt.s32.f32 s5, s21
+ vcvt.s32.f32 s6, s22
+ vcvt.s32.f32 s7, s23
+1:
+ subs r2, r2, #8
+ vmov r3, r4, s0, s1
+ vmov r5, r6, s2, s3
+ vmov r7, r8, s4, s5
+ vmov ip, lr, s6, s7
+ vldmiagt r1!, {s16-s23}
+ ssat r4, #16, r4
+ ssat r3, #16, r3
+ ssat r6, #16, r6
+ ssat r5, #16, r5
+ pkhbt r3, r3, r4, lsl #16
+ pkhbt r4, r5, r6, lsl #16
+ vcvtgt.s32.f32 s0, s16
+ vcvtgt.s32.f32 s1, s17
+ vcvtgt.s32.f32 s2, s18
+ vcvtgt.s32.f32 s3, s19
+ vcvtgt.s32.f32 s4, s20
+ vcvtgt.s32.f32 s5, s21
+ vcvtgt.s32.f32 s6, s22
+ vcvtgt.s32.f32 s7, s23
+ ssat r8, #16, r8
+ ssat r7, #16, r7
+ ssat lr, #16, lr
+ ssat ip, #16, ip
+ pkhbt r5, r7, r8, lsl #16
+ pkhbt r6, ip, lr, lsl #16
+ stmia r0!, {r3-r6}
+ bgt 1b
+
+ vpop {d8-d11}
+ pop {r4-r8,pc}
+endfunc
diff --git a/mplayer/ffmpeg/libavcodec/arm/synth_filter_neon.S b/mplayer/ffmpeg/libavcodec/arm/synth_filter_neon.S
index a7c23df0..1464abe5 100644
--- a/mplayer/ffmpeg/libavcodec/arm/synth_filter_neon.S
+++ b/mplayer/ffmpeg/libavcodec/arm/synth_filter_neon.S
@@ -42,7 +42,7 @@ VFP vpop {d0}
ldr r5, [sp, #9*4] @ window
ldr r2, [sp, #10*4] @ out
-NOVFP vldr d0, [sp, #12*4] @ scale, bias
+NOVFP vldr s0, [sp, #12*4] @ scale
add r8, r9, #12*4
mov lr, #64*4
@@ -90,10 +90,8 @@ NOVFP vldr d0, [sp, #12*4] @ scale, bias
sub r11, r11, #512*4
b 2b
3:
- vdup.32 q8, d0[1]
- vdup.32 q9, d0[1]
- vmla.f32 q8, q10, d0[0]
- vmla.f32 q9, q1, d0[0]
+ vmul.f32 q8, q10, d0[0]
+ vmul.f32 q9, q1, d0[0]
vst1.32 {q3}, [r3,:128]
sub r3, r3, #16*4
vst1.32 {q2}, [r3,:128]
diff --git a/mplayer/ffmpeg/libavcodec/arm/vp56_arith.h b/mplayer/ffmpeg/libavcodec/arm/vp56_arith.h
new file mode 100644
index 00000000..9bcb466b
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/arm/vp56_arith.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2010 Mans Rullgard
+ *
+ * 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_ARM_VP56_ARITH_H
+#define AVCODEC_ARM_VP56_ARITH_H
+
+#if HAVE_ARMV6 && HAVE_INLINE_ASM
+
+#define vp56_rac_get_prob vp56_rac_get_prob_armv6
+static inline int vp56_rac_get_prob_armv6(VP56RangeCoder *c, int pr)
+{
+ unsigned shift = ff_vp56_norm_shift[c->high];
+ unsigned code_word = c->code_word << shift;
+ unsigned high = c->high << shift;
+ unsigned bit;
+
+ __asm__ volatile ("adds %3, %3, %0 \n"
+ "cmpcs %7, %4 \n"
+ "ldrcsh %2, [%4], #2 \n"
+ "rsb %0, %6, #256 \n"
+ "smlabb %0, %5, %6, %0 \n"
+ "rev16cs %2, %2 \n"
+ "orrcs %1, %1, %2, lsl %3 \n"
+ "subcs %3, %3, #16 \n"
+ "lsr %0, %0, #8 \n"
+ "cmp %1, %0, lsl #16 \n"
+ "subge %1, %1, %0, lsl #16 \n"
+ "subge %0, %5, %0 \n"
+ "movge %2, #1 \n"
+ "movlt %2, #0 \n"
+ : "=&r"(c->high), "=&r"(c->code_word), "=&r"(bit),
+ "+&r"(c->bits), "+&r"(c->buffer)
+ : "r"(high), "r"(pr), "r"(c->end - 1),
+ "0"(shift), "1"(code_word));
+
+ return bit;
+}
+
+#define vp56_rac_get_prob_branchy vp56_rac_get_prob_branchy_armv6
+static inline int vp56_rac_get_prob_branchy_armv6(VP56RangeCoder *c, int pr)
+{
+ unsigned shift = ff_vp56_norm_shift[c->high];
+ unsigned code_word = c->code_word << shift;
+ unsigned high = c->high << shift;
+ unsigned low;
+ unsigned tmp;
+
+ __asm__ volatile ("adds %3, %3, %0 \n"
+ "cmpcs %7, %4 \n"
+ "ldrcsh %2, [%4], #2 \n"
+ "rsb %0, %6, #256 \n"
+ "smlabb %0, %5, %6, %0 \n"
+ "rev16cs %2, %2 \n"
+ "orrcs %1, %1, %2, lsl %3 \n"
+ "subcs %3, %3, #16 \n"
+ "lsr %0, %0, #8 \n"
+ "lsl %2, %0, #16 \n"
+ : "=&r"(low), "+&r"(code_word), "=&r"(tmp),
+ "+&r"(c->bits), "+&r"(c->buffer)
+ : "r"(high), "r"(pr), "r"(c->end - 1), "0"(shift));
+
+ if (code_word >= tmp) {
+ c->high = high - low;
+ c->code_word = code_word - tmp;
+ return 1;
+ }
+
+ c->high = low;
+ c->code_word = code_word;
+ return 0;
+}
+
+#endif
+
+#endif
diff --git a/mplayer/ffmpeg/libavcore/internal.h b/mplayer/ffmpeg/libavcodec/arm/vp8.h
similarity index 67%
rename from mplayer/ffmpeg/libavcore/internal.h
rename to mplayer/ffmpeg/libavcodec/arm/vp8.h
index 3960bd39..90e7344b 100644
--- a/mplayer/ffmpeg/libavcore/internal.h
+++ b/mplayer/ffmpeg/libavcodec/arm/vp8.h
@@ -1,4 +1,4 @@
-/*
+/**
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
@@ -16,16 +16,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCORE_INTERNAL_H
-#define AVCORE_INTERNAL_H
-
-/**
- * @file
- * internal functions
- */
-
-#include "avcore.h"
+#ifndef AVCODEC_ARM_VP8_H
+#define AVCODEC_ARM_VP8_H
-int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt);
+#if HAVE_ARMV6
+#define decode_block_coeffs_internal ff_decode_block_coeffs_armv6
+int ff_decode_block_coeffs_armv6(VP56RangeCoder *rc, DCTELEM block[16],
+ uint8_t probs[8][3][NUM_DCT_TOKENS-1],
+ int i, uint8_t *token_prob, int16_t qmul[2]);
+#endif
-#endif /* AVCORE_INTERNAL_H */
+#endif
diff --git a/mplayer/ffmpeg/libavcodec/arm/vp8_armv6.S b/mplayer/ffmpeg/libavcodec/arm/vp8_armv6.S
new file mode 100644
index 00000000..d981db81
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/arm/vp8_armv6.S
@@ -0,0 +1,220 @@
+/**
+ * Copyright (C) 2010 Mans Rullgard
+ *
+ * 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
+ */
+
+#include "asm.S"
+
+ .syntax unified
+
+.macro rac_get_prob h, bs, buf, cw, pr, t0, t1
+ adds \bs, \bs, \t0
+ lsl \cw, \cw, \t0
+ lsl \t0, \h, \t0
+ rsb \h, \pr, #256
+ ldrhcs \t1, [\buf], #2
+ smlabb \h, \t0, \pr, \h
+ rev16cs \t1, \t1
+ orrcs \cw, \cw, \t1, lsl \bs
+ subcs \bs, \bs, #16
+ lsr \h, \h, #8
+ cmp \cw, \h, lsl #16
+ subge \cw, \cw, \h, lsl #16
+ subge \h, \t0, \h
+.endm
+
+.macro rac_get_128 h, bs, buf, cw, t0, t1
+ adds \bs, \bs, \t0
+ lsl \cw, \cw, \t0
+ lsl \t0, \h, \t0
+ ldrhcs \t1, [\buf], #2
+ mov \h, #128
+ rev16cs \t1, \t1
+ add \h, \h, \t0, lsl #7
+ orrcs \cw, \cw, \t1, lsl \bs
+ subcs \bs, \bs, #16
+ lsr \h, \h, #8
+ cmp \cw, \h, lsl #16
+ subge \cw, \cw, \h, lsl #16
+ subge \h, \t0, \h
+.endm
+
+function ff_decode_block_coeffs_armv6, export=1
+ push {r0,r1,r4-r11,lr}
+ movrel lr, X(ff_vp56_norm_shift)
+ ldrd r4, r5, [sp, #44] @ token_prob, qmul
+ cmp r3, #0
+ ldr r11, [r5]
+ ldm r0, {r5-r7} @ high, bits, buf
+ pkhtbne r11, r11, r11, asr #16
+ ldr r8, [r0, #16] @ code_word
+0:
+ ldrb r9, [lr, r5]
+ add r3, r3, #1
+ ldrb r0, [r4, #1]
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ blt 2f
+
+ ldrb r9, [lr, r5]
+ ldrb r0, [r4, #2]
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ ldrb r9, [lr, r5]
+ bge 3f
+
+ add r4, r3, r3, lsl #5
+ sxth r12, r11
+ add r4, r2, r4
+ adds r6, r6, r9
+ add r4, r4, #11
+ lsl r8, r8, r9
+ ldrhcs r10, [r7], #2
+ lsl r9, r5, r9
+ mov r5, #128
+ rev16cs r10, r10
+ add r5, r5, r9, lsl #7
+ orrcs r8, r8, r10, lsl r6
+ subcs r6, r6, #16
+ lsr r5, r5, #8
+ cmp r8, r5, lsl #16
+ movrel r10, zigzag_scan-1
+ subge r8, r8, r5, lsl #16
+ subge r5, r9, r5
+ ldrb r10, [r10, r3]
+ rsbge r12, r12, #0
+ cmp r3, #16
+ strh r12, [r1, r10]
+ bge 6f
+5:
+ ldrb r9, [lr, r5]
+ ldrb r0, [r4]
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ pkhtb r11, r11, r11, asr #16
+ bge 0b
+
+6:
+ ldr r0, [sp]
+ ldr r9, [r0, #12]
+ cmp r7, r9
+ movhi r7, r9
+ stm r0, {r5-r7} @ high, bits, buf
+ str r8, [r0, #16] @ code_word
+
+ add sp, sp, #8
+ mov r0, r3
+ pop {r4-r11,pc}
+2:
+ add r4, r3, r3, lsl #5
+ cmp r3, #16
+ add r4, r2, r4
+ pkhtb r11, r11, r11, asr #16
+ bne 0b
+ b 6b
+3:
+ ldrb r0, [r4, #3]
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ ldrb r9, [lr, r5]
+ bge 1f
+
+ mov r12, #2
+ ldrb r0, [r4, #4]
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ addge r12, #1
+ ldrb r9, [lr, r5]
+ blt 4f
+ ldrb r0, [r4, #5]
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ addge r12, #1
+ ldrb r9, [lr, r5]
+ b 4f
+1:
+ ldrb r0, [r4, #6]
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ ldrb r9, [lr, r5]
+ bge 3f
+
+ ldrb r0, [r4, #7]
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ ldrb r9, [lr, r5]
+ bge 2f
+
+ mov r12, #5
+ mov r0, #159
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ addge r12, r12, #1
+ ldrb r9, [lr, r5]
+ b 4f
+2:
+ mov r12, #7
+ mov r0, #165
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ addge r12, r12, #2
+ ldrb r9, [lr, r5]
+ mov r0, #145
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ addge r12, r12, #1
+ ldrb r9, [lr, r5]
+ b 4f
+3:
+ ldrb r0, [r4, #8]
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ addge r4, r4, #1
+ ldrb r9, [lr, r5]
+ movge r12, #2
+ movlt r12, #0
+ ldrb r0, [r4, #9]
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ mov r9, #8
+ addge r12, r12, #1
+ movrel r4, ff_vp8_dct_cat_prob
+ lsl r9, r9, r12
+ ldr r4, [r4, r12, lsl #2]
+ add r12, r9, #3
+ mov r1, #0
+ ldrb r0, [r4], #1
+1:
+ ldrb r9, [lr, r5]
+ lsl r1, r1, #1
+ rac_get_prob r5, r6, r7, r8, r0, r9, r10
+ ldrb r0, [r4], #1
+ addge r1, r1, #1
+ cmp r0, #0
+ bne 1b
+ ldrb r9, [lr, r5]
+ add r12, r12, r1
+ ldr r1, [sp, #4]
+4:
+ add r4, r3, r3, lsl #5
+ add r4, r2, r4
+ add r4, r4, #22
+ rac_get_128 r5, r6, r7, r8, r9, r10
+ rsbge r12, r12, #0
+ smulbb r12, r12, r11
+ movrel r9, zigzag_scan-1
+ ldrb r9, [r9, r3]
+ cmp r3, #16
+ strh r12, [r1, r9]
+ bge 6b
+ b 5b
+endfunc
+
+ .section .rodata
+zigzag_scan:
+ .byte 0, 2, 8, 16
+ .byte 10, 4, 6, 12
+ .byte 18, 24, 26, 20
+ .byte 14, 22, 28, 30
diff --git a/mplayer/ffmpeg/libavcodec/arm/vp8dsp_init_arm.c b/mplayer/ffmpeg/libavcodec/arm/vp8dsp_init_arm.c
new file mode 100644
index 00000000..c970ca54
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/arm/vp8dsp_init_arm.c
@@ -0,0 +1,163 @@
+/**
+ * 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
+ */
+
+#include
+#include "libavcodec/vp8dsp.h"
+
+void ff_vp8_luma_dc_wht_neon(DCTELEM block[4][4][16], DCTELEM dc[16]);
+void ff_vp8_luma_dc_wht_dc_neon(DCTELEM block[4][4][16], DCTELEM dc[16]);
+
+void ff_vp8_idct_add_neon(uint8_t *dst, DCTELEM block[16], int stride);
+void ff_vp8_idct_dc_add_neon(uint8_t *dst, DCTELEM block[16], int stride);
+void ff_vp8_idct_dc_add4y_neon(uint8_t *dst, DCTELEM block[4][16], int stride);
+void ff_vp8_idct_dc_add4uv_neon(uint8_t *dst, DCTELEM block[4][16], int stride);
+
+void ff_vp8_v_loop_filter16_neon(uint8_t *dst, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+void ff_vp8_h_loop_filter16_neon(uint8_t *dst, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+void ff_vp8_v_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+void ff_vp8_h_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+
+void ff_vp8_v_loop_filter16_inner_neon(uint8_t *dst, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+void ff_vp8_h_loop_filter16_inner_neon(uint8_t *dst, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+void ff_vp8_v_loop_filter8uv_inner_neon(uint8_t *dstU, uint8_t *dstV,
+ int stride, int flim_E, int flim_I,
+ int hev_thresh);
+void ff_vp8_h_loop_filter8uv_inner_neon(uint8_t *dstU, uint8_t *dstV,
+ int stride, int flim_E, int flim_I,
+ int hev_thresh);
+
+void ff_vp8_v_loop_filter16_simple_neon(uint8_t *dst, int stride, int flim);
+void ff_vp8_h_loop_filter16_simple_neon(uint8_t *dst, int stride, int flim);
+
+
+#define VP8_MC(n) \
+ void ff_put_vp8_##n##_neon(uint8_t *dst, int dststride, \
+ uint8_t *src, int srcstride, \
+ int h, int x, int y)
+
+#define VP8_EPEL(w) \
+ VP8_MC(pixels ## w); \
+ VP8_MC(epel ## w ## _h4); \
+ VP8_MC(epel ## w ## _h6); \
+ VP8_MC(epel ## w ## _v4); \
+ VP8_MC(epel ## w ## _h4v4); \
+ VP8_MC(epel ## w ## _h6v4); \
+ VP8_MC(epel ## w ## _v6); \
+ VP8_MC(epel ## w ## _h4v6); \
+ VP8_MC(epel ## w ## _h6v6)
+
+VP8_EPEL(16);
+VP8_EPEL(8);
+VP8_EPEL(4);
+
+VP8_MC(bilin16_h);
+VP8_MC(bilin16_v);
+VP8_MC(bilin16_hv);
+VP8_MC(bilin8_h);
+VP8_MC(bilin8_v);
+VP8_MC(bilin8_hv);
+VP8_MC(bilin4_h);
+VP8_MC(bilin4_v);
+VP8_MC(bilin4_hv);
+
+av_cold void ff_vp8dsp_init_arm(VP8DSPContext *dsp)
+{
+ if (HAVE_NEON) {
+ dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_neon;
+ dsp->vp8_luma_dc_wht_dc = ff_vp8_luma_dc_wht_dc_neon;
+
+ dsp->vp8_idct_add = ff_vp8_idct_add_neon;
+ dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_neon;
+ dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_neon;
+ dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_neon;
+
+ dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_neon;
+ dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_neon;
+ dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_neon;
+ dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_neon;
+
+ dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_neon;
+ dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_neon;
+ dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_neon;
+ dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_neon;
+
+ dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter16_simple_neon;
+ dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter16_simple_neon;
+
+ dsp->put_vp8_epel_pixels_tab[0][0][0] = ff_put_vp8_pixels16_neon;
+ dsp->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_neon;
+ dsp->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_neon;
+ dsp->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_neon;
+
+ dsp->put_vp8_epel_pixels_tab[1][0][0] = ff_put_vp8_pixels8_neon;
+ dsp->put_vp8_epel_pixels_tab[1][0][1] = ff_put_vp8_epel8_h4_neon;
+ dsp->put_vp8_epel_pixels_tab[1][0][2] = ff_put_vp8_epel8_h6_neon;
+ dsp->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_neon;
+ dsp->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_neon;
+ dsp->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_neon;
+ dsp->put_vp8_epel_pixels_tab[1][2][0] = ff_put_vp8_epel8_v6_neon;
+ dsp->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_neon;
+ dsp->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_neon;
+
+ dsp->put_vp8_epel_pixels_tab[2][0][0] = ff_put_vp8_pixels4_neon;
+ dsp->put_vp8_epel_pixels_tab[2][0][1] = ff_put_vp8_epel4_h4_neon;
+ dsp->put_vp8_epel_pixels_tab[2][0][2] = ff_put_vp8_epel4_h6_neon;
+ dsp->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_neon;
+ dsp->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_neon;
+ dsp->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_neon;
+ dsp->put_vp8_epel_pixels_tab[2][2][0] = ff_put_vp8_epel4_v6_neon;
+ dsp->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_neon;
+ dsp->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_neon;
+
+ dsp->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_neon;
+ dsp->put_vp8_bilinear_pixels_tab[0][0][1] = ff_put_vp8_bilin16_h_neon;
+ dsp->put_vp8_bilinear_pixels_tab[0][0][2] = ff_put_vp8_bilin16_h_neon;
+ dsp->put_vp8_bilinear_pixels_tab[0][1][0] = ff_put_vp8_bilin16_v_neon;
+ dsp->put_vp8_bilinear_pixels_tab[0][1][1] = ff_put_vp8_bilin16_hv_neon;
+ dsp->put_vp8_bilinear_pixels_tab[0][1][2] = ff_put_vp8_bilin16_hv_neon;
+ dsp->put_vp8_bilinear_pixels_tab[0][2][0] = ff_put_vp8_bilin16_v_neon;
+ dsp->put_vp8_bilinear_pixels_tab[0][2][1] = ff_put_vp8_bilin16_hv_neon;
+ dsp->put_vp8_bilinear_pixels_tab[0][2][2] = ff_put_vp8_bilin16_hv_neon;
+
+ dsp->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_neon;
+ dsp->put_vp8_bilinear_pixels_tab[1][0][1] = ff_put_vp8_bilin8_h_neon;
+ dsp->put_vp8_bilinear_pixels_tab[1][0][2] = ff_put_vp8_bilin8_h_neon;
+ dsp->put_vp8_bilinear_pixels_tab[1][1][0] = ff_put_vp8_bilin8_v_neon;
+ dsp->put_vp8_bilinear_pixels_tab[1][1][1] = ff_put_vp8_bilin8_hv_neon;
+ dsp->put_vp8_bilinear_pixels_tab[1][1][2] = ff_put_vp8_bilin8_hv_neon;
+ dsp->put_vp8_bilinear_pixels_tab[1][2][0] = ff_put_vp8_bilin8_v_neon;
+ dsp->put_vp8_bilinear_pixels_tab[1][2][1] = ff_put_vp8_bilin8_hv_neon;
+ dsp->put_vp8_bilinear_pixels_tab[1][2][2] = ff_put_vp8_bilin8_hv_neon;
+
+ dsp->put_vp8_bilinear_pixels_tab[2][0][0] = ff_put_vp8_pixels4_neon;
+ dsp->put_vp8_bilinear_pixels_tab[2][0][1] = ff_put_vp8_bilin4_h_neon;
+ dsp->put_vp8_bilinear_pixels_tab[2][0][2] = ff_put_vp8_bilin4_h_neon;
+ dsp->put_vp8_bilinear_pixels_tab[2][1][0] = ff_put_vp8_bilin4_v_neon;
+ dsp->put_vp8_bilinear_pixels_tab[2][1][1] = ff_put_vp8_bilin4_hv_neon;
+ dsp->put_vp8_bilinear_pixels_tab[2][1][2] = ff_put_vp8_bilin4_hv_neon;
+ dsp->put_vp8_bilinear_pixels_tab[2][2][0] = ff_put_vp8_bilin4_v_neon;
+ dsp->put_vp8_bilinear_pixels_tab[2][2][1] = ff_put_vp8_bilin4_hv_neon;
+ dsp->put_vp8_bilinear_pixels_tab[2][2][2] = ff_put_vp8_bilin4_hv_neon;
+ }
+}
diff --git a/mplayer/ffmpeg/libavcodec/arm/vp8dsp_neon.S b/mplayer/ffmpeg/libavcodec/arm/vp8dsp_neon.S
new file mode 100644
index 00000000..23330900
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/arm/vp8dsp_neon.S
@@ -0,0 +1,1912 @@
+/**
+ * VP8 NEON optimisations
+ *
+ * Copyright (c) 2010 Rob Clark
+ * Copyright (c) 2011 Mans Rullgard
+ *
+ * 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
+ */
+
+#include "asm.S"
+
+function ff_vp8_luma_dc_wht_neon, export=1
+ vld1.16 {q0-q1}, [r1,:128]
+ vmov.i16 q15, #0
+
+ vadd.i16 d4, d0, d3
+ vadd.i16 d6, d1, d2
+ vst1.16 {q15}, [r1,:128]!
+ vsub.i16 d7, d1, d2
+ vsub.i16 d5, d0, d3
+ vst1.16 {q15}, [r1,:128]
+ vadd.i16 q0, q2, q3
+ vsub.i16 q1, q2, q3
+
+ vmov.i16 q8, #3
+
+ vtrn.32 d0, d2
+ vtrn.32 d1, d3
+ vtrn.16 d0, d1
+ vtrn.16 d2, d3
+
+ vadd.i16 d0, d0, d16
+
+ vadd.i16 d4, d0, d3
+ vadd.i16 d6, d1, d2
+ vsub.i16 d7, d1, d2
+ vsub.i16 d5, d0, d3
+ vadd.i16 q0, q2, q3
+ vsub.i16 q1, q2, q3
+
+ vshr.s16 q0, q0, #3
+ vshr.s16 q1, q1, #3
+
+ mov r3, #32
+ vst1.16 {d0[0]}, [r0,:16], r3
+ vst1.16 {d1[0]}, [r0,:16], r3
+ vst1.16 {d2[0]}, [r0,:16], r3
+ vst1.16 {d3[0]}, [r0,:16], r3
+ vst1.16 {d0[1]}, [r0,:16], r3
+ vst1.16 {d1[1]}, [r0,:16], r3
+ vst1.16 {d2[1]}, [r0,:16], r3
+ vst1.16 {d3[1]}, [r0,:16], r3
+ vst1.16 {d0[2]}, [r0,:16], r3
+ vst1.16 {d1[2]}, [r0,:16], r3
+ vst1.16 {d2[2]}, [r0,:16], r3
+ vst1.16 {d3[2]}, [r0,:16], r3
+ vst1.16 {d0[3]}, [r0,:16], r3
+ vst1.16 {d1[3]}, [r0,:16], r3
+ vst1.16 {d2[3]}, [r0,:16], r3
+ vst1.16 {d3[3]}, [r0,:16], r3
+
+ bx lr
+endfunc
+
+function ff_vp8_luma_dc_wht_dc_neon, export=1
+ ldrsh r2, [r1]
+ mov r3, #0
+ add r2, r2, #3
+ strh r3, [r1]
+ asr r2, r2, #3
+ .rept 16
+ strh r2, [r0], #32
+ .endr
+ bx lr
+endfunc
+
+function ff_vp8_idct_add_neon, export=1
+ vld1.16 {q0-q1}, [r1,:128]
+ movw r3, #20091
+ movt r3, #35468/2
+ vdup.32 d4, r3
+
+ vmull.s16 q12, d1, d4[0]
+ vmull.s16 q13, d3, d4[0]
+ vqdmulh.s16 d20, d1, d4[1]
+ vqdmulh.s16 d23, d3, d4[1]
+ vshrn.s32 d21, q12, #16
+ vshrn.s32 d22, q13, #16
+ vadd.s16 d21, d21, d1
+ vadd.s16 d22, d22, d3
+
+ vadd.s16 d16, d0, d2
+ vsub.s16 d17, d0, d2
+ vadd.s16 d18, d21, d23
+ vsub.s16 d19, d20, d22
+ vadd.s16 q0, q8, q9
+ vsub.s16 q1, q8, q9
+
+ vtrn.32 d0, d3
+ vtrn.32 d1, d2
+ vtrn.16 d0, d1
+ vtrn.16 d3, d2
+
+ vmov.i16 q15, #0
+ vmull.s16 q12, d1, d4[0]
+ vst1.16 {q15}, [r1,:128]!
+ vmull.s16 q13, d2, d4[0]
+ vst1.16 {q15}, [r1,:128]
+ vqdmulh.s16 d21, d1, d4[1]
+ vqdmulh.s16 d23, d2, d4[1]
+ vshrn.s32 d20, q12, #16
+ vshrn.s32 d22, q13, #16
+ vadd.i16 d20, d20, d1
+ vadd.i16 d22, d22, d2
+
+ vadd.i16 d16, d0, d3
+ vsub.i16 d17, d0, d3
+ vadd.i16 d18, d20, d23
+ vld1.32 {d20[]}, [r0,:32], r2
+ vsub.i16 d19, d21, d22
+ vld1.32 {d22[]}, [r0,:32], r2
+ vadd.s16 q0, q8, q9
+ vld1.32 {d23[]}, [r0,:32], r2
+ vsub.s16 q1, q8, q9
+ vld1.32 {d21[]}, [r0,:32], r2
+ vrshr.s16 q0, q0, #3
+ vtrn.32 q10, q11
+ vrshr.s16 q1, q1, #3
+
+ sub r0, r0, r2, lsl #2
+
+ vtrn.32 d0, d3
+ vtrn.32 d1, d2
+ vtrn.16 d0, d1
+ vtrn.16 d3, d2
+
+ vaddw.u8 q0, q0, d20
+ vaddw.u8 q1, q1, d21
+ vqmovun.s16 d0, q0
+ vqmovun.s16 d1, q1
+
+ vst1.32 {d0[0]}, [r0,:32], r2
+ vst1.32 {d0[1]}, [r0,:32], r2
+ vst1.32 {d1[1]}, [r0,:32], r2
+ vst1.32 {d1[0]}, [r0,:32], r2
+
+ bx lr
+endfunc
+
+function ff_vp8_idct_dc_add_neon, export=1
+ mov r3, #0
+ ldrsh r12, [r1]
+ strh r3, [r1]
+ vdup.16 q1, r12
+ vrshr.s16 q1, q1, #3
+ vld1.32 {d0[]}, [r0,:32], r2
+ vld1.32 {d1[]}, [r0,:32], r2
+ vld1.32 {d0[1]}, [r0,:32], r2
+ vld1.32 {d1[1]}, [r0,:32], r2
+ vaddw.u8 q2, q1, d0
+ vaddw.u8 q3, q1, d1
+ sub r0, r0, r2, lsl #2
+ vqmovun.s16 d0, q2
+ vqmovun.s16 d1, q3
+ vst1.32 {d0[0]}, [r0,:32], r2
+ vst1.32 {d1[0]}, [r0,:32], r2
+ vst1.32 {d0[1]}, [r0,:32], r2
+ vst1.32 {d1[1]}, [r0,:32], r2
+ bx lr
+endfunc
+
+function ff_vp8_idct_dc_add4uv_neon, export=1
+ vmov.i16 d0, #0
+ mov r3, #32
+ vld1.16 {d16[]}, [r1,:16]
+ vst1.16 {d0[0]}, [r1,:16], r3
+ vld1.16 {d17[]}, [r1,:16]
+ vst1.16 {d0[0]}, [r1,:16], r3
+ vld1.16 {d18[]}, [r1,:16]
+ vst1.16 {d0[0]}, [r1,:16], r3
+ vld1.16 {d19[]}, [r1,:16]
+ vst1.16 {d0[0]}, [r1,:16], r3
+ mov r3, r0
+ vrshr.s16 q8, q8, #3 @ dc >>= 3
+ vld1.8 {d0}, [r0,:64], r2
+ vrshr.s16 q9, q9, #3
+ vld1.8 {d1}, [r0,:64], r2
+ vaddw.u8 q10, q8, d0
+ vld1.8 {d2}, [r0,:64], r2
+ vaddw.u8 q0, q8, d1
+ vld1.8 {d3}, [r0,:64], r2
+ vaddw.u8 q11, q8, d2
+ vld1.8 {d4}, [r0,:64], r2
+ vaddw.u8 q1, q8, d3
+ vld1.8 {d5}, [r0,:64], r2
+ vaddw.u8 q12, q9, d4
+ vld1.8 {d6}, [r0,:64], r2
+ vaddw.u8 q2, q9, d5
+ vld1.8 {d7}, [r0,:64], r2
+ vaddw.u8 q13, q9, d6
+ vqmovun.s16 d20, q10
+ vaddw.u8 q3, q9, d7
+ vqmovun.s16 d21, q0
+ vqmovun.s16 d22, q11
+ vst1.8 {d20}, [r3,:64], r2
+ vqmovun.s16 d23, q1
+ vst1.8 {d21}, [r3,:64], r2
+ vqmovun.s16 d24, q12
+ vst1.8 {d22}, [r3,:64], r2
+ vqmovun.s16 d25, q2
+ vst1.8 {d23}, [r3,:64], r2
+ vqmovun.s16 d26, q13
+ vst1.8 {d24}, [r3,:64], r2
+ vqmovun.s16 d27, q3
+ vst1.8 {d25}, [r3,:64], r2
+ vst1.8 {d26}, [r3,:64], r2
+ vst1.8 {d27}, [r3,:64], r2
+
+ bx lr
+endfunc
+
+function ff_vp8_idct_dc_add4y_neon, export=1
+ vmov.i16 d0, #0
+ mov r3, #32
+ vld1.16 {d16[]}, [r1,:16]
+ vst1.16 {d0[0]}, [r1,:16], r3
+ vld1.16 {d17[]}, [r1,:16]
+ vst1.16 {d0[0]}, [r1,:16], r3
+ vld1.16 {d18[]}, [r1,:16]
+ vst1.16 {d0[0]}, [r1,:16], r3
+ vld1.16 {d19[]}, [r1,:16]
+ vst1.16 {d0[0]}, [r1,:16], r3
+ vrshr.s16 q8, q8, #3 @ dc >>= 3
+ vld1.8 {q0}, [r0,:128], r2
+ vrshr.s16 q9, q9, #3
+ vld1.8 {q1}, [r0,:128], r2
+ vaddw.u8 q10, q8, d0
+ vld1.8 {q2}, [r0,:128], r2
+ vaddw.u8 q0, q9, d1
+ vld1.8 {q3}, [r0,:128], r2
+ vaddw.u8 q11, q8, d2
+ vaddw.u8 q1, q9, d3
+ vaddw.u8 q12, q8, d4
+ vaddw.u8 q2, q9, d5
+ vaddw.u8 q13, q8, d6
+ vaddw.u8 q3, q9, d7
+ sub r0, r0, r2, lsl #2
+ vqmovun.s16 d20, q10
+ vqmovun.s16 d21, q0
+ vqmovun.s16 d22, q11
+ vqmovun.s16 d23, q1
+ vqmovun.s16 d24, q12
+ vst1.8 {q10}, [r0,:128], r2
+ vqmovun.s16 d25, q2
+ vst1.8 {q11}, [r0,:128], r2
+ vqmovun.s16 d26, q13
+ vst1.8 {q12}, [r0,:128], r2
+ vqmovun.s16 d27, q3
+ vst1.8 {q13}, [r0,:128], r2
+
+ bx lr
+endfunc
+
+@ Register layout:
+@ P3..Q3 -> q0..q7
+@ flim_E -> q14
+@ flim_I -> q15
+@ hev_thresh -> r12
+@
+.macro vp8_loop_filter, inner=0, simple=0
+ .if \simple
+ vabd.u8 q9, q3, q4 @ abs(P0-Q0)
+ vabd.u8 q15, q2, q5 @ abs(P1-Q1)
+ vqadd.u8 q9, q9, q9 @ abs(P0-Q0) * 2
+ vshr.u8 q10, q15, #1 @ abs(P1-Q1) / 2
+ vqadd.u8 q11, q9, q10 @ (abs(P0-Q0)*2) + (abs(P1-Q1)/2)
+ vmov.i8 q13, #0x80
+ vcle.u8 q8, q11, q14 @ (abs(P0-Q0)*2) + (abs(P1-Q1)/2) <= flim
+ .else
+ @ calculate hev and normal_limit:
+ vabd.u8 q12, q2, q3 @ abs(P1-P0)
+ vabd.u8 q13, q5, q4 @ abs(Q1-Q0)
+ vabd.u8 q10, q0, q1 @ abs(P3-P2)
+ vabd.u8 q11, q1, q2 @ abs(P2-P1)
+ vcle.u8 q8, q12, q15 @ abs(P1-P0) <= flim_I
+ vcle.u8 q9, q13, q15 @ abs(Q1-Q0) <= flim_I
+ vcle.u8 q10, q10, q15 @ abs(P3-P2) <= flim_I
+ vcle.u8 q11, q11, q15 @ abs(P2-P1) <= flim_I
+ vand q8, q8, q9
+ vabd.u8 q9, q7, q6 @ abs(Q3-Q2)
+ vand q8, q8, q11
+ vabd.u8 q11, q6, q5 @ abs(Q2-Q1)
+ vand q8, q8, q10
+ vcle.u8 q10, q9, q15 @ abs(Q3-Q2) <= flim_I
+ vcle.u8 q11, q11, q15 @ abs(Q2-Q1) <= flim_I
+ vabd.u8 q9, q3, q4 @ abs(P0-Q0)
+ vabd.u8 q15, q2, q5 @ abs(P1-Q1)
+ vand q8, q8, q10
+ vqadd.u8 q9, q9, q9 @ abs(P0-Q0) * 2
+ vand q8, q8, q11
+ vshr.u8 q10, q15, #1 @ abs(P1-Q1) / 2
+ vdup.8 q15, r12 @ hev_thresh
+ vqadd.u8 q11, q9, q10 @ (abs(P0-Q0)*2) + (abs(P1-Q1)/2)
+ vcgt.u8 q12, q12, q15 @ abs(P1-P0) > hev_thresh
+ vcle.u8 q11, q11, q14 @ (abs(P0-Q0)*2) + (abs(P1-Q1)/2) <= flim_E
+ vcgt.u8 q14, q13, q15 @ abs(Q1-Q0) > hev_thresh
+ vand q8, q8, q11
+ vmov.i8 q13, #0x80
+ vorr q9, q12, q14
+ .endif
+
+ @ at this point:
+ @ q8: normal_limit
+ @ q9: hev
+
+ @ convert to signed value:
+ veor q3, q3, q13 @ PS0 = P0 ^ 0x80
+ veor q4, q4, q13 @ QS0 = Q0 ^ 0x80
+
+ vmov.i16 q12, #3
+ vsubl.s8 q10, d8, d6 @ QS0 - PS0
+ vsubl.s8 q11, d9, d7 @ (widened to 16bit)
+ veor q2, q2, q13 @ PS1 = P1 ^ 0x80
+ veor q5, q5, q13 @ QS1 = Q1 ^ 0x80
+ vmul.i16 q10, q10, q12 @ w = 3 * (QS0 - PS0)
+ vmul.i16 q11, q11, q12
+
+ vqsub.s8 q12, q2, q5 @ clamp(PS1-QS1)
+ vmov.i8 q14, #4
+ vmov.i8 q15, #3
+ .if \inner
+ vand q12, q12, q9 @ if(hev) w += clamp(PS1-QS1)
+ .endif
+ vaddw.s8 q10, q10, d24 @ w += clamp(PS1-QS1)
+ vaddw.s8 q11, q11, d25
+ vqmovn.s16 d20, q10 @ narrow result back into q10
+ vqmovn.s16 d21, q11
+ .if !\inner && !\simple
+ veor q1, q1, q13 @ PS2 = P2 ^ 0x80
+ veor q6, q6, q13 @ QS2 = Q2 ^ 0x80
+ .endif
+ vand q10, q10, q8 @ w &= normal_limit
+
+ @ registers used at this point..
+ @ q0 -> P3 (don't corrupt)
+ @ q1-q6 -> PS2-QS2
+ @ q7 -> Q3 (don't corrupt)
+ @ q9 -> hev
+ @ q10 -> w
+ @ q13 -> #0x80
+ @ q14 -> #4
+ @ q15 -> #3
+ @ q8, q11, q12 -> unused
+
+ @ filter_common: is4tap==1
+ @ c1 = clamp(w + 4) >> 3;
+ @ c2 = clamp(w + 3) >> 3;
+ @ Q0 = s2u(QS0 - c1);
+ @ P0 = s2u(PS0 + c2);
+
+ .if \simple
+ vqadd.s8 q11, q10, q14 @ c1 = clamp((w&hev)+4)
+ vqadd.s8 q12, q10, q15 @ c2 = clamp((w&hev)+3)
+ vshr.s8 q11, q11, #3 @ c1 >>= 3
+ vshr.s8 q12, q12, #3 @ c2 >>= 3
+ vqsub.s8 q4, q4, q11 @ QS0 = clamp(QS0-c1)
+ vqadd.s8 q3, q3, q12 @ PS0 = clamp(PS0+c2)
+ veor q4, q4, q13 @ Q0 = QS0 ^ 0x80
+ veor q3, q3, q13 @ P0 = PS0 ^ 0x80
+ veor q5, q5, q13 @ Q1 = QS1 ^ 0x80
+ veor q2, q2, q13 @ P1 = PS1 ^ 0x80
+ .elseif \inner
+ @ the !is4tap case of filter_common, only used for inner blocks
+ @ c3 = ((c1&~hev) + 1) >> 1;
+ @ Q1 = s2u(QS1 - c3);
+ @ P1 = s2u(PS1 + c3);
+ vqadd.s8 q11, q10, q14 @ c1 = clamp((w&hev)+4)
+ vqadd.s8 q12, q10, q15 @ c2 = clamp((w&hev)+3)
+ vshr.s8 q11, q11, #3 @ c1 >>= 3
+ vshr.s8 q12, q12, #3 @ c2 >>= 3
+ vqsub.s8 q4, q4, q11 @ QS0 = clamp(QS0-c1)
+ vqadd.s8 q3, q3, q12 @ PS0 = clamp(PS0+c2)
+ vbic q11, q11, q9 @ c1 & ~hev
+ veor q4, q4, q13 @ Q0 = QS0 ^ 0x80
+ vrshr.s8 q11, q11, #1 @ c3 >>= 1
+ veor q3, q3, q13 @ P0 = PS0 ^ 0x80
+ vqsub.s8 q5, q5, q11 @ QS1 = clamp(QS1-c3)
+ vqadd.s8 q2, q2, q11 @ PS1 = clamp(PS1+c3)
+ veor q5, q5, q13 @ Q1 = QS1 ^ 0x80
+ veor q2, q2, q13 @ P1 = PS1 ^ 0x80
+ .else
+ vand q12, q10, q9 @ w & hev
+ vqadd.s8 q11, q12, q14 @ c1 = clamp((w&hev)+4)
+ vqadd.s8 q12, q12, q15 @ c2 = clamp((w&hev)+3)
+ vshr.s8 q11, q11, #3 @ c1 >>= 3
+ vshr.s8 q12, q12, #3 @ c2 >>= 3
+ vbic q10, q10, q9 @ w &= ~hev
+ vqsub.s8 q4, q4, q11 @ QS0 = clamp(QS0-c1)
+ vqadd.s8 q3, q3, q12 @ PS0 = clamp(PS0+c2)
+
+ @ filter_mbedge:
+ @ a = clamp((27*w + 63) >> 7);
+ @ Q0 = s2u(QS0 - a);
+ @ P0 = s2u(PS0 + a);
+ @ a = clamp((18*w + 63) >> 7);
+ @ Q1 = s2u(QS1 - a);
+ @ P1 = s2u(PS1 + a);
+ @ a = clamp((9*w + 63) >> 7);
+ @ Q2 = s2u(QS2 - a);
+ @ P2 = s2u(PS2 + a);
+ vmov.i16 q9, #63
+ vshll.s8 q14, d20, #3
+ vshll.s8 q15, d21, #3
+ vaddw.s8 q14, q14, d20
+ vaddw.s8 q15, q15, d21
+ vadd.s16 q8, q9, q14
+ vadd.s16 q9, q9, q15 @ 9*w + 63
+ vadd.s16 q11, q8, q14
+ vadd.s16 q12, q9, q15 @ 18*w + 63
+ vadd.s16 q14, q11, q14
+ vadd.s16 q15, q12, q15 @ 27*w + 63
+ vqshrn.s16 d16, q8, #7
+ vqshrn.s16 d17, q9, #7 @ clamp(( 9*w + 63)>>7)
+ vqshrn.s16 d22, q11, #7
+ vqshrn.s16 d23, q12, #7 @ clamp((18*w + 63)>>7)
+ vqshrn.s16 d28, q14, #7
+ vqshrn.s16 d29, q15, #7 @ clamp((27*w + 63)>>7)
+ vqadd.s8 q1, q1, q8 @ PS2 = clamp(PS2+a)
+ vqsub.s8 q6, q6, q8 @ QS2 = clamp(QS2-a)
+ vqadd.s8 q2, q2, q11 @ PS1 = clamp(PS1+a)
+ vqsub.s8 q5, q5, q11 @ QS1 = clamp(QS1-a)
+ vqadd.s8 q3, q3, q14 @ PS0 = clamp(PS0+a)
+ vqsub.s8 q4, q4, q14 @ QS0 = clamp(QS0-a)
+ veor q3, q3, q13 @ P0 = PS0 ^ 0x80
+ veor q4, q4, q13 @ Q0 = QS0 ^ 0x80
+ veor q2, q2, q13 @ P1 = PS1 ^ 0x80
+ veor q5, q5, q13 @ Q1 = QS1 ^ 0x80
+ veor q1, q1, q13 @ P2 = PS2 ^ 0x80
+ veor q6, q6, q13 @ Q2 = QS2 ^ 0x80
+ .endif
+.endm
+
+.macro transpose8x16matrix
+ vtrn.32 q0, q4
+ vtrn.32 q1, q5
+ vtrn.32 q2, q6
+ vtrn.32 q3, q7
+
+ vtrn.16 q0, q2
+ vtrn.16 q1, q3
+ vtrn.16 q4, q6
+ vtrn.16 q5, q7
+
+ vtrn.8 q0, q1
+ vtrn.8 q2, q3
+ vtrn.8 q4, q5
+ vtrn.8 q6, q7
+.endm
+
+.macro vp8_v_loop_filter16 name, inner=0, simple=0
+function ff_vp8_v_loop_filter16\name\()_neon, export=1
+ vpush {q4-q7}
+ sub r0, r0, r1, lsl #1+!\simple
+
+ @ Load pixels:
+ .if !\simple
+ ldr r12, [sp, #64] @ hev_thresh
+ vld1.8 {q0}, [r0,:128], r1 @ P3
+ vld1.8 {q1}, [r0,:128], r1 @ P2
+ .endif
+ vld1.8 {q2}, [r0,:128], r1 @ P1
+ vld1.8 {q3}, [r0,:128], r1 @ P0
+ vld1.8 {q4}, [r0,:128], r1 @ Q0
+ vld1.8 {q5}, [r0,:128], r1 @ Q1
+ .if !\simple
+ vld1.8 {q6}, [r0,:128], r1 @ Q2
+ vld1.8 {q7}, [r0,:128] @ Q3
+ vdup.8 q15, r3 @ flim_I
+ .endif
+ vdup.8 q14, r2 @ flim_E
+
+ vp8_loop_filter inner=\inner, simple=\simple
+
+ @ back up to P2: dst -= stride * 6
+ sub r0, r0, r1, lsl #2
+ .if !\simple
+ sub r0, r0, r1, lsl #1
+
+ @ Store pixels:
+ vst1.8 {q1}, [r0,:128], r1 @ P2
+ .endif
+ vst1.8 {q2}, [r0,:128], r1 @ P1
+ vst1.8 {q3}, [r0,:128], r1 @ P0
+ vst1.8 {q4}, [r0,:128], r1 @ Q0
+ vst1.8 {q5}, [r0,:128], r1 @ Q1
+ .if !\simple
+ vst1.8 {q6}, [r0,:128] @ Q2
+ .endif
+
+ vpop {q4-q7}
+ bx lr
+endfunc
+.endm
+
+vp8_v_loop_filter16
+vp8_v_loop_filter16 _inner, inner=1
+vp8_v_loop_filter16 _simple, simple=1
+
+.macro vp8_v_loop_filter8uv name, inner=0
+function ff_vp8_v_loop_filter8uv\name\()_neon, export=1
+ vpush {q4-q7}
+ sub r0, r0, r2, lsl #2
+ sub r1, r1, r2, lsl #2
+ ldr r12, [sp, #64] @ flim_I
+
+ @ Load pixels:
+ vld1.8 {d0}, [r0,:64], r2 @ P3
+ vld1.8 {d1}, [r1,:64], r2 @ P3
+ vld1.8 {d2}, [r0,:64], r2 @ P2
+ vld1.8 {d3}, [r1,:64], r2 @ P2
+ vld1.8 {d4}, [r0,:64], r2 @ P1
+ vld1.8 {d5}, [r1,:64], r2 @ P1
+ vld1.8 {d6}, [r0,:64], r2 @ P0
+ vld1.8 {d7}, [r1,:64], r2 @ P0
+ vld1.8 {d8}, [r0,:64], r2 @ Q0
+ vld1.8 {d9}, [r1,:64], r2 @ Q0
+ vld1.8 {d10}, [r0,:64], r2 @ Q1
+ vld1.8 {d11}, [r1,:64], r2 @ Q1
+ vld1.8 {d12}, [r0,:64], r2 @ Q2
+ vld1.8 {d13}, [r1,:64], r2 @ Q2
+ vld1.8 {d14}, [r0,:64] @ Q3
+ vld1.8 {d15}, [r1,:64] @ Q3
+
+ vdup.8 q14, r3 @ flim_E
+ vdup.8 q15, r12 @ flim_I
+ ldr r12, [sp, #68] @ hev_thresh
+
+ vp8_loop_filter inner=\inner
+
+ @ back up to P2: u,v -= stride * 6
+ sub r0, r0, r2, lsl #2
+ sub r1, r1, r2, lsl #2
+ sub r0, r0, r2, lsl #1
+ sub r1, r1, r2, lsl #1
+
+ @ Store pixels:
+ vst1.8 {d2}, [r0,:64], r2 @ P2
+ vst1.8 {d3}, [r1,:64], r2 @ P2
+ vst1.8 {d4}, [r0,:64], r2 @ P1
+ vst1.8 {d5}, [r1,:64], r2 @ P1
+ vst1.8 {d6}, [r0,:64], r2 @ P0
+ vst1.8 {d7}, [r1,:64], r2 @ P0
+ vst1.8 {d8}, [r0,:64], r2 @ Q0
+ vst1.8 {d9}, [r1,:64], r2 @ Q0
+ vst1.8 {d10}, [r0,:64], r2 @ Q1
+ vst1.8 {d11}, [r1,:64], r2 @ Q1
+ vst1.8 {d12}, [r0,:64] @ Q2
+ vst1.8 {d13}, [r1,:64] @ Q2
+
+ vpop {q4-q7}
+ bx lr
+endfunc
+.endm
+
+vp8_v_loop_filter8uv
+vp8_v_loop_filter8uv _inner, inner=1
+
+.macro vp8_h_loop_filter16 name, inner=0, simple=0
+function ff_vp8_h_loop_filter16\name\()_neon, export=1
+ vpush {q4-q7}
+ sub r0, r0, #4
+ .if !\simple
+ ldr r12, [sp, #64] @ hev_thresh
+ .endif
+
+ @ Load pixels:
+ vld1.8 {d0}, [r0], r1 @ load first 8-line src data
+ vld1.8 {d2}, [r0], r1
+ vld1.8 {d4}, [r0], r1
+ vld1.8 {d6}, [r0], r1
+ vld1.8 {d8}, [r0], r1
+ vld1.8 {d10}, [r0], r1
+ vld1.8 {d12}, [r0], r1
+ vld1.8 {d14}, [r0], r1
+ vld1.8 {d1}, [r0], r1 @ load second 8-line src data
+ vld1.8 {d3}, [r0], r1
+ vld1.8 {d5}, [r0], r1
+ vld1.8 {d7}, [r0], r1
+ vld1.8 {d9}, [r0], r1
+ vld1.8 {d11}, [r0], r1
+ vld1.8 {d13}, [r0], r1
+ vld1.8 {d15}, [r0], r1
+
+ transpose8x16matrix
+
+ vdup.8 q14, r2 @ flim_E
+ .if !\simple
+ vdup.8 q15, r3 @ flim_I
+ .endif
+
+ vp8_loop_filter inner=\inner, simple=\simple
+
+ sub r0, r0, r1, lsl #4 @ backup 16 rows
+
+ transpose8x16matrix
+
+ @ Store pixels:
+ vst1.8 {d0}, [r0], r1
+ vst1.8 {d2}, [r0], r1
+ vst1.8 {d4}, [r0], r1
+ vst1.8 {d6}, [r0], r1
+ vst1.8 {d8}, [r0], r1
+ vst1.8 {d10}, [r0], r1
+ vst1.8 {d12}, [r0], r1
+ vst1.8 {d14}, [r0], r1
+ vst1.8 {d1}, [r0], r1
+ vst1.8 {d3}, [r0], r1
+ vst1.8 {d5}, [r0], r1
+ vst1.8 {d7}, [r0], r1
+ vst1.8 {d9}, [r0], r1
+ vst1.8 {d11}, [r0], r1
+ vst1.8 {d13}, [r0], r1
+ vst1.8 {d15}, [r0]
+
+ vpop {q4-q7}
+ bx lr
+endfunc
+.endm
+
+vp8_h_loop_filter16
+vp8_h_loop_filter16 _inner, inner=1
+vp8_h_loop_filter16 _simple, simple=1
+
+.macro vp8_h_loop_filter8uv name, inner=0
+function ff_vp8_h_loop_filter8uv\name\()_neon, export=1
+ vpush {q4-q7}
+ sub r0, r0, #4
+ sub r1, r1, #4
+ ldr r12, [sp, #64] @ flim_I
+
+ @ Load pixels:
+ vld1.8 {d0}, [r0], r2 @ load u
+ vld1.8 {d1}, [r1], r2 @ load v
+ vld1.8 {d2}, [r0], r2
+ vld1.8 {d3}, [r1], r2
+ vld1.8 {d4}, [r0], r2
+ vld1.8 {d5}, [r1], r2
+ vld1.8 {d6}, [r0], r2
+ vld1.8 {d7}, [r1], r2
+ vld1.8 {d8}, [r0], r2
+ vld1.8 {d9}, [r1], r2
+ vld1.8 {d10}, [r0], r2
+ vld1.8 {d11}, [r1], r2
+ vld1.8 {d12}, [r0], r2
+ vld1.8 {d13}, [r1], r2
+ vld1.8 {d14}, [r0], r2
+ vld1.8 {d15}, [r1], r2
+
+ transpose8x16matrix
+
+ vdup.8 q14, r3 @ flim_E
+ vdup.8 q15, r12 @ flim_I
+ ldr r12, [sp, #68] @ hev_thresh
+
+ vp8_loop_filter inner=\inner
+
+ sub r0, r0, r2, lsl #3 @ backup u 8 rows
+ sub r1, r1, r2, lsl #3 @ backup v 8 rows
+
+ transpose8x16matrix
+
+ @ Store pixels:
+ vst1.8 {d0}, [r0], r2
+ vst1.8 {d1}, [r1], r2
+ vst1.8 {d2}, [r0], r2
+ vst1.8 {d3}, [r1], r2
+ vst1.8 {d4}, [r0], r2
+ vst1.8 {d5}, [r1], r2
+ vst1.8 {d6}, [r0], r2
+ vst1.8 {d7}, [r1], r2
+ vst1.8 {d8}, [r0], r2
+ vst1.8 {d9}, [r1], r2
+ vst1.8 {d10}, [r0], r2
+ vst1.8 {d11}, [r1], r2
+ vst1.8 {d12}, [r0], r2
+ vst1.8 {d13}, [r1], r2
+ vst1.8 {d14}, [r0]
+ vst1.8 {d15}, [r1]
+
+ vpop {q4-q7}
+ bx lr
+endfunc
+.endm
+
+vp8_h_loop_filter8uv
+vp8_h_loop_filter8uv _inner, inner=1
+
+function ff_put_vp8_pixels16_neon, export=1
+ ldr r12, [sp, #0] @ h
+1:
+ subs r12, r12, #4
+ vld1.8 {q0}, [r2], r3
+ vld1.8 {q1}, [r2], r3
+ vld1.8 {q2}, [r2], r3
+ vld1.8 {q3}, [r2], r3
+ vst1.8 {q0}, [r0,:128], r1
+ vst1.8 {q1}, [r0,:128], r1
+ vst1.8 {q2}, [r0,:128], r1
+ vst1.8 {q3}, [r0,:128], r1
+ bgt 1b
+ bx lr
+endfunc
+
+function ff_put_vp8_pixels8_neon, export=1
+ ldr r12, [sp, #0] @ h
+1:
+ subs r12, r12, #4
+ vld1.8 {d0}, [r2], r3
+ vld1.8 {d1}, [r2], r3
+ vld1.8 {d2}, [r2], r3
+ vld1.8 {d3}, [r2], r3
+ vst1.8 {d0}, [r0,:64], r1
+ vst1.8 {d1}, [r0,:64], r1
+ vst1.8 {d2}, [r0,:64], r1
+ vst1.8 {d3}, [r0,:64], r1
+ bgt 1b
+ bx lr
+endfunc
+
+function ff_put_vp8_pixels4_neon, export=1
+ ldr r12, [sp, #0] @ h
+ push {r4-r6,lr}
+1:
+ subs r12, r12, #4
+ ldr r4, [r2], r3
+ ldr r5, [r2], r3
+ ldr r6, [r2], r3
+ ldr lr, [r2], r3
+ str r4, [r0], r1
+ str r5, [r0], r1
+ str r6, [r0], r1
+ str lr, [r0], r1
+ bgt 1b
+ pop {r4-r6,pc}
+endfunc
+
+/* 4/6-tap 8th-pel MC */
+
+.macro vp8_epel8_h6 d, a, b
+ vext.8 d27, \a, \b, #1
+ vmovl.u8 q8, \a
+ vext.8 d28, \a, \b, #2
+ vmovl.u8 q9, d27
+ vext.8 d29, \a, \b, #3
+ vmovl.u8 q10, d28
+ vext.8 d30, \a, \b, #4
+ vmovl.u8 q11, d29
+ vext.8 d31, \a, \b, #5
+ vmovl.u8 q12, d30
+ vmul.u16 q10, q10, d0[2]
+ vmovl.u8 q13, d31
+ vmul.u16 q11, q11, d0[3]
+ vmls.u16 q10, q9, d0[1]
+ vmls.u16 q11, q12, d1[0]
+ vmla.u16 q10, q8, d0[0]
+ vmla.u16 q11, q13, d1[1]
+ vqadd.s16 q11, q10, q11
+ vqrshrun.s16 \d, q11, #7
+.endm
+
+.macro vp8_epel16_h6 d0, d1, s0, s1, s2, q0, q1
+ vext.8 q14, \q0, \q1, #3
+ vext.8 q15, \q0, \q1, #4
+ vmovl.u8 q11, d28
+ vmovl.u8 q14, d29
+ vext.8 q3, \q0, \q1, #2
+ vmovl.u8 q12, d30
+ vmovl.u8 q15, d31
+ vext.8 q8, \q0, \q1, #1
+ vmovl.u8 q10, d6
+ vmovl.u8 q3, d7
+ vext.8 q2, \q0, \q1, #5
+ vmovl.u8 q13, d4
+ vmovl.u8 q2, d5
+ vmovl.u8 q9, d16
+ vmovl.u8 q8, d17
+ vmul.u16 q11, q11, d0[3]
+ vmul.u16 q10, q10, d0[2]
+ vmul.u16 q3, q3, d0[2]
+ vmul.u16 q14, q14, d0[3]
+ vmls.u16 q11, q12, d1[0]
+ vmovl.u8 q12, \s0
+ vmovl.u8 q1, \s1
+ vmls.u16 q10, q9, d0[1]
+ vmls.u16 q3, q8, d0[1]
+ vmls.u16 q14, q15, d1[0]
+ vmla.u16 q10, q12, d0[0]
+ vmla.u16 q11, q13, d1[1]
+ vmla.u16 q3, q1, d0[0]
+ vmla.u16 q14, q2, d1[1]
+ vqadd.s16 q11, q10, q11
+ vqadd.s16 q14, q3, q14
+ vqrshrun.s16 \d0, q11, #7
+ vqrshrun.s16 \d1, q14, #7
+.endm
+
+.macro vp8_epel8_v6 d0, s0, s1, s2, s3, s4, s5
+ vmovl.u8 q10, \s2
+ vmovl.u8 q11, \s3
+ vmovl.u8 q9, \s1
+ vmovl.u8 q12, \s4
+ vmovl.u8 q8, \s0
+ vmovl.u8 q13, \s5
+ vmul.u16 q10, q10, d0[2]
+ vmul.u16 q11, q11, d0[3]
+ vmls.u16 q10, q9, d0[1]
+ vmls.u16 q11, q12, d1[0]
+ vmla.u16 q10, q8, d0[0]
+ vmla.u16 q11, q13, d1[1]
+ vqadd.s16 q11, q10, q11
+ vqrshrun.s16 \d0, q11, #7
+.endm
+
+.macro vp8_epel8_v6_y2 d0, d1, s0, s1, s2, s3, s4, s5, s6
+ vmovl.u8 q10, \s0
+ vmovl.u8 q11, \s3
+ vmovl.u8 q14, \s6
+ vmovl.u8 q9, \s1
+ vmovl.u8 q12, \s4
+ vmovl.u8 q8, \s2
+ vmovl.u8 q13, \s5
+ vmul.u16 q10, q10, d0[0]
+ vmul.u16 q15, q11, d0[3]
+ vmul.u16 q11, q11, d0[2]
+ vmul.u16 q14, q14, d1[1]
+ vmls.u16 q10, q9, d0[1]
+ vmls.u16 q15, q12, d1[0]
+ vmls.u16 q11, q8, d0[1]
+ vmls.u16 q14, q13, d1[0]
+ vmla.u16 q10, q8, d0[2]
+ vmla.u16 q15, q13, d1[1]
+ vmla.u16 q11, q9, d0[0]
+ vmla.u16 q14, q12, d0[3]
+ vqadd.s16 q15, q10, q15
+ vqadd.s16 q14, q11, q14
+ vqrshrun.s16 \d0, q15, #7
+ vqrshrun.s16 \d1, q14, #7
+.endm
+
+.macro vp8_epel8_h4 d, a, b
+ vext.8 d28, \a, \b, #1
+ vmovl.u8 q9, \a
+ vext.8 d29, \a, \b, #2
+ vmovl.u8 q10, d28
+ vext.8 d30, \a, \b, #3
+ vmovl.u8 q11, d29
+ vmovl.u8 q12, d30
+ vmul.u16 q10, q10, d0[2]
+ vmul.u16 q11, q11, d0[3]
+ vmls.u16 q10, q9, d0[1]
+ vmls.u16 q11, q12, d1[0]
+ vqadd.s16 q11, q10, q11
+ vqrshrun.s16 \d, q11, #7
+.endm
+
+.macro vp8_epel8_v4_y2 d0, d1, s0, s1, s2, s3, s4
+ vmovl.u8 q9, \s0
+ vmovl.u8 q10, \s1
+ vmovl.u8 q11, \s2
+ vmovl.u8 q12, \s3
+ vmovl.u8 q13, \s4
+ vmul.u16 q8, q10, d0[2]
+ vmul.u16 q14, q11, d0[3]
+ vmul.u16 q11, q11, d0[2]
+ vmul.u16 q15, q12, d0[3]
+ vmls.u16 q8, q9, d0[1]
+ vmls.u16 q14, q12, d1[0]
+ vmls.u16 q11, q10, d0[1]
+ vmls.u16 q15, q13, d1[0]
+ vqadd.s16 q8, q8, q14
+ vqadd.s16 q11, q11, q15
+ vqrshrun.s16 \d0, q8, #7
+ vqrshrun.s16 \d1, q11, #7
+.endm
+
+function ff_put_vp8_epel16_v6_neon, export=1
+ sub r2, r2, r3, lsl #1
+ push {r4,lr}
+ vpush {d8-d15}
+
+ ldr r4, [sp, #80] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #72] @ h
+ add r4, lr, r4, lsl #4
+ vld1.16 {q0}, [r4,:128]
+1:
+ vld1.8 {d2-d3}, [r2], r3
+ vld1.8 {d4-d5}, [r2], r3
+ vld1.8 {d6-d7}, [r2], r3
+ vld1.8 {d8-d9}, [r2], r3
+ vld1.8 {d10-d11},[r2], r3
+ vld1.8 {d12-d13},[r2], r3
+ vld1.8 {d14-d15},[r2]
+ sub r2, r2, r3, lsl #2
+
+ vp8_epel8_v6_y2 d2, d4, d2, d4, d6, d8, d10, d12, d14
+ vp8_epel8_v6_y2 d3, d5, d3, d5, d7, d9, d11, d13, d15
+
+ vst1.8 {d2-d3}, [r0,:128], r1
+ vst1.8 {d4-d5}, [r0,:128], r1
+ subs r12, r12, #2
+ bne 1b
+
+ vpop {d8-d15}
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel16_h6_neon, export=1
+ sub r2, r2, #2
+ push {r4,lr}
+
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ vld1.16 {q0}, [r4,:128]
+1:
+ vld1.8 {d2-d4}, [r2], r3
+
+ vp8_epel16_h6 d2, d3, d2, d3, d4, q1, q2
+
+ vst1.8 {d2-d3}, [r0,:128], r1
+ subs r12, r12, #1
+ bne 1b
+
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel16_h6v6_neon, export=1
+ sub r2, r2, r3, lsl #1
+ sub r2, r2, #2
+ push {r4,lr}
+ vpush {d8-d9}
+
+ @ first pass (horizontal):
+ ldr r4, [sp, #28] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #24] @ h
+ add r4, lr, r4, lsl #4
+ sub sp, sp, #336+16
+ vld1.16 {q0}, [r4,:128]
+ add lr, sp, #15
+ add r12, r12, #5
+ bic lr, lr, #15
+1:
+ vld1.8 {d2,d3,d4}, [r2], r3
+
+ vp8_epel16_h6 d2, d3, d2, d3, d4, q1, q2
+
+ vst1.8 {d2-d3}, [lr,:128]!
+ subs r12, r12, #1
+ bne 1b
+
+ @ second pass (vertical):
+ ldr r4, [sp, #336+16+32] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #336+16+24] @ h
+ add r4, lr, r4, lsl #4
+ add lr, sp, #15
+ vld1.16 {q0}, [r4,:128]
+ bic lr, lr, #15
+2:
+ vld1.8 {d2-d5}, [lr,:128]!
+ vld1.8 {d6-d9}, [lr,:128]!
+ vld1.8 {d28-d31},[lr,:128]
+ sub lr, lr, #48
+
+ vp8_epel8_v6 d2, d2, d4, d6, d8, d28, d30
+ vp8_epel8_v6 d3, d3, d5, d7, d9, d29, d31
+
+ vst1.8 {d2-d3}, [r0,:128], r1
+ subs r12, r12, #1
+ bne 2b
+
+ add sp, sp, #336+16
+ vpop {d8-d9}
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel8_v6_neon, export=1
+ sub r2, r2, r3, lsl #1
+ push {r4,lr}
+
+ ldr r4, [sp, #16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ vld1.16 {q0}, [r4,:128]
+1:
+ vld1.8 {d2}, [r2], r3
+ vld1.8 {d3}, [r2], r3
+ vld1.8 {d4}, [r2], r3
+ vld1.8 {d5}, [r2], r3
+ vld1.8 {d6}, [r2], r3
+ vld1.8 {d7}, [r2], r3
+ vld1.8 {d28}, [r2]
+
+ sub r2, r2, r3, lsl #2
+
+ vp8_epel8_v6_y2 d2, d3, d2, d3, d4, d5, d6, d7, d28
+
+ vst1.8 {d2}, [r0,:64], r1
+ vst1.8 {d3}, [r0,:64], r1
+ subs r12, r12, #2
+ bne 1b
+
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel8_h6_neon, export=1
+ sub r2, r2, #2
+ push {r4,lr}
+
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ vld1.16 {q0}, [r4,:128]
+1:
+ vld1.8 {d2,d3}, [r2], r3
+
+ vp8_epel8_h6 d2, d2, d3
+
+ vst1.8 {d2}, [r0,:64], r1
+ subs r12, r12, #1
+ bne 1b
+
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel8_h6v6_neon, export=1
+ sub r2, r2, r3, lsl #1
+ sub r2, r2, #2
+ push {r4,lr}
+
+ @ first pass (horizontal):
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ sub sp, sp, #168+16
+ vld1.16 {q0}, [r4,:128]
+ add lr, sp, #15
+ add r12, r12, #5
+ bic lr, lr, #15
+1:
+ vld1.8 {d2,d3}, [r2], r3
+
+ vp8_epel8_h6 d2, d2, d3
+
+ vst1.8 {d2}, [lr,:64]!
+ subs r12, r12, #1
+ bne 1b
+
+ @ second pass (vertical):
+ ldr r4, [sp, #168+16+16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #168+16+8] @ h
+ add r4, lr, r4, lsl #4
+ add lr, sp, #15
+ vld1.16 {q0}, [r4,:128]
+ bic lr, lr, #15
+2:
+ vld1.8 {d2-d5}, [lr,:128]!
+ vld1.8 {d6-d7}, [lr,:128]!
+ vld1.8 {d30}, [lr,:64]
+ sub lr, lr, #32
+
+ vp8_epel8_v6_y2 d2, d3, d2, d3, d4, d5, d6, d7, d30
+
+ vst1.8 {d2}, [r0,:64], r1
+ vst1.8 {d3}, [r0,:64], r1
+ subs r12, r12, #2
+ bne 2b
+
+ add sp, sp, #168+16
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel8_v4_neon, export=1
+ sub r2, r2, r3
+ push {r4,lr}
+
+ ldr r4, [sp, #16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ vld1.16 {q0}, [r4,:128]
+1:
+ vld1.8 {d2}, [r2], r3
+ vld1.8 {d3}, [r2], r3
+ vld1.8 {d4}, [r2], r3
+ vld1.8 {d5}, [r2], r3
+ vld1.8 {d6}, [r2]
+ sub r2, r2, r3, lsl #1
+
+ vp8_epel8_v4_y2 d2, d3, d2, d3, d4, d5, d6
+
+ vst1.8 {d2}, [r0,:64], r1
+ vst1.8 {d3}, [r0,:64], r1
+ subs r12, r12, #2
+ bne 1b
+
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel8_h4_neon, export=1
+ sub r2, r2, #1
+ push {r4,lr}
+
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ vld1.16 {q0}, [r4,:128]
+1:
+ vld1.8 {d2,d3}, [r2], r3
+
+ vp8_epel8_h4 d2, d2, d3
+
+ vst1.8 {d2}, [r0,:64], r1
+ subs r12, r12, #1
+ bne 1b
+
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel8_h4v4_neon, export=1
+ sub r2, r2, r3
+ sub r2, r2, #1
+ push {r4,lr}
+
+ @ first pass (horizontal):
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ sub sp, sp, #168+16
+ vld1.16 {q0}, [r4,:128]
+ add lr, sp, #15
+ add r12, r12, #3
+ bic lr, lr, #15
+1:
+ vld1.8 {d2,d3}, [r2], r3
+
+ vp8_epel8_h4 d2, d2, d3
+
+ vst1.8 {d2}, [lr,:64]!
+ subs r12, r12, #1
+ bne 1b
+
+ @ second pass (vertical):
+ ldr r4, [sp, #168+16+16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #168+16+8] @ h
+ add r4, lr, r4, lsl #4
+ add lr, sp, #15
+ vld1.16 {q0}, [r4,:128]
+ bic lr, lr, #15
+2:
+ vld1.8 {d2-d5}, [lr,:128]!
+ vld1.8 {d6}, [lr,:64]
+ sub lr, lr, #16
+
+ vp8_epel8_v4_y2 d2, d3, d2, d3, d4, d5, d6
+
+ vst1.8 {d2}, [r0,:64], r1
+ vst1.8 {d3}, [r0,:64], r1
+ subs r12, r12, #2
+ bne 2b
+
+ add sp, sp, #168+16
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel8_h6v4_neon, export=1
+ sub r2, r2, r3
+ sub r2, r2, #2
+ push {r4,lr}
+
+ @ first pass (horizontal):
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ sub sp, sp, #168+16
+ vld1.16 {q0}, [r4,:128]
+ add lr, sp, #15
+ add r12, r12, #3
+ bic lr, lr, #15
+1:
+ vld1.8 {d2,d3}, [r2], r3
+
+ vp8_epel8_h6 d2, d2, d3
+
+ vst1.8 {d2}, [lr,:64]!
+ subs r12, r12, #1
+ bne 1b
+
+ @ second pass (vertical):
+ ldr r4, [sp, #168+16+16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #168+16+8] @ h
+ add r4, lr, r4, lsl #4
+ add lr, sp, #15
+ vld1.16 {q0}, [r4,:128]
+ bic lr, lr, #15
+2:
+ vld1.8 {d2-d5}, [lr,:128]!
+ vld1.8 {d6}, [lr,:64]
+ sub lr, lr, #16
+
+ vp8_epel8_v4_y2 d2, d3, d2, d3, d4, d5, d6
+
+ vst1.8 {d2}, [r0,:64], r1
+ vst1.8 {d3}, [r0,:64], r1
+ subs r12, r12, #2
+ bne 2b
+
+ add sp, sp, #168+16
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel8_h4v6_neon, export=1
+ sub r2, r2, r3, lsl #1
+ sub r2, r2, #1
+ push {r4,lr}
+
+ @ first pass (horizontal):
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ sub sp, sp, #168+16
+ vld1.16 {q0}, [r4,:128]
+ add lr, sp, #15
+ add r12, r12, #5
+ bic lr, lr, #15
+1:
+ vld1.8 {d2,d3}, [r2], r3
+
+ vp8_epel8_h4 d2, d2, d3
+
+ vst1.8 {d2}, [lr,:64]!
+ subs r12, r12, #1
+ bne 1b
+
+ @ second pass (vertical):
+ ldr r4, [sp, #168+16+16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #168+16+8] @ h
+ add r4, lr, r4, lsl #4
+ add lr, sp, #15
+ vld1.16 {q0}, [r4,:128]
+ bic lr, lr, #15
+2:
+ vld1.8 {d2-d5}, [lr,:128]!
+ vld1.8 {d6-d7}, [lr,:128]!
+ vld1.8 {d30}, [lr,:64]
+ sub lr, lr, #32
+
+ vp8_epel8_v6_y2 d2, d3, d2, d3, d4, d5, d6, d7, d30
+
+ vst1.8 {d2}, [r0,:64], r1
+ vst1.8 {d3}, [r0,:64], r1
+ subs r12, r12, #2
+ bne 2b
+
+ add sp, sp, #168+16
+ pop {r4,pc}
+endfunc
+
+.ltorg
+
+function ff_put_vp8_epel4_v6_neon, export=1
+ sub r2, r2, r3, lsl #1
+ push {r4,lr}
+
+ ldr r4, [sp, #16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ vld1.16 {q0}, [r4,:128]
+1:
+ vld1.32 {d2[]}, [r2], r3
+ vld1.32 {d3[]}, [r2], r3
+ vld1.32 {d4[]}, [r2], r3
+ vld1.32 {d5[]}, [r2], r3
+ vld1.32 {d6[]}, [r2], r3
+ vld1.32 {d7[]}, [r2], r3
+ vld1.32 {d28[]}, [r2]
+ sub r2, r2, r3, lsl #2
+ vld1.32 {d2[1]}, [r2], r3
+ vld1.32 {d3[1]}, [r2], r3
+ vld1.32 {d4[1]}, [r2], r3
+ vld1.32 {d5[1]}, [r2], r3
+ vld1.32 {d6[1]}, [r2], r3
+ vld1.32 {d7[1]}, [r2], r3
+ vld1.32 {d28[1]}, [r2]
+ sub r2, r2, r3, lsl #2
+
+ vp8_epel8_v6_y2 d2, d3, d2, d3, d4, d5, d6, d7, d28
+
+ vst1.32 {d2[0]}, [r0,:32], r1
+ vst1.32 {d3[0]}, [r0,:32], r1
+ vst1.32 {d2[1]}, [r0,:32], r1
+ vst1.32 {d3[1]}, [r0,:32], r1
+ subs r12, r12, #4
+ bne 1b
+
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel4_h6_neon, export=1
+ sub r2, r2, #2
+ push {r4,lr}
+
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ vld1.16 {q0}, [r4,:128]
+1:
+ vld1.8 {q1}, [r2], r3
+ vp8_epel8_h6 d2, d2, d3
+ vst1.32 {d2[0]}, [r0,:32], r1
+ subs r12, r12, #1
+ bne 1b
+
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel4_h6v6_neon, export=1
+ sub r2, r2, r3, lsl #1
+ sub r2, r2, #2
+ push {r4,lr}
+
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ sub sp, sp, #52+16
+ vld1.16 {q0}, [r4,:128]
+ add lr, sp, #15
+ add r12, r12, #5
+ bic lr, lr, #15
+1:
+ vld1.8 {q1}, [r2], r3
+ vp8_epel8_h6 d2, d2, d3
+ vst1.32 {d2[0]}, [lr,:32]!
+ subs r12, r12, #1
+ bne 1b
+
+ ldr r4, [sp, #52+16+16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #52+16+8] @ h
+ add r4, lr, r4, lsl #4
+ add lr, sp, #15
+ vld1.16 {q0}, [r4,:128]
+ bic lr, lr, #15
+2:
+ vld1.8 {d2-d3}, [lr,:128]!
+ vld1.8 {d6}, [lr,:64]!
+ vld1.32 {d28[]}, [lr,:32]
+ sub lr, lr, #16
+ vld1.8 {d4-d5}, [lr]!
+ vld1.8 {d7}, [lr,:64]!
+ vld1.32 {d28[1]}, [lr,:32]
+ sub lr, lr, #16
+ vtrn.32 q1, q2
+ vtrn.32 d6, d7
+ vp8_epel8_v6_y2 d2, d3, d2, d4, d3, d5, d6, d7, d28
+ vst1.32 {d2[0]}, [r0,:32], r1
+ vst1.32 {d3[0]}, [r0,:32], r1
+ vst1.32 {d2[1]}, [r0,:32], r1
+ vst1.32 {d3[1]}, [r0,:32], r1
+ subs r12, r12, #4
+ bne 2b
+
+ add sp, sp, #52+16
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel4_h4v6_neon, export=1
+ sub r2, r2, r3, lsl #1
+ sub r2, r2, #1
+ push {r4,lr}
+
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ sub sp, sp, #52+16
+ vld1.16 {q0}, [r4,:128]
+ add lr, sp, #15
+ add r12, r12, #5
+ bic lr, lr, #15
+1:
+ vld1.8 {d2}, [r2], r3
+ vp8_epel8_h4 d2, d2, d2
+ vst1.32 {d2[0]}, [lr,:32]!
+ subs r12, r12, #1
+ bne 1b
+
+ ldr r4, [sp, #52+16+16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #52+16+8] @ h
+ add r4, lr, r4, lsl #4
+ add lr, sp, #15
+ vld1.16 {q0}, [r4,:128]
+ bic lr, lr, #15
+2:
+ vld1.8 {d2-d3}, [lr,:128]!
+ vld1.8 {d6}, [lr,:64]!
+ vld1.32 {d28[]}, [lr,:32]
+ sub lr, lr, #16
+ vld1.8 {d4-d5}, [lr]!
+ vld1.8 {d7}, [lr,:64]!
+ vld1.32 {d28[1]}, [lr,:32]
+ sub lr, lr, #16
+ vtrn.32 q1, q2
+ vtrn.32 d6, d7
+ vp8_epel8_v6_y2 d2, d3, d2, d4, d3, d5, d6, d7, d28
+ vst1.32 {d2[0]}, [r0,:32], r1
+ vst1.32 {d3[0]}, [r0,:32], r1
+ vst1.32 {d2[1]}, [r0,:32], r1
+ vst1.32 {d3[1]}, [r0,:32], r1
+ subs r12, r12, #4
+ bne 2b
+
+ add sp, sp, #52+16
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel4_h6v4_neon, export=1
+ sub r2, r2, r3
+ sub r2, r2, #2
+ push {r4,lr}
+
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ sub sp, sp, #44+16
+ vld1.16 {q0}, [r4,:128]
+ add lr, sp, #15
+ add r12, r12, #3
+ bic lr, lr, #15
+1:
+ vld1.8 {q1}, [r2], r3
+ vp8_epel8_h6 d2, d2, d3
+ vst1.32 {d2[0]}, [lr,:32]!
+ subs r12, r12, #1
+ bne 1b
+
+ ldr r4, [sp, #44+16+16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #44+16+8] @ h
+ add r4, lr, r4, lsl #4
+ add lr, sp, #15
+ vld1.16 {q0}, [r4,:128]
+ bic lr, lr, #15
+2:
+ vld1.8 {d2-d3}, [lr,:128]!
+ vld1.32 {d6[]}, [lr,:32]
+ sub lr, lr, #8
+ vld1.8 {d4-d5}, [lr]!
+ vld1.32 {d6[1]}, [lr,:32]
+ sub lr, lr, #8
+ vtrn.32 q1, q2
+ vp8_epel8_v4_y2 d2, d3, d2, d4, d3, d5, d6
+ vst1.32 {d2[0]}, [r0,:32], r1
+ vst1.32 {d3[0]}, [r0,:32], r1
+ vst1.32 {d2[1]}, [r0,:32], r1
+ vst1.32 {d3[1]}, [r0,:32], r1
+ subs r12, r12, #4
+ bne 2b
+
+ add sp, sp, #44+16
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel4_h4_neon, export=1
+ sub r2, r2, #1
+ push {r4,lr}
+
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ vld1.16 {q0}, [r4,:128]
+1:
+ vld1.8 {d2}, [r2], r3
+ vp8_epel8_h4 d2, d2, d2
+ vst1.32 {d2[0]}, [r0,:32], r1
+ subs r12, r12, #1
+ bne 1b
+
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel4_v4_neon, export=1
+ sub r2, r2, r3
+ push {r4,lr}
+
+ ldr r4, [sp, #16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ vld1.16 {q0}, [r4,:128]
+1:
+ vld1.32 {d2[]}, [r2], r3
+ vld1.32 {d3[]}, [r2], r3
+ vld1.32 {d4[]}, [r2], r3
+ vld1.32 {d5[]}, [r2], r3
+ vld1.32 {d6[]}, [r2]
+ sub r2, r2, r3, lsl #1
+ vld1.32 {d2[1]}, [r2], r3
+ vld1.32 {d3[1]}, [r2], r3
+ vld1.32 {d4[1]}, [r2], r3
+ vld1.32 {d5[1]}, [r2], r3
+ vld1.32 {d6[1]}, [r2]
+ sub r2, r2, r3, lsl #1
+
+ vp8_epel8_v4_y2 d2, d3, d2, d3, d4, d5, d6
+
+ vst1.32 {d2[0]}, [r0,:32], r1
+ vst1.32 {d3[0]}, [r0,:32], r1
+ vst1.32 {d2[1]}, [r0,:32], r1
+ vst1.32 {d3[1]}, [r0,:32], r1
+ subs r12, r12, #4
+ bne 1b
+
+ pop {r4,pc}
+endfunc
+
+function ff_put_vp8_epel4_h4v4_neon, export=1
+ sub r2, r2, r3
+ sub r2, r2, #1
+ push {r4,lr}
+
+ ldr r4, [sp, #12] @ mx
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #8] @ h
+ add r4, lr, r4, lsl #4
+ sub sp, sp, #44+16
+ vld1.16 {q0}, [r4,:128]
+ add lr, sp, #15
+ add r12, r12, #3
+ bic lr, lr, #15
+1:
+ vld1.8 {d2}, [r2], r3
+ vp8_epel8_h4 d2, d2, d3
+ vst1.32 {d2[0]}, [lr,:32]!
+ subs r12, r12, #1
+ bne 1b
+
+ ldr r4, [sp, #44+16+16] @ my
+ movrel lr, subpel_filters-16
+ ldr r12, [sp, #44+16+8] @ h
+ add r4, lr, r4, lsl #4
+ add lr, sp, #15
+ vld1.16 {q0}, [r4,:128]
+ bic lr, lr, #15
+2:
+ vld1.8 {d2-d3}, [lr,:128]!
+ vld1.32 {d6[]}, [lr,:32]
+ sub lr, lr, #8
+ vld1.8 {d4-d5}, [lr]!
+ vld1.32 {d6[1]}, [lr,:32]
+ sub lr, lr, #8
+ vtrn.32 q1, q2
+ vp8_epel8_v4_y2 d2, d3, d2, d4, d3, d5, d6
+ vst1.32 {d2[0]}, [r0,:32], r1
+ vst1.32 {d3[0]}, [r0,:32], r1
+ vst1.32 {d2[1]}, [r0,:32], r1
+ vst1.32 {d3[1]}, [r0,:32], r1
+ subs r12, r12, #4
+ bne 2b
+
+ add sp, sp, #44+16
+ pop {r4,pc}
+endfunc
+
+@ note: worst case sum of all 6-tap filter values * 255 is 0x7f80 so 16 bit
+@ arithmatic can be used to apply filters
+const subpel_filters, align=4
+ .short 0, 6, 123, 12, 1, 0, 0, 0
+ .short 2, 11, 108, 36, 8, 1, 0, 0
+ .short 0, 9, 93, 50, 6, 0, 0, 0
+ .short 3, 16, 77, 77, 16, 3, 0, 0
+ .short 0, 6, 50, 93, 9, 0, 0, 0
+ .short 1, 8, 36, 108, 11, 2, 0, 0
+ .short 0, 1, 12, 123, 6, 0, 0, 0
+endconst
+
+/* Bilinear MC */
+
+function ff_put_vp8_bilin16_h_neon, export=1
+ ldr r3, [sp, #4] @ mx
+ rsb r12, r3, #8
+ vdup.8 d0, r3
+ vdup.8 d1, r12
+ ldr r12, [sp] @ h
+1:
+ subs r12, r12, #2
+ vld1.8 {d2-d4}, [r2], r1
+ vext.8 q2, q1, q2, #1
+ vmull.u8 q8, d2, d1
+ vmlal.u8 q8, d4, d0
+ vld1.8 {d18-d20},[r2], r1
+ vmull.u8 q3, d3, d1
+ vmlal.u8 q3, d5, d0
+ vext.8 q10, q9, q10, #1
+ vmull.u8 q11, d18, d1
+ vmlal.u8 q11, d20, d0
+ vmull.u8 q12, d19, d1
+ vmlal.u8 q12, d21, d0
+ vrshrn.u16 d4, q8, #3
+ vrshrn.u16 d5, q3, #3
+ vrshrn.u16 d6, q11, #3
+ vrshrn.u16 d7, q12, #3
+ vst1.8 {q2}, [r0,:128], r1
+ vst1.8 {q3}, [r0,:128], r1
+ bgt 1b
+
+ bx lr
+endfunc
+
+function ff_put_vp8_bilin16_v_neon, export=1
+ ldr r3, [sp, #8] @ my
+ rsb r12, r3, #8
+ vdup.8 d0, r3
+ vdup.8 d1, r12
+ ldr r12, [sp] @ h
+ vld1.8 {q1}, [r2], r1
+1:
+ subs r12, r12, #2
+ vld1.8 {q2}, [r2], r1
+ vmull.u8 q3, d2, d1
+ vmlal.u8 q3, d4, d0
+ vmull.u8 q8, d3, d1
+ vmlal.u8 q8, d5, d0
+ vld1.8 {q1}, [r2], r1
+ vmull.u8 q9, d4, d1
+ vmlal.u8 q9, d2, d0
+ vmull.u8 q10, d5, d1
+ vmlal.u8 q10, d3, d0
+ vrshrn.u16 d4, q3, #3
+ vrshrn.u16 d5, q8, #3
+ vrshrn.u16 d6, q9, #3
+ vrshrn.u16 d7, q10, #3
+ vst1.8 {q2}, [r0,:128], r1
+ vst1.8 {q3}, [r0,:128], r1
+ bgt 1b
+
+ bx lr
+endfunc
+
+function ff_put_vp8_bilin16_hv_neon, export=1
+ ldr r3, [sp, #4] @ mx
+ rsb r12, r3, #8
+ vdup.8 d0, r3
+ vdup.8 d1, r12
+ ldr r3, [sp, #8] @ my
+ rsb r12, r3, #8
+ vdup.8 d2, r3
+ vdup.8 d3, r12
+ ldr r12, [sp] @ h
+
+ vld1.8 {d4-d6}, [r2], r1
+ vext.8 q3, q2, q3, #1
+ vmull.u8 q8, d4, d1
+ vmlal.u8 q8, d6, d0
+ vmull.u8 q9, d5, d1
+ vmlal.u8 q9, d7, d0
+ vrshrn.u16 d4, q8, #3
+ vrshrn.u16 d5, q9, #3
+1:
+ subs r12, r12, #2
+ vld1.8 {d18-d20},[r2], r1
+ vext.8 q10, q9, q10, #1
+ vmull.u8 q11, d18, d1
+ vmlal.u8 q11, d20, d0
+ vld1.8 {d26-d28},[r2], r1
+ vmull.u8 q12, d19, d1
+ vmlal.u8 q12, d21, d0
+ vext.8 q14, q13, q14, #1
+ vmull.u8 q8, d26, d1
+ vmlal.u8 q8, d28, d0
+ vmull.u8 q9, d27, d1
+ vmlal.u8 q9, d29, d0
+ vrshrn.u16 d6, q11, #3
+ vrshrn.u16 d7, q12, #3
+ vmull.u8 q12, d4, d3
+ vmlal.u8 q12, d6, d2
+ vmull.u8 q15, d5, d3
+ vmlal.u8 q15, d7, d2
+ vrshrn.u16 d4, q8, #3
+ vrshrn.u16 d5, q9, #3
+ vmull.u8 q10, d6, d3
+ vmlal.u8 q10, d4, d2
+ vmull.u8 q11, d7, d3
+ vmlal.u8 q11, d5, d2
+ vrshrn.u16 d24, q12, #3
+ vrshrn.u16 d25, q15, #3
+ vst1.8 {q12}, [r0,:128], r1
+ vrshrn.u16 d20, q10, #3
+ vrshrn.u16 d21, q11, #3
+ vst1.8 {q10}, [r0,:128], r1
+ bgt 1b
+
+ bx lr
+endfunc
+
+function ff_put_vp8_bilin8_h_neon, export=1
+ ldr r3, [sp, #4] @ mx
+ rsb r12, r3, #8
+ vdup.8 d0, r3
+ vdup.8 d1, r12
+ ldr r12, [sp] @ h
+1:
+ subs r12, r12, #2
+ vld1.8 {q1}, [r2], r1
+ vext.8 d3, d2, d3, #1
+ vmull.u8 q2, d2, d1
+ vmlal.u8 q2, d3, d0
+ vld1.8 {q3}, [r2], r1
+ vext.8 d7, d6, d7, #1
+ vmull.u8 q8, d6, d1
+ vmlal.u8 q8, d7, d0
+ vrshrn.u16 d4, q2, #3
+ vrshrn.u16 d16, q8, #3
+ vst1.8 {d4}, [r0,:64], r1
+ vst1.8 {d16}, [r0,:64], r1
+ bgt 1b
+
+ bx lr
+endfunc
+
+function ff_put_vp8_bilin8_v_neon, export=1
+ ldr r3, [sp, #8] @ my
+ rsb r12, r3, #8
+ vdup.8 d0, r3
+ vdup.8 d1, r12
+ ldr r12, [sp] @ h
+ vld1.8 {d2}, [r2], r1
+1:
+ subs r12, r12, #2
+ vld1.8 {d3}, [r2], r1
+ vmull.u8 q2, d2, d1
+ vmlal.u8 q2, d3, d0
+ vld1.8 {d2}, [r2], r1
+ vmull.u8 q3, d3, d1
+ vmlal.u8 q3, d2, d0
+ vrshrn.u16 d4, q2, #3
+ vrshrn.u16 d6, q3, #3
+ vst1.8 {d4}, [r0,:64], r1
+ vst1.8 {d6}, [r0,:64], r1
+ bgt 1b
+
+ bx lr
+endfunc
+
+function ff_put_vp8_bilin8_hv_neon, export=1
+ ldr r3, [sp, #4] @ mx
+ rsb r12, r3, #8
+ vdup.8 d0, r3
+ vdup.8 d1, r12
+ ldr r3, [sp, #8] @ my
+ rsb r12, r3, #8
+ vdup.8 d2, r3
+ vdup.8 d3, r12
+ ldr r12, [sp] @ h
+
+ vld1.8 {q2}, [r2], r1
+ vext.8 d5, d4, d5, #1
+ vmull.u8 q9, d4, d1
+ vmlal.u8 q9, d5, d0
+ vrshrn.u16 d22, q9, #3
+1:
+ subs r12, r12, #2
+ vld1.8 {q3}, [r2], r1
+ vext.8 d7, d6, d7, #1
+ vmull.u8 q8, d6, d1
+ vmlal.u8 q8, d7, d0
+ vld1.8 {q2}, [r2], r1
+ vext.8 d5, d4, d5, #1
+ vmull.u8 q9, d4, d1
+ vmlal.u8 q9, d5, d0
+ vrshrn.u16 d16, q8, #3
+ vmull.u8 q10, d22, d3
+ vmlal.u8 q10, d16, d2
+ vrshrn.u16 d22, q9, #3
+ vmull.u8 q12, d16, d3
+ vmlal.u8 q12, d22, d2
+ vrshrn.u16 d20, q10, #3
+ vst1.8 {d20}, [r0,:64], r1
+ vrshrn.u16 d23, q12, #3
+ vst1.8 {d23}, [r0,:64], r1
+ bgt 1b
+
+ bx lr
+endfunc
+
+function ff_put_vp8_bilin4_h_neon, export=1
+ ldr r3, [sp, #4] @ mx
+ rsb r12, r3, #8
+ vdup.8 d0, r3
+ vdup.8 d1, r12
+ ldr r12, [sp] @ h
+1:
+ subs r12, r12, #2
+ vld1.8 {d2}, [r2], r1
+ vext.8 d3, d2, d3, #1
+ vld1.8 {d6}, [r2], r1
+ vext.8 d7, d6, d7, #1
+ vtrn.32 q1, q3
+ vmull.u8 q2, d2, d1
+ vmlal.u8 q2, d3, d0
+ vrshrn.u16 d4, q2, #3
+ vst1.32 {d4[0]}, [r0,:32], r1
+ vst1.32 {d4[1]}, [r0,:32], r1
+ bgt 1b
+
+ bx lr
+endfunc
+
+function ff_put_vp8_bilin4_v_neon, export=1
+ ldr r3, [sp, #8] @ my
+ rsb r12, r3, #8
+ vdup.8 d0, r3
+ vdup.8 d1, r12
+ ldr r12, [sp] @ h
+ vld1.32 {d2[]}, [r2], r1
+1:
+ vld1.32 {d3[]}, [r2]
+ vld1.32 {d2[1]}, [r2], r1
+ vld1.32 {d3[1]}, [r2], r1
+ vmull.u8 q2, d2, d1
+ vmlal.u8 q2, d3, d0
+ vtrn.32 d3, d2
+ vrshrn.u16 d4, q2, #3
+ vst1.32 {d4[0]}, [r0,:32], r1
+ vst1.32 {d4[1]}, [r0,:32], r1
+ subs r12, r12, #2
+ bgt 1b
+
+ bx lr
+endfunc
+
+function ff_put_vp8_bilin4_hv_neon, export=1
+ ldr r3, [sp, #4] @ mx
+ rsb r12, r3, #8
+ vdup.8 d0, r3
+ vdup.8 d1, r12
+ ldr r3, [sp, #8] @ my
+ rsb r12, r3, #8
+ vdup.8 d2, r3
+ vdup.8 d3, r12
+ ldr r12, [sp] @ h
+
+ vld1.8 {d4}, [r2], r1
+ vext.8 d5, d4, d4, #1
+ vmull.u8 q9, d4, d1
+ vmlal.u8 q9, d5, d0
+ vrshrn.u16 d22, q9, #3
+1:
+ subs r12, r12, #2
+ vld1.8 {d6}, [r2], r1
+ vext.8 d7, d6, d6, #1
+ vld1.8 {d4}, [r2], r1
+ vext.8 d5, d4, d4, #1
+ vtrn.32 q3, q2
+ vmull.u8 q8, d6, d1
+ vmlal.u8 q8, d7, d0
+ vrshrn.u16 d16, q8, #3
+ vmull.u8 q10, d16, d2
+ vtrn.32 d22, d16
+ vmlal.u8 q10, d22, d3
+ vrev64.32 d22, d16
+ vrshrn.u16 d20, q10, #3
+ vst1.32 {d20[0]}, [r0,:32], r1
+ vst1.32 {d20[1]}, [r0,:32], r1
+ bgt 1b
+
+ bx lr
+endfunc
diff --git a/mplayer/ffmpeg/libavcodec/atrac1.c b/mplayer/ffmpeg/libavcodec/atrac1.c
index 4de1dcea..be78445b 100644
--- a/mplayer/ffmpeg/libavcodec/atrac1.c
+++ b/mplayer/ffmpeg/libavcodec/atrac1.c
@@ -141,7 +141,7 @@ static int at1_imdct_block(AT1SUCtx* su, AT1Ctx *q)
/* overlap and window */
q->dsp.vector_fmul_window(&q->bands[band_num][start_pos], prev_buf,
- &su->spectrum[0][ref_pos + start_pos], ff_sine_32, 0, 16);
+ &su->spectrum[0][ref_pos + start_pos], ff_sine_32, 16);
prev_buf = &su->spectrum[0][ref_pos+start_pos + 16];
start_pos += block_size;
diff --git a/mplayer/ffmpeg/libavcodec/audioconvert.c b/mplayer/ffmpeg/libavcodec/audioconvert.c
index b29b0306..67cacbdc 100644
--- a/mplayer/ffmpeg/libavcodec/audioconvert.c
+++ b/mplayer/ffmpeg/libavcodec/audioconvert.c
@@ -27,7 +27,7 @@
#include "libavutil/avstring.h"
#include "libavutil/libm.h"
-#include "libavcore/samplefmt.h"
+#include "libavutil/samplefmt.h"
#include "avcodec.h"
#include "audioconvert.h"
diff --git a/mplayer/ffmpeg/libavcodec/audioconvert.h b/mplayer/ffmpeg/libavcodec/audioconvert.h
index be4867c2..5f38cca5 100644
--- a/mplayer/ffmpeg/libavcodec/audioconvert.h
+++ b/mplayer/ffmpeg/libavcodec/audioconvert.h
@@ -31,6 +31,7 @@
#include "libavutil/cpu.h"
#include "avcodec.h"
+#include "libavutil/audioconvert.h"
#if FF_API_OLD_SAMPLE_FMT
/**
diff --git a/mplayer/ffmpeg/libavcodec/avcodec.h b/mplayer/ffmpeg/libavcodec/avcodec.h
index 601f8ed6..3eedcf94 100644
--- a/mplayer/ffmpeg/libavcodec/avcodec.h
+++ b/mplayer/ffmpeg/libavcodec/avcodec.h
@@ -27,13 +27,13 @@
*/
#include
-#include "libavcore/samplefmt.h"
+#include "libavutil/samplefmt.h"
#include "libavutil/avutil.h"
#include "libavutil/cpu.h"
#define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR 108
-#define LIBAVCODEC_VERSION_MICRO 0
+#define LIBAVCODEC_VERSION_MINOR 113
+#define LIBAVCODEC_VERSION_MICRO 2
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
@@ -260,6 +260,7 @@ enum CodecID {
CODEC_ID_R10K,
CODEC_ID_MXPEG,
CODEC_ID_LAGARITH,
+ CODEC_ID_PRORES,
/* various PCM "codecs" */
CODEC_ID_PCM_S16LE= 0x10000,
@@ -388,6 +389,7 @@ enum CodecID {
CODEC_ID_BINKAUDIO_RDFT,
CODEC_ID_BINKAUDIO_DCT,
CODEC_ID_AAC_LATM,
+ CODEC_ID_QDMC,
/* subtitle codecs */
CODEC_ID_DVD_SUBTITLE= 0x17000,
@@ -435,7 +437,7 @@ enum CodecID {
#endif
#if FF_API_OLD_AUDIOCONVERT
-#include "libavcore/audioconvert.h"
+#include "libavutil/audioconvert.h"
/* Audio channel masks */
#define CH_FRONT_LEFT AV_CH_FRONT_LEFT
@@ -726,6 +728,10 @@ typedef struct RcOverride{
* Codec is able to deal with negative linesizes
*/
#define CODEC_CAP_NEG_LINESIZES 0x0800
+/**
+ * Codec supports frame-level multithreading.
+ */
+#define CODEC_CAP_FRAME_THREADS 0x1000
//The following defines may change, don't expect compatibility if you use them.
#define MB_TYPE_INTRA4x4 0x0001
@@ -1025,7 +1031,20 @@ typedef struct AVPanScan{
* - decoding: Read by user.\
*/\
int64_t pkt_dts;\
-
+\
+ /**\
+ * the AVCodecContext which ff_thread_get_buffer() was last called on\
+ * - encoding: Set by libavcodec.\
+ * - decoding: Set by libavcodec.\
+ */\
+ struct AVCodecContext *owner;\
+\
+ /**\
+ * used by multithreading to store frame-specific info\
+ * - encoding: Set by libavcodec.\
+ * - decoding: Set by libavcodec.\
+ */\
+ void *thread_opaque;\
#define FF_QSCALE_TYPE_MPEG1 0
#define FF_QSCALE_TYPE_MPEG2 1
@@ -1237,6 +1256,10 @@ typedef struct AVCodecContext {
* decoder to draw a horizontal band. It improves cache usage. Not
* all codecs can do that. You must check the codec capabilities
* beforehand.
+ * When multithreading is used, it may be called from multiple threads
+ * at the same time; threads might draw different parts of the same AVFrame,
+ * or multiple AVFrames, and there is no guarantee that slices will be drawn
+ * in order.
* The function is also used by hardware acceleration APIs.
* It is called at least once during frame decoding to pass
* the data needed for hardware render.
@@ -1490,6 +1513,9 @@ typedef struct AVCodecContext {
* if CODEC_CAP_DR1 is not set then get_buffer() must call
* avcodec_default_get_buffer() instead of providing buffers allocated by
* some other means.
+ * If frame multithreading is used and thread_safe_callbacks is set,
+ * it may be called from a different thread, but not from more than one at once.
+ * Does not need to be reentrant.
* - encoding: unused
* - decoding: Set by libavcodec, user can override.
*/
@@ -1499,6 +1525,8 @@ typedef struct AVCodecContext {
* Called to release buffers which were allocated with get_buffer.
* A released buffer can be reused in get_buffer().
* pic.data[*] must be set to NULL.
+ * May be called from a different thread if frame multithreading is used,
+ * but not by more than one thread at once, so does not need to be reentrant.
* - encoding: unused
* - decoding: Set by libavcodec, user can override.
*/
@@ -1802,6 +1830,7 @@ typedef struct AVCodecContext {
#define FF_DEBUG_VIS_QP 0x00002000
#define FF_DEBUG_VIS_MB_TYPE 0x00004000
#define FF_DEBUG_BUFFERS 0x00008000
+#define FF_DEBUG_THREADS 0x00010000
/**
* debug
@@ -2260,14 +2289,22 @@ typedef struct AVCodecContext {
#define FF_PROFILE_DTS_HD_HRA 50
#define FF_PROFILE_DTS_HD_MA 60
-#define FF_PROFILE_H264_BASELINE 66
-#define FF_PROFILE_H264_MAIN 77
-#define FF_PROFILE_H264_EXTENDED 88
-#define FF_PROFILE_H264_HIGH 100
-#define FF_PROFILE_H264_HIGH_10 110
-#define FF_PROFILE_H264_HIGH_422 122
-#define FF_PROFILE_H264_HIGH_444 244
-#define FF_PROFILE_H264_CAVLC_444 44
+#define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
+#define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
+
+#define FF_PROFILE_H264_BASELINE 66
+#define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
+#define FF_PROFILE_H264_MAIN 77
+#define FF_PROFILE_H264_EXTENDED 88
+#define FF_PROFILE_H264_HIGH 100
+#define FF_PROFILE_H264_HIGH_10 110
+#define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
+#define FF_PROFILE_H264_HIGH_422 122
+#define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
+#define FF_PROFILE_H264_HIGH_444 144
+#define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
+#define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
+#define FF_PROFILE_H264_CAVLC_444 44
/**
* level
@@ -2817,6 +2854,52 @@ typedef struct AVCodecContext {
* - encoding: unused
*/
AVPacket *pkt;
+
+ /**
+ * Whether this is a copy of the context which had init() called on it.
+ * This is used by multithreading - shared tables and picture pointers
+ * should be freed from the original context only.
+ * - encoding: Set by libavcodec.
+ * - decoding: Set by libavcodec.
+ */
+ int is_copy;
+
+ /**
+ * Which multithreading methods to use.
+ * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
+ * so clients which cannot provide future frames should not use it.
+ *
+ * - encoding: Set by user, otherwise the default is used.
+ * - decoding: Set by user, otherwise the default is used.
+ */
+ int thread_type;
+#define FF_THREAD_FRAME 1 //< Decode more than one frame at once
+#define FF_THREAD_SLICE 2 //< Decode more than one part of a single frame at once
+
+ /**
+ * Which multithreading methods are in use by the codec.
+ * - encoding: Set by libavcodec.
+ * - decoding: Set by libavcodec.
+ */
+ int active_thread_type;
+
+ /**
+ * Set by the client if its custom get_buffer() callback can be called
+ * from another thread, which allows faster multithreaded decoding.
+ * draw_horiz_band() will be called from other threads regardless of this setting.
+ * Ignored if the default get_buffer() is used.
+ * - encoding: Set by user.
+ * - decoding: Set by user.
+ */
+ int thread_safe_callbacks;
+
+ /**
+ * VBV delay coded in the last frame (in periods of a 27 MHz clock).
+ * Used for compliant TS muxing.
+ * - encoding: Set by libavcodec.
+ * - decoding: unused.
+ */
+ uint64_t vbv_delay;
} AVCodecContext;
/**
@@ -2869,6 +2952,26 @@ typedef struct AVCodec {
uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
AVClass *priv_class; ///< AVClass for the private context
const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
+
+ /**
+ * @defgroup framethreading Frame-level threading support functions.
+ * @{
+ */
+ /**
+ * If defined, called on thread contexts when they are created.
+ * If the codec allocates writable tables in init(), re-allocate them here.
+ * priv_data will be set to a copy of the original.
+ */
+ int (*init_thread_copy)(AVCodecContext *);
+ /**
+ * Copy necessary context variables from a previous thread context to the current one.
+ * If not defined, the next thread will start automatically; otherwise, the codec
+ * must call ff_thread_finish_setup().
+ *
+ * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
+ */
+ int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
+ /** @} */
} AVCodec;
/**
@@ -3119,8 +3222,9 @@ typedef struct ReSampleContext ReSampleContext;
attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, int input_channels,
int output_rate, int input_rate);
#endif
+
/**
- * Initialize audio resampling context
+ * Initialize audio resampling context.
*
* @param output_channels number of output channels
* @param input_channels number of input channels
@@ -3128,9 +3232,9 @@ attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, i
* @param input_rate input sample rate
* @param sample_fmt_out requested output sample format
* @param sample_fmt_in input sample format
- * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
+ * @param filter_length length of each FIR filter in the filterbank relative to the cutoff frequency
* @param log2_phase_count log2 of the number of entries in the polyphase filterbank
- * @param linear If 1 then the used FIR filter will be linearly interpolated
+ * @param linear if 1 then the used FIR filter will be linearly interpolated
between the 2 closest, if 0 the closest will be used
* @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
* @return allocated ReSampleContext, NULL if error occured
@@ -3143,6 +3247,13 @@ ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
int linear, double cutoff);
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
+
+/**
+ * Free resample context.
+ *
+ * @param s a non-NULL pointer to a resample context previously
+ * created with av_audio_resample_init()
+ */
void audio_resample_close(ReSampleContext *s);
@@ -3542,8 +3653,14 @@ int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
+#if LIBAVCODEC_VERSION_MAJOR < 53
+/**
+ * @deprecated Set s->thread_count before calling avcodec_open() instead of calling this.
+ */
+attribute_deprecated
int avcodec_thread_init(AVCodecContext *s, int thread_count);
void avcodec_thread_free(AVCodecContext *s);
+#endif
int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
//FIXME func typedef
diff --git a/mplayer/ffmpeg/libavcodec/bink.c b/mplayer/ffmpeg/libavcodec/bink.c
index 64a10b71..d1985edd 100644
--- a/mplayer/ffmpeg/libavcodec/bink.c
+++ b/mplayer/ffmpeg/libavcodec/bink.c
@@ -1,6 +1,7 @@
/*
* Bink video decoder
* Copyright (c) 2009 Konstantin Shishkov
+ * Copyright (C) 2011 Peter Ross
*
* This file is part of FFmpeg.
*
@@ -19,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "binkdata.h"
@@ -33,6 +34,35 @@
static VLC bink_trees[16];
+/**
+ * IDs for different data types used in old version of Bink video codec
+ */
+enum OldSources {
+ BINKB_SRC_BLOCK_TYPES = 0, ///< 8x8 block types
+ BINKB_SRC_COLORS, ///< pixel values used for different block types
+ BINKB_SRC_PATTERN, ///< 8-bit values for 2-colour pattern fill
+ BINKB_SRC_X_OFF, ///< X components of motion value
+ BINKB_SRC_Y_OFF, ///< Y components of motion value
+ BINKB_SRC_INTRA_DC, ///< DC values for intrablocks with DCT
+ BINKB_SRC_INTER_DC, ///< DC values for interblocks with DCT
+ BINKB_SRC_INTRA_Q, ///< quantizer values for intrablocks with DCT
+ BINKB_SRC_INTER_Q, ///< quantizer values for interblocks with DCT
+ BINKB_SRC_INTER_COEFS, ///< number of coefficients for residue blocks
+
+ BINKB_NB_SRC
+};
+
+static const int binkb_bundle_sizes[BINKB_NB_SRC] = {
+ 4, 8, 8, 5, 5, 11, 11, 4, 4, 7
+};
+
+static const int binkb_bundle_signed[BINKB_NB_SRC] = {
+ 0, 0, 0, 1, 1, 0, 1, 0, 0, 0
+};
+
+static uint32_t binkb_intra_quant[16][64];
+static uint32_t binkb_inter_quant[16][64];
+
/**
* IDs for different data types used in Bink video codec
*/
@@ -85,7 +115,7 @@ typedef struct BinkContext {
int swap_planes;
ScanTable scantable; ///< permutated scantable for DCT coeffs decoding
- Bundle bundle[BINK_NB_SRC]; ///< bundles for decoding all data types
+ Bundle bundle[BINKB_NB_SRC]; ///< bundles for decoding all data types
Tree col_high[16]; ///< trees for decoding high nibble in "colours" data type
int col_lastval; ///< value of last decoded high nibble in "colours" data type
} BinkContext;
@@ -145,7 +175,7 @@ static av_cold void init_bundles(BinkContext *c)
bh = (c->avctx->height + 7) >> 3;
blocks = bw * bh;
- for (i = 0; i < BINK_NB_SRC; i++) {
+ for (i = 0; i < BINKB_NB_SRC; i++) {
c->bundle[i].data = av_malloc(blocks * 64);
c->bundle[i].data_end = c->bundle[i].data + blocks * 64;
}
@@ -159,7 +189,7 @@ static av_cold void init_bundles(BinkContext *c)
static av_cold void free_bundles(BinkContext *c)
{
int i;
- for (i = 0; i < BINK_NB_SRC; i++)
+ for (i = 0; i < BINKB_NB_SRC; i++)
av_freep(&c->bundle[i].data);
}
@@ -470,7 +500,7 @@ static int read_dcs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b,
*/
static inline int get_value(BinkContext *c, int bundle)
{
- int16_t ret;
+ int ret;
if (bundle < BINK_SRC_X_OFF || bundle == BINK_SRC_RUN)
return *c->bundle[bundle].cur_ptr++;
@@ -481,17 +511,77 @@ static inline int get_value(BinkContext *c, int bundle)
return ret;
}
+static void binkb_init_bundle(BinkContext *c, int bundle_num)
+{
+ c->bundle[bundle_num].cur_dec =
+ c->bundle[bundle_num].cur_ptr = c->bundle[bundle_num].data;
+ c->bundle[bundle_num].len = 13;
+}
+
+static void binkb_init_bundles(BinkContext *c)
+{
+ int i;
+ for (i = 0; i < BINKB_NB_SRC; i++)
+ binkb_init_bundle(c, i);
+}
+
+static int binkb_read_bundle(BinkContext *c, GetBitContext *gb, int bundle_num)
+{
+ const int bits = binkb_bundle_sizes[bundle_num];
+ const int mask = 1 << (bits - 1);
+ const int issigned = binkb_bundle_signed[bundle_num];
+ Bundle *b = &c->bundle[bundle_num];
+ int i, len;
+
+ CHECK_READ_VAL(gb, b, len);
+ if (bits <= 8) {
+ if (!issigned) {
+ for (i = 0; i < len; i++)
+ *b->cur_dec++ = get_bits(gb, bits);
+ } else {
+ for (i = 0; i < len; i++)
+ *b->cur_dec++ = get_bits(gb, bits) - mask;
+ }
+ } else {
+ int16_t *dst = (int16_t*)b->cur_dec;
+
+ if (!issigned) {
+ for (i = 0; i < len; i++)
+ *dst++ = get_bits(gb, bits);
+ } else {
+ for (i = 0; i < len; i++)
+ *dst++ = get_bits(gb, bits) - mask;
+ }
+ b->cur_dec = (uint8_t*)dst;
+ }
+ return 0;
+}
+
+static inline int binkb_get_value(BinkContext *c, int bundle_num)
+{
+ int16_t ret;
+ const int bits = binkb_bundle_sizes[bundle_num];
+
+ if (bits <= 8) {
+ int val = *c->bundle[bundle_num].cur_ptr++;
+ return binkb_bundle_signed[bundle_num] ? (int8_t)val : val;
+ }
+ ret = *(int16_t*)c->bundle[bundle_num].cur_ptr;
+ c->bundle[bundle_num].cur_ptr += 2;
+ return ret;
+}
+
/**
* Read 8x8 block of DCT coefficients.
*
* @param gb context for reading bits
* @param block place for storing coefficients
* @param scan scan order table
- * @param is_intra tells what set of quantizer matrices to use
+ * @param quant_matrices quantization matrices
* @return 0 for success, negative value in other cases
*/
static int read_dct_coeffs(GetBitContext *gb, DCTELEM block[64], const uint8_t *scan,
- int is_intra)
+ const uint32_t quant_matrices[16][64], int q)
{
int coef_list[128];
int mode_list[128];
@@ -571,9 +661,14 @@ static int read_dct_coeffs(GetBitContext *gb, DCTELEM block[64], const uint8_t *
}
}
- quant_idx = get_bits(gb, 4);
- quant = is_intra ? bink_intra_quant[quant_idx]
- : bink_inter_quant[quant_idx];
+ if (q == -1) {
+ quant_idx = get_bits(gb, 4);
+ } else {
+ quant_idx = q;
+ }
+
+ quant = quant_matrices[quant_idx];
+
block[0] = (block[0] * quant[0]) >> 11;
for (i = 0; i < coef_count; i++) {
int idx = coef_idx[i];
@@ -673,6 +768,164 @@ static int read_residue(GetBitContext *gb, DCTELEM block[64], int masks_count)
return 0;
}
+/**
+ * Copy 8x8 block from source to destination, where src and dst may be overlapped
+ */
+static inline void put_pixels8x8_overlapped(uint8_t *dst, uint8_t *src, int stride)
+{
+ uint8_t tmp[64];
+ int i;
+ for (i = 0; i < 8; i++)
+ memcpy(tmp + i*8, src + i*stride, 8);
+ for (i = 0; i < 8; i++)
+ memcpy(dst + i*stride, tmp + i*8, 8);
+}
+
+static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx,
+ int is_key, int is_chroma)
+{
+ int blk;
+ int i, j, bx, by;
+ uint8_t *dst, *ref, *ref_start, *ref_end;
+ int v, col[2];
+ const uint8_t *scan;
+ int xoff, yoff;
+ LOCAL_ALIGNED_16(DCTELEM, block, [64]);
+ int coordmap[64];
+ int ybias = is_key ? -15 : 0;
+ int qp;
+
+ const int stride = c->pic.linesize[plane_idx];
+ int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3;
+ int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;
+
+ binkb_init_bundles(c);
+ ref_start = c->pic.data[plane_idx];
+ ref_end = c->pic.data[plane_idx] + (bh * c->pic.linesize[plane_idx] + bw) * 8;
+
+ for (i = 0; i < 64; i++)
+ coordmap[i] = (i & 7) + (i >> 3) * stride;
+
+ for (by = 0; by < bh; by++) {
+ for (i = 0; i < BINKB_NB_SRC; i++) {
+ if (binkb_read_bundle(c, gb, i) < 0)
+ return -1;
+ }
+
+ dst = c->pic.data[plane_idx] + 8*by*stride;
+ for (bx = 0; bx < bw; bx++, dst += 8) {
+ blk = binkb_get_value(c, BINKB_SRC_BLOCK_TYPES);
+ switch (blk) {
+ case 0:
+ break;
+ case 1:
+ scan = bink_patterns[get_bits(gb, 4)];
+ i = 0;
+ do {
+ int mode, run;
+
+ mode = get_bits1(gb);
+ run = get_bits(gb, binkb_runbits[i]) + 1;
+
+ i += run;
+ if (i > 64) {
+ av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
+ return -1;
+ }
+ if (mode) {
+ v = binkb_get_value(c, BINKB_SRC_COLORS);
+ for (j = 0; j < run; j++)
+ dst[coordmap[*scan++]] = v;
+ } else {
+ for (j = 0; j < run; j++)
+ dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS);
+ }
+ } while (i < 63);
+ if (i == 63)
+ dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS);
+ break;
+ case 2:
+ c->dsp.clear_block(block);
+ block[0] = binkb_get_value(c, BINKB_SRC_INTRA_DC);
+ qp = binkb_get_value(c, BINKB_SRC_INTRA_Q);
+ read_dct_coeffs(gb, block, c->scantable.permutated, binkb_intra_quant, qp);
+ c->dsp.idct_put(dst, stride, block);
+ break;
+ case 3:
+ xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
+ yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
+ ref = dst + xoff + yoff * stride;
+ if (ref < ref_start || ref + 8*stride > ref_end) {
+ av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
+ } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
+ c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
+ } else {
+ put_pixels8x8_overlapped(dst, ref, stride);
+ }
+ c->dsp.clear_block(block);
+ v = binkb_get_value(c, BINKB_SRC_INTER_COEFS);
+ read_residue(gb, block, v);
+ c->dsp.add_pixels8(dst, block, stride);
+ break;
+ case 4:
+ xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
+ yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
+ ref = dst + xoff + yoff * stride;
+ if (ref < ref_start || ref + 8 * stride > ref_end) {
+ av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
+ } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
+ c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
+ } else {
+ put_pixels8x8_overlapped(dst, ref, stride);
+ }
+ c->dsp.clear_block(block);
+ block[0] = binkb_get_value(c, BINKB_SRC_INTER_DC);
+ qp = binkb_get_value(c, BINKB_SRC_INTER_Q);
+ read_dct_coeffs(gb, block, c->scantable.permutated, binkb_inter_quant, qp);
+ c->dsp.idct_add(dst, stride, block);
+ break;
+ case 5:
+ v = binkb_get_value(c, BINKB_SRC_COLORS);
+ c->dsp.fill_block_tab[1](dst, v, stride, 8);
+ break;
+ case 6:
+ for (i = 0; i < 2; i++)
+ col[i] = binkb_get_value(c, BINKB_SRC_COLORS);
+ for (i = 0; i < 8; i++) {
+ v = binkb_get_value(c, BINKB_SRC_PATTERN);
+ for (j = 0; j < 8; j++, v >>= 1)
+ dst[i*stride + j] = col[v & 1];
+ }
+ break;
+ case 7:
+ xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
+ yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
+ ref = dst + xoff + yoff * stride;
+ if (ref < ref_start || ref + 8 * stride > ref_end) {
+ av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
+ } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
+ c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
+ } else {
+ put_pixels8x8_overlapped(dst, ref, stride);
+ }
+ break;
+ case 8:
+ for (i = 0; i < 8; i++)
+ memcpy(dst + i*stride, c->bundle[BINKB_SRC_COLORS].cur_ptr + i*8, 8);
+ c->bundle[BINKB_SRC_COLORS].cur_ptr += 64;
+ break;
+ default:
+ av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk);
+ return -1;
+ }
+ }
+ }
+ if (get_bits_count(gb) & 0x1F) //next plane data starts at 32-bit boundary
+ skip_bits_long(gb, 32 - (get_bits_count(gb) & 0x1F));
+
+ return 0;
+}
+
static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx,
int is_chroma)
{
@@ -768,7 +1021,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx,
case INTRA_BLOCK:
c->dsp.clear_block(block);
block[0] = get_value(c, BINK_SRC_INTRA_DC);
- read_dct_coeffs(gb, block, c->scantable.permutated, 1);
+ read_dct_coeffs(gb, block, c->scantable.permutated, bink_intra_quant, -1);
c->dsp.idct(block);
c->dsp.put_pixels_nonclamped(block, ublock, 8);
break;
@@ -852,7 +1105,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx,
case INTRA_BLOCK:
c->dsp.clear_block(block);
block[0] = get_value(c, BINK_SRC_INTRA_DC);
- read_dct_coeffs(gb, block, c->scantable.permutated, 1);
+ read_dct_coeffs(gb, block, c->scantable.permutated, bink_intra_quant, -1);
c->dsp.idct_put(dst, stride, block);
break;
case FILL_BLOCK:
@@ -866,7 +1119,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx,
c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
c->dsp.clear_block(block);
block[0] = get_value(c, BINK_SRC_INTER_DC);
- read_dct_coeffs(gb, block, c->scantable.permutated, 0);
+ read_dct_coeffs(gb, block, c->scantable.permutated, bink_inter_quant, -1);
c->dsp.idct_add(dst, stride, block);
break;
case PATTERN_BLOCK:
@@ -902,12 +1155,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
int plane, plane_idx;
int bits_count = pkt->size << 3;
- if(c->pic.data[0])
- avctx->release_buffer(avctx, &c->pic);
+ if (c->version > 'b') {
+ if(c->pic.data[0])
+ avctx->release_buffer(avctx, &c->pic);
- if(avctx->get_buffer(avctx, &c->pic) < 0){
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
+ if(avctx->get_buffer(avctx, &c->pic) < 0){
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return -1;
+ }
+ } else {
+ if(avctx->reget_buffer(avctx, &c->pic) < 0){
+ av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
+ return -1;
+ }
}
init_get_bits(&gb, pkt->data, bits_count);
@@ -923,8 +1183,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
for (plane = 0; plane < 3; plane++) {
plane_idx = (!plane || !c->swap_planes) ? plane : (plane ^ 3);
- if (bink_decode_plane(c, &gb, plane_idx, !!plane) < 0)
- return -1;
+ if (c->version > 'b') {
+ if (bink_decode_plane(c, &gb, plane_idx, !!plane) < 0)
+ return -1;
+ } else {
+ if (binkb_decode_plane(c, &gb, plane_idx, !pkt->pts, !!plane) < 0)
+ return -1;
+ }
if (get_bits_count(&gb) >= bits_count)
break;
}
@@ -933,24 +1198,67 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
*data_size = sizeof(AVFrame);
*(AVFrame*)data = c->pic;
- FFSWAP(AVFrame, c->pic, c->last);
+ if (c->version > 'b')
+ FFSWAP(AVFrame, c->pic, c->last);
/* always report that the buffer was completely consumed */
return pkt->size;
}
+/**
+ * Caclulate quantization tables for version b
+ */
+static av_cold void binkb_calc_quant()
+{
+ uint8_t inv_bink_scan[64];
+ double s[64];
+ int i, j;
+
+ for (j = 0; j < 8; j++) {
+ for (i = 0; i < 8; i++) {
+ if (j && j != 4)
+ if (i && i != 4)
+ s[j*8 + i] = cos(j * M_PI/16.0) * cos(i * M_PI/16.0) * 2.0;
+ else
+ s[j*8 + i] = cos(j * M_PI/16.0) * sqrt(2.0);
+ else
+ if (i && i != 4)
+ s[j*8 + i] = cos(i * M_PI/16.0) * sqrt(2.0);
+ else
+ s[j*8 + i] = 1.0;
+ }
+ }
+
+ for (i = 0; i < 64; i++)
+ inv_bink_scan[bink_scan[i]] = i;
+
+ for (j = 0; j < 16; j++) {
+ for (i = 0; i < 64; i++) {
+ int k = inv_bink_scan[i];
+ if (s[i] == 1.0) {
+ binkb_intra_quant[j][k] = (1L << 12) * binkb_intra_seed[i] *
+ binkb_num[j]/binkb_den[j];
+ binkb_inter_quant[j][k] = (1L << 12) * binkb_inter_seed[i] *
+ binkb_num[j]/binkb_den[j];
+ } else {
+ binkb_intra_quant[j][k] = (1L << 12) * binkb_intra_seed[i] * s[i] *
+ binkb_num[j]/(double)binkb_den[j];
+ binkb_inter_quant[j][k] = (1L << 12) * binkb_inter_seed[i] * s[i] *
+ binkb_num[j]/(double)binkb_den[j];
+ }
+ }
+ }
+}
+
static av_cold int decode_init(AVCodecContext *avctx)
{
BinkContext * const c = avctx->priv_data;
static VLC_TYPE table[16 * 128][2];
+ static int binkb_initialised = 0;
int i;
int flags;
c->version = avctx->codec_tag >> 24;
- if (c->version < 'c') {
- av_log(avctx, AV_LOG_ERROR, "Too old version '%c'\n", c->version);
- return -1;
- }
if (avctx->extradata_size < 4) {
av_log(avctx, AV_LOG_ERROR, "Extradata missing or too short\n");
return -1;
@@ -984,6 +1292,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
init_bundles(c);
+ if (c->version == 'b') {
+ if (!binkb_initialised) {
+ binkb_calc_quant();
+ binkb_initialised = 1;
+ }
+ }
+
return 0;
}
diff --git a/mplayer/ffmpeg/libavcodec/binkaudio.c b/mplayer/ffmpeg/libavcodec/binkaudio.c
index ae2f6c88..a00d6578 100644
--- a/mplayer/ffmpeg/libavcodec/binkaudio.c
+++ b/mplayer/ffmpeg/libavcodec/binkaudio.c
@@ -1,6 +1,6 @@
/*
* Bink Audio decoder
- * Copyright (c) 2007-2010 Peter Ross (pross@xvid.org)
+ * Copyright (c) 2007-2011 Peter Ross (pross@xvid.org)
* Copyright (c) 2009 Daniel Verkamp (daniel@drv.nu)
*
* This file is part of FFmpeg.
@@ -33,6 +33,8 @@
#include "get_bits.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
+#include "libavutil/intfloat_readwrite.h"
extern const uint16_t ff_wma_critical_freqs[25];
@@ -40,9 +42,10 @@ extern const uint16_t ff_wma_critical_freqs[25];
#define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11)
typedef struct {
- AVCodecContext *avctx;
GetBitContext gb;
DSPContext dsp;
+ FmtConvertContext fmt_conv;
+ int version_b; ///< Bink version 'b'
int first;
int channels;
int frame_len; ///< transform size (samples)
@@ -69,8 +72,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
int i;
int frame_len_bits;
- s->avctx = avctx;
dsputil_init(&s->dsp, avctx);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
/* determine frame length */
if (avctx->sample_rate < 22050) {
@@ -80,24 +83,25 @@ static av_cold int decode_init(AVCodecContext *avctx)
} else {
frame_len_bits = 11;
}
- s->frame_len = 1 << frame_len_bits;
- if (s->channels > MAX_CHANNELS) {
- av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels);
+ if (avctx->channels > MAX_CHANNELS) {
+ av_log(avctx, AV_LOG_ERROR, "too many channels: %d\n", avctx->channels);
return -1;
}
+ s->version_b = avctx->codec_tag == MKTAG('B','I','K','b');
+
if (avctx->codec->id == CODEC_ID_BINKAUDIO_RDFT) {
// audio is already interleaved for the RDFT format variant
sample_rate *= avctx->channels;
- s->frame_len *= avctx->channels;
s->channels = 1;
- if (avctx->channels == 2)
- frame_len_bits++;
+ if (!s->version_b)
+ frame_len_bits += av_log2(avctx->channels);
} else {
s->channels = avctx->channels;
}
+ s->frame_len = 1 << frame_len_bits;
s->overlap_len = s->frame_len / 16;
s->block_size = (s->frame_len - s->overlap_len) * s->channels;
sample_rate_half = (sample_rate + 1) / 2;
@@ -113,10 +117,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
/* populate bands data */
- s->bands[0] = 1;
+ s->bands[0] = 2;
for (i = 1; i < s->num_bands; i++)
- s->bands[i] = ff_wma_critical_freqs[i - 1] * (s->frame_len / 2) / sample_rate_half;
- s->bands[s->num_bands] = s->frame_len / 2;
+ s->bands[i] = (ff_wma_critical_freqs[i - 1] * s->frame_len / sample_rate_half) & ~1;
+ s->bands[s->num_bands] = s->frame_len;
s->first = 1;
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
@@ -163,9 +167,13 @@ static void decode_block(BinkAudioContext *s, short *out, int use_dct)
for (ch = 0; ch < s->channels; ch++) {
FFTSample *coeffs = s->coeffs_ptr[ch];
- q = 0.0f;
- coeffs[0] = get_float(gb) * s->root;
- coeffs[1] = get_float(gb) * s->root;
+ if (s->version_b) {
+ coeffs[0] = av_int2flt(get_bits(gb, 32)) * s->root;
+ coeffs[1] = av_int2flt(get_bits(gb, 32)) * s->root;
+ } else {
+ coeffs[0] = get_float(gb) * s->root;
+ coeffs[1] = get_float(gb) * s->root;
+ }
for (i = 0; i < s->num_bands; i++) {
/* constant is result of 0.066399999/log10(M_E) */
@@ -173,15 +181,15 @@ static void decode_block(BinkAudioContext *s, short *out, int use_dct)
quant[i] = expf(FFMIN(value, 95) * 0.15289164787221953823f) * s->root;
}
- // find band (k)
- for (k = 0; s->bands[k] < 1; k++) {
- q = quant[k];
- }
+ k = 0;
+ q = quant[0];
// parse coefficients
i = 2;
while (i < s->frame_len) {
- if (get_bits1(gb)) {
+ if (s->version_b) {
+ j = i + 16;
+ } else if (get_bits1(gb)) {
j = i + rle_length_tab[get_bits(gb, 4)] * 8;
} else {
j = i + 8;
@@ -193,11 +201,11 @@ static void decode_block(BinkAudioContext *s, short *out, int use_dct)
if (width == 0) {
memset(coeffs + i, 0, (j - i) * sizeof(*coeffs));
i = j;
- while (s->bands[k] * 2 < i)
+ while (s->bands[k] < i)
q = quant[k++];
} else {
while (i < j) {
- if (s->bands[k] * 2 == i)
+ if (s->bands[k] == i)
q = quant[k++];
coeff = get_bits(gb, width);
if (coeff) {
@@ -222,7 +230,8 @@ static void decode_block(BinkAudioContext *s, short *out, int use_dct)
ff_rdft_calc(&s->trans.rdft, coeffs);
}
- s->dsp.float_to_int16_interleave(out, (const float **)s->coeffs_ptr, s->frame_len, s->channels);
+ s->fmt_conv.float_to_int16_interleave(out, (const float **)s->coeffs_ptr,
+ s->frame_len, s->channels);
if (!s->first) {
int count = s->overlap_len * s->channels;
diff --git a/mplayer/ffmpeg/libavcodec/binkdata.h b/mplayer/ffmpeg/libavcodec/binkdata.h
index 1ca34a68..2c20b4a4 100644
--- a/mplayer/ffmpeg/libavcodec/binkdata.h
+++ b/mplayer/ffmpeg/libavcodec/binkdata.h
@@ -611,4 +611,45 @@ static const uint32_t bink_inter_quant[16][64] = {
},
};
+static const uint8_t binkb_runbits[64] = {
+ 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6,
+ 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5,
+ 4, 4, 4, 4, 4, 4, 4, 4,
+ 3, 3, 3, 3, 2, 2, 1, 0,
+};
+
+static const uint8_t binkb_intra_seed[64] = {
+ 16, 16, 16, 19, 16, 19, 22, 22,
+ 22, 22, 26, 24, 26, 22, 22, 27,
+ 27, 27, 26, 26, 26, 29, 29, 29,
+ 27, 27, 27, 26, 34, 34, 34, 29,
+ 29, 29, 27, 27, 37, 34, 34, 32,
+ 32, 29, 29, 38, 37, 35, 35, 34,
+ 35, 40, 40, 40, 38, 38, 48, 48,
+ 46, 46, 58, 56, 56, 69, 69, 83,
+};
+
+static const uint8_t binkb_inter_seed[64] = {
+ 16, 17, 17, 18, 18, 18, 19, 19,
+ 19, 19, 20, 20, 20, 20, 20, 21,
+ 21, 21, 21, 21, 21, 22, 22, 22,
+ 22, 22, 22, 22, 23, 23, 23, 23,
+ 23, 23, 23, 23, 24, 24, 24, 25,
+ 24, 24, 24, 25, 26, 26, 26, 26,
+ 25, 27, 27, 27, 27, 27, 28, 28,
+ 28, 28, 30, 30, 30, 31, 31, 33,
+};
+
+static const uint8_t binkb_num[16] = {
+ 1, 4, 5, 2, 7, 8, 3, 7, 4, 9, 5, 6, 7, 8, 9, 10
+};
+
+static const uint8_t binkb_den[16] = {
+ 1, 3, 3, 1, 3, 3, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1
+};
+
#endif /* AVCODEC_BINKDATA_H */
diff --git a/mplayer/ffmpeg/libavcodec/binkidct.c b/mplayer/ffmpeg/libavcodec/binkidct.c
index 160926e1..ddb6cc1a 100644
--- a/mplayer/ffmpeg/libavcodec/binkidct.c
+++ b/mplayer/ffmpeg/libavcodec/binkidct.c
@@ -62,7 +62,7 @@
#define MUNGE_ROW(x) (((x) + 0x7F)>>8)
#define IDCT_ROW(dest,src) IDCT_TRANSFORM(dest,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,MUNGE_ROW,src)
-static inline void bink_idct_col(DCTELEM *dest, const DCTELEM *src)
+static inline void bink_idct_col(int *dest, const DCTELEM *src)
{
if ((src[8]|src[16]|src[24]|src[32]|src[40]|src[48]|src[56])==0) {
dest[0] =
@@ -81,7 +81,7 @@ static inline void bink_idct_col(DCTELEM *dest, const DCTELEM *src)
void ff_bink_idct_c(DCTELEM *block)
{
int i;
- DCTELEM temp[64];
+ int temp[64];
for (i = 0; i < 8; i++)
bink_idct_col(&temp[i], &block[i]);
@@ -103,7 +103,7 @@ void ff_bink_idct_add_c(uint8_t *dest, int linesize, DCTELEM *block)
void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block)
{
int i;
- DCTELEM temp[64];
+ int temp[64];
for (i = 0; i < 8; i++)
bink_idct_col(&temp[i], &block[i]);
for (i = 0; i < 8; i++) {
diff --git a/mplayer/ffmpeg/libavcodec/bmpenc.c b/mplayer/ffmpeg/libavcodec/bmpenc.c
index d424662b..b8f9047c 100644
--- a/mplayer/ffmpeg/libavcodec/bmpenc.c
+++ b/mplayer/ffmpeg/libavcodec/bmpenc.c
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcore/internal.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "bmp.h"
diff --git a/mplayer/ffmpeg/libavcodec/cook.c b/mplayer/ffmpeg/libavcodec/cook.c
index 6b705605..da31e9f5 100644
--- a/mplayer/ffmpeg/libavcodec/cook.c
+++ b/mplayer/ffmpeg/libavcodec/cook.c
@@ -53,6 +53,7 @@
#include "dsputil.h"
#include "bytestream.h"
#include "fft.h"
+#include "libavutil/audioconvert.h"
#include "cookdata.h"
@@ -1274,7 +1275,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
if (channel_mask)
avctx->channel_layout = channel_mask;
else
- avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
+ avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
#ifdef COOKDEBUG
dump_cook_context(q);
diff --git a/mplayer/ffmpeg/libavcodec/dca.c b/mplayer/ffmpeg/libavcodec/dca.c
index fc5c0b55..14b0b2d1 100644
--- a/mplayer/ffmpeg/libavcodec/dca.c
+++ b/mplayer/ffmpeg/libavcodec/dca.c
@@ -29,7 +29,7 @@
#include "libavutil/common.h"
#include "libavutil/intmath.h"
#include "libavutil/intreadwrite.h"
-#include "libavcore/audioconvert.h"
+#include "libavutil/audioconvert.h"
#include "avcodec.h"
#include "dsputil.h"
#include "fft.h"
@@ -40,6 +40,7 @@
#include "dca.h"
#include "synth_filter.h"
#include "dcadsp.h"
+#include "fmtconvert.h"
//#define TRACE
@@ -98,6 +99,21 @@ enum DCAExtensionMask {
DCA_EXT_EXSS_XLL = 0x200, ///< lossless extension in ExSS
};
+/* -1 are reserved or unknown */
+static const int dca_ext_audio_descr_mask[] = {
+ DCA_EXT_XCH,
+ -1,
+ DCA_EXT_X96,
+ DCA_EXT_XCH | DCA_EXT_X96,
+ -1,
+ -1,
+ DCA_EXT_XXCH,
+ -1,
+};
+
+/* extensions that reside in core substream */
+#define DCA_CORE_EXTS (DCA_EXT_XCH | DCA_EXT_XXCH | DCA_EXT_X96)
+
/* Tables for mapping dts channel configurations to libavcodec multichannel api.
* Some compromises have been made for special configurations. Most configurations
* are never used so complete accuracy is not needed.
@@ -105,7 +121,7 @@ enum DCAExtensionMask {
* L = left, R = right, C = center, S = surround, F = front, R = rear, T = total, OV = overhead.
* S -> side, when both rear and back are configured move one of them to the side channel
* OV -> center back
- * All 2 channel configurations -> CH_LAYOUT_STEREO
+ * All 2 channel configurations -> AV_CH_LAYOUT_STEREO
*/
static const int64_t dca_core_channel_layout[] = {
@@ -116,7 +132,7 @@ static const int64_t dca_core_channel_layout[] = {
AV_CH_LAYOUT_STEREO, ///< 2, LT +RT (left and right total)
AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER, ///< 3, C+L+R
AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER, ///< 3, L+R+S
- AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER|CH_BACK_CENTER, ///< 4, C + L + R+ S
+ AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER, ///< 4, C + L + R+ S
AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 4, L + R +SL+ SR
AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 5, C + L + R+ SL+SR
AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR
@@ -326,14 +342,12 @@ typedef struct {
int current_subframe;
int current_subsubframe;
+ int core_ext_mask; ///< present extensions in the core substream
+
/* XCh extension information */
- int xch_present;
+ int xch_present; ///< XCh extension present and valid
int xch_base_channel; ///< index of first (only) channel containing XCH data
- /* Other detected extensions in the core substream */
- int xxch_present;
- int x96_present;
-
/* ExSS header parser */
int static_fields; ///< static fields present
int mix_metadata; ///< mixing metadata present
@@ -347,6 +361,7 @@ typedef struct {
FFTContext imdct;
SynthFilterContext synth;
DCADSPContext dcadsp;
+ FmtConvertContext fmt_conv;
} DCAContext;
static const uint16_t dca_vlc_offs[] = {
@@ -896,7 +911,7 @@ static void qmf_32_subbands(DCAContext * s, int chans,
s->synth.synth_filter_float(&s->imdct,
s->subband_fir_hist[chans], &s->hist_index[chans],
s->subband_fir_noidea[chans], prCoeff,
- samples_out, s->raXin, scale, 0);
+ samples_out, s->raXin, scale);
samples_out+= 32;
}
@@ -929,7 +944,7 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
/* Interpolation */
for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor,
- scale, 0);
+ scale);
samples_in++;
samples_out += 2 * decifactor;
}
@@ -1115,7 +1130,7 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index)
block[m] = get_bitalloc(&s->gb, &dca_smpl_bitalloc[abits], sel);
}
- s->dsp.int32_to_float_fmul_scalar(subband_samples[k][l],
+ s->fmt_conv.int32_to_float_fmul_scalar(subband_samples[k][l],
block, rscale, 8);
}
@@ -1354,7 +1369,9 @@ static int dca_exss_mask2count(int mask)
*/
static void dca_exss_skip_mix_coeffs(GetBitContext *gb, int channels, int out_ch)
{
- for (int i = 0; i < channels; i++) {
+ int i;
+
+ for (i = 0; i < channels; i++) {
int mix_map_mask = get_bits(gb, out_ch);
int num_coeffs = av_popcount(mix_map_mask);
skip_bits_long(gb, num_coeffs * 6);
@@ -1504,12 +1521,9 @@ static int dca_exss_parse_asset_header(DCAContext *s)
if (!(extensions_mask & DCA_EXT_CORE))
av_log(s->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n");
- if (!!(extensions_mask & DCA_EXT_XCH) != s->xch_present)
- av_log(s->avctx, AV_LOG_WARNING, "DTS XCh detection mismatch.\n");
- if (!!(extensions_mask & DCA_EXT_XXCH) != s->xxch_present)
- av_log(s->avctx, AV_LOG_WARNING, "DTS XXCh detection mismatch.\n");
- if (!!(extensions_mask & DCA_EXT_X96) != s->x96_present)
- av_log(s->avctx, AV_LOG_WARNING, "DTS X96 detection mismatch.\n");
+ if ((extensions_mask & DCA_CORE_EXTS) != s->core_ext_mask)
+ av_log(s->avctx, AV_LOG_WARNING, "DTS extensions detection mismatch (%d, %d)\n",
+ extensions_mask & DCA_CORE_EXTS, s->core_ext_mask);
return 0;
}
@@ -1619,8 +1633,6 @@ static int dca_decode_frame(AVCodecContext * avctx,
s->xch_present = 0;
- s->x96_present = 0;
- s->xxch_present = 0;
s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer,
DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE);
@@ -1648,11 +1660,24 @@ static int dca_decode_frame(AVCodecContext * avctx,
/* record number of core channels incase less than max channels are requested */
num_core_channels = s->prim_channels;
- /* extensions start at 32-bit boundaries into bitstream */
- skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
+ if (s->ext_coding)
+ s->core_ext_mask = dca_ext_audio_descr_mask[s->ext_descr];
+ else
+ s->core_ext_mask = 0;
core_ss_end = FFMIN(s->frame_size, s->dca_buffer_size) * 8;
+ /* only scan for extensions if ext_descr was unknown or indicated a
+ * supported XCh extension */
+ if (s->core_ext_mask < 0 || s->core_ext_mask & DCA_EXT_XCH) {
+
+ /* if ext_descr was unknown, clear s->core_ext_mask so that the
+ * extensions scan can fill it up */
+ s->core_ext_mask = FFMAX(s->core_ext_mask, 0);
+
+ /* extensions start at 32-bit boundaries into bitstream */
+ skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
+
while(core_ss_end - get_bits_count(&s->gb) >= 32) {
uint32_t bits = get_bits_long(&s->gb, 32);
@@ -1671,7 +1696,7 @@ static int dca_decode_frame(AVCodecContext * avctx,
/* skip length-to-end-of-frame field for the moment */
skip_bits(&s->gb, 10);
- s->profile = FFMAX(s->profile, FF_PROFILE_DTS_ES);
+ s->core_ext_mask |= DCA_EXT_XCH;
/* extension amode should == 1, number of channels in extension */
/* AFAIK XCh is not used for more channels */
@@ -1695,8 +1720,7 @@ static int dca_decode_frame(AVCodecContext * avctx,
/* XXCh: extended channels */
/* usually found either in core or HD part in DTS-HD HRA streams,
* but not in DTS-ES which contains XCh extensions instead */
- s->xxch_present = 1;
- s->profile = FFMAX(s->profile, FF_PROFILE_DTS_ES);
+ s->core_ext_mask |= DCA_EXT_XXCH;
break;
case 0x1d95f262: {
@@ -1709,8 +1733,7 @@ static int dca_decode_frame(AVCodecContext * avctx,
av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", fsize96);
av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4));
- s->x96_present = 1;
- s->profile = FFMAX(s->profile, FF_PROFILE_DTS_96_24);
+ s->core_ext_mask |= DCA_EXT_X96;
break;
}
}
@@ -1718,6 +1741,16 @@ static int dca_decode_frame(AVCodecContext * avctx,
skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
}
+ } else {
+ /* no supported extensions, skip the rest of the core substream */
+ skip_bits_long(&s->gb, core_ss_end - get_bits_count(&s->gb));
+ }
+
+ if (s->core_ext_mask & DCA_EXT_X96)
+ s->profile = FF_PROFILE_DTS_96_24;
+ else if (s->core_ext_mask & (DCA_EXT_XCH | DCA_EXT_XXCH))
+ s->profile = FF_PROFILE_DTS_ES;
+
/* check for ExSS (HD part) */
if (s->dca_buffer_size - s->frame_size > 32
&& get_bits_long(&s->gb, 32) == DCA_HD_MARKER)
@@ -1800,7 +1833,7 @@ static int dca_decode_frame(AVCodecContext * avctx,
}
}
- s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels);
+ s->fmt_conv.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels);
samples += 256 * channels;
}
@@ -1833,6 +1866,7 @@ static av_cold int dca_decode_init(AVCodecContext * avctx)
ff_mdct_init(&s->imdct, 6, 1, 1.0);
ff_synth_filter_init(&s->synth);
ff_dcadsp_init(&s->dcadsp);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
for (i = 0; i < DCA_PRIM_CHANNELS_MAX+1; i++)
s->samples_chanptr[i] = s->samples + i * 256;
diff --git a/mplayer/ffmpeg/libavcodec/dcadsp.c b/mplayer/ffmpeg/libavcodec/dcadsp.c
index af48e3ce..dd4994d2 100644
--- a/mplayer/ffmpeg/libavcodec/dcadsp.c
+++ b/mplayer/ffmpeg/libavcodec/dcadsp.c
@@ -23,7 +23,7 @@
#include "dcadsp.h"
static void dca_lfe_fir_c(float *out, const float *in, const float *coefs,
- int decifactor, float scale, float bias)
+ int decifactor, float scale)
{
float *out2 = out + decifactor;
const float *cf0 = coefs;
@@ -39,8 +39,8 @@ static void dca_lfe_fir_c(float *out, const float *in, const float *coefs,
v0 += s * *cf0++;
v1 += s * *--cf1;
}
- *out++ = (v0 * scale) + bias;
- *out2++ = (v1 * scale) + bias;
+ *out++ = v0 * scale;
+ *out2++ = v1 * scale;
}
}
diff --git a/mplayer/ffmpeg/libavcodec/dcadsp.h b/mplayer/ffmpeg/libavcodec/dcadsp.h
index 20020ae0..bb157f76 100644
--- a/mplayer/ffmpeg/libavcodec/dcadsp.h
+++ b/mplayer/ffmpeg/libavcodec/dcadsp.h
@@ -21,7 +21,7 @@
typedef struct DCADSPContext {
void (*lfe_fir)(float *out, const float *in, const float *coefs,
- int decifactor, float scale, float bias);
+ int decifactor, float scale);
} DCADSPContext;
void ff_dcadsp_init(DCADSPContext *s);
diff --git a/mplayer/ffmpeg/libavcodec/dirac.c b/mplayer/ffmpeg/libavcodec/dirac.c
index bacd1f8e..c8dc7a0f 100644
--- a/mplayer/ffmpeg/libavcodec/dirac.c
+++ b/mplayer/ffmpeg/libavcodec/dirac.c
@@ -25,7 +25,7 @@
* @author Marco Gerards
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "dirac.h"
#include "avcodec.h"
#include "golomb.h"
diff --git a/mplayer/ffmpeg/libavcodec/dnxhddec.c b/mplayer/ffmpeg/libavcodec/dnxhddec.c
index 58893aca..9b37d1d6 100644
--- a/mplayer/ffmpeg/libavcodec/dnxhddec.c
+++ b/mplayer/ffmpeg/libavcodec/dnxhddec.c
@@ -22,7 +22,7 @@
//#define TRACE
//#define DEBUG
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "get_bits.h"
#include "dnxhddata.h"
diff --git a/mplayer/ffmpeg/libavcodec/dnxhdenc.c b/mplayer/ffmpeg/libavcodec/dnxhdenc.c
index d6f8bd3c..2e8720ac 100644
--- a/mplayer/ffmpeg/libavcodec/dnxhdenc.c
+++ b/mplayer/ffmpeg/libavcodec/dnxhdenc.c
@@ -24,11 +24,20 @@
//#define DEBUG
#define RC_VARIANCE 1 // use variance or ssd for fast rc
+#include "libavutil/opt.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
#include "dnxhdenc.h"
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+
+static const AVOption options[]={
+ {"nitris_compat", "encode with Avid Nitris compatibility", offsetof(DNXHDEncContext, nitris_compat), FF_OPT_TYPE_INT, 0, 0, 1, VE},
+{NULL}
+};
+static const AVClass class = { "dnxhd", av_default_item_name, options, LIBAVUTIL_VERSION_INT };
+
int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
#define LAMBDA_FRAC_BITS 10
@@ -146,7 +155,7 @@ static int dnxhd_init_rc(DNXHDEncContext *ctx)
if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail);
- ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4) * 8;
+ ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4 - ctx->min_padding) * 8;
ctx->qscale = 1;
ctx->lambda = 2<m.intra_quant_bias, 0) < 0) // XXX tune lbias/cbias
return -1;
+ // Avid Nitris hardware decoder requires a minimum amount of padding in the coding unit payload
+ if (ctx->nitris_compat)
+ ctx->min_padding = 1600;
+
if (dnxhd_init_vlc(ctx) < 0)
return -1;
if (dnxhd_init_rc(ctx) < 0)
@@ -858,4 +871,5 @@ AVCodec ff_dnxhd_encoder = {
dnxhd_encode_end,
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"),
+ .priv_class = &class,
};
diff --git a/mplayer/ffmpeg/libavcodec/dnxhdenc.h b/mplayer/ffmpeg/libavcodec/dnxhdenc.h
index eaf33d5c..f0b38a59 100644
--- a/mplayer/ffmpeg/libavcodec/dnxhdenc.h
+++ b/mplayer/ffmpeg/libavcodec/dnxhdenc.h
@@ -55,6 +55,9 @@ typedef struct DNXHDEncContext {
int interlaced;
int cur_field;
+ int nitris_compat;
+ unsigned min_padding;
+
DECLARE_ALIGNED(16, DCTELEM, blocks)[8][64];
int (*qmatrix_c) [64];
diff --git a/mplayer/ffmpeg/libavcodec/dpcm.c b/mplayer/ffmpeg/libavcodec/dpcm.c
index 6053a145..ee8eb6a7 100644
--- a/mplayer/ffmpeg/libavcodec/dpcm.c
+++ b/mplayer/ffmpeg/libavcodec/dpcm.c
@@ -309,7 +309,7 @@ AVCodec ff_ ## name ## _decoder = { \
NULL, \
dpcm_decode_frame, \
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
-};
+}
DPCM_DECODER(CODEC_ID_INTERPLAY_DPCM, interplay_dpcm, "DPCM Interplay");
DPCM_DECODER(CODEC_ID_ROQ_DPCM, roq_dpcm, "DPCM id RoQ");
diff --git a/mplayer/ffmpeg/libavcodec/dpx.c b/mplayer/ffmpeg/libavcodec/dpx.c
index 55ae4e72..ade4e8cb 100644
--- a/mplayer/ffmpeg/libavcodec/dpx.c
+++ b/mplayer/ffmpeg/libavcodec/dpx.c
@@ -20,7 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "bytestream.h"
#include "avcodec.h"
diff --git a/mplayer/ffmpeg/libavcodec/dsputil.c b/mplayer/ffmpeg/libavcodec/dsputil.c
index f604f0e7..1f7bd4cb 100644
--- a/mplayer/ffmpeg/libavcodec/dsputil.c
+++ b/mplayer/ffmpeg/libavcodec/dsputil.c
@@ -27,7 +27,7 @@
* DSP utils
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "simple_idct.h"
@@ -437,8 +437,8 @@ static void diff_pixels_c(DCTELEM *restrict block, const uint8_t *s1,
}
-static void put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
- int line_size)
+void ff_put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
+ int line_size)
{
int i;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
@@ -493,9 +493,9 @@ static void put_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels
}
}
-static void put_signed_pixels_clamped_c(const DCTELEM *block,
- uint8_t *restrict pixels,
- int line_size)
+void ff_put_signed_pixels_clamped_c(const DCTELEM *block,
+ uint8_t *restrict pixels,
+ int line_size)
{
int i, j;
@@ -535,8 +535,8 @@ static void put_pixels_nonclamped_c(const DCTELEM *block, uint8_t *restrict pixe
}
}
-static void add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
- int line_size)
+void ff_add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
+ int line_size)
{
int i;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
@@ -1600,54 +1600,6 @@ H264_CHROMA_MC(avg_ , op_avg)
#undef op_avg
#undef op_put
-static void put_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
- const int A=(8-x)*(8-y);
- const int B=( x)*(8-y);
- const int C=(8-x)*( y);
- const int D=( x)*( y);
- int i;
-
- assert(x<8 && y<8 && x>=0 && y>=0);
-
- for(i=0; i> 6;
- dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6;
- dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6;
- dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6;
- dst[4] = (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6;
- dst[5] = (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6;
- dst[6] = (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6;
- dst[7] = (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6;
- dst+= stride;
- src+= stride;
- }
-}
-
-static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
- const int A=(8-x)*(8-y);
- const int B=( x)*(8-y);
- const int C=(8-x)*( y);
- const int D=( x)*( y);
- int i;
-
- assert(x<8 && y<8 && x>=0 && y>=0);
-
- for(i=0; i> 6));
- dst[1] = avg2(dst[1], ((A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6));
- dst[2] = avg2(dst[2], ((A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6));
- dst[3] = avg2(dst[3], ((A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6));
- dst[4] = avg2(dst[4], ((A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6));
- dst[5] = avg2(dst[5], ((A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6));
- dst[6] = avg2(dst[6], ((A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6));
- dst[7] = avg2(dst[7], ((A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6));
- dst+= stride;
- src+= stride;
- }
-}
-
#define QPEL_MC(r, OPNAME, RND, OP) \
static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
@@ -3776,7 +3728,9 @@ static void vector_fmul_add_c(float *dst, const float *src0, const float *src1,
dst[i] = src0[i] * src1[i] + src2[i];
}
-void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len){
+static void vector_fmul_window_c(float *dst, const float *src0,
+ const float *src1, const float *win, int len)
+{
int i,j;
dst += len;
win += len;
@@ -3786,8 +3740,8 @@ void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1, c
float s1 = src1[j];
float wi = win[i];
float wj = win[j];
- dst[i] = s0*wj - s1*wi + add_bias;
- dst[j] = s0*wi + s1*wj + add_bias;
+ dst[i] = s0*wj - s1*wi;
+ dst[j] = s0*wi + s1*wj;
}
}
@@ -3865,12 +3819,6 @@ static float scalarproduct_float_c(const float *v1, const float *v2, int len)
return p;
}
-static void int32_to_float_fmul_scalar_c(float *dst, const int *src, float mul, int len){
- int i;
- for(i=0; iget_pixels = get_pixels_c;
c->diff_pixels = diff_pixels_c;
- c->put_pixels_clamped = put_pixels_clamped_c;
- c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
+ c->put_pixels_clamped = ff_put_pixels_clamped_c;
+ c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c;
c->put_pixels_nonclamped = put_pixels_nonclamped_c;
- c->add_pixels_clamped = add_pixels_clamped_c;
+ c->add_pixels_clamped = ff_add_pixels_clamped_c;
c->add_pixels8 = add_pixels8_c;
c->add_pixels4 = add_pixels4_c;
c->sum_abs_dctelem = sum_abs_dctelem_c;
@@ -4329,17 +4253,12 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c;
c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c;
- c->put_no_rnd_vc1_chroma_pixels_tab[0]= put_no_rnd_vc1_chroma_mc8_c;
- c->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_no_rnd_vc1_chroma_mc8_c;
c->draw_edges = draw_edges_c;
#if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER
ff_mlp_init(c, avctx);
#endif
-#if CONFIG_VC1_DECODER
- ff_vc1dsp_init(c,avctx);
-#endif
#if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER
ff_intrax8dsp_init(c,avctx);
#endif
@@ -4434,11 +4353,8 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->vector_fmul = vector_fmul_c;
c->vector_fmul_reverse = vector_fmul_reverse_c;
c->vector_fmul_add = vector_fmul_add_c;
- c->vector_fmul_window = ff_vector_fmul_window_c;
- c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c;
+ c->vector_fmul_window = vector_fmul_window_c;
c->vector_clipf = vector_clipf_c;
- c->float_to_int16 = ff_float_to_int16_c;
- c->float_to_int16_interleave = ff_float_to_int16_interleave_c;
c->scalarproduct_int16 = scalarproduct_int16_c;
c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
c->scalarproduct_float = scalarproduct_float_c;
diff --git a/mplayer/ffmpeg/libavcodec/dsputil.h b/mplayer/ffmpeg/libavcodec/dsputil.h
index 9a1172b1..3e55d133 100644
--- a/mplayer/ffmpeg/libavcodec/dsputil.h
+++ b/mplayer/ffmpeg/libavcodec/dsputil.h
@@ -68,9 +68,6 @@ void ff_h264_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qmul);
void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qp);
void ff_svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc);
-void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1,
- const float *win, float add_bias, int len);
-
/* encoding scans */
extern const uint8_t ff_alternate_horizontal_scan[64];
extern const uint8_t ff_alternate_vertical_scan[64];
@@ -201,6 +198,10 @@ void ff_emulated_edge_mc(uint8_t *buf, const uint8_t *src, int linesize,
int block_w, int block_h,
int src_x, int src_y, int w, int h);
+void ff_add_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize);
+void ff_put_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize);
+void ff_put_signed_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize);
+
/**
* DSPContext.
*/
@@ -344,9 +345,6 @@ typedef struct DSPContext {
*/
h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
h264_chroma_mc_func avg_h264_chroma_pixels_tab[3];
- /* This is really one func used in VC-1 decoding */
- h264_chroma_mc_func put_no_rnd_vc1_chroma_pixels_tab[3];
- h264_chroma_mc_func avg_no_rnd_vc1_chroma_pixels_tab[3];
qpel_mc_func put_h264_qpel_pixels_tab[4][16];
qpel_mc_func avg_h264_qpel_pixels_tab[4][16];
@@ -393,9 +391,8 @@ typedef struct DSPContext {
/* assume len is a multiple of 8, and src arrays are 16-byte aligned */
void (*vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len);
/* assume len is a multiple of 4, and arrays are 16-byte aligned */
- void (*vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len);
+ void (*vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len);
/* assume len is a multiple of 8, and arrays are 16-byte aligned */
- void (*int32_to_float_fmul_scalar)(float *dst, const int *src, float mul, int len);
void (*vector_clipf)(float *dst /* align 16 */, const float *src /* align 16 */, float min, float max, int len /* align 16 */);
/**
* Multiply a vector of floats by a scalar float. Source and
@@ -448,10 +445,6 @@ typedef struct DSPContext {
*/
void (*butterflies_float)(float *restrict v1, float *restrict v2, int len);
- /* convert floats from [-32768.0,32767.0] without rescaling and arrays are 16byte aligned */
- void (*float_to_int16)(int16_t *dst, const float *src, long len);
- void (*float_to_int16_interleave)(int16_t *dst, const float **src, long len, int channels);
-
/* (I)DCT */
void (*fdct)(DCTELEM *block/* align 16*/);
void (*fdct248)(DCTELEM *block/* align 16*/);
@@ -511,29 +504,6 @@ typedef struct DSPContext {
unsigned int filter_shift, int32_t mask, int blocksize,
int32_t *sample_buffer);
- /* vc1 functions */
- void (*vc1_inv_trans_8x8)(DCTELEM *b);
- void (*vc1_inv_trans_8x4)(uint8_t *dest, int line_size, DCTELEM *block);
- void (*vc1_inv_trans_4x8)(uint8_t *dest, int line_size, DCTELEM *block);
- void (*vc1_inv_trans_4x4)(uint8_t *dest, int line_size, DCTELEM *block);
- void (*vc1_inv_trans_8x8_dc)(uint8_t *dest, int line_size, DCTELEM *block);
- void (*vc1_inv_trans_8x4_dc)(uint8_t *dest, int line_size, DCTELEM *block);
- void (*vc1_inv_trans_4x8_dc)(uint8_t *dest, int line_size, DCTELEM *block);
- void (*vc1_inv_trans_4x4_dc)(uint8_t *dest, int line_size, DCTELEM *block);
- void (*vc1_v_overlap)(uint8_t* src, int stride);
- void (*vc1_h_overlap)(uint8_t* src, int stride);
- void (*vc1_v_loop_filter4)(uint8_t *src, int stride, int pq);
- void (*vc1_h_loop_filter4)(uint8_t *src, int stride, int pq);
- void (*vc1_v_loop_filter8)(uint8_t *src, int stride, int pq);
- void (*vc1_h_loop_filter8)(uint8_t *src, int stride, int pq);
- void (*vc1_v_loop_filter16)(uint8_t *src, int stride, int pq);
- void (*vc1_h_loop_filter16)(uint8_t *src, int stride, int pq);
- /* put 8x8 block with bicubic interpolation and quarterpel precision
- * last argument is actually round value instead of height
- */
- op_pixels_func put_vc1_mspel_pixels_tab[16];
- op_pixels_func avg_vc1_mspel_pixels_tab[16];
-
/* intrax8 functions */
void (*x8_spatial_compensation[12])(uint8_t *src , uint8_t *dst, int linesize);
void (*x8_setup_spatial_compensation)(uint8_t *src, uint8_t *dst, int linesize,
@@ -637,7 +607,6 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
void ff_dsputil_init_dwt(DSPContext *c);
void ff_rv30dsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_rv40dsp_init(DSPContext* c, AVCodecContext *avctx);
-void ff_vc1dsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_intrax8dsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_mlp_init(DSPContext* c, AVCodecContext *avctx);
void ff_mlp_init_x86(DSPContext* c, AVCodecContext *avctx);
diff --git a/mplayer/ffmpeg/libavcodec/dvbsub.c b/mplayer/ffmpeg/libavcodec/dvbsub.c
index c2a12986..ed128234 100644
--- a/mplayer/ffmpeg/libavcodec/dvbsub.c
+++ b/mplayer/ffmpeg/libavcodec/dvbsub.c
@@ -223,7 +223,7 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s,
else
page_state = 2; /* mode change */
/* page_version = 0 + page_state */
- *q++ = s->object_version | (page_state << 2) | 3;
+ *q++ = (s->object_version << 4) | (page_state << 2) | 3;
for (region_id = 0; region_id < h->num_rects; region_id++) {
*q++ = region_id;
diff --git a/mplayer/ffmpeg/libavcodec/dvbsubdec.c b/mplayer/ffmpeg/libavcodec/dvbsubdec.c
index 0f1e0046..45737136 100644
--- a/mplayer/ffmpeg/libavcodec/dvbsubdec.c
+++ b/mplayer/ffmpeg/libavcodec/dvbsubdec.c
@@ -332,9 +332,7 @@ static void delete_state(DVBSubContext *ctx)
ctx->region_list = region->next;
delete_region_display_list(ctx, region);
- if (region->pbuf)
- av_free(region->pbuf);
-
+ av_free(region->pbuf);
av_free(region);
}
@@ -794,7 +792,7 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDis
map_table = NULL;
x_pos += dvbsub_read_2bit_string(pbuf + (y_pos * region->width) + x_pos,
- region->width - x_pos, &buf, buf_size,
+ region->width - x_pos, &buf, buf_end - buf,
non_mod, map_table);
break;
case 0x11:
@@ -809,7 +807,7 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDis
map_table = NULL;
x_pos += dvbsub_read_4bit_string(pbuf + (y_pos * region->width) + x_pos,
- region->width - x_pos, &buf, buf_size,
+ region->width - x_pos, &buf, buf_end - buf,
non_mod, map_table);
break;
case 0x12:
@@ -819,7 +817,7 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDis
}
x_pos += dvbsub_read_8bit_string(pbuf + (y_pos * region->width) + x_pos,
- region->width - x_pos, &buf, buf_size,
+ region->width - x_pos, &buf, buf_end - buf,
non_mod, NULL);
break;
@@ -1032,8 +1030,7 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx,
buf += 2;
if (region->width * region->height != region->buf_size) {
- if (region->pbuf)
- av_free(region->pbuf);
+ av_free(region->pbuf);
region->buf_size = region->width * region->height;
@@ -1426,13 +1423,15 @@ static int dvbsub_decode(AVCodecContext *avctx,
#endif
- if (buf_size <= 2)
+ if (buf_size <= 6 || *buf != 0x0f) {
+ av_dlog(avctx, "incomplete or broken packet");
return -1;
+ }
p = buf;
p_end = buf + buf_size;
- while (p < p_end && *p == 0x0f) {
+ while (p_end - p >= 6 && *p == 0x0f) {
p += 1;
segment_type = *p++;
page_id = AV_RB16(p);
@@ -1440,6 +1439,11 @@ static int dvbsub_decode(AVCodecContext *avctx,
segment_length = AV_RB16(p);
p += 2;
+ if (p_end - p < segment_length) {
+ av_dlog(avctx, "incomplete or broken packet");
+ return -1;
+ }
+
if (page_id == ctx->composition_id || page_id == ctx->ancillary_id ||
ctx->composition_id == -1 || ctx->ancillary_id == -1) {
switch (segment_type) {
@@ -1470,12 +1474,7 @@ static int dvbsub_decode(AVCodecContext *avctx,
p += segment_length;
}
- if (p != p_end) {
- av_dlog(avctx, "Junk at end of packet\n");
- return -1;
- }
-
- return buf_size;
+ return p - buf;
}
diff --git a/mplayer/ffmpeg/libavcodec/dxva2_internal.h b/mplayer/ffmpeg/libavcodec/dxva2_internal.h
index a9be7a07..23d4d875 100644
--- a/mplayer/ffmpeg/libavcodec/dxva2_internal.h
+++ b/mplayer/ffmpeg/libavcodec/dxva2_internal.h
@@ -23,6 +23,8 @@
#ifndef AVCODEC_DXVA_INTERNAL_H
#define AVCODEC_DXVA_INTERNAL_H
+#define _WIN32_WINNT 0x0600
+#define COBJMACROS
#include "dxva2.h"
#include "avcodec.h"
#include "mpegvideo.h"
diff --git a/mplayer/ffmpeg/libavcodec/eacmv.c b/mplayer/ffmpeg/libavcodec/eacmv.c
index 6770cd19..7f6c2a45 100644
--- a/mplayer/ffmpeg/libavcodec/eacmv.c
+++ b/mplayer/ffmpeg/libavcodec/eacmv.c
@@ -29,7 +29,7 @@
*/
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
typedef struct CmvContext {
diff --git a/mplayer/ffmpeg/libavcodec/eamad.c b/mplayer/ffmpeg/libavcodec/eamad.c
index 1dd3b797..d4881ab8 100644
--- a/mplayer/ffmpeg/libavcodec/eamad.c
+++ b/mplayer/ffmpeg/libavcodec/eamad.c
@@ -34,7 +34,7 @@
#include "aandcttab.h"
#include "mpeg12.h"
#include "mpeg12data.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#define EA_PREAMBLE_SIZE 8
#define MADk_TAG MKTAG('M', 'A', 'D', 'k') /* MAD i-frame */
diff --git a/mplayer/ffmpeg/libavcodec/eatgv.c b/mplayer/ffmpeg/libavcodec/eatgv.c
index 075405a9..9ad08347 100644
--- a/mplayer/ffmpeg/libavcodec/eatgv.c
+++ b/mplayer/ffmpeg/libavcodec/eatgv.c
@@ -32,7 +32,7 @@
#define ALT_BITSTREAM_READER_LE
#include "get_bits.h"
#include "libavutil/lzo.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#define EA_PREAMBLE_SIZE 8
#define kVGT_TAG MKTAG('k', 'V', 'G', 'T')
diff --git a/mplayer/ffmpeg/libavcodec/fft.c b/mplayer/ffmpeg/libavcodec/fft.c
index e560b562..9e0cb769 100644
--- a/mplayer/ffmpeg/libavcodec/fft.c
+++ b/mplayer/ffmpeg/libavcodec/fft.c
@@ -97,6 +97,7 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
if (!s->tmp_buf)
goto fail;
s->inverse = inverse;
+ s->fft_permutation = FF_FFT_PERM_DEFAULT;
s->fft_permute = ff_fft_permute_c;
s->fft_calc = ff_fft_calc_c;
@@ -114,8 +115,12 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
for(j=4; j<=nbits; j++) {
ff_init_ff_cos_tabs(j);
}
- for(i=0; irevtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i;
+ for(i=0; ifft_permutation == FF_FFT_PERM_SWAP_LSBS)
+ j = (j&~3) | ((j>>1)&1) | ((j<<1)&2);
+ s->revtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = j;
+ }
return 0;
fail:
diff --git a/mplayer/ffmpeg/libavcodec/fft.h b/mplayer/ffmpeg/libavcodec/fft.h
index a398d92d..1f7e9dfb 100644
--- a/mplayer/ffmpeg/libavcodec/fft.h
+++ b/mplayer/ffmpeg/libavcodec/fft.h
@@ -44,7 +44,10 @@ struct FFTContext {
void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
- int permutation;
+ int fft_permutation;
+#define FF_FFT_PERM_DEFAULT 0
+#define FF_FFT_PERM_SWAP_LSBS 1
+ int mdct_permutation;
#define FF_MDCT_PERM_NONE 0
#define FF_MDCT_PERM_INTERLEAVE 1
};
diff --git a/mplayer/ffmpeg/libavcodec/flashsv.c b/mplayer/ffmpeg/libavcodec/flashsv.c
index 08748c65..f5ffca08 100644
--- a/mplayer/ffmpeg/libavcodec/flashsv.c
+++ b/mplayer/ffmpeg/libavcodec/flashsv.c
@@ -133,8 +133,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx,
/* the block size could change between frames, make sure the buffer
* is large enough, if not, get a larger one */
if(s->block_size < s->block_width*s->block_height) {
- if (s->tmpblock != NULL)
- av_free(s->tmpblock);
+ av_free(s->tmpblock);
if ((s->tmpblock = av_malloc(3*s->block_width*s->block_height)) == NULL) {
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
return -1;
@@ -243,8 +242,7 @@ static av_cold int flashsv_decode_end(AVCodecContext *avctx)
avctx->release_buffer(avctx, &s->frame);
/* free the tmpblock */
- if (s->tmpblock != NULL)
- av_free(s->tmpblock);
+ av_free(s->tmpblock);
return 0;
}
diff --git a/mplayer/ffmpeg/libavcodec/flvdec.c b/mplayer/ffmpeg/libavcodec/flvdec.c
index b1a75781..cf4dfe43 100644
--- a/mplayer/ffmpeg/libavcodec/flvdec.c
+++ b/mplayer/ffmpeg/libavcodec/flvdec.c
@@ -20,7 +20,7 @@
#include "mpegvideo.h"
#include "h263.h"
#include "flv.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last){
int is11 = get_bits1(gb);
diff --git a/mplayer/ffmpeg/libavcodec/fmtconvert.c b/mplayer/ffmpeg/libavcodec/fmtconvert.c
new file mode 100644
index 00000000..e26b8997
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/fmtconvert.c
@@ -0,0 +1,68 @@
+/*
+ * Format Conversion Utils
+ * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer
+ *
+ * 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
+ */
+
+#include "avcodec.h"
+#include "fmtconvert.h"
+
+static void int32_to_float_fmul_scalar_c(float *dst, const int *src, float mul, int len){
+ int i;
+ for(i=0; iint32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c;
+ c->float_to_int16 = float_to_int16_c;
+ c->float_to_int16_interleave = float_to_int16_interleave_c;
+
+ if (ARCH_ARM) ff_fmt_convert_init_arm(c, avctx);
+ if (ARCH_PPC) ff_fmt_convert_init_ppc(c, avctx);
+ if (HAVE_MMX) ff_fmt_convert_init_x86(c, avctx);
+}
diff --git a/mplayer/ffmpeg/libavcodec/fmtconvert.h b/mplayer/ffmpeg/libavcodec/fmtconvert.h
new file mode 100644
index 00000000..f2ee261f
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/fmtconvert.h
@@ -0,0 +1,79 @@
+/*
+ * Format Conversion Utils
+ * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer
+ *
+ * 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_FMTCONVERT_H
+#define AVCODEC_FMTCONVERT_H
+
+#include "avcodec.h"
+
+typedef struct FmtConvertContext {
+ /**
+ * Convert an array of int32_t to float and multiply by a float value.
+ * @param dst destination array of float.
+ * constraints: 16-byte aligned
+ * @param src source array of int32_t.
+ * constraints: 16-byte aligned
+ * @param len number of elements to convert.
+ * constraints: multiple of 8
+ */
+ void (*int32_to_float_fmul_scalar)(float *dst, const int *src, float mul, int len);
+
+ /**
+ * Convert an array of float to an array of int16_t.
+ *
+ * Convert floats from in the range [-32768.0,32767.0] to ints
+ * without rescaling
+ *
+ * @param dst destination array of int16_t.
+ * constraints: 16-byte aligned
+ * @param src source array of float.
+ * constraints: 16-byte aligned
+ * @param len number of elements to convert.
+ * constraints: multiple of 8
+ */
+ void (*float_to_int16)(int16_t *dst, const float *src, long len);
+
+ /**
+ * Convert multiple arrays of float to an interleaved array of int16_t.
+ *
+ * Convert floats from in the range [-32768.0,32767.0] to ints
+ * without rescaling
+ *
+ * @param dst destination array of interleaved int16_t.
+ * constraints: 16-byte aligned
+ * @param src source array of float arrays, one for each channel.
+ * constraints: 16-byte aligned
+ * @param len number of elements to convert.
+ * constraints: multiple of 8
+ * @param channels number of channels
+ */
+ void (*float_to_int16_interleave)(int16_t *dst, const float **src,
+ long len, int channels);
+} FmtConvertContext;
+
+void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx);
+
+void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx);
+void ff_fmt_convert_init_ppc(FmtConvertContext *c, AVCodecContext *avctx);
+void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx);
+
+#endif /* AVCODEC_FMTCONVERT_H */
diff --git a/mplayer/ffmpeg/libavcodec/gekkothread.c b/mplayer/ffmpeg/libavcodec/gekkothread.c
deleted file mode 100644
index d328643a..00000000
--- a/mplayer/ffmpeg/libavcodec/gekkothread.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2009 rodries
- *
- */
-
-#include "avcodec.h"
-
-#include
-#include
-//#include "mp_msg.h"
-
-typedef struct ThreadContext{
- AVCodecContext *avctx;
- lwp_t thread;
- sem_t work_sem;
- sem_t done_sem;
- int (*func)(AVCodecContext *c, void *arg);
- void *arg;
- int ret;
-}ThreadContext;
-
-
-static void * thread_func(void *v)
-{
- ThreadContext *c= v;
-
- while(1)
- {
- //mp_msg(MSGT_VO, MSGL_ERR,"thread_func Lock work_sem %i\n",c->work_sem);
- LWP_SemWait(c->work_sem);
- //mp_msg(MSGT_VO, MSGL_ERR,"thread_func pass Lock work_sem %i, exec\n",c->work_sem);
- if(c->func)
- c->ret= c->func(c->avctx, c->arg);
- else
- {
- return NULL;
- }
- //mp_msg(MSGT_VO, MSGL_ERR,"thread_func UnLock done_sem %i\n",c->thread);
- LWP_SemPost(c->done_sem);
- }
- return NULL;
-}
-
-/**
- * Free what has been allocated by avcodec_thread_init().
- * Must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running.
- */
-void avcodec_thread_free(AVCodecContext *s)
-{
- ThreadContext *c= s->thread_opaque;
- int i;
-
- for(i=0; ithread_count; i++)
- {
- c[i].func= NULL;
- LWP_SemPost(c[i].work_sem);
- LWP_JoinThread(c[i].thread, NULL);
- LWP_SemDestroy(c[i].work_sem);
- LWP_SemDestroy(c[i].done_sem);
- }
- av_freep(&s->thread_opaque);
-}
-
-int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){
- ThreadContext *c= s->thread_opaque;
- int i;
-
-
- assert(s == c->avctx);
- assert(count <= s->thread_count);
-
- /* note, we can be certain that this is not called with the same AVCodecContext by different threads at the same time */
-
- for(i=0; ithread_count = thread_count;
-
- assert(!s->thread_opaque);
- c= av_mallocz(sizeof(ThreadContext)*thread_count);
- s->thread_opaque= c;
-
- for(i=0; iexecute= avcodec_thread_execute;
-//mp_msg(MSGT_VO, MSGL_ERR,"threads ok\n");sleep(8);
- return 0;
-fail:
-//mp_msg(MSGT_VO, MSGL_ERR,"error threads\n");sleep(4);
- avcodec_thread_free(s);
- return -1;
-}
diff --git a/mplayer/ffmpeg/libavcodec/gifdec.c b/mplayer/ffmpeg/libavcodec/gifdec.c
index 7be284cb..39d0db9c 100644
--- a/mplayer/ffmpeg/libavcodec/gifdec.c
+++ b/mplayer/ffmpeg/libavcodec/gifdec.c
@@ -22,7 +22,7 @@
//#define DEBUG
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "lzw.h"
diff --git a/mplayer/ffmpeg/libavcodec/h264.c b/mplayer/ffmpeg/libavcodec/h264.c
index 2a3357b0..5ebf929e 100644
--- a/mplayer/ffmpeg/libavcodec/h264.c
+++ b/mplayer/ffmpeg/libavcodec/h264.c
@@ -25,7 +25,7 @@
* @author Michael Niedermayer
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "internal.h"
#include "dsputil.h"
#include "avcodec.h"
@@ -1677,6 +1677,33 @@ static void clone_slice(H264Context *dst, H264Context *src)
memcpy(dst->dequant8_coeff, src->dequant8_coeff, sizeof(src->dequant8_coeff));
}
+/**
+ * computes profile from profile_idc and constraint_set?_flags
+ *
+ * @param sps SPS
+ *
+ * @return profile as defined by FF_PROFILE_H264_*
+ */
+int ff_h264_get_profile(SPS *sps)
+{
+ int profile = sps->profile_idc;
+
+ switch(sps->profile_idc) {
+ case FF_PROFILE_H264_BASELINE:
+ // constraint_set1_flag set to 1
+ profile |= (sps->constraint_set_flags & 1<<1) ? FF_PROFILE_H264_CONSTRAINED : 0;
+ break;
+ case FF_PROFILE_H264_HIGH_10:
+ case FF_PROFILE_H264_HIGH_422:
+ case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
+ // constraint_set3_flag set to 1
+ profile |= (sps->constraint_set_flags & 1<<3) ? FF_PROFILE_H264_INTRA : 0;
+ break;
+ }
+
+ return profile;
+}
+
/**
* decodes a slice header.
* This will also call MPV_common_init() and frame_start() as needed.
@@ -1756,7 +1783,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
}
h->sps = *h0->sps_buffers[h->pps.sps_id];
- s->avctx->profile = h->sps.profile_idc;
+ s->avctx->profile = ff_h264_get_profile(&h->sps);
s->avctx->level = h->sps.level_idc;
s->avctx->refs = h->sps.ref_frame_count;
@@ -3359,6 +3386,22 @@ av_cold int ff_h264_decode_end(AVCodecContext *avctx)
return 0;
}
+static const AVProfile profiles[] = {
+ { FF_PROFILE_H264_BASELINE, "Baseline" },
+ { FF_PROFILE_H264_CONSTRAINED_BASELINE, "Constrained Baseline" },
+ { FF_PROFILE_H264_MAIN, "Main" },
+ { FF_PROFILE_H264_EXTENDED, "Extended" },
+ { FF_PROFILE_H264_HIGH, "High" },
+ { FF_PROFILE_H264_HIGH_10, "High 10" },
+ { FF_PROFILE_H264_HIGH_10_INTRA, "High 10 Intra" },
+ { FF_PROFILE_H264_HIGH_422, "High 4:2:2" },
+ { FF_PROFILE_H264_HIGH_422_INTRA, "High 4:2:2 Intra" },
+ { FF_PROFILE_H264_HIGH_444, "High 4:4:4" },
+ { FF_PROFILE_H264_HIGH_444_PREDICTIVE, "High 4:4:4 Predictive" },
+ { FF_PROFILE_H264_HIGH_444_INTRA, "High 4:4:4 Intra" },
+ { FF_PROFILE_H264_CAVLC_444, "CAVLC 4:4:4" },
+ { FF_PROFILE_UNKNOWN },
+};
AVCodec ff_h264_decoder = {
"h264",
@@ -3372,6 +3415,7 @@ AVCodec ff_h264_decoder = {
/*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.flush= flush_dpb,
.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
+ .profiles = NULL_IF_CONFIG_SMALL(profiles),
};
#if CONFIG_H264_VDPAU_DECODER
@@ -3388,5 +3432,6 @@ AVCodec ff_h264_vdpau_decoder = {
.flush= flush_dpb,
.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)"),
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_H264, PIX_FMT_NONE},
+ .profiles = NULL_IF_CONFIG_SMALL(profiles),
};
#endif
diff --git a/mplayer/ffmpeg/libavcodec/h264.h b/mplayer/ffmpeg/libavcodec/h264.h
index f4f9b257..b4039684 100644
--- a/mplayer/ffmpeg/libavcodec/h264.h
+++ b/mplayer/ffmpeg/libavcodec/h264.h
@@ -209,6 +209,7 @@ typedef struct SPS{
int bit_depth_luma; ///< bit_depth_luma_minus8 + 8
int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8
int residual_color_transform_flag; ///< residual_colour_transform_flag
+ int constraint_set_flags; ///< constraint_set[0-3]_flag
}SPS;
/**
@@ -611,6 +612,11 @@ int ff_h264_decode_sei(H264Context *h);
*/
int ff_h264_decode_seq_parameter_set(H264Context *h);
+/**
+ * compute profile from sps
+ */
+int ff_h264_get_profile(SPS *sps);
+
/**
* Decode PPS
*/
diff --git a/mplayer/ffmpeg/libavcodec/h264_parser.c b/mplayer/ffmpeg/libavcodec/h264_parser.c
index 51760dcf..c5728e26 100644
--- a/mplayer/ffmpeg/libavcodec/h264_parser.c
+++ b/mplayer/ffmpeg/libavcodec/h264_parser.c
@@ -187,7 +187,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
h->sps = *h->sps_buffers[h->pps.sps_id];
h->frame_num = get_bits(&h->s.gb, h->sps.log2_max_frame_num);
- avctx->profile = h->sps.profile_idc;
+ avctx->profile = ff_h264_get_profile(&h->sps);
avctx->level = h->sps.level_idc;
if(h->sps.frame_mbs_only_flag){
diff --git a/mplayer/ffmpeg/libavcodec/h264_ps.c b/mplayer/ffmpeg/libavcodec/h264_ps.c
index 876bcb2a..469d3d8b 100644
--- a/mplayer/ffmpeg/libavcodec/h264_ps.c
+++ b/mplayer/ffmpeg/libavcodec/h264_ps.c
@@ -25,7 +25,7 @@
* @author Michael Niedermayer
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "internal.h"
#include "dsputil.h"
#include "avcodec.h"
@@ -267,16 +267,16 @@ static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_s
int ff_h264_decode_seq_parameter_set(H264Context *h){
MpegEncContext * const s = &h->s;
- int profile_idc, level_idc;
+ int profile_idc, level_idc, constraint_set_flags = 0;
unsigned int sps_id;
int i;
SPS *sps;
profile_idc= get_bits(&s->gb, 8);
- get_bits1(&s->gb); //constraint_set0_flag
- get_bits1(&s->gb); //constraint_set1_flag
- get_bits1(&s->gb); //constraint_set2_flag
- get_bits1(&s->gb); //constraint_set3_flag
+ constraint_set_flags |= get_bits1(&s->gb) << 0; //constraint_set0_flag
+ constraint_set_flags |= get_bits1(&s->gb) << 1; //constraint_set1_flag
+ constraint_set_flags |= get_bits1(&s->gb) << 2; //constraint_set2_flag
+ constraint_set_flags |= get_bits1(&s->gb) << 3; //constraint_set3_flag
get_bits(&s->gb, 4); // reserved
level_idc= get_bits(&s->gb, 8);
sps_id= get_ue_golomb_31(&s->gb);
@@ -291,6 +291,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
sps->time_offset_length = 24;
sps->profile_idc= profile_idc;
+ sps->constraint_set_flags = constraint_set_flags;
sps->level_idc= level_idc;
memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4));
diff --git a/mplayer/ffmpeg/libavcodec/h264dsp.c b/mplayer/ffmpeg/libavcodec/h264dsp.c
index e7792cdb..fc4f0298 100644
--- a/mplayer/ffmpeg/libavcodec/h264dsp.c
+++ b/mplayer/ffmpeg/libavcodec/h264dsp.c
@@ -316,6 +316,6 @@ void ff_h264dsp_init(H264DSPContext *c)
c->h264_loop_filter_strength= NULL;
if (ARCH_ARM) ff_h264dsp_init_arm(c);
- if (HAVE_ALTIVEC || HAVE_PAIRED) ff_h264dsp_init_ppc(c);
+ if (ARCH_PPC) ff_h264dsp_init_ppc(c);
if (HAVE_MMX) ff_h264dsp_init_x86(c);
}
diff --git a/mplayer/ffmpeg/libavcodec/h264pred.c b/mplayer/ffmpeg/libavcodec/h264pred.c
index 0a194a50..3c691adb 100644
--- a/mplayer/ffmpeg/libavcodec/h264pred.c
+++ b/mplayer/ffmpeg/libavcodec/h264pred.c
@@ -1363,7 +1363,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){
h->pred16x16_add[VERT_PRED8x8]= pred16x16_vertical_add_c;
h->pred16x16_add[ HOR_PRED8x8]= pred16x16_horizontal_add_c;
- if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id);
+ if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id);
if (HAVE_PAIRED) ff_h264_pred_init_ppc(h, codec_id);
- if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id);
+ if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id);
}
diff --git a/mplayer/ffmpeg/libavcodec/huffyuv.c b/mplayer/ffmpeg/libavcodec/huffyuv.c
index 2eb5864c..f81a042c 100644
--- a/mplayer/ffmpeg/libavcodec/huffyuv.c
+++ b/mplayer/ffmpeg/libavcodec/huffyuv.c
@@ -32,6 +32,7 @@
#include "get_bits.h"
#include "put_bits.h"
#include "dsputil.h"
+#include "thread.h"
#define VLC_BITS 11
@@ -527,6 +528,28 @@ s->bgr32=1;
return 0;
}
+
+static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
+{
+ HYuvContext *s = avctx->priv_data;
+ int i;
+
+ avctx->coded_frame= &s->picture;
+ alloc_temp(s);
+
+ for (i = 0; i < 6; i++)
+ s->vlc[i].table = NULL;
+
+ if(s->version==2){
+ if(read_huffman_tables(s, ((uint8_t*)avctx->extradata)+4, avctx->extradata_size) < 0)
+ return -1;
+ }else{
+ if(read_old_huffman_tables(s) < 0)
+ return -1;
+ }
+
+ return 0;
+}
#endif /* CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER */
#if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER
@@ -950,10 +973,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
s->dsp.bswap_buf((uint32_t*)s->bitstream_buffer, (const uint32_t*)buf, buf_size/4);
if(p->data[0])
- avctx->release_buffer(avctx, p);
+ ff_thread_release_buffer(avctx, p);
p->reference= 0;
- if(avctx->get_buffer(avctx, p) < 0){
+ if(ff_thread_get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
@@ -1425,8 +1448,9 @@ AVCodec ff_huffyuv_decoder = {
NULL,
decode_end,
decode_frame,
- CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
+ CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
NULL,
+ .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
};
#endif
@@ -1441,8 +1465,9 @@ AVCodec ff_ffvhuff_decoder = {
NULL,
decode_end,
decode_frame,
- CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
+ CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
NULL,
+ .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"),
};
#endif
diff --git a/mplayer/ffmpeg/libavcodec/iff.c b/mplayer/ffmpeg/libavcodec/iff.c
index 18ad7004..e64ce1ee 100644
--- a/mplayer/ffmpeg/libavcodec/iff.c
+++ b/mplayer/ffmpeg/libavcodec/iff.c
@@ -25,7 +25,7 @@
* IFF PBM/ILBM bitmap decoder
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "bytestream.h"
#include "avcodec.h"
#include "get_bits.h"
diff --git a/mplayer/ffmpeg/libavcodec/imc.c b/mplayer/ffmpeg/libavcodec/imc.c
index 4d7fbd1d..4cbb287a 100644
--- a/mplayer/ffmpeg/libavcodec/imc.c
+++ b/mplayer/ffmpeg/libavcodec/imc.c
@@ -40,6 +40,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "fft.h"
+#include "libavutil/audioconvert.h"
#include "imcdata.h"
@@ -157,7 +158,7 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
ff_fft_init(&q->fft, 7, 1);
dsputil_init(&q->dsp, avctx);
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
- avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
+ avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
return 0;
}
diff --git a/mplayer/ffmpeg/libavcodec/imgconvert.c b/mplayer/ffmpeg/libavcodec/imgconvert.c
index 143e5711..df85ca95 100644
--- a/mplayer/ffmpeg/libavcodec/imgconvert.c
+++ b/mplayer/ffmpeg/libavcodec/imgconvert.c
@@ -36,8 +36,7 @@
#include "imgconvert.h"
#include "libavutil/colorspace.h"
#include "libavutil/pixdesc.h"
-#include "libavcore/imgutils.h"
-#include "libavcore/internal.h"
+#include "libavutil/imgutils.h"
#if ARCH_PPC
#include "ppc/deinterlace.h"
diff --git a/mplayer/ffmpeg/libavcodec/indeo3.c b/mplayer/ffmpeg/libavcodec/indeo3.c
index 5c4cd056..c9d85736 100644
--- a/mplayer/ffmpeg/libavcodec/indeo3.c
+++ b/mplayer/ffmpeg/libavcodec/indeo3.c
@@ -23,7 +23,7 @@
#include
#include
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "bytestream.h"
diff --git a/mplayer/ffmpeg/libavcodec/ivi_dsp.c b/mplayer/ffmpeg/libavcodec/ivi_dsp.c
index ccaffd45..913fdc31 100644
--- a/mplayer/ffmpeg/libavcodec/ivi_dsp.c
+++ b/mplayer/ffmpeg/libavcodec/ivi_dsp.c
@@ -461,7 +461,7 @@ void ff_ivi_mc_ ## size ##x## size ## suffix (int16_t *buf, const int16_t *ref_b
#define OP_PUT(a, b) (a) = (b)
#define OP_ADD(a, b) (a) += (b)
-IVI_MC_TEMPLATE(8, _no_delta, OP_PUT);
-IVI_MC_TEMPLATE(8, _delta, OP_ADD);
-IVI_MC_TEMPLATE(4, _no_delta, OP_PUT);
-IVI_MC_TEMPLATE(4, _delta, OP_ADD);
+IVI_MC_TEMPLATE(8, _no_delta, OP_PUT)
+IVI_MC_TEMPLATE(8, _delta, OP_ADD)
+IVI_MC_TEMPLATE(4, _no_delta, OP_PUT)
+IVI_MC_TEMPLATE(4, _delta, OP_ADD)
diff --git a/mplayer/ffmpeg/libavcodec/kgv1dec.c b/mplayer/ffmpeg/libavcodec/kgv1dec.c
index efc477f3..2f6a80c2 100644
--- a/mplayer/ffmpeg/libavcodec/kgv1dec.c
+++ b/mplayer/ffmpeg/libavcodec/kgv1dec.c
@@ -25,7 +25,7 @@
*/
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
typedef struct {
diff --git a/mplayer/ffmpeg/libavcodec/lagarith.c b/mplayer/ffmpeg/libavcodec/lagarith.c
index 89580dc1..d53cd05c 100644
--- a/mplayer/ffmpeg/libavcodec/lagarith.c
+++ b/mplayer/ffmpeg/libavcodec/lagarith.c
@@ -510,7 +510,7 @@ static av_cold int lag_decode_end(AVCodecContext *avctx)
AVCodec ff_lagarith_decoder = {
"lagarith",
- CODEC_TYPE_VIDEO,
+ AVMEDIA_TYPE_VIDEO,
CODEC_ID_LAGARITH,
sizeof(LagarithContext),
lag_decode_init,
diff --git a/mplayer/ffmpeg/libavcodec/libdiracdec.c b/mplayer/ffmpeg/libavcodec/libdiracdec.c
index 520ec3f0..fb6ff45f 100644
--- a/mplayer/ffmpeg/libavcodec/libdiracdec.c
+++ b/mplayer/ffmpeg/libavcodec/libdiracdec.c
@@ -28,7 +28,7 @@
* (http://dirac.sourceforge.net/specification.html).
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "libdirac.h"
#undef NDEBUG
diff --git a/mplayer/ffmpeg/libavcodec/libopenjpeg.c b/mplayer/ffmpeg/libavcodec/libopenjpeg.c
index 0a9ded89..1f8530c7 100644
--- a/mplayer/ffmpeg/libavcodec/libopenjpeg.c
+++ b/mplayer/ffmpeg/libavcodec/libopenjpeg.c
@@ -24,7 +24,7 @@
* JPEG 2000 decoder using libopenjpeg
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "libavutil/intreadwrite.h"
#define OPJ_STATIC
diff --git a/mplayer/ffmpeg/libavcodec/libschroedingerdec.c b/mplayer/ffmpeg/libavcodec/libschroedingerdec.c
index e733d9e3..7603f7e1 100644
--- a/mplayer/ffmpeg/libavcodec/libschroedingerdec.c
+++ b/mplayer/ffmpeg/libavcodec/libschroedingerdec.c
@@ -27,7 +27,7 @@
* (http://dirac.sourceforge.net/specification.html).
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "libdirac_libschro.h"
#include "libschroedinger.h"
diff --git a/mplayer/ffmpeg/libavcodec/libvpxdec.c b/mplayer/ffmpeg/libavcodec/libvpxdec.c
index f912322c..29b8eec4 100644
--- a/mplayer/ffmpeg/libavcodec/libvpxdec.c
+++ b/mplayer/ffmpeg/libavcodec/libvpxdec.c
@@ -27,7 +27,7 @@
#include
#include
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
typedef struct VP8DecoderContext {
diff --git a/mplayer/ffmpeg/libavcodec/libx264.c b/mplayer/ffmpeg/libavcodec/libx264.c
index 84ecb2ae..185287c1 100644
--- a/mplayer/ffmpeg/libavcodec/libx264.c
+++ b/mplayer/ffmpeg/libavcodec/libx264.c
@@ -277,12 +277,11 @@ static av_cold int X264_init(AVCodecContext *avctx)
if (avctx->level > 0)
x4->params.i_level_idc = avctx->level;
- if ((avctx->rc_buffer_size != 0) &&
+ if (avctx->rc_buffer_size && avctx->rc_initial_buffer_occupancy &&
(avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) {
x4->params.rc.f_vbv_buffer_init =
(float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size;
- } else
- x4->params.rc.f_vbv_buffer_init = 0.9;
+ }
x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE);
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
diff --git a/mplayer/ffmpeg/libavcodec/libxvidff.c b/mplayer/ffmpeg/libavcodec/libxvidff.c
index d95ddee8..9008b848 100644
--- a/mplayer/ffmpeg/libavcodec/libxvidff.c
+++ b/mplayer/ffmpeg/libavcodec/libxvidff.c
@@ -527,18 +527,14 @@ static av_cold int xvid_encode_close(AVCodecContext *avctx) {
xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
- if( avctx->extradata != NULL )
- av_freep(&avctx->extradata);
+ av_freep(&avctx->extradata);
if( x->twopassbuffer != NULL ) {
av_free(x->twopassbuffer);
av_free(x->old_twopassbuffer);
}
- if( x->twopassfile != NULL )
- av_free(x->twopassfile);
- if( x->intra_matrix != NULL )
- av_free(x->intra_matrix);
- if( x->inter_matrix != NULL )
- av_free(x->inter_matrix);
+ av_free(x->twopassfile);
+ av_free(x->intra_matrix);
+ av_free(x->inter_matrix);
return 0;
}
diff --git a/mplayer/ffmpeg/libavcodec/mdct.c b/mplayer/ffmpeg/libavcodec/mdct.c
index c511188d..31e2216d 100644
--- a/mplayer/ffmpeg/libavcodec/mdct.c
+++ b/mplayer/ffmpeg/libavcodec/mdct.c
@@ -71,7 +71,7 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
s->mdct_bits = nbits;
s->mdct_size = n;
n4 = n >> 2;
- s->permutation = FF_MDCT_PERM_NONE;
+ s->mdct_permutation = FF_MDCT_PERM_NONE;
if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0)
goto fail;
@@ -80,7 +80,7 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
if (!s->tcos)
goto fail;
- switch (s->permutation) {
+ switch (s->mdct_permutation) {
case FF_MDCT_PERM_NONE:
s->tsin = s->tcos + n4;
tstep = 1;
@@ -202,7 +202,7 @@ void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input)
/* pre rotation */
for(i=0;i
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mjpeg.h"
@@ -1547,7 +1547,7 @@ AVCodec ff_mjpeg_decoder = {
ff_mjpeg_decode_frame,
CODEC_CAP_DR1,
NULL,
- .max_lowres = 4,
+ .max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
};
diff --git a/mplayer/ffmpeg/libavcodec/mpc7.c b/mplayer/ffmpeg/libavcodec/mpc7.c
index a77648f7..04657e5f 100644
--- a/mplayer/ffmpeg/libavcodec/mpc7.c
+++ b/mplayer/ffmpeg/libavcodec/mpc7.c
@@ -30,6 +30,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "mpegaudio.h"
+#include "libavutil/audioconvert.h"
#include "mpc.h"
#include "mpc7data.h"
@@ -86,7 +87,7 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
c->frames_to_skip = 0;
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
- avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
+ avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
if(vlc_initialized) return 0;
av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n");
diff --git a/mplayer/ffmpeg/libavcodec/mpc8.c b/mplayer/ffmpeg/libavcodec/mpc8.c
index 327a0c02..cf65ffe9 100644
--- a/mplayer/ffmpeg/libavcodec/mpc8.c
+++ b/mplayer/ffmpeg/libavcodec/mpc8.c
@@ -30,6 +30,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "mpegaudio.h"
+#include "libavutil/audioconvert.h"
#include "mpc.h"
#include "mpcdata.h"
@@ -135,7 +136,7 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
c->frames = 1 << (get_bits(&gb, 3) * 2);
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
- avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
+ avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
if(vlc_initialized) return 0;
av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n");
diff --git a/mplayer/ffmpeg/libavcodec/mpeg4audio.h b/mplayer/ffmpeg/libavcodec/mpeg4audio.h
index b9418507..174624e1 100644
--- a/mplayer/ffmpeg/libavcodec/mpeg4audio.h
+++ b/mplayer/ffmpeg/libavcodec/mpeg4audio.h
@@ -57,7 +57,7 @@ enum AudioObjectType {
AOT_AAC_MAIN, ///< Y Main
AOT_AAC_LC, ///< Y Low Complexity
AOT_AAC_SSR, ///< N (code in SoC repo) Scalable Sample Rate
- AOT_AAC_LTP, ///< N (code in SoC repo) Long Term Prediction
+ AOT_AAC_LTP, ///< Y Long Term Prediction
AOT_SBR, ///< Y Spectral Band Replication
AOT_AAC_SCALABLE, ///< N Scalable
AOT_TWINVQ, ///< N Twin Vector Quantizer
diff --git a/mplayer/ffmpeg/libavcodec/mpeg4data.h b/mplayer/ffmpeg/libavcodec/mpeg4data.h
index bef5f880..1f4e578c 100644
--- a/mplayer/ffmpeg/libavcodec/mpeg4data.h
+++ b/mplayer/ffmpeg/libavcodec/mpeg4data.h
@@ -115,7 +115,7 @@ RLTable ff_mpeg4_rl_intra = {
};
/* Note this is identical to the intra rvlc except that it is reordered. */
-const uint16_t inter_rvlc[170][2]={
+static const uint16_t inter_rvlc[170][2]={
{0x0006, 3},{0x0001, 4},{0x0004, 5},{0x001C, 7},
{0x003C, 8},{0x003D, 8},{0x007C, 9},{0x00FC, 10},
{0x00FD, 10},{0x01FC, 11},{0x01FD, 11},{0x03FC, 12},
@@ -219,7 +219,7 @@ RLTable rvlc_rl_inter = {
inter_rvlc_level,
};
-const uint16_t intra_rvlc[170][2]={
+static const uint16_t intra_rvlc[170][2]={
{0x0006, 3},{0x0007, 3},{0x000A, 4},{0x0009, 5},
{0x0014, 6},{0x0015, 6},{0x0034, 7},{0x0074, 8},
{0x0075, 8},{0x00DD, 9},{0x00EC, 9},{0x01EC, 10},
diff --git a/mplayer/ffmpeg/libavcodec/mpeg4video.h b/mplayer/ffmpeg/libavcodec/mpeg4video.h
index aab32364..96db3668 100644
--- a/mplayer/ffmpeg/libavcodec/mpeg4video.h
+++ b/mplayer/ffmpeg/libavcodec/mpeg4video.h
@@ -66,10 +66,7 @@ extern const uint16_t ff_mpeg4_intra_vlc[103][2];
extern RLTable ff_mpeg4_rl_intra;
/* Note this is identical to the intra rvlc except that it is reordered. */
-extern const uint16_t inter_rvlc[170][2];
extern RLTable rvlc_rl_inter;
-
-extern const uint16_t intra_rvlc[170][2];
extern RLTable rvlc_rl_intra;
extern const uint16_t sprite_trajectory_tab[15][2];
diff --git a/mplayer/ffmpeg/libavcodec/mpeg4videodec.c b/mplayer/ffmpeg/libavcodec/mpeg4videodec.c
index 5303da38..617dcb9f 100644
--- a/mplayer/ffmpeg/libavcodec/mpeg4videodec.c
+++ b/mplayer/ffmpeg/libavcodec/mpeg4videodec.c
@@ -1494,16 +1494,17 @@ static int mpeg4_decode_mb(MpegEncContext *s,
static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){
int hours, minutes, seconds;
-
- hours= get_bits(gb, 5);
- minutes= get_bits(gb, 6);
- skip_bits1(gb);
- seconds= get_bits(gb, 6);
-
- s->time_base= seconds + 60*(minutes + 60*hours);
-
- skip_bits1(gb);
- skip_bits1(gb);
+ unsigned time_code = show_bits(gb, 18);
+
+ if (time_code & 0x40) { /* marker_bit */
+ hours = time_code >> 13;
+ minutes = time_code >> 7 & 0x3f;
+ seconds = time_code & 0x3f;
+ s->time_base = seconds + 60*(minutes + 60*hours);
+ skip_bits(gb, 20); /* time_code, closed_gov, broken_link */
+ } else {
+ av_log(s->avctx, AV_LOG_WARNING, "GOP header missing marker_bit\n");
+ }
return 0;
}
@@ -2071,7 +2072,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
/* detect buggy encoders which don't set the low_delay flag (divx4/xvid/opendivx)*/
// note we cannot detect divx5 without b-frames easily (although it's buggy too)
if(s->vo_type==0 && s->vol_control_parameters==0 && s->divx_version==-1 && s->picture_number==0){
- av_log(s->avctx, AV_LOG_ERROR, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
+ av_log(s->avctx, AV_LOG_WARNING, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
s->low_delay=1;
}
@@ -2110,7 +2111,7 @@ int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb)
for(;;) {
if(get_bits_count(gb) >= gb->size_in_bits){
if(gb->size_in_bits==8 && (s->divx_version>=0 || s->xvid_build>=0)){
- av_log(s->avctx, AV_LOG_ERROR, "frame skip %d\n", gb->size_in_bits);
+ av_log(s->avctx, AV_LOG_WARNING, "frame skip %d\n", gb->size_in_bits);
return FRAME_SKIPPED; //divx bug
}else
return -1; //end of stream
diff --git a/mplayer/ffmpeg/libavcodec/mpegaudiodec.c b/mplayer/ffmpeg/libavcodec/mpegaudiodec.c
index 0cd0b688..aa31e46a 100644
--- a/mplayer/ffmpeg/libavcodec/mpegaudiodec.c
+++ b/mplayer/ffmpeg/libavcodec/mpegaudiodec.c
@@ -2054,6 +2054,7 @@ static int decode_frame(AVCodecContext * avctx,
}
/* update codec info */
avctx->channels = s->nb_channels;
+ avctx->channel_layout = s->nb_channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
if (!avctx->bit_rate)
avctx->bit_rate = s->bit_rate;
avctx->sub_id = s->layer;
@@ -2227,8 +2228,7 @@ static av_cold int decode_close_mp3on4(AVCodecContext * avctx)
int i;
for (i = 0; i < s->frames; i++)
- if (s->mp3decctx[i])
- av_free(s->mp3decctx[i]);
+ av_free(s->mp3decctx[i]);
return 0;
}
diff --git a/mplayer/ffmpeg/libavcodec/mpegvideo.c b/mplayer/ffmpeg/libavcodec/mpegvideo.c
index c8706bcf..efb03659 100644
--- a/mplayer/ffmpeg/libavcodec/mpegvideo.c
+++ b/mplayer/ffmpeg/libavcodec/mpegvideo.c
@@ -28,7 +28,7 @@
*/
#include "libavutil/intmath.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "internal.h"
diff --git a/mplayer/ffmpeg/libavcodec/mpegvideo_enc.c b/mplayer/ffmpeg/libavcodec/mpegvideo_enc.c
index 6167a9b2..a7f16080 100644
--- a/mplayer/ffmpeg/libavcodec/mpegvideo_enc.c
+++ b/mplayer/ffmpeg/libavcodec/mpegvideo_enc.c
@@ -1381,6 +1381,7 @@ int MPV_encode_picture(AVCodecContext *avctx,
s->vbv_delay_ptr[1] = vbv_delay>>5;
s->vbv_delay_ptr[2] &= 0x07;
s->vbv_delay_ptr[2] |= vbv_delay<<3;
+ avctx->vbv_delay = vbv_delay*300;
}
s->total_bits += s->frame_bits;
avctx->frame_bits = s->frame_bits;
diff --git a/mplayer/ffmpeg/libavcodec/nellymoserdec.c b/mplayer/ffmpeg/libavcodec/nellymoserdec.c
index 8b13a5d8..fd8568d5 100644
--- a/mplayer/ffmpeg/libavcodec/nellymoserdec.c
+++ b/mplayer/ffmpeg/libavcodec/nellymoserdec.c
@@ -34,10 +34,11 @@
#include "nellymoser.h"
#include "libavutil/lfg.h"
#include "libavutil/random_seed.h"
-#include "libavcore/audioconvert.h"
+#include "libavutil/audioconvert.h"
#include "avcodec.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
#define ALT_BITSTREAM_READER_LE
#include "get_bits.h"
@@ -52,6 +53,7 @@ typedef struct NellyMoserDecodeContext {
float scale_bias;
DSPContext dsp;
FFTContext imdct_ctx;
+ FmtConvertContext fmt_conv;
DECLARE_ALIGNED(16, float,imdct_out)[NELLY_BUF_LEN * 2];
} NellyMoserDecodeContext;
@@ -134,6 +136,7 @@ static av_cold int decode_init(AVCodecContext * avctx) {
ff_mdct_init(&s->imdct_ctx, 8, 1, 1.0);
dsputil_init(&s->dsp, avctx);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
s->scale_bias = 1.0/(1*8);
@@ -175,7 +178,7 @@ static int decode_tag(AVCodecContext * avctx,
for (i=0 ; ifloat_buf);
- s->dsp.float_to_int16(&samples[i*NELLY_SAMPLES], s->float_buf, NELLY_SAMPLES);
+ s->fmt_conv.float_to_int16(&samples[i*NELLY_SAMPLES], s->float_buf, NELLY_SAMPLES);
*data_size += NELLY_SAMPLES*sizeof(int16_t);
}
diff --git a/mplayer/ffmpeg/libavcodec/nuv.c b/mplayer/ffmpeg/libavcodec/nuv.c
index d53d4578..84ee6af9 100644
--- a/mplayer/ffmpeg/libavcodec/nuv.c
+++ b/mplayer/ffmpeg/libavcodec/nuv.c
@@ -23,7 +23,7 @@
#include "libavutil/bswap.h"
#include "libavutil/lzo.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "rtjpeg.h"
diff --git a/mplayer/ffmpeg/libavcodec/options.c b/mplayer/ffmpeg/libavcodec/options.c
index 369ee5d3..e4bc8a62 100644
--- a/mplayer/ffmpeg/libavcodec/options.c
+++ b/mplayer/ffmpeg/libavcodec/options.c
@@ -117,8 +117,8 @@ static const AVOption options[]={
{"delay", NULL, OFFSET(delay), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"qcomp", "video quantizer scale compression (VBR)", OFFSET(qcompress), FF_OPT_TYPE_FLOAT, 0.5, -FLT_MAX, FLT_MAX, V|E},
{"qblur", "video quantizer scale blur (VBR)", OFFSET(qblur), FF_OPT_TYPE_FLOAT, 0.5, 0, FLT_MAX, V|E},
-{"qmin", "min video quantizer scale (VBR)", OFFSET(qmin), FF_OPT_TYPE_INT, 2, 0, 63, V|E},
-{"qmax", "max video quantizer scale (VBR)", OFFSET(qmax), FF_OPT_TYPE_INT, 31, 0, 63, V|E},
+{"qmin", "min video quantizer scale (VBR)", OFFSET(qmin), FF_OPT_TYPE_INT, 2, 0, 69, V|E},
+{"qmax", "max video quantizer scale (VBR)", OFFSET(qmax), FF_OPT_TYPE_INT, 31, 0, 69, V|E},
{"qdiff", "max difference between the quantizer scale (VBR)", OFFSET(max_qdiff), FF_OPT_TYPE_INT, 3, INT_MIN, INT_MAX, V|E},
{"bf", "use 'frames' B frames", OFFSET(max_b_frames), FF_OPT_TYPE_INT, DEFAULT, 0, FF_MAX_B_FRAMES, V|E},
{"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, 1.25, -FLT_MAX, FLT_MAX, V|E},
@@ -250,6 +250,7 @@ static const AVOption options[]={
{"vis_qp", "visualize quantization parameter (QP), lower QP are tinted greener", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_QP, INT_MIN, INT_MAX, V|D, "debug"},
{"vis_mb_type", "visualize block types", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MB_TYPE, INT_MIN, INT_MAX, V|D, "debug"},
{"buffers", "picture buffer allocations", 0, FF_OPT_TYPE_CONST, FF_DEBUG_BUFFERS, INT_MIN, INT_MAX, V|D, "debug"},
+{"thread_ops", "threading operations", 0, FF_OPT_TYPE_CONST, FF_DEBUG_THREADS, INT_MIN, INT_MAX, V|D, "debug"},
{"vismv", "visualize motion vectors (MVs)", OFFSET(debug_mv), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|D, "debug_mv"},
{"pf", "forward predicted MVs of P-frames", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_P_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"},
{"bf", "forward predicted MVs of B-frames", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_B_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"},
@@ -431,6 +432,10 @@ static const AVOption options[]={
{"cholesky", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_CHOLESKY, INT_MIN, INT_MAX, A|E, "lpc_type"},
{"lpc_passes", "number of passes to use for Cholesky factorization during LPC analysis", OFFSET(lpc_passes), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
{"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
+{"thread_type", "select multithreading type", OFFSET(thread_type), FF_OPT_TYPE_INT, FF_THREAD_SLICE|FF_THREAD_FRAME, 0, INT_MAX, V|E|D, "thread_type"},
+{"slice", NULL, 0, FF_OPT_TYPE_CONST, FF_THREAD_SLICE, INT_MIN, INT_MAX, V|E|D, "thread_type"},
+{"frame", NULL, 0, FF_OPT_TYPE_CONST, FF_THREAD_FRAME, INT_MIN, INT_MAX, V|E|D, "thread_type"},
+{"vbv_delay", "initial buffer fill time in periods of 27Mhz clock", 0, FF_OPT_TYPE_INT64, 0, 0, INT64_MAX},
{NULL},
};
diff --git a/mplayer/ffmpeg/libavcodec/pcm-mpeg.c b/mplayer/ffmpeg/libavcodec/pcm-mpeg.c
index 189b2b56..03050750 100644
--- a/mplayer/ffmpeg/libavcodec/pcm-mpeg.c
+++ b/mplayer/ffmpeg/libavcodec/pcm-mpeg.c
@@ -24,7 +24,7 @@
* PCM codecs for encodings found in MPEG streams (DVD/Blu-ray)
*/
-#include "libavcore/audioconvert.h"
+#include "libavutil/audioconvert.h"
#include "avcodec.h"
#include "bytestream.h"
diff --git a/mplayer/ffmpeg/libavcodec/pcm.c b/mplayer/ffmpeg/libavcodec/pcm.c
index 0785a9d2..cdc11f80 100644
--- a/mplayer/ffmpeg/libavcodec/pcm.c
+++ b/mplayer/ffmpeg/libavcodec/pcm.c
@@ -482,7 +482,7 @@ AVCodec ff_ ## name_ ## _encoder = { \
.close = pcm_encode_close, \
.sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
-};
+}
#else
#define PCM_ENCODER(id,sample_fmt_,name,long_name_)
#endif
@@ -498,13 +498,13 @@ AVCodec ff_ ## name_ ## _decoder = { \
.decode = pcm_decode_frame, \
.sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
-};
+}
#else
#define PCM_DECODER(id,sample_fmt_,name,long_name_)
#endif
#define PCM_CODEC(id, sample_fmt_, name, long_name_) \
- PCM_ENCODER(id,sample_fmt_,name,long_name_) PCM_DECODER(id,sample_fmt_,name,long_name_)
+ PCM_ENCODER(id,sample_fmt_,name,long_name_); PCM_DECODER(id,sample_fmt_,name,long_name_)
/* Note: Do not forget to add new entries to the Makefile as well. */
PCM_CODEC (CODEC_ID_PCM_ALAW, AV_SAMPLE_FMT_S16, pcm_alaw, "PCM A-law");
diff --git a/mplayer/ffmpeg/libavcodec/pcx.c b/mplayer/ffmpeg/libavcodec/pcx.c
index cafade2d..d47417e3 100644
--- a/mplayer/ffmpeg/libavcodec/pcx.c
+++ b/mplayer/ffmpeg/libavcodec/pcx.c
@@ -22,7 +22,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "get_bits.h"
diff --git a/mplayer/ffmpeg/libavcodec/pgssubdec.c b/mplayer/ffmpeg/libavcodec/pgssubdec.c
index 1ed47578..b7fe5609 100644
--- a/mplayer/ffmpeg/libavcodec/pgssubdec.c
+++ b/mplayer/ffmpeg/libavcodec/pgssubdec.c
@@ -28,7 +28,7 @@
#include "dsputil.h"
#include "bytestream.h"
#include "libavutil/colorspace.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
//#define DEBUG_PACKET_CONTENTS
diff --git a/mplayer/ffmpeg/libavcodec/pictordec.c b/mplayer/ffmpeg/libavcodec/pictordec.c
index 59885ae3..f1b36070 100644
--- a/mplayer/ffmpeg/libavcodec/pictordec.c
+++ b/mplayer/ffmpeg/libavcodec/pictordec.c
@@ -24,7 +24,7 @@
* Pictor/PC Paint decoder
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "cga_data.h"
diff --git a/mplayer/ffmpeg/libavcodec/pngdec.c b/mplayer/ffmpeg/libavcodec/pngdec.c
index 4bc5c370..2f9b343e 100644
--- a/mplayer/ffmpeg/libavcodec/pngdec.c
+++ b/mplayer/ffmpeg/libavcodec/pngdec.c
@@ -18,7 +18,7 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "png.h"
diff --git a/mplayer/ffmpeg/libavcodec/pnm.c b/mplayer/ffmpeg/libavcodec/pnm.c
index c104e234..2cbbdf60 100644
--- a/mplayer/ffmpeg/libavcodec/pnm.c
+++ b/mplayer/ffmpeg/libavcodec/pnm.c
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "pnm.h"
diff --git a/mplayer/ffmpeg/libavcodec/ppc/Makefile b/mplayer/ffmpeg/libavcodec/ppc/Makefile
index b34910de..1ecae994 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/Makefile
+++ b/mplayer/ffmpeg/libavcodec/ppc/Makefile
@@ -21,6 +21,7 @@ ALTIVEC-OBJS-$(CONFIG_FFT) += ppc/fft_altivec.o \
OBJS-$(HAVE_ALTIVEC) += ppc/dsputil_altivec.o \
ppc/fdct_altivec.o \
ppc/float_altivec.o \
+ ppc/fmtconvert_altivec.o \
ppc/gmc_altivec.o \
ppc/idct_altivec.o \
ppc/int_altivec.o \
@@ -37,4 +38,5 @@ PAIRED-OBJS-$(CONFIG_RDFT) += ppc/rdft_paired.o
OBJS-$(HAVE_PAIRED) += ppc/dsputil_paired.o \
ppc/float_paired.o \
+ ppc/fmtconvert_paired.o \
$(PAIRED-OBJS-yes)
diff --git a/mplayer/ffmpeg/libavcodec/ppc/deinterlace.h b/mplayer/ffmpeg/libavcodec/ppc/deinterlace.h
index 29f44087..3cec10d2 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/deinterlace.h
+++ b/mplayer/ffmpeg/libavcodec/ppc/deinterlace.h
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/mplayer/ffmpeg/libavcodec/ppc/dsputil_altivec.h b/mplayer/ffmpeg/libavcodec/ppc/dsputil_altivec.h
index cd44f602..4147eec8 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/dsputil_altivec.h
+++ b/mplayer/ffmpeg/libavcodec/ppc/dsputil_altivec.h
@@ -43,7 +43,6 @@ void ff_vp3_idct_add_altivec(uint8_t *dest, int line_size, DCTELEM *block);
void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx);
void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx);
-void vc1dsp_init_altivec(DSPContext* c, AVCodecContext *avctx);
void float_init_altivec(DSPContext* c, AVCodecContext *avctx);
void int_init_altivec(DSPContext* c, AVCodecContext *avctx);
diff --git a/mplayer/ffmpeg/libavcodec/ppc/dsputil_paired.c b/mplayer/ffmpeg/libavcodec/ppc/dsputil_paired.c
index 2e69c81f..e6fd5c06 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/dsputil_paired.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/dsputil_paired.c
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -185,7 +185,7 @@ static void ac3_downmix_paired(float (*samples)[256], float (*matrix)[2], int ou
paired_stx(result[1], i, samples[1]);
}
} else if (out_ch == 1) {
- for(i=0; igmc1 = gmc1_altivec;
@@ -300,8 +298,5 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
if (CONFIG_H264_DECODER)
dsputil_h264_init_ppc(c, avctx);
-
- if (CONFIG_VC1_DECODER)
- vc1dsp_init_paired(c, avctx);
#endif /* HAVE_PAIRED */
}
diff --git a/mplayer/ffmpeg/libavcodec/ppc/fft_paired.c b/mplayer/ffmpeg/libavcodec/ppc/fft_paired.c
index 0bead577..63420fa1 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/fft_paired.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/fft_paired.c
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/mplayer/ffmpeg/libavcodec/ppc/float_altivec.c b/mplayer/ffmpeg/libavcodec/ppc/float_altivec.c
index 188e03ea..ba97cbfd 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/float_altivec.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/float_altivec.c
@@ -90,13 +90,9 @@ static void vector_fmul_add_altivec(float *dst, const float *src0,
}
}
-static void vector_fmul_window_altivec(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len)
+static void vector_fmul_window_altivec(float *dst, const float *src0, const float *src1, const float *win, int len)
{
- union {
- vector float v;
- float s[4];
- } vadd;
- vector float vadd_bias, zero, t0, t1, s0, s1, wi, wj;
+ vector float zero, t0, t1, s0, s1, wi, wj;
const vector unsigned char reverse = vcprm(3,2,1,0);
int i,j;
@@ -104,8 +100,6 @@ static void vector_fmul_window_altivec(float *dst, const float *src0, const floa
win += len;
src0+= len;
- vadd.s[0] = add_bias;
- vadd_bias = vec_splat(vadd.v, 0);
zero = (vector float)vec_splat_u32(0);
for(i=-len*4, j=len*4-16; i<0; i+=16, j-=16) {
@@ -117,9 +111,9 @@ static void vector_fmul_window_altivec(float *dst, const float *src0, const floa
s1 = vec_perm(s1, s1, reverse);
wj = vec_perm(wj, wj, reverse);
- t0 = vec_madd(s0, wj, vadd_bias);
+ t0 = vec_madd(s0, wj, zero);
t0 = vec_nmsub(s1, wi, t0);
- t1 = vec_madd(s0, wi, vadd_bias);
+ t1 = vec_madd(s0, wi, zero);
t1 = vec_madd(s1, wj, t1);
t1 = vec_perm(t1, t1, reverse);
@@ -128,124 +122,12 @@ static void vector_fmul_window_altivec(float *dst, const float *src0, const floa
}
}
-static void int32_to_float_fmul_scalar_altivec(float *dst, const int *src, float mul, int len)
-{
- union {
- vector float v;
- float s[4];
- } mul_u;
- int i;
- vector float src1, src2, dst1, dst2, mul_v, zero;
-
- zero = (vector float)vec_splat_u32(0);
- mul_u.s[0] = mul;
- mul_v = vec_splat(mul_u.v, 0);
-
- for(i=0; ivector_fmul = vector_fmul_altivec;
c->vector_fmul_reverse = vector_fmul_reverse_altivec;
c->vector_fmul_add = vector_fmul_add_altivec;
- c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_altivec;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)) {
c->vector_fmul_window = vector_fmul_window_altivec;
- c->float_to_int16 = float_to_int16_altivec;
- c->float_to_int16_interleave = float_to_int16_interleave_altivec;
}
}
diff --git a/mplayer/ffmpeg/libavcodec/ppc/float_paired.c b/mplayer/ffmpeg/libavcodec/ppc/float_paired.c
index c5d8f3a9..37bd930e 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/float_paired.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/float_paired.c
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -66,10 +66,9 @@ static void vector_fmul_add_paired(float *dst, const float *src0, const float *s
}
}
-static void vector_fmul_window_paired(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len)
+static void vector_fmul_window_paired(float *dst, const float *src0, const float *src1, const float *win, int len)
{
vector float pair[2], window[2];
- vector float bias = {add_bias,add_bias};
vector float result;
dst += len;
@@ -85,78 +84,17 @@ static void vector_fmul_window_paired(float *dst, const float *src0, const float
window[1] = paired_lx(j, win);
window[1] = paired_merge10(window[1], window[1]);
- result = paired_madd(pair[0], window[1], bias);
- result = ps_nmsub(pair[1], window[0], result);
+ result = paired_mul(pair[1], window[0]);
+ result = paired_msub(pair[0], window[1], result);
paired_stx(result, i, dst);
- result = paired_madd(pair[1], window[1], bias);
+ result = paired_mul(pair[1], window[1]);
result = paired_madd(pair[0], window[0], result);
result = paired_merge10(result, result);
paired_stx(result, j, dst);
}
}
-static void int32_to_float_fmul_scalar_paired(float *dst, const int *src, float mul, int len)
-{
- vector float pair;
-
- for (int i=0; i>1); i++) {
- vector float pair = psq_lu(8,src,0,0);
- psq_stu(pair,4,dst,0,7);
- }
-}
-
-static void float_to_int16_interleave_paired(int16_t *dst, const float **src, long len, int channels)
-{
- vector float pair[2];
- vector float result;
-
- int i, c;
- if (channels > 2) {
- dst -= 2;
- for (i=0; ivector_fmul_reverse = vector_fmul_reverse_paired;
c->vector_fmul_add = vector_fmul_add_paired;
c->vector_fmul_window = vector_fmul_window_paired;
- c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_paired;
- c->float_to_int16 = float_to_int16_paired;
- c->float_to_int16_interleave = float_to_int16_interleave_paired;
c->butterflies_float = butterflies_float_paired;
c->scalarproduct_float = scalarproduct_float_paired;
c->vector_fmul_scalar = vector_fmul_scalar_paired;
diff --git a/mplayer/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c b/mplayer/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c
new file mode 100644
index 00000000..e5287c96
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2006 Luca Barbato
+ *
+ * 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
+ */
+
+#include "libavcodec/fmtconvert.h"
+
+#include "dsputil_altivec.h"
+#include "util_altivec.h"
+
+static void int32_to_float_fmul_scalar_altivec(float *dst, const int *src, float mul, int len)
+{
+ union {
+ vector float v;
+ float s[4];
+ } mul_u;
+ int i;
+ vector float src1, src2, dst1, dst2, mul_v, zero;
+
+ zero = (vector float)vec_splat_u32(0);
+ mul_u.s[0] = mul;
+ mul_v = vec_splat(mul_u.v, 0);
+
+ for(i=0; iint32_to_float_fmul_scalar = int32_to_float_fmul_scalar_altivec;
+ if(!(avctx->flags & CODEC_FLAG_BITEXACT)) {
+ c->float_to_int16 = float_to_int16_altivec;
+ c->float_to_int16_interleave = float_to_int16_interleave_altivec;
+ }
+}
diff --git a/mplayer/ffmpeg/libavcodec/ppc/fmtconvert_paired.c b/mplayer/ffmpeg/libavcodec/ppc/fmtconvert_paired.c
new file mode 100644
index 00000000..451fc778
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/ppc/fmtconvert_paired.c
@@ -0,0 +1,89 @@
+/*
+ * This file is part of MPlayer CE.
+ *
+ * MPlayer CE 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.
+ *
+ * MPlayer CE 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 MPlayer CE; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/fmtconvert.h"
+#include "dsputil_paired.h"
+#include "libavutil/ppc/paired.h"
+
+static void int32_to_float_fmul_scalar_paired(float *dst, const int *src, float mul, int len)
+{
+ vector float pair;
+
+ for (int i=0; i>1); i++) {
+ vector float pair = psq_lu(8,src,0,0);
+ psq_stu(pair,4,dst,0,7);
+ }
+}
+
+static void float_to_int16_interleave_paired(int16_t *dst, const float **src, long len, int channels)
+{
+ vector float pair[2];
+ vector float result;
+
+ int i, c;
+ if (channels > 2) {
+ dst -= 2;
+ for (i=0; iint32_to_float_fmul_scalar = int32_to_float_fmul_scalar_paired;
+ c->float_to_int16 = float_to_int16_paired;
+ c->float_to_int16_interleave = float_to_int16_interleave_paired;
+}
diff --git a/mplayer/ffmpeg/libavcodec/ppc/h264_altivec.c b/mplayer/ffmpeg/libavcodec/ppc/h264_altivec.c
index aee2bc2d..ef95de1b 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/h264_altivec.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/h264_altivec.c
@@ -32,7 +32,6 @@
#define OP_U8_ALTIVEC PUT_OP_U8_ALTIVEC
#define PREFIX_h264_chroma_mc8_altivec put_h264_chroma_mc8_altivec
-#define PREFIX_no_rnd_vc1_chroma_mc8_altivec put_no_rnd_vc1_chroma_mc8_altivec
#define PREFIX_h264_chroma_mc8_num altivec_put_h264_chroma_mc8_num
#define PREFIX_h264_qpel16_h_lowpass_altivec put_h264_qpel16_h_lowpass_altivec
#define PREFIX_h264_qpel16_h_lowpass_num altivec_put_h264_qpel16_h_lowpass_num
@@ -43,7 +42,6 @@
#include "h264_template_altivec.c"
#undef OP_U8_ALTIVEC
#undef PREFIX_h264_chroma_mc8_altivec
-#undef PREFIX_no_rnd_vc1_chroma_mc8_altivec
#undef PREFIX_h264_chroma_mc8_num
#undef PREFIX_h264_qpel16_h_lowpass_altivec
#undef PREFIX_h264_qpel16_h_lowpass_num
@@ -54,7 +52,6 @@
#define OP_U8_ALTIVEC AVG_OP_U8_ALTIVEC
#define PREFIX_h264_chroma_mc8_altivec avg_h264_chroma_mc8_altivec
-#define PREFIX_no_rnd_vc1_chroma_mc8_altivec avg_no_rnd_vc1_chroma_mc8_altivec
#define PREFIX_h264_chroma_mc8_num altivec_avg_h264_chroma_mc8_num
#define PREFIX_h264_qpel16_h_lowpass_altivec avg_h264_qpel16_h_lowpass_altivec
#define PREFIX_h264_qpel16_h_lowpass_num altivec_avg_h264_qpel16_h_lowpass_num
@@ -65,7 +62,6 @@
#include "h264_template_altivec.c"
#undef OP_U8_ALTIVEC
#undef PREFIX_h264_chroma_mc8_altivec
-#undef PREFIX_no_rnd_vc1_chroma_mc8_altivec
#undef PREFIX_h264_chroma_mc8_num
#undef PREFIX_h264_qpel16_h_lowpass_altivec
#undef PREFIX_h264_qpel16_h_lowpass_num
@@ -973,8 +969,6 @@ void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) {
if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec;
c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_altivec;
- c->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_altivec;
- c->avg_no_rnd_vc1_chroma_pixels_tab[0] = avg_no_rnd_vc1_chroma_mc8_altivec;
#define dspfunc(PFX, IDX, NUM) \
c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_altivec; \
diff --git a/mplayer/ffmpeg/libavcodec/ppc/h264_template_altivec.c b/mplayer/ffmpeg/libavcodec/ppc/h264_template_altivec.c
index 8cf39c8b..29e4d40d 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/h264_template_altivec.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/h264_template_altivec.c
@@ -75,6 +75,7 @@
#define noop(a) a
#define add28(a) vec_add(v28ss, a)
+#ifdef PREFIX_h264_chroma_mc8_altivec
static void PREFIX_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src,
int stride, int h, int x, int y) {
DECLARE_ALIGNED(16, signed int, ABCD)[4] =
@@ -201,8 +202,10 @@ static void PREFIX_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src,
}
}
}
+#endif
/* this code assume that stride % 16 == 0 */
+#ifdef PREFIX_no_rnd_vc1_chroma_mc8_altivec
static void PREFIX_no_rnd_vc1_chroma_mc8_altivec(uint8_t * dst, uint8_t * src, int stride, int h, int x, int y) {
DECLARE_ALIGNED(16, signed int, ABCD)[4] =
{((8 - x) * (8 - y)),
@@ -284,12 +287,14 @@ static void PREFIX_no_rnd_vc1_chroma_mc8_altivec(uint8_t * dst, uint8_t * src, i
}
}
}
+#endif
#undef noop
#undef add28
#undef CHROMA_MC8_ALTIVEC_CORE
/* this code assume stride % 16 == 0 */
+#ifdef PREFIX_h264_qpel16_h_lowpass_altivec
static void PREFIX_h264_qpel16_h_lowpass_altivec(uint8_t * dst, uint8_t * src, int dstStride, int srcStride) {
register int i;
@@ -427,8 +432,10 @@ static void PREFIX_h264_qpel16_h_lowpass_altivec(uint8_t * dst, uint8_t * src, i
dst += dstStride;
}
}
+#endif
/* this code assume stride % 16 == 0 */
+#ifdef PREFIX_h264_qpel16_v_lowpass_altivec
static void PREFIX_h264_qpel16_v_lowpass_altivec(uint8_t * dst, uint8_t * src, int dstStride, int srcStride) {
register int i;
@@ -533,8 +540,10 @@ static void PREFIX_h264_qpel16_v_lowpass_altivec(uint8_t * dst, uint8_t * src, i
dst += dstStride;
}
}
+#endif
/* this code assume stride % 16 == 0 *and* tmp is properly aligned */
+#ifdef PREFIX_h264_qpel16_hv_lowpass_altivec
static void PREFIX_h264_qpel16_hv_lowpass_altivec(uint8_t * dst, int16_t * tmp, uint8_t * src, int dstStride, int tmpStride, int srcStride) {
register int i;
LOAD_ZERO;
@@ -765,3 +774,4 @@ static void PREFIX_h264_qpel16_hv_lowpass_altivec(uint8_t * dst, int16_t * tmp,
dst += dstStride;
}
}
+#endif
diff --git a/mplayer/ffmpeg/libavcodec/ppc/h264dsp_paired.c b/mplayer/ffmpeg/libavcodec/ppc/h264dsp_paired.c
index 813f4837..4b19a1c6 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/h264dsp_paired.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/h264dsp_paired.c
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -460,7 +460,7 @@ static void avg_h264_chroma_mc8_paired(uint8_t *dst, uint8_t *src, int stride, i
}
}
-static void put_no_rnd_vc1_chroma_mc8_paired(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y)
+void ff_put_vc1_chroma_mc8_paired_nornd(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y)
{
const vector float zero = {0.0,0.0};
const float offset = 0.4375;
@@ -581,7 +581,7 @@ static void put_no_rnd_vc1_chroma_mc8_paired(uint8_t *dst, uint8_t *src, int str
}
}
-static void avg_no_rnd_vc1_chroma_mc8_paired(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y)
+void ff_avg_vc1_chroma_mc8_paired_nornd(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y)
{
const vector float zero = {0.0,0.0};
const float offset = 0.4375;
@@ -1212,8 +1212,6 @@ void dsputil_h264_init_ppc(DSPContext *c, AVCodecContext *avctx)
c->put_h264_chroma_pixels_tab[1] = put_h264_chroma_mc4_paired;
c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_paired;
c->avg_h264_chroma_pixels_tab[1] = avg_h264_chroma_mc4_paired;
- c->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_paired;
- c->avg_no_rnd_vc1_chroma_pixels_tab[0] = avg_no_rnd_vc1_chroma_mc8_paired;
}
void ff_h264dsp_init_ppc(H264DSPContext *c)
@@ -1223,8 +1221,8 @@ void ff_h264dsp_init_ppc(H264DSPContext *c)
c->h264_idct_add16 = ff_h264_idct_add16_paired;
c->h264_idct_add16intra = ff_h264_idct_add16intra_paired;
c->h264_idct_dc_add = ff_h264_idct_dc_add_paired;
- c->h264_idct8_dc_add = ff_h264_idct8_dc_add_paired;
//c->h264_idct8_add = ff_h264_idct8_add_paired;
+ c->h264_idct8_dc_add = ff_h264_idct8_dc_add_paired;
c->h264_idct8_add4 = ff_h264_idct8_add4_paired;
c->weight_h264_pixels_tab[0] = weight_h264_pixels16x16_paired;
diff --git a/mplayer/ffmpeg/libavcodec/ppc/h264pred_paired.c b/mplayer/ffmpeg/libavcodec/ppc/h264pred_paired.c
index 3cdf7d63..3ab4f633 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/h264pred_paired.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/h264pred_paired.c
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/mplayer/ffmpeg/libavcodec/ppc/mdct_paired.c b/mplayer/ffmpeg/libavcodec/ppc/mdct_paired.c
index 81bbb7a1..b6c26ab3 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/mdct_paired.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/mdct_paired.c
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/mplayer/ffmpeg/libavcodec/ppc/rdft_paired.c b/mplayer/ffmpeg/libavcodec/ppc/rdft_paired.c
index e0db835c..bbd6b618 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/rdft_paired.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/rdft_paired.c
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/mplayer/ffmpeg/libavcodec/ppc/vc1dsp_altivec.c b/mplayer/ffmpeg/libavcodec/ppc/vc1dsp_altivec.c
index a2f55f2d..05edb53b 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/vc1dsp_altivec.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/vc1dsp_altivec.c
@@ -20,6 +20,7 @@
*/
#include "libavcodec/dsputil.h"
+#include "libavcodec/vc1dsp.h"
#include "util_altivec.h"
#include "dsputil_altivec.h"
@@ -129,7 +130,8 @@ do { \
/** Do inverse transform on 8x8 block
*/
-static void vc1_inv_trans_8x8_altivec(DCTELEM block[64])
+static void vc1_inv_trans_8x8_altivec(DCTELEM block[64],
+ int sign, int rangered)
{
vector signed short src0, src1, src2, src3, src4, src5, src6, src7;
vector signed int s0, s1, s2, s3, s4, s5, s6, s7;
@@ -143,7 +145,9 @@ static void vc1_inv_trans_8x8_altivec(DCTELEM block[64])
const vector unsigned int vec_2 = vec_splat_u32(2);
const vector signed int vec_1s = vec_splat_s32(1);
const vector unsigned int vec_1 = vec_splat_u32(1);
-
+ const vector unsigned short rangered_shift = vec_splat_u16(1);
+ const vector signed short signed_bias = vec_sl(vec_splat_s16(4),
+ vec_splat_u16(4));
src0 = vec_ld( 0, block);
src1 = vec_ld( 16, block);
@@ -154,7 +158,6 @@ static void vc1_inv_trans_8x8_altivec(DCTELEM block[64])
src6 = vec_ld( 96, block);
src7 = vec_ld(112, block);
- TRANSPOSE8(src0, src1, src2, src3, src4, src5, src6, src7);
s0 = vec_unpackl(src0);
s1 = vec_unpackl(src1);
s2 = vec_unpackl(src2);
@@ -214,6 +217,27 @@ static void vc1_inv_trans_8x8_altivec(DCTELEM block[64])
src6 = vec_pack(sE, s6);
src7 = vec_pack(sF, s7);
+ if (rangered) {
+ if (!sign) {
+ src0 = vec_sub(src0, signed_bias);
+ src1 = vec_sub(src1, signed_bias);
+ src2 = vec_sub(src2, signed_bias);
+ src3 = vec_sub(src3, signed_bias);
+ src4 = vec_sub(src4, signed_bias);
+ src5 = vec_sub(src5, signed_bias);
+ src6 = vec_sub(src6, signed_bias);
+ src7 = vec_sub(src7, signed_bias);
+ }
+ src0 = vec_sl(src0, rangered_shift);
+ src1 = vec_sl(src1, rangered_shift);
+ src2 = vec_sl(src2, rangered_shift);
+ src3 = vec_sl(src3, rangered_shift);
+ src4 = vec_sl(src4, rangered_shift);
+ src5 = vec_sl(src5, rangered_shift);
+ src6 = vec_sl(src6, rangered_shift);
+ src7 = vec_sl(src7, rangered_shift);
+ }
+
vec_st(src0, 0, block);
vec_st(src1, 16, block);
vec_st(src2, 32, block);
@@ -224,6 +248,36 @@ static void vc1_inv_trans_8x8_altivec(DCTELEM block[64])
vec_st(src7,112, block);
}
+static void vc1_inv_trans_8x8_add_altivec(uint8_t *dest, int stride, DCTELEM *b)
+{
+ vc1_inv_trans_8x8_altivec(b, 0, 0);
+ ff_add_pixels_clamped_c(b, dest, stride);
+}
+
+static void vc1_inv_trans_8x8_put_signed_altivec(uint8_t *dest, int stride, DCTELEM *b)
+{
+ vc1_inv_trans_8x8_altivec(b, 1, 0);
+ ff_put_signed_pixels_clamped_c(b, dest, stride);
+}
+
+static void vc1_inv_trans_8x8_put_signed_rangered_altivec(uint8_t *dest, int stride, DCTELEM *b)
+{
+ vc1_inv_trans_8x8_altivec(b, 1, 1);
+ ff_put_signed_pixels_clamped_c(b, dest, stride);
+}
+
+static void vc1_inv_trans_8x8_put_altivec(uint8_t *dest, int stride, DCTELEM *b)
+{
+ vc1_inv_trans_8x8_altivec(b, 0, 0);
+ ff_put_pixels_clamped_c(b, dest, stride);
+}
+
+static void vc1_inv_trans_8x8_put_rangered_altivec(uint8_t *dest, int stride, DCTELEM *b)
+{
+ vc1_inv_trans_8x8_altivec(b, 0, 1);
+ ff_put_pixels_clamped_c(b, dest, stride);
+}
+
/** Do inverse transform on 8x4 part of block
*/
static void vc1_inv_trans_8x4_altivec(uint8_t *dest, int stride, DCTELEM *block)
@@ -322,8 +376,32 @@ static void vc1_inv_trans_8x4_altivec(uint8_t *dest, int stride, DCTELEM *block)
ADD (dest, src3, perm1)
}
+#define PUT_OP_U8_ALTIVEC(d, s, dst) d = s
+#define AVG_OP_U8_ALTIVEC(d, s, dst) d = vec_avg(dst, s)
+
+#define OP_U8_ALTIVEC PUT_OP_U8_ALTIVEC
+#define PREFIX_no_rnd_vc1_chroma_mc8_altivec put_no_rnd_vc1_chroma_mc8_altivec
+#include "h264_template_altivec.c"
+#undef OP_U8_ALTIVEC
+#undef PREFIX_no_rnd_vc1_chroma_mc8_altivec
+
+#define OP_U8_ALTIVEC AVG_OP_U8_ALTIVEC
+#define PREFIX_no_rnd_vc1_chroma_mc8_altivec avg_no_rnd_vc1_chroma_mc8_altivec
+#include "h264_template_altivec.c"
+#undef OP_U8_ALTIVEC
+#undef PREFIX_no_rnd_vc1_chroma_mc8_altivec
+
+void ff_vc1dsp_init_altivec(VC1DSPContext* dsp)
+{
+ if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
+ return;
-void vc1dsp_init_altivec(DSPContext* dsp, AVCodecContext *avctx) {
- dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_altivec;
+ dsp->vc1_inv_trans_8x8_add = vc1_inv_trans_8x8_add_altivec;
+ dsp->vc1_inv_trans_8x8_put_signed[0] = vc1_inv_trans_8x8_put_signed_altivec;
+ dsp->vc1_inv_trans_8x8_put_signed[1] = vc1_inv_trans_8x8_put_signed_rangered_altivec;
+ dsp->vc1_inv_trans_8x8_put[0] = vc1_inv_trans_8x8_put_altivec;
+ dsp->vc1_inv_trans_8x8_put[1] = vc1_inv_trans_8x8_put_rangered_altivec;
dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_altivec;
+ dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_altivec;
+ dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = avg_no_rnd_vc1_chroma_mc8_altivec;
}
diff --git a/mplayer/ffmpeg/libavcodec/ppc/vc1dsp_paired.c b/mplayer/ffmpeg/libavcodec/ppc/vc1dsp_paired.c
index 433a24f1..81bb243c 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/vc1dsp_paired.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/vc1dsp_paired.c
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,9 +17,13 @@
*/
#include "libavcodec/dsputil.h"
+#include "libavcodec/vc1dsp.h"
#include "dsputil_paired.h"
#include "libavutil/ppc/paired.h"
+void ff_put_vc1_chroma_mc8_paired_nornd(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y);
+void ff_avg_vc1_chroma_mc8_paired_nornd(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y);
+
static void vc1_inv_trans_8x8_dc_paired(uint8_t *dest, int linesize, DCTELEM *block)
{
const float half = 0.5;
@@ -130,10 +134,13 @@ static void vc1_inv_trans_4x4_dc_paired(uint8_t *dest, int linesize, DCTELEM *bl
}
}
-void vc1dsp_init_paired(DSPContext *dsp, AVCodecContext *avctx)
+void ff_vc1dsp_init_paired(VC1DSPContext *dsp)
{
dsp->vc1_inv_trans_8x8_dc = vc1_inv_trans_8x8_dc_paired;
dsp->vc1_inv_trans_8x4_dc = vc1_inv_trans_8x4_dc_paired;
dsp->vc1_inv_trans_4x8_dc = vc1_inv_trans_4x8_dc_paired;
dsp->vc1_inv_trans_4x4_dc = vc1_inv_trans_4x4_dc_paired;
+
+ dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_paired_nornd;
+ dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_paired_nornd;
}
diff --git a/mplayer/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c b/mplayer/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c
index 8096c4a5..8bb60aae 100644
--- a/mplayer/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c
+++ b/mplayer/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c
@@ -56,8 +56,8 @@ static const vec_s8 h_subpel_filters_outer[3] =
vec_s8 filter_outerl = vec_sld(filter_outerh, filter_outerh, 2)
#define FILTER_H(dstv, off) \
- a = vec_ld((off)-2, src); \
- b = vec_ld((off)-2+15, src); \
+ a = vec_ld((off)-is6tap-1, src); \
+ b = vec_ld((off)-is6tap-1+15, src); \
\
pixh = vec_perm(a, b, permh##off); \
pixl = vec_perm(a, b, perml##off); \
@@ -86,13 +86,15 @@ void put_vp8_epel_h_altivec_core(uint8_t *dst, int dst_stride,
vec_s16 f16h, f16l;
vec_s32 filth, filtl;
- vec_u8 perm_inner = { 1,2,3,4, 2,3,4,5, 3,4,5,6, 4,5,6,7 };
+ vec_u8 perm_inner6 = { 1,2,3,4, 2,3,4,5, 3,4,5,6, 4,5,6,7 };
+ vec_u8 perm_inner4 = { 0,1,2,3, 1,2,3,4, 2,3,4,5, 3,4,5,6 };
+ vec_u8 perm_inner = is6tap ? perm_inner6 : perm_inner4;
vec_u8 perm_outer = { 4,9, 0,5, 5,10, 1,6, 6,11, 2,7, 7,12, 3,8 };
vec_s32 c64 = vec_sl(vec_splat_s32(1), vec_splat_u32(6));
vec_u16 c7 = vec_splat_u16(7);
- align_vec0 = vec_lvsl( -2, src);
- align_vec8 = vec_lvsl(8-2, src);
+ align_vec0 = vec_lvsl( -is6tap-1, src);
+ align_vec8 = vec_lvsl(8-is6tap-1, src);
permh0 = vec_perm(align_vec0, align_vec0, perm_inner);
permh8 = vec_perm(align_vec8, align_vec8, perm_inner);
@@ -239,8 +241,13 @@ void put_vp8_epel ## WIDTH ## _v ## TAPS ## _altivec(uint8_t *dst, int dst_strid
static void put_vp8_epel ## WIDTH ## _h ## HTAPS ## v ## VTAPS ## _altivec(uint8_t *dst, int stride, uint8_t *src, int s, int h, int mx, int my) \
{ \
DECLARE_ALIGNED(16, uint8_t, tmp)[(2*WIDTH+5)*16]; \
- put_vp8_epel ## WIDTH ## _h ## HTAPS ## _altivec(tmp, 16, src-2*stride, stride, h+5, mx, my); \
- put_vp8_epel ## WIDTH ## _v ## VTAPS ## _altivec(dst, stride, tmp+2*16, 16, h, mx, my); \
+ if (VTAPS == 6) { \
+ put_vp8_epel ## WIDTH ## _h ## HTAPS ## _altivec(tmp, 16, src-2*stride, stride, h+5, mx, my); \
+ put_vp8_epel ## WIDTH ## _v ## VTAPS ## _altivec(dst, stride, tmp+2*16, 16, h, mx, my); \
+ } else { \
+ put_vp8_epel ## WIDTH ## _h ## HTAPS ## _altivec(tmp, 16, src-stride, stride, h+4, mx, my); \
+ put_vp8_epel ## WIDTH ## _v ## VTAPS ## _altivec(dst, stride, tmp+16, 16, h, mx, my); \
+ } \
}
EPEL_FUNCS(16,6)
diff --git a/mplayer/ffmpeg/libavcodec/pthread.c b/mplayer/ffmpeg/libavcodec/pthread.c
index 1628b21a..658dbacb 100644
--- a/mplayer/ffmpeg/libavcodec/pthread.c
+++ b/mplayer/ffmpeg/libavcodec/pthread.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2004 Roman Shaposhnik
+ * Copyright (c) 2008 Alexander Strange (astrange@ithinksw.com)
*
* Many thanks to Steven M. Schultz for providing clever ideas and
* to Michael Niedermayer for writing initial
@@ -21,9 +22,17 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+/**
+ * @file
+ * Multithreading support functions
+ * @see doc/multithreading.txt
+ */
+
#include
#include "avcodec.h"
+#include "thread.h"
typedef int (action_func)(AVCodecContext *c, void *arg);
typedef int (action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr);
@@ -45,6 +54,78 @@ typedef struct ThreadContext {
int done;
} ThreadContext;
+/// Max number of frame buffers that can be allocated when using frame threads.
+#define MAX_BUFFERS 32
+
+/**
+ * Context used by codec threads and stored in their AVCodecContext thread_opaque.
+ */
+typedef struct PerThreadContext {
+ struct FrameThreadContext *parent;
+
+ pthread_t thread;
+ pthread_cond_t input_cond; ///< Used to wait for a new packet from the main thread.
+ pthread_cond_t progress_cond; ///< Used by child threads to wait for progress to change.
+ pthread_cond_t output_cond; ///< Used by the main thread to wait for frames to finish.
+
+ pthread_mutex_t mutex; ///< Mutex used to protect the contents of the PerThreadContext.
+ pthread_mutex_t progress_mutex; ///< Mutex used to protect frame progress values and progress_cond.
+
+ AVCodecContext *avctx; ///< Context used to decode packets passed to this thread.
+
+ AVPacket avpkt; ///< Input packet (for decoding) or output (for encoding).
+ int allocated_buf_size; ///< Size allocated for avpkt.data
+
+ AVFrame frame; ///< Output frame (for decoding) or input (for encoding).
+ int got_frame; ///< The output of got_picture_ptr from the last avcodec_decode_video() call.
+ int result; ///< The result of the last codec decode/encode() call.
+
+ enum {
+ STATE_INPUT_READY, ///< Set when the thread is awaiting a packet.
+ STATE_SETTING_UP, ///< Set before the codec has called ff_thread_finish_setup().
+ STATE_GET_BUFFER, /**<
+ * Set when the codec calls get_buffer().
+ * State is returned to STATE_SETTING_UP afterwards.
+ */
+ STATE_SETUP_FINISHED ///< Set after the codec has called ff_thread_finish_setup().
+ } state;
+
+ /**
+ * Array of frames passed to ff_thread_release_buffer().
+ * Frames are released after all threads referencing them are finished.
+ */
+ AVFrame released_buffers[MAX_BUFFERS];
+ int num_released_buffers;
+
+ /**
+ * Array of progress values used by ff_thread_get_buffer().
+ */
+ int progress[MAX_BUFFERS][2];
+ uint8_t progress_used[MAX_BUFFERS];
+
+ AVFrame *requested_frame; ///< AVFrame the codec passed to get_buffer()
+} PerThreadContext;
+
+/**
+ * Context stored in the client AVCodecContext thread_opaque.
+ */
+typedef struct FrameThreadContext {
+ PerThreadContext *threads; ///< The contexts for each thread.
+ PerThreadContext *prev_thread; ///< The last thread submit_packet() was called on.
+
+ pthread_mutex_t buffer_mutex; ///< Mutex used to protect get/release_buffer().
+
+ int next_decoding; ///< The next context to submit a packet to.
+ int next_finished; ///< The next context to return output from.
+
+ int delaying; /**<
+ * Set for the first N packets, where N is the number of threads.
+ * While it is set, ff_thread_en/decode_frame won't return any results.
+ */
+
+ int die; ///< Set when threads should exit.
+} FrameThreadContext;
+
static void* attribute_align_arg worker(void *v)
{
AVCodecContext *avctx = v;
@@ -84,7 +165,7 @@ static av_always_inline void avcodec_thread_park_workers(ThreadContext *c, int t
pthread_mutex_unlock(&c->current_job_lock);
}
-void avcodec_thread_free(AVCodecContext *avctx)
+static void thread_free(AVCodecContext *avctx)
{
ThreadContext *c = avctx->thread_opaque;
int i;
@@ -109,6 +190,9 @@ static int avcodec_thread_execute(AVCodecContext *avctx, action_func* func, void
ThreadContext *c= avctx->thread_opaque;
int dummy_ret;
+ if (!(avctx->active_thread_type&FF_THREAD_SLICE) || avctx->thread_count <= 1)
+ return avcodec_default_execute(avctx, func, arg, ret, job_count, job_size);
+
if (job_count <= 0)
return 0;
@@ -140,12 +224,11 @@ static int avcodec_thread_execute2(AVCodecContext *avctx, action_func2* func2, v
return avcodec_thread_execute(avctx, NULL, arg, ret, job_count, 0);
}
-int avcodec_thread_init(AVCodecContext *avctx, int thread_count)
+static int thread_init(AVCodecContext *avctx)
{
int i;
ThreadContext *c;
-
- avctx->thread_count = thread_count;
+ int thread_count = avctx->thread_count;
if (thread_count <= 1)
return 0;
@@ -173,7 +256,7 @@ int avcodec_thread_init(AVCodecContext *avctx, int thread_count)
if(pthread_create(&c->workers[i], NULL, worker, avctx)) {
avctx->thread_count = i;
pthread_mutex_unlock(&c->current_job_lock);
- avcodec_thread_free(avctx);
+ ff_thread_free(avctx);
return -1;
}
}
@@ -184,3 +267,642 @@ int avcodec_thread_init(AVCodecContext *avctx, int thread_count)
avctx->execute2 = avcodec_thread_execute2;
return 0;
}
+
+/**
+ * Codec worker thread.
+ *
+ * Automatically calls ff_thread_finish_setup() if the codec does
+ * not provide an update_thread_context method, or if the codec returns
+ * before calling it.
+ */
+static attribute_align_arg void *frame_worker_thread(void *arg)
+{
+ PerThreadContext *p = arg;
+ FrameThreadContext *fctx = p->parent;
+ AVCodecContext *avctx = p->avctx;
+ AVCodec *codec = avctx->codec;
+
+ while (1) {
+ if (p->state == STATE_INPUT_READY && !fctx->die) {
+ pthread_mutex_lock(&p->mutex);
+ while (p->state == STATE_INPUT_READY && !fctx->die)
+ pthread_cond_wait(&p->input_cond, &p->mutex);
+ pthread_mutex_unlock(&p->mutex);
+ }
+
+ if (fctx->die) break;
+
+ if (!codec->update_thread_context && avctx->thread_safe_callbacks)
+ ff_thread_finish_setup(avctx);
+
+ pthread_mutex_lock(&p->mutex);
+ avcodec_get_frame_defaults(&p->frame);
+ p->got_frame = 0;
+ p->result = codec->decode(avctx, &p->frame, &p->got_frame, &p->avpkt);
+
+ if (p->state == STATE_SETTING_UP) ff_thread_finish_setup(avctx);
+
+ p->state = STATE_INPUT_READY;
+
+ pthread_mutex_lock(&p->progress_mutex);
+ pthread_cond_signal(&p->output_cond);
+ pthread_mutex_unlock(&p->progress_mutex);
+
+ pthread_mutex_unlock(&p->mutex);
+ }
+
+ return NULL;
+}
+
+/**
+ * Updates the next thread's AVCodecContext with values from the reference thread's context.
+ *
+ * @param dst The destination context.
+ * @param src The source context.
+ * @param for_user 0 if the destination is a codec thread, 1 if the destination is the user's thread
+ */
+static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, int for_user)
+{
+ int err = 0;
+
+ if (dst != src) {
+ dst->sub_id = src->sub_id;
+ dst->time_base = src->time_base;
+ dst->width = src->width;
+ dst->height = src->height;
+ dst->pix_fmt = src->pix_fmt;
+
+ dst->has_b_frames = src->has_b_frames;
+ dst->idct_algo = src->idct_algo;
+ dst->slice_count = src->slice_count;
+
+ dst->bits_per_coded_sample = src->bits_per_coded_sample;
+ dst->sample_aspect_ratio = src->sample_aspect_ratio;
+ dst->dtg_active_format = src->dtg_active_format;
+
+ dst->profile = src->profile;
+ dst->level = src->level;
+
+ dst->bits_per_raw_sample = src->bits_per_raw_sample;
+ dst->ticks_per_frame = src->ticks_per_frame;
+ dst->color_primaries = src->color_primaries;
+
+ dst->color_trc = src->color_trc;
+ dst->colorspace = src->colorspace;
+ dst->color_range = src->color_range;
+ dst->chroma_sample_location = src->chroma_sample_location;
+ }
+
+ if (for_user) {
+ dst->coded_frame = src->coded_frame;
+ dst->has_b_frames += src->thread_count - 1;
+ } else {
+ if (dst->codec->update_thread_context)
+ err = dst->codec->update_thread_context(dst, src);
+ }
+
+ return err;
+}
+
+/**
+ * Update the next thread's AVCodecContext with values set by the user.
+ *
+ * @param dst The destination context.
+ * @param src The source context.
+ */
+static void update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
+{
+#define copy_fields(s, e) memcpy(&dst->s, &src->s, (char*)&dst->e - (char*)&dst->s);
+ dst->flags = src->flags;
+
+ dst->draw_horiz_band= src->draw_horiz_band;
+ dst->get_buffer = src->get_buffer;
+ dst->release_buffer = src->release_buffer;
+
+ dst->opaque = src->opaque;
+ dst->hurry_up = src->hurry_up;
+ dst->dsp_mask = src->dsp_mask;
+ dst->debug = src->debug;
+ dst->debug_mv = src->debug_mv;
+
+ dst->slice_flags = src->slice_flags;
+ dst->flags2 = src->flags2;
+
+ copy_fields(skip_loop_filter, bidir_refine);
+
+ dst->frame_number = src->frame_number;
+ dst->reordered_opaque = src->reordered_opaque;
+#undef copy_fields
+}
+
+static void free_progress(AVFrame *f)
+{
+ PerThreadContext *p = f->owner->thread_opaque;
+ int *progress = f->thread_opaque;
+
+ p->progress_used[(progress - p->progress[0]) / 2] = 0;
+}
+
+/// Releases the buffers that this decoding thread was the last user of.
+static void release_delayed_buffers(PerThreadContext *p)
+{
+ FrameThreadContext *fctx = p->parent;
+
+ while (p->num_released_buffers > 0) {
+ AVFrame *f = &p->released_buffers[--p->num_released_buffers];
+
+ pthread_mutex_lock(&fctx->buffer_mutex);
+ free_progress(f);
+ f->thread_opaque = NULL;
+
+ f->owner->release_buffer(f->owner, f);
+ pthread_mutex_unlock(&fctx->buffer_mutex);
+ }
+}
+
+static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
+{
+ FrameThreadContext *fctx = p->parent;
+ PerThreadContext *prev_thread = fctx->prev_thread;
+ AVCodec *codec = p->avctx->codec;
+ uint8_t *buf = p->avpkt.data;
+
+ if (!avpkt->size && !(codec->capabilities & CODEC_CAP_DELAY)) return 0;
+
+ pthread_mutex_lock(&p->mutex);
+
+ release_delayed_buffers(p);
+
+ if (prev_thread) {
+ int err;
+ if (prev_thread->state == STATE_SETTING_UP) {
+ pthread_mutex_lock(&prev_thread->progress_mutex);
+ while (prev_thread->state == STATE_SETTING_UP)
+ pthread_cond_wait(&prev_thread->progress_cond, &prev_thread->progress_mutex);
+ pthread_mutex_unlock(&prev_thread->progress_mutex);
+ }
+
+ err = update_context_from_thread(p->avctx, prev_thread->avctx, 0);
+ if (err) {
+ pthread_mutex_unlock(&p->mutex);
+ return err;
+ }
+ }
+
+ av_fast_malloc(&buf, &p->allocated_buf_size, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
+ p->avpkt = *avpkt;
+ p->avpkt.data = buf;
+ memcpy(buf, avpkt->data, avpkt->size);
+ memset(buf + avpkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+
+ p->state = STATE_SETTING_UP;
+ pthread_cond_signal(&p->input_cond);
+ pthread_mutex_unlock(&p->mutex);
+
+ /*
+ * If the client doesn't have a thread-safe get_buffer(),
+ * then decoding threads call back to the main thread,
+ * and it calls back to the client here.
+ */
+
+ if (!p->avctx->thread_safe_callbacks &&
+ p->avctx->get_buffer != avcodec_default_get_buffer) {
+ while (p->state != STATE_SETUP_FINISHED && p->state != STATE_INPUT_READY) {
+ pthread_mutex_lock(&p->progress_mutex);
+ while (p->state == STATE_SETTING_UP)
+ pthread_cond_wait(&p->progress_cond, &p->progress_mutex);
+
+ if (p->state == STATE_GET_BUFFER) {
+ p->result = p->avctx->get_buffer(p->avctx, p->requested_frame);
+ p->state = STATE_SETTING_UP;
+ pthread_cond_signal(&p->progress_cond);
+ }
+ pthread_mutex_unlock(&p->progress_mutex);
+ }
+ }
+
+ fctx->prev_thread = p;
+
+ return 0;
+}
+
+int ff_thread_decode_frame(AVCodecContext *avctx,
+ AVFrame *picture, int *got_picture_ptr,
+ AVPacket *avpkt)
+{
+ FrameThreadContext *fctx = avctx->thread_opaque;
+ int finished = fctx->next_finished;
+ PerThreadContext *p;
+ int err;
+
+ /*
+ * Submit a packet to the next decoding thread.
+ */
+
+ p = &fctx->threads[fctx->next_decoding];
+ update_context_from_user(p->avctx, avctx);
+ err = submit_packet(p, avpkt);
+ if (err) return err;
+
+ fctx->next_decoding++;
+
+ /*
+ * If we're still receiving the initial packets, don't return a frame.
+ */
+
+ if (fctx->delaying && avpkt->size) {
+ if (fctx->next_decoding >= (avctx->thread_count-1)) fctx->delaying = 0;
+
+ *got_picture_ptr=0;
+ return 0;
+ }
+
+ /*
+ * Return the next available frame from the oldest thread.
+ * If we're at the end of the stream, then we have to skip threads that
+ * didn't output a frame, because we don't want to accidentally signal
+ * EOF (avpkt->size == 0 && *got_picture_ptr == 0).
+ */
+
+ do {
+ p = &fctx->threads[finished++];
+
+ if (p->state != STATE_INPUT_READY) {
+ pthread_mutex_lock(&p->progress_mutex);
+ while (p->state != STATE_INPUT_READY)
+ pthread_cond_wait(&p->output_cond, &p->progress_mutex);
+ pthread_mutex_unlock(&p->progress_mutex);
+ }
+
+ *picture = p->frame;
+ *got_picture_ptr = p->got_frame;
+ picture->pkt_dts = p->avpkt.dts;
+
+ /*
+ * A later call with avkpt->size == 0 may loop over all threads,
+ * including this one, searching for a frame to return before being
+ * stopped by the "finished != fctx->next_finished" condition.
+ * Make sure we don't mistakenly return the same frame again.
+ */
+ p->got_frame = 0;
+
+ if (finished >= avctx->thread_count) finished = 0;
+ } while (!avpkt->size && !*got_picture_ptr && finished != fctx->next_finished);
+
+ update_context_from_thread(avctx, p->avctx, 1);
+
+ if (fctx->next_decoding >= avctx->thread_count) fctx->next_decoding = 0;
+
+ fctx->next_finished = finished;
+
+ return p->result;
+}
+
+void ff_thread_report_progress(AVFrame *f, int n, int field)
+{
+ PerThreadContext *p;
+ int *progress = f->thread_opaque;
+
+ if (!progress || progress[field] >= n) return;
+
+ p = f->owner->thread_opaque;
+
+ if (f->owner->debug&FF_DEBUG_THREADS)
+ av_log(f->owner, AV_LOG_DEBUG, "%p finished %d field %d\n", progress, n, field);
+
+ pthread_mutex_lock(&p->progress_mutex);
+ progress[field] = n;
+ pthread_cond_broadcast(&p->progress_cond);
+ pthread_mutex_unlock(&p->progress_mutex);
+}
+
+void ff_thread_await_progress(AVFrame *f, int n, int field)
+{
+ PerThreadContext *p;
+ int *progress = f->thread_opaque;
+
+ if (!progress || progress[field] >= n) return;
+
+ p = f->owner->thread_opaque;
+
+ if (f->owner->debug&FF_DEBUG_THREADS)
+ av_log(f->owner, AV_LOG_DEBUG, "thread awaiting %d field %d from %p\n", n, field, progress);
+
+ pthread_mutex_lock(&p->progress_mutex);
+ while (progress[field] < n)
+ pthread_cond_wait(&p->progress_cond, &p->progress_mutex);
+ pthread_mutex_unlock(&p->progress_mutex);
+}
+
+void ff_thread_finish_setup(AVCodecContext *avctx) {
+ PerThreadContext *p = avctx->thread_opaque;
+
+ if (!(avctx->active_thread_type&FF_THREAD_FRAME)) return;
+
+ pthread_mutex_lock(&p->progress_mutex);
+ p->state = STATE_SETUP_FINISHED;
+ pthread_cond_broadcast(&p->progress_cond);
+ pthread_mutex_unlock(&p->progress_mutex);
+}
+
+/// Waits for all threads to finish.
+static void park_frame_worker_threads(FrameThreadContext *fctx, int thread_count)
+{
+ int i;
+
+ for (i = 0; i < thread_count; i++) {
+ PerThreadContext *p = &fctx->threads[i];
+
+ if (p->state != STATE_INPUT_READY) {
+ pthread_mutex_lock(&p->progress_mutex);
+ while (p->state != STATE_INPUT_READY)
+ pthread_cond_wait(&p->output_cond, &p->progress_mutex);
+ pthread_mutex_unlock(&p->progress_mutex);
+ }
+ }
+}
+
+static void frame_thread_free(AVCodecContext *avctx, int thread_count)
+{
+ FrameThreadContext *fctx = avctx->thread_opaque;
+ AVCodec *codec = avctx->codec;
+ int i;
+
+ park_frame_worker_threads(fctx, thread_count);
+
+ if (fctx->prev_thread)
+ update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0);
+
+ fctx->die = 1;
+
+ for (i = 0; i < thread_count; i++) {
+ PerThreadContext *p = &fctx->threads[i];
+
+ pthread_mutex_lock(&p->mutex);
+ pthread_cond_signal(&p->input_cond);
+ pthread_mutex_unlock(&p->mutex);
+
+ pthread_join(p->thread, NULL);
+
+ if (codec->close)
+ codec->close(p->avctx);
+
+ avctx->codec = NULL;
+
+ release_delayed_buffers(p);
+ }
+
+ for (i = 0; i < thread_count; i++) {
+ PerThreadContext *p = &fctx->threads[i];
+
+ avcodec_default_free_buffers(p->avctx);
+
+ pthread_mutex_destroy(&p->mutex);
+ pthread_mutex_destroy(&p->progress_mutex);
+ pthread_cond_destroy(&p->input_cond);
+ pthread_cond_destroy(&p->progress_cond);
+ pthread_cond_destroy(&p->output_cond);
+ av_freep(&p->avpkt.data);
+
+ if (i)
+ av_freep(&p->avctx->priv_data);
+
+ av_freep(&p->avctx);
+ }
+
+ av_freep(&fctx->threads);
+ pthread_mutex_destroy(&fctx->buffer_mutex);
+ av_freep(&avctx->thread_opaque);
+}
+
+static int frame_thread_init(AVCodecContext *avctx)
+{
+ int thread_count = avctx->thread_count;
+ AVCodec *codec = avctx->codec;
+ AVCodecContext *src = avctx;
+ FrameThreadContext *fctx;
+ int i, err = 0;
+
+ if (thread_count <= 1) {
+ avctx->active_thread_type = 0;
+ return 0;
+ }
+
+ avctx->thread_opaque = fctx = av_mallocz(sizeof(FrameThreadContext));
+
+ fctx->threads = av_mallocz(sizeof(PerThreadContext) * thread_count);
+ pthread_mutex_init(&fctx->buffer_mutex, NULL);
+ fctx->delaying = 1;
+
+ for (i = 0; i < thread_count; i++) {
+ AVCodecContext *copy = av_malloc(sizeof(AVCodecContext));
+ PerThreadContext *p = &fctx->threads[i];
+
+ pthread_mutex_init(&p->mutex, NULL);
+ pthread_mutex_init(&p->progress_mutex, NULL);
+ pthread_cond_init(&p->input_cond, NULL);
+ pthread_cond_init(&p->progress_cond, NULL);
+ pthread_cond_init(&p->output_cond, NULL);
+
+ p->parent = fctx;
+ p->avctx = copy;
+
+ *copy = *src;
+ copy->thread_opaque = p;
+ copy->pkt = &p->avpkt;
+
+ if (!i) {
+ src = copy;
+
+ if (codec->init)
+ err = codec->init(copy);
+
+ update_context_from_thread(avctx, copy, 1);
+ } else {
+ copy->is_copy = 1;
+ copy->priv_data = av_malloc(codec->priv_data_size);
+ memcpy(copy->priv_data, src->priv_data, codec->priv_data_size);
+
+ if (codec->init_thread_copy)
+ err = codec->init_thread_copy(copy);
+ }
+
+ if (err) goto error;
+
+ pthread_create(&p->thread, NULL, frame_worker_thread, p);
+ }
+
+ return 0;
+
+error:
+ frame_thread_free(avctx, i+1);
+
+ return err;
+}
+
+void ff_thread_flush(AVCodecContext *avctx)
+{
+ FrameThreadContext *fctx = avctx->thread_opaque;
+
+ if (!avctx->thread_opaque) return;
+
+ park_frame_worker_threads(fctx, avctx->thread_count);
+
+ if (fctx->prev_thread)
+ update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0);
+
+ fctx->next_decoding = fctx->next_finished = 0;
+ fctx->delaying = 1;
+ fctx->prev_thread = NULL;
+}
+
+static int *allocate_progress(PerThreadContext *p)
+{
+ int i;
+
+ for (i = 0; i < MAX_BUFFERS; i++)
+ if (!p->progress_used[i]) break;
+
+ if (i == MAX_BUFFERS) {
+ av_log(p->avctx, AV_LOG_ERROR, "allocate_progress() overflow\n");
+ return NULL;
+ }
+
+ p->progress_used[i] = 1;
+
+ return p->progress[i];
+}
+
+int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
+{
+ PerThreadContext *p = avctx->thread_opaque;
+ int *progress, err;
+
+ f->owner = avctx;
+
+ if (!(avctx->active_thread_type&FF_THREAD_FRAME)) {
+ f->thread_opaque = NULL;
+ return avctx->get_buffer(avctx, f);
+ }
+
+ if (p->state != STATE_SETTING_UP &&
+ (avctx->codec->update_thread_context || !avctx->thread_safe_callbacks)) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n");
+ return -1;
+ }
+
+ pthread_mutex_lock(&p->parent->buffer_mutex);
+ f->thread_opaque = progress = allocate_progress(p);
+
+ if (!progress) {
+ pthread_mutex_unlock(&p->parent->buffer_mutex);
+ return -1;
+ }
+
+ progress[0] =
+ progress[1] = -1;
+
+ if (avctx->thread_safe_callbacks ||
+ avctx->get_buffer == avcodec_default_get_buffer) {
+ err = avctx->get_buffer(avctx, f);
+ } else {
+ p->requested_frame = f;
+ p->state = STATE_GET_BUFFER;
+ pthread_mutex_lock(&p->progress_mutex);
+ pthread_cond_signal(&p->progress_cond);
+
+ while (p->state != STATE_SETTING_UP)
+ pthread_cond_wait(&p->progress_cond, &p->progress_mutex);
+
+ err = p->result;
+
+ pthread_mutex_unlock(&p->progress_mutex);
+
+ if (!avctx->codec->update_thread_context)
+ ff_thread_finish_setup(avctx);
+ }
+
+ pthread_mutex_unlock(&p->parent->buffer_mutex);
+
+ /*
+ * Buffer age is difficult to keep track of between
+ * multiple threads, and the optimizations it allows
+ * are not worth the effort. It is disabled for now.
+ */
+ f->age = INT_MAX;
+
+ return err;
+}
+
+void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
+{
+ PerThreadContext *p = avctx->thread_opaque;
+
+ if (!(avctx->active_thread_type&FF_THREAD_FRAME)) {
+ avctx->release_buffer(avctx, f);
+ return;
+ }
+
+ if (p->num_released_buffers >= MAX_BUFFERS) {
+ av_log(p->avctx, AV_LOG_ERROR, "too many thread_release_buffer calls!\n");
+ return;
+ }
+
+ if(avctx->debug & FF_DEBUG_BUFFERS)
+ av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on pic %p, %d buffers used\n",
+ f, f->owner->internal_buffer_count);
+
+ p->released_buffers[p->num_released_buffers++] = *f;
+ memset(f->data, 0, sizeof(f->data));
+}
+
+/**
+ * Set the threading algorithms used.
+ *
+ * Threading requires more than one thread.
+ * Frame threading requires entire frames to be passed to the codec,
+ * and introduces extra decoding delay, so is incompatible with low_delay.
+ *
+ * @param avctx The context.
+ */
+static void validate_thread_parameters(AVCodecContext *avctx)
+{
+ int frame_threading_supported = (avctx->codec->capabilities & CODEC_CAP_FRAME_THREADS)
+ && !(avctx->flags & CODEC_FLAG_TRUNCATED)
+ && !(avctx->flags & CODEC_FLAG_LOW_DELAY)
+ && !(avctx->flags2 & CODEC_FLAG2_CHUNKS);
+ if (avctx->thread_count == 1) {
+ avctx->active_thread_type = 0;
+ } else if (frame_threading_supported && (avctx->thread_type & FF_THREAD_FRAME)) {
+ avctx->active_thread_type = FF_THREAD_FRAME;
+ } else {
+ avctx->active_thread_type = FF_THREAD_SLICE;
+ }
+}
+
+int ff_thread_init(AVCodecContext *avctx, int thread_count)
+{
+ if (avctx->thread_opaque) {
+ av_log(avctx, AV_LOG_ERROR, "avcodec_thread_init is ignored after avcodec_open\n");
+ return -1;
+ }
+
+ if (avctx->codec) {
+ validate_thread_parameters(avctx);
+
+ if (avctx->active_thread_type&FF_THREAD_SLICE)
+ return thread_init(avctx);
+ else if (avctx->active_thread_type&FF_THREAD_FRAME)
+ return frame_thread_init(avctx);
+ }
+
+ return 0;
+}
+
+void ff_thread_free(AVCodecContext *avctx)
+{
+ if (avctx->active_thread_type&FF_THREAD_FRAME)
+ frame_thread_free(avctx, avctx->thread_count);
+ else
+ thread_free(avctx);
+}
diff --git a/mplayer/ffmpeg/libavcodec/ptx.c b/mplayer/ffmpeg/libavcodec/ptx.c
index 86b06b4a..28df0b6f 100644
--- a/mplayer/ffmpeg/libavcodec/ptx.c
+++ b/mplayer/ffmpeg/libavcodec/ptx.c
@@ -20,7 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
typedef struct PTXContext {
diff --git a/mplayer/ffmpeg/libavcodec/qtrleenc.c b/mplayer/ffmpeg/libavcodec/qtrleenc.c
index 78149e5e..8815736e 100644
--- a/mplayer/ffmpeg/libavcodec/qtrleenc.c
+++ b/mplayer/ffmpeg/libavcodec/qtrleenc.c
@@ -22,7 +22,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
diff --git a/mplayer/ffmpeg/libavcodec/rawdec.c b/mplayer/ffmpeg/libavcodec/rawdec.c
index 29cc5e44..baffceb5 100644
--- a/mplayer/ffmpeg/libavcodec/rawdec.c
+++ b/mplayer/ffmpeg/libavcodec/rawdec.c
@@ -28,8 +28,7 @@
#include "imgconvert.h"
#include "raw.h"
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
-#include "libavcore/internal.h"
+#include "libavutil/imgutils.h"
typedef struct RawVideoContext {
uint32_t palette[AVPALETTE_COUNT];
diff --git a/mplayer/ffmpeg/libavcodec/resample.c b/mplayer/ffmpeg/libavcodec/resample.c
index 27283152..45fba69f 100644
--- a/mplayer/ffmpeg/libavcodec/resample.c
+++ b/mplayer/ffmpeg/libavcodec/resample.c
@@ -27,7 +27,7 @@
#include "avcodec.h"
#include "audioconvert.h"
#include "libavutil/opt.h"
-#include "libavcore/samplefmt.h"
+#include "libavutil/samplefmt.h"
struct AVResampleContext;
diff --git a/mplayer/ffmpeg/libavcodec/rv10.c b/mplayer/ffmpeg/libavcodec/rv10.c
index f47540d8..e6e9afaf 100644
--- a/mplayer/ffmpeg/libavcodec/rv10.c
+++ b/mplayer/ffmpeg/libavcodec/rv10.c
@@ -25,7 +25,7 @@
* RV10/RV20 decoder
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
diff --git a/mplayer/ffmpeg/libavcodec/rv40.c b/mplayer/ffmpeg/libavcodec/rv40.c
index acebeb7d..5d4aafc0 100644
--- a/mplayer/ffmpeg/libavcodec/rv40.c
+++ b/mplayer/ffmpeg/libavcodec/rv40.c
@@ -24,7 +24,7 @@
* RV40 decoder
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
diff --git a/mplayer/ffmpeg/libavcodec/sgidec.c b/mplayer/ffmpeg/libavcodec/sgidec.c
index ac2adfe7..96af5c6f 100644
--- a/mplayer/ffmpeg/libavcodec/sgidec.c
+++ b/mplayer/ffmpeg/libavcodec/sgidec.c
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "sgi.h"
diff --git a/mplayer/ffmpeg/libavcodec/smacker.c b/mplayer/ffmpeg/libavcodec/smacker.c
index 2fcc3351..e3f00b84 100644
--- a/mplayer/ffmpeg/libavcodec/smacker.c
+++ b/mplayer/ffmpeg/libavcodec/smacker.c
@@ -32,6 +32,7 @@
#include
#include "avcodec.h"
+#include "libavutil/audioconvert.h"
#define ALT_BITSTREAM_READER_LE
#include "get_bits.h"
@@ -554,7 +555,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
static av_cold int smka_decode_init(AVCodecContext *avctx)
{
- avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
+ avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? AV_SAMPLE_FMT_U8 : AV_SAMPLE_FMT_S16;
return 0;
}
@@ -677,12 +678,9 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
for(i = 0; i < 4; i++) {
if(vlc[i].table)
free_vlc(&vlc[i]);
- if(h[i].bits)
- av_free(h[i].bits);
- if(h[i].lengths)
- av_free(h[i].lengths);
- if(h[i].values)
- av_free(h[i].values);
+ av_free(h[i].bits);
+ av_free(h[i].lengths);
+ av_free(h[i].values);
}
*data_size = unp_size;
diff --git a/mplayer/ffmpeg/libavcodec/srtdec.c b/mplayer/ffmpeg/libavcodec/srtdec.c
index 30fdc12f..af03cc4d 100644
--- a/mplayer/ffmpeg/libavcodec/srtdec.c
+++ b/mplayer/ffmpeg/libavcodec/srtdec.c
@@ -20,7 +20,7 @@
*/
#include "libavutil/avstring.h"
-#include "libavcore/parseutils.h"
+#include "libavutil/parseutils.h"
#include "avcodec.h"
#include "ass.h"
diff --git a/mplayer/ffmpeg/libavcodec/sunrast.c b/mplayer/ffmpeg/libavcodec/sunrast.c
index 76b65b35..73e4b5b9 100644
--- a/mplayer/ffmpeg/libavcodec/sunrast.c
+++ b/mplayer/ffmpeg/libavcodec/sunrast.c
@@ -20,7 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#define RT_OLD 0
diff --git a/mplayer/ffmpeg/libavcodec/synth_filter.c b/mplayer/ffmpeg/libavcodec/synth_filter.c
index a0ae364d..4af496d3 100644
--- a/mplayer/ffmpeg/libavcodec/synth_filter.c
+++ b/mplayer/ffmpeg/libavcodec/synth_filter.c
@@ -24,7 +24,7 @@
static void synth_filter_float(FFTContext *imdct,
float *synth_buf_ptr, int *synth_buf_offset,
float synth_buf2[32], const float window[512],
- float out[32], const float in[32], float scale, float bias)
+ float out[32], const float in[32], float scale)
{
float *synth_buf= synth_buf_ptr + *synth_buf_offset;
int i, j;
@@ -48,8 +48,8 @@ static void synth_filter_float(FFTContext *imdct,
c += window[i + j + 32]*( synth_buf[16 + i + j - 512]);
d += window[i + j + 48]*( synth_buf[31 - i + j - 512]);
}
- out[i ] = a*scale + bias;
- out[i + 16] = b*scale + bias;
+ out[i ] = a*scale;
+ out[i + 16] = b*scale;
synth_buf2[i ] = c;
synth_buf2[i + 16] = d;
}
diff --git a/mplayer/ffmpeg/libavcodec/synth_filter.h b/mplayer/ffmpeg/libavcodec/synth_filter.h
index d6209d5d..33edcc43 100644
--- a/mplayer/ffmpeg/libavcodec/synth_filter.h
+++ b/mplayer/ffmpeg/libavcodec/synth_filter.h
@@ -28,7 +28,7 @@ typedef struct SynthFilterContext {
float *synth_buf_ptr, int *synth_buf_offset,
float synth_buf2[32], const float window[512],
float out[32], const float in[32],
- float scale, float bias);
+ float scale);
} SynthFilterContext;
void ff_synth_filter_init(SynthFilterContext *c);
diff --git a/mplayer/ffmpeg/libavcodec/targa.c b/mplayer/ffmpeg/libavcodec/targa.c
index e6e1ca6f..3c220f40 100644
--- a/mplayer/ffmpeg/libavcodec/targa.c
+++ b/mplayer/ffmpeg/libavcodec/targa.c
@@ -20,7 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "targa.h"
@@ -33,22 +33,35 @@ typedef struct TargaContext {
int compression_type;
} TargaContext;
-static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_t *src, uint8_t *dst, int w, int h, int stride, int bpp)
+#define CHECK_BUFFER_SIZE(buf, buf_end, needed, where) \
+ if(needed > buf_end - buf){ \
+ av_log(avctx, AV_LOG_ERROR, "Problem: unexpected end of data while reading " where "\n"); \
+ return -1; \
+ } \
+
+static int targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_t *src, int src_size, uint8_t *dst, int w, int h, int stride, int bpp)
{
int i, x, y;
int depth = (bpp + 1) >> 3;
int type, count;
int diff;
+ const uint8_t *src_end = src + src_size;
diff = stride - w * depth;
x = y = 0;
while(y < h){
+ CHECK_BUFFER_SIZE(src, src_end, 1, "image type");
type = *src++;
count = (type & 0x7F) + 1;
type &= 0x80;
if((x + count > w) && (x + count + 1 > (h - y) * w)){
av_log(avctx, AV_LOG_ERROR, "Packet went out of bounds: position (%i,%i) size %i\n", x, y, count);
- return;
+ return -1;
+ }
+ if(type){
+ CHECK_BUFFER_SIZE(src, src_end, depth, "image data");
+ }else{
+ CHECK_BUFFER_SIZE(src, src_end, count * depth, "image data");
}
for(i = 0; i < count; i++){
switch(depth){
@@ -81,6 +94,7 @@ static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8
if(type)
src += depth;
}
+ return src_size;
}
static int decode_frame(AVCodecContext *avctx,
@@ -88,7 +102,7 @@ static int decode_frame(AVCodecContext *avctx,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
+ const uint8_t *buf_end = avpkt->data + avpkt->size;
TargaContext * const s = avctx->priv_data;
AVFrame *picture = data;
AVFrame * const p= (AVFrame*)&s->picture;
@@ -98,6 +112,7 @@ static int decode_frame(AVCodecContext *avctx,
int first_clr, colors, csize;
/* parse image header */
+ CHECK_BUFFER_SIZE(buf, buf_end, 18, "header");
idlen = *buf++;
pal = *buf++;
compr = *buf++;
@@ -111,6 +126,7 @@ static int decode_frame(AVCodecContext *avctx,
bpp = *buf++;
flags = *buf++;
//skip identifier if any
+ CHECK_BUFFER_SIZE(buf, buf_end, idlen, "identifiers");
buf += idlen;
s->bpp = bpp;
s->width = w;
@@ -163,6 +179,7 @@ static int decode_frame(AVCodecContext *avctx,
}
}
if(colors){
+ size_t pal_size;
if((colors + first_clr) > 256){
av_log(avctx, AV_LOG_ERROR, "Incorrect palette: %i colors with offset %i\n", colors, first_clr);
return -1;
@@ -171,8 +188,10 @@ static int decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "Palette entry size %i bits is not supported\n", csize);
return -1;
}
+ pal_size = colors * ((csize + 1) >> 3);
+ CHECK_BUFFER_SIZE(buf, buf_end, pal_size, "color table");
if(avctx->pix_fmt != PIX_FMT_PAL8)//should not occur but skip palette anyway
- buf += colors * ((csize + 1) >> 3);
+ buf += pal_size;
else{
int r, g, b, t;
int32_t *pal = ((int32_t*)p->data[1]) + first_clr;
@@ -188,9 +207,14 @@ static int decode_frame(AVCodecContext *avctx,
if((compr & (~TGA_RLE)) == TGA_NODATA)
memset(p->data[0], 0, p->linesize[0] * s->height);
else{
- if(compr & TGA_RLE)
- targa_decode_rle(avctx, s, buf, dst, avctx->width, avctx->height, stride, bpp);
- else{
+ if(compr & TGA_RLE){
+ int res = targa_decode_rle(avctx, s, buf, buf_end - buf, dst, avctx->width, avctx->height, stride, bpp);
+ if (res < 0)
+ return -1;
+ buf += res;
+ }else{
+ size_t img_size = s->width * ((s->bpp + 1) >> 3);
+ CHECK_BUFFER_SIZE(buf, buf_end, img_size, "image data");
for(y = 0; y < s->height; y++){
#if HAVE_BIGENDIAN
if((s->bpp + 1) >> 3 == 2){
@@ -203,10 +227,10 @@ static int decode_frame(AVCodecContext *avctx,
dst32[x] = AV_RL32(buf + x * 4);
}else
#endif
- memcpy(dst, buf, s->width * ((s->bpp + 1) >> 3));
+ memcpy(dst, buf, img_size);
dst += stride;
- buf += s->width * ((s->bpp + 1) >> 3);
+ buf += img_size;
}
}
}
@@ -214,7 +238,7 @@ static int decode_frame(AVCodecContext *avctx,
*picture= *(AVFrame*)&s->picture;
*data_size = sizeof(AVPicture);
- return buf_size;
+ return avpkt->size;
}
static av_cold int targa_init(AVCodecContext *avctx){
diff --git a/mplayer/ffmpeg/libavcodec/thread.h b/mplayer/ffmpeg/libavcodec/thread.h
new file mode 100644
index 00000000..485f4ec1
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/thread.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2008 Alexander Strange
+ *
+ * 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
+ * Multithreading support functions
+ * @author Alexander Strange
+ */
+
+#ifndef AVCODEC_THREAD_H
+#define AVCODEC_THREAD_H
+
+#include "config.h"
+#include "avcodec.h"
+
+/**
+ * Waits for decoding threads to finish and resets internal
+ * state. Called by avcodec_flush_buffers().
+ *
+ * @param avctx The context.
+ */
+void ff_thread_flush(AVCodecContext *avctx);
+
+/**
+ * Submits a new frame to a decoding thread.
+ * Returns the next available frame in picture. *got_picture_ptr
+ * will be 0 if none is available.
+ *
+ * Parameters are the same as avcodec_decode_video2().
+ */
+int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture,
+ int *got_picture_ptr, AVPacket *avpkt);
+
+/**
+ * If the codec defines update_thread_context(), call this
+ * when they are ready for the next thread to start decoding
+ * the next frame. After calling it, do not change any variables
+ * read by the update_thread_context() method, or call ff_thread_get_buffer().
+ *
+ * @param avctx The context.
+ */
+void ff_thread_finish_setup(AVCodecContext *avctx);
+
+/**
+ * Notifies later decoding threads when part of their reference picture
+ * is ready.
+ * Call this when some part of the picture is finished decoding.
+ * Later calls with lower values of progress have no effect.
+ *
+ * @param f The picture being decoded.
+ * @param progress Value, in arbitrary units, of how much of the picture has decoded.
+ * @param field The field being decoded, for field-picture codecs.
+ * 0 for top field or frame pictures, 1 for bottom field.
+ */
+void ff_thread_report_progress(AVFrame *f, int progress, int field);
+
+/**
+ * Waits for earlier decoding threads to finish reference pictures
+ * Call this before accessing some part of a picture, with a given
+ * value for progress, and it will return after the responsible decoding
+ * thread calls ff_thread_report_progress() with the same or
+ * higher value for progress.
+ *
+ * @param f The picture being referenced.
+ * @param progress Value, in arbitrary units, to wait for.
+ * @param field The field being referenced, for field-picture codecs.
+ * 0 for top field or frame pictures, 1 for bottom field.
+ */
+void ff_thread_await_progress(AVFrame *f, int progress, int field);
+
+/**
+ * Wrapper around get_buffer() for frame-multithreaded codecs.
+ * Call this function instead of avctx->get_buffer(f).
+ * Cannot be called after the codec has called ff_thread_finish_setup().
+ *
+ * @param avctx The current context.
+ * @param f The frame to write into.
+ */
+int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f);
+
+/**
+ * Wrapper around release_buffer() frame-for multithreaded codecs.
+ * Call this function instead of avctx->release_buffer(f).
+ * The AVFrame will be copied and the actual release_buffer() call
+ * will be performed later. The contents of data pointed to by the
+ * AVFrame should not be changed until ff_thread_get_buffer() is called
+ * on it.
+ *
+ * @param avctx The current context.
+ * @param f The picture being released.
+ */
+void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f);
+
+int ff_thread_init(AVCodecContext *s, int thread_count);
+void ff_thread_free(AVCodecContext *s);
+
+#endif /* AVCODEC_THREAD_H */
diff --git a/mplayer/ffmpeg/libavcodec/tiff.c b/mplayer/ffmpeg/libavcodec/tiff.c
index b012baa9..8295a4b4 100644
--- a/mplayer/ffmpeg/libavcodec/tiff.c
+++ b/mplayer/ffmpeg/libavcodec/tiff.c
@@ -33,7 +33,7 @@
#include "faxcompr.h"
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
typedef struct TiffContext {
AVCodecContext *avctx;
diff --git a/mplayer/ffmpeg/libavcodec/truemotion1.c b/mplayer/ffmpeg/libavcodec/truemotion1.c
index 448da84c..c7d414a6 100644
--- a/mplayer/ffmpeg/libavcodec/truemotion1.c
+++ b/mplayer/ffmpeg/libavcodec/truemotion1.c
@@ -35,7 +35,7 @@
#include "avcodec.h"
#include "dsputil.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "truemotion1data.h"
diff --git a/mplayer/ffmpeg/libavcodec/truemotion2.c b/mplayer/ffmpeg/libavcodec/truemotion2.c
index d20ee94b..86454ec2 100644
--- a/mplayer/ffmpeg/libavcodec/truemotion2.c
+++ b/mplayer/ffmpeg/libavcodec/truemotion2.c
@@ -185,8 +185,7 @@ static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
static void tm2_free_codes(TM2Codes *code)
{
- if(code->recode)
- av_free(code->recode);
+ av_free(code->recode);
if(code->vlc.table)
free_vlc(&code->vlc);
}
@@ -859,13 +858,10 @@ static av_cold int decode_end(AVCodecContext *avctx){
AVFrame *pic = &l->pic;
int i;
- if(l->last)
- av_free(l->last);
- if(l->clast)
- av_free(l->clast);
+ av_free(l->last);
+ av_free(l->clast);
for(i = 0; i < TM2_NUM_STREAMS; i++)
- if(l->tokens[i])
- av_free(l->tokens[i]);
+ av_free(l->tokens[i]);
if(l->Y1){
av_free(l->Y1);
av_free(l->U1);
diff --git a/mplayer/ffmpeg/libavcodec/tta.c b/mplayer/ffmpeg/libavcodec/tta.c
index 936dff23..eb4d71ff 100644
--- a/mplayer/ffmpeg/libavcodec/tta.c
+++ b/mplayer/ffmpeg/libavcodec/tta.c
@@ -449,8 +449,7 @@ static int tta_decode_frame(AVCodecContext *avctx,
static av_cold int tta_decode_close(AVCodecContext *avctx) {
TTAContext *s = avctx->priv_data;
- if (s->decode_buffer)
- av_free(s->decode_buffer);
+ av_free(s->decode_buffer);
av_freep(&s->ch_ctx);
return 0;
diff --git a/mplayer/ffmpeg/libavcodec/twinvq.c b/mplayer/ffmpeg/libavcodec/twinvq.c
index 8334e83d..bd43104e 100644
--- a/mplayer/ffmpeg/libavcodec/twinvq.c
+++ b/mplayer/ffmpeg/libavcodec/twinvq.c
@@ -646,7 +646,6 @@ static void imdct_and_window(TwinContext *tctx, enum FrameType ftype, int wtype,
prev_buf + (bsize-wsize)/2,
buf1 + bsize*j,
ff_sine_windows[av_log2(wsize)],
- 0.0,
wsize/2);
out2 += wsize;
diff --git a/mplayer/ffmpeg/libavcodec/txd.c b/mplayer/ffmpeg/libavcodec/txd.c
index b394e1f5..da1f5c1e 100644
--- a/mplayer/ffmpeg/libavcodec/txd.c
+++ b/mplayer/ffmpeg/libavcodec/txd.c
@@ -22,7 +22,7 @@
*/
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "s3tc.h"
diff --git a/mplayer/ffmpeg/libavcodec/utils.c b/mplayer/ffmpeg/libavcodec/utils.c
index 53a06743..03fa7bae 100644
--- a/mplayer/ffmpeg/libavcodec/utils.c
+++ b/mplayer/ffmpeg/libavcodec/utils.c
@@ -29,14 +29,14 @@
#include "libavutil/integer.h"
#include "libavutil/crc.h"
#include "libavutil/pixdesc.h"
-#include "libavcore/audioconvert.h"
-#include "libavcore/imgutils.h"
-#include "libavcore/internal.h"
-#include "libavcore/samplefmt.h"
+#include "libavutil/audioconvert.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/samplefmt.h"
#include "avcodec.h"
#include "dsputil.h"
#include "libavutil/opt.h"
#include "imgconvert.h"
+#include "thread.h"
#include "audioconvert.h"
#include "internal.h"
#include
@@ -261,6 +261,11 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
(*picture_number)++;
if(buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)){
+ if(s->active_thread_type&FF_THREAD_FRAME) {
+ av_log_missing_feature(s, "Width/height changing with frame threads is", 0);
+ return -1;
+ }
+
for(i=0; i<4; i++){
av_freep(&buf->base[i]);
buf->data[i]= NULL;
@@ -396,6 +401,8 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){
/* If internal buffer type return the same buffer */
if(pic->type == FF_BUFFER_TYPE_INTERNAL) {
+ if(s->pkt) pic->pkt_pts= s->pkt->pts;
+ else pic->pkt_pts= AV_NOPTS_VALUE;
pic->reordered_opaque= s->reordered_opaque;
return 0;
}
@@ -530,13 +537,31 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
goto free_and_end;
}
avctx->frame_number = 0;
+
+ if (HAVE_THREADS && !avctx->thread_opaque) {
+ ret = ff_thread_init(avctx, avctx->thread_count);
+ if (ret < 0) {
+ goto free_and_end;
+ }
+ }
+
if (avctx->codec->max_lowres < avctx->lowres) {
av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
avctx->codec->max_lowres);
goto free_and_end;
}
+ if (avctx->codec->sample_fmts && avctx->codec->encode) {
+ int i;
+ for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
+ if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
+ break;
+ if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
+ av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
+ goto free_and_end;
+ }
+ }
- if(avctx->codec->init){
+ if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){
ret = avctx->codec->init(avctx);
if (ret < 0) {
goto free_and_end;
@@ -634,14 +659,18 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
avctx->pkt = avpkt;
- if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){
- ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
- avpkt);
+ if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){
+ if (HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME)
+ ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
+ avpkt);
+ else {
+ ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
+ avpkt);
+ picture->pkt_dts= avpkt->dts;
+ }
emms_c(); //needed to avoid an emms_c() call before every return;
- picture->pkt_dts= avpkt->dts;
-
if (*got_picture_ptr)
avctx->frame_number++;
}else
@@ -757,7 +786,7 @@ av_cold int avcodec_close(AVCodecContext *avctx)
}
if (HAVE_THREADS && avctx->thread_opaque)
- avcodec_thread_free(avctx);
+ ff_thread_free(avctx);
if (avctx->codec && avctx->codec->close)
avctx->codec->close(avctx);
avcodec_default_free_buffers(avctx);
@@ -766,6 +795,7 @@ av_cold int avcodec_close(AVCodecContext *avctx)
if(avctx->codec && avctx->codec->encode)
av_freep(&avctx->extradata);
avctx->codec = NULL;
+ avctx->active_thread_type = 0;
entangled_thread_counter--;
/* Release any user-supplied mutex. */
@@ -1027,6 +1057,8 @@ void avcodec_init(void)
void avcodec_flush_buffers(AVCodecContext *avctx)
{
+ if(HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME)
+ ff_thread_flush(avctx);
if(avctx->codec->flush)
avctx->codec->flush(avctx);
}
@@ -1115,7 +1147,7 @@ int av_get_bits_per_sample_format(enum AVSampleFormat sample_fmt) {
#endif
#if !HAVE_THREADS
-int avcodec_thread_init(AVCodecContext *s, int thread_count){
+int ff_thread_init(AVCodecContext *s, int thread_count){
s->thread_count = thread_count;
return -1;
}
@@ -1136,7 +1168,7 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
}
#if LIBAVCODEC_VERSION_MAJOR < 53
-#include "libavcore/parseutils.h"
+#include "libavutil/parseutils.h"
int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str)
{
@@ -1227,3 +1259,46 @@ unsigned int ff_toupper4(unsigned int x)
+ (toupper((x>>16)&0xFF)<<16)
+ (toupper((x>>24)&0xFF)<<24);
}
+
+#if !HAVE_PTHREADS
+
+int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
+{
+ f->owner = avctx;
+ return avctx->get_buffer(avctx, f);
+}
+
+void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
+{
+ f->owner->release_buffer(f->owner, f);
+}
+
+void ff_thread_finish_setup(AVCodecContext *avctx)
+{
+}
+
+void ff_thread_report_progress(AVFrame *f, int progress, int field)
+{
+}
+
+void ff_thread_await_progress(AVFrame *f, int progress, int field)
+{
+}
+
+#endif
+
+#if LIBAVCODEC_VERSION_MAJOR < 53
+
+int avcodec_thread_init(AVCodecContext *s, int thread_count)
+{
+ return ff_thread_init(s, thread_count);
+}
+
+void avcodec_thread_free(AVCodecContext *s)
+{
+#if HAVE_THREADS
+ ff_thread_free(s);
+#endif
+}
+
+#endif
diff --git a/mplayer/ffmpeg/libavcodec/vc1.c b/mplayer/ffmpeg/libavcodec/vc1.c
index 86904cbf..27cd0108 100644
--- a/mplayer/ffmpeg/libavcodec/vc1.c
+++ b/mplayer/ffmpeg/libavcodec/vc1.c
@@ -280,6 +280,28 @@ static int vop_dquant_decoding(VC1Context *v)
static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb);
+static void simple_idct_put_rangered(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ int i;
+ ff_simple_idct(block);
+ for (i = 0; i < 64; i++) block[i] = (block[i] - 64) << 1;
+ ff_put_pixels_clamped_c(block, dest, line_size);
+}
+
+static void simple_idct_put_signed(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ ff_simple_idct(block);
+ ff_put_signed_pixels_clamped_c(block, dest, line_size);
+}
+
+static void simple_idct_put_signed_rangered(uint8_t *dest, int line_size, DCTELEM *block)
+{
+ int i;
+ ff_simple_idct(block);
+ for (i = 0; i < 64; i++) block[i] <<= 1;
+ ff_put_signed_pixels_clamped_c(block, dest, line_size);
+}
+
/**
* Decode Simple/Main Profiles sequence header
* @see Figure 7-8, p16-17
@@ -293,7 +315,7 @@ int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitConte
v->profile = get_bits(gb, 2);
if (v->profile == PROFILE_COMPLEX)
{
- av_log(avctx, AV_LOG_ERROR, "WMV3 Complex Profile is not fully supported\n");
+ av_log(avctx, AV_LOG_WARNING, "WMV3 Complex Profile is not fully supported\n");
}
if (v->profile == PROFILE_ADVANCED)
@@ -337,14 +359,18 @@ int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitConte
v->res_fasttx = get_bits1(gb);
if (!v->res_fasttx)
{
- v->s.dsp.vc1_inv_trans_8x8 = ff_simple_idct;
- v->s.dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add;
- v->s.dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add;
- v->s.dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add;
- v->s.dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add;
- v->s.dsp.vc1_inv_trans_8x4_dc = ff_simple_idct84_add;
- v->s.dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add;
- v->s.dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add;
+ v->vc1dsp.vc1_inv_trans_8x8_add = ff_simple_idct_add;
+ v->vc1dsp.vc1_inv_trans_8x8_put[0] = ff_simple_idct_put;
+ v->vc1dsp.vc1_inv_trans_8x8_put[1] = simple_idct_put_rangered;
+ v->vc1dsp.vc1_inv_trans_8x8_put_signed[0] = simple_idct_put_signed;
+ v->vc1dsp.vc1_inv_trans_8x8_put_signed[1] = simple_idct_put_signed_rangered;
+ v->vc1dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add;
+ v->vc1dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add;
+ v->vc1dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add;
+ v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add;
+ v->vc1dsp.vc1_inv_trans_8x4_dc = ff_simple_idct84_add;
+ v->vc1dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add;
+ v->vc1dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add;
}
v->fastuvmc = get_bits1(gb); //common
diff --git a/mplayer/ffmpeg/libavcodec/vc1.h b/mplayer/ffmpeg/libavcodec/vc1.h
index e5a9cbae..d826c5a8 100644
--- a/mplayer/ffmpeg/libavcodec/vc1.h
+++ b/mplayer/ffmpeg/libavcodec/vc1.h
@@ -26,6 +26,7 @@
#include "avcodec.h"
#include "mpegvideo.h"
#include "intrax8.h"
+#include "vc1dsp.h"
/** Markers used in VC-1 AP frame data */
//@{
@@ -155,6 +156,7 @@ enum COTypes {
typedef struct VC1Context{
MpegEncContext s;
IntraX8Context x8;
+ VC1DSPContext vc1dsp;
int bits;
@@ -215,6 +217,7 @@ typedef struct VC1Context{
int k_y; ///< Number of bits for MVs (depends on MV range)
int range_x, range_y; ///< MV range
uint8_t pq, altpq; ///< Current/alternate frame quantizer scale
+ uint8_t zz_8x8[4][64];///< Zigzag table for TT_8x8, permuted for IDCT
const uint8_t* zz_8x4;///< Zigzag scan table for TT_8x4 coding mode
const uint8_t* zz_4x8;///< Zigzag scan table for TT_4x8 coding mode
/** pquant parameters */
diff --git a/mplayer/ffmpeg/libavcodec/vc1dec.c b/mplayer/ffmpeg/libavcodec/vc1dec.c
index 3bd2cce2..b27b6d01 100644
--- a/mplayer/ffmpeg/libavcodec/vc1dec.c
+++ b/mplayer/ffmpeg/libavcodec/vc1dec.c
@@ -160,62 +160,30 @@ enum Imode {
/** @} */ //Bitplane group
-static void vc1_loop_filter_iblk(MpegEncContext *s, int pq)
+static void vc1_loop_filter_iblk(VC1Context *v, int pq)
{
+ MpegEncContext *s = &v->s;
int j;
if (!s->first_slice_line) {
- s->dsp.vc1_v_loop_filter16(s->dest[0], s->linesize, pq);
+ v->vc1dsp.vc1_v_loop_filter16(s->dest[0], s->linesize, pq);
if (s->mb_x)
- s->dsp.vc1_h_loop_filter16(s->dest[0] - 16*s->linesize, s->linesize, pq);
- s->dsp.vc1_h_loop_filter16(s->dest[0] - 16*s->linesize+8, s->linesize, pq);
+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16*s->linesize, s->linesize, pq);
+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16*s->linesize+8, s->linesize, pq);
for(j = 0; j < 2; j++){
- s->dsp.vc1_v_loop_filter8(s->dest[j+1], s->uvlinesize, pq);
+ v->vc1dsp.vc1_v_loop_filter8(s->dest[j+1], s->uvlinesize, pq);
if (s->mb_x)
- s->dsp.vc1_h_loop_filter8(s->dest[j+1]-8*s->uvlinesize, s->uvlinesize, pq);
+ v->vc1dsp.vc1_h_loop_filter8(s->dest[j+1]-8*s->uvlinesize, s->uvlinesize, pq);
}
}
- s->dsp.vc1_v_loop_filter16(s->dest[0] + 8*s->linesize, s->linesize, pq);
+ v->vc1dsp.vc1_v_loop_filter16(s->dest[0] + 8*s->linesize, s->linesize, pq);
if (s->mb_y == s->mb_height-1) {
if (s->mb_x) {
- s->dsp.vc1_h_loop_filter16(s->dest[0], s->linesize, pq);
- s->dsp.vc1_h_loop_filter8(s->dest[1], s->uvlinesize, pq);
- s->dsp.vc1_h_loop_filter8(s->dest[2], s->uvlinesize, pq);
+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0], s->linesize, pq);
+ v->vc1dsp.vc1_h_loop_filter8(s->dest[1], s->uvlinesize, pq);
+ v->vc1dsp.vc1_h_loop_filter8(s->dest[2], s->uvlinesize, pq);
}
- s->dsp.vc1_h_loop_filter16(s->dest[0] + 8, s->linesize, pq);
- }
-}
-
-/** Put block onto picture
- */
-static void vc1_put_block(VC1Context *v, DCTELEM block[6][64])
-{
- uint8_t *Y;
- int ys, us, vs;
- DSPContext *dsp = &v->s.dsp;
-
- if(v->rangeredfrm) {
- int i, j, k;
- for(k = 0; k < 6; k++)
- for(j = 0; j < 8; j++)
- for(i = 0; i < 8; i++)
- block[k][i + j*8] = ((block[k][i + j*8] - 128) << 1) + 128;
-
- }
- ys = v->s.current_picture.linesize[0];
- us = v->s.current_picture.linesize[1];
- vs = v->s.current_picture.linesize[2];
- Y = v->s.dest[0];
-
- dsp->put_pixels_clamped(block[0], Y, ys);
- dsp->put_pixels_clamped(block[1], Y + 8, ys);
- Y += ys * 8;
- dsp->put_pixels_clamped(block[2], Y, ys);
- dsp->put_pixels_clamped(block[3], Y + 8, ys);
-
- if(!(v->s.flags & CODEC_FLAG_GRAY)) {
- dsp->put_pixels_clamped(block[4], v->s.dest[1], us);
- dsp->put_pixels_clamped(block[5], v->s.dest[2], vs);
+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] + 8, s->linesize, pq);
}
}
@@ -342,11 +310,11 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
if(s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
- dsp->put_vc1_mspel_pixels_tab[dxy](s->dest[0] , srcY , s->linesize, v->rnd);
- dsp->put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8, srcY + 8, s->linesize, v->rnd);
+ v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] , srcY , s->linesize, v->rnd);
+ v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8, srcY + 8, s->linesize, v->rnd);
srcY += s->linesize * 8;
- dsp->put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize , srcY , s->linesize, v->rnd);
- dsp->put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);
+ v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize , srcY , s->linesize, v->rnd);
+ v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);
} else { // hpel mc - always used for luma
dxy = (my & 2) | ((mx & 2) >> 1);
@@ -364,8 +332,8 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
dsp->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
dsp->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
}else{
- dsp->put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
- dsp->put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
+ v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
+ v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
}
}
@@ -433,7 +401,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n)
if(s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
- dsp->put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize, v->rnd);
+ v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize, v->rnd);
} else { // hpel mc - always used for luma
dxy = (my & 2) | ((mx & 2) >> 1);
if(!v->rnd)
@@ -583,8 +551,8 @@ static void vc1_mc_4mv_chroma(VC1Context *v)
dsp->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
dsp->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
}else{
- dsp->put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
- dsp->put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
+ v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
+ v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
}
}
@@ -906,11 +874,11 @@ static void vc1_interp_mc(VC1Context *v)
if(s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
- dsp->avg_vc1_mspel_pixels_tab[dxy](s->dest[0] , srcY , s->linesize, v->rnd);
- dsp->avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8, srcY + 8, s->linesize, v->rnd);
+ v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] , srcY , s->linesize, v->rnd);
+ v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8, srcY + 8, s->linesize, v->rnd);
srcY += s->linesize * 8;
- dsp->avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize , srcY , s->linesize, v->rnd);
- dsp->avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);
+ v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize , srcY , s->linesize, v->rnd);
+ v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);
} else { // hpel mc
dxy = (my & 2) | ((mx & 2) >> 1);
@@ -928,8 +896,8 @@ static void vc1_interp_mc(VC1Context *v)
dsp->avg_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
dsp->avg_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
}else{
- dsp->avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
- dsp->avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
+ v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
+ v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
}
}
@@ -1375,7 +1343,7 @@ static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value,
if (index != vc1_ac_sizes[codingset] - 1) {
run = vc1_index_decode_table[codingset][index][0];
level = vc1_index_decode_table[codingset][index][1];
- lst = index >= vc1_last_decode_table[codingset];
+ lst = index >= vc1_last_decode_table[codingset] || get_bits_left(gb) < 0;
if(get_bits1(gb))
level = -level;
} else {
@@ -1499,11 +1467,11 @@ static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, int coded
if(v->s.ac_pred) {
if(!dc_pred_dir)
- zz_table = wmv1_scantable[2];
+ zz_table = v->zz_8x8[2];
else
- zz_table = wmv1_scantable[3];
+ zz_table = v->zz_8x8[3];
} else
- zz_table = wmv1_scantable[1];
+ zz_table = v->zz_8x8[1];
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
@@ -1524,16 +1492,16 @@ static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, int coded
if(s->ac_pred) {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
- block[k << 3] += ac_val[k];
+ block[k] += ac_val[k];
} else { //top
for(k = 1; k < 8; k++)
- block[k] += ac_val[k + 8];
+ block[k << 3] += ac_val[k + 8];
}
}
/* save AC coeffs for further prediction */
for(k = 1; k < 8; k++) {
- ac_val2[k] = block[k << 3];
- ac_val2[k + 8] = block[k];
+ ac_val2[k] = block[k];
+ ac_val2[k + 8] = block[k << 3];
}
/* scale AC coeffs */
@@ -1570,15 +1538,15 @@ static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, int coded
if(s->ac_pred) {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++) {
- block[k << 3] = ac_val[k] * scale;
- if(!v->pquantizer && block[k << 3])
- block[k << 3] += (block[k << 3] < 0) ? -v->pq : v->pq;
+ block[k] = ac_val[k] * scale;
+ if(!v->pquantizer && block[k])
+ block[k] += (block[k] < 0) ? -v->pq : v->pq;
}
} else { //top
for(k = 1; k < 8; k++) {
- block[k] = ac_val[k + 8] * scale;
- if(!v->pquantizer && block[k])
- block[k] += (block[k] < 0) ? -v->pq : v->pq;
+ block[k << 3] = ac_val[k + 8] * scale;
+ if(!v->pquantizer && block[k << 3])
+ block[k << 3] += (block[k << 3] < 0) ? -v->pq : v->pq;
}
}
i = 63;
@@ -1682,11 +1650,11 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c
if(v->s.ac_pred) {
if(!dc_pred_dir)
- zz_table = wmv1_scantable[2];
+ zz_table = v->zz_8x8[2];
else
- zz_table = wmv1_scantable[3];
+ zz_table = v->zz_8x8[3];
} else
- zz_table = wmv1_scantable[1];
+ zz_table = v->zz_8x8[1];
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
@@ -1705,25 +1673,25 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
- block[k << 3] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
+ block[k] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else { //top
for(k = 1; k < 8; k++)
- block[k] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
+ block[k << 3] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
- block[k << 3] += ac_val[k];
+ block[k] += ac_val[k];
} else { //top
for(k = 1; k < 8; k++)
- block[k] += ac_val[k + 8];
+ block[k << 3] += ac_val[k + 8];
}
}
}
/* save AC coeffs for further prediction */
for(k = 1; k < 8; k++) {
- ac_val2[k] = block[k << 3];
- ac_val2[k + 8] = block[k];
+ ac_val2[k] = block[k];
+ ac_val2[k + 8] = block[k << 3];
}
/* scale AC coeffs */
@@ -1765,15 +1733,15 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c
if(use_pred) {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++) {
- block[k << 3] = ac_val2[k] * scale;
- if(!v->pquantizer && block[k << 3])
- block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
+ block[k] = ac_val2[k] * scale;
+ if(!v->pquantizer && block[k])
+ block[k] += (block[k] < 0) ? -mquant : mquant;
}
} else { //top
for(k = 1; k < 8; k++) {
- block[k] = ac_val2[k + 8] * scale;
- if(!v->pquantizer && block[k])
- block[k] += (block[k] < 0) ? -mquant : mquant;
+ block[k << 3] = ac_val2[k + 8] * scale;
+ if(!v->pquantizer && block[k << 3])
+ block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
}
}
i = 63;
@@ -1884,17 +1852,14 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c
if(coded) {
int last = 0, skip, value;
- const uint8_t *zz_table;
int k;
- zz_table = wmv1_scantable[0];
-
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
i += skip;
if(i > 63)
break;
- block[zz_table[i++]] = value;
+ block[v->zz_8x8[0][i++]] = value;
}
/* apply AC prediction if needed */
@@ -1906,25 +1871,25 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
- block[k << 3] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
+ block[k] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else { //top
for(k = 1; k < 8; k++)
- block[k] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
+ block[k << 3] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
- block[k << 3] += ac_val[k];
+ block[k] += ac_val[k];
} else { //top
for(k = 1; k < 8; k++)
- block[k] += ac_val[k + 8];
+ block[k << 3] += ac_val[k + 8];
}
}
}
/* save AC coeffs for further prediction */
for(k = 1; k < 8; k++) {
- ac_val2[k] = block[k << 3];
- ac_val2[k + 8] = block[k];
+ ac_val2[k] = block[k];
+ ac_val2[k + 8] = block[k << 3];
}
/* scale AC coeffs */
@@ -1966,15 +1931,15 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c
if(use_pred) {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++) {
- block[k << 3] = ac_val2[k] * scale;
- if(!v->pquantizer && block[k << 3])
- block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
+ block[k] = ac_val2[k] * scale;
+ if(!v->pquantizer && block[k])
+ block[k] += (block[k] < 0) ? -mquant : mquant;
}
} else { //top
for(k = 1; k < 8; k++) {
- block[k] = ac_val2[k + 8] * scale;
- if(!v->pquantizer && block[k])
- block[k] += (block[k] < 0) ? -mquant : mquant;
+ block[k << 3] = ac_val2[k + 8] * scale;
+ if(!v->pquantizer && block[k << 3])
+ block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
}
}
i = 63;
@@ -2035,22 +2000,21 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan
i += skip;
if(i > 63)
break;
- idx = wmv1_scantable[0][i++];
+ idx = v->zz_8x8[0][i++];
block[idx] = value * scale;
if(!v->pquantizer)
block[idx] += (block[idx] < 0) ? -mquant : mquant;
}
if(!skip_block){
if(i==1)
- s->dsp.vc1_inv_trans_8x8_dc(dst, linesize, block);
+ v->vc1dsp.vc1_inv_trans_8x8_dc(dst, linesize, block);
else{
- s->dsp.vc1_inv_trans_8x8(block);
- s->dsp.add_pixels_clamped(block, dst, linesize);
+ v->vc1dsp.vc1_inv_trans_8x8_add(dst, linesize, block);
}
if(apply_filter && cbp_top & 0xC)
- s->dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
+ v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
if(apply_filter && cbp_left & 0xA)
- s->dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
+ v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
}
break;
case TT_4X4:
@@ -2071,13 +2035,13 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan
}
if(!(subblkpat & (1 << (3 - j))) && !skip_block){
if(i==1)
- s->dsp.vc1_inv_trans_4x4_dc(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off);
+ v->vc1dsp.vc1_inv_trans_4x4_dc(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off);
else
- s->dsp.vc1_inv_trans_4x4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off);
+ v->vc1dsp.vc1_inv_trans_4x4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off);
if(apply_filter && (j&2 ? pat & (1<<(j-2)) : (cbp_top & (1 << (j + 2)))))
- s->dsp.vc1_v_loop_filter4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, v->pq);
+ v->vc1dsp.vc1_v_loop_filter4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, v->pq);
if(apply_filter && (j&1 ? pat & (1<<(j-1)) : (cbp_left & (1 << (j + 1)))))
- s->dsp.vc1_h_loop_filter4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, v->pq);
+ v->vc1dsp.vc1_h_loop_filter4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, v->pq);
}
}
break;
@@ -2099,13 +2063,13 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan
}
if(!(subblkpat & (1 << (1 - j))) && !skip_block){
if(i==1)
- s->dsp.vc1_inv_trans_8x4_dc(dst + j*4*linesize, linesize, block + off);
+ v->vc1dsp.vc1_inv_trans_8x4_dc(dst + j*4*linesize, linesize, block + off);
else
- s->dsp.vc1_inv_trans_8x4(dst + j*4*linesize, linesize, block + off);
+ v->vc1dsp.vc1_inv_trans_8x4(dst + j*4*linesize, linesize, block + off);
if(apply_filter && j ? pat & 0x3 : (cbp_top & 0xC))
- s->dsp.vc1_v_loop_filter8(dst + j*4*linesize, linesize, v->pq);
+ v->vc1dsp.vc1_v_loop_filter8(dst + j*4*linesize, linesize, v->pq);
if(apply_filter && cbp_left & (2 << j))
- s->dsp.vc1_h_loop_filter4(dst + j*4*linesize, linesize, v->pq);
+ v->vc1dsp.vc1_h_loop_filter4(dst + j*4*linesize, linesize, v->pq);
}
}
break;
@@ -2127,13 +2091,13 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan
}
if(!(subblkpat & (1 << (1 - j))) && !skip_block){
if(i==1)
- s->dsp.vc1_inv_trans_4x8_dc(dst + j*4, linesize, block + off);
+ v->vc1dsp.vc1_inv_trans_4x8_dc(dst + j*4, linesize, block + off);
else
- s->dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off);
+ v->vc1dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off);
if(apply_filter && cbp_top & (2 << j))
- s->dsp.vc1_v_loop_filter4(dst + j*4, linesize, v->pq);
+ v->vc1dsp.vc1_v_loop_filter4(dst + j*4, linesize, v->pq);
if(apply_filter && j ? pat & 0x5 : (cbp_left & 0xA))
- s->dsp.vc1_h_loop_filter8(dst + j*4, linesize, v->pq);
+ v->vc1dsp.vc1_h_loop_filter8(dst + j*4, linesize, v->pq);
}
}
break;
@@ -2152,7 +2116,7 @@ static int vc1_decode_p_mb(VC1Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &s->gb;
- int i, j;
+ int i;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int cbp; /* cbp decoding stuff */
int mqdiff, mquant; /* MB quantization */
@@ -2184,6 +2148,8 @@ static int vc1_decode_p_mb(VC1Context *v)
{
if (!skipped)
{
+ vc1_idct_func idct8x8_fn;
+
GET_MVDATA(dmv_x, dmv_y);
if (s->mb_intra) {
@@ -2218,6 +2184,7 @@ static int vc1_decode_p_mb(VC1Context *v)
VC1_TTMB_VLC_BITS, 2);
if(!s->mb_intra) vc1_mc_1mv(v, 0);
dst_idx = 0;
+ idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put_signed[!!v->rangeredfrm];
for (i=0; i<6; i++)
{
s->dc_val[0][s->block_index[i]] = 0;
@@ -2235,14 +2202,14 @@ static int vc1_decode_p_mb(VC1Context *v)
vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset);
if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
- s->dsp.vc1_inv_trans_8x8(s->block[i]);
- if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
- s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
+ idct8x8_fn(s->dest[dst_idx] + off,
+ i & 4 ? s->uvlinesize : s->linesize,
+ s->block[i]);
if(v->pq >= 9 && v->overlap) {
if(v->c_avail)
- s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
if(v->a_avail)
- s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
}
if(apply_loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){
int left_cbp, top_cbp;
@@ -2254,9 +2221,9 @@ static int vc1_decode_p_mb(VC1Context *v)
top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
}
if(left_cbp & 0xC)
- s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
+ v->vc1dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
if(top_cbp & 0xA)
- s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
+ v->vc1dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
}
block_cbp |= 0xF << (i << 2);
} else if(val) {
@@ -2271,9 +2238,9 @@ static int vc1_decode_p_mb(VC1Context *v)
top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
}
if(left_cbp & 0xC)
- s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
+ v->vc1dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
if(top_cbp & 0xA)
- s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
+ v->vc1dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
}
pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), filter, left_cbp, top_cbp);
block_cbp |= pat << (i << 2);
@@ -2302,6 +2269,7 @@ static int vc1_decode_p_mb(VC1Context *v)
{
int intra_count = 0, coded_inter = 0;
int is_intra[6], is_coded[6];
+ vc1_idct_func idct8x8_fn;
/* Get CBPCY */
cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
for (i=0; i<6; i++)
@@ -2351,6 +2319,7 @@ static int vc1_decode_p_mb(VC1Context *v)
}
if (!v->ttmbf && coded_inter)
ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
+ idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put_signed[!!v->rangeredfrm];
for (i=0; i<6; i++)
{
dst_idx += i >> 2;
@@ -2366,14 +2335,14 @@ static int vc1_decode_p_mb(VC1Context *v)
vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant, (i&4)?v->codingset2:v->codingset);
if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
- s->dsp.vc1_inv_trans_8x8(s->block[i]);
- if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
- s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize);
+ idct8x8_fn(s->dest[dst_idx] + off,
+ (i&4)?s->uvlinesize:s->linesize,
+ s->block[i]);
if(v->pq >= 9 && v->overlap) {
if(v->c_avail)
- s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
if(v->a_avail)
- s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
}
if(v->s.loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){
int left_cbp, top_cbp;
@@ -2385,9 +2354,9 @@ static int vc1_decode_p_mb(VC1Context *v)
top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
}
if(left_cbp & 0xC)
- s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
+ v->vc1dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
if(top_cbp & 0xA)
- s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
+ v->vc1dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
}
block_cbp |= 0xF << (i << 2);
} else if(is_coded[i]) {
@@ -2402,9 +2371,9 @@ static int vc1_decode_p_mb(VC1Context *v)
top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
}
if(left_cbp & 0xC)
- s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
+ v->vc1dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
if(top_cbp & 0xA)
- s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
+ v->vc1dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq);
}
pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), filter, left_cbp, top_cbp);
block_cbp |= pat << (i << 2);
@@ -2444,7 +2413,7 @@ static void vc1_decode_b_mb(VC1Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &s->gb;
- int i, j;
+ int i;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int cbp = 0; /* cbp decoding stuff */
int mqdiff, mquant; /* MB quantization */
@@ -2457,6 +2426,7 @@ static void vc1_decode_b_mb(VC1Context *v)
int skipped, direct;
int dmv_x[2], dmv_y[2];
int bmvtype = BMV_TYPE_BACKWARD;
+ vc1_idct_func idct8x8_fn;
mquant = v->pq; /* Loosy initialization */
s->mb_intra = 0;
@@ -2554,6 +2524,7 @@ static void vc1_decode_b_mb(VC1Context *v)
}
}
dst_idx = 0;
+ idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put_signed[!!v->rangeredfrm];
for (i=0; i<6; i++)
{
s->dc_val[0][s->block_index[i]] = 0;
@@ -2571,9 +2542,9 @@ static void vc1_decode_b_mb(VC1Context *v)
vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset);
if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
- s->dsp.vc1_inv_trans_8x8(s->block[i]);
- if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
- s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
+ idct8x8_fn(s->dest[dst_idx] + off,
+ i & 4 ? s->uvlinesize : s->linesize,
+ s->block[i]);
} else if(val) {
vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), 0, 0, 0);
if(!v->ttmbf && ttmb < 8) ttmb = -1;
@@ -2586,11 +2557,12 @@ static void vc1_decode_b_mb(VC1Context *v)
*/
static void vc1_decode_i_blocks(VC1Context *v)
{
- int k, j;
+ int k;
MpegEncContext *s = &v->s;
int cbp, val;
uint8_t *coded_val;
int mb_pos;
+ vc1_idct_func idct8x8_fn;
/* select codingmode used for VLC tables selection */
switch(v->y_ac_table_index){
@@ -2625,11 +2597,22 @@ static void vc1_decode_i_blocks(VC1Context *v)
s->mb_x = s->mb_y = 0;
s->mb_intra = 1;
s->first_slice_line = 1;
+ if(v->pq >= 9 && v->overlap) {
+ idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put_signed[!!v->rangeredfrm];
+ } else
+ idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put[!!v->rangeredfrm];
for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
s->mb_x = 0;
ff_init_block_index(s);
for(; s->mb_x < s->mb_width; s->mb_x++) {
+ uint8_t *dst[6];
ff_update_block_index(s);
+ dst[0] = s->dest[0];
+ dst[1] = dst[0] + 8;
+ dst[2] = s->dest[0] + s->linesize * 8;
+ dst[3] = dst[2] + 8;
+ dst[4] = s->dest[1];
+ dst[5] = s->dest[2];
s->dsp.clear_blocks(s->block[0]);
mb_pos = s->mb_x + s->mb_y * s->mb_width;
s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
@@ -2653,36 +2636,35 @@ static void vc1_decode_i_blocks(VC1Context *v)
vc1_decode_i_block(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2);
- s->dsp.vc1_inv_trans_8x8(s->block[k]);
- if(v->pq >= 9 && v->overlap) {
- for(j = 0; j < 64; j++) s->block[k][j] += 128;
- }
+ if (k > 3 && (s->flags & CODEC_FLAG_GRAY)) continue;
+ idct8x8_fn(dst[k],
+ k & 4 ? s->uvlinesize : s->linesize,
+ s->block[k]);
}
- vc1_put_block(v, s->block);
if(v->pq >= 9 && v->overlap) {
if(s->mb_x) {
- s->dsp.vc1_h_overlap(s->dest[0], s->linesize);
- s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[0], s->linesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
if(!(s->flags & CODEC_FLAG_GRAY)) {
- s->dsp.vc1_h_overlap(s->dest[1], s->uvlinesize);
- s->dsp.vc1_h_overlap(s->dest[2], s->uvlinesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[1], s->uvlinesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[2], s->uvlinesize);
}
}
- s->dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize);
- s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
if(!s->first_slice_line) {
- s->dsp.vc1_v_overlap(s->dest[0], s->linesize);
- s->dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[0], s->linesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize);
if(!(s->flags & CODEC_FLAG_GRAY)) {
- s->dsp.vc1_v_overlap(s->dest[1], s->uvlinesize);
- s->dsp.vc1_v_overlap(s->dest[2], s->uvlinesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[1], s->uvlinesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[2], s->uvlinesize);
}
}
- s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
- s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
}
- if(v->s.loop_filter) vc1_loop_filter_iblk(s, v->pq);
+ if(v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq);
if(get_bits_count(&s->gb) > v->bits) {
ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
@@ -2706,7 +2688,7 @@ static void vc1_decode_i_blocks(VC1Context *v)
*/
static void vc1_decode_i_blocks_adv(VC1Context *v)
{
- int k, j;
+ int k;
MpegEncContext *s = &v->s;
int cbp, val;
uint8_t *coded_val;
@@ -2715,6 +2697,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
int mqdiff;
int overlap;
GetBitContext *gb = &s->gb;
+ vc1_idct_func idct8x8_fn;
/* select codingmode used for VLC tables selection */
switch(v->y_ac_table_index){
@@ -2745,11 +2728,19 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
s->mb_x = s->mb_y = 0;
s->mb_intra = 1;
s->first_slice_line = 1;
+ idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put_signed[0];
for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
s->mb_x = 0;
ff_init_block_index(s);
for(;s->mb_x < s->mb_width; s->mb_x++) {
+ uint8_t *dst[6];
ff_update_block_index(s);
+ dst[0] = s->dest[0];
+ dst[1] = dst[0] + 8;
+ dst[2] = s->dest[0] + s->linesize * 8;
+ dst[3] = dst[2] + 8;
+ dst[4] = s->dest[1];
+ dst[5] = s->dest[2];
s->dsp.clear_blocks(s->block[0]);
mb_pos = s->mb_x + s->mb_y * s->mb_stride;
s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
@@ -2793,34 +2784,35 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
vc1_decode_i_block_adv(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2, mquant);
- s->dsp.vc1_inv_trans_8x8(s->block[k]);
- for(j = 0; j < 64; j++) s->block[k][j] += 128;
+ if (k > 3 && (s->flags & CODEC_FLAG_GRAY)) continue;
+ idct8x8_fn(dst[k],
+ k & 4 ? s->uvlinesize : s->linesize,
+ s->block[k]);
}
- vc1_put_block(v, s->block);
if(overlap) {
if(s->mb_x) {
- s->dsp.vc1_h_overlap(s->dest[0], s->linesize);
- s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[0], s->linesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
if(!(s->flags & CODEC_FLAG_GRAY)) {
- s->dsp.vc1_h_overlap(s->dest[1], s->uvlinesize);
- s->dsp.vc1_h_overlap(s->dest[2], s->uvlinesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[1], s->uvlinesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[2], s->uvlinesize);
}
}
- s->dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize);
- s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize);
+ v->vc1dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
if(!s->first_slice_line) {
- s->dsp.vc1_v_overlap(s->dest[0], s->linesize);
- s->dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[0], s->linesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize);
if(!(s->flags & CODEC_FLAG_GRAY)) {
- s->dsp.vc1_v_overlap(s->dest[1], s->uvlinesize);
- s->dsp.vc1_v_overlap(s->dest[2], s->uvlinesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[1], s->uvlinesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[2], s->uvlinesize);
}
}
- s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
- s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
+ v->vc1dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
}
- if(v->s.loop_filter) vc1_loop_filter_iblk(s, v->pq);
+ if(v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq);
if(get_bits_count(&s->gb) > v->bits) {
ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
@@ -2932,7 +2924,7 @@ static void vc1_decode_b_blocks(VC1Context *v)
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", get_bits_count(&s->gb), v->bits,s->mb_x,s->mb_y);
return;
}
- if(v->s.loop_filter) vc1_loop_filter_iblk(s, v->pq);
+ if(v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq);
}
if (!v->s.loop_filter)
ff_draw_horiz_band(s, s->mb_y * 16, 16);
@@ -3007,6 +2999,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
GetBitContext gb;
+ int i;
if (!avctx->extradata_size || !avctx->extradata) return -1;
if (!(avctx->flags & CODEC_FLAG_GRAY))
@@ -3025,6 +3018,14 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
if(ff_msmpeg4_decode_init(avctx) < 0)
return -1;
if (vc1_init_common(v) < 0) return -1;
+ ff_vc1dsp_init(&v->vc1dsp);
+ for (i = 0; i < 64; i++) {
+#define transpose(x) ((x>>3) | ((x&7)<<3))
+ v->zz_8x8[0][i] = transpose(wmv1_scantable[0][i]);
+ v->zz_8x8[1][i] = transpose(wmv1_scantable[1][i]);
+ v->zz_8x8[2][i] = transpose(wmv1_scantable[2][i]);
+ v->zz_8x8[3][i] = transpose(wmv1_scantable[3][i]);
+ }
avctx->coded_width = avctx->width;
avctx->coded_height = avctx->height;
@@ -3148,7 +3149,7 @@ static int vc1_decode_frame(AVCodecContext *avctx,
const uint8_t *buf_start = buf;
/* no supplementary picture */
- if (buf_size == 0) {
+ if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) {
/* special case for last picture */
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
diff --git a/mplayer/ffmpeg/libavcodec/vc1dsp.c b/mplayer/ffmpeg/libavcodec/vc1dsp.c
index aab16947..2ab312ab 100644
--- a/mplayer/ffmpeg/libavcodec/vc1dsp.c
+++ b/mplayer/ffmpeg/libavcodec/vc1dsp.c
@@ -25,7 +25,7 @@
*
*/
-#include "dsputil.h"
+#include "vc1dsp.h"
/** Apply overlap transform to horizontal edge
@@ -199,29 +199,29 @@ static void vc1_inv_trans_8x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
}
}
-static void vc1_inv_trans_8x8_c(DCTELEM block[64])
+static av_always_inline void vc1_inv_trans_8x8_c(DCTELEM block[64], int shl, int sub)
{
int i;
register int t1,t2,t3,t4,t5,t6,t7,t8;
- DCTELEM *src, *dst;
+ DCTELEM *src, *dst, temp[64];
src = block;
- dst = block;
+ dst = temp;
for(i = 0; i < 8; i++){
- t1 = 12 * (src[0] + src[4]) + 4;
- t2 = 12 * (src[0] - src[4]) + 4;
- t3 = 16 * src[2] + 6 * src[6];
- t4 = 6 * src[2] - 16 * src[6];
+ t1 = 12 * (src[ 0] + src[32]) + 4;
+ t2 = 12 * (src[ 0] - src[32]) + 4;
+ t3 = 16 * src[16] + 6 * src[48];
+ t4 = 6 * src[16] - 16 * src[48];
t5 = t1 + t3;
t6 = t2 + t4;
t7 = t2 - t4;
t8 = t1 - t3;
- t1 = 16 * src[1] + 15 * src[3] + 9 * src[5] + 4 * src[7];
- t2 = 15 * src[1] - 4 * src[3] - 16 * src[5] - 9 * src[7];
- t3 = 9 * src[1] - 16 * src[3] + 4 * src[5] + 15 * src[7];
- t4 = 4 * src[1] - 9 * src[3] + 15 * src[5] - 16 * src[7];
+ t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];
+ t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];
+ t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
+ t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
dst[0] = (t5 + t1) >> 3;
dst[1] = (t6 + t2) >> 3;
@@ -232,11 +232,11 @@ static void vc1_inv_trans_8x8_c(DCTELEM block[64])
dst[6] = (t6 - t2) >> 3;
dst[7] = (t5 - t1) >> 3;
- src += 8;
+ src += 1;
dst += 8;
}
- src = block;
+ src = temp;
dst = block;
for(i = 0; i < 8; i++){
t1 = 12 * (src[ 0] + src[32]) + 64;
@@ -254,20 +254,50 @@ static void vc1_inv_trans_8x8_c(DCTELEM block[64])
t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
- dst[ 0] = (t5 + t1) >> 7;
- dst[ 8] = (t6 + t2) >> 7;
- dst[16] = (t7 + t3) >> 7;
- dst[24] = (t8 + t4) >> 7;
- dst[32] = (t8 - t4 + 1) >> 7;
- dst[40] = (t7 - t3 + 1) >> 7;
- dst[48] = (t6 - t2 + 1) >> 7;
- dst[56] = (t5 - t1 + 1) >> 7;
+ dst[ 0] = (((t5 + t1 ) >> 7) - sub) << shl;
+ dst[ 8] = (((t6 + t2 ) >> 7) - sub) << shl;
+ dst[16] = (((t7 + t3 ) >> 7) - sub) << shl;
+ dst[24] = (((t8 + t4 ) >> 7) - sub) << shl;
+ dst[32] = (((t8 - t4 + 1) >> 7) - sub) << shl;
+ dst[40] = (((t7 - t3 + 1) >> 7) - sub) << shl;
+ dst[48] = (((t6 - t2 + 1) >> 7) - sub) << shl;
+ dst[56] = (((t5 - t1 + 1) >> 7) - sub) << shl;
src++;
dst++;
}
}
+static void vc1_inv_trans_8x8_add_c(uint8_t *dest, int linesize, DCTELEM *block)
+{
+ vc1_inv_trans_8x8_c(block, 0, 0);
+ ff_add_pixels_clamped_c(block, dest, linesize);
+}
+
+static void vc1_inv_trans_8x8_put_signed_c(uint8_t *dest, int linesize, DCTELEM *block)
+{
+ vc1_inv_trans_8x8_c(block, 0, 0);
+ ff_put_signed_pixels_clamped_c(block, dest, linesize);
+}
+
+static void vc1_inv_trans_8x8_put_signed_rangered_c(uint8_t *dest, int linesize, DCTELEM *block)
+{
+ vc1_inv_trans_8x8_c(block, 1, 0);
+ ff_put_signed_pixels_clamped_c(block, dest, linesize);
+}
+
+static void vc1_inv_trans_8x8_put_c(uint8_t *dest, int linesize, DCTELEM *block)
+{
+ vc1_inv_trans_8x8_c(block, 0, 0);
+ ff_put_pixels_clamped_c(block, dest, linesize);
+}
+
+static void vc1_inv_trans_8x8_put_rangered_c(uint8_t *dest, int linesize, DCTELEM *block)
+{
+ vc1_inv_trans_8x8_c(block, 1, 64);
+ ff_put_pixels_clamped_c(block, dest, linesize);
+}
+
/** Do inverse transform on 8x4 part of block
*/
static void vc1_inv_trans_8x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
@@ -612,8 +642,61 @@ PUT_VC1_MSPEL(1, 3)
PUT_VC1_MSPEL(2, 3)
PUT_VC1_MSPEL(3, 3)
-av_cold void ff_vc1dsp_init(DSPContext* dsp, AVCodecContext *avctx) {
- dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_c;
+static void put_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
+ const int A=(8-x)*(8-y);
+ const int B=( x)*(8-y);
+ const int C=(8-x)*( y);
+ const int D=( x)*( y);
+ int i;
+
+ assert(x<8 && y<8 && x>=0 && y>=0);
+
+ for(i=0; i> 6;
+ dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6;
+ dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6;
+ dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6;
+ dst[4] = (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6;
+ dst[5] = (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6;
+ dst[6] = (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6;
+ dst[7] = (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6;
+ dst+= stride;
+ src+= stride;
+ }
+}
+
+#define avg2(a,b) ((a+b+1)>>1)
+static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
+ const int A=(8-x)*(8-y);
+ const int B=( x)*(8-y);
+ const int C=(8-x)*( y);
+ const int D=( x)*( y);
+ int i;
+
+ assert(x<8 && y<8 && x>=0 && y>=0);
+
+ for(i=0; i> 6));
+ dst[1] = avg2(dst[1], ((A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6));
+ dst[2] = avg2(dst[2], ((A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6));
+ dst[3] = avg2(dst[3], ((A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6));
+ dst[4] = avg2(dst[4], ((A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6));
+ dst[5] = avg2(dst[5], ((A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6));
+ dst[6] = avg2(dst[6], ((A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6));
+ dst[7] = avg2(dst[7], ((A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6));
+ dst+= stride;
+ src+= stride;
+ }
+}
+
+av_cold void ff_vc1dsp_init(VC1DSPContext* dsp) {
+ dsp->vc1_inv_trans_8x8_add = vc1_inv_trans_8x8_add_c;
+ dsp->vc1_inv_trans_8x8_put_signed[0] = vc1_inv_trans_8x8_put_signed_c;
+ dsp->vc1_inv_trans_8x8_put_signed[1] = vc1_inv_trans_8x8_put_signed_rangered_c;
+ dsp->vc1_inv_trans_8x8_put[0] = vc1_inv_trans_8x8_put_c;
+ dsp->vc1_inv_trans_8x8_put[1] = vc1_inv_trans_8x8_put_rangered_c;
dsp->vc1_inv_trans_4x8 = vc1_inv_trans_4x8_c;
dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_c;
dsp->vc1_inv_trans_4x4 = vc1_inv_trans_4x4_c;
@@ -663,4 +746,14 @@ av_cold void ff_vc1dsp_init(DSPContext* dsp, AVCodecContext *avctx) {
dsp->avg_vc1_mspel_pixels_tab[13] = avg_vc1_mspel_mc13_c;
dsp->avg_vc1_mspel_pixels_tab[14] = avg_vc1_mspel_mc23_c;
dsp->avg_vc1_mspel_pixels_tab[15] = avg_vc1_mspel_mc33_c;
+
+ dsp->put_no_rnd_vc1_chroma_pixels_tab[0]= put_no_rnd_vc1_chroma_mc8_c;
+ dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_no_rnd_vc1_chroma_mc8_c;
+
+ if (HAVE_ALTIVEC)
+ ff_vc1dsp_init_altivec(dsp);
+ if (HAVE_PAIRED)
+ ff_vc1dsp_init_paired(dsp);
+ if (HAVE_MMX)
+ ff_vc1dsp_init_mmx(dsp);
}
diff --git a/mplayer/ffmpeg/libavcodec/vc1dsp.h b/mplayer/ffmpeg/libavcodec/vc1dsp.h
new file mode 100644
index 00000000..4d255e06
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/vc1dsp.h
@@ -0,0 +1,72 @@
+/*
+ * VC-1 and WMV3 decoder - DSP functions
+ * Copyright (c) 2006 Konstantin Shishkov
+ *
+ * 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
+ * VC-1 and WMV3 decoder
+ *
+ */
+
+#ifndef AVCODEC_VC1DSP_H
+#define AVCODEC_VC1DSP_H
+
+#include "dsputil.h"
+
+typedef void (*vc1_idct_func)(uint8_t *dest, int line_size, DCTELEM *block);
+
+typedef struct VC1DSPContext {
+ /* vc1 functions */
+ vc1_idct_func vc1_inv_trans_8x8_add;
+ vc1_idct_func vc1_inv_trans_8x8_put_signed[2];
+ vc1_idct_func vc1_inv_trans_8x8_put[2];
+ void (*vc1_inv_trans_8x4)(uint8_t *dest, int line_size, DCTELEM *block);
+ void (*vc1_inv_trans_4x8)(uint8_t *dest, int line_size, DCTELEM *block);
+ void (*vc1_inv_trans_4x4)(uint8_t *dest, int line_size, DCTELEM *block);
+ void (*vc1_inv_trans_8x8_dc)(uint8_t *dest, int line_size, DCTELEM *block);
+ void (*vc1_inv_trans_8x4_dc)(uint8_t *dest, int line_size, DCTELEM *block);
+ void (*vc1_inv_trans_4x8_dc)(uint8_t *dest, int line_size, DCTELEM *block);
+ void (*vc1_inv_trans_4x4_dc)(uint8_t *dest, int line_size, DCTELEM *block);
+ void (*vc1_v_overlap)(uint8_t* src, int stride);
+ void (*vc1_h_overlap)(uint8_t* src, int stride);
+ void (*vc1_v_loop_filter4)(uint8_t *src, int stride, int pq);
+ void (*vc1_h_loop_filter4)(uint8_t *src, int stride, int pq);
+ void (*vc1_v_loop_filter8)(uint8_t *src, int stride, int pq);
+ void (*vc1_h_loop_filter8)(uint8_t *src, int stride, int pq);
+ void (*vc1_v_loop_filter16)(uint8_t *src, int stride, int pq);
+ void (*vc1_h_loop_filter16)(uint8_t *src, int stride, int pq);
+
+ /* put 8x8 block with bicubic interpolation and quarterpel precision
+ * last argument is actually round value instead of height
+ */
+ op_pixels_func put_vc1_mspel_pixels_tab[16];
+ op_pixels_func avg_vc1_mspel_pixels_tab[16];
+
+ /* This is really one func used in VC-1 decoding */
+ h264_chroma_mc_func put_no_rnd_vc1_chroma_pixels_tab[3];
+ h264_chroma_mc_func avg_no_rnd_vc1_chroma_pixels_tab[3];
+} VC1DSPContext;
+
+void ff_vc1dsp_init(VC1DSPContext* c);
+void ff_vc1dsp_init_altivec(VC1DSPContext* c);
+void ff_vc1dsp_init_paired(VC1DSPContext* c);
+void ff_vc1dsp_init_mmx(VC1DSPContext* dsp);
+
+#endif /* AVCODEC_VC1DSP_H */
diff --git a/mplayer/ffmpeg/libavcodec/vmdav.c b/mplayer/ffmpeg/libavcodec/vmdav.c
index e396c0bc..86e36837 100644
--- a/mplayer/ffmpeg/libavcodec/vmdav.c
+++ b/mplayer/ffmpeg/libavcodec/vmdav.c
@@ -414,11 +414,13 @@ static av_cold int vmdvideo_decode_end(AVCodecContext *avctx)
* Audio Decoder
*/
+#define BLOCK_TYPE_AUDIO 1
+#define BLOCK_TYPE_INITIAL 2
+#define BLOCK_TYPE_SILENCE 3
+
typedef struct VmdAudioContext {
AVCodecContext *avctx;
- int channels;
- int bits;
- int block_align;
+ int out_bps;
int predictors[2];
} VmdAudioContext;
@@ -443,13 +445,16 @@ static av_cold int vmdaudio_decode_init(AVCodecContext *avctx)
VmdAudioContext *s = avctx->priv_data;
s->avctx = avctx;
- s->channels = avctx->channels;
- s->bits = avctx->bits_per_coded_sample;
- s->block_align = avctx->block_align;
- avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ if (avctx->bits_per_coded_sample == 16)
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ else
+ avctx->sample_fmt = AV_SAMPLE_FMT_U8;
+ s->out_bps = av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3;
- av_log(s->avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, block align = %d, sample rate = %d\n",
- s->channels, s->bits, s->block_align, avctx->sample_rate);
+ av_log(avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, "
+ "block align = %d, sample rate = %d\n",
+ avctx->channels, avctx->bits_per_coded_sample, avctx->block_align,
+ avctx->sample_rate);
return 0;
}
@@ -473,49 +478,22 @@ static void vmdaudio_decode_audio(VmdAudioContext *s, unsigned char *data,
}
static int vmdaudio_loadsound(VmdAudioContext *s, unsigned char *data,
- const uint8_t *buf, int silence, int data_size)
+ const uint8_t *buf, int silent_chunks, int data_size)
{
- int bytes_decoded = 0;
- int i;
+ int silent_size = s->avctx->block_align * silent_chunks * s->out_bps;
-// if (silence)
-// av_log(s->avctx, AV_LOG_INFO, "silent block!\n");
- if (s->channels == 2) {
-
- /* stereo handling */
- if (silence) {
- memset(data, 0, data_size * 2);
- } else {
- if (s->bits == 16)
- vmdaudio_decode_audio(s, data, buf, data_size, 1);
- else {
- /* copy the data but convert it to signed */
- for (i = 0; i < data_size; i++){
- *data++ = buf[i] + 0x80;
- *data++ = buf[i] + 0x80;
- }
- }
- }
- } else {
- bytes_decoded = data_size * 2;
-
- /* mono handling */
- if (silence) {
- memset(data, 0, data_size * 2);
- } else {
- if (s->bits == 16) {
- vmdaudio_decode_audio(s, data, buf, data_size, 0);
- } else {
- /* copy the data but convert it to signed */
- for (i = 0; i < data_size; i++){
- *data++ = buf[i] + 0x80;
- *data++ = buf[i] + 0x80;
- }
- }
- }
+ if (silent_chunks) {
+ memset(data, s->out_bps == 2 ? 0x00 : 0x80, silent_size);
+ data += silent_size;
+ }
+ if (s->avctx->bits_per_coded_sample == 16)
+ vmdaudio_decode_audio(s, data, buf, data_size, s->avctx->channels == 2);
+ else {
+ /* just copy the data */
+ memcpy(data, buf, data_size);
}
- return data_size * 2;
+ return silent_size + data_size * s->out_bps;
}
static int vmdaudio_decode_frame(AVCodecContext *avctx,
@@ -525,39 +503,41 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
VmdAudioContext *s = avctx->priv_data;
+ int block_type, silent_chunks;
unsigned char *output_samples = (unsigned char *)data;
- /* point to the start of the encoded data */
- const unsigned char *p = buf + 16;
-
- if (buf_size < 16)
+ if (buf_size < 16) {
+ av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
+ *data_size = 0;
return buf_size;
+ }
- if (buf[6] == 1) {
- /* the chunk contains audio */
- *data_size = vmdaudio_loadsound(s, output_samples, p, 0, buf_size - 16);
- } else if (buf[6] == 2) {
- /* initial chunk, may contain audio and silence */
- uint32_t flags = AV_RB32(p);
- int raw_block_size = s->block_align * s->bits / 8;
- int silent_chunks;
- if(flags == 0xFFFFFFFF)
- silent_chunks = 32;
- else
- silent_chunks = av_log2(flags + 1);
- if(*data_size < (s->block_align*silent_chunks + buf_size - 20) * 2)
- return -1;
- *data_size = 0;
- memset(output_samples, 0, raw_block_size * silent_chunks);
- output_samples += raw_block_size * silent_chunks;
- *data_size = raw_block_size * silent_chunks;
- *data_size += vmdaudio_loadsound(s, output_samples, p + 4, 0, buf_size - 20);
- } else if (buf[6] == 3) {
- /* silent chunk */
- *data_size = vmdaudio_loadsound(s, output_samples, p, 1, 0);
+ block_type = buf[6];
+ if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {
+ av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);
+ return AVERROR(EINVAL);
+ }
+ buf += 16;
+ buf_size -= 16;
+
+ silent_chunks = 0;
+ if (block_type == BLOCK_TYPE_INITIAL) {
+ uint32_t flags = AV_RB32(buf);
+ silent_chunks = av_popcount(flags);
+ buf += 4;
+ buf_size -= 4;
+ } else if (block_type == BLOCK_TYPE_SILENCE) {
+ silent_chunks = 1;
+ buf_size = 0; // should already be zero but set it just to be sure
}
- return buf_size;
+ /* ensure output buffer is large enough */
+ if (*data_size < (avctx->block_align*silent_chunks + buf_size) * s->out_bps)
+ return -1;
+
+ *data_size = vmdaudio_loadsound(s, output_samples, buf, silent_chunks, buf_size);
+
+ return avpkt->size;
}
diff --git a/mplayer/ffmpeg/libavcodec/vorbis_data.c b/mplayer/ffmpeg/libavcodec/vorbis_data.c
index 24c9921f..8fa62416 100644
--- a/mplayer/ffmpeg/libavcodec/vorbis_data.c
+++ b/mplayer/ffmpeg/libavcodec/vorbis_data.c
@@ -20,6 +20,7 @@
#include "dsputil.h"
#include "vorbis.h"
+#include "libavutil/audioconvert.h"
const uint8_t ff_vorbis_channel_layout_offsets[8][8] = {
{ 0 },
@@ -44,14 +45,14 @@ const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8] = {
};
const int64_t ff_vorbis_channel_layouts[9] = {
- CH_LAYOUT_MONO,
- CH_LAYOUT_STEREO,
- CH_LAYOUT_SURROUND,
- CH_LAYOUT_QUAD,
- CH_LAYOUT_5POINT0_BACK,
- CH_LAYOUT_5POINT1_BACK,
- CH_LAYOUT_5POINT1|CH_BACK_CENTER,
- CH_LAYOUT_7POINT1,
+ AV_CH_LAYOUT_MONO,
+ AV_CH_LAYOUT_STEREO,
+ AV_CH_LAYOUT_SURROUND,
+ AV_CH_LAYOUT_QUAD,
+ AV_CH_LAYOUT_5POINT0_BACK,
+ AV_CH_LAYOUT_5POINT1_BACK,
+ AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER,
+ AV_CH_LAYOUT_7POINT1,
0
};
diff --git a/mplayer/ffmpeg/libavcodec/vorbis_dec.c b/mplayer/ffmpeg/libavcodec/vorbis_dec.c
index 69b784c6..deaae757 100644
--- a/mplayer/ffmpeg/libavcodec/vorbis_dec.c
+++ b/mplayer/ffmpeg/libavcodec/vorbis_dec.c
@@ -31,6 +31,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
#include "vorbis.h"
#include "xiph.h"
@@ -127,6 +128,7 @@ typedef struct vorbis_context_s {
AVCodecContext *avccontext;
GetBitContext gb;
DSPContext dsp;
+ FmtConvertContext fmt_conv;
FFTContext mdct[2];
uint_fast8_t first_frame;
@@ -566,9 +568,9 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
/* zero would result in a div by zero later *
* 2^0 - 1 == 0 */
if (floor_setup->data.t0.amplitude_bits == 0) {
- av_log(vc->avccontext, AV_LOG_ERROR,
- "Floor 0 amplitude bits is 0.\n");
- return -1;
+ av_log(vc->avccontext, AV_LOG_ERROR,
+ "Floor 0 amplitude bits is 0.\n");
+ return -1;
}
floor_setup->data.t0.amplitude_offset = get_bits(gb, 8);
floor_setup->data.t0.num_books = get_bits(gb, 4) + 1;
@@ -592,37 +594,34 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
create_map(vc, i);
- /* allocate mem for lsp coefficients */
- {
- /* codebook dim is for padding if codebook dim doesn't *
- * divide order+1 then we need to read more data */
- floor_setup->data.t0.lsp =
- av_malloc((floor_setup->data.t0.order+1 + max_codebook_dim)
- * sizeof(float));
- if (!floor_setup->data.t0.lsp)
- return -1;
- }
+ /* codebook dim is for padding if codebook dim doesn't *
+ * divide order+1 then we need to read more data */
+ floor_setup->data.t0.lsp =
+ av_malloc((floor_setup->data.t0.order+1 + max_codebook_dim)
+ * sizeof(float));
+ if (!floor_setup->data.t0.lsp)
+ return -1;
#ifdef V_DEBUG /* debug output parsed headers */
AV_DEBUG("floor0 order: %u\n", floor_setup->data.t0.order);
AV_DEBUG("floor0 rate: %u\n", floor_setup->data.t0.rate);
AV_DEBUG("floor0 bark map size: %u\n",
- floor_setup->data.t0.bark_map_size);
+ floor_setup->data.t0.bark_map_size);
AV_DEBUG("floor0 amplitude bits: %u\n",
- floor_setup->data.t0.amplitude_bits);
+ floor_setup->data.t0.amplitude_bits);
AV_DEBUG("floor0 amplitude offset: %u\n",
- floor_setup->data.t0.amplitude_offset);
+ floor_setup->data.t0.amplitude_offset);
AV_DEBUG("floor0 number of books: %u\n",
- floor_setup->data.t0.num_books);
+ floor_setup->data.t0.num_books);
AV_DEBUG("floor0 book list pointer: %p\n",
- floor_setup->data.t0.book_list);
+ floor_setup->data.t0.book_list);
{
- int idx;
- for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) {
- AV_DEBUG(" Book %d: %u\n",
- idx+1,
- floor_setup->data.t0.book_list[idx]);
- }
+ int idx;
+ for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) {
+ AV_DEBUG(" Book %d: %u\n",
+ idx+1,
+ floor_setup->data.t0.book_list[idx]);
+ }
}
#endif
} else {
@@ -800,12 +799,12 @@ static void create_map(vorbis_context *vc, uint_fast8_t floor_number)
vf->map_size[blockflag] = n;
}
-# ifdef V_DEBUG
+#ifdef V_DEBUG
for (idx = 0; idx <= n; ++idx) {
AV_DEBUG("floor0 map: map at pos %d is %d\n",
idx, map[idx]);
}
-# endif
+#endif
}
static int vorbis_parse_setup_hdr_modes(vorbis_context *vc)
@@ -961,6 +960,7 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext)
vc->avccontext = avccontext;
dsputil_init(&vc->dsp, avccontext);
+ ff_fmt_convert_init(&vc->fmt_conv, avccontext);
vc->scale_bias = 32768.0f;
@@ -1037,7 +1037,6 @@ static int vorbis_floor0_decode(vorbis_context *vc,
av_log(vc->avccontext, AV_LOG_ERROR,
"floor0 dec: booknumber too high!\n");
book_idx = 0;
- //FIXME: look above
}
AV_DEBUG("floor0 dec: booknumber: %u\n", book_idx);
codebook = vc->codebooks[vf->book_list[book_idx]];
@@ -1107,11 +1106,9 @@ static int vorbis_floor0_decode(vorbis_context *vc,
}
/* calculate linear floor value */
- {
- q = exp((((amplitude*vf->amplitude_offset) /
- (((1 << vf->amplitude_bits) - 1) * sqrt(p + q)))
- - vf->amplitude_offset) * .11512925f);
- }
+ q = exp((((amplitude*vf->amplitude_offset) /
+ (((1 << vf->amplitude_bits) - 1) * sqrt(p + q)))
+ - vf->amplitude_offset) * .11512925f);
/* fill vector */
do {
@@ -1575,13 +1572,13 @@ static int vorbis_parse_audio_packet(vorbis_context *vc)
const float *win = vc->win[blockflag & previous_window];
if (blockflag == previous_window) {
- vc->dsp.vector_fmul_window(ret, saved, buf, win, 0, blocksize / 4);
+ vc->dsp.vector_fmul_window(ret, saved, buf, win, blocksize / 4);
} else if (blockflag > previous_window) {
- vc->dsp.vector_fmul_window(ret, saved, buf, win, 0, bs0 / 4);
+ vc->dsp.vector_fmul_window(ret, saved, buf, win, bs0 / 4);
memcpy(ret+bs0/2, buf+bs0/4, ((bs1-bs0)/4) * sizeof(float));
} else {
memcpy(ret, saved, ((bs1 - bs0) / 4) * sizeof(float));
- vc->dsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, 0, bs0 / 4);
+ vc->dsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, bs0 / 4);
}
memcpy(saved, buf + blocksize / 4, blocksize / 4 * sizeof(float));
}
@@ -1636,7 +1633,8 @@ static int vorbis_decode_frame(AVCodecContext *avccontext,
len * ff_vorbis_channel_layout_offsets[vc->audio_channels - 1][i];
}
- vc->dsp.float_to_int16_interleave(data, channel_ptrs, len, vc->audio_channels);
+ vc->fmt_conv.float_to_int16_interleave(data, channel_ptrs, len,
+ vc->audio_channels);
*data_size = len * 2 * vc->audio_channels;
return buf_size ;
diff --git a/mplayer/ffmpeg/libavcodec/vp3.c b/mplayer/ffmpeg/libavcodec/vp3.c
index 06f55f6d..97e5d643 100644
--- a/mplayer/ffmpeg/libavcodec/vp3.c
+++ b/mplayer/ffmpeg/libavcodec/vp3.c
@@ -33,13 +33,14 @@
#include
#include
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "get_bits.h"
#include "vp3data.h"
#include "xiph.h"
+#include "thread.h"
#define FRAGMENT_PIXELS 8
@@ -236,8 +237,7 @@ typedef struct Vp3DecodeContext {
* is coded. */
unsigned char *macroblock_coding;
- uint8_t edge_emu_buffer[9*2048]; //FIXME dynamic alloc
- int8_t qscale_table[2048]; //FIXME dynamic alloc (width+15)/16
+ uint8_t *edge_emu_buffer;
/* Huffman decode */
int hti;
@@ -324,8 +324,6 @@ static void init_dequantizer(Vp3DecodeContext *s, int qpi)
s->qmat[qpi][inter][plane][0] = s->qmat[0][inter][plane][0];
}
}
-
- memset(s->qscale_table, (FFMAX(s->qmat[0][0][0][1], s->qmat[0][0][1][1])+8)/16, 512); //FIXME finetune
}
/*
@@ -1318,6 +1316,15 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
int h, cy;
int offset[4];
+ if (HAVE_PTHREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) {
+ int y_flipped = s->flipped_image ? s->avctx->height-y : y;
+
+ // At the end of the frame, report INT_MAX instead of the height of the frame.
+ // This makes the other threads' ff_thread_await_progress() calls cheaper, because
+ // they don't have to clip their values.
+ ff_thread_report_progress(&s->current_frame, y_flipped==s->avctx->height ? INT_MAX : y_flipped-1, 0);
+ }
+
if(s->avctx->draw_horiz_band==NULL)
return;
@@ -1339,13 +1346,35 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
s->avctx->draw_horiz_band(s->avctx, &s->current_frame, offset, y, 3, h);
}
+/**
+ * Wait for the reference frame of the current fragment.
+ * The progress value is in luma pixel rows.
+ */
+static void await_reference_row(Vp3DecodeContext *s, Vp3Fragment *fragment, int motion_y, int y)
+{
+ AVFrame *ref_frame;
+ int ref_row;
+ int border = motion_y&1;
+
+ if (fragment->coding_method == MODE_USING_GOLDEN ||
+ fragment->coding_method == MODE_GOLDEN_MV)
+ ref_frame = &s->golden_frame;
+ else
+ ref_frame = &s->last_frame;
+
+ ref_row = y + (motion_y>>1);
+ ref_row = FFMAX(FFABS(ref_row), ref_row + 8 + border);
+
+ ff_thread_await_progress(ref_frame, ref_row, 0);
+}
+
/*
* Perform the final rendering for a particular slice of data.
* The slice number ranges from 0..(c_superblock_height - 1).
*/
static void render_slice(Vp3DecodeContext *s, int slice)
{
- int x, y, i, j;
+ int x, y, i, j, fragment;
LOCAL_ALIGNED_16(DCTELEM, block, [64]);
int motion_x = 0xdeadbeef, motion_y = 0xdeadbeef;
int motion_halfpel_index;
@@ -1371,15 +1400,12 @@ static void render_slice(Vp3DecodeContext *s, int slice)
int fragment_width = s->fragment_width[!!plane];
int fragment_height = s->fragment_height[!!plane];
int fragment_start = s->fragment_start[plane];
+ int do_await = !plane && HAVE_PTHREADS && (s->avctx->active_thread_type&FF_THREAD_FRAME);
if (!s->flipped_image) stride = -stride;
if (CONFIG_GRAY && plane && (s->avctx->flags & CODEC_FLAG_GRAY))
continue;
-
- if(FFABS(stride) > 2048)
- return; //various tables are fixed size
-
/* for each superblock row in the slice (both of them)... */
for (; sb_y < slice_height; sb_y++) {
@@ -1390,8 +1416,9 @@ static void render_slice(Vp3DecodeContext *s, int slice)
for (j = 0; j < 16; j++) {
x = 4*sb_x + hilbert_offset[j][0];
y = 4*sb_y + hilbert_offset[j][1];
+ fragment = y*fragment_width + x;
- i = fragment_start + y*fragment_width + x;
+ i = fragment_start + fragment;
// bounds check
if (x >= fragment_width || y >= fragment_height)
@@ -1399,6 +1426,9 @@ static void render_slice(Vp3DecodeContext *s, int slice)
first_pixel = 8*y*stride + 8*x;
+ if (do_await && s->all_fragments[i].coding_method != MODE_INTRA)
+ await_reference_row(s, &s->all_fragments[i], motion_val[fragment][1], (16*y) >> s->chroma_y_shift);
+
/* transform if this block was coded */
if (s->all_fragments[i].coding_method != MODE_COPY) {
if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) ||
@@ -1415,8 +1445,8 @@ static void render_slice(Vp3DecodeContext *s, int slice)
if ((s->all_fragments[i].coding_method > MODE_INTRA) &&
(s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) {
int src_x, src_y;
- motion_x = motion_val[y*fragment_width + x][0];
- motion_y = motion_val[y*fragment_width + x][1];
+ motion_x = motion_val[fragment][0];
+ motion_y = motion_val[fragment][1];
src_x= (motion_x>>1) + 8*x;
src_y= (motion_y>>1) + 8*y;
@@ -1429,8 +1459,7 @@ static void render_slice(Vp3DecodeContext *s, int slice)
if(src_x<0 || src_y<0 || src_x + 9 >= plane_width || src_y + 9 >= plane_height){
uint8_t *temp= s->edge_emu_buffer;
- if(stride<0) temp -= 9*stride;
- else temp += 9*stride;
+ if(stride<0) temp -= 8*stride;
s->dsp.emulated_edge_mc(temp, motion_source, stride, 9, 9, src_x, src_y, plane_width, plane_height);
motion_source= temp;
@@ -1510,6 +1539,38 @@ static void render_slice(Vp3DecodeContext *s, int slice)
vp3_draw_horiz_band(s, FFMIN((32 << s->chroma_y_shift) * (slice + 1) -16, s->height-16));
}
+/// Allocate tables for per-frame data in Vp3DecodeContext
+static av_cold int allocate_tables(AVCodecContext *avctx)
+{
+ Vp3DecodeContext *s = avctx->priv_data;
+ int y_fragment_count, c_fragment_count;
+
+ y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
+ c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
+
+ s->superblock_coding = av_malloc(s->superblock_count);
+ s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
+ s->coded_fragment_list[0] = av_malloc(s->fragment_count * sizeof(int));
+ s->dct_tokens_base = av_malloc(64*s->fragment_count * sizeof(*s->dct_tokens_base));
+ s->motion_val[0] = av_malloc(y_fragment_count * sizeof(*s->motion_val[0]));
+ s->motion_val[1] = av_malloc(c_fragment_count * sizeof(*s->motion_val[1]));
+
+ /* work out the block mapping tables */
+ s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
+ s->macroblock_coding = av_malloc(s->macroblock_count + 1);
+
+ if (!s->superblock_coding || !s->all_fragments || !s->dct_tokens_base ||
+ !s->coded_fragment_list[0] || !s->superblock_fragments || !s->macroblock_coding ||
+ !s->motion_val[0] || !s->motion_val[1]) {
+ vp3_decode_end(avctx);
+ return -1;
+ }
+
+ init_block_mapping(s);
+
+ return 0;
+}
+
/*
* This is the ffmpeg/libavcodec API init function.
*/
@@ -1559,7 +1620,6 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2);
s->u_superblock_start = s->y_superblock_count;
s->v_superblock_start = s->u_superblock_start + s->c_superblock_count;
- s->superblock_coding = av_malloc(s->superblock_count);
s->macroblock_width = (s->width + 15) / 16;
s->macroblock_height = (s->height + 15) / 16;
@@ -1577,18 +1637,6 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
s->fragment_start[1] = y_fragment_count;
s->fragment_start[2] = y_fragment_count + c_fragment_count;
- s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
- s->coded_fragment_list[0] = av_malloc(s->fragment_count * sizeof(int));
- s->dct_tokens_base = av_malloc(64*s->fragment_count * sizeof(*s->dct_tokens_base));
- s->motion_val[0] = av_malloc(y_fragment_count * sizeof(*s->motion_val[0]));
- s->motion_val[1] = av_malloc(c_fragment_count * sizeof(*s->motion_val[1]));
-
- if (!s->superblock_coding || !s->all_fragments || !s->dct_tokens_base ||
- !s->coded_fragment_list[0] || !s->motion_val[0] || !s->motion_val[1]) {
- vp3_decode_end(avctx);
- return -1;
- }
-
if (!s->theora_tables)
{
for (i = 0; i < 64; i++) {
@@ -1688,28 +1736,92 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
&motion_vector_vlc_table[0][1], 2, 1,
&motion_vector_vlc_table[0][0], 2, 1, 0);
- /* work out the block mapping tables */
- s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
- s->macroblock_coding = av_malloc(s->macroblock_count + 1);
- if (!s->superblock_fragments || !s->macroblock_coding) {
- vp3_decode_end(avctx);
- return -1;
- }
- init_block_mapping(s);
-
for (i = 0; i < 3; i++) {
s->current_frame.data[i] = NULL;
s->last_frame.data[i] = NULL;
s->golden_frame.data[i] = NULL;
}
- return 0;
+ return allocate_tables(avctx);
vlc_fail:
av_log(avctx, AV_LOG_FATAL, "Invalid huffman table\n");
return -1;
}
+/// Release and shuffle frames after decode finishes
+static void update_frames(AVCodecContext *avctx)
+{
+ Vp3DecodeContext *s = avctx->priv_data;
+
+ /* release the last frame, if it is allocated and if it is not the
+ * golden frame */
+ if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY)
+ ff_thread_release_buffer(avctx, &s->last_frame);
+
+ /* shuffle frames (last = current) */
+ s->last_frame= s->current_frame;
+
+ if (s->keyframe) {
+ if (s->golden_frame.data[0])
+ ff_thread_release_buffer(avctx, &s->golden_frame);
+ s->golden_frame = s->current_frame;
+ s->last_frame.type = FF_BUFFER_TYPE_COPY;
+ }
+
+ s->current_frame.data[0]= NULL; /* ensure that we catch any access to this released frame */
+}
+
+static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
+{
+ Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data;
+ int qps_changed = 0, i, err;
+
+ if (!s1->current_frame.data[0]
+ ||s->width != s1->width
+ ||s->height!= s1->height)
+ return -1;
+
+ if (s != s1) {
+ // init tables if the first frame hasn't been decoded
+ if (!s->current_frame.data[0]) {
+ int y_fragment_count, c_fragment_count;
+ s->avctx = dst;
+ err = allocate_tables(dst);
+ if (err)
+ return err;
+ y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
+ c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
+ memcpy(s->motion_val[0], s1->motion_val[0], y_fragment_count * sizeof(*s->motion_val[0]));
+ memcpy(s->motion_val[1], s1->motion_val[1], c_fragment_count * sizeof(*s->motion_val[1]));
+ }
+
+#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
+
+ // copy previous frame data
+ copy_fields(s, s1, golden_frame, dsp);
+
+ // copy qscale data if necessary
+ for (i = 0; i < 3; i++) {
+ if (s->qps[i] != s1->qps[1]) {
+ qps_changed = 1;
+ memcpy(&s->qmat[i], &s1->qmat[i], sizeof(s->qmat[i]));
+ }
+ }
+
+ if (s->qps[0] != s1->qps[0])
+ memcpy(&s->bounding_values_array, &s1->bounding_values_array, sizeof(s->bounding_values_array));
+
+ if (qps_changed)
+ copy_fields(s, s1, qps, superblock_count);
+#undef copy_fields
+ }
+
+ update_frames(dst);
+
+ return 0;
+}
+
/*
* This is the ffmpeg/libavcodec API frame decode function.
*/
@@ -1765,11 +1877,14 @@ static int vp3_decode_frame(AVCodecContext *avctx,
s->current_frame.reference = 3;
s->current_frame.pict_type = s->keyframe ? FF_I_TYPE : FF_P_TYPE;
- if (avctx->get_buffer(avctx, &s->current_frame) < 0) {
+ if (ff_thread_get_buffer(avctx, &s->current_frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
goto error;
}
+ if (!s->edge_emu_buffer)
+ s->edge_emu_buffer = av_malloc(9*FFABS(s->current_frame.linesize[0]));
+
if (s->keyframe) {
if (!s->theora)
{
@@ -1794,19 +1909,18 @@ static int vp3_decode_frame(AVCodecContext *avctx,
s->golden_frame.reference = 3;
s->golden_frame.pict_type = FF_I_TYPE;
- if (avctx->get_buffer(avctx, &s->golden_frame) < 0) {
+ if (ff_thread_get_buffer(avctx, &s->golden_frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
goto error;
}
s->last_frame = s->golden_frame;
s->last_frame.type = FF_BUFFER_TYPE_COPY;
+ ff_thread_report_progress(&s->last_frame, INT_MAX, 0);
}
}
- s->current_frame.qscale_table= s->qscale_table; //FIXME allocate individual tables per AVFrame
- s->current_frame.qstride= 0;
-
memset(s->all_fragments, 0, s->fragment_count * sizeof(Vp3Fragment));
+ ff_thread_finish_setup(avctx);
if (unpack_superblocks(s, &gb)){
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n");
@@ -1851,28 +1965,17 @@ static int vp3_decode_frame(AVCodecContext *avctx,
*data_size=sizeof(AVFrame);
*(AVFrame*)data= s->current_frame;
- /* release the last frame, if it is allocated and if it is not the
- * golden frame */
- if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY)
- avctx->release_buffer(avctx, &s->last_frame);
-
- /* shuffle frames (last = current) */
- s->last_frame= s->current_frame;
-
- if (s->keyframe) {
- if (s->golden_frame.data[0])
- avctx->release_buffer(avctx, &s->golden_frame);
- s->golden_frame = s->current_frame;
- s->last_frame.type = FF_BUFFER_TYPE_COPY;
- }
-
- s->current_frame.data[0]= NULL; /* ensure that we catch any access to this released frame */
+ if (!HAVE_PTHREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME))
+ update_frames(avctx);
return buf_size;
error:
- if (s->current_frame.data[0])
+ ff_thread_report_progress(&s->current_frame, INT_MAX, 0);
+
+ if (!HAVE_PTHREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME))
avctx->release_buffer(avctx, &s->current_frame);
+
return -1;
}
@@ -1884,6 +1987,9 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
Vp3DecodeContext *s = avctx->priv_data;
int i;
+ if (avctx->is_copy && !s->current_frame.data[0])
+ return 0;
+
av_free(s->superblock_coding);
av_free(s->all_fragments);
av_free(s->coded_fragment_list[0]);
@@ -1892,6 +1998,9 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
av_free(s->macroblock_coding);
av_free(s->motion_val[0]);
av_free(s->motion_val[1]);
+ av_free(s->edge_emu_buffer);
+
+ if (avctx->is_copy) return 0;
for (i = 0; i < 16; i++) {
free_vlc(&s->dc_vlc[i]);
@@ -1908,9 +2017,9 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
/* release all frames */
if (s->golden_frame.data[0])
- avctx->release_buffer(avctx, &s->golden_frame);
+ ff_thread_release_buffer(avctx, &s->golden_frame);
if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY)
- avctx->release_buffer(avctx, &s->last_frame);
+ ff_thread_release_buffer(avctx, &s->last_frame);
/* no need to release the current_frame since it will always be pointing
* to the same frame as either the golden or last frame */
@@ -2221,9 +2330,10 @@ AVCodec ff_theora_decoder = {
NULL,
vp3_decode_end,
vp3_decode_frame,
- CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
+ CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
NULL,
.long_name = NULL_IF_CONFIG_SMALL("Theora"),
+ .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
};
#endif
@@ -2236,7 +2346,8 @@ AVCodec ff_vp3_decoder = {
NULL,
vp3_decode_end,
vp3_decode_frame,
- CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
+ CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
NULL,
.long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
+ .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
};
diff --git a/mplayer/ffmpeg/libavcodec/vp56.h b/mplayer/ffmpeg/libavcodec/vp56.h
index da6b1b64..d1735e56 100644
--- a/mplayer/ffmpeg/libavcodec/vp56.h
+++ b/mplayer/ffmpeg/libavcodec/vp56.h
@@ -201,7 +201,9 @@ static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c)
return code_word;
}
-#if ARCH_X86
+#if ARCH_ARM
+#include "arm/vp56_arith.h"
+#elif ARCH_X86
#include "x86/vp56_arith.h"
#endif
@@ -221,6 +223,7 @@ static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
}
#endif
+#ifndef vp56_rac_get_prob_branchy
// branchy variant, to be used where there's a branch based on the bit decoded
static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int prob)
{
@@ -238,6 +241,7 @@ static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int pro
c->code_word = code_word;
return 0;
}
+#endif
static av_always_inline int vp56_rac_get(VP56RangeCoder *c)
{
diff --git a/mplayer/ffmpeg/libavcodec/vp8.c b/mplayer/ffmpeg/libavcodec/vp8.c
index ef4e270f..f71a7b77 100644
--- a/mplayer/ffmpeg/libavcodec/vp8.c
+++ b/mplayer/ffmpeg/libavcodec/vp8.c
@@ -22,183 +22,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
-#include "vp56.h"
+#include "vp8.h"
#include "vp8data.h"
-#include "vp8dsp.h"
-#include "h264pred.h"
#include "rectangle.h"
-typedef struct {
- uint8_t filter_level;
- uint8_t inner_limit;
- uint8_t inner_filter;
-} VP8FilterStrength;
-
-typedef struct {
- uint8_t skip;
- // todo: make it possible to check for at least (i4x4 or split_mv)
- // in one op. are others needed?
- uint8_t mode;
- uint8_t ref_frame;
- uint8_t partitioning;
- VP56mv mv;
- VP56mv bmv[16];
-} VP8Macroblock;
-
-typedef struct {
- AVCodecContext *avctx;
- DSPContext dsp;
- VP8DSPContext vp8dsp;
- H264PredContext hpc;
- vp8_mc_func put_pixels_tab[3][3][3];
- AVFrame frames[4];
- AVFrame *framep[4];
- uint8_t *edge_emu_buffer;
- VP56RangeCoder c; ///< header context, includes mb modes and motion vectors
- int profile;
-
- int mb_width; /* number of horizontal MB */
- int mb_height; /* number of vertical MB */
- int linesize;
- int uvlinesize;
-
- int keyframe;
- int invisible;
- int update_last; ///< update VP56_FRAME_PREVIOUS with the current one
- int update_golden; ///< VP56_FRAME_NONE if not updated, or which frame to copy if so
- int update_altref;
- int deblock_filter;
-
- /**
- * If this flag is not set, all the probability updates
- * are discarded after this frame is decoded.
- */
- int update_probabilities;
-
- /**
- * All coefficients are contained in separate arith coding contexts.
- * There can be 1, 2, 4, or 8 of these after the header context.
- */
- int num_coeff_partitions;
- VP56RangeCoder coeff_partition[8];
-
- VP8Macroblock *macroblocks;
- VP8Macroblock *macroblocks_base;
- VP8FilterStrength *filter_strength;
-
- uint8_t *intra4x4_pred_mode_top;
- uint8_t intra4x4_pred_mode_left[4];
- uint8_t *segmentation_map;
-
- /**
- * Cache of the top row needed for intra prediction
- * 16 for luma, 8 for each chroma plane
- */
- uint8_t (*top_border)[16+8+8];
-
- /**
- * For coeff decode, we need to know whether the above block had non-zero
- * coefficients. This means for each macroblock, we need data for 4 luma
- * blocks, 2 u blocks, 2 v blocks, and the luma dc block, for a total of 9
- * per macroblock. We keep the last row in top_nnz.
- */
- uint8_t (*top_nnz)[9];
- DECLARE_ALIGNED(8, uint8_t, left_nnz)[9];
-
- /**
- * This is the index plus one of the last non-zero coeff
- * for each of the blocks in the current macroblock.
- * So, 0 -> no coeffs
- * 1 -> dc-only (special transform)
- * 2+-> full transform
- */
- DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4];
- DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16];
- DECLARE_ALIGNED(16, DCTELEM, block_dc)[16];
- uint8_t intra4x4_pred_mode_mb[16];
-
- int chroma_pred_mode; ///< 8x8c pred mode of the current macroblock
- int segment; ///< segment of the current macroblock
-
- int mbskip_enabled;
- int sign_bias[4]; ///< one state [0, 1] per ref frame type
- int ref_count[3];
-
- /**
- * Base parameters for segmentation, i.e. per-macroblock parameters.
- * These must be kept unchanged even if segmentation is not used for
- * a frame, since the values persist between interframes.
- */
- struct {
- int enabled;
- int absolute_vals;
- int update_map;
- int8_t base_quant[4];
- int8_t filter_level[4]; ///< base loop filter level
- } segmentation;
-
- /**
- * Macroblocks can have one of 4 different quants in a frame when
- * segmentation is enabled.
- * If segmentation is disabled, only the first segment's values are used.
- */
- struct {
- // [0] - DC qmul [1] - AC qmul
- int16_t luma_qmul[2];
- int16_t luma_dc_qmul[2]; ///< luma dc-only block quant
- int16_t chroma_qmul[2];
- } qmat[4];
-
- struct {
- int simple;
- int level;
- int sharpness;
- } filter;
-
- struct {
- int enabled; ///< whether each mb can have a different strength based on mode/ref
-
- /**
- * filter strength adjustment for the following macroblock modes:
- * [0] - i4x4
- * [1] - zero mv
- * [2] - inter modes except for zero or split mv
- * [3] - split mv
- * i16x16 modes never have any adjustment
- */
- int8_t mode[4];
-
- /**
- * filter strength adjustment for macroblocks that reference:
- * [0] - intra / VP56_FRAME_CURRENT
- * [1] - VP56_FRAME_PREVIOUS
- * [2] - VP56_FRAME_GOLDEN
- * [3] - altref / VP56_FRAME_GOLDEN2
- */
- int8_t ref[4];
- } lf_delta;
-
- /**
- * These are all of the updatable probabilities for binary decisions.
- * They are only implictly reset on keyframes, making it quite likely
- * for an interframe to desync if a prior frame's header was corrupt
- * or missing outright!
- */
- struct {
- uint8_t segmentid[3];
- uint8_t mbskip;
- uint8_t intra;
- uint8_t last;
- uint8_t golden;
- uint8_t pred16x16[4];
- uint8_t pred8x8c[3];
- /* Padded to allow overreads */
- uint8_t token[4][17][3][NUM_DCT_TOKENS-1];
- uint8_t mvc[2][19];
- } prob[2];
-} VP8Context;
+#if ARCH_ARM
+# include "arm/vp8.h"
+#endif
static void vp8_decode_flush(AVCodecContext *avctx)
{
@@ -278,7 +110,7 @@ static void update_lf_deltas(VP8Context *s)
for (i = 0; i < 4; i++)
s->lf_delta.ref[i] = vp8_rac_get_sint(c, 6);
- for (i = 0; i < 4; i++)
+ for (i = MODE_I4x4; i <= VP8_MVMODE_SPLIT; i++)
s->lf_delta.mode[i] = vp8_rac_get_sint(c, 6);
}
@@ -517,76 +349,10 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
return 0;
}
-static av_always_inline
-void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *src, int mb_x, int mb_y)
+static av_always_inline void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *src)
{
-#define MARGIN (16 << 2)
- dst->x = av_clip(src->x, -((mb_x << 6) + MARGIN),
- ((s->mb_width - 1 - mb_x) << 6) + MARGIN);
- dst->y = av_clip(src->y, -((mb_y << 6) + MARGIN),
- ((s->mb_height - 1 - mb_y) << 6) + MARGIN);
-}
-
-static av_always_inline
-void find_near_mvs(VP8Context *s, VP8Macroblock *mb,
- VP56mv near[2], VP56mv *best, uint8_t cnt[4])
-{
- VP8Macroblock *mb_edge[3] = { mb + 2 /* top */,
- mb - 1 /* left */,
- mb + 1 /* top-left */ };
- enum { EDGE_TOP, EDGE_LEFT, EDGE_TOPLEFT };
- VP56mv near_mv[4] = {{ 0 }};
- enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
- int idx = CNT_ZERO;
- int best_idx = CNT_ZERO;
- int cur_sign_bias = s->sign_bias[mb->ref_frame];
- int *sign_bias = s->sign_bias;
-
- /* Process MB on top, left and top-left */
- #define MV_EDGE_CHECK(n)\
- {\
- VP8Macroblock *edge = mb_edge[n];\
- int edge_ref = edge->ref_frame;\
- if (edge_ref != VP56_FRAME_CURRENT) {\
- uint32_t mv = AV_RN32A(&edge->mv);\
- if (mv) {\
- if (cur_sign_bias != sign_bias[edge_ref]) {\
- /* SWAR negate of the values in mv. */\
- mv = ~mv;\
- mv = ((mv&0x7fff7fff) + 0x00010001) ^ (mv&0x80008000);\
- }\
- if (!n || mv != AV_RN32A(&near_mv[idx]))\
- AV_WN32A(&near_mv[++idx], mv);\
- cnt[idx] += 1 + (n != 2);\
- } else\
- cnt[CNT_ZERO] += 1 + (n != 2);\
- }\
- }
- MV_EDGE_CHECK(0)
- MV_EDGE_CHECK(1)
- MV_EDGE_CHECK(2)
-
- /* If we have three distinct MVs, merge first and last if they're the same */
- if (cnt[CNT_SPLITMV] && AV_RN32A(&near_mv[1+EDGE_TOP]) == AV_RN32A(&near_mv[1+EDGE_TOPLEFT]))
- cnt[CNT_NEAREST] += 1;
-
- cnt[CNT_SPLITMV] = ((mb_edge[EDGE_LEFT]->mode == VP8_MVMODE_SPLIT) +
- (mb_edge[EDGE_TOP]->mode == VP8_MVMODE_SPLIT)) * 2 +
- (mb_edge[EDGE_TOPLEFT]->mode == VP8_MVMODE_SPLIT);
-
- /* Swap near and nearest if necessary */
- if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
- FFSWAP(uint8_t, cnt[CNT_NEAREST], cnt[CNT_NEAR]);
- FFSWAP( VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);
- }
-
- /* Choose the best mv out of 0,0 and the nearest mv */
- if (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])
- best_idx = CNT_NEAREST;
-
- mb->mv = near_mv[best_idx];
- near[0] = near_mv[CNT_NEAREST];
- near[1] = near_mv[CNT_NEAR];
+ dst->x = av_clip(src->x, s->mv_min.x, s->mv_max.x);
+ dst->y = av_clip(src->y, s->mv_min.y, s->mv_max.y);
}
/**
@@ -698,6 +464,95 @@ int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb)
return num;
}
+static av_always_inline
+void decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y)
+{
+ VP8Macroblock *mb_edge[3] = { mb + 2 /* top */,
+ mb - 1 /* left */,
+ mb + 1 /* top-left */ };
+ enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
+ enum { EDGE_TOP, EDGE_LEFT, EDGE_TOPLEFT };
+ int idx = CNT_ZERO;
+ int cur_sign_bias = s->sign_bias[mb->ref_frame];
+ int *sign_bias = s->sign_bias;
+ VP56mv near_mv[4];
+ uint8_t cnt[4] = { 0 };
+ VP56RangeCoder *c = &s->c;
+
+ AV_ZERO32(&near_mv[0]);
+ AV_ZERO32(&near_mv[1]);
+
+ /* Process MB on top, left and top-left */
+ #define MV_EDGE_CHECK(n)\
+ {\
+ VP8Macroblock *edge = mb_edge[n];\
+ int edge_ref = edge->ref_frame;\
+ if (edge_ref != VP56_FRAME_CURRENT) {\
+ uint32_t mv = AV_RN32A(&edge->mv);\
+ if (mv) {\
+ if (cur_sign_bias != sign_bias[edge_ref]) {\
+ /* SWAR negate of the values in mv. */\
+ mv = ~mv;\
+ mv = ((mv&0x7fff7fff) + 0x00010001) ^ (mv&0x80008000);\
+ }\
+ if (!n || mv != AV_RN32A(&near_mv[idx]))\
+ AV_WN32A(&near_mv[++idx], mv);\
+ cnt[idx] += 1 + (n != 2);\
+ } else\
+ cnt[CNT_ZERO] += 1 + (n != 2);\
+ }\
+ }
+
+ MV_EDGE_CHECK(0)
+ MV_EDGE_CHECK(1)
+ MV_EDGE_CHECK(2)
+
+ mb->partitioning = VP8_SPLITMVMODE_NONE;
+ if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_ZERO]][0])) {
+ mb->mode = VP8_MVMODE_MV;
+
+ /* If we have three distinct MVs, merge first and last if they're the same */
+ if (cnt[CNT_SPLITMV] && AV_RN32A(&near_mv[1+EDGE_TOP]) == AV_RN32A(&near_mv[1+EDGE_TOPLEFT]))
+ cnt[CNT_NEAREST] += 1;
+
+ /* Swap near and nearest if necessary */
+ if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
+ FFSWAP(uint8_t, cnt[CNT_NEAREST], cnt[CNT_NEAR]);
+ FFSWAP( VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);
+ }
+
+ if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAREST]][1])) {
+ if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAR]][2])) {
+
+ /* Choose the best mv out of 0,0 and the nearest mv */
+ clamp_mv(s, &mb->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);
+ cnt[CNT_SPLITMV] = ((mb_edge[EDGE_LEFT]->mode == VP8_MVMODE_SPLIT) +
+ (mb_edge[EDGE_TOP]->mode == VP8_MVMODE_SPLIT)) * 2 +
+ (mb_edge[EDGE_TOPLEFT]->mode == VP8_MVMODE_SPLIT);
+
+ if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_SPLITMV]][3])) {
+ mb->mode = VP8_MVMODE_SPLIT;
+ mb->mv = mb->bmv[decode_splitmvs(s, c, mb) - 1];
+ } else {
+ mb->mv.y += read_mv_component(c, s->prob->mvc[0]);
+ mb->mv.x += read_mv_component(c, s->prob->mvc[1]);
+ mb->bmv[0] = mb->mv;
+ }
+ } else {
+ clamp_mv(s, &mb->mv, &near_mv[CNT_NEAR]);
+ mb->bmv[0] = mb->mv;
+ }
+ } else {
+ clamp_mv(s, &mb->mv, &near_mv[CNT_NEAREST]);
+ mb->bmv[0] = mb->mv;
+ }
+ } else {
+ mb->mode = VP8_MVMODE_ZERO;
+ AV_ZERO32(&mb->mv);
+ mb->bmv[0] = mb->mv;
+ }
+}
+
static av_always_inline
void decode_intra4x4_modes(VP8Context *s, VP56RangeCoder *c,
int mb_x, int keyframe)
@@ -748,9 +603,6 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_
s->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, vp8_pred8x8c_prob_intra);
mb->ref_frame = VP56_FRAME_CURRENT;
} else if (vp56_rac_get_prob_branchy(c, s->prob->intra)) {
- VP56mv near[2], best;
- uint8_t cnt[4] = { 0 };
-
// inter MB, 16.2
if (vp56_rac_get_prob_branchy(c, s->prob->last))
mb->ref_frame = vp56_rac_get_prob(c, s->prob->golden) ?
@@ -760,36 +612,7 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_
s->ref_count[mb->ref_frame-1]++;
// motion vectors, 16.3
- find_near_mvs(s, mb, near, &best, cnt);
- if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[0]][0])) {
- if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[1]][1])) {
- if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[2]][2])) {
- if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[3]][3])) {
- mb->mode = VP8_MVMODE_SPLIT;
- clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y);
- mb->mv = mb->bmv[decode_splitmvs(s, c, mb) - 1];
- } else {
- mb->mode = VP8_MVMODE_NEW;
- clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y);
- mb->mv.y += read_mv_component(c, s->prob->mvc[0]);
- mb->mv.x += read_mv_component(c, s->prob->mvc[1]);
- }
- } else {
- mb->mode = VP8_MVMODE_NEAR;
- clamp_mv(s, &mb->mv, &near[1], mb_x, mb_y);
- }
- } else {
- mb->mode = VP8_MVMODE_NEAREST;
- clamp_mv(s, &mb->mv, &near[0], mb_x, mb_y);
- }
- } else {
- mb->mode = VP8_MVMODE_ZERO;
- AV_ZERO32(&mb->mv);
- }
- if (mb->mode != VP8_MVMODE_SPLIT) {
- mb->partitioning = VP8_SPLITMVMODE_NONE;
- mb->bmv[0] = mb->mv;
- }
+ decode_mvs(s, mb, mb_x, mb_y);
} else {
// intra MB, 16.1
mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16);
@@ -804,6 +627,7 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_
}
}
+#ifndef decode_block_coeffs_internal
/**
* @param c arithmetic bitstream reader context
* @param block destination for block coefficients
@@ -857,7 +681,7 @@ static int decode_block_coeffs_internal(VP56RangeCoder *c, DCTELEM block[16],
int b = vp56_rac_get_prob(c, token_prob[9+a]);
int cat = (a<<1) + b;
coeff = 3 + (8<filter.simple, 0);
}
+static const uint8_t subpel_idx[3][8] = {
+ { 0, 1, 2, 1, 2, 1, 2, 1 }, // nr. of left extra pixels,
+ // also function pointer index
+ { 0, 3, 5, 3, 5, 3, 5, 3 }, // nr. of extra pixels required
+ { 0, 2, 3, 2, 3, 2, 3, 2 }, // nr. of right extra pixels
+};
+
/**
* Generic MC function.
*
@@ -1211,32 +1043,26 @@ void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
* @param mc_func motion compensation function pointers (bilinear or sixtap MC)
*/
static av_always_inline
-void vp8_mc(VP8Context *s, int luma,
- uint8_t *dst, uint8_t *src, const VP56mv *mv,
- int x_off, int y_off, int block_w, int block_h,
- int width, int height, int linesize,
- vp8_mc_func mc_func[3][3])
+void vp8_mc_luma(VP8Context *s, uint8_t *dst, uint8_t *src, const VP56mv *mv,
+ int x_off, int y_off, int block_w, int block_h,
+ int width, int height, int linesize,
+ vp8_mc_func mc_func[3][3])
{
if (AV_RN32A(mv)) {
- static const uint8_t idx[3][8] = {
- { 0, 1, 2, 1, 2, 1, 2, 1 }, // nr. of left extra pixels,
- // also function pointer index
- { 0, 3, 5, 3, 5, 3, 5, 3 }, // nr. of extra pixels required
- { 0, 2, 3, 2, 3, 2, 3, 2 }, // nr. of right extra pixels
- };
- int mx = (mv->x << luma)&7, mx_idx = idx[0][mx];
- int my = (mv->y << luma)&7, my_idx = idx[0][my];
- x_off += mv->x >> (3 - luma);
- y_off += mv->y >> (3 - luma);
+ int mx = (mv->x << 1)&7, mx_idx = subpel_idx[0][mx];
+ int my = (mv->y << 1)&7, my_idx = subpel_idx[0][my];
+
+ x_off += mv->x >> 2;
+ y_off += mv->y >> 2;
// edge emulation
src += y_off * linesize + x_off;
- if (x_off < mx_idx || x_off >= width - block_w - idx[2][mx] ||
- y_off < my_idx || y_off >= height - block_h - idx[2][my]) {
+ if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||
+ y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {
s->dsp.emulated_edge_mc(s->edge_emu_buffer, src - my_idx * linesize - mx_idx, linesize,
- block_w + idx[1][mx], block_h + idx[1][my],
- x_off - mx_idx, y_off - my_idx, width, height);
+ block_w + subpel_idx[1][mx], block_h + subpel_idx[1][my],
+ x_off - mx_idx, y_off - my_idx, width, height);
src = s->edge_emu_buffer + mx_idx + linesize * my_idx;
}
mc_func[my_idx][mx_idx](dst, linesize, src, linesize, block_h, mx, my);
@@ -1244,6 +1070,45 @@ void vp8_mc(VP8Context *s, int luma,
mc_func[0][0](dst, linesize, src + y_off * linesize + x_off, linesize, block_h, 0, 0);
}
+static av_always_inline
+void vp8_mc_chroma(VP8Context *s, uint8_t *dst1, uint8_t *dst2, uint8_t *src1,
+ uint8_t *src2, const VP56mv *mv, int x_off, int y_off,
+ int block_w, int block_h, int width, int height, int linesize,
+ vp8_mc_func mc_func[3][3])
+{
+ if (AV_RN32A(mv)) {
+ int mx = mv->x&7, mx_idx = subpel_idx[0][mx];
+ int my = mv->y&7, my_idx = subpel_idx[0][my];
+
+ x_off += mv->x >> 3;
+ y_off += mv->y >> 3;
+
+ // edge emulation
+ src1 += y_off * linesize + x_off;
+ src2 += y_off * linesize + x_off;
+ if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||
+ y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src1 - my_idx * linesize - mx_idx, linesize,
+ block_w + subpel_idx[1][mx], block_h + subpel_idx[1][my],
+ x_off - mx_idx, y_off - my_idx, width, height);
+ src1 = s->edge_emu_buffer + mx_idx + linesize * my_idx;
+ mc_func[my_idx][mx_idx](dst1, linesize, src1, linesize, block_h, mx, my);
+
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src2 - my_idx * linesize - mx_idx, linesize,
+ block_w + subpel_idx[1][mx], block_h + subpel_idx[1][my],
+ x_off - mx_idx, y_off - my_idx, width, height);
+ src2 = s->edge_emu_buffer + mx_idx + linesize * my_idx;
+ mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);
+ } else {
+ mc_func[my_idx][mx_idx](dst1, linesize, src1, linesize, block_h, mx, my);
+ mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);
+ }
+ } else {
+ mc_func[0][0](dst1, linesize, src1 + y_off * linesize + x_off, linesize, block_h, 0, 0);
+ mc_func[0][0](dst2, linesize, src2 + y_off * linesize + x_off, linesize, block_h, 0, 0);
+ }
+}
+
static av_always_inline
void vp8_mc_part(VP8Context *s, uint8_t *dst[3],
AVFrame *ref_frame, int x_off, int y_off,
@@ -1254,10 +1119,10 @@ void vp8_mc_part(VP8Context *s, uint8_t *dst[3],
VP56mv uvmv = *mv;
/* Y */
- vp8_mc(s, 1, dst[0] + by_off * s->linesize + bx_off,
- ref_frame->data[0], mv, x_off + bx_off, y_off + by_off,
- block_w, block_h, width, height, s->linesize,
- s->put_pixels_tab[block_w == 8]);
+ vp8_mc_luma(s, dst[0] + by_off * s->linesize + bx_off,
+ ref_frame->data[0], mv, x_off + bx_off, y_off + by_off,
+ block_w, block_h, width, height, s->linesize,
+ s->put_pixels_tab[block_w == 8]);
/* U/V */
if (s->profile == 3) {
@@ -1268,14 +1133,11 @@ void vp8_mc_part(VP8Context *s, uint8_t *dst[3],
bx_off >>= 1; by_off >>= 1;
width >>= 1; height >>= 1;
block_w >>= 1; block_h >>= 1;
- vp8_mc(s, 0, dst[1] + by_off * s->uvlinesize + bx_off,
- ref_frame->data[1], &uvmv, x_off + bx_off, y_off + by_off,
- block_w, block_h, width, height, s->uvlinesize,
- s->put_pixels_tab[1 + (block_w == 4)]);
- vp8_mc(s, 0, dst[2] + by_off * s->uvlinesize + bx_off,
- ref_frame->data[2], &uvmv, x_off + bx_off, y_off + by_off,
- block_w, block_h, width, height, s->uvlinesize,
- s->put_pixels_tab[1 + (block_w == 4)]);
+ vp8_mc_chroma(s, dst[1] + by_off * s->uvlinesize + bx_off,
+ dst[2] + by_off * s->uvlinesize + bx_off, ref_frame->data[1],
+ ref_frame->data[2], &uvmv, x_off + bx_off, y_off + by_off,
+ block_w, block_h, width, height, s->uvlinesize,
+ s->put_pixels_tab[1 + (block_w == 4)]);
}
/* Fetch pixels for estimated mv 4 macroblocks ahead.
@@ -1307,10 +1169,11 @@ void inter_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
AVFrame *ref = s->framep[mb->ref_frame];
VP56mv *bmv = mb->bmv;
- if (mb->mode < VP8_MVMODE_SPLIT) {
+ switch (mb->partitioning) {
+ case VP8_SPLITMVMODE_NONE:
vp8_mc_part(s, dst, ref, x_off, y_off,
0, 0, 16, 16, width, height, &mb->mv);
- } else switch (mb->partitioning) {
+ break;
case VP8_SPLITMVMODE_4x4: {
int x, y;
VP56mv uvmv;
@@ -1318,11 +1181,11 @@ void inter_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
/* Y */
for (y = 0; y < 4; y++) {
for (x = 0; x < 4; x++) {
- vp8_mc(s, 1, dst[0] + 4*y*s->linesize + x*4,
- ref->data[0], &bmv[4*y + x],
- 4*x + x_off, 4*y + y_off, 4, 4,
- width, height, s->linesize,
- s->put_pixels_tab[2]);
+ vp8_mc_luma(s, dst[0] + 4*y*s->linesize + x*4,
+ ref->data[0], &bmv[4*y + x],
+ 4*x + x_off, 4*y + y_off, 4, 4,
+ width, height, s->linesize,
+ s->put_pixels_tab[2]);
}
}
@@ -1344,16 +1207,12 @@ void inter_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
uvmv.x &= ~7;
uvmv.y &= ~7;
}
- vp8_mc(s, 0, dst[1] + 4*y*s->uvlinesize + x*4,
- ref->data[1], &uvmv,
- 4*x + x_off, 4*y + y_off, 4, 4,
- width, height, s->uvlinesize,
- s->put_pixels_tab[2]);
- vp8_mc(s, 0, dst[2] + 4*y*s->uvlinesize + x*4,
- ref->data[2], &uvmv,
- 4*x + x_off, 4*y + y_off, 4, 4,
- width, height, s->uvlinesize,
- s->put_pixels_tab[2]);
+ vp8_mc_chroma(s, dst[1] + 4*y*s->uvlinesize + x*4,
+ dst[2] + 4*y*s->uvlinesize + x*4,
+ ref->data[1], ref->data[2], &uvmv,
+ 4*x + x_off, 4*y + y_off, 4, 4,
+ width, height, s->uvlinesize,
+ s->put_pixels_tab[2]);
}
}
break;
@@ -1390,17 +1249,17 @@ static av_always_inline void idct_mb(VP8Context *s, uint8_t *dst[3], VP8Macroblo
if (mb->mode != MODE_I4x4) {
uint8_t *y_dst = dst[0];
for (y = 0; y < 4; y++) {
- uint32_t nnz4 = AV_RN32A(s->non_zero_count_cache[y]);
+ uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[y]);
if (nnz4) {
if (nnz4&~0x01010101) {
for (x = 0; x < 4; x++) {
- int nnz = s->non_zero_count_cache[y][x];
- if (nnz) {
- if (nnz == 1)
- s->vp8dsp.vp8_idct_dc_add(y_dst+4*x, s->block[y][x], s->linesize);
- else
- s->vp8dsp.vp8_idct_add(y_dst+4*x, s->block[y][x], s->linesize);
- }
+ if ((uint8_t)nnz4 == 1)
+ s->vp8dsp.vp8_idct_dc_add(y_dst+4*x, s->block[y][x], s->linesize);
+ else if((uint8_t)nnz4 > 1)
+ s->vp8dsp.vp8_idct_add(y_dst+4*x, s->block[y][x], s->linesize);
+ nnz4 >>= 8;
+ if (!nnz4)
+ break;
}
} else {
s->vp8dsp.vp8_idct_dc_add4y(y_dst, s->block[y], s->linesize);
@@ -1411,19 +1270,19 @@ static av_always_inline void idct_mb(VP8Context *s, uint8_t *dst[3], VP8Macroblo
}
for (ch = 0; ch < 2; ch++) {
- uint32_t nnz4 = AV_RN32A(s->non_zero_count_cache[4+ch]);
+ uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[4+ch]);
if (nnz4) {
uint8_t *ch_dst = dst[1+ch];
if (nnz4&~0x01010101) {
for (y = 0; y < 2; y++) {
for (x = 0; x < 2; x++) {
- int nnz = s->non_zero_count_cache[4+ch][(y<<1)+x];
- if (nnz) {
- if (nnz == 1)
- s->vp8dsp.vp8_idct_dc_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
- else
- s->vp8dsp.vp8_idct_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
- }
+ if ((uint8_t)nnz4 == 1)
+ s->vp8dsp.vp8_idct_dc_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
+ else if((uint8_t)nnz4 > 1)
+ s->vp8dsp.vp8_idct_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
+ nnz4 >>= 8;
+ if (!nnz4)
+ break;
}
ch_dst += 4*s->uvlinesize;
}
@@ -1447,24 +1306,16 @@ static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *m
if (s->lf_delta.enabled) {
filter_level += s->lf_delta.ref[mb->ref_frame];
-
- if (mb->ref_frame == VP56_FRAME_CURRENT) {
- if (mb->mode == MODE_I4x4)
- filter_level += s->lf_delta.mode[0];
- } else {
- if (mb->mode == VP8_MVMODE_ZERO)
- filter_level += s->lf_delta.mode[1];
- else if (mb->mode == VP8_MVMODE_SPLIT)
- filter_level += s->lf_delta.mode[3];
- else
- filter_level += s->lf_delta.mode[2];
- }
+ filter_level += s->lf_delta.mode[mb->mode];
}
- filter_level = av_clip(filter_level, 0, 63);
+
+/* Like av_clip for inputs 0 and max, where max is equal to (2^n-1) */
+#define POW2CLIP(x,max) (((x) & ~max) ? (-(x))>>31 & max : (x));
+ filter_level = POW2CLIP(filter_level, 63);
interior_limit = filter_level;
if (s->filter.sharpness) {
- interior_limit >>= s->filter.sharpness > 4 ? 2 : 1;
+ interior_limit >>= (s->filter.sharpness + 3) >> 2;
interior_limit = FFMIN(interior_limit, 9 - s->filter.sharpness);
}
interior_limit = FFMAX(interior_limit, 1);
@@ -1482,23 +1333,24 @@ static av_always_inline void filter_mb(VP8Context *s, uint8_t *dst[3], VP8Filter
int inner_filter = f->inner_filter;
int linesize = s->linesize;
int uvlinesize = s->uvlinesize;
+ static const uint8_t hev_thresh_lut[2][64] = {
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2 }
+ };
if (!filter_level)
return;
- mbedge_lim = 2*(filter_level+2) + inner_limit;
- bedge_lim = 2* filter_level + inner_limit;
- hev_thresh = filter_level >= 15;
+ bedge_lim = 2*filter_level + inner_limit;
+ mbedge_lim = bedge_lim + 4;
- if (s->keyframe) {
- if (filter_level >= 40)
- hev_thresh = 2;
- } else {
- if (filter_level >= 40)
- hev_thresh = 3;
- else if (filter_level >= 20)
- hev_thresh = 2;
- }
+ hev_thresh = hev_thresh_lut[s->keyframe][filter_level];
if (mb_x) {
s->vp8dsp.vp8_h_loop_filter16y(dst[0], linesize,
@@ -1554,8 +1406,8 @@ static av_always_inline void filter_mb_simple(VP8Context *s, uint8_t *dst, VP8Fi
if (!filter_level)
return;
- mbedge_lim = 2*(filter_level+2) + inner_limit;
- bedge_lim = 2* filter_level + inner_limit;
+ bedge_lim = 2*filter_level + inner_limit;
+ mbedge_lim = bedge_lim + 4;
if (mb_x)
s->vp8dsp.vp8_h_loop_filter_simple(dst, linesize, mbedge_lim);
@@ -1677,6 +1529,10 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
if (s->keyframe)
memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width*4);
+ #define MARGIN (16 << 2)
+ s->mv_min.y = -MARGIN;
+ s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN;
+
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions-1)];
VP8Macroblock *mb = s->macroblocks + (s->mb_height - mb_y - 1)*2;
@@ -1700,6 +1556,9 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
s->top_border[0][15] = s->top_border[0][23] = s->top_border[0][31] = 129;
}
+ s->mv_min.x = -MARGIN;
+ s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
+
for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
/* Prefetch the current frame, 4 MBs ahead */
s->dsp.prefetch(dst[0] + (mb_x&3)*4*s->linesize + 64, s->linesize, 4);
@@ -1740,6 +1599,8 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
dst[0] += 16;
dst[1] += 8;
dst[2] += 8;
+ s->mv_min.x -= 64;
+ s->mv_max.x -= 64;
}
if (s->deblock_filter) {
if (s->filter.simple)
@@ -1747,6 +1608,8 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
else
filter_mb_row(s, mb_y);
}
+ s->mv_min.y -= 64;
+ s->mv_max.y -= 64;
}
skip_decode:
diff --git a/mplayer/ffmpeg/libavcodec/vp8.h b/mplayer/ffmpeg/libavcodec/vp8.h
new file mode 100644
index 00000000..d3b8705e
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/vp8.h
@@ -0,0 +1,242 @@
+/**
+ * VP8 compatible video decoder
+ *
+ * Copyright (C) 2010 David Conrad
+ * Copyright (C) 2010 Ronald S. Bultje
+ * Copyright (C) 2010 Jason Garrett-Glaser
+ *
+ * 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_VP8_H
+#define AVCODEC_VP8_H
+
+#include "vp56.h"
+#include "vp56data.h"
+#include "vp8dsp.h"
+#include "h264pred.h"
+
+#define VP8_MAX_QUANT 127
+
+enum dct_token {
+ DCT_0,
+ DCT_1,
+ DCT_2,
+ DCT_3,
+ DCT_4,
+ DCT_CAT1,
+ DCT_CAT2,
+ DCT_CAT3,
+ DCT_CAT4,
+ DCT_CAT5,
+ DCT_CAT6,
+ DCT_EOB,
+
+ NUM_DCT_TOKENS
+};
+
+// used to signal 4x4 intra pred in luma MBs
+#define MODE_I4x4 4
+
+enum inter_mvmode {
+ VP8_MVMODE_ZERO = MODE_I4x4 + 1,
+ VP8_MVMODE_MV,
+ VP8_MVMODE_SPLIT
+};
+
+enum inter_splitmvmode {
+ VP8_SPLITMVMODE_16x8 = 0, ///< 2 16x8 blocks (vertical)
+ VP8_SPLITMVMODE_8x16, ///< 2 8x16 blocks (horizontal)
+ VP8_SPLITMVMODE_8x8, ///< 2x2 blocks of 8x8px each
+ VP8_SPLITMVMODE_4x4, ///< 4x4 blocks of 4x4px each
+ VP8_SPLITMVMODE_NONE, ///< (only used in prediction) no split MVs
+};
+
+typedef struct {
+ uint8_t filter_level;
+ uint8_t inner_limit;
+ uint8_t inner_filter;
+} VP8FilterStrength;
+
+typedef struct {
+ uint8_t skip;
+ // todo: make it possible to check for at least (i4x4 or split_mv)
+ // in one op. are others needed?
+ uint8_t mode;
+ uint8_t ref_frame;
+ uint8_t partitioning;
+ VP56mv mv;
+ VP56mv bmv[16];
+} VP8Macroblock;
+
+typedef struct {
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ VP8DSPContext vp8dsp;
+ H264PredContext hpc;
+ vp8_mc_func put_pixels_tab[3][3][3];
+ AVFrame frames[4];
+ AVFrame *framep[4];
+ uint8_t *edge_emu_buffer;
+ VP56RangeCoder c; ///< header context, includes mb modes and motion vectors
+ int profile;
+
+ int mb_width; /* number of horizontal MB */
+ int mb_height; /* number of vertical MB */
+ int linesize;
+ int uvlinesize;
+
+ int keyframe;
+ int invisible;
+ int update_last; ///< update VP56_FRAME_PREVIOUS with the current one
+ int update_golden; ///< VP56_FRAME_NONE if not updated, or which frame to copy if so
+ int update_altref;
+ int deblock_filter;
+
+ /**
+ * If this flag is not set, all the probability updates
+ * are discarded after this frame is decoded.
+ */
+ int update_probabilities;
+
+ /**
+ * All coefficients are contained in separate arith coding contexts.
+ * There can be 1, 2, 4, or 8 of these after the header context.
+ */
+ int num_coeff_partitions;
+ VP56RangeCoder coeff_partition[8];
+
+ VP8Macroblock *macroblocks;
+ VP8Macroblock *macroblocks_base;
+ VP8FilterStrength *filter_strength;
+
+ uint8_t *intra4x4_pred_mode_top;
+ uint8_t intra4x4_pred_mode_left[4];
+ uint8_t *segmentation_map;
+
+ /**
+ * Cache of the top row needed for intra prediction
+ * 16 for luma, 8 for each chroma plane
+ */
+ uint8_t (*top_border)[16+8+8];
+
+ /**
+ * For coeff decode, we need to know whether the above block had non-zero
+ * coefficients. This means for each macroblock, we need data for 4 luma
+ * blocks, 2 u blocks, 2 v blocks, and the luma dc block, for a total of 9
+ * per macroblock. We keep the last row in top_nnz.
+ */
+ uint8_t (*top_nnz)[9];
+ DECLARE_ALIGNED(8, uint8_t, left_nnz)[9];
+
+ /**
+ * This is the index plus one of the last non-zero coeff
+ * for each of the blocks in the current macroblock.
+ * So, 0 -> no coeffs
+ * 1 -> dc-only (special transform)
+ * 2+-> full transform
+ */
+ DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4];
+ DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16];
+ DECLARE_ALIGNED(16, DCTELEM, block_dc)[16];
+ uint8_t intra4x4_pred_mode_mb[16];
+
+ int chroma_pred_mode; ///< 8x8c pred mode of the current macroblock
+ int segment; ///< segment of the current macroblock
+ VP56mv mv_min;
+ VP56mv mv_max;
+
+ int mbskip_enabled;
+ int sign_bias[4]; ///< one state [0, 1] per ref frame type
+ int ref_count[3];
+
+ /**
+ * Base parameters for segmentation, i.e. per-macroblock parameters.
+ * These must be kept unchanged even if segmentation is not used for
+ * a frame, since the values persist between interframes.
+ */
+ struct {
+ int enabled;
+ int absolute_vals;
+ int update_map;
+ int8_t base_quant[4];
+ int8_t filter_level[4]; ///< base loop filter level
+ } segmentation;
+
+ /**
+ * Macroblocks can have one of 4 different quants in a frame when
+ * segmentation is enabled.
+ * If segmentation is disabled, only the first segment's values are used.
+ */
+ struct {
+ // [0] - DC qmul [1] - AC qmul
+ int16_t luma_qmul[2];
+ int16_t luma_dc_qmul[2]; ///< luma dc-only block quant
+ int16_t chroma_qmul[2];
+ } qmat[4];
+
+ struct {
+ int simple;
+ int level;
+ int sharpness;
+ } filter;
+
+ struct {
+ int enabled; ///< whether each mb can have a different strength based on mode/ref
+
+ /**
+ * filter strength adjustment for the following macroblock modes:
+ * [0-3] - i16x16 (always zero)
+ * [4] - i4x4
+ * [5] - zero mv
+ * [6] - inter modes except for zero or split mv
+ * [7] - split mv
+ * i16x16 modes never have any adjustment
+ */
+ int8_t mode[VP8_MVMODE_SPLIT+1];
+
+ /**
+ * filter strength adjustment for macroblocks that reference:
+ * [0] - intra / VP56_FRAME_CURRENT
+ * [1] - VP56_FRAME_PREVIOUS
+ * [2] - VP56_FRAME_GOLDEN
+ * [3] - altref / VP56_FRAME_GOLDEN2
+ */
+ int8_t ref[4];
+ } lf_delta;
+
+ /**
+ * These are all of the updatable probabilities for binary decisions.
+ * They are only implictly reset on keyframes, making it quite likely
+ * for an interframe to desync if a prior frame's header was corrupt
+ * or missing outright!
+ */
+ struct {
+ uint8_t segmentid[3];
+ uint8_t mbskip;
+ uint8_t intra;
+ uint8_t last;
+ uint8_t golden;
+ uint8_t pred16x16[4];
+ uint8_t pred8x8c[3];
+ /* Padded to allow overreads */
+ uint8_t token[4][17][3][NUM_DCT_TOKENS-1];
+ uint8_t mvc[2][19];
+ } prob[2];
+} VP8Context;
+
+#endif
diff --git a/mplayer/ffmpeg/libavcodec/vp8data.h b/mplayer/ffmpeg/libavcodec/vp8data.h
index 775472e8..af9b0d91 100644
--- a/mplayer/ffmpeg/libavcodec/vp8data.h
+++ b/mplayer/ffmpeg/libavcodec/vp8data.h
@@ -21,48 +21,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-// TODO: move these #define and enum to a better header...
-
-#define VP8_MAX_QUANT 127
-
-enum dct_token {
- DCT_0,
- DCT_1,
- DCT_2,
- DCT_3,
- DCT_4,
- DCT_CAT1,
- DCT_CAT2,
- DCT_CAT3,
- DCT_CAT4,
- DCT_CAT5,
- DCT_CAT6,
- DCT_EOB,
-
- NUM_DCT_TOKENS
-};
+#ifndef AVCODEC_VP8DATA_H
+#define AVCODEC_VP8DATA_H
+#include "vp8.h"
#include "h264pred.h"
-// used to signal 4x4 intra pred in luma MBs
-#define MODE_I4x4 4
-
-enum inter_mvmode {
- VP8_MVMODE_NEAREST = MODE_I4x4 + 1,
- VP8_MVMODE_NEAR,
- VP8_MVMODE_ZERO,
- VP8_MVMODE_NEW,
- VP8_MVMODE_SPLIT
-};
-
-enum inter_splitmvmode {
- VP8_SPLITMVMODE_16x8 = 0, ///< 2 16x8 blocks (vertical)
- VP8_SPLITMVMODE_8x16, ///< 2 8x16 blocks (horizontal)
- VP8_SPLITMVMODE_8x8, ///< 2x2 blocks of 8x8px each
- VP8_SPLITMVMODE_4x4, ///< 4x4 blocks of 4x4px each
- VP8_SPLITMVMODE_NONE, ///< (only used in prediction) no split MVs
-};
-
static const uint8_t vp8_pred4x4_mode[] =
{
[DC_PRED8x8] = DC_PRED,
@@ -315,7 +279,7 @@ static const uint8_t vp8_dct_cat5_prob[] = { 180, 157, 141, 134, 130, 0 };
static const uint8_t vp8_dct_cat6_prob[] = { 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0 };
// only used for cat3 and above; cat 1 and 2 are referenced directly
-static const uint8_t * const vp8_dct_cat_prob[] =
+const uint8_t * const ff_vp8_dct_cat_prob[] =
{
vp8_dct_cat3_prob,
vp8_dct_cat4_prob,
@@ -720,3 +684,5 @@ static const uint8_t vp8_mv_default_prob[2][19] = {
204, 170, 119, 235, 140, 230, 228,
128, 130, 130, 74, 148, 180, 203, 236, 254, 254 }
};
+
+#endif
diff --git a/mplayer/ffmpeg/libavcodec/vp8dsp.c b/mplayer/ffmpeg/libavcodec/vp8dsp.c
index 30699cec..4391a7eb 100644
--- a/mplayer/ffmpeg/libavcodec/vp8dsp.c
+++ b/mplayer/ffmpeg/libavcodec/vp8dsp.c
@@ -523,4 +523,6 @@ av_cold void ff_vp8dsp_init(VP8DSPContext *dsp)
ff_vp8dsp_init_x86(dsp);
if (HAVE_ALTIVEC)
ff_vp8dsp_init_altivec(dsp);
+ if (ARCH_ARM)
+ ff_vp8dsp_init_arm(dsp);
}
diff --git a/mplayer/ffmpeg/libavcodec/vp8dsp.h b/mplayer/ffmpeg/libavcodec/vp8dsp.h
index ee5c7ec0..e8757ab7 100644
--- a/mplayer/ffmpeg/libavcodec/vp8dsp.h
+++ b/mplayer/ffmpeg/libavcodec/vp8dsp.h
@@ -79,5 +79,6 @@ void ff_put_vp8_pixels4_c(uint8_t *dst, uint8_t *src, int stride, int h, int x,
void ff_vp8dsp_init(VP8DSPContext *c);
void ff_vp8dsp_init_x86(VP8DSPContext *c);
void ff_vp8dsp_init_altivec(VP8DSPContext *c);
+void ff_vp8dsp_init_arm(VP8DSPContext *c);
#endif /* AVCODEC_VP8DSP_H */
diff --git a/mplayer/ffmpeg/libavcodec/vqavideo.c b/mplayer/ffmpeg/libavcodec/vqavideo.c
index c3b5ba65..f0ecda62 100644
--- a/mplayer/ffmpeg/libavcodec/vqavideo.c
+++ b/mplayer/ffmpeg/libavcodec/vqavideo.c
@@ -68,7 +68,7 @@
#include
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#define PALETTE_COUNT 256
diff --git a/mplayer/ffmpeg/libavcodec/w32thread.c b/mplayer/ffmpeg/libavcodec/w32thread.c
index f7a14306..f2b8f5b3 100644
--- a/mplayer/ffmpeg/libavcodec/w32thread.c
+++ b/mplayer/ffmpeg/libavcodec/w32thread.c
@@ -20,6 +20,7 @@
//#define DEBUG
#include "avcodec.h"
+#include "thread.h"
#define WIN32_LEAN_AND_MEAN
#include
@@ -69,10 +70,10 @@ static unsigned WINAPI attribute_align_arg thread_func(void *v){
}
/**
- * Free what has been allocated by avcodec_thread_init().
+ * Free what has been allocated by ff_thread_init().
* Must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running.
*/
-void avcodec_thread_free(AVCodecContext *s){
+void ff_thread_free(AVCodecContext *s){
ThreadContext *c= s->thread_opaque;
int i;
@@ -124,12 +125,18 @@ static int avcodec_thread_execute2(AVCodecContext *s, int (*func)(AVCodecContext
avcodec_thread_execute(s, NULL, arg, ret, count, 0);
}
-int avcodec_thread_init(AVCodecContext *s, int thread_count){
+int ff_thread_init(AVCodecContext *s, int thread_count){
int i;
ThreadContext *c;
uint32_t threadid;
+ if(!(s->thread_type & FF_THREAD_SLICE)){
+ av_log(s, AV_LOG_WARNING, "The requested thread algorithm is not supported with this thread library.\n");
+ return 0;
+ }
+
s->thread_count= thread_count;
+ s->active_thread_type= FF_THREAD_SLICE;
if (thread_count <= 1)
return 0;
@@ -163,6 +170,6 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count){
return 0;
fail:
- avcodec_thread_free(s);
+ ff_thread_free(s);
return -1;
}
diff --git a/mplayer/ffmpeg/libavcodec/wavpack.c b/mplayer/ffmpeg/libavcodec/wavpack.c
index e9698146..d5102320 100644
--- a/mplayer/ffmpeg/libavcodec/wavpack.c
+++ b/mplayer/ffmpeg/libavcodec/wavpack.c
@@ -22,6 +22,7 @@
#include "avcodec.h"
#include "get_bits.h"
#include "unary.h"
+#include "libavutil/audioconvert.h"
/**
* @file
@@ -706,7 +707,7 @@ static av_cold int wavpack_decode_init(AVCodecContext *avctx)
else
avctx->sample_fmt = AV_SAMPLE_FMT_S32;
if(avctx->channels <= 2 && !avctx->channel_layout)
- avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
+ avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
s->multichannel = avctx->channels > 2;
/* lavf demuxer does not provide extradata, Matroska stores 0x403
diff --git a/mplayer/ffmpeg/libavcodec/wma.c b/mplayer/ffmpeg/libavcodec/wma.c
index e0b9b683..a7eacb8c 100644
--- a/mplayer/ffmpeg/libavcodec/wma.c
+++ b/mplayer/ffmpeg/libavcodec/wma.c
@@ -126,6 +126,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
s->block_align = avctx->block_align;
dsputil_init(&s->dsp, avctx);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
if (avctx->codec->id == CODEC_ID_WMAV1) {
s->version = 1;
diff --git a/mplayer/ffmpeg/libavcodec/wma.h b/mplayer/ffmpeg/libavcodec/wma.h
index 11274ad9..a51b3e83 100644
--- a/mplayer/ffmpeg/libavcodec/wma.h
+++ b/mplayer/ffmpeg/libavcodec/wma.h
@@ -26,6 +26,7 @@
#include "put_bits.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
/* size of blocks */
#define BLOCK_MIN_BITS 7
@@ -134,6 +135,7 @@ typedef struct WMACodecContext {
float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
DSPContext dsp;
+ FmtConvertContext fmt_conv;
#ifdef TRACE
int frame_count;
diff --git a/mplayer/ffmpeg/libavcodec/wmadec.c b/mplayer/ffmpeg/libavcodec/wmadec.c
index d85d80d5..83f8dea8 100644
--- a/mplayer/ffmpeg/libavcodec/wmadec.c
+++ b/mplayer/ffmpeg/libavcodec/wmadec.c
@@ -791,7 +791,7 @@ static int wma_decode_frame(WMACodecContext *s, int16_t *samples)
incr = s->nb_channels;
for (ch = 0; ch < MAX_CHANNELS; ch++)
output[ch] = s->frame_out[ch];
- s->dsp.float_to_int16_interleave(samples, output, n, incr);
+ s->fmt_conv.float_to_int16_interleave(samples, output, n, incr);
for (ch = 0; ch < incr; ch++) {
/* prepare for next block */
memmove(&s->frame_out[ch][0], &s->frame_out[ch][n], n * sizeof(float));
diff --git a/mplayer/ffmpeg/libavcodec/wmaprodec.c b/mplayer/ffmpeg/libavcodec/wmaprodec.c
index bb1cd311..d248ae4a 100644
--- a/mplayer/ffmpeg/libavcodec/wmaprodec.c
+++ b/mplayer/ffmpeg/libavcodec/wmaprodec.c
@@ -1031,7 +1031,7 @@ static void wmapro_window(WMAProDecodeCtx *s)
winlen >>= 1;
s->dsp.vector_fmul_window(start, start, start + winlen,
- window, 0, winlen);
+ window, winlen);
s->channel[c].prev_block_len = s->subframe_len;
}
diff --git a/mplayer/ffmpeg/libavcodec/x86/Makefile b/mplayer/ffmpeg/libavcodec/x86/Makefile
index 943edcb0..1b58fa12 100644
--- a/mplayer/ffmpeg/libavcodec/x86/Makefile
+++ b/mplayer/ffmpeg/libavcodec/x86/Makefile
@@ -17,6 +17,10 @@ MMX-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred_init.o
YASM-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_yasm.o
+MMX-OBJS-$(CONFIG_AC3_ENCODER) += x86/ac3dsp_mmx.o
+MMX-OBJS-$(CONFIG_AC3_FIXED_ENCODER) += x86/ac3dsp_mmx.o
+YASM-OBJS-$(CONFIG_AC3_ENCODER) += x86/ac3dsp.o
+YASM-OBJS-$(CONFIG_AC3_FIXED_ENCODER) += x86/ac3dsp.o
MMX-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsdsp_mmx.o
MMX-OBJS-$(CONFIG_MP1FLOAT_DECODER) += x86/mpegaudiodec_mmx.o
MMX-OBJS-$(CONFIG_MP2FLOAT_DECODER) += x86/mpegaudiodec_mmx.o
@@ -39,6 +43,7 @@ YASM-OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp.o
MMX-OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp-init.o
MMX-OBJS-$(HAVE_YASM) += x86/dsputil_yasm.o \
x86/deinterlace.o \
+ x86/fmtconvert.o \
x86/h264_chromamc.o \
$(YASM-OBJS-yes)
@@ -47,6 +52,7 @@ MMX-OBJS-$(CONFIG_FFT) += x86/fft.o
OBJS-$(HAVE_MMX) += x86/dnxhd_mmx.o \
x86/dsputil_mmx.o \
x86/fdct_mmx.o \
+ x86/fmtconvert_mmx.o \
x86/idct_mmx_xvid.o \
x86/idct_sse2_xvid.o \
x86/motion_est_mmx.o \
diff --git a/mplayer/ffmpeg/libavcodec/x86/ac3dsp.asm b/mplayer/ffmpeg/libavcodec/x86/ac3dsp.asm
new file mode 100644
index 00000000..b1eeca9c
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/x86/ac3dsp.asm
@@ -0,0 +1,135 @@
+;*****************************************************************************
+;* x86-optimized AC-3 DSP utils
+;* Copyright (c) 2011 Justin Ruggles
+;*
+;* 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
+;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "x86inc.asm"
+%include "x86util.asm"
+
+SECTION .text
+
+;-----------------------------------------------------------------------------
+; void ff_ac3_exponent_min(uint8_t *exp, int num_reuse_blocks, int nb_coefs)
+;-----------------------------------------------------------------------------
+
+%macro AC3_EXPONENT_MIN 1
+cglobal ac3_exponent_min_%1, 3,4,2, exp, reuse_blks, expn, offset
+ shl reuse_blksq, 8
+ jz .end
+ LOOP_ALIGN
+.nextexp:
+ mov offsetq, reuse_blksq
+ mova m0, [expq+offsetq]
+ sub offsetq, 256
+ LOOP_ALIGN
+.nextblk:
+ PMINUB m0, [expq+offsetq], m1
+ sub offsetq, 256
+ jae .nextblk
+ mova [expq], m0
+ add expq, mmsize
+ sub expnq, mmsize
+ jg .nextexp
+.end:
+ REP_RET
+%endmacro
+
+%define PMINUB PMINUB_MMX
+%define LOOP_ALIGN
+INIT_MMX
+AC3_EXPONENT_MIN mmx
+%ifdef HAVE_MMX2
+%define PMINUB PMINUB_MMXEXT
+%define LOOP_ALIGN ALIGN 16
+AC3_EXPONENT_MIN mmxext
+%endif
+%ifdef HAVE_SSE
+INIT_XMM
+AC3_EXPONENT_MIN sse2
+%endif
+%undef PMINUB
+%undef LOOP_ALIGN
+
+;-----------------------------------------------------------------------------
+; int ff_ac3_max_msb_abs_int16(const int16_t *src, int len)
+;
+; This function uses 2 different methods to calculate a valid result.
+; 1) logical 'or' of abs of each element
+; This is used for ssse3 because of the pabsw instruction.
+; It is also used for mmx because of the lack of min/max instructions.
+; 2) calculate min/max for the array, then or(abs(min),abs(max))
+; This is used for mmxext and sse2 because they have pminsw/pmaxsw.
+;-----------------------------------------------------------------------------
+
+%macro AC3_MAX_MSB_ABS_INT16 2
+cglobal ac3_max_msb_abs_int16_%1, 2,2,5, src, len
+ pxor m2, m2
+ pxor m3, m3
+.loop:
+%ifidn %2, min_max
+ mova m0, [srcq]
+ mova m1, [srcq+mmsize]
+ pminsw m2, m0
+ pminsw m2, m1
+ pmaxsw m3, m0
+ pmaxsw m3, m1
+%else ; or_abs
+%ifidn %1, mmx
+ mova m0, [srcq]
+ mova m1, [srcq+mmsize]
+ ABS2 m0, m1, m3, m4
+%else ; ssse3
+ ; using memory args is faster for ssse3
+ pabsw m0, [srcq]
+ pabsw m1, [srcq+mmsize]
+%endif
+ por m2, m0
+ por m2, m1
+%endif
+ add srcq, mmsize*2
+ sub lend, mmsize
+ ja .loop
+%ifidn %2, min_max
+ ABS2 m2, m3, m0, m1
+ por m2, m3
+%endif
+%ifidn mmsize, 16
+ movhlps m0, m2
+ por m2, m0
+%endif
+ PSHUFLW m0, m2, 0xe
+ por m2, m0
+ PSHUFLW m0, m2, 0x1
+ por m2, m0
+ movd eax, m2
+ and eax, 0xFFFF
+ RET
+%endmacro
+
+INIT_MMX
+%define ABS2 ABS2_MMX
+%define PSHUFLW pshufw
+AC3_MAX_MSB_ABS_INT16 mmx, or_abs
+%define ABS2 ABS2_MMX2
+AC3_MAX_MSB_ABS_INT16 mmxext, min_max
+INIT_XMM
+%define PSHUFLW pshuflw
+AC3_MAX_MSB_ABS_INT16 sse2, min_max
+%define ABS2 ABS2_SSSE3
+AC3_MAX_MSB_ABS_INT16 ssse3, or_abs
diff --git a/mplayer/ffmpeg/libavcodec/x86/ac3dsp_mmx.c b/mplayer/ffmpeg/libavcodec/x86/ac3dsp_mmx.c
new file mode 100644
index 00000000..d8af59ce
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/x86/ac3dsp_mmx.c
@@ -0,0 +1,56 @@
+/*
+ * x86-optimized AC-3 DSP utils
+ * Copyright (c) 2011 Justin Ruggles
+ *
+ * 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
+ */
+
+#include "libavutil/x86_cpu.h"
+#include "dsputil_mmx.h"
+#include "libavcodec/ac3dsp.h"
+
+extern void ff_ac3_exponent_min_mmx (uint8_t *exp, int num_reuse_blocks, int nb_coefs);
+extern void ff_ac3_exponent_min_mmxext(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
+extern void ff_ac3_exponent_min_sse2 (uint8_t *exp, int num_reuse_blocks, int nb_coefs);
+
+extern int ff_ac3_max_msb_abs_int16_mmx (const int16_t *src, int len);
+extern int ff_ac3_max_msb_abs_int16_mmxext(const int16_t *src, int len);
+extern int ff_ac3_max_msb_abs_int16_sse2 (const int16_t *src, int len);
+extern int ff_ac3_max_msb_abs_int16_ssse3 (const int16_t *src, int len);
+
+av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c)
+{
+ int mm_flags = av_get_cpu_flags();
+
+#if HAVE_YASM
+ if (mm_flags & AV_CPU_FLAG_MMX) {
+ c->ac3_exponent_min = ff_ac3_exponent_min_mmx;
+ c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmx;
+ }
+ if (mm_flags & AV_CPU_FLAG_MMX2 && HAVE_MMX2) {
+ c->ac3_exponent_min = ff_ac3_exponent_min_mmxext;
+ c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmxext;
+ }
+ if (mm_flags & AV_CPU_FLAG_SSE2 && HAVE_SSE) {
+ c->ac3_exponent_min = ff_ac3_exponent_min_sse2;
+ c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_sse2;
+ }
+ if (mm_flags & AV_CPU_FLAG_SSSE3 && HAVE_SSSE3) {
+ c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_ssse3;
+ }
+#endif
+}
diff --git a/mplayer/ffmpeg/libavcodec/x86/dsputil_mmx.c b/mplayer/ffmpeg/libavcodec/x86/dsputil_mmx.c
index 5ddfecae..a5b0b3ae 100644
--- a/mplayer/ffmpeg/libavcodec/x86/dsputil_mmx.c
+++ b/mplayer/ffmpeg/libavcodec/x86/dsputil_mmx.c
@@ -286,9 +286,6 @@ void ff_put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_s
:"memory");
}
-DECLARE_ASM_CONST(8, uint8_t, ff_vector128)[8] =
- { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
-
#define put_signed_pixels_clamped_mmx_half(off) \
"movq "#off"(%2), %%mm1 \n\t"\
"movq 16+"#off"(%2), %%mm2 \n\t"\
@@ -313,7 +310,7 @@ void ff_put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int
x86_reg line_skip3;
__asm__ volatile (
- "movq "MANGLE(ff_vector128)", %%mm0 \n\t"
+ "movq "MANGLE(ff_pb_80)", %%mm0 \n\t"
"lea (%3, %3, 2), %1 \n\t"
put_signed_pixels_clamped_mmx_half(0)
"lea (%0, %3, 4), %0 \n\t"
@@ -1664,8 +1661,80 @@ QPEL_2TAP(avg_, 8, 3dnow)
static void just_return(void) { return; }
#endif
-static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
- int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height){
+#if HAVE_YASM
+typedef void emu_edge_core_func (uint8_t *buf, const uint8_t *src,
+ x86_reg linesize, x86_reg start_y,
+ x86_reg end_y, x86_reg block_h,
+ x86_reg start_x, x86_reg end_x,
+ x86_reg block_w);
+extern emu_edge_core_func ff_emu_edge_core_mmx;
+extern emu_edge_core_func ff_emu_edge_core_sse;
+
+static av_always_inline
+void emulated_edge_mc(uint8_t *buf, const uint8_t *src, int linesize,
+ int block_w, int block_h,
+ int src_x, int src_y, int w, int h,
+ emu_edge_core_func *core_fn)
+{
+ int start_y, start_x, end_y, end_x, src_y_add=0;
+
+ if(src_y>= h){
+ src_y_add = h-1-src_y;
+ src_y=h-1;
+ }else if(src_y<=-block_h){
+ src_y_add = 1-block_h-src_y;
+ src_y=1-block_h;
+ }
+ if(src_x>= w){
+ src+= (w-1-src_x);
+ src_x=w-1;
+ }else if(src_x<=-block_w){
+ src+= (1-block_w-src_x);
+ src_x=1-block_w;
+ }
+
+ start_y= FFMAX(0, -src_y);
+ start_x= FFMAX(0, -src_x);
+ end_y= FFMIN(block_h, h-src_y);
+ end_x= FFMIN(block_w, w-src_x);
+ assert(start_x < end_x && block_w > 0);
+ assert(start_y < end_y && block_h > 0);
+
+ // fill in the to-be-copied part plus all above/below
+ src += (src_y_add+start_y)*linesize + start_x;
+ buf += start_x;
+ core_fn(buf, src, linesize, start_y, end_y, block_h, start_x, end_x, block_w);
+}
+
+#if ARCH_X86_32
+static av_noinline
+void emulated_edge_mc_mmx(uint8_t *buf, const uint8_t *src, int linesize,
+ int block_w, int block_h,
+ int src_x, int src_y, int w, int h)
+{
+ emulated_edge_mc(buf, src, linesize, block_w, block_h, src_x, src_y,
+ w, h, &ff_emu_edge_core_mmx);
+}
+#endif
+static av_noinline
+void emulated_edge_mc_sse(uint8_t *buf, const uint8_t *src, int linesize,
+ int block_w, int block_h,
+ int src_x, int src_y, int w, int h)
+{
+ emulated_edge_mc(buf, src, linesize, block_w, block_h, src_x, src_y,
+ w, h, &ff_emu_edge_core_sse);
+}
+#endif /* HAVE_YASM */
+
+typedef void emulated_edge_mc_func (uint8_t *dst, const uint8_t *src,
+ int linesize, int block_w, int block_h,
+ int src_x, int src_y, int w, int h);
+
+static av_always_inline
+void gmc(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
+ int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height,
+ emulated_edge_mc_func *emu_edge_fn)
+{
const int w = 8;
const int ix = ox>>(16+shift);
const int iy = oy>>(16+shift);
@@ -1701,7 +1770,7 @@ static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int o
if( (unsigned)ix >= width-w ||
(unsigned)iy >= height-h )
{
- ff_emulated_edge_mc(edge_buf, src, stride, w+1, h+1, ix, iy, width, height);
+ emu_edge_fn(edge_buf, src, stride, w+1, h+1, ix, iy, width, height);
src = edge_buf;
}
@@ -1782,6 +1851,30 @@ static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int o
}
}
+#if HAVE_YASM
+#if ARCH_X86_32
+static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
+ int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
+{
+ gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r,
+ width, height, &emulated_edge_mc_mmx);
+}
+#endif
+static void gmc_sse(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
+ int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
+{
+ gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r,
+ width, height, &emulated_edge_mc_sse);
+}
+#else
+static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
+ int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
+{
+ gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r,
+ width, height, &ff_emulated_edge_mc);
+}
+#endif
+
#define PREFETCH(name, op) \
static void name(void *mem, int stride, int h){\
const uint8_t *p= mem;\
@@ -1798,20 +1891,14 @@ PREFETCH(prefetch_3dnow, prefetch)
void ff_put_h264_chroma_mc8_mmx_rnd (uint8_t *dst, uint8_t *src,
int stride, int h, int x, int y);
-void ff_put_vc1_chroma_mc8_mmx_nornd (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
void ff_put_rv40_chroma_mc8_mmx (uint8_t *dst, uint8_t *src,
int stride, int h, int x, int y);
void ff_avg_h264_chroma_mc8_mmx2_rnd (uint8_t *dst, uint8_t *src,
int stride, int h, int x, int y);
-void ff_avg_vc1_chroma_mc8_mmx2_nornd (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
void ff_avg_rv40_chroma_mc8_mmx2 (uint8_t *dst, uint8_t *src,
int stride, int h, int x, int y);
void ff_avg_h264_chroma_mc8_3dnow_rnd (uint8_t *dst, uint8_t *src,
int stride, int h, int x, int y);
-void ff_avg_vc1_chroma_mc8_3dnow_nornd(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
void ff_avg_rv40_chroma_mc8_3dnow (uint8_t *dst, uint8_t *src,
int stride, int h, int x, int y);
@@ -1835,15 +1922,11 @@ void ff_avg_h264_chroma_mc2_mmx2 (uint8_t *dst, uint8_t *src,
void ff_put_h264_chroma_mc8_ssse3_rnd (uint8_t *dst, uint8_t *src,
int stride, int h, int x, int y);
-void ff_put_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
void ff_put_h264_chroma_mc4_ssse3 (uint8_t *dst, uint8_t *src,
int stride, int h, int x, int y);
void ff_avg_h264_chroma_mc8_ssse3_rnd (uint8_t *dst, uint8_t *src,
int stride, int h, int x, int y);
-void ff_avg_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
void ff_avg_h264_chroma_mc4_ssse3 (uint8_t *dst, uint8_t *src,
int stride, int h, int x, int y);
@@ -2190,120 +2273,68 @@ static void vector_fmul_add_sse(float *dst, const float *src0, const float *src1
);
}
-static void vector_fmul_window_3dnow2(float *dst, const float *src0, const float *src1,
- const float *win, float add_bias, int len){
-#if HAVE_6REGS
- if(add_bias == 0){
- x86_reg i = -len*4;
- x86_reg j = len*4-8;
- __asm__ volatile(
- "1: \n"
- "pswapd (%5,%1), %%mm1 \n"
- "movq (%5,%0), %%mm0 \n"
- "pswapd (%4,%1), %%mm5 \n"
- "movq (%3,%0), %%mm4 \n"
- "movq %%mm0, %%mm2 \n"
- "movq %%mm1, %%mm3 \n"
- "pfmul %%mm4, %%mm2 \n" // src0[len+i]*win[len+i]
- "pfmul %%mm5, %%mm3 \n" // src1[ j]*win[len+j]
- "pfmul %%mm4, %%mm1 \n" // src0[len+i]*win[len+j]
- "pfmul %%mm5, %%mm0 \n" // src1[ j]*win[len+i]
- "pfadd %%mm3, %%mm2 \n"
- "pfsub %%mm0, %%mm1 \n"
- "pswapd %%mm2, %%mm2 \n"
- "movq %%mm1, (%2,%0) \n"
- "movq %%mm2, (%2,%1) \n"
- "sub $8, %1 \n"
- "add $8, %0 \n"
- "jl 1b \n"
- "femms \n"
- :"+r"(i), "+r"(j)
- :"r"(dst+len), "r"(src0+len), "r"(src1), "r"(win+len)
- );
- }else
-#endif
- ff_vector_fmul_window_c(dst, src0, src1, win, add_bias, len);
-}
-
-static void vector_fmul_window_sse(float *dst, const float *src0, const float *src1,
- const float *win, float add_bias, int len){
#if HAVE_6REGS
- if(add_bias == 0){
- x86_reg i = -len*4;
- x86_reg j = len*4-16;
- __asm__ volatile(
- "1: \n"
- "movaps (%5,%1), %%xmm1 \n"
- "movaps (%5,%0), %%xmm0 \n"
- "movaps (%4,%1), %%xmm5 \n"
- "movaps (%3,%0), %%xmm4 \n"
- "shufps $0x1b, %%xmm1, %%xmm1 \n"
- "shufps $0x1b, %%xmm5, %%xmm5 \n"
- "movaps %%xmm0, %%xmm2 \n"
- "movaps %%xmm1, %%xmm3 \n"
- "mulps %%xmm4, %%xmm2 \n" // src0[len+i]*win[len+i]
- "mulps %%xmm5, %%xmm3 \n" // src1[ j]*win[len+j]
- "mulps %%xmm4, %%xmm1 \n" // src0[len+i]*win[len+j]
- "mulps %%xmm5, %%xmm0 \n" // src1[ j]*win[len+i]
- "addps %%xmm3, %%xmm2 \n"
- "subps %%xmm0, %%xmm1 \n"
- "shufps $0x1b, %%xmm2, %%xmm2 \n"
- "movaps %%xmm1, (%2,%0) \n"
- "movaps %%xmm2, (%2,%1) \n"
- "sub $16, %1 \n"
- "add $16, %0 \n"
- "jl 1b \n"
- :"+r"(i), "+r"(j)
- :"r"(dst+len), "r"(src0+len), "r"(src1), "r"(win+len)
- );
- }else
-#endif
- ff_vector_fmul_window_c(dst, src0, src1, win, add_bias, len);
-}
-
-static void int32_to_float_fmul_scalar_sse(float *dst, const int *src, float mul, int len)
-{
- x86_reg i = -4*len;
+static void vector_fmul_window_3dnow2(float *dst, const float *src0, const float *src1,
+ const float *win, int len){
+ x86_reg i = -len*4;
+ x86_reg j = len*4-8;
__asm__ volatile(
- "movss %3, %%xmm4 \n"
- "shufps $0, %%xmm4, %%xmm4 \n"
"1: \n"
- "cvtpi2ps (%2,%0), %%xmm0 \n"
- "cvtpi2ps 8(%2,%0), %%xmm1 \n"
- "cvtpi2ps 16(%2,%0), %%xmm2 \n"
- "cvtpi2ps 24(%2,%0), %%xmm3 \n"
- "movlhps %%xmm1, %%xmm0 \n"
- "movlhps %%xmm3, %%xmm2 \n"
- "mulps %%xmm4, %%xmm0 \n"
- "mulps %%xmm4, %%xmm2 \n"
- "movaps %%xmm0, (%1,%0) \n"
- "movaps %%xmm2, 16(%1,%0) \n"
- "add $32, %0 \n"
+ "pswapd (%5,%1), %%mm1 \n"
+ "movq (%5,%0), %%mm0 \n"
+ "pswapd (%4,%1), %%mm5 \n"
+ "movq (%3,%0), %%mm4 \n"
+ "movq %%mm0, %%mm2 \n"
+ "movq %%mm1, %%mm3 \n"
+ "pfmul %%mm4, %%mm2 \n" // src0[len+i]*win[len+i]
+ "pfmul %%mm5, %%mm3 \n" // src1[ j]*win[len+j]
+ "pfmul %%mm4, %%mm1 \n" // src0[len+i]*win[len+j]
+ "pfmul %%mm5, %%mm0 \n" // src1[ j]*win[len+i]
+ "pfadd %%mm3, %%mm2 \n"
+ "pfsub %%mm0, %%mm1 \n"
+ "pswapd %%mm2, %%mm2 \n"
+ "movq %%mm1, (%2,%0) \n"
+ "movq %%mm2, (%2,%1) \n"
+ "sub $8, %1 \n"
+ "add $8, %0 \n"
"jl 1b \n"
- :"+r"(i)
- :"r"(dst+len), "r"(src+len), "m"(mul)
+ "femms \n"
+ :"+r"(i), "+r"(j)
+ :"r"(dst+len), "r"(src0+len), "r"(src1), "r"(win+len)
);
}
-static void int32_to_float_fmul_scalar_sse2(float *dst, const int *src, float mul, int len)
-{
- x86_reg i = -4*len;
+static void vector_fmul_window_sse(float *dst, const float *src0, const float *src1,
+ const float *win, int len){
+ x86_reg i = -len*4;
+ x86_reg j = len*4-16;
__asm__ volatile(
- "movss %3, %%xmm4 \n"
- "shufps $0, %%xmm4, %%xmm4 \n"
"1: \n"
- "cvtdq2ps (%2,%0), %%xmm0 \n"
- "cvtdq2ps 16(%2,%0), %%xmm1 \n"
- "mulps %%xmm4, %%xmm0 \n"
- "mulps %%xmm4, %%xmm1 \n"
- "movaps %%xmm0, (%1,%0) \n"
- "movaps %%xmm1, 16(%1,%0) \n"
- "add $32, %0 \n"
+ "movaps (%5,%1), %%xmm1 \n"
+ "movaps (%5,%0), %%xmm0 \n"
+ "movaps (%4,%1), %%xmm5 \n"
+ "movaps (%3,%0), %%xmm4 \n"
+ "shufps $0x1b, %%xmm1, %%xmm1 \n"
+ "shufps $0x1b, %%xmm5, %%xmm5 \n"
+ "movaps %%xmm0, %%xmm2 \n"
+ "movaps %%xmm1, %%xmm3 \n"
+ "mulps %%xmm4, %%xmm2 \n" // src0[len+i]*win[len+i]
+ "mulps %%xmm5, %%xmm3 \n" // src1[ j]*win[len+j]
+ "mulps %%xmm4, %%xmm1 \n" // src0[len+i]*win[len+j]
+ "mulps %%xmm5, %%xmm0 \n" // src1[ j]*win[len+i]
+ "addps %%xmm3, %%xmm2 \n"
+ "subps %%xmm0, %%xmm1 \n"
+ "shufps $0x1b, %%xmm2, %%xmm2 \n"
+ "movaps %%xmm1, (%2,%0) \n"
+ "movaps %%xmm2, (%2,%1) \n"
+ "sub $16, %1 \n"
+ "add $16, %0 \n"
"jl 1b \n"
- :"+r"(i)
- :"r"(dst+len), "r"(src+len), "m"(mul)
+ :"+r"(i), "+r"(j)
+ :"r"(dst+len), "r"(src0+len), "r"(src1), "r"(win+len)
);
}
+#endif /* HAVE_6REGS */
static void vector_clipf_sse(float *dst, const float *src, float min, float max,
int len)
@@ -2339,70 +2370,6 @@ static void vector_clipf_sse(float *dst, const float *src, float min, float max,
);
}
-static void float_to_int16_3dnow(int16_t *dst, const float *src, long len){
- x86_reg reglen = len;
- // not bit-exact: pf2id uses different rounding than C and SSE
- __asm__ volatile(
- "add %0 , %0 \n\t"
- "lea (%2,%0,2) , %2 \n\t"
- "add %0 , %1 \n\t"
- "neg %0 \n\t"
- "1: \n\t"
- "pf2id (%2,%0,2) , %%mm0 \n\t"
- "pf2id 8(%2,%0,2) , %%mm1 \n\t"
- "pf2id 16(%2,%0,2) , %%mm2 \n\t"
- "pf2id 24(%2,%0,2) , %%mm3 \n\t"
- "packssdw %%mm1 , %%mm0 \n\t"
- "packssdw %%mm3 , %%mm2 \n\t"
- "movq %%mm0 , (%1,%0) \n\t"
- "movq %%mm2 , 8(%1,%0) \n\t"
- "add $16 , %0 \n\t"
- " js 1b \n\t"
- "femms \n\t"
- :"+r"(reglen), "+r"(dst), "+r"(src)
- );
-}
-static void float_to_int16_sse(int16_t *dst, const float *src, long len){
- x86_reg reglen = len;
- __asm__ volatile(
- "add %0 , %0 \n\t"
- "lea (%2,%0,2) , %2 \n\t"
- "add %0 , %1 \n\t"
- "neg %0 \n\t"
- "1: \n\t"
- "cvtps2pi (%2,%0,2) , %%mm0 \n\t"
- "cvtps2pi 8(%2,%0,2) , %%mm1 \n\t"
- "cvtps2pi 16(%2,%0,2) , %%mm2 \n\t"
- "cvtps2pi 24(%2,%0,2) , %%mm3 \n\t"
- "packssdw %%mm1 , %%mm0 \n\t"
- "packssdw %%mm3 , %%mm2 \n\t"
- "movq %%mm0 , (%1,%0) \n\t"
- "movq %%mm2 , 8(%1,%0) \n\t"
- "add $16 , %0 \n\t"
- " js 1b \n\t"
- "emms \n\t"
- :"+r"(reglen), "+r"(dst), "+r"(src)
- );
-}
-
-static void float_to_int16_sse2(int16_t *dst, const float *src, long len){
- x86_reg reglen = len;
- __asm__ volatile(
- "add %0 , %0 \n\t"
- "lea (%2,%0,2) , %2 \n\t"
- "add %0 , %1 \n\t"
- "neg %0 \n\t"
- "1: \n\t"
- "cvtps2dq (%2,%0,2) , %%xmm0 \n\t"
- "cvtps2dq 16(%2,%0,2) , %%xmm1 \n\t"
- "packssdw %%xmm1 , %%xmm0 \n\t"
- "movdqa %%xmm0 , (%1,%0) \n\t"
- "add $16 , %0 \n\t"
- " js 1b \n\t"
- :"+r"(reglen), "+r"(dst), "+r"(src)
- );
-}
-
void ff_vp3_idct_mmx(int16_t *input_data);
void ff_vp3_idct_put_mmx(uint8_t *dest, int line_size, DCTELEM *block);
void ff_vp3_idct_add_mmx(uint8_t *dest, int line_size, DCTELEM *block);
@@ -2416,9 +2383,6 @@ void ff_vp3_idct_sse2(int16_t *input_data);
void ff_vp3_idct_put_sse2(uint8_t *dest, int line_size, DCTELEM *block);
void ff_vp3_idct_add_sse2(uint8_t *dest, int line_size, DCTELEM *block);
-void ff_float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len);
-void ff_float_to_int16_interleave6_3dnow(int16_t *dst, const float **src, int len);
-void ff_float_to_int16_interleave6_3dn2(int16_t *dst, const float **src, int len);
int32_t ff_scalarproduct_int16_mmx2(const int16_t *v1, const int16_t *v2, int order, int shift);
int32_t ff_scalarproduct_int16_sse2(const int16_t *v1, const int16_t *v2, int order, int shift);
int32_t ff_scalarproduct_and_madd_int16_mmx2(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul);
@@ -2428,102 +2392,6 @@ void ff_add_hfyu_median_prediction_mmx2(uint8_t *dst, const uint8_t *top, const
int ff_add_hfyu_left_prediction_ssse3(uint8_t *dst, const uint8_t *src, int w, int left);
int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src, int w, int left);
-#if !HAVE_YASM
-#define ff_float_to_int16_interleave6_sse(a,b,c) float_to_int16_interleave_misc_sse(a,b,c,6)
-#define ff_float_to_int16_interleave6_3dnow(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6)
-#define ff_float_to_int16_interleave6_3dn2(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6)
-#endif
-#define ff_float_to_int16_interleave6_sse2 ff_float_to_int16_interleave6_sse
-
-#define FLOAT_TO_INT16_INTERLEAVE(cpu, body) \
-/* gcc pessimizes register allocation if this is in the same function as float_to_int16_interleave_sse2*/\
-static av_noinline void float_to_int16_interleave_misc_##cpu(int16_t *dst, const float **src, long len, int channels){\
- DECLARE_ALIGNED(16, int16_t, tmp)[len];\
- int i,j,c;\
- for(c=0; cgmc= gmc_mmx;
+#endif
+#if ARCH_X86_32 && HAVE_YASM
+ c->emulated_edge_mc = emulated_edge_mc_mmx;
+#endif
c->add_bytes= add_bytes_mmx;
c->add_bytes_l2= add_bytes_l2_mmx;
@@ -2649,7 +2522,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
#if HAVE_YASM
c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_mmx_rnd;
c->put_h264_chroma_pixels_tab[1]= ff_put_h264_chroma_mc4_mmx;
- c->put_no_rnd_vc1_chroma_pixels_tab[0]= ff_put_vc1_chroma_mc8_mmx_nornd;
c->put_rv40_chroma_pixels_tab[0]= ff_put_rv40_chroma_mc8_mmx;
c->put_rv40_chroma_pixels_tab[1]= ff_put_rv40_chroma_mc4_mmx;
@@ -2736,8 +2608,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->avg_rv40_chroma_pixels_tab[0]= ff_avg_rv40_chroma_mc8_mmx2;
c->avg_rv40_chroma_pixels_tab[1]= ff_avg_rv40_chroma_mc4_mmx2;
- c->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_mmx2_nornd;
-
c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_mmx2_rnd;
c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_mmx2;
c->avg_h264_chroma_pixels_tab[2]= ff_avg_h264_chroma_mc2_mmx2;
@@ -2750,9 +2620,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov;
#endif
- if (CONFIG_VC1_DECODER)
- ff_vc1dsp_init_mmx(c, avctx);
-
c->add_png_paeth_prediction= add_png_paeth_prediction_mmx2;
} else if (mm_flags & AV_CPU_FLAG_3DNOW) {
c->prefetch = prefetch_3dnow;
@@ -2809,8 +2676,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_3dnow_rnd;
c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_3dnow;
- c->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_3dnow_nornd;
-
c->avg_rv40_chroma_pixels_tab[0]= ff_avg_rv40_chroma_mc8_3dnow;
c->avg_rv40_chroma_pixels_tab[1]= ff_avg_rv40_chroma_mc4_3dnow;
#endif
@@ -2859,8 +2724,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
H264_QPEL_FUNCS(3, 3, ssse3);
c->add_png_paeth_prediction= add_png_paeth_prediction_ssse3;
#if HAVE_YASM
- c->put_no_rnd_vc1_chroma_pixels_tab[0]= ff_put_vc1_chroma_mc8_ssse3_nornd;
- c->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_ssse3_nornd;
c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_ssse3_rnd;
c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_ssse3_rnd;
c->put_h264_chroma_pixels_tab[1]= ff_put_h264_chroma_mc4_ssse3;
@@ -2875,17 +2738,12 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
if(mm_flags & AV_CPU_FLAG_3DNOW){
c->vorbis_inverse_coupling = vorbis_inverse_coupling_3dnow;
c->vector_fmul = vector_fmul_3dnow;
- if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
- c->float_to_int16 = float_to_int16_3dnow;
- c->float_to_int16_interleave = float_to_int16_interleave_3dnow;
- }
}
if(mm_flags & AV_CPU_FLAG_3DNOWEXT){
c->vector_fmul_reverse = vector_fmul_reverse_3dnow2;
+#if HAVE_6REGS
c->vector_fmul_window = vector_fmul_window_3dnow2;
- if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
- c->float_to_int16_interleave = float_to_int16_interleave_3dn2;
- }
+#endif
}
if(mm_flags & AV_CPU_FLAG_MMX2){
#if HAVE_YASM
@@ -2899,11 +2757,10 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->vector_fmul = vector_fmul_sse;
c->vector_fmul_reverse = vector_fmul_reverse_sse;
c->vector_fmul_add = vector_fmul_add_sse;
+#if HAVE_6REGS
c->vector_fmul_window = vector_fmul_window_sse;
- c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse;
+#endif
c->vector_clipf = vector_clipf_sse;
- c->float_to_int16 = float_to_int16_sse;
- c->float_to_int16_interleave = float_to_int16_interleave_sse;
#if HAVE_YASM
c->scalarproduct_float = ff_scalarproduct_float_sse;
#endif
@@ -2911,12 +2768,12 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
if(mm_flags & AV_CPU_FLAG_3DNOW)
c->vector_fmul_add = vector_fmul_add_3dnow; // faster than sse
if(mm_flags & AV_CPU_FLAG_SSE2){
- c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2;
- c->float_to_int16 = float_to_int16_sse2;
- c->float_to_int16_interleave = float_to_int16_interleave_sse2;
#if HAVE_YASM
c->scalarproduct_int16 = ff_scalarproduct_int16_sse2;
c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_sse2;
+
+ c->emulated_edge_mc = emulated_edge_mc_sse;
+ c->gmc= gmc_sse;
#endif
}
if((mm_flags & AV_CPU_FLAG_SSSE3) && !(mm_flags & (AV_CPU_FLAG_SSE42|AV_CPU_FLAG_3DNOW)) && HAVE_YASM) // cachesplit
diff --git a/mplayer/ffmpeg/libavcodec/x86/dsputil_mmx.h b/mplayer/ffmpeg/libavcodec/x86/dsputil_mmx.h
index a095e1ef..59a96136 100644
--- a/mplayer/ffmpeg/libavcodec/x86/dsputil_mmx.h
+++ b/mplayer/ffmpeg/libavcodec/x86/dsputil_mmx.h
@@ -196,7 +196,6 @@ void ff_avg_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
void ff_put_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
void ff_avg_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
-void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx);
void ff_put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd);
void ff_avg_vc1_mspel_mc00_mmx2(uint8_t *dst, const uint8_t *src, int stride, int rnd);
diff --git a/mplayer/ffmpeg/libavcodec/x86/dsputil_yasm.asm b/mplayer/ffmpeg/libavcodec/x86/dsputil_yasm.asm
index bda04727..53884a6b 100644
--- a/mplayer/ffmpeg/libavcodec/x86/dsputil_yasm.asm
+++ b/mplayer/ffmpeg/libavcodec/x86/dsputil_yasm.asm
@@ -30,75 +30,6 @@ pb_zz11zz55zz99zzdd: db -1,-1,1,1,-1,-1,5,5,-1,-1,9,9,-1,-1,13,13
section .text align=16
-%macro PSWAPD_SSE 2
- pshufw %1, %2, 0x4e
-%endmacro
-%macro PSWAPD_3DN1 2
- movq %1, %2
- psrlq %1, 32
- punpckldq %1, %2
-%endmacro
-
-%macro FLOAT_TO_INT16_INTERLEAVE6 1
-; void float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len)
-cglobal float_to_int16_interleave6_%1, 2,7,0, dst, src, src1, src2, src3, src4, src5
-%ifdef ARCH_X86_64
- %define lend r10d
- mov lend, r2d
-%else
- %define lend dword r2m
-%endif
- mov src1q, [srcq+1*gprsize]
- mov src2q, [srcq+2*gprsize]
- mov src3q, [srcq+3*gprsize]
- mov src4q, [srcq+4*gprsize]
- mov src5q, [srcq+5*gprsize]
- mov srcq, [srcq]
- sub src1q, srcq
- sub src2q, srcq
- sub src3q, srcq
- sub src4q, srcq
- sub src5q, srcq
-.loop:
- cvtps2pi mm0, [srcq]
- cvtps2pi mm1, [srcq+src1q]
- cvtps2pi mm2, [srcq+src2q]
- cvtps2pi mm3, [srcq+src3q]
- cvtps2pi mm4, [srcq+src4q]
- cvtps2pi mm5, [srcq+src5q]
- packssdw mm0, mm3
- packssdw mm1, mm4
- packssdw mm2, mm5
- pswapd mm3, mm0
- punpcklwd mm0, mm1
- punpckhwd mm1, mm2
- punpcklwd mm2, mm3
- pswapd mm3, mm0
- punpckldq mm0, mm2
- punpckhdq mm2, mm1
- punpckldq mm1, mm3
- movq [dstq ], mm0
- movq [dstq+16], mm2
- movq [dstq+ 8], mm1
- add srcq, 8
- add dstq, 24
- sub lend, 2
- jg .loop
- emms
- RET
-%endmacro ; FLOAT_TO_INT16_INTERLEAVE6
-
-%define pswapd PSWAPD_SSE
-FLOAT_TO_INT16_INTERLEAVE6 sse
-%define cvtps2pi pf2id
-%define pswapd PSWAPD_3DN1
-FLOAT_TO_INT16_INTERLEAVE6 3dnow
-%undef pswapd
-FLOAT_TO_INT16_INTERLEAVE6 3dn2
-%undef cvtps2pi
-
-
-
%macro SCALARPRODUCT 1
; int scalarproduct_int16(int16_t *v1, int16_t *v2, int order, int shift)
cglobal scalarproduct_int16_%1, 3,3,4, v1, v2, order, shift
@@ -421,3 +352,573 @@ cglobal scalarproduct_float_sse, 3,3,2, v1, v2, offset
fld dword r0m
%endif
RET
+
+; extern void ff_emu_edge_core(uint8_t *buf, const uint8_t *src, x86_reg linesize,
+; x86_reg start_y, x86_reg end_y, x86_reg block_h,
+; x86_reg start_x, x86_reg end_x, x86_reg block_w);
+;
+; The actual function itself is below. It basically wraps a very simple
+; w = end_x - start_x
+; if (w) {
+; if (w > 22) {
+; jump to the slow loop functions
+; } else {
+; jump to the fast loop functions
+; }
+; }
+;
+; ... and then the same for left/right extend also. See below for loop
+; function implementations. Fast are fixed-width, slow is variable-width
+
+%macro EMU_EDGE_FUNC 1
+%ifdef ARCH_X86_64
+%define w_reg r10
+cglobal emu_edge_core_%1, 6, 7, 1
+ mov r11, r5 ; save block_h
+%else
+%define w_reg r6
+cglobal emu_edge_core_%1, 2, 7, 0
+ mov r4, r4m ; end_y
+ mov r5, r5m ; block_h
+%endif
+
+ ; start with vertical extend (top/bottom) and body pixel copy
+ mov w_reg, r7m
+ sub w_reg, r6m ; w = start_x - end_x
+ sub r5, r4
+%ifdef ARCH_X86_64
+ sub r4, r3
+%else
+ sub r4, dword r3m
+%endif
+ cmp w_reg, 22
+ jg .slow_v_extend_loop
+%ifdef ARCH_X86_32
+ mov r2, r2m ; linesize
+%endif
+ sal w_reg, 7 ; w * 128
+%ifdef PIC
+ lea rax, [.emuedge_v_extend_1 - (.emuedge_v_extend_2 - .emuedge_v_extend_1)]
+ add w_reg, rax
+%else
+ lea w_reg, [.emuedge_v_extend_1 - (.emuedge_v_extend_2 - .emuedge_v_extend_1)+w_reg]
+%endif
+ call w_reg ; fast top extend, body copy and bottom extend
+.v_extend_end:
+
+ ; horizontal extend (left/right)
+ mov w_reg, r6m ; start_x
+ sub r0, w_reg
+%ifdef ARCH_X86_64
+ mov r3, r0 ; backup of buf+block_h*linesize
+ mov r5, r11
+%else
+ mov r0m, r0 ; backup of buf+block_h*linesize
+ mov r5, r5m
+%endif
+ test w_reg, w_reg
+ jz .right_extend
+ cmp w_reg, 22
+ jg .slow_left_extend_loop
+ mov r1, w_reg
+ dec w_reg
+ ; FIXME we can do a if size == 1 here if that makes any speed difference, test me
+ sar w_reg, 1
+ sal w_reg, 6
+ ; r0=buf+block_h*linesize,r10(64)/r6(32)=start_x offset for funcs
+ ; r6(rax)/r3(ebx)=val,r2=linesize,r1=start_x,r5=block_h
+%ifdef PIC
+ lea rax, [.emuedge_extend_left_2]
+ add w_reg, rax
+%else
+ lea w_reg, [.emuedge_extend_left_2+w_reg]
+%endif
+ call w_reg
+
+ ; now r3(64)/r0(32)=buf,r2=linesize,r11/r5=block_h,r6/r3=val, r10/r6=end_x, r1=block_w
+.right_extend:
+%ifdef ARCH_X86_32
+ mov r0, r0m
+ mov r5, r5m
+%endif
+ mov w_reg, r7m ; end_x
+ mov r1, r8m ; block_w
+ mov r4, r1
+ sub r1, w_reg
+ jz .h_extend_end ; if (end_x == block_w) goto h_extend_end
+ cmp r1, 22
+ jg .slow_right_extend_loop
+ dec r1
+ ; FIXME we can do a if size == 1 here if that makes any speed difference, test me
+ sar r1, 1
+ sal r1, 6
+%ifdef PIC
+ lea rax, [.emuedge_extend_right_2]
+ add r1, rax
+%else
+ lea r1, [.emuedge_extend_right_2+r1]
+%endif
+ call r1
+.h_extend_end:
+ RET
+
+%ifdef ARCH_X86_64
+%define vall al
+%define valh ah
+%define valw ax
+%define valw2 r10w
+%define valw3 r3w
+%ifdef WIN64
+%define valw4 r4w
+%else ; unix64
+%define valw4 r3w
+%endif
+%define vald eax
+%else
+%define vall bl
+%define valh bh
+%define valw bx
+%define valw2 r6w
+%define valw3 valw2
+%define valw4 valw3
+%define vald ebx
+%define stack_offset 0x14
+%endif
+
+%endmacro
+
+; macro to read/write a horizontal number of pixels (%2) to/from registers
+; on x86-64, - fills xmm0-15 for consecutive sets of 16 pixels
+; - if (%2 & 15 == 8) fills the last 8 bytes into rax
+; - else if (%2 & 8) fills 8 bytes into mm0
+; - if (%2 & 7 == 4) fills the last 4 bytes into rax
+; - else if (%2 & 4) fills 4 bytes into mm0-1
+; - if (%2 & 3 == 3) fills 2 bytes into r10/r3, and 1 into eax
+; (note that we're using r3 for body/bottom because it's a shorter
+; opcode, and then the loop fits in 128 bytes)
+; - else fills remaining bytes into rax
+; on x86-32, - fills mm0-7 for consecutive sets of 8 pixels
+; - if (%2 & 7 == 4) fills 4 bytes into ebx
+; - else if (%2 & 4) fills 4 bytes into mm0-7
+; - if (%2 & 3 == 3) fills 2 bytes into r6, and 1 into ebx
+; - else fills remaining bytes into ebx
+; writing data out is in the same way
+%macro READ_NUM_BYTES 3
+%assign %%src_off 0 ; offset in source buffer
+%assign %%smidx 0 ; mmx register idx
+%assign %%sxidx 0 ; xmm register idx
+
+%ifnidn %3, mmx
+%rep %2/16
+ movdqu xmm %+ %%sxidx, [r1+%%src_off]
+%assign %%src_off %%src_off+16
+%assign %%sxidx %%sxidx+1
+%endrep ; %2/16
+%endif ; !mmx
+
+%ifdef ARCH_X86_64
+%if (%2-%%src_off) == 8
+ mov rax, [r1+%%src_off]
+%assign %%src_off %%src_off+8
+%endif ; (%2-%%src_off) == 8
+%endif ; x86-64
+
+%rep (%2-%%src_off)/8
+ movq mm %+ %%smidx, [r1+%%src_off]
+%assign %%src_off %%src_off+8
+%assign %%smidx %%smidx+1
+%endrep ; (%2-%%dst_off)/8
+
+%if (%2-%%src_off) == 4
+ mov vald, [r1+%%src_off]
+%elif (%2-%%src_off) & 4
+ movd mm %+ %%smidx, [r1+%%src_off]
+%assign %%src_off %%src_off+4
+%endif ; (%2-%%src_off) ==/& 4
+
+%if (%2-%%src_off) == 1
+ mov vall, [r1+%%src_off]
+%elif (%2-%%src_off) == 2
+ mov valw, [r1+%%src_off]
+%elif (%2-%%src_off) == 3
+%ifidn %1, top
+ mov valw2, [r1+%%src_off]
+%elifidn %1, body
+ mov valw3, [r1+%%src_off]
+%elifidn %1, bottom
+ mov valw4, [r1+%%src_off]
+%endif ; %1 ==/!= top
+ mov vall, [r1+%%src_off+2]
+%endif ; (%2-%%src_off) == 1/2/3
+%endmacro ; READ_NUM_BYTES
+
+%macro WRITE_NUM_BYTES 3
+%assign %%dst_off 0 ; offset in destination buffer
+%assign %%dmidx 0 ; mmx register idx
+%assign %%dxidx 0 ; xmm register idx
+
+%ifnidn %3, mmx
+%rep %2/16
+ movdqu [r0+%%dst_off], xmm %+ %%dxidx
+%assign %%dst_off %%dst_off+16
+%assign %%dxidx %%dxidx+1
+%endrep ; %2/16
+%endif
+
+%ifdef ARCH_X86_64
+%if (%2-%%dst_off) == 8
+ mov [r0+%%dst_off], rax
+%assign %%dst_off %%dst_off+8
+%endif ; (%2-%%dst_off) == 8
+%endif ; x86-64
+
+%rep (%2-%%dst_off)/8
+ movq [r0+%%dst_off], mm %+ %%dmidx
+%assign %%dst_off %%dst_off+8
+%assign %%dmidx %%dmidx+1
+%endrep ; (%2-%%dst_off)/8
+
+%if (%2-%%dst_off) == 4
+ mov [r0+%%dst_off], vald
+%elif (%2-%%dst_off) & 4
+ movd [r0+%%dst_off], mm %+ %%dmidx
+%assign %%dst_off %%dst_off+4
+%endif ; (%2-%%dst_off) ==/& 4
+
+%if (%2-%%dst_off) == 1
+ mov [r0+%%dst_off], vall
+%elif (%2-%%dst_off) == 2
+ mov [r0+%%dst_off], valw
+%elif (%2-%%dst_off) == 3
+%ifidn %1, top
+ mov [r0+%%dst_off], valw2
+%elifidn %1, body
+ mov [r0+%%dst_off], valw3
+%elifidn %1, bottom
+ mov [r0+%%dst_off], valw4
+%endif ; %1 ==/!= top
+ mov [r0+%%dst_off+2], vall
+%endif ; (%2-%%dst_off) == 1/2/3
+%endmacro ; WRITE_NUM_BYTES
+
+; vertical top/bottom extend and body copy fast loops
+; these are function pointers to set-width line copy functions, i.e.
+; they read a fixed number of pixels into set registers, and write
+; those out into the destination buffer
+; r0=buf,r1=src,r2=linesize,r3(64)/r3m(32)=start_x,r4=end_y,r5=block_h
+; r6(eax/64)/r3(ebx/32)=val_reg
+%macro VERTICAL_EXTEND 1
+%assign %%n 1
+%rep 22
+ALIGN 128
+.emuedge_v_extend_ %+ %%n:
+ ; extend pixels above body
+%ifdef ARCH_X86_64
+ test r3 , r3 ; if (!start_y)
+ jz .emuedge_copy_body_ %+ %%n %+ _loop ; goto body
+%else ; ARCH_X86_32
+ cmp dword r3m, 0
+ je .emuedge_copy_body_ %+ %%n %+ _loop
+%endif ; ARCH_X86_64/32
+ READ_NUM_BYTES top, %%n, %1 ; read bytes
+.emuedge_extend_top_ %+ %%n %+ _loop: ; do {
+ WRITE_NUM_BYTES top, %%n, %1 ; write bytes
+ add r0 , r2 ; dst += linesize
+%ifdef ARCH_X86_64
+ dec r3d
+%else ; ARCH_X86_32
+ dec dword r3m
+%endif ; ARCH_X86_64/32
+ jnz .emuedge_extend_top_ %+ %%n %+ _loop ; } while (--start_y)
+
+ ; copy body pixels
+.emuedge_copy_body_ %+ %%n %+ _loop: ; do {
+ READ_NUM_BYTES body, %%n, %1 ; read bytes
+ WRITE_NUM_BYTES body, %%n, %1 ; write bytes
+ add r0 , r2 ; dst += linesize
+ add r1 , r2 ; src += linesize
+ dec r4d
+ jnz .emuedge_copy_body_ %+ %%n %+ _loop ; } while (--end_y)
+
+ ; copy bottom pixels
+ test r5 , r5 ; if (!block_h)
+ jz .emuedge_v_extend_end_ %+ %%n ; goto end
+ sub r1 , r2 ; src -= linesize
+ READ_NUM_BYTES bottom, %%n, %1 ; read bytes
+.emuedge_extend_bottom_ %+ %%n %+ _loop: ; do {
+ WRITE_NUM_BYTES bottom, %%n, %1 ; write bytes
+ add r0 , r2 ; dst += linesize
+ dec r5d
+ jnz .emuedge_extend_bottom_ %+ %%n %+ _loop ; } while (--block_h)
+
+.emuedge_v_extend_end_ %+ %%n:
+%ifdef ARCH_X86_64
+ ret
+%else ; ARCH_X86_32
+ rep ret
+%endif ; ARCH_X86_64/32
+%assign %%n %%n+1
+%endrep
+%endmacro VERTICAL_EXTEND
+
+; left/right (horizontal) fast extend functions
+; these are essentially identical to the vertical extend ones above,
+; just left/right separated because number of pixels to extend is
+; obviously not the same on both sides.
+; for reading, pixels are placed in eax (x86-64) or ebx (x86-64) in the
+; lowest two bytes of the register (so val*0x0101), and are splatted
+; into each byte of mm0 as well if n_pixels >= 8
+
+%macro READ_V_PIXEL 3
+ mov vall, %2
+ mov valh, vall
+%if %1 >= 8
+ movd mm0, vald
+%ifidn %3, mmx
+ punpcklwd mm0, mm0
+ punpckldq mm0, mm0
+%else ; !mmx
+ pshufw mm0, mm0, 0
+%endif ; mmx
+%endif ; %1 >= 8
+%endmacro
+
+%macro WRITE_V_PIXEL 2
+%assign %%dst_off 0
+%rep %1/8
+ movq [%2+%%dst_off], mm0
+%assign %%dst_off %%dst_off+8
+%endrep
+%if %1 & 4
+%if %1 >= 8
+ movd [%2+%%dst_off], mm0
+%else ; %1 < 8
+ mov [%2+%%dst_off] , valw
+ mov [%2+%%dst_off+2], valw
+%endif ; %1 >=/< 8
+%assign %%dst_off %%dst_off+4
+%endif ; %1 & 4
+%if %1&2
+ mov [%2+%%dst_off], valw
+%endif ; %1 & 2
+%endmacro
+
+; r0=buf+block_h*linesize, r1=start_x, r2=linesize, r5=block_h, r6/r3=val
+%macro LEFT_EXTEND 1
+%assign %%n 2
+%rep 11
+ALIGN 64
+.emuedge_extend_left_ %+ %%n: ; do {
+ sub r0, r2 ; dst -= linesize
+ READ_V_PIXEL %%n, [r0+r1], %1 ; read pixels
+ WRITE_V_PIXEL %%n, r0 ; write pixels
+ dec r5
+ jnz .emuedge_extend_left_ %+ %%n ; } while (--block_h)
+%ifdef ARCH_X86_64
+ ret
+%else ; ARCH_X86_32
+ rep ret
+%endif ; ARCH_X86_64/32
+%assign %%n %%n+2
+%endrep
+%endmacro ; LEFT_EXTEND
+
+; r3/r0=buf+block_h*linesize, r2=linesize, r11/r5=block_h, r0/r6=end_x, r6/r3=val
+%macro RIGHT_EXTEND 1
+%assign %%n 2
+%rep 11
+ALIGN 64
+.emuedge_extend_right_ %+ %%n: ; do {
+%ifdef ARCH_X86_64
+ sub r3, r2 ; dst -= linesize
+ READ_V_PIXEL %%n, [r3+w_reg-1], %1 ; read pixels
+ WRITE_V_PIXEL %%n, r3+r4-%%n ; write pixels
+ dec r11
+%else ; ARCH_X86_32
+ sub r0, r2 ; dst -= linesize
+ READ_V_PIXEL %%n, [r0+w_reg-1], %1 ; read pixels
+ WRITE_V_PIXEL %%n, r0+r4-%%n ; write pixels
+ dec r5
+%endif ; ARCH_X86_64/32
+ jnz .emuedge_extend_right_ %+ %%n ; } while (--block_h)
+%ifdef ARCH_X86_64
+ ret
+%else ; ARCH_X86_32
+ rep ret
+%endif ; ARCH_X86_64/32
+%assign %%n %%n+2
+%endrep
+
+%ifdef ARCH_X86_32
+%define stack_offset 0x10
+%endif
+%endmacro ; RIGHT_EXTEND
+
+; below follow the "slow" copy/extend functions, these act on a non-fixed
+; width specified in a register, and run a loop to copy the full amount
+; of bytes. They are optimized for copying of large amounts of pixels per
+; line, so they unconditionally splat data into mm registers to copy 8
+; bytes per loop iteration. It could be considered to use xmm for x86-64
+; also, but I haven't optimized this as much (i.e. FIXME)
+%macro V_COPY_NPX 4-5
+%if %0 == 4
+ test w_reg, %4
+ jz .%1_skip_%4_px
+%else ; %0 == 5
+.%1_%4_px_loop:
+%endif
+ %3 %2, [r1+cnt_reg]
+ %3 [r0+cnt_reg], %2
+ add cnt_reg, %4
+%if %0 == 5
+ sub w_reg, %4
+ test w_reg, %5
+ jnz .%1_%4_px_loop
+%endif
+.%1_skip_%4_px:
+%endmacro
+
+%macro V_COPY_ROW 3
+%ifidn %1, bottom
+ sub r1, linesize
+%endif
+.%1_copy_loop:
+ xor cnt_reg, cnt_reg
+%ifidn %3, mmx
+%define linesize r2m
+ V_COPY_NPX %1, mm0, movq, 8, 0xFFFFFFF8
+%else ; !mmx
+ V_COPY_NPX %1, xmm0, movdqu, 16, 0xFFFFFFF0
+%ifdef ARCH_X86_64
+%define linesize r2
+ V_COPY_NPX %1, rax , mov, 8
+%else ; ARCH_X86_32
+%define linesize r2m
+ V_COPY_NPX %1, mm0, movq, 8
+%endif ; ARCH_X86_64/32
+%endif ; mmx
+ V_COPY_NPX %1, vald, mov, 4
+ V_COPY_NPX %1, valw, mov, 2
+ V_COPY_NPX %1, vall, mov, 1
+ mov w_reg, cnt_reg
+%ifidn %1, body
+ add r1, linesize
+%endif
+ add r0, linesize
+ dec %2
+ jnz .%1_copy_loop
+%endmacro
+
+%macro SLOW_V_EXTEND 1
+.slow_v_extend_loop:
+; r0=buf,r1=src,r2(64)/r2m(32)=linesize,r3(64)/r3m(32)=start_x,r4=end_y,r5=block_h
+; r11(64)/r3(later-64)/r2(32)=cnt_reg,r6(64)/r3(32)=val_reg,r10(64)/r6(32)=w=end_x-start_x
+%ifdef ARCH_X86_64
+ push r11 ; save old value of block_h
+ test r3, r3
+%define cnt_reg r11
+ jz .do_body_copy ; if (!start_y) goto do_body_copy
+ V_COPY_ROW top, r3, %1
+%else
+ cmp dword r3m, 0
+%define cnt_reg r2
+ je .do_body_copy ; if (!start_y) goto do_body_copy
+ V_COPY_ROW top, dword r3m, %1
+%endif
+
+.do_body_copy:
+ V_COPY_ROW body, r4, %1
+
+%ifdef ARCH_X86_64
+ pop r11 ; restore old value of block_h
+%define cnt_reg r3
+%endif
+ test r5, r5
+%ifdef ARCH_X86_64
+ jz .v_extend_end
+%else
+ jz .skip_bottom_extend
+%endif
+ V_COPY_ROW bottom, r5, %1
+%ifdef ARCH_X86_32
+.skip_bottom_extend:
+ mov r2, r2m
+%endif
+ jmp .v_extend_end
+%endmacro
+
+%macro SLOW_LEFT_EXTEND 1
+.slow_left_extend_loop:
+; r0=buf+block_h*linesize,r2=linesize,r6(64)/r3(32)=val,r5=block_h,r4=cntr,r10/r6=start_x
+ mov r4, 8
+ sub r0, linesize
+ READ_V_PIXEL 8, [r0+w_reg], %1
+.left_extend_8px_loop:
+ movq [r0+r4-8], mm0
+ add r4, 8
+ cmp r4, w_reg
+ jle .left_extend_8px_loop
+ sub r4, 8
+ cmp r4, w_reg
+ jge .left_extend_loop_end
+.left_extend_2px_loop:
+ mov [r0+r4], valw
+ add r4, 2
+ cmp r4, w_reg
+ jl .left_extend_2px_loop
+.left_extend_loop_end:
+ dec r5
+ jnz .slow_left_extend_loop
+%ifdef ARCH_X86_32
+ mov r2, r2m
+%endif
+ jmp .right_extend
+%endmacro
+
+%macro SLOW_RIGHT_EXTEND 1
+.slow_right_extend_loop:
+; r3(64)/r0(32)=buf+block_h*linesize,r2=linesize,r4=block_w,r11(64)/r5(32)=block_h,
+; r10(64)/r6(32)=end_x,r6/r3=val,r1=cntr
+%ifdef ARCH_X86_64
+%define buf_reg r3
+%define bh_reg r11
+%else
+%define buf_reg r0
+%define bh_reg r5
+%endif
+ lea r1, [r4-8]
+ sub buf_reg, linesize
+ READ_V_PIXEL 8, [buf_reg+w_reg-1], %1
+.right_extend_8px_loop:
+ movq [buf_reg+r1], mm0
+ sub r1, 8
+ cmp r1, w_reg
+ jge .right_extend_8px_loop
+ add r1, 8
+ cmp r1, w_reg
+ je .right_extend_loop_end
+.right_extend_2px_loop:
+ sub r1, 2
+ mov [buf_reg+r1], valw
+ cmp r1, w_reg
+ jg .right_extend_2px_loop
+.right_extend_loop_end:
+ dec bh_reg
+ jnz .slow_right_extend_loop
+ jmp .h_extend_end
+%endmacro
+
+%macro emu_edge 1
+EMU_EDGE_FUNC %1
+VERTICAL_EXTEND %1
+LEFT_EXTEND %1
+RIGHT_EXTEND %1
+SLOW_V_EXTEND %1
+SLOW_LEFT_EXTEND %1
+SLOW_RIGHT_EXTEND %1
+%endmacro
+
+emu_edge sse
+%ifdef ARCH_X86_32
+emu_edge mmx
+%endif
diff --git a/mplayer/ffmpeg/libavcodec/x86/fft.c b/mplayer/ffmpeg/libavcodec/x86/fft.c
index 771b1e66..5ca341d5 100644
--- a/mplayer/ffmpeg/libavcodec/x86/fft.c
+++ b/mplayer/ffmpeg/libavcodec/x86/fft.c
@@ -30,6 +30,7 @@ av_cold void ff_fft_init_mmx(FFTContext *s)
s->imdct_half = ff_imdct_half_sse;
s->fft_permute = ff_fft_permute_sse;
s->fft_calc = ff_fft_calc_sse;
+ s->fft_permutation = FF_FFT_PERM_SWAP_LSBS;
} else if (has_vectors & AV_CPU_FLAG_3DNOWEXT && HAVE_AMD3DNOWEXT) {
/* 3DNowEx for K7 */
s->imdct_calc = ff_imdct_calc_3dn2;
diff --git a/mplayer/ffmpeg/libavcodec/x86/fft_mmx.asm b/mplayer/ffmpeg/libavcodec/x86/fft_mmx.asm
index 1dcd6291..68e20df3 100644
--- a/mplayer/ffmpeg/libavcodec/x86/fft_mmx.asm
+++ b/mplayer/ffmpeg/libavcodec/x86/fft_mmx.asm
@@ -51,6 +51,7 @@ SECTION_RODATA
%define M_SQRT1_2 0.70710678118654752440
ps_root2: times 4 dd M_SQRT1_2
ps_root2mppm: dd -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2
+ps_p1p1m1p1: dd 0, 0, 1<<31, 0
ps_m1p1: dd 1<<31, 0
%assign i 16
@@ -95,54 +96,51 @@ section .text align=16
SWAP %3, %6
%endmacro
-; in: %1={r0,i0,r1,i1} %2={r2,i2,r3,i3}
+; in: %1={r0,i0,r2,i2} %2={r1,i1,r3,i3}
; out: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3}
%macro T4_SSE 3
mova %3, %1
- shufps %1, %2, 0x64 ; {r0,i0,r3,i2}
- shufps %3, %2, 0xce ; {r1,i1,r2,i3}
+ addps %1, %2 ; {t1,t2,t6,t5}
+ subps %3, %2 ; {t3,t4,-t8,t7}
+ xorps %3, [ps_p1p1m1p1]
mova %2, %1
- addps %1, %3 ; {t1,t2,t6,t5}
- subps %2, %3 ; {t3,t4,t8,t7}
+ shufps %1, %3, 0x44 ; {t1,t2,t3,t4}
+ shufps %2, %3, 0xbe ; {t6,t5,t7,t8}
mova %3, %1
- shufps %1, %2, 0x44 ; {t1,t2,t3,t4}
- shufps %3, %2, 0xbe ; {t6,t5,t7,t8}
+ addps %1, %2 ; {r0,i0,r1,i1}
+ subps %3, %2 ; {r2,i2,r3,i3}
mova %2, %1
- addps %1, %3 ; {r0,i0,r1,i1}
- subps %2, %3 ; {r2,i2,r3,i3}
- mova %3, %1
- shufps %1, %2, 0x88 ; {r0,r1,r2,r3}
- shufps %3, %2, 0xdd ; {i0,i1,i2,i3}
- SWAP %2, %3
+ shufps %1, %3, 0x88 ; {r0,r1,r2,r3}
+ shufps %2, %3, 0xdd ; {i0,i1,i2,i3}
%endmacro
-%macro T8_SSE 6 ; r0,i0,r1,i1,t0,t1
- mova %5, %3
- shufps %3, %4, 0x44 ; {r4,i4,r6,i6}
- shufps %5, %4, 0xee ; {r5,i5,r7,i7}
+; in: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3} %3={r4,i4,r6,i6} %4={r5,i5,r7,i7}
+; out: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3} %1={r4,r5,r6,r7} %2={i4,i5,i6,i7}
+%macro T8_SSE 6
mova %6, %3
- subps %3, %5 ; {r5,i5,r7,i7}
- addps %6, %5 ; {t1,t2,t3,t4}
- mova %5, %3
- shufps %5, %5, 0xb1 ; {i5,r5,i7,r7}
+ subps %3, %4 ; {r5,i5,r7,i7}
+ addps %6, %4 ; {t1,t2,t3,t4}
+ mova %4, %3
+ shufps %4, %4, 0xb1 ; {i5,r5,i7,r7}
mulps %3, [ps_root2mppm] ; {-r5,i5,r7,-i7}
- mulps %5, [ps_root2]
- addps %3, %5 ; {t8,t7,ta,t9}
- mova %5, %6
+ mulps %4, [ps_root2]
+ addps %3, %4 ; {t8,t7,ta,t9}
+ mova %4, %6
shufps %6, %3, 0x36 ; {t3,t2,t9,t8}
- shufps %5, %3, 0x9c ; {t1,t4,t7,ta}
+ shufps %4, %3, 0x9c ; {t1,t4,t7,ta}
mova %3, %6
- addps %6, %5 ; {t1,t2,t9,ta}
- subps %3, %5 ; {t6,t5,tc,tb}
- mova %5, %6
+ addps %6, %4 ; {t1,t2,t9,ta}
+ subps %3, %4 ; {t6,t5,tc,tb}
+ mova %4, %6
shufps %6, %3, 0xd8 ; {t1,t9,t5,tb}
- shufps %5, %3, 0x8d ; {t2,ta,t6,tc}
+ shufps %4, %3, 0x8d ; {t2,ta,t6,tc}
mova %3, %1
- mova %4, %2
+ mova %5, %2
addps %1, %6 ; {r0,r1,r2,r3}
- addps %2, %5 ; {i0,i1,i2,i3}
+ addps %2, %4 ; {i0,i1,i2,i3}
subps %3, %6 ; {r4,r5,r6,r7}
- subps %4, %5 ; {i4,i5,i6,i7}
+ subps %5, %4 ; {i4,i5,i6,i7}
+ SWAP %4, %5
%endmacro
; scheduled for cpu-bound sizes
diff --git a/mplayer/ffmpeg/libavcodec/x86/fft_sse.c b/mplayer/ffmpeg/libavcodec/x86/fft_sse.c
index 9f02816d..0d151bc4 100644
--- a/mplayer/ffmpeg/libavcodec/x86/fft_sse.c
+++ b/mplayer/ffmpeg/libavcodec/x86/fft_sse.c
@@ -23,7 +23,7 @@
#include "libavcodec/dsputil.h"
#include "fft.h"
-DECLARE_ALIGNED(16, static const int, m1m1m1m1)[4] =
+DECLARE_ASM_CONST(16, int, ff_m1m1m1m1)[4] =
{ 1 << 31, 1 << 31, 1 << 31, 1 << 31 };
void ff_fft_dispatch_sse(FFTComplex *z, int nbits);
@@ -82,7 +82,7 @@ void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input)
j = -n;
k = n-16;
__asm__ volatile(
- "movaps %4, %%xmm7 \n"
+ "movaps "MANGLE(ff_m1m1m1m1)", %%xmm7 \n"
"1: \n"
"movaps (%2,%1), %%xmm0 \n"
"movaps (%3,%0), %%xmm1 \n"
@@ -95,8 +95,7 @@ void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input)
"add $16, %0 \n"
"jl 1b \n"
:"+r"(j), "+r"(k)
- :"r"(output+n4), "r"(output+n4*3),
- "m"(*m1m1m1m1)
+ :"r"(output+n4), "r"(output+n4*3)
XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm7")
);
}
diff --git a/mplayer/ffmpeg/libavcodec/x86/fmtconvert.asm b/mplayer/ffmpeg/libavcodec/x86/fmtconvert.asm
new file mode 100644
index 00000000..6c744fc5
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/x86/fmtconvert.asm
@@ -0,0 +1,91 @@
+;******************************************************************************
+;* x86 optimized Format Conversion Utils
+;* Copyright (c) 2008 Loren Merritt
+;*
+;* 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
+;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "x86inc.asm"
+
+section .text align=16
+
+%macro PSWAPD_SSE 2
+ pshufw %1, %2, 0x4e
+%endmacro
+%macro PSWAPD_3DN1 2
+ movq %1, %2
+ psrlq %1, 32
+ punpckldq %1, %2
+%endmacro
+
+%macro FLOAT_TO_INT16_INTERLEAVE6 1
+; void float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len)
+cglobal float_to_int16_interleave6_%1, 2,7,0, dst, src, src1, src2, src3, src4, src5
+%ifdef ARCH_X86_64
+ %define lend r10d
+ mov lend, r2d
+%else
+ %define lend dword r2m
+%endif
+ mov src1q, [srcq+1*gprsize]
+ mov src2q, [srcq+2*gprsize]
+ mov src3q, [srcq+3*gprsize]
+ mov src4q, [srcq+4*gprsize]
+ mov src5q, [srcq+5*gprsize]
+ mov srcq, [srcq]
+ sub src1q, srcq
+ sub src2q, srcq
+ sub src3q, srcq
+ sub src4q, srcq
+ sub src5q, srcq
+.loop:
+ cvtps2pi mm0, [srcq]
+ cvtps2pi mm1, [srcq+src1q]
+ cvtps2pi mm2, [srcq+src2q]
+ cvtps2pi mm3, [srcq+src3q]
+ cvtps2pi mm4, [srcq+src4q]
+ cvtps2pi mm5, [srcq+src5q]
+ packssdw mm0, mm3
+ packssdw mm1, mm4
+ packssdw mm2, mm5
+ pswapd mm3, mm0
+ punpcklwd mm0, mm1
+ punpckhwd mm1, mm2
+ punpcklwd mm2, mm3
+ pswapd mm3, mm0
+ punpckldq mm0, mm2
+ punpckhdq mm2, mm1
+ punpckldq mm1, mm3
+ movq [dstq ], mm0
+ movq [dstq+16], mm2
+ movq [dstq+ 8], mm1
+ add srcq, 8
+ add dstq, 24
+ sub lend, 2
+ jg .loop
+ emms
+ RET
+%endmacro ; FLOAT_TO_INT16_INTERLEAVE6
+
+%define pswapd PSWAPD_SSE
+FLOAT_TO_INT16_INTERLEAVE6 sse
+%define cvtps2pi pf2id
+%define pswapd PSWAPD_3DN1
+FLOAT_TO_INT16_INTERLEAVE6 3dnow
+%undef pswapd
+FLOAT_TO_INT16_INTERLEAVE6 3dn2
+%undef cvtps2pi
diff --git a/mplayer/ffmpeg/libavcodec/x86/fmtconvert_mmx.c b/mplayer/ffmpeg/libavcodec/x86/fmtconvert_mmx.c
new file mode 100644
index 00000000..ea41f730
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/x86/fmtconvert_mmx.c
@@ -0,0 +1,266 @@
+/*
+ * Format Conversion Utils
+ * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer
+ *
+ * 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
+ *
+ * MMX optimization by Nick Kurshev
+ */
+
+#include "libavutil/cpu.h"
+#include "libavutil/x86_cpu.h"
+#include "libavcodec/fmtconvert.h"
+
+static void int32_to_float_fmul_scalar_sse(float *dst, const int *src, float mul, int len)
+{
+ x86_reg i = -4*len;
+ __asm__ volatile(
+ "movss %3, %%xmm4 \n"
+ "shufps $0, %%xmm4, %%xmm4 \n"
+ "1: \n"
+ "cvtpi2ps (%2,%0), %%xmm0 \n"
+ "cvtpi2ps 8(%2,%0), %%xmm1 \n"
+ "cvtpi2ps 16(%2,%0), %%xmm2 \n"
+ "cvtpi2ps 24(%2,%0), %%xmm3 \n"
+ "movlhps %%xmm1, %%xmm0 \n"
+ "movlhps %%xmm3, %%xmm2 \n"
+ "mulps %%xmm4, %%xmm0 \n"
+ "mulps %%xmm4, %%xmm2 \n"
+ "movaps %%xmm0, (%1,%0) \n"
+ "movaps %%xmm2, 16(%1,%0) \n"
+ "add $32, %0 \n"
+ "jl 1b \n"
+ :"+r"(i)
+ :"r"(dst+len), "r"(src+len), "m"(mul)
+ );
+}
+
+static void int32_to_float_fmul_scalar_sse2(float *dst, const int *src, float mul, int len)
+{
+ x86_reg i = -4*len;
+ __asm__ volatile(
+ "movss %3, %%xmm4 \n"
+ "shufps $0, %%xmm4, %%xmm4 \n"
+ "1: \n"
+ "cvtdq2ps (%2,%0), %%xmm0 \n"
+ "cvtdq2ps 16(%2,%0), %%xmm1 \n"
+ "mulps %%xmm4, %%xmm0 \n"
+ "mulps %%xmm4, %%xmm1 \n"
+ "movaps %%xmm0, (%1,%0) \n"
+ "movaps %%xmm1, 16(%1,%0) \n"
+ "add $32, %0 \n"
+ "jl 1b \n"
+ :"+r"(i)
+ :"r"(dst+len), "r"(src+len), "m"(mul)
+ );
+}
+
+static void float_to_int16_3dnow(int16_t *dst, const float *src, long len){
+ x86_reg reglen = len;
+ // not bit-exact: pf2id uses different rounding than C and SSE
+ __asm__ volatile(
+ "add %0 , %0 \n\t"
+ "lea (%2,%0,2) , %2 \n\t"
+ "add %0 , %1 \n\t"
+ "neg %0 \n\t"
+ "1: \n\t"
+ "pf2id (%2,%0,2) , %%mm0 \n\t"
+ "pf2id 8(%2,%0,2) , %%mm1 \n\t"
+ "pf2id 16(%2,%0,2) , %%mm2 \n\t"
+ "pf2id 24(%2,%0,2) , %%mm3 \n\t"
+ "packssdw %%mm1 , %%mm0 \n\t"
+ "packssdw %%mm3 , %%mm2 \n\t"
+ "movq %%mm0 , (%1,%0) \n\t"
+ "movq %%mm2 , 8(%1,%0) \n\t"
+ "add $16 , %0 \n\t"
+ " js 1b \n\t"
+ "femms \n\t"
+ :"+r"(reglen), "+r"(dst), "+r"(src)
+ );
+}
+
+static void float_to_int16_sse(int16_t *dst, const float *src, long len){
+ x86_reg reglen = len;
+ __asm__ volatile(
+ "add %0 , %0 \n\t"
+ "lea (%2,%0,2) , %2 \n\t"
+ "add %0 , %1 \n\t"
+ "neg %0 \n\t"
+ "1: \n\t"
+ "cvtps2pi (%2,%0,2) , %%mm0 \n\t"
+ "cvtps2pi 8(%2,%0,2) , %%mm1 \n\t"
+ "cvtps2pi 16(%2,%0,2) , %%mm2 \n\t"
+ "cvtps2pi 24(%2,%0,2) , %%mm3 \n\t"
+ "packssdw %%mm1 , %%mm0 \n\t"
+ "packssdw %%mm3 , %%mm2 \n\t"
+ "movq %%mm0 , (%1,%0) \n\t"
+ "movq %%mm2 , 8(%1,%0) \n\t"
+ "add $16 , %0 \n\t"
+ " js 1b \n\t"
+ "emms \n\t"
+ :"+r"(reglen), "+r"(dst), "+r"(src)
+ );
+}
+
+static void float_to_int16_sse2(int16_t *dst, const float *src, long len){
+ x86_reg reglen = len;
+ __asm__ volatile(
+ "add %0 , %0 \n\t"
+ "lea (%2,%0,2) , %2 \n\t"
+ "add %0 , %1 \n\t"
+ "neg %0 \n\t"
+ "1: \n\t"
+ "cvtps2dq (%2,%0,2) , %%xmm0 \n\t"
+ "cvtps2dq 16(%2,%0,2) , %%xmm1 \n\t"
+ "packssdw %%xmm1 , %%xmm0 \n\t"
+ "movdqa %%xmm0 , (%1,%0) \n\t"
+ "add $16 , %0 \n\t"
+ " js 1b \n\t"
+ :"+r"(reglen), "+r"(dst), "+r"(src)
+ );
+}
+
+void ff_float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len);
+void ff_float_to_int16_interleave6_3dnow(int16_t *dst, const float **src, int len);
+void ff_float_to_int16_interleave6_3dn2(int16_t *dst, const float **src, int len);
+
+#if !HAVE_YASM
+#define ff_float_to_int16_interleave6_sse(a,b,c) float_to_int16_interleave_misc_sse(a,b,c,6)
+#define ff_float_to_int16_interleave6_3dnow(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6)
+#define ff_float_to_int16_interleave6_3dn2(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6)
+#endif
+#define ff_float_to_int16_interleave6_sse2 ff_float_to_int16_interleave6_sse
+
+#define FLOAT_TO_INT16_INTERLEAVE(cpu, body) \
+/* gcc pessimizes register allocation if this is in the same function as float_to_int16_interleave_sse2*/\
+static av_noinline void float_to_int16_interleave_misc_##cpu(int16_t *dst, const float **src, long len, int channels){\
+ DECLARE_ALIGNED(16, int16_t, tmp)[len];\
+ int i,j,c;\
+ for(c=0; cflags & CODEC_FLAG_BITEXACT)){
+ c->float_to_int16 = float_to_int16_3dnow;
+ c->float_to_int16_interleave = float_to_int16_interleave_3dnow;
+ }
+ }
+ if(mm_flags & AV_CPU_FLAG_3DNOWEXT){
+ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
+ c->float_to_int16_interleave = float_to_int16_interleave_3dn2;
+ }
+ }
+ if(mm_flags & AV_CPU_FLAG_SSE){
+ c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse;
+ c->float_to_int16 = float_to_int16_sse;
+ c->float_to_int16_interleave = float_to_int16_interleave_sse;
+ }
+ if(mm_flags & AV_CPU_FLAG_SSE2){
+ c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2;
+ c->float_to_int16 = float_to_int16_sse2;
+ c->float_to_int16_interleave = float_to_int16_interleave_sse2;
+ }
+ }
+}
diff --git a/mplayer/ffmpeg/libavcodec/x86/vc1dsp_mmx.c b/mplayer/ffmpeg/libavcodec/x86/vc1dsp_mmx.c
index 04b4abaa..a525aeee 100644
--- a/mplayer/ffmpeg/libavcodec/x86/vc1dsp_mmx.c
+++ b/mplayer/ffmpeg/libavcodec/x86/vc1dsp_mmx.c
@@ -28,6 +28,7 @@
#include "libavutil/x86_cpu.h"
#include "libavcodec/dsputil.h"
#include "dsputil_mmx.h"
+#include "libavcodec/vc1dsp.h"
#define OP_PUT(S,D)
#define OP_AVG(S,D) "pavgb " #S ", " #D " \n\t"
@@ -712,30 +713,45 @@ static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq)
ff_vc1_h_loop_filter8_sse4(src, stride, pq);
ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq);
}
+
#endif
-void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx) {
+void ff_put_vc1_chroma_mc8_mmx_nornd (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_vc1_chroma_mc8_mmx2_nornd (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_vc1_chroma_mc8_3dnow_nornd(uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_put_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+
+void ff_vc1dsp_init_mmx(VC1DSPContext *dsp)
+{
int mm_flags = av_get_cpu_flags();
- dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 8] = put_vc1_mspel_mc02_mmx;
- dsp->put_vc1_mspel_pixels_tab[12] = put_vc1_mspel_mc03_mmx;
-
- dsp->put_vc1_mspel_pixels_tab[ 1] = put_vc1_mspel_mc10_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 5] = put_vc1_mspel_mc11_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 9] = put_vc1_mspel_mc12_mmx;
- dsp->put_vc1_mspel_pixels_tab[13] = put_vc1_mspel_mc13_mmx;
-
- dsp->put_vc1_mspel_pixels_tab[ 2] = put_vc1_mspel_mc20_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 6] = put_vc1_mspel_mc21_mmx;
- dsp->put_vc1_mspel_pixels_tab[10] = put_vc1_mspel_mc22_mmx;
- dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_mmx;
-
- dsp->put_vc1_mspel_pixels_tab[ 3] = put_vc1_mspel_mc30_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 7] = put_vc1_mspel_mc31_mmx;
- dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_mmx;
- dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_mmx;
+ if (mm_flags & AV_CPU_FLAG_MMX) {
+ dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_mmx;
+ dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_mmx;
+ dsp->put_vc1_mspel_pixels_tab[ 8] = put_vc1_mspel_mc02_mmx;
+ dsp->put_vc1_mspel_pixels_tab[12] = put_vc1_mspel_mc03_mmx;
+
+ dsp->put_vc1_mspel_pixels_tab[ 1] = put_vc1_mspel_mc10_mmx;
+ dsp->put_vc1_mspel_pixels_tab[ 5] = put_vc1_mspel_mc11_mmx;
+ dsp->put_vc1_mspel_pixels_tab[ 9] = put_vc1_mspel_mc12_mmx;
+ dsp->put_vc1_mspel_pixels_tab[13] = put_vc1_mspel_mc13_mmx;
+
+ dsp->put_vc1_mspel_pixels_tab[ 2] = put_vc1_mspel_mc20_mmx;
+ dsp->put_vc1_mspel_pixels_tab[ 6] = put_vc1_mspel_mc21_mmx;
+ dsp->put_vc1_mspel_pixels_tab[10] = put_vc1_mspel_mc22_mmx;
+ dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_mmx;
+
+ dsp->put_vc1_mspel_pixels_tab[ 3] = put_vc1_mspel_mc30_mmx;
+ dsp->put_vc1_mspel_pixels_tab[ 7] = put_vc1_mspel_mc31_mmx;
+ dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_mmx;
+ dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_mmx;
+ }
if (mm_flags & AV_CPU_FLAG_MMX2){
dsp->avg_vc1_mspel_pixels_tab[ 0] = ff_avg_vc1_mspel_mc00_mmx2;
@@ -775,11 +791,16 @@ void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx) {
#if HAVE_YASM
if (mm_flags & AV_CPU_FLAG_MMX) {
ASSIGN_LF(mmx);
+ dsp->put_no_rnd_vc1_chroma_pixels_tab[0]= ff_put_vc1_chroma_mc8_mmx_nornd;
}
return;
if (mm_flags & AV_CPU_FLAG_MMX2) {
ASSIGN_LF(mmx2);
+ dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_mmx2_nornd;
+ } else if (mm_flags & AV_CPU_FLAG_3DNOW) {
+ dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_3dnow_nornd;
}
+
if (mm_flags & AV_CPU_FLAG_SSE2) {
dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_sse2;
dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse2;
@@ -788,6 +809,8 @@ void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx) {
}
if (mm_flags & AV_CPU_FLAG_SSSE3) {
ASSIGN_LF(ssse3);
+ dsp->put_no_rnd_vc1_chroma_pixels_tab[0]= ff_put_vc1_chroma_mc8_ssse3_nornd;
+ dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_ssse3_nornd;
}
if (mm_flags & AV_CPU_FLAG_SSE4) {
dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4;
diff --git a/mplayer/ffmpeg/libavcodec/x86/x86util.asm b/mplayer/ffmpeg/libavcodec/x86/x86util.asm
index 7cabc70b..b28a6198 100644
--- a/mplayer/ffmpeg/libavcodec/x86/x86util.asm
+++ b/mplayer/ffmpeg/libavcodec/x86/x86util.asm
@@ -434,3 +434,13 @@
movh [%7], %3
movh [%7+%8], %4
%endmacro
+
+%macro PMINUB_MMX 3 ; dst, src, tmp
+ mova %3, %1
+ psubusb %3, %2
+ psubb %1, %3
+%endmacro
+
+%macro PMINUB_MMXEXT 3 ; dst, src, ignored
+ pminub %1, %2
+%endmacro
diff --git a/mplayer/ffmpeg/libavcodec/xan.c b/mplayer/ffmpeg/libavcodec/xan.c
index 0ae84a69..52033163 100644
--- a/mplayer/ffmpeg/libavcodec/xan.c
+++ b/mplayer/ffmpeg/libavcodec/xan.c
@@ -358,9 +358,6 @@ static void xan_wc3_decode_frame(XanContext *s) {
}
}
-static void xan_wc4_decode_frame(XanContext *s) {
-}
-
#if RUNTIME_GAMMA
static inline unsigned mul(unsigned a, unsigned b)
{
@@ -515,23 +512,12 @@ static int xan_decode_frame(AVCodecContext *avctx,
if (!s->frame_size)
s->frame_size = s->current_frame.linesize[0] * s->avctx->height;
- if (avctx->codec->id == CODEC_ID_XAN_WC3) {
- memcpy(s->current_frame.data[1], s->palettes + s->cur_palette * AVPALETTE_COUNT, AVPALETTE_SIZE);
- } else {
- AVPaletteControl *palette_control = avctx->palctrl;
- palette_control->palette_changed = 0;
- memcpy(s->current_frame.data[1], palette_control->palette,
- AVPALETTE_SIZE);
- s->current_frame.palette_has_changed = 1;
- }
+ memcpy(s->current_frame.data[1], s->palettes + s->cur_palette * AVPALETTE_COUNT, AVPALETTE_SIZE);
s->buf = buf;
s->size = buf_size;
- if (avctx->codec->id == CODEC_ID_XAN_WC3)
- xan_wc3_decode_frame(s);
- else if (avctx->codec->id == CODEC_ID_XAN_WC4)
- xan_wc4_decode_frame(s);
+ xan_wc3_decode_frame(s);
/* release the last frame if it is allocated */
if (s->last_frame.data[0])
@@ -577,17 +563,3 @@ AVCodec ff_xan_wc3_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("Wing Commander III / Xan"),
};
-/*
-AVCodec ff_xan_wc4_decoder = {
- "xan_wc4",
- AVMEDIA_TYPE_VIDEO,
- CODEC_ID_XAN_WC4,
- sizeof(XanContext),
- xan_decode_init,
- NULL,
- xan_decode_end,
- xan_decode_frame,
- CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("Wing Commander IV / Xxan"),
-};
-*/
diff --git a/mplayer/ffmpeg/libavcodec/xsubdec.c b/mplayer/ffmpeg/libavcodec/xsubdec.c
index 872b227d..d24588b8 100644
--- a/mplayer/ffmpeg/libavcodec/xsubdec.c
+++ b/mplayer/ffmpeg/libavcodec/xsubdec.c
@@ -18,7 +18,7 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "get_bits.h"
#include "bytestream.h"
diff --git a/mplayer/ffmpeg/libavcodec/xxan.c b/mplayer/ffmpeg/libavcodec/xxan.c
new file mode 100644
index 00000000..10ec53f4
--- /dev/null
+++ b/mplayer/ffmpeg/libavcodec/xxan.c
@@ -0,0 +1,429 @@
+/*
+ * Wing Commander/Xan Video Decoder
+ * Copyright (C) 2011 Konstantin Shishkov
+ * based on work by Mike Melanson
+ *
+ * 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
+ */
+
+#include "avcodec.h"
+#include "libavutil/intreadwrite.h"
+#include "bytestream.h"
+#define ALT_BITSTREAM_READER_LE
+#include "get_bits.h"
+// for av_memcpy_backptr
+#include "libavutil/lzo.h"
+
+typedef struct XanContext {
+ AVCodecContext *avctx;
+ AVFrame pic;
+
+ uint8_t *y_buffer;
+ uint8_t *scratch_buffer;
+ int buffer_size;
+} XanContext;
+
+static av_cold int xan_decode_init(AVCodecContext *avctx)
+{
+ XanContext *s = avctx->priv_data;
+
+ s->avctx = avctx;
+
+ avctx->pix_fmt = PIX_FMT_YUV420P;
+
+ s->buffer_size = avctx->width * avctx->height;
+ s->y_buffer = av_malloc(s->buffer_size);
+ if (!s->y_buffer)
+ return AVERROR(ENOMEM);
+ s->scratch_buffer = av_malloc(s->buffer_size + 130);
+ if (!s->scratch_buffer) {
+ av_freep(&s->y_buffer);
+ return AVERROR(ENOMEM);
+ }
+
+ return 0;
+}
+
+static int xan_unpack_luma(const uint8_t *src, const int src_size,
+ uint8_t *dst, const int dst_size)
+{
+ int tree_size, eof;
+ const uint8_t *tree;
+ int bits, mask;
+ int tree_root, node;
+ const uint8_t *dst_end = dst + dst_size;
+ const uint8_t *src_end = src + src_size;
+
+ tree_size = *src++;
+ eof = *src++;
+ tree = src - eof * 2 - 2;
+ tree_root = eof + tree_size;
+ src += tree_size * 2;
+
+ node = tree_root;
+ bits = *src++;
+ mask = 0x80;
+ for (;;) {
+ int bit = !!(bits & mask);
+ mask >>= 1;
+ node = tree[node*2 + bit];
+ if (node == eof)
+ break;
+ if (node < eof) {
+ *dst++ = node;
+ if (dst > dst_end)
+ break;
+ node = tree_root;
+ }
+ if (!mask) {
+ bits = *src++;
+ if (src > src_end)
+ break;
+ mask = 0x80;
+ }
+ }
+ return dst != dst_end;
+}
+
+/* almost the same as in xan_wc3 decoder */
+static int xan_unpack(uint8_t *dest, const int dest_len,
+ const uint8_t *src, const int src_len)
+{
+ uint8_t opcode;
+ int size;
+ uint8_t *orig_dest = dest;
+ const uint8_t *src_end = src + src_len;
+ const uint8_t *dest_end = dest + dest_len;
+
+ while (dest < dest_end) {
+ opcode = *src++;
+
+ if (opcode < 0xe0) {
+ int size2, back;
+ if ((opcode & 0x80) == 0) {
+ size = opcode & 3;
+ back = ((opcode & 0x60) << 3) + *src++ + 1;
+ size2 = ((opcode & 0x1c) >> 2) + 3;
+ } else if ((opcode & 0x40) == 0) {
+ size = *src >> 6;
+ back = (bytestream_get_be16(&src) & 0x3fff) + 1;
+ size2 = (opcode & 0x3f) + 4;
+ } else {
+ size = opcode & 3;
+ back = ((opcode & 0x10) << 12) + bytestream_get_be16(&src) + 1;
+ size2 = ((opcode & 0x0c) << 6) + *src++ + 5;
+ if (size + size2 > dest_end - dest)
+ break;
+ }
+ if (src + size > src_end || dest + size + size2 > dest_end)
+ return -1;
+ bytestream_get_buffer(&src, dest, size);
+ dest += size;
+ av_memcpy_backptr(dest, back, size2);
+ dest += size2;
+ } else {
+ int finish = opcode >= 0xfc;
+
+ size = finish ? opcode & 3 : ((opcode & 0x1f) << 2) + 4;
+ if (src + size > src_end || dest + size > dest_end)
+ return -1;
+ bytestream_get_buffer(&src, dest, size);
+ dest += size;
+ if (finish)
+ break;
+ }
+ }
+ return dest - orig_dest;
+}
+
+static int xan_decode_chroma(AVCodecContext *avctx, AVPacket *avpkt)
+{
+ const uint8_t *buf = avpkt->data;
+ XanContext *s = avctx->priv_data;
+ uint8_t *U, *V;
+ unsigned chroma_off;
+ int val, uval, vval;
+ int i, j;
+ const uint8_t *src, *src_end;
+ const uint8_t *table;
+ int mode, offset, dec_size;
+
+ chroma_off = AV_RL32(buf + 4);
+ if (!chroma_off)
+ return 0;
+ if (chroma_off + 10 >= avpkt->size) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid chroma block position\n");
+ return -1;
+ }
+ src = avpkt->data + 4 + chroma_off;
+ table = src + 2;
+ mode = bytestream_get_le16(&src);
+ offset = bytestream_get_le16(&src) * 2;
+
+ if (src - avpkt->data >= avpkt->size - offset) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid chroma block offset\n");
+ return -1;
+ }
+
+ memset(s->scratch_buffer, 0, s->buffer_size);
+ dec_size = xan_unpack(s->scratch_buffer, s->buffer_size, src + offset,
+ avpkt->size - offset - (src - avpkt->data));
+ if (dec_size < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Chroma unpacking failed\n");
+ return -1;
+ }
+
+ U = s->pic.data[1];
+ V = s->pic.data[2];
+ src = s->scratch_buffer;
+ src_end = src + dec_size;
+ if (mode) {
+ for (j = 0; j < avctx->height >> 1; j++) {
+ for (i = 0; i < avctx->width >> 1; i++) {
+ val = *src++;
+ if (val) {
+ val = AV_RL16(table + (val << 1));
+ uval = (val >> 3) & 0xF8;
+ vval = (val >> 8) & 0xF8;
+ U[i] = uval | (uval >> 5);
+ V[i] = vval | (vval >> 5);
+ }
+ if (src == src_end)
+ return 0;
+ }
+ U += s->pic.linesize[1];
+ V += s->pic.linesize[2];
+ }
+ } else {
+ uint8_t *U2 = U + s->pic.linesize[1];
+ uint8_t *V2 = V + s->pic.linesize[2];
+
+ for (j = 0; j < avctx->height >> 2; j++) {
+ for (i = 0; i < avctx->width >> 1; i += 2) {
+ val = *src++;
+ if (val) {
+ val = AV_RL16(table + (val << 1));
+ uval = (val >> 3) & 0xF8;
+ vval = (val >> 8) & 0xF8;
+ U[i] = U[i+1] = U2[i] = U2[i+1] = uval | (uval >> 5);
+ V[i] = V[i+1] = V2[i] = V2[i+1] = vval | (vval >> 5);
+ }
+ }
+ U += s->pic.linesize[1] * 2;
+ V += s->pic.linesize[2] * 2;
+ U2 += s->pic.linesize[1] * 2;
+ V2 += s->pic.linesize[2] * 2;
+ }
+ }
+
+ return 0;
+}
+
+static int xan_decode_frame_type0(AVCodecContext *avctx, AVPacket *avpkt)
+{
+ const uint8_t *buf = avpkt->data;
+ XanContext *s = avctx->priv_data;
+ uint8_t *ybuf, *prev_buf, *src = s->scratch_buffer;
+ unsigned chroma_off, corr_off;
+ int cur, last, size;
+ int i, j;
+ int ret;
+
+ corr_off = AV_RL32(buf + 8);
+ chroma_off = AV_RL32(buf + 4);
+
+ if ((ret = xan_decode_chroma(avctx, avpkt)) != 0)
+ return ret;
+
+ size = avpkt->size - 4;
+ if (corr_off >= avpkt->size) {
+ av_log(avctx, AV_LOG_WARNING, "Ignoring invalid correction block position\n");
+ corr_off = 0;
+ }
+ if (corr_off)
+ size = corr_off;
+ if (chroma_off)
+ size = FFMIN(size, chroma_off);
+ ret = xan_unpack_luma(buf + 12, size, src, s->buffer_size >> 1);
+ if (ret) {
+ av_log(avctx, AV_LOG_ERROR, "Luma decoding failed\n");
+ return ret;
+ }
+
+ ybuf = s->y_buffer;
+ last = *src++;
+ ybuf[0] = last << 1;
+ for (j = 1; j < avctx->width - 1; j += 2) {
+ cur = (last + *src++) & 0x1F;
+ ybuf[j] = last + cur;
+ ybuf[j+1] = cur << 1;
+ last = cur;
+ }
+ ybuf[j] = last << 1;
+ prev_buf = ybuf;
+ ybuf += avctx->width;
+
+ for (i = 1; i < avctx->height; i++) {
+ last = ((prev_buf[0] >> 1) + *src++) & 0x1F;
+ ybuf[0] = last << 1;
+ for (j = 1; j < avctx->width - 1; j += 2) {
+ cur = ((prev_buf[j + 1] >> 1) + *src++) & 0x1F;
+ ybuf[j] = last + cur;
+ ybuf[j+1] = cur << 1;
+ last = cur;
+ }
+ ybuf[j] = last << 1;
+ prev_buf = ybuf;
+ ybuf += avctx->width;
+ }
+
+ if (corr_off) {
+ int corr_end, dec_size;
+
+ corr_end = avpkt->size;
+ if (chroma_off > corr_off)
+ corr_end = chroma_off;
+ dec_size = xan_unpack(s->scratch_buffer, s->buffer_size,
+ avpkt->data + 8 + corr_off,
+ corr_end - corr_off);
+ if (dec_size < 0)
+ dec_size = 0;
+ for (i = 0; i < dec_size; i++)
+ s->y_buffer[i*2+1] = (s->y_buffer[i*2+1] + (s->scratch_buffer[i] << 1)) & 0x3F;
+ }
+
+ src = s->y_buffer;
+ ybuf = s->pic.data[0];
+ for (j = 0; j < avctx->height; j++) {
+ for (i = 0; i < avctx->width; i++)
+ ybuf[i] = (src[i] << 2) | (src[i] >> 3);
+ src += avctx->width;
+ ybuf += s->pic.linesize[0];
+ }
+
+ return 0;
+}
+
+static int xan_decode_frame_type1(AVCodecContext *avctx, AVPacket *avpkt)
+{
+ const uint8_t *buf = avpkt->data;
+ XanContext *s = avctx->priv_data;
+ uint8_t *ybuf, *src = s->scratch_buffer;
+ int cur, last;
+ int i, j;
+ int ret;
+
+ if ((ret = xan_decode_chroma(avctx, avpkt)) != 0)
+ return ret;
+
+ ret = xan_unpack_luma(buf + 16, avpkt->size - 16, src,
+ s->buffer_size >> 1);
+ if (ret) {
+ av_log(avctx, AV_LOG_ERROR, "Luma decoding failed\n");
+ return ret;
+ }
+
+ ybuf = s->y_buffer;
+ for (i = 0; i < avctx->height; i++) {
+ last = (ybuf[0] + (*src++ << 1)) & 0x3F;
+ ybuf[0] = last;
+ for (j = 1; j < avctx->width - 1; j += 2) {
+ cur = (ybuf[j + 1] + (*src++ << 1)) & 0x3F;
+ ybuf[j] = (last + cur) >> 1;
+ ybuf[j+1] = cur;
+ last = cur;
+ }
+ ybuf[j] = last;
+ ybuf += avctx->width;
+ }
+
+ src = s->y_buffer;
+ ybuf = s->pic.data[0];
+ for (j = 0; j < avctx->height; j++) {
+ for (i = 0; i < avctx->width; i++)
+ ybuf[i] = (src[i] << 2) | (src[i] >> 3);
+ src += avctx->width;
+ ybuf += s->pic.linesize[0];
+ }
+
+ return 0;
+}
+
+static int xan_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ AVPacket *avpkt)
+{
+ XanContext *s = avctx->priv_data;
+ int ftype;
+ int ret;
+
+ s->pic.reference = 1;
+ s->pic.buffer_hints = FF_BUFFER_HINTS_VALID |
+ FF_BUFFER_HINTS_PRESERVE |
+ FF_BUFFER_HINTS_REUSABLE;
+ if ((ret = avctx->reget_buffer(avctx, &s->pic))) {
+ av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
+ return ret;
+ }
+
+ ftype = AV_RL32(avpkt->data);
+ switch (ftype) {
+ case 0:
+ ret = xan_decode_frame_type0(avctx, avpkt);
+ break;
+ case 1:
+ ret = xan_decode_frame_type1(avctx, avpkt);
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "Unknown frame type %d\n", ftype);
+ return -1;
+ }
+ if (ret)
+ return ret;
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->pic;
+
+ return avpkt->size;
+}
+
+static av_cold int xan_decode_end(AVCodecContext *avctx)
+{
+ XanContext *s = avctx->priv_data;
+
+ if (s->pic.data[0])
+ avctx->release_buffer(avctx, &s->pic);
+
+ av_freep(&s->y_buffer);
+ av_freep(&s->scratch_buffer);
+
+ return 0;
+}
+
+AVCodec ff_xan_wc4_decoder = {
+ "xan_wc4",
+ AVMEDIA_TYPE_VIDEO,
+ CODEC_ID_XAN_WC4,
+ sizeof(XanContext),
+ xan_decode_init,
+ NULL,
+ xan_decode_end,
+ xan_decode_frame,
+ CODEC_CAP_DR1,
+ .long_name = NULL_IF_CONFIG_SMALL("Wing Commander IV / Xxan"),
+};
+
diff --git a/mplayer/ffmpeg/libavcodec/yop.c b/mplayer/ffmpeg/libavcodec/yop.c
index 6a75e74b..a117e2d7 100644
--- a/mplayer/ffmpeg/libavcodec/yop.c
+++ b/mplayer/ffmpeg/libavcodec/yop.c
@@ -24,7 +24,7 @@
*/
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "get_bits.h"
diff --git a/mplayer/ffmpeg/libavcore/Makefile b/mplayer/ffmpeg/libavcore/Makefile
deleted file mode 100644
index f2e82970..00000000
--- a/mplayer/ffmpeg/libavcore/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-include $(SUBDIR)../config.mak
-
-NAME = avcore
-FFLIBS = avutil
-
-HEADERS = \
- audioconvert.h \
- avcore.h \
- imgutils.h \
- parseutils.h \
- samplefmt.h \
-
-OBJS = \
- audioconvert.o \
- imgutils.o \
- parseutils.o \
- samplefmt.o \
- utils.o \
-
-include $(SUBDIR)../subdir.mak
diff --git a/mplayer/ffmpeg/libavcore/avcore.h b/mplayer/ffmpeg/libavcore/avcore.h
deleted file mode 100644
index 9b02c3b5..00000000
--- a/mplayer/ffmpeg/libavcore/avcore.h
+++ /dev/null
@@ -1,70 +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 AVCORE_AVCORE_H
-#define AVCORE_AVCORE_H
-
-/**
- * @file
- * shared media utilities for the libav* libraries
- */
-
-#include "libavutil/avutil.h"
-
-#define LIBAVCORE_VERSION_MAJOR 0
-#define LIBAVCORE_VERSION_MINOR 16
-#define LIBAVCORE_VERSION_MICRO 1
-
-#define LIBAVCORE_VERSION_INT AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \
- LIBAVCORE_VERSION_MINOR, \
- LIBAVCORE_VERSION_MICRO)
-#define LIBAVCORE_VERSION AV_VERSION(LIBAVCORE_VERSION_MAJOR, \
- LIBAVCORE_VERSION_MINOR, \
- LIBAVCORE_VERSION_MICRO)
-#define LIBAVCORE_BUILD LIBAVCORE_VERSION_INT
-
-#define LIBAVCORE_IDENT "Lavcore" AV_STRINGIFY(LIBAVCORE_VERSION)
-
-/**
- * Return the LIBAVCORE_VERSION_INT constant.
- */
-unsigned avcore_version(void);
-
-/**
- * Return the libavcore build-time configuration.
- */
-const char *avcore_configuration(void);
-
-/**
- * Return the libavcore license.
- */
-const char *avcore_license(void);
-
-#define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
-#define AV_TIME_BASE 1000000
-#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
-
-/**
- * Those FF_API_* defines are not part of public API.
- * They may change, break or disappear at any time.
- */
-#ifndef FF_API_OLD_IMAGE_NAMES
-#define FF_API_OLD_IMAGE_NAMES (LIBAVCORE_VERSION_MAJOR < 1)
-#endif
-
-#endif /* AVCORE_AVCORE_H */
diff --git a/mplayer/ffmpeg/libavcore/libavcore.v b/mplayer/ffmpeg/libavcore/libavcore.v
deleted file mode 100644
index dc84cc49..00000000
--- a/mplayer/ffmpeg/libavcore/libavcore.v
+++ /dev/null
@@ -1,4 +0,0 @@
-LIBAVCORE_$MAJOR {
- global: av_*; ff_*; avcore*;
- local: *;
-};
diff --git a/mplayer/ffmpeg/libavcore/utils.c b/mplayer/ffmpeg/libavcore/utils.c
deleted file mode 100644
index 8350a9bc..00000000
--- a/mplayer/ffmpeg/libavcore/utils.c
+++ /dev/null
@@ -1,41 +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
- */
-
-#include "config.h"
-#include "avcore.h"
-
-/**
- * @file
- * various utility functions
- */
-
-unsigned avcore_version(void)
-{
- return LIBAVCORE_VERSION_INT;
-}
-
-const char *avcore_configuration(void)
-{
- return FFMPEG_CONFIGURATION;
-}
-
-const char *avcore_license(void)
-{
-#define LICENSE_PREFIX "libavcore license: "
- return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
-}
diff --git a/mplayer/ffmpeg/libavdevice/Makefile b/mplayer/ffmpeg/libavdevice/Makefile
index 1c0630b3..be28f4a0 100644
--- a/mplayer/ffmpeg/libavdevice/Makefile
+++ b/mplayer/ffmpeg/libavdevice/Makefile
@@ -1,7 +1,7 @@
include $(SUBDIR)../config.mak
NAME = avdevice
-FFLIBS = avformat avcodec avcore avutil
+FFLIBS = avformat avcodec avutil
HEADERS = avdevice.h
diff --git a/mplayer/ffmpeg/libavdevice/v4l.c b/mplayer/ffmpeg/libavdevice/v4l.c
index c107684b..9a155f9d 100644
--- a/mplayer/ffmpeg/libavdevice/v4l.c
+++ b/mplayer/ffmpeg/libavdevice/v4l.c
@@ -22,7 +22,7 @@
#undef __STRICT_ANSI__ //workaround due to broken kernel headers
#include "config.h"
#include "libavutil/rational.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "libavformat/avformat.h"
#include "libavcodec/dsputil.h"
#include
diff --git a/mplayer/ffmpeg/libavdevice/v4l2.c b/mplayer/ffmpeg/libavdevice/v4l2.c
index 993e2adc..1f1a4bcf 100644
--- a/mplayer/ffmpeg/libavdevice/v4l2.c
+++ b/mplayer/ffmpeg/libavdevice/v4l2.c
@@ -43,7 +43,7 @@
#endif
#include
#include
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
static const int desired_video_buffers = 256;
diff --git a/mplayer/ffmpeg/libavfilter/Makefile b/mplayer/ffmpeg/libavfilter/Makefile
index fdb181e0..bbd82023 100644
--- a/mplayer/ffmpeg/libavfilter/Makefile
+++ b/mplayer/ffmpeg/libavfilter/Makefile
@@ -1,7 +1,8 @@
include $(SUBDIR)../config.mak
NAME = avfilter
-FFLIBS = avcore avutil
+FFLIBS = avutil
+FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec
FFLIBS-$(CONFIG_SCALE_FILTER) += swscale
HEADERS = avfilter.h avfiltergraph.h
@@ -10,6 +11,7 @@ OBJS = allfilters.o \
avfilter.o \
avfiltergraph.o \
defaults.o \
+ drawutils.o \
formats.o \
graphparser.o \
@@ -48,8 +50,9 @@ OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o
OBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o
OBJS-$(CONFIG_BUFFER_FILTER) += vsrc_buffer.o
-OBJS-$(CONFIG_COLOR_FILTER) += vf_pad.o
+OBJS-$(CONFIG_COLOR_FILTER) += vsrc_color.o
OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o
+OBJS-$(CONFIG_MOVIE_FILTER) += vsrc_movie.o
OBJS-$(CONFIG_NULLSRC_FILTER) += vsrc_nullsrc.o
OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o
diff --git a/mplayer/ffmpeg/libavfilter/allfilters.c b/mplayer/ffmpeg/libavfilter/allfilters.c
index 1dffb804..cb29c2f1 100644
--- a/mplayer/ffmpeg/libavfilter/allfilters.c
+++ b/mplayer/ffmpeg/libavfilter/allfilters.c
@@ -71,6 +71,7 @@ void avfilter_register_all(void)
REGISTER_FILTER (BUFFER, buffer, vsrc);
REGISTER_FILTER (COLOR, color, vsrc);
REGISTER_FILTER (FREI0R, frei0r_src, vsrc);
+ REGISTER_FILTER (MOVIE, movie, vsrc);
REGISTER_FILTER (NULLSRC, nullsrc, vsrc);
REGISTER_FILTER (NULLSINK, nullsink, vsink);
diff --git a/mplayer/ffmpeg/libavfilter/asrc_anullsrc.c b/mplayer/ffmpeg/libavfilter/asrc_anullsrc.c
index 306e0a3d..4f49c3f1 100644
--- a/mplayer/ffmpeg/libavfilter/asrc_anullsrc.c
+++ b/mplayer/ffmpeg/libavfilter/asrc_anullsrc.c
@@ -22,7 +22,7 @@
*/
#include "avfilter.h"
-#include "libavcore/audioconvert.h"
+#include "libavutil/audioconvert.h"
typedef struct {
int64_t channel_layout;
diff --git a/mplayer/ffmpeg/libavfilter/avfilter.c b/mplayer/ffmpeg/libavfilter/avfilter.c
index 3d8d08ac..039e04bf 100644
--- a/mplayer/ffmpeg/libavfilter/avfilter.c
+++ b/mplayer/ffmpeg/libavfilter/avfilter.c
@@ -23,8 +23,8 @@
#include "libavutil/pixdesc.h"
#include "libavutil/rational.h"
-#include "libavcore/audioconvert.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/audioconvert.h"
+#include "libavutil/imgutils.h"
#include "avfilter.h"
#include "internal.h"
@@ -194,6 +194,16 @@ int avfilter_config_links(AVFilterContext *filter)
link->time_base = link->src && link->src->input_count ?
link->src->inputs[0]->time_base : AV_TIME_BASE_Q;
+ if (link->sample_aspect_ratio.num == 0 && link->sample_aspect_ratio.den == 0)
+ link->sample_aspect_ratio = link->src->input_count ?
+ link->src->inputs[0]->sample_aspect_ratio : (AVRational){1,1};
+
+ if (link->sample_rate == 0 && link->src && link->src->input_count)
+ link->sample_rate = link->src->inputs[0]->sample_rate;
+
+ if (link->channel_layout == 0 && link->src && link->src->input_count)
+ link->channel_layout = link->src->inputs[0]->channel_layout;
+
if ((config_link = link->dstpad->config_props))
if ((ret = config_link(link)) < 0)
return ret;
@@ -217,24 +227,24 @@ static char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms)
return buf;
}
-static void ff_dprintf_ref(void *ctx, AVFilterBufferRef *ref, int end)
+static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end)
{
av_unused char buf[16];
- dprintf(ctx,
+ av_dlog(ctx,
"ref[%p buf:%p refcount:%d perms:%s data:%p linesize[%d, %d, %d, %d] pts:%"PRId64" pos:%"PRId64,
ref, ref->buf, ref->buf->refcount, ff_get_ref_perms_string(buf, sizeof(buf), ref->perms), ref->data[0],
ref->linesize[0], ref->linesize[1], ref->linesize[2], ref->linesize[3],
ref->pts, ref->pos);
if (ref->video) {
- dprintf(ctx, " a:%d/%d s:%dx%d i:%c",
+ av_dlog(ctx, " a:%d/%d s:%dx%d i:%c",
ref->video->pixel_aspect.num, ref->video->pixel_aspect.den,
ref->video->w, ref->video->h,
!ref->video->interlaced ? 'P' : /* Progressive */
ref->video->top_field_first ? 'T' : 'B'); /* Top / Bottom */
}
if (ref->audio) {
- dprintf(ctx, " cl:%"PRId64"d sn:%d s:%d sr:%d p:%d",
+ av_dlog(ctx, " cl:%"PRId64"d sn:%d s:%d sr:%d p:%d",
ref->audio->channel_layout,
ref->audio->nb_samples,
ref->audio->size,
@@ -242,13 +252,13 @@ static void ff_dprintf_ref(void *ctx, AVFilterBufferRef *ref, int end)
ref->audio->planar);
}
- dprintf(ctx, "]%s", end ? "\n" : "");
+ av_dlog(ctx, "]%s", end ? "\n" : "");
}
-static void ff_dprintf_link(void *ctx, AVFilterLink *link, int end)
+static void ff_dlog_link(void *ctx, AVFilterLink *link, int end)
{
if (link->type == AVMEDIA_TYPE_VIDEO) {
- dprintf(ctx,
+ av_dlog(ctx,
"link[%p s:%dx%d fmt:%-16s %-16s->%-16s]%s",
link, link->w, link->h,
av_pix_fmt_descriptors[link->format].name,
@@ -259,7 +269,7 @@ static void ff_dprintf_link(void *ctx, AVFilterLink *link, int end)
char buf[128];
av_get_channel_layout_string(buf, sizeof(buf), -1, link->channel_layout);
- dprintf(ctx,
+ av_dlog(ctx,
"link[%p r:%"PRId64" cl:%s fmt:%-16s %-16s->%-16s]%s",
link, link->sample_rate, buf,
av_get_sample_fmt_name(link->format),
@@ -269,15 +279,15 @@ static void ff_dprintf_link(void *ctx, AVFilterLink *link, int end)
}
}
-#define FF_DPRINTF_START(ctx, func) dprintf(NULL, "%-16s: ", #func)
+#define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func)
AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
{
AVFilterBufferRef *ret = NULL;
av_unused char buf[16];
- FF_DPRINTF_START(NULL, get_video_buffer); ff_dprintf_link(NULL, link, 0);
- dprintf(NULL, " perms:%s w:%d h:%d\n", ff_get_ref_perms_string(buf, sizeof(buf), perms), w, h);
+ FF_DPRINTF_START(NULL, get_video_buffer); ff_dlog_link(NULL, link, 0);
+ av_dlog(NULL, " perms:%s w:%d h:%d\n", ff_get_ref_perms_string(buf, sizeof(buf), perms), w, h);
if (link->dstpad->get_video_buffer)
ret = link->dstpad->get_video_buffer(link, perms, w, h);
@@ -288,7 +298,7 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int
if (ret)
ret->type = AVMEDIA_TYPE_VIDEO;
- FF_DPRINTF_START(NULL, get_video_buffer); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " returning "); ff_dprintf_ref(NULL, ret, 1);
+ FF_DPRINTF_START(NULL, get_video_buffer); ff_dlog_link(NULL, link, 0); av_dlog(NULL, " returning "); ff_dlog_ref(NULL, ret, 1);
return ret;
}
@@ -353,7 +363,7 @@ AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
int avfilter_request_frame(AVFilterLink *link)
{
- FF_DPRINTF_START(NULL, request_frame); ff_dprintf_link(NULL, link, 1);
+ FF_DPRINTF_START(NULL, request_frame); ff_dlog_link(NULL, link, 1);
if (link->srcpad->request_frame)
return link->srcpad->request_frame(link);
@@ -388,7 +398,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
AVFilterPad *dst = link->dstpad;
int perms = picref->perms;
- FF_DPRINTF_START(NULL, start_frame); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " "); ff_dprintf_ref(NULL, picref, 1);
+ FF_DPRINTF_START(NULL, start_frame); ff_dlog_link(NULL, link, 0); av_dlog(NULL, " "); ff_dlog_ref(NULL, picref, 1);
if (!(start_frame = dst->start_frame))
start_frame = avfilter_default_start_frame;
@@ -435,7 +445,7 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
int i, j, vsub;
void (*draw_slice)(AVFilterLink *, int, int, int);
- FF_DPRINTF_START(NULL, draw_slice); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " y:%d h:%d dir:%d\n", y, h, slice_dir);
+ FF_DPRINTF_START(NULL, draw_slice); ff_dlog_link(NULL, link, 0); av_dlog(NULL, " y:%d h:%d dir:%d\n", y, h, slice_dir);
/* copy the slice if needed for permission reasons */
if (link->src_buf) {
@@ -475,6 +485,8 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *);
AVFilterPad *dst = link->dstpad;
+ FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1);
+
if (!(filter_samples = dst->filter_samples))
filter_samples = avfilter_default_filter_samples;
diff --git a/mplayer/ffmpeg/libavfilter/avfilter.h b/mplayer/ffmpeg/libavfilter/avfilter.h
index ad8b1e51..935214da 100644
--- a/mplayer/ffmpeg/libavfilter/avfilter.h
+++ b/mplayer/ffmpeg/libavfilter/avfilter.h
@@ -23,11 +23,10 @@
#define AVFILTER_AVFILTER_H
#include "libavutil/avutil.h"
-#include "libavcore/avcore.h"
-#include "libavcore/samplefmt.h"
+#include "libavutil/samplefmt.h"
#define LIBAVFILTER_VERSION_MAJOR 1
-#define LIBAVFILTER_VERSION_MINOR 74
+#define LIBAVFILTER_VERSION_MINOR 76
#define LIBAVFILTER_VERSION_MICRO 0
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -580,11 +579,12 @@ struct AVFilterLink {
enum AVMediaType type; ///< filter media type
- /* These two parameters apply only to video */
+ /* These parameters apply only to video */
int w; ///< agreed upon image width
int h; ///< agreed upon image height
+ AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
/* These two parameters apply only to audio */
- int64_t channel_layout; ///< channel layout of current buffer (see libavcore/audioconvert.h)
+ int64_t channel_layout; ///< channel layout of current buffer (see libavutil/audioconvert.h)
int64_t sample_rate; ///< samples per second
int format; ///< agreed upon media format
diff --git a/mplayer/ffmpeg/libavfilter/avfiltergraph.c b/mplayer/ffmpeg/libavfilter/avfiltergraph.c
index a62fe2f7..bdf22b3d 100644
--- a/mplayer/ffmpeg/libavfilter/avfiltergraph.c
+++ b/mplayer/ffmpeg/libavfilter/avfiltergraph.c
@@ -32,14 +32,15 @@ AVFilterGraph *avfilter_graph_alloc(void)
return av_mallocz(sizeof(AVFilterGraph));
}
-void avfilter_graph_free(AVFilterGraph *graph)
+void avfilter_graph_free(AVFilterGraph **graph)
{
- if (!graph)
+ if (!*graph)
return;
- for (; graph->filter_count > 0; graph->filter_count --)
- avfilter_free(graph->filters[graph->filter_count - 1]);
- av_freep(&graph->scale_sws_opts);
- av_freep(&graph->filters);
+ for (; (*graph)->filter_count > 0; (*graph)->filter_count--)
+ avfilter_free((*graph)->filters[(*graph)->filter_count - 1]);
+ av_freep(&(*graph)->scale_sws_opts);
+ av_freep(&(*graph)->filters);
+ av_freep(graph);
}
int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
diff --git a/mplayer/ffmpeg/libavfilter/avfiltergraph.h b/mplayer/ffmpeg/libavfilter/avfiltergraph.h
index 1b0d242d..0140af08 100644
--- a/mplayer/ffmpeg/libavfilter/avfiltergraph.h
+++ b/mplayer/ffmpeg/libavfilter/avfiltergraph.h
@@ -79,9 +79,10 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt,
int avfilter_graph_config(AVFilterGraph *graphctx, AVClass *log_ctx);
/**
- * Free a graph and destroy its links, graph may be NULL.
+ * Free a graph, destroy its links, and set *graph to NULL.
+ * If *graph is NULL, do nothing.
*/
-void avfilter_graph_free(AVFilterGraph *graph);
+void avfilter_graph_free(AVFilterGraph **graph);
/**
* A linked-list of the inputs/outputs of the filter chain.
diff --git a/mplayer/ffmpeg/libavfilter/defaults.c b/mplayer/ffmpeg/libavfilter/defaults.c
index 98339b6f..1da26304 100644
--- a/mplayer/ffmpeg/libavfilter/defaults.c
+++ b/mplayer/ffmpeg/libavfilter/defaults.c
@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcore/audioconvert.h"
-#include "libavcore/imgutils.h"
-#include "libavcore/samplefmt.h"
+#include "libavutil/audioconvert.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/samplefmt.h"
#include "avfilter.h"
#include "internal.h"
@@ -126,7 +126,7 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per
return ref;
fail:
- if (ref && ref->audio)
+ if (ref)
av_free(ref->audio);
av_free(ref);
av_free(samples);
diff --git a/mplayer/ffmpeg/libavfilter/drawutils.c b/mplayer/ffmpeg/libavfilter/drawutils.c
new file mode 100644
index 00000000..dd9ceff1
--- /dev/null
+++ b/mplayer/ffmpeg/libavfilter/drawutils.c
@@ -0,0 +1,117 @@
+/*
+ * 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
+ */
+
+#include "libavutil/avutil.h"
+#include "libavutil/colorspace.h"
+#include "libavutil/pixdesc.h"
+#include "drawutils.h"
+
+enum { RED = 0, GREEN, BLUE, ALPHA };
+
+int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t dst_color[4],
+ enum PixelFormat pix_fmt, uint8_t rgba_color[4],
+ int *is_packed_rgba, uint8_t rgba_map_ptr[4])
+{
+ uint8_t rgba_map[4] = {0};
+ int i;
+ const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt];
+ int hsub = pix_desc->log2_chroma_w;
+
+ *is_packed_rgba = 1;
+ switch (pix_fmt) {
+ case PIX_FMT_ARGB: rgba_map[ALPHA] = 0; rgba_map[RED ] = 1; rgba_map[GREEN] = 2; rgba_map[BLUE ] = 3; break;
+ case PIX_FMT_ABGR: rgba_map[ALPHA] = 0; rgba_map[BLUE ] = 1; rgba_map[GREEN] = 2; rgba_map[RED ] = 3; break;
+ case PIX_FMT_RGBA:
+ case PIX_FMT_RGB24: rgba_map[RED ] = 0; rgba_map[GREEN] = 1; rgba_map[BLUE ] = 2; rgba_map[ALPHA] = 3; break;
+ case PIX_FMT_BGRA:
+ case PIX_FMT_BGR24: rgba_map[BLUE ] = 0; rgba_map[GREEN] = 1; rgba_map[RED ] = 2; rgba_map[ALPHA] = 3; break;
+ default:
+ *is_packed_rgba = 0;
+ }
+
+ if (*is_packed_rgba) {
+ pixel_step[0] = (av_get_bits_per_pixel(pix_desc))>>3;
+ for (i = 0; i < 4; i++)
+ dst_color[rgba_map[i]] = rgba_color[i];
+
+ line[0] = av_malloc(w * pixel_step[0]);
+ for (i = 0; i < w; i++)
+ memcpy(line[0] + i * pixel_step[0], dst_color, pixel_step[0]);
+ if (rgba_map_ptr)
+ memcpy(rgba_map_ptr, rgba_map, sizeof(rgba_map[0]) * 4);
+ } else {
+ int plane;
+
+ dst_color[0] = RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
+ dst_color[1] = RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
+ dst_color[2] = RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
+ dst_color[3] = rgba_color[3];
+
+ for (plane = 0; plane < 4; plane++) {
+ int line_size;
+ int hsub1 = (plane == 1 || plane == 2) ? hsub : 0;
+
+ pixel_step[plane] = 1;
+ line_size = (w >> hsub1) * pixel_step[plane];
+ line[plane] = av_malloc(line_size);
+ memset(line[plane], dst_color[plane], line_size);
+ }
+ }
+
+ return 0;
+}
+
+void ff_draw_rectangle(uint8_t *dst[4], int dst_linesize[4],
+ uint8_t *src[4], int pixelstep[4],
+ int hsub, int vsub, int x, int y, int w, int h)
+{
+ int i, plane;
+ uint8_t *p;
+
+ for (plane = 0; plane < 4 && dst[plane]; plane++) {
+ int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
+ int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
+
+ p = dst[plane] + (y >> vsub1) * dst_linesize[plane];
+ for (i = 0; i < (h >> vsub1); i++) {
+ memcpy(p + (x >> hsub1) * pixelstep[plane],
+ src[plane], (w >> hsub1) * pixelstep[plane]);
+ p += dst_linesize[plane];
+ }
+ }
+}
+
+void ff_copy_rectangle(uint8_t *dst[4], int dst_linesize[4],
+ uint8_t *src[4], int src_linesize[4], int pixelstep[4],
+ int hsub, int vsub, int x, int y, int y2, int w, int h)
+{
+ int i, plane;
+ uint8_t *p;
+
+ for (plane = 0; plane < 4 && dst[plane]; plane++) {
+ int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
+ int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
+
+ p = dst[plane] + (y >> vsub1) * dst_linesize[plane];
+ for (i = 0; i < (h >> vsub1); i++) {
+ memcpy(p + (x >> hsub1) * pixelstep[plane],
+ src[plane] + src_linesize[plane]*(i+(y2>>vsub1)), (w >> hsub1) * pixelstep[plane]);
+ p += dst_linesize[plane];
+ }
+ }
+}
diff --git a/mplayer/ffmpeg/libavfilter/drawutils.h b/mplayer/ffmpeg/libavfilter/drawutils.h
new file mode 100644
index 00000000..e8386605
--- /dev/null
+++ b/mplayer/ffmpeg/libavfilter/drawutils.h
@@ -0,0 +1,43 @@
+/*
+ * 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 AVFILTER_DRAWUTILS_H
+#define AVFILTER_DRAWUTILS_H
+
+/**
+ * @file
+ * misc drawing utilities
+ */
+
+#include
+#include "libavutil/pixfmt.h"
+
+int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w,
+ uint8_t dst_color[4],
+ enum PixelFormat pix_fmt, uint8_t rgba_color[4],
+ int *is_packed_rgba, uint8_t rgba_map[4]);
+
+void ff_draw_rectangle(uint8_t *dst[4], int dst_linesize[4],
+ uint8_t *src[4], int pixelstep[4],
+ int hsub, int vsub, int x, int y, int w, int h);
+
+void ff_copy_rectangle(uint8_t *dst[4], int dst_linesize[4],
+ uint8_t *src[4], int src_linesize[4], int pixelstep[4],
+ int hsub, int vsub, int x, int y, int y2, int w, int h);
+
+#endif /* AVFILTER_DRAWUTILS_H */
diff --git a/mplayer/ffmpeg/libavfilter/graphparser.c b/mplayer/ffmpeg/libavfilter/graphparser.c
index 7151e4fe..47179e5e 100644
--- a/mplayer/ffmpeg/libavfilter/graphparser.c
+++ b/mplayer/ffmpeg/libavfilter/graphparser.c
@@ -393,7 +393,9 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
return 0;
fail:
- avfilter_graph_free(graph);
+ for (; graph->filter_count > 0; graph->filter_count--)
+ avfilter_free(graph->filters[graph->filter_count - 1]);
+ av_freep(&graph->filters);
free_inout(open_inputs);
free_inout(open_outputs);
free_inout(curr_inputs);
diff --git a/mplayer/ffmpeg/libavfilter/vf_aspect.c b/mplayer/ffmpeg/libavfilter/vf_aspect.c
index 6f86bf29..95bfb666 100644
--- a/mplayer/ffmpeg/libavfilter/vf_aspect.c
+++ b/mplayer/ffmpeg/libavfilter/vf_aspect.c
@@ -82,6 +82,9 @@ static int setdar_config_props(AVFilterLink *inlink)
av_log(inlink->dst, AV_LOG_INFO, "w:%d h:%d -> dar:%d/%d par:%d/%d\n",
inlink->w, inlink->h, dar.num, dar.den, aspect->aspect.num, aspect->aspect.den);
+
+ inlink->sample_aspect_ratio = aspect->aspect;
+
return 0;
}
@@ -108,6 +111,16 @@ AVFilter avfilter_vf_setdar = {
#endif /* CONFIG_SETDAR_FILTER */
#if CONFIG_SETSAR_FILTER
+/* for setdar filter, convert from frame aspect ratio to pixel aspect ratio */
+static int setsar_config_props(AVFilterLink *inlink)
+{
+ AspectContext *aspect = inlink->dst->priv;
+
+ inlink->sample_aspect_ratio = aspect->aspect;
+
+ return 0;
+}
+
AVFilter avfilter_vf_setsar = {
.name = "setsar",
.description = NULL_IF_CONFIG_SMALL("Set the pixel sample aspect ratio."),
@@ -118,6 +131,7 @@ AVFilter avfilter_vf_setsar = {
.inputs = (AVFilterPad[]) {{ .name = "default",
.type = AVMEDIA_TYPE_VIDEO,
+ .config_props = setsar_config_props,
.get_video_buffer = avfilter_null_get_video_buffer,
.start_frame = start_frame,
.end_frame = avfilter_null_end_frame },
diff --git a/mplayer/ffmpeg/libavfilter/vf_crop.c b/mplayer/ffmpeg/libavfilter/vf_crop.c
index e768fbb5..e02c24fe 100644
--- a/mplayer/ffmpeg/libavfilter/vf_crop.c
+++ b/mplayer/ffmpeg/libavfilter/vf_crop.c
@@ -29,7 +29,7 @@
#include "libavutil/eval.h"
#include "libavutil/avstring.h"
#include "libavutil/libm.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
static const char *var_names[] = {
"E",
diff --git a/mplayer/ffmpeg/libavfilter/vf_cropdetect.c b/mplayer/ffmpeg/libavfilter/vf_cropdetect.c
index 62c68640..000c8bb2 100644
--- a/mplayer/ffmpeg/libavfilter/vf_cropdetect.c
+++ b/mplayer/ffmpeg/libavfilter/vf_cropdetect.c
@@ -23,7 +23,7 @@
* Ported from MPlayer libmpcodecs/vf_cropdetect.c.
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avfilter.h"
typedef struct {
diff --git a/mplayer/ffmpeg/libavfilter/vf_drawbox.c b/mplayer/ffmpeg/libavfilter/vf_drawbox.c
index 40d5e16e..37850729 100644
--- a/mplayer/ffmpeg/libavfilter/vf_drawbox.c
+++ b/mplayer/ffmpeg/libavfilter/vf_drawbox.c
@@ -26,7 +26,7 @@
#include "libavutil/colorspace.h"
#include "libavutil/pixdesc.h"
-#include "libavcore/parseutils.h"
+#include "libavutil/parseutils.h"
#include "avfilter.h"
enum { Y, U, V, A };
diff --git a/mplayer/ffmpeg/libavfilter/vf_frei0r.c b/mplayer/ffmpeg/libavfilter/vf_frei0r.c
index 03d4f28f..adccccb9 100644
--- a/mplayer/ffmpeg/libavfilter/vf_frei0r.c
+++ b/mplayer/ffmpeg/libavfilter/vf_frei0r.c
@@ -27,8 +27,8 @@
#include
#include
#include "libavutil/avstring.h"
-#include "libavcore/imgutils.h"
-#include "libavcore/parseutils.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/parseutils.h"
#include "avfilter.h"
typedef f0r_instance_t (*f0r_construct_f)(unsigned int width, unsigned int height);
diff --git a/mplayer/ffmpeg/libavfilter/vf_gradfun.c b/mplayer/ffmpeg/libavfilter/vf_gradfun.c
index 3a400a04..83ed3d79 100644
--- a/mplayer/ffmpeg/libavfilter/vf_gradfun.c
+++ b/mplayer/ffmpeg/libavfilter/vf_gradfun.c
@@ -32,7 +32,7 @@
* Dither it back to 8bit.
*/
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "libavutil/cpu.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
diff --git a/mplayer/ffmpeg/libavfilter/vf_hflip.c b/mplayer/ffmpeg/libavfilter/vf_hflip.c
index 4deb14a5..5250695f 100644
--- a/mplayer/ffmpeg/libavfilter/vf_hflip.c
+++ b/mplayer/ffmpeg/libavfilter/vf_hflip.c
@@ -27,7 +27,7 @@
#include "avfilter.h"
#include "libavutil/pixdesc.h"
#include "libavutil/intreadwrite.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
typedef struct {
int max_step[4]; ///< max pixel step for each plane, expressed as a number of bytes
diff --git a/mplayer/ffmpeg/libavfilter/vf_overlay.c b/mplayer/ffmpeg/libavfilter/vf_overlay.c
index a170e817..0eb24b96 100644
--- a/mplayer/ffmpeg/libavfilter/vf_overlay.c
+++ b/mplayer/ffmpeg/libavfilter/vf_overlay.c
@@ -29,7 +29,7 @@
#include "libavutil/eval.h"
#include "libavutil/avstring.h"
#include "libavutil/pixdesc.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "internal.h"
static const char *var_names[] = {
diff --git a/mplayer/ffmpeg/libavfilter/vf_pad.c b/mplayer/ffmpeg/libavfilter/vf_pad.c
index 467db5bf..492b08eb 100644
--- a/mplayer/ffmpeg/libavfilter/vf_pad.c
+++ b/mplayer/ffmpeg/libavfilter/vf_pad.c
@@ -28,96 +28,9 @@
#include "libavutil/pixdesc.h"
#include "libavutil/colorspace.h"
#include "libavutil/avassert.h"
-#include "libavcore/imgutils.h"
-#include "libavcore/parseutils.h"
-
-enum { RED = 0, GREEN, BLUE, ALPHA };
-
-static int fill_line_with_color(uint8_t *line[4], int line_step[4], int w, uint8_t color[4],
- enum PixelFormat pix_fmt, uint8_t rgba_color[4], int *is_packed_rgba)
-{
- uint8_t rgba_map[4] = {0};
- int i;
- const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt];
- int hsub = pix_desc->log2_chroma_w;
-
- *is_packed_rgba = 1;
- switch (pix_fmt) {
- case PIX_FMT_ARGB: rgba_map[ALPHA] = 0; rgba_map[RED ] = 1; rgba_map[GREEN] = 2; rgba_map[BLUE ] = 3; break;
- case PIX_FMT_ABGR: rgba_map[ALPHA] = 0; rgba_map[BLUE ] = 1; rgba_map[GREEN] = 2; rgba_map[RED ] = 3; break;
- case PIX_FMT_RGBA:
- case PIX_FMT_RGB24: rgba_map[RED ] = 0; rgba_map[GREEN] = 1; rgba_map[BLUE ] = 2; rgba_map[ALPHA] = 3; break;
- case PIX_FMT_BGRA:
- case PIX_FMT_BGR24: rgba_map[BLUE ] = 0; rgba_map[GREEN] = 1; rgba_map[RED ] = 2; rgba_map[ALPHA] = 3; break;
- default:
- *is_packed_rgba = 0;
- }
-
- if (*is_packed_rgba) {
- line_step[0] = (av_get_bits_per_pixel(pix_desc))>>3;
- for (i = 0; i < 4; i++)
- color[rgba_map[i]] = rgba_color[i];
-
- line[0] = av_malloc(w * line_step[0]);
- for (i = 0; i < w; i++)
- memcpy(line[0] + i * line_step[0], color, line_step[0]);
- } else {
- int plane;
-
- color[RED ] = RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
- color[GREEN] = RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
- color[BLUE ] = RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
- color[ALPHA] = rgba_color[3];
-
- for (plane = 0; plane < 4; plane++) {
- int line_size;
- int hsub1 = (plane == 1 || plane == 2) ? hsub : 0;
-
- line_step[plane] = 1;
- line_size = (w >> hsub1) * line_step[plane];
- line[plane] = av_malloc(line_size);
- memset(line[plane], color[plane], line_size);
- }
- }
-
- return 0;
-}
-
-static void draw_rectangle(AVFilterBufferRef *outpic, uint8_t *line[4], int line_step[4],
- int hsub, int vsub, int x, int y, int w, int h)
-{
- int i, plane;
- uint8_t *p;
-
- for (plane = 0; plane < 4 && outpic->data[plane]; plane++) {
- int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
- int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
-
- p = outpic->data[plane] + (y >> vsub1) * outpic->linesize[plane];
- for (i = 0; i < (h >> vsub1); i++) {
- memcpy(p + (x >> hsub1) * line_step[plane], line[plane], (w >> hsub1) * line_step[plane]);
- p += outpic->linesize[plane];
- }
- }
-}
-
-static void copy_rectangle(AVFilterBufferRef *outpic,uint8_t *line[4], int line_step[4], int linesize[4],
- int hsub, int vsub, int x, int y, int y2, int w, int h)
-{
- int i, plane;
- uint8_t *p;
-
- for (plane = 0; plane < 4 && outpic->data[plane]; plane++) {
- int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
- int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
-
- p = outpic->data[plane] + (y >> vsub1) * outpic->linesize[plane];
- for (i = 0; i < (h >> vsub1); i++) {
- memcpy(p + (x >> hsub1) * line_step[plane], line[plane] + linesize[plane]*(i+(y2>>vsub1)), (w >> hsub1) * line_step[plane]);
- p += outpic->linesize[plane];
- }
- }
-}
+#include "libavutil/imgutils.h"
+#include "libavutil/parseutils.h"
+#include "drawutils.h"
static int query_formats(AVFilterContext *ctx)
{
@@ -140,8 +53,6 @@ static int query_formats(AVFilterContext *ctx)
return 0;
}
-#if CONFIG_PAD_FILTER
-
typedef struct {
int w, h; ///< output dimensions, a value of 0 will result in the input size
int x, y; ///< offsets of the input area with respect to the padded area
@@ -210,8 +121,8 @@ static int config_input(AVFilterLink *inlink)
pad->in_h = inlink->h & ~((1 << pad->vsub) - 1);
memcpy(rgba_color, pad->color, sizeof(rgba_color));
- fill_line_with_color(pad->line, pad->line_step, pad->w, pad->color,
- inlink->format, rgba_color, &is_packed_rgba);
+ ff_fill_line_with_color(pad->line, pad->line_step, pad->w, pad->color,
+ inlink->format, rgba_color, &is_packed_rgba, NULL);
av_log(ctx, AV_LOG_INFO, "w:%d h:%d -> w:%d h:%d x:%d y:%d color:0x%02X%02X%02X%02X[%s]\n",
inlink->w, inlink->h, pad->w, pad->h, pad->x, pad->y,
@@ -351,9 +262,10 @@ static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir,
}
if (bar_h) {
- draw_rectangle(link->dst->outputs[0]->out_buf,
- pad->line, pad->line_step, pad->hsub, pad->vsub,
- 0, bar_y, pad->w, bar_h);
+ ff_draw_rectangle(link->dst->outputs[0]->out_buf->data,
+ link->dst->outputs[0]->out_buf->linesize,
+ pad->line, pad->line_step, pad->hsub, pad->vsub,
+ 0, bar_y, pad->w, bar_h);
avfilter_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir);
}
}
@@ -374,18 +286,20 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
draw_send_bar_slice(link, y, h, slice_dir, 1);
/* left border */
- draw_rectangle(outpic, pad->line, pad->line_step, pad->hsub, pad->vsub,
- 0, y, pad->x, h);
+ ff_draw_rectangle(outpic->data, outpic->linesize, pad->line, pad->line_step,
+ pad->hsub, pad->vsub, 0, y, pad->x, h);
if(pad->needs_copy){
- copy_rectangle(outpic,
- inpic->data, pad->line_step, inpic->linesize, pad->hsub, pad->vsub,
- pad->x, y, y-pad->y, inpic->video->w, h);
+ ff_copy_rectangle(outpic->data, outpic->linesize,
+ inpic->data, inpic->linesize, pad->line_step,
+ pad->hsub, pad->vsub,
+ pad->x, y, y-pad->y, inpic->video->w, h);
}
/* right border */
- draw_rectangle(outpic, pad->line, pad->line_step, pad->hsub, pad->vsub,
- pad->x + pad->in_w, y, pad->w - pad->x - pad->in_w, h);
+ ff_draw_rectangle(outpic->data, outpic->linesize,
+ pad->line, pad->line_step, pad->hsub, pad->vsub,
+ pad->x + pad->in_w, y, pad->w - pad->x - pad->in_w, h);
avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir);
draw_send_bar_slice(link, y, h, slice_dir, -1);
@@ -414,129 +328,3 @@ AVFilter avfilter_vf_pad = {
.config_props = config_output, },
{ .name = NULL}},
};
-
-#endif /* CONFIG_PAD_FILTER */
-
-#if CONFIG_COLOR_FILTER
-
-typedef struct {
- int w, h;
- uint8_t color[4];
- AVRational time_base;
- uint8_t *line[4];
- int line_step[4];
- int hsub, vsub; ///< chroma subsampling values
- uint64_t pts;
-} ColorContext;
-
-static av_cold int color_init(AVFilterContext *ctx, const char *args, void *opaque)
-{
- ColorContext *color = ctx->priv;
- char color_string[128] = "black";
- char frame_size [128] = "320x240";
- char frame_rate [128] = "25";
- AVRational frame_rate_q;
- int ret;
-
- if (args)
- sscanf(args, "%127[^:]:%127[^:]:%127s", color_string, frame_size, frame_rate);
-
- if (av_parse_video_size(&color->w, &color->h, frame_size) < 0) {
- av_log(ctx, AV_LOG_ERROR, "Invalid frame size: %s\n", frame_size);
- return AVERROR(EINVAL);
- }
-
- if (av_parse_video_rate(&frame_rate_q, frame_rate) < 0 ||
- frame_rate_q.den <= 0 || frame_rate_q.num <= 0) {
- av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: %s\n", frame_rate);
- return AVERROR(EINVAL);
- }
- color->time_base.num = frame_rate_q.den;
- color->time_base.den = frame_rate_q.num;
-
- if ((ret = av_parse_color(color->color, color_string, -1, ctx)) < 0)
- return ret;
-
- return 0;
-}
-
-static av_cold void color_uninit(AVFilterContext *ctx)
-{
- ColorContext *color = ctx->priv;
- int i;
-
- for (i = 0; i < 4; i++) {
- av_freep(&color->line[i]);
- color->line_step[i] = 0;
- }
-}
-
-static int color_config_props(AVFilterLink *inlink)
-{
- AVFilterContext *ctx = inlink->src;
- ColorContext *color = ctx->priv;
- uint8_t rgba_color[4];
- int is_packed_rgba;
- const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format];
-
- color->hsub = pix_desc->log2_chroma_w;
- color->vsub = pix_desc->log2_chroma_h;
-
- color->w &= ~((1 << color->hsub) - 1);
- color->h &= ~((1 << color->vsub) - 1);
- if (av_image_check_size(color->w, color->h, 0, ctx) < 0)
- return AVERROR(EINVAL);
-
- memcpy(rgba_color, color->color, sizeof(rgba_color));
- fill_line_with_color(color->line, color->line_step, color->w, color->color,
- inlink->format, rgba_color, &is_packed_rgba);
-
- av_log(ctx, AV_LOG_INFO, "w:%d h:%d r:%d/%d color:0x%02x%02x%02x%02x[%s]\n",
- color->w, color->h, color->time_base.den, color->time_base.num,
- color->color[0], color->color[1], color->color[2], color->color[3],
- is_packed_rgba ? "rgba" : "yuva");
- inlink->w = color->w;
- inlink->h = color->h;
-
- return 0;
-}
-
-static int color_request_frame(AVFilterLink *link)
-{
- ColorContext *color = link->src->priv;
- AVFilterBufferRef *picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, color->w, color->h);
- picref->video->pixel_aspect = (AVRational) {1, 1};
- picref->pts = av_rescale_q(color->pts++, color->time_base, AV_TIME_BASE_Q);
- picref->pos = 0;
-
- avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0));
- draw_rectangle(picref,
- color->line, color->line_step, color->hsub, color->vsub,
- 0, 0, color->w, color->h);
- avfilter_draw_slice(link, 0, color->h, 1);
- avfilter_end_frame(link);
- avfilter_unref_buffer(picref);
-
- return 0;
-}
-
-AVFilter avfilter_vsrc_color = {
- .name = "color",
- .description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input, syntax is: [color[:size[:rate]]]"),
-
- .priv_size = sizeof(ColorContext),
- .init = color_init,
- .uninit = color_uninit,
-
- .query_formats = query_formats,
-
- .inputs = (AVFilterPad[]) {{ .name = NULL}},
-
- .outputs = (AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_VIDEO,
- .request_frame = color_request_frame,
- .config_props = color_config_props },
- { .name = NULL}},
-};
-
-#endif /* CONFIG_COLOR_FILTER */
diff --git a/mplayer/ffmpeg/libavfilter/vf_transpose.c b/mplayer/ffmpeg/libavfilter/vf_transpose.c
index 970c3812..ed91aaad 100644
--- a/mplayer/ffmpeg/libavfilter/vf_transpose.c
+++ b/mplayer/ffmpeg/libavfilter/vf_transpose.c
@@ -27,7 +27,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/pixdesc.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "avfilter.h"
typedef struct {
@@ -102,6 +102,11 @@ static int config_props_output(AVFilterLink *outlink)
outlink->w = inlink->h;
outlink->h = inlink->w;
+ if (inlink->sample_aspect_ratio.num){
+ outlink->sample_aspect_ratio = av_div_q((AVRational){1,1}, inlink->sample_aspect_ratio);
+ } else
+ outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
+
av_log(ctx, AV_LOG_INFO, "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n",
inlink->w, inlink->h, trans->dir, outlink->w, outlink->h,
trans->dir == 1 || trans->dir == 3 ? "clockwise" : "counterclockwise",
diff --git a/mplayer/ffmpeg/libavfilter/vsrc_buffer.c b/mplayer/ffmpeg/libavfilter/vsrc_buffer.c
index 74d9bf62..3c48a71c 100644
--- a/mplayer/ffmpeg/libavfilter/vsrc_buffer.c
+++ b/mplayer/ffmpeg/libavfilter/vsrc_buffer.c
@@ -25,7 +25,7 @@
#include "avfilter.h"
#include "vsrc_buffer.h"
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
typedef struct {
int64_t pts;
diff --git a/mplayer/ffmpeg/libavfilter/vsrc_color.c b/mplayer/ffmpeg/libavfilter/vsrc_color.c
new file mode 100644
index 00000000..3fab260a
--- /dev/null
+++ b/mplayer/ffmpeg/libavfilter/vsrc_color.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2010 Stefano Sabatini
+ *
+ * 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
+ */
+
+#include "avfilter.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/colorspace.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/parseutils.h"
+#include "drawutils.h"
+
+typedef struct {
+ int w, h;
+ uint8_t color[4];
+ AVRational time_base;
+ uint8_t *line[4];
+ int line_step[4];
+ int hsub, vsub; ///< chroma subsampling values
+ uint64_t pts;
+} ColorContext;
+
+static av_cold int color_init(AVFilterContext *ctx, const char *args, void *opaque)
+{
+ ColorContext *color = ctx->priv;
+ char color_string[128] = "black";
+ char frame_size [128] = "320x240";
+ char frame_rate [128] = "25";
+ AVRational frame_rate_q;
+ int ret;
+
+ if (args)
+ sscanf(args, "%127[^:]:%127[^:]:%127s", color_string, frame_size, frame_rate);
+
+ if (av_parse_video_size(&color->w, &color->h, frame_size) < 0) {
+ av_log(ctx, AV_LOG_ERROR, "Invalid frame size: %s\n", frame_size);
+ return AVERROR(EINVAL);
+ }
+
+ if (av_parse_video_rate(&frame_rate_q, frame_rate) < 0 ||
+ frame_rate_q.den <= 0 || frame_rate_q.num <= 0) {
+ av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: %s\n", frame_rate);
+ return AVERROR(EINVAL);
+ }
+ color->time_base.num = frame_rate_q.den;
+ color->time_base.den = frame_rate_q.num;
+
+ if ((ret = av_parse_color(color->color, color_string, -1, ctx)) < 0)
+ return ret;
+
+ return 0;
+}
+
+static av_cold void color_uninit(AVFilterContext *ctx)
+{
+ ColorContext *color = ctx->priv;
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ av_freep(&color->line[i]);
+ color->line_step[i] = 0;
+ }
+}
+
+static int query_formats(AVFilterContext *ctx)
+{
+ static const enum PixelFormat pix_fmts[] = {
+ PIX_FMT_ARGB, PIX_FMT_RGBA,
+ PIX_FMT_ABGR, PIX_FMT_BGRA,
+ PIX_FMT_RGB24, PIX_FMT_BGR24,
+
+ PIX_FMT_YUV444P, PIX_FMT_YUV422P,
+ PIX_FMT_YUV420P, PIX_FMT_YUV411P,
+ PIX_FMT_YUV410P, PIX_FMT_YUV440P,
+ PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P,
+ PIX_FMT_YUVJ420P, PIX_FMT_YUVJ440P,
+ PIX_FMT_YUVA420P,
+
+ PIX_FMT_NONE
+ };
+
+ avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
+ return 0;
+}
+
+static int color_config_props(AVFilterLink *inlink)
+{
+ AVFilterContext *ctx = inlink->src;
+ ColorContext *color = ctx->priv;
+ uint8_t rgba_color[4];
+ int is_packed_rgba;
+ const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format];
+
+ color->hsub = pix_desc->log2_chroma_w;
+ color->vsub = pix_desc->log2_chroma_h;
+
+ color->w &= ~((1 << color->hsub) - 1);
+ color->h &= ~((1 << color->vsub) - 1);
+ if (av_image_check_size(color->w, color->h, 0, ctx) < 0)
+ return AVERROR(EINVAL);
+
+ memcpy(rgba_color, color->color, sizeof(rgba_color));
+ ff_fill_line_with_color(color->line, color->line_step, color->w, color->color,
+ inlink->format, rgba_color, &is_packed_rgba, NULL);
+
+ av_log(ctx, AV_LOG_INFO, "w:%d h:%d r:%d/%d color:0x%02x%02x%02x%02x[%s]\n",
+ color->w, color->h, color->time_base.den, color->time_base.num,
+ color->color[0], color->color[1], color->color[2], color->color[3],
+ is_packed_rgba ? "rgba" : "yuva");
+ inlink->w = color->w;
+ inlink->h = color->h;
+
+ return 0;
+}
+
+static int color_request_frame(AVFilterLink *link)
+{
+ ColorContext *color = link->src->priv;
+ AVFilterBufferRef *picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, color->w, color->h);
+ picref->video->pixel_aspect = (AVRational) {1, 1};
+ picref->pts = av_rescale_q(color->pts++, color->time_base, AV_TIME_BASE_Q);
+ picref->pos = 0;
+
+ avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0));
+ ff_draw_rectangle(picref->data, picref->linesize,
+ color->line, color->line_step, color->hsub, color->vsub,
+ 0, 0, color->w, color->h);
+ avfilter_draw_slice(link, 0, color->h, 1);
+ avfilter_end_frame(link);
+ avfilter_unref_buffer(picref);
+
+ return 0;
+}
+
+AVFilter avfilter_vsrc_color = {
+ .name = "color",
+ .description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input, syntax is: [color[:size[:rate]]]"),
+
+ .priv_size = sizeof(ColorContext),
+ .init = color_init,
+ .uninit = color_uninit,
+
+ .query_formats = query_formats,
+
+ .inputs = (AVFilterPad[]) {{ .name = NULL}},
+
+ .outputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .request_frame = color_request_frame,
+ .config_props = color_config_props },
+ { .name = NULL}},
+};
diff --git a/mplayer/ffmpeg/libavfilter/vsrc_movie.c b/mplayer/ffmpeg/libavfilter/vsrc_movie.c
new file mode 100644
index 00000000..fac30f9a
--- /dev/null
+++ b/mplayer/ffmpeg/libavfilter/vsrc_movie.c
@@ -0,0 +1,311 @@
+/*
+ * Copyright (c) 2010 Stefano Sabatini
+ * Copyright (c) 2008 Victor Paesa
+ *
+ * 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
+ * movie video source
+ *
+ * @todo use direct rendering (no allocation of a new frame)
+ * @todo support a PTS correction mechanism
+ * @todo support more than one output stream
+ */
+
+/* #define DEBUG */
+
+#include
+#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
+#include "libavutil/imgutils.h"
+#include "libavformat/avformat.h"
+#include "avfilter.h"
+
+typedef struct {
+ const AVClass *class;
+ int64_t seek_point; ///< seekpoint in microseconds
+ double seek_point_d;
+ char *format_name;
+ char *file_name;
+ int stream_index;
+
+ AVFormatContext *format_ctx;
+ AVCodecContext *codec_ctx;
+ int is_done;
+ AVFrame *frame; ///< video frame to store the decoded images in
+
+ int w, h;
+ AVFilterBufferRef *picref;
+} MovieContext;
+
+#define OFFSET(x) offsetof(MovieContext, x)
+
+static const AVOption movie_options[]= {
+{"format_name", "set format name", OFFSET(format_name), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX },
+{"f", "set format name", OFFSET(format_name), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX },
+{"stream_index", "set stream index", OFFSET(stream_index), FF_OPT_TYPE_INT, -1, -1, INT_MAX },
+{"si", "set stream index", OFFSET(stream_index), FF_OPT_TYPE_INT, -1, -1, INT_MAX },
+{"seek_point", "set seekpoint (seconds)", OFFSET(seek_point_d), FF_OPT_TYPE_DOUBLE, 0, 0, (INT64_MAX-1) / 1000000 },
+{"sp", "set seekpoint (seconds)", OFFSET(seek_point_d), FF_OPT_TYPE_DOUBLE, 0, 0, (INT64_MAX-1) / 1000000 },
+{NULL},
+};
+
+static const char *movie_get_name(void *ctx)
+{
+ return "movie";
+}
+
+static const AVClass movie_class = {
+ "MovieContext",
+ movie_get_name,
+ movie_options
+};
+
+static int movie_init(AVFilterContext *ctx)
+{
+ MovieContext *movie = ctx->priv;
+ AVInputFormat *iformat = NULL;
+ AVCodec *codec;
+ int ret;
+ int64_t timestamp;
+
+ av_register_all();
+
+ // Try to find the movie format (container)
+ iformat = movie->format_name ? av_find_input_format(movie->format_name) : NULL;
+
+ movie->format_ctx = NULL;
+ if ((ret = av_open_input_file(&movie->format_ctx, movie->file_name, iformat, 0, NULL)) < 0) {
+ av_log(ctx, AV_LOG_ERROR,
+ "Failed to av_open_input_file '%s'\n", movie->file_name);
+ return ret;
+ }
+ if ((ret = av_find_stream_info(movie->format_ctx)) < 0)
+ av_log(ctx, AV_LOG_WARNING, "Failed to find stream info\n");
+
+ // if seeking requested, we execute it
+ if (movie->seek_point > 0) {
+ timestamp = movie->seek_point;
+ // add the stream start time, should it exist
+ if (movie->format_ctx->start_time != AV_NOPTS_VALUE) {
+ if (timestamp > INT64_MAX - movie->format_ctx->start_time) {
+ av_log(ctx, AV_LOG_ERROR,
+ "%s: seek value overflow with start_time:%"PRId64" seek_point:%"PRId64"\n",
+ movie->file_name, movie->format_ctx->start_time, movie->seek_point);
+ return AVERROR(EINVAL);
+ }
+ timestamp += movie->format_ctx->start_time;
+ }
+ if ((ret = av_seek_frame(movie->format_ctx, -1, timestamp, AVSEEK_FLAG_BACKWARD)) < 0) {
+ av_log(ctx, AV_LOG_ERROR, "%s: could not seek to position %"PRId64"\n",
+ movie->file_name, timestamp);
+ return ret;
+ }
+ }
+
+ /* select the video stream */
+ if ((ret = av_find_best_stream(movie->format_ctx, AVMEDIA_TYPE_VIDEO,
+ movie->stream_index, -1, NULL, 0)) < 0) {
+ av_log(ctx, AV_LOG_ERROR, "No video stream with index '%d' found\n",
+ movie->stream_index);
+ return ret;
+ }
+ movie->stream_index = ret;
+ movie->codec_ctx = movie->format_ctx->streams[movie->stream_index]->codec;
+
+ /*
+ * So now we've got a pointer to the so-called codec context for our video
+ * stream, but we still have to find the actual codec and open it.
+ */
+ codec = avcodec_find_decoder(movie->codec_ctx->codec_id);
+ if (!codec) {
+ av_log(ctx, AV_LOG_ERROR, "Failed to find any codec\n");
+ return AVERROR(EINVAL);
+ }
+
+ if ((ret = avcodec_open(movie->codec_ctx, codec)) < 0) {
+ av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n");
+ return ret;
+ }
+
+ if (!(movie->frame = avcodec_alloc_frame()) ) {
+ av_log(ctx, AV_LOG_ERROR, "Failed to alloc frame\n");
+ return AVERROR(ENOMEM);
+ }
+
+ movie->w = movie->codec_ctx->width;
+ movie->h = movie->codec_ctx->height;
+
+ av_log(ctx, AV_LOG_INFO, "seek_point:%lld format_name:%s file_name:%s stream_index:%d\n",
+ movie->seek_point, movie->format_name, movie->file_name,
+ movie->stream_index);
+
+ return 0;
+}
+
+static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
+{
+ MovieContext *movie = ctx->priv;
+ int ret;
+ movie->class = &movie_class;
+ av_opt_set_defaults2(movie, 0, 0);
+
+ if (args)
+ movie->file_name = av_get_token(&args, ":");
+ if (!movie->file_name || !*movie->file_name) {
+ av_log(ctx, AV_LOG_ERROR, "No filename provided!\n");
+ return AVERROR(EINVAL);
+ }
+
+ if (*args++ == ':' && (ret = av_set_options_string(movie, args, "=", ":")) < 0) {
+ av_log(ctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
+ return ret;
+ }
+
+ movie->seek_point = movie->seek_point_d * 1000000 + 0.5;
+
+ return movie_init(ctx);
+}
+
+static av_cold void uninit(AVFilterContext *ctx)
+{
+ MovieContext *movie = ctx->priv;
+
+ av_free(movie->file_name);
+ av_free(movie->format_name);
+ if (movie->codec_ctx)
+ avcodec_close(movie->codec_ctx);
+ if (movie->format_ctx)
+ av_close_input_file(movie->format_ctx);
+ avfilter_unref_buffer(movie->picref);
+ av_freep(&movie->frame);
+}
+
+static int query_formats(AVFilterContext *ctx)
+{
+ MovieContext *movie = ctx->priv;
+ enum PixelFormat pix_fmts[] = { movie->codec_ctx->pix_fmt, PIX_FMT_NONE };
+
+ avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
+ return 0;
+}
+
+static int config_output_props(AVFilterLink *outlink)
+{
+ MovieContext *movie = outlink->src->priv;
+
+ outlink->w = movie->w;
+ outlink->h = movie->h;
+ outlink->time_base = movie->format_ctx->streams[movie->stream_index]->time_base;
+
+ return 0;
+}
+
+static int movie_get_frame(AVFilterLink *outlink)
+{
+ MovieContext *movie = outlink->src->priv;
+ AVPacket pkt;
+ int ret, frame_decoded;
+ AVStream *st = movie->format_ctx->streams[movie->stream_index];
+
+ if (movie->is_done == 1)
+ return 0;
+
+ while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
+ // Is this a packet from the video stream?
+ if (pkt.stream_index == movie->stream_index) {
+ movie->codec_ctx->reordered_opaque = pkt.pos;
+ avcodec_decode_video2(movie->codec_ctx, movie->frame, &frame_decoded, &pkt);
+
+ if (frame_decoded) {
+ /* FIXME: avoid the memcpy */
+ movie->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE | AV_PERM_PRESERVE |
+ AV_PERM_REUSE2, outlink->w, outlink->h);
+ av_image_copy(movie->picref->data, movie->picref->linesize,
+ movie->frame->data, movie->frame->linesize,
+ movie->picref->format, outlink->w, outlink->h);
+
+ /* FIXME: use a PTS correction mechanism as that in
+ * ffplay.c when some API will be available for that */
+ /* use pkt_dts if pkt_pts is not available */
+ movie->picref->pts = movie->frame->pkt_pts == AV_NOPTS_VALUE ?
+ movie->frame->pkt_dts : movie->frame->pkt_pts;
+
+ movie->picref->pos = movie->frame->reordered_opaque;
+ movie->picref->video->pixel_aspect = st->sample_aspect_ratio.num ?
+ st->sample_aspect_ratio : movie->codec_ctx->sample_aspect_ratio;
+ movie->picref->video->interlaced = movie->frame->interlaced_frame;
+ movie->picref->video->top_field_first = movie->frame->top_field_first;
+ av_dlog(outlink->src,
+ "movie_get_frame(): file:'%s' pts:%"PRId64" time:%lf pos:%"PRId64" aspect:%d/%d\n",
+ movie->file_name, movie->picref->pts,
+ (double)movie->picref->pts * av_q2d(st->time_base),
+ movie->picref->pos,
+ movie->picref->video->pixel_aspect.num, movie->picref->video->pixel_aspect.den);
+ // We got it. Free the packet since we are returning
+ av_free_packet(&pkt);
+
+ return 0;
+ }
+ }
+ // Free the packet that was allocated by av_read_frame
+ av_free_packet(&pkt);
+ }
+
+ // On multi-frame source we should stop the mixing process when
+ // the movie source does not have more frames
+ if (ret == AVERROR_EOF)
+ movie->is_done = 1;
+ return ret;
+}
+
+static int request_frame(AVFilterLink *outlink)
+{
+ AVFilterBufferRef *outpicref;
+ MovieContext *movie = outlink->src->priv;
+ int ret;
+
+ if (movie->is_done)
+ return AVERROR_EOF;
+ if ((ret = movie_get_frame(outlink)) < 0)
+ return ret;
+
+ outpicref = avfilter_ref_buffer(movie->picref, ~0);
+ avfilter_start_frame(outlink, outpicref);
+ avfilter_draw_slice(outlink, 0, outlink->h, 1);
+ avfilter_end_frame(outlink);
+
+ return 0;
+}
+
+AVFilter avfilter_vsrc_movie = {
+ .name = "movie",
+ .description = NULL_IF_CONFIG_SMALL("Read from a movie source."),
+ .priv_size = sizeof(MovieContext),
+ .init = init,
+ .uninit = uninit,
+ .query_formats = query_formats,
+
+ .inputs = (AVFilterPad[]) {{ .name = NULL }},
+ .outputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .request_frame = request_frame,
+ .config_props = config_output_props, },
+ { .name = NULL}},
+};
diff --git a/mplayer/ffmpeg/libavfilter/vsrc_nullsrc.c b/mplayer/ffmpeg/libavfilter/vsrc_nullsrc.c
index 1cd06e13..487aa500 100644
--- a/mplayer/ffmpeg/libavfilter/vsrc_nullsrc.c
+++ b/mplayer/ffmpeg/libavfilter/vsrc_nullsrc.c
@@ -23,7 +23,7 @@
#include "libavutil/avstring.h"
#include "libavutil/eval.h"
-#include "libavcore/parseutils.h"
+#include "libavutil/parseutils.h"
#include "avfilter.h"
static const char *var_names[] = {
diff --git a/mplayer/ffmpeg/libavformat/4xm.c b/mplayer/ffmpeg/libavformat/4xm.c
index 6f737e34..2757e892 100644
--- a/mplayer/ffmpeg/libavformat/4xm.c
+++ b/mplayer/ffmpeg/libavformat/4xm.c
@@ -54,11 +54,11 @@
#define strk_SIZE 0x28
#define GET_LIST_HEADER() \
- fourcc_tag = get_le32(pb); \
- size = get_le32(pb); \
+ fourcc_tag = avio_rl32(pb); \
+ size = avio_rl32(pb); \
if (fourcc_tag != LIST_TAG) \
return AVERROR_INVALIDDATA; \
- fourcc_tag = get_le32(pb);
+ fourcc_tag = avio_rl32(pb);
typedef struct AudioTrack {
int sample_rate;
@@ -92,7 +92,7 @@ static int fourxm_probe(AVProbeData *p)
static int fourxm_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int fourcc_tag;
unsigned int size;
int header_size;
@@ -106,7 +106,7 @@ static int fourxm_read_header(AVFormatContext *s,
fourxm->fps = 1.0;
/* skip the first 3 32-bit numbers */
- url_fseek(pb, 12, SEEK_CUR);
+ avio_seek(pb, 12, SEEK_CUR);
/* check for LIST-HEAD */
GET_LIST_HEADER();
@@ -118,7 +118,7 @@ static int fourxm_read_header(AVFormatContext *s,
header = av_malloc(header_size);
if (!header)
return AVERROR(ENOMEM);
- if (get_buffer(pb, header, header_size) != header_size){
+ if (avio_read(pb, header, header_size) != header_size){
av_free(header);
return AVERROR(EIO);
}
@@ -244,7 +244,7 @@ static int fourxm_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
FourxmDemuxContext *fourxm = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int fourcc_tag;
unsigned int size, out_size;
int ret = 0;
@@ -255,7 +255,7 @@ static int fourxm_read_packet(AVFormatContext *s,
while (!packet_read) {
- if ((ret = get_buffer(s->pb, header, 8)) < 0)
+ if ((ret = avio_read(s->pb, header, 8)) < 0)
return ret;
fourcc_tag = AV_RL32(&header[0]);
size = AV_RL32(&header[4]);
@@ -268,7 +268,7 @@ static int fourxm_read_packet(AVFormatContext *s,
fourxm->video_pts ++;
/* skip the LIST-* tag and move on to the next fourcc */
- get_le32(pb);
+ avio_rl32(pb);
break;
case ifrm_TAG:
@@ -285,7 +285,7 @@ static int fourxm_read_packet(AVFormatContext *s,
pkt->pts = fourxm->video_pts;
pkt->pos = url_ftell(s->pb);
memcpy(pkt->data, header, 8);
- ret = get_buffer(s->pb, &pkt->data[8], size);
+ ret = avio_read(s->pb, &pkt->data[8], size);
if (ret < 0){
av_free_packet(pkt);
@@ -294,8 +294,8 @@ static int fourxm_read_packet(AVFormatContext *s,
break;
case snd__TAG:
- track_number = get_le32(pb);
- out_size= get_le32(pb);
+ track_number = avio_rl32(pb);
+ out_size= avio_rl32(pb);
size-=8;
if (track_number < fourxm->track_count && fourxm->tracks[track_number].channels>0) {
@@ -322,12 +322,12 @@ static int fourxm_read_packet(AVFormatContext *s,
fourxm->tracks[track_number].audio_pts += audio_frame_count;
} else {
- url_fseek(pb, size, SEEK_CUR);
+ avio_seek(pb, size, SEEK_CUR);
}
break;
default:
- url_fseek(pb, size, SEEK_CUR);
+ avio_seek(pb, size, SEEK_CUR);
break;
}
}
diff --git a/mplayer/ffmpeg/libavformat/Makefile b/mplayer/ffmpeg/libavformat/Makefile
index 8f583e04..f319031c 100644
--- a/mplayer/ffmpeg/libavformat/Makefile
+++ b/mplayer/ffmpeg/libavformat/Makefile
@@ -1,7 +1,7 @@
include $(SUBDIR)../config.mak
NAME = avformat
-FFLIBS = avcodec avcore avutil
+FFLIBS = avcodec avutil
HEADERS = avformat.h avio.h version.h
@@ -128,7 +128,8 @@ OBJS-$(CONFIG_MM_DEMUXER) += mm.o
OBJS-$(CONFIG_MMF_DEMUXER) += mmf.o pcm.o
OBJS-$(CONFIG_MMF_MUXER) += mmf.o riff.o
OBJS-$(CONFIG_MOV_DEMUXER) += mov.o riff.o isom.o
-OBJS-$(CONFIG_MOV_MUXER) += movenc.o riff.o isom.o avc.o movenchint.o
+OBJS-$(CONFIG_MOV_MUXER) += movenc.o riff.o isom.o avc.o \
+ movenchint.o rtpenc_chain.o
OBJS-$(CONFIG_MP2_MUXER) += mp3enc.o
OBJS-$(CONFIG_MP3_DEMUXER) += mp3dec.o
OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o
diff --git a/mplayer/ffmpeg/libavformat/a64.c b/mplayer/ffmpeg/libavformat/a64.c
index 46441b23..17dcd96b 100644
--- a/mplayer/ffmpeg/libavformat/a64.c
+++ b/mplayer/ffmpeg/libavformat/a64.c
@@ -57,7 +57,7 @@ static int a64_write_header(struct AVFormatContext *s)
return AVERROR(EINVAL);
break;
}
- put_buffer(s->pb, header, 2);
+ avio_write(s->pb, header, 2);
c->prev_pkt.size = 0;
c->prev_frame_count = 0;
return 0;
@@ -110,18 +110,18 @@ static int a64_write_packet(struct AVFormatContext *s, AVPacket *pkt)
for(i = 0; i < num_frames; i++) {
if(pkt->data) {
/* if available, put newest charset chunk into buffer */
- put_buffer(s->pb, pkt->data + ch_chunksize * i, ch_chunksize);
+ avio_write(s->pb, pkt->data + ch_chunksize * i, ch_chunksize);
} else {
/* a bit ugly, but is there an alternative to put many zeros? */
- for(j = 0; j < ch_chunksize; j++) put_byte(s->pb, 0);
+ for(j = 0; j < ch_chunksize; j++) avio_w8(s->pb, 0);
}
if(c->prev_pkt.data) {
/* put frame (screen + colram) from last packet into buffer */
- put_buffer(s->pb, c->prev_pkt.data + charset_size + frame_size * i, frame_size);
+ avio_write(s->pb, c->prev_pkt.data + charset_size + frame_size * i, frame_size);
} else {
/* a bit ugly, but is there an alternative to put many zeros? */
- for(j = 0; j < frame_size; j++) put_byte(s->pb, 0);
+ for(j = 0; j < frame_size; j++) avio_w8(s->pb, 0);
}
}
@@ -145,7 +145,7 @@ static int a64_write_packet(struct AVFormatContext *s, AVPacket *pkt)
default:
/* Write things as is. Nice for self-contained frames from non-multicolor modes or if played
* directly from ram and not from a streaming device (rrnet/mmc) */
- if(pkt) put_buffer(s->pb, pkt->data, pkt->size);
+ if(pkt) avio_write(s->pb, pkt->data, pkt->size);
break;
}
diff --git a/mplayer/ffmpeg/libavformat/adtsenc.c b/mplayer/ffmpeg/libavformat/adtsenc.c
index f309c896..1f5453db 100644
--- a/mplayer/ffmpeg/libavformat/adtsenc.c
+++ b/mplayer/ffmpeg/libavformat/adtsenc.c
@@ -118,20 +118,20 @@ int ff_adts_write_frame_header(ADTSContext *ctx,
static int adts_write_packet(AVFormatContext *s, AVPacket *pkt)
{
ADTSContext *adts = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint8_t buf[ADTS_HEADER_SIZE];
if (!pkt->size)
return 0;
if (adts->write_adts) {
ff_adts_write_frame_header(adts, buf, pkt->size, adts->pce_size);
- put_buffer(pb, buf, ADTS_HEADER_SIZE);
+ avio_write(pb, buf, ADTS_HEADER_SIZE);
if (adts->pce_size) {
- put_buffer(pb, adts->pce_data, adts->pce_size);
+ avio_write(pb, adts->pce_data, adts->pce_size);
adts->pce_size = 0;
}
}
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
put_flush_packet(pb);
return 0;
diff --git a/mplayer/ffmpeg/libavformat/aea.c b/mplayer/ffmpeg/libavformat/aea.c
index 6816506e..60b2d38f 100644
--- a/mplayer/ffmpeg/libavformat/aea.c
+++ b/mplayer/ffmpeg/libavformat/aea.c
@@ -23,6 +23,7 @@
#include "avformat.h"
#include "pcm.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/audioconvert.h"
#define AT1_SU_SIZE 212
@@ -61,9 +62,9 @@ static int aea_read_header(AVFormatContext *s,
return AVERROR(ENOMEM);
/* Parse the amount of channels and skip to pos 2048(0x800) */
- url_fskip(s->pb, 264);
- st->codec->channels = get_byte(s->pb);
- url_fskip(s->pb, 1783);
+ avio_seek(s->pb, 264, SEEK_CUR);
+ st->codec->channels = avio_r8(s->pb);
+ avio_seek(s->pb, 1783, SEEK_CUR);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -76,7 +77,7 @@ static int aea_read_header(AVFormatContext *s,
return -1;
}
- st->codec->channel_layout = (st->codec->channels == 1) ? CH_LAYOUT_MONO : CH_LAYOUT_STEREO;
+ st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
st->codec->block_align = AT1_SU_SIZE * st->codec->channels;
return 0;
diff --git a/mplayer/ffmpeg/libavformat/aiffdec.c b/mplayer/ffmpeg/libavformat/aiffdec.c
index b8410237..849793a1 100644
--- a/mplayer/ffmpeg/libavformat/aiffdec.c
+++ b/mplayer/ffmpeg/libavformat/aiffdec.c
@@ -47,15 +47,15 @@ static enum CodecID aiff_codec_get_id(int bps)
}
/* returns the size of the found tag */
-static int get_tag(ByteIOContext *pb, uint32_t * tag)
+static int get_tag(AVIOContext *pb, uint32_t * tag)
{
int size;
if (url_feof(pb))
return AVERROR(EIO);
- *tag = get_le32(pb);
- size = get_be32(pb);
+ *tag = avio_rl32(pb);
+ size = avio_rb32(pb);
if (size < 0)
size = 0x7fffffff;
@@ -70,11 +70,11 @@ static void get_meta(AVFormatContext *s, const char *key, int size)
int res;
if (!str) {
- url_fskip(s->pb, size);
+ avio_seek(s->pb, size, SEEK_CUR);
return;
}
- res = get_buffer(s->pb, str, size);
+ res = avio_read(s->pb, str, size);
if (res < 0)
return;
@@ -83,7 +83,7 @@ static void get_meta(AVFormatContext *s, const char *key, int size)
}
/* Returns the number of sound data frames or negative on error */
-static unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec,
+static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec,
int size, unsigned version)
{
AVExtFloat ext;
@@ -93,18 +93,18 @@ static unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec,
if (size & 1)
size++;
codec->codec_type = AVMEDIA_TYPE_AUDIO;
- codec->channels = get_be16(pb);
- num_frames = get_be32(pb);
- codec->bits_per_coded_sample = get_be16(pb);
+ codec->channels = avio_rb16(pb);
+ num_frames = avio_rb32(pb);
+ codec->bits_per_coded_sample = avio_rb16(pb);
- get_buffer(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */
+ avio_read(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */
sample_rate = av_ext2dbl(ext); /* 80 bits BE IEEE extended float */
codec->sample_rate = sample_rate;
size -= 18;
/* Got an AIFF-C? */
if (version == AIFF_C_VERSION1) {
- codec->codec_tag = get_le32(pb);
+ codec->codec_tag = avio_rl32(pb);
codec->codec_id = ff_codec_get_id(ff_codec_aiff_tags, codec->codec_tag);
switch (codec->codec_id) {
@@ -152,7 +152,7 @@ static unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec,
/* Chunk is over */
if (size)
- url_fseek(pb, size, SEEK_CUR);
+ avio_seek(pb, size, SEEK_CUR);
return num_frames;
}
@@ -177,7 +177,7 @@ static int aiff_read_header(AVFormatContext *s,
int64_t offset = 0;
uint32_t tag;
unsigned version = AIFF_C_VERSION1;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream * st;
AIFFInputContext *aiff = s->priv_data;
@@ -187,7 +187,7 @@ static int aiff_read_header(AVFormatContext *s,
return AVERROR_INVALIDDATA;
/* AIFF data type */
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag == MKTAG('A', 'I', 'F', 'F')) /* Got an AIFF file */
version = AIFF;
else if (tag != MKTAG('A', 'I', 'F', 'C')) /* An AIFF-C file then */
@@ -217,7 +217,7 @@ static int aiff_read_header(AVFormatContext *s,
goto got_sound;
break;
case MKTAG('F', 'V', 'E', 'R'): /* Version chunk */
- version = get_be32(pb);
+ version = avio_rb32(pb);
break;
case MKTAG('N', 'A', 'M', 'E'): /* Sample name chunk */
get_meta(s, "title" , size);
@@ -233,8 +233,8 @@ static int aiff_read_header(AVFormatContext *s,
break;
case MKTAG('S', 'S', 'N', 'D'): /* Sampled sound chunk */
aiff->data_end = url_ftell(pb) + size;
- offset = get_be32(pb); /* Offset of sound data */
- get_be32(pb); /* BlockSize... don't care */
+ offset = avio_rb32(pb); /* Offset of sound data */
+ avio_rb32(pb); /* BlockSize... don't care */
offset += url_ftell(pb); /* Compute absolute data offset */
if (st->codec->block_align) /* Assume COMM already parsed */
goto got_sound;
@@ -242,7 +242,7 @@ static int aiff_read_header(AVFormatContext *s,
av_log(s, AV_LOG_ERROR, "file is not seekable\n");
return -1;
}
- url_fskip(pb, size - 8);
+ avio_seek(pb, size - 8, SEEK_CUR);
break;
case MKTAG('w', 'a', 'v', 'e'):
if ((uint64_t)size > (1<<30))
@@ -251,12 +251,12 @@ static int aiff_read_header(AVFormatContext *s,
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = size;
- get_buffer(pb, st->codec->extradata, size);
+ avio_read(pb, st->codec->extradata, size);
break;
default: /* Jump */
if (size & 1) /* Always even aligned */
size++;
- url_fskip (pb, size);
+ avio_seek(pb, size, SEEK_CUR);
}
}
@@ -276,7 +276,7 @@ static int aiff_read_header(AVFormatContext *s,
st->nb_frames * st->codec->frame_size : st->nb_frames;
/* Position the stream at the first block */
- url_fseek(pb, offset, SEEK_SET);
+ avio_seek(pb, offset, SEEK_SET);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/aiffenc.c b/mplayer/ffmpeg/libavformat/aiffenc.c
index 6e473907..150f36bd 100644
--- a/mplayer/ffmpeg/libavformat/aiffenc.c
+++ b/mplayer/ffmpeg/libavformat/aiffenc.c
@@ -21,6 +21,7 @@
#include "avformat.h"
#include "aiff.h"
+#include "avio_internal.h"
typedef struct {
int64_t form;
@@ -31,7 +32,7 @@ typedef struct {
static int aiff_write_header(AVFormatContext *s)
{
AIFFOutputContext *aiff = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
AVExtFloat sample_rate;
int aifc = 0;
@@ -43,10 +44,10 @@ static int aiff_write_header(AVFormatContext *s)
aifc = 1;
/* FORM AIFF header */
- put_tag(pb, "FORM");
+ ffio_wfourcc(pb, "FORM");
aiff->form = url_ftell(pb);
- put_be32(pb, 0); /* file length */
- put_tag(pb, aifc ? "AIFC" : "AIFF");
+ avio_wb32(pb, 0); /* file length */
+ ffio_wfourcc(pb, aifc ? "AIFC" : "AIFF");
if (aifc) { // compressed audio
enc->bits_per_coded_sample = 16;
@@ -55,18 +56,18 @@ static int aiff_write_header(AVFormatContext *s)
return -1;
}
/* Version chunk */
- put_tag(pb, "FVER");
- put_be32(pb, 4);
- put_be32(pb, 0xA2805140);
+ ffio_wfourcc(pb, "FVER");
+ avio_wb32(pb, 4);
+ avio_wb32(pb, 0xA2805140);
}
/* Common chunk */
- put_tag(pb, "COMM");
- put_be32(pb, aifc ? 24 : 18); /* size */
- put_be16(pb, enc->channels); /* Number of channels */
+ ffio_wfourcc(pb, "COMM");
+ avio_wb32(pb, aifc ? 24 : 18); /* size */
+ avio_wb16(pb, enc->channels); /* Number of channels */
aiff->frames = url_ftell(pb);
- put_be32(pb, 0); /* Number of frames */
+ avio_wb32(pb, 0); /* Number of frames */
if (!enc->bits_per_coded_sample)
enc->bits_per_coded_sample = av_get_bits_per_sample(enc->codec_id);
@@ -77,22 +78,22 @@ static int aiff_write_header(AVFormatContext *s)
if (!enc->block_align)
enc->block_align = (enc->bits_per_coded_sample * enc->channels) >> 3;
- put_be16(pb, enc->bits_per_coded_sample); /* Sample size */
+ avio_wb16(pb, enc->bits_per_coded_sample); /* Sample size */
sample_rate = av_dbl2ext((double)enc->sample_rate);
- put_buffer(pb, (uint8_t*)&sample_rate, sizeof(sample_rate));
+ avio_write(pb, (uint8_t*)&sample_rate, sizeof(sample_rate));
if (aifc) {
- put_le32(pb, enc->codec_tag);
- put_be16(pb, 0);
+ avio_wl32(pb, enc->codec_tag);
+ avio_wb16(pb, 0);
}
/* Sound data chunk */
- put_tag(pb, "SSND");
+ ffio_wfourcc(pb, "SSND");
aiff->ssnd = url_ftell(pb); /* Sound chunk size */
- put_be32(pb, 0); /* Sound samples data size */
- put_be32(pb, 0); /* Data offset */
- put_be32(pb, 0); /* Block-size (block align) */
+ avio_wb32(pb, 0); /* Sound samples data size */
+ avio_wb32(pb, 0); /* Data offset */
+ avio_wb32(pb, 0); /* Block-size (block align) */
av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
@@ -104,14 +105,14 @@ static int aiff_write_header(AVFormatContext *s)
static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
- put_buffer(pb, pkt->data, pkt->size);
+ AVIOContext *pb = s->pb;
+ avio_write(pb, pkt->data, pkt->size);
return 0;
}
static int aiff_write_trailer(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AIFFOutputContext *aiff = s->priv_data;
AVCodecContext *enc = s->streams[0]->codec;
@@ -119,25 +120,25 @@ static int aiff_write_trailer(AVFormatContext *s)
int64_t file_size, end_size;
end_size = file_size = url_ftell(pb);
if (file_size & 1) {
- put_byte(pb, 0);
+ avio_w8(pb, 0);
end_size++;
}
if (!url_is_streamed(s->pb)) {
/* File length */
- url_fseek(pb, aiff->form, SEEK_SET);
- put_be32(pb, file_size - aiff->form - 4);
+ avio_seek(pb, aiff->form, SEEK_SET);
+ avio_wb32(pb, file_size - aiff->form - 4);
/* Number of sample frames */
- url_fseek(pb, aiff->frames, SEEK_SET);
- put_be32(pb, (file_size-aiff->ssnd-12)/enc->block_align);
+ avio_seek(pb, aiff->frames, SEEK_SET);
+ avio_wb32(pb, (file_size-aiff->ssnd-12)/enc->block_align);
/* Sound Data chunk size */
- url_fseek(pb, aiff->ssnd, SEEK_SET);
- put_be32(pb, file_size - aiff->ssnd - 4);
+ avio_seek(pb, aiff->ssnd, SEEK_SET);
+ avio_wb32(pb, file_size - aiff->ssnd - 4);
/* return to the end */
- url_fseek(pb, end_size, SEEK_SET);
+ avio_seek(pb, end_size, SEEK_SET);
put_flush_packet(pb);
}
diff --git a/mplayer/ffmpeg/libavformat/amr.c b/mplayer/ffmpeg/libavformat/amr.c
index 11bb4e51..fd43283a 100644
--- a/mplayer/ffmpeg/libavformat/amr.c
+++ b/mplayer/ffmpeg/libavformat/amr.c
@@ -33,18 +33,18 @@ static const char AMRWB_header [] = "#!AMR-WB\n";
#if CONFIG_AMR_MUXER
static int amr_write_header(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
s->priv_data = NULL;
if (enc->codec_id == CODEC_ID_AMR_NB)
{
- put_tag(pb, AMR_header); /* magic number */
+ avio_write(pb, AMR_header, sizeof(AMR_header) - 1); /* magic number */
}
else if(enc->codec_id == CODEC_ID_AMR_WB)
{
- put_tag(pb, AMRWB_header); /* magic number */
+ avio_write(pb, AMRWB_header, sizeof(AMRWB_header) - 1); /* magic number */
}
else
{
@@ -56,7 +56,7 @@ static int amr_write_header(AVFormatContext *s)
static int amr_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
return 0;
}
@@ -78,11 +78,11 @@ static int amr_probe(AVProbeData *p)
static int amr_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
uint8_t header[9];
- get_buffer(pb, header, 6);
+ avio_read(pb, header, 6);
st = av_new_stream(s, 0);
if (!st)
@@ -91,7 +91,7 @@ static int amr_read_header(AVFormatContext *s,
}
if(memcmp(header,AMR_header,6)!=0)
{
- get_buffer(pb, header+6, 3);
+ avio_read(pb, header+6, 3);
if(memcmp(header,AMRWB_header,9)!=0)
{
return -1;
@@ -128,7 +128,7 @@ static int amr_read_packet(AVFormatContext *s,
}
//FIXME this is wrong, this should rather be in a AVParset
- toc=get_byte(s->pb);
+ toc=avio_r8(s->pb);
mode = (toc >> 3) & 0x0F;
if (enc->codec_id == CODEC_ID_AMR_NB)
@@ -157,7 +157,7 @@ static int amr_read_packet(AVFormatContext *s,
pkt->pos= url_ftell(s->pb);
pkt->data[0]=toc;
pkt->duration= enc->codec_id == CODEC_ID_AMR_NB ? 160 : 320;
- read = get_buffer(s->pb, pkt->data+1, size-1);
+ read = avio_read(s->pb, pkt->data+1, size-1);
if (read != size-1)
{
diff --git a/mplayer/ffmpeg/libavformat/anm.c b/mplayer/ffmpeg/libavformat/anm.c
index dbe1b688..060cc9a0 100644
--- a/mplayer/ffmpeg/libavformat/anm.c
+++ b/mplayer/ffmpeg/libavformat/anm.c
@@ -79,21 +79,21 @@ static int read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
AnmDemuxContext *anm = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
int i, ret;
- url_fskip(pb, 4); /* magic number */
- if (get_le16(pb) != MAX_PAGES) {
+ avio_seek(pb, 4, SEEK_CUR); /* magic number */
+ if (avio_rl16(pb) != MAX_PAGES) {
av_log_ask_for_sample(s, "max_pages != " AV_STRINGIFY(MAX_PAGES) "\n");
return AVERROR_INVALIDDATA;
}
- anm->nb_pages = get_le16(pb);
- anm->nb_records = get_le32(pb);
- url_fskip(pb, 2); /* max records per page */
- anm->page_table_offset = get_le16(pb);
- if (get_le32(pb) != ANIM_TAG)
+ anm->nb_pages = avio_rl16(pb);
+ anm->nb_records = avio_rl32(pb);
+ avio_seek(pb, 2, SEEK_CUR); /* max records per page */
+ anm->page_table_offset = avio_rl16(pb);
+ if (avio_rl32(pb) != ANIM_TAG)
return AVERROR_INVALIDDATA;
/* video stream */
@@ -103,33 +103,33 @@ static int read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_ANM;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = get_le16(pb);
- st->codec->height = get_le16(pb);
- if (get_byte(pb) != 0)
+ st->codec->width = avio_rl16(pb);
+ st->codec->height = avio_rl16(pb);
+ if (avio_r8(pb) != 0)
goto invalid;
- url_fskip(pb, 1); /* frame rate multiplier info */
+ avio_seek(pb, 1, SEEK_CUR); /* frame rate multiplier info */
/* ignore last delta record (used for looping) */
- if (get_byte(pb)) /* has_last_delta */
+ if (avio_r8(pb)) /* has_last_delta */
anm->nb_records = FFMAX(anm->nb_records - 1, 0);
- url_fskip(pb, 1); /* last_delta_valid */
+ avio_seek(pb, 1, SEEK_CUR); /* last_delta_valid */
- if (get_byte(pb) != 0)
+ if (avio_r8(pb) != 0)
goto invalid;
- if (get_byte(pb) != 1)
+ if (avio_r8(pb) != 1)
goto invalid;
- url_fskip(pb, 1); /* other recs per frame */
+ avio_seek(pb, 1, SEEK_CUR); /* other recs per frame */
- if (get_byte(pb) != 1)
+ if (avio_r8(pb) != 1)
goto invalid;
- url_fskip(pb, 32); /* record_types */
- st->nb_frames = get_le32(pb);
- av_set_pts_info(st, 64, 1, get_le16(pb));
- url_fskip(pb, 58);
+ avio_seek(pb, 32, SEEK_CUR); /* record_types */
+ st->nb_frames = avio_rl32(pb);
+ av_set_pts_info(st, 64, 1, avio_rl16(pb));
+ avio_seek(pb, 58, SEEK_CUR);
/* color cycling and palette data */
st->codec->extradata_size = 16*8 + 4*256;
@@ -138,20 +138,20 @@ static int read_header(AVFormatContext *s,
ret = AVERROR(ENOMEM);
goto close_and_return;
}
- ret = get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
+ ret = avio_read(pb, st->codec->extradata, st->codec->extradata_size);
if (ret < 0)
goto close_and_return;
/* read page table */
- ret = url_fseek(pb, anm->page_table_offset, SEEK_SET);
+ ret = avio_seek(pb, anm->page_table_offset, SEEK_SET);
if (ret < 0)
goto close_and_return;
for (i = 0; i < MAX_PAGES; i++) {
Page *p = &anm->pt[i];
- p->base_record = get_le16(pb);
- p->nb_records = get_le16(pb);
- p->size = get_le16(pb);
+ p->base_record = avio_rl16(pb);
+ p->nb_records = avio_rl16(pb);
+ p->size = avio_rl16(pb);
}
/* find page of first frame */
@@ -177,7 +177,7 @@ static int read_packet(AVFormatContext *s,
AVPacket *pkt)
{
AnmDemuxContext *anm = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
Page *p;
int tmp, record_size;
@@ -192,8 +192,8 @@ static int read_packet(AVFormatContext *s,
/* parse page header */
if (anm->record < 0) {
- url_fseek(pb, anm->page_table_offset + MAX_PAGES*6 + (anm->page<<16), SEEK_SET);
- url_fskip(pb, 8 + 2*p->nb_records);
+ avio_seek(pb, anm->page_table_offset + MAX_PAGES*6 + (anm->page<<16), SEEK_SET);
+ avio_seek(pb, 8 + 2*p->nb_records, SEEK_CUR);
anm->record = 0;
}
@@ -209,10 +209,10 @@ static int read_packet(AVFormatContext *s,
/* fetch record size */
tmp = url_ftell(pb);
- url_fseek(pb, anm->page_table_offset + MAX_PAGES*6 + (anm->page<<16) +
+ avio_seek(pb, anm->page_table_offset + MAX_PAGES*6 + (anm->page<<16) +
8 + anm->record * 2, SEEK_SET);
- record_size = get_le16(pb);
- url_fseek(pb, tmp, SEEK_SET);
+ record_size = avio_rl16(pb);
+ avio_seek(pb, tmp, SEEK_SET);
/* fetch record */
pkt->size = av_get_packet(s->pb, pkt, record_size);
diff --git a/mplayer/ffmpeg/libavformat/apc.c b/mplayer/ffmpeg/libavformat/apc.c
index 942a4cf3..bf93fc15 100644
--- a/mplayer/ffmpeg/libavformat/apc.c
+++ b/mplayer/ffmpeg/libavformat/apc.c
@@ -32,12 +32,12 @@ static int apc_probe(AVProbeData *p)
static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
- get_le32(pb); /* CRYO */
- get_le32(pb); /* _APC */
- get_le32(pb); /* 1.20 */
+ avio_rl32(pb); /* CRYO */
+ avio_rl32(pb); /* _APC */
+ avio_rl32(pb); /* 1.20 */
st = av_new_stream(s, 0);
if (!st)
@@ -46,8 +46,8 @@ static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS;
- get_le32(pb); /* number of samples */
- st->codec->sample_rate = get_le32(pb);
+ avio_rl32(pb); /* number of samples */
+ st->codec->sample_rate = avio_rl32(pb);
st->codec->extradata_size = 2 * 4;
st->codec->extradata = av_malloc(st->codec->extradata_size +
@@ -56,10 +56,10 @@ static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR(ENOMEM);
/* initial predictor values for adpcm decoder */
- get_buffer(pb, st->codec->extradata, 2 * 4);
+ avio_read(pb, st->codec->extradata, 2 * 4);
st->codec->channels = 1;
- if (get_le32(pb))
+ if (avio_rl32(pb))
st->codec->channels = 2;
st->codec->bits_per_coded_sample = 4;
diff --git a/mplayer/ffmpeg/libavformat/ape.c b/mplayer/ffmpeg/libavformat/ape.c
index 327e1a9b..2de47ef4 100644
--- a/mplayer/ffmpeg/libavformat/ape.c
+++ b/mplayer/ffmpeg/libavformat/ape.c
@@ -151,7 +151,7 @@ static void ape_dumpinfo(AVFormatContext * s, APEContext * ape_ctx)
static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
APEContext *ape = s->priv_data;
AVStream *st;
uint32_t tag;
@@ -162,11 +162,11 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
/* TODO: Skip any leading junk such as id3v2 tags */
ape->junklength = 0;
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('M', 'A', 'C', ' '))
return -1;
- ape->fileversion = get_le16(pb);
+ ape->fileversion = avio_rl16(pb);
if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {
av_log(s, AV_LOG_ERROR, "Unsupported file version - %d.%02d\n", ape->fileversion / 1000, (ape->fileversion % 1000) / 10);
@@ -174,50 +174,50 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
}
if (ape->fileversion >= 3980) {
- ape->padding1 = get_le16(pb);
- ape->descriptorlength = get_le32(pb);
- ape->headerlength = get_le32(pb);
- ape->seektablelength = get_le32(pb);
- ape->wavheaderlength = get_le32(pb);
- ape->audiodatalength = get_le32(pb);
- ape->audiodatalength_high = get_le32(pb);
- ape->wavtaillength = get_le32(pb);
- get_buffer(pb, ape->md5, 16);
+ ape->padding1 = avio_rl16(pb);
+ ape->descriptorlength = avio_rl32(pb);
+ ape->headerlength = avio_rl32(pb);
+ ape->seektablelength = avio_rl32(pb);
+ ape->wavheaderlength = avio_rl32(pb);
+ ape->audiodatalength = avio_rl32(pb);
+ ape->audiodatalength_high = avio_rl32(pb);
+ ape->wavtaillength = avio_rl32(pb);
+ avio_read(pb, ape->md5, 16);
/* Skip any unknown bytes at the end of the descriptor.
This is for future compatibility */
if (ape->descriptorlength > 52)
- url_fseek(pb, ape->descriptorlength - 52, SEEK_CUR);
+ avio_seek(pb, ape->descriptorlength - 52, SEEK_CUR);
/* Read header data */
- ape->compressiontype = get_le16(pb);
- ape->formatflags = get_le16(pb);
- ape->blocksperframe = get_le32(pb);
- ape->finalframeblocks = get_le32(pb);
- ape->totalframes = get_le32(pb);
- ape->bps = get_le16(pb);
- ape->channels = get_le16(pb);
- ape->samplerate = get_le32(pb);
+ ape->compressiontype = avio_rl16(pb);
+ ape->formatflags = avio_rl16(pb);
+ ape->blocksperframe = avio_rl32(pb);
+ ape->finalframeblocks = avio_rl32(pb);
+ ape->totalframes = avio_rl32(pb);
+ ape->bps = avio_rl16(pb);
+ ape->channels = avio_rl16(pb);
+ ape->samplerate = avio_rl32(pb);
} else {
ape->descriptorlength = 0;
ape->headerlength = 32;
- ape->compressiontype = get_le16(pb);
- ape->formatflags = get_le16(pb);
- ape->channels = get_le16(pb);
- ape->samplerate = get_le32(pb);
- ape->wavheaderlength = get_le32(pb);
- ape->wavtaillength = get_le32(pb);
- ape->totalframes = get_le32(pb);
- ape->finalframeblocks = get_le32(pb);
+ ape->compressiontype = avio_rl16(pb);
+ ape->formatflags = avio_rl16(pb);
+ ape->channels = avio_rl16(pb);
+ ape->samplerate = avio_rl32(pb);
+ ape->wavheaderlength = avio_rl32(pb);
+ ape->wavtaillength = avio_rl32(pb);
+ ape->totalframes = avio_rl32(pb);
+ ape->finalframeblocks = avio_rl32(pb);
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {
- url_fseek(pb, 4, SEEK_CUR); /* Skip the peak level */
+ avio_seek(pb, 4, SEEK_CUR); /* Skip the peak level */
ape->headerlength += 4;
}
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {
- ape->seektablelength = get_le32(pb);
+ ape->seektablelength = avio_rl32(pb);
ape->headerlength += 4;
ape->seektablelength *= sizeof(int32_t);
} else
@@ -239,7 +239,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
/* Skip any stored wav header */
if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER))
- url_fskip(pb, ape->wavheaderlength);
+ avio_seek(pb, ape->wavheaderlength, SEEK_CUR);
}
if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){
@@ -260,7 +260,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
if (ape->seektablelength > 0) {
ape->seektable = av_malloc(ape->seektablelength);
for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++)
- ape->seektable[i] = get_le32(pb);
+ ape->seektable[i] = avio_rl32(pb);
}
ape->frames[0].pos = ape->firstframe;
@@ -289,7 +289,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
/* try to read APE tags */
if (!url_is_streamed(pb)) {
ff_ape_parse_tag(s);
- url_fseek(pb, 0, SEEK_SET);
+ avio_seek(pb, 0, SEEK_SET);
}
av_log(s, AV_LOG_DEBUG, "Decoding file - v%d.%02d, compression level %d\n", ape->fileversion / 1000, (ape->fileversion % 1000) / 10, ape->compressiontype);
@@ -342,7 +342,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
if (ape->currentframe > ape->totalframes)
return AVERROR(EIO);
- url_fseek (s->pb, ape->frames[ape->currentframe].pos, SEEK_SET);
+ avio_seek (s->pb, ape->frames[ape->currentframe].pos, SEEK_SET);
/* Calculate how many blocks there are in this frame */
if (ape->currentframe == (ape->totalframes - 1))
@@ -355,7 +355,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
AV_WL32(pkt->data , nblocks);
AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
- ret = get_buffer(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
+ ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
pkt->pts = ape->frames[ape->currentframe].pts;
pkt->stream_index = 0;
diff --git a/mplayer/ffmpeg/libavformat/apetag.c b/mplayer/ffmpeg/libavformat/apetag.c
index d30c1322..c3c57717 100644
--- a/mplayer/ffmpeg/libavformat/apetag.c
+++ b/mplayer/ffmpeg/libavformat/apetag.c
@@ -33,15 +33,15 @@
static int ape_tag_read_field(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint8_t key[1024], *value;
uint32_t size, flags;
int i, c;
- size = get_le32(pb); /* field size */
- flags = get_le32(pb); /* field flags */
+ size = avio_rl32(pb); /* field size */
+ flags = avio_rl32(pb); /* field flags */
for (i = 0; i < sizeof(key) - 1; i++) {
- c = get_byte(pb);
+ c = avio_r8(pb);
if (c < 0x20 || c > 0x7E)
break;
else
@@ -57,7 +57,7 @@ static int ape_tag_read_field(AVFormatContext *s)
value = av_malloc(size+1);
if (!value)
return AVERROR(ENOMEM);
- get_buffer(pb, value, size);
+ avio_read(pb, value, size);
value[size] = 0;
av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
return 0;
@@ -65,7 +65,7 @@ static int ape_tag_read_field(AVFormatContext *s)
void ff_ape_parse_tag(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int file_size = url_fsize(pb);
uint32_t val, fields, tag_bytes;
uint8_t buf[8];
@@ -74,38 +74,38 @@ void ff_ape_parse_tag(AVFormatContext *s)
if (file_size < APE_TAG_FOOTER_BYTES)
return;
- url_fseek(pb, file_size - APE_TAG_FOOTER_BYTES, SEEK_SET);
+ avio_seek(pb, file_size - APE_TAG_FOOTER_BYTES, SEEK_SET);
- get_buffer(pb, buf, 8); /* APETAGEX */
+ avio_read(pb, buf, 8); /* APETAGEX */
if (strncmp(buf, "APETAGEX", 8)) {
return;
}
- val = get_le32(pb); /* APE tag version */
+ val = avio_rl32(pb); /* APE tag version */
if (val > APE_TAG_VERSION) {
av_log(s, AV_LOG_ERROR, "Unsupported tag version. (>=%d)\n", APE_TAG_VERSION);
return;
}
- tag_bytes = get_le32(pb); /* tag size */
+ tag_bytes = avio_rl32(pb); /* tag size */
if (tag_bytes - APE_TAG_FOOTER_BYTES > (1024 * 1024 * 16)) {
av_log(s, AV_LOG_ERROR, "Tag size is way too big\n");
return;
}
- fields = get_le32(pb); /* number of fields */
+ fields = avio_rl32(pb); /* number of fields */
if (fields > 65536) {
av_log(s, AV_LOG_ERROR, "Too many tag fields (%d)\n", fields);
return;
}
- val = get_le32(pb); /* flags */
+ val = avio_rl32(pb); /* flags */
if (val & APE_TAG_FLAG_IS_HEADER) {
av_log(s, AV_LOG_ERROR, "APE Tag is a header\n");
return;
}
- url_fseek(pb, file_size - tag_bytes, SEEK_SET);
+ avio_seek(pb, file_size - tag_bytes, SEEK_SET);
for (i=0; i 0 && isspace(buf[len - 1]))
@@ -90,6 +90,20 @@ static void make_absolute_url(char *buf, int size, const char *base,
const char *rel)
{
char *sep;
+ /* Absolute path, relative to the current server */
+ if (base && strstr(base, "://") && rel[0] == '/') {
+ if (base != buf)
+ av_strlcpy(buf, base, size);
+ sep = strstr(buf, "://");
+ if (sep) {
+ sep += 3;
+ sep = strchr(sep, '/');
+ if (sep)
+ *sep = '\0';
+ }
+ av_strlcat(buf, rel, size);
+ return;
+ }
/* If rel actually is an absolute url, just copy it */
if (!base || strstr(rel, "://") || rel[0] == '/') {
av_strlcpy(buf, rel, size);
@@ -140,7 +154,7 @@ static void free_variant_list(AppleHTTPContext *c)
free_segment_list(var);
av_free_packet(&var->pkt);
if (var->pb)
- url_fclose(var->pb);
+ avio_close(var->pb);
if (var->ctx) {
var->ctx->pb = NULL;
av_close_input_file(var->ctx);
@@ -188,7 +202,7 @@ static void handle_variant_args(struct variant_info *info, const char *key,
}
static int parse_playlist(AppleHTTPContext *c, const char *url,
- struct variant *var, ByteIOContext *in)
+ struct variant *var, AVIOContext *in)
{
int ret = 0, duration = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
char line[1024];
@@ -197,7 +211,7 @@ static int parse_playlist(AppleHTTPContext *c, const char *url,
if (!in) {
close_in = 1;
- if ((ret = url_fopen(&in, url, URL_RDONLY)) < 0)
+ if ((ret = avio_open(&in, url, URL_RDONLY)) < 0)
return ret;
}
@@ -270,7 +284,7 @@ static int parse_playlist(AppleHTTPContext *c, const char *url,
fail:
if (close_in)
- url_fclose(in);
+ avio_close(in);
return ret;
}
@@ -324,7 +338,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap)
ret = av_open_input_file(&v->ctx, v->segments[0]->url, NULL, 0, NULL);
if (ret < 0)
goto fail;
- url_fclose(v->ctx->pb);
+ avio_close(v->ctx->pb);
v->ctx->pb = NULL;
v->stream_offset = stream_offset;
/* Create new AVStreams for each stream in this variant */
@@ -364,7 +378,7 @@ static int open_variant(AppleHTTPContext *c, struct variant *var, int skip)
}
if (c->cur_seq_no - var->start_seq_no >= var->n_segments)
return c->finished ? AVERROR_EOF : 0;
- ret = url_fopen(&var->pb,
+ ret = avio_open(&var->pb,
var->segments[c->cur_seq_no - var->start_seq_no]->url,
URL_RDONLY);
if (ret < 0)
@@ -421,7 +435,7 @@ static int applehttp_read_packet(AVFormatContext *s, AVPacket *pkt)
"Closing variant stream %d, no longer needed\n", i);
av_free_packet(&var->pkt);
reset_packet(&var->pkt);
- url_fclose(var->pb);
+ avio_close(var->pb);
var->pb = NULL;
changed = 1;
} else if (!var->pb && var->needed) {
@@ -470,7 +484,7 @@ static int applehttp_read_packet(AVFormatContext *s, AVPacket *pkt)
for (i = 0; i < c->n_variants; i++) {
struct variant *var = c->variants[i];
if (var->pb) {
- url_fclose(var->pb);
+ avio_close(var->pb);
var->pb = NULL;
}
}
@@ -544,7 +558,7 @@ static int applehttp_read_seek(AVFormatContext *s, int stream_index,
for (i = 0; i < c->n_variants; i++) {
struct variant *var = c->variants[i];
if (var->pb) {
- url_fclose(var->pb);
+ avio_close(var->pb);
var->pb = NULL;
}
av_free_packet(&var->pkt);
diff --git a/mplayer/ffmpeg/libavformat/asf.c b/mplayer/ffmpeg/libavformat/asf.c
index e6659923..1f6af18b 100644
--- a/mplayer/ffmpeg/libavformat/asf.c
+++ b/mplayer/ffmpeg/libavformat/asf.c
@@ -153,6 +153,8 @@ const AVMetadataConv ff_asf_metadata_conv[] = {
{ "WM/Tool" , "encoder" },
{ "WM/TrackNumber" , "track" },
{ "WM/Track" , "track" },
+ { "WM/MediaStationCallSign", "service_provider" },
+ { "WM/MediaStationName", "service_name" },
// { "Year" , "date" }, TODO: conversion year<->date
{ 0 }
};
diff --git a/mplayer/ffmpeg/libavformat/asf.h b/mplayer/ffmpeg/libavformat/asf.h
index f336c43f..94c93d2c 100644
--- a/mplayer/ffmpeg/libavformat/asf.h
+++ b/mplayer/ffmpeg/libavformat/asf.h
@@ -79,64 +79,6 @@ typedef struct {
uint16_t packet_count;
} ASFIndex;
-
-typedef struct {
- uint32_t seqno;
- int is_streamed;
- int asfid2avid[128]; ///< conversion table from asf ID 2 AVStream ID
- ASFStream streams[128]; ///< it's max number and it's not that big
- uint32_t stream_bitrates[128]; ///< max number of streams, bitrate for each (for streaming)
- char stream_languages[128][6]; ///< max number of streams, language for each (RFC1766, e.g. en-US)
- /* non streamed additonnal info */
- uint64_t nb_packets; ///< how many packets are there in the file, invalid if broadcasting
- int64_t duration; ///< in 100ns units
- /* packet filling */
- unsigned char multi_payloads_present;
- int packet_size_left;
- int packet_timestamp_start;
- int packet_timestamp_end;
- unsigned int packet_nb_payloads;
- int packet_nb_frames;
- uint8_t packet_buf[PACKET_SIZE];
- ByteIOContext pb;
- /* only for reading */
- uint64_t data_offset; ///< beginning of the first data packet
- uint64_t data_object_offset; ///< data object offset (excl. GUID & size)
- uint64_t data_object_size; ///< size of the data object
- int index_read;
-
- ASFMainHeader hdr;
-
- int packet_flags;
- int packet_property;
- int packet_timestamp;
- int packet_segsizetype;
- int packet_segments;
- int packet_seq;
- int packet_replic_size;
- int packet_key_frame;
- int packet_padsize;
- unsigned int packet_frag_offset;
- unsigned int packet_frag_size;
- int64_t packet_frag_timestamp;
- int packet_multi_size;
- int packet_obj_size;
- int packet_time_delta;
- int packet_time_start;
- int64_t packet_pos;
-
- int stream_index;
-
-
- int64_t last_indexed_pts;
- ASFIndex* index_ptr;
- uint32_t nb_index_count;
- uint32_t nb_index_memory_alloc;
- uint16_t maximum_packet;
-
- ASFStream* asf_st; ///< currently decoded stream
-} ASFContext;
-
extern const ff_asf_guid ff_asf_header;
extern const ff_asf_guid ff_asf_file_header;
extern const ff_asf_guid ff_asf_stream_header;
@@ -230,7 +172,12 @@ extern const AVMetadataConv ff_asf_metadata_conv[];
#define ASF_PL_FLAG_KEY_FRAME 0x80 //1000 0000
extern AVInputFormat ff_asf_demuxer;
-int ff_guidcmp(const void *g1, const void *g2);
-void ff_get_guid(ByteIOContext *s, ff_asf_guid *g);
+
+static av_always_inline int ff_guidcmp(const void *g1, const void *g2)
+{
+ return memcmp(g1, g2, sizeof(ff_asf_guid));
+}
+
+void ff_get_guid(AVIOContext *s, ff_asf_guid *g);
#endif /* AVFORMAT_ASF_H */
diff --git a/mplayer/ffmpeg/libavformat/asfdec.c b/mplayer/ffmpeg/libavformat/asfdec.c
index 35e892c4..85761a3f 100644
--- a/mplayer/ffmpeg/libavformat/asfdec.c
+++ b/mplayer/ffmpeg/libavformat/asfdec.c
@@ -32,6 +32,46 @@
void ff_mms_set_stream_selection(URLContext *h, AVFormatContext *format);
+typedef struct {
+ int asfid2avid[128]; ///< conversion table from asf ID 2 AVStream ID
+ ASFStream streams[128]; ///< it's max number and it's not that big
+ uint32_t stream_bitrates[128]; ///< max number of streams, bitrate for each (for streaming)
+ AVRational dar[128];
+ char stream_languages[128][6]; ///< max number of streams, language for each (RFC1766, e.g. en-US)
+ /* non streamed additonnal info */
+ /* packet filling */
+ int packet_size_left;
+ /* only for reading */
+ uint64_t data_offset; ///< beginning of the first data packet
+ uint64_t data_object_offset; ///< data object offset (excl. GUID & size)
+ uint64_t data_object_size; ///< size of the data object
+ int index_read;
+
+ ASFMainHeader hdr;
+
+ int packet_flags;
+ int packet_property;
+ int packet_timestamp;
+ int packet_segsizetype;
+ int packet_segments;
+ int packet_seq;
+ int packet_replic_size;
+ int packet_key_frame;
+ int packet_padsize;
+ unsigned int packet_frag_offset;
+ unsigned int packet_frag_size;
+ int64_t packet_frag_timestamp;
+ int packet_multi_size;
+ int packet_obj_size;
+ int packet_time_delta;
+ int packet_time_start;
+ int64_t packet_pos;
+
+ int stream_index;
+
+ ASFStream* asf_st; ///< currently decoded stream
+} ASFContext;
+
#undef NDEBUG
#include
@@ -49,11 +89,6 @@ static const ff_asf_guid stream_bitrate_guid = { /* (http://get.to/sdp) */
/**********************************/
/* decoding */
-int ff_guidcmp(const void *g1, const void *g2)
-{
- return memcmp(g1, g2, sizeof(ff_asf_guid));
-}
-
#ifdef DEBUG
#define PRINT_IF_GUID(g,cmp) \
if (!ff_guidcmp(g, &cmp)) \
@@ -97,10 +132,10 @@ static void print_guid(const ff_asf_guid *g)
#define print_guid(g)
#endif
-void ff_get_guid(ByteIOContext *s, ff_asf_guid *g)
+void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
{
assert(sizeof(*g) == 16);
- get_buffer(s, *g, sizeof(*g));
+ avio_read(s, *g, sizeof(*g));
}
static int asf_probe(AVProbeData *pd)
@@ -112,12 +147,12 @@ static int asf_probe(AVProbeData *pd)
return 0;
}
-static int get_value(ByteIOContext *pb, int type){
+static int get_value(AVIOContext *pb, int type){
switch(type){
- case 2: return get_le32(pb);
- case 3: return get_le32(pb);
- case 4: return get_le64(pb);
- case 5: return get_le16(pb);
+ case 2: return avio_rl32(pb);
+ case 3: return avio_rl32(pb);
+ case 4: return avio_rl64(pb);
+ case 5: return avio_rl16(pb);
default:return INT_MIN;
}
}
@@ -143,40 +178,426 @@ static void get_tag(AVFormatContext *s, const char *key, int type, int len)
av_log(s, AV_LOG_DEBUG, "Unsupported value type %d in tag %s.\n", type, key);
goto finish;
}
- av_metadata_set2(&s->metadata, key, value, 0);
+ if (*value)
+ av_metadata_set2(&s->metadata, key, value, 0);
finish:
av_freep(&value);
- url_fseek(s->pb, off + len, SEEK_SET);
+ avio_seek(s->pb, off + len, SEEK_SET);
}
-static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
+static int asf_read_file_properties(AVFormatContext *s, int64_t size)
{
ASFContext *asf = s->priv_data;
- ff_asf_guid g;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
+
+ ff_get_guid(pb, &asf->hdr.guid);
+ asf->hdr.file_size = avio_rl64(pb);
+ asf->hdr.create_time = avio_rl64(pb);
+ avio_rl64(pb); /* number of packets */
+ asf->hdr.play_time = avio_rl64(pb);
+ asf->hdr.send_time = avio_rl64(pb);
+ asf->hdr.preroll = avio_rl32(pb);
+ asf->hdr.ignore = avio_rl32(pb);
+ asf->hdr.flags = avio_rl32(pb);
+ asf->hdr.min_pktsize = avio_rl32(pb);
+ asf->hdr.max_pktsize = avio_rl32(pb);
+ asf->hdr.max_bitrate = avio_rl32(pb);
+ s->packet_size = asf->hdr.max_pktsize;
+
+ return 0;
+}
+
+static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
+{
+ ASFContext *asf = s->priv_data;
+ AVIOContext *pb = s->pb;
AVStream *st;
ASFStream *asf_st;
- int size, i;
- int64_t gsize;
- AVRational dar[128];
- uint32_t bitrate[128];
+ ff_asf_guid g;
+ enum AVMediaType type;
+ int type_specific_size, sizeX;
+ uint64_t total_size;
+ unsigned int tag1;
+ int64_t pos1, pos2, start_time;
+ int test_for_ext_stream_audio, is_dvr_ms_audio=0;
+
+ if (s->nb_streams == ASF_MAX_STREAMS) {
+ av_log(s, AV_LOG_ERROR, "too many streams\n");
+ return AVERROR(EINVAL);
+ }
+
+ pos1 = url_ftell(pb);
+
+ st = av_new_stream(s, 0);
+ if (!st)
+ return AVERROR(ENOMEM);
+ av_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
+ asf_st = av_mallocz(sizeof(ASFStream));
+ if (!asf_st)
+ return AVERROR(ENOMEM);
+ st->priv_data = asf_st;
+ start_time = asf->hdr.preroll;
+
+ asf_st->stream_language_index = 128; // invalid stream index means no language info
+
+ if(!(asf->hdr.flags & 0x01)) { // if we aren't streaming...
+ st->duration = asf->hdr.play_time /
+ (10000000 / 1000) - start_time;
+ }
+ ff_get_guid(pb, &g);
+
+ test_for_ext_stream_audio = 0;
+ if (!ff_guidcmp(&g, &ff_asf_audio_stream)) {
+ type = AVMEDIA_TYPE_AUDIO;
+ } else if (!ff_guidcmp(&g, &ff_asf_video_stream)) {
+ type = AVMEDIA_TYPE_VIDEO;
+ } else if (!ff_guidcmp(&g, &ff_asf_jfif_media)) {
+ type = AVMEDIA_TYPE_VIDEO;
+ st->codec->codec_id = CODEC_ID_MJPEG;
+ } else if (!ff_guidcmp(&g, &ff_asf_command_stream)) {
+ type = AVMEDIA_TYPE_DATA;
+ } else if (!ff_guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) {
+ test_for_ext_stream_audio = 1;
+ type = AVMEDIA_TYPE_UNKNOWN;
+ } else {
+ return -1;
+ }
+ ff_get_guid(pb, &g);
+ total_size = avio_rl64(pb);
+ type_specific_size = avio_rl32(pb);
+ avio_rl32(pb);
+ st->id = avio_rl16(pb) & 0x7f; /* stream id */
+ // mapping of asf ID to AV stream ID;
+ asf->asfid2avid[st->id] = s->nb_streams - 1;
+
+ avio_rl32(pb);
+
+ if (test_for_ext_stream_audio) {
+ ff_get_guid(pb, &g);
+ if (!ff_guidcmp(&g, &ff_asf_ext_stream_audio_stream)) {
+ type = AVMEDIA_TYPE_AUDIO;
+ is_dvr_ms_audio=1;
+ ff_get_guid(pb, &g);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ ff_get_guid(pb, &g);
+ avio_rl32(pb);
+ }
+ }
+
+ st->codec->codec_type = type;
+ if (type == AVMEDIA_TYPE_AUDIO) {
+ ff_get_wav_header(pb, st->codec, type_specific_size);
+ if (is_dvr_ms_audio) {
+ // codec_id and codec_tag are unreliable in dvr_ms
+ // files. Set them later by probing stream.
+ st->codec->codec_id = CODEC_ID_PROBE;
+ st->codec->codec_tag = 0;
+ }
+ if (st->codec->codec_id == CODEC_ID_AAC) {
+ st->need_parsing = AVSTREAM_PARSE_NONE;
+ } else {
+ st->need_parsing = AVSTREAM_PARSE_FULL;
+ }
+ /* We have to init the frame size at some point .... */
+ pos2 = url_ftell(pb);
+ if (size >= (pos2 + 8 - pos1 + 24)) {
+ asf_st->ds_span = avio_r8(pb);
+ asf_st->ds_packet_size = avio_rl16(pb);
+ asf_st->ds_chunk_size = avio_rl16(pb);
+ avio_rl16(pb); //ds_data_size
+ avio_r8(pb); //ds_silence_data
+ }
+ //printf("Descrambling: ps:%d cs:%d ds:%d s:%d sd:%d\n",
+ // asf_st->ds_packet_size, asf_st->ds_chunk_size,
+ // asf_st->ds_data_size, asf_st->ds_span, asf_st->ds_silence_data);
+ if (asf_st->ds_span > 1) {
+ if (!asf_st->ds_chunk_size
+ || (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1)
+ || asf_st->ds_packet_size % asf_st->ds_chunk_size)
+ asf_st->ds_span = 0; // disable descrambling
+ }
+ switch (st->codec->codec_id) {
+ case CODEC_ID_MP3:
+ st->codec->frame_size = MPA_FRAME_SIZE;
+ break;
+ case CODEC_ID_PCM_S16LE:
+ case CODEC_ID_PCM_S16BE:
+ case CODEC_ID_PCM_U16LE:
+ case CODEC_ID_PCM_U16BE:
+ case CODEC_ID_PCM_S8:
+ case CODEC_ID_PCM_U8:
+ case CODEC_ID_PCM_ALAW:
+ case CODEC_ID_PCM_MULAW:
+ st->codec->frame_size = 1;
+ break;
+ default:
+ /* This is probably wrong, but it prevents a crash later */
+ st->codec->frame_size = 1;
+ break;
+ }
+ } else if (type == AVMEDIA_TYPE_VIDEO &&
+ size - (url_ftell(pb) - pos1 + 24) >= 51) {
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_r8(pb);
+ avio_rl16(pb); /* size */
+ sizeX= avio_rl32(pb); /* size */
+ st->codec->width = avio_rl32(pb);
+ st->codec->height = avio_rl32(pb);
+ /* not available for asf */
+ avio_rl16(pb); /* panes */
+ st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */
+ tag1 = avio_rl32(pb);
+ avio_seek(pb, 20, SEEK_CUR);
+ // av_log(s, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX);
+ if (sizeX > 40) {
+ st->codec->extradata_size = sizeX - 40;
+ st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ avio_read(pb, st->codec->extradata, st->codec->extradata_size);
+ }
+
+ /* Extract palette from extradata if bpp <= 8 */
+ /* This code assumes that extradata contains only palette */
+ /* This is true for all paletted codecs implemented in ffmpeg */
+ if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) {
+ int av_unused i;
+ st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl));
+#if HAVE_BIGENDIAN
+ for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++)
+ st->codec->palctrl->palette[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]);
+#else
+ memcpy(st->codec->palctrl->palette, st->codec->extradata,
+ FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
+#endif
+ st->codec->palctrl->palette_changed = 1;
+ }
+
+ st->codec->codec_tag = tag1;
+ st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1);
+ if(tag1 == MKTAG('D', 'V', 'R', ' ')){
+ st->need_parsing = AVSTREAM_PARSE_FULL;
+ // issue658 containse wrong w/h and MS even puts a fake seq header with wrong w/h in extradata while a correct one is in te stream. maximum lameness
+ st->codec->width =
+ st->codec->height = 0;
+ av_freep(&st->codec->extradata);
+ st->codec->extradata_size=0;
+ }
+ if(st->codec->codec_id == CODEC_ID_H264)
+ st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
+ }
+ pos2 = url_ftell(pb);
+ avio_seek(pb, size - (pos2 - pos1 + 24), SEEK_CUR);
+
+ return 0;
+}
+
+static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size)
+{
+ ASFContext *asf = s->priv_data;
+ AVIOContext *pb = s->pb;
+ ff_asf_guid g;
+ int ext_len, payload_ext_ct, stream_ct, i;
+ uint32_t ext_d, leak_rate, stream_num;
+ unsigned int stream_languageid_index;
+
+ avio_rl64(pb); // starttime
+ avio_rl64(pb); // endtime
+ leak_rate = avio_rl32(pb); // leak-datarate
+ avio_rl32(pb); // bucket-datasize
+ avio_rl32(pb); // init-bucket-fullness
+ avio_rl32(pb); // alt-leak-datarate
+ avio_rl32(pb); // alt-bucket-datasize
+ avio_rl32(pb); // alt-init-bucket-fullness
+ avio_rl32(pb); // max-object-size
+ avio_rl32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved)
+ stream_num = avio_rl16(pb); // stream-num
+
+ stream_languageid_index = avio_rl16(pb); // stream-language-id-index
+ if (stream_num < 128)
+ asf->streams[stream_num].stream_language_index = stream_languageid_index;
+
+ avio_rl64(pb); // avg frametime in 100ns units
+ stream_ct = avio_rl16(pb); //stream-name-count
+ payload_ext_ct = avio_rl16(pb); //payload-extension-system-count
+
+ if (stream_num < 128)
+ asf->stream_bitrates[stream_num] = leak_rate;
+
+ for (i=0; ipb;
+ int len1, len2, len3, len4, len5;
+
+ len1 = avio_rl16(pb);
+ len2 = avio_rl16(pb);
+ len3 = avio_rl16(pb);
+ len4 = avio_rl16(pb);
+ len5 = avio_rl16(pb);
+ get_tag(s, "title" , 0, len1);
+ get_tag(s, "author" , 0, len2);
+ get_tag(s, "copyright", 0, len3);
+ get_tag(s, "comment" , 0, len4);
+ avio_seek(pb, len5, SEEK_CUR);
+
+ return 0;
+}
+
+static int asf_read_ext_content_desc(AVFormatContext *s, int64_t size)
+{
+ AVIOContext *pb = s->pb;
+ ASFContext *asf = s->priv_data;
+ int desc_count, i, ret;
+
+ desc_count = avio_rl16(pb);
+ for(i=0;idar[0].num= get_value(s->pb, value_type);
+ } else if(!strcmp(name, "AspectRatioY")){
+ asf->dar[0].den= get_value(s->pb, value_type);
+ } else
+ get_tag(s, name, value_type, value_len);
+ }
+
+ return 0;
+}
- memset(dar, 0, sizeof(dar));
- memset(bitrate, 0, sizeof(bitrate));
+static int asf_read_language_list(AVFormatContext *s, int64_t size)
+{
+ AVIOContext *pb = s->pb;
+ ASFContext *asf = s->priv_data;
+ int j, ret;
+ int stream_count = avio_rl16(pb);
+ for(j = 0; j < stream_count; j++) {
+ char lang[6];
+ unsigned int lang_len = avio_r8(pb);
+ if ((ret = avio_get_str16le(pb, lang_len, lang, sizeof(lang))) < lang_len)
+ avio_seek(pb, lang_len - ret, SEEK_CUR);
+ if (j < 128)
+ av_strlcpy(asf->stream_languages[j], lang, sizeof(*asf->stream_languages));
+ }
+
+ return 0;
+}
+
+static int asf_read_metadata(AVFormatContext *s, int64_t size)
+{
+ AVIOContext *pb = s->pb;
+ ASFContext *asf = s->priv_data;
+ int n, stream_num, name_len, value_len, value_type, value_num;
+ int ret, i;
+ n = avio_rl16(pb);
+
+ for(i=0;i\n", i, stream_num, name_len, value_type, value_len, name);
+ value_num= avio_rl16(pb);//we should use get_value() here but it does not work 2 is le16 here but le32 elsewhere
+ avio_seek(pb, value_len - 2, SEEK_CUR);
+
+ if(stream_num<128){
+ if (!strcmp(name, "AspectRatioX")) asf->dar[stream_num].num= value_num;
+ else if(!strcmp(name, "AspectRatioY")) asf->dar[stream_num].den= value_num;
+ }
+ }
+
+ return 0;
+}
+
+static int asf_read_marker(AVFormatContext *s, int64_t size)
+{
+ AVIOContext *pb = s->pb;
+ int i, count, name_len, ret;
+ char name[1024];
+
+ avio_rl64(pb); // reserved 16 bytes
+ avio_rl64(pb); // ...
+ count = avio_rl32(pb); // markers count
+ avio_rl16(pb); // reserved 2 bytes
+ name_len = avio_rl16(pb); // name length
+ for(i=0;ipriv_data;
+ ff_asf_guid g;
+ AVIOContext *pb = s->pb;
+ int i;
+ int64_t gsize;
ff_get_guid(pb, &g);
if (ff_guidcmp(&g, &ff_asf_header))
return -1;
- get_le64(pb);
- get_le32(pb);
- get_byte(pb);
- get_byte(pb);
+ avio_rl64(pb);
+ avio_rl32(pb);
+ avio_r8(pb);
+ avio_r8(pb);
memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid));
for(;;) {
uint64_t gpos= url_ftell(pb);
- int ret;
ff_get_guid(pb, &g);
- gsize = get_le64(pb);
+ gsize = avio_rl64(pb);
av_dlog(s, "%08"PRIx64": ", gpos);
print_guid(&g);
av_dlog(s, " size=0x%"PRIx64"\n", gsize);
@@ -193,326 +614,19 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (gsize < 24)
return -1;
if (!ff_guidcmp(&g, &ff_asf_file_header)) {
- ff_get_guid(pb, &asf->hdr.guid);
- asf->hdr.file_size = get_le64(pb);
- asf->hdr.create_time = get_le64(pb);
- asf->nb_packets = get_le64(pb);
- asf->hdr.play_time = get_le64(pb);
- asf->hdr.send_time = get_le64(pb);
- asf->hdr.preroll = get_le32(pb);
- asf->hdr.ignore = get_le32(pb);
- asf->hdr.flags = get_le32(pb);
- asf->hdr.min_pktsize = get_le32(pb);
- asf->hdr.max_pktsize = get_le32(pb);
- asf->hdr.max_bitrate = get_le32(pb);
- s->packet_size = asf->hdr.max_pktsize;
+ asf_read_file_properties(s, gsize);
} else if (!ff_guidcmp(&g, &ff_asf_stream_header)) {
- enum AVMediaType type;
- int type_specific_size, sizeX;
- uint64_t total_size;
- unsigned int tag1;
- int64_t pos1, pos2, start_time;
- int test_for_ext_stream_audio, is_dvr_ms_audio=0;
-
- if (s->nb_streams == ASF_MAX_STREAMS) {
- av_log(s, AV_LOG_ERROR, "too many streams\n");
- return AVERROR(EINVAL);
- }
-
- pos1 = url_ftell(pb);
-
- st = av_new_stream(s, 0);
- if (!st)
- return AVERROR(ENOMEM);
- av_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
- asf_st = av_mallocz(sizeof(ASFStream));
- if (!asf_st)
- return AVERROR(ENOMEM);
- st->priv_data = asf_st;
- start_time = asf->hdr.preroll;
-
- asf_st->stream_language_index = 128; // invalid stream index means no language info
-
- if(!(asf->hdr.flags & 0x01)) { // if we aren't streaming...
- st->duration = asf->hdr.play_time /
- (10000000 / 1000) - start_time;
- }
- ff_get_guid(pb, &g);
-
- test_for_ext_stream_audio = 0;
- if (!ff_guidcmp(&g, &ff_asf_audio_stream)) {
- type = AVMEDIA_TYPE_AUDIO;
- } else if (!ff_guidcmp(&g, &ff_asf_video_stream)) {
- type = AVMEDIA_TYPE_VIDEO;
- } else if (!ff_guidcmp(&g, &ff_asf_jfif_media)) {
- type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = CODEC_ID_MJPEG;
- } else if (!ff_guidcmp(&g, &ff_asf_command_stream)) {
- type = AVMEDIA_TYPE_DATA;
- } else if (!ff_guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) {
- test_for_ext_stream_audio = 1;
- type = AVMEDIA_TYPE_UNKNOWN;
- } else {
- return -1;
- }
- ff_get_guid(pb, &g);
- total_size = get_le64(pb);
- type_specific_size = get_le32(pb);
- get_le32(pb);
- st->id = get_le16(pb) & 0x7f; /* stream id */
- // mapping of asf ID to AV stream ID;
- asf->asfid2avid[st->id] = s->nb_streams - 1;
-
- get_le32(pb);
-
- if (test_for_ext_stream_audio) {
- ff_get_guid(pb, &g);
- if (!ff_guidcmp(&g, &ff_asf_ext_stream_audio_stream)) {
- type = AVMEDIA_TYPE_AUDIO;
- is_dvr_ms_audio=1;
- ff_get_guid(pb, &g);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- ff_get_guid(pb, &g);
- get_le32(pb);
- }
- }
-
- st->codec->codec_type = type;
- if (type == AVMEDIA_TYPE_AUDIO) {
- ff_get_wav_header(pb, st->codec, type_specific_size);
- if (is_dvr_ms_audio) {
- // codec_id and codec_tag are unreliable in dvr_ms
- // files. Set them later by probing stream.
- st->codec->codec_id = CODEC_ID_PROBE;
- st->codec->codec_tag = 0;
- }
- if (st->codec->codec_id == CODEC_ID_AAC) {
- st->need_parsing = AVSTREAM_PARSE_NONE;
- } else {
- st->need_parsing = AVSTREAM_PARSE_FULL;
- }
- /* We have to init the frame size at some point .... */
- pos2 = url_ftell(pb);
- if (gsize >= (pos2 + 8 - pos1 + 24)) {
- asf_st->ds_span = get_byte(pb);
- asf_st->ds_packet_size = get_le16(pb);
- asf_st->ds_chunk_size = get_le16(pb);
- get_le16(pb); //ds_data_size
- get_byte(pb); //ds_silence_data
- }
- //printf("Descrambling: ps:%d cs:%d ds:%d s:%d sd:%d\n",
- // asf_st->ds_packet_size, asf_st->ds_chunk_size,
- // asf_st->ds_data_size, asf_st->ds_span, asf_st->ds_silence_data);
- if (asf_st->ds_span > 1) {
- if (!asf_st->ds_chunk_size
- || (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1)
- || asf_st->ds_packet_size % asf_st->ds_chunk_size)
- asf_st->ds_span = 0; // disable descrambling
- }
- switch (st->codec->codec_id) {
- case CODEC_ID_MP3:
- st->codec->frame_size = MPA_FRAME_SIZE;
- break;
- case CODEC_ID_PCM_S16LE:
- case CODEC_ID_PCM_S16BE:
- case CODEC_ID_PCM_U16LE:
- case CODEC_ID_PCM_U16BE:
- case CODEC_ID_PCM_S8:
- case CODEC_ID_PCM_U8:
- case CODEC_ID_PCM_ALAW:
- case CODEC_ID_PCM_MULAW:
- st->codec->frame_size = 1;
- break;
- default:
- /* This is probably wrong, but it prevents a crash later */
- st->codec->frame_size = 1;
- break;
- }
- } else if (type == AVMEDIA_TYPE_VIDEO &&
- gsize - (url_ftell(pb) - pos1 + 24) >= 51) {
- get_le32(pb);
- get_le32(pb);
- get_byte(pb);
- size = get_le16(pb); /* size */
- sizeX= get_le32(pb); /* size */
- st->codec->width = get_le32(pb);
- st->codec->height = get_le32(pb);
- /* not available for asf */
- get_le16(pb); /* panes */
- st->codec->bits_per_coded_sample = get_le16(pb); /* depth */
- tag1 = get_le32(pb);
- url_fskip(pb, 20);
-// av_log(s, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX);
- size= sizeX;
- if (size > 40) {
- st->codec->extradata_size = size - 40;
- st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
- }
-
- /* Extract palette from extradata if bpp <= 8 */
- /* This code assumes that extradata contains only palette */
- /* This is true for all paletted codecs implemented in ffmpeg */
- if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) {
- st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl));
-#if HAVE_BIGENDIAN
- for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++)
- st->codec->palctrl->palette[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]);
-#else
- memcpy(st->codec->palctrl->palette, st->codec->extradata,
- FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
-#endif
- st->codec->palctrl->palette_changed = 1;
- }
-
- st->codec->codec_tag = tag1;
- st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1);
- if(tag1 == MKTAG('D', 'V', 'R', ' ')){
- st->need_parsing = AVSTREAM_PARSE_FULL;
- // issue658 containse wrong w/h and MS even puts a fake seq header with wrong w/h in extradata while a correct one is in te stream. maximum lameness
- st->codec->width =
- st->codec->height = 0;
- av_freep(&st->codec->extradata);
- st->codec->extradata_size=0;
- }
- if(st->codec->codec_id == CODEC_ID_H264)
- st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
- }
- pos2 = url_ftell(pb);
- url_fskip(pb, gsize - (pos2 - pos1 + 24));
+ asf_read_stream_properties(s, gsize);
} else if (!ff_guidcmp(&g, &ff_asf_comment_header)) {
- int len1, len2, len3, len4, len5;
-
- len1 = get_le16(pb);
- len2 = get_le16(pb);
- len3 = get_le16(pb);
- len4 = get_le16(pb);
- len5 = get_le16(pb);
- get_tag(s, "title" , 0, len1);
- get_tag(s, "author" , 0, len2);
- get_tag(s, "copyright", 0, len3);
- get_tag(s, "comment" , 0, len4);
- url_fskip(pb, len5);
- } else if (!ff_guidcmp(&g, &stream_bitrate_guid)) {
- int stream_count = get_le16(pb);
- int j;
-
-// av_log(s, AV_LOG_ERROR, "stream bitrate properties\n");
-// av_log(s, AV_LOG_ERROR, "streams %d\n", streams);
- for(j = 0; j < stream_count; j++) {
- int flags, bitrate, stream_id;
-
- flags= get_le16(pb);
- bitrate= get_le32(pb);
- stream_id= (flags & 0x7f);
-// av_log(s, AV_LOG_ERROR, "flags: 0x%x stream id %d, bitrate %d\n", flags, stream_id, bitrate);
- asf->stream_bitrates[stream_id]= bitrate;
- }
+ asf_read_content_desc(s, gsize);
} else if (!ff_guidcmp(&g, &ff_asf_language_guid)) {
- int j;
- int stream_count = get_le16(pb);
- for(j = 0; j < stream_count; j++) {
- char lang[6];
- unsigned int lang_len = get_byte(pb);
- if ((ret = avio_get_str16le(pb, lang_len, lang, sizeof(lang))) < lang_len)
- url_fskip(pb, lang_len - ret);
- if (j < 128)
- av_strlcpy(asf->stream_languages[j], lang, sizeof(*asf->stream_languages));
- }
+ asf_read_language_list(s, gsize);
} else if (!ff_guidcmp(&g, &ff_asf_extended_content_header)) {
- int desc_count, i;
-
- desc_count = get_le16(pb);
- for(i=0;ipb, value_type);
- } else if(!strcmp(name, "AspectRatioY")){
- dar[0].den= get_value(s->pb, value_type);
- } else
- get_tag(s, name, value_type, value_len);
- }
+ asf_read_ext_content_desc(s, gsize);
} else if (!ff_guidcmp(&g, &ff_asf_metadata_header)) {
- int n, stream_num, name_len, value_len, value_type, value_num;
- n = get_le16(pb);
-
- for(i=0;i\n", i, stream_num, name_len, value_type, value_len, name);
- value_num= get_le16(pb);//we should use get_value() here but it does not work 2 is le16 here but le32 elsewhere
- url_fskip(pb, value_len - 2);
-
- if(stream_num<128){
- if (!strcmp(name, "AspectRatioX")) dar[stream_num].num= value_num;
- else if(!strcmp(name, "AspectRatioY")) dar[stream_num].den= value_num;
- }
- }
+ asf_read_metadata(s, gsize);
} else if (!ff_guidcmp(&g, &ff_asf_ext_stream_header)) {
- int ext_len, payload_ext_ct, stream_ct;
- uint32_t ext_d, leak_rate, stream_num;
- unsigned int stream_languageid_index;
-
- get_le64(pb); // starttime
- get_le64(pb); // endtime
- leak_rate = get_le32(pb); // leak-datarate
- get_le32(pb); // bucket-datasize
- get_le32(pb); // init-bucket-fullness
- get_le32(pb); // alt-leak-datarate
- get_le32(pb); // alt-bucket-datasize
- get_le32(pb); // alt-init-bucket-fullness
- get_le32(pb); // max-object-size
- get_le32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved)
- stream_num = get_le16(pb); // stream-num
-
- stream_languageid_index = get_le16(pb); // stream-language-id-index
- if (stream_num < 128)
- asf->streams[stream_num].stream_language_index = stream_languageid_index;
-
- get_le64(pb); // avg frametime in 100ns units
- stream_ct = get_le16(pb); //stream-name-count
- payload_ext_ct = get_le16(pb); //payload-extension-system-count
-
- if (stream_num < 128)
- bitrate[stream_num] = leak_rate;
-
- for (i=0; idata_offset = url_ftell(pb);
@@ -582,15 +671,15 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
if(stream_num>=0){
AVStream *st = s->streams[stream_num];
if (!st->codec->bit_rate)
- st->codec->bit_rate = bitrate[i];
- if (dar[i].num > 0 && dar[i].den > 0){
+ st->codec->bit_rate = asf->stream_bitrates[i];
+ if (asf->dar[i].num > 0 && asf->dar[i].den > 0){
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
- dar[i].num, dar[i].den, INT_MAX);
- } else if ((dar[0].num > 0) && (dar[0].den > 0) && (st->codec->codec_type==AVMEDIA_TYPE_VIDEO)) // Use ASF container value if the stream doesn't AR set.
+ asf->dar[i].num, asf->dar[i].den, INT_MAX);
+ } else if ((asf->dar[0].num > 0) && (asf->dar[0].den > 0) && (st->codec->codec_type==AVMEDIA_TYPE_VIDEO)) // Use ASF container value if the stream doesn't AR set.
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
- dar[0].num, dar[0].den, INT_MAX);
+ asf->dar[0].num, asf->dar[0].den, INT_MAX);
//av_log(s, AV_LOG_INFO, "i=%d, st->codec->codec_type:%d, dar %d:%d sar=%d:%d\n", i, st->codec->codec_type, dar[i].num, dar[i].den, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
@@ -615,9 +704,9 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
#define DO_2BITS(bits, var, defval) \
switch (bits & 3) \
{ \
- case 3: var = get_le32(pb); rsize += 4; break; \
- case 2: var = get_le16(pb); rsize += 2; break; \
- case 1: var = get_byte(pb); rsize++; break; \
+ case 3: var = avio_rl32(pb); rsize += 4; break; \
+ case 2: var = avio_rl16(pb); rsize += 2; break; \
+ case 1: var = avio_r8(pb); rsize++; break; \
default: var = defval; break; \
}
@@ -627,7 +716,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
* @param pb context to read data from
* @return 0 on success, <0 on error
*/
-static int ff_asf_get_packet(AVFormatContext *s, ByteIOContext *pb)
+static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
{
ASFContext *asf = s->priv_data;
uint32_t packet_length, padsize;
@@ -642,7 +731,7 @@ static int ff_asf_get_packet(AVFormatContext *s, ByteIOContext *pb)
c=d=e=-1;
while(off-- > 0){
c=d; d=e;
- e= get_byte(pb);
+ e= avio_r8(pb);
if(c == 0x82 && !d && !e)
break;
}
@@ -665,11 +754,11 @@ static int ff_asf_get_packet(AVFormatContext *s, ByteIOContext *pb)
av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
return -1;
}
- c= get_byte(pb);
- d= get_byte(pb);
+ c= avio_r8(pb);
+ d= avio_r8(pb);
rsize+=3;
}else{
- url_fseek(pb, -1, SEEK_CUR); //FIXME
+ avio_seek(pb, -1, SEEK_CUR); //FIXME
}
asf->packet_flags = c;
@@ -689,12 +778,12 @@ static int ff_asf_get_packet(AVFormatContext *s, ByteIOContext *pb)
return -1;
}
- asf->packet_timestamp = get_le32(pb);
- get_le16(pb); /* duration */
+ asf->packet_timestamp = avio_rl32(pb);
+ avio_rl16(pb); /* duration */
// rsize has at least 11 bytes which have to be present
if (asf->packet_flags & 0x01) {
- asf->packet_segsizetype = get_byte(pb); rsize++;
+ asf->packet_segsizetype = avio_r8(pb); rsize++;
asf->packet_segments = asf->packet_segsizetype & 0x3f;
} else {
asf->packet_segments = 1;
@@ -712,10 +801,10 @@ static int ff_asf_get_packet(AVFormatContext *s, ByteIOContext *pb)
*
* @return <0 if error
*/
-static int asf_read_frame_header(AVFormatContext *s, ByteIOContext *pb){
+static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){
ASFContext *asf = s->priv_data;
int rsize = 1;
- int num = get_byte(pb);
+ int num = avio_r8(pb);
int64_t ts0, ts1;
asf->packet_segments--;
@@ -727,26 +816,26 @@ static int asf_read_frame_header(AVFormatContext *s, ByteIOContext *pb){
DO_2BITS(asf->packet_property, asf->packet_replic_size, 0);
//printf("key:%d stream:%d seq:%d offset:%d replic_size:%d\n", asf->packet_key_frame, asf->stream_index, asf->packet_seq, //asf->packet_frag_offset, asf->packet_replic_size);
if (asf->packet_replic_size >= 8) {
- asf->packet_obj_size = get_le32(pb);
+ asf->packet_obj_size = avio_rl32(pb);
if(asf->packet_obj_size >= (1<<24) || asf->packet_obj_size <= 0){
av_log(s, AV_LOG_ERROR, "packet_obj_size invalid\n");
return -1;
}
- asf->packet_frag_timestamp = get_le32(pb); // timestamp
+ asf->packet_frag_timestamp = avio_rl32(pb); // timestamp
if(asf->packet_replic_size >= 8+38+4){
// for(i=0; ipacket_replic_size-8; i++)
-// av_log(s, AV_LOG_DEBUG, "%02X ",get_byte(pb));
+// av_log(s, AV_LOG_DEBUG, "%02X ",avio_r8(pb));
// av_log(s, AV_LOG_DEBUG, "\n");
- url_fskip(pb, 10);
- ts0= get_le64(pb);
- ts1= get_le64(pb);
- url_fskip(pb, 12);
- get_le32(pb);
- url_fskip(pb, asf->packet_replic_size - 8 - 38 - 4);
+ avio_seek(pb, 10, SEEK_CUR);
+ ts0= avio_rl64(pb);
+ ts1= avio_rl64(pb);
+ avio_seek(pb, 12, SEEK_CUR);
+ avio_rl32(pb);
+ avio_seek(pb, asf->packet_replic_size - 8 - 38 - 4, SEEK_CUR);
if(ts0!= -1) asf->packet_frag_timestamp= ts0/10000;
else asf->packet_frag_timestamp= AV_NOPTS_VALUE;
}else
- url_fskip(pb, asf->packet_replic_size - 8);
+ avio_seek(pb, asf->packet_replic_size - 8, SEEK_CUR);
rsize += asf->packet_replic_size; // FIXME - check validity
} else if (asf->packet_replic_size==1){
// multipacket - frag_offset is beginning timestamp
@@ -754,7 +843,7 @@ static int asf_read_frame_header(AVFormatContext *s, ByteIOContext *pb){
asf->packet_frag_offset = 0;
asf->packet_frag_timestamp = asf->packet_timestamp;
- asf->packet_time_delta = get_byte(pb);
+ asf->packet_time_delta = avio_r8(pb);
rsize++;
}else if(asf->packet_replic_size!=0){
av_log(s, AV_LOG_ERROR, "unexpected packet_replic_size of %d\n", asf->packet_replic_size);
@@ -791,7 +880,7 @@ static int asf_read_frame_header(AVFormatContext *s, ByteIOContext *pb){
* @return 0 if data was stored in pkt, <0 on error or 1 if more ASF
* packets need to be loaded (through asf_get_packet())
*/
-static int ff_asf_parse_packet(AVFormatContext *s, ByteIOContext *pb, AVPacket *pkt)
+static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
{
ASFContext *asf = s->priv_data;
ASFStream *asf_st = 0;
@@ -806,7 +895,7 @@ static int ff_asf_parse_packet(AVFormatContext *s, ByteIOContext *pb, AVPacket *
//printf("PacketLeftSize:%d Pad:%d Pos:%"PRId64"\n", asf->packet_size_left, asf->packet_padsize, url_ftell(pb));
assert(ret>=0);
/* fail safe */
- url_fskip(pb, ret);
+ avio_seek(pb, ret, SEEK_CUR);
asf->packet_pos= url_ftell(pb);
if (asf->data_object_size != (uint64_t)-1 &&
@@ -825,7 +914,7 @@ static int ff_asf_parse_packet(AVFormatContext *s, ByteIOContext *pb, AVPacket *
) {
asf->packet_time_start = 0;
/* unhandled packet (should not happen) */
- url_fskip(pb, asf->packet_frag_size);
+ avio_seek(pb, asf->packet_frag_size, SEEK_CUR);
asf->packet_size_left -= asf->packet_frag_size;
if(asf->stream_index < 0)
av_log(s, AV_LOG_ERROR, "ff asf skip %d (unknown stream)\n", asf->packet_frag_size);
@@ -839,13 +928,13 @@ static int ff_asf_parse_packet(AVFormatContext *s, ByteIOContext *pb, AVPacket *
// frag_offset is here used as the beginning timestamp
asf->packet_frag_timestamp = asf->packet_time_start;
asf->packet_time_start += asf->packet_time_delta;
- asf->packet_obj_size = asf->packet_frag_size = get_byte(pb);
+ asf->packet_obj_size = asf->packet_frag_size = avio_r8(pb);
asf->packet_size_left--;
asf->packet_multi_size--;
if (asf->packet_multi_size < asf->packet_obj_size)
{
asf->packet_time_start = 0;
- url_fskip(pb, asf->packet_multi_size);
+ avio_seek(pb, asf->packet_multi_size, SEEK_CUR);
asf->packet_size_left -= asf->packet_multi_size;
continue;
}
@@ -899,7 +988,7 @@ static int ff_asf_parse_packet(AVFormatContext *s, ByteIOContext *pb, AVPacket *
continue;
}
- ret = get_buffer(pb, asf_st->pkt.data + asf->packet_frag_offset,
+ ret = avio_read(pb, asf_st->pkt.data + asf->packet_frag_offset,
asf->packet_frag_size);
if (ret != asf->packet_frag_size) {
if (ret < 0 || asf->packet_frag_offset + ret == 0)
@@ -1001,7 +1090,6 @@ static void asf_reset_header(AVFormatContext *s)
ASFStream *asf_st;
int i;
- asf->packet_nb_frames = 0;
asf->packet_size_left = 0;
asf->packet_segments = 0;
asf->packet_flags = 0;
@@ -1058,7 +1146,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos,
if (s->packet_size > 0)
pos= (pos+s->packet_size-1-s->data_offset)/s->packet_size*s->packet_size+ s->data_offset;
*ppos= pos;
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
//printf("asf_read_pts\n");
asf_reset_header(s);
@@ -1100,34 +1188,34 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index)
int64_t current_pos= url_ftell(s->pb);
int i;
- url_fseek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET);
+ avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET);
ff_get_guid(s->pb, &g);
/* the data object can be followed by other top-level objects,
skip them until the simple index object is reached */
while (ff_guidcmp(&g, &index_guid)) {
- int64_t gsize= get_le64(s->pb);
+ int64_t gsize= avio_rl64(s->pb);
if (gsize < 24 || url_feof(s->pb)) {
- url_fseek(s->pb, current_pos, SEEK_SET);
+ avio_seek(s->pb, current_pos, SEEK_SET);
return;
}
- url_fseek(s->pb, gsize-24, SEEK_CUR);
+ avio_seek(s->pb, gsize-24, SEEK_CUR);
ff_get_guid(s->pb, &g);
}
{
int64_t itime, last_pos=-1;
int pct, ict;
- int64_t av_unused gsize= get_le64(s->pb);
+ int64_t av_unused gsize= avio_rl64(s->pb);
ff_get_guid(s->pb, &g);
- itime=get_le64(s->pb);
- pct=get_le32(s->pb);
- ict=get_le32(s->pb);
+ itime=avio_rl64(s->pb);
+ pct=avio_rl32(s->pb);
+ ict=avio_rl32(s->pb);
av_log(s, AV_LOG_DEBUG, "itime:0x%"PRIx64", pct:%d, ict:%d\n",itime,pct,ict);
for (i=0;ipb);
- int pktct =get_le16(s->pb);
+ int pktnum=avio_rl32(s->pb);
+ int pktct =avio_rl16(s->pb);
int64_t pos = s->data_offset + s->packet_size*(int64_t)pktnum;
int64_t index_pts= av_rescale(itime, i, 10000);
@@ -1139,7 +1227,7 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index)
}
asf->index_read= 1;
}
- url_fseek(s->pb, current_pos, SEEK_SET);
+ avio_seek(s->pb, current_pos, SEEK_SET);
}
static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
@@ -1177,7 +1265,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int
// various attempts to find key frame have failed so far
// asf_reset_header(s);
- // url_fseek(s->pb, pos, SEEK_SET);
+ // avio_seek(s->pb, pos, SEEK_SET);
// key_pos = pos;
// for(i=0;i<16;i++){
// pos = url_ftell(s->pb);
@@ -1198,7 +1286,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int
/* do the seek */
av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
}
asf_reset_header(s);
return 0;
diff --git a/mplayer/ffmpeg/libavformat/asfenc.c b/mplayer/ffmpeg/libavformat/asfenc.c
index b8f86356..267f9b3d 100644
--- a/mplayer/ffmpeg/libavformat/asfenc.c
+++ b/mplayer/ffmpeg/libavformat/asfenc.c
@@ -22,6 +22,7 @@
#include "metadata.h"
#include "riff.h"
#include "asf.h"
+#include "avio_internal.h"
#undef NDEBUG
#include
@@ -188,6 +189,31 @@
2*PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
)
+typedef struct {
+ uint32_t seqno;
+ int is_streamed;
+ ASFStream streams[128]; ///< it's max number and it's not that big
+ /* non streamed additonnal info */
+ uint64_t nb_packets; ///< how many packets are there in the file, invalid if broadcasting
+ int64_t duration; ///< in 100ns units
+ /* packet filling */
+ unsigned char multi_payloads_present;
+ int packet_size_left;
+ int packet_timestamp_start;
+ int packet_timestamp_end;
+ unsigned int packet_nb_payloads;
+ uint8_t packet_buf[PACKET_SIZE];
+ AVIOContext pb;
+ /* only for reading */
+ uint64_t data_offset; ///< beginning of the first data packet
+
+ int64_t last_indexed_pts;
+ ASFIndex* index_ptr;
+ uint32_t nb_index_count;
+ uint32_t nb_index_memory_alloc;
+ uint16_t maximum_packet;
+} ASFContext;
+
static const AVCodecTag codec_asf_bmp_tags[] = {
{ CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
{ CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
@@ -197,61 +223,61 @@ static const AVCodecTag codec_asf_bmp_tags[] = {
#define PREROLL_TIME 3100
-static void put_guid(ByteIOContext *s, const ff_asf_guid *g)
+static void put_guid(AVIOContext *s, const ff_asf_guid *g)
{
assert(sizeof(*g) == 16);
- put_buffer(s, *g, sizeof(*g));
+ avio_write(s, *g, sizeof(*g));
}
-static void put_str16(ByteIOContext *s, const char *tag)
+static void put_str16(AVIOContext *s, const char *tag)
{
int len;
uint8_t *pb;
- ByteIOContext *dyn_buf;
+ AVIOContext *dyn_buf;
if (url_open_dyn_buf(&dyn_buf) < 0)
return;
avio_put_str16le(dyn_buf, tag);
len = url_close_dyn_buf(dyn_buf, &pb);
- put_le16(s, len);
- put_buffer(s, pb, len);
+ avio_wl16(s, len);
+ avio_write(s, pb, len);
av_freep(&pb);
}
-static int64_t put_header(ByteIOContext *pb, const ff_asf_guid *g)
+static int64_t put_header(AVIOContext *pb, const ff_asf_guid *g)
{
int64_t pos;
pos = url_ftell(pb);
put_guid(pb, g);
- put_le64(pb, 24);
+ avio_wl64(pb, 24);
return pos;
}
/* update header size */
-static void end_header(ByteIOContext *pb, int64_t pos)
+static void end_header(AVIOContext *pb, int64_t pos)
{
int64_t pos1;
pos1 = url_ftell(pb);
- url_fseek(pb, pos + 16, SEEK_SET);
- put_le64(pb, pos1 - pos);
- url_fseek(pb, pos1, SEEK_SET);
+ avio_seek(pb, pos + 16, SEEK_SET);
+ avio_wl64(pb, pos1 - pos);
+ avio_seek(pb, pos1, SEEK_SET);
}
/* write an asf chunk (only used in streaming case) */
static void put_chunk(AVFormatContext *s, int type, int payload_length, int flags)
{
ASFContext *asf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int length;
length = payload_length + 8;
- put_le16(pb, type);
- put_le16(pb, length); //size
- put_le32(pb, asf->seqno);//sequence number
- put_le16(pb, flags); /* unknown bytes */
- put_le16(pb, length); //size_confirm
+ avio_wl16(pb, type);
+ avio_wl16(pb, length); //size
+ avio_wl32(pb, asf->seqno);//sequence number
+ avio_wl16(pb, flags); /* unknown bytes */
+ avio_wl16(pb, length); //size_confirm
asf->seqno++;
}
@@ -269,7 +295,7 @@ static int64_t unix_to_file_time(int ti)
static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data_chunk_size)
{
ASFContext *asf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVMetadataTag *tags[5];
int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
int has_title;
@@ -305,40 +331,40 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
}
put_guid(pb, &ff_asf_header);
- put_le64(pb, -1); /* header length, will be patched after */
- put_le32(pb, 3 + has_title + !!metadata_count + s->nb_streams); /* number of chunks in header */
- put_byte(pb, 1); /* ??? */
- put_byte(pb, 2); /* ??? */
+ avio_wl64(pb, -1); /* header length, will be patched after */
+ avio_wl32(pb, 3 + has_title + !!metadata_count + s->nb_streams); /* number of chunks in header */
+ avio_w8(pb, 1); /* ??? */
+ avio_w8(pb, 2); /* ??? */
/* file header */
header_offset = url_ftell(pb);
hpos = put_header(pb, &ff_asf_file_header);
put_guid(pb, &ff_asf_my_guid);
- put_le64(pb, file_size);
+ avio_wl64(pb, file_size);
file_time = 0;
- put_le64(pb, unix_to_file_time(file_time));
- put_le64(pb, asf->nb_packets); /* number of packets */
- put_le64(pb, duration); /* end time stamp (in 100ns units) */
- put_le64(pb, asf->duration); /* duration (in 100ns units) */
- put_le64(pb, PREROLL_TIME); /* start time stamp */
- put_le32(pb, (asf->is_streamed || url_is_streamed(pb)) ? 3 : 2); /* ??? */
- put_le32(pb, s->packet_size); /* packet size */
- put_le32(pb, s->packet_size); /* packet size */
- put_le32(pb, bit_rate); /* Nominal data rate in bps */
+ avio_wl64(pb, unix_to_file_time(file_time));
+ avio_wl64(pb, asf->nb_packets); /* number of packets */
+ avio_wl64(pb, duration); /* end time stamp (in 100ns units) */
+ avio_wl64(pb, asf->duration); /* duration (in 100ns units) */
+ avio_wl64(pb, PREROLL_TIME); /* start time stamp */
+ avio_wl32(pb, (asf->is_streamed || url_is_streamed(pb)) ? 3 : 2); /* ??? */
+ avio_wl32(pb, s->packet_size); /* packet size */
+ avio_wl32(pb, s->packet_size); /* packet size */
+ avio_wl32(pb, bit_rate); /* Nominal data rate in bps */
end_header(pb, hpos);
/* unknown headers */
hpos = put_header(pb, &ff_asf_head1_guid);
put_guid(pb, &ff_asf_head2_guid);
- put_le32(pb, 6);
- put_le16(pb, 0);
+ avio_wl32(pb, 6);
+ avio_wl16(pb, 0);
end_header(pb, hpos);
/* title and other infos */
if (has_title) {
int len;
uint8_t *buf;
- ByteIOContext *dyn_buf;
+ AVIOContext *dyn_buf;
if (url_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
@@ -347,20 +373,20 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0;
- put_le16(pb, len);
+ avio_wl16(pb, len);
}
len = url_close_dyn_buf(dyn_buf, &buf);
- put_buffer(pb, buf, len);
+ avio_write(pb, buf, len);
av_freep(&buf);
end_header(pb, hpos);
}
if (metadata_count) {
AVMetadataTag *tag = NULL;
hpos = put_header(pb, &ff_asf_extended_content_header);
- put_le16(pb, metadata_count);
+ avio_wl16(pb, metadata_count);
while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
put_str16(pb, tag->key);
- put_le16(pb, 0);
+ avio_wl16(pb, 0);
put_str16(pb, tag->value);
}
end_header(pb, hpos);
@@ -398,45 +424,45 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
put_guid(pb, &ff_asf_video_stream);
put_guid(pb, &ff_asf_video_conceal_none);
}
- put_le64(pb, 0); /* ??? */
+ avio_wl64(pb, 0); /* ??? */
es_pos = url_ftell(pb);
- put_le32(pb, extra_size); /* wav header len */
- put_le32(pb, extra_size2); /* additional data len */
- put_le16(pb, n + 1); /* stream number */
- put_le32(pb, 0); /* ??? */
+ avio_wl32(pb, extra_size); /* wav header len */
+ avio_wl32(pb, extra_size2); /* additional data len */
+ avio_wl16(pb, n + 1); /* stream number */
+ avio_wl32(pb, 0); /* ??? */
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
/* WAVEFORMATEX header */
int wavsize = ff_put_wav_header(pb, enc);
if ((enc->codec_id != CODEC_ID_MP3) && (enc->codec_id != CODEC_ID_MP2) && (enc->codec_id != CODEC_ID_ADPCM_IMA_WAV) && (enc->extradata_size==0)) {
wavsize += 2;
- put_le16(pb, 0);
+ avio_wl16(pb, 0);
}
if (wavsize < 0)
return -1;
if (wavsize != extra_size) {
cur_pos = url_ftell(pb);
- url_fseek(pb, es_pos, SEEK_SET);
- put_le32(pb, wavsize); /* wav header len */
- url_fseek(pb, cur_pos, SEEK_SET);
+ avio_seek(pb, es_pos, SEEK_SET);
+ avio_wl32(pb, wavsize); /* wav header len */
+ avio_seek(pb, cur_pos, SEEK_SET);
}
/* ERROR Correction */
- put_byte(pb, 0x01);
+ avio_w8(pb, 0x01);
if(enc->codec_id == CODEC_ID_ADPCM_G726 || !enc->block_align){
- put_le16(pb, 0x0190);
- put_le16(pb, 0x0190);
+ avio_wl16(pb, 0x0190);
+ avio_wl16(pb, 0x0190);
}else{
- put_le16(pb, enc->block_align);
- put_le16(pb, enc->block_align);
+ avio_wl16(pb, enc->block_align);
+ avio_wl16(pb, enc->block_align);
}
- put_le16(pb, 0x01);
- put_byte(pb, 0x00);
+ avio_wl16(pb, 0x01);
+ avio_w8(pb, 0x00);
} else {
- put_le32(pb, enc->width);
- put_le32(pb, enc->height);
- put_byte(pb, 2); /* ??? */
- put_le16(pb, 40 + enc->extradata_size); /* size */
+ avio_wl32(pb, enc->width);
+ avio_wl32(pb, enc->height);
+ avio_w8(pb, 2); /* ??? */
+ avio_wl16(pb, 40 + enc->extradata_size); /* size */
/* BITMAPINFOHEADER header */
ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 1);
@@ -448,23 +474,23 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
hpos = put_header(pb, &ff_asf_codec_comment_header);
put_guid(pb, &ff_asf_codec_comment1_header);
- put_le32(pb, s->nb_streams);
+ avio_wl32(pb, s->nb_streams);
for(n=0;nnb_streams;n++) {
AVCodec *p;
const char *desc;
int len;
uint8_t *buf;
- ByteIOContext *dyn_buf;
+ AVIOContext *dyn_buf;
enc = s->streams[n]->codec;
p = avcodec_find_encoder(enc->codec_id);
if(enc->codec_type == AVMEDIA_TYPE_AUDIO)
- put_le16(pb, 2);
+ avio_wl16(pb, 2);
else if(enc->codec_type == AVMEDIA_TYPE_VIDEO)
- put_le16(pb, 1);
+ avio_wl16(pb, 1);
else
- put_le16(pb, -1);
+ avio_wl16(pb, -1);
if(enc->codec_id == CODEC_ID_WMAV2)
desc = "Windows Media Audio V8";
@@ -476,21 +502,21 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
avio_put_str16le(dyn_buf, desc);
len = url_close_dyn_buf(dyn_buf, &buf);
- put_le16(pb, len / 2); // "number of characters" = length in bytes / 2
+ avio_wl16(pb, len / 2); // "number of characters" = length in bytes / 2
- put_buffer(pb, buf, len);
+ avio_write(pb, buf, len);
av_freep(&buf);
- put_le16(pb, 0); /* no parameters */
+ avio_wl16(pb, 0); /* no parameters */
/* id */
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
- put_le16(pb, 2);
- put_le16(pb, enc->codec_tag);
+ avio_wl16(pb, 2);
+ avio_wl16(pb, enc->codec_tag);
} else {
- put_le16(pb, 4);
- put_le32(pb, enc->codec_tag);
+ avio_wl16(pb, 4);
+ avio_wl32(pb, enc->codec_tag);
}
if(!enc->codec_tag)
return -1;
@@ -504,26 +530,26 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
if (asf->is_streamed) {
header_size += 8 + 30 + 50;
- url_fseek(pb, header_offset - 10 - 30, SEEK_SET);
- put_le16(pb, header_size);
- url_fseek(pb, header_offset - 2 - 30, SEEK_SET);
- put_le16(pb, header_size);
+ avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
+ avio_wl16(pb, header_size);
+ avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
+ avio_wl16(pb, header_size);
header_size -= 8 + 30 + 50;
}
header_size += 24 + 6;
- url_fseek(pb, header_offset - 14, SEEK_SET);
- put_le64(pb, header_size);
- url_fseek(pb, cur_pos, SEEK_SET);
+ avio_seek(pb, header_offset - 14, SEEK_SET);
+ avio_wl64(pb, header_size);
+ avio_seek(pb, cur_pos, SEEK_SET);
/* movie chunk, followed by packets of packet_size */
asf->data_offset = cur_pos;
put_guid(pb, &ff_asf_data_header);
- put_le64(pb, data_chunk_size);
+ avio_wl64(pb, data_chunk_size);
put_guid(pb, &ff_asf_my_guid);
- put_le64(pb, asf->nb_packets); /* nb packets */
- put_byte(pb, 1); /* ??? */
- put_byte(pb, 1); /* ??? */
+ avio_wl64(pb, asf->nb_packets); /* nb packets */
+ avio_w8(pb, 1); /* ??? */
+ avio_w8(pb, 1); /* ??? */
return 0;
}
@@ -553,7 +579,7 @@ static int asf_write_header(AVFormatContext *s)
asf->packet_nb_payloads = 0;
asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1;
- init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1,
+ ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
NULL, NULL, NULL, NULL);
return 0;
@@ -577,7 +603,7 @@ static int put_payload_parsing_info(
)
{
ASFContext *asf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ppi_size, i;
int64_t start= url_ftell(pb);
@@ -588,9 +614,9 @@ static int put_payload_parsing_info(
padsize--;
assert(padsize>=0);
- put_byte(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS);
+ avio_w8(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS);
for (i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++){
- put_byte(pb, 0x0);
+ avio_w8(pb, 0x0);
}
if (asf->multi_payloads_present)
@@ -602,19 +628,19 @@ static int put_payload_parsing_info(
else
iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD;
}
- put_byte(pb, iLengthTypeFlags);
+ avio_w8(pb, iLengthTypeFlags);
- put_byte(pb, ASF_PPI_PROPERTY_FLAGS);
+ avio_w8(pb, ASF_PPI_PROPERTY_FLAGS);
if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD)
- put_le16(pb, padsize - 2);
+ avio_wl16(pb, padsize - 2);
if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE)
- put_byte(pb, padsize - 1);
+ avio_w8(pb, padsize - 1);
- put_le32(pb, sendtime);
- put_le16(pb, duration);
+ avio_wl32(pb, sendtime);
+ avio_wl16(pb, duration);
if (asf->multi_payloads_present)
- put_byte(pb, nb_payloads | ASF_PAYLOAD_FLAGS);
+ avio_w8(pb, nb_payloads | ASF_PAYLOAD_FLAGS);
ppi_size = url_ftell(pb) - start;
@@ -644,14 +670,14 @@ static void flush_packet(AVFormatContext *s)
assert(packet_hdr_size <= asf->packet_size_left);
memset(asf->packet_buf + packet_filled_size, 0, asf->packet_size_left);
- put_buffer(s->pb, asf->packet_buf, s->packet_size - packet_hdr_size);
+ avio_write(s->pb, asf->packet_buf, s->packet_size - packet_hdr_size);
put_flush_packet(s->pb);
asf->nb_packets++;
asf->packet_nb_payloads = 0;
asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1;
- init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1,
+ ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
NULL, NULL, NULL, NULL);
}
@@ -666,29 +692,29 @@ static void put_payload_header(
)
{
ASFContext *asf = s->priv_data;
- ByteIOContext *pb = &asf->pb;
+ AVIOContext *pb = &asf->pb;
int val;
val = stream->num;
if (flags & AV_PKT_FLAG_KEY)
val |= ASF_PL_FLAG_KEY_FRAME;
- put_byte(pb, val);
+ avio_w8(pb, val);
- put_byte(pb, stream->seq); //Media object number
- put_le32(pb, m_obj_offset); //Offset Into Media Object
+ avio_w8(pb, stream->seq); //Media object number
+ avio_wl32(pb, m_obj_offset); //Offset Into Media Object
// Replicated Data shall be at least 8 bytes long.
// The first 4 bytes of data shall contain the
// Size of the Media Object that the payload belongs to.
// The next 4 bytes of data shall contain the
// Presentation Time for the media object that the payload belongs to.
- put_byte(pb, ASF_PAYLOAD_REPLICATED_DATA_LENGTH);
+ avio_w8(pb, ASF_PAYLOAD_REPLICATED_DATA_LENGTH);
- put_le32(pb, m_obj_size); //Replicated Data - Media Object Size
- put_le32(pb, presentation_time);//Replicated Data - Presentation Time
+ avio_wl32(pb, m_obj_size); //Replicated Data - Media Object Size
+ avio_wl32(pb, presentation_time);//Replicated Data - Presentation Time
if (asf->multi_payloads_present){
- put_le16(pb, payload_len); //payload length
+ avio_wl16(pb, payload_len); //payload length
}
}
@@ -736,7 +762,7 @@ static void put_frame(
payload_len = frag_len1 - 2; //additional byte need to put padding length
put_payload_header(s, stream, timestamp+PREROLL_TIME, m_obj_size, m_obj_offset, payload_len, flags);
- put_buffer(&asf->pb, buf, payload_len);
+ avio_write(&asf->pb, buf, payload_len);
if (asf->multi_payloads_present)
asf->packet_size_left -= (payload_len + PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS);
@@ -807,18 +833,18 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
//
static int asf_write_index(AVFormatContext *s, ASFIndex *index, uint16_t max, uint32_t count)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int i;
put_guid(pb, &ff_asf_simple_index_header);
- put_le64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2)*count);
+ avio_wl64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2)*count);
put_guid(pb, &ff_asf_my_guid);
- put_le64(pb, ASF_INDEXED_INTERVAL);
- put_le32(pb, max);
- put_le32(pb, count);
+ avio_wl64(pb, ASF_INDEXED_INTERVAL);
+ avio_wl32(pb, max);
+ avio_wl32(pb, count);
for(i=0; ipb);
- url_fseek(s->pb, 0, SEEK_SET);
+ avio_seek(s->pb, 0, SEEK_SET);
asf_write_header1(s, file_size, data_size - asf->data_offset);
}
diff --git a/mplayer/ffmpeg/libavformat/assdec.c b/mplayer/ffmpeg/libavformat/assdec.c
index 86f03390..e04d92ae 100644
--- a/mplayer/ffmpeg/libavformat/assdec.c
+++ b/mplayer/ffmpeg/libavformat/assdec.c
@@ -76,7 +76,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
{
int i, len, header_remaining;
ASSContext *ass = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
int allocated[2]={0};
uint8_t *p, **dst[2]={0};
diff --git a/mplayer/ffmpeg/libavformat/assenc.c b/mplayer/ffmpeg/libavformat/assenc.c
index fdd53060..9abe3027 100644
--- a/mplayer/ffmpeg/libavformat/assenc.c
+++ b/mplayer/ffmpeg/libavformat/assenc.c
@@ -42,7 +42,7 @@ static int write_header(AVFormatContext *s)
if(!end) end= avctx->extradata + avctx->extradata_size;
else end++;
- put_buffer(s->pb, p, end-p);
+ avio_write(s->pb, p, end-p);
ass->extra_index += end-p;
if(last && !memcmp(last, "[Events]", 8))
@@ -57,7 +57,7 @@ static int write_header(AVFormatContext *s)
static int write_packet(AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
@@ -69,7 +69,7 @@ static int write_trailer(AVFormatContext *s)
ASSContext *ass = s->priv_data;
AVCodecContext *avctx= s->streams[0]->codec;
- put_buffer(s->pb, avctx->extradata + ass->extra_index,
+ avio_write(s->pb, avctx->extradata + ass->extra_index,
avctx->extradata_size - ass->extra_index);
put_flush_packet(s->pb);
diff --git a/mplayer/ffmpeg/libavformat/au.c b/mplayer/ffmpeg/libavformat/au.c
index e18022dd..16b33e78 100644
--- a/mplayer/ffmpeg/libavformat/au.c
+++ b/mplayer/ffmpeg/libavformat/au.c
@@ -28,6 +28,7 @@
*/
#include "avformat.h"
+#include "avio_internal.h"
#include "pcm.h"
#include "riff.h"
@@ -49,22 +50,22 @@ static const AVCodecTag codec_au_tags[] = {
#if CONFIG_AU_MUXER
/* AUDIO_FILE header */
-static int put_au_header(ByteIOContext *pb, AVCodecContext *enc)
+static int put_au_header(AVIOContext *pb, AVCodecContext *enc)
{
if(!enc->codec_tag)
return -1;
- put_tag(pb, ".snd"); /* magic number */
- put_be32(pb, 24); /* header size */
- put_be32(pb, AU_UNKNOWN_SIZE); /* data size */
- put_be32(pb, (uint32_t)enc->codec_tag); /* codec ID */
- put_be32(pb, enc->sample_rate);
- put_be32(pb, (uint32_t)enc->channels);
+ ffio_wfourcc(pb, ".snd"); /* magic number */
+ avio_wb32(pb, 24); /* header size */
+ avio_wb32(pb, AU_UNKNOWN_SIZE); /* data size */
+ avio_wb32(pb, (uint32_t)enc->codec_tag); /* codec ID */
+ avio_wb32(pb, enc->sample_rate);
+ avio_wb32(pb, (uint32_t)enc->channels);
return 0;
}
static int au_write_header(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
s->priv_data = NULL;
@@ -80,23 +81,23 @@ static int au_write_header(AVFormatContext *s)
static int au_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
- put_buffer(pb, pkt->data, pkt->size);
+ AVIOContext *pb = s->pb;
+ avio_write(pb, pkt->data, pkt->size);
return 0;
}
static int au_write_trailer(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t file_size;
if (!url_is_streamed(s->pb)) {
/* update file size */
file_size = url_ftell(pb);
- url_fseek(pb, 8, SEEK_SET);
- put_be32(pb, (uint32_t)(file_size - 24));
- url_fseek(pb, file_size, SEEK_SET);
+ avio_seek(pb, 8, SEEK_SET);
+ avio_wb32(pb, (uint32_t)(file_size - 24));
+ avio_seek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
}
@@ -121,21 +122,21 @@ static int au_read_header(AVFormatContext *s,
{
int size;
unsigned int tag;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int id, channels, rate;
enum CodecID codec;
AVStream *st;
/* check ".snd" header */
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('.', 's', 'n', 'd'))
return -1;
- size = get_be32(pb); /* header size */
- get_be32(pb); /* data size */
+ size = avio_rb32(pb); /* header size */
+ avio_rb32(pb); /* data size */
- id = get_be32(pb);
- rate = get_be32(pb);
- channels = get_be32(pb);
+ id = avio_rb32(pb);
+ rate = avio_rb32(pb);
+ channels = avio_rb32(pb);
codec = ff_codec_get_id(codec_au_tags, id);
@@ -146,7 +147,7 @@ static int au_read_header(AVFormatContext *s,
if (size >= 24) {
/* skip unused data */
- url_fseek(pb, size - 24, SEEK_CUR);
+ avio_seek(pb, size - 24, SEEK_CUR);
}
/* now we are ready: build format streams */
diff --git a/mplayer/ffmpeg/libavformat/avc.c b/mplayer/ffmpeg/libavformat/avc.c
index 7c991961..a39343b1 100644
--- a/mplayer/ffmpeg/libavformat/avc.c
+++ b/mplayer/ffmpeg/libavformat/avc.c
@@ -67,7 +67,7 @@ const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end){
return out;
}
-int ff_avc_parse_nal_units(ByteIOContext *pb, const uint8_t *buf_in, int size)
+int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
{
const uint8_t *p = buf_in;
const uint8_t *end = p + size;
@@ -78,8 +78,8 @@ int ff_avc_parse_nal_units(ByteIOContext *pb, const uint8_t *buf_in, int size)
while (nal_start < end) {
while(!*(nal_start++));
nal_end = ff_avc_find_startcode(nal_start, end);
- put_be32(pb, nal_end - nal_start);
- put_buffer(pb, nal_start, nal_end - nal_start);
+ avio_wb32(pb, nal_end - nal_start);
+ avio_write(pb, nal_start, nal_end - nal_start);
size += 4 + nal_end - nal_start;
nal_start = nal_end;
}
@@ -88,7 +88,7 @@ int ff_avc_parse_nal_units(ByteIOContext *pb, const uint8_t *buf_in, int size)
int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
{
- ByteIOContext *pb;
+ AVIOContext *pb;
int ret = url_open_dyn_buf(&pb);
if(ret < 0)
return ret;
@@ -100,7 +100,7 @@ int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
return 0;
}
-int ff_isom_write_avcc(ByteIOContext *pb, const uint8_t *data, int len)
+int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
{
if (len > 6) {
/* check for h264 start code */
@@ -134,21 +134,21 @@ int ff_isom_write_avcc(ByteIOContext *pb, const uint8_t *data, int len)
assert(sps);
assert(pps);
- put_byte(pb, 1); /* version */
- put_byte(pb, sps[1]); /* profile */
- put_byte(pb, sps[2]); /* profile compat */
- put_byte(pb, sps[3]); /* level */
- put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
- put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-
- put_be16(pb, sps_size);
- put_buffer(pb, sps, sps_size);
- put_byte(pb, 1); /* number of pps */
- put_be16(pb, pps_size);
- put_buffer(pb, pps, pps_size);
+ avio_w8(pb, 1); /* version */
+ avio_w8(pb, sps[1]); /* profile */
+ avio_w8(pb, sps[2]); /* profile compat */
+ avio_w8(pb, sps[3]); /* level */
+ avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
+ avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
+
+ avio_wb16(pb, sps_size);
+ avio_write(pb, sps, sps_size);
+ avio_w8(pb, 1); /* number of pps */
+ avio_wb16(pb, pps_size);
+ avio_write(pb, pps, pps_size);
av_free(start);
} else {
- put_buffer(pb, data, len);
+ avio_write(pb, data, len);
}
}
return 0;
diff --git a/mplayer/ffmpeg/libavformat/avc.h b/mplayer/ffmpeg/libavformat/avc.h
index 2deb77df..46e5e37a 100644
--- a/mplayer/ffmpeg/libavformat/avc.h
+++ b/mplayer/ffmpeg/libavformat/avc.h
@@ -25,9 +25,9 @@
#include
#include "avio.h"
-int ff_avc_parse_nal_units(ByteIOContext *s, const uint8_t *buf, int size);
+int ff_avc_parse_nal_units(AVIOContext *s, const uint8_t *buf, int size);
int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size);
-int ff_isom_write_avcc(ByteIOContext *pb, const uint8_t *data, int len);
+int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len);
const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end);
#endif /* AVFORMAT_AVC_H */
diff --git a/mplayer/ffmpeg/libavformat/avformat.h b/mplayer/ffmpeg/libavformat/avformat.h
index f9f9be5b..f5afde84 100644
--- a/mplayer/ffmpeg/libavformat/avformat.h
+++ b/mplayer/ffmpeg/libavformat/avformat.h
@@ -193,7 +193,7 @@ void av_metadata_free(AVMetadata **m);
* @param size desired payload size
* @return >0 (read size) if OK, AVERROR_xxx otherwise
*/
-int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
+int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
/**
@@ -209,7 +209,7 @@ int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
* @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data
* will not be lost even if an error occurs.
*/
-int av_append_packet(ByteIOContext *s, AVPacket *pkt, int size);
+int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
/*************************************************/
/* fractional numbers for exact pts handling */
@@ -261,7 +261,7 @@ typedef struct AVFormatParameters {
#endif
} AVFormatParameters;
-//! Demuxer will use url_fopen, no opened file should be provided by the caller.
+//! Demuxer will use avio_open, no opened file should be provided by the caller.
#define AVFMT_NOFILE 0x0001
#define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */
#define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */
@@ -472,6 +472,9 @@ typedef struct AVIndexEntry {
* even when user did not explicitly ask for subtitles.
*/
#define AV_DISPOSITION_FORCED 0x0040
+#define AV_DISPOSITION_HEARING_IMPAIRED 0x0080 /**< stream for hearing impaired audiences */
+#define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */
+#define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */
/**
* Stream structure.
@@ -507,6 +510,8 @@ typedef struct AVStream {
* This is the fundamental unit of time (in seconds) in terms
* of which frame timestamps are represented. For fixed-fps content,
* time base should be 1/framerate and timestamp increments should be 1.
+ * decoding: set by libavformat
+ * encoding: set by libavformat in av_write_header
*/
AVRational time_base;
int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
@@ -683,7 +688,7 @@ typedef struct AVFormatContext {
struct AVInputFormat *iformat;
struct AVOutputFormat *oformat;
void *priv_data;
- ByteIOContext *pb;
+ AVIOContext *pb;
unsigned int nb_streams;
#if FF_API_MAX_STREAMS
AVStream *streams[MAX_STREAMS];
@@ -750,7 +755,9 @@ typedef struct AVFormatContext {
/* av_seek_frame() support */
int64_t data_offset; /**< offset of the first packet */
- int index_built;
+#if FF_API_INDEX_BUILT
+ attribute_deprecated int index_built;
+#endif
int mux_rate;
unsigned int packet_size;
@@ -942,7 +949,7 @@ enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
* @param buf buffer
* @param size buffer size
*
- * @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log
+ * @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2
*/
void av_hex_dump(FILE *f, uint8_t *buf, int size);
@@ -956,7 +963,7 @@ void av_hex_dump(FILE *f, uint8_t *buf, int size);
* @param buf buffer
* @param size buffer size
*
- * @see av_hex_dump, av_pkt_dump, av_pkt_dump_log
+ * @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log2
*/
void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
@@ -966,8 +973,11 @@ void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
* @param f The file stream pointer where the dump should be sent to.
* @param pkt packet to dump
* @param dump_payload True if the payload must be displayed, too.
+ * @param st AVStream that the packet belongs to
*/
-void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
+void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
+
+attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
/**
* Send a nice dump of a packet to the log.
@@ -978,8 +988,13 @@ void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
* higher importance.
* @param pkt packet to dump
* @param dump_payload True if the payload must be displayed, too.
+ * @param st AVStream that the packet belongs to
*/
-void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
+void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
+ AVStream *st);
+
+attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt,
+ int dump_payload);
/**
* Initialize libavformat and register all the muxers, demuxers and
@@ -1038,12 +1053,31 @@ AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
*/
AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
+/**
+ * Probe a bytestream to determine the input format. Each time a probe returns
+ * with a score that is too low, the probe buffer size is increased and another
+ * attempt is made. When the maximum probe size is reached, the input format
+ * with the highest score is returned.
+ *
+ * @param pb the bytestream to probe
+ * @param fmt the input format is put here
+ * @param filename the filename of the stream
+ * @param logctx the log context
+ * @param offset the offset within the bytestream to probe from
+ * @param max_probe_size the maximum probe buffer size (zero for default)
+ * @return 0 in case of success, a negative value corresponding to an
+ * AVERROR code otherwise
+ */
+int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
+ const char *filename, void *logctx,
+ unsigned int offset, unsigned int max_probe_size);
+
/**
* Allocate all the structures needed to read an input stream.
* This does not open the needed codecs for decoding the stream[s].
*/
int av_open_input_stream(AVFormatContext **ic_ptr,
- ByteIOContext *pb, const char *filename,
+ AVIOContext *pb, const char *filename,
AVInputFormat *fmt, AVFormatParameters *ap);
/**
@@ -1072,8 +1106,8 @@ attribute_deprecated AVFormatContext *av_alloc_format_context(void);
/**
* Allocate an AVFormatContext.
- * Can be freed with av_free() but do not forget to free everything you
- * explicitly allocated as well!
+ * avformat_free_context() can be used to free the context and everything
+ * allocated by the framework within it.
*/
AVFormatContext *avformat_alloc_context(void);
@@ -1229,6 +1263,12 @@ void av_close_input_stream(AVFormatContext *s);
*/
void av_close_input_file(AVFormatContext *s);
+/**
+ * Free an AVFormatContext and all its streams.
+ * @param s context to free
+ */
+void avformat_free_context(AVFormatContext *s);
+
/**
* Add a new stream to a media file.
*
@@ -1243,23 +1283,8 @@ AVStream *av_new_stream(AVFormatContext *s, int id);
AVProgram *av_new_program(AVFormatContext *s, int id);
/**
- * Add a new chapter.
- * This function is NOT part of the public API
- * and should ONLY be used by demuxers.
- *
- * @param s media file handle
- * @param id unique ID for this chapter
- * @param start chapter start time in time_base units
- * @param end chapter end time in time_base units
- * @param title chapter title
- *
- * @return AVChapter or NULL on error
- */
-AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base,
- int64_t start, int64_t end, const char *title);
-
-/**
- * Set the pts for a given stream.
+ * Set the pts for a given stream. If the new values would be invalid
+ * (<= 0), it leaves the AVStream unchanged.
*
* @param s stream
* @param pts_wrap_bits number of bits effectively used by the pts
@@ -1287,15 +1312,6 @@ int av_find_default_stream_index(AVFormatContext *s);
*/
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
-/**
- * Ensure the index uses less memory than the maximum specified in
- * AVFormatContext.max_index_size by discarding entries if it grows
- * too large.
- * This function is not part of the public API and should only be called
- * by demuxers.
- */
-void ff_reduce_index(AVFormatContext *s, int stream_index);
-
/**
* Add an index entry into a sorted list. Update the entry if the list
* already contains it.
@@ -1374,6 +1390,8 @@ void av_url_split(char *proto, int proto_size,
/**
* Allocate the stream private data and write the stream header to an
* output media file.
+ * @note: this sets stream time-bases, if possible to stream->codec->time_base
+ * but for some formats it might also be some other time base
*
* @param s media file handle
* @return 0 if OK, AVERROR_xxx on error
@@ -1440,10 +1458,17 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
*/
int av_write_trailer(AVFormatContext *s);
-void dump_format(AVFormatContext *ic,
- int index,
- const char *url,
- int is_output);
+#if FF_API_DUMP_FORMAT
+attribute_deprecated void dump_format(AVFormatContext *ic,
+ int index,
+ const char *url,
+ int is_output);
+#endif
+
+void av_dump_format(AVFormatContext *ic,
+ int index,
+ const char *url,
+ int is_output);
#if FF_API_PARSE_FRAME_PARAM
/**
@@ -1461,34 +1486,17 @@ attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base,
const char *arg);
#endif
+#if FF_API_PARSE_DATE
/**
* Parse datestr and return a corresponding number of microseconds.
+ *
* @param datestr String representing a date or a duration.
- * - If a date the syntax is:
- * @code
- * now|{[{YYYY-MM-DD|YYYYMMDD}[T|t| ]]{{HH[:MM[:SS[.m...]]]}|{HH[MM[SS[.m...]]]}}[Z|z]}
- * @endcode
- * If the value is "now" it takes the current time.
- * Time is local time unless Z is appended, in which case it is
- * interpreted as UTC.
- * If the year-month-day part is not specified it takes the current
- * year-month-day.
- * @return the number of microseconds since 1st of January, 1970 up to
- * the time of the parsed date or INT64_MIN if datestr cannot be
- * successfully parsed.
- * - If a duration the syntax is:
- * @code
- * [-]HH[:MM[:SS[.m...]]]
- * [-]S+[.m...]
- * @endcode
- * @return the number of microseconds contained in a time interval
- * with the specified duration or INT64_MIN if datestr cannot be
- * successfully parsed.
- * @param duration Flag which tells how to interpret datestr, if
- * not zero datestr is interpreted as a duration, otherwise as a
- * date.
+ * See av_parse_time() for the syntax of the provided string.
+ * @deprecated in favor of av_parse_time()
*/
+attribute_deprecated
int64_t parse_date(const char *datestr, int duration);
+#endif
/**
* Get the current time in microseconds.
@@ -1501,13 +1509,12 @@ int64_t ffm_read_write_index(int fd);
int ffm_write_write_index(int fd, int64_t pos);
void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
+#if FF_API_FIND_INFO_TAG
/**
- * Attempt to find a specific tag in a URL.
- *
- * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
- * Return 1 if found.
+ * @deprecated use av_find_info_tag in libavutil instead.
*/
-int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
+attribute_deprecated int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
+#endif
/**
* Return in 'buf' the path with '%d' replaced by a number.
diff --git a/mplayer/ffmpeg/libavformat/avi.h b/mplayer/ffmpeg/libavformat/avi.h
index f345c147..b4e55197 100644
--- a/mplayer/ffmpeg/libavformat/avi.h
+++ b/mplayer/ffmpeg/libavformat/avi.h
@@ -32,6 +32,7 @@
#define AVI_MAX_RIFF_SIZE 0x40000000LL
#define AVI_MASTER_INDEX_SIZE 256
+#define AVI_MAX_STREAM_COUNT 100
/* index flags */
#define AVIIF_INDEX 0x10
diff --git a/mplayer/ffmpeg/libavformat/avidec.c b/mplayer/ffmpeg/libavformat/avidec.c
index 747d3ee6..6c4a930b 100644
--- a/mplayer/ffmpeg/libavformat/avidec.c
+++ b/mplayer/ffmpeg/libavformat/avidec.c
@@ -27,7 +27,6 @@
#endif
#include "libavutil/intreadwrite.h"
#include "libavutil/bswap.h"
-#include "libavcodec/bytestream.h"
#include "avformat.h"
#include "avi.h"
#include "dv.h"
@@ -103,17 +102,17 @@ static inline int get_duration(AVIStream *ast, int len){
return 1;
}
-static int get_riff(AVFormatContext *s, ByteIOContext *pb)
+static int get_riff(AVFormatContext *s, AVIOContext *pb)
{
AVIContext *avi = s->priv_data;
char header[8];
int i;
/* check RIFF header */
- get_buffer(pb, header, 4);
- avi->riff_end = get_le32(pb); /* RIFF chunk size */
+ avio_read(pb, header, 4);
+ avi->riff_end = avio_rl32(pb); /* RIFF chunk size */
avi->riff_end += url_ftell(pb); /* RIFF chunk end */
- get_buffer(pb, header+4, 4);
+ avio_read(pb, header+4, 4);
for(i=0; avi_headers[i][0]; i++)
if(!memcmp(header, avi_headers[i], 8))
@@ -129,13 +128,13 @@ static int get_riff(AVFormatContext *s, ByteIOContext *pb)
static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
AVIContext *avi = s->priv_data;
- ByteIOContext *pb = s->pb;
- int longs_pre_entry= get_le16(pb);
- int index_sub_type = get_byte(pb);
- int index_type = get_byte(pb);
- int entries_in_use = get_le32(pb);
- int chunk_id = get_le32(pb);
- int64_t base = get_le64(pb);
+ AVIOContext *pb = s->pb;
+ int longs_pre_entry= avio_rl16(pb);
+ int index_sub_type = avio_r8(pb);
+ int index_type = avio_r8(pb);
+ int entries_in_use = avio_rl32(pb);
+ int chunk_id = avio_rl32(pb);
+ int64_t base = avio_rl64(pb);
int stream_id= 10*((chunk_id&0xFF) - '0') + (((chunk_id>>8)&0xFF) - '0');
AVStream *st;
AVIStream *ast;
@@ -156,7 +155,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
if(index_sub_type)
return -1;
- get_le32(pb);
+ avio_rl32(pb);
if(index_type && longs_pre_entry != 2)
return -1;
@@ -173,8 +172,8 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
for(i=0; i= 0;
len &= 0x7FFFFFFF;
@@ -194,9 +193,9 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
}else{
int64_t offset, pos;
int duration;
- offset = get_le64(pb);
- get_le32(pb); /* size */
- duration = get_le32(pb);
+ offset = avio_rl64(pb);
+ avio_rl32(pb); /* size */
+ duration = avio_rl32(pb);
if(url_feof(pb))
return -1;
@@ -208,13 +207,13 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
return -1;
}
- url_fseek(pb, offset+8, SEEK_SET);
+ avio_seek(pb, offset+8, SEEK_SET);
avi->odml_depth++;
read_braindead_odml_indx(s, frame_num);
avi->odml_depth--;
frame_num += duration;
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, pos, SEEK_SET);
}
}
avi->index_loaded=1;
@@ -249,7 +248,7 @@ static void clean_index(AVFormatContext *s){
static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t size)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
char key[5] = {0}, *value;
size += (size & 1);
@@ -259,7 +258,7 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t
value = av_malloc(size+1);
if (!value)
return -1;
- get_buffer(pb, value, size);
+ avio_read(pb, value, size);
value[size]=0;
AV_WL32(key, tag);
@@ -271,8 +270,8 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t
static void avi_read_info(AVFormatContext *s, uint64_t end)
{
while (url_ftell(s->pb) < end) {
- uint32_t tag = get_le32(s->pb);
- uint32_t size = get_le32(s->pb);
+ uint32_t tag = avio_rl32(s->pb);
+ uint32_t size = avio_rl32(s->pb);
avi_read_tag(s, NULL, tag, size);
}
}
@@ -302,17 +301,17 @@ static void avi_metadata_creation_time(AVMetadata **metadata, char *date)
static void avi_read_nikon(AVFormatContext *s, uint64_t end)
{
while (url_ftell(s->pb) < end) {
- uint32_t tag = get_le32(s->pb);
- uint32_t size = get_le32(s->pb);
+ uint32_t tag = avio_rl32(s->pb);
+ uint32_t size = avio_rl32(s->pb);
switch (tag) {
case MKTAG('n', 'c', 't', 'g'): { /* Nikon Tags */
uint64_t tag_end = url_ftell(s->pb) + size;
while (url_ftell(s->pb) < tag_end) {
- uint16_t tag = get_le16(s->pb);
- uint16_t size = get_le16(s->pb);
+ uint16_t tag = avio_rl16(s->pb);
+ uint16_t size = avio_rl16(s->pb);
const char *name = NULL;
char buffer[64] = {0};
- size -= get_buffer(s->pb, buffer,
+ size -= avio_read(s->pb, buffer,
FFMIN(size, sizeof(buffer)-1));
switch (tag) {
case 0x03: name = "maker"; break;
@@ -324,12 +323,12 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
}
if (name)
av_metadata_set2(&s->metadata, name, buffer, 0);
- url_fskip(s->pb, size);
+ avio_seek(s->pb, size, SEEK_CUR);
}
break;
}
default:
- url_fskip(s->pb, size);
+ avio_seek(s->pb, size, SEEK_CUR);
break;
}
}
@@ -338,7 +337,7 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVIContext *avi = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int tag, tag1, handler;
int codec_type, stream_index, frame_period, bit_rate;
unsigned int size;
@@ -365,8 +364,8 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
for(;;) {
if (url_feof(pb))
goto fail;
- tag = get_le32(pb);
- size = get_le32(pb);
+ tag = avio_rl32(pb);
+ size = avio_rl32(pb);
print_tag("tag", tag, size);
@@ -374,7 +373,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
case MKTAG('L', 'I', 'S', 'T'):
list_end = url_ftell(pb) + size;
/* Ignored, except at start of video packets. */
- tag1 = get_le32(pb);
+ tag1 = avio_rl32(pb);
print_tag("list", tag1, 0);
@@ -394,41 +393,41 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
case MKTAG('I', 'D', 'I', 'T'): {
unsigned char date[64] = {0};
size += (size & 1);
- size -= get_buffer(pb, date, FFMIN(size, sizeof(date)-1));
- url_fskip(pb, size);
+ size -= avio_read(pb, date, FFMIN(size, sizeof(date)-1));
+ avio_seek(pb, size, SEEK_CUR);
avi_metadata_creation_time(&s->metadata, date);
break;
}
case MKTAG('d', 'm', 'l', 'h'):
avi->is_odml = 1;
- url_fskip(pb, size + (size & 1));
+ avio_seek(pb, size + (size & 1), SEEK_CUR);
break;
case MKTAG('a', 'm', 'v', 'h'):
amv_file_format=1;
case MKTAG('a', 'v', 'i', 'h'):
/* AVI header */
/* using frame_period is bad idea */
- frame_period = get_le32(pb);
- bit_rate = get_le32(pb) * 8;
- get_le32(pb);
- avi->non_interleaved |= get_le32(pb) & AVIF_MUSTUSEINDEX;
-
- url_fskip(pb, 2 * 4);
- get_le32(pb);
- get_le32(pb);
- avih_width=get_le32(pb);
- avih_height=get_le32(pb);
-
- url_fskip(pb, size - 10 * 4);
+ frame_period = avio_rl32(pb);
+ bit_rate = avio_rl32(pb) * 8;
+ avio_rl32(pb);
+ avi->non_interleaved |= avio_rl32(pb) & AVIF_MUSTUSEINDEX;
+
+ avio_seek(pb, 2 * 4, SEEK_CUR);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avih_width=avio_rl32(pb);
+ avih_height=avio_rl32(pb);
+
+ avio_seek(pb, size - 10 * 4, SEEK_CUR);
break;
case MKTAG('s', 't', 'r', 'h'):
/* stream header */
- tag1 = get_le32(pb);
- handler = get_le32(pb); /* codec tag */
+ tag1 = avio_rl32(pb);
+ handler = avio_rl32(pb); /* codec tag */
if(tag1 == MKTAG('p', 'a', 'd', 's')){
- url_fskip(pb, size - 8);
+ avio_seek(pb, size - 8, SEEK_CUR);
break;
}else{
stream_index++;
@@ -472,12 +471,12 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
goto fail;
}
s->streams[0]->priv_data = ast;
- url_fskip(pb, 3 * 4);
- ast->scale = get_le32(pb);
- ast->rate = get_le32(pb);
- url_fskip(pb, 4); /* start time */
+ avio_seek(pb, 3 * 4, SEEK_CUR);
+ ast->scale = avio_rl32(pb);
+ ast->rate = avio_rl32(pb);
+ avio_seek(pb, 4, SEEK_CUR); /* start time */
- dv_dur = get_le32(pb);
+ dv_dur = avio_rl32(pb);
if (ast->scale > 0 && ast->rate > 0 && dv_dur > 0) {
dv_dur *= AV_TIME_BASE;
s->duration = av_rescale(dv_dur, ast->scale, ast->rate);
@@ -488,19 +487,19 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
*/
stream_index = s->nb_streams - 1;
- url_fskip(pb, size - 9*4);
+ avio_seek(pb, size - 9*4, SEEK_CUR);
break;
}
assert(stream_index < s->nb_streams);
st->codec->stream_codec_tag= handler;
- get_le32(pb); /* flags */
- get_le16(pb); /* priority */
- get_le16(pb); /* language */
- get_le32(pb); /* initial frame */
- ast->scale = get_le32(pb);
- ast->rate = get_le32(pb);
+ avio_rl32(pb); /* flags */
+ avio_rl16(pb); /* priority */
+ avio_rl16(pb); /* language */
+ avio_rl32(pb); /* initial frame */
+ ast->scale = avio_rl32(pb);
+ ast->rate = avio_rl32(pb);
if(!(ast->scale && ast->rate)){
av_log(s, AV_LOG_WARNING, "scale/rate is %u/%u which is invalid. (This file has been generated by broken software.)\n", ast->scale, ast->rate);
if(frame_period){
@@ -513,13 +512,13 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
av_set_pts_info(st, 64, ast->scale, ast->rate);
- ast->cum_len=get_le32(pb); /* start */
- st->nb_frames = get_le32(pb);
+ ast->cum_len=avio_rl32(pb); /* start */
+ st->nb_frames = avio_rl32(pb);
st->start_time = 0;
- get_le32(pb); /* buffer size */
- get_le32(pb); /* quality */
- ast->sample_size = get_le32(pb); /* sample ssize */
+ avio_rl32(pb); /* buffer size */
+ avio_rl32(pb); /* quality */
+ ast->sample_size = avio_rl32(pb); /* sample ssize */
ast->cum_len *= FFMAX(1, ast->sample_size);
// av_log(s, AV_LOG_DEBUG, "%d %d %d %d\n", ast->rate, ast->scale, ast->start, ast->sample_size);
@@ -545,12 +544,12 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
if(ast->sample_size == 0)
st->duration = st->nb_frames;
ast->frame_offset= ast->cum_len;
- url_fskip(pb, size - 12 * 4);
+ avio_seek(pb, size - 12 * 4, SEEK_CUR);
break;
case MKTAG('s', 't', 'r', 'f'):
/* stream header */
if (stream_index >= (unsigned)s->nb_streams || avi->dv_demux) {
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
} else {
uint64_t cur_pos = url_ftell(pb);
if (cur_pos < list_end)
@@ -563,7 +562,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->height=avih_height;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_AMV;
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
break;
}
tag1 = ff_get_bmp_header(pb, st);
@@ -582,11 +581,11 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->extradata_size= 0;
return AVERROR(ENOMEM);
}
- get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(pb, st->codec->extradata, st->codec->extradata_size);
}
if(st->codec->extradata_size & 1) //FIXME check if the encoder really did this correctly
- get_byte(pb);
+ avio_r8(pb);
/* Extract palette from extradata if bpp <= 8. */
/* This code assumes that extradata contains only palette. */
@@ -623,7 +622,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
st->codec->height= FFABS(st->codec->height);
-// url_fskip(pb, size - 5 * 4);
+// avio_seek(pb, size - 5 * 4, SEEK_CUR);
break;
case AVMEDIA_TYPE_AUDIO:
ff_get_wav_header(pb, st->codec, size);
@@ -633,7 +632,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
ast->sample_size= st->codec->block_align;
}
if (size&1) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
- url_fskip(pb, 1);
+ avio_seek(pb, 1, SEEK_CUR);
/* Force parsing as several audio frames can be in
* one packet and timestamps refer to packet start. */
st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
@@ -661,7 +660,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_type = AVMEDIA_TYPE_DATA;
st->codec->codec_id= CODEC_ID_NONE;
st->codec->codec_tag= 0;
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
break;
}
}
@@ -671,24 +670,24 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
if(!url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_IGNIDX)){
read_braindead_odml_indx(s, 0);
}
- url_fseek(pb, i+size, SEEK_SET);
+ avio_seek(pb, i+size, SEEK_SET);
break;
case MKTAG('v', 'p', 'r', 'p'):
if(stream_index < (unsigned)s->nb_streams && size > 9*4){
AVRational active, active_aspect;
st = s->streams[stream_index];
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
-
- active_aspect.den= get_le16(pb);
- active_aspect.num= get_le16(pb);
- active.num = get_le32(pb);
- active.den = get_le32(pb);
- get_le32(pb); //nbFieldsPerFrame
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+
+ active_aspect.den= avio_rl16(pb);
+ active_aspect.num= avio_rl16(pb);
+ active.num = avio_rl32(pb);
+ active.den = avio_rl32(pb);
+ avio_rl32(pb); //nbFieldsPerFrame
if(active_aspect.num && active_aspect.den && active.num && active.den){
st->sample_aspect_ratio= av_div_q(active_aspect, active);
@@ -696,7 +695,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
size -= 9*4;
}
- url_fseek(pb, size, SEEK_CUR);
+ avio_seek(pb, size, SEEK_CUR);
break;
case MKTAG('s', 't', 'r', 'n'):
if(s->nb_streams){
@@ -713,7 +712,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
/* skip tag */
size += (size & 1);
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
break;
}
}
@@ -750,39 +749,32 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int read_gab2_sub(AVStream *st, AVPacket *pkt) {
if (!strcmp(pkt->data, "GAB2") && AV_RL16(pkt->data+5) == 2) {
- uint8_t desc[256], *d = desc;
- uint8_t *end, *ptr = pkt->data+7;
- unsigned int size, desc_len = bytestream_get_le32(&ptr);
- int score = AVPROBE_SCORE_MAX / 2;
+ uint8_t desc[256];
+ int score = AVPROBE_SCORE_MAX / 2, ret;
AVIStream *ast = st->priv_data;
AVInputFormat *sub_demuxer;
AVRational time_base;
- ByteIOContext *pb;
+ AVIOContext *pb = avio_alloc_context( pkt->data + 7,
+ pkt->size - 7,
+ 0, NULL, NULL, NULL, NULL);
AVProbeData pd;
+ unsigned int desc_len = avio_rl32(pb);
- if (desc_len > FFMAX(pkt->size-17, 0))
- return 0;
+ if (desc_len > pb->buf_end - pb->buf_ptr)
+ goto error;
- end = ptr + desc_len;
- while (ptr < end-1) {
- uint8_t tmp;
- uint32_t ch;
- GET_UTF16(ch, ptr < end-1 ? bytestream_get_le16(&ptr) : 0, break;);
- PUT_UTF8(ch, tmp, if(d-desc < sizeof(desc)-1) *d++ = tmp;);
- }
- *d = 0;
+ ret = avio_get_str16le(pb, desc_len, desc, sizeof(desc));
+ avio_seek(pb, desc_len - ret, SEEK_CUR);
if (*desc)
av_metadata_set2(&st->metadata, "title", desc, 0);
- ptr = end + 2;
- size = bytestream_get_le32(&ptr);
- size = FFMIN(size, pkt->size+pkt->data-ptr);
+ avio_rl16(pb); /* flags? */
+ avio_rl32(pb); /* data size */
- pd = (AVProbeData) { .buf = ptr, .buf_size = size };
+ pd = (AVProbeData) { .buf = pb->buf_ptr, .buf_size = pb->buf_end - pb->buf_ptr };
if (!(sub_demuxer = av_probe_input_format2(&pd, 1, &score)))
- return 0;
+ goto error;
- pb = av_alloc_put_byte(ptr, size, 0, NULL, NULL, NULL, NULL);
if (!av_open_input_stream(&ast->sub_ctx, pb, "", sub_demuxer, NULL)) {
av_read_packet(ast->sub_ctx, &ast->sub_pkt);
*st->codec = *ast->sub_ctx->streams[0]->codec;
@@ -793,6 +785,8 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt) {
ast->sub_buffer = pkt->data;
memset(pkt, 0, sizeof(*pkt));
return 1;
+error:
+ av_freep(&pb);
}
return 0;
}
@@ -842,7 +836,7 @@ static int get_stream_idx(int *d){
static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIContext *avi = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int n, d[8];
unsigned int size;
int64_t i, sync;
@@ -900,7 +894,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
if(i>=0){
int64_t pos= best_st->index_entries[i].pos;
pos += best_ast->packet_size - best_ast->remaining;
- url_fseek(s->pb, pos + 8, SEEK_SET);
+ avio_seek(s->pb, pos + 8, SEEK_SET);
// av_log(s, AV_LOG_DEBUG, "pos=%"PRId64"\n", pos);
assert(best_ast->remaining <= best_ast->packet_size);
@@ -1002,7 +996,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
for(j=0; j<7; j++)
d[j]= d[j+1];
- d[7]= get_byte(pb);
+ d[7]= avio_r8(pb);
size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24);
@@ -1016,14 +1010,14 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
//parse JUNK
||(d[0] == 'J' && d[1] == 'U' && d[2] == 'N' && d[3] == 'K')
||(d[0] == 'i' && d[1] == 'd' && d[2] == 'x' && d[3] == '1')){
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
//av_log(s, AV_LOG_DEBUG, "SKIP\n");
goto resync;
}
//parse stray LIST
if(d[0] == 'L' && d[1] == 'I' && d[2] == 'S' && d[3] == 'T'){
- url_fskip(pb, 4);
+ avio_seek(pb, 4, SEEK_CUR);
goto resync;
}
@@ -1034,7 +1028,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
//detect ##ix chunk and skip
if(d[2] == 'i' && d[3] == 'x' && n < s->nb_streams){
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
goto resync;
}
@@ -1068,18 +1062,18 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
/*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & AV_PKT_FLAG_KEY))*/ //FIXME needs a little reordering
|| st->discard >= AVDISCARD_ALL){
ast->frame_offset += get_duration(ast, size);
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
goto resync;
}
if (d[2] == 'p' && d[3] == 'c' && size<=4*256+4) {
- int k = get_byte(pb);
- int last = (k + get_byte(pb) - 1) & 0xFF;
+ int k = avio_r8(pb);
+ int last = (k + avio_r8(pb) - 1) & 0xFF;
- get_le16(pb); //flags
+ avio_rl16(pb); //flags
for (; k <= last; k++)
- ast->pal[k] = get_be32(pb)>>8;// b + (g << 8) + (r << 16);
+ ast->pal[k] = avio_rb32(pb)>>8;// b + (g << 8) + (r << 16);
ast->has_pal= 1;
goto resync;
} else if( ((ast->prefix_count<5 || sync+9 > i) && d[2]<128 && d[3]<128) ||
@@ -1118,7 +1112,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
static int avi_read_idx1(AVFormatContext *s, int size)
{
AVIContext *avi = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int nb_index_entries, i;
AVStream *st;
AVIStream *ast;
@@ -1131,10 +1125,10 @@ static int avi_read_idx1(AVFormatContext *s, int size)
/* Read the entries and sort them in each stream component. */
for(i = 0; i < nb_index_entries; i++) {
- tag = get_le32(pb);
- flags = get_le32(pb);
- pos = get_le32(pb);
- len = get_le32(pb);
+ tag = avio_rl32(pb);
+ flags = avio_rl32(pb);
+ pos = avio_rl32(pb);
+ len = avio_rl32(pb);
#if defined(DEBUG_SEEK)
av_log(s, AV_LOG_DEBUG, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/",
i, tag, flags, pos, len);
@@ -1182,8 +1176,8 @@ static int guess_ni_flag(AVFormatContext *s){
if(n >= 2){
int64_t pos= st->index_entries[0].pos;
- url_fseek(s->pb, pos + 4, SEEK_SET);
- size= get_le32(s->pb);
+ avio_seek(s->pb, pos + 4, SEEK_SET);
+ size= avio_rl32(s->pb);
if(pos + size > st->index_entries[1].pos)
last_start= INT64_MAX;
}
@@ -1193,19 +1187,19 @@ static int guess_ni_flag(AVFormatContext *s){
if(st->index_entries[n-1].pos < first_end)
first_end= st->index_entries[n-1].pos;
}
- url_fseek(s->pb, oldpos, SEEK_SET);
+ avio_seek(s->pb, oldpos, SEEK_SET);
return last_start > first_end;
}
static int avi_load_index(AVFormatContext *s)
{
AVIContext *avi = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint32_t tag, size;
int64_t pos= url_ftell(pb);
int ret = -1;
- if (url_fseek(pb, avi->movi_end, SEEK_SET) < 0)
+ if (avio_seek(pb, avi->movi_end, SEEK_SET) < 0)
goto the_end; // maybe truncated file
#ifdef DEBUG_SEEK
printf("movi_end=0x%"PRIx64"\n", avi->movi_end);
@@ -1213,8 +1207,8 @@ static int avi_load_index(AVFormatContext *s)
for(;;) {
if (url_feof(pb))
break;
- tag = get_le32(pb);
- size = get_le32(pb);
+ tag = avio_rl32(pb);
+ size = avio_rl32(pb);
#ifdef DEBUG_SEEK
printf("tag=%c%c%c%c size=0x%x\n",
tag & 0xff,
@@ -1233,13 +1227,13 @@ static int avi_load_index(AVFormatContext *s)
default:
skip:
size += (size & 1);
- if (url_fseek(pb, size, SEEK_CUR) < 0)
+ if (avio_seek(pb, size, SEEK_CUR) < 0)
goto the_end; // something is wrong here
break;
}
}
the_end:
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, pos, SEEK_SET);
return ret;
}
@@ -1290,7 +1284,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
/* DV demux so it can synthesize correct timestamps. */
dv_offset_reset(avi->dv_demux, timestamp);
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
avi->stream_index= -1;
return 0;
}
@@ -1332,7 +1326,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
}
/* do the seek */
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
avi->stream_index= -1;
return 0;
}
@@ -1356,8 +1350,7 @@ static int avi_read_close(AVFormatContext *s)
}
}
- if (avi->dv_demux)
- av_free(avi->dv_demux);
+ av_free(avi->dv_demux);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/avienc.c b/mplayer/ffmpeg/libavformat/avienc.c
index 33976570..5aab1925 100644
--- a/mplayer/ffmpeg/libavformat/avienc.c
+++ b/mplayer/ffmpeg/libavformat/avienc.c
@@ -20,6 +20,7 @@
*/
#include "avformat.h"
#include "avi.h"
+#include "avio_internal.h"
#include "riff.h"
#include "libavutil/intreadwrite.h"
@@ -63,7 +64,7 @@ static inline AVIIentry* avi_get_ientry(AVIIndex* idx, int ent_id)
return &idx->cluster[cl][id];
}
-static int64_t avi_start_new_riff(AVFormatContext *s, ByteIOContext *pb,
+static int64_t avi_start_new_riff(AVFormatContext *s, AVIOContext *pb,
const char* riff_tag, const char* list_tag)
{
AVIContext *avi= s->priv_data;
@@ -77,16 +78,16 @@ static int64_t avi_start_new_riff(AVFormatContext *s, ByteIOContext *pb,
}
avi->riff_start = ff_start_tag(pb, "RIFF");
- put_tag(pb, riff_tag);
+ ffio_wfourcc(pb, riff_tag);
loff = ff_start_tag(pb, "LIST");
- put_tag(pb, list_tag);
+ ffio_wfourcc(pb, list_tag);
return loff;
}
static char* avi_stream2fourcc(char* tag, int index, enum AVMediaType type)
{
- tag[0] = '0';
- tag[1] = '0' + index;
+ tag[0] = '0' + index/10;
+ tag[1] = '0' + index%10;
if (type == AVMEDIA_TYPE_VIDEO) {
tag[2] = 'd';
tag[3] = 'c';
@@ -102,22 +103,22 @@ static char* avi_stream2fourcc(char* tag, int index, enum AVMediaType type)
return tag;
}
-static void avi_write_info_tag(ByteIOContext *pb, const char *tag, const char *str)
+static void avi_write_info_tag(AVIOContext *pb, const char *tag, const char *str)
{
int len = strlen(str);
if (len > 0) {
len++;
- put_tag(pb, tag);
- put_le32(pb, len);
+ ffio_wfourcc(pb, tag);
+ avio_wl32(pb, len);
avio_put_str(pb, str);
if (len & 1)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
}
static int avi_write_counters(AVFormatContext* s, int riff_id)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVIContext *avi = s->priv_data;
int n, au_byterate, au_ssize, au_scale, nb_frames = 0;
int64_t file_size;
@@ -129,22 +130,22 @@ static int avi_write_counters(AVFormatContext* s, int riff_id)
assert(avist->frames_hdr_strm);
stream = s->streams[n]->codec;
- url_fseek(pb, avist->frames_hdr_strm, SEEK_SET);
+ avio_seek(pb, avist->frames_hdr_strm, SEEK_SET);
ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
if(au_ssize == 0) {
- put_le32(pb, avist->packet_count);
+ avio_wl32(pb, avist->packet_count);
} else {
- put_le32(pb, avist->audio_strm_length / au_ssize);
+ avio_wl32(pb, avist->audio_strm_length / au_ssize);
}
if(stream->codec_type == AVMEDIA_TYPE_VIDEO)
nb_frames = FFMAX(nb_frames, avist->packet_count);
}
if(riff_id == 1) {
assert(avi->frames_hdr_all);
- url_fseek(pb, avi->frames_hdr_all, SEEK_SET);
- put_le32(pb, nb_frames);
+ avio_seek(pb, avi->frames_hdr_all, SEEK_SET);
+ avio_wl32(pb, nb_frames);
}
- url_fseek(pb, file_size, SEEK_SET);
+ avio_seek(pb, file_size, SEEK_SET);
return 0;
}
@@ -152,12 +153,18 @@ static int avi_write_counters(AVFormatContext* s, int riff_id)
static int avi_write_header(AVFormatContext *s)
{
AVIContext *avi = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
AVCodecContext *stream, *video_enc;
int64_t list1, list2, strh, strf;
AVMetadataTag *t = NULL;
+ if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
+ av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n",
+ AVI_MAX_STREAM_COUNT);
+ return -1;
+ }
+
for(n=0;nnb_streams;n++) {
s->streams[n]->priv_data= av_mallocz(sizeof(AVIStream));
if(!s->streams[n]->priv_data)
@@ -169,8 +176,8 @@ static int avi_write_header(AVFormatContext *s)
list1 = avi_start_new_riff(s, pb, "AVI ", "hdrl");
/* avi header */
- put_tag(pb, "avih");
- put_le32(pb, 14 * 4);
+ ffio_wfourcc(pb, "avih");
+ avio_wl32(pb, 14 * 4);
bitrate = 0;
video_enc = NULL;
@@ -184,38 +191,38 @@ static int avi_write_header(AVFormatContext *s)
nb_frames = 0;
if(video_enc){
- put_le32(pb, (uint32_t)(INT64_C(1000000) * video_enc->time_base.num / video_enc->time_base.den));
+ avio_wl32(pb, (uint32_t)(INT64_C(1000000) * video_enc->time_base.num / video_enc->time_base.den));
} else {
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
}
- put_le32(pb, bitrate / 8); /* XXX: not quite exact */
- put_le32(pb, 0); /* padding */
+ avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */
+ avio_wl32(pb, 0); /* padding */
if (url_is_streamed(pb))
- put_le32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */
+ avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */
else
- put_le32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */
+ avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */
avi->frames_hdr_all = url_ftell(pb); /* remember this offset to fill later */
- put_le32(pb, nb_frames); /* nb frames, filled later */
- put_le32(pb, 0); /* initial frame */
- put_le32(pb, s->nb_streams); /* nb streams */
- put_le32(pb, 1024 * 1024); /* suggested buffer size */
+ avio_wl32(pb, nb_frames); /* nb frames, filled later */
+ avio_wl32(pb, 0); /* initial frame */
+ avio_wl32(pb, s->nb_streams); /* nb streams */
+ avio_wl32(pb, 1024 * 1024); /* suggested buffer size */
if(video_enc){
- put_le32(pb, video_enc->width);
- put_le32(pb, video_enc->height);
+ avio_wl32(pb, video_enc->width);
+ avio_wl32(pb, video_enc->height);
} else {
- put_le32(pb, 0);
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
}
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
/* stream list */
for(i=0;istreams[i]->priv_data;
list2 = ff_start_tag(pb, "LIST");
- put_tag(pb, "strl");
+ ffio_wfourcc(pb, "strl");
stream = s->streams[i]->codec;
@@ -229,46 +236,46 @@ static int avi_write_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
return AVERROR_PATCHWELCOME;
}
- case AVMEDIA_TYPE_VIDEO: put_tag(pb, "vids"); break;
- case AVMEDIA_TYPE_AUDIO: put_tag(pb, "auds"); break;
-// case AVMEDIA_TYPE_TEXT : put_tag(pb, "txts"); break;
- case AVMEDIA_TYPE_DATA : put_tag(pb, "dats"); break;
+ case AVMEDIA_TYPE_VIDEO: ffio_wfourcc(pb, "vids"); break;
+ case AVMEDIA_TYPE_AUDIO: ffio_wfourcc(pb, "auds"); break;
+// case AVMEDIA_TYPE_TEXT : ffio_wfourcc(pb, "txts"); break;
+ case AVMEDIA_TYPE_DATA : ffio_wfourcc(pb, "dats"); break;
}
if(stream->codec_type == AVMEDIA_TYPE_VIDEO ||
stream->codec_id == CODEC_ID_XSUB)
- put_le32(pb, stream->codec_tag);
+ avio_wl32(pb, stream->codec_tag);
else
- put_le32(pb, 1);
- put_le32(pb, 0); /* flags */
- put_le16(pb, 0); /* priority */
- put_le16(pb, 0); /* language */
- put_le32(pb, 0); /* initial frame */
+ avio_wl32(pb, 1);
+ avio_wl32(pb, 0); /* flags */
+ avio_wl16(pb, 0); /* priority */
+ avio_wl16(pb, 0); /* language */
+ avio_wl32(pb, 0); /* initial frame */
ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
- put_le32(pb, au_scale); /* scale */
- put_le32(pb, au_byterate); /* rate */
+ avio_wl32(pb, au_scale); /* scale */
+ avio_wl32(pb, au_byterate); /* rate */
av_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
- put_le32(pb, 0); /* start */
+ avio_wl32(pb, 0); /* start */
avist->frames_hdr_strm = url_ftell(pb); /* remember this offset to fill later */
if (url_is_streamed(pb))
- put_le32(pb, AVI_MAX_RIFF_SIZE); /* FIXME: this may be broken, but who cares */
+ avio_wl32(pb, AVI_MAX_RIFF_SIZE); /* FIXME: this may be broken, but who cares */
else
- put_le32(pb, 0); /* length, XXX: filled later */
+ avio_wl32(pb, 0); /* length, XXX: filled later */
/* suggested buffer size */ //FIXME set at the end to largest chunk
if(stream->codec_type == AVMEDIA_TYPE_VIDEO)
- put_le32(pb, 1024 * 1024);
+ avio_wl32(pb, 1024 * 1024);
else if(stream->codec_type == AVMEDIA_TYPE_AUDIO)
- put_le32(pb, 12 * 1024);
+ avio_wl32(pb, 12 * 1024);
else
- put_le32(pb, 0);
- put_le32(pb, -1); /* quality */
- put_le32(pb, au_ssize); /* sample size */
- put_le32(pb, 0);
- put_le16(pb, stream->width);
- put_le16(pb, stream->height);
+ avio_wl32(pb, 0);
+ avio_wl32(pb, -1); /* quality */
+ avio_wl32(pb, au_ssize); /* sample size */
+ avio_wl32(pb, 0);
+ avio_wl16(pb, stream->width);
+ avio_wl16(pb, stream->height);
ff_end_tag(pb, strh);
if(stream->codec_type != AVMEDIA_TYPE_DATA){
@@ -307,16 +314,16 @@ static int avi_write_header(AVFormatContext *s)
*/
avist->indexes.entry = avist->indexes.ents_allocated = 0;
avist->indexes.indx_start = ff_start_tag(pb, "JUNK");
- put_le16(pb, 4); /* wLongsPerEntry */
- put_byte(pb, 0); /* bIndexSubType (0 == frame index) */
- put_byte(pb, 0); /* bIndexType (0 == AVI_INDEX_OF_INDEXES) */
- put_le32(pb, 0); /* nEntriesInUse (will fill out later on) */
- put_tag(pb, avi_stream2fourcc(&tag[0], i, stream->codec_type));
+ avio_wl16(pb, 4); /* wLongsPerEntry */
+ avio_w8(pb, 0); /* bIndexSubType (0 == frame index) */
+ avio_w8(pb, 0); /* bIndexType (0 == AVI_INDEX_OF_INDEXES) */
+ avio_wl32(pb, 0); /* nEntriesInUse (will fill out later on) */
+ ffio_wfourcc(pb, avi_stream2fourcc(tag, i, stream->codec_type));
/* dwChunkId */
- put_le64(pb, 0); /* dwReserved[3]
- put_le32(pb, 0); Must be 0. */
+ avio_wl64(pb, 0); /* dwReserved[3]
+ avio_wl32(pb, 0); Must be 0. */
for (j=0; j < AVI_MASTER_INDEX_SIZE * 2; j++)
- put_le64(pb, 0);
+ avio_wl64(pb, 0);
ff_end_tag(pb, avist->indexes.indx_start);
}
@@ -329,26 +336,26 @@ static int avi_write_header(AVFormatContext *s)
int num, den;
av_reduce(&num, &den, dar.num, dar.den, 0xFFFF);
- put_le32(pb, 0); //video format = unknown
- put_le32(pb, 0); //video standard= unknown
- put_le32(pb, lrintf(1.0/av_q2d(stream->time_base)));
- put_le32(pb, stream->width );
- put_le32(pb, stream->height);
- put_le16(pb, den);
- put_le16(pb, num);
- put_le32(pb, stream->width );
- put_le32(pb, stream->height);
- put_le32(pb, 1); //progressive FIXME
-
- put_le32(pb, stream->height);
- put_le32(pb, stream->width );
- put_le32(pb, stream->height);
- put_le32(pb, stream->width );
- put_le32(pb, 0);
- put_le32(pb, 0);
-
- put_le32(pb, 0);
- put_le32(pb, 0);
+ avio_wl32(pb, 0); //video format = unknown
+ avio_wl32(pb, 0); //video standard= unknown
+ avio_wl32(pb, lrintf(1.0/av_q2d(stream->time_base)));
+ avio_wl32(pb, stream->width );
+ avio_wl32(pb, stream->height);
+ avio_wl16(pb, den);
+ avio_wl16(pb, num);
+ avio_wl32(pb, stream->width );
+ avio_wl32(pb, stream->height);
+ avio_wl32(pb, 1); //progressive FIXME
+
+ avio_wl32(pb, stream->height);
+ avio_wl32(pb, stream->width );
+ avio_wl32(pb, stream->height);
+ avio_wl32(pb, stream->width );
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
+
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
ff_end_tag(pb, vprp);
}
@@ -358,18 +365,18 @@ static int avi_write_header(AVFormatContext *s)
if (!url_is_streamed(pb)) {
/* AVI could become an OpenDML one, if it grows beyond 2Gb range */
avi->odml_list = ff_start_tag(pb, "JUNK");
- put_tag(pb, "odml");
- put_tag(pb, "dmlh");
- put_le32(pb, 248);
+ ffio_wfourcc(pb, "odml");
+ ffio_wfourcc(pb, "dmlh");
+ avio_wl32(pb, 248);
for (i = 0; i < 248; i+= 4)
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
ff_end_tag(pb, avi->odml_list);
}
ff_end_tag(pb, list1);
list2 = ff_start_tag(pb, "LIST");
- put_tag(pb, "INFO");
+ ffio_wfourcc(pb, "INFO");
ff_metadata_conv(&s->metadata, ff_avi_metadata_conv, NULL);
for (i = 0; *ff_avi_tags[i]; i++) {
if ((t = av_metadata_get(s->metadata, ff_avi_tags[i], NULL, AV_METADATA_MATCH_CASE)))
@@ -380,11 +387,11 @@ static int avi_write_header(AVFormatContext *s)
/* some padding for easier tag editing */
list2 = ff_start_tag(pb, "JUNK");
for (i = 0; i < 1016; i += 4)
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
ff_end_tag(pb, list2);
avi->movi_list = ff_start_tag(pb, "LIST");
- put_tag(pb, "movi");
+ ffio_wfourcc(pb, "movi");
put_flush_packet(pb);
@@ -393,7 +400,7 @@ static int avi_write_header(AVFormatContext *s)
static int avi_write_ix(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVIContext *avi = s->priv_data;
char tag[5];
char ix_tag[] = "ix00";
@@ -408,50 +415,50 @@ static int avi_write_ix(AVFormatContext *s)
AVIStream *avist= s->streams[i]->priv_data;
int64_t ix, pos;
- avi_stream2fourcc(&tag[0], i, s->streams[i]->codec->codec_type);
+ avi_stream2fourcc(tag, i, s->streams[i]->codec->codec_type);
ix_tag[3] = '0' + i;
/* Writing AVI OpenDML leaf index chunk */
ix = url_ftell(pb);
- put_tag(pb, &ix_tag[0]); /* ix?? */
- put_le32(pb, avist->indexes.entry * 8 + 24);
+ ffio_wfourcc(pb, ix_tag); /* ix?? */
+ avio_wl32(pb, avist->indexes.entry * 8 + 24);
/* chunk size */
- put_le16(pb, 2); /* wLongsPerEntry */
- put_byte(pb, 0); /* bIndexSubType (0 == frame index) */
- put_byte(pb, 1); /* bIndexType (1 == AVI_INDEX_OF_CHUNKS) */
- put_le32(pb, avist->indexes.entry);
+ avio_wl16(pb, 2); /* wLongsPerEntry */
+ avio_w8(pb, 0); /* bIndexSubType (0 == frame index) */
+ avio_w8(pb, 1); /* bIndexType (1 == AVI_INDEX_OF_CHUNKS) */
+ avio_wl32(pb, avist->indexes.entry);
/* nEntriesInUse */
- put_tag(pb, &tag[0]); /* dwChunkId */
- put_le64(pb, avi->movi_list);/* qwBaseOffset */
- put_le32(pb, 0); /* dwReserved_3 (must be 0) */
+ ffio_wfourcc(pb, tag); /* dwChunkId */
+ avio_wl64(pb, avi->movi_list);/* qwBaseOffset */
+ avio_wl32(pb, 0); /* dwReserved_3 (must be 0) */
for (j=0; jindexes.entry; j++) {
AVIIentry* ie = avi_get_ientry(&avist->indexes, j);
- put_le32(pb, ie->pos + 8);
- put_le32(pb, ((uint32_t)ie->len & ~0x80000000) |
+ avio_wl32(pb, ie->pos + 8);
+ avio_wl32(pb, ((uint32_t)ie->len & ~0x80000000) |
(ie->flags & 0x10 ? 0 : 0x80000000));
}
put_flush_packet(pb);
pos = url_ftell(pb);
/* Updating one entry in the AVI OpenDML master index */
- url_fseek(pb, avist->indexes.indx_start - 8, SEEK_SET);
- put_tag(pb, "indx"); /* enabling this entry */
- url_fskip(pb, 8);
- put_le32(pb, avi->riff_id); /* nEntriesInUse */
- url_fskip(pb, 16*avi->riff_id);
- put_le64(pb, ix); /* qwOffset */
- put_le32(pb, pos - ix); /* dwSize */
- put_le32(pb, avist->indexes.entry); /* dwDuration */
-
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
+ ffio_wfourcc(pb, "indx"); /* enabling this entry */
+ avio_seek(pb, 8, SEEK_CUR);
+ avio_wl32(pb, avi->riff_id); /* nEntriesInUse */
+ avio_seek(pb, 16*avi->riff_id, SEEK_CUR);
+ avio_wl64(pb, ix); /* qwOffset */
+ avio_wl32(pb, pos - ix); /* dwSize */
+ avio_wl32(pb, avist->indexes.entry); /* dwDuration */
+
+ avio_seek(pb, pos, SEEK_SET);
}
return 0;
}
static int avi_write_idx1(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVIContext *avi = s->priv_data;
int64_t idx_chunk;
int i;
@@ -484,12 +491,12 @@ static int avi_write_idx1(AVFormatContext *s)
}
if (!empty) {
avist= s->streams[stream_id]->priv_data;
- avi_stream2fourcc(&tag[0], stream_id,
+ avi_stream2fourcc(tag, stream_id,
s->streams[stream_id]->codec->codec_type);
- put_tag(pb, &tag[0]);
- put_le32(pb, ie->flags);
- put_le32(pb, ie->pos);
- put_le32(pb, ie->len);
+ ffio_wfourcc(pb, tag);
+ avio_wl32(pb, ie->flags);
+ avio_wl32(pb, ie->pos);
+ avio_wl32(pb, ie->len);
avist->entry++;
}
} while (!empty);
@@ -503,7 +510,7 @@ static int avi_write_idx1(AVFormatContext *s)
static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIContext *avi = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned char tag[5];
unsigned int flags=0;
const int stream_index= pkt->stream_index;
@@ -538,7 +545,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
avi->movi_list = avi_start_new_riff(s, pb, "AVIX", "movi");
}
- avi_stream2fourcc(&tag[0], stream_index, enc->codec_type);
+ avi_stream2fourcc(tag, stream_index, enc->codec_type);
if(pkt->flags&AV_PKT_FLAG_KEY)
flags = 0x10;
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
@@ -565,11 +572,11 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
idx->entry++;
}
- put_buffer(pb, tag, 4);
- put_le32(pb, size);
- put_buffer(pb, pkt->data, size);
+ avio_write(pb, tag, 4);
+ avio_wl32(pb, size);
+ avio_write(pb, pkt->data, size);
if (size & 1)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
put_flush_packet(pb);
return 0;
@@ -578,7 +585,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
static int avi_write_trailer(AVFormatContext *s)
{
AVIContext *avi = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int res = 0;
int i, j, n, nb_frames;
int64_t file_size;
@@ -594,9 +601,9 @@ static int avi_write_trailer(AVFormatContext *s)
ff_end_tag(pb, avi->riff_start);
file_size = url_ftell(pb);
- url_fseek(pb, avi->odml_list - 8, SEEK_SET);
- put_tag(pb, "LIST"); /* Making this AVI OpenDML one */
- url_fskip(pb, 16);
+ avio_seek(pb, avi->odml_list - 8, SEEK_SET);
+ ffio_wfourcc(pb, "LIST"); /* Making this AVI OpenDML one */
+ avio_seek(pb, 16, SEEK_CUR);
for (n=nb_frames=0;nnb_streams;n++) {
AVCodecContext *stream = s->streams[n]->codec;
@@ -611,8 +618,8 @@ static int avi_write_trailer(AVFormatContext *s)
}
}
}
- put_le32(pb, nb_frames);
- url_fseek(pb, file_size, SEEK_SET);
+ avio_wl32(pb, nb_frames);
+ avio_seek(pb, file_size, SEEK_SET);
avi_write_counters(s, avi->riff_id);
}
diff --git a/mplayer/ffmpeg/libavformat/avio.c b/mplayer/ffmpeg/libavformat/avio.c
index 9a4d7355..a19ec37c 100644
--- a/mplayer/ffmpeg/libavformat/avio.c
+++ b/mplayer/ffmpeg/libavformat/avio.c
@@ -206,24 +206,21 @@ int url_open(URLContext **puc, const char *filename, int flags)
return ret;
}
-int url_read(URLContext *h, unsigned char *buf, int size)
-{
- int ret;
- if (h->flags & URL_WRONLY)
- return AVERROR(EIO);
- ret = h->prot->url_read(h, buf, size);
- return ret;
-}
-
-static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int size,
+static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int size, int size_min,
int (*transfer_func)(URLContext *h, unsigned char *buf, int size))
{
int ret, len;
int fast_retries = 5;
len = 0;
- while (len < size) {
+ while (len < size_min) {
+ if (url_interrupt_cb())
+ return AVERROR(EINTR);
ret = transfer_func(h, buf+len, size-len);
+ if (ret == AVERROR(EINTR))
+ continue;
+ if (h->flags & URL_FLAG_NONBLOCK)
+ return ret;
if (ret == AVERROR(EAGAIN)) {
ret = 0;
if (fast_retries)
@@ -239,9 +236,18 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
return len;
}
+int url_read(URLContext *h, unsigned char *buf, int size)
+{
+ if (h->flags & URL_WRONLY)
+ return AVERROR(EIO);
+ return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read);
+}
+
int url_read_complete(URLContext *h, unsigned char *buf, int size)
{
- return retry_transfer_wrapper(h, buf, size, url_read);
+ if (h->flags & URL_WRONLY)
+ return AVERROR(EIO);
+ return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read);
}
int url_write(URLContext *h, const unsigned char *buf, int size)
@@ -252,7 +258,7 @@ int url_write(URLContext *h, const unsigned char *buf, int size)
if (h->max_packet_size && size > h->max_packet_size)
return AVERROR(EIO);
- return retry_transfer_wrapper(h, buf, size, h->prot->url_write);
+ return retry_transfer_wrapper(h, buf, size, size, h->prot->url_write);
}
int64_t url_seek(URLContext *h, int64_t pos, int whence)
diff --git a/mplayer/ffmpeg/libavformat/avio.h b/mplayer/ffmpeg/libavformat/avio.h
index a606f7cb..cc46ad79 100644
--- a/mplayer/ffmpeg/libavformat/avio.h
+++ b/mplayer/ffmpeg/libavformat/avio.h
@@ -63,9 +63,32 @@ typedef struct URLPollEntry {
int revents;
} URLPollEntry;
-#define URL_RDONLY 0
-#define URL_WRONLY 1
-#define URL_RDWR 2
+/**
+ * @defgroup open_modes URL open modes
+ * The flags argument to url_open and cosins must be one of the following
+ * constants, optionally ORed with other flags.
+ * @{
+ */
+#define URL_RDONLY 0 /**< read-only */
+#define URL_WRONLY 1 /**< write-only */
+#define URL_RDWR 2 /**< read-write */
+/**
+ * @}
+ */
+
+/**
+ * Use non-blocking mode.
+ * If this flag is set, operations on the context will return
+ * AVERROR(EAGAIN) if they can not be performed immediately.
+ * If this flag is not set, operations on the context will never return
+ * AVERROR(EAGAIN).
+ * Note that this flag does not affect the opening/connecting of the
+ * context. Connecting a protocol will always block if necessary (e.g. on
+ * network protocols) but never hang (e.g. on busy devices).
+ * Warning: non-blocking protocols is work-in-progress; this flag may be
+ * silently ignored.
+ */
+#define URL_FLAG_NONBLOCK 4
typedef int URLInterruptCB(void);
@@ -128,7 +151,6 @@ int url_read(URLContext *h, unsigned char *buf, int size);
/**
* Read as many bytes as possible (up to size), calling the
* read function multiple times if necessary.
- * Will also retry if the read function returns AVERROR(EAGAIN).
* This makes special short-read handling in applications
* unnecessary, if the return value is < size then it is
* certain there was either an error or the end of file was reached.
@@ -312,7 +334,7 @@ int av_register_protocol2(URLProtocol *protocol, int size);
* New fields can be added to the end with minor version bumps.
* Removal, reordering and changes to existing fields require a major
* version bump.
- * sizeof(ByteIOContext) must not be used outside libav*.
+ * sizeof(AVIOContext) must not be used outside libav*.
*/
typedef struct {
unsigned char *buffer;
@@ -335,9 +357,12 @@ typedef struct {
int (*read_pause)(void *opaque, int pause);
int64_t (*read_seek)(void *opaque, int stream_index,
int64_t timestamp, int flags);
-} ByteIOContext;
+} AVIOContext;
-int init_put_byte(ByteIOContext *s,
+#if FF_API_OLD_AVIO
+typedef attribute_deprecated AVIOContext ByteIOContext;
+
+attribute_deprecated int init_put_byte(AVIOContext *s,
unsigned char *buffer,
int buffer_size,
int write_flag,
@@ -345,7 +370,7 @@ int init_put_byte(ByteIOContext *s,
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int64_t (*seek)(void *opaque, int64_t offset, int whence));
-ByteIOContext *av_alloc_put_byte(
+attribute_deprecated AVIOContext *av_alloc_put_byte(
unsigned char *buffer,
int buffer_size,
int write_flag,
@@ -354,111 +379,151 @@ ByteIOContext *av_alloc_put_byte(
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int64_t (*seek)(void *opaque, int64_t offset, int whence));
-void put_byte(ByteIOContext *s, int b);
-void put_nbyte(ByteIOContext *s, int b, int count);
-void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
-void put_le64(ByteIOContext *s, uint64_t val);
-void put_be64(ByteIOContext *s, uint64_t val);
-void put_le32(ByteIOContext *s, unsigned int val);
-void put_be32(ByteIOContext *s, unsigned int val);
-void put_le24(ByteIOContext *s, unsigned int val);
-void put_be24(ByteIOContext *s, unsigned int val);
-void put_le16(ByteIOContext *s, unsigned int val);
-void put_be16(ByteIOContext *s, unsigned int val);
-void put_tag(ByteIOContext *s, const char *tag);
+/**
+ * @defgroup old_avio_funcs Old put_/get_*() functions
+ * @deprecated use the avio_ -prefixed functions instead.
+ * @{
+ */
+attribute_deprecated int get_buffer(AVIOContext *s, unsigned char *buf, int size);
+attribute_deprecated int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size);
+attribute_deprecated int get_byte(AVIOContext *s);
+attribute_deprecated unsigned int get_le16(AVIOContext *s);
+attribute_deprecated unsigned int get_le24(AVIOContext *s);
+attribute_deprecated unsigned int get_le32(AVIOContext *s);
+attribute_deprecated uint64_t get_le64(AVIOContext *s);
+attribute_deprecated unsigned int get_be16(AVIOContext *s);
+attribute_deprecated unsigned int get_be24(AVIOContext *s);
+attribute_deprecated unsigned int get_be32(AVIOContext *s);
+attribute_deprecated uint64_t get_be64(AVIOContext *s);
+
+attribute_deprecated void put_byte(AVIOContext *s, int b);
+attribute_deprecated void put_nbyte(AVIOContext *s, int b, int count);
+attribute_deprecated void put_buffer(AVIOContext *s, const unsigned char *buf, int size);
+attribute_deprecated void put_le64(AVIOContext *s, uint64_t val);
+attribute_deprecated void put_be64(AVIOContext *s, uint64_t val);
+attribute_deprecated void put_le32(AVIOContext *s, unsigned int val);
+attribute_deprecated void put_be32(AVIOContext *s, unsigned int val);
+attribute_deprecated void put_le24(AVIOContext *s, unsigned int val);
+attribute_deprecated void put_be24(AVIOContext *s, unsigned int val);
+attribute_deprecated void put_le16(AVIOContext *s, unsigned int val);
+attribute_deprecated void put_be16(AVIOContext *s, unsigned int val);
+attribute_deprecated void put_tag(AVIOContext *s, const char *tag);
+/**
+ * @}
+ */
+
+
+/**
+ * @defgroup old_url_f_funcs Old url_f* functions
+ * @deprecated use the avio_ -prefixed functions instead.
+ * @{
+ */
+attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags);
+attribute_deprecated int url_fclose(AVIOContext *s);
+attribute_deprecated int64_t url_fseek(AVIOContext *s, int64_t offset, int whence);
+attribute_deprecated int url_fskip(AVIOContext *s, int64_t offset);
+/**
+ * @}
+ */
+#endif
+
+AVIOContext *avio_alloc_context(
+ unsigned char *buffer,
+ int buffer_size,
+ int write_flag,
+ void *opaque,
+ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int64_t (*seek)(void *opaque, int64_t offset, int whence));
+
+void avio_w8(AVIOContext *s, int b);
+void avio_write(AVIOContext *s, const unsigned char *buf, int size);
+void avio_wl64(AVIOContext *s, uint64_t val);
+void avio_wb64(AVIOContext *s, uint64_t val);
+void avio_wl32(AVIOContext *s, unsigned int val);
+void avio_wb32(AVIOContext *s, unsigned int val);
+void avio_wl24(AVIOContext *s, unsigned int val);
+void avio_wb24(AVIOContext *s, unsigned int val);
+void avio_wl16(AVIOContext *s, unsigned int val);
+void avio_wb16(AVIOContext *s, unsigned int val);
#if FF_API_OLD_AVIO
-attribute_deprecated void put_strz(ByteIOContext *s, const char *buf);
+attribute_deprecated void put_strz(AVIOContext *s, const char *buf);
#endif
/**
* Write a NULL-terminated string.
* @return number of bytes written.
*/
-int avio_put_str(ByteIOContext *s, const char *str);
+int avio_put_str(AVIOContext *s, const char *str);
/**
* Convert an UTF-8 string to UTF-16LE and write it.
* @return number of bytes written.
*/
-int avio_put_str16le(ByteIOContext *s, const char *str);
+int avio_put_str16le(AVIOContext *s, const char *str);
/**
- * fseek() equivalent for ByteIOContext.
+ * fseek() equivalent for AVIOContext.
* @return new position or AVERROR.
*/
-int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence);
-
-/**
- * Skip given number of bytes forward.
- * @param offset number of bytes
- * @return 0 on success, <0 on error
- */
-int url_fskip(ByteIOContext *s, int64_t offset);
+int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
/**
- * ftell() equivalent for ByteIOContext.
+ * ftell() equivalent for AVIOContext.
* @return position or AVERROR.
*/
-int64_t url_ftell(ByteIOContext *s);
+int64_t url_ftell(AVIOContext *s);
/**
* Get the filesize.
* @return filesize or AVERROR
*/
-int64_t url_fsize(ByteIOContext *s);
+int64_t url_fsize(AVIOContext *s);
/**
- * feof() equivalent for ByteIOContext.
+ * feof() equivalent for AVIOContext.
* @return non zero if and only if end of file
*/
-int url_feof(ByteIOContext *s);
+int url_feof(AVIOContext *s);
-int url_ferror(ByteIOContext *s);
+int url_ferror(AVIOContext *s);
-int av_url_read_fpause(ByteIOContext *h, int pause);
-int64_t av_url_read_fseek(ByteIOContext *h, int stream_index,
+int av_url_read_fpause(AVIOContext *h, int pause);
+int64_t av_url_read_fseek(AVIOContext *h, int stream_index,
int64_t timestamp, int flags);
#define URL_EOF (-1)
/** @note return URL_EOF (-1) if EOF */
-int url_fgetc(ByteIOContext *s);
+int url_fgetc(AVIOContext *s);
/** @warning currently size is limited */
#ifdef __GNUC__
-int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
+int url_fprintf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
#else
-int url_fprintf(ByteIOContext *s, const char *fmt, ...);
+int url_fprintf(AVIOContext *s, const char *fmt, ...);
#endif
/** @note unlike fgets, the EOL character is not returned and a whole
line is parsed. return NULL if first char read was EOF */
-char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
+char *url_fgets(AVIOContext *s, char *buf, int buf_size);
-void put_flush_packet(ByteIOContext *s);
+void put_flush_packet(AVIOContext *s);
/**
- * Read size bytes from ByteIOContext into buf.
- * @return number of bytes read or AVERROR
- */
-int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
-
-/**
- * Read size bytes from ByteIOContext into buf.
- * This reads at most 1 packet. If that is not enough fewer bytes will be
- * returned.
+ * Read size bytes from AVIOContext into buf.
* @return number of bytes read or AVERROR
*/
-int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
+int avio_read(AVIOContext *s, unsigned char *buf, int size);
/** @note return 0 if EOF, so you cannot use it if EOF handling is
necessary */
-int get_byte(ByteIOContext *s);
-unsigned int get_le24(ByteIOContext *s);
-unsigned int get_le32(ByteIOContext *s);
-uint64_t get_le64(ByteIOContext *s);
-unsigned int get_le16(ByteIOContext *s);
+int avio_r8 (AVIOContext *s);
+unsigned int avio_rl16(AVIOContext *s);
+unsigned int avio_rl24(AVIOContext *s);
+unsigned int avio_rl32(AVIOContext *s);
+uint64_t avio_rl64(AVIOContext *s);
/**
* Read a UTF-16 string from pb and convert it to UTF-8.
@@ -466,77 +531,77 @@ unsigned int get_le16(ByteIOContext *s);
* encountered or maxlen bytes have been read.
* @return number of bytes read (is always <= maxlen)
*/
-int avio_get_str16le(ByteIOContext *pb, int maxlen, char *buf, int buflen);
-int avio_get_str16be(ByteIOContext *pb, int maxlen, char *buf, int buflen);
+int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
+int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
-char *get_strz(ByteIOContext *s, char *buf, int maxlen);
-unsigned int get_be16(ByteIOContext *s);
-unsigned int get_be24(ByteIOContext *s);
-unsigned int get_be32(ByteIOContext *s);
-uint64_t get_be64(ByteIOContext *s);
+char *get_strz(AVIOContext *s, char *buf, int maxlen);
+unsigned int avio_rb16(AVIOContext *s);
+unsigned int avio_rb24(AVIOContext *s);
+unsigned int avio_rb32(AVIOContext *s);
+uint64_t avio_rb64(AVIOContext *s);
-uint64_t ff_get_v(ByteIOContext *bc);
+uint64_t ff_get_v(AVIOContext *bc);
-static inline int url_is_streamed(ByteIOContext *s)
+static inline int url_is_streamed(AVIOContext *s)
{
return s->is_streamed;
}
/**
- * Create and initialize a ByteIOContext for accessing the
+ * Create and initialize a AVIOContext for accessing the
* resource referenced by the URLContext h.
* @note When the URLContext h has been opened in read+write mode, the
- * ByteIOContext can be used only for writing.
+ * AVIOContext can be used only for writing.
*
- * @param s Used to return the pointer to the created ByteIOContext.
+ * @param s Used to return the pointer to the created AVIOContext.
* In case of failure the pointed to value is set to NULL.
* @return 0 in case of success, a negative value corresponding to an
* AVERROR code in case of failure
*/
-int url_fdopen(ByteIOContext **s, URLContext *h);
+int url_fdopen(AVIOContext **s, URLContext *h);
/** @warning must be called before any I/O */
-int url_setbufsize(ByteIOContext *s, int buf_size);
+int url_setbufsize(AVIOContext *s, int buf_size);
#if FF_API_URL_RESETBUF
/** Reset the buffer for reading or writing.
* @note Will drop any data currently in the buffer without transmitting it.
* @param flags URL_RDONLY to set up the buffer for reading, or URL_WRONLY
* to set up the buffer for writing. */
-int url_resetbuf(ByteIOContext *s, int flags);
+int url_resetbuf(AVIOContext *s, int flags);
#endif
/**
- * Rewind the ByteIOContext using the specified buffer containing the first buf_size bytes of the file.
+ * Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file.
* Used after probing to avoid seeking.
* Joins buf and s->buffer, taking any overlap into consideration.
* @note s->buffer must overlap with buf or they can't be joined and the function fails
* @note This function is NOT part of the public API
*
- * @param s The read-only ByteIOContext to rewind
+ * @param s The read-only AVIOContext to rewind
* @param buf The probe buffer containing the first buf_size bytes of the file
* @param buf_size The size of buf
* @return 0 in case of success, a negative value corresponding to an
* AVERROR code in case of failure
*/
-int ff_rewind_with_probe_data(ByteIOContext *s, unsigned char *buf, int buf_size);
+int ff_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size);
/**
- * Create and initialize a ByteIOContext for accessing the
+ * Create and initialize a AVIOContext for accessing the
* resource indicated by url.
* @note When the resource indicated by url has been opened in
- * read+write mode, the ByteIOContext can be used only for writing.
+ * read+write mode, the AVIOContext can be used only for writing.
*
- * @param s Used to return the pointer to the created ByteIOContext.
+ * @param s Used to return the pointer to the created AVIOContext.
* In case of failure the pointed to value is set to NULL.
* @param flags flags which control how the resource indicated by url
* is to be opened
* @return 0 in case of success, a negative value corresponding to an
* AVERROR code in case of failure
*/
-int url_fopen(ByteIOContext **s, const char *url, int flags);
+int avio_open(AVIOContext **s, const char *url, int flags);
-int url_fclose(ByteIOContext *s);
-URLContext *url_fileno(ByteIOContext *s);
+int avio_close(AVIOContext *s);
+URLContext *url_fileno(AVIOContext *s);
/**
* Return the maximum packet size associated to packetized buffered file
@@ -546,12 +611,12 @@ URLContext *url_fileno(ByteIOContext *s);
* @param s buffered file handle
* @return maximum packet size in bytes
*/
-int url_fget_max_packet_size(ByteIOContext *s);
+int url_fget_max_packet_size(AVIOContext *s);
-int url_open_buf(ByteIOContext **s, uint8_t *buf, int buf_size, int flags);
+int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags);
/** return the written or read size */
-int url_close_buf(ByteIOContext *s);
+int url_close_buf(AVIOContext *s);
/**
* Open a write only memory stream.
@@ -559,7 +624,7 @@ int url_close_buf(ByteIOContext *s);
* @param s new IO context
* @return zero if no error.
*/
-int url_open_dyn_buf(ByteIOContext **s);
+int url_open_dyn_buf(AVIOContext **s);
/**
* Open a write only packetized memory stream with a maximum packet
@@ -570,7 +635,7 @@ int url_open_dyn_buf(ByteIOContext **s);
* @param max_packet_size maximum packet size (must be > 0)
* @return zero if no error.
*/
-int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size);
+int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
/**
* Return the written size and a pointer to the buffer. The buffer
@@ -582,12 +647,12 @@ int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size);
* @param pbuffer pointer to a byte buffer
* @return the length of the byte buffer
*/
-int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
+int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
unsigned int len);
-unsigned long get_checksum(ByteIOContext *s);
-void init_checksum(ByteIOContext *s,
+unsigned long get_checksum(AVIOContext *s);
+void init_checksum(AVIOContext *s,
unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
unsigned long checksum);
diff --git a/mplayer/ffmpeg/libavformat/avio_internal.h b/mplayer/ffmpeg/libavformat/avio_internal.h
new file mode 100644
index 00000000..3b38990f
--- /dev/null
+++ b/mplayer/ffmpeg/libavformat/avio_internal.h
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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 AVFORMAT_AVIO_INTERNAL_H
+#define AVFORMAT_AVIO_INTERNAL_H
+
+#include "avio.h"
+
+int ffio_init_context(AVIOContext *s,
+ unsigned char *buffer,
+ int buffer_size,
+ int write_flag,
+ void *opaque,
+ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int64_t (*seek)(void *opaque, int64_t offset, int whence));
+
+
+/**
+ * Read size bytes from AVIOContext into buf.
+ * This reads at most 1 packet. If that is not enough fewer bytes will be
+ * returned.
+ * @return number of bytes read or AVERROR
+ */
+int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size);
+
+void ffio_fill(AVIOContext *s, int b, int count);
+
+#define ffio_wfourcc(pb, str) avio_wl32(pb, MKTAG((str)[0], (str)[1], (str)[2], (str)[3]))
+
+#endif // AVFORMAT_AVIO_INTERNAL_H
diff --git a/mplayer/ffmpeg/libavformat/aviobuf.c b/mplayer/ffmpeg/libavformat/aviobuf.c
index acea8111..3f3721c5 100644
--- a/mplayer/ffmpeg/libavformat/aviobuf.c
+++ b/mplayer/ffmpeg/libavformat/aviobuf.c
@@ -23,6 +23,7 @@
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "avio.h"
+#include "avio_internal.h"
#include "internal.h"
#include
@@ -35,12 +36,12 @@
*/
#define SHORT_SEEK_THRESHOLD 4096
-static void fill_buffer(ByteIOContext *s);
+static void fill_buffer(AVIOContext *s);
#if !FF_API_URL_RESETBUF
-static int url_resetbuf(ByteIOContext *s, int flags);
+static int url_resetbuf(AVIOContext *s, int flags);
#endif
-int init_put_byte(ByteIOContext *s,
+int ffio_init_context(AVIOContext *s,
unsigned char *buffer,
int buffer_size,
int write_flag,
@@ -73,7 +74,8 @@ int init_put_byte(ByteIOContext *s,
return 0;
}
-ByteIOContext *av_alloc_put_byte(
+#if FF_API_OLD_AVIO
+int init_put_byte(AVIOContext *s,
unsigned char *buffer,
int buffer_size,
int write_flag,
@@ -82,13 +84,39 @@ ByteIOContext *av_alloc_put_byte(
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int64_t (*seek)(void *opaque, int64_t offset, int whence))
{
- ByteIOContext *s = av_mallocz(sizeof(ByteIOContext));
- init_put_byte(s, buffer, buffer_size, write_flag, opaque,
+ return ffio_init_context(s, buffer, buffer_size, write_flag, opaque,
+ read_packet, write_packet, seek);
+}
+AVIOContext *av_alloc_put_byte(
+ unsigned char *buffer,
+ int buffer_size,
+ int write_flag,
+ void *opaque,
+ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int64_t (*seek)(void *opaque, int64_t offset, int whence))
+{
+ return avio_alloc_context(buffer, buffer_size, write_flag, opaque,
+ read_packet, write_packet, seek);
+}
+#endif
+
+AVIOContext *avio_alloc_context(
+ unsigned char *buffer,
+ int buffer_size,
+ int write_flag,
+ void *opaque,
+ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
+ int64_t (*seek)(void *opaque, int64_t offset, int whence))
+{
+ AVIOContext *s = av_mallocz(sizeof(AVIOContext));
+ ffio_init_context(s, buffer, buffer_size, write_flag, opaque,
read_packet, write_packet, seek);
return s;
}
-static void flush_buffer(ByteIOContext *s)
+static void flush_buffer(AVIOContext *s)
{
if (s->buf_ptr > s->buffer) {
if (s->write_packet && !s->error){
@@ -106,14 +134,14 @@ static void flush_buffer(ByteIOContext *s)
s->buf_ptr = s->buffer;
}
-void put_byte(ByteIOContext *s, int b)
+void avio_w8(AVIOContext *s, int b)
{
*(s->buf_ptr)++ = b;
if (s->buf_ptr >= s->buf_end)
flush_buffer(s);
}
-void put_nbyte(ByteIOContext *s, int b, int count)
+void ffio_fill(AVIOContext *s, int b, int count)
{
while (count > 0) {
int len = FFMIN(s->buf_end - s->buf_ptr, count);
@@ -127,7 +155,7 @@ void put_nbyte(ByteIOContext *s, int b, int count)
}
}
-void put_buffer(ByteIOContext *s, const unsigned char *buf, int size)
+void avio_write(AVIOContext *s, const unsigned char *buf, int size)
{
while (size > 0) {
int len = FFMIN(s->buf_end - s->buf_ptr, size);
@@ -142,13 +170,13 @@ void put_buffer(ByteIOContext *s, const unsigned char *buf, int size)
}
}
-void put_flush_packet(ByteIOContext *s)
+void put_flush_packet(AVIOContext *s)
{
flush_buffer(s);
s->must_flush = 0;
}
-int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence)
+int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
{
int64_t offset1;
int64_t pos;
@@ -205,18 +233,20 @@ int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence)
return offset;
}
-int url_fskip(ByteIOContext *s, int64_t offset)
+#if FF_API_OLD_AVIO
+int url_fskip(AVIOContext *s, int64_t offset)
{
- int64_t ret = url_fseek(s, offset, SEEK_CUR);
+ int64_t ret = avio_seek(s, offset, SEEK_CUR);
return ret < 0 ? ret : 0;
}
+#endif
-int64_t url_ftell(ByteIOContext *s)
+int64_t url_ftell(AVIOContext *s)
{
- return url_fseek(s, 0, SEEK_CUR);
+ return avio_seek(s, 0, SEEK_CUR);
}
-int64_t url_fsize(ByteIOContext *s)
+int64_t url_fsize(AVIOContext *s)
{
int64_t size;
@@ -235,55 +265,126 @@ int64_t url_fsize(ByteIOContext *s)
return size;
}
-int url_feof(ByteIOContext *s)
+int url_feof(AVIOContext *s)
{
if(!s)
return 0;
return s->eof_reached;
}
-int url_ferror(ByteIOContext *s)
+int url_ferror(AVIOContext *s)
{
if(!s)
return 0;
return s->error;
}
-void put_le32(ByteIOContext *s, unsigned int val)
+void avio_wl32(AVIOContext *s, unsigned int val)
{
- put_byte(s, val);
- put_byte(s, val >> 8);
- put_byte(s, val >> 16);
- put_byte(s, val >> 24);
+ avio_w8(s, val);
+ avio_w8(s, val >> 8);
+ avio_w8(s, val >> 16);
+ avio_w8(s, val >> 24);
}
-void put_be32(ByteIOContext *s, unsigned int val)
+void avio_wb32(AVIOContext *s, unsigned int val)
{
- put_byte(s, val >> 24);
- put_byte(s, val >> 16);
- put_byte(s, val >> 8);
- put_byte(s, val);
+ avio_w8(s, val >> 24);
+ avio_w8(s, val >> 16);
+ avio_w8(s, val >> 8);
+ avio_w8(s, val);
}
#if FF_API_OLD_AVIO
-void put_strz(ByteIOContext *s, const char *str)
+void put_strz(AVIOContext *s, const char *str)
{
avio_put_str(s, str);
}
+
+#define GET(name, type) \
+ type get_be ##name(AVIOContext *s) \
+{\
+ return avio_rb ##name(s);\
+}\
+ type get_le ##name(AVIOContext *s) \
+{\
+ return avio_rl ##name(s);\
+}
+
+GET(16, unsigned int)
+GET(24, unsigned int)
+GET(32, unsigned int)
+GET(64, uint64_t)
+
+#undef GET
+
+#define PUT(name, type ) \
+ void put_le ##name(AVIOContext *s, type val)\
+{\
+ avio_wl ##name(s, val);\
+}\
+ void put_be ##name(AVIOContext *s, type val)\
+{\
+ avio_wb ##name(s, val);\
+}
+
+PUT(16, unsigned int)
+PUT(24, unsigned int)
+PUT(32, unsigned int)
+PUT(64, uint64_t)
+#undef PUT
+
+int get_byte(AVIOContext *s)
+{
+ return avio_r8(s);
+}
+int get_buffer(AVIOContext *s, unsigned char *buf, int size)
+{
+ return avio_read(s, buf, size);
+}
+int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size)
+{
+ return ffio_read_partial(s, buf, size);
+}
+void put_byte(AVIOContext *s, int val)
+{
+ avio_w8(s, val);
+}
+void put_buffer(AVIOContext *s, const unsigned char *buf, int size)
+{
+ avio_write(s, buf, size);
+}
+void put_nbyte(AVIOContext *s, int b, int count)
+{
+ ffio_fill(s, b, count);
+}
+
+int url_fopen(AVIOContext **s, const char *filename, int flags)
+{
+ return avio_open(s, filename, flags);
+}
+int url_fclose(AVIOContext *s)
+{
+ return avio_close(s);
+}
+int64_t url_fseek(AVIOContext *s, int64_t offset, int whence)
+{
+ return avio_seek(s, offset, whence);
+}
#endif
-int avio_put_str(ByteIOContext *s, const char *str)
+int avio_put_str(AVIOContext *s, const char *str)
{
int len = 1;
if (str) {
len += strlen(str);
- put_buffer(s, (const unsigned char *) str, len);
+ avio_write(s, (const unsigned char *) str, len);
} else
- put_byte(s, 0);
+ avio_w8(s, 0);
return len;
}
-int avio_put_str16le(ByteIOContext *s, const char *str)
+int avio_put_str16le(AVIOContext *s, const char *str)
{
const uint8_t *q = str;
int ret = 0;
@@ -293,9 +394,9 @@ int avio_put_str16le(ByteIOContext *s, const char *str)
uint16_t tmp;
GET_UTF8(ch, *q++, break;)
- PUT_UTF16(ch, tmp, put_le16(s, tmp);ret += 2;)
+ PUT_UTF16(ch, tmp, avio_wl16(s, tmp);ret += 2;)
}
- put_le16(s, 0);
+ avio_wl16(s, 0);
ret += 2;
return ret;
}
@@ -309,63 +410,65 @@ int ff_get_v_length(uint64_t val){
return i;
}
-void ff_put_v(ByteIOContext *bc, uint64_t val){
+void ff_put_v(AVIOContext *bc, uint64_t val){
int i= ff_get_v_length(val);
while(--i>0)
- put_byte(bc, 128 | (val>>(7*i)));
+ avio_w8(bc, 128 | (val>>(7*i)));
- put_byte(bc, val&127);
+ avio_w8(bc, val&127);
}
-void put_le64(ByteIOContext *s, uint64_t val)
+void avio_wl64(AVIOContext *s, uint64_t val)
{
- put_le32(s, (uint32_t)(val & 0xffffffff));
- put_le32(s, (uint32_t)(val >> 32));
+ avio_wl32(s, (uint32_t)(val & 0xffffffff));
+ avio_wl32(s, (uint32_t)(val >> 32));
}
-void put_be64(ByteIOContext *s, uint64_t val)
+void avio_wb64(AVIOContext *s, uint64_t val)
{
- put_be32(s, (uint32_t)(val >> 32));
- put_be32(s, (uint32_t)(val & 0xffffffff));
+ avio_wb32(s, (uint32_t)(val >> 32));
+ avio_wb32(s, (uint32_t)(val & 0xffffffff));
}
-void put_le16(ByteIOContext *s, unsigned int val)
+void avio_wl16(AVIOContext *s, unsigned int val)
{
- put_byte(s, val);
- put_byte(s, val >> 8);
+ avio_w8(s, val);
+ avio_w8(s, val >> 8);
}
-void put_be16(ByteIOContext *s, unsigned int val)
+void avio_wb16(AVIOContext *s, unsigned int val)
{
- put_byte(s, val >> 8);
- put_byte(s, val);
+ avio_w8(s, val >> 8);
+ avio_w8(s, val);
}
-void put_le24(ByteIOContext *s, unsigned int val)
+void avio_wl24(AVIOContext *s, unsigned int val)
{
- put_le16(s, val & 0xffff);
- put_byte(s, val >> 16);
+ avio_wl16(s, val & 0xffff);
+ avio_w8(s, val >> 16);
}
-void put_be24(ByteIOContext *s, unsigned int val)
+void avio_wb24(AVIOContext *s, unsigned int val)
{
- put_be16(s, val >> 8);
- put_byte(s, val);
+ avio_wb16(s, val >> 8);
+ avio_w8(s, val);
}
-void put_tag(ByteIOContext *s, const char *tag)
+#if FF_API_OLD_AVIO
+void put_tag(AVIOContext *s, const char *tag)
{
while (*tag) {
- put_byte(s, *tag++);
+ avio_w8(s, *tag++);
}
}
+#endif
/* Input stream */
-static void fill_buffer(ByteIOContext *s)
+static void fill_buffer(AVIOContext *s)
{
- uint8_t *dst= !s->max_packet_size && s->buf_end - s->buffer < s->buffer_size ? s->buf_ptr : s->buffer;
+ uint8_t *dst= !s->max_packet_size && s->buf_end - s->buffer < s->buffer_size ? s->buf_end : s->buffer;
int len= s->buffer_size - (dst - s->buffer);
int max_buffer_size = s->max_packet_size ? s->max_packet_size : IO_BUFFER_SIZE;
@@ -410,14 +513,14 @@ unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
return av_crc(av_crc_get_table(AV_CRC_32_IEEE), checksum, buf, len);
}
-unsigned long get_checksum(ByteIOContext *s)
+unsigned long get_checksum(AVIOContext *s)
{
s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_ptr - s->checksum_ptr);
s->update_checksum= NULL;
return s->checksum;
}
-void init_checksum(ByteIOContext *s,
+void init_checksum(AVIOContext *s,
unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
unsigned long checksum)
{
@@ -429,7 +532,7 @@ void init_checksum(ByteIOContext *s,
}
/* XXX: put an inline version */
-int get_byte(ByteIOContext *s)
+int avio_r8(AVIOContext *s)
{
if (s->buf_ptr >= s->buf_end)
fill_buffer(s);
@@ -438,7 +541,7 @@ int get_byte(ByteIOContext *s)
return 0;
}
-int url_fgetc(ByteIOContext *s)
+int url_fgetc(AVIOContext *s)
{
if (s->buf_ptr >= s->buf_end)
fill_buffer(s);
@@ -447,7 +550,7 @@ int url_fgetc(ByteIOContext *s)
return URL_EOF;
}
-int get_buffer(ByteIOContext *s, unsigned char *buf, int size)
+int avio_read(AVIOContext *s, unsigned char *buf, int size)
{
int len, size1;
@@ -494,7 +597,7 @@ int get_buffer(ByteIOContext *s, unsigned char *buf, int size)
return size1 - size;
}
-int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size)
+int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size)
{
int len;
@@ -517,67 +620,67 @@ int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size)
return len;
}
-unsigned int get_le16(ByteIOContext *s)
+unsigned int avio_rl16(AVIOContext *s)
{
unsigned int val;
- val = get_byte(s);
- val |= get_byte(s) << 8;
+ val = avio_r8(s);
+ val |= avio_r8(s) << 8;
return val;
}
-unsigned int get_le24(ByteIOContext *s)
+unsigned int avio_rl24(AVIOContext *s)
{
unsigned int val;
- val = get_le16(s);
- val |= get_byte(s) << 16;
+ val = avio_rl16(s);
+ val |= avio_r8(s) << 16;
return val;
}
-unsigned int get_le32(ByteIOContext *s)
+unsigned int avio_rl32(AVIOContext *s)
{
unsigned int val;
- val = get_le16(s);
- val |= get_le16(s) << 16;
+ val = avio_rl16(s);
+ val |= avio_rl16(s) << 16;
return val;
}
-uint64_t get_le64(ByteIOContext *s)
+uint64_t avio_rl64(AVIOContext *s)
{
uint64_t val;
- val = (uint64_t)get_le32(s);
- val |= (uint64_t)get_le32(s) << 32;
+ val = (uint64_t)avio_rl32(s);
+ val |= (uint64_t)avio_rl32(s) << 32;
return val;
}
-unsigned int get_be16(ByteIOContext *s)
+unsigned int avio_rb16(AVIOContext *s)
{
unsigned int val;
- val = get_byte(s) << 8;
- val |= get_byte(s);
+ val = avio_r8(s) << 8;
+ val |= avio_r8(s);
return val;
}
-unsigned int get_be24(ByteIOContext *s)
+unsigned int avio_rb24(AVIOContext *s)
{
unsigned int val;
- val = get_be16(s) << 8;
- val |= get_byte(s);
+ val = avio_rb16(s) << 8;
+ val |= avio_r8(s);
return val;
}
-unsigned int get_be32(ByteIOContext *s)
+unsigned int avio_rb32(AVIOContext *s)
{
unsigned int val;
- val = get_be16(s) << 16;
- val |= get_be16(s);
+ val = avio_rb16(s) << 16;
+ val |= avio_rb16(s);
return val;
}
-char *get_strz(ByteIOContext *s, char *buf, int maxlen)
+char *get_strz(AVIOContext *s, char *buf, int maxlen)
{
int i = 0;
char c;
- while ((c = get_byte(s))) {
+ while ((c = avio_r8(s))) {
if (i < maxlen-1)
buf[i++] = c;
}
@@ -587,13 +690,13 @@ char *get_strz(ByteIOContext *s, char *buf, int maxlen)
return buf;
}
-int ff_get_line(ByteIOContext *s, char *buf, int maxlen)
+int ff_get_line(AVIOContext *s, char *buf, int maxlen)
{
int i = 0;
char c;
do {
- c = get_byte(s);
+ c = avio_r8(s);
if (c && i < maxlen-1)
buf[i++] = c;
} while (c != '\n' && c);
@@ -603,7 +706,7 @@ int ff_get_line(ByteIOContext *s, char *buf, int maxlen)
}
#define GET_STR16(type, read) \
- int avio_get_str16 ##type(ByteIOContext *pb, int maxlen, char *buf, int buflen)\
+ int avio_get_str16 ##type(AVIOContext *pb, int maxlen, char *buf, int buflen)\
{\
char* q = buf;\
int ret = 0;\
@@ -619,31 +722,31 @@ int ff_get_line(ByteIOContext *s, char *buf, int maxlen)
return ret;\
}\
-GET_STR16(le, get_le16)
-GET_STR16(be, get_be16)
+GET_STR16(le, avio_rl16)
+GET_STR16(be, avio_rb16)
#undef GET_STR16
-uint64_t get_be64(ByteIOContext *s)
+uint64_t avio_rb64(AVIOContext *s)
{
uint64_t val;
- val = (uint64_t)get_be32(s) << 32;
- val |= (uint64_t)get_be32(s);
+ val = (uint64_t)avio_rb32(s) << 32;
+ val |= (uint64_t)avio_rb32(s);
return val;
}
-uint64_t ff_get_v(ByteIOContext *bc){
+uint64_t ff_get_v(AVIOContext *bc){
uint64_t val = 0;
int tmp;
do{
- tmp = get_byte(bc);
+ tmp = avio_r8(bc);
val= (val<<7) + (tmp&127);
}while(tmp&128);
return val;
}
-int url_fdopen(ByteIOContext **s, URLContext *h)
+int url_fdopen(AVIOContext **s, URLContext *h)
{
uint8_t *buffer;
int buffer_size, max_packet_size;
@@ -658,13 +761,13 @@ int url_fdopen(ByteIOContext **s, URLContext *h)
if (!buffer)
return AVERROR(ENOMEM);
- *s = av_mallocz(sizeof(ByteIOContext));
+ *s = av_mallocz(sizeof(AVIOContext));
if(!*s) {
av_free(buffer);
return AVERROR(ENOMEM);
}
- if (init_put_byte(*s, buffer, buffer_size,
+ if (ffio_init_context(*s, buffer, buffer_size,
(h->flags & URL_WRONLY || h->flags & URL_RDWR), h,
url_read, url_write, url_seek) < 0) {
av_free(buffer);
@@ -680,7 +783,7 @@ int url_fdopen(ByteIOContext **s, URLContext *h)
return 0;
}
-int url_setbufsize(ByteIOContext *s, int buf_size)
+int url_setbufsize(AVIOContext *s, int buf_size)
{
uint8_t *buffer;
buffer = av_malloc(buf_size);
@@ -696,9 +799,9 @@ int url_setbufsize(ByteIOContext *s, int buf_size)
}
#if FF_API_URL_RESETBUF
-int url_resetbuf(ByteIOContext *s, int flags)
+int url_resetbuf(AVIOContext *s, int flags)
#else
-static int url_resetbuf(ByteIOContext *s, int flags)
+static int url_resetbuf(AVIOContext *s, int flags)
#endif
{
#if FF_API_URL_RESETBUF
@@ -718,7 +821,7 @@ static int url_resetbuf(ByteIOContext *s, int flags)
return 0;
}
-int ff_rewind_with_probe_data(ByteIOContext *s, unsigned char *buf, int buf_size)
+int ff_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size)
{
int64_t buffer_start;
int buffer_size;
@@ -757,7 +860,7 @@ int ff_rewind_with_probe_data(ByteIOContext *s, unsigned char *buf, int buf_size
return 0;
}
-int url_fopen(ByteIOContext **s, const char *filename, int flags)
+int avio_open(AVIOContext **s, const char *filename, int flags)
{
URLContext *h;
int err;
@@ -773,7 +876,7 @@ int url_fopen(ByteIOContext **s, const char *filename, int flags)
return 0;
}
-int url_fclose(ByteIOContext *s)
+int avio_close(AVIOContext *s)
{
URLContext *h = s->opaque;
@@ -782,13 +885,13 @@ int url_fclose(ByteIOContext *s)
return url_close(h);
}
-URLContext *url_fileno(ByteIOContext *s)
+URLContext *url_fileno(AVIOContext *s)
{
return s->opaque;
}
#if CONFIG_MUXERS
-int url_fprintf(ByteIOContext *s, const char *fmt, ...)
+int url_fprintf(AVIOContext *s, const char *fmt, ...)
{
va_list ap;
char buf[4096];
@@ -797,12 +900,12 @@ int url_fprintf(ByteIOContext *s, const char *fmt, ...)
va_start(ap, fmt);
ret = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
- put_buffer(s, buf, strlen(buf));
+ avio_write(s, buf, strlen(buf));
return ret;
}
#endif //CONFIG_MUXERS
-char *url_fgets(ByteIOContext *s, char *buf, int buf_size)
+char *url_fgets(AVIOContext *s, char *buf, int buf_size)
{
int c;
char *q;
@@ -823,19 +926,19 @@ char *url_fgets(ByteIOContext *s, char *buf, int buf_size)
return buf;
}
-int url_fget_max_packet_size(ByteIOContext *s)
+int url_fget_max_packet_size(AVIOContext *s)
{
return s->max_packet_size;
}
-int av_url_read_fpause(ByteIOContext *s, int pause)
+int av_url_read_fpause(AVIOContext *s, int pause)
{
if (!s->read_pause)
return AVERROR(ENOSYS);
return s->read_pause(s->opaque, pause);
}
-int64_t av_url_read_fseek(ByteIOContext *s, int stream_index,
+int64_t av_url_read_fseek(AVIOContext *s, int stream_index,
int64_t timestamp, int flags)
{
URLContext *h = s->opaque;
@@ -859,13 +962,13 @@ int64_t av_url_read_fseek(ByteIOContext *s, int stream_index,
* back to the server even if CONFIG_MUXERS is false. */
#if CONFIG_MUXERS || CONFIG_NETWORK
/* buffer handling */
-int url_open_buf(ByteIOContext **s, uint8_t *buf, int buf_size, int flags)
+int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags)
{
int ret;
- *s = av_mallocz(sizeof(ByteIOContext));
+ *s = av_mallocz(sizeof(AVIOContext));
if(!*s)
return AVERROR(ENOMEM);
- ret = init_put_byte(*s, buf, buf_size,
+ ret = ffio_init_context(*s, buf, buf_size,
(flags & URL_WRONLY || flags & URL_RDWR),
NULL, NULL, NULL, NULL);
if(ret != 0)
@@ -873,7 +976,7 @@ int url_open_buf(ByteIOContext **s, uint8_t *buf, int buf_size, int flags)
return ret;
}
-int url_close_buf(ByteIOContext *s)
+int url_close_buf(AVIOContext *s)
{
put_flush_packet(s);
return s->buf_ptr - s->buffer;
@@ -947,7 +1050,7 @@ static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence)
return 0;
}
-static int url_open_dyn_buf_internal(ByteIOContext **s, int max_packet_size)
+static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size)
{
DynBuffer *d;
int ret;
@@ -958,13 +1061,13 @@ static int url_open_dyn_buf_internal(ByteIOContext **s, int max_packet_size)
d = av_mallocz(sizeof(DynBuffer) + io_buffer_size);
if (!d)
return AVERROR(ENOMEM);
- *s = av_mallocz(sizeof(ByteIOContext));
+ *s = av_mallocz(sizeof(AVIOContext));
if(!*s) {
av_free(d);
return AVERROR(ENOMEM);
}
d->io_buffer_size = io_buffer_size;
- ret = init_put_byte(*s, d->io_buffer, io_buffer_size,
+ ret = ffio_init_context(*s, d->io_buffer, io_buffer_size,
1, d, NULL,
max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
max_packet_size ? NULL : dyn_buf_seek);
@@ -977,19 +1080,19 @@ static int url_open_dyn_buf_internal(ByteIOContext **s, int max_packet_size)
return ret;
}
-int url_open_dyn_buf(ByteIOContext **s)
+int url_open_dyn_buf(AVIOContext **s)
{
return url_open_dyn_buf_internal(s, 0);
}
-int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size)
+int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
{
if (max_packet_size <= 0)
return -1;
return url_open_dyn_buf_internal(s, max_packet_size);
}
-int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer)
+int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
{
DynBuffer *d = s->opaque;
int size;
@@ -998,7 +1101,7 @@ int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer)
/* don't attempt to pad fixed-size packet buffers */
if (!s->max_packet_size) {
- put_buffer(s, padbuf, sizeof(padbuf));
+ avio_write(s, padbuf, sizeof(padbuf));
padding = FF_INPUT_BUFFER_PADDING_SIZE;
}
diff --git a/mplayer/ffmpeg/libavformat/avs.c b/mplayer/ffmpeg/libavformat/avs.c
index 2e1b2243..476c0a9a 100644
--- a/mplayer/ffmpeg/libavformat/avs.c
+++ b/mplayer/ffmpeg/libavformat/avs.c
@@ -61,12 +61,12 @@ static int avs_read_header(AVFormatContext * s, AVFormatParameters * ap)
s->ctx_flags |= AVFMTCTX_NOHEADER;
- url_fskip(s->pb, 4);
- avs->width = get_le16(s->pb);
- avs->height = get_le16(s->pb);
- avs->bits_per_sample = get_le16(s->pb);
- avs->fps = get_le16(s->pb);
- avs->nb_frames = get_le32(s->pb);
+ avio_seek(s->pb, 4, SEEK_CUR);
+ avs->width = avio_rl16(s->pb);
+ avs->height = avio_rl16(s->pb);
+ avs->bits_per_sample = avio_rl16(s->pb);
+ avs->fps = avio_rl16(s->pb);
+ avs->nb_frames = avio_rl32(s->pb);
avs->remaining_frame_size = 0;
avs->remaining_audio_size = 0;
@@ -104,7 +104,7 @@ avs_read_video_packet(AVFormatContext * s, AVPacket * pkt,
pkt->data[palette_size + 1] = type;
pkt->data[palette_size + 2] = size & 0xFF;
pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
- ret = get_buffer(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
+ ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
if (ret < size) {
av_free_packet(pkt);
return AVERROR(EIO);
@@ -154,20 +154,20 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
while (1) {
if (avs->remaining_frame_size <= 0) {
- if (!get_le16(s->pb)) /* found EOF */
+ if (!avio_rl16(s->pb)) /* found EOF */
return AVERROR(EIO);
- avs->remaining_frame_size = get_le16(s->pb) - 4;
+ avs->remaining_frame_size = avio_rl16(s->pb) - 4;
}
while (avs->remaining_frame_size > 0) {
- sub_type = get_byte(s->pb);
- type = get_byte(s->pb);
- size = get_le16(s->pb);
+ sub_type = avio_r8(s->pb);
+ type = avio_r8(s->pb);
+ size = avio_rl16(s->pb);
avs->remaining_frame_size -= size;
switch (type) {
case AVS_PALETTE:
- ret = get_buffer(s->pb, palette, size - 4);
+ ret = avio_read(s->pb, palette, size - 4);
if (ret < size - 4)
return AVERROR(EIO);
palette_size = size;
@@ -204,7 +204,7 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
break;
default:
- url_fskip(s->pb, size - 4);
+ avio_seek(s->pb, size - 4, SEEK_CUR);
}
}
}
diff --git a/mplayer/ffmpeg/libavformat/bethsoftvid.c b/mplayer/ffmpeg/libavformat/bethsoftvid.c
index 97e8e7e0..00b3ea2a 100644
--- a/mplayer/ffmpeg/libavformat/bethsoftvid.c
+++ b/mplayer/ffmpeg/libavformat/bethsoftvid.c
@@ -60,15 +60,15 @@ static int vid_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
BVID_DemuxContext *vid = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *stream;
/* load main header. Contents:
* bytes: 'V' 'I' 'D'
* int16s: always_512, nframes, width, height, delay, always_14
*/
- url_fseek(pb, 5, SEEK_CUR);
- vid->nframes = get_le16(pb);
+ avio_seek(pb, 5, SEEK_CUR);
+ vid->nframes = avio_rl16(pb);
stream = av_new_stream(s, 0);
if (!stream)
@@ -76,11 +76,11 @@ static int vid_read_header(AVFormatContext *s,
av_set_pts_info(stream, 32, 1, 60); // 16 ms increments, i.e. 60 fps
stream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
stream->codec->codec_id = CODEC_ID_BETHSOFTVID;
- stream->codec->width = get_le16(pb);
- stream->codec->height = get_le16(pb);
+ stream->codec->width = avio_rl16(pb);
+ stream->codec->height = avio_rl16(pb);
stream->codec->pix_fmt = PIX_FMT_PAL8;
- vid->bethsoft_global_delay = get_le16(pb);
- get_le16(pb);
+ vid->bethsoft_global_delay = avio_rl16(pb);
+ avio_rl16(pb);
// done with video codec, set up audio codec
stream = av_new_stream(s, 0);
@@ -97,7 +97,7 @@ static int vid_read_header(AVFormatContext *s,
}
#define BUFFER_PADDING_SIZE 1000
-static int read_frame(BVID_DemuxContext *vid, ByteIOContext *pb, AVPacket *pkt,
+static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
uint8_t block_type, AVFormatContext *s, int npixels)
{
uint8_t * vidbuf_start = NULL;
@@ -117,11 +117,11 @@ static int read_frame(BVID_DemuxContext *vid, ByteIOContext *pb, AVPacket *pkt,
vidbuf_start[vidbuf_nbytes++] = block_type;
// get the video delay (next int16), and set the presentation time
- vid->video_pts += vid->bethsoft_global_delay + get_le16(pb);
+ vid->video_pts += vid->bethsoft_global_delay + avio_rl16(pb);
// set the y offset if it exists (decoder header data should be in data section)
if(block_type == VIDEO_YOFF_P_FRAME){
- if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], 2) != 2)
+ if(avio_read(pb, &vidbuf_start[vidbuf_nbytes], 2) != 2)
goto fail;
vidbuf_nbytes += 2;
}
@@ -131,22 +131,22 @@ static int read_frame(BVID_DemuxContext *vid, ByteIOContext *pb, AVPacket *pkt,
if(!vidbuf_start)
return AVERROR(ENOMEM);
- code = get_byte(pb);
+ code = avio_r8(pb);
vidbuf_start[vidbuf_nbytes++] = code;
if(code >= 0x80){ // rle sequence
if(block_type == VIDEO_I_FRAME)
- vidbuf_start[vidbuf_nbytes++] = get_byte(pb);
+ vidbuf_start[vidbuf_nbytes++] = avio_r8(pb);
} else if(code){ // plain sequence
- if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], code) != code)
+ if(avio_read(pb, &vidbuf_start[vidbuf_nbytes], code) != code)
goto fail;
vidbuf_nbytes += code;
}
bytes_copied += code & 0x7F;
if(bytes_copied == npixels){ // sometimes no stop character is given, need to keep track of bytes copied
// may contain a 0 byte even if read all pixels
- if(get_byte(pb))
- url_fseek(pb, -1, SEEK_CUR);
+ if(avio_r8(pb))
+ avio_seek(pb, -1, SEEK_CUR);
break;
}
if(bytes_copied > npixels)
@@ -174,7 +174,7 @@ static int vid_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
BVID_DemuxContext *vid = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned char block_type;
int audio_length;
int ret_value;
@@ -182,10 +182,10 @@ static int vid_read_packet(AVFormatContext *s,
if(vid->is_finished || url_feof(pb))
return AVERROR(EIO);
- block_type = get_byte(pb);
+ block_type = avio_r8(pb);
switch(block_type){
case PALETTE_BLOCK:
- url_fseek(pb, -1, SEEK_CUR); // include block type
+ avio_seek(pb, -1, SEEK_CUR); // include block type
ret_value = av_get_packet(pb, pkt, 3 * 256 + 1);
if(ret_value != 3 * 256 + 1){
av_free_packet(pkt);
@@ -195,12 +195,12 @@ static int vid_read_packet(AVFormatContext *s,
return ret_value;
case FIRST_AUDIO_BLOCK:
- get_le16(pb);
+ avio_rl16(pb);
// soundblaster DAC used for sample rate, as on specification page (link above)
- s->streams[1]->codec->sample_rate = 1000000 / (256 - get_byte(pb));
+ s->streams[1]->codec->sample_rate = 1000000 / (256 - avio_r8(pb));
s->streams[1]->codec->bit_rate = s->streams[1]->codec->channels * s->streams[1]->codec->sample_rate * s->streams[1]->codec->bits_per_coded_sample;
case AUDIO_BLOCK:
- audio_length = get_le16(pb);
+ audio_length = avio_rl16(pb);
ret_value = av_get_packet(pb, pkt, audio_length);
pkt->stream_index = 1;
return ret_value != audio_length ? AVERROR(EIO) : ret_value;
diff --git a/mplayer/ffmpeg/libavformat/bfi.c b/mplayer/ffmpeg/libavformat/bfi.c
index 3b1c9aa9..21676e44 100644
--- a/mplayer/ffmpeg/libavformat/bfi.c
+++ b/mplayer/ffmpeg/libavformat/bfi.c
@@ -49,7 +49,7 @@ static int bfi_probe(AVProbeData * p)
static int bfi_read_header(AVFormatContext * s, AVFormatParameters * ap)
{
BFIContext *bfi = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *vstream;
AVStream *astream;
int fps, chunk_header;
@@ -65,25 +65,25 @@ static int bfi_read_header(AVFormatContext * s, AVFormatParameters * ap)
return AVERROR(ENOMEM);
/* Set the total number of frames. */
- url_fskip(pb, 8);
- chunk_header = get_le32(pb);
- bfi->nframes = get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- fps = get_le32(pb);
- url_fskip(pb, 12);
- vstream->codec->width = get_le32(pb);
- vstream->codec->height = get_le32(pb);
+ avio_seek(pb, 8, SEEK_CUR);
+ chunk_header = avio_rl32(pb);
+ bfi->nframes = avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ fps = avio_rl32(pb);
+ avio_seek(pb, 12, SEEK_CUR);
+ vstream->codec->width = avio_rl32(pb);
+ vstream->codec->height = avio_rl32(pb);
/*Load the palette to extradata */
- url_fskip(pb, 8);
+ avio_seek(pb, 8, SEEK_CUR);
vstream->codec->extradata = av_malloc(768);
vstream->codec->extradata_size = 768;
- get_buffer(pb, vstream->codec->extradata,
+ avio_read(pb, vstream->codec->extradata,
vstream->codec->extradata_size);
- astream->codec->sample_rate = get_le32(pb);
+ astream->codec->sample_rate = avio_rl32(pb);
/* Set up the video codec... */
av_set_pts_info(vstream, 32, 1, fps);
@@ -98,7 +98,7 @@ static int bfi_read_header(AVFormatContext * s, AVFormatParameters * ap)
astream->codec->bits_per_coded_sample = 8;
astream->codec->bit_rate =
astream->codec->sample_rate * astream->codec->bits_per_coded_sample;
- url_fseek(pb, chunk_header - 3, SEEK_SET);
+ avio_seek(pb, chunk_header - 3, SEEK_SET);
av_set_pts_info(astream, 64, 1, astream->codec->sample_rate);
return 0;
}
@@ -107,7 +107,7 @@ static int bfi_read_header(AVFormatContext * s, AVFormatParameters * ap)
static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
{
BFIContext *bfi = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret, audio_offset, video_offset, chunk_size, audio_size = 0;
if (bfi->nframes == 0 || url_feof(pb)) {
return AVERROR(EIO);
@@ -119,14 +119,14 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
while(state != MKTAG('S','A','V','I')){
if (url_feof(pb))
return AVERROR(EIO);
- state = 256*state + get_byte(pb);
+ state = 256*state + avio_r8(pb);
}
/* Now that the chunk's location is confirmed, we proceed... */
- chunk_size = get_le32(pb);
- get_le32(pb);
- audio_offset = get_le32(pb);
- get_le32(pb);
- video_offset = get_le32(pb);
+ chunk_size = avio_rl32(pb);
+ avio_rl32(pb);
+ audio_offset = avio_rl32(pb);
+ avio_rl32(pb);
+ video_offset = avio_rl32(pb);
audio_size = video_offset - audio_offset;
bfi->video_size = chunk_size - video_offset;
diff --git a/mplayer/ffmpeg/libavformat/bink.c b/mplayer/ffmpeg/libavformat/bink.c
index c134dd80..22beb4cb 100644
--- a/mplayer/ffmpeg/libavformat/bink.c
+++ b/mplayer/ffmpeg/libavformat/bink.c
@@ -70,7 +70,7 @@ static int probe(AVProbeData *p)
static int read_header(AVFormatContext *s, AVFormatParameters *ap)
{
BinkDemuxContext *bink = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint32_t fps_num, fps_den;
AVStream *vst, *ast;
unsigned int i;
@@ -82,29 +82,29 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
if (!vst)
return AVERROR(ENOMEM);
- vst->codec->codec_tag = get_le32(pb);
+ vst->codec->codec_tag = avio_rl32(pb);
- bink->file_size = get_le32(pb) + 8;
- vst->duration = get_le32(pb);
+ bink->file_size = avio_rl32(pb) + 8;
+ vst->duration = avio_rl32(pb);
if (vst->duration > 1000000) {
av_log(s, AV_LOG_ERROR, "invalid header: more than 1000000 frames\n");
return AVERROR(EIO);
}
- if (get_le32(pb) > bink->file_size) {
+ if (avio_rl32(pb) > bink->file_size) {
av_log(s, AV_LOG_ERROR,
"invalid header: largest frame size greater than file size\n");
return AVERROR(EIO);
}
- url_fskip(pb, 4);
+ avio_seek(pb, 4, SEEK_CUR);
- vst->codec->width = get_le32(pb);
- vst->codec->height = get_le32(pb);
+ vst->codec->width = avio_rl32(pb);
+ vst->codec->height = avio_rl32(pb);
- fps_num = get_le32(pb);
- fps_den = get_le32(pb);
+ fps_num = avio_rl32(pb);
+ fps_den = avio_rl32(pb);
if (fps_num == 0 || fps_den == 0) {
av_log(s, AV_LOG_ERROR, "invalid header: invalid fps (%d/%d)\n", fps_num, fps_den);
return AVERROR(EIO);
@@ -115,9 +115,9 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
vst->codec->codec_id = CODEC_ID_BINKVIDEO;
vst->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE);
vst->codec->extradata_size = 4;
- get_buffer(pb, vst->codec->extradata, 4);
+ avio_read(pb, vst->codec->extradata, 4);
- bink->num_audio_tracks = get_le32(pb);
+ bink->num_audio_tracks = avio_rl32(pb);
if (bink->num_audio_tracks > BINK_MAX_AUDIO_TRACKS) {
av_log(s, AV_LOG_ERROR,
@@ -127,34 +127,35 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
}
if (bink->num_audio_tracks) {
- url_fskip(pb, 4 * bink->num_audio_tracks);
+ avio_seek(pb, 4 * bink->num_audio_tracks, SEEK_CUR);
for (i = 0; i < bink->num_audio_tracks; i++) {
ast = av_new_stream(s, 1);
if (!ast)
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_tag = 0;
- ast->codec->sample_rate = get_le16(pb);
+ ast->codec->codec_tag = vst->codec->codec_tag;
+ ast->codec->sample_rate = avio_rl16(pb);
av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
- flags = get_le16(pb);
+ flags = avio_rl16(pb);
ast->codec->codec_id = flags & BINK_AUD_USEDCT ?
CODEC_ID_BINKAUDIO_DCT : CODEC_ID_BINKAUDIO_RDFT;
ast->codec->channels = flags & BINK_AUD_STEREO ? 2 : 1;
}
- url_fskip(pb, 4 * bink->num_audio_tracks);
+ for (i = 0; i < bink->num_audio_tracks; i++)
+ s->streams[i + 1]->id = avio_rl32(pb);
}
/* frame index table */
- next_pos = get_le32(pb);
+ next_pos = avio_rl32(pb);
for (i = 0; i < vst->duration; i++) {
pos = next_pos;
if (i == vst->duration - 1) {
next_pos = bink->file_size;
keyframe = 0;
} else {
- next_pos = get_le32(pb);
+ next_pos = avio_rl32(pb);
keyframe = pos & 1;
}
pos &= ~1;
@@ -168,7 +169,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
keyframe ? AVINDEX_KEYFRAME : 0);
}
- url_fskip(pb, 4);
+ avio_seek(pb, 4, SEEK_CUR);
bink->current_track = -1;
return 0;
@@ -177,7 +178,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
BinkDemuxContext *bink = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret;
if (bink->current_track < 0) {
@@ -201,7 +202,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
}
while (bink->current_track < bink->num_audio_tracks) {
- uint32_t audio_size = get_le32(pb);
+ uint32_t audio_size = avio_rl32(pb);
if (audio_size > bink->remain_packet_size - 4) {
av_log(s, AV_LOG_ERROR,
"frame %"PRId64": audio size in header (%u) > size of packet left (%u)\n",
@@ -224,7 +225,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
AV_RL32(pkt->data) / (2 * s->streams[bink->current_track]->codec->channels);
return 0;
} else {
- url_fseek(pb, audio_size, SEEK_CUR);
+ avio_seek(pb, audio_size, SEEK_CUR);
}
}
@@ -250,7 +251,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in
return -1;
/* seek to the first frame */
- url_fseek(s->pb, vst->index_entries[0].pos, SEEK_SET);
+ avio_seek(s->pb, vst->index_entries[0].pos, SEEK_SET);
bink->video_pts = 0;
memset(bink->audio_pts, 0, sizeof(bink->audio_pts));
bink->current_track = -1;
diff --git a/mplayer/ffmpeg/libavformat/c93.c b/mplayer/ffmpeg/libavformat/c93.c
index dbb2bf38..a4a0fe3a 100644
--- a/mplayer/ffmpeg/libavformat/c93.c
+++ b/mplayer/ffmpeg/libavformat/c93.c
@@ -60,15 +60,15 @@ static int read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
AVStream *video;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
C93DemuxContext *c93 = s->priv_data;
int i;
int framecount = 0;
for (i = 0; i < 512; i++) {
- c93->block_records[i].index = get_le16(pb);
- c93->block_records[i].length = get_byte(pb);
- c93->block_records[i].frames = get_byte(pb);
+ c93->block_records[i].index = avio_rl16(pb);
+ c93->block_records[i].length = avio_r8(pb);
+ c93->block_records[i].frames = avio_r8(pb);
if (c93->block_records[i].frames > 32) {
av_log(s, AV_LOG_ERROR, "too many frames in block\n");
return AVERROR_INVALIDDATA;
@@ -89,7 +89,7 @@ static int read_header(AVFormatContext *s,
video->codec->height = 192;
/* 4:3 320x200 with 8 empty lines */
video->sample_aspect_ratio = (AVRational) { 5, 6 };
- video->time_base = (AVRational) { 2, 25 };
+ av_set_pts_info(video, 64, 2, 25);
video->nb_frames = framecount;
video->duration = framecount;
video->start_time = 0;
@@ -105,7 +105,7 @@ static int read_header(AVFormatContext *s,
static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
C93DemuxContext *c93 = s->priv_data;
C93BlockRecord *br = &c93->block_records[c93->current_block];
int datasize;
@@ -114,7 +114,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
if (c93->next_pkt_is_audio) {
c93->current_frame++;
c93->next_pkt_is_audio = 0;
- datasize = get_le16(pb);
+ datasize = avio_rl16(pb);
if (datasize > 42) {
if (!c93->audio) {
c93->audio = av_new_stream(s, 1);
@@ -122,7 +122,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(ENOMEM);
c93->audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;
}
- url_fskip(pb, 26); /* VOC header */
+ avio_seek(pb, 26, SEEK_CUR); /* VOC header */
ret = voc_get_packet(s, pkt, c93->audio, datasize - 26);
if (ret > 0) {
pkt->stream_index = 1;
@@ -140,15 +140,15 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
}
if (c93->current_frame == 0) {
- url_fseek(pb, br->index * 2048, SEEK_SET);
+ avio_seek(pb, br->index * 2048, SEEK_SET);
for (i = 0; i < 32; i++) {
- c93->frame_offsets[i] = get_le32(pb);
+ c93->frame_offsets[i] = avio_rl32(pb);
}
}
- url_fseek(pb,br->index * 2048 +
+ avio_seek(pb,br->index * 2048 +
c93->frame_offsets[c93->current_frame], SEEK_SET);
- datasize = get_le16(pb); /* video frame size */
+ datasize = avio_rl16(pb); /* video frame size */
ret = av_new_packet(pkt, datasize + 768 + 1);
if (ret < 0)
@@ -156,13 +156,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[0] = 0;
pkt->size = datasize + 1;
- ret = get_buffer(pb, pkt->data + 1, datasize);
+ ret = avio_read(pb, pkt->data + 1, datasize);
if (ret < datasize) {
ret = AVERROR(EIO);
goto fail;
}
- datasize = get_le16(pb); /* palette size */
+ datasize = avio_rl16(pb); /* palette size */
if (datasize) {
if (datasize != 768) {
av_log(s, AV_LOG_ERROR, "invalid palette size %u\n", datasize);
@@ -170,7 +170,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
goto fail;
}
pkt->data[0] |= C93_HAS_PALETTE;
- ret = get_buffer(pb, pkt->data + pkt->size, datasize);
+ ret = avio_read(pb, pkt->data + pkt->size, datasize);
if (ret < datasize) {
ret = AVERROR(EIO);
goto fail;
diff --git a/mplayer/ffmpeg/libavformat/cafdec.c b/mplayer/ffmpeg/libavformat/cafdec.c
index 7b0c8717..d98c4bf0 100644
--- a/mplayer/ffmpeg/libavformat/cafdec.c
+++ b/mplayer/ffmpeg/libavformat/cafdec.c
@@ -53,7 +53,7 @@ static int probe(AVProbeData *p)
/** Read audio description chunk */
static int read_desc_chunk(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
CaffContext *caf = s->priv_data;
AVStream *st;
int flags;
@@ -65,14 +65,14 @@ static int read_desc_chunk(AVFormatContext *s)
/* parse format description */
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->sample_rate = av_int2dbl(get_be64(pb));
- st->codec->codec_tag = get_be32(pb);
- flags = get_be32(pb);
- caf->bytes_per_packet = get_be32(pb);
+ st->codec->sample_rate = av_int2dbl(avio_rb64(pb));
+ st->codec->codec_tag = avio_rb32(pb);
+ flags = avio_rb32(pb);
+ caf->bytes_per_packet = avio_rb32(pb);
st->codec->block_align = caf->bytes_per_packet;
- caf->frames_per_packet = get_be32(pb);
- st->codec->channels = get_be32(pb);
- st->codec->bits_per_coded_sample = get_be32(pb);
+ caf->frames_per_packet = avio_rb32(pb);
+ st->codec->channels = avio_rb32(pb);
+ st->codec->bits_per_coded_sample = avio_rb32(pb);
/* calculate bit rate for constant size packets */
if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) {
@@ -93,7 +93,7 @@ static int read_desc_chunk(AVFormatContext *s)
/** Read magic cookie chunk */
static int read_kuki_chunk(AVFormatContext *s, int64_t size)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
if (size < 0 || size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE)
@@ -114,27 +114,27 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
av_log(s, AV_LOG_ERROR, "invalid AAC magic cookie\n");
return AVERROR_INVALIDDATA;
}
- url_fskip(pb, skip);
+ avio_seek(pb, skip, SEEK_CUR);
} else if (st->codec->codec_id == CODEC_ID_ALAC) {
#define ALAC_PREAMBLE 12
#define ALAC_HEADER 36
if (size < ALAC_PREAMBLE + ALAC_HEADER) {
av_log(s, AV_LOG_ERROR, "invalid ALAC magic cookie\n");
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
return AVERROR_INVALIDDATA;
}
- url_fskip(pb, ALAC_PREAMBLE);
+ avio_seek(pb, ALAC_PREAMBLE, SEEK_CUR);
st->codec->extradata = av_mallocz(ALAC_HEADER + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, st->codec->extradata, ALAC_HEADER);
+ avio_read(pb, st->codec->extradata, ALAC_HEADER);
st->codec->extradata_size = ALAC_HEADER;
- url_fskip(pb, size - ALAC_PREAMBLE - ALAC_HEADER);
+ avio_seek(pb, size - ALAC_PREAMBLE - ALAC_HEADER, SEEK_CUR);
} else {
st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, st->codec->extradata, size);
+ avio_read(pb, st->codec->extradata, size);
st->codec->extradata_size = size;
}
@@ -144,7 +144,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
/** Read packet table chunk */
static int read_pakt_chunk(AVFormatContext *s, int64_t size)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
CaffContext *caf = s->priv_data;
int64_t pos = 0, ccount;
@@ -152,13 +152,13 @@ static int read_pakt_chunk(AVFormatContext *s, int64_t size)
ccount = url_ftell(pb);
- num_packets = get_be64(pb);
+ num_packets = avio_rb64(pb);
if (num_packets < 0 || INT32_MAX / sizeof(AVIndexEntry) < num_packets)
return AVERROR_INVALIDDATA;
- st->nb_frames = get_be64(pb); /* valid frames */
- st->nb_frames += get_be32(pb); /* priming frames */
- st->nb_frames += get_be32(pb); /* remainder frames */
+ st->nb_frames = avio_rb64(pb); /* valid frames */
+ st->nb_frames += avio_rb32(pb); /* priming frames */
+ st->nb_frames += avio_rb32(pb); /* remainder frames */
st->duration = 0;
for (i = 0; i < num_packets; i++) {
@@ -179,9 +179,9 @@ static int read_pakt_chunk(AVFormatContext *s, int64_t size)
/** Read information chunk */
static void read_info_chunk(AVFormatContext *s, int64_t size)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int i;
- unsigned int nb_entries = get_be32(pb);
+ unsigned int nb_entries = avio_rb32(pb);
for (i = 0; i < nb_entries; i++) {
char key[32];
char value[1024];
@@ -194,21 +194,21 @@ static void read_info_chunk(AVFormatContext *s, int64_t size)
static int read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
CaffContext *caf = s->priv_data;
AVStream *st;
uint32_t tag = 0;
int found_data, ret;
int64_t size;
- url_fskip(pb, 8); /* magic, version, file flags */
+ avio_seek(pb, 8, SEEK_CUR); /* magic, version, file flags */
/* audio description chunk */
- if (get_be32(pb) != MKBETAG('d','e','s','c')) {
+ if (avio_rb32(pb) != MKBETAG('d','e','s','c')) {
av_log(s, AV_LOG_ERROR, "desc chunk not present\n");
return AVERROR_INVALIDDATA;
}
- size = get_be64(pb);
+ size = avio_rb64(pb);
if (size != 32)
return AVERROR_INVALIDDATA;
@@ -226,18 +226,18 @@ static int read_header(AVFormatContext *s,
if (found_data && (caf->data_size < 0 || url_is_streamed(pb)))
break;
- tag = get_be32(pb);
- size = get_be64(pb);
+ tag = avio_rb32(pb);
+ size = avio_rb64(pb);
if (url_feof(pb))
break;
switch (tag) {
case MKBETAG('d','a','t','a'):
- url_fskip(pb, 4); /* edit count */
+ avio_seek(pb, 4, SEEK_CUR); /* edit count */
caf->data_start = url_ftell(pb);
caf->data_size = size < 0 ? -1 : size - 4;
if (caf->data_size > 0 && !url_is_streamed(pb))
- url_fskip(pb, caf->data_size);
+ avio_seek(pb, caf->data_size, SEEK_CUR);
found_data = 1;
break;
@@ -265,7 +265,7 @@ static int read_header(AVFormatContext *s,
case MKBETAG('f','r','e','e'):
if (size < 0)
return AVERROR_INVALIDDATA;
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
break;
}
}
@@ -292,7 +292,7 @@ static int read_header(AVFormatContext *s,
/* position the stream at the start of data */
if (caf->data_size >= 0)
- url_fseek(pb, caf->data_start, SEEK_SET);
+ avio_seek(pb, caf->data_start, SEEK_SET);
return 0;
}
@@ -301,7 +301,7 @@ static int read_header(AVFormatContext *s,
static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
CaffContext *caf = s->priv_data;
int res, pkt_size = 0, pkt_frames = 0;
@@ -377,7 +377,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
return -1;
}
- url_fseek(s->pb, pos + caf->data_start, SEEK_SET);
+ avio_seek(s->pb, pos + caf->data_start, SEEK_SET);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/crcenc.c b/mplayer/ffmpeg/libavformat/crcenc.c
index 2f9a099a..ec106b0b 100644
--- a/mplayer/ffmpeg/libavformat/crcenc.c
+++ b/mplayer/ffmpeg/libavformat/crcenc.c
@@ -49,7 +49,7 @@ static int crc_write_trailer(struct AVFormatContext *s)
char buf[64];
snprintf(buf, sizeof(buf), "CRC=0x%08x\n", crc->crcval);
- put_buffer(s->pb, buf, strlen(buf));
+ avio_write(s->pb, buf, strlen(buf));
put_flush_packet(s->pb);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/cutils.c b/mplayer/ffmpeg/libavformat/cutils.c
index c1b56139..e6578df2 100644
--- a/mplayer/ffmpeg/libavformat/cutils.c
+++ b/mplayer/ffmpeg/libavformat/cutils.c
@@ -42,25 +42,6 @@ void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem)
*nb_ptr = nb;
}
-time_t mktimegm(struct tm *tm)
-{
- time_t t;
-
- int y = tm->tm_year + 1900, m = tm->tm_mon + 1, d = tm->tm_mday;
-
- if (m < 3) {
- m += 12;
- y--;
- }
-
- t = 86400 *
- (d + (153 * m - 457) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 719469);
-
- t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
-
- return t;
-}
-
#define ISLEAP(y) (((y) % 4 == 0) && (((y) % 100) != 0 || ((y) % 400) == 0))
#define LEAPS_COUNT(y) ((y)/4 - (y)/100 + (y)/400)
@@ -95,94 +76,3 @@ struct tm *brktimegm(time_t secs, struct tm *tm)
return tm;
}
-
-/* get a positive number between n_min and n_max, for a maximum length
- of len_max. Return -1 if error. */
-static int date_get_num(const char **pp,
- int n_min, int n_max, int len_max)
-{
- int i, val, c;
- const char *p;
-
- p = *pp;
- val = 0;
- for(i = 0; i < len_max; i++) {
- c = *p;
- if (!isdigit(c))
- break;
- val = (val * 10) + c - '0';
- p++;
- }
- /* no number read ? */
- if (p == *pp)
- return -1;
- if (val < n_min || val > n_max)
- return -1;
- *pp = p;
- return val;
-}
-
-/* small strptime for ffmpeg */
-const char *small_strptime(const char *p, const char *fmt,
- struct tm *dt)
-{
- int c, val;
-
- for(;;) {
- c = *fmt++;
- if (c == '\0') {
- return p;
- } else if (c == '%') {
- c = *fmt++;
- switch(c) {
- case 'H':
- val = date_get_num(&p, 0, 23, 2);
- if (val == -1)
- return NULL;
- dt->tm_hour = val;
- break;
- case 'M':
- val = date_get_num(&p, 0, 59, 2);
- if (val == -1)
- return NULL;
- dt->tm_min = val;
- break;
- case 'S':
- val = date_get_num(&p, 0, 59, 2);
- if (val == -1)
- return NULL;
- dt->tm_sec = val;
- break;
- case 'Y':
- val = date_get_num(&p, 0, 9999, 4);
- if (val == -1)
- return NULL;
- dt->tm_year = val - 1900;
- break;
- case 'm':
- val = date_get_num(&p, 1, 12, 2);
- if (val == -1)
- return NULL;
- dt->tm_mon = val - 1;
- break;
- case 'd':
- val = date_get_num(&p, 1, 31, 2);
- if (val == -1)
- return NULL;
- dt->tm_mday = val;
- break;
- case '%':
- goto match;
- default:
- return NULL;
- }
- } else {
- match:
- if (c != *p)
- return NULL;
- p++;
- }
- }
- return p;
-}
-
diff --git a/mplayer/ffmpeg/libavformat/daud.c b/mplayer/ffmpeg/libavformat/daud.c
index c8af2e44..39a994b6 100644
--- a/mplayer/ffmpeg/libavformat/daud.c
+++ b/mplayer/ffmpeg/libavformat/daud.c
@@ -36,12 +36,12 @@ static int daud_header(AVFormatContext *s, AVFormatParameters *ap) {
}
static int daud_packet(AVFormatContext *s, AVPacket *pkt) {
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret, size;
if (url_feof(pb))
return AVERROR(EIO);
- size = get_be16(pb);
- get_be16(pb); // unknown
+ size = avio_rb16(pb);
+ avio_rb16(pb); // unknown
ret = av_get_packet(pb, pkt, size);
pkt->stream_index = 0;
return ret;
@@ -57,9 +57,9 @@ static int daud_write_header(struct AVFormatContext *s)
static int daud_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
- put_be16(s->pb, pkt->size);
- put_be16(s->pb, 0x8010); // unknown
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_wb16(s->pb, pkt->size);
+ avio_wb16(s->pb, 0x8010); // unknown
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/dsicin.c b/mplayer/ffmpeg/libavformat/dsicin.c
index 10a2a9d2..328f9014 100644
--- a/mplayer/ffmpeg/libavformat/dsicin.c
+++ b/mplayer/ffmpeg/libavformat/dsicin.c
@@ -70,19 +70,19 @@ static int cin_probe(AVProbeData *p)
return AVPROBE_SCORE_MAX;
}
-static int cin_read_file_header(CinDemuxContext *cin, ByteIOContext *pb) {
+static int cin_read_file_header(CinDemuxContext *cin, AVIOContext *pb) {
CinFileHeader *hdr = &cin->file_header;
- if (get_le32(pb) != 0x55AA0000)
+ if (avio_rl32(pb) != 0x55AA0000)
return AVERROR_INVALIDDATA;
- hdr->video_frame_size = get_le32(pb);
- hdr->video_frame_width = get_le16(pb);
- hdr->video_frame_height = get_le16(pb);
- hdr->audio_frequency = get_le32(pb);
- hdr->audio_bits = get_byte(pb);
- hdr->audio_stereo = get_byte(pb);
- hdr->audio_frame_size = get_le16(pb);
+ hdr->video_frame_size = avio_rl32(pb);
+ hdr->video_frame_width = avio_rl16(pb);
+ hdr->video_frame_height = avio_rl16(pb);
+ hdr->audio_frequency = avio_rl32(pb);
+ hdr->audio_bits = avio_r8(pb);
+ hdr->audio_stereo = avio_r8(pb);
+ hdr->audio_frame_size = avio_rl16(pb);
if (hdr->audio_frequency != 22050 || hdr->audio_bits != 16 || hdr->audio_stereo != 0)
return AVERROR_INVALIDDATA;
@@ -95,7 +95,7 @@ static int cin_read_header(AVFormatContext *s, AVFormatParameters *ap)
int rc;
CinDemuxContext *cin = s->priv_data;
CinFileHeader *hdr = &cin->file_header;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
rc = cin_read_file_header(cin, pb);
@@ -138,19 +138,19 @@ static int cin_read_header(AVFormatContext *s, AVFormatParameters *ap)
return 0;
}
-static int cin_read_frame_header(CinDemuxContext *cin, ByteIOContext *pb) {
+static int cin_read_frame_header(CinDemuxContext *cin, AVIOContext *pb) {
CinFrameHeader *hdr = &cin->frame_header;
- hdr->video_frame_type = get_byte(pb);
- hdr->audio_frame_type = get_byte(pb);
- hdr->pal_colors_count = get_le16(pb);
- hdr->video_frame_size = get_le32(pb);
- hdr->audio_frame_size = get_le32(pb);
+ hdr->video_frame_type = avio_r8(pb);
+ hdr->audio_frame_type = avio_r8(pb);
+ hdr->pal_colors_count = avio_rl16(pb);
+ hdr->video_frame_size = avio_rl32(pb);
+ hdr->audio_frame_size = avio_rl32(pb);
if (url_feof(pb) || url_ferror(pb))
return AVERROR(EIO);
- if (get_le32(pb) != 0xAA55AA55)
+ if (avio_rl32(pb) != 0xAA55AA55)
return AVERROR_INVALIDDATA;
return 0;
@@ -159,7 +159,7 @@ static int cin_read_frame_header(CinDemuxContext *cin, ByteIOContext *pb) {
static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
{
CinDemuxContext *cin = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
CinFrameHeader *hdr = &cin->frame_header;
int rc, palette_type, pkt_size;
int ret;
@@ -191,7 +191,7 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[2] = hdr->pal_colors_count >> 8;
pkt->data[3] = hdr->video_frame_type;
- ret = get_buffer(pb, &pkt->data[4], pkt_size);
+ ret = avio_read(pb, &pkt->data[4], pkt_size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
diff --git a/mplayer/ffmpeg/libavformat/dv.c b/mplayer/ffmpeg/libavformat/dv.c
index 1f05eb2d..cdc5f769 100644
--- a/mplayer/ffmpeg/libavformat/dv.c
+++ b/mplayer/ffmpeg/libavformat/dv.c
@@ -410,7 +410,7 @@ static int dv_read_header(AVFormatContext *s,
if (!c->dv_demux)
return -1;
- state = get_be32(s->pb);
+ state = avio_rb32(s->pb);
while ((state & 0xffffff7f) != 0x1f07003f) {
if (url_feof(s->pb)) {
av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n");
@@ -419,16 +419,16 @@ static int dv_read_header(AVFormatContext *s,
if (state == 0x003f0700 || state == 0xff3f0700)
marker_pos = url_ftell(s->pb);
if (state == 0xff3f0701 && url_ftell(s->pb) - marker_pos == 80) {
- url_fseek(s->pb, -163, SEEK_CUR);
- state = get_be32(s->pb);
+ avio_seek(s->pb, -163, SEEK_CUR);
+ state = avio_rb32(s->pb);
break;
}
- state = (state << 8) | get_byte(s->pb);
+ state = (state << 8) | avio_r8(s->pb);
}
AV_WB32(c->buf, state);
- if (get_buffer(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) <= 0 ||
- url_fseek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0)
+ if (avio_read(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) <= 0 ||
+ avio_seek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0)
return AVERROR(EIO);
c->dv_demux->sys = ff_dv_frame_profile(c->dv_demux->sys, c->buf, DV_PROFILE_BYTES);
@@ -455,7 +455,7 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)
if (!c->dv_demux->sys)
return AVERROR(EIO);
size = c->dv_demux->sys->frame_size;
- if (get_buffer(s->pb, c->buf, size) <= 0)
+ if (avio_read(s->pb, c->buf, size) <= 0)
return AVERROR(EIO);
size = dv_produce_packet(c->dv_demux, pkt, c->buf, size);
@@ -473,7 +473,7 @@ static int dv_read_seek(AVFormatContext *s, int stream_index,
dv_offset_reset(c, offset / c->sys->frame_size);
- offset = url_fseek(s->pb, offset, SEEK_SET);
+ offset = avio_seek(s->pb, offset, SEEK_SET);
return (offset < 0) ? offset : 0;
}
diff --git a/mplayer/ffmpeg/libavformat/dvenc.c b/mplayer/ffmpeg/libavformat/dvenc.c
index faaa5298..6d90024e 100644
--- a/mplayer/ffmpeg/libavformat/dvenc.c
+++ b/mplayer/ffmpeg/libavformat/dvenc.c
@@ -381,7 +381,7 @@ static int dv_write_packet(struct AVFormatContext *s, AVPacket *pkt)
fsize = dv_assemble_frame(s->priv_data, s->streams[pkt->stream_index],
pkt->data, pkt->size, &frame);
if (fsize > 0) {
- put_buffer(s->pb, frame, fsize);
+ avio_write(s->pb, frame, fsize);
put_flush_packet(s->pb);
}
return 0;
diff --git a/mplayer/ffmpeg/libavformat/dxa.c b/mplayer/ffmpeg/libavformat/dxa.c
index 6ad4582e..695ca959 100644
--- a/mplayer/ffmpeg/libavformat/dxa.c
+++ b/mplayer/ffmpeg/libavformat/dxa.c
@@ -52,7 +52,7 @@ static int dxa_probe(AVProbeData *p)
static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
DXAContext *c = s->priv_data;
AVStream *st, *ast;
uint32_t tag;
@@ -61,17 +61,17 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
int num, den;
int flags;
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('D', 'E', 'X', 'A'))
return -1;
- flags = get_byte(pb);
- c->frames = get_be16(pb);
+ flags = avio_r8(pb);
+ c->frames = avio_rb16(pb);
if(!c->frames){
av_log(s, AV_LOG_ERROR, "File contains no frames ???\n");
return -1;
}
- fps = get_be32(pb);
+ fps = avio_rb32(pb);
if(fps > 0){
den = 1000;
num = fps;
@@ -82,8 +82,8 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
den = 10;
num = 1;
}
- w = get_be16(pb);
- h = get_be16(pb);
+ w = avio_rb16(pb);
+ h = avio_rb16(pb);
c->has_sound = 0;
st = av_new_stream(s, 0);
@@ -91,13 +91,13 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1;
// Parse WAV data header
- if(get_le32(pb) == MKTAG('W', 'A', 'V', 'E')){
+ if(avio_rl32(pb) == MKTAG('W', 'A', 'V', 'E')){
uint32_t size, fsize;
c->has_sound = 1;
- size = get_be32(pb);
+ size = avio_rb32(pb);
c->vidpos = url_ftell(pb) + size;
- url_fskip(pb, 16);
- fsize = get_le32(pb);
+ avio_seek(pb, 16, SEEK_CUR);
+ fsize = avio_rl32(pb);
ast = av_new_stream(s, 0);
if (!ast)
@@ -105,17 +105,17 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
ff_get_wav_header(pb, ast->codec, fsize);
// find 'data' chunk
while(url_ftell(pb) < c->vidpos && !url_feof(pb)){
- tag = get_le32(pb);
- fsize = get_le32(pb);
+ tag = avio_rl32(pb);
+ fsize = avio_rl32(pb);
if(tag == MKTAG('d', 'a', 't', 'a')) break;
- url_fskip(pb, fsize);
+ avio_seek(pb, fsize, SEEK_CUR);
}
c->bpc = (fsize + c->frames - 1) / c->frames;
if(ast->codec->block_align)
c->bpc = ((c->bpc + ast->codec->block_align - 1) / ast->codec->block_align) * ast->codec->block_align;
c->bytes_left = fsize;
c->wavpos = url_ftell(pb);
- url_fseek(pb, c->vidpos, SEEK_SET);
+ avio_seek(pb, c->vidpos, SEEK_SET);
}
/* now we are ready: build format streams */
@@ -151,7 +151,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
if(!c->readvid && c->has_sound && c->bytes_left){
c->readvid = 1;
- url_fseek(s->pb, c->wavpos, SEEK_SET);
+ avio_seek(s->pb, c->wavpos, SEEK_SET);
size = FFMIN(c->bytes_left, c->bpc);
ret = av_get_packet(s->pb, pkt, size);
pkt->stream_index = 1;
@@ -161,9 +161,9 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
c->wavpos = url_ftell(s->pb);
return 0;
}
- url_fseek(s->pb, c->vidpos, SEEK_SET);
+ avio_seek(s->pb, c->vidpos, SEEK_SET);
while(!url_feof(s->pb) && c->frames){
- get_buffer(s->pb, buf, 4);
+ avio_read(s->pb, buf, 4);
switch(AV_RL32(buf)){
case MKTAG('N', 'U', 'L', 'L'):
if(av_new_packet(pkt, 4 + pal_size) < 0)
@@ -178,10 +178,10 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
case MKTAG('C', 'M', 'A', 'P'):
pal_size = 768+4;
memcpy(pal, buf, 4);
- get_buffer(s->pb, pal + 4, 768);
+ avio_read(s->pb, pal + 4, 768);
break;
case MKTAG('F', 'R', 'A', 'M'):
- get_buffer(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
+ avio_read(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
size = AV_RB32(buf + 5);
if(size > 0xFFFFFF){
av_log(s, AV_LOG_ERROR, "Frame size is too big: %d\n", size);
@@ -190,7 +190,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0)
return AVERROR(ENOMEM);
memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
- ret = get_buffer(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
+ ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
if(ret != size){
av_free_packet(pkt);
return AVERROR(EIO);
diff --git a/mplayer/ffmpeg/libavformat/eacdata.c b/mplayer/ffmpeg/libavformat/eacdata.c
index 809b190d..8fc8c422 100644
--- a/mplayer/ffmpeg/libavformat/eacdata.c
+++ b/mplayer/ffmpeg/libavformat/eacdata.c
@@ -47,11 +47,11 @@ static int cdata_probe(AVProbeData *p)
static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
CdataDemuxContext *cdata = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int sample_rate, header;
AVStream *st;
- header = get_be16(pb);
+ header = avio_rb16(pb);
switch (header) {
case 0x0400: cdata->channels = 1; break;
case 0x0404: cdata->channels = 2; break;
@@ -61,8 +61,8 @@ static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1;
};
- sample_rate = get_be16(pb);
- url_fskip(pb, 12);
+ sample_rate = avio_rb16(pb);
+ avio_seek(pb, 12, SEEK_CUR);
st = av_new_stream(s, 0);
if (!st)
diff --git a/mplayer/ffmpeg/libavformat/electronicarts.c b/mplayer/ffmpeg/libavformat/electronicarts.c
index 5408a1f0..cd3c3380 100644
--- a/mplayer/ffmpeg/libavformat/electronicarts.c
+++ b/mplayer/ffmpeg/libavformat/electronicarts.c
@@ -77,16 +77,16 @@ typedef struct EaDemuxContext {
int num_samples;
} EaDemuxContext;
-static uint32_t read_arbitary(ByteIOContext *pb) {
+static uint32_t read_arbitary(AVIOContext *pb) {
uint8_t size, byte;
int i;
uint32_t word;
- size = get_byte(pb);
+ size = avio_r8(pb);
word = 0;
for (i = 0; i < size; i++) {
- byte = get_byte(pb);
+ byte = avio_r8(pb);
word <<= 8;
word |= byte;
}
@@ -102,7 +102,7 @@ static int process_audio_header_elements(AVFormatContext *s)
{
int inHeader = 1;
EaDemuxContext *ea = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int compression_type = -1, revision = -1, revision2 = -1;
ea->bytes = 2;
@@ -112,7 +112,7 @@ static int process_audio_header_elements(AVFormatContext *s)
while (!url_feof(pb) && inHeader) {
int inSubheader;
uint8_t byte;
- byte = get_byte(pb);
+ byte = avio_r8(pb);
switch (byte) {
case 0xFD:
@@ -120,7 +120,7 @@ static int process_audio_header_elements(AVFormatContext *s)
inSubheader = 1;
while (!url_feof(pb) && inSubheader) {
uint8_t subbyte;
- subbyte = get_byte(pb);
+ subbyte = avio_r8(pb);
switch (subbyte) {
case 0x80:
@@ -215,14 +215,14 @@ static int process_audio_header_elements(AVFormatContext *s)
static int process_audio_header_eacs(AVFormatContext *s)
{
EaDemuxContext *ea = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int compression_type;
- ea->sample_rate = ea->big_endian ? get_be32(pb) : get_le32(pb);
- ea->bytes = get_byte(pb); /* 1=8-bit, 2=16-bit */
- ea->num_channels = get_byte(pb);
- compression_type = get_byte(pb);
- url_fskip(pb, 13);
+ ea->sample_rate = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
+ ea->bytes = avio_r8(pb); /* 1=8-bit, 2=16-bit */
+ ea->num_channels = avio_r8(pb);
+ compression_type = avio_r8(pb);
+ avio_seek(pb, 13, SEEK_CUR);
switch (compression_type) {
case 0:
@@ -247,11 +247,11 @@ static int process_audio_header_eacs(AVFormatContext *s)
static int process_audio_header_sead(AVFormatContext *s)
{
EaDemuxContext *ea = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
- ea->sample_rate = get_le32(pb);
- ea->bytes = get_le32(pb); /* 1=8-bit, 2=16-bit */
- ea->num_channels = get_le32(pb);
+ ea->sample_rate = avio_rl32(pb);
+ ea->bytes = avio_rl32(pb); /* 1=8-bit, 2=16-bit */
+ ea->num_channels = avio_rl32(pb);
ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_SEAD;
return 1;
@@ -260,10 +260,10 @@ static int process_audio_header_sead(AVFormatContext *s)
static int process_video_header_mdec(AVFormatContext *s)
{
EaDemuxContext *ea = s->priv_data;
- ByteIOContext *pb = s->pb;
- url_fskip(pb, 4);
- ea->width = get_le16(pb);
- ea->height = get_le16(pb);
+ AVIOContext *pb = s->pb;
+ avio_seek(pb, 4, SEEK_CUR);
+ ea->width = avio_rl16(pb);
+ ea->height = avio_rl16(pb);
ea->time_base = (AVRational){1,15};
ea->video_codec = CODEC_ID_MDEC;
return 1;
@@ -272,11 +272,11 @@ static int process_video_header_mdec(AVFormatContext *s)
static int process_video_header_vp6(AVFormatContext *s)
{
EaDemuxContext *ea = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
- url_fskip(pb, 16);
- ea->time_base.den = get_le32(pb);
- ea->time_base.num = get_le32(pb);
+ avio_seek(pb, 16, SEEK_CUR);
+ ea->time_base.den = avio_rl32(pb);
+ ea->time_base.num = avio_rl32(pb);
ea->video_codec = CODEC_ID_VP6;
return 1;
@@ -289,15 +289,15 @@ static int process_video_header_vp6(AVFormatContext *s)
static int process_ea_header(AVFormatContext *s) {
uint32_t blockid, size = 0;
EaDemuxContext *ea = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int i;
for (i=0; i<5 && (!ea->audio_codec || !ea->video_codec); i++) {
unsigned int startpos = url_ftell(pb);
int err = 0;
- blockid = get_le32(pb);
- size = get_le32(pb);
+ blockid = avio_rl32(pb);
+ size = avio_rl32(pb);
if (i == 0)
ea->big_endian = size > 0x000FFFFF;
if (ea->big_endian)
@@ -305,7 +305,7 @@ static int process_ea_header(AVFormatContext *s) {
switch (blockid) {
case ISNh_TAG:
- if (get_le32(pb) != EACS_TAG) {
+ if (avio_rl32(pb) != EACS_TAG) {
av_log (s, AV_LOG_ERROR, "unknown 1SNh headerid\n");
return 0;
}
@@ -314,9 +314,9 @@ static int process_ea_header(AVFormatContext *s) {
case SCHl_TAG :
case SHEN_TAG :
- blockid = get_le32(pb);
+ blockid = avio_rl32(pb);
if (blockid == GSTR_TAG) {
- url_fskip(pb, 4);
+ avio_seek(pb, 4, SEEK_CUR);
} else if ((blockid & 0xFFFF)!=PT00_TAG) {
av_log (s, AV_LOG_ERROR, "unknown SCHl headerid\n");
return 0;
@@ -369,10 +369,10 @@ static int process_ea_header(AVFormatContext *s) {
return err;
}
- url_fseek(pb, startpos + size, SEEK_SET);
+ avio_seek(pb, startpos + size, SEEK_SET);
}
- url_fseek(pb, 0, SEEK_SET);
+ avio_seek(pb, 0, SEEK_SET);
return 1;
}
@@ -459,7 +459,7 @@ static int ea_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
EaDemuxContext *ea = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret = 0;
int packet_read = 0;
unsigned int chunk_type, chunk_size;
@@ -467,26 +467,26 @@ static int ea_read_packet(AVFormatContext *s,
int av_uninit(num_samples);
while (!packet_read) {
- chunk_type = get_le32(pb);
- chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8;
+ chunk_type = avio_rl32(pb);
+ chunk_size = (ea->big_endian ? avio_rb32(pb) : avio_rl32(pb)) - 8;
switch (chunk_type) {
/* audio data */
case ISNh_TAG:
/* header chunk also contains data; skip over the header portion*/
- url_fskip(pb, 32);
+ avio_seek(pb, 32, SEEK_CUR);
chunk_size -= 32;
case ISNd_TAG:
case SCDl_TAG:
case SNDC_TAG:
case SDEN_TAG:
if (!ea->audio_codec) {
- url_fskip(pb, chunk_size);
+ avio_seek(pb, chunk_size, SEEK_CUR);
break;
} else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR ||
ea->audio_codec == CODEC_ID_MP3) {
- num_samples = get_le32(pb);
- url_fskip(pb, 8);
+ num_samples = avio_rl32(pb);
+ avio_seek(pb, 8, SEEK_CUR);
chunk_size -= 12;
}
ret = av_get_packet(pb, pkt, chunk_size);
@@ -536,12 +536,12 @@ static int ea_read_packet(AVFormatContext *s,
case fVGT_TAG:
case MADm_TAG:
case MADe_TAG:
- url_fseek(pb, -8, SEEK_CUR); // include chunk preamble
+ avio_seek(pb, -8, SEEK_CUR); // include chunk preamble
chunk_size += 8;
goto get_video_packet;
case mTCD_TAG:
- url_fseek(pb, 8, SEEK_CUR); // skip ea dct header
+ avio_seek(pb, 8, SEEK_CUR); // skip ea dct header
chunk_size -= 8;
goto get_video_packet;
@@ -560,7 +560,7 @@ static int ea_read_packet(AVFormatContext *s,
break;
default:
- url_fseek(pb, chunk_size, SEEK_CUR);
+ avio_seek(pb, chunk_size, SEEK_CUR);
break;
}
}
diff --git a/mplayer/ffmpeg/libavformat/ffmdec.c b/mplayer/ffmpeg/libavformat/ffmdec.c
index 91da6504..bcfc1658 100644
--- a/mplayer/ffmpeg/libavformat/ffmdec.c
+++ b/mplayer/ffmpeg/libavformat/ffmdec.c
@@ -95,7 +95,7 @@ static int ffm_resync(AVFormatContext *s, int state)
av_log(s, AV_LOG_ERROR, "cannot find FFM syncword\n");
return -1;
}
- state = (state << 8) | get_byte(s->pb);
+ state = (state << 8) | avio_r8(s->pb);
}
return 0;
}
@@ -105,7 +105,7 @@ static int ffm_read_data(AVFormatContext *s,
uint8_t *buf, int size, int header)
{
FFMContext *ffm = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int len, fill_size, size1, frame_offset, id;
size1 = size;
@@ -118,16 +118,16 @@ static int ffm_read_data(AVFormatContext *s,
len = size;
if (len == 0) {
if (url_ftell(pb) == ffm->file_size)
- url_fseek(pb, ffm->packet_size, SEEK_SET);
+ avio_seek(pb, ffm->packet_size, SEEK_SET);
retry_read:
- id = get_be16(pb); /* PACKET_ID */
+ id = avio_rb16(pb); /* PACKET_ID */
if (id != PACKET_ID)
if (ffm_resync(s, id) < 0)
return -1;
- fill_size = get_be16(pb);
- ffm->dts = get_be64(pb);
- frame_offset = get_be16(pb);
- get_buffer(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE);
+ fill_size = avio_rb16(pb);
+ ffm->dts = avio_rb64(pb);
+ frame_offset = avio_rb16(pb);
+ avio_read(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE);
ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size);
if (ffm->packet_end < ffm->packet || frame_offset < 0)
return -1;
@@ -137,7 +137,7 @@ static int ffm_read_data(AVFormatContext *s,
if (!frame_offset) {
/* This packet has no frame headers in it */
if (url_ftell(pb) >= ffm->packet_size * 3) {
- url_fseek(pb, -ffm->packet_size * 2, SEEK_CUR);
+ avio_seek(pb, -ffm->packet_size * 2, SEEK_CUR);
goto retry_read;
}
/* This is bad, we cannot find a valid frame header */
@@ -170,7 +170,7 @@ static int ffm_read_data(AVFormatContext *s,
static void ffm_seek1(AVFormatContext *s, int64_t pos1)
{
FFMContext *ffm = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pos;
pos = FFMIN(pos1, ffm->file_size - FFM_PACKET_SIZE);
@@ -178,17 +178,17 @@ static void ffm_seek1(AVFormatContext *s, int64_t pos1)
#ifdef DEBUG_SEEK
av_log(s, AV_LOG_DEBUG, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
#endif
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, pos, SEEK_SET);
}
static int64_t get_dts(AVFormatContext *s, int64_t pos)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t dts;
ffm_seek1(s, pos);
- url_fskip(pb, 4);
- dts = get_be64(pb);
+ avio_seek(pb, 4, SEEK_CUR);
+ dts = avio_rb64(pb);
#ifdef DEBUG_SEEK
av_log(s, AV_LOG_DEBUG, "dts=%0.6f\n", dts / 1000000.0);
#endif
@@ -198,7 +198,7 @@ static int64_t get_dts(AVFormatContext *s, int64_t pos)
static void adjust_write_index(AVFormatContext *s)
{
FFMContext *ffm = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pts;
//int64_t orig_write_index = ffm->write_index;
int64_t pos_min, pos_max;
@@ -248,7 +248,7 @@ static void adjust_write_index(AVFormatContext *s)
//printf("pts range %0.6f - %0.6f\n", get_dts(s, 0) / 1000000. , get_dts(s, ffm->file_size - 2 * FFM_PACKET_SIZE) / 1000000. );
end:
- url_fseek(pb, ptr, SEEK_SET);
+ avio_seek(pb, ptr, SEEK_SET);
}
@@ -267,19 +267,19 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
FFMContext *ffm = s->priv_data;
AVStream *st;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *codec;
int i, nb_streams;
uint32_t tag;
/* header */
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('F', 'F', 'M', '1'))
goto fail;
- ffm->packet_size = get_be32(pb);
+ ffm->packet_size = avio_rb32(pb);
if (ffm->packet_size != FFM_PACKET_SIZE)
goto fail;
- ffm->write_index = get_be64(pb);
+ ffm->write_index = avio_rb64(pb);
/* get also filesize */
if (!url_is_streamed(pb)) {
ffm->file_size = url_fsize(pb);
@@ -289,8 +289,8 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
ffm->file_size = (UINT64_C(1) << 63) - 1;
}
- nb_streams = get_be32(pb);
- get_be32(pb); /* total bitrate */
+ nb_streams = avio_rb32(pb);
+ avio_rb32(pb); /* total bitrate */
/* read each stream */
for(i=0;icodec;
/* generic info */
- codec->codec_id = get_be32(pb);
- codec->codec_type = get_byte(pb); /* codec_type */
- codec->bit_rate = get_be32(pb);
- st->quality = get_be32(pb);
- codec->flags = get_be32(pb);
- codec->flags2 = get_be32(pb);
- codec->debug = get_be32(pb);
+ codec->codec_id = avio_rb32(pb);
+ codec->codec_type = avio_r8(pb); /* codec_type */
+ codec->bit_rate = avio_rb32(pb);
+ st->quality = avio_rb32(pb);
+ codec->flags = avio_rb32(pb);
+ codec->flags2 = avio_rb32(pb);
+ codec->debug = avio_rb32(pb);
/* specific info */
switch(codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- codec->time_base.num = get_be32(pb);
- codec->time_base.den = get_be32(pb);
- codec->width = get_be16(pb);
- codec->height = get_be16(pb);
- codec->gop_size = get_be16(pb);
- codec->pix_fmt = get_be32(pb);
- codec->qmin = get_byte(pb);
- codec->qmax = get_byte(pb);
- codec->max_qdiff = get_byte(pb);
- codec->qcompress = get_be16(pb) / 10000.0;
- codec->qblur = get_be16(pb) / 10000.0;
- codec->bit_rate_tolerance = get_be32(pb);
+ codec->time_base.num = avio_rb32(pb);
+ codec->time_base.den = avio_rb32(pb);
+ codec->width = avio_rb16(pb);
+ codec->height = avio_rb16(pb);
+ codec->gop_size = avio_rb16(pb);
+ codec->pix_fmt = avio_rb32(pb);
+ codec->qmin = avio_r8(pb);
+ codec->qmax = avio_r8(pb);
+ codec->max_qdiff = avio_r8(pb);
+ codec->qcompress = avio_rb16(pb) / 10000.0;
+ codec->qblur = avio_rb16(pb) / 10000.0;
+ codec->bit_rate_tolerance = avio_rb32(pb);
codec->rc_eq = av_strdup(get_strz(pb, rc_eq_buf, sizeof(rc_eq_buf)));
- codec->rc_max_rate = get_be32(pb);
- codec->rc_min_rate = get_be32(pb);
- codec->rc_buffer_size = get_be32(pb);
- codec->i_quant_factor = av_int2dbl(get_be64(pb));
- codec->b_quant_factor = av_int2dbl(get_be64(pb));
- codec->i_quant_offset = av_int2dbl(get_be64(pb));
- codec->b_quant_offset = av_int2dbl(get_be64(pb));
- codec->dct_algo = get_be32(pb);
- codec->strict_std_compliance = get_be32(pb);
- codec->max_b_frames = get_be32(pb);
- codec->luma_elim_threshold = get_be32(pb);
- codec->chroma_elim_threshold = get_be32(pb);
- codec->mpeg_quant = get_be32(pb);
- codec->intra_dc_precision = get_be32(pb);
- codec->me_method = get_be32(pb);
- codec->mb_decision = get_be32(pb);
- codec->nsse_weight = get_be32(pb);
- codec->frame_skip_cmp = get_be32(pb);
- codec->rc_buffer_aggressivity = av_int2dbl(get_be64(pb));
- codec->codec_tag = get_be32(pb);
- codec->thread_count = get_byte(pb);
- codec->coder_type = get_be32(pb);
- codec->me_cmp = get_be32(pb);
- codec->partitions = get_be32(pb);
- codec->me_subpel_quality = get_be32(pb);
- codec->me_range = get_be32(pb);
- codec->keyint_min = get_be32(pb);
- codec->scenechange_threshold = get_be32(pb);
- codec->b_frame_strategy = get_be32(pb);
- codec->qcompress = av_int2dbl(get_be64(pb));
- codec->qblur = av_int2dbl(get_be64(pb));
- codec->max_qdiff = get_be32(pb);
- codec->refs = get_be32(pb);
- codec->directpred = get_be32(pb);
+ codec->rc_max_rate = avio_rb32(pb);
+ codec->rc_min_rate = avio_rb32(pb);
+ codec->rc_buffer_size = avio_rb32(pb);
+ codec->i_quant_factor = av_int2dbl(avio_rb64(pb));
+ codec->b_quant_factor = av_int2dbl(avio_rb64(pb));
+ codec->i_quant_offset = av_int2dbl(avio_rb64(pb));
+ codec->b_quant_offset = av_int2dbl(avio_rb64(pb));
+ codec->dct_algo = avio_rb32(pb);
+ codec->strict_std_compliance = avio_rb32(pb);
+ codec->max_b_frames = avio_rb32(pb);
+ codec->luma_elim_threshold = avio_rb32(pb);
+ codec->chroma_elim_threshold = avio_rb32(pb);
+ codec->mpeg_quant = avio_rb32(pb);
+ codec->intra_dc_precision = avio_rb32(pb);
+ codec->me_method = avio_rb32(pb);
+ codec->mb_decision = avio_rb32(pb);
+ codec->nsse_weight = avio_rb32(pb);
+ codec->frame_skip_cmp = avio_rb32(pb);
+ codec->rc_buffer_aggressivity = av_int2dbl(avio_rb64(pb));
+ codec->codec_tag = avio_rb32(pb);
+ codec->thread_count = avio_r8(pb);
+ codec->coder_type = avio_rb32(pb);
+ codec->me_cmp = avio_rb32(pb);
+ codec->partitions = avio_rb32(pb);
+ codec->me_subpel_quality = avio_rb32(pb);
+ codec->me_range = avio_rb32(pb);
+ codec->keyint_min = avio_rb32(pb);
+ codec->scenechange_threshold = avio_rb32(pb);
+ codec->b_frame_strategy = avio_rb32(pb);
+ codec->qcompress = av_int2dbl(avio_rb64(pb));
+ codec->qblur = av_int2dbl(avio_rb64(pb));
+ codec->max_qdiff = avio_rb32(pb);
+ codec->refs = avio_rb32(pb);
+ codec->directpred = avio_rb32(pb);
break;
case AVMEDIA_TYPE_AUDIO:
- codec->sample_rate = get_be32(pb);
- codec->channels = get_le16(pb);
- codec->frame_size = get_le16(pb);
- codec->sample_fmt = (int16_t) get_le16(pb);
+ codec->sample_rate = avio_rb32(pb);
+ codec->channels = avio_rl16(pb);
+ codec->frame_size = avio_rl16(pb);
+ codec->sample_fmt = (int16_t) avio_rl16(pb);
break;
default:
goto fail;
}
if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) {
- codec->extradata_size = get_be32(pb);
+ codec->extradata_size = avio_rb32(pb);
codec->extradata = av_malloc(codec->extradata_size);
if (!codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, codec->extradata, codec->extradata_size);
+ avio_read(pb, codec->extradata, codec->extradata_size);
}
}
/* get until end of block reached */
while ((url_ftell(pb) % ffm->packet_size) != 0)
- get_byte(pb);
+ avio_r8(pb);
/* init packet demux */
ffm->packet_ptr = ffm->packet;
diff --git a/mplayer/ffmpeg/libavformat/ffmenc.c b/mplayer/ffmpeg/libavformat/ffmenc.c
index f9e0782c..eeaaa229 100644
--- a/mplayer/ffmpeg/libavformat/ffmenc.c
+++ b/mplayer/ffmpeg/libavformat/ffmenc.c
@@ -27,7 +27,7 @@ static void flush_packet(AVFormatContext *s)
{
FFMContext *ffm = s->priv_data;
int fill_size, h;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
fill_size = ffm->packet_end - ffm->packet_ptr;
memset(ffm->packet_ptr, 0, fill_size);
@@ -36,14 +36,14 @@ static void flush_packet(AVFormatContext *s)
av_abort();
/* put header */
- put_be16(pb, PACKET_ID);
- put_be16(pb, fill_size);
- put_be64(pb, ffm->dts);
+ avio_wb16(pb, PACKET_ID);
+ avio_wb16(pb, fill_size);
+ avio_wb64(pb, ffm->dts);
h = ffm->frame_offset;
if (ffm->first_packet)
h |= 0x8000;
- put_be16(pb, h);
- put_buffer(pb, ffm->packet, ffm->packet_end - ffm->packet);
+ avio_wb16(pb, h);
+ avio_write(pb, ffm->packet, ffm->packet_end - ffm->packet);
put_flush_packet(pb);
/* prepare next packet */
@@ -84,24 +84,24 @@ static int ffm_write_header(AVFormatContext *s)
{
FFMContext *ffm = s->priv_data;
AVStream *st;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *codec;
int bit_rate, i;
ffm->packet_size = FFM_PACKET_SIZE;
/* header */
- put_le32(pb, MKTAG('F', 'F', 'M', '1'));
- put_be32(pb, ffm->packet_size);
- put_be64(pb, 0); /* current write position */
+ avio_wl32(pb, MKTAG('F', 'F', 'M', '1'));
+ avio_wb32(pb, ffm->packet_size);
+ avio_wb64(pb, 0); /* current write position */
- put_be32(pb, s->nb_streams);
+ avio_wb32(pb, s->nb_streams);
bit_rate = 0;
for(i=0;inb_streams;i++) {
st = s->streams[i];
bit_rate += st->codec->bit_rate;
}
- put_be32(pb, bit_rate);
+ avio_wb32(pb, bit_rate);
/* list of streams */
for(i=0;inb_streams;i++) {
@@ -110,82 +110,82 @@ static int ffm_write_header(AVFormatContext *s)
codec = st->codec;
/* generic info */
- put_be32(pb, codec->codec_id);
- put_byte(pb, codec->codec_type);
- put_be32(pb, codec->bit_rate);
- put_be32(pb, st->quality);
- put_be32(pb, codec->flags);
- put_be32(pb, codec->flags2);
- put_be32(pb, codec->debug);
+ avio_wb32(pb, codec->codec_id);
+ avio_w8(pb, codec->codec_type);
+ avio_wb32(pb, codec->bit_rate);
+ avio_wb32(pb, st->quality);
+ avio_wb32(pb, codec->flags);
+ avio_wb32(pb, codec->flags2);
+ avio_wb32(pb, codec->debug);
/* specific info */
switch(codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- put_be32(pb, codec->time_base.num);
- put_be32(pb, codec->time_base.den);
- put_be16(pb, codec->width);
- put_be16(pb, codec->height);
- put_be16(pb, codec->gop_size);
- put_be32(pb, codec->pix_fmt);
- put_byte(pb, codec->qmin);
- put_byte(pb, codec->qmax);
- put_byte(pb, codec->max_qdiff);
- put_be16(pb, (int) (codec->qcompress * 10000.0));
- put_be16(pb, (int) (codec->qblur * 10000.0));
- put_be32(pb, codec->bit_rate_tolerance);
+ avio_wb32(pb, codec->time_base.num);
+ avio_wb32(pb, codec->time_base.den);
+ avio_wb16(pb, codec->width);
+ avio_wb16(pb, codec->height);
+ avio_wb16(pb, codec->gop_size);
+ avio_wb32(pb, codec->pix_fmt);
+ avio_w8(pb, codec->qmin);
+ avio_w8(pb, codec->qmax);
+ avio_w8(pb, codec->max_qdiff);
+ avio_wb16(pb, (int) (codec->qcompress * 10000.0));
+ avio_wb16(pb, (int) (codec->qblur * 10000.0));
+ avio_wb32(pb, codec->bit_rate_tolerance);
avio_put_str(pb, codec->rc_eq ? codec->rc_eq : "tex^qComp");
- put_be32(pb, codec->rc_max_rate);
- put_be32(pb, codec->rc_min_rate);
- put_be32(pb, codec->rc_buffer_size);
- put_be64(pb, av_dbl2int(codec->i_quant_factor));
- put_be64(pb, av_dbl2int(codec->b_quant_factor));
- put_be64(pb, av_dbl2int(codec->i_quant_offset));
- put_be64(pb, av_dbl2int(codec->b_quant_offset));
- put_be32(pb, codec->dct_algo);
- put_be32(pb, codec->strict_std_compliance);
- put_be32(pb, codec->max_b_frames);
- put_be32(pb, codec->luma_elim_threshold);
- put_be32(pb, codec->chroma_elim_threshold);
- put_be32(pb, codec->mpeg_quant);
- put_be32(pb, codec->intra_dc_precision);
- put_be32(pb, codec->me_method);
- put_be32(pb, codec->mb_decision);
- put_be32(pb, codec->nsse_weight);
- put_be32(pb, codec->frame_skip_cmp);
- put_be64(pb, av_dbl2int(codec->rc_buffer_aggressivity));
- put_be32(pb, codec->codec_tag);
- put_byte(pb, codec->thread_count);
- put_be32(pb, codec->coder_type);
- put_be32(pb, codec->me_cmp);
- put_be32(pb, codec->partitions);
- put_be32(pb, codec->me_subpel_quality);
- put_be32(pb, codec->me_range);
- put_be32(pb, codec->keyint_min);
- put_be32(pb, codec->scenechange_threshold);
- put_be32(pb, codec->b_frame_strategy);
- put_be64(pb, av_dbl2int(codec->qcompress));
- put_be64(pb, av_dbl2int(codec->qblur));
- put_be32(pb, codec->max_qdiff);
- put_be32(pb, codec->refs);
- put_be32(pb, codec->directpred);
+ avio_wb32(pb, codec->rc_max_rate);
+ avio_wb32(pb, codec->rc_min_rate);
+ avio_wb32(pb, codec->rc_buffer_size);
+ avio_wb64(pb, av_dbl2int(codec->i_quant_factor));
+ avio_wb64(pb, av_dbl2int(codec->b_quant_factor));
+ avio_wb64(pb, av_dbl2int(codec->i_quant_offset));
+ avio_wb64(pb, av_dbl2int(codec->b_quant_offset));
+ avio_wb32(pb, codec->dct_algo);
+ avio_wb32(pb, codec->strict_std_compliance);
+ avio_wb32(pb, codec->max_b_frames);
+ avio_wb32(pb, codec->luma_elim_threshold);
+ avio_wb32(pb, codec->chroma_elim_threshold);
+ avio_wb32(pb, codec->mpeg_quant);
+ avio_wb32(pb, codec->intra_dc_precision);
+ avio_wb32(pb, codec->me_method);
+ avio_wb32(pb, codec->mb_decision);
+ avio_wb32(pb, codec->nsse_weight);
+ avio_wb32(pb, codec->frame_skip_cmp);
+ avio_wb64(pb, av_dbl2int(codec->rc_buffer_aggressivity));
+ avio_wb32(pb, codec->codec_tag);
+ avio_w8(pb, codec->thread_count);
+ avio_wb32(pb, codec->coder_type);
+ avio_wb32(pb, codec->me_cmp);
+ avio_wb32(pb, codec->partitions);
+ avio_wb32(pb, codec->me_subpel_quality);
+ avio_wb32(pb, codec->me_range);
+ avio_wb32(pb, codec->keyint_min);
+ avio_wb32(pb, codec->scenechange_threshold);
+ avio_wb32(pb, codec->b_frame_strategy);
+ avio_wb64(pb, av_dbl2int(codec->qcompress));
+ avio_wb64(pb, av_dbl2int(codec->qblur));
+ avio_wb32(pb, codec->max_qdiff);
+ avio_wb32(pb, codec->refs);
+ avio_wb32(pb, codec->directpred);
break;
case AVMEDIA_TYPE_AUDIO:
- put_be32(pb, codec->sample_rate);
- put_le16(pb, codec->channels);
- put_le16(pb, codec->frame_size);
- put_le16(pb, codec->sample_fmt);
+ avio_wb32(pb, codec->sample_rate);
+ avio_wl16(pb, codec->channels);
+ avio_wl16(pb, codec->frame_size);
+ avio_wl16(pb, codec->sample_fmt);
break;
default:
return -1;
}
if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) {
- put_be32(pb, codec->extradata_size);
- put_buffer(pb, codec->extradata, codec->extradata_size);
+ avio_wb32(pb, codec->extradata_size);
+ avio_write(pb, codec->extradata, codec->extradata_size);
}
}
/* flush until end of block reached */
while ((url_ftell(pb) % ffm->packet_size) != 0)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
put_flush_packet(pb);
@@ -228,7 +228,7 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)
static int ffm_write_trailer(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
FFMContext *ffm = s->priv_data;
/* flush packets */
diff --git a/mplayer/ffmpeg/libavformat/ffmetadec.c b/mplayer/ffmpeg/libavformat/ffmetadec.c
index ab35746e..cc7e1da4 100644
--- a/mplayer/ffmpeg/libavformat/ffmetadec.c
+++ b/mplayer/ffmpeg/libavformat/ffmetadec.c
@@ -21,6 +21,7 @@
#include "avformat.h"
#include "ffmeta.h"
+#include "internal.h"
static int probe(AVProbeData *p)
{
@@ -29,17 +30,17 @@ static int probe(AVProbeData *p)
return 0;
}
-static void get_line(ByteIOContext *s, uint8_t *buf, int size)
+static void get_line(AVIOContext *s, uint8_t *buf, int size)
{
do {
uint8_t c;
int i = 0;
- while ((c = get_byte(s))) {
+ while ((c = avio_r8(s))) {
if (c == '\\') {
if (i < size - 1)
buf[i++] = c;
- c = get_byte(s);
+ c = avio_r8(s);
} else if (c == '\n')
break;
diff --git a/mplayer/ffmpeg/libavformat/ffmetaenc.c b/mplayer/ffmpeg/libavformat/ffmetaenc.c
index b20abc90..77db0b9b 100644
--- a/mplayer/ffmpeg/libavformat/ffmetaenc.c
+++ b/mplayer/ffmpeg/libavformat/ffmetaenc.c
@@ -25,34 +25,34 @@
#include "ffmeta.h"
-static void write_escape_str(ByteIOContext *s, const uint8_t *str)
+static void write_escape_str(AVIOContext *s, const uint8_t *str)
{
const uint8_t *p = str;
while (*p) {
if (*p == '#' || *p == ';' || *p == '=' || *p == '\\' || *p == '\n')
- put_byte(s, '\\');
- put_byte(s, *p);
+ avio_w8(s, '\\');
+ avio_w8(s, *p);
p++;
}
}
-static void write_tags(ByteIOContext *s, AVMetadata *m)
+static void write_tags(AVIOContext *s, AVMetadata *m)
{
AVMetadataTag *t = NULL;
while ((t = av_metadata_get(m, "", t, AV_METADATA_IGNORE_SUFFIX))) {
write_escape_str(s, t->key);
- put_byte(s, '=');
+ avio_w8(s, '=');
write_escape_str(s, t->value);
- put_byte(s, '\n');
+ avio_w8(s, '\n');
}
}
static int write_header(AVFormatContext *s)
{
- put_tag(s->pb, ID_STRING);
- put_byte(s->pb, '1'); // version
- put_byte(s->pb, '\n');
+ avio_write(s->pb, ID_STRING, sizeof(ID_STRING) - 1);
+ avio_w8(s->pb, '1'); // version
+ avio_w8(s->pb, '\n');
put_flush_packet(s->pb);
return 0;
}
@@ -64,15 +64,15 @@ static int write_trailer(AVFormatContext *s)
write_tags(s->pb, s->metadata);
for (i = 0; i < s->nb_streams; i++) {
- put_tag(s->pb, ID_STREAM);
- put_byte(s->pb, '\n');
+ avio_write(s->pb, ID_STREAM, sizeof(ID_STREAM) - 1);
+ avio_w8(s->pb, '\n');
write_tags(s->pb, s->streams[i]->metadata);
}
for (i = 0; i < s->nb_chapters; i++) {
AVChapter *ch = s->chapters[i];
- put_tag(s->pb, ID_CHAPTER);
- put_byte(s->pb, '\n');
+ avio_write(s->pb, ID_CHAPTER, sizeof(ID_CHAPTER) - 1);
+ avio_w8(s->pb, '\n');
url_fprintf(s->pb, "TIMEBASE=%d/%d\n", ch->time_base.num, ch->time_base.den);
url_fprintf(s->pb, "START=%"PRId64"\n", ch->start);
url_fprintf(s->pb, "END=%"PRId64"\n", ch->end);
diff --git a/mplayer/ffmpeg/libavformat/filmstripdec.c b/mplayer/ffmpeg/libavformat/filmstripdec.c
index 805ca991..a987b93b 100644
--- a/mplayer/ffmpeg/libavformat/filmstripdec.c
+++ b/mplayer/ffmpeg/libavformat/filmstripdec.c
@@ -37,14 +37,14 @@ static int read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
FilmstripDemuxContext *film = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
if (url_is_streamed(s->pb))
return AVERROR(EIO);
- url_fseek(pb, url_fsize(pb) - 36, SEEK_SET);
- if (get_be32(pb) != RAND_TAG) {
+ avio_seek(pb, url_fsize(pb) - 36, SEEK_SET);
+ if (avio_rb32(pb) != RAND_TAG) {
av_log(s, AV_LOG_ERROR, "magic number not found");
return AVERROR_INVALIDDATA;
}
@@ -53,23 +53,23 @@ static int read_header(AVFormatContext *s,
if (!st)
return AVERROR(ENOMEM);
- st->nb_frames = get_be32(pb);
- if (get_be16(pb) != 0) {
+ st->nb_frames = avio_rb32(pb);
+ if (avio_rb16(pb) != 0) {
av_log_ask_for_sample(s, "unsupported packing method\n");
return AVERROR_INVALIDDATA;
}
- url_fskip(pb, 2);
+ avio_seek(pb, 2, SEEK_CUR);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec->pix_fmt = PIX_FMT_RGBA;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = get_be16(pb);
- st->codec->height = get_be16(pb);
- film->leading = get_be16(pb);
- av_set_pts_info(st, 64, 1, get_be16(pb));
+ st->codec->width = avio_rb16(pb);
+ st->codec->height = avio_rb16(pb);
+ film->leading = avio_rb16(pb);
+ av_set_pts_info(st, 64, 1, avio_rb16(pb));
- url_fseek(pb, 0, SEEK_SET);
+ avio_seek(pb, 0, SEEK_SET);
return 0;
}
@@ -84,7 +84,7 @@ static int read_packet(AVFormatContext *s,
return AVERROR(EIO);
pkt->dts = url_ftell(s->pb) / (st->codec->width * (st->codec->height + film->leading) * 4);
pkt->size = av_get_packet(s->pb, pkt, st->codec->width * st->codec->height * 4);
- url_fskip(s->pb, st->codec->width * film->leading * 4);
+ avio_seek(s->pb, st->codec->width * film->leading * 4, SEEK_CUR);
if (pkt->size < 0)
return pkt->size;
pkt->flags |= AV_PKT_FLAG_KEY;
@@ -94,7 +94,7 @@ static int read_packet(AVFormatContext *s,
static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
AVStream *st = s->streams[stream_index];
- url_fseek(s->pb, FFMAX(timestamp, 0) * st->codec->width * st->codec->height * 4, SEEK_SET);
+ avio_seek(s->pb, FFMAX(timestamp, 0) * st->codec->width * st->codec->height * 4, SEEK_SET);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/filmstripenc.c b/mplayer/ffmpeg/libavformat/filmstripenc.c
index 6da575cc..d20b4ecd 100644
--- a/mplayer/ffmpeg/libavformat/filmstripenc.c
+++ b/mplayer/ffmpeg/libavformat/filmstripenc.c
@@ -45,7 +45,7 @@ static int write_header(AVFormatContext *s)
static int write_packet(AVFormatContext *s, AVPacket *pkt)
{
FilmstripMuxContext *film = s->priv_data;
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
film->nb_frames++;
return 0;
}
@@ -53,20 +53,20 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
static int write_trailer(AVFormatContext *s)
{
FilmstripMuxContext *film = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
int i;
- put_be32(pb, RAND_TAG);
- put_be32(pb, film->nb_frames);
- put_be16(pb, 0); // packing method
- put_be16(pb, 0); // reserved
- put_be16(pb, st->codec->width);
- put_be16(pb, st->codec->height);
- put_be16(pb, 0); // leading
- put_be16(pb, 1/av_q2d(st->codec->time_base));
+ avio_wb32(pb, RAND_TAG);
+ avio_wb32(pb, film->nb_frames);
+ avio_wb16(pb, 0); // packing method
+ avio_wb16(pb, 0); // reserved
+ avio_wb16(pb, st->codec->width);
+ avio_wb16(pb, st->codec->height);
+ avio_wb16(pb, 0); // leading
+ avio_wb16(pb, 1/av_q2d(st->codec->time_base));
for (i = 0; i < 16; i++)
- put_byte(pb, 0x00); // reserved
+ avio_w8(pb, 0x00); // reserved
put_flush_packet(pb);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/flacdec.c b/mplayer/ffmpeg/libavformat/flacdec.c
index f971d099..73eeacb4 100644
--- a/mplayer/ffmpeg/libavformat/flacdec.c
+++ b/mplayer/ffmpeg/libavformat/flacdec.c
@@ -40,14 +40,14 @@ static int flac_read_header(AVFormatContext *s,
/* the parameters will be extracted from the compressed bitstream */
/* if fLaC marker is not found, assume there is no header */
- if (get_le32(s->pb) != MKTAG('f','L','a','C')) {
- url_fseek(s->pb, -4, SEEK_CUR);
+ if (avio_rl32(s->pb) != MKTAG('f','L','a','C')) {
+ avio_seek(s->pb, -4, SEEK_CUR);
return 0;
}
/* process metadata blocks */
while (!url_feof(s->pb) && !metadata_last) {
- get_buffer(s->pb, header, 4);
+ avio_read(s->pb, header, 4);
ff_flac_parse_block_header(header, &metadata_last, &metadata_type,
&metadata_size);
switch (metadata_type) {
@@ -58,14 +58,14 @@ static int flac_read_header(AVFormatContext *s,
if (!buffer) {
return AVERROR(ENOMEM);
}
- if (get_buffer(s->pb, buffer, metadata_size) != metadata_size) {
+ if (avio_read(s->pb, buffer, metadata_size) != metadata_size) {
av_freep(&buffer);
return AVERROR(EIO);
}
break;
/* skip metadata block for unsupported types */
default:
- ret = url_fseek(s->pb, metadata_size, SEEK_CUR);
+ ret = avio_seek(s->pb, metadata_size, SEEK_CUR);
if (ret < 0)
return ret;
}
diff --git a/mplayer/ffmpeg/libavformat/flacenc.c b/mplayer/ffmpeg/libavformat/flacenc.c
index 5eee5bec..cfd9e094 100644
--- a/mplayer/ffmpeg/libavformat/flacenc.c
+++ b/mplayer/ffmpeg/libavformat/flacenc.c
@@ -27,19 +27,19 @@
#include "libavcodec/bytestream.h"
-static int flac_write_block_padding(ByteIOContext *pb, unsigned int n_padding_bytes,
+static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_bytes,
int last_block)
{
- put_byte(pb, last_block ? 0x81 : 0x01);
- put_be24(pb, n_padding_bytes);
+ avio_w8(pb, last_block ? 0x81 : 0x01);
+ avio_wb24(pb, n_padding_bytes);
while (n_padding_bytes > 0) {
- put_byte(pb, 0);
+ avio_w8(pb, 0);
n_padding_bytes--;
}
return 0;
}
-static int flac_write_block_comment(ByteIOContext *pb, AVMetadata **m,
+static int flac_write_block_comment(AVIOContext *pb, AVMetadata **m,
int last_block, int bitexact)
{
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
@@ -58,7 +58,7 @@ static int flac_write_block_comment(ByteIOContext *pb, AVMetadata **m,
bytestream_put_be24(&p, len);
ff_vorbiscomment_write(&p, m, vendor, count);
- put_buffer(pb, p0, len+4);
+ avio_write(pb, p0, len+4);
av_freep(&p0);
p = NULL;
@@ -90,7 +90,7 @@ static int flac_write_header(struct AVFormatContext *s)
static int flac_write_trailer(struct AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint8_t *streaminfo;
enum FLACExtradataFormat format;
int64_t file_size;
@@ -101,9 +101,9 @@ static int flac_write_trailer(struct AVFormatContext *s)
if (!url_is_streamed(pb)) {
/* rewrite the STREAMINFO header block data */
file_size = url_ftell(pb);
- url_fseek(pb, 8, SEEK_SET);
- put_buffer(pb, streaminfo, FLAC_STREAMINFO_SIZE);
- url_fseek(pb, file_size, SEEK_SET);
+ avio_seek(pb, 8, SEEK_SET);
+ avio_write(pb, streaminfo, FLAC_STREAMINFO_SIZE);
+ avio_seek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
} else {
av_log(s, AV_LOG_WARNING, "unable to rewrite FLAC header.\n");
@@ -113,7 +113,7 @@ static int flac_write_trailer(struct AVFormatContext *s)
static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/flacenc.h b/mplayer/ffmpeg/libavformat/flacenc.h
index 8ad1c267..e83ee32a 100644
--- a/mplayer/ffmpeg/libavformat/flacenc.h
+++ b/mplayer/ffmpeg/libavformat/flacenc.h
@@ -26,7 +26,7 @@
#include "libavcodec/bytestream.h"
#include "avformat.h"
-int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec,
+int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec,
int last_block);
#endif /* AVFORMAT_FLACENC_H */
diff --git a/mplayer/ffmpeg/libavformat/flacenc_header.c b/mplayer/ffmpeg/libavformat/flacenc_header.c
index 92a129a7..389efbd0 100644
--- a/mplayer/ffmpeg/libavformat/flacenc_header.c
+++ b/mplayer/ffmpeg/libavformat/flacenc_header.c
@@ -24,7 +24,7 @@
#include "avformat.h"
#include "flacenc.h"
-int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec,
+int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec,
int last_block)
{
uint8_t header[8] = {
@@ -39,11 +39,11 @@ int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec,
/* write "fLaC" stream marker and first metadata block header if needed */
if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) {
- put_buffer(pb, header, 8);
+ avio_write(pb, header, 8);
}
/* write STREAMINFO or full header */
- put_buffer(pb, codec->extradata, codec->extradata_size);
+ avio_write(pb, codec->extradata, codec->extradata_size);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/flic.c b/mplayer/ffmpeg/libavformat/flic.c
index bf93c5c9..cdbd9c80 100644
--- a/mplayer/ffmpeg/libavformat/flic.c
+++ b/mplayer/ffmpeg/libavformat/flic.c
@@ -32,6 +32,7 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavutil/audioconvert.h"
#include "avformat.h"
#define FLIC_FILE_MAGIC_1 0xAF11
@@ -85,7 +86,7 @@ static int flic_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
FlicDemuxContext *flic = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned char header[FLIC_HEADER_SIZE];
AVStream *st, *ast;
int speed;
@@ -95,7 +96,7 @@ static int flic_read_header(AVFormatContext *s,
flic->frame_number = 0;
/* load the whole header and pull out the width and height */
- if (get_buffer(pb, header, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE)
+ if (avio_read(pb, header, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE)
return AVERROR(EIO);
magic_number = AV_RL16(&header[4]);
@@ -129,12 +130,12 @@ static int flic_read_header(AVFormatContext *s,
memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE);
/* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */
- if (get_buffer(pb, preamble, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) {
+ if (avio_read(pb, preamble, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) {
av_log(s, AV_LOG_ERROR, "Failed to peek at preamble\n");
return AVERROR(EIO);
}
- url_fseek(pb, -FLIC_PREAMBLE_SIZE, SEEK_CUR);
+ avio_seek(pb, -FLIC_PREAMBLE_SIZE, SEEK_CUR);
/* Time to figure out the framerate:
* If the first preamble's magic number is 0xAAAA then this file is from
@@ -160,7 +161,7 @@ static int flic_read_header(AVFormatContext *s,
ast->codec->sample_fmt = AV_SAMPLE_FMT_U8;
ast->codec->bit_rate = st->codec->sample_rate * 8;
ast->codec->bits_per_coded_sample = 8;
- ast->codec->channel_layout = CH_LAYOUT_MONO;
+ ast->codec->channel_layout = AV_CH_LAYOUT_MONO;
ast->codec->extradata_size = 0;
/* Since the header information is incorrect we have to figure out the
@@ -172,7 +173,7 @@ static int flic_read_header(AVFormatContext *s,
av_set_pts_info(st, 64, FLIC_MC_SPEED, 70);
/* rewind the stream since the first chunk is at offset 12 */
- url_fseek(pb, 12, SEEK_SET);
+ avio_seek(pb, 12, SEEK_SET);
/* send over abbreviated FLIC header chunk */
av_free(st->codec->extradata);
@@ -197,7 +198,7 @@ static int flic_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
FlicDemuxContext *flic = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int packet_read = 0;
unsigned int size;
int magic;
@@ -206,7 +207,7 @@ static int flic_read_packet(AVFormatContext *s,
while (!packet_read) {
- if ((ret = get_buffer(pb, preamble, FLIC_PREAMBLE_SIZE)) !=
+ if ((ret = avio_read(pb, preamble, FLIC_PREAMBLE_SIZE)) !=
FLIC_PREAMBLE_SIZE) {
ret = AVERROR(EIO);
break;
@@ -224,7 +225,7 @@ static int flic_read_packet(AVFormatContext *s,
pkt->pts = flic->frame_number++;
pkt->pos = url_ftell(pb);
memcpy(pkt->data, preamble, FLIC_PREAMBLE_SIZE);
- ret = get_buffer(pb, pkt->data + FLIC_PREAMBLE_SIZE,
+ ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE,
size - FLIC_PREAMBLE_SIZE);
if (ret != size - FLIC_PREAMBLE_SIZE) {
av_free_packet(pkt);
@@ -238,11 +239,11 @@ static int flic_read_packet(AVFormatContext *s,
}
/* skip useless 10B sub-header (yes, it's not accounted for in the chunk header) */
- url_fseek(pb, 10, SEEK_CUR);
+ avio_seek(pb, 10, SEEK_CUR);
pkt->stream_index = flic->audio_stream_index;
pkt->pos = url_ftell(pb);
- ret = get_buffer(pb, pkt->data, size);
+ ret = avio_read(pb, pkt->data, size);
if (ret != size) {
av_free_packet(pkt);
@@ -252,7 +253,7 @@ static int flic_read_packet(AVFormatContext *s,
packet_read = 1;
} else {
/* not interested in this chunk */
- url_fseek(pb, size - 6, SEEK_CUR);
+ avio_seek(pb, size - 6, SEEK_CUR);
}
}
diff --git a/mplayer/ffmpeg/libavformat/flvdec.c b/mplayer/ffmpeg/libavformat/flvdec.c
index e6081d98..3b30c7f2 100644
--- a/mplayer/ffmpeg/libavformat/flvdec.c
+++ b/mplayer/ffmpeg/libavformat/flvdec.c
@@ -97,7 +97,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_co
vcodec->extradata_size = 1;
vcodec->extradata = av_malloc(1);
}
- vcodec->extradata[0] = get_byte(s->pb);
+ vcodec->extradata[0] = avio_r8(s->pb);
return 1; // 1 byte body size adjustment for flv_read_packet()
case FLV_CODECID_H264:
vcodec->codec_id = CODEC_ID_H264;
@@ -110,14 +110,14 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_co
return 0;
}
-static int amf_get_string(ByteIOContext *ioc, char *buffer, int buffsize) {
- int length = get_be16(ioc);
+static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize) {
+ int length = avio_rb16(ioc);
if(length >= buffsize) {
- url_fskip(ioc, length);
+ avio_seek(ioc, length, SEEK_CUR);
return -1;
}
- get_buffer(ioc, buffer, length);
+ avio_read(ioc, buffer, length);
buffer[length] = '\0';
@@ -126,7 +126,7 @@ static int amf_get_string(ByteIOContext *ioc, char *buffer, int buffsize) {
static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth) {
AVCodecContext *acodec, *vcodec;
- ByteIOContext *ioc;
+ AVIOContext *ioc;
AMFDataType amf_type;
char str_val[256];
double num_val;
@@ -134,13 +134,13 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
num_val = 0;
ioc = s->pb;
- amf_type = get_byte(ioc);
+ amf_type = avio_r8(ioc);
switch(amf_type) {
case AMF_DATA_TYPE_NUMBER:
- num_val = av_int2dbl(get_be64(ioc)); break;
+ num_val = av_int2dbl(avio_rb64(ioc)); break;
case AMF_DATA_TYPE_BOOL:
- num_val = get_byte(ioc); break;
+ num_val = avio_r8(ioc); break;
case AMF_DATA_TYPE_STRING:
if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
return -1;
@@ -148,12 +148,12 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
case AMF_DATA_TYPE_OBJECT: {
unsigned int keylen;
- while(url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) {
- url_fskip(ioc, keylen); //skip key string
+ while(url_ftell(ioc) < max_pos - 2 && (keylen = avio_rb16(ioc))) {
+ avio_seek(ioc, keylen, SEEK_CUR); //skip key string
if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1; //if we couldn't skip, bomb out.
}
- if(get_byte(ioc) != AMF_END_OF_OBJECT)
+ if(avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
}
break;
@@ -162,19 +162,19 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
case AMF_DATA_TYPE_UNSUPPORTED:
break; //these take up no additional space
case AMF_DATA_TYPE_MIXEDARRAY:
- url_fskip(ioc, 4); //skip 32-bit max array index
+ avio_seek(ioc, 4, SEEK_CUR); //skip 32-bit max array index
while(url_ftell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) {
//this is the only case in which we would want a nested parse to not skip over the object
if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0)
return -1;
}
- if(get_byte(ioc) != AMF_END_OF_OBJECT)
+ if(avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_ARRAY: {
unsigned int arraylen, i;
- arraylen = get_be32(ioc);
+ arraylen = avio_rb32(ioc);
for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) {
if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1; //if we couldn't skip, bomb out.
@@ -182,7 +182,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
}
break;
case AMF_DATA_TYPE_DATE:
- url_fskip(ioc, 8 + 2); //timestamp (double) and UTC offset (int16)
+ avio_seek(ioc, 8 + 2, SEEK_CUR); //timestamp (double) and UTC offset (int16)
break;
default: //unsupported type, we couldn't skip
return -1;
@@ -213,7 +213,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
static int flv_read_metabody(AVFormatContext *s, int64_t next_pos) {
AMFDataType type;
AVStream *stream, *astream, *vstream;
- ByteIOContext *ioc;
+ AVIOContext *ioc;
int i;
char buffer[11]; //only needs to hold the string "onMetaData". Anything longer is something we don't want.
@@ -222,7 +222,7 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos) {
ioc = s->pb;
//first object needs to be "onMetaData" string
- type = get_byte(ioc);
+ type = avio_r8(ioc);
if(type != AMF_DATA_TYPE_STRING || amf_get_string(ioc, buffer, sizeof(buffer)) < 0 || strcmp(buffer, "onMetaData"))
return -1;
@@ -254,8 +254,8 @@ static int flv_read_header(AVFormatContext *s,
{
int offset, flags;
- url_fskip(s->pb, 4);
- flags = get_byte(s->pb);
+ avio_seek(s->pb, 4, SEEK_CUR);
+ flags = avio_r8(s->pb);
/* old flvtool cleared this field */
/* FIXME: better fix needed */
if (!flags) {
@@ -276,9 +276,9 @@ static int flv_read_header(AVFormatContext *s,
return AVERROR(ENOMEM);
}
- offset = get_be32(s->pb);
- url_fseek(s->pb, offset, SEEK_SET);
- url_fskip(s->pb, 4);
+ offset = avio_rb32(s->pb);
+ avio_seek(s->pb, offset, SEEK_SET);
+ avio_seek(s->pb, 4, SEEK_CUR);
s->start_time = 0;
@@ -292,7 +292,7 @@ static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = size;
- get_buffer(s->pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
return 0;
}
@@ -304,16 +304,16 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
int64_t dts, pts = AV_NOPTS_VALUE;
AVStream *st = NULL;
- for(;;url_fskip(s->pb, 4)){ /* pkt size is repeated at end. skip it */
+ for(;;avio_seek(s->pb, 4, SEEK_CUR)){ /* pkt size is repeated at end. skip it */
pos = url_ftell(s->pb);
- type = get_byte(s->pb);
- size = get_be24(s->pb);
- dts = get_be24(s->pb);
- dts |= get_byte(s->pb) << 24;
+ type = avio_r8(s->pb);
+ size = avio_rb24(s->pb);
+ dts = avio_rb24(s->pb);
+ dts |= avio_r8(s->pb) << 24;
// av_log(s, AV_LOG_DEBUG, "type:%d, size:%d, dts:%d\n", type, size, dts);
if (url_feof(s->pb))
return AVERROR_EOF;
- url_fskip(s->pb, 3); /* stream id, always 0 */
+ avio_seek(s->pb, 3, SEEK_CUR); /* stream id, always 0 */
flags = 0;
if(size == 0)
@@ -323,11 +323,11 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
if (type == FLV_TAG_TYPE_AUDIO) {
is_audio=1;
- flags = get_byte(s->pb);
+ flags = avio_r8(s->pb);
size--;
} else if (type == FLV_TAG_TYPE_VIDEO) {
is_audio=0;
- flags = get_byte(s->pb);
+ flags = avio_r8(s->pb);
size--;
if ((flags & 0xf0) == 0x50) /* video info / command frame */
goto skip;
@@ -337,7 +337,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
else /* skip packet */
av_log(s, AV_LOG_DEBUG, "skipping flv packet: type %d, size %d, flags %d\n", type, size, flags);
skip:
- url_fseek(s->pb, next, SEEK_SET);
+ avio_seek(s->pb, next, SEEK_SET);
continue;
}
@@ -361,7 +361,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
||(st->discard >= AVDISCARD_BIDIR && ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_DISP_INTER && !is_audio))
|| st->discard >= AVDISCARD_ALL
){
- url_fseek(s->pb, next, SEEK_SET);
+ avio_seek(s->pb, next, SEEK_SET);
continue;
}
if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY)
@@ -374,15 +374,15 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
int size;
const int64_t pos= url_ftell(s->pb);
const int64_t fsize= url_fsize(s->pb);
- url_fseek(s->pb, fsize-4, SEEK_SET);
- size= get_be32(s->pb);
- url_fseek(s->pb, fsize-3-size, SEEK_SET);
- if(size == get_be24(s->pb) + 11){
- uint32_t ts = get_be24(s->pb);
- ts |= get_byte(s->pb) << 24;
+ avio_seek(s->pb, fsize-4, SEEK_SET);
+ size= avio_rb32(s->pb);
+ avio_seek(s->pb, fsize-3-size, SEEK_SET);
+ if(size == avio_rb24(s->pb) + 11){
+ uint32_t ts = avio_rb24(s->pb);
+ ts |= avio_r8(s->pb) << 24;
s->duration = ts * (int64_t)AV_TIME_BASE / 1000;
}
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
}
if(is_audio){
@@ -400,10 +400,10 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
if (st->codec->codec_id == CODEC_ID_AAC ||
st->codec->codec_id == CODEC_ID_H264) {
- int type = get_byte(s->pb);
+ int type = avio_r8(s->pb);
size--;
if (st->codec->codec_id == CODEC_ID_H264) {
- int32_t cts = (get_be24(s->pb)+0xff800000)^0xff800000; // sign extension
+ int32_t cts = (avio_rb24(s->pb)+0xff800000)^0xff800000; // sign extension
pts = dts + cts;
if (cts < 0) { // dts are wrong
flv->wrong_dts = 1;
@@ -454,7 +454,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->flags |= AV_PKT_FLAG_KEY;
leave:
- url_fskip(s->pb, 4);
+ avio_seek(s->pb, 4, SEEK_CUR);
return ret;
}
diff --git a/mplayer/ffmpeg/libavformat/flvenc.c b/mplayer/ffmpeg/libavformat/flvenc.c
index b6e406bf..7dd47da8 100644
--- a/mplayer/ffmpeg/libavformat/flvenc.c
+++ b/mplayer/ffmpeg/libavformat/flvenc.c
@@ -139,39 +139,39 @@ static int get_audio_flags(AVCodecContext *enc){
return flags;
}
-static void put_amf_string(ByteIOContext *pb, const char *str)
+static void put_amf_string(AVIOContext *pb, const char *str)
{
size_t len = strlen(str);
- put_be16(pb, len);
- put_buffer(pb, str, len);
+ avio_wb16(pb, len);
+ avio_write(pb, str, len);
}
-static void put_avc_eos_tag(ByteIOContext *pb, unsigned ts) {
- put_byte(pb, FLV_TAG_TYPE_VIDEO);
- put_be24(pb, 5); /* Tag Data Size */
- put_be24(pb, ts); /* lower 24 bits of timestamp in ms*/
- put_byte(pb, (ts >> 24) & 0x7F); /* MSB of ts in ms*/
- put_be24(pb, 0); /* StreamId = 0 */
- put_byte(pb, 23); /* ub[4] FrameType = 1, ub[4] CodecId = 7 */
- put_byte(pb, 2); /* AVC end of sequence */
- put_be24(pb, 0); /* Always 0 for AVC EOS. */
- put_be32(pb, 16); /* Size of FLV tag */
+static void put_avc_eos_tag(AVIOContext *pb, unsigned ts) {
+ avio_w8(pb, FLV_TAG_TYPE_VIDEO);
+ avio_wb24(pb, 5); /* Tag Data Size */
+ avio_wb24(pb, ts); /* lower 24 bits of timestamp in ms*/
+ avio_w8(pb, (ts >> 24) & 0x7F); /* MSB of ts in ms*/
+ avio_wb24(pb, 0); /* StreamId = 0 */
+ avio_w8(pb, 23); /* ub[4] FrameType = 1, ub[4] CodecId = 7 */
+ avio_w8(pb, 2); /* AVC end of sequence */
+ avio_wb24(pb, 0); /* Always 0 for AVC EOS. */
+ avio_wb32(pb, 16); /* Size of FLV tag */
}
-static void put_amf_double(ByteIOContext *pb, double d)
+static void put_amf_double(AVIOContext *pb, double d)
{
- put_byte(pb, AMF_DATA_TYPE_NUMBER);
- put_be64(pb, av_dbl2int(d));
+ avio_w8(pb, AMF_DATA_TYPE_NUMBER);
+ avio_wb64(pb, av_dbl2int(d));
}
-static void put_amf_bool(ByteIOContext *pb, int b) {
- put_byte(pb, AMF_DATA_TYPE_BOOL);
- put_byte(pb, !!b);
+static void put_amf_bool(AVIOContext *pb, int b) {
+ avio_w8(pb, AMF_DATA_TYPE_BOOL);
+ avio_w8(pb, !!b);
}
static int flv_write_header(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
FLVContext *flv = s->priv_data;
AVCodecContext *audio_enc = NULL, *video_enc = NULL;
int i;
@@ -199,20 +199,20 @@ static int flv_write_header(AVFormatContext *s)
}
av_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */
}
- put_tag(pb,"FLV");
- put_byte(pb,1);
- put_byte(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc
+ avio_write(pb, "FLV", 3);
+ avio_w8(pb,1);
+ avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc
+ FLV_HEADER_FLAG_HASVIDEO * !!video_enc);
- put_be32(pb,9);
- put_be32(pb,0);
+ avio_wb32(pb,9);
+ avio_wb32(pb,0);
for(i=0; inb_streams; i++){
if(s->streams[i]->codec->codec_tag == 5){
- put_byte(pb,8); // message type
- put_be24(pb,0); // include flags
- put_be24(pb,0); // time stamp
- put_be32(pb,0); // reserved
- put_be32(pb,11); // size
+ avio_w8(pb,8); // message type
+ avio_wb24(pb,0); // include flags
+ avio_wb24(pb,0); // time stamp
+ avio_wb32(pb,0); // reserved
+ avio_wb32(pb,11); // size
flv->reserved=5;
}
}
@@ -220,21 +220,21 @@ static int flv_write_header(AVFormatContext *s)
flv->last_video_ts = -1;
/* write meta_tag */
- put_byte(pb, 18); // tag type META
+ avio_w8(pb, 18); // tag type META
metadata_size_pos= url_ftell(pb);
- put_be24(pb, 0); // size of data part (sum of all parts below)
- put_be24(pb, 0); // time stamp
- put_be32(pb, 0); // reserved
+ avio_wb24(pb, 0); // size of data part (sum of all parts below)
+ avio_wb24(pb, 0); // time stamp
+ avio_wb32(pb, 0); // reserved
/* now data of data_size size */
/* first event name as a string */
- put_byte(pb, AMF_DATA_TYPE_STRING);
+ avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, "onMetaData"); // 12 bytes
/* mixed array (hash) with size and string/type/data tuples */
- put_byte(pb, AMF_DATA_TYPE_MIXEDARRAY);
- put_be32(pb, 5*!!video_enc + 5*!!audio_enc + 2); // +2 for duration and file size
+ avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
+ avio_wb32(pb, 5*!!video_enc + 5*!!audio_enc + 2); // +2 for duration and file size
put_amf_string(pb, "duration");
flv->duration_offset= url_ftell(pb);
@@ -276,7 +276,7 @@ static int flv_write_header(AVFormatContext *s)
while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
put_amf_string(pb, tag->key);
- put_byte(pb, AMF_DATA_TYPE_STRING);
+ avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, tag->value);
}
@@ -285,41 +285,41 @@ static int flv_write_header(AVFormatContext *s)
put_amf_double(pb, 0); // delayed write
put_amf_string(pb, "");
- put_byte(pb, AMF_END_OF_OBJECT);
+ avio_w8(pb, AMF_END_OF_OBJECT);
/* write total size of tag */
data_size= url_ftell(pb) - metadata_size_pos - 10;
- url_fseek(pb, metadata_size_pos, SEEK_SET);
- put_be24(pb, data_size);
- url_fseek(pb, data_size + 10 - 3, SEEK_CUR);
- put_be32(pb, data_size + 11);
+ avio_seek(pb, metadata_size_pos, SEEK_SET);
+ avio_wb24(pb, data_size);
+ avio_seek(pb, data_size + 10 - 3, SEEK_CUR);
+ avio_wb32(pb, data_size + 11);
for (i = 0; i < s->nb_streams; i++) {
AVCodecContext *enc = s->streams[i]->codec;
if (enc->codec_id == CODEC_ID_AAC || enc->codec_id == CODEC_ID_H264) {
int64_t pos;
- put_byte(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?
+ avio_w8(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?
FLV_TAG_TYPE_VIDEO : FLV_TAG_TYPE_AUDIO);
- put_be24(pb, 0); // size patched later
- put_be24(pb, 0); // ts
- put_byte(pb, 0); // ts ext
- put_be24(pb, 0); // streamid
+ avio_wb24(pb, 0); // size patched later
+ avio_wb24(pb, 0); // ts
+ avio_w8(pb, 0); // ts ext
+ avio_wb24(pb, 0); // streamid
pos = url_ftell(pb);
if (enc->codec_id == CODEC_ID_AAC) {
- put_byte(pb, get_audio_flags(enc));
- put_byte(pb, 0); // AAC sequence header
- put_buffer(pb, enc->extradata, enc->extradata_size);
+ avio_w8(pb, get_audio_flags(enc));
+ avio_w8(pb, 0); // AAC sequence header
+ avio_write(pb, enc->extradata, enc->extradata_size);
} else {
- put_byte(pb, enc->codec_tag | FLV_FRAME_KEY); // flags
- put_byte(pb, 0); // AVC sequence header
- put_be24(pb, 0); // composition time
+ avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY); // flags
+ avio_w8(pb, 0); // AVC sequence header
+ avio_wb24(pb, 0); // composition time
ff_isom_write_avcc(pb, enc->extradata, enc->extradata_size);
}
data_size = url_ftell(pb) - pos;
- url_fseek(pb, -data_size - 10, SEEK_CUR);
- put_be24(pb, data_size);
- url_fseek(pb, data_size + 10 - 3, SEEK_CUR);
- put_be32(pb, data_size + 11); // previous tag size
+ avio_seek(pb, -data_size - 10, SEEK_CUR);
+ avio_wb24(pb, data_size);
+ avio_seek(pb, data_size + 10 - 3, SEEK_CUR);
+ avio_wb32(pb, data_size + 11); // previous tag size
}
}
@@ -330,7 +330,7 @@ static int flv_write_trailer(AVFormatContext *s)
{
int64_t file_size;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
FLVContext *flv = s->priv_data;
int i;
@@ -346,18 +346,18 @@ static int flv_write_trailer(AVFormatContext *s)
file_size = url_ftell(pb);
/* update informations */
- url_fseek(pb, flv->duration_offset, SEEK_SET);
+ avio_seek(pb, flv->duration_offset, SEEK_SET);
put_amf_double(pb, flv->duration / (double)1000);
- url_fseek(pb, flv->filesize_offset, SEEK_SET);
+ avio_seek(pb, flv->filesize_offset, SEEK_SET);
put_amf_double(pb, file_size);
- url_fseek(pb, file_size, SEEK_SET);
+ avio_seek(pb, file_size, SEEK_SET);
return 0;
}
static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[pkt->stream_index]->codec;
FLVContext *flv = s->priv_data;
unsigned ts;
@@ -376,7 +376,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
flags_size= 1;
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
- put_byte(pb, FLV_TAG_TYPE_VIDEO);
+ avio_w8(pb, FLV_TAG_TYPE_VIDEO);
flags = enc->codec_tag;
if(flags == 0) {
@@ -391,7 +391,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
assert(size);
- put_byte(pb, FLV_TAG_TYPE_AUDIO);
+ avio_w8(pb, FLV_TAG_TYPE_AUDIO);
}
if (enc->codec_id == CODEC_ID_H264) {
@@ -409,25 +409,25 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
if (flv->last_video_ts < ts)
flv->last_video_ts = ts;
}
- put_be24(pb,size + flags_size);
- put_be24(pb,ts);
- put_byte(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_
- put_be24(pb,flv->reserved);
- put_byte(pb,flags);
+ avio_wb24(pb,size + flags_size);
+ avio_wb24(pb,ts);
+ avio_w8(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_
+ avio_wb24(pb,flv->reserved);
+ avio_w8(pb,flags);
if (enc->codec_id == CODEC_ID_VP6)
- put_byte(pb,0);
+ avio_w8(pb,0);
if (enc->codec_id == CODEC_ID_VP6F)
- put_byte(pb, enc->extradata_size ? enc->extradata[0] : 0);
+ avio_w8(pb, enc->extradata_size ? enc->extradata[0] : 0);
else if (enc->codec_id == CODEC_ID_AAC)
- put_byte(pb,1); // AAC raw
+ avio_w8(pb,1); // AAC raw
else if (enc->codec_id == CODEC_ID_H264) {
- put_byte(pb,1); // AVC NALU
- put_be24(pb,pkt->pts - pkt->dts);
+ avio_w8(pb,1); // AVC NALU
+ avio_wb24(pb,pkt->pts - pkt->dts);
}
- put_buffer(pb, data ? data : pkt->data, size);
+ avio_write(pb, data ? data : pkt->data, size);
- put_be32(pb,size+flags_size+11); // previous tag size
+ avio_wb32(pb,size+flags_size+11); // previous tag size
flv->duration = FFMAX(flv->duration, pkt->pts + flv->delay + pkt->duration);
put_flush_packet(pb);
diff --git a/mplayer/ffmpeg/libavformat/framecrcenc.c b/mplayer/ffmpeg/libavformat/framecrcenc.c
index f456ec68..26ede954 100644
--- a/mplayer/ffmpeg/libavformat/framecrcenc.c
+++ b/mplayer/ffmpeg/libavformat/framecrcenc.c
@@ -28,7 +28,7 @@ static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
char buf[256];
snprintf(buf, sizeof(buf), "%d, %"PRId64", %d, 0x%08x\n", pkt->stream_index, pkt->dts, pkt->size, crc);
- put_buffer(s->pb, buf, strlen(buf));
+ avio_write(s->pb, buf, strlen(buf));
put_flush_packet(s->pb);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/gif.c b/mplayer/ffmpeg/libavformat/gif.c
index 2388f9ba..17effaaa 100644
--- a/mplayer/ffmpeg/libavformat/gif.c
+++ b/mplayer/ffmpeg/libavformat/gif.c
@@ -107,33 +107,33 @@ static const rgb_triplet gif_clut[216] = {
};
/* GIF header */
-static int gif_image_write_header(ByteIOContext *pb,
+static int gif_image_write_header(AVIOContext *pb,
int width, int height, int loop_count,
uint32_t *palette)
{
int i;
unsigned int v;
- put_tag(pb, "GIF");
- put_tag(pb, "89a");
- put_le16(pb, width);
- put_le16(pb, height);
+ avio_write(pb, "GIF", 3);
+ avio_write(pb, "89a", 3);
+ avio_wl16(pb, width);
+ avio_wl16(pb, height);
- put_byte(pb, 0xf7); /* flags: global clut, 256 entries */
- put_byte(pb, 0x1f); /* background color index */
- put_byte(pb, 0); /* aspect ratio */
+ avio_w8(pb, 0xf7); /* flags: global clut, 256 entries */
+ avio_w8(pb, 0x1f); /* background color index */
+ avio_w8(pb, 0); /* aspect ratio */
/* the global palette */
if (!palette) {
- put_buffer(pb, (const unsigned char *)gif_clut, 216*3);
+ avio_write(pb, (const unsigned char *)gif_clut, 216*3);
for(i=0;i<((256-216)*3);i++)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
} else {
for(i=0;i<256;i++) {
v = palette[i];
- put_byte(pb, (v >> 16) & 0xff);
- put_byte(pb, (v >> 8) & 0xff);
- put_byte(pb, (v) & 0xff);
+ avio_w8(pb, (v >> 16) & 0xff);
+ avio_w8(pb, (v >> 8) & 0xff);
+ avio_w8(pb, (v) & 0xff);
}
}
@@ -159,14 +159,14 @@ static int gif_image_write_header(ByteIOContext *pb,
/* application extension header */
#ifdef GIF_ADD_APP_HEADER
if (loop_count >= 0 && loop_count <= 65535) {
- put_byte(pb, 0x21);
- put_byte(pb, 0xff);
- put_byte(pb, 0x0b);
- put_tag(pb, "NETSCAPE2.0"); // bytes 4 to 14
- put_byte(pb, 0x03); // byte 15
- put_byte(pb, 0x01); // byte 16
- put_le16(pb, (uint16_t)loop_count);
- put_byte(pb, 0x00); // byte 19
+ avio_w8(pb, 0x21);
+ avio_w8(pb, 0xff);
+ avio_w8(pb, 0x0b);
+ avio_write(pb, "NETSCAPE2.0", sizeof("NETSCAPE2.0") - 1); // bytes 4 to 14
+ avio_w8(pb, 0x03); // byte 15
+ avio_w8(pb, 0x01); // byte 16
+ avio_wl16(pb, (uint16_t)loop_count);
+ avio_w8(pb, 0x00); // byte 19
}
#endif
return 0;
@@ -179,7 +179,7 @@ static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b)
}
-static int gif_image_write_image(ByteIOContext *pb,
+static int gif_image_write_image(AVIOContext *pb,
int x1, int y1, int width, int height,
const uint8_t *buf, int linesize, int pix_fmt)
{
@@ -189,15 +189,15 @@ static int gif_image_write_image(ByteIOContext *pb,
const uint8_t *ptr;
/* image block */
- put_byte(pb, 0x2c);
- put_le16(pb, x1);
- put_le16(pb, y1);
- put_le16(pb, width);
- put_le16(pb, height);
- put_byte(pb, 0x00); /* flags */
+ avio_w8(pb, 0x2c);
+ avio_wl16(pb, x1);
+ avio_wl16(pb, y1);
+ avio_wl16(pb, width);
+ avio_wl16(pb, height);
+ avio_w8(pb, 0x00); /* flags */
/* no local clut */
- put_byte(pb, 0x08);
+ avio_w8(pb, 0x08);
left= width * height;
@@ -233,13 +233,13 @@ static int gif_image_write_image(ByteIOContext *pb,
flush_put_bits(&p);
}
if(put_bits_ptr(&p) - p.buf > 0) {
- put_byte(pb, put_bits_ptr(&p) - p.buf); /* byte count of the packet */
- put_buffer(pb, p.buf, put_bits_ptr(&p) - p.buf); /* the actual buffer */
+ avio_w8(pb, put_bits_ptr(&p) - p.buf); /* byte count of the packet */
+ avio_write(pb, p.buf, put_bits_ptr(&p) - p.buf); /* the actual buffer */
p.buf_ptr = p.buf; /* dequeue the bytes off the bitstream */
}
left-=GIF_CHUNKS;
}
- put_byte(pb, 0x00); /* end of image block */
+ avio_w8(pb, 0x00); /* end of image block */
return 0;
}
@@ -252,7 +252,7 @@ typedef struct {
static int gif_write_header(AVFormatContext *s)
{
GIFContext *gif = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *enc, *video_enc;
int i, width, height, loop_count /*, rate*/;
@@ -294,16 +294,16 @@ static int gif_write_header(AVFormatContext *s)
static int gif_write_video(AVFormatContext *s,
AVCodecContext *enc, const uint8_t *buf, int size)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
GIFContext *gif = s->priv_data;
int jiffies;
int64_t delay;
/* graphic control extension block */
- put_byte(pb, 0x21);
- put_byte(pb, 0xf9);
- put_byte(pb, 0x04); /* block size */
- put_byte(pb, 0x04); /* flags */
+ avio_w8(pb, 0x21);
+ avio_w8(pb, 0xf9);
+ avio_w8(pb, 0x04); /* block size */
+ avio_w8(pb, 0x04); /* flags */
/* 1 jiffy is 1/70 s */
/* the delay_time field indicates the number of jiffies - 1 */
@@ -314,10 +314,10 @@ static int gif_write_video(AVFormatContext *s,
/* XXX: don't even remember if I really use it for now */
jiffies = (70*enc->time_base.num/enc->time_base.den) - 1;
- put_le16(pb, jiffies);
+ avio_wl16(pb, jiffies);
- put_byte(pb, 0x1f); /* transparent color index */
- put_byte(pb, 0x00);
+ avio_w8(pb, 0x1f); /* transparent color index */
+ avio_w8(pb, 0x00);
gif_image_write_image(pb, 0, 0, enc->width, enc->height,
buf, enc->width * 3, PIX_FMT_RGB24);
@@ -337,9 +337,9 @@ static int gif_write_packet(AVFormatContext *s, AVPacket *pkt)
static int gif_write_trailer(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
- put_byte(pb, 0x3b);
+ avio_w8(pb, 0x3b);
put_flush_packet(s->pb);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/gxf.c b/mplayer/ffmpeg/libavformat/gxf.c
index 1e08d826..e2625f9d 100644
--- a/mplayer/ffmpeg/libavformat/gxf.c
+++ b/mplayer/ffmpeg/libavformat/gxf.c
@@ -33,26 +33,26 @@ struct gxf_stream_info {
/**
* \brief parses a packet header, extracting type and length
- * \param pb ByteIOContext to read header from
+ * \param pb AVIOContext to read header from
* \param type detected packet type is stored here
* \param length detected packet length, excluding header is stored here
* \return 0 if header not found or contains invalid data, 1 otherwise
*/
-static int parse_packet_header(ByteIOContext *pb, GXFPktType *type, int *length) {
- if (get_be32(pb))
+static int parse_packet_header(AVIOContext *pb, GXFPktType *type, int *length) {
+ if (avio_rb32(pb))
return 0;
- if (get_byte(pb) != 1)
+ if (avio_r8(pb) != 1)
return 0;
- *type = get_byte(pb);
- *length = get_be32(pb);
+ *type = avio_r8(pb);
+ *length = avio_rb32(pb);
if ((*length >> 24) || *length < 16)
return 0;
*length -= 16;
- if (get_be32(pb))
+ if (avio_rb32(pb))
return 0;
- if (get_byte(pb) != 0xe1)
+ if (avio_r8(pb) != 0xe1)
return 0;
- if (get_byte(pb) != 0xe2)
+ if (avio_r8(pb) != 0xe2)
return 0;
return 1;
}
@@ -157,24 +157,24 @@ static int get_sindex(AVFormatContext *s, int id, int format) {
* \param len length of tag section, will be adjusted to contain remaining bytes
* \param si struct to store collected information into
*/
-static void gxf_material_tags(ByteIOContext *pb, int *len, struct gxf_stream_info *si) {
+static void gxf_material_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si) {
si->first_field = AV_NOPTS_VALUE;
si->last_field = AV_NOPTS_VALUE;
while (*len >= 2) {
- GXFMatTag tag = get_byte(pb);
- int tlen = get_byte(pb);
+ GXFMatTag tag = avio_r8(pb);
+ int tlen = avio_r8(pb);
*len -= 2;
if (tlen > *len)
return;
*len -= tlen;
if (tlen == 4) {
- uint32_t value = get_be32(pb);
+ uint32_t value = avio_rb32(pb);
if (tag == MAT_FIRST_FIELD)
si->first_field = value;
else if (tag == MAT_LAST_FIELD)
si->last_field = value;
} else
- url_fskip(pb, tlen);
+ avio_seek(pb, tlen, SEEK_CUR);
}
}
@@ -206,24 +206,24 @@ static AVRational fps_umf2avr(uint32_t flags) {
* \param len length of tag section, will be adjusted to contain remaining bytes
* \param si struct to store collected information into
*/
-static void gxf_track_tags(ByteIOContext *pb, int *len, struct gxf_stream_info *si) {
+static void gxf_track_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si) {
si->frames_per_second = (AVRational){0, 0};
si->fields_per_frame = 0;
while (*len >= 2) {
- GXFTrackTag tag = get_byte(pb);
- int tlen = get_byte(pb);
+ GXFTrackTag tag = avio_r8(pb);
+ int tlen = avio_r8(pb);
*len -= 2;
if (tlen > *len)
return;
*len -= tlen;
if (tlen == 4) {
- uint32_t value = get_be32(pb);
+ uint32_t value = avio_rb32(pb);
if (tag == TRACK_FPS)
si->frames_per_second = fps_tag2avr(value);
else if (tag == TRACK_FPF && (value == 1 || value == 2))
si->fields_per_frame = value;
} else
- url_fskip(pb, tlen);
+ avio_seek(pb, tlen, SEEK_CUR);
}
}
@@ -231,14 +231,14 @@ static void gxf_track_tags(ByteIOContext *pb, int *len, struct gxf_stream_info *
* \brief read index from FLT packet into stream 0 av_index
*/
static void gxf_read_index(AVFormatContext *s, int pkt_len) {
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
- uint32_t fields_per_map = get_le32(pb);
- uint32_t map_cnt = get_le32(pb);
+ uint32_t fields_per_map = avio_rl32(pb);
+ uint32_t map_cnt = avio_rl32(pb);
int i;
pkt_len -= 8;
if (s->flags & AVFMT_FLAG_IGNIDX) {
- url_fskip(pb, pkt_len);
+ avio_seek(pb, pkt_len, SEEK_CUR);
return;
}
if (map_cnt > 1000) {
@@ -247,19 +247,19 @@ static void gxf_read_index(AVFormatContext *s, int pkt_len) {
}
if (pkt_len < 4 * map_cnt) {
av_log(s, AV_LOG_ERROR, "invalid index length\n");
- url_fskip(pb, pkt_len);
+ avio_seek(pb, pkt_len, SEEK_CUR);
return;
}
pkt_len -= 4 * map_cnt;
av_add_index_entry(st, 0, 0, 0, 0, 0);
for (i = 0; i < map_cnt; i++)
- av_add_index_entry(st, (uint64_t)get_le32(pb) * 1024,
+ av_add_index_entry(st, (uint64_t)avio_rl32(pb) * 1024,
i * (uint64_t)fields_per_map + 1, 0, 0, 0);
- url_fskip(pb, pkt_len);
+ avio_seek(pb, pkt_len, SEEK_CUR);
}
static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
GXFPktType pkt_type;
int map_len;
int len;
@@ -271,21 +271,21 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
return 0;
}
map_len -= 2;
- if (get_byte(pb) != 0x0e0 || get_byte(pb) != 0xff) {
+ if (avio_r8(pb) != 0x0e0 || avio_r8(pb) != 0xff) {
av_log(s, AV_LOG_ERROR, "unknown version or invalid map preamble\n");
return 0;
}
map_len -= 2;
- len = get_be16(pb); // length of material data section
+ len = avio_rb16(pb); // length of material data section
if (len > map_len) {
av_log(s, AV_LOG_ERROR, "material data longer than map data\n");
return 0;
}
map_len -= len;
gxf_material_tags(pb, &len, &si);
- url_fskip(pb, len);
+ avio_seek(pb, len, SEEK_CUR);
map_len -= 2;
- len = get_be16(pb); // length of track description
+ len = avio_rb16(pb); // length of track description
if (len > map_len) {
av_log(s, AV_LOG_ERROR, "track description longer than map data\n");
return 0;
@@ -296,12 +296,12 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
AVStream *st;
int idx;
len -= 4;
- track_type = get_byte(pb);
- track_id = get_byte(pb);
- track_len = get_be16(pb);
+ track_type = avio_r8(pb);
+ track_id = avio_r8(pb);
+ track_len = avio_rb16(pb);
len -= track_len;
gxf_track_tags(pb, &track_len, &si);
- url_fskip(pb, track_len);
+ avio_seek(pb, track_len, SEEK_CUR);
if (!(track_type & 0x80)) {
av_log(s, AV_LOG_ERROR, "invalid track type %x\n", track_type);
continue;
@@ -326,7 +326,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
if (len < 0)
av_log(s, AV_LOG_ERROR, "invalid track description length specified\n");
if (map_len)
- url_fskip(pb, map_len);
+ avio_seek(pb, map_len, SEEK_CUR);
if (!parse_packet_header(pb, &pkt_type, &len)) {
av_log(s, AV_LOG_ERROR, "sync lost in header\n");
return -1;
@@ -342,9 +342,9 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
if (len >= 0x39) {
AVRational fps;
len -= 0x39;
- url_fskip(pb, 5); // preamble
- url_fskip(pb, 0x30); // payload description
- fps = fps_umf2avr(get_le32(pb));
+ avio_seek(pb, 5, SEEK_CUR); // preamble
+ avio_seek(pb, 0x30, SEEK_CUR); // payload description
+ fps = fps_umf2avr(avio_rl32(pb));
if (!main_timebase.num || !main_timebase.den) {
// this may not always be correct, but simply the best we can get
main_timebase.num = fps.den;
@@ -354,7 +354,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
av_log(s, AV_LOG_INFO, "UMF packet too short\n");
} else
av_log(s, AV_LOG_INFO, "UMF packet missing\n");
- url_fskip(pb, len);
+ avio_seek(pb, len, SEEK_CUR);
// set a fallback value, 60000/1001 is specified for audio-only files
// so use that regardless of why we do not know the video frame rate.
if (!main_timebase.num || !main_timebase.den)
@@ -370,7 +370,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
{ \
if (!max_interval-- || url_feof(pb)) \
goto out; \
- tmp = tmp << 8 | get_byte(pb); \
+ tmp = tmp << 8 | avio_r8(pb); \
}
/**
@@ -387,9 +387,9 @@ static int64_t gxf_resync_media(AVFormatContext *s, uint64_t max_interval, int t
int cur_track;
int64_t cur_timestamp = AV_NOPTS_VALUE;
int len;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
GXFPktType type;
- tmp = get_be32(pb);
+ tmp = avio_rb32(pb);
start:
while (tmp)
READ_ONE();
@@ -397,29 +397,29 @@ static int64_t gxf_resync_media(AVFormatContext *s, uint64_t max_interval, int t
if (tmp != 1)
goto start;
last_pos = url_ftell(pb);
- if (url_fseek(pb, -5, SEEK_CUR) < 0)
+ if (avio_seek(pb, -5, SEEK_CUR) < 0)
goto out;
if (!parse_packet_header(pb, &type, &len) || type != PKT_MEDIA) {
- if (url_fseek(pb, last_pos, SEEK_SET) < 0)
+ if (avio_seek(pb, last_pos, SEEK_SET) < 0)
goto out;
goto start;
}
- get_byte(pb);
- cur_track = get_byte(pb);
- cur_timestamp = get_be32(pb);
+ avio_r8(pb);
+ cur_track = avio_r8(pb);
+ cur_timestamp = avio_rb32(pb);
last_found_pos = url_ftell(pb) - 16 - 6;
if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) {
- if (url_fseek(pb, last_pos, SEEK_SET) >= 0)
+ if (avio_seek(pb, last_pos, SEEK_SET) >= 0)
goto start;
}
out:
if (last_found_pos)
- url_fseek(pb, last_found_pos, SEEK_SET);
+ avio_seek(pb, last_found_pos, SEEK_SET);
return cur_timestamp;
}
static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
GXFPktType pkt_type;
int pkt_len;
while (!url_feof(pb)) {
@@ -437,7 +437,7 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
continue;
}
if (pkt_type != PKT_MEDIA) {
- url_fskip(pb, pkt_len);
+ avio_seek(pb, pkt_len, SEEK_CUR);
continue;
}
if (pkt_len < 16) {
@@ -445,24 +445,24 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
continue;
}
pkt_len -= 16;
- track_type = get_byte(pb);
- track_id = get_byte(pb);
+ track_type = avio_r8(pb);
+ track_id = avio_r8(pb);
stream_index = get_sindex(s, track_id, track_type);
if (stream_index < 0)
return stream_index;
st = s->streams[stream_index];
- field_nr = get_be32(pb);
- field_info = get_be32(pb);
- get_be32(pb); // "timeline" field number
- get_byte(pb); // flags
- get_byte(pb); // reserved
+ field_nr = avio_rb32(pb);
+ field_info = avio_rb32(pb);
+ avio_rb32(pb); // "timeline" field number
+ avio_r8(pb); // flags
+ avio_r8(pb); // reserved
if (st->codec->codec_id == CODEC_ID_PCM_S24LE ||
st->codec->codec_id == CODEC_ID_PCM_S16LE) {
int first = field_info >> 16;
int last = field_info & 0xffff; // last is exclusive
int bps = av_get_bits_per_sample(st->codec->codec_id)>>3;
if (first <= last && last*bps <= pkt_len) {
- url_fskip(pb, first*bps);
+ avio_seek(pb, first*bps, SEEK_CUR);
skip = pkt_len - last*bps;
pkt_len = (last-first)*bps;
} else
@@ -470,7 +470,7 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
}
ret = av_get_packet(pb, pkt, pkt_len);
if (skip)
- url_fskip(pb, skip);
+ avio_seek(pb, skip, SEEK_CUR);
pkt->stream_index = stream_index;
pkt->dts = field_nr;
return ret;
@@ -495,7 +495,7 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int
if (idx < st->nb_index_entries - 2)
maxlen = st->index_entries[idx + 2].pos - pos;
maxlen = FFMAX(maxlen, 200 * 1024);
- res = url_fseek(s->pb, pos, SEEK_SET);
+ res = avio_seek(s->pb, pos, SEEK_SET);
if (res < 0)
return res;
found = gxf_resync_media(s, maxlen, -1, timestamp);
@@ -506,9 +506,9 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int
static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index,
int64_t *pos, int64_t pos_limit) {
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t res;
- if (url_fseek(pb, *pos, SEEK_SET) < 0)
+ if (avio_seek(pb, *pos, SEEK_SET) < 0)
return AV_NOPTS_VALUE;
res = gxf_resync_media(s, pos_limit - *pos, -1, -1);
*pos = url_ftell(pb);
diff --git a/mplayer/ffmpeg/libavformat/gxfenc.c b/mplayer/ffmpeg/libavformat/gxfenc.c
index 94976a36..66accb3e 100644
--- a/mplayer/ffmpeg/libavformat/gxfenc.c
+++ b/mplayer/ffmpeg/libavformat/gxfenc.c
@@ -113,14 +113,14 @@ static int gxf_find_lines_index(AVStream *st)
return -1;
}
-static void gxf_write_padding(ByteIOContext *pb, int64_t to_pad)
+static void gxf_write_padding(AVIOContext *pb, int64_t to_pad)
{
for (; to_pad > 0; to_pad--) {
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
}
-static int64_t updatePacketSize(ByteIOContext *pb, int64_t pos)
+static int64_t updatePacketSize(AVIOContext *pb, int64_t pos)
{
int64_t curpos;
int size;
@@ -131,35 +131,35 @@ static int64_t updatePacketSize(ByteIOContext *pb, int64_t pos)
size = url_ftell(pb) - pos;
}
curpos = url_ftell(pb);
- url_fseek(pb, pos + 6, SEEK_SET);
- put_be32(pb, size);
- url_fseek(pb, curpos, SEEK_SET);
+ avio_seek(pb, pos + 6, SEEK_SET);
+ avio_wb32(pb, size);
+ avio_seek(pb, curpos, SEEK_SET);
return curpos - pos;
}
-static int64_t updateSize(ByteIOContext *pb, int64_t pos)
+static int64_t updateSize(AVIOContext *pb, int64_t pos)
{
int64_t curpos;
curpos = url_ftell(pb);
- url_fseek(pb, pos, SEEK_SET);
- put_be16(pb, curpos - pos - 2);
- url_fseek(pb, curpos, SEEK_SET);
+ avio_seek(pb, pos, SEEK_SET);
+ avio_wb16(pb, curpos - pos - 2);
+ avio_seek(pb, curpos, SEEK_SET);
return curpos - pos;
}
-static void gxf_write_packet_header(ByteIOContext *pb, GXFPktType type)
+static void gxf_write_packet_header(AVIOContext *pb, GXFPktType type)
{
- put_be32(pb, 0); /* packet leader for synchro */
- put_byte(pb, 1);
- put_byte(pb, type); /* map packet */
- put_be32(pb, 0); /* size */
- put_be32(pb, 0); /* reserved */
- put_byte(pb, 0xE1); /* trailer 1 */
- put_byte(pb, 0xE2); /* trailer 2 */
+ avio_wb32(pb, 0); /* packet leader for synchro */
+ avio_w8(pb, 1);
+ avio_w8(pb, type); /* map packet */
+ avio_wb32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* reserved */
+ avio_w8(pb, 0xE1); /* trailer 1 */
+ avio_w8(pb, 0xE2); /* trailer 2 */
}
-static int gxf_write_mpeg_auxiliary(ByteIOContext *pb, AVStream *st)
+static int gxf_write_mpeg_auxiliary(AVIOContext *pb, AVStream *st)
{
GXFStreamContext *sc = st->priv_data;
char buffer[1024];
@@ -191,75 +191,75 @@ static int gxf_write_mpeg_auxiliary(ByteIOContext *pb, AVStream *st)
(float)st->codec->bit_rate, sc->p_per_gop, sc->b_per_i_or_p,
st->codec->pix_fmt == PIX_FMT_YUV422P ? 2 : 1, sc->first_gop_closed == 1,
starting_line, (st->codec->height + 15) / 16);
- put_byte(pb, TRACK_MPG_AUX);
- put_byte(pb, size + 1);
- put_buffer(pb, (uint8_t *)buffer, size + 1);
+ avio_w8(pb, TRACK_MPG_AUX);
+ avio_w8(pb, size + 1);
+ avio_write(pb, (uint8_t *)buffer, size + 1);
return size + 3;
}
-static int gxf_write_timecode_auxiliary(ByteIOContext *pb, GXFStreamContext *sc)
+static int gxf_write_timecode_auxiliary(AVIOContext *pb, GXFStreamContext *sc)
{
- put_byte(pb, 0); /* fields */
- put_byte(pb, 0); /* seconds */
- put_byte(pb, 0); /* minutes */
- put_byte(pb, 0); /* flags + hours */
+ avio_w8(pb, 0); /* fields */
+ avio_w8(pb, 0); /* seconds */
+ avio_w8(pb, 0); /* minutes */
+ avio_w8(pb, 0); /* flags + hours */
/* reserved */
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
return 8;
}
static int gxf_write_track_description(AVFormatContext *s, GXFStreamContext *sc, int index)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pos;
int mpeg = sc->track_type == 4 || sc->track_type == 9;
/* track description section */
- put_byte(pb, sc->media_type + 0x80);
- put_byte(pb, index + 0xC0);
+ avio_w8(pb, sc->media_type + 0x80);
+ avio_w8(pb, index + 0xC0);
pos = url_ftell(pb);
- put_be16(pb, 0); /* size */
+ avio_wb16(pb, 0); /* size */
/* media file name */
- put_byte(pb, TRACK_NAME);
- put_byte(pb, strlen(ES_NAME_PATTERN) + 3);
- put_tag(pb, ES_NAME_PATTERN);
- put_be16(pb, sc->media_info);
- put_byte(pb, 0);
+ avio_w8(pb, TRACK_NAME);
+ avio_w8(pb, strlen(ES_NAME_PATTERN) + 3);
+ avio_write(pb, ES_NAME_PATTERN, sizeof(ES_NAME_PATTERN) - 1);
+ avio_wb16(pb, sc->media_info);
+ avio_w8(pb, 0);
if (!mpeg) {
/* auxiliary information */
- put_byte(pb, TRACK_AUX);
- put_byte(pb, 8);
+ avio_w8(pb, TRACK_AUX);
+ avio_w8(pb, 8);
if (sc->track_type == 3)
gxf_write_timecode_auxiliary(pb, sc);
else
- put_le64(pb, 0);
+ avio_wl64(pb, 0);
}
/* file system version */
- put_byte(pb, TRACK_VER);
- put_byte(pb, 4);
- put_be32(pb, 0);
+ avio_w8(pb, TRACK_VER);
+ avio_w8(pb, 4);
+ avio_wb32(pb, 0);
if (mpeg)
gxf_write_mpeg_auxiliary(pb, s->streams[index]);
/* frame rate */
- put_byte(pb, TRACK_FPS);
- put_byte(pb, 4);
- put_be32(pb, sc->frame_rate_index);
+ avio_w8(pb, TRACK_FPS);
+ avio_w8(pb, 4);
+ avio_wb32(pb, sc->frame_rate_index);
/* lines per frame */
- put_byte(pb, TRACK_LINES);
- put_byte(pb, 4);
- put_be32(pb, sc->lines_index);
+ avio_w8(pb, TRACK_LINES);
+ avio_w8(pb, 4);
+ avio_wb32(pb, sc->lines_index);
/* fields per frame */
- put_byte(pb, TRACK_FPF);
- put_byte(pb, 4);
- put_be32(pb, sc->fields);
+ avio_w8(pb, TRACK_FPF);
+ avio_w8(pb, 4);
+ avio_wb32(pb, sc->fields);
return updateSize(pb, pos);
}
@@ -267,47 +267,50 @@ static int gxf_write_track_description(AVFormatContext *s, GXFStreamContext *sc,
static int gxf_write_material_data_section(AVFormatContext *s)
{
GXFContext *gxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pos;
+ int len;
const char *filename = strrchr(s->filename, '/');
pos = url_ftell(pb);
- put_be16(pb, 0); /* size */
+ avio_wb16(pb, 0); /* size */
/* name */
if (filename)
filename++;
else
filename = s->filename;
- put_byte(pb, MAT_NAME);
- put_byte(pb, strlen(SERVER_PATH) + strlen(filename) + 1);
- put_tag(pb, SERVER_PATH);
- put_tag(pb, filename);
- put_byte(pb, 0);
+ len = strlen(filename);
+
+ avio_w8(pb, MAT_NAME);
+ avio_w8(pb, strlen(SERVER_PATH) + len + 1);
+ avio_write(pb, SERVER_PATH, sizeof(SERVER_PATH) - 1);
+ avio_write(pb, filename, len);
+ avio_w8(pb, 0);
/* first field */
- put_byte(pb, MAT_FIRST_FIELD);
- put_byte(pb, 4);
- put_be32(pb, 0);
+ avio_w8(pb, MAT_FIRST_FIELD);
+ avio_w8(pb, 4);
+ avio_wb32(pb, 0);
/* last field */
- put_byte(pb, MAT_LAST_FIELD);
- put_byte(pb, 4);
- put_be32(pb, gxf->nb_fields);
+ avio_w8(pb, MAT_LAST_FIELD);
+ avio_w8(pb, 4);
+ avio_wb32(pb, gxf->nb_fields);
/* reserved */
- put_byte(pb, MAT_MARK_IN);
- put_byte(pb, 4);
- put_be32(pb, 0);
+ avio_w8(pb, MAT_MARK_IN);
+ avio_w8(pb, 4);
+ avio_wb32(pb, 0);
- put_byte(pb, MAT_MARK_OUT);
- put_byte(pb, 4);
- put_be32(pb, gxf->nb_fields);
+ avio_w8(pb, MAT_MARK_OUT);
+ avio_w8(pb, 4);
+ avio_wb32(pb, gxf->nb_fields);
/* estimated size */
- put_byte(pb, MAT_SIZE);
- put_byte(pb, 4);
- put_be32(pb, url_fsize(pb) / 1024);
+ avio_w8(pb, MAT_SIZE);
+ avio_w8(pb, 4);
+ avio_wb32(pb, url_fsize(pb) / 1024);
return updateSize(pb, pos);
}
@@ -315,12 +318,12 @@ static int gxf_write_material_data_section(AVFormatContext *s)
static int gxf_write_track_description_section(AVFormatContext *s)
{
GXFContext *gxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pos;
int i;
pos = url_ftell(pb);
- put_be16(pb, 0); /* size */
+ avio_wb16(pb, 0); /* size */
for (i = 0; i < s->nb_streams; ++i)
gxf_write_track_description(s, s->streams[i]->priv_data, i);
@@ -332,7 +335,7 @@ static int gxf_write_track_description_section(AVFormatContext *s)
static int gxf_write_map_packet(AVFormatContext *s, int rewrite)
{
GXFContext *gxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pos = url_ftell(pb);
if (!rewrite) {
@@ -350,8 +353,8 @@ static int gxf_write_map_packet(AVFormatContext *s, int rewrite)
gxf_write_packet_header(pb, PKT_MAP);
/* preamble */
- put_byte(pb, 0xE0); /* version */
- put_byte(pb, 0xFF); /* reserved */
+ avio_w8(pb, 0xE0); /* version */
+ avio_w8(pb, 0xFF); /* reserved */
gxf_write_material_data_section(s);
gxf_write_track_description_section(s);
@@ -362,7 +365,7 @@ static int gxf_write_map_packet(AVFormatContext *s, int rewrite)
static int gxf_write_flt_packet(AVFormatContext *s)
{
GXFContext *gxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pos = url_ftell(pb);
int fields_per_flt = (gxf->nb_fields+1) / 1000 + 1;
int flt_entries = gxf->nb_fields / fields_per_flt;
@@ -370,16 +373,16 @@ static int gxf_write_flt_packet(AVFormatContext *s)
gxf_write_packet_header(pb, PKT_FLT);
- put_le32(pb, fields_per_flt); /* number of fields */
- put_le32(pb, flt_entries); /* number of active flt entries */
+ avio_wl32(pb, fields_per_flt); /* number of fields */
+ avio_wl32(pb, flt_entries); /* number of active flt entries */
if (gxf->flt_entries) {
for (i = 0; i < flt_entries; i++)
- put_le32(pb, gxf->flt_entries[(i*fields_per_flt)>>1]);
+ avio_wl32(pb, gxf->flt_entries[(i*fields_per_flt)>>1]);
}
for (; i < 1000; i++)
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
return updatePacketSize(pb, pos);
}
@@ -387,7 +390,7 @@ static int gxf_write_flt_packet(AVFormatContext *s)
static int gxf_write_umf_material_description(AVFormatContext *s)
{
GXFContext *gxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int timecode_base = gxf->time_base.den == 60000 ? 60 : 50;
// XXX drop frame
@@ -397,47 +400,47 @@ static int gxf_write_umf_material_description(AVFormatContext *s)
gxf->nb_fields / timecode_base % 60 << 8 | // seconds
gxf->nb_fields % timecode_base; // fields
- put_le32(pb, gxf->flags);
- put_le32(pb, gxf->nb_fields); /* length of the longest track */
- put_le32(pb, gxf->nb_fields); /* length of the shortest track */
- put_le32(pb, 0); /* mark in */
- put_le32(pb, gxf->nb_fields); /* mark out */
- put_le32(pb, 0); /* timecode mark in */
- put_le32(pb, timecode); /* timecode mark out */
- put_le64(pb, s->timestamp); /* modification time */
- put_le64(pb, s->timestamp); /* creation time */
- put_le16(pb, 0); /* reserved */
- put_le16(pb, 0); /* reserved */
- put_le16(pb, gxf->audio_tracks);
- put_le16(pb, 1); /* timecode track count */
- put_le16(pb, 0); /* reserved */
- put_le16(pb, gxf->mpeg_tracks);
+ avio_wl32(pb, gxf->flags);
+ avio_wl32(pb, gxf->nb_fields); /* length of the longest track */
+ avio_wl32(pb, gxf->nb_fields); /* length of the shortest track */
+ avio_wl32(pb, 0); /* mark in */
+ avio_wl32(pb, gxf->nb_fields); /* mark out */
+ avio_wl32(pb, 0); /* timecode mark in */
+ avio_wl32(pb, timecode); /* timecode mark out */
+ avio_wl64(pb, s->timestamp); /* modification time */
+ avio_wl64(pb, s->timestamp); /* creation time */
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl16(pb, gxf->audio_tracks);
+ avio_wl16(pb, 1); /* timecode track count */
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl16(pb, gxf->mpeg_tracks);
return 48;
}
static int gxf_write_umf_payload(AVFormatContext *s)
{
GXFContext *gxf = s->priv_data;
- ByteIOContext *pb = s->pb;
-
- put_le32(pb, gxf->umf_length); /* total length of the umf data */
- put_le32(pb, 3); /* version */
- put_le32(pb, s->nb_streams+1);
- put_le32(pb, gxf->umf_track_offset); /* umf track section offset */
- put_le32(pb, gxf->umf_track_size);
- put_le32(pb, s->nb_streams+1);
- put_le32(pb, gxf->umf_media_offset);
- put_le32(pb, gxf->umf_media_size);
- put_le32(pb, gxf->umf_length); /* user data offset */
- put_le32(pb, 0); /* user data size */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
+ AVIOContext *pb = s->pb;
+
+ avio_wl32(pb, gxf->umf_length); /* total length of the umf data */
+ avio_wl32(pb, 3); /* version */
+ avio_wl32(pb, s->nb_streams+1);
+ avio_wl32(pb, gxf->umf_track_offset); /* umf track section offset */
+ avio_wl32(pb, gxf->umf_track_size);
+ avio_wl32(pb, s->nb_streams+1);
+ avio_wl32(pb, gxf->umf_media_offset);
+ avio_wl32(pb, gxf->umf_media_size);
+ avio_wl32(pb, gxf->umf_length); /* user data offset */
+ avio_wl32(pb, 0); /* user data size */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
return 48;
}
static int gxf_write_umf_track_description(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
GXFContext *gxf = s->priv_data;
int64_t pos = url_ftell(pb);
int i;
@@ -445,80 +448,80 @@ static int gxf_write_umf_track_description(AVFormatContext *s)
gxf->umf_track_offset = pos - gxf->umf_start_offset;
for (i = 0; i < s->nb_streams; ++i) {
GXFStreamContext *sc = s->streams[i]->priv_data;
- put_le16(pb, sc->media_info);
- put_le16(pb, 1);
+ avio_wl16(pb, sc->media_info);
+ avio_wl16(pb, 1);
}
- put_le16(pb, gxf->timecode_track.media_info);
- put_le16(pb, 1);
+ avio_wl16(pb, gxf->timecode_track.media_info);
+ avio_wl16(pb, 1);
return url_ftell(pb) - pos;
}
-static int gxf_write_umf_media_mpeg(ByteIOContext *pb, AVStream *st)
+static int gxf_write_umf_media_mpeg(AVIOContext *pb, AVStream *st)
{
GXFStreamContext *sc = st->priv_data;
if (st->codec->pix_fmt == PIX_FMT_YUV422P)
- put_le32(pb, 2);
+ avio_wl32(pb, 2);
else
- put_le32(pb, 1); /* default to 420 */
- put_le32(pb, sc->first_gop_closed == 1); /* closed = 1, open = 0, unknown = 255 */
- put_le32(pb, 3); /* top = 1, bottom = 2, frame = 3, unknown = 0 */
- put_le32(pb, 1); /* I picture per GOP */
- put_le32(pb, sc->p_per_gop);
- put_le32(pb, sc->b_per_i_or_p);
+ avio_wl32(pb, 1); /* default to 420 */
+ avio_wl32(pb, sc->first_gop_closed == 1); /* closed = 1, open = 0, unknown = 255 */
+ avio_wl32(pb, 3); /* top = 1, bottom = 2, frame = 3, unknown = 0 */
+ avio_wl32(pb, 1); /* I picture per GOP */
+ avio_wl32(pb, sc->p_per_gop);
+ avio_wl32(pb, sc->b_per_i_or_p);
if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO)
- put_le32(pb, 2);
+ avio_wl32(pb, 2);
else if (st->codec->codec_id == CODEC_ID_MPEG1VIDEO)
- put_le32(pb, 1);
+ avio_wl32(pb, 1);
else
- put_le32(pb, 0);
- put_le32(pb, 0); /* reserved */
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0); /* reserved */
return 32;
}
-static int gxf_write_umf_media_timecode(ByteIOContext *pb, GXFStreamContext *sc)
+static int gxf_write_umf_media_timecode(AVIOContext *pb, GXFStreamContext *sc)
{
- put_le32(pb, 1); /* non drop frame */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
+ avio_wl32(pb, 1); /* non drop frame */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
return 32;
}
-static int gxf_write_umf_media_dv(ByteIOContext *pb, GXFStreamContext *sc)
+static int gxf_write_umf_media_dv(AVIOContext *pb, GXFStreamContext *sc)
{
int i;
for (i = 0; i < 8; i++) {
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
}
return 32;
}
-static int gxf_write_umf_media_audio(ByteIOContext *pb, GXFStreamContext *sc)
+static int gxf_write_umf_media_audio(AVIOContext *pb, GXFStreamContext *sc)
{
- put_le64(pb, av_dbl2int(1)); /* sound level to begin to */
- put_le64(pb, av_dbl2int(1)); /* sound level to begin to */
- put_le32(pb, 0); /* number of fields over which to ramp up sound level */
- put_le32(pb, 0); /* number of fields over which to ramp down sound level */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
+ avio_wl64(pb, av_dbl2int(1)); /* sound level to begin to */
+ avio_wl64(pb, av_dbl2int(1)); /* sound level to begin to */
+ avio_wl32(pb, 0); /* number of fields over which to ramp up sound level */
+ avio_wl32(pb, 0); /* number of fields over which to ramp down sound level */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
return 32;
}
#if 0
-static int gxf_write_umf_media_mjpeg(ByteIOContext *pb, GXFStreamContext *sc)
+static int gxf_write_umf_media_mjpeg(AVIOContext *pb, GXFStreamContext *sc)
{
- put_be64(pb, 0); /* FIXME FLOAT max chroma quant level */
- put_be64(pb, 0); /* FIXME FLOAT max luma quant level */
- put_be64(pb, 0); /* FIXME FLOAT min chroma quant level */
- put_be64(pb, 0); /* FIXME FLOAT min luma quant level */
+ avio_wb64(pb, 0); /* FIXME FLOAT max chroma quant level */
+ avio_wb64(pb, 0); /* FIXME FLOAT max luma quant level */
+ avio_wb64(pb, 0); /* FIXME FLOAT min chroma quant level */
+ avio_wb64(pb, 0); /* FIXME FLOAT min luma quant level */
return 32;
}
#endif
@@ -526,7 +529,7 @@ static int gxf_write_umf_media_mjpeg(ByteIOContext *pb, GXFStreamContext *sc)
static int gxf_write_umf_media_description(AVFormatContext *s)
{
GXFContext *gxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pos;
int i, j;
@@ -542,22 +545,22 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
sc = s->streams[i]->priv_data;
startpos = url_ftell(pb);
- put_le16(pb, 0); /* length */
- put_le16(pb, sc->media_info);
- put_le16(pb, 0); /* reserved */
- put_le16(pb, 0); /* reserved */
- put_le32(pb, gxf->nb_fields);
- put_le32(pb, 0); /* attributes rw, ro */
- put_le32(pb, 0); /* mark in */
- put_le32(pb, gxf->nb_fields); /* mark out */
- put_buffer(pb, ES_NAME_PATTERN, strlen(ES_NAME_PATTERN));
- put_be16(pb, sc->media_info);
+ avio_wl16(pb, 0); /* length */
+ avio_wl16(pb, sc->media_info);
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl32(pb, gxf->nb_fields);
+ avio_wl32(pb, 0); /* attributes rw, ro */
+ avio_wl32(pb, 0); /* mark in */
+ avio_wl32(pb, gxf->nb_fields); /* mark out */
+ avio_write(pb, ES_NAME_PATTERN, strlen(ES_NAME_PATTERN));
+ avio_wb16(pb, sc->media_info);
for (j = strlen(ES_NAME_PATTERN)+2; j < 88; j++)
- put_byte(pb, 0);
- put_le32(pb, sc->track_type);
- put_le32(pb, sc->sample_rate);
- put_le32(pb, sc->sample_size);
- put_le32(pb, 0); /* reserved */
+ avio_w8(pb, 0);
+ avio_wl32(pb, sc->track_type);
+ avio_wl32(pb, sc->sample_rate);
+ avio_wl32(pb, sc->sample_size);
+ avio_wl32(pb, 0); /* reserved */
if (sc == &gxf->timecode_track)
gxf_write_umf_media_timecode(pb, sc); /* 8 0bytes */
@@ -578,9 +581,9 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
}
curpos = url_ftell(pb);
- url_fseek(pb, startpos, SEEK_SET);
- put_le16(pb, curpos - startpos);
- url_fseek(pb, curpos, SEEK_SET);
+ avio_seek(pb, startpos, SEEK_SET);
+ avio_wl16(pb, curpos - startpos);
+ avio_seek(pb, curpos, SEEK_SET);
}
return url_ftell(pb) - pos;
}
@@ -588,14 +591,14 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
static int gxf_write_umf_packet(AVFormatContext *s)
{
GXFContext *gxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pos = url_ftell(pb);
gxf_write_packet_header(pb, PKT_UMF);
/* preamble */
- put_byte(pb, 3); /* first and last (only) packet */
- put_be32(pb, gxf->umf_length); /* data length */
+ avio_w8(pb, 3); /* first and last (only) packet */
+ avio_wb32(pb, gxf->umf_length); /* data length */
gxf->umf_start_offset = url_ftell(pb);
gxf_write_umf_payload(s);
@@ -625,7 +628,7 @@ static void gxf_init_timecode_track(GXFStreamContext *sc, GXFStreamContext *vsc)
static int gxf_write_header(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
GXFContext *gxf = s->priv_data;
GXFStreamContext *vsc = NULL;
uint8_t tracks[255] = {0};
@@ -754,7 +757,7 @@ static int gxf_write_header(AVFormatContext *s)
return 0;
}
-static int gxf_write_eos_packet(ByteIOContext *pb)
+static int gxf_write_eos_packet(AVIOContext *pb)
{
int64_t pos = url_ftell(pb);
@@ -765,7 +768,7 @@ static int gxf_write_eos_packet(ByteIOContext *pb)
static int gxf_write_trailer(AVFormatContext *s)
{
GXFContext *gxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t end;
int i;
@@ -773,7 +776,7 @@ static int gxf_write_trailer(AVFormatContext *s)
gxf_write_eos_packet(pb);
end = url_ftell(pb);
- url_fseek(pb, 0, SEEK_SET);
+ avio_seek(pb, 0, SEEK_SET);
/* overwrite map, flt and umf packets with new values */
gxf_write_map_packet(s, 1);
gxf_write_flt_packet(s);
@@ -781,12 +784,12 @@ static int gxf_write_trailer(AVFormatContext *s)
put_flush_packet(pb);
/* update duration in all map packets */
for (i = 1; i < gxf->map_offsets_nb; i++) {
- url_fseek(pb, gxf->map_offsets[i], SEEK_SET);
+ avio_seek(pb, gxf->map_offsets[i], SEEK_SET);
gxf_write_map_packet(s, 1);
put_flush_packet(pb);
}
- url_fseek(pb, end, SEEK_SET);
+ avio_seek(pb, end, SEEK_SET);
av_freep(&gxf->flt_entries);
av_freep(&gxf->map_offsets);
@@ -809,7 +812,7 @@ static int gxf_parse_mpeg_frame(GXFStreamContext *sc, const uint8_t *buf, int si
static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
{
GXFContext *gxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st = s->streams[pkt->stream_index];
GXFStreamContext *sc = st->priv_data;
unsigned field_nb;
@@ -823,40 +826,40 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
(int64_t)48000*gxf->time_base.num, AV_ROUND_UP);
}
- put_byte(pb, sc->media_type);
- put_byte(pb, st->index);
- put_be32(pb, field_nb);
+ avio_w8(pb, sc->media_type);
+ avio_w8(pb, st->index);
+ avio_wb32(pb, field_nb);
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- put_be16(pb, 0);
- put_be16(pb, size / 2);
+ avio_wb16(pb, 0);
+ avio_wb16(pb, size / 2);
} else if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO) {
int frame_type = gxf_parse_mpeg_frame(sc, pkt->data, pkt->size);
if (frame_type == FF_I_TYPE) {
- put_byte(pb, 0x0d);
+ avio_w8(pb, 0x0d);
sc->iframes++;
} else if (frame_type == FF_B_TYPE) {
- put_byte(pb, 0x0f);
+ avio_w8(pb, 0x0f);
sc->bframes++;
} else {
- put_byte(pb, 0x0e);
+ avio_w8(pb, 0x0e);
sc->pframes++;
}
- put_be24(pb, size);
+ avio_wb24(pb, size);
} else if (st->codec->codec_id == CODEC_ID_DVVIDEO) {
- put_byte(pb, size / 4096);
- put_be24(pb, 0);
+ avio_w8(pb, size / 4096);
+ avio_wb24(pb, 0);
} else
- put_be32(pb, size);
- put_be32(pb, field_nb);
- put_byte(pb, 1); /* flags */
- put_byte(pb, 0); /* reserved */
+ avio_wb32(pb, size);
+ avio_wb32(pb, field_nb);
+ avio_w8(pb, 1); /* flags */
+ avio_w8(pb, 0); /* reserved */
return 16;
}
static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
{
GXFContext *gxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st = s->streams[pkt->stream_index];
int64_t pos = url_ftell(pb);
int padding = 0;
@@ -868,7 +871,7 @@ static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
padding = GXF_AUDIO_PACKET_SIZE - pkt->size;
gxf_write_media_preamble(s, pkt, pkt->size + padding);
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
gxf_write_padding(pb, padding);
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
diff --git a/mplayer/ffmpeg/libavformat/id3v1.c b/mplayer/ffmpeg/libavformat/id3v1.c
index 481db973..e17e785a 100644
--- a/mplayer/ffmpeg/libavformat/id3v1.c
+++ b/mplayer/ffmpeg/libavformat/id3v1.c
@@ -232,12 +232,12 @@ void ff_id3v1_read(AVFormatContext *s)
/* XXX: change that */
filesize = url_fsize(s->pb);
if (filesize > 128) {
- url_fseek(s->pb, filesize - 128, SEEK_SET);
- ret = get_buffer(s->pb, buf, ID3v1_TAG_SIZE);
+ avio_seek(s->pb, filesize - 128, SEEK_SET);
+ ret = avio_read(s->pb, buf, ID3v1_TAG_SIZE);
if (ret == ID3v1_TAG_SIZE) {
parse_tag(s, buf);
}
- url_fseek(s->pb, 0, SEEK_SET);
+ avio_seek(s->pb, 0, SEEK_SET);
}
}
}
diff --git a/mplayer/ffmpeg/libavformat/id3v2.c b/mplayer/ffmpeg/libavformat/id3v2.c
index 7cedf6e6..47bc706d 100644
--- a/mplayer/ffmpeg/libavformat/id3v2.c
+++ b/mplayer/ffmpeg/libavformat/id3v2.c
@@ -24,6 +24,7 @@
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "metadata.h"
+#include "avio_internal.h"
int ff_id3v2_match(const uint8_t *buf, const char * magic)
{
@@ -50,21 +51,21 @@ int ff_id3v2_tag_len(const uint8_t * buf)
return len;
}
-static unsigned int get_size(ByteIOContext *s, int len)
+static unsigned int get_size(AVIOContext *s, int len)
{
int v = 0;
while (len--)
- v = (v << 7) + (get_byte(s) & 0x7F);
+ v = (v << 7) + (avio_r8(s) & 0x7F);
return v;
}
-static void read_ttag(AVFormatContext *s, ByteIOContext *pb, int taglen, const char *key)
+static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const char *key)
{
char *q, dst[512];
const char *val = NULL;
int len, dstlen = sizeof(dst) - 1;
unsigned genre;
- unsigned int (*get)(ByteIOContext*) = get_be16;
+ unsigned int (*get)(AVIOContext*) = avio_rb16;
dst[0] = 0;
if (taglen < 1)
@@ -72,22 +73,22 @@ static void read_ttag(AVFormatContext *s, ByteIOContext *pb, int taglen, const c
taglen--; /* account for encoding type byte */
- switch (get_byte(pb)) { /* encoding type */
+ switch (avio_r8(pb)) { /* encoding type */
case ID3v2_ENCODING_ISO8859:
q = dst;
while (taglen-- && q - dst < dstlen - 7) {
uint8_t tmp;
- PUT_UTF8(get_byte(pb), tmp, *q++ = tmp;)
+ PUT_UTF8(avio_r8(pb), tmp, *q++ = tmp;)
}
*q = 0;
break;
case ID3v2_ENCODING_UTF16BOM:
taglen -= 2;
- switch (get_be16(pb)) {
+ switch (avio_rb16(pb)) {
case 0xfffe:
- get = get_le16;
+ get = avio_rl16;
case 0xfeff:
break;
default:
@@ -110,7 +111,7 @@ static void read_ttag(AVFormatContext *s, ByteIOContext *pb, int taglen, const c
case ID3v2_ENCODING_UTF8:
len = FFMIN(taglen, dstlen);
- get_buffer(pb, dst, len);
+ avio_read(pb, dst, len);
dst[len] = 0;
break;
default:
@@ -142,7 +143,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
int64_t next;
int taghdrlen;
const char *reason;
- ByteIOContext pb;
+ AVIOContext pb;
unsigned char *buffer = NULL;
int buffer_size = 0;
@@ -170,25 +171,25 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
unsync = flags & 0x80;
if (isv34 && flags & 0x40) /* Extended header present, just skip over it */
- url_fskip(s->pb, get_size(s->pb, 4));
+ avio_seek(s->pb, get_size(s->pb, 4), SEEK_CUR);
while (len >= taghdrlen) {
unsigned int tflags;
int tunsync = 0;
if (isv34) {
- get_buffer(s->pb, tag, 4);
+ avio_read(s->pb, tag, 4);
tag[4] = 0;
if(version==3){
- tlen = get_be32(s->pb);
+ tlen = avio_rb32(s->pb);
}else
tlen = get_size(s->pb, 4);
- tflags = get_be16(s->pb);
+ tflags = avio_rb16(s->pb);
tunsync = tflags & ID3v2_FLAG_UNSYNCH;
} else {
- get_buffer(s->pb, tag, 3);
+ avio_read(s->pb, tag, 3);
tag[3] = 0;
- tlen = get_be24(s->pb);
+ tlen = avio_rb24(s->pb);
}
len -= taghdrlen + tlen;
@@ -198,25 +199,25 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
next = url_ftell(s->pb) + tlen;
if (tflags & ID3v2_FLAG_DATALEN) {
- get_be32(s->pb);
+ avio_rb32(s->pb);
tlen -= 4;
}
if (tflags & (ID3v2_FLAG_ENCRYPTION | ID3v2_FLAG_COMPRESSION)) {
av_log(s, AV_LOG_WARNING, "Skipping encrypted/compressed ID3v2 frame %s.\n", tag);
- url_fskip(s->pb, tlen);
+ avio_seek(s->pb, tlen, SEEK_CUR);
} else if (tag[0] == 'T') {
if (unsync || tunsync) {
int i, j;
av_fast_malloc(&buffer, &buffer_size, tlen);
for (i = 0, j = 0; i < tlen; i++, j++) {
- buffer[j] = get_byte(s->pb);
+ buffer[j] = avio_r8(s->pb);
if (j > 0 && !buffer[j] && buffer[j - 1] == 0xff) {
/* Unsynchronised byte, skip it */
j--;
}
}
- init_put_byte(&pb, buffer, j, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, buffer, j, 0, NULL, NULL, NULL, NULL);
read_ttag(s, &pb, j, tag);
} else {
read_ttag(s, s->pb, tlen, tag);
@@ -225,26 +226,26 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
else if (!tag[0]) {
if (tag[1])
av_log(s, AV_LOG_WARNING, "invalid frame id, assuming padding");
- url_fskip(s->pb, tlen);
+ avio_seek(s->pb, tlen, SEEK_CUR);
break;
}
/* Skip to end of tag */
- url_fseek(s->pb, next, SEEK_SET);
+ avio_seek(s->pb, next, SEEK_SET);
}
if (len > 0) {
/* Skip padding */
- url_fskip(s->pb, len);
+ avio_seek(s->pb, len, SEEK_CUR);
}
if (version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */
- url_fskip(s->pb, 10);
+ avio_seek(s->pb, 10, SEEK_CUR);
av_free(buffer);
return;
error:
av_log(s, AV_LOG_INFO, "ID3v2.%d tag skipped, cannot handle %s\n", version, reason);
- url_fskip(s->pb, len);
+ avio_seek(s->pb, len, SEEK_CUR);
av_free(buffer);
}
@@ -258,7 +259,7 @@ void ff_id3v2_read(AVFormatContext *s, const char *magic)
do {
/* save the current offset in case there's nothing to read/skip */
off = url_ftell(s->pb);
- ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
+ ret = avio_read(s->pb, buf, ID3v2_HEADER_SIZE);
if (ret != ID3v2_HEADER_SIZE)
break;
found_header = ff_id3v2_match(buf, magic);
@@ -270,7 +271,7 @@ void ff_id3v2_read(AVFormatContext *s, const char *magic)
(buf[9] & 0x7f);
ff_id3v2_parse(s, len, buf[3], buf[5]);
} else {
- url_fseek(s->pb, off, SEEK_SET);
+ avio_seek(s->pb, off, SEEK_SET);
}
} while (found_header);
ff_metadata_conv(&s->metadata, NULL, ff_id3v2_34_metadata_conv);
diff --git a/mplayer/ffmpeg/libavformat/idcin.c b/mplayer/ffmpeg/libavformat/idcin.c
index e40d725f..1aecf866 100644
--- a/mplayer/ffmpeg/libavformat/idcin.c
+++ b/mplayer/ffmpeg/libavformat/idcin.c
@@ -142,18 +142,18 @@ static int idcin_probe(AVProbeData *p)
static int idcin_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
IdcinDemuxContext *idcin = s->priv_data;
AVStream *st;
unsigned int width, height;
unsigned int sample_rate, bytes_per_sample, channels;
/* get the 5 header parameters */
- width = get_le32(pb);
- height = get_le32(pb);
- sample_rate = get_le32(pb);
- bytes_per_sample = get_le32(pb);
- channels = get_le32(pb);
+ width = avio_rl32(pb);
+ height = avio_rl32(pb);
+ sample_rate = avio_rl32(pb);
+ bytes_per_sample = avio_rl32(pb);
+ channels = avio_rl32(pb);
st = av_new_stream(s, 0);
if (!st)
@@ -169,7 +169,7 @@ static int idcin_read_header(AVFormatContext *s,
/* load up the Huffman tables into extradata */
st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
- if (get_buffer(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) !=
+ if (avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) !=
HUFFMAN_TABLE_SIZE)
return AVERROR(EIO);
/* save a reference in order to transport the palette */
@@ -221,7 +221,7 @@ static int idcin_read_packet(AVFormatContext *s,
unsigned int command;
unsigned int chunk_size;
IdcinDemuxContext *idcin = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int i;
int palette_scale;
unsigned char r, g, b;
@@ -231,13 +231,13 @@ static int idcin_read_packet(AVFormatContext *s,
return AVERROR(EIO);
if (idcin->next_chunk_is_video) {
- command = get_le32(pb);
+ command = avio_rl32(pb);
if (command == 2) {
return AVERROR(EIO);
} else if (command == 1) {
/* trigger a palette change */
idcin->palctrl.palette_changed = 1;
- if (get_buffer(pb, palette_buffer, 768) != 768)
+ if (avio_read(pb, palette_buffer, 768) != 768)
return AVERROR(EIO);
/* scale the palette as necessary */
palette_scale = 2;
@@ -255,9 +255,9 @@ static int idcin_read_packet(AVFormatContext *s,
}
}
- chunk_size = get_le32(pb);
+ chunk_size = avio_rl32(pb);
/* skip the number of decoded bytes (always equal to width * height) */
- url_fseek(pb, 4, SEEK_CUR);
+ avio_seek(pb, 4, SEEK_CUR);
chunk_size -= 4;
ret= av_get_packet(pb, pkt, chunk_size);
if (ret < 0)
diff --git a/mplayer/ffmpeg/libavformat/idroqdec.c b/mplayer/ffmpeg/libavformat/idroqdec.c
index 285a3e1e..71324d88 100644
--- a/mplayer/ffmpeg/libavformat/idroqdec.c
+++ b/mplayer/ffmpeg/libavformat/idroqdec.c
@@ -68,13 +68,13 @@ static int roq_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
RoqDemuxContext *roq = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int framerate;
AVStream *st;
unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];
/* get the main header */
- if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
framerate = AV_RL16(&preamble[6]);
@@ -100,7 +100,7 @@ static int roq_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
RoqDemuxContext *roq = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret = 0;
unsigned int chunk_size;
unsigned int chunk_type;
@@ -115,7 +115,7 @@ static int roq_read_packet(AVFormatContext *s,
return AVERROR(EIO);
/* get the next chunk preamble */
- if ((ret = get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) !=
+ if ((ret = avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
@@ -129,29 +129,29 @@ static int roq_read_packet(AVFormatContext *s,
case RoQ_INFO:
if (!roq->width || !roq->height) {
AVStream *st = s->streams[roq->video_stream_index];
- if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
+ if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
st->codec->width = roq->width = AV_RL16(preamble);
st->codec->height = roq->height = AV_RL16(preamble + 2);
break;
}
/* don't care about this chunk anymore */
- url_fseek(pb, RoQ_CHUNK_PREAMBLE_SIZE, SEEK_CUR);
+ avio_seek(pb, RoQ_CHUNK_PREAMBLE_SIZE, SEEK_CUR);
break;
case RoQ_QUAD_CODEBOOK:
/* packet needs to contain both this codebook and next VQ chunk */
codebook_offset = url_ftell(pb) - RoQ_CHUNK_PREAMBLE_SIZE;
codebook_size = chunk_size;
- url_fseek(pb, codebook_size, SEEK_CUR);
- if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
+ avio_seek(pb, codebook_size, SEEK_CUR);
+ if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
codebook_size;
/* rewind */
- url_fseek(pb, codebook_offset, SEEK_SET);
+ avio_seek(pb, codebook_offset, SEEK_SET);
/* load up the packet */
ret= av_get_packet(pb, pkt, chunk_size);
@@ -198,7 +198,7 @@ static int roq_read_packet(AVFormatContext *s,
}
pkt->pos= url_ftell(pb);
- ret = get_buffer(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
+ ret = avio_read(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
chunk_size);
if (ret != chunk_size)
ret = AVERROR(EIO);
diff --git a/mplayer/ffmpeg/libavformat/idroqenc.c b/mplayer/ffmpeg/libavformat/idroqenc.c
index 8859c98a..9935b61e 100644
--- a/mplayer/ffmpeg/libavformat/idroqenc.c
+++ b/mplayer/ffmpeg/libavformat/idroqenc.c
@@ -29,7 +29,7 @@ static int roq_write_header(struct AVFormatContext *s)
0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
};
- put_buffer(s->pb, header, 8);
+ avio_write(s->pb, header, 8);
put_flush_packet(s->pb);
return 0;
diff --git a/mplayer/ffmpeg/libavformat/iff.c b/mplayer/ffmpeg/libavformat/iff.c
index 90a3ea9c..66224456 100644
--- a/mplayer/ffmpeg/libavformat/iff.c
+++ b/mplayer/ffmpeg/libavformat/iff.c
@@ -101,7 +101,7 @@ static int get_metadata(AVFormatContext *s,
if (!buf)
return AVERROR(ENOMEM);
- if (get_buffer(s->pb, buf, data_size) < 0) {
+ if (avio_read(s->pb, buf, data_size) < 0) {
av_free(buf);
return AVERROR(EIO);
}
@@ -124,7 +124,7 @@ static int iff_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
IffDemuxContext *iff = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
uint32_t chunk_id, data_size;
int compression = -1;
@@ -134,16 +134,16 @@ static int iff_read_header(AVFormatContext *s,
return AVERROR(ENOMEM);
st->codec->channels = 1;
- url_fskip(pb, 8);
+ avio_seek(pb, 8, SEEK_CUR);
// codec_tag used by ByteRun1 decoder to distinguish progressive (PBM) and interlaced (ILBM) content
- st->codec->codec_tag = get_le32(pb);
+ st->codec->codec_tag = avio_rl32(pb);
while(!url_feof(pb)) {
uint64_t orig_pos;
int res;
const char *metadata_tag = NULL;
- chunk_id = get_le32(pb);
- data_size = get_be32(pb);
+ chunk_id = avio_rl32(pb);
+ data_size = avio_rb32(pb);
orig_pos = url_ftell(pb);
switch(chunk_id) {
@@ -152,11 +152,11 @@ static int iff_read_header(AVFormatContext *s,
if (data_size < 14)
return AVERROR_INVALIDDATA;
- url_fskip(pb, 12);
- st->codec->sample_rate = get_be16(pb);
+ avio_seek(pb, 12, SEEK_CUR);
+ st->codec->sample_rate = avio_rb16(pb);
if (data_size >= 16) {
- url_fskip(pb, 1);
- compression = get_byte(pb);
+ avio_seek(pb, 1, SEEK_CUR);
+ compression = avio_r8(pb);
}
break;
@@ -168,7 +168,7 @@ static int iff_read_header(AVFormatContext *s,
case ID_CHAN:
if (data_size < 4)
return AVERROR_INVALIDDATA;
- st->codec->channels = (get_be32(pb) < 6) ? 1 : 2;
+ st->codec->channels = (avio_rb32(pb) < 6) ? 1 : 2;
break;
case ID_CMAP:
@@ -176,7 +176,7 @@ static int iff_read_header(AVFormatContext *s,
st->codec->extradata = av_malloc(data_size);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- if (get_buffer(pb, st->codec->extradata, data_size) < 0)
+ if (avio_read(pb, st->codec->extradata, data_size) < 0)
return AVERROR(EIO);
break;
@@ -184,18 +184,18 @@ static int iff_read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
if (data_size <= 8)
return AVERROR_INVALIDDATA;
- st->codec->width = get_be16(pb);
- st->codec->height = get_be16(pb);
- url_fskip(pb, 4); // x, y offset
- st->codec->bits_per_coded_sample = get_byte(pb);
+ st->codec->width = avio_rb16(pb);
+ st->codec->height = avio_rb16(pb);
+ avio_seek(pb, 4, SEEK_CUR); // x, y offset
+ st->codec->bits_per_coded_sample = avio_r8(pb);
if (data_size >= 11) {
- url_fskip(pb, 1); // masking
- compression = get_byte(pb);
+ avio_seek(pb, 1, SEEK_CUR); // masking
+ compression = avio_r8(pb);
}
if (data_size >= 16) {
- url_fskip(pb, 3); // paddding, transparent
- st->sample_aspect_ratio.num = get_byte(pb);
- st->sample_aspect_ratio.den = get_byte(pb);
+ avio_seek(pb, 3, SEEK_CUR); // paddding, transparent
+ st->sample_aspect_ratio.num = avio_r8(pb);
+ st->sample_aspect_ratio.den = avio_r8(pb);
}
break;
@@ -223,10 +223,10 @@ static int iff_read_header(AVFormatContext *s,
return res;
}
}
- url_fskip(pb, data_size - (url_ftell(pb) - orig_pos) + (data_size & 1));
+ avio_seek(pb, data_size - (url_ftell(pb) - orig_pos) + (data_size & 1), SEEK_CUR);
}
- url_fseek(pb, iff->body_pos, SEEK_SET);
+ avio_seek(pb, iff->body_pos, SEEK_SET);
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
@@ -276,7 +276,7 @@ static int iff_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
IffDemuxContext *iff = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
int ret;
@@ -286,7 +286,7 @@ static int iff_read_packet(AVFormatContext *s,
if(st->codec->channels == 2) {
uint8_t sample_buffer[PACKET_SIZE];
- ret = get_buffer(pb, sample_buffer, PACKET_SIZE);
+ ret = avio_read(pb, sample_buffer, PACKET_SIZE);
if(av_new_packet(pkt, PACKET_SIZE) < 0) {
av_log(s, AV_LOG_ERROR, "cannot allocate packet\n");
return AVERROR(ENOMEM);
diff --git a/mplayer/ffmpeg/libavformat/img2.c b/mplayer/ffmpeg/libavformat/img2.c
index 13fdc74d..c37af1f7 100644
--- a/mplayer/ffmpeg/libavformat/img2.c
+++ b/mplayer/ffmpeg/libavformat/img2.c
@@ -23,6 +23,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/avstring.h"
#include "avformat.h"
+#include "avio_internal.h"
#ifndef GEKKO
#include
#endif
@@ -257,7 +258,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
char filename[1024];
int i;
int size[3]={0}, ret[3]={0};
- ByteIOContext *f[3];
+ AVIOContext *f[3];
AVCodecContext *codec= s1->streams[0]->codec;
if (!s->is_pipe) {
@@ -271,7 +272,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
s->path, s->img_number)<0 && s->img_number > 1)
return AVERROR(EIO);
for(i=0; i<3; i++){
- if (url_fopen(&f[i], filename, URL_RDONLY) < 0) {
+ if (avio_open(&f[i], filename, URL_RDONLY) < 0) {
if(i==1)
break;
av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename);
@@ -300,9 +301,9 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
pkt->size= 0;
for(i=0; i<3; i++){
if(size[i]){
- ret[i]= get_buffer(f[i], pkt->data + pkt->size, size[i]);
+ ret[i]= avio_read(f[i], pkt->data + pkt->size, size[i]);
if (!s->is_pipe)
- url_fclose(f[i]);
+ avio_close(f[i]);
if(ret[i]>0)
pkt->size += ret[i];
}
@@ -341,7 +342,7 @@ static int write_header(AVFormatContext *s)
static int write_packet(AVFormatContext *s, AVPacket *pkt)
{
VideoData *img = s->priv_data;
- ByteIOContext *pb[3];
+ AVIOContext *pb[3];
char filename[1024];
AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec;
int i;
@@ -355,7 +356,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EIO);
}
for(i=0; i<3; i++){
- if (url_fopen(&pb[i], filename, URL_WRONLY) < 0) {
+ if (avio_open(&pb[i], filename, URL_WRONLY) < 0) {
av_log(s, AV_LOG_ERROR, "Could not open file : %s\n",filename);
return AVERROR(EIO);
}
@@ -370,13 +371,13 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
if(codec->codec_id == CODEC_ID_RAWVIDEO){
int ysize = codec->width * codec->height;
- put_buffer(pb[0], pkt->data , ysize);
- put_buffer(pb[1], pkt->data + ysize, (pkt->size - ysize)/2);
- put_buffer(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2);
+ avio_write(pb[0], pkt->data , ysize);
+ avio_write(pb[1], pkt->data + ysize, (pkt->size - ysize)/2);
+ avio_write(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2);
put_flush_packet(pb[1]);
put_flush_packet(pb[2]);
- url_fclose(pb[1]);
- url_fclose(pb[2]);
+ avio_close(pb[1]);
+ avio_close(pb[2]);
}else{
if(av_str2id(img_tags, s->filename) == CODEC_ID_JPEG2000){
AVStream *st = s->streams[0];
@@ -384,15 +385,15 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
AV_RL32(st->codec->extradata+4) == MKTAG('j','p','2','h')){
if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c'))
goto error;
- put_be32(pb[0], 12);
- put_tag (pb[0], "jP ");
- put_be32(pb[0], 0x0D0A870A); // signature
- put_be32(pb[0], 20);
- put_tag (pb[0], "ftyp");
- put_tag (pb[0], "jp2 ");
- put_be32(pb[0], 0);
- put_tag (pb[0], "jp2 ");
- put_buffer(pb[0], st->codec->extradata, st->codec->extradata_size);
+ avio_wb32(pb[0], 12);
+ ffio_wfourcc(pb[0], "jP ");
+ avio_wb32(pb[0], 0x0D0A870A); // signature
+ avio_wb32(pb[0], 20);
+ ffio_wfourcc(pb[0], "ftyp");
+ ffio_wfourcc(pb[0], "jp2 ");
+ avio_wb32(pb[0], 0);
+ ffio_wfourcc(pb[0], "jp2 ");
+ avio_write(pb[0], st->codec->extradata, st->codec->extradata_size);
}else if(pkt->size < 8 ||
(!st->codec->extradata_size &&
AV_RL32(pkt->data+4) != MKTAG('j','P',' ',' '))){ // signature
@@ -401,11 +402,11 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
return -1;
}
}
- put_buffer(pb[0], pkt->data, pkt->size);
+ avio_write(pb[0], pkt->data, pkt->size);
}
put_flush_packet(pb[0]);
if (!img->is_pipe) {
- url_fclose(pb[0]);
+ avio_close(pb[0]);
}
img->img_number++;
diff --git a/mplayer/ffmpeg/libavformat/ingenientdec.c b/mplayer/ffmpeg/libavformat/ingenientdec.c
index 79587b51..9f7065ce 100644
--- a/mplayer/ffmpeg/libavformat/ingenientdec.c
+++ b/mplayer/ffmpeg/libavformat/ingenientdec.c
@@ -27,19 +27,19 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size, w, h, unk1, unk2;
- if (get_le32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
+ if (avio_rl32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
return AVERROR(EIO); // FIXME
- size = get_le32(s->pb);
+ size = avio_rl32(s->pb);
- w = get_le16(s->pb);
- h = get_le16(s->pb);
+ w = avio_rl16(s->pb);
+ h = avio_rl16(s->pb);
- url_fskip(s->pb, 8); // zero + size (padded?)
- url_fskip(s->pb, 2);
- unk1 = get_le16(s->pb);
- unk2 = get_le16(s->pb);
- url_fskip(s->pb, 22); // ASCII timestamp
+ avio_seek(s->pb, 8, SEEK_CUR); // zero + size (padded?)
+ avio_seek(s->pb, 2, SEEK_CUR);
+ unk1 = avio_rl16(s->pb);
+ unk2 = avio_rl16(s->pb);
+ avio_seek(s->pb, 22, SEEK_CUR); // ASCII timestamp
av_log(s, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n",
size, w, h, unk1, unk2);
@@ -49,7 +49,7 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos = url_ftell(s->pb);
pkt->stream_index = 0;
- ret = get_buffer(s->pb, pkt->data, size);
+ ret = avio_read(s->pb, pkt->data, size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
diff --git a/mplayer/ffmpeg/libavformat/internal.h b/mplayer/ffmpeg/libavformat/internal.h
index b401d352..02a27e47 100644
--- a/mplayer/ffmpeg/libavformat/internal.h
+++ b/mplayer/ffmpeg/libavformat/internal.h
@@ -48,10 +48,7 @@ do {\
} while(0)
#endif
-time_t mktimegm(struct tm *tm);
struct tm *brktimegm(time_t secs, struct tm *tm);
-const char *small_strptime(const char *p, const char *fmt,
- struct tm *dt);
char *ff_data_to_hex(char *buf, const uint8_t *src, int size, int lowercase);
@@ -82,25 +79,6 @@ void ff_read_frame_flush(AVFormatContext *s);
/** Get the current time since NTP epoch in microseconds. */
uint64_t ff_ntp_time(void);
-/**
- * Probe a bytestream to determine the input format. Each time a probe returns
- * with a score that is too low, the probe buffer size is increased and another
- * attempt is made. When the maximum probe size is reached, the input format
- * with the highest score is returned.
- *
- * @param pb the bytestream to probe, it may be closed and opened again
- * @param fmt the input format is put here
- * @param filename the filename of the stream
- * @param logctx the log context
- * @param offset the offset within the bytestream to probe from
- * @param max_probe_size the maximum probe buffer size (zero for default)
- * @return 0 in case of success, a negative value corresponding to an
- * AVERROR code otherwise
- */
-int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,
- const char *filename, void *logctx,
- unsigned int offset, unsigned int max_probe_size);
-
#if FF_API_URL_SPLIT
/**
* @deprecated use av_url_split() instead
@@ -179,20 +157,20 @@ int ff_get_v_length(uint64_t val);
/**
* Put val using a variable number of bytes.
*/
-void ff_put_v(ByteIOContext *bc, uint64_t val);
+void ff_put_v(AVIOContext *bc, uint64_t val);
/**
- * Read a whole line of text from ByteIOContext. Stop reading after reaching
+ * Read a whole line of text from AVIOContext. Stop reading after reaching
* either a \n, a \0 or EOF. The returned string is always \0 terminated,
* and may be truncated if the buffer is too small.
*
- * @param s the read-only ByteIOContext
+ * @param s the read-only AVIOContext
* @param buf buffer to store the read line
* @param maxlen size of the buffer
* @return the length of the string written in the buffer, not including the
* final \0
*/
-int ff_get_line(ByteIOContext *s, char *buf, int maxlen);
+int ff_get_line(AVIOContext *s, char *buf, int maxlen);
#define SPACE_CHARS " \t\r\n"
@@ -226,4 +204,39 @@ void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
*/
int ff_find_stream_index(AVFormatContext *s, int id);
+/**
+ * Internal version of av_index_search_timestamp
+ */
+int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries,
+ int64_t wanted_timestamp, int flags);
+
+/**
+ * Internal version of av_add_index_entry
+ */
+int ff_add_index_entry(AVIndexEntry **index_entries,
+ int *nb_index_entries,
+ unsigned int *index_entries_allocated_size,
+ int64_t pos, int64_t timestamp, int size, int distance, int flags);
+
+/**
+ * Add a new chapter.
+ *
+ * @param s media file handle
+ * @param id unique ID for this chapter
+ * @param start chapter start time in time_base units
+ * @param end chapter end time in time_base units
+ * @param title chapter title
+ *
+ * @return AVChapter or NULL on error
+ */
+AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base,
+ int64_t start, int64_t end, const char *title);
+
+/**
+ * Ensure the index uses less memory than the maximum specified in
+ * AVFormatContext.max_index_size by discarding entries if it grows
+ * too large.
+ */
+void ff_reduce_index(AVFormatContext *s, int stream_index);
+
#endif /* AVFORMAT_INTERNAL_H */
diff --git a/mplayer/ffmpeg/libavformat/ipmovie.c b/mplayer/ffmpeg/libavformat/ipmovie.c
index 6d84402c..e02e00b1 100644
--- a/mplayer/ffmpeg/libavformat/ipmovie.c
+++ b/mplayer/ffmpeg/libavformat/ipmovie.c
@@ -120,7 +120,7 @@ typedef struct IPMVEContext {
} IPMVEContext;
-static int load_ipmovie_packet(IPMVEContext *s, ByteIOContext *pb,
+static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
AVPacket *pkt) {
int chunk_type;
@@ -133,7 +133,7 @@ static int load_ipmovie_packet(IPMVEContext *s, ByteIOContext *pb,
s->audio_chunk_size -= 6;
}
- url_fseek(pb, s->audio_chunk_offset, SEEK_SET);
+ avio_seek(pb, s->audio_chunk_offset, SEEK_SET);
s->audio_chunk_offset = 0;
if (s->audio_chunk_size != av_get_packet(pb, pkt, s->audio_chunk_size))
@@ -163,19 +163,19 @@ static int load_ipmovie_packet(IPMVEContext *s, ByteIOContext *pb,
return CHUNK_NOMEM;
pkt->pos= s->decode_map_chunk_offset;
- url_fseek(pb, s->decode_map_chunk_offset, SEEK_SET);
+ avio_seek(pb, s->decode_map_chunk_offset, SEEK_SET);
s->decode_map_chunk_offset = 0;
- if (get_buffer(pb, pkt->data, s->decode_map_chunk_size) !=
+ if (avio_read(pb, pkt->data, s->decode_map_chunk_size) !=
s->decode_map_chunk_size) {
av_free_packet(pkt);
return CHUNK_EOF;
}
- url_fseek(pb, s->video_chunk_offset, SEEK_SET);
+ avio_seek(pb, s->video_chunk_offset, SEEK_SET);
s->video_chunk_offset = 0;
- if (get_buffer(pb, pkt->data + s->decode_map_chunk_size,
+ if (avio_read(pb, pkt->data + s->decode_map_chunk_size,
s->video_chunk_size) != s->video_chunk_size) {
av_free_packet(pkt);
return CHUNK_EOF;
@@ -193,7 +193,7 @@ static int load_ipmovie_packet(IPMVEContext *s, ByteIOContext *pb,
} else {
- url_fseek(pb, s->next_chunk_offset, SEEK_SET);
+ avio_seek(pb, s->next_chunk_offset, SEEK_SET);
chunk_type = CHUNK_DONE;
}
@@ -203,7 +203,7 @@ static int load_ipmovie_packet(IPMVEContext *s, ByteIOContext *pb,
/* This function loads and processes a single chunk in an IP movie file.
* It returns the type of chunk that was processed. */
-static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
+static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
AVPacket *pkt)
{
unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
@@ -227,7 +227,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
/* read the next chunk, wherever the file happens to be pointing */
if (url_feof(pb))
return CHUNK_EOF;
- if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE)
return CHUNK_BAD;
chunk_size = AV_RL16(&chunk_preamble[0]);
@@ -275,7 +275,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
chunk_type = CHUNK_EOF;
break;
}
- if (get_buffer(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE) {
chunk_type = CHUNK_BAD;
break;
@@ -299,12 +299,12 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
case OPCODE_END_OF_STREAM:
debug_ipmovie("end of stream\n");
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_END_OF_CHUNK:
debug_ipmovie("end of chunk\n");
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_CREATE_TIMER:
@@ -314,7 +314,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) !=
+ if (avio_read(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
@@ -331,7 +331,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) !=
+ if (avio_read(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
@@ -359,7 +359,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
case OPCODE_START_STOP_AUDIO:
debug_ipmovie("start/stop audio\n");
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_INIT_VIDEO_BUFFERS:
@@ -369,7 +369,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) !=
+ if (avio_read(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
@@ -393,12 +393,12 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
case OPCODE_UNKNOWN_14:
case OPCODE_UNKNOWN_15:
debug_ipmovie("unknown (but documented) opcode %02X\n", opcode_type);
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_SEND_BUFFER:
debug_ipmovie("send buffer\n");
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_AUDIO_FRAME:
@@ -407,22 +407,22 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
/* log position and move on for now */
s->audio_chunk_offset = url_ftell(pb);
s->audio_chunk_size = opcode_size;
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_SILENCE_FRAME:
debug_ipmovie("silence frame\n");
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_INIT_VIDEO_MODE:
debug_ipmovie("initialize video mode\n");
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_CREATE_GRADIENT:
debug_ipmovie("create gradient\n");
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_SET_PALETTE:
@@ -434,7 +434,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) != opcode_size) {
+ if (avio_read(pb, scratch, opcode_size) != opcode_size) {
chunk_type = CHUNK_BAD;
break;
}
@@ -464,7 +464,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
case OPCODE_SET_PALETTE_COMPRESSED:
debug_ipmovie("set palette compressed\n");
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_SET_DECODING_MAP:
@@ -473,7 +473,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
/* log position and move on for now */
s->decode_map_chunk_offset = url_ftell(pb);
s->decode_map_chunk_size = opcode_size;
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_VIDEO_DATA:
@@ -482,7 +482,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
/* log position and move on for now */
s->video_chunk_offset = url_ftell(pb);
s->video_chunk_size = opcode_size;
- url_fseek(pb, opcode_size, SEEK_CUR);
+ avio_seek(pb, opcode_size, SEEK_CUR);
break;
default:
@@ -521,17 +521,17 @@ static int ipmovie_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
IPMVEContext *ipmovie = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVPacket pkt;
AVStream *st;
unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
int chunk_type;
uint8_t signature_buffer[sizeof(signature)];
- get_buffer(pb, signature_buffer, sizeof(signature_buffer));
+ avio_read(pb, signature_buffer, sizeof(signature_buffer));
while (memcmp(signature_buffer, signature, sizeof(signature))) {
memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1);
- signature_buffer[sizeof(signature_buffer) - 1] = get_byte(pb);
+ signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb);
if (url_feof(pb))
return AVERROR_EOF;
}
@@ -549,11 +549,11 @@ static int ipmovie_read_header(AVFormatContext *s,
/* peek ahead to the next chunk-- if it is an init audio chunk, process
* it; if it is the first video chunk, this is a silent file */
- if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
chunk_type = AV_RL16(&chunk_preamble[2]);
- url_fseek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
+ avio_seek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
if (chunk_type == CHUNK_VIDEO)
ipmovie->audio_type = CODEC_ID_NONE; /* no audio */
@@ -602,7 +602,7 @@ static int ipmovie_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
IPMVEContext *ipmovie = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret;
ret = process_ipmovie_chunk(ipmovie, pb, pkt);
diff --git a/mplayer/ffmpeg/libavformat/isom.c b/mplayer/ffmpeg/libavformat/isom.c
index 23ef82a1..3a0d3487 100644
--- a/mplayer/ffmpeg/libavformat/isom.c
+++ b/mplayer/ffmpeg/libavformat/isom.c
@@ -134,6 +134,10 @@ const AVCodecTag codec_movvideo_tags[] = {
{ CODEC_ID_RAWVIDEO, MKTAG('W', 'R', 'A', 'W') },
{ CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */
+ { CODEC_ID_H264, MKTAG('a', 'i', '5', '5') }, /* AVC Intra 50 / 1080 */
+ { CODEC_ID_H264, MKTAG('a', 'i', '5', 'q') }, /* AVC Intra 50 / 720 */
+ { CODEC_ID_H264, MKTAG('a', 'i', '1', '5') }, /* AVC Intra 100 / 1080 */
+ { CODEC_ID_H264, MKTAG('a', 'i', '1', 'q') }, /* AVC Intra 100 / 720 */
{ CODEC_ID_MPEG1VIDEO, MKTAG('m', '1', 'v', '1') }, /* Apple MPEG-1 Camcorder */
{ CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'e', 'g') }, /* MPEG */
@@ -193,6 +197,12 @@ const AVCodecTag codec_movvideo_tags[] = {
{ CODEC_ID_SGI, MKTAG('s', 'g', 'i', ' ') }, /* SGI */
{ CODEC_ID_DPX, MKTAG('d', 'p', 'x', ' ') }, /* DPX */
+ { CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 'h') }, /* Apple ProRes 422 High Quality */
+ { CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 'n') }, /* Apple ProRes 422 Standard Definition */
+ { CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 's') }, /* Apple ProRes 422 LT */
+ { CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 'o') }, /* Apple ProRes 422 Proxy */
+ { CODEC_ID_PRORES, MKTAG('a', 'p', '4', 'h') }, /* Apple ProRes 4444 */
+
{ CODEC_ID_NONE, 0 },
};
@@ -241,6 +251,7 @@ const AVCodecTag codec_movaudio_tags[] = {
{ CODEC_ID_QCELP, MKTAG('Q','c','l','q') },
{ CODEC_ID_QCELP, MKTAG('s','q','c','p') }, /* ISO Media fourcc */
+ { CODEC_ID_QDMC, MKTAG('Q', 'D', 'M', 'C') }, /* QDMC */
{ CODEC_ID_QDM2, MKTAG('Q', 'D', 'M', '2') }, /* QDM2 */
{ CODEC_ID_DVAUDIO, MKTAG('v', 'd', 'v', 'a') },
@@ -332,12 +343,12 @@ int ff_mov_lang_to_iso639(unsigned code, char to[4])
return 1;
}
-int ff_mp4_read_descr_len(ByteIOContext *pb)
+int ff_mp4_read_descr_len(AVIOContext *pb)
{
int len = 0;
int count = 4;
while (count--) {
- int c = get_byte(pb);
+ int c = avio_r8(pb);
len = (len << 7) | (c & 0x7f);
if (!(c & 0x80))
break;
@@ -345,10 +356,10 @@ int ff_mp4_read_descr_len(ByteIOContext *pb)
return len;
}
-int ff_mp4_read_descr(AVFormatContext *fc, ByteIOContext *pb, int *tag)
+int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag)
{
int len;
- *tag = get_byte(pb);
+ *tag = avio_r8(pb);
len = ff_mp4_read_descr_len(pb);
av_dlog(fc, "MPEG4 description: tag=0x%02x len=%d\n", *tag, len);
return len;
@@ -363,14 +374,14 @@ static const AVCodecTag mp4_audio_types[] = {
{ CODEC_ID_NONE, AOT_NULL },
};
-int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, ByteIOContext *pb)
+int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
{
int len, tag;
- int object_type_id = get_byte(pb);
- get_byte(pb); /* stream type */
- get_be24(pb); /* buffer size db */
- get_be32(pb); /* max bitrate */
- get_be32(pb); /* avg bitrate */
+ int object_type_id = avio_r8(pb);
+ avio_r8(pb); /* stream type */
+ avio_rb24(pb); /* buffer size db */
+ avio_rb32(pb); /* max bitrate */
+ avio_rb32(pb); /* avg bitrate */
st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
av_dlog(fc, "esds object type id 0x%02x\n", object_type_id);
@@ -383,7 +394,7 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, ByteIOContex
st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, st->codec->extradata, len);
+ avio_read(pb, st->codec->extradata, len);
st->codec->extradata_size = len;
if (st->codec->codec_id == CODEC_ID_AAC) {
MPEG4AudioConfig cfg;
diff --git a/mplayer/ffmpeg/libavformat/isom.h b/mplayer/ffmpeg/libavformat/isom.h
index 2990c9ce..1df666f1 100644
--- a/mplayer/ffmpeg/libavformat/isom.h
+++ b/mplayer/ffmpeg/libavformat/isom.h
@@ -88,7 +88,7 @@ typedef struct {
} MOVTrackExt;
typedef struct MOVStreamContext {
- ByteIOContext *pb;
+ AVIOContext *pb;
int ffindex; ///< AVStream index
int next_chunk;
unsigned int chunk_count;
@@ -141,18 +141,18 @@ typedef struct MOVContext {
int chapter_track;
} MOVContext;
-int ff_mp4_read_descr_len(ByteIOContext *pb);
-int ff_mp4_read_descr(AVFormatContext *fc, ByteIOContext *pb, int *tag);
-int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, ByteIOContext *pb);
+int ff_mp4_read_descr_len(AVIOContext *pb);
+int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag);
+int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb);
#define MP4IODescrTag 0x02
#define MP4ESDescrTag 0x03
#define MP4DecConfigDescrTag 0x04
#define MP4DecSpecificDescrTag 0x05
-int ff_mov_read_esds(AVFormatContext *fc, ByteIOContext *pb, MOVAtom atom);
+int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom);
enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags);
-int ff_mov_read_stsd_entries(MOVContext *c, ByteIOContext *pb, int entries);
+int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries);
#endif /* AVFORMAT_ISOM_H */
diff --git a/mplayer/ffmpeg/libavformat/iss.c b/mplayer/ffmpeg/libavformat/iss.c
index c47c8c87..04bb1c52 100644
--- a/mplayer/ffmpeg/libavformat/iss.c
+++ b/mplayer/ffmpeg/libavformat/iss.c
@@ -39,12 +39,12 @@ typedef struct {
int sample_start_pos;
} IssDemuxContext;
-static void get_token(ByteIOContext *s, char *buf, int maxlen)
+static void get_token(AVIOContext *s, char *buf, int maxlen)
{
int i = 0;
char c;
- while ((c = get_byte(s))) {
+ while ((c = avio_r8(s))) {
if(c == ' ')
break;
if (i < maxlen-1)
@@ -52,7 +52,7 @@ static void get_token(ByteIOContext *s, char *buf, int maxlen)
}
if(!c)
- get_byte(s);
+ avio_r8(s);
buf[i] = 0; /* Ensure null terminated, but may be truncated */
}
@@ -68,7 +68,7 @@ static int iss_probe(AVProbeData *p)
static av_cold int iss_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
IssDemuxContext *iss = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
char token[MAX_TOKEN_SIZE];
int stereo, rate_divisor;
diff --git a/mplayer/ffmpeg/libavformat/iv8.c b/mplayer/ffmpeg/libavformat/iv8.c
index 07659cf8..4671a18e 100644
--- a/mplayer/ffmpeg/libavformat/iv8.c
+++ b/mplayer/ffmpeg/libavformat/iv8.c
@@ -57,20 +57,20 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size, pts, type;
retry:
- type= get_be16(s->pb); // 257 or 258
- size= get_be16(s->pb);
+ type= avio_rb16(s->pb); // 257 or 258
+ size= avio_rb16(s->pb);
- get_be16(s->pb); //some flags, 0x80 indicates end of frame
- get_be16(s->pb); //packet number
- pts=get_be32(s->pb);
- get_be32(s->pb); //6A 13 E3 88
+ avio_rb16(s->pb); //some flags, 0x80 indicates end of frame
+ avio_rb16(s->pb); //packet number
+ pts=avio_rb32(s->pb);
+ avio_rb32(s->pb); //6A 13 E3 88
size -= 12;
if(size<1)
return -1;
if(type==258){
- url_fskip(s->pb, size);
+ avio_seek(s->pb, size, SEEK_CUR);
goto retry;
}
diff --git a/mplayer/ffmpeg/libavformat/ivfdec.c b/mplayer/ffmpeg/libavformat/ivfdec.c
index 94b8b82a..af3fe19e 100644
--- a/mplayer/ffmpeg/libavformat/ivfdec.c
+++ b/mplayer/ffmpeg/libavformat/ivfdec.c
@@ -36,9 +36,9 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
AVStream *st;
AVRational time_base;
- get_le32(s->pb); // DKIF
- get_le16(s->pb); // version
- get_le16(s->pb); // header size
+ avio_rl32(s->pb); // DKIF
+ avio_rl16(s->pb); // version
+ avio_rl16(s->pb); // header size
st = av_new_stream(s, 0);
if (!st)
@@ -46,13 +46,13 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_tag = get_le32(s->pb);
+ st->codec->codec_tag = avio_rl32(s->pb);
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag);
- st->codec->width = get_le16(s->pb);
- st->codec->height = get_le16(s->pb);
- time_base.den = get_le32(s->pb);
- time_base.num = get_le32(s->pb);
- st->duration = get_le64(s->pb);
+ st->codec->width = avio_rl16(s->pb);
+ st->codec->height = avio_rl16(s->pb);
+ time_base.den = avio_rl32(s->pb);
+ time_base.num = avio_rl32(s->pb);
+ st->duration = avio_rl64(s->pb);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
@@ -68,8 +68,8 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
- int ret, size = get_le32(s->pb);
- int64_t pts = get_le64(s->pb);
+ int ret, size = avio_rl32(s->pb);
+ int64_t pts = avio_rl64(s->pb);
ret = av_get_packet(s->pb, pkt, size);
pkt->stream_index = 0;
diff --git a/mplayer/ffmpeg/libavformat/ivfenc.c b/mplayer/ffmpeg/libavformat/ivfenc.c
index b3b28419..39139881 100644
--- a/mplayer/ffmpeg/libavformat/ivfenc.c
+++ b/mplayer/ffmpeg/libavformat/ivfenc.c
@@ -23,36 +23,36 @@
static int ivf_write_header(AVFormatContext *s)
{
AVCodecContext *ctx;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
if (s->nb_streams != 1) {
av_log(s, AV_LOG_ERROR, "Format supports only exactly one video stream\n");
return AVERROR(EINVAL);
}
ctx = s->streams[0]->codec;
- if (ctx->codec_type != CODEC_TYPE_VIDEO || ctx->codec_id != CODEC_ID_VP8) {
+ if (ctx->codec_type != AVMEDIA_TYPE_VIDEO || ctx->codec_id != CODEC_ID_VP8) {
av_log(s, AV_LOG_ERROR, "Currently only VP8 is supported!\n");
return AVERROR(EINVAL);
}
- put_buffer(pb, "DKIF", 4);
- put_le16(pb, 0); // version
- put_le16(pb, 32); // header length
- put_le32(pb, ctx->codec_tag ? ctx->codec_tag : AV_RL32("VP80"));
- put_le16(pb, ctx->width);
- put_le16(pb, ctx->height);
- put_le32(pb, s->streams[0]->time_base.den);
- put_le32(pb, s->streams[0]->time_base.num);
- put_le64(pb, s->streams[0]->duration); // TODO: duration or number of frames?!?
+ avio_write(pb, "DKIF", 4);
+ avio_wl16(pb, 0); // version
+ avio_wl16(pb, 32); // header length
+ avio_wl32(pb, ctx->codec_tag ? ctx->codec_tag : AV_RL32("VP80"));
+ avio_wl16(pb, ctx->width);
+ avio_wl16(pb, ctx->height);
+ avio_wl32(pb, s->streams[0]->time_base.den);
+ avio_wl32(pb, s->streams[0]->time_base.num);
+ avio_wl64(pb, s->streams[0]->duration); // TODO: duration or number of frames?!?
return 0;
}
static int ivf_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
- put_le32(pb, pkt->size);
- put_le64(pb, pkt->pts);
- put_buffer(pb, pkt->data, pkt->size);
+ AVIOContext *pb = s->pb;
+ avio_wl32(pb, pkt->size);
+ avio_wl64(pb, pkt->pts);
+ avio_write(pb, pkt->data, pkt->size);
put_flush_packet(pb);
return 0;
diff --git a/mplayer/ffmpeg/libavformat/libnut.c b/mplayer/ffmpeg/libavformat/libnut.c
index 5630bf8c..467ca9c4 100644
--- a/mplayer/ffmpeg/libavformat/libnut.c
+++ b/mplayer/ffmpeg/libavformat/libnut.c
@@ -46,15 +46,15 @@ static const AVCodecTag nut_tags[] = {
#if CONFIG_LIBNUT_MUXER
static int av_write(void * h, size_t len, const uint8_t * buf) {
- ByteIOContext * bc = h;
- put_buffer(bc, buf, len);
+ AVIOContext * bc = h;
+ avio_write(bc, buf, len);
//put_flush_packet(bc);
return len;
}
static int nut_write_header(AVFormatContext * avf) {
NUTContext * priv = avf->priv_data;
- ByteIOContext * bc = avf->pb;
+ AVIOContext * bc = avf->pb;
nut_muxer_opts_tt mopts = {
.output = {
.priv = bc,
@@ -137,7 +137,7 @@ static int nut_write_packet(AVFormatContext * avf, AVPacket * pkt) {
}
static int nut_write_trailer(AVFormatContext * avf) {
- ByteIOContext * bc = avf->pb;
+ AVIOContext * bc = avf->pb;
NUTContext * priv = avf->priv_data;
int i;
@@ -172,22 +172,22 @@ static int nut_probe(AVProbeData *p) {
}
static size_t av_read(void * h, size_t len, uint8_t * buf) {
- ByteIOContext * bc = h;
- return get_buffer(bc, buf, len);
+ AVIOContext * bc = h;
+ return avio_read(bc, buf, len);
}
static off_t av_seek(void * h, long long pos, int whence) {
- ByteIOContext * bc = h;
+ AVIOContext * bc = h;
if (whence == SEEK_END) {
pos = url_fsize(bc) + pos;
whence = SEEK_SET;
}
- return url_fseek(bc, pos, whence);
+ return avio_seek(bc, pos, whence);
}
static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) {
NUTContext * priv = avf->priv_data;
- ByteIOContext * bc = avf->pb;
+ AVIOContext * bc = avf->pb;
nut_demuxer_opts_tt dopts = {
.input = {
.priv = bc,
diff --git a/mplayer/ffmpeg/libavformat/lmlm4.c b/mplayer/ffmpeg/libavformat/lmlm4.c
index 5cb202e4..97ece015 100644
--- a/mplayer/ffmpeg/libavformat/lmlm4.c
+++ b/mplayer/ffmpeg/libavformat/lmlm4.c
@@ -78,13 +78,13 @@ static int lmlm4_read_header(AVFormatContext *s, AVFormatParameters *ap) {
}
static int lmlm4_read_packet(AVFormatContext *s, AVPacket *pkt) {
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret;
unsigned int frame_type, packet_size, padding, frame_size;
- get_be16(pb); /* channel number */
- frame_type = get_be16(pb);
- packet_size = get_be32(pb);
+ avio_rb16(pb); /* channel number */
+ frame_type = avio_rb16(pb);
+ packet_size = avio_rb32(pb);
padding = -packet_size & 511;
frame_size = packet_size - 8;
@@ -100,7 +100,7 @@ static int lmlm4_read_packet(AVFormatContext *s, AVPacket *pkt) {
if ((ret = av_get_packet(pb, pkt, frame_size)) <= 0)
return AVERROR(EIO);
- url_fskip(pb, padding);
+ avio_seek(pb, padding, SEEK_CUR);
switch (frame_type) {
case LMLM4_I_FRAME:
diff --git a/mplayer/ffmpeg/libavformat/lxfdec.c b/mplayer/ffmpeg/libavformat/lxfdec.c
index 1d4d269d..4e98c895 100644
--- a/mplayer/ffmpeg/libavformat/lxfdec.c
+++ b/mplayer/ffmpeg/libavformat/lxfdec.c
@@ -86,7 +86,7 @@ static int sync(AVFormatContext *s, uint8_t *header)
uint8_t buf[LXF_IDENT_LENGTH];
int ret;
- if ((ret = get_buffer(s->pb, buf, LXF_IDENT_LENGTH)) != LXF_IDENT_LENGTH)
+ if ((ret = avio_read(s->pb, buf, LXF_IDENT_LENGTH)) != LXF_IDENT_LENGTH)
return ret < 0 ? ret : AVERROR_EOF;
while (memcmp(buf, LXF_IDENT, LXF_IDENT_LENGTH)) {
@@ -94,7 +94,7 @@ static int sync(AVFormatContext *s, uint8_t *header)
return AVERROR_EOF;
memmove(buf, &buf[1], LXF_IDENT_LENGTH-1);
- buf[LXF_IDENT_LENGTH-1] = get_byte(s->pb);
+ buf[LXF_IDENT_LENGTH-1] = avio_r8(s->pb);
}
memcpy(header, LXF_IDENT, LXF_IDENT_LENGTH);
@@ -111,7 +111,7 @@ static int sync(AVFormatContext *s, uint8_t *header)
*/
static int get_packet_header(AVFormatContext *s, uint8_t *header, uint32_t *format)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int track_size, samples, ret;
AVStream *st;
@@ -120,7 +120,7 @@ static int get_packet_header(AVFormatContext *s, uint8_t *header, uint32_t *form
return ret;
//read the rest of the packet header
- if ((ret = get_buffer(pb, header + LXF_IDENT_LENGTH,
+ if ((ret = avio_read(pb, header + LXF_IDENT_LENGTH,
LXF_PACKET_HEADER_SIZE - LXF_IDENT_LENGTH)) !=
LXF_PACKET_HEADER_SIZE - LXF_IDENT_LENGTH) {
return ret < 0 ? ret : AVERROR_EOF;
@@ -137,8 +137,8 @@ static int get_packet_header(AVFormatContext *s, uint8_t *header, uint32_t *form
case 0:
//video
//skip VBI data and metadata
- url_fskip(pb, (int64_t)(uint32_t)AV_RL32(&header[44]) +
- (int64_t)(uint32_t)AV_RL32(&header[52]));
+ avio_seek(pb, (int64_t)(uint32_t)AV_RL32(&header[44]) +
+ (int64_t)(uint32_t)AV_RL32(&header[52]), SEEK_CUR);
break;
case 1:
//audio
@@ -198,7 +198,7 @@ static int get_packet_header(AVFormatContext *s, uint8_t *header, uint32_t *form
static int lxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
LXFDemuxContext *lxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint8_t header[LXF_PACKET_HEADER_SIZE], header_data[LXF_HEADER_DATA_SIZE];
int ret;
AVStream *st;
@@ -214,7 +214,7 @@ static int lxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR_INVALIDDATA;
}
- if ((ret = get_buffer(pb, header_data, LXF_HEADER_DATA_SIZE)) != LXF_HEADER_DATA_SIZE)
+ if ((ret = avio_read(pb, header_data, LXF_HEADER_DATA_SIZE)) != LXF_HEADER_DATA_SIZE)
return ret < 0 ? ret : AVERROR_EOF;
if (!(st = av_new_stream(s, 0)))
@@ -255,7 +255,7 @@ static int lxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (format == 1) {
//skip extended field data
- url_fskip(s->pb, (uint32_t)AV_RL32(&header[40]));
+ avio_seek(s->pb, (uint32_t)AV_RL32(&header[40]), SEEK_CUR);
}
return 0;
@@ -281,7 +281,7 @@ static void deplanarize(LXFDemuxContext *lxf, AVStream *ast, uint8_t *out, int b
static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
{
LXFDemuxContext *lxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint8_t header[LXF_PACKET_HEADER_SIZE], *buf;
AVStream *ast = NULL;
uint32_t stream, format;
@@ -315,7 +315,7 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
//read non-20-bit audio data into lxf->temp so we can deplanarize it
buf = ast && ast->codec->codec_id != CODEC_ID_PCM_LXF ? lxf->temp : pkt->data;
- if ((ret2 = get_buffer(pb, buf, ret)) != ret) {
+ if ((ret2 = avio_read(pb, buf, ret)) != ret) {
av_free_packet(pkt);
return ret2 < 0 ? ret2 : AVERROR_EOF;
}
diff --git a/mplayer/ffmpeg/libavformat/matroskadec.c b/mplayer/ffmpeg/libavformat/matroskadec.c
index 1a87f4a0..7480475c 100644
--- a/mplayer/ffmpeg/libavformat/matroskadec.c
+++ b/mplayer/ffmpeg/libavformat/matroskadec.c
@@ -31,6 +31,7 @@
#include
#include "avformat.h"
#include "internal.h"
+#include "avio_internal.h"
/* For ff_codec_get_id(). */
#include "riff.h"
#include "isom.h"
@@ -58,6 +59,7 @@ typedef enum {
EBML_NEST,
EBML_PASS,
EBML_STOP,
+ EBML_TYPE_COUNT
} EbmlType;
typedef const struct EbmlSyntax {
@@ -514,7 +516,7 @@ static const char *matroska_doctypes[] = { "matroska", "webm" };
*/
static int ebml_level_end(MatroskaDemuxContext *matroska)
{
- ByteIOContext *pb = matroska->ctx->pb;
+ AVIOContext *pb = matroska->ctx->pb;
int64_t pos = url_ftell(pb);
if (matroska->num_levels > 0) {
@@ -535,16 +537,16 @@ static int ebml_level_end(MatroskaDemuxContext *matroska)
* number.
* Returns: number of bytes read, < 0 on error
*/
-static int ebml_read_num(MatroskaDemuxContext *matroska, ByteIOContext *pb,
+static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb,
int max_size, uint64_t *number)
{
int read = 1, n = 1;
uint64_t total = 0;
- /* The first byte tells us the length in bytes - get_byte() can normally
+ /* The first byte tells us the length in bytes - avio_r8() can normally
* return 0, but since that's not a valid first ebmlID byte, we can
* use it safely here to catch EOS. */
- if (!(total = get_byte(pb))) {
+ if (!(total = avio_r8(pb))) {
/* we might encounter EOS here */
if (!url_feof(pb)) {
int64_t pos = url_ftell(pb);
@@ -568,7 +570,7 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, ByteIOContext *pb,
/* read out length */
total ^= 1 << ff_log2_tab[total];
while (n++ < read)
- total = (total << 8) | get_byte(pb);
+ total = (total << 8) | avio_r8(pb);
*number = total;
@@ -580,7 +582,7 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, ByteIOContext *pb,
* This needs special handling for the "unknown length" case which has multiple
* encodings.
*/
-static int ebml_read_length(MatroskaDemuxContext *matroska, ByteIOContext *pb,
+static int ebml_read_length(MatroskaDemuxContext *matroska, AVIOContext *pb,
uint64_t *number)
{
int res = ebml_read_num(matroska, pb, 8, number);
@@ -593,7 +595,7 @@ static int ebml_read_length(MatroskaDemuxContext *matroska, ByteIOContext *pb,
* Read the next element as an unsigned int.
* 0 is success, < 0 is failure.
*/
-static int ebml_read_uint(ByteIOContext *pb, int size, uint64_t *num)
+static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num)
{
int n = 0;
@@ -603,7 +605,7 @@ static int ebml_read_uint(ByteIOContext *pb, int size, uint64_t *num)
/* big-endian ordering; build up number */
*num = 0;
while (n++ < size)
- *num = (*num << 8) | get_byte(pb);
+ *num = (*num << 8) | avio_r8(pb);
return 0;
}
@@ -612,14 +614,14 @@ static int ebml_read_uint(ByteIOContext *pb, int size, uint64_t *num)
* Read the next element as a float.
* 0 is success, < 0 is failure.
*/
-static int ebml_read_float(ByteIOContext *pb, int size, double *num)
+static int ebml_read_float(AVIOContext *pb, int size, double *num)
{
if (size == 0) {
*num = 0;
} else if (size == 4) {
- *num= av_int2flt(get_be32(pb));
+ *num= av_int2flt(avio_rb32(pb));
} else if(size==8){
- *num= av_int2dbl(get_be64(pb));
+ *num= av_int2dbl(avio_rb64(pb));
} else
return AVERROR_INVALIDDATA;
@@ -630,14 +632,14 @@ static int ebml_read_float(ByteIOContext *pb, int size, double *num)
* Read the next element as an ASCII string.
* 0 is success, < 0 is failure.
*/
-static int ebml_read_ascii(ByteIOContext *pb, int size, char **str)
+static int ebml_read_ascii(AVIOContext *pb, int size, char **str)
{
av_free(*str);
/* EBML strings are usually not 0-terminated, so we allocate one
* byte more, read the string and NULL-terminate it ourselves. */
if (!(*str = av_malloc(size + 1)))
return AVERROR(ENOMEM);
- if (get_buffer(pb, (uint8_t *) *str, size) != size) {
+ if (avio_read(pb, (uint8_t *) *str, size) != size) {
av_freep(str);
return AVERROR(EIO);
}
@@ -650,7 +652,7 @@ static int ebml_read_ascii(ByteIOContext *pb, int size, char **str)
* Read the next element as binary data.
* 0 is success, < 0 is failure.
*/
-static int ebml_read_binary(ByteIOContext *pb, int length, EbmlBin *bin)
+static int ebml_read_binary(AVIOContext *pb, int length, EbmlBin *bin)
{
av_free(bin->data);
if (!(bin->data = av_malloc(length)))
@@ -658,7 +660,7 @@ static int ebml_read_binary(ByteIOContext *pb, int length, EbmlBin *bin)
bin->size = length;
bin->pos = url_ftell(pb);
- if (get_buffer(pb, bin->data, length) != length) {
+ if (avio_read(pb, bin->data, length) != length) {
av_freep(&bin->data);
return AVERROR(EIO);
}
@@ -673,7 +675,7 @@ static int ebml_read_binary(ByteIOContext *pb, int length, EbmlBin *bin)
*/
static int ebml_read_master(MatroskaDemuxContext *matroska, uint64_t length)
{
- ByteIOContext *pb = matroska->ctx->pb;
+ AVIOContext *pb = matroska->ctx->pb;
MatroskaLevel *level;
if (matroska->num_levels >= EBML_MAX_DEPTH) {
@@ -696,8 +698,8 @@ static int ebml_read_master(MatroskaDemuxContext *matroska, uint64_t length)
static int matroska_ebmlnum_uint(MatroskaDemuxContext *matroska,
uint8_t *data, uint32_t size, uint64_t *num)
{
- ByteIOContext pb;
- init_put_byte(&pb, data, size, 0, NULL, NULL, NULL, NULL);
+ AVIOContext pb;
+ ffio_init_context(&pb, data, size, 0, NULL, NULL, NULL, NULL);
return ebml_read_num(matroska, &pb, FFMIN(size, 8), num);
}
@@ -780,7 +782,17 @@ static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
static int ebml_parse_elem(MatroskaDemuxContext *matroska,
EbmlSyntax *syntax, void *data)
{
- ByteIOContext *pb = matroska->ctx->pb;
+ static const uint64_t max_lengths[EBML_TYPE_COUNT] = {
+ [EBML_UINT] = 8,
+ [EBML_FLOAT] = 8,
+ // max. 16 MB for strings
+ [EBML_STR] = 0x1000000,
+ [EBML_UTF8] = 0x1000000,
+ // max. 256 MB for binary data
+ [EBML_BIN] = 0x10000000,
+ // no limits for anything else
+ };
+ AVIOContext *pb = matroska->ctx->pb;
uint32_t id = syntax->id;
uint64_t length;
int res;
@@ -798,6 +810,12 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
matroska->current_id = 0;
if ((res = ebml_read_length(matroska, pb, &length)) < 0)
return res;
+ if (max_lengths[syntax->type] && length > max_lengths[syntax->type]) {
+ av_log(matroska->ctx, AV_LOG_ERROR,
+ "Invalid length 0x%"PRIx64" > 0x%"PRIx64" for syntax element %i\n",
+ length, max_lengths[syntax->type], syntax->type);
+ return AVERROR_INVALIDDATA;
+ }
}
switch (syntax->type) {
@@ -813,7 +831,7 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
return ebml_parse_nest(matroska, syntax->def.n, data);
case EBML_PASS: return ebml_parse_id(matroska, syntax->def.n, id, data);
case EBML_STOP: return 1;
- default: return url_fseek(pb,length,SEEK_CUR)<0 ? AVERROR(EIO) : 0;
+ default: return avio_seek(pb,length,SEEK_CUR)<0 ? AVERROR(EIO) : 0;
}
if (res == AVERROR_INVALIDDATA)
av_log(matroska->ctx, AV_LOG_ERROR, "Invalid element\n");
@@ -1112,7 +1130,7 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska)
continue;
/* seek */
- if (url_fseek(matroska->ctx->pb, offset, SEEK_SET) != offset)
+ if (avio_seek(matroska->ctx->pb, offset, SEEK_SET) != offset)
continue;
/* We don't want to lose our seekhead level, so we add
@@ -1141,7 +1159,7 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska)
}
/* seek back */
- url_fseek(matroska->ctx->pb, before_pos, SEEK_SET);
+ avio_seek(matroska->ctx->pb, before_pos, SEEK_SET);
matroska->level_up = level_up;
matroska->current_id = saved_id;
}
@@ -1225,7 +1243,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
uint8_t *extradata = NULL;
int extradata_size = 0;
int extradata_offset = 0;
- ByteIOContext b;
+ AVIOContext b;
/* Apply some sanity checks. */
if (track->type != MATROSKA_TRACK_TYPE_VIDEO &&
@@ -1311,7 +1329,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
} else if (!strcmp(track->codec_id, "A_MS/ACM")
&& track->codec_priv.size >= 14
&& track->codec_priv.data != NULL) {
- init_put_byte(&b, track->codec_priv.data, track->codec_priv.size,
+ ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size,
URL_RDONLY, NULL, NULL, NULL, NULL);
ff_get_wav_header(&b, st->codec, track->codec_priv.size);
codec_id = st->codec->codec_id;
@@ -1356,14 +1374,14 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
extradata = av_mallocz(extradata_size);
if (extradata == NULL)
return AVERROR(ENOMEM);
- init_put_byte(&b, extradata, extradata_size, 1,
+ ffio_init_context(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
- put_buffer(&b, "TTA1", 4);
- put_le16(&b, 1);
- put_le16(&b, track->audio.channels);
- put_le16(&b, track->audio.bitdepth);
- put_le32(&b, track->audio.out_samplerate);
- put_le32(&b, matroska->ctx->duration * track->audio.out_samplerate);
+ avio_write(&b, "TTA1", 4);
+ avio_wl16(&b, 1);
+ avio_wl16(&b, track->audio.channels);
+ avio_wl16(&b, track->audio.bitdepth);
+ avio_wl32(&b, track->audio.out_samplerate);
+ avio_wl32(&b, matroska->ctx->duration * track->audio.out_samplerate);
} else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||
codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {
extradata_offset = 26;
@@ -1373,15 +1391,15 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
} else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK ||
codec_id == CODEC_ID_ATRAC3 || codec_id == CODEC_ID_SIPR) {
int flavor;
- init_put_byte(&b, track->codec_priv.data,track->codec_priv.size,
+ ffio_init_context(&b, track->codec_priv.data,track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
- url_fskip(&b, 22);
- flavor = get_be16(&b);
- track->audio.coded_framesize = get_be32(&b);
- url_fskip(&b, 12);
- track->audio.sub_packet_h = get_be16(&b);
- track->audio.frame_size = get_be16(&b);
- track->audio.sub_packet_size = get_be16(&b);
+ avio_seek(&b, 22, SEEK_CUR);
+ flavor = avio_rb16(&b);
+ track->audio.coded_framesize = avio_rb32(&b);
+ avio_seek(&b, 12, SEEK_CUR);
+ track->audio.sub_packet_h = avio_rb16(&b);
+ track->audio.frame_size = avio_rb16(&b);
+ track->audio.sub_packet_size = avio_rb16(&b);
track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
if (codec_id == CODEC_ID_RA_288) {
st->codec->block_align = track->audio.coded_framesize;
@@ -1871,7 +1889,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
timestamp = FFMAX(timestamp, st->index_entries[0].timestamp);
if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
- url_fseek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET);
+ avio_seek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET);
while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
matroska_clear_queue(matroska);
if (matroska_parse_cluster(matroska) < 0)
@@ -1896,7 +1914,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
}
}
- url_fseek(s->pb, st->index_entries[index_min].pos, SEEK_SET);
+ avio_seek(s->pb, st->index_entries[index_min].pos, SEEK_SET);
matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY);
matroska->skip_to_timecode = st->index_entries[index].timestamp;
matroska->done = 0;
diff --git a/mplayer/ffmpeg/libavformat/matroskaenc.c b/mplayer/ffmpeg/libavformat/matroskaenc.c
index a288c7f8..6f752204 100644
--- a/mplayer/ffmpeg/libavformat/matroskaenc.c
+++ b/mplayer/ffmpeg/libavformat/matroskaenc.c
@@ -26,7 +26,7 @@
#include "avc.h"
#include "flacenc.h"
#include "avlanguage.h"
-#include "libavcore/samplefmt.h"
+#include "libavutil/samplefmt.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/random_seed.h"
#include "libavutil/lfg.h"
@@ -74,7 +74,7 @@ typedef struct {
typedef struct MatroskaMuxContext {
int mode;
- ByteIOContext *dyn_bc;
+ AVIOContext *dyn_bc;
ebml_master segment;
int64_t segment_offset;
ebml_master cluster;
@@ -108,11 +108,11 @@ static int ebml_id_size(unsigned int id)
return (av_log2(id+1)-1)/7+1;
}
-static void put_ebml_id(ByteIOContext *pb, unsigned int id)
+static void put_ebml_id(AVIOContext *pb, unsigned int id)
{
int i = ebml_id_size(id);
while (i--)
- put_byte(pb, id >> (i*8));
+ avio_w8(pb, id >> (i*8));
}
/**
@@ -120,12 +120,12 @@ static void put_ebml_id(ByteIOContext *pb, unsigned int id)
*
* @param bytes The number of bytes the size should occupy (maximum: 8).
*/
-static void put_ebml_size_unknown(ByteIOContext *pb, int bytes)
+static void put_ebml_size_unknown(AVIOContext *pb, int bytes)
{
assert(bytes <= 8);
- put_byte(pb, 0x1ff >> bytes);
+ avio_w8(pb, 0x1ff >> bytes);
while (--bytes)
- put_byte(pb, 0xff);
+ avio_w8(pb, 0xff);
}
/**
@@ -144,7 +144,7 @@ static int ebml_num_size(uint64_t num)
* @param bytes The number of bytes that need to be used to write the number.
* If zero, any number of bytes can be used.
*/
-static void put_ebml_num(ByteIOContext *pb, uint64_t num, int bytes)
+static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes)
{
int i, needed_bytes = ebml_num_size(num);
@@ -160,10 +160,10 @@ static void put_ebml_num(ByteIOContext *pb, uint64_t num, int bytes)
num |= 1ULL << bytes*7;
for (i = bytes - 1; i >= 0; i--)
- put_byte(pb, num >> i*8);
+ avio_w8(pb, num >> i*8);
}
-static void put_ebml_uint(ByteIOContext *pb, unsigned int elementid, uint64_t val)
+static void put_ebml_uint(AVIOContext *pb, unsigned int elementid, uint64_t val)
{
int i, bytes = 1;
uint64_t tmp = val;
@@ -172,25 +172,25 @@ static void put_ebml_uint(ByteIOContext *pb, unsigned int elementid, uint64_t va
put_ebml_id(pb, elementid);
put_ebml_num(pb, bytes, 0);
for (i = bytes - 1; i >= 0; i--)
- put_byte(pb, val >> i*8);
+ avio_w8(pb, val >> i*8);
}
-static void put_ebml_float(ByteIOContext *pb, unsigned int elementid, double val)
+static void put_ebml_float(AVIOContext *pb, unsigned int elementid, double val)
{
put_ebml_id(pb, elementid);
put_ebml_num(pb, 8, 0);
- put_be64(pb, av_dbl2int(val));
+ avio_wb64(pb, av_dbl2int(val));
}
-static void put_ebml_binary(ByteIOContext *pb, unsigned int elementid,
+static void put_ebml_binary(AVIOContext *pb, unsigned int elementid,
const void *buf, int size)
{
put_ebml_id(pb, elementid);
put_ebml_num(pb, size, 0);
- put_buffer(pb, buf, size);
+ avio_write(pb, buf, size);
}
-static void put_ebml_string(ByteIOContext *pb, unsigned int elementid, const char *str)
+static void put_ebml_string(AVIOContext *pb, unsigned int elementid, const char *str)
{
put_ebml_binary(pb, elementid, str, strlen(str));
}
@@ -201,7 +201,7 @@ static void put_ebml_string(ByteIOContext *pb, unsigned int elementid, const cha
*
* @param size The number of bytes to reserve, which must be at least 2.
*/
-static void put_ebml_void(ByteIOContext *pb, uint64_t size)
+static void put_ebml_void(AVIOContext *pb, uint64_t size)
{
int64_t currentpos = url_ftell(pb);
@@ -216,10 +216,10 @@ static void put_ebml_void(ByteIOContext *pb, uint64_t size)
else
put_ebml_num(pb, size-9, 8);
while(url_ftell(pb) < currentpos + size)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
-static ebml_master start_ebml_master(ByteIOContext *pb, unsigned int elementid, uint64_t expectedsize)
+static ebml_master start_ebml_master(AVIOContext *pb, unsigned int elementid, uint64_t expectedsize)
{
int bytes = expectedsize ? ebml_num_size(expectedsize) : 8;
put_ebml_id(pb, elementid);
@@ -227,22 +227,22 @@ static ebml_master start_ebml_master(ByteIOContext *pb, unsigned int elementid,
return (ebml_master){ url_ftell(pb), bytes };
}
-static void end_ebml_master(ByteIOContext *pb, ebml_master master)
+static void end_ebml_master(AVIOContext *pb, ebml_master master)
{
int64_t pos = url_ftell(pb);
- if (url_fseek(pb, master.pos - master.sizebytes, SEEK_SET) < 0)
+ if (avio_seek(pb, master.pos - master.sizebytes, SEEK_SET) < 0)
return;
put_ebml_num(pb, pos - master.pos, master.sizebytes);
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, pos, SEEK_SET);
}
-static void put_xiph_size(ByteIOContext *pb, int size)
+static void put_xiph_size(AVIOContext *pb, int size)
{
int i;
for (i = 0; i < size / 255; i++)
- put_byte(pb, 255);
- put_byte(pb, size % 255);
+ avio_w8(pb, 255);
+ avio_w8(pb, size % 255);
}
/**
@@ -256,7 +256,7 @@ static void put_xiph_size(ByteIOContext *pb, int size)
* @param numelements The maximum number of elements that will be indexed
* by this seek head, 0 if unlimited.
*/
-static mkv_seekhead * mkv_start_seekhead(ByteIOContext *pb, int64_t segment_offset, int numelements)
+static mkv_seekhead * mkv_start_seekhead(AVIOContext *pb, int64_t segment_offset, int numelements)
{
mkv_seekhead *new_seekhead = av_mallocz(sizeof(mkv_seekhead));
if (new_seekhead == NULL)
@@ -304,7 +304,7 @@ static int mkv_add_seekhead_entry(mkv_seekhead *seekhead, unsigned int elementid
* @return The file offset where the seekhead was written,
* -1 if an error occurred.
*/
-static int64_t mkv_write_seekhead(ByteIOContext *pb, mkv_seekhead *seekhead)
+static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead)
{
ebml_master metaseek, seekentry;
int64_t currentpos;
@@ -313,7 +313,7 @@ static int64_t mkv_write_seekhead(ByteIOContext *pb, mkv_seekhead *seekhead)
currentpos = url_ftell(pb);
if (seekhead->reserved_size > 0)
- if (url_fseek(pb, seekhead->filepos, SEEK_SET) < 0)
+ if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0)
return -1;
metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size);
@@ -334,7 +334,7 @@ static int64_t mkv_write_seekhead(ByteIOContext *pb, mkv_seekhead *seekhead)
if (seekhead->reserved_size > 0) {
uint64_t remaining = seekhead->filepos + seekhead->reserved_size - url_ftell(pb);
put_ebml_void(pb, remaining);
- url_fseek(pb, currentpos, SEEK_SET);
+ avio_seek(pb, currentpos, SEEK_SET);
currentpos = seekhead->filepos;
}
@@ -373,7 +373,7 @@ static int mkv_add_cuepoint(mkv_cues *cues, int stream, int64_t ts, int64_t clus
return 0;
}
-static int64_t mkv_write_cues(ByteIOContext *pb, mkv_cues *cues, int num_tracks)
+static int64_t mkv_write_cues(AVIOContext *pb, mkv_cues *cues, int num_tracks)
{
ebml_master cues_element;
int64_t currentpos;
@@ -408,7 +408,7 @@ static int64_t mkv_write_cues(ByteIOContext *pb, mkv_cues *cues, int num_tracks)
return currentpos;
}
-static int put_xiph_codecpriv(AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec)
+static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec)
{
uint8_t *header_start[3];
int header_len[3];
@@ -426,12 +426,12 @@ static int put_xiph_codecpriv(AVFormatContext *s, ByteIOContext *pb, AVCodecCont
return -1;
}
- put_byte(pb, 2); // number packets - 1
+ avio_w8(pb, 2); // number packets - 1
for (j = 0; j < 2; j++) {
put_xiph_size(pb, header_len[j]);
}
for (j = 0; j < 3; j++)
- put_buffer(pb, header_start[j], header_len[j]);
+ avio_write(pb, header_start[j], header_len[j]);
return 0;
}
@@ -463,9 +463,9 @@ static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int
}
}
-static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec, int native_id, int qt_id)
+static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec, int native_id, int qt_id)
{
- ByteIOContext *dyn_cp;
+ AVIOContext *dyn_cp;
uint8_t *codecpriv;
int ret, codecpriv_size;
@@ -481,13 +481,13 @@ static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodec
else if (codec->codec_id == CODEC_ID_H264)
ret = ff_isom_write_avcc(dyn_cp, codec->extradata, codec->extradata_size);
else if (codec->extradata_size)
- put_buffer(dyn_cp, codec->extradata, codec->extradata_size);
+ avio_write(dyn_cp, codec->extradata, codec->extradata_size);
} else if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (qt_id) {
if (!codec->codec_tag)
codec->codec_tag = ff_codec_get_tag(codec_movvideo_tags, codec->codec_id);
if (codec->extradata_size)
- put_buffer(dyn_cp, codec->extradata, codec->extradata_size);
+ avio_write(dyn_cp, codec->extradata, codec->extradata_size);
} else {
if (!codec->codec_tag)
codec->codec_tag = ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id);
@@ -522,7 +522,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodec
static int mkv_write_tracks(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
ebml_master tracks;
int i, j, ret;
@@ -650,7 +650,7 @@ static int mkv_write_tracks(AVFormatContext *s)
static int mkv_write_chapters(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
ebml_master chapters, editionentry;
AVRational scale = {1, 1E9};
int i, ret;
@@ -691,7 +691,7 @@ static int mkv_write_chapters(AVFormatContext *s)
return 0;
}
-static void mkv_write_simpletag(ByteIOContext *pb, AVMetadataTag *t)
+static void mkv_write_simpletag(AVIOContext *pb, AVMetadataTag *t)
{
uint8_t *key = av_strdup(t->key);
uint8_t *p = key;
@@ -790,7 +790,7 @@ static int mkv_write_tags(AVFormatContext *s)
static int mkv_write_header(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
ebml_master ebml_header, segment_info;
AVMetadataTag *tag;
int ret, i;
@@ -901,7 +901,7 @@ static int ass_get_duration(const uint8_t *p)
return end - start;
}
-static int mkv_write_ass_blocks(AVFormatContext *s, ByteIOContext *pb, AVPacket *pkt)
+static int mkv_write_ass_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
{
MatroskaMuxContext *mkv = s->priv_data;
int i, layer = 0, max_duration = 0, size, line_size, data_size = pkt->size;
@@ -932,10 +932,10 @@ static int mkv_write_ass_blocks(AVFormatContext *s, ByteIOContext *pb, AVPacket
blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(size));
put_ebml_id(pb, MATROSKA_ID_BLOCK);
put_ebml_num(pb, size+4, 0);
- put_byte(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126
- put_be16(pb, pkt->pts - mkv->cluster_pts);
- put_byte(pb, 0);
- put_buffer(pb, buffer, size);
+ avio_w8(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126
+ avio_wb16(pb, pkt->pts - mkv->cluster_pts);
+ avio_w8(pb, 0);
+ avio_write(pb, buffer, size);
put_ebml_uint(pb, MATROSKA_ID_BLOCKDURATION, duration);
end_ebml_master(pb, blockgroup);
@@ -946,7 +946,7 @@ static int mkv_write_ass_blocks(AVFormatContext *s, ByteIOContext *pb, AVPacket
return max_duration;
}
-static void mkv_write_block(AVFormatContext *s, ByteIOContext *pb,
+static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
unsigned int blockid, AVPacket *pkt, int flags)
{
MatroskaMuxContext *mkv = s->priv_data;
@@ -965,10 +965,10 @@ static void mkv_write_block(AVFormatContext *s, ByteIOContext *pb,
data = pkt->data;
put_ebml_id(pb, blockid);
put_ebml_num(pb, size+4, 0);
- put_byte(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126
- put_be16(pb, ts - mkv->cluster_pts);
- put_byte(pb, flags);
- put_buffer(pb, data, size);
+ avio_w8(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126
+ avio_wb16(pb, ts - mkv->cluster_pts);
+ avio_w8(pb, flags);
+ avio_write(pb, data, size);
if (data != pkt->data)
av_free(data);
}
@@ -992,7 +992,7 @@ static int srt_get_duration(uint8_t **buf)
return duration;
}
-static int mkv_write_srt_blocks(AVFormatContext *s, ByteIOContext *pb, AVPacket *pkt)
+static int mkv_write_srt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
{
ebml_master blockgroup;
AVPacket pkt2 = *pkt;
@@ -1018,7 +1018,7 @@ static void mkv_flush_dynbuf(AVFormatContext *s)
return;
bufsize = url_close_dyn_buf(mkv->dyn_bc, &dyn_buf);
- put_buffer(s->pb, dyn_buf, bufsize);
+ avio_write(s->pb, dyn_buf, bufsize);
av_free(dyn_buf);
mkv->dyn_bc = NULL;
}
@@ -1026,7 +1026,7 @@ static void mkv_flush_dynbuf(AVFormatContext *s)
static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
{
MatroskaMuxContext *mkv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
int keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY);
int duration = pkt->duration;
@@ -1090,7 +1090,7 @@ static int mkv_copy_packet(MatroskaMuxContext *mkv, const AVPacket *pkt)
static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
{
MatroskaMuxContext *mkv = s->priv_data;
- ByteIOContext *pb = url_is_streamed(s->pb) ? mkv->dyn_bc : s->pb;
+ AVIOContext *pb = url_is_streamed(s->pb) ? mkv->dyn_bc : s->pb;
AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
int ret, keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY);
int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts;
@@ -1132,7 +1132,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
static int mkv_write_trailer(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t currentpos, cuespos;
int ret;
@@ -1163,10 +1163,10 @@ static int mkv_write_trailer(AVFormatContext *s)
// update the duration
av_log(s, AV_LOG_DEBUG, "end duration = %" PRIu64 "\n", mkv->duration);
currentpos = url_ftell(pb);
- url_fseek(pb, mkv->duration_offset, SEEK_SET);
+ avio_seek(pb, mkv->duration_offset, SEEK_SET);
put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);
- url_fseek(pb, currentpos, SEEK_SET);
+ avio_seek(pb, currentpos, SEEK_SET);
}
end_ebml_master(pb, mkv->segment);
diff --git a/mplayer/ffmpeg/libavformat/md5enc.c b/mplayer/ffmpeg/libavformat/md5enc.c
index dd2f7c03..065f7e8d 100644
--- a/mplayer/ffmpeg/libavformat/md5enc.c
+++ b/mplayer/ffmpeg/libavformat/md5enc.c
@@ -36,7 +36,7 @@ static void md5_finish(struct AVFormatContext *s, char *buf)
buf[offset] = '\n';
buf[offset+1] = 0;
- put_buffer(s->pb, buf, strlen(buf));
+ avio_write(s->pb, buf, strlen(buf));
put_flush_packet(s->pb);
}
diff --git a/mplayer/ffmpeg/libavformat/mm.c b/mplayer/ffmpeg/libavformat/mm.c
index 475930f8..699daac5 100644
--- a/mplayer/ffmpeg/libavformat/mm.c
+++ b/mplayer/ffmpeg/libavformat/mm.c
@@ -84,25 +84,25 @@ static int read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
MmDemuxContext *mm = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
unsigned int type, length;
unsigned int frame_rate, width, height;
- type = get_le16(pb);
- length = get_le32(pb);
+ type = avio_rl16(pb);
+ length = avio_rl32(pb);
if (type != MM_TYPE_HEADER)
return AVERROR_INVALIDDATA;
/* read header */
- get_le16(pb); /* total number of chunks */
- frame_rate = get_le16(pb);
- get_le16(pb); /* ibm-pc video bios mode */
- width = get_le16(pb);
- height = get_le16(pb);
- url_fseek(pb, length - 10, SEEK_CUR); /* unknown data */
+ avio_rl16(pb); /* total number of chunks */
+ frame_rate = avio_rl16(pb);
+ avio_rl16(pb); /* ibm-pc video bios mode */
+ width = avio_rl16(pb);
+ height = avio_rl16(pb);
+ avio_seek(pb, length - 10, SEEK_CUR); /* unknown data */
/* video stream */
st = av_new_stream(s, 0);
@@ -137,13 +137,13 @@ static int read_packet(AVFormatContext *s,
AVPacket *pkt)
{
MmDemuxContext *mm = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned char preamble[MM_PREAMBLE_SIZE];
unsigned int type, length;
while(1) {
- if (get_buffer(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) {
+ if (avio_read(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) {
return AVERROR(EIO);
}
@@ -162,7 +162,7 @@ static int read_packet(AVFormatContext *s,
if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE))
return AVERROR(ENOMEM);
memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE);
- if (get_buffer(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)
+ if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)
return AVERROR(EIO);
pkt->size = length + MM_PREAMBLE_SIZE;
pkt->stream_index = 0;
@@ -181,7 +181,7 @@ static int read_packet(AVFormatContext *s,
default :
av_log(s, AV_LOG_INFO, "unknown chunk type 0x%x\n", type);
- url_fseek(pb, length, SEEK_CUR);
+ avio_seek(pb, length, SEEK_CUR);
}
}
diff --git a/mplayer/ffmpeg/libavformat/mmf.c b/mplayer/ffmpeg/libavformat/mmf.c
index 2b2af4df..a68870c1 100644
--- a/mplayer/ffmpeg/libavformat/mmf.c
+++ b/mplayer/ffmpeg/libavformat/mmf.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
+#include "avio_internal.h"
#include "pcm.h"
#include "riff.h"
@@ -47,20 +48,20 @@ static int mmf_rate_code(int rate)
}
/* Copy of end_tag() from avienc.c, but for big-endian chunk size */
-static void end_tag_be(ByteIOContext *pb, int64_t start)
+static void end_tag_be(AVIOContext *pb, int64_t start)
{
int64_t pos;
pos = url_ftell(pb);
- url_fseek(pb, start - 4, SEEK_SET);
- put_be32(pb, (uint32_t)(pos - start));
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, start - 4, SEEK_SET);
+ avio_wb32(pb, (uint32_t)(pos - start));
+ avio_seek(pb, pos, SEEK_SET);
}
static int mmf_write_header(AVFormatContext *s)
{
MMFContext *mmf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pos;
int rate;
@@ -70,32 +71,32 @@ static int mmf_write_header(AVFormatContext *s)
return -1;
}
- put_tag(pb, "MMMD");
- put_be32(pb, 0);
+ ffio_wfourcc(pb, "MMMD");
+ avio_wb32(pb, 0);
pos = ff_start_tag(pb, "CNTI");
- put_byte(pb, 0); /* class */
- put_byte(pb, 0); /* type */
- put_byte(pb, 0); /* code type */
- put_byte(pb, 0); /* status */
- put_byte(pb, 0); /* counts */
- put_tag(pb, "VN:libavcodec,"); /* metadata ("ST:songtitle,VN:version,...") */
+ avio_w8(pb, 0); /* class */
+ avio_w8(pb, 0); /* type */
+ avio_w8(pb, 0); /* code type */
+ avio_w8(pb, 0); /* status */
+ avio_w8(pb, 0); /* counts */
+ avio_write(pb, "VN:libavcodec,", sizeof("VN:libavcodec,") -1); /* metadata ("ST:songtitle,VN:version,...") */
end_tag_be(pb, pos);
- put_buffer(pb, "ATR\x00", 4);
- put_be32(pb, 0);
+ avio_write(pb, "ATR\x00", 4);
+ avio_wb32(pb, 0);
mmf->atrpos = url_ftell(pb);
- put_byte(pb, 0); /* format type */
- put_byte(pb, 0); /* sequence type */
- put_byte(pb, (0 << 7) | (1 << 4) | rate); /* (channel << 7) | (format << 4) | rate */
- put_byte(pb, 0); /* wave base bit */
- put_byte(pb, 2); /* time base d */
- put_byte(pb, 2); /* time base g */
-
- put_tag(pb, "Atsq");
- put_be32(pb, 16);
+ avio_w8(pb, 0); /* format type */
+ avio_w8(pb, 0); /* sequence type */
+ avio_w8(pb, (0 << 7) | (1 << 4) | rate); /* (channel << 7) | (format << 4) | rate */
+ avio_w8(pb, 0); /* wave base bit */
+ avio_w8(pb, 2); /* time base d */
+ avio_w8(pb, 2); /* time base g */
+
+ ffio_wfourcc(pb, "Atsq");
+ avio_wb32(pb, 16);
mmf->atsqpos = url_ftell(pb);
/* Will be filled on close */
- put_buffer(pb, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 16);
+ avio_write(pb, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 16);
mmf->awapos = ff_start_tag(pb, "Awa\x01");
@@ -108,26 +109,26 @@ static int mmf_write_header(AVFormatContext *s)
static int mmf_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
- put_buffer(pb, pkt->data, pkt->size);
+ AVIOContext *pb = s->pb;
+ avio_write(pb, pkt->data, pkt->size);
return 0;
}
/* Write a variable-length symbol */
-static void put_varlength(ByteIOContext *pb, int val)
+static void put_varlength(AVIOContext *pb, int val)
{
if(val < 128)
- put_byte(pb, val);
+ avio_w8(pb, val);
else {
val -= 128;
- put_byte(pb, 0x80 | val >> 7);
- put_byte(pb, 0x7f & val);
+ avio_w8(pb, 0x80 | val >> 7);
+ avio_w8(pb, 0x7f & val);
}
}
static int mmf_write_trailer(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
MMFContext *mmf = s->priv_data;
int64_t pos, size;
int gatetime;
@@ -142,22 +143,22 @@ static int mmf_write_trailer(AVFormatContext *s)
size = pos - mmf->awapos;
/* Fill Atsq chunk */
- url_fseek(pb, mmf->atsqpos, SEEK_SET);
+ avio_seek(pb, mmf->atsqpos, SEEK_SET);
/* "play wav" */
- put_byte(pb, 0); /* start time */
- put_byte(pb, 1); /* (channel << 6) | wavenum */
+ avio_w8(pb, 0); /* start time */
+ avio_w8(pb, 1); /* (channel << 6) | wavenum */
gatetime = size * 500 / s->streams[0]->codec->sample_rate;
put_varlength(pb, gatetime); /* duration */
/* "nop" */
put_varlength(pb, gatetime); /* start time */
- put_buffer(pb, "\xff\x00", 2); /* nop */
+ avio_write(pb, "\xff\x00", 2); /* nop */
/* "end of sequence" */
- put_buffer(pb, "\x00\x00\x00\x00", 4);
+ avio_write(pb, "\x00\x00\x00\x00", 4);
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, pos, SEEK_SET);
put_flush_packet(pb);
}
@@ -183,20 +184,20 @@ static int mmf_read_header(AVFormatContext *s,
{
MMFContext *mmf = s->priv_data;
unsigned int tag;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
int64_t file_size, size;
int rate, params;
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('M', 'M', 'M', 'D'))
return -1;
- file_size = get_be32(pb);
+ file_size = avio_rb32(pb);
/* Skip some unused chunks that may or may not be present */
- for(;; url_fseek(pb, size, SEEK_CUR)) {
- tag = get_le32(pb);
- size = get_be32(pb);
+ for(;; avio_seek(pb, size, SEEK_CUR)) {
+ tag = avio_rl32(pb);
+ size = avio_rb32(pb);
if(tag == MKTAG('C','N','T','I')) continue;
if(tag == MKTAG('O','P','D','A')) continue;
break;
@@ -212,22 +213,22 @@ static int mmf_read_header(AVFormatContext *s,
return -1;
}
- get_byte(pb); /* format type */
- get_byte(pb); /* sequence type */
- params = get_byte(pb); /* (channel << 7) | (format << 4) | rate */
+ avio_r8(pb); /* format type */
+ avio_r8(pb); /* sequence type */
+ params = avio_r8(pb); /* (channel << 7) | (format << 4) | rate */
rate = mmf_rate(params & 0x0f);
if(rate < 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate\n");
return -1;
}
- get_byte(pb); /* wave base bit */
- get_byte(pb); /* time base d */
- get_byte(pb); /* time base g */
+ avio_r8(pb); /* wave base bit */
+ avio_r8(pb); /* time base d */
+ avio_r8(pb); /* time base g */
/* Skip some unused chunks that may or may not be present */
- for(;; url_fseek(pb, size, SEEK_CUR)) {
- tag = get_le32(pb);
- size = get_be32(pb);
+ for(;; avio_seek(pb, size, SEEK_CUR)) {
+ tag = avio_rl32(pb);
+ size = avio_rb32(pb);
if(tag == MKTAG('A','t','s','q')) continue;
if(tag == MKTAG('A','s','p','I')) continue;
break;
@@ -280,7 +281,7 @@ static int mmf_read_packet(AVFormatContext *s,
return AVERROR(EIO);
pkt->stream_index = 0;
- ret = get_buffer(s->pb, pkt->data, pkt->size);
+ ret = avio_read(s->pb, pkt->data, pkt->size);
if (ret < 0)
av_free_packet(pkt);
diff --git a/mplayer/ffmpeg/libavformat/mms.c b/mplayer/ffmpeg/libavformat/mms.c
index d995a43a..b541208e 100644
--- a/mplayer/ffmpeg/libavformat/mms.c
+++ b/mplayer/ffmpeg/libavformat/mms.c
@@ -115,6 +115,34 @@ int ff_mms_asf_header_parser(MMSContext *mms)
"Corrupt stream (too many A/V streams)\n");
return AVERROR_INVALIDDATA;
}
+ } else if (!memcmp(p, ff_asf_ext_stream_header, sizeof(ff_asf_guid))) {
+ if (end - p >= 88) {
+ int stream_count = AV_RL16(p + 84), ext_len_count = AV_RL16(p + 86);
+ uint64_t skip_bytes = 88;
+ while (stream_count--) {
+ if (end - p < skip_bytes + 4) {
+ av_log(NULL, AV_LOG_ERROR,
+ "Corrupt stream (next stream name length is not in the buffer)\n");
+ return AVERROR_INVALIDDATA;
+ }
+ skip_bytes += 4 + AV_RL16(p + skip_bytes + 2);
+ }
+ while (ext_len_count--) {
+ if (end - p < skip_bytes + 22) {
+ av_log(NULL, AV_LOG_ERROR,
+ "Corrupt stream (next extension system info length is not in the buffer)\n");
+ return AVERROR_INVALIDDATA;
+ }
+ skip_bytes += 22 + AV_RL32(p + skip_bytes + 18);
+ }
+ if (end - p < skip_bytes) {
+ av_log(NULL, AV_LOG_ERROR,
+ "Corrupt stream (the last extension system info length is invalid)\n");
+ return AVERROR_INVALIDDATA;
+ }
+ if (chunksize - skip_bytes > 24)
+ chunksize = skip_bytes;
+ }
} else if (!memcmp(p, ff_asf_head1_guid, sizeof(ff_asf_guid))) {
chunksize = 46; // see references [2] section 3.4. This should be set 46.
}
diff --git a/mplayer/ffmpeg/libavformat/mmst.c b/mplayer/ffmpeg/libavformat/mmst.c
index 8464d3b3..e3af4bfb 100644
--- a/mplayer/ffmpeg/libavformat/mmst.c
+++ b/mplayer/ffmpeg/libavformat/mmst.c
@@ -31,6 +31,7 @@
#include "avformat.h"
#include "mms.h"
#include "internal.h"
+#include "avio_internal.h"
#include "libavutil/intreadwrite.h"
#include "libavcodec/bytestream.h"
#include "network.h"
@@ -152,10 +153,10 @@ static int send_command_packet(MMSTContext *mmst)
static void mms_put_utf16(MMSContext *mms, uint8_t *src)
{
- ByteIOContext bic;
+ AVIOContext bic;
int size = mms->write_out_ptr - mms->out_buffer;
int len;
- init_put_byte(&bic, mms->write_out_ptr,
+ ffio_init_context(&bic, mms->write_out_ptr,
sizeof(mms->out_buffer) - size, 1, NULL, NULL, NULL, NULL);
len = avio_put_str16le(&bic, src);
@@ -290,10 +291,9 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
return read_result < 0 ? read_result : AVERROR_IO;
}
packet_type= AV_RL16(mms->in_buffer+36);
- hr = AV_RL32(mms->in_buffer + 40);
- if (hr) {
+ if (read_result >= 44 && (hr = AV_RL32(mms->in_buffer + 40))) {
av_log(NULL, AV_LOG_ERROR,
- "Server sent an error status code: 0x%08x\n", hr);
+ "Server sent a message with packet type 0x%x and error status code 0x%08x\n", packet_type, hr);
return AVERROR_UNKNOWN;
}
} else {
diff --git a/mplayer/ffmpeg/libavformat/mov.c b/mplayer/ffmpeg/libavformat/mov.c
index a48000fe..537b9c6f 100644
--- a/mplayer/ffmpeg/libavformat/mov.c
+++ b/mplayer/ffmpeg/libavformat/mov.c
@@ -29,6 +29,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/avstring.h"
#include "avformat.h"
+#include "avio_internal.h"
#include "riff.h"
#include "isom.h"
#include "libavcodec/get_bits.h"
@@ -73,20 +74,20 @@
/* links atom IDs to parse functions */
typedef struct MOVParseTableEntry {
uint32_t type;
- int (*parse)(MOVContext *ctx, ByteIOContext *pb, MOVAtom atom);
+ int (*parse)(MOVContext *ctx, AVIOContext *pb, MOVAtom atom);
} MOVParseTableEntry;
static const MOVParseTableEntry mov_default_parse_table[];
-static int mov_metadata_trkn(MOVContext *c, ByteIOContext *pb, unsigned len)
+static int mov_metadata_trkn(MOVContext *c, AVIOContext *pb, unsigned len)
{
char buf[16];
- get_be16(pb); // unknown
- snprintf(buf, sizeof(buf), "%d", get_be16(pb));
+ avio_rb16(pb); // unknown
+ snprintf(buf, sizeof(buf), "%d", avio_rb16(pb));
av_metadata_set2(&c->fc->metadata, "track", buf, 0);
- get_be16(pb); // total tracks
+ avio_rb16(pb); // total tracks
return 0;
}
@@ -110,7 +111,7 @@ static const uint32_t mac_to_unicode[128] = {
0x00AF,0x02D8,0x02D9,0x02DA,0x00B8,0x02DD,0x02DB,0x02C7,
};
-static int mov_read_mac_string(MOVContext *c, ByteIOContext *pb, int len,
+static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len,
char *dst, int dstlen)
{
char *p = dst;
@@ -118,7 +119,7 @@ static int mov_read_mac_string(MOVContext *c, ByteIOContext *pb, int len,
int i;
for (i = 0; i < len; i++) {
- uint8_t t, c = get_byte(pb);
+ uint8_t t, c = avio_r8(pb);
if (c < 0x80 && p < end)
*p++ = c;
else
@@ -128,7 +129,7 @@ static int mov_read_mac_string(MOVContext *c, ByteIOContext *pb, int len,
return p - dst;
}
-static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
#ifdef MOV_EXPORT_ALL_METADATA
char tmp_key[5];
@@ -137,7 +138,7 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
const char *key = NULL;
uint16_t str_size, langcode = 0;
uint32_t data_type = 0;
- int (*parse)(MOVContext*, ByteIOContext*, unsigned) = NULL;
+ int (*parse)(MOVContext*, AVIOContext*, unsigned) = NULL;
switch (atom.type) {
case MKTAG(0xa9,'n','a','m'): key = "title"; break;
@@ -164,17 +165,17 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
}
if (c->itunes_metadata && atom.size > 8) {
- int data_size = get_be32(pb);
- int tag = get_le32(pb);
+ int data_size = avio_rb32(pb);
+ int tag = avio_rl32(pb);
if (tag == MKTAG('d','a','t','a')) {
- data_type = get_be32(pb); // type
- get_be32(pb); // unknown
+ data_type = avio_rb32(pb); // type
+ avio_rb32(pb); // unknown
str_size = data_size - 16;
atom.size -= 16;
} else return 0;
} else if (atom.size > 4 && key && !c->itunes_metadata) {
- str_size = get_be16(pb); // string length
- langcode = get_be16(pb);
+ str_size = avio_rb16(pb); // string length
+ langcode = avio_rb16(pb);
ff_mov_lang_to_iso639(langcode, language);
atom.size -= 4;
} else
@@ -200,7 +201,7 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
if (data_type == 3 || (data_type == 0 && langcode < 0x800)) { // MAC Encoded
mov_read_mac_string(c, pb, str_size, str, sizeof(str));
} else {
- get_buffer(pb, str, str_size);
+ avio_read(pb, str, str_size);
str[str_size] = 0;
}
av_metadata_set2(&c->fc->metadata, key, str, 0);
@@ -218,7 +219,7 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0;
}
-static int mov_read_chpl(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_chpl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int64_t start;
int i, nb_chapters, str_len, version;
@@ -227,30 +228,30 @@ static int mov_read_chpl(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
if ((atom.size -= 5) < 0)
return 0;
- version = get_byte(pb);
- get_be24(pb);
+ version = avio_r8(pb);
+ avio_rb24(pb);
if (version)
- get_be32(pb); // ???
- nb_chapters = get_byte(pb);
+ avio_rb32(pb); // ???
+ nb_chapters = avio_r8(pb);
for (i = 0; i < nb_chapters; i++) {
if (atom.size < 9)
return 0;
- start = get_be64(pb);
- str_len = get_byte(pb);
+ start = avio_rb64(pb);
+ str_len = avio_r8(pb);
if ((atom.size -= 9+str_len) < 0)
return 0;
- get_buffer(pb, str, str_len);
+ avio_read(pb, str, str_len);
str[str_len] = 0;
ff_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str);
}
return 0;
}
-static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int64_t total_size = 0;
MOVAtom a;
@@ -259,18 +260,18 @@ static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
if (atom.size < 0)
atom.size = INT64_MAX;
while (total_size + 8 < atom.size && !url_feof(pb)) {
- int (*parse)(MOVContext*, ByteIOContext*, MOVAtom) = NULL;
+ int (*parse)(MOVContext*, AVIOContext*, MOVAtom) = NULL;
a.size = atom.size;
a.type=0;
if(atom.size >= 8) {
- a.size = get_be32(pb);
- a.type = get_le32(pb);
+ a.size = avio_rb32(pb);
+ a.type = avio_rl32(pb);
}
av_dlog(c->fc, "type: %08x '%.4s' parent:'%.4s' sz: %"PRId64" %"PRId64" %"PRId64"\n",
a.type, (char*)&a.type, (char*)&atom.type, a.size, total_size, atom.size);
total_size += 8;
if (a.size == 1) { /* 64 bit extended size */
- a.size = get_be64(pb) - 8;
+ a.size = avio_rb64(pb) - 8;
total_size += 8;
}
if (a.size == 0) {
@@ -295,7 +296,7 @@ static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
parse = mov_read_udta_string;
if (!parse) { /* skip leaf atoms data */
- url_fskip(pb, a.size);
+ avio_seek(pb, a.size, SEEK_CUR);
} else {
int64_t start_pos = url_ftell(pb);
int64_t left;
@@ -307,19 +308,19 @@ static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0;
left = a.size - url_ftell(pb) + start_pos;
if (left > 0) /* skip garbage at atom end */
- url_fskip(pb, left);
+ avio_seek(pb, left, SEEK_CUR);
}
total_size += a.size;
}
if (total_size < atom.size && atom.size < 0x7ffff)
- url_fskip(pb, atom.size - total_size);
+ avio_seek(pb, atom.size - total_size, SEEK_CUR);
return 0;
}
-static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
@@ -330,8 +331,8 @@ static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_be32(pb); // version + flags
- entries = get_be32(pb);
+ avio_rb32(pb); // version + flags
+ entries = avio_rb32(pb);
if (entries >= UINT_MAX / sizeof(*sc->drefs))
return -1;
sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));
@@ -341,14 +342,14 @@ static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
for (i = 0; i < sc->drefs_count; i++) {
MOVDref *dref = &sc->drefs[i];
- uint32_t size = get_be32(pb);
+ uint32_t size = avio_rb32(pb);
int64_t next = url_ftell(pb) + size - 4;
if (size < 12)
return -1;
- dref->type = get_le32(pb);
- get_be32(pb); // version + flags
+ dref->type = avio_rl32(pb);
+ avio_rb32(pb); // version + flags
av_dlog(c->fc, "type %.4s size %d\n", (char*)&dref->type, size);
if (dref->type == MKTAG('a','l','i','s') && size > 150) {
@@ -356,35 +357,35 @@ static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
uint16_t volume_len, len;
int16_t type;
- url_fskip(pb, 10);
+ avio_seek(pb, 10, SEEK_CUR);
- volume_len = get_byte(pb);
+ volume_len = avio_r8(pb);
volume_len = FFMIN(volume_len, 27);
- get_buffer(pb, dref->volume, 27);
+ avio_read(pb, dref->volume, 27);
dref->volume[volume_len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "volume %s, len %d\n", dref->volume, volume_len);
- url_fskip(pb, 12);
+ avio_seek(pb, 12, SEEK_CUR);
- len = get_byte(pb);
+ len = avio_r8(pb);
len = FFMIN(len, 63);
- get_buffer(pb, dref->filename, 63);
+ avio_read(pb, dref->filename, 63);
dref->filename[len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "filename %s, len %d\n", dref->filename, len);
- url_fskip(pb, 16);
+ avio_seek(pb, 16, SEEK_CUR);
/* read next level up_from_alias/down_to_target */
- dref->nlvl_from = get_be16(pb);
- dref->nlvl_to = get_be16(pb);
+ dref->nlvl_from = avio_rb16(pb);
+ dref->nlvl_to = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "nlvl from %d, nlvl to %d\n",
dref->nlvl_from, dref->nlvl_to);
- url_fskip(pb, 16);
+ avio_seek(pb, 16, SEEK_CUR);
for (type = 0; type != -1 && url_ftell(pb) < next; ) {
- type = get_be16(pb);
- len = get_be16(pb);
+ type = avio_rb16(pb);
+ len = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);
if (len&1)
len += 1;
@@ -393,7 +394,7 @@ static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
dref->path = av_mallocz(len+1);
if (!dref->path)
return AVERROR(ENOMEM);
- get_buffer(pb, dref->path, len);
+ avio_read(pb, dref->path, len);
if (len > volume_len && !strncmp(dref->path, dref->volume, volume_len)) {
len -= volume_len;
memmove(dref->path, dref->path+volume_len, len);
@@ -408,22 +409,22 @@ static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
dref->dir = av_malloc(len+1);
if (!dref->dir)
return AVERROR(ENOMEM);
- get_buffer(pb, dref->dir, len);
+ avio_read(pb, dref->dir, len);
dref->dir[len] = 0;
for (j = 0; j < len; j++)
if (dref->dir[j] == ':')
dref->dir[j] = '/';
av_log(c->fc, AV_LOG_DEBUG, "dir %s\n", dref->dir);
} else
- url_fskip(pb, len);
+ avio_seek(pb, len, SEEK_CUR);
}
}
- url_fseek(pb, next, SEEK_SET);
+ avio_seek(pb, next, SEEK_SET);
}
return 0;
}
-static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
uint32_t type;
@@ -434,12 +435,12 @@ static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
/* component type */
- ctype = get_le32(pb);
- type = get_le32(pb); /* component subtype */
+ ctype = avio_rl32(pb);
+ type = avio_rl32(pb); /* component subtype */
av_dlog(c->fc, "ctype= %.4s (0x%08x)\n", (char*)&ctype, ctype);
av_dlog(c->fc, "stype= %.4s\n", (char*)&type);
@@ -453,14 +454,14 @@ static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
else if(type == MKTAG('s','u','b','p'))
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- get_be32(pb); /* component manufacture */
- get_be32(pb); /* component flags */
- get_be32(pb); /* component flags mask */
+ avio_rb32(pb); /* component manufacture */
+ avio_rb32(pb); /* component flags */
+ avio_rb32(pb); /* component flags mask */
return 0;
}
-int ff_mov_read_esds(AVFormatContext *fc, ByteIOContext *pb, MOVAtom atom)
+int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
int tag, len;
@@ -469,13 +470,13 @@ int ff_mov_read_esds(AVFormatContext *fc, ByteIOContext *pb, MOVAtom atom)
return 0;
st = fc->streams[fc->nb_streams-1];
- get_be32(pb); /* version + flags */
+ avio_rb32(pb); /* version + flags */
len = ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4ESDescrTag) {
- get_be16(pb); /* ID */
- get_byte(pb); /* priority */
+ avio_rb16(pb); /* ID */
+ avio_r8(pb); /* priority */
} else
- get_be16(pb); /* ID */
+ avio_rb16(pb); /* ID */
len = ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecConfigDescrTag)
@@ -483,12 +484,12 @@ int ff_mov_read_esds(AVFormatContext *fc, ByteIOContext *pb, MOVAtom atom)
return 0;
}
-static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_esds(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
return ff_mov_read_esds(c->fc, pb, atom);
}
-static int mov_read_dac3(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
int ac3info, acmod, lfeon;
@@ -497,7 +498,7 @@ static int mov_read_dac3(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
- ac3info = get_be24(pb);
+ ac3info = avio_rb24(pb);
acmod = (ac3info >> 11) & 0x7;
lfeon = (ac3info >> 10) & 0x1;
st->codec->channels = ((int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
@@ -505,10 +506,10 @@ static int mov_read_dac3(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0;
}
-static int mov_read_pasp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
- const int num = get_be32(pb);
- const int den = get_be32(pb);
+ const int num = avio_rb32(pb);
+ const int den = avio_rb32(pb);
AVStream *st;
if (c->fc->nb_streams < 1)
@@ -529,7 +530,7 @@ static int mov_read_pasp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
}
/* this atom contains actual media data */
-static int mov_read_mdat(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_mdat(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
if(atom.size == 0) /* wrong one (MP4) */
return 0;
@@ -538,7 +539,7 @@ static int mov_read_mdat(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
}
/* read major brand, minor version and compatible brands and store them as metadata */
-static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
uint32_t minor_ver;
int comp_brand_size;
@@ -546,12 +547,12 @@ static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
char* comp_brands_str;
uint8_t type[5] = {0};
- get_buffer(pb, type, 4);
+ avio_read(pb, type, 4);
if (strcmp(type, "qt "))
c->isom = 1;
av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type);
av_metadata_set2(&c->fc->metadata, "major_brand", type, 0);
- minor_ver = get_be32(pb); /* minor version */
+ minor_ver = avio_rb32(pb); /* minor version */
snprintf(minor_ver_str, sizeof(minor_ver_str), "%d", minor_ver);
av_metadata_set2(&c->fc->metadata, "minor_version", minor_ver_str, 0);
@@ -561,7 +562,7 @@ static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
comp_brands_str = av_malloc(comp_brand_size + 1); /* Add null terminator */
if (!comp_brands_str)
return AVERROR(ENOMEM);
- get_buffer(pb, comp_brands_str, comp_brand_size);
+ avio_read(pb, comp_brands_str, comp_brand_size);
comp_brands_str[comp_brand_size] = 0;
av_metadata_set2(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
av_freep(&comp_brands_str);
@@ -570,7 +571,7 @@ static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
}
/* this atom should contain all header atoms */
-static int mov_read_moov(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_moov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
if (mov_read_default(c, pb, atom) < 0)
return -1;
@@ -580,7 +581,7 @@ static int mov_read_moov(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0; /* now go for mdat */
}
-static int mov_read_moof(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
c->fragment.moof_offset = url_ftell(pb) - 8;
av_dlog(c->fc, "moof offset %llx\n", c->fragment.moof_offset);
@@ -600,7 +601,7 @@ static void mov_metadata_creation_time(AVMetadata **metadata, time_t time)
}
}
-static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
@@ -614,70 +615,70 @@ static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- version = get_byte(pb);
+ version = avio_r8(pb);
if (version > 1)
return -1; /* unsupported */
- get_be24(pb); /* flags */
+ avio_rb24(pb); /* flags */
if (version == 1) {
- creation_time = get_be64(pb);
- get_be64(pb);
+ creation_time = avio_rb64(pb);
+ avio_rb64(pb);
} else {
- creation_time = get_be32(pb);
- get_be32(pb); /* modification time */
+ creation_time = avio_rb32(pb);
+ avio_rb32(pb); /* modification time */
}
mov_metadata_creation_time(&st->metadata, creation_time);
- sc->time_scale = get_be32(pb);
- st->duration = (version == 1) ? get_be64(pb) : get_be32(pb); /* duration */
+ sc->time_scale = avio_rb32(pb);
+ st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
- lang = get_be16(pb); /* language */
+ lang = avio_rb16(pb); /* language */
if (ff_mov_lang_to_iso639(lang, language))
av_metadata_set2(&st->metadata, "language", language, 0);
- get_be16(pb); /* quality */
+ avio_rb16(pb); /* quality */
return 0;
}
-static int mov_read_mvhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
time_t creation_time;
- int version = get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ int version = avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
if (version == 1) {
- creation_time = get_be64(pb);
- get_be64(pb);
+ creation_time = avio_rb64(pb);
+ avio_rb64(pb);
} else {
- creation_time = get_be32(pb);
- get_be32(pb); /* modification time */
+ creation_time = avio_rb32(pb);
+ avio_rb32(pb); /* modification time */
}
mov_metadata_creation_time(&c->fc->metadata, creation_time);
- c->time_scale = get_be32(pb); /* time scale */
+ c->time_scale = avio_rb32(pb); /* time scale */
av_dlog(c->fc, "time scale = %i\n", c->time_scale);
- c->duration = (version == 1) ? get_be64(pb) : get_be32(pb); /* duration */
- get_be32(pb); /* preferred scale */
+ c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
+ avio_rb32(pb); /* preferred scale */
- get_be16(pb); /* preferred volume */
+ avio_rb16(pb); /* preferred volume */
- url_fskip(pb, 10); /* reserved */
+ avio_seek(pb, 10, SEEK_CUR); /* reserved */
- url_fskip(pb, 36); /* display matrix */
+ avio_seek(pb, 36, SEEK_CUR); /* display matrix */
- get_be32(pb); /* preview time */
- get_be32(pb); /* preview duration */
- get_be32(pb); /* poster time */
- get_be32(pb); /* selection time */
- get_be32(pb); /* selection duration */
- get_be32(pb); /* current time */
- get_be32(pb); /* next track ID */
+ avio_rb32(pb); /* preview time */
+ avio_rb32(pb); /* preview duration */
+ avio_rb32(pb); /* poster time */
+ avio_rb32(pb); /* selection time */
+ avio_rb32(pb); /* selection duration */
+ avio_rb32(pb); /* current time */
+ avio_rb32(pb); /* next track ID */
return 0;
}
-static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_smi(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
@@ -696,12 +697,12 @@ static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return AVERROR(ENOMEM);
st->codec->extradata_size = 0x5a + atom.size;
memcpy(st->codec->extradata, "SVQ3", 4); // fake
- get_buffer(pb, st->codec->extradata + 0x5a, atom.size);
+ avio_read(pb, st->codec->extradata + 0x5a, atom.size);
av_dlog(c->fc, "Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a);
return 0;
}
-static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
int little_endian;
@@ -710,7 +711,7 @@ static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
- little_endian = get_be16(pb);
+ little_endian = avio_rb16(pb);
av_dlog(c->fc, "enda %d\n", little_endian);
if (little_endian == 1) {
switch (st->codec->codec_id) {
@@ -734,7 +735,7 @@ static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
}
/* FIXME modify qdm2/svq3/h264 decoders to take full atom as extradata */
-static int mov_read_extradata(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
uint64_t size;
@@ -754,11 +755,11 @@ static int mov_read_extradata(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE;
AV_WB32( buf , atom.size + 8);
AV_WL32( buf + 4, atom.type);
- get_buffer(pb, buf + 8, atom.size);
+ avio_read(pb, buf + 8, atom.size);
return 0;
}
-static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
@@ -769,19 +770,19 @@ static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
if((uint64_t)atom.size > (1<<30))
return -1;
- if (st->codec->codec_id == CODEC_ID_QDM2) {
- // pass all frma atom to codec, needed at least for QDM2
+ if (st->codec->codec_id == CODEC_ID_QDM2 || st->codec->codec_id == CODEC_ID_QDMC) {
+ // pass all frma atom to codec, needed at least for QDMC and QDM2
av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size;
- get_buffer(pb, st->codec->extradata, atom.size);
+ avio_read(pb, st->codec->extradata, atom.size);
} else if (atom.size > 8) { /* to read frma, esds atoms */
if (mov_read_default(c, pb, atom) < 0)
return -1;
} else
- url_fskip(pb, atom.size);
+ avio_seek(pb, atom.size, SEEK_CUR);
return 0;
}
@@ -789,7 +790,7 @@ static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
* This function reads atom content and puts data in extradata without tag
* nor size unlike mov_read_extradata.
*/
-static int mov_read_glbl(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
@@ -805,7 +806,7 @@ static int mov_read_glbl(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size;
- get_buffer(pb, st->codec->extradata, atom.size);
+ avio_read(pb, st->codec->extradata, atom.size);
return 0;
}
@@ -814,7 +815,7 @@ static int mov_read_glbl(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
* but can have extradata appended at the end after the 40 bytes belonging
* to the struct.
*/
-static int mov_read_strf(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
@@ -832,12 +833,12 @@ static int mov_read_strf(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size - 40;
- url_fskip(pb, 40);
- get_buffer(pb, st->codec->extradata, atom.size - 40);
+ avio_seek(pb, 40, SEEK_CUR);
+ avio_read(pb, st->codec->extradata, atom.size - 40);
return 0;
}
-static int mov_read_stco(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
@@ -848,10 +849,10 @@ static int mov_read_stco(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
if(entries >= UINT_MAX/sizeof(int64_t))
return -1;
@@ -863,10 +864,10 @@ static int mov_read_stco(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
if (atom.type == MKTAG('s','t','c','o'))
for(i=0; ichunk_offsets[i] = get_be32(pb);
+ sc->chunk_offsets[i] = avio_rb32(pb);
else if (atom.type == MKTAG('c','o','6','4'))
for(i=0; ichunk_offsets[i] = get_be64(pb);
+ sc->chunk_offsets[i] = avio_rb64(pb);
else
return -1;
@@ -908,7 +909,7 @@ enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags)
return CODEC_ID_NONE;
}
-int ff_mov_read_stsd_entries(MOVContext *c, ByteIOContext *pb, int entries)
+int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
{
AVStream *st;
MOVStreamContext *sc;
@@ -925,13 +926,13 @@ int ff_mov_read_stsd_entries(MOVContext *c, ByteIOContext *pb, int entries)
int dref_id = 1;
MOVAtom a = { AV_RL32("stsd") };
int64_t start_pos = url_ftell(pb);
- int size = get_be32(pb); /* size */
- uint32_t format = get_le32(pb); /* data format */
+ int size = avio_rb32(pb); /* size */
+ uint32_t format = avio_rl32(pb); /* data format */
if (size >= 16) {
- get_be32(pb); /* reserved */
- get_be16(pb); /* reserved */
- dref_id = get_be16(pb);
+ avio_rb32(pb); /* reserved */
+ avio_rb16(pb); /* reserved */
+ dref_id = avio_rb16(pb);
}
if (st->codec->codec_tag &&
@@ -944,7 +945,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, ByteIOContext *pb, int entries)
* in the MOV demuxer, patch welcome. */
multiple_stsd:
av_log(c->fc, AV_LOG_WARNING, "multiple fourcc not supported\n");
- url_fskip(pb, size - (url_ftell(pb) - start_pos));
+ avio_seek(pb, size - (url_ftell(pb) - start_pos), SEEK_CUR);
continue;
}
/* we cannot demux concatenated h264 streams because of different extradata */
@@ -983,32 +984,32 @@ int ff_mov_read_stsd_entries(MOVContext *c, ByteIOContext *pb, int entries)
int color_greyscale;
st->codec->codec_id = id;
- get_be16(pb); /* version */
- get_be16(pb); /* revision level */
- get_be32(pb); /* vendor */
- get_be32(pb); /* temporal quality */
- get_be32(pb); /* spatial quality */
+ avio_rb16(pb); /* version */
+ avio_rb16(pb); /* revision level */
+ avio_rb32(pb); /* vendor */
+ avio_rb32(pb); /* temporal quality */
+ avio_rb32(pb); /* spatial quality */
- st->codec->width = get_be16(pb); /* width */
- st->codec->height = get_be16(pb); /* height */
+ st->codec->width = avio_rb16(pb); /* width */
+ st->codec->height = avio_rb16(pb); /* height */
- get_be32(pb); /* horiz resolution */
- get_be32(pb); /* vert resolution */
- get_be32(pb); /* data size, always 0 */
- get_be16(pb); /* frames per samples */
+ avio_rb32(pb); /* horiz resolution */
+ avio_rb32(pb); /* vert resolution */
+ avio_rb32(pb); /* data size, always 0 */
+ avio_rb16(pb); /* frames per samples */
- len = get_byte(pb); /* codec name, pascal string */
+ len = avio_r8(pb); /* codec name, pascal string */
if (len > 31)
len = 31;
mov_read_mac_string(c, pb, len, st->codec->codec_name, 32);
if (len < 31)
- url_fskip(pb, 31 - len);
+ avio_seek(pb, 31 - len, SEEK_CUR);
/* codec_tag YV12 triggers an UV swap in rawdec.c */
if (!memcmp(st->codec->codec_name, "Planar Y'CbCr 8-bit 4:2:0", 25))
st->codec->codec_tag=MKTAG('I', '4', '2', '0');
- st->codec->bits_per_coded_sample = get_be16(pb); /* depth */
- st->codec->color_table_id = get_be16(pb); /* colortable id */
+ st->codec->bits_per_coded_sample = avio_rb16(pb); /* depth */
+ st->codec->color_table_id = avio_rb16(pb); /* colortable id */
av_dlog(c->fc, "depth %d, ctab id %d\n",
st->codec->bits_per_coded_sample, st->codec->color_table_id);
/* figure out the palette situation */
@@ -1058,23 +1059,23 @@ int ff_mov_read_stsd_entries(MOVContext *c, ByteIOContext *pb, int entries)
}
} else {
/* load the palette from the file */
- color_start = get_be32(pb);
- color_count = get_be16(pb);
- color_end = get_be16(pb);
+ color_start = avio_rb32(pb);
+ color_count = avio_rb16(pb);
+ color_end = avio_rb16(pb);
if ((color_start <= 255) &&
(color_end <= 255)) {
for (j = color_start; j <= color_end; j++) {
/* each R, G, or B component is 16 bits;
* only use the top 8 bits; skip alpha bytes
* up front */
- get_byte(pb);
- get_byte(pb);
- r = get_byte(pb);
- get_byte(pb);
- g = get_byte(pb);
- get_byte(pb);
- b = get_byte(pb);
- get_byte(pb);
+ avio_r8(pb);
+ avio_r8(pb);
+ r = avio_r8(pb);
+ avio_r8(pb);
+ g = avio_r8(pb);
+ avio_r8(pb);
+ b = avio_r8(pb);
+ avio_r8(pb);
st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b);
}
@@ -1084,38 +1085,38 @@ int ff_mov_read_stsd_entries(MOVContext *c, ByteIOContext *pb, int entries)
}
} else if(st->codec->codec_type==AVMEDIA_TYPE_AUDIO) {
int bits_per_sample, flags;
- uint16_t version = get_be16(pb);
+ uint16_t version = avio_rb16(pb);
st->codec->codec_id = id;
- get_be16(pb); /* revision level */
- get_be32(pb); /* vendor */
+ avio_rb16(pb); /* revision level */
+ avio_rb32(pb); /* vendor */
- st->codec->channels = get_be16(pb); /* channel count */
+ st->codec->channels = avio_rb16(pb); /* channel count */
av_dlog(c->fc, "audio channels %d\n", st->codec->channels);
- st->codec->bits_per_coded_sample = get_be16(pb); /* sample size */
+ st->codec->bits_per_coded_sample = avio_rb16(pb); /* sample size */
- sc->audio_cid = get_be16(pb);
- get_be16(pb); /* packet size = 0 */
+ sc->audio_cid = avio_rb16(pb);
+ avio_rb16(pb); /* packet size = 0 */
- st->codec->sample_rate = ((get_be32(pb) >> 16));
+ st->codec->sample_rate = ((avio_rb32(pb) >> 16));
//Read QT version 1 fields. In version 0 these do not exist.
av_dlog(c->fc, "version =%d, isom =%d\n",version,c->isom);
if(!c->isom) {
if(version==1) {
- sc->samples_per_frame = get_be32(pb);
- get_be32(pb); /* bytes per packet */
- sc->bytes_per_frame = get_be32(pb);
- get_be32(pb); /* bytes per sample */
+ sc->samples_per_frame = avio_rb32(pb);
+ avio_rb32(pb); /* bytes per packet */
+ sc->bytes_per_frame = avio_rb32(pb);
+ avio_rb32(pb); /* bytes per sample */
} else if(version==2) {
- get_be32(pb); /* sizeof struct only */
- st->codec->sample_rate = av_int2dbl(get_be64(pb)); /* float 64 */
- st->codec->channels = get_be32(pb);
- get_be32(pb); /* always 0x7F000000 */
- st->codec->bits_per_coded_sample = get_be32(pb); /* bits per channel if sound is uncompressed */
- flags = get_be32(pb); /* lpcm format specific flag */
- sc->bytes_per_frame = get_be32(pb); /* bytes per audio packet if constant */
- sc->samples_per_frame = get_be32(pb); /* lpcm frames per audio packet if constant */
+ avio_rb32(pb); /* sizeof struct only */
+ st->codec->sample_rate = av_int2dbl(avio_rb64(pb)); /* float 64 */
+ st->codec->channels = avio_rb32(pb);
+ avio_rb32(pb); /* always 0x7F000000 */
+ st->codec->bits_per_coded_sample = avio_rb32(pb); /* bits per channel if sound is uncompressed */
+ flags = avio_rb32(pb); /* lpcm format specific flag */
+ sc->bytes_per_frame = avio_rb32(pb); /* bytes per audio packet if constant */
+ sc->samples_per_frame = avio_rb32(pb); /* lpcm frames per audio packet if constant */
if (format == MKTAG('l','p','c','m'))
st->codec->codec_id = ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags);
}
@@ -1173,7 +1174,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, ByteIOContext *pb, int entries)
st->codec->height = sc->height;
} else {
/* other codec type, just skip (rtp, mp4s, tmcd ...) */
- url_fskip(pb, size - (url_ftell(pb) - start_pos));
+ avio_seek(pb, size - (url_ftell(pb) - start_pos), SEEK_CUR);
}
/* this will read extra atoms at the end (wave, alac, damr, avcC, SMI ...) */
a.size = size - (url_ftell(pb) - start_pos);
@@ -1181,7 +1182,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, ByteIOContext *pb, int entries)
if (mov_read_default(c, pb, a) < 0)
return -1;
} else if (a.size > 0)
- url_fskip(pb, a.size);
+ avio_seek(pb, a.size, SEEK_CUR);
}
if(st->codec->codec_type==AVMEDIA_TYPE_AUDIO && st->codec->sample_rate==0 && sc->time_scale>1)
@@ -1244,18 +1245,18 @@ int ff_mov_read_stsd_entries(MOVContext *c, ByteIOContext *pb, int entries)
return 0;
}
-static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int entries;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ entries = avio_rb32(pb);
return ff_mov_read_stsd_entries(c, pb, entries);
}
-static int mov_read_stsc(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
@@ -1266,10 +1267,10 @@ static int mov_read_stsc(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries);
@@ -1281,14 +1282,14 @@ static int mov_read_stsc(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
sc->stsc_count = entries;
for(i=0; istsc_data[i].first = get_be32(pb);
- sc->stsc_data[i].count = get_be32(pb);
- sc->stsc_data[i].id = get_be32(pb);
+ sc->stsc_data[i].first = avio_rb32(pb);
+ sc->stsc_data[i].count = avio_rb32(pb);
+ sc->stsc_data[i].id = avio_rb32(pb);
}
return 0;
}
-static int mov_read_stps(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
@@ -1299,9 +1300,9 @@ static int mov_read_stps(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_be32(pb); // version + flags
+ avio_rb32(pb); // version + flags
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
if (entries >= UINT_MAX / sizeof(*sc->stps_data))
return -1;
sc->stps_data = av_malloc(entries * sizeof(*sc->stps_data));
@@ -1310,14 +1311,14 @@ static int mov_read_stps(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
sc->stps_count = entries;
for (i = 0; i < entries; i++) {
- sc->stps_data[i] = get_be32(pb);
+ sc->stps_data[i] = avio_rb32(pb);
//av_dlog(c->fc, "stps %d\n", sc->stps_data[i]);
}
return 0;
}
-static int mov_read_stss(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
@@ -1328,10 +1329,10 @@ static int mov_read_stss(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "keyframe_count = %d\n", entries);
@@ -1343,13 +1344,13 @@ static int mov_read_stss(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
sc->keyframe_count = entries;
for(i=0; ikeyframes[i] = get_be32(pb);
+ sc->keyframes[i] = avio_rb32(pb);
//av_dlog(c->fc, "keyframes[]=%d\n", sc->keyframes[i]);
}
return 0;
}
-static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
@@ -1362,20 +1363,20 @@ static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
if (atom.type == MKTAG('s','t','s','z')) {
- sample_size = get_be32(pb);
+ sample_size = avio_rb32(pb);
if (!sc->sample_size) /* do not overwrite value computed in stsd */
sc->sample_size = sample_size;
field_size = 32;
} else {
sample_size = 0;
- get_be24(pb); /* reserved */
- field_size = get_byte(pb);
+ avio_rb24(pb); /* reserved */
+ field_size = avio_r8(pb);
}
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "sample_size = %d sample_count = %d\n", sc->sample_size, entries);
@@ -1402,7 +1403,7 @@ static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return AVERROR(ENOMEM);
}
- if (get_buffer(pb, buf, num_bytes) < num_bytes) {
+ if (avio_read(pb, buf, num_bytes) < num_bytes) {
av_freep(&sc->sample_sizes);
av_free(buf);
return -1;
@@ -1417,7 +1418,7 @@ static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0;
}
-static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
@@ -1430,9 +1431,9 @@ static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries);
@@ -1447,8 +1448,8 @@ static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
int sample_duration;
int sample_count;
- sample_count=get_be32(pb);
- sample_duration = get_be32(pb);
+ sample_count=avio_rb32(pb);
+ sample_duration = avio_rb32(pb);
sc->stts_data[i].count= sample_count;
sc->stts_data[i].duration= sample_duration;
@@ -1464,7 +1465,7 @@ static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0;
}
-static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
@@ -1475,9 +1476,9 @@ static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
@@ -1489,8 +1490,8 @@ static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
sc->ctts_count = entries;
for(i=0; ictts_data[i].count = count;
sc->ctts_data[i].duration= duration;
@@ -1682,7 +1683,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
}
}
-static int mov_open_dref(ByteIOContext **pb, char *src, MOVDref *ref)
+static int mov_open_dref(AVIOContext **pb, char *src, MOVDref *ref)
{
/* try relative path, we do not try the absolute because it can leak information about our
system to an attacker */
@@ -1717,15 +1718,15 @@ static int mov_open_dref(ByteIOContext **pb, char *src, MOVDref *ref)
av_strlcat(filename, ref->path + l + 1, 1024);
- if (!url_fopen(pb, filename, URL_RDONLY))
+ if (!avio_open(pb, filename, URL_RDONLY))
return 0;
}
}
return AVERROR(ENOENT);
-};
+}
-static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
@@ -1824,7 +1825,7 @@ static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0;
}
-static int mov_read_ilst(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_ilst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int ret;
c->itunes_metadata = 1;
@@ -1833,13 +1834,13 @@ static int mov_read_ilst(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return ret;
}
-static int mov_read_meta(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
while (atom.size > 8) {
- uint32_t tag = get_le32(pb);
+ uint32_t tag = avio_rl32(pb);
atom.size -= 4;
if (tag == MKTAG('h','d','l','r')) {
- url_fseek(pb, -8, SEEK_CUR);
+ avio_seek(pb, -8, SEEK_CUR);
atom.size += 8;
return mov_read_default(c, pb, atom);
}
@@ -1847,7 +1848,7 @@ static int mov_read_meta(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0;
}
-static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int i;
int width;
@@ -1863,8 +1864,8 @@ static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- version = get_byte(pb);
- get_be24(pb); /* flags */
+ version = avio_r8(pb);
+ avio_rb24(pb); /* flags */
/*
MOV_TRACK_ENABLED 0x0001
MOV_TRACK_IN_MOVIE 0x0002
@@ -1873,36 +1874,36 @@ static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
*/
if (version == 1) {
- get_be64(pb);
- get_be64(pb);
+ avio_rb64(pb);
+ avio_rb64(pb);
} else {
- get_be32(pb); /* creation time */
- get_be32(pb); /* modification time */
+ avio_rb32(pb); /* creation time */
+ avio_rb32(pb); /* modification time */
}
- st->id = (int)get_be32(pb); /* track id (NOT 0 !)*/
- get_be32(pb); /* reserved */
+ st->id = (int)avio_rb32(pb); /* track id (NOT 0 !)*/
+ avio_rb32(pb); /* reserved */
/* highlevel (considering edits) duration in movie timebase */
- (version == 1) ? get_be64(pb) : get_be32(pb);
- get_be32(pb); /* reserved */
- get_be32(pb); /* reserved */
+ (version == 1) ? avio_rb64(pb) : avio_rb32(pb);
+ avio_rb32(pb); /* reserved */
+ avio_rb32(pb); /* reserved */
- get_be16(pb); /* layer */
- get_be16(pb); /* alternate group */
- get_be16(pb); /* volume */
- get_be16(pb); /* reserved */
+ avio_rb16(pb); /* layer */
+ avio_rb16(pb); /* alternate group */
+ avio_rb16(pb); /* volume */
+ avio_rb16(pb); /* reserved */
//read in the display matrix (outlined in ISO 14496-12, Section 6.2.2)
// they're kept in fixed point format through all calculations
// ignore u,v,z b/c we don't need the scale factor to calc aspect ratio
for (i = 0; i < 3; i++) {
- display_matrix[i][0] = get_be32(pb); // 16.16 fixed point
- display_matrix[i][1] = get_be32(pb); // 16.16 fixed point
- get_be32(pb); // 2.30 fixed point (not used)
+ display_matrix[i][0] = avio_rb32(pb); // 16.16 fixed point
+ display_matrix[i][1] = avio_rb32(pb); // 16.16 fixed point
+ avio_rb32(pb); // 2.30 fixed point (not used)
}
- width = get_be32(pb); // 16.16 fixed point track width
- height = get_be32(pb); // 16.16 fixed point track height
+ width = avio_rb32(pb); // 16.16 fixed point track width
+ height = avio_rb32(pb); // 16.16 fixed point track height
sc->width = width >> 16;
sc->height = height >> 16;
@@ -1930,16 +1931,16 @@ static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0;
}
-static int mov_read_tfhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVFragment *frag = &c->fragment;
MOVTrackExt *trex = NULL;
int flags, track_id, i;
- get_byte(pb); /* version */
- flags = get_be24(pb);
+ avio_r8(pb); /* version */
+ flags = avio_rb24(pb);
- track_id = get_be32(pb);
+ track_id = avio_rb32(pb);
if (!track_id)
return -1;
frag->track_id = track_id;
@@ -1953,25 +1954,25 @@ static int mov_read_tfhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return -1;
}
- if (flags & 0x01) frag->base_data_offset = get_be64(pb);
+ if (flags & 0x01) frag->base_data_offset = avio_rb64(pb);
else frag->base_data_offset = frag->moof_offset;
- if (flags & 0x02) frag->stsd_id = get_be32(pb);
+ if (flags & 0x02) frag->stsd_id = avio_rb32(pb);
else frag->stsd_id = trex->stsd_id;
- frag->duration = flags & 0x08 ? get_be32(pb) : trex->duration;
- frag->size = flags & 0x10 ? get_be32(pb) : trex->size;
- frag->flags = flags & 0x20 ? get_be32(pb) : trex->flags;
+ frag->duration = flags & 0x08 ? avio_rb32(pb) : trex->duration;
+ frag->size = flags & 0x10 ? avio_rb32(pb) : trex->size;
+ frag->flags = flags & 0x20 ? avio_rb32(pb) : trex->flags;
av_dlog(c->fc, "frag flags 0x%x\n", frag->flags);
return 0;
}
-static int mov_read_chap(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_chap(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
- c->chapter_track = get_be32(pb);
+ c->chapter_track = avio_rb32(pb);
return 0;
}
-static int mov_read_trex(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_trex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVTrackExt *trex;
@@ -1982,17 +1983,17 @@ static int mov_read_trex(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return AVERROR(ENOMEM);
c->trex_data = trex;
trex = &c->trex_data[c->trex_count++];
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- trex->track_id = get_be32(pb);
- trex->stsd_id = get_be32(pb);
- trex->duration = get_be32(pb);
- trex->size = get_be32(pb);
- trex->flags = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ trex->track_id = avio_rb32(pb);
+ trex->stsd_id = avio_rb32(pb);
+ trex->duration = avio_rb32(pb);
+ trex->size = avio_rb32(pb);
+ trex->flags = avio_rb32(pb);
return 0;
}
-static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVFragment *frag = &c->fragment;
AVStream *st = NULL;
@@ -2016,12 +2017,12 @@ static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
sc = st->priv_data;
if (sc->pseudo_stream_id+1 != frag->stsd_id)
return 0;
- get_byte(pb); /* version */
- flags = get_be24(pb);
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ flags = avio_rb24(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "flags 0x%x entries %d\n", flags, entries);
- if (flags & 0x001) data_offset = get_be32(pb);
- if (flags & 0x004) first_sample_flags = get_be32(pb);
+ if (flags & 0x001) data_offset = avio_rb32(pb);
+ if (flags & 0x004) first_sample_flags = avio_rb32(pb);
if (flags & 0x800) {
MOVStts *ctts_data;
if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data))
@@ -2042,12 +2043,12 @@ static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
unsigned sample_duration = frag->duration;
int keyframe;
- if (flags & 0x100) sample_duration = get_be32(pb);
- if (flags & 0x200) sample_size = get_be32(pb);
- if (flags & 0x400) sample_flags = get_be32(pb);
+ if (flags & 0x100) sample_duration = avio_rb32(pb);
+ if (flags & 0x200) sample_size = avio_rb32(pb);
+ if (flags & 0x400) sample_flags = avio_rb32(pb);
if (flags & 0x800) {
sc->ctts_data[sc->ctts_count].count = 1;
- sc->ctts_data[sc->ctts_count].duration = get_be32(pb);
+ sc->ctts_data[sc->ctts_count].duration = avio_rb32(pb);
sc->ctts_count++;
}
if ((keyframe = st->codec->codec_type == AVMEDIA_TYPE_AUDIO ||
@@ -2070,46 +2071,46 @@ static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
/* this atom should be null (from specs), but some buggy files put the 'moov' atom inside it... */
/* like the files created with Adobe Premiere 5.0, for samples see */
/* http://graphics.tudelft.nl/~wouter/publications/soundtests/ */
-static int mov_read_wide(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_wide(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int err;
if (atom.size < 8)
return 0; /* continue */
- if (get_be32(pb) != 0) { /* 0 sized mdat atom... use the 'wide' atom size */
- url_fskip(pb, atom.size - 4);
+ if (avio_rb32(pb) != 0) { /* 0 sized mdat atom... use the 'wide' atom size */
+ avio_seek(pb, atom.size - 4, SEEK_CUR);
return 0;
}
- atom.type = get_le32(pb);
+ atom.type = avio_rl32(pb);
atom.size -= 8;
if (atom.type != MKTAG('m','d','a','t')) {
- url_fskip(pb, atom.size);
+ avio_seek(pb, atom.size, SEEK_CUR);
return 0;
}
err = mov_read_mdat(c, pb, atom);
return err;
}
-static int mov_read_cmov(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
#if CONFIG_ZLIB
- ByteIOContext ctx;
+ AVIOContext ctx;
uint8_t *cmov_data;
uint8_t *moov_data; /* uncompressed data */
long cmov_len, moov_len;
int ret = -1;
- get_be32(pb); /* dcom atom */
- if (get_le32(pb) != MKTAG('d','c','o','m'))
+ avio_rb32(pb); /* dcom atom */
+ if (avio_rl32(pb) != MKTAG('d','c','o','m'))
return -1;
- if (get_le32(pb) != MKTAG('z','l','i','b')) {
+ if (avio_rl32(pb) != MKTAG('z','l','i','b')) {
av_log(c->fc, AV_LOG_ERROR, "unknown compression for cmov atom !");
return -1;
}
- get_be32(pb); /* cmvd atom */
- if (get_le32(pb) != MKTAG('c','m','v','d'))
+ avio_rb32(pb); /* cmvd atom */
+ if (avio_rl32(pb) != MKTAG('c','m','v','d'))
return -1;
- moov_len = get_be32(pb); /* uncompressed size */
+ moov_len = avio_rb32(pb); /* uncompressed size */
cmov_len = atom.size - 6 * 4;
cmov_data = av_malloc(cmov_len);
@@ -2120,10 +2121,10 @@ static int mov_read_cmov(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
av_free(cmov_data);
return AVERROR(ENOMEM);
}
- get_buffer(pb, cmov_data, cmov_len);
+ avio_read(pb, cmov_data, cmov_len);
if(uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK)
goto free_and_return;
- if(init_put_byte(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
+ if(ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
goto free_and_return;
atom.type = MKTAG('m','o','o','v');
atom.size = moov_len;
@@ -2142,7 +2143,7 @@ static int mov_read_cmov(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
}
/* edit list atom */
-static int mov_read_elst(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVStreamContext *sc;
int i, edit_count;
@@ -2151,18 +2152,18 @@ static int mov_read_elst(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0;
sc = c->fc->streams[c->fc->nb_streams-1]->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- edit_count = get_be32(pb); /* entries */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ edit_count = avio_rb32(pb); /* entries */
if((uint64_t)edit_count*12+8 > atom.size)
return -1;
for(i=0; i= -1) {
sc->time_offset = time != -1 ? time : -duration;
}
@@ -2307,13 +2308,13 @@ static void mov_read_chapters(AVFormatContext *s)
uint16_t ch;
int len, title_len;
- if (url_fseek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
+ if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
av_log(s, AV_LOG_ERROR, "Chapter %d not found in file\n", i);
goto finish;
}
// the first two bytes are the length of the title
- len = get_be16(sc->pb);
+ len = avio_rb16(sc->pb);
if (len > sample->size-2)
continue;
title_len = 2*len + 1;
@@ -2323,7 +2324,7 @@ static void mov_read_chapters(AVFormatContext *s)
// The samples could theoretically be in any encoding if there's an encd
// atom following, but in practice are only utf-8 or utf-16, distinguished
// instead by the presence of a BOM
- ch = get_be16(sc->pb);
+ ch = avio_rb16(sc->pb);
if (ch == 0xfeff)
avio_get_str16be(sc->pb, len, title, title_len);
else if (ch == 0xfffe)
@@ -2337,13 +2338,13 @@ static void mov_read_chapters(AVFormatContext *s)
av_freep(&title);
}
finish:
- url_fseek(sc->pb, cur_pos, SEEK_SET);
+ avio_seek(sc->pb, cur_pos, SEEK_SET);
}
static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
MOVContext *mov = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int err;
MOVAtom atom = { AV_RL32("root") };
@@ -2420,7 +2421,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
sc->current_sample++;
if (st->discard != AVDISCARD_ALL) {
- if (url_fseek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
+ if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n",
sc->ffindex, sample->pos);
return -1;
@@ -2545,7 +2546,7 @@ static int mov_read_close(AVFormatContext *s)
}
av_freep(&sc->drefs);
if (sc->pb && sc->pb != s->pb)
- url_fclose(sc->pb);
+ avio_close(sc->pb);
av_freep(&st->codec->palctrl);
}
diff --git a/mplayer/ffmpeg/libavformat/movenc.c b/mplayer/ffmpeg/libavformat/movenc.c
index 0949d294..231976b0 100644
--- a/mplayer/ffmpeg/libavformat/movenc.c
+++ b/mplayer/ffmpeg/libavformat/movenc.c
@@ -23,6 +23,7 @@
#include "movenc.h"
#include "avformat.h"
+#include "avio_internal.h"
#include "riff.h"
#include "avio.h"
#include "isom.h"
@@ -36,49 +37,49 @@
#include
//FIXME support 64 bit variant with wide placeholders
-static int64_t updateSize(ByteIOContext *pb, int64_t pos)
+static int64_t updateSize(AVIOContext *pb, int64_t pos)
{
int64_t curpos = url_ftell(pb);
- url_fseek(pb, pos, SEEK_SET);
- put_be32(pb, curpos - pos); /* rewrite size */
- url_fseek(pb, curpos, SEEK_SET);
+ avio_seek(pb, pos, SEEK_SET);
+ avio_wb32(pb, curpos - pos); /* rewrite size */
+ avio_seek(pb, curpos, SEEK_SET);
return curpos - pos;
}
/* Chunk offset atom */
-static int mov_write_stco_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track)
{
int i;
int mode64 = 0; // use 32 bit size variant if possible
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
if (pos > UINT32_MAX) {
mode64 = 1;
- put_tag(pb, "co64");
+ ffio_wfourcc(pb, "co64");
} else
- put_tag(pb, "stco");
- put_be32(pb, 0); /* version & flags */
- put_be32(pb, track->entry); /* entry count */
+ ffio_wfourcc(pb, "stco");
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb32(pb, track->entry); /* entry count */
for (i=0; ientry; i++) {
if(mode64 == 1)
- put_be64(pb, track->cluster[i].pos);
+ avio_wb64(pb, track->cluster[i].pos);
else
- put_be32(pb, track->cluster[i].pos);
+ avio_wb32(pb, track->cluster[i].pos);
}
return updateSize(pb, pos);
}
/* Sample size atom */
-static int mov_write_stsz_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_stsz_tag(AVIOContext *pb, MOVTrack *track)
{
int equalChunks = 1;
int i, j, entries = 0, tst = -1, oldtst = -1;
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, "stsz");
- put_be32(pb, 0); /* version & flags */
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "stsz");
+ avio_wb32(pb, 0); /* version & flags */
for (i=0; ientry; i++) {
tst = track->cluster[i].size/track->cluster[i].entries;
@@ -90,15 +91,15 @@ static int mov_write_stsz_tag(ByteIOContext *pb, MOVTrack *track)
}
if (equalChunks) {
int sSize = track->cluster[0].size/track->cluster[0].entries;
- put_be32(pb, sSize); // sample size
- put_be32(pb, entries); // sample count
+ avio_wb32(pb, sSize); // sample size
+ avio_wb32(pb, entries); // sample count
}
else {
- put_be32(pb, 0); // sample size
- put_be32(pb, entries); // sample count
+ avio_wb32(pb, 0); // sample size
+ avio_wb32(pb, entries); // sample count
for (i=0; ientry; i++) {
for (j=0; jcluster[i].entries; j++) {
- put_be32(pb, track->cluster[i].size /
+ avio_wb32(pb, track->cluster[i].size /
track->cluster[i].entries);
}
}
@@ -107,74 +108,74 @@ static int mov_write_stsz_tag(ByteIOContext *pb, MOVTrack *track)
}
/* Sample to chunk atom */
-static int mov_write_stsc_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_stsc_tag(AVIOContext *pb, MOVTrack *track)
{
int index = 0, oldval = -1, i;
int64_t entryPos, curpos;
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, "stsc");
- put_be32(pb, 0); // version & flags
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "stsc");
+ avio_wb32(pb, 0); // version & flags
entryPos = url_ftell(pb);
- put_be32(pb, track->entry); // entry count
+ avio_wb32(pb, track->entry); // entry count
for (i=0; ientry; i++) {
if(oldval != track->cluster[i].samplesInChunk)
{
- put_be32(pb, i+1); // first chunk
- put_be32(pb, track->cluster[i].samplesInChunk); // samples per chunk
- put_be32(pb, 0x1); // sample description index
+ avio_wb32(pb, i+1); // first chunk
+ avio_wb32(pb, track->cluster[i].samplesInChunk); // samples per chunk
+ avio_wb32(pb, 0x1); // sample description index
oldval = track->cluster[i].samplesInChunk;
index++;
}
}
curpos = url_ftell(pb);
- url_fseek(pb, entryPos, SEEK_SET);
- put_be32(pb, index); // rewrite size
- url_fseek(pb, curpos, SEEK_SET);
+ avio_seek(pb, entryPos, SEEK_SET);
+ avio_wb32(pb, index); // rewrite size
+ avio_seek(pb, curpos, SEEK_SET);
return updateSize(pb, pos);
}
/* Sync sample atom */
-static int mov_write_stss_tag(ByteIOContext *pb, MOVTrack *track, uint32_t flag)
+static int mov_write_stss_tag(AVIOContext *pb, MOVTrack *track, uint32_t flag)
{
int64_t curpos, entryPos;
int i, index = 0;
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); // size
- put_tag(pb, flag == MOV_SYNC_SAMPLE ? "stss" : "stps");
- put_be32(pb, 0); // version & flags
+ avio_wb32(pb, 0); // size
+ ffio_wfourcc(pb, flag == MOV_SYNC_SAMPLE ? "stss" : "stps");
+ avio_wb32(pb, 0); // version & flags
entryPos = url_ftell(pb);
- put_be32(pb, track->entry); // entry count
+ avio_wb32(pb, track->entry); // entry count
for (i=0; ientry; i++) {
if (track->cluster[i].flags & flag) {
- put_be32(pb, i+1);
+ avio_wb32(pb, i+1);
index++;
}
}
curpos = url_ftell(pb);
- url_fseek(pb, entryPos, SEEK_SET);
- put_be32(pb, index); // rewrite size
- url_fseek(pb, curpos, SEEK_SET);
+ avio_seek(pb, entryPos, SEEK_SET);
+ avio_wb32(pb, index); // rewrite size
+ avio_seek(pb, curpos, SEEK_SET);
return updateSize(pb, pos);
}
-static int mov_write_amr_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_amr_tag(AVIOContext *pb, MOVTrack *track)
{
- put_be32(pb, 0x11); /* size */
- if (track->mode == MODE_MOV) put_tag(pb, "samr");
- else put_tag(pb, "damr");
- put_tag(pb, "FFMP");
- put_byte(pb, 0); /* decoder version */
+ avio_wb32(pb, 0x11); /* size */
+ if (track->mode == MODE_MOV) ffio_wfourcc(pb, "samr");
+ else ffio_wfourcc(pb, "damr");
+ ffio_wfourcc(pb, "FFMP");
+ avio_w8(pb, 0); /* decoder version */
- put_be16(pb, 0x81FF); /* Mode set (all modes for AMR_NB) */
- put_byte(pb, 0x00); /* Mode change period (no restriction) */
- put_byte(pb, 0x01); /* Frames per sample */
+ avio_wb16(pb, 0x81FF); /* Mode set (all modes for AMR_NB) */
+ avio_w8(pb, 0x00); /* Mode change period (no restriction) */
+ avio_w8(pb, 0x01); /* Frames per sample */
return 0x11;
}
-static int mov_write_ac3_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track)
{
GetBitContext gbc;
PutBitContext pbc;
@@ -184,8 +185,8 @@ static int mov_write_ac3_tag(ByteIOContext *pb, MOVTrack *track)
if (track->vosLen < 7)
return -1;
- put_be32(pb, 11);
- put_tag(pb, "dac3");
+ avio_wb32(pb, 11);
+ ffio_wfourcc(pb, "dac3");
init_get_bits(&gbc, track->vosData+4, track->vosLen-4);
fscod = get_bits(&gbc, 2);
@@ -213,7 +214,7 @@ static int mov_write_ac3_tag(ByteIOContext *pb, MOVTrack *track)
put_bits(&pbc, 5, 0); // reserved
flush_put_bits(&pbc);
- put_buffer(pb, buf, sizeof(buf));
+ avio_write(pb, buf, sizeof(buf));
return 11;
}
@@ -222,17 +223,17 @@ static int mov_write_ac3_tag(ByteIOContext *pb, MOVTrack *track)
* This function writes extradata "as is".
* Extradata must be formated like a valid atom (with size and tag)
*/
-static int mov_write_extradata_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_extradata_tag(AVIOContext *pb, MOVTrack *track)
{
- put_buffer(pb, track->enc->extradata, track->enc->extradata_size);
+ avio_write(pb, track->enc->extradata, track->enc->extradata_size);
return track->enc->extradata_size;
}
-static int mov_write_enda_tag(ByteIOContext *pb)
+static int mov_write_enda_tag(AVIOContext *pb)
{
- put_be32(pb, 10);
- put_tag(pb, "enda");
- put_be16(pb, 1); /* little endian */
+ avio_wb32(pb, 10);
+ ffio_wfourcc(pb, "enda");
+ avio_wb16(pb, 1); /* little endian */
return 10;
}
@@ -243,29 +244,29 @@ static unsigned int descrLength(unsigned int len)
return len + 1 + i;
}
-static void putDescr(ByteIOContext *pb, int tag, unsigned int size)
+static void putDescr(AVIOContext *pb, int tag, unsigned int size)
{
int i= descrLength(size) - size - 2;
- put_byte(pb, tag);
+ avio_w8(pb, tag);
for(; i>0; i--)
- put_byte(pb, (size>>(7*i)) | 0x80);
- put_byte(pb, size & 0x7F);
+ avio_w8(pb, (size>>(7*i)) | 0x80);
+ avio_w8(pb, size & 0x7F);
}
-static int mov_write_esds_tag(ByteIOContext *pb, MOVTrack *track) // Basic
+static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
{
int64_t pos = url_ftell(pb);
int decoderSpecificInfoLen = track->vosLen ? descrLength(track->vosLen):0;
- put_be32(pb, 0); // size
- put_tag(pb, "esds");
- put_be32(pb, 0); // Version
+ avio_wb32(pb, 0); // size
+ ffio_wfourcc(pb, "esds");
+ avio_wb32(pb, 0); // Version
// ES descriptor
putDescr(pb, 0x03, 3 + descrLength(13 + decoderSpecificInfoLen) +
descrLength(1));
- put_be16(pb, track->trackID);
- put_byte(pb, 0x00); // flags (= no flags)
+ avio_wb16(pb, track->trackID);
+ avio_w8(pb, 0x00); // flags (= no flags)
// DecoderConfig descriptor
putDescr(pb, 0x04, 13 + decoderSpecificInfoLen);
@@ -274,35 +275,35 @@ static int mov_write_esds_tag(ByteIOContext *pb, MOVTrack *track) // Basic
if ((track->enc->codec_id == CODEC_ID_MP2 ||
track->enc->codec_id == CODEC_ID_MP3) &&
track->enc->sample_rate > 24000)
- put_byte(pb, 0x6B); // 11172-3
+ avio_w8(pb, 0x6B); // 11172-3
else
- put_byte(pb, ff_codec_get_tag(ff_mp4_obj_type, track->enc->codec_id));
+ avio_w8(pb, ff_codec_get_tag(ff_mp4_obj_type, track->enc->codec_id));
// the following fields is made of 6 bits to identify the streamtype (4 for video, 5 for audio)
// plus 1 bit to indicate upstream and 1 bit set to 1 (reserved)
if(track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
- put_byte(pb, 0x15); // flags (= Audiostream)
+ avio_w8(pb, 0x15); // flags (= Audiostream)
else
- put_byte(pb, 0x11); // flags (= Visualstream)
+ avio_w8(pb, 0x11); // flags (= Visualstream)
- put_byte(pb, track->enc->rc_buffer_size>>(3+16)); // Buffersize DB (24 bits)
- put_be16(pb, (track->enc->rc_buffer_size>>3)&0xFFFF); // Buffersize DB
+ avio_w8(pb, track->enc->rc_buffer_size>>(3+16)); // Buffersize DB (24 bits)
+ avio_wb16(pb, (track->enc->rc_buffer_size>>3)&0xFFFF); // Buffersize DB
- put_be32(pb, FFMAX(track->enc->bit_rate, track->enc->rc_max_rate)); // maxbitrate (FIXME should be max rate in any 1 sec window)
+ avio_wb32(pb, FFMAX(track->enc->bit_rate, track->enc->rc_max_rate)); // maxbitrate (FIXME should be max rate in any 1 sec window)
if(track->enc->rc_max_rate != track->enc->rc_min_rate || track->enc->rc_min_rate==0)
- put_be32(pb, 0); // vbr
+ avio_wb32(pb, 0); // vbr
else
- put_be32(pb, track->enc->rc_max_rate); // avg bitrate
+ avio_wb32(pb, track->enc->rc_max_rate); // avg bitrate
if (track->vosLen) {
// DecoderSpecific info descriptor
putDescr(pb, 0x05, track->vosLen);
- put_buffer(pb, track->vosData, track->vosLen);
+ avio_write(pb, track->vosData, track->vosLen);
}
// SL descriptor
putDescr(pb, 0x06, 1);
- put_byte(pb, 0x02);
+ avio_w8(pb, 0x02);
return updateSize(pb, pos);
}
@@ -314,32 +315,32 @@ static int mov_pcm_le_gt16(enum CodecID codec_id)
codec_id == CODEC_ID_PCM_F64LE;
}
-static int mov_write_ms_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_ms_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0);
- put_le32(pb, track->tag); // store it byteswapped
+ avio_wb32(pb, 0);
+ avio_wl32(pb, track->tag); // store it byteswapped
track->enc->codec_tag = av_bswap16(track->tag >> 16);
ff_put_wav_header(pb, track->enc);
return updateSize(pb, pos);
}
-static int mov_write_wave_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, "wave");
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "wave");
- put_be32(pb, 12); /* size */
- put_tag(pb, "frma");
- put_le32(pb, track->tag);
+ avio_wb32(pb, 12); /* size */
+ ffio_wfourcc(pb, "frma");
+ avio_wl32(pb, track->tag);
if (track->enc->codec_id == CODEC_ID_AAC) {
/* useless atom needed by mplayer, ipod, not needed by quicktime */
- put_be32(pb, 12); /* size */
- put_tag(pb, "mp4a");
- put_be32(pb, 0);
+ avio_wb32(pb, 12); /* size */
+ ffio_wfourcc(pb, "mp4a");
+ avio_wb32(pb, 0);
mov_write_esds_tag(pb, track);
} else if (mov_pcm_le_gt16(track->enc->codec_id)) {
mov_write_enda_tag(pb);
@@ -354,17 +355,17 @@ static int mov_write_wave_tag(ByteIOContext *pb, MOVTrack *track)
mov_write_ms_tag(pb, track);
}
- put_be32(pb, 8); /* size */
- put_be32(pb, 0); /* null tag */
+ avio_wb32(pb, 8); /* size */
+ avio_wb32(pb, 0); /* null tag */
return updateSize(pb, pos);
}
-static int mov_write_glbl_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_glbl_tag(AVIOContext *pb, MOVTrack *track)
{
- put_be32(pb, track->vosLen+8);
- put_tag(pb, "glbl");
- put_buffer(pb, track->vosData, track->vosLen);
+ avio_wb32(pb, track->vosLen+8);
+ ffio_wfourcc(pb, "glbl");
+ avio_write(pb, track->vosData, track->vosLen);
return 8+track->vosLen;
}
@@ -397,7 +398,7 @@ static int mov_get_lpcm_flags(enum CodecID codec_id)
}
}
-static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
int version = 0;
@@ -415,56 +416,56 @@ static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack *track)
}
}
- put_be32(pb, 0); /* size */
- put_le32(pb, tag); // store it byteswapped
- put_be32(pb, 0); /* Reserved */
- put_be16(pb, 0); /* Reserved */
- put_be16(pb, 1); /* Data-reference index, XXX == 1 */
+ avio_wb32(pb, 0); /* size */
+ avio_wl32(pb, tag); // store it byteswapped
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb16(pb, 0); /* Reserved */
+ avio_wb16(pb, 1); /* Data-reference index, XXX == 1 */
/* SoundDescription */
- put_be16(pb, version); /* Version */
- put_be16(pb, 0); /* Revision level */
- put_be32(pb, 0); /* Reserved */
+ avio_wb16(pb, version); /* Version */
+ avio_wb16(pb, 0); /* Revision level */
+ avio_wb32(pb, 0); /* Reserved */
if (version == 2) {
- put_be16(pb, 3);
- put_be16(pb, 16);
- put_be16(pb, 0xfffe);
- put_be16(pb, 0);
- put_be32(pb, 0x00010000);
- put_be32(pb, 72);
- put_be64(pb, av_dbl2int(track->timescale));
- put_be32(pb, track->enc->channels);
- put_be32(pb, 0x7F000000);
- put_be32(pb, av_get_bits_per_sample(track->enc->codec_id));
- put_be32(pb, mov_get_lpcm_flags(track->enc->codec_id));
- put_be32(pb, track->sampleSize);
- put_be32(pb, track->enc->frame_size);
+ avio_wb16(pb, 3);
+ avio_wb16(pb, 16);
+ avio_wb16(pb, 0xfffe);
+ avio_wb16(pb, 0);
+ avio_wb32(pb, 0x00010000);
+ avio_wb32(pb, 72);
+ avio_wb64(pb, av_dbl2int(track->timescale));
+ avio_wb32(pb, track->enc->channels);
+ avio_wb32(pb, 0x7F000000);
+ avio_wb32(pb, av_get_bits_per_sample(track->enc->codec_id));
+ avio_wb32(pb, mov_get_lpcm_flags(track->enc->codec_id));
+ avio_wb32(pb, track->sampleSize);
+ avio_wb32(pb, track->enc->frame_size);
} else {
if (track->mode == MODE_MOV) {
- put_be16(pb, track->enc->channels);
+ avio_wb16(pb, track->enc->channels);
if (track->enc->codec_id == CODEC_ID_PCM_U8 ||
track->enc->codec_id == CODEC_ID_PCM_S8)
- put_be16(pb, 8); /* bits per sample */
+ avio_wb16(pb, 8); /* bits per sample */
else
- put_be16(pb, 16);
- put_be16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
+ avio_wb16(pb, 16);
+ avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
} else { /* reserved for mp4/3gp */
- put_be16(pb, 2);
- put_be16(pb, 16);
- put_be16(pb, 0);
+ avio_wb16(pb, 2);
+ avio_wb16(pb, 16);
+ avio_wb16(pb, 0);
}
- put_be16(pb, 0); /* packet size (= 0) */
- put_be16(pb, track->timescale); /* Time scale */
- put_be16(pb, 0); /* Reserved */
+ avio_wb16(pb, 0); /* packet size (= 0) */
+ avio_wb16(pb, track->timescale); /* Time scale */
+ avio_wb16(pb, 0); /* Reserved */
}
if(version == 1) { /* SoundDescription V1 extended info */
- put_be32(pb, track->enc->frame_size); /* Samples per packet */
- put_be32(pb, track->sampleSize / track->enc->channels); /* Bytes per packet */
- put_be32(pb, track->sampleSize); /* Bytes per frame */
- put_be32(pb, 2); /* Bytes per sample */
+ avio_wb32(pb, track->enc->frame_size); /* Samples per packet */
+ avio_wb32(pb, track->sampleSize / track->enc->channels); /* Bytes per packet */
+ avio_wb32(pb, track->sampleSize); /* Bytes per frame */
+ avio_wb32(pb, 2); /* Bytes per sample */
}
if(track->mode == MODE_MOV &&
@@ -490,86 +491,86 @@ static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack *track)
return updateSize(pb, pos);
}
-static int mov_write_d263_tag(ByteIOContext *pb)
+static int mov_write_d263_tag(AVIOContext *pb)
{
- put_be32(pb, 0xf); /* size */
- put_tag(pb, "d263");
- put_tag(pb, "FFMP");
- put_byte(pb, 0); /* decoder version */
+ avio_wb32(pb, 0xf); /* size */
+ ffio_wfourcc(pb, "d263");
+ ffio_wfourcc(pb, "FFMP");
+ avio_w8(pb, 0); /* decoder version */
/* FIXME use AVCodecContext level/profile, when encoder will set values */
- put_byte(pb, 0xa); /* level */
- put_byte(pb, 0); /* profile */
+ avio_w8(pb, 0xa); /* level */
+ avio_w8(pb, 0); /* profile */
return 0xf;
}
/* TODO: No idea about these values */
-static int mov_write_svq3_tag(ByteIOContext *pb)
-{
- put_be32(pb, 0x15);
- put_tag(pb, "SMI ");
- put_tag(pb, "SEQH");
- put_be32(pb, 0x5);
- put_be32(pb, 0xe2c0211d);
- put_be32(pb, 0xc0000000);
- put_byte(pb, 0);
+static int mov_write_svq3_tag(AVIOContext *pb)
+{
+ avio_wb32(pb, 0x15);
+ ffio_wfourcc(pb, "SMI ");
+ ffio_wfourcc(pb, "SEQH");
+ avio_wb32(pb, 0x5);
+ avio_wb32(pb, 0xe2c0211d);
+ avio_wb32(pb, 0xc0000000);
+ avio_w8(pb, 0);
return 0x15;
}
-static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0);
- put_tag(pb, "avcC");
+ avio_wb32(pb, 0);
+ ffio_wfourcc(pb, "avcC");
ff_isom_write_avcc(pb, track->vosData, track->vosLen);
return updateSize(pb, pos);
}
/* also used by all avid codecs (dv, imx, meridien) and their variants */
-static int mov_write_avid_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
{
int i;
- put_be32(pb, 24); /* size */
- put_tag(pb, "ACLR");
- put_tag(pb, "ACLR");
- put_tag(pb, "0001");
- put_be32(pb, 1); /* yuv 1 / rgb 2 ? */
- put_be32(pb, 0); /* unknown */
-
- put_be32(pb, 24); /* size */
- put_tag(pb, "APRG");
- put_tag(pb, "APRG");
- put_tag(pb, "0001");
- put_be32(pb, 1); /* unknown */
- put_be32(pb, 0); /* unknown */
-
- put_be32(pb, 120); /* size */
- put_tag(pb, "ARES");
- put_tag(pb, "ARES");
- put_tag(pb, "0001");
- put_be32(pb, AV_RB32(track->vosData + 0x28)); /* dnxhd cid, some id ? */
- put_be32(pb, track->enc->width);
+ avio_wb32(pb, 24); /* size */
+ ffio_wfourcc(pb, "ACLR");
+ ffio_wfourcc(pb, "ACLR");
+ ffio_wfourcc(pb, "0001");
+ avio_wb32(pb, 1); /* yuv 1 / rgb 2 ? */
+ avio_wb32(pb, 0); /* unknown */
+
+ avio_wb32(pb, 24); /* size */
+ ffio_wfourcc(pb, "APRG");
+ ffio_wfourcc(pb, "APRG");
+ ffio_wfourcc(pb, "0001");
+ avio_wb32(pb, 1); /* unknown */
+ avio_wb32(pb, 0); /* unknown */
+
+ avio_wb32(pb, 120); /* size */
+ ffio_wfourcc(pb, "ARES");
+ ffio_wfourcc(pb, "ARES");
+ ffio_wfourcc(pb, "0001");
+ avio_wb32(pb, AV_RB32(track->vosData + 0x28)); /* dnxhd cid, some id ? */
+ avio_wb32(pb, track->enc->width);
/* values below are based on samples created with quicktime and avid codecs */
if (track->vosData[5] & 2) { // interlaced
- put_be32(pb, track->enc->height/2);
- put_be32(pb, 2); /* unknown */
- put_be32(pb, 0); /* unknown */
- put_be32(pb, 4); /* unknown */
+ avio_wb32(pb, track->enc->height/2);
+ avio_wb32(pb, 2); /* unknown */
+ avio_wb32(pb, 0); /* unknown */
+ avio_wb32(pb, 4); /* unknown */
} else {
- put_be32(pb, track->enc->height);
- put_be32(pb, 1); /* unknown */
- put_be32(pb, 0); /* unknown */
+ avio_wb32(pb, track->enc->height);
+ avio_wb32(pb, 1); /* unknown */
+ avio_wb32(pb, 0); /* unknown */
if (track->enc->height == 1080)
- put_be32(pb, 5); /* unknown */
+ avio_wb32(pb, 5); /* unknown */
else
- put_be32(pb, 6); /* unknown */
+ avio_wb32(pb, 6); /* unknown */
}
/* padding */
for (i = 0; i < 10; i++)
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
/* extra padding for stsd needed */
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
return 0;
}
@@ -622,12 +623,23 @@ static int mov_get_dv_codec_tag(AVFormatContext *s, MOVTrack *track)
{
int tag;
- if (track->enc->height == 480) /* NTSC */
- if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n');
- else tag = MKTAG('d','v','c',' ');
- else if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p');
- else if (track->enc->pix_fmt == PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p');
- else tag = MKTAG('d','v','p','p');
+ if (track->enc->width == 720) /* SD */
+ if (track->enc->height == 480) /* NTSC */
+ if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n');
+ else tag = MKTAG('d','v','c',' ');
+ else if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p');
+ else if (track->enc->pix_fmt == PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p');
+ else tag = MKTAG('d','v','p','p');
+ else if (track->enc->height == 720) /* HD 720 line */
+ if (track->enc->time_base.den == 50) tag = MKTAG('d','v','h','q');
+ else tag = MKTAG('d','v','h','p');
+ else if (track->enc->height == 1080) /* HD 1080 line */
+ if (track->enc->time_base.den == 25) tag = MKTAG('d','v','h','5');
+ else tag = MKTAG('d','v','h','6');
+ else {
+ av_log(s, AV_LOG_ERROR, "unsupported height for dv codec\n");
+ return 0;
+ }
return tag;
}
@@ -738,92 +750,92 @@ static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
* Needed to make file play in iPods running newest firmware
* goes after avcC atom in moov.trak.mdia.minf.stbl.stsd.avc1
*/
-static int mov_write_uuid_tag_ipod(ByteIOContext *pb)
-{
- put_be32(pb, 28);
- put_tag(pb, "uuid");
- put_be32(pb, 0x6b6840f2);
- put_be32(pb, 0x5f244fc5);
- put_be32(pb, 0xba39a51b);
- put_be32(pb, 0xcf0323f3);
- put_be32(pb, 0x0);
+static int mov_write_uuid_tag_ipod(AVIOContext *pb)
+{
+ avio_wb32(pb, 28);
+ ffio_wfourcc(pb, "uuid");
+ avio_wb32(pb, 0x6b6840f2);
+ avio_wb32(pb, 0x5f244fc5);
+ avio_wb32(pb, 0xba39a51b);
+ avio_wb32(pb, 0xcf0323f3);
+ avio_wb32(pb, 0x0);
return 28;
}
-static int mov_write_subtitle_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_subtitle_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_le32(pb, track->tag); // store it byteswapped
- put_be32(pb, 0); /* Reserved */
- put_be16(pb, 0); /* Reserved */
- put_be16(pb, 1); /* Data-reference index */
+ avio_wb32(pb, 0); /* size */
+ avio_wl32(pb, track->tag); // store it byteswapped
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb16(pb, 0); /* Reserved */
+ avio_wb16(pb, 1); /* Data-reference index */
if (track->enc->extradata_size)
- put_buffer(pb, track->enc->extradata, track->enc->extradata_size);
+ avio_write(pb, track->enc->extradata, track->enc->extradata_size);
return updateSize(pb, pos);
}
-static int mov_write_pasp_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_pasp_tag(AVIOContext *pb, MOVTrack *track)
{
AVRational sar;
av_reduce(&sar.num, &sar.den, track->enc->sample_aspect_ratio.num,
track->enc->sample_aspect_ratio.den, INT_MAX);
- put_be32(pb, 16);
- put_tag(pb, "pasp");
- put_be32(pb, sar.num);
- put_be32(pb, sar.den);
+ avio_wb32(pb, 16);
+ ffio_wfourcc(pb, "pasp");
+ avio_wb32(pb, sar.num);
+ avio_wb32(pb, sar.den);
return 16;
}
-static int mov_write_video_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
char compressor_name[32];
- put_be32(pb, 0); /* size */
- put_le32(pb, track->tag); // store it byteswapped
- put_be32(pb, 0); /* Reserved */
- put_be16(pb, 0); /* Reserved */
- put_be16(pb, 1); /* Data-reference index */
+ avio_wb32(pb, 0); /* size */
+ avio_wl32(pb, track->tag); // store it byteswapped
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb16(pb, 0); /* Reserved */
+ avio_wb16(pb, 1); /* Data-reference index */
- put_be16(pb, 0); /* Codec stream version */
- put_be16(pb, 0); /* Codec stream revision (=0) */
+ avio_wb16(pb, 0); /* Codec stream version */
+ avio_wb16(pb, 0); /* Codec stream revision (=0) */
if (track->mode == MODE_MOV) {
- put_tag(pb, "FFMP"); /* Vendor */
+ ffio_wfourcc(pb, "FFMP"); /* Vendor */
if(track->enc->codec_id == CODEC_ID_RAWVIDEO) {
- put_be32(pb, 0); /* Temporal Quality */
- put_be32(pb, 0x400); /* Spatial Quality = lossless*/
+ avio_wb32(pb, 0); /* Temporal Quality */
+ avio_wb32(pb, 0x400); /* Spatial Quality = lossless*/
} else {
- put_be32(pb, 0x200); /* Temporal Quality = normal */
- put_be32(pb, 0x200); /* Spatial Quality = normal */
+ avio_wb32(pb, 0x200); /* Temporal Quality = normal */
+ avio_wb32(pb, 0x200); /* Spatial Quality = normal */
}
} else {
- put_be32(pb, 0); /* Reserved */
- put_be32(pb, 0); /* Reserved */
- put_be32(pb, 0); /* Reserved */
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb32(pb, 0); /* Reserved */
}
- put_be16(pb, track->enc->width); /* Video width */
- put_be16(pb, track->height); /* Video height */
- put_be32(pb, 0x00480000); /* Horizontal resolution 72dpi */
- put_be32(pb, 0x00480000); /* Vertical resolution 72dpi */
- put_be32(pb, 0); /* Data size (= 0) */
- put_be16(pb, 1); /* Frame count (= 1) */
+ avio_wb16(pb, track->enc->width); /* Video width */
+ avio_wb16(pb, track->height); /* Video height */
+ avio_wb32(pb, 0x00480000); /* Horizontal resolution 72dpi */
+ avio_wb32(pb, 0x00480000); /* Vertical resolution 72dpi */
+ avio_wb32(pb, 0); /* Data size (= 0) */
+ avio_wb16(pb, 1); /* Frame count (= 1) */
memset(compressor_name,0,32);
/* FIXME not sure, ISO 14496-1 draft where it shall be set to 0 */
if (track->mode == MODE_MOV && track->enc->codec && track->enc->codec->name)
strncpy(compressor_name,track->enc->codec->name,31);
- put_byte(pb, strlen(compressor_name));
- put_buffer(pb, compressor_name, 31);
+ avio_w8(pb, strlen(compressor_name));
+ avio_write(pb, compressor_name, 31);
if (track->mode == MODE_MOV && track->enc->bits_per_coded_sample)
- put_be16(pb, track->enc->bits_per_coded_sample);
+ avio_wb16(pb, track->enc->bits_per_coded_sample);
else
- put_be16(pb, 0x18); /* Reserved */
- put_be16(pb, 0xffff); /* Reserved */
+ avio_wb16(pb, 0x18); /* Reserved */
+ avio_wb16(pb, 0xffff); /* Reserved */
if(track->tag == MKTAG('m','p','4','v'))
mov_write_esds_tag(pb, track);
else if(track->enc->codec_id == CODEC_ID_H263)
@@ -839,8 +851,7 @@ static int mov_write_video_tag(ByteIOContext *pb, MOVTrack *track)
} else if(track->vosLen > 0)
mov_write_glbl_tag(pb, track);
- if (track->mode == MODE_MOV &&
- track->enc->sample_aspect_ratio.den && track->enc->sample_aspect_ratio.num &&
+ if (track->enc->sample_aspect_ratio.den && track->enc->sample_aspect_ratio.num &&
track->enc->sample_aspect_ratio.den != track->enc->sample_aspect_ratio.num) {
mov_write_pasp_tag(pb, track);
}
@@ -848,33 +859,33 @@ static int mov_write_video_tag(ByteIOContext *pb, MOVTrack *track)
return updateSize(pb, pos);
}
-static int mov_write_rtp_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, "rtp ");
- put_be32(pb, 0); /* Reserved */
- put_be16(pb, 0); /* Reserved */
- put_be16(pb, 1); /* Data-reference index */
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "rtp ");
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb16(pb, 0); /* Reserved */
+ avio_wb16(pb, 1); /* Data-reference index */
- put_be16(pb, 1); /* Hint track version */
- put_be16(pb, 1); /* Highest compatible version */
- put_be32(pb, track->max_packet_size); /* Max packet size */
+ avio_wb16(pb, 1); /* Hint track version */
+ avio_wb16(pb, 1); /* Highest compatible version */
+ avio_wb32(pb, track->max_packet_size); /* Max packet size */
- put_be32(pb, 12); /* size */
- put_tag(pb, "tims");
- put_be32(pb, track->timescale);
+ avio_wb32(pb, 12); /* size */
+ ffio_wfourcc(pb, "tims");
+ avio_wb32(pb, track->timescale);
return updateSize(pb, pos);
}
-static int mov_write_stsd_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_stsd_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, "stsd");
- put_be32(pb, 0); /* version & flags */
- put_be32(pb, 1); /* entry count */
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "stsd");
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb32(pb, 1); /* entry count */
if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
mov_write_video_tag(pb, track);
else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
@@ -886,7 +897,7 @@ static int mov_write_stsd_tag(ByteIOContext *pb, MOVTrack *track)
return updateSize(pb, pos);
}
-static int mov_write_ctts_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_ctts_tag(AVIOContext *pb, MOVTrack *track)
{
MOVStts *ctts_entries;
uint32_t entries = 0;
@@ -907,20 +918,20 @@ static int mov_write_ctts_tag(ByteIOContext *pb, MOVTrack *track)
}
entries++; /* last one */
atom_size = 16 + (entries * 8);
- put_be32(pb, atom_size); /* size */
- put_tag(pb, "ctts");
- put_be32(pb, 0); /* version & flags */
- put_be32(pb, entries); /* entry count */
+ avio_wb32(pb, atom_size); /* size */
+ ffio_wfourcc(pb, "ctts");
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb32(pb, entries); /* entry count */
for (i=0; ienc->codec_type == AVMEDIA_TYPE_VIDEO ||
@@ -997,59 +1008,59 @@ static int mov_write_stbl_tag(ByteIOContext *pb, MOVTrack *track)
return updateSize(pb, pos);
}
-static int mov_write_dinf_tag(ByteIOContext *pb)
+static int mov_write_dinf_tag(AVIOContext *pb)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, "dinf");
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "dinf");
mov_write_dref_tag(pb);
return updateSize(pb, pos);
}
-static int mov_write_nmhd_tag(ByteIOContext *pb)
+static int mov_write_nmhd_tag(AVIOContext *pb)
{
- put_be32(pb, 12);
- put_tag(pb, "nmhd");
- put_be32(pb, 0);
+ avio_wb32(pb, 12);
+ ffio_wfourcc(pb, "nmhd");
+ avio_wb32(pb, 0);
return 12;
}
-static int mov_write_gmhd_tag(ByteIOContext *pb)
+static int mov_write_gmhd_tag(AVIOContext *pb)
{
- put_be32(pb, 0x20); /* size */
- put_tag(pb, "gmhd");
- put_be32(pb, 0x18); /* gmin size */
- put_tag(pb, "gmin"); /* generic media info */
- put_be32(pb, 0); /* version & flags */
- put_be16(pb, 0x40); /* graphics mode = */
- put_be16(pb, 0x8000); /* opColor (r?) */
- put_be16(pb, 0x8000); /* opColor (g?) */
- put_be16(pb, 0x8000); /* opColor (b?) */
- put_be16(pb, 0); /* balance */
- put_be16(pb, 0); /* reserved */
+ avio_wb32(pb, 0x20); /* size */
+ ffio_wfourcc(pb, "gmhd");
+ avio_wb32(pb, 0x18); /* gmin size */
+ ffio_wfourcc(pb, "gmin");/* generic media info */
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb16(pb, 0x40); /* graphics mode = */
+ avio_wb16(pb, 0x8000); /* opColor (r?) */
+ avio_wb16(pb, 0x8000); /* opColor (g?) */
+ avio_wb16(pb, 0x8000); /* opColor (b?) */
+ avio_wb16(pb, 0); /* balance */
+ avio_wb16(pb, 0); /* reserved */
return 0x20;
}
-static int mov_write_smhd_tag(ByteIOContext *pb)
+static int mov_write_smhd_tag(AVIOContext *pb)
{
- put_be32(pb, 16); /* size */
- put_tag(pb, "smhd");
- put_be32(pb, 0); /* version & flags */
- put_be16(pb, 0); /* reserved (balance, normally = 0) */
- put_be16(pb, 0); /* reserved */
+ avio_wb32(pb, 16); /* size */
+ ffio_wfourcc(pb, "smhd");
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb16(pb, 0); /* reserved (balance, normally = 0) */
+ avio_wb16(pb, 0); /* reserved */
return 16;
}
-static int mov_write_vmhd_tag(ByteIOContext *pb)
+static int mov_write_vmhd_tag(AVIOContext *pb)
{
- put_be32(pb, 0x14); /* size (always 0x14) */
- put_tag(pb, "vmhd");
- put_be32(pb, 0x01); /* version & flags */
- put_be64(pb, 0); /* reserved (graphics mode = copy) */
+ avio_wb32(pb, 0x14); /* size (always 0x14) */
+ ffio_wfourcc(pb, "vmhd");
+ avio_wb32(pb, 0x01); /* version & flags */
+ avio_wb64(pb, 0); /* reserved (graphics mode = copy) */
return 0x14;
}
-static int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)
{
const char *hdlr, *descr = NULL, *hdlr_type = NULL;
int64_t pos = url_ftell(pb);
@@ -1076,42 +1087,42 @@ static int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack *track)
}
}
- put_be32(pb, 0); /* size */
- put_tag(pb, "hdlr");
- put_be32(pb, 0); /* Version & flags */
- put_buffer(pb, hdlr, 4); /* handler */
- put_tag(pb, hdlr_type); /* handler type */
- put_be32(pb ,0); /* reserved */
- put_be32(pb ,0); /* reserved */
- put_be32(pb ,0); /* reserved */
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "hdlr");
+ avio_wb32(pb, 0); /* Version & flags */
+ avio_write(pb, hdlr, 4); /* handler */
+ ffio_wfourcc(pb, hdlr_type); /* handler type */
+ avio_wb32(pb ,0); /* reserved */
+ avio_wb32(pb ,0); /* reserved */
+ avio_wb32(pb ,0); /* reserved */
if (!track || track->mode == MODE_MOV)
- put_byte(pb, strlen(descr)); /* pascal string */
- put_buffer(pb, descr, strlen(descr)); /* handler description */
+ avio_w8(pb, strlen(descr)); /* pascal string */
+ avio_write(pb, descr, strlen(descr)); /* handler description */
if (track && track->mode != MODE_MOV)
- put_byte(pb, 0); /* c string */
+ avio_w8(pb, 0); /* c string */
return updateSize(pb, pos);
}
-static int mov_write_hmhd_tag(ByteIOContext *pb)
+static int mov_write_hmhd_tag(AVIOContext *pb)
{
/* This atom must be present, but leaving the values at zero
* seems harmless. */
- put_be32(pb, 28); /* size */
- put_tag(pb, "hmhd");
- put_be32(pb, 0); /* version, flags */
- put_be16(pb, 0); /* maxPDUsize */
- put_be16(pb, 0); /* avgPDUsize */
- put_be32(pb, 0); /* maxbitrate */
- put_be32(pb, 0); /* avgbitrate */
- put_be32(pb, 0); /* reserved */
+ avio_wb32(pb, 28); /* size */
+ ffio_wfourcc(pb, "hmhd");
+ avio_wb32(pb, 0); /* version, flags */
+ avio_wb16(pb, 0); /* maxPDUsize */
+ avio_wb16(pb, 0); /* avgPDUsize */
+ avio_wb32(pb, 0); /* maxbitrate */
+ avio_wb32(pb, 0); /* avgbitrate */
+ avio_wb32(pb, 0); /* reserved */
return 28;
}
-static int mov_write_minf_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_minf_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, "minf");
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "minf");
if(track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
mov_write_vmhd_tag(pb);
else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
@@ -1129,25 +1140,25 @@ static int mov_write_minf_tag(ByteIOContext *pb, MOVTrack *track)
return updateSize(pb, pos);
}
-static int mov_write_mdhd_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track)
{
int version = track->trackDuration < INT32_MAX ? 0 : 1;
- (version == 1) ? put_be32(pb, 44) : put_be32(pb, 32); /* size */
- put_tag(pb, "mdhd");
- put_byte(pb, version);
- put_be24(pb, 0); /* flags */
+ (version == 1) ? avio_wb32(pb, 44) : avio_wb32(pb, 32); /* size */
+ ffio_wfourcc(pb, "mdhd");
+ avio_w8(pb, version);
+ avio_wb24(pb, 0); /* flags */
if (version == 1) {
- put_be64(pb, track->time);
- put_be64(pb, track->time);
+ avio_wb64(pb, track->time);
+ avio_wb64(pb, track->time);
} else {
- put_be32(pb, track->time); /* creation time */
- put_be32(pb, track->time); /* modification time */
+ avio_wb32(pb, track->time); /* creation time */
+ avio_wb32(pb, track->time); /* modification time */
}
- put_be32(pb, track->timescale); /* time scale (sample rate for audio) */
- (version == 1) ? put_be64(pb, track->trackDuration) : put_be32(pb, track->trackDuration); /* duration */
- put_be16(pb, track->language); /* language */
- put_be16(pb, 0); /* reserved (quality) */
+ avio_wb32(pb, track->timescale); /* time scale (sample rate for audio) */
+ (version == 1) ? avio_wb64(pb, track->trackDuration) : avio_wb32(pb, track->trackDuration); /* duration */
+ avio_wb16(pb, track->language); /* language */
+ avio_wb16(pb, 0); /* reserved (quality) */
if(version!=0 && track->mode == MODE_MOV){
av_log(NULL, AV_LOG_ERROR,
@@ -1159,124 +1170,154 @@ static int mov_write_mdhd_tag(ByteIOContext *pb, MOVTrack *track)
return 32;
}
-static int mov_write_mdia_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_mdia_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, "mdia");
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "mdia");
mov_write_mdhd_tag(pb, track);
mov_write_hdlr_tag(pb, track);
mov_write_minf_tag(pb, track);
return updateSize(pb, pos);
}
-static int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st)
+static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st)
{
int64_t duration = av_rescale_rnd(track->trackDuration, MOV_TIMESCALE,
track->timescale, AV_ROUND_UP);
int version = duration < INT32_MAX ? 0 : 1;
- (version == 1) ? put_be32(pb, 104) : put_be32(pb, 92); /* size */
- put_tag(pb, "tkhd");
- put_byte(pb, version);
- put_be24(pb, 0xf); /* flags (track enabled) */
+ (version == 1) ? avio_wb32(pb, 104) : avio_wb32(pb, 92); /* size */
+ ffio_wfourcc(pb, "tkhd");
+ avio_w8(pb, version);
+ avio_wb24(pb, 0xf); /* flags (track enabled) */
if (version == 1) {
- put_be64(pb, track->time);
- put_be64(pb, track->time);
+ avio_wb64(pb, track->time);
+ avio_wb64(pb, track->time);
} else {
- put_be32(pb, track->time); /* creation time */
- put_be32(pb, track->time); /* modification time */
+ avio_wb32(pb, track->time); /* creation time */
+ avio_wb32(pb, track->time); /* modification time */
}
- put_be32(pb, track->trackID); /* track-id */
- put_be32(pb, 0); /* reserved */
- (version == 1) ? put_be64(pb, duration) : put_be32(pb, duration);
+ avio_wb32(pb, track->trackID); /* track-id */
+ avio_wb32(pb, 0); /* reserved */
+ (version == 1) ? avio_wb64(pb, duration) : avio_wb32(pb, duration);
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0x0); /* reserved (Layer & Alternate group) */
+ avio_wb32(pb, 0); /* reserved */
+ avio_wb32(pb, 0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved (Layer & Alternate group) */
/* Volume, only for audio */
if(track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
- put_be16(pb, 0x0100);
+ avio_wb16(pb, 0x0100);
else
- put_be16(pb, 0);
- put_be16(pb, 0); /* reserved */
+ avio_wb16(pb, 0);
+ avio_wb16(pb, 0); /* reserved */
/* Matrix structure */
- put_be32(pb, 0x00010000); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x00010000); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x40000000); /* reserved */
+ avio_wb32(pb, 0x00010000); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x00010000); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x40000000); /* reserved */
/* Track width and height, for visual only */
if(st && (track->enc->codec_type == AVMEDIA_TYPE_VIDEO ||
track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
- double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);
- if(!sample_aspect_ratio || track->height != track->enc->height)
- sample_aspect_ratio = 1;
- put_be32(pb, sample_aspect_ratio * track->enc->width*0x10000);
- put_be32(pb, track->height*0x10000);
+ if(track->mode == MODE_MOV) {
+ avio_wb32(pb, track->enc->width << 16);
+ avio_wb32(pb, track->height << 16);
+ } else {
+ double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);
+ if(!sample_aspect_ratio || track->height != track->enc->height)
+ sample_aspect_ratio = 1;
+ avio_wb32(pb, sample_aspect_ratio * track->enc->width*0x10000);
+ avio_wb32(pb, track->height*0x10000);
+ }
}
else {
- put_be32(pb, 0);
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
}
return 0x5c;
}
+static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack *track)
+{
+ int32_t width = av_rescale(track->enc->sample_aspect_ratio.num, track->enc->width,
+ track->enc->sample_aspect_ratio.den);
+
+ int64_t pos = url_ftell(pb);
+
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "tapt");
+
+ avio_wb32(pb, 20);
+ ffio_wfourcc(pb, "clef");
+ avio_wb32(pb, 0);
+ avio_wb32(pb, width << 16);
+ avio_wb32(pb, track->enc->height << 16);
+
+ avio_wb32(pb, 20);
+ ffio_wfourcc(pb, "enof");
+ avio_wb32(pb, 0);
+ avio_wb32(pb, track->enc->width << 16);
+ avio_wb32(pb, track->enc->height << 16);
+
+ return updateSize(pb, pos);
+};
+
// This box seems important for the psp playback ... without it the movie seems to hang
-static int mov_write_edts_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_edts_tag(AVIOContext *pb, MOVTrack *track)
{
- put_be32(pb, 0x24); /* size */
- put_tag(pb, "edts");
- put_be32(pb, 0x1c); /* size */
- put_tag(pb, "elst");
- put_be32(pb, 0x0);
- put_be32(pb, 0x1);
+ avio_wb32(pb, 0x24); /* size */
+ ffio_wfourcc(pb, "edts");
+ avio_wb32(pb, 0x1c); /* size */
+ ffio_wfourcc(pb, "elst");
+ avio_wb32(pb, 0x0);
+ avio_wb32(pb, 0x1);
/* duration ... doesn't seem to effect psp */
- put_be32(pb, av_rescale_rnd(track->trackDuration, MOV_TIMESCALE,
+ avio_wb32(pb, av_rescale_rnd(track->trackDuration, MOV_TIMESCALE,
track->timescale, AV_ROUND_UP));
- put_be32(pb, track->cluster[0].cts); /* first pts is cts since dts is 0 */
- put_be32(pb, 0x00010000);
+ avio_wb32(pb, track->cluster[0].cts); /* first pts is cts since dts is 0 */
+ avio_wb32(pb, 0x00010000);
return 0x24;
}
-static int mov_write_tref_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_tref_tag(AVIOContext *pb, MOVTrack *track)
{
- put_be32(pb, 20); // size
- put_tag(pb, "tref");
- put_be32(pb, 12); // size (subatom)
- put_le32(pb, track->tref_tag);
- put_be32(pb, track->tref_id);
+ avio_wb32(pb, 20); // size
+ ffio_wfourcc(pb, "tref");
+ avio_wb32(pb, 12); // size (subatom)
+ avio_wl32(pb, track->tref_tag);
+ avio_wb32(pb, track->tref_id);
return 20;
}
// goes at the end of each track! ... Critical for PSP playback ("Incompatible data" without it)
-static int mov_write_uuid_tag_psp(ByteIOContext *pb, MOVTrack *mov)
-{
- put_be32(pb, 0x34); /* size ... reports as 28 in mp4box! */
- put_tag(pb, "uuid");
- put_tag(pb, "USMT");
- put_be32(pb, 0x21d24fce);
- put_be32(pb, 0xbb88695c);
- put_be32(pb, 0xfac9c740);
- put_be32(pb, 0x1c); // another size here!
- put_tag(pb, "MTDT");
- put_be32(pb, 0x00010012);
- put_be32(pb, 0x0a);
- put_be32(pb, 0x55c40000);
- put_be32(pb, 0x1);
- put_be32(pb, 0x0);
+static int mov_write_uuid_tag_psp(AVIOContext *pb, MOVTrack *mov)
+{
+ avio_wb32(pb, 0x34); /* size ... reports as 28 in mp4box! */
+ ffio_wfourcc(pb, "uuid");
+ ffio_wfourcc(pb, "USMT");
+ avio_wb32(pb, 0x21d24fce);
+ avio_wb32(pb, 0xbb88695c);
+ avio_wb32(pb, 0xfac9c740);
+ avio_wb32(pb, 0x1c); // another size here!
+ ffio_wfourcc(pb, "MTDT");
+ avio_wb32(pb, 0x00010012);
+ avio_wb32(pb, 0x0a);
+ avio_wb32(pb, 0x55c40000);
+ avio_wb32(pb, 0x1);
+ avio_wb32(pb, 0x0);
return 0x34;
}
-static int mov_write_udta_sdp(ByteIOContext *pb, AVCodecContext *ctx, int index)
+static int mov_write_udta_sdp(AVIOContext *pb, AVCodecContext *ctx, int index)
{
char buf[1000] = "";
int len;
@@ -1285,21 +1326,21 @@ static int mov_write_udta_sdp(ByteIOContext *pb, AVCodecContext *ctx, int index)
av_strlcatf(buf, sizeof(buf), "a=control:streamid=%d\r\n", index);
len = strlen(buf);
- put_be32(pb, len + 24);
- put_tag (pb, "udta");
- put_be32(pb, len + 16);
- put_tag (pb, "hnti");
- put_be32(pb, len + 8);
- put_tag (pb, "sdp ");
- put_buffer(pb, buf, len);
+ avio_wb32(pb, len + 24);
+ ffio_wfourcc(pb, "udta");
+ avio_wb32(pb, len + 16);
+ ffio_wfourcc(pb, "hnti");
+ avio_wb32(pb, len + 8);
+ ffio_wfourcc(pb, "sdp ");
+ avio_write(pb, buf, len);
return len + 24;
}
-static int mov_write_trak_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st)
+static int mov_write_trak_tag(AVIOContext *pb, MOVTrack *track, AVStream *st)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, "trak");
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "trak");
mov_write_tkhd_tag(pb, track, st);
if (track->mode == MODE_PSP || track->flags & MOV_TRACK_CTTS)
mov_write_edts_tag(pb, track); // PSP Movies require edts box
@@ -1310,26 +1351,31 @@ static int mov_write_trak_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st)
mov_write_uuid_tag_psp(pb,track); // PSP Movies require this uuid box
if (track->tag == MKTAG('r','t','p',' '))
mov_write_udta_sdp(pb, track->rtp_ctx->streams[0]->codec, track->trackID);
+ if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO && track->mode == MODE_MOV) {
+ double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);
+ if (0.0 != sample_aspect_ratio && 1.0 != sample_aspect_ratio)
+ mov_write_tapt_tag(pb, track);
+ };
return updateSize(pb, pos);
}
#if 0
/* TODO: Not sorted out, but not necessary either */
-static int mov_write_iods_tag(ByteIOContext *pb, MOVMuxContext *mov)
-{
- put_be32(pb, 0x15); /* size */
- put_tag(pb, "iods");
- put_be32(pb, 0); /* version & flags */
- put_be16(pb, 0x1007);
- put_byte(pb, 0);
- put_be16(pb, 0x4fff);
- put_be16(pb, 0xfffe);
- put_be16(pb, 0x01ff);
+static int mov_write_iods_tag(AVIOContext *pb, MOVMuxContext *mov)
+{
+ avio_wb32(pb, 0x15); /* size */
+ ffio_wfourcc(pb, "iods");
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb16(pb, 0x1007);
+ avio_w8(pb, 0);
+ avio_wb16(pb, 0x4fff);
+ avio_wb16(pb, 0xfffe);
+ avio_wb16(pb, 0x01ff);
return 0x15;
}
#endif
-static int mov_write_mvhd_tag(ByteIOContext *pb, MOVMuxContext *mov)
+static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov)
{
int maxTrackID = 1, i;
int64_t maxTrackLenTemp, maxTrackLen = 0;
@@ -1349,96 +1395,96 @@ static int mov_write_mvhd_tag(ByteIOContext *pb, MOVMuxContext *mov)
}
version = maxTrackLen < UINT32_MAX ? 0 : 1;
- (version == 1) ? put_be32(pb, 120) : put_be32(pb, 108); /* size */
- put_tag(pb, "mvhd");
- put_byte(pb, version);
- put_be24(pb, 0); /* flags */
+ (version == 1) ? avio_wb32(pb, 120) : avio_wb32(pb, 108); /* size */
+ ffio_wfourcc(pb, "mvhd");
+ avio_w8(pb, version);
+ avio_wb24(pb, 0); /* flags */
if (version == 1) {
- put_be64(pb, mov->time);
- put_be64(pb, mov->time);
+ avio_wb64(pb, mov->time);
+ avio_wb64(pb, mov->time);
} else {
- put_be32(pb, mov->time); /* creation time */
- put_be32(pb, mov->time); /* modification time */
+ avio_wb32(pb, mov->time); /* creation time */
+ avio_wb32(pb, mov->time); /* modification time */
}
- put_be32(pb, MOV_TIMESCALE);
- (version == 1) ? put_be64(pb, maxTrackLen) : put_be32(pb, maxTrackLen); /* duration of longest track */
+ avio_wb32(pb, MOV_TIMESCALE);
+ (version == 1) ? avio_wb64(pb, maxTrackLen) : avio_wb32(pb, maxTrackLen); /* duration of longest track */
- put_be32(pb, 0x00010000); /* reserved (preferred rate) 1.0 = normal */
- put_be16(pb, 0x0100); /* reserved (preferred volume) 1.0 = normal */
- put_be16(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
+ avio_wb32(pb, 0x00010000); /* reserved (preferred rate) 1.0 = normal */
+ avio_wb16(pb, 0x0100); /* reserved (preferred volume) 1.0 = normal */
+ avio_wb16(pb, 0); /* reserved */
+ avio_wb32(pb, 0); /* reserved */
+ avio_wb32(pb, 0); /* reserved */
/* Matrix structure */
- put_be32(pb, 0x00010000); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x00010000); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x40000000); /* reserved */
-
- put_be32(pb, 0); /* reserved (preview time) */
- put_be32(pb, 0); /* reserved (preview duration) */
- put_be32(pb, 0); /* reserved (poster time) */
- put_be32(pb, 0); /* reserved (selection time) */
- put_be32(pb, 0); /* reserved (selection duration) */
- put_be32(pb, 0); /* reserved (current time) */
- put_be32(pb, maxTrackID+1); /* Next track id */
+ avio_wb32(pb, 0x00010000); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x00010000); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x40000000); /* reserved */
+
+ avio_wb32(pb, 0); /* reserved (preview time) */
+ avio_wb32(pb, 0); /* reserved (preview duration) */
+ avio_wb32(pb, 0); /* reserved (poster time) */
+ avio_wb32(pb, 0); /* reserved (selection time) */
+ avio_wb32(pb, 0); /* reserved (selection duration) */
+ avio_wb32(pb, 0); /* reserved (current time) */
+ avio_wb32(pb, maxTrackID+1); /* Next track id */
return 0x6c;
}
-static int mov_write_itunes_hdlr_tag(ByteIOContext *pb, MOVMuxContext *mov,
+static int mov_write_itunes_hdlr_tag(AVIOContext *pb, MOVMuxContext *mov,
AVFormatContext *s)
{
- put_be32(pb, 33); /* size */
- put_tag(pb, "hdlr");
- put_be32(pb, 0);
- put_be32(pb, 0);
- put_tag(pb, "mdir");
- put_tag(pb, "appl");
- put_be32(pb, 0);
- put_be32(pb, 0);
- put_byte(pb, 0);
+ avio_wb32(pb, 33); /* size */
+ ffio_wfourcc(pb, "hdlr");
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
+ ffio_wfourcc(pb, "mdir");
+ ffio_wfourcc(pb, "appl");
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
+ avio_w8(pb, 0);
return 33;
}
/* helper function to write a data tag with the specified string as data */
-static int mov_write_string_data_tag(ByteIOContext *pb, const char *data, int lang, int long_style)
+static int mov_write_string_data_tag(AVIOContext *pb, const char *data, int lang, int long_style)
{
if(long_style){
int size = 16 + strlen(data);
- put_be32(pb, size); /* size */
- put_tag(pb, "data");
- put_be32(pb, 1);
- put_be32(pb, 0);
- put_buffer(pb, data, strlen(data));
+ avio_wb32(pb, size); /* size */
+ ffio_wfourcc(pb, "data");
+ avio_wb32(pb, 1);
+ avio_wb32(pb, 0);
+ avio_write(pb, data, strlen(data));
return size;
}else{
if (!lang)
lang = ff_mov_iso639_to_lang("und", 1);
- put_be16(pb, strlen(data)); /* string length */
- put_be16(pb, lang);
- put_buffer(pb, data, strlen(data));
+ avio_wb16(pb, strlen(data)); /* string length */
+ avio_wb16(pb, lang);
+ avio_write(pb, data, strlen(data));
return strlen(data) + 4;
}
}
-static int mov_write_string_tag(ByteIOContext *pb, const char *name, const char *value, int lang, int long_style){
+static int mov_write_string_tag(AVIOContext *pb, const char *name, const char *value, int lang, int long_style){
int size = 0;
if (value && value[0]) {
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, name);
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, name);
mov_write_string_data_tag(pb, value, lang, long_style);
size= updateSize(pb, pos);
}
return size;
}
-static int mov_write_string_metadata(AVFormatContext *s, ByteIOContext *pb,
+static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb,
const char *name, const char *tag,
int long_style)
{
@@ -1463,34 +1509,34 @@ static int mov_write_string_metadata(AVFormatContext *s, ByteIOContext *pb,
}
/* iTunes track number */
-static int mov_write_trkn_tag(ByteIOContext *pb, MOVMuxContext *mov,
+static int mov_write_trkn_tag(AVIOContext *pb, MOVMuxContext *mov,
AVFormatContext *s)
{
AVMetadataTag *t = av_metadata_get(s->metadata, "track", NULL, 0);
int size = 0, track = t ? atoi(t->value) : 0;
if (track) {
- put_be32(pb, 32); /* size */
- put_tag(pb, "trkn");
- put_be32(pb, 24); /* size */
- put_tag(pb, "data");
- put_be32(pb, 0); // 8 bytes empty
- put_be32(pb, 0);
- put_be16(pb, 0); // empty
- put_be16(pb, track); // track number
- put_be16(pb, 0); // total track number
- put_be16(pb, 0); // empty
+ avio_wb32(pb, 32); /* size */
+ ffio_wfourcc(pb, "trkn");
+ avio_wb32(pb, 24); /* size */
+ ffio_wfourcc(pb, "data");
+ avio_wb32(pb, 0); // 8 bytes empty
+ avio_wb32(pb, 0);
+ avio_wb16(pb, 0); // empty
+ avio_wb16(pb, track); // track number
+ avio_wb16(pb, 0); // total track number
+ avio_wb16(pb, 0); // empty
size = 32;
}
return size;
}
/* iTunes meta data list */
-static int mov_write_ilst_tag(ByteIOContext *pb, MOVMuxContext *mov,
+static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov,
AVFormatContext *s)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, "ilst");
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "ilst");
mov_write_string_metadata(s, pb, "\251nam", "title" , 1);
mov_write_string_metadata(s, pb, "\251ART", "artist" , 1);
mov_write_string_metadata(s, pb, "aART", "album_artist", 1);
@@ -1513,14 +1559,14 @@ static int mov_write_ilst_tag(ByteIOContext *pb, MOVMuxContext *mov,
}
/* iTunes meta data tag */
-static int mov_write_meta_tag(ByteIOContext *pb, MOVMuxContext *mov,
+static int mov_write_meta_tag(AVIOContext *pb, MOVMuxContext *mov,
AVFormatContext *s)
{
int size = 0;
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_tag(pb, "meta");
- put_be32(pb, 0);
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "meta");
+ avio_wb32(pb, 0);
mov_write_itunes_hdlr_tag(pb, mov, s);
mov_write_ilst_tag(pb, mov, s);
size = updateSize(pb, pos);
@@ -1538,14 +1584,14 @@ static int utf8len(const uint8_t *b)
return len;
}
-static int ascii_to_wc(ByteIOContext *pb, const uint8_t *b)
+static int ascii_to_wc(AVIOContext *pb, const uint8_t *b)
{
int val;
while(*b){
GET_UTF8(val, *b++, return -1;)
- put_be16(pb, val);
+ avio_wb16(pb, val);
}
- put_be16(pb, 0x00);
+ avio_wb16(pb, 0x00);
return 0;
}
@@ -1554,58 +1600,58 @@ static uint16_t language_code(const char *str)
return (((str[0]-0x60) & 0x1F) << 10) + (((str[1]-0x60) & 0x1F) << 5) + ((str[2]-0x60) & 0x1F);
}
-static int mov_write_3gp_udta_tag(ByteIOContext *pb, AVFormatContext *s,
+static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s,
const char *tag, const char *str)
{
int64_t pos = url_ftell(pb);
AVMetadataTag *t = av_metadata_get(s->metadata, str, NULL, 0);
if (!t || !utf8len(t->value))
return 0;
- put_be32(pb, 0); /* size */
- put_tag (pb, tag); /* type */
- put_be32(pb, 0); /* version + flags */
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, tag); /* type */
+ avio_wb32(pb, 0); /* version + flags */
if (!strcmp(tag, "yrrc"))
- put_be16(pb, atoi(t->value));
+ avio_wb16(pb, atoi(t->value));
else {
- put_be16(pb, language_code("eng")); /* language */
- put_buffer(pb, t->value, strlen(t->value)+1); /* UTF8 string value */
+ avio_wb16(pb, language_code("eng")); /* language */
+ avio_write(pb, t->value, strlen(t->value)+1); /* UTF8 string value */
if (!strcmp(tag, "albm") &&
(t = av_metadata_get(s->metadata, "track", NULL, 0)))
- put_byte(pb, atoi(t->value));
+ avio_w8(pb, atoi(t->value));
}
return updateSize(pb, pos);
}
-static int mov_write_chpl_tag(ByteIOContext *pb, AVFormatContext *s)
+static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s)
{
int64_t pos = url_ftell(pb);
int i, nb_chapters = FFMIN(s->nb_chapters, 255);
- put_be32(pb, 0); // size
- put_tag (pb, "chpl");
- put_be32(pb, 0x01000000); // version + flags
- put_be32(pb, 0); // unknown
- put_byte(pb, nb_chapters);
+ avio_wb32(pb, 0); // size
+ ffio_wfourcc(pb, "chpl");
+ avio_wb32(pb, 0x01000000); // version + flags
+ avio_wb32(pb, 0); // unknown
+ avio_w8(pb, nb_chapters);
for (i = 0; i < nb_chapters; i++) {
AVChapter *c = s->chapters[i];
AVMetadataTag *t;
- put_be64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000}));
+ avio_wb64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000}));
if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
int len = FFMIN(strlen(t->value), 255);
- put_byte(pb, len);
- put_buffer(pb, t->value, len);
+ avio_w8(pb, len);
+ avio_write(pb, t->value, len);
} else
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
return updateSize(pb, pos);
}
-static int mov_write_udta_tag(ByteIOContext *pb, MOVMuxContext *mov,
+static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
AVFormatContext *s)
{
- ByteIOContext *pb_buf;
+ AVIOContext *pb_buf;
int i, ret, size;
uint8_t *buf;
@@ -1646,53 +1692,53 @@ static int mov_write_udta_tag(ByteIOContext *pb, MOVMuxContext *mov,
mov_write_chpl_tag(pb_buf, s);
if ((size = url_close_dyn_buf(pb_buf, &buf)) > 0) {
- put_be32(pb, size+8);
- put_tag(pb, "udta");
- put_buffer(pb, buf, size);
+ avio_wb32(pb, size+8);
+ ffio_wfourcc(pb, "udta");
+ avio_write(pb, buf, size);
}
av_free(buf);
return 0;
}
-static void mov_write_psp_udta_tag(ByteIOContext *pb,
+static void mov_write_psp_udta_tag(AVIOContext *pb,
const char *str, const char *lang, int type)
{
int len = utf8len(str)+1;
if(len<=0)
return;
- put_be16(pb, len*2+10); /* size */
- put_be32(pb, type); /* type */
- put_be16(pb, language_code(lang)); /* language */
- put_be16(pb, 0x01); /* ? */
+ avio_wb16(pb, len*2+10); /* size */
+ avio_wb32(pb, type); /* type */
+ avio_wb16(pb, language_code(lang)); /* language */
+ avio_wb16(pb, 0x01); /* ? */
ascii_to_wc(pb, str);
}
-static int mov_write_uuidusmt_tag(ByteIOContext *pb, AVFormatContext *s)
+static int mov_write_uuidusmt_tag(AVIOContext *pb, AVFormatContext *s)
{
AVMetadataTag *title = av_metadata_get(s->metadata, "title", NULL, 0);
int64_t pos, pos2;
if (title) {
pos = url_ftell(pb);
- put_be32(pb, 0); /* size placeholder*/
- put_tag(pb, "uuid");
- put_tag(pb, "USMT");
- put_be32(pb, 0x21d24fce); /* 96 bit UUID */
- put_be32(pb, 0xbb88695c);
- put_be32(pb, 0xfac9c740);
+ avio_wb32(pb, 0); /* size placeholder*/
+ ffio_wfourcc(pb, "uuid");
+ ffio_wfourcc(pb, "USMT");
+ avio_wb32(pb, 0x21d24fce); /* 96 bit UUID */
+ avio_wb32(pb, 0xbb88695c);
+ avio_wb32(pb, 0xfac9c740);
pos2 = url_ftell(pb);
- put_be32(pb, 0); /* size placeholder*/
- put_tag(pb, "MTDT");
- put_be16(pb, 4);
+ avio_wb32(pb, 0); /* size placeholder*/
+ ffio_wfourcc(pb, "MTDT");
+ avio_wb16(pb, 4);
// ?
- put_be16(pb, 0x0C); /* size */
- put_be32(pb, 0x0B); /* type */
- put_be16(pb, language_code("und")); /* language */
- put_be16(pb, 0x0); /* ? */
- put_be16(pb, 0x021C); /* data */
+ avio_wb16(pb, 0x0C); /* size */
+ avio_wb32(pb, 0x0B); /* type */
+ avio_wb16(pb, language_code("und")); /* language */
+ avio_wb16(pb, 0x0); /* ? */
+ avio_wb16(pb, 0x021C); /* data */
mov_write_psp_udta_tag(pb, LIBAVCODEC_IDENT, "eng", 0x04);
mov_write_psp_udta_tag(pb, title->value, "eng", 0x01);
@@ -1706,13 +1752,13 @@ static int mov_write_uuidusmt_tag(ByteIOContext *pb, AVFormatContext *s)
return 0;
}
-static int mov_write_moov_tag(ByteIOContext *pb, MOVMuxContext *mov,
+static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov,
AVFormatContext *s)
{
int i;
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size placeholder*/
- put_tag(pb, "moov");
+ avio_wb32(pb, 0); /* size placeholder*/
+ ffio_wfourcc(pb, "moov");
for (i=0; inb_streams; i++) {
if(mov->tracks[i].entry <= 0) continue;
@@ -1750,19 +1796,19 @@ static int mov_write_moov_tag(ByteIOContext *pb, MOVMuxContext *mov,
return updateSize(pb, pos);
}
-static int mov_write_mdat_tag(ByteIOContext *pb, MOVMuxContext *mov)
+static int mov_write_mdat_tag(AVIOContext *pb, MOVMuxContext *mov)
{
- put_be32(pb, 8); // placeholder for extended size field (64 bit)
- put_tag(pb, mov->mode == MODE_MOV ? "wide" : "free");
+ avio_wb32(pb, 8); // placeholder for extended size field (64 bit)
+ ffio_wfourcc(pb, mov->mode == MODE_MOV ? "wide" : "free");
mov->mdat_pos = url_ftell(pb);
- put_be32(pb, 0); /* size placeholder*/
- put_tag(pb, "mdat");
+ avio_wb32(pb, 0); /* size placeholder*/
+ ffio_wfourcc(pb, "mdat");
return 0;
}
/* TODO: This needs to be more general */
-static int mov_write_ftyp_tag(ByteIOContext *pb, AVFormatContext *s)
+static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
{
MOVMuxContext *mov = s->priv_data;
int64_t pos = url_ftell(pb);
@@ -1778,47 +1824,47 @@ static int mov_write_ftyp_tag(ByteIOContext *pb, AVFormatContext *s)
has_h264 = 1;
}
- put_be32(pb, 0); /* size */
- put_tag(pb, "ftyp");
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "ftyp");
if (mov->mode == MODE_3GP) {
- put_tag(pb, has_h264 ? "3gp6" : "3gp4");
+ ffio_wfourcc(pb, has_h264 ? "3gp6" : "3gp4");
minor = has_h264 ? 0x100 : 0x200;
} else if (mov->mode & MODE_3G2) {
- put_tag(pb, has_h264 ? "3g2b" : "3g2a");
+ ffio_wfourcc(pb, has_h264 ? "3g2b" : "3g2a");
minor = has_h264 ? 0x20000 : 0x10000;
}else if (mov->mode == MODE_PSP)
- put_tag(pb, "MSNV");
+ ffio_wfourcc(pb, "MSNV");
else if (mov->mode == MODE_MP4)
- put_tag(pb, "isom");
+ ffio_wfourcc(pb, "isom");
else if (mov->mode == MODE_IPOD)
- put_tag(pb, has_video ? "M4V ":"M4A ");
+ ffio_wfourcc(pb, has_video ? "M4V ":"M4A ");
else
- put_tag(pb, "qt ");
+ ffio_wfourcc(pb, "qt ");
- put_be32(pb, minor);
+ avio_wb32(pb, minor);
if(mov->mode == MODE_MOV)
- put_tag(pb, "qt ");
+ ffio_wfourcc(pb, "qt ");
else{
- put_tag(pb, "isom");
- put_tag(pb, "iso2");
+ ffio_wfourcc(pb, "isom");
+ ffio_wfourcc(pb, "iso2");
if(has_h264)
- put_tag(pb, "avc1");
+ ffio_wfourcc(pb, "avc1");
}
if (mov->mode == MODE_3GP)
- put_tag(pb, has_h264 ? "3gp6":"3gp4");
+ ffio_wfourcc(pb, has_h264 ? "3gp6":"3gp4");
else if (mov->mode & MODE_3G2)
- put_tag(pb, has_h264 ? "3g2b":"3g2a");
+ ffio_wfourcc(pb, has_h264 ? "3g2b":"3g2a");
else if (mov->mode == MODE_PSP)
- put_tag(pb, "MSNV");
+ ffio_wfourcc(pb, "MSNV");
else if (mov->mode == MODE_MP4)
- put_tag(pb, "mp41");
+ ffio_wfourcc(pb, "mp41");
return updateSize(pb, pos);
}
-static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s)
+static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
{
AVCodecContext *VideoCodec = s->streams[0]->codec;
AVCodecContext *AudioCodec = s->streams[1]->codec;
@@ -1827,56 +1873,56 @@ static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s)
int audio_kbitrate= AudioCodec->bit_rate / 1000;
int video_kbitrate= FFMIN(VideoCodec->bit_rate / 1000, 800 - audio_kbitrate);
- put_be32(pb, 0x94); /* size */
- put_tag(pb, "uuid");
- put_tag(pb, "PROF");
-
- put_be32(pb, 0x21d24fce); /* 96 bit UUID */
- put_be32(pb, 0xbb88695c);
- put_be32(pb, 0xfac9c740);
-
- put_be32(pb, 0x0); /* ? */
- put_be32(pb, 0x3); /* 3 sections ? */
-
- put_be32(pb, 0x14); /* size */
- put_tag(pb, "FPRF");
- put_be32(pb, 0x0); /* ? */
- put_be32(pb, 0x0); /* ? */
- put_be32(pb, 0x0); /* ? */
-
- put_be32(pb, 0x2c); /* size */
- put_tag(pb, "APRF"); /* audio */
- put_be32(pb, 0x0);
- put_be32(pb, 0x2); /* TrackID */
- put_tag(pb, "mp4a");
- put_be32(pb, 0x20f);
- put_be32(pb, 0x0);
- put_be32(pb, audio_kbitrate);
- put_be32(pb, audio_kbitrate);
- put_be32(pb, AudioRate);
- put_be32(pb, AudioCodec->channels);
-
- put_be32(pb, 0x34); /* size */
- put_tag(pb, "VPRF"); /* video */
- put_be32(pb, 0x0);
- put_be32(pb, 0x1); /* TrackID */
+ avio_wb32(pb, 0x94); /* size */
+ ffio_wfourcc(pb, "uuid");
+ ffio_wfourcc(pb, "PROF");
+
+ avio_wb32(pb, 0x21d24fce); /* 96 bit UUID */
+ avio_wb32(pb, 0xbb88695c);
+ avio_wb32(pb, 0xfac9c740);
+
+ avio_wb32(pb, 0x0); /* ? */
+ avio_wb32(pb, 0x3); /* 3 sections ? */
+
+ avio_wb32(pb, 0x14); /* size */
+ ffio_wfourcc(pb, "FPRF");
+ avio_wb32(pb, 0x0); /* ? */
+ avio_wb32(pb, 0x0); /* ? */
+ avio_wb32(pb, 0x0); /* ? */
+
+ avio_wb32(pb, 0x2c); /* size */
+ ffio_wfourcc(pb, "APRF");/* audio */
+ avio_wb32(pb, 0x0);
+ avio_wb32(pb, 0x2); /* TrackID */
+ ffio_wfourcc(pb, "mp4a");
+ avio_wb32(pb, 0x20f);
+ avio_wb32(pb, 0x0);
+ avio_wb32(pb, audio_kbitrate);
+ avio_wb32(pb, audio_kbitrate);
+ avio_wb32(pb, AudioRate);
+ avio_wb32(pb, AudioCodec->channels);
+
+ avio_wb32(pb, 0x34); /* size */
+ ffio_wfourcc(pb, "VPRF"); /* video */
+ avio_wb32(pb, 0x0);
+ avio_wb32(pb, 0x1); /* TrackID */
if (VideoCodec->codec_id == CODEC_ID_H264) {
- put_tag(pb, "avc1");
- put_be16(pb, 0x014D);
- put_be16(pb, 0x0015);
+ ffio_wfourcc(pb, "avc1");
+ avio_wb16(pb, 0x014D);
+ avio_wb16(pb, 0x0015);
} else {
- put_tag(pb, "mp4v");
- put_be16(pb, 0x0000);
- put_be16(pb, 0x0103);
+ ffio_wfourcc(pb, "mp4v");
+ avio_wb16(pb, 0x0000);
+ avio_wb16(pb, 0x0103);
}
- put_be32(pb, 0x0);
- put_be32(pb, video_kbitrate);
- put_be32(pb, video_kbitrate);
- put_be32(pb, FrameRate);
- put_be32(pb, FrameRate);
- put_be16(pb, VideoCodec->width);
- put_be16(pb, VideoCodec->height);
- put_be32(pb, 0x010001); /* ? */
+ avio_wb32(pb, 0x0);
+ avio_wb32(pb, video_kbitrate);
+ avio_wb32(pb, video_kbitrate);
+ avio_wb32(pb, FrameRate);
+ avio_wb32(pb, FrameRate);
+ avio_wb16(pb, VideoCodec->width);
+ avio_wb16(pb, VideoCodec->height);
+ avio_wb32(pb, 0x010001); /* ? */
}
static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags)
@@ -1903,7 +1949,7 @@ static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags)
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
{
MOVMuxContext *mov = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
MOVTrack *trk = &mov->tracks[pkt->stream_index];
AVCodecContext *enc = trk->enc;
unsigned int samplesInChunk = 0;
@@ -1946,7 +1992,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
/* nal reformating needed */
size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
} else {
- put_buffer(pb, pkt->data, size);
+ avio_write(pb, pkt->data, size);
}
if ((enc->codec_id == CODEC_ID_DNXHD ||
@@ -1981,7 +2027,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
trk->cluster[trk->entry].cts = pkt->pts - pkt->dts;
trk->cluster[trk->entry].flags = 0;
if (pkt->flags & AV_PKT_FLAG_KEY) {
- if (mov->mode == MODE_MOV && enc->codec_id == CODEC_ID_MPEG2VIDEO) {
+ if (mov->mode == MODE_MOV && enc->codec_id == CODEC_ID_MPEG2VIDEO &&
+ trk->entry > 0) { // force sync sample for the first key frame
mov_parse_mpeg2_frame(pkt, &trk->cluster[trk->entry].flags);
if (trk->cluster[trk->entry].flags & MOV_PARTIAL_SYNC_SAMPLE)
trk->flags |= MOV_TRACK_STPS;
@@ -2039,7 +2086,7 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
static int mov_write_header(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
MOVMuxContext *mov = s->priv_data;
int i, hint_track = 0;
@@ -2191,7 +2238,7 @@ static int mov_write_header(AVFormatContext *s)
static int mov_write_trailer(AVFormatContext *s)
{
MOVMuxContext *mov = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int res = 0;
int i;
@@ -2199,16 +2246,16 @@ static int mov_write_trailer(AVFormatContext *s)
/* Write size of mdat tag */
if (mov->mdat_size+8 <= UINT32_MAX) {
- url_fseek(pb, mov->mdat_pos, SEEK_SET);
- put_be32(pb, mov->mdat_size+8);
+ avio_seek(pb, mov->mdat_pos, SEEK_SET);
+ avio_wb32(pb, mov->mdat_size+8);
} else {
/* overwrite 'wide' placeholder atom */
- url_fseek(pb, mov->mdat_pos - 8, SEEK_SET);
- put_be32(pb, 1); /* special value: real atom size will be 64 bit value after tag field */
- put_tag(pb, "mdat");
- put_be64(pb, mov->mdat_size+16);
+ avio_seek(pb, mov->mdat_pos - 8, SEEK_SET);
+ avio_wb32(pb, 1); /* special value: real atom size will be 64 bit value after tag field */
+ ffio_wfourcc(pb, "mdat");
+ avio_wb64(pb, mov->mdat_size+16);
}
- url_fseek(pb, moov_pos, SEEK_SET);
+ avio_seek(pb, moov_pos, SEEK_SET);
mov_write_moov_tag(pb, mov, s);
diff --git a/mplayer/ffmpeg/libavformat/movenchint.c b/mplayer/ffmpeg/libavformat/movenchint.c
index 2ebe8b80..e6f74cdb 100644
--- a/mplayer/ffmpeg/libavformat/movenchint.c
+++ b/mplayer/ffmpeg/libavformat/movenchint.c
@@ -22,6 +22,7 @@
#include "movenc.h"
#include "libavutil/intreadwrite.h"
#include "internal.h"
+#include "rtpenc_chain.h"
int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)
{
@@ -30,44 +31,20 @@ int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)
MOVTrack *src_track = &mov->tracks[src_index];
AVStream *src_st = s->streams[src_index];
int ret = AVERROR(ENOMEM);
- AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
track->tag = MKTAG('r','t','p',' ');
track->src_track = src_index;
- if (!rtp_format) {
- ret = AVERROR(ENOENT);
- goto fail;
- }
-
track->enc = avcodec_alloc_context();
if (!track->enc)
goto fail;
track->enc->codec_type = AVMEDIA_TYPE_DATA;
track->enc->codec_tag = track->tag;
- track->rtp_ctx = avformat_alloc_context();
+ track->rtp_ctx = ff_rtp_chain_mux_open(s, src_st, NULL,
+ RTP_MAX_PACKET_SIZE);
if (!track->rtp_ctx)
goto fail;
- track->rtp_ctx->oformat = rtp_format;
- if (!av_new_stream(track->rtp_ctx, 0))
- goto fail;
-
- /* Copy stream parameters */
- track->rtp_ctx->streams[0]->sample_aspect_ratio =
- src_st->sample_aspect_ratio;
-
- /* Remove the allocated codec context, link to the original one
- * instead, to give the rtp muxer access to codec parameters. */
- av_free(track->rtp_ctx->streams[0]->codec);
- track->rtp_ctx->streams[0]->codec = src_st->codec;
-
- if ((ret = url_open_dyn_packet_buf(&track->rtp_ctx->pb,
- RTP_MAX_PACKET_SIZE)) < 0)
- goto fail;
- ret = av_write_header(track->rtp_ctx);
- if (ret)
- goto fail;
/* Copy the RTP AVStream timebase back to the hint AVStream */
track->timescale = track->rtp_ctx->streams[0]->time_base.den;
@@ -79,22 +56,8 @@ int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)
fail:
av_log(s, AV_LOG_WARNING,
"Unable to initialize hinting of stream %d\n", src_index);
- if (track->rtp_ctx && track->rtp_ctx->pb) {
- uint8_t *buf;
- url_close_dyn_buf(track->rtp_ctx->pb, &buf);
- av_free(buf);
- }
- if (track->rtp_ctx && track->rtp_ctx->streams[0]) {
- av_metadata_free(&track->rtp_ctx->streams[0]->metadata);
- av_free(track->rtp_ctx->streams[0]);
- }
- if (track->rtp_ctx) {
- av_metadata_free(&track->rtp_ctx->metadata);
- av_free(track->rtp_ctx->priv_data);
- av_freep(&track->rtp_ctx);
- }
av_freep(&track->enc);
- /* Set a default timescale, to avoid crashes in dump_format */
+ /* Set a default timescale, to avoid crashes in av_dump_format */
track->timescale = 90000;
return ret;
}
@@ -282,40 +245,40 @@ static int find_sample_match(const uint8_t *data, int len,
}
static void output_immediate(const uint8_t *data, int size,
- ByteIOContext *out, int *entries)
+ AVIOContext *out, int *entries)
{
while (size > 0) {
int len = size;
if (len > 14)
len = 14;
- put_byte(out, 1); /* immediate constructor */
- put_byte(out, len); /* amount of valid data */
- put_buffer(out, data, len);
+ avio_w8(out, 1); /* immediate constructor */
+ avio_w8(out, len); /* amount of valid data */
+ avio_write(out, data, len);
data += len;
size -= len;
for (; len < 14; len++)
- put_byte(out, 0);
+ avio_w8(out, 0);
(*entries)++;
}
}
-static void output_match(ByteIOContext *out, int match_sample,
+static void output_match(AVIOContext *out, int match_sample,
int match_offset, int match_len, int *entries)
{
- put_byte(out, 2); /* sample constructor */
- put_byte(out, 0); /* track reference */
- put_be16(out, match_len);
- put_be32(out, match_sample);
- put_be32(out, match_offset);
- put_be16(out, 1); /* bytes per block */
- put_be16(out, 1); /* samples per block */
+ avio_w8(out, 2); /* sample constructor */
+ avio_w8(out, 0); /* track reference */
+ avio_wb16(out, match_len);
+ avio_wb32(out, match_sample);
+ avio_wb32(out, match_offset);
+ avio_wb16(out, 1); /* bytes per block */
+ avio_wb16(out, 1); /* samples per block */
(*entries)++;
}
static void describe_payload(const uint8_t *data, int size,
- ByteIOContext *out, int *entries,
+ AVIOContext *out, int *entries,
HintSampleQueue *queue)
{
/* Describe the payload using different constructors */
@@ -346,7 +309,7 @@ static void describe_payload(const uint8_t *data, int size,
* @param pts pointer where the timestamp for the written RTP hint is stored
* @return the number of RTP packets in the written hint
*/
-static int write_hint_packets(ByteIOContext *out, const uint8_t *data,
+static int write_hint_packets(AVIOContext *out, const uint8_t *data,
int size, MOVTrack *trk, int64_t *pts)
{
int64_t curpos;
@@ -355,8 +318,8 @@ static int write_hint_packets(ByteIOContext *out, const uint8_t *data,
count_pos = url_ftell(out);
/* RTPsample header */
- put_be16(out, 0); /* packet count */
- put_be16(out, 0); /* reserved */
+ avio_wb16(out, 0); /* packet count */
+ avio_wb16(out, 0); /* reserved */
while (size > 4) {
uint32_t packet_len = AV_RB32(data);
@@ -391,12 +354,12 @@ static int write_hint_packets(ByteIOContext *out, const uint8_t *data,
count++;
/* RTPpacket header */
- put_be32(out, 0); /* relative_time */
- put_buffer(out, data, 2); /* RTP header */
- put_be16(out, seq); /* RTPsequenceseed */
- put_be16(out, 0); /* reserved + flags */
+ avio_wb32(out, 0); /* relative_time */
+ avio_write(out, data, 2); /* RTP header */
+ avio_wb16(out, seq); /* RTPsequenceseed */
+ avio_wb16(out, 0); /* reserved + flags */
entries_pos = url_ftell(out);
- put_be16(out, 0); /* entry count */
+ avio_wb16(out, 0); /* entry count */
data += 12;
size -= 12;
@@ -409,15 +372,15 @@ static int write_hint_packets(ByteIOContext *out, const uint8_t *data,
size -= packet_len;
curpos = url_ftell(out);
- url_fseek(out, entries_pos, SEEK_SET);
- put_be16(out, entries);
- url_fseek(out, curpos, SEEK_SET);
+ avio_seek(out, entries_pos, SEEK_SET);
+ avio_wb16(out, entries);
+ avio_seek(out, curpos, SEEK_SET);
}
curpos = url_ftell(out);
- url_fseek(out, count_pos, SEEK_SET);
- put_be16(out, count);
- url_fseek(out, curpos, SEEK_SET);
+ avio_seek(out, count_pos, SEEK_SET);
+ avio_wb16(out, count);
+ avio_seek(out, curpos, SEEK_SET);
return count;
}
@@ -429,7 +392,7 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt,
AVFormatContext *rtp_ctx = trk->rtp_ctx;
uint8_t *buf = NULL;
int size;
- ByteIOContext *hintbuf = NULL;
+ AVIOContext *hintbuf = NULL;
AVPacket hint_pkt;
int ret = 0, count;
@@ -488,9 +451,6 @@ void ff_mov_close_hinting(MOVTrack *track) {
url_close_dyn_buf(rtp_ctx->pb, &ptr);
av_free(ptr);
}
- av_metadata_free(&rtp_ctx->streams[0]->metadata);
- av_metadata_free(&rtp_ctx->metadata);
- av_free(rtp_ctx->streams[0]);
- av_freep(&rtp_ctx);
+ avformat_free_context(rtp_ctx);
}
diff --git a/mplayer/ffmpeg/libavformat/mp3dec.c b/mplayer/ffmpeg/libavformat/mp3dec.c
index 5bc4ce64..f90348c1 100644
--- a/mplayer/ffmpeg/libavformat/mp3dec.c
+++ b/mplayer/ffmpeg/libavformat/mp3dec.c
@@ -80,7 +80,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
MPADecodeHeader c;
int vbrtag_size = 0;
- v = get_be32(s->pb);
+ v = avio_rb32(s->pb);
if(ff_mpa_check_header(v) < 0)
return -1;
@@ -90,26 +90,26 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
return -1;
/* Check for Xing / Info tag */
- url_fseek(s->pb, xing_offtbl[c.lsf == 1][c.nb_channels == 1], SEEK_CUR);
- v = get_be32(s->pb);
+ avio_seek(s->pb, xing_offtbl[c.lsf == 1][c.nb_channels == 1], SEEK_CUR);
+ v = avio_rb32(s->pb);
if(v == MKBETAG('X', 'i', 'n', 'g') || v == MKBETAG('I', 'n', 'f', 'o')) {
- v = get_be32(s->pb);
+ v = avio_rb32(s->pb);
if(v & 0x1)
- frames = get_be32(s->pb);
+ frames = avio_rb32(s->pb);
if(v & 0x2)
- size = get_be32(s->pb);
+ size = avio_rb32(s->pb);
}
/* Check for VBRI tag (always 32 bytes after end of mpegaudio header) */
- url_fseek(s->pb, base + 4 + 32, SEEK_SET);
- v = get_be32(s->pb);
+ avio_seek(s->pb, base + 4 + 32, SEEK_SET);
+ v = avio_rb32(s->pb);
if(v == MKBETAG('V', 'B', 'R', 'I')) {
/* Check tag version */
- if(get_be16(s->pb) == 1) {
+ if(avio_rb16(s->pb) == 1) {
/* skip delay and quality */
- url_fseek(s->pb, 4, SEEK_CUR);
- frames = get_be32(s->pb);
- size = get_be32(s->pb);
+ avio_seek(s->pb, 4, SEEK_CUR);
+ frames = avio_rb32(s->pb);
+ size = avio_rb32(s->pb);
}
}
@@ -117,7 +117,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
return -1;
/* Skip the vbr tag frame */
- url_fseek(s->pb, base + vbrtag_size, SEEK_SET);
+ avio_seek(s->pb, base + vbrtag_size, SEEK_SET);
spf = c.lsf ? 576 : 1152; /* Samples per frame, layer 3 */
if(frames)
@@ -153,7 +153,7 @@ static int mp3_read_header(AVFormatContext *s,
ff_id3v1_read(s);
if (mp3_parse_vbr_tags(s, st, off) < 0)
- url_fseek(s->pb, off, SEEK_SET);
+ avio_seek(s->pb, off, SEEK_SET);
/* the parameters will be extracted from the compressed bitstream */
return 0;
diff --git a/mplayer/ffmpeg/libavformat/mp3enc.c b/mplayer/ffmpeg/libavformat/mp3enc.c
index b2c0a7e6..c4654206 100644
--- a/mplayer/ffmpeg/libavformat/mp3enc.c
+++ b/mplayer/ffmpeg/libavformat/mp3enc.c
@@ -71,10 +71,16 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
static void id3v2_put_size(AVFormatContext *s, int size)
{
- put_byte(s->pb, size >> 21 & 0x7f);
- put_byte(s->pb, size >> 14 & 0x7f);
- put_byte(s->pb, size >> 7 & 0x7f);
- put_byte(s->pb, size & 0x7f);
+ avio_w8(s->pb, size >> 21 & 0x7f);
+ avio_w8(s->pb, size >> 14 & 0x7f);
+ avio_w8(s->pb, size >> 7 & 0x7f);
+ avio_w8(s->pb, size & 0x7f);
+}
+
+static int string_is_ascii(const uint8_t *str)
+{
+ while (*str && *str < 128) str++;
+ return !*str;
}
/**
@@ -87,14 +93,20 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2
{
int len;
uint8_t *pb;
- int (*put)(ByteIOContext*, const char*);
- ByteIOContext *dyn_buf;
+ int (*put)(AVIOContext*, const char*);
+ AVIOContext *dyn_buf;
if (url_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
- put_byte(dyn_buf, enc);
+ /* check if the strings are ASCII-only and use UTF16 only if
+ * they're not */
+ if (enc == ID3v2_ENCODING_UTF16BOM && string_is_ascii(str1) &&
+ (!str2 || string_is_ascii(str2)))
+ enc = ID3v2_ENCODING_ISO8859;
+
+ avio_w8(dyn_buf, enc);
if (enc == ID3v2_ENCODING_UTF16BOM) {
- put_le16(dyn_buf, 0xFEFF); /* BOM */
+ avio_wl16(dyn_buf, 0xFEFF); /* BOM */
put = avio_put_str16le;
} else
put = avio_put_str;
@@ -104,10 +116,10 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2
put(dyn_buf, str2);
len = url_close_dyn_buf(dyn_buf, &pb);
- put_be32(s->pb, tag);
+ avio_wb32(s->pb, tag);
id3v2_put_size(s, len);
- put_be16(s->pb, 0);
- put_buffer(s->pb, pb, len);
+ avio_wb16(s->pb, 0);
+ avio_write(s->pb, pb, len);
av_freep(&pb);
return len + ID3v2_HEADER_SIZE;
@@ -116,7 +128,7 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2
static int mp3_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
return 0;
}
@@ -127,7 +139,7 @@ static int mp3_write_trailer(struct AVFormatContext *s)
/* write the id3v1 tag */
if (id3v1_create_tag(s, buf) > 0) {
- put_buffer(s->pb, buf, ID3v1_TAG_SIZE);
+ avio_write(s->pb, buf, ID3v1_TAG_SIZE);
put_flush_packet(s->pb);
}
return 0;
@@ -194,13 +206,13 @@ static int mp3_write_header(struct AVFormatContext *s)
ID3v2_ENCODING_UTF8;
int64_t size_pos, cur_pos;
- put_be32(s->pb, MKBETAG('I', 'D', '3', mp3->id3v2_version));
- put_byte(s->pb, 0);
- put_byte(s->pb, 0); /* flags */
+ avio_wb32(s->pb, MKBETAG('I', 'D', '3', mp3->id3v2_version));
+ avio_w8(s->pb, 0);
+ avio_w8(s->pb, 0); /* flags */
/* reserve space for size */
size_pos = url_ftell(s->pb);
- put_be32(s->pb, 0);
+ avio_wb32(s->pb, 0);
ff_metadata_conv(&s->metadata, ff_id3v2_34_metadata_conv, NULL);
if (mp3->id3v2_version == 4)
@@ -226,9 +238,9 @@ static int mp3_write_header(struct AVFormatContext *s)
}
cur_pos = url_ftell(s->pb);
- url_fseek(s->pb, size_pos, SEEK_SET);
+ avio_seek(s->pb, size_pos, SEEK_SET);
id3v2_put_size(s, totlen);
- url_fseek(s->pb, cur_pos, SEEK_SET);
+ avio_seek(s->pb, cur_pos, SEEK_SET);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/mpc.c b/mplayer/ffmpeg/libavformat/mpc.c
index aa057260..c2293836 100644
--- a/mplayer/ffmpeg/libavformat/mpc.c
+++ b/mplayer/ffmpeg/libavformat/mpc.c
@@ -55,16 +55,16 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap)
MPCContext *c = s->priv_data;
AVStream *st;
- if(get_le24(s->pb) != MKTAG('M', 'P', '+', 0)){
+ if(avio_rl24(s->pb) != MKTAG('M', 'P', '+', 0)){
av_log(s, AV_LOG_ERROR, "Not a Musepack file\n");
return -1;
}
- c->ver = get_byte(s->pb);
+ c->ver = avio_r8(s->pb);
if(c->ver != 0x07 && c->ver != 0x17){
av_log(s, AV_LOG_ERROR, "Can demux Musepack SV7, got version %02X\n", c->ver);
return -1;
}
- c->fcount = get_le32(s->pb);
+ c->fcount = avio_rl32(s->pb);
if((int64_t)c->fcount * sizeof(MPCFrame) >= UINT_MAX){
av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n");
return -1;
@@ -85,7 +85,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->extradata_size = 16;
st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(s->pb, st->codec->extradata, 16);
+ avio_read(s->pb, st->codec->extradata, 16);
st->codec->sample_rate = mpc_rate[st->codec->extradata[2] & 3];
av_set_pts_info(st, 32, MPC_FRAMESIZE, st->codec->sample_rate);
/* scan for seekpoints */
@@ -98,7 +98,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap)
ff_ape_parse_tag(s);
if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
ff_id3v1_read(s);
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
}
return 0;
@@ -114,22 +114,22 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
return -1;
if(c->curframe != c->lastframe + 1){
- url_fseek(s->pb, c->frames[c->curframe].pos, SEEK_SET);
+ avio_seek(s->pb, c->frames[c->curframe].pos, SEEK_SET);
c->curbits = c->frames[c->curframe].skip;
}
c->lastframe = c->curframe;
c->curframe++;
curbits = c->curbits;
pos = url_ftell(s->pb);
- tmp = get_le32(s->pb);
+ tmp = avio_rl32(s->pb);
if(curbits <= 12){
size2 = (tmp >> (12 - curbits)) & 0xFFFFF;
}else{
- tmp = (tmp << 32) | get_le32(s->pb);
+ tmp = (tmp << 32) | avio_rl32(s->pb);
size2 = (tmp >> (44 - curbits)) & 0xFFFFF;
}
curbits += 20;
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
size = ((size2 + curbits + 31) & ~31) >> 3;
if(cur == c->frames_noted){
@@ -151,9 +151,9 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index = 0;
pkt->pts = cur;
- ret = get_buffer(s->pb, pkt->data + 4, size);
+ ret = avio_read(s->pb, pkt->data + 4, size);
if(c->curbits)
- url_fseek(s->pb, -4, SEEK_CUR);
+ avio_seek(s->pb, -4, SEEK_CUR);
if(ret < size){
av_free_packet(pkt);
return AVERROR(EIO);
diff --git a/mplayer/ffmpeg/libavformat/mpc8.c b/mplayer/ffmpeg/libavformat/mpc8.c
index 11173004..9d8a4d80 100644
--- a/mplayer/ffmpeg/libavformat/mpc8.c
+++ b/mplayer/ffmpeg/libavformat/mpc8.c
@@ -117,11 +117,11 @@ static inline int64_t gb_get_v(GetBitContext *gb)
return v;
}
-static void mpc8_get_chunk_header(ByteIOContext *pb, int *tag, int64_t *size)
+static void mpc8_get_chunk_header(AVIOContext *pb, int *tag, int64_t *size)
{
int64_t pos;
pos = url_ftell(pb);
- *tag = get_le16(pb);
+ *tag = avio_rl16(pb);
*size = ff_get_v(pb);
*size -= url_ftell(pb) - pos;
}
@@ -135,7 +135,7 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off)
int i, t, seekd;
GetBitContext gb;
- url_fseek(s->pb, off, SEEK_SET);
+ avio_seek(s->pb, off, SEEK_SET);
mpc8_get_chunk_header(s->pb, &tag, &size);
if(tag != TAG_SEEKTABLE){
av_log(s, AV_LOG_ERROR, "No seek table at given position\n");
@@ -143,7 +143,7 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off)
}
if(!(buf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE)))
return;
- get_buffer(s->pb, buf, size);
+ avio_read(s->pb, buf, size);
init_get_bits(&gb, buf, size * 8);
size = gb_get_v(&gb);
if(size > UINT_MAX/4 || size > c->samples/1152){
@@ -171,7 +171,7 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off)
static void mpc8_handle_chunk(AVFormatContext *s, int tag, int64_t chunk_pos, int64_t size)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pos, off;
switch(tag){
@@ -179,23 +179,23 @@ static void mpc8_handle_chunk(AVFormatContext *s, int tag, int64_t chunk_pos, in
pos = url_ftell(pb) + size;
off = ff_get_v(pb);
mpc8_parse_seektable(s, chunk_pos + off);
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, pos, SEEK_SET);
break;
default:
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
}
}
static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
MPCContext *c = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
int tag = 0;
int64_t size, pos;
c->header_pos = url_ftell(pb);
- if(get_le32(pb) != TAG_MPCK){
+ if(avio_rl32(pb) != TAG_MPCK){
av_log(s, AV_LOG_ERROR, "Not a Musepack8 file\n");
return -1;
}
@@ -212,8 +212,8 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1;
}
pos = url_ftell(pb);
- url_fskip(pb, 4); //CRC
- c->ver = get_byte(pb);
+ avio_seek(pb, 4, SEEK_CUR); //CRC
+ c->ver = avio_r8(pb);
if(c->ver != 8){
av_log(s, AV_LOG_ERROR, "Unknown stream version %d\n", c->ver);
return -1;
@@ -230,7 +230,7 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->extradata_size = 2;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(pb, st->codec->extradata, st->codec->extradata_size);
st->codec->channels = (st->codec->extradata[1] >> 4) + 1;
st->codec->sample_rate = mpc8_rate[st->codec->extradata[0] >> 5];
@@ -273,7 +273,7 @@ static int mpc8_read_seek(AVFormatContext *s, int stream_index, int64_t timestam
int index = av_index_search_timestamp(st, timestamp, flags);
if(index < 0) return -1;
- url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET);
+ avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET);
c->frame = st->index_entries[index].timestamp;
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/mpeg.c b/mplayer/ffmpeg/libavformat/mpeg.c
index 135482b7..a1ba6aa2 100644
--- a/mplayer/ffmpeg/libavformat/mpeg.c
+++ b/mplayer/ffmpeg/libavformat/mpeg.c
@@ -20,6 +20,7 @@
*/
#include "avformat.h"
+#include "internal.h"
#include "mpeg.h"
//#define DEBUG_SEEK
@@ -112,7 +113,7 @@ static int mpegps_read_header(AVFormatContext *s,
m->sofdec = -1;
do {
- v = get_byte(s->pb);
+ v = avio_r8(s->pb);
m->header_state = m->header_state << 8 | v;
m->sofdec++;
} while (v == sofdec[i] && i++ < 6);
@@ -123,17 +124,17 @@ static int mpegps_read_header(AVFormatContext *s,
return 0;
}
-static int64_t get_pts(ByteIOContext *pb, int c)
+static int64_t get_pts(AVIOContext *pb, int c)
{
uint8_t buf[5];
- buf[0] = c<0 ? get_byte(pb) : c;
- get_buffer(pb, buf+1, 4);
+ buf[0] = c<0 ? avio_r8(pb) : c;
+ avio_read(pb, buf+1, 4);
return ff_parse_pes_pts(buf);
}
-static int find_next_start_code(ByteIOContext *pb, int *size_ptr,
+static int find_next_start_code(AVIOContext *pb, int *size_ptr,
int32_t *header_state)
{
unsigned int state, v;
@@ -144,7 +145,7 @@ static int find_next_start_code(ByteIOContext *pb, int *size_ptr,
while (n > 0) {
if (url_feof(pb))
break;
- v = get_byte(pb);
+ v = avio_r8(pb);
n--;
if (state == 0x000001) {
state = ((state << 8) | v) & 0xffffff;
@@ -162,7 +163,7 @@ static int find_next_start_code(ByteIOContext *pb, int *size_ptr,
#if 0 /* unused, remove? */
/* XXX: optimize */
-static int find_prev_start_code(ByteIOContext *pb, int *size_ptr)
+static int find_prev_start_code(AVIOContext *pb, int *size_ptr)
{
int64_t pos, pos_start;
int max_size, start_code;
@@ -174,8 +175,8 @@ static int find_prev_start_code(ByteIOContext *pb, int *size_ptr)
pos = pos_start - 16386;
if (pos < 0)
pos = 0;
- url_fseek(pb, pos, SEEK_SET);
- get_byte(pb);
+ avio_seek(pb, pos, SEEK_SET);
+ avio_r8(pb);
pos = pos_start;
for(;;) {
@@ -184,8 +185,8 @@ static int find_prev_start_code(ByteIOContext *pb, int *size_ptr)
start_code = -1;
goto the_end;
}
- url_fseek(pb, pos, SEEK_SET);
- start_code = get_be32(pb);
+ avio_seek(pb, pos, SEEK_SET);
+ start_code = avio_rb32(pb);
if ((start_code & 0xffffff00) == 0x100)
break;
}
@@ -201,31 +202,31 @@ static int find_prev_start_code(ByteIOContext *pb, int *size_ptr)
*
* @return number of bytes occupied by PSM in the bitstream
*/
-static long mpegps_psm_parse(MpegDemuxContext *m, ByteIOContext *pb)
+static long mpegps_psm_parse(MpegDemuxContext *m, AVIOContext *pb)
{
int psm_length, ps_info_length, es_map_length;
- psm_length = get_be16(pb);
- get_byte(pb);
- get_byte(pb);
- ps_info_length = get_be16(pb);
+ psm_length = avio_rb16(pb);
+ avio_r8(pb);
+ avio_r8(pb);
+ ps_info_length = avio_rb16(pb);
/* skip program_stream_info */
- url_fskip(pb, ps_info_length);
- es_map_length = get_be16(pb);
+ avio_seek(pb, ps_info_length, SEEK_CUR);
+ es_map_length = avio_rb16(pb);
/* at least one es available? */
while (es_map_length >= 4){
- unsigned char type = get_byte(pb);
- unsigned char es_id = get_byte(pb);
- uint16_t es_info_length = get_be16(pb);
+ unsigned char type = avio_r8(pb);
+ unsigned char es_id = avio_r8(pb);
+ uint16_t es_info_length = avio_rb16(pb);
/* remember mapping from stream id to stream type */
m->psm_es_type[es_id] = type;
/* skip program_stream_info */
- url_fskip(pb, es_info_length);
+ avio_seek(pb, es_info_length, SEEK_CUR);
es_map_length -= 4 + es_info_length;
}
- get_be32(pb); /* crc32 */
+ avio_rb32(pb); /* crc32 */
return 2 + psm_length;
}
@@ -243,7 +244,7 @@ static int mpegps_read_pes_header(AVFormatContext *s,
int64_t last_sync= url_ftell(s->pb);
error_redo:
- url_fseek(s->pb, last_sync, SEEK_SET);
+ avio_seek(s->pb, last_sync, SEEK_SET);
redo:
/* next start code (should be immediately after) */
m->header_state = 0xff;
@@ -263,16 +264,16 @@ static int mpegps_read_pes_header(AVFormatContext *s,
if (startcode == SYSTEM_HEADER_START_CODE)
goto redo;
if (startcode == PADDING_STREAM) {
- url_fskip(s->pb, get_be16(s->pb));
+ avio_seek(s->pb, avio_rb16(s->pb), SEEK_CUR);
goto redo;
}
if (startcode == PRIVATE_STREAM_2) {
- len = get_be16(s->pb);
+ len = avio_rb16(s->pb);
if (!m->sofdec) {
while (len-- >= 6) {
- if (get_byte(s->pb) == 'S') {
+ if (avio_r8(s->pb) == 'S') {
uint8_t buf[5];
- get_buffer(s->pb, buf, sizeof(buf));
+ avio_read(s->pb, buf, sizeof(buf));
m->sofdec = !memcmp(buf, "ofdec", 5);
len -= sizeof(buf);
break;
@@ -280,7 +281,7 @@ static int mpegps_read_pes_header(AVFormatContext *s,
}
m->sofdec -= !m->sofdec;
}
- url_fskip(s->pb, len);
+ avio_seek(s->pb, len, SEEK_CUR);
goto redo;
}
if (startcode == PROGRAM_STREAM_MAP) {
@@ -296,14 +297,14 @@ static int mpegps_read_pes_header(AVFormatContext *s,
if (ppos) {
*ppos = url_ftell(s->pb) - 4;
}
- len = get_be16(s->pb);
+ len = avio_rb16(s->pb);
pts =
dts = AV_NOPTS_VALUE;
/* stuffing */
for(;;) {
if (len < 1)
goto error_redo;
- c = get_byte(s->pb);
+ c = avio_r8(s->pb);
len--;
/* XXX: for mpeg1, should test only bit 7 */
if (c != 0xff)
@@ -311,8 +312,8 @@ static int mpegps_read_pes_header(AVFormatContext *s,
}
if ((c & 0xc0) == 0x40) {
/* buffer scale & size */
- get_byte(s->pb);
- c = get_byte(s->pb);
+ avio_r8(s->pb);
+ c = avio_r8(s->pb);
len -= 2;
}
if ((c & 0xe0) == 0x20) {
@@ -330,8 +331,8 @@ static int mpegps_read_pes_header(AVFormatContext *s,
goto redo;
}
#endif
- flags = get_byte(s->pb);
- header_len = get_byte(s->pb);
+ flags = avio_r8(s->pb);
+ header_len = avio_r8(s->pb);
len -= 2;
if (header_len > len)
goto error_redo;
@@ -349,7 +350,7 @@ static int mpegps_read_pes_header(AVFormatContext *s,
av_log(s, AV_LOG_WARNING, "Further flags set but no bytes left\n");
}
if (flags & 0x01) { /* PES extension */
- pes_ext = get_byte(s->pb);
+ pes_ext = avio_r8(s->pb);
header_len--;
/* Skip PES private data, program packet sequence counter and P-STD buffer */
skip = (pes_ext >> 4) & 0xb;
@@ -358,14 +359,14 @@ static int mpegps_read_pes_header(AVFormatContext *s,
av_log(s, AV_LOG_WARNING, "pes_ext %X is invalid\n", pes_ext);
pes_ext=skip=0;
}
- url_fskip(s->pb, skip);
+ avio_seek(s->pb, skip, SEEK_CUR);
header_len -= skip;
if (pes_ext & 0x01) { /* PES extension 2 */
- ext2_len = get_byte(s->pb);
+ ext2_len = avio_r8(s->pb);
header_len--;
if ((ext2_len & 0x7f) > 0) {
- id_ext = get_byte(s->pb);
+ id_ext = avio_r8(s->pb);
if ((id_ext & 0x80) == 0)
startcode = ((startcode & 0xff) << 8) | id_ext;
header_len--;
@@ -374,23 +375,23 @@ static int mpegps_read_pes_header(AVFormatContext *s,
}
if(header_len < 0)
goto error_redo;
- url_fskip(s->pb, header_len);
+ avio_seek(s->pb, header_len, SEEK_CUR);
}
else if( c!= 0xf )
goto redo;
if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
- startcode = get_byte(s->pb);
+ startcode = avio_r8(s->pb);
len--;
if (startcode >= 0x80 && startcode <= 0xcf) {
/* audio: skip header */
- get_byte(s->pb);
- get_byte(s->pb);
- get_byte(s->pb);
+ avio_r8(s->pb);
+ avio_r8(s->pb);
+ avio_r8(s->pb);
len -= 3;
if (startcode >= 0xb0 && startcode <= 0xbf) {
/* MLP/TrueHD audio has a 4-byte header */
- get_byte(s->pb);
+ avio_r8(s->pb);
len--;
}
}
@@ -431,8 +432,8 @@ static int mpegps_read_packet(AVFormatContext *s,
return len;
if(startcode == 0x1bd) {
- dvdaudio_substream_type = get_byte(s->pb);
- url_fskip(s->pb, 3);
+ dvdaudio_substream_type = avio_r8(s->pb);
+ avio_seek(s->pb, 3, SEEK_CUR);
len -= 4;
}
@@ -473,8 +474,8 @@ static int mpegps_read_packet(AVFormatContext *s,
} else if (startcode >= 0x1e0 && startcode <= 0x1ef) {
static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 };
unsigned char buf[8];
- get_buffer(s->pb, buf, 8);
- url_fseek(s->pb, -8, SEEK_CUR);
+ avio_read(s->pb, buf, 8);
+ avio_seek(s->pb, -8, SEEK_CUR);
if(!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1))
codec_id = CODEC_ID_CAVS;
else
@@ -524,7 +525,7 @@ static int mpegps_read_packet(AVFormatContext *s,
} else {
skip:
/* skip packet */
- url_fskip(s->pb, len);
+ avio_seek(s->pb, len, SEEK_CUR);
goto redo;
}
/* no stream found: add a new stream */
@@ -546,9 +547,9 @@ static int mpegps_read_packet(AVFormatContext *s,
audio data */
if (len <= 3)
goto skip;
- get_byte(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
- b1 = get_byte(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
- get_byte(s->pb); /* dynamic range control (0x80 = off) */
+ avio_r8(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
+ b1 = avio_r8(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
+ avio_r8(s->pb); /* dynamic range control (0x80 = off) */
len -= 3;
freq = (b1 >> 4) & 3;
st->codec->sample_rate = lpcm_freq_tab[freq];
@@ -563,7 +564,7 @@ static int mpegps_read_packet(AVFormatContext *s,
return AVERROR(EINVAL);
}
av_new_packet(pkt, len);
- get_buffer(s->pb, pkt->data, pkt->size);
+ avio_read(s->pb, pkt->data, pkt->size);
pkt->pts = pts;
pkt->dts = dts;
pkt->pos = dummy_pos;
@@ -586,7 +587,7 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index,
#ifdef DEBUG_SEEK
printf("read_dts: pos=0x%"PRIx64" next=%d -> ", pos, find_next);
#endif
- if (url_fseek(s->pb, pos, SEEK_SET) < 0)
+ if (avio_seek(s->pb, pos, SEEK_SET) < 0)
return AV_NOPTS_VALUE;
for(;;) {
@@ -601,7 +602,7 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index,
dts != AV_NOPTS_VALUE) {
break;
}
- url_fskip(s->pb, len);
+ avio_seek(s->pb, len, SEEK_CUR);
}
#ifdef DEBUG_SEEK
printf("pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n", pos, dts, dts / 90000.0);
diff --git a/mplayer/ffmpeg/libavformat/mpeg.h b/mplayer/ffmpeg/libavformat/mpeg.h
index d09b2e81..ca019c9e 100644
--- a/mplayer/ffmpeg/libavformat/mpeg.h
+++ b/mplayer/ffmpeg/libavformat/mpeg.h
@@ -63,7 +63,7 @@ static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 };
/**
* Parse MPEG-PES five-byte timestamp
*/
-static inline int64_t ff_parse_pes_pts(uint8_t *buf) {
+static inline int64_t ff_parse_pes_pts(const uint8_t *buf) {
return (int64_t)(*buf & 0x0e) << 29 |
(AV_RB16(buf+1) >> 1) << 15 |
AV_RB16(buf+3) >> 1;
diff --git a/mplayer/ffmpeg/libavformat/mpegenc.c b/mplayer/ffmpeg/libavformat/mpegenc.c
index eef385f0..8c5c644f 100644
--- a/mplayer/ffmpeg/libavformat/mpegenc.c
+++ b/mplayer/ffmpeg/libavformat/mpegenc.c
@@ -491,14 +491,14 @@ static int mpeg_mux_init(AVFormatContext *ctx)
return AVERROR(ENOMEM);
}
-static inline void put_timestamp(ByteIOContext *pb, int id, int64_t timestamp)
+static inline void put_timestamp(AVIOContext *pb, int id, int64_t timestamp)
{
- put_byte(pb,
+ avio_w8(pb,
(id << 4) |
(((timestamp >> 30) & 0x07) << 1) |
1);
- put_be16(pb, (uint16_t)((((timestamp >> 15) & 0x7fff) << 1) | 1));
- put_be16(pb, (uint16_t)((((timestamp ) & 0x7fff) << 1) | 1));
+ avio_wb16(pb, (uint16_t)((((timestamp >> 15) & 0x7fff) << 1) | 1));
+ avio_wb16(pb, (uint16_t)((((timestamp ) & 0x7fff) << 1) | 1));
}
@@ -613,21 +613,21 @@ static int get_packet_payload_size(AVFormatContext *ctx, int stream_index,
#endif
/* Write an MPEG padding packet header. */
-static void put_padding_packet(AVFormatContext *ctx, ByteIOContext *pb,int packet_bytes)
+static void put_padding_packet(AVFormatContext *ctx, AVIOContext *pb,int packet_bytes)
{
MpegMuxContext *s = ctx->priv_data;
int i;
- put_be32(pb, PADDING_STREAM);
- put_be16(pb, packet_bytes - 6);
+ avio_wb32(pb, PADDING_STREAM);
+ avio_wb16(pb, packet_bytes - 6);
if (!s->is_mpeg2) {
- put_byte(pb, 0x0f);
+ avio_w8(pb, 0x0f);
packet_bytes -= 7;
} else
packet_bytes -= 6;
for(i=0;ipb, buffer, size);
+ avio_write(ctx->pb, buffer, size);
- put_be32(ctx->pb, PRIVATE_STREAM_2);
- put_be16(ctx->pb, 0x03d4); // length
- put_byte(ctx->pb, 0x00); // substream ID, 00=PCI
+ avio_wb32(ctx->pb, PRIVATE_STREAM_2);
+ avio_wb16(ctx->pb, 0x03d4); // length
+ avio_w8(ctx->pb, 0x00); // substream ID, 00=PCI
for (i = 0; i < 979; i++)
- put_byte(ctx->pb, 0x00);
+ avio_w8(ctx->pb, 0x00);
- put_be32(ctx->pb, PRIVATE_STREAM_2);
- put_be16(ctx->pb, 0x03fa); // length
- put_byte(ctx->pb, 0x01); // substream ID, 01=DSI
+ avio_wb32(ctx->pb, PRIVATE_STREAM_2);
+ avio_wb16(ctx->pb, 0x03fa); // length
+ avio_w8(ctx->pb, 0x01); // substream ID, 01=DSI
for (i = 0; i < 1017; i++)
- put_byte(ctx->pb, 0x00);
+ avio_w8(ctx->pb, 0x00);
memset(buffer, 0, 128);
buf_ptr = buffer;
@@ -734,7 +734,7 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
}
}
size = buf_ptr - buffer;
- put_buffer(ctx->pb, buffer, size);
+ avio_write(ctx->pb, buffer, size);
packet_size = s->packet_size - size;
@@ -839,16 +839,16 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
nb_frames= get_nb_frames(ctx, stream, payload_size - stuffing_size);
- put_be32(ctx->pb, startcode);
+ avio_wb32(ctx->pb, startcode);
- put_be16(ctx->pb, packet_size);
+ avio_wb16(ctx->pb, packet_size);
if (!s->is_mpeg2)
for(i=0;ipb, 0xff);
+ avio_w8(ctx->pb, 0xff);
if (s->is_mpeg2) {
- put_byte(ctx->pb, 0x80); /* mpeg2 id */
+ avio_w8(ctx->pb, 0x80); /* mpeg2 id */
pes_flags=0;
@@ -865,8 +865,8 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
if (stream->packet_number == 0)
pes_flags |= 0x01;
- put_byte(ctx->pb, pes_flags); /* flags */
- put_byte(ctx->pb, header_len - 3 + stuffing_size);
+ avio_w8(ctx->pb, pes_flags); /* flags */
+ avio_w8(ctx->pb, header_len - 3 + stuffing_size);
if (pes_flags & 0x80) /*write pts*/
put_timestamp(ctx->pb, (pes_flags & 0x40) ? 0x03 : 0x02, pts);
@@ -874,13 +874,13 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
put_timestamp(ctx->pb, 0x01, dts);
if (pes_flags & 0x01) { /*write pes extension*/
- put_byte(ctx->pb, 0x10); /* flags */
+ avio_w8(ctx->pb, 0x10); /* flags */
/* P-STD buffer info */
if ((id & 0xe0) == AUDIO_ID)
- put_be16(ctx->pb, 0x4000 | stream->max_buffer_size/ 128);
+ avio_wb16(ctx->pb, 0x4000 | stream->max_buffer_size/ 128);
else
- put_be16(ctx->pb, 0x6000 | stream->max_buffer_size/1024);
+ avio_wb16(ctx->pb, 0x6000 | stream->max_buffer_size/1024);
}
} else {
@@ -892,38 +892,38 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
put_timestamp(ctx->pb, 0x02, pts);
}
} else {
- put_byte(ctx->pb, 0x0f);
+ avio_w8(ctx->pb, 0x0f);
}
}
if (s->is_mpeg2) {
/* special stuffing byte that is always written
to prevent accidental generation of start codes. */
- put_byte(ctx->pb, 0xff);
+ avio_w8(ctx->pb, 0xff);
for(i=0;ipb, 0xff);
+ avio_w8(ctx->pb, 0xff);
}
if (startcode == PRIVATE_STREAM_1) {
- put_byte(ctx->pb, id);
+ avio_w8(ctx->pb, id);
if (id >= 0xa0) {
/* LPCM (XXX: check nb_frames) */
- put_byte(ctx->pb, 7);
- put_be16(ctx->pb, 4); /* skip 3 header bytes */
- put_byte(ctx->pb, stream->lpcm_header[0]);
- put_byte(ctx->pb, stream->lpcm_header[1]);
- put_byte(ctx->pb, stream->lpcm_header[2]);
+ avio_w8(ctx->pb, 7);
+ avio_wb16(ctx->pb, 4); /* skip 3 header bytes */
+ avio_w8(ctx->pb, stream->lpcm_header[0]);
+ avio_w8(ctx->pb, stream->lpcm_header[1]);
+ avio_w8(ctx->pb, stream->lpcm_header[2]);
} else if (id >= 0x40) {
/* AC-3 */
- put_byte(ctx->pb, nb_frames);
- put_be16(ctx->pb, trailer_size+1);
+ avio_w8(ctx->pb, nb_frames);
+ avio_wb16(ctx->pb, trailer_size+1);
}
}
/* output data */
assert(payload_size - stuffing_size <= av_fifo_size(stream->fifo));
- av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, &put_buffer);
+ av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, &avio_write);
stream->bytes_to_iframe -= payload_size - stuffing_size;
}else{
payload_size=
@@ -934,7 +934,7 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
put_padding_packet(ctx,ctx->pb, pad_packet_bytes);
for(i=0;ipb, 0x00);
+ avio_w8(ctx->pb, 0x00);
put_flush_packet(ctx->pb);
@@ -961,7 +961,7 @@ static void put_vcd_padding_sector(AVFormatContext *ctx)
int i;
for(i=0;ipacket_size;i++)
- put_byte(ctx->pb, 0);
+ avio_w8(ctx->pb, 0);
s->vcd_padding_bytes_written += s->packet_size;
@@ -1220,7 +1220,7 @@ static int mpeg_mux_end(AVFormatContext *ctx)
/* End header according to MPEG1 systems standard. We do not write
it as it is usually not needed by decoders and because it
complicates MPEG stream concatenation. */
- //put_be32(ctx->pb, ISO_11172_END_CODE);
+ //avio_wb32(ctx->pb, ISO_11172_END_CODE);
//put_flush_packet(ctx->pb);
for(i=0;inb_streams;i++) {
diff --git a/mplayer/ffmpeg/libavformat/mpegts.c b/mplayer/ffmpeg/libavformat/mpegts.c
index f2b580a2..8815044f 100644
--- a/mplayer/ffmpeg/libavformat/mpegts.c
+++ b/mplayer/ffmpeg/libavformat/mpegts.c
@@ -29,12 +29,11 @@
#include "avformat.h"
#include "mpegts.h"
#include "internal.h"
+#include "avio_internal.h"
#include "seek.h"
+#include "mpeg.h"
#include "isom.h"
-/* 1.0 second at 24Mbit/s */
-#define MAX_SCAN_PACKETS 32000
-
/* maximum size in which we look for synchronisation if
synchronisation is lost */
#define MAX_RESYNC_SIZE 65536
@@ -601,14 +600,6 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
return 0;
}
-static int64_t get_pts(const uint8_t *p)
-{
- int64_t pts = (int64_t)((p[0] >> 1) & 0x07) << 30;
- pts |= (AV_RB16(p + 1) >> 1) << 15;
- pts |= AV_RB16(p + 3) >> 1;
- return pts;
-}
-
static void new_pes_packet(PESContext *pes, AVPacket *pkt)
{
av_init_packet(pkt);
@@ -767,12 +758,12 @@ static int mpegts_push_data(MpegTSFilter *filter,
pes->pts = AV_NOPTS_VALUE;
pes->dts = AV_NOPTS_VALUE;
if ((flags & 0xc0) == 0x80) {
- pes->dts = pes->pts = get_pts(r);
+ pes->dts = pes->pts = ff_parse_pes_pts(r);
r += 5;
} else if ((flags & 0xc0) == 0xc0) {
- pes->pts = get_pts(r);
+ pes->pts = ff_parse_pes_pts(r);
r += 5;
- pes->dts = get_pts(r);
+ pes->dts = ff_parse_pes_pts(r);
r += 5;
}
pes->extended_stream_id = -1;
@@ -861,32 +852,32 @@ static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size,
int *es_id, uint8_t **dec_config_descr,
int *dec_config_descr_size)
{
- ByteIOContext pb;
+ AVIOContext pb;
int tag;
unsigned len;
- init_put_byte(&pb, buf, size, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, buf, size, 0, NULL, NULL, NULL, NULL);
len = ff_mp4_read_descr(s, &pb, &tag);
if (tag == MP4IODescrTag) {
- get_be16(&pb); // ID
- get_byte(&pb);
- get_byte(&pb);
- get_byte(&pb);
- get_byte(&pb);
- get_byte(&pb);
+ avio_rb16(&pb); // ID
+ avio_r8(&pb);
+ avio_r8(&pb);
+ avio_r8(&pb);
+ avio_r8(&pb);
+ avio_r8(&pb);
len = ff_mp4_read_descr(s, &pb, &tag);
if (tag == MP4ESDescrTag) {
- *es_id = get_be16(&pb); /* ES_ID */
+ *es_id = avio_rb16(&pb); /* ES_ID */
av_dlog(s, "ES_ID %#x\n", *es_id);
- get_byte(&pb); /* priority */
+ avio_r8(&pb); /* priority */
len = ff_mp4_read_descr(s, &pb, &tag);
if (tag == MP4DecConfigDescrTag) {
*dec_config_descr = av_malloc(len);
if (!*dec_config_descr)
return AVERROR(ENOMEM);
*dec_config_descr_size = len;
- get_buffer(&pb, *dec_config_descr, len);
+ avio_read(&pb, *dec_config_descr, len);
}
}
}
@@ -923,8 +914,8 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
get16(pp, desc_end);
if (st->codec->codec_id == CODEC_ID_AAC_LATM &&
mp4_dec_config_descr_len && mp4_es_id == pid) {
- ByteIOContext pb;
- init_put_byte(&pb, mp4_dec_config_descr,
+ AVIOContext pb;
+ ffio_init_context(&pb, mp4_dec_config_descr,
mp4_dec_config_descr_len, 0, NULL, NULL, NULL, NULL);
ff_mp4_read_dec_config_descr(fc, st, &pb);
if (st->codec->codec_id == CODEC_ID_AAC &&
@@ -964,6 +955,11 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
language[2] = get8(pp, desc_end);
language[3] = 0;
av_metadata_set2(&st->metadata, "language", language, 0);
+ switch (get8(pp, desc_end)) {
+ case 0x01: st->disposition |= AV_DISPOSITION_CLEAN_EFFECTS; break;
+ case 0x02: st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED; break;
+ case 0x03: st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED; break;
+ }
break;
case 0x05: /* registration descriptor */
st->codec->codec_tag = bytestream_get_le32(pp);
@@ -1312,7 +1308,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
get_packet_size() ?) */
static int mpegts_resync(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int c, i;
for(i = 0;i < MAX_RESYNC_SIZE; i++) {
@@ -1320,7 +1316,7 @@ static int mpegts_resync(AVFormatContext *s)
if (c < 0)
return -1;
if (c == 0x47) {
- url_fseek(pb, -1, SEEK_CUR);
+ avio_seek(pb, -1, SEEK_CUR);
return 0;
}
}
@@ -1332,17 +1328,17 @@ static int mpegts_resync(AVFormatContext *s)
/* return -1 if error or EOF. Return 0 if OK. */
static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int skip, len;
for(;;) {
- len = get_buffer(pb, buf, TS_PACKET_SIZE);
+ len = avio_read(pb, buf, TS_PACKET_SIZE);
if (len != TS_PACKET_SIZE)
return AVERROR(EIO);
/* check paquet sync byte */
if (buf[0] != 0x47) {
/* find a new packet start */
- url_fseek(pb, -TS_PACKET_SIZE, SEEK_CUR);
+ avio_seek(pb, -TS_PACKET_SIZE, SEEK_CUR);
if (mpegts_resync(s) < 0)
return AVERROR(EAGAIN);
else
@@ -1350,7 +1346,7 @@ static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size)
} else {
skip = raw_packet_size - TS_PACKET_SIZE;
if (skip > 0)
- url_fskip(pb, skip);
+ avio_seek(pb, skip, SEEK_CUR);
break;
}
}
@@ -1444,7 +1440,7 @@ static int mpegts_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
MpegTSContext *ts = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint8_t buf[5*1024];
int len;
int64_t pos;
@@ -1459,7 +1455,7 @@ static int mpegts_read_header(AVFormatContext *s,
/* read the first 1024 bytes to get packet size */
pos = url_ftell(pb);
- len = get_buffer(pb, buf, sizeof(buf));
+ len = avio_read(pb, buf, sizeof(buf));
if (len != sizeof(buf))
goto fail;
ts->raw_packet_size = get_packet_size(buf, sizeof(buf));
@@ -1472,7 +1468,7 @@ static int mpegts_read_header(AVFormatContext *s,
/* normal demux */
/* first do a scaning to get all the services */
- if (url_fseek(pb, pos, SEEK_SET) < 0)
+ if (avio_seek(pb, pos, SEEK_SET) < 0)
av_log(s, AV_LOG_ERROR, "Unable to seek back to the start\n");
mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
@@ -1537,7 +1533,7 @@ static int mpegts_read_header(AVFormatContext *s,
#endif
}
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, pos, SEEK_SET);
return 0;
fail:
return -1;
@@ -1568,8 +1564,8 @@ static int mpegts_raw_read_packet(AVFormatContext *s,
/* we read the next PCR (XXX: optimize it by using a bigger buffer */
pos = url_ftell(s->pb);
for(i = 0; i < MAX_PACKET_READAHEAD; i++) {
- url_fseek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET);
- get_buffer(s->pb, pcr_buf, 12);
+ avio_seek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET);
+ avio_read(s->pb, pcr_buf, 12);
if (parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) {
/* XXX: not precise enough */
ts->pcr_incr = ((next_pcr_h - pcr_h) * 300 + (next_pcr_l - pcr_l)) /
@@ -1577,7 +1573,7 @@ static int mpegts_raw_read_packet(AVFormatContext *s,
break;
}
}
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
/* no next PCR found: we use previous increment */
ts->cur_pcr = pcr_h * 300 + pcr_l;
}
@@ -1653,8 +1649,8 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47;
if (find_next) {
for(;;) {
- url_fseek(s->pb, pos, SEEK_SET);
- if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
+ avio_seek(s->pb, pos, SEEK_SET);
+ if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
return AV_NOPTS_VALUE;
if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
parse_pcr(×tamp, &pcr_l, buf) == 0) {
@@ -1667,8 +1663,8 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
pos -= ts->raw_packet_size;
if (pos < 0)
return AV_NOPTS_VALUE;
- url_fseek(s->pb, pos, SEEK_SET);
- if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
+ avio_seek(s->pb, pos, SEEK_SET);
+ if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
return AV_NOPTS_VALUE;
if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
parse_pcr(×tamp, &pcr_l, buf) == 0) {
@@ -1778,14 +1774,14 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, in
pos= url_ftell(s->pb);
for(;;) {
- url_fseek(s->pb, pos, SEEK_SET);
- if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
+ avio_seek(s->pb, pos, SEEK_SET);
+ if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
return -1;
// pid = AV_RB16(buf + 1) & 0x1fff;
if(buf[1] & 0x40) break;
pos += ts->raw_packet_size;
}
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/mpegtsenc.c b/mplayer/ffmpeg/libavformat/mpegtsenc.c
index b58e84be..be11a06f 100644
--- a/mplayer/ffmpeg/libavformat/mpegtsenc.c
+++ b/mplayer/ffmpeg/libavformat/mpegtsenc.c
@@ -21,6 +21,7 @@
#include "libavutil/bswap.h"
#include "libavutil/crc.h"
+#include "libavutil/opt.h"
#include "libavcodec/mpegvideo.h"
#include "avformat.h"
#include "internal.h"
@@ -64,8 +65,36 @@ typedef struct MpegTSWrite {
int tsid;
int64_t first_pcr;
int mux_rate; ///< set to 1 when VBR
+
+ int transport_stream_id;
+ int original_network_id;
+ int service_id;
+
+ int pmt_start_pid;
+ int start_pid;
} MpegTSWrite;
+static const AVOption options[] = {
+ { "mpegts_transport_stream_id", "Set transport_stream_id field.",
+ offsetof(MpegTSWrite, transport_stream_id), FF_OPT_TYPE_INT, 0x0001, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM},
+ { "mpegts_original_network_id", "Set original_network_id field.",
+ offsetof(MpegTSWrite, original_network_id), FF_OPT_TYPE_INT, 0x0001, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM},
+ { "mpegts_service_id", "Set service_id field.",
+ offsetof(MpegTSWrite, service_id), FF_OPT_TYPE_INT, 0x0001, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM},
+ { "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
+ offsetof(MpegTSWrite, pmt_start_pid), FF_OPT_TYPE_INT, 0x1000, 0x1000, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM},
+ { "mpegts_start_pid", "Set the first pid.",
+ offsetof(MpegTSWrite, start_pid), FF_OPT_TYPE_INT, 0x0100, 0x0100, 0x0f00, AV_OPT_FLAG_ENCODING_PARAM},
+ { NULL },
+};
+
+static const AVClass mpegts_muxer_class = {
+ "MPEGTS muxer",
+ av_default_item_name,
+ options,
+ LIBAVUTIL_VERSION_INT,
+};
+
/* NOTE: 4 bytes must be left at the end for the crc32 */
static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len)
{
@@ -152,16 +181,9 @@ static int mpegts_write_section1(MpegTSSection *s, int tid, int id,
/*********************************************/
/* mpegts writer */
-#define DEFAULT_PMT_START_PID 0x1000
-#define DEFAULT_START_PID 0x0100
#define DEFAULT_PROVIDER_NAME "FFmpeg"
#define DEFAULT_SERVICE_NAME "Service01"
-/* default network id, transport stream and service identifiers */
-#define DEFAULT_ONID 0x0001
-#define DEFAULT_TSID 0x0001
-#define DEFAULT_SID 0x0001
-
/* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */
#define DEFAULT_PES_HEADER_FREQ 16
#define DEFAULT_PES_PAYLOAD_SIZE ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170)
@@ -267,7 +289,14 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
*q++ = lang->value[0];
*q++ = lang->value[1];
*q++ = lang->value[2];
- *q++ = 0; /* undefined type */
+ if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
+ *q++ = 0x01;
+ else if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
+ *q++ = 0x02;
+ else if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
+ *q++ = 0x03;
+ else
+ *q++ = 0; /* undefined type */
}
break;
case AVMEDIA_TYPE_SUBTITLE:
@@ -374,7 +403,7 @@ static MpegTSService *mpegts_add_service(MpegTSWrite *ts,
service = av_mallocz(sizeof(MpegTSService));
if (!service)
return NULL;
- service->pmt.pid = DEFAULT_PMT_START_PID + ts->nb_services - 1;
+ service->pmt.pid = ts->pmt_start_pid + ts->nb_services - 1;
service->sid = sid;
service->provider_name = av_strdup(provider_name);
service->name = av_strdup(name);
@@ -386,7 +415,7 @@ static MpegTSService *mpegts_add_service(MpegTSWrite *ts,
static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
{
AVFormatContext *ctx = s->opaque;
- put_buffer(ctx->pb, packet, TS_PACKET_SIZE);
+ avio_write(ctx->pb, packet, TS_PACKET_SIZE);
}
static int mpegts_write_header(AVFormatContext *s)
@@ -401,8 +430,8 @@ static int mpegts_write_header(AVFormatContext *s)
const char *provider_name;
int *pids;
- ts->tsid = DEFAULT_TSID;
- ts->onid = DEFAULT_ONID;
+ ts->tsid = ts->transport_stream_id;
+ ts->onid = ts->original_network_id;
/* allocate a single DVB service */
title = av_metadata_get(s->metadata, "service_name", NULL, 0);
if (!title)
@@ -410,7 +439,7 @@ static int mpegts_write_header(AVFormatContext *s)
service_name = title ? title->value : DEFAULT_SERVICE_NAME;
provider = av_metadata_get(s->metadata, "service_provider", NULL, 0);
provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
- service = mpegts_add_service(ts, DEFAULT_SID, provider_name, service_name);
+ service = mpegts_add_service(ts, ts->service_id, provider_name, service_name);
service->pmt.write_packet = section_write_packet;
service->pmt.opaque = s;
service->pmt.cc = 15;
@@ -440,7 +469,7 @@ static int mpegts_write_header(AVFormatContext *s)
/* MPEG pid values < 16 are reserved. Applications which set st->id in
* this range are assigned a calculated pid. */
if (st->id < 16) {
- ts_st->pid = DEFAULT_START_PID + i;
+ ts_st->pid = ts->start_pid + i;
} else if (st->id < 0x1FFF) {
ts_st->pid = st->id;
} else {
@@ -564,7 +593,7 @@ static void retransmit_si_info(AVFormatContext *s)
}
}
-static int64_t get_pcr(const MpegTSWrite *ts, ByteIOContext *pb)
+static int64_t get_pcr(const MpegTSWrite *ts, AVIOContext *pb)
{
return av_rescale(url_ftell(pb) + 11, 8 * PCR_TIME_BASE, ts->mux_rate) +
ts->first_pcr;
@@ -596,7 +625,7 @@ static void mpegts_insert_null_packet(AVFormatContext *s)
*q++ = 0xff;
*q++ = 0x10;
memset(q, 0x0FF, TS_PACKET_SIZE - (q - buf));
- put_buffer(s->pb, buf, TS_PACKET_SIZE);
+ avio_write(s->pb, buf, TS_PACKET_SIZE);
}
/* Write a single transport stream packet with a PCR and no payload */
@@ -621,7 +650,7 @@ static void mpegts_insert_pcr_only(AVFormatContext *s, AVStream *st)
/* stuffing bytes */
memset(q, 0xFF, TS_PACKET_SIZE - (q - buf));
- put_buffer(s->pb, buf, TS_PACKET_SIZE);
+ avio_write(s->pb, buf, TS_PACKET_SIZE);
}
static void write_pts(uint8_t *q, int fourbits, int64_t pts)
@@ -717,7 +746,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
*q++ = 0xe0;
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
(st->codec->codec_id == CODEC_ID_MP2 ||
- st->codec->codec_id == CODEC_ID_MP3)) {
+ st->codec->codec_id == CODEC_ID_MP3 ||
+ st->codec->codec_id == CODEC_ID_AAC)) {
*q++ = 0xc0;
} else {
*q++ = 0xbd;
@@ -815,7 +845,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
memcpy(buf + TS_PACKET_SIZE - len, payload, len);
payload += len;
payload_size -= len;
- put_buffer(s->pb, buf, TS_PACKET_SIZE);
+ avio_write(s->pb, buf, TS_PACKET_SIZE);
}
put_flush_packet(s->pb);
}
@@ -964,4 +994,5 @@ AVOutputFormat ff_mpegts_muxer = {
mpegts_write_header,
mpegts_write_packet,
mpegts_write_end,
+ .priv_class = &mpegts_muxer_class,
};
diff --git a/mplayer/ffmpeg/libavformat/mpjpeg.c b/mplayer/ffmpeg/libavformat/mpjpeg.c
index 76f59859..e98fb363 100644
--- a/mplayer/ffmpeg/libavformat/mpjpeg.c
+++ b/mplayer/ffmpeg/libavformat/mpjpeg.c
@@ -29,7 +29,7 @@ static int mpjpeg_write_header(AVFormatContext *s)
uint8_t buf1[256];
snprintf(buf1, sizeof(buf1), "--%s\n", BOUNDARY_TAG);
- put_buffer(s->pb, buf1, strlen(buf1));
+ avio_write(s->pb, buf1, strlen(buf1));
put_flush_packet(s->pb);
return 0;
}
@@ -39,11 +39,11 @@ static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
uint8_t buf1[256];
snprintf(buf1, sizeof(buf1), "Content-type: image/jpeg\n\n");
- put_buffer(s->pb, buf1, strlen(buf1));
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, buf1, strlen(buf1));
+ avio_write(s->pb, pkt->data, pkt->size);
snprintf(buf1, sizeof(buf1), "\n--%s\n", BOUNDARY_TAG);
- put_buffer(s->pb, buf1, strlen(buf1));
+ avio_write(s->pb, buf1, strlen(buf1));
put_flush_packet(s->pb);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/msnwc_tcp.c b/mplayer/ffmpeg/libavformat/msnwc_tcp.c
index f9cde027..2a11a572 100644
--- a/mplayer/ffmpeg/libavformat/msnwc_tcp.c
+++ b/mplayer/ffmpeg/libavformat/msnwc_tcp.c
@@ -71,7 +71,7 @@ static int msnwc_tcp_probe(AVProbeData *p)
static int msnwc_tcp_read_header(AVFormatContext *ctx, AVFormatParameters *ap)
{
- ByteIOContext *pb = ctx->pb;
+ AVIOContext *pb = ctx->pb;
AVCodecContext *codec;
AVStream *st;
@@ -88,7 +88,7 @@ static int msnwc_tcp_read_header(AVFormatContext *ctx, AVFormatParameters *ap)
/* Some files start with "connected\r\n\r\n".
* So skip until we find the first byte of struct size */
- while(get_byte(pb) != HEADER_SIZE && !url_feof(pb));
+ while(avio_r8(pb) != HEADER_SIZE && !url_feof(pb));
if(url_feof(pb)) {
av_log(ctx, AV_LOG_ERROR, "Could not find valid start.");
@@ -100,23 +100,23 @@ static int msnwc_tcp_read_header(AVFormatContext *ctx, AVFormatParameters *ap)
static int msnwc_tcp_read_packet(AVFormatContext *ctx, AVPacket *pkt)
{
- ByteIOContext *pb = ctx->pb;
+ AVIOContext *pb = ctx->pb;
uint16_t keyframe;
uint32_t size, timestamp;
- url_fskip(pb, 1); /* one byte has been read ahead */
- url_fskip(pb, 2);
- url_fskip(pb, 2);
- keyframe = get_le16(pb);
- size = get_le32(pb);
- url_fskip(pb, 4);
- url_fskip(pb, 4);
- timestamp = get_le32(pb);
+ avio_seek(pb, 1, SEEK_CUR); /* one byte has been read ahead */
+ avio_seek(pb, 2, SEEK_CUR);
+ avio_seek(pb, 2, SEEK_CUR);
+ keyframe = avio_rl16(pb);
+ size = avio_rl32(pb);
+ avio_seek(pb, 4, SEEK_CUR);
+ avio_seek(pb, 4, SEEK_CUR);
+ timestamp = avio_rl32(pb);
if(!size || av_get_packet(pb, pkt, size) != size)
return -1;
- url_fskip(pb, 1); /* Read ahead one byte of struct size like read_header */
+ avio_seek(pb, 1, SEEK_CUR); /* Read ahead one byte of struct size like read_header */
pkt->pts = timestamp;
pkt->dts = timestamp;
diff --git a/mplayer/ffmpeg/libavformat/mtv.c b/mplayer/ffmpeg/libavformat/mtv.c
index acb21a99..c5f14cf6 100644
--- a/mplayer/ffmpeg/libavformat/mtv.c
+++ b/mplayer/ffmpeg/libavformat/mtv.c
@@ -79,21 +79,21 @@ static int mtv_probe(AVProbeData *p)
static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
MTVDemuxContext *mtv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
unsigned int audio_subsegments;
- url_fskip(pb, 3);
- mtv->file_size = get_le32(pb);
- mtv->segments = get_le32(pb);
- url_fskip(pb, 32);
- mtv->audio_identifier = get_le24(pb);
- mtv->audio_br = get_le16(pb);
- mtv->img_colorfmt = get_le24(pb);
- mtv->img_bpp = get_byte(pb);
- mtv->img_width = get_le16(pb);
- mtv->img_height = get_le16(pb);
- mtv->img_segment_size = get_le16(pb);
+ avio_seek(pb, 3, SEEK_CUR);
+ mtv->file_size = avio_rl32(pb);
+ mtv->segments = avio_rl32(pb);
+ avio_seek(pb, 32, SEEK_CUR);
+ mtv->audio_identifier = avio_rl24(pb);
+ mtv->audio_br = avio_rl16(pb);
+ mtv->img_colorfmt = avio_rl24(pb);
+ mtv->img_bpp = avio_r8(pb);
+ mtv->img_width = avio_rl16(pb);
+ mtv->img_height = avio_rl16(pb);
+ mtv->img_segment_size = avio_rl16(pb);
/* Calculate width and height if missing from header */
@@ -105,8 +105,8 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap)
mtv->img_height=mtv->img_segment_size / (mtv->img_bpp>>3)
/ mtv->img_width;
- url_fskip(pb, 4);
- audio_subsegments = get_le16(pb);
+ avio_seek(pb, 4, SEEK_CUR);
+ audio_subsegments = avio_rl16(pb);
mtv->full_segment_size =
audio_subsegments * (MTV_AUDIO_PADDING_SIZE + MTV_ASUBCHUNK_DATA_SIZE) +
mtv->img_segment_size;
@@ -146,7 +146,7 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap)
// Jump over header
- if(url_fseek(pb, MTV_HEADER_SIZE, SEEK_SET) != MTV_HEADER_SIZE)
+ if(avio_seek(pb, MTV_HEADER_SIZE, SEEK_SET) != MTV_HEADER_SIZE)
return AVERROR(EIO);
return 0;
@@ -156,7 +156,7 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt)
{
MTVDemuxContext *mtv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret;
#if !HAVE_BIGENDIAN
int i;
@@ -164,7 +164,7 @@ static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt)
if((url_ftell(pb) - s->data_offset + mtv->img_segment_size) % mtv->full_segment_size)
{
- url_fskip(pb, MTV_AUDIO_PADDING_SIZE);
+ avio_seek(pb, MTV_AUDIO_PADDING_SIZE, SEEK_CUR);
ret = av_get_packet(pb, pkt, MTV_ASUBCHUNK_DATA_SIZE);
if(ret < 0)
diff --git a/mplayer/ffmpeg/libavformat/mvi.c b/mplayer/ffmpeg/libavformat/mvi.c
index c982e6bc..4784efae 100644
--- a/mplayer/ffmpeg/libavformat/mvi.c
+++ b/mplayer/ffmpeg/libavformat/mvi.c
@@ -27,7 +27,7 @@
#define MVI_VIDEO_STREAM_INDEX 1
typedef struct MviDemuxContext {
- unsigned int (*get_int)(ByteIOContext *);
+ unsigned int (*get_int)(AVIOContext *);
uint32_t audio_data_size;
uint64_t audio_size_counter;
uint64_t audio_frame_size;
@@ -38,7 +38,7 @@ typedef struct MviDemuxContext {
static int read_header(AVFormatContext *s, AVFormatParameters *ap)
{
MviDemuxContext *mvi = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *ast, *vst;
unsigned int version, frames_count, msecs_per_frame, player_version;
@@ -53,20 +53,20 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
vst->codec->extradata_size = 2;
vst->codec->extradata = av_mallocz(2 + FF_INPUT_BUFFER_PADDING_SIZE);
- version = get_byte(pb);
- vst->codec->extradata[0] = get_byte(pb);
- vst->codec->extradata[1] = get_byte(pb);
- frames_count = get_le32(pb);
- msecs_per_frame = get_le32(pb);
- vst->codec->width = get_le16(pb);
- vst->codec->height = get_le16(pb);
- get_byte(pb);
- ast->codec->sample_rate = get_le16(pb);
- mvi->audio_data_size = get_le32(pb);
- get_byte(pb);
- player_version = get_le32(pb);
- get_le16(pb);
- get_byte(pb);
+ version = avio_r8(pb);
+ vst->codec->extradata[0] = avio_r8(pb);
+ vst->codec->extradata[1] = avio_r8(pb);
+ frames_count = avio_rl32(pb);
+ msecs_per_frame = avio_rl32(pb);
+ vst->codec->width = avio_rl16(pb);
+ vst->codec->height = avio_rl16(pb);
+ avio_r8(pb);
+ ast->codec->sample_rate = avio_rl16(pb);
+ mvi->audio_data_size = avio_rl32(pb);
+ avio_r8(pb);
+ player_version = avio_rl32(pb);
+ avio_rl16(pb);
+ avio_r8(pb);
if (frames_count == 0 || mvi->audio_data_size == 0)
return AVERROR_INVALIDDATA;
@@ -87,7 +87,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = CODEC_ID_MOTIONPIXELS;
- mvi->get_int = (vst->codec->width * vst->codec->height < (1 << 16)) ? get_le16 : get_le24;
+ mvi->get_int = (vst->codec->width * vst->codec->height < (1 << 16)) ? avio_rl16 : avio_rl24;
mvi->audio_frame_size = ((uint64_t)mvi->audio_data_size << MVI_FRAC_BITS) / frames_count;
mvi->audio_size_counter = (ast->codec->sample_rate * 830 / mvi->audio_frame_size - 1) * mvi->audio_frame_size;
@@ -100,7 +100,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, count;
MviDemuxContext *mvi = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
if (mvi->video_frame_size == 0) {
mvi->video_frame_size = (mvi->get_int)(pb);
diff --git a/mplayer/ffmpeg/libavformat/mxfdec.c b/mplayer/ffmpeg/libavformat/mxfdec.c
index 91935619..be618406 100644
--- a/mplayer/ffmpeg/libavformat/mxfdec.c
+++ b/mplayer/ffmpeg/libavformat/mxfdec.c
@@ -140,7 +140,7 @@ enum MXFWrappingScheme {
Clip,
};
-typedef int MXFMetadataReadFunc(void *arg, ByteIOContext *pb, int tag, int size, UID uid);
+typedef int MXFMetadataReadFunc(void *arg, AVIOContext *pb, int tag, int size, UID uid);
typedef struct {
const UID key;
@@ -161,9 +161,9 @@ static const uint8_t mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x
#define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
-static int64_t klv_decode_ber_length(ByteIOContext *pb)
+static int64_t klv_decode_ber_length(AVIOContext *pb)
{
- uint64_t size = get_byte(pb);
+ uint64_t size = avio_r8(pb);
if (size & 0x80) { /* long form */
int bytes_num = size & 0x7f;
/* SMPTE 379M 5.3.4 guarantee that bytes_num must not exceed 8 bytes */
@@ -171,16 +171,16 @@ static int64_t klv_decode_ber_length(ByteIOContext *pb)
return -1;
size = 0;
while (bytes_num--)
- size = size << 8 | get_byte(pb);
+ size = size << 8 | avio_r8(pb);
}
return size;
}
-static int mxf_read_sync(ByteIOContext *pb, const uint8_t *key, unsigned size)
+static int mxf_read_sync(AVIOContext *pb, const uint8_t *key, unsigned size)
{
int i, b;
for (i = 0; i < size && !url_feof(pb); i++) {
- b = get_byte(pb);
+ b = avio_r8(pb);
if (b == key[0])
i = 0;
else if (b != key[i])
@@ -189,13 +189,13 @@ static int mxf_read_sync(ByteIOContext *pb, const uint8_t *key, unsigned size)
return i == size;
}
-static int klv_read_packet(KLVPacket *klv, ByteIOContext *pb)
+static int klv_read_packet(KLVPacket *klv, AVIOContext *pb)
{
if (!mxf_read_sync(pb, mxf_klv_key, 4))
return -1;
klv->offset = url_ftell(pb) - 4;
memcpy(klv->key, mxf_klv_key, 4);
- get_buffer(pb, klv->key + 4, 12);
+ avio_read(pb, klv->key + 4, 12);
klv->length = klv_decode_ber_length(pb);
return klv->length == -1 ? -1 : 0;
}
@@ -215,7 +215,7 @@ static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv)
}
/* XXX: use AVBitStreamFilter */
-static int mxf_get_d10_aes3_packet(ByteIOContext *pb, AVStream *st, AVPacket *pkt, int64_t length)
+static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt, int64_t length)
{
const uint8_t *buf_ptr, *end_ptr;
uint8_t *data_ptr;
@@ -224,7 +224,7 @@ static int mxf_get_d10_aes3_packet(ByteIOContext *pb, AVStream *st, AVPacket *pk
if (length > 61444) /* worst case PAL 1920 samples 8 channels */
return -1;
av_new_packet(pkt, length);
- get_buffer(pb, pkt->data, length);
+ avio_read(pb, pkt->data, length);
data_ptr = pkt->data;
end_ptr = pkt->data + length;
buf_ptr = pkt->data + 4; /* skip SMPTE 331M header */
@@ -246,7 +246,7 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
{
static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t end = url_ftell(pb) + klv->length;
uint64_t size;
uint64_t orig_size;
@@ -262,13 +262,13 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
av_aes_init(mxf->aesc, s->key, 128, 1);
}
// crypto context
- url_fskip(pb, klv_decode_ber_length(pb));
+ avio_seek(pb, klv_decode_ber_length(pb), SEEK_CUR);
// plaintext offset
klv_decode_ber_length(pb);
- plaintext_size = get_be64(pb);
+ plaintext_size = avio_rb64(pb);
// source klv key
klv_decode_ber_length(pb);
- get_buffer(pb, klv->key, 16);
+ avio_read(pb, klv->key, 16);
if (!IS_KLV_KEY(klv, mxf_essence_element_key))
return -1;
index = mxf_get_stream_index(s, klv);
@@ -276,15 +276,15 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
return -1;
// source size
klv_decode_ber_length(pb);
- orig_size = get_be64(pb);
+ orig_size = avio_rb64(pb);
if (orig_size < plaintext_size)
return -1;
// enc. code
size = klv_decode_ber_length(pb);
if (size < 32 || size - 32 < orig_size)
return -1;
- get_buffer(pb, ivec, 16);
- get_buffer(pb, tmpbuf, 16);
+ avio_read(pb, ivec, 16);
+ avio_read(pb, tmpbuf, 16);
if (mxf->aesc)
av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1);
if (memcmp(tmpbuf, checkv, 16))
@@ -297,7 +297,7 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
&pkt->data[plaintext_size], size >> 4, ivec, 1);
pkt->size = orig_size;
pkt->stream_index = index;
- url_fskip(pb, end - url_ftell(pb));
+ avio_seek(pb, end - url_ftell(pb), SEEK_CUR);
return 0;
}
@@ -339,16 +339,16 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
return 0;
} else
skip:
- url_fskip(s->pb, klv.length);
+ avio_seek(s->pb, klv.length, SEEK_CUR);
}
return AVERROR_EOF;
}
-static int mxf_read_primer_pack(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFContext *mxf = arg;
- int item_num = get_be32(pb);
- int item_len = get_be32(pb);
+ int item_num = avio_rb32(pb);
+ int item_len = avio_rb32(pb);
if (item_len != 18) {
av_log(mxf->fc, AV_LOG_ERROR, "unsupported primer pack item length\n");
@@ -360,7 +360,7 @@ static int mxf_read_primer_pack(void *arg, ByteIOContext *pb, int tag, int size,
mxf->local_tags = av_malloc(item_num*item_len);
if (!mxf->local_tags)
return -1;
- get_buffer(pb, mxf->local_tags, item_num*item_len);
+ avio_read(pb, mxf->local_tags, item_num*item_len);
return 0;
}
@@ -376,166 +376,166 @@ static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
return 0;
}
-static int mxf_read_cryptographic_context(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_cryptographic_context(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFCryptoContext *cryptocontext = arg;
if (size != 16)
return -1;
if (IS_KLV_KEY(uid, mxf_crypto_source_container_ul))
- get_buffer(pb, cryptocontext->source_container_ul, 16);
+ avio_read(pb, cryptocontext->source_container_ul, 16);
return 0;
}
-static int mxf_read_content_storage(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_content_storage(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFContext *mxf = arg;
switch (tag) {
case 0x1901:
- mxf->packages_count = get_be32(pb);
+ mxf->packages_count = avio_rb32(pb);
if (mxf->packages_count >= UINT_MAX / sizeof(UID))
return -1;
mxf->packages_refs = av_malloc(mxf->packages_count * sizeof(UID));
if (!mxf->packages_refs)
return -1;
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
+ avio_seek(pb, 4, SEEK_CUR); /* useless size of objects, always 16 according to specs */
+ avio_read(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
break;
}
return 0;
}
-static int mxf_read_source_clip(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_source_clip(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFStructuralComponent *source_clip = arg;
switch(tag) {
case 0x0202:
- source_clip->duration = get_be64(pb);
+ source_clip->duration = avio_rb64(pb);
break;
case 0x1201:
- source_clip->start_position = get_be64(pb);
+ source_clip->start_position = avio_rb64(pb);
break;
case 0x1101:
/* UMID, only get last 16 bytes */
- url_fskip(pb, 16);
- get_buffer(pb, source_clip->source_package_uid, 16);
+ avio_seek(pb, 16, SEEK_CUR);
+ avio_read(pb, source_clip->source_package_uid, 16);
break;
case 0x1102:
- source_clip->source_track_id = get_be32(pb);
+ source_clip->source_track_id = avio_rb32(pb);
break;
}
return 0;
}
-static int mxf_read_material_package(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_material_package(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFPackage *package = arg;
switch(tag) {
case 0x4403:
- package->tracks_count = get_be32(pb);
+ package->tracks_count = avio_rb32(pb);
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
if (!package->tracks_refs)
return -1;
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
+ avio_seek(pb, 4, SEEK_CUR); /* useless size of objects, always 16 according to specs */
+ avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
}
return 0;
}
-static int mxf_read_track(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_track(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFTrack *track = arg;
switch(tag) {
case 0x4801:
- track->track_id = get_be32(pb);
+ track->track_id = avio_rb32(pb);
break;
case 0x4804:
- get_buffer(pb, track->track_number, 4);
+ avio_read(pb, track->track_number, 4);
break;
case 0x4B01:
- track->edit_rate.den = get_be32(pb);
- track->edit_rate.num = get_be32(pb);
+ track->edit_rate.den = avio_rb32(pb);
+ track->edit_rate.num = avio_rb32(pb);
break;
case 0x4803:
- get_buffer(pb, track->sequence_ref, 16);
+ avio_read(pb, track->sequence_ref, 16);
break;
}
return 0;
}
-static int mxf_read_sequence(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_sequence(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFSequence *sequence = arg;
switch(tag) {
case 0x0202:
- sequence->duration = get_be64(pb);
+ sequence->duration = avio_rb64(pb);
break;
case 0x0201:
- get_buffer(pb, sequence->data_definition_ul, 16);
+ avio_read(pb, sequence->data_definition_ul, 16);
break;
case 0x1001:
- sequence->structural_components_count = get_be32(pb);
+ sequence->structural_components_count = avio_rb32(pb);
if (sequence->structural_components_count >= UINT_MAX / sizeof(UID))
return -1;
sequence->structural_components_refs = av_malloc(sequence->structural_components_count * sizeof(UID));
if (!sequence->structural_components_refs)
return -1;
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID));
+ avio_seek(pb, 4, SEEK_CUR); /* useless size of objects, always 16 according to specs */
+ avio_read(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID));
break;
}
return 0;
}
-static int mxf_read_source_package(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFPackage *package = arg;
switch(tag) {
case 0x4403:
- package->tracks_count = get_be32(pb);
+ package->tracks_count = avio_rb32(pb);
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
if (!package->tracks_refs)
return -1;
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
+ avio_seek(pb, 4, SEEK_CUR); /* useless size of objects, always 16 according to specs */
+ avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
case 0x4401:
/* UMID, only get last 16 bytes */
- url_fskip(pb, 16);
- get_buffer(pb, package->package_uid, 16);
+ avio_seek(pb, 16, SEEK_CUR);
+ avio_read(pb, package->package_uid, 16);
break;
case 0x4701:
- get_buffer(pb, package->descriptor_ref, 16);
+ avio_read(pb, package->descriptor_ref, 16);
break;
}
return 0;
}
-static int mxf_read_index_table_segment(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
switch(tag) {
- case 0x3F05: av_dlog(NULL, "EditUnitByteCount %d\n", get_be32(pb)); break;
- case 0x3F06: av_dlog(NULL, "IndexSID %d\n", get_be32(pb)); break;
- case 0x3F07: av_dlog(NULL, "BodySID %d\n", get_be32(pb)); break;
- case 0x3F0B: av_dlog(NULL, "IndexEditRate %d/%d\n", get_be32(pb), get_be32(pb)); break;
- case 0x3F0C: av_dlog(NULL, "IndexStartPosition %lld\n", get_be64(pb)); break;
- case 0x3F0D: av_dlog(NULL, "IndexDuration %lld\n", get_be64(pb)); break;
+ case 0x3F05: av_dlog(NULL, "EditUnitByteCount %d\n", avio_rb32(pb)); break;
+ case 0x3F06: av_dlog(NULL, "IndexSID %d\n", avio_rb32(pb)); break;
+ case 0x3F07: av_dlog(NULL, "BodySID %d\n", avio_rb32(pb)); break;
+ case 0x3F0B: av_dlog(NULL, "IndexEditRate %d/%d\n", avio_rb32(pb), avio_rb32(pb)); break;
+ case 0x3F0C: av_dlog(NULL, "IndexStartPosition %lld\n", avio_rb64(pb)); break;
+ case 0x3F0D: av_dlog(NULL, "IndexDuration %lld\n", avio_rb64(pb)); break;
}
return 0;
}
-static void mxf_read_pixel_layout(ByteIOContext *pb, MXFDescriptor *descriptor)
+static void mxf_read_pixel_layout(AVIOContext *pb, MXFDescriptor *descriptor)
{
int code, value, ofs = 0;
char layout[16] = {0};
do {
- code = get_byte(pb);
- value = get_byte(pb);
+ code = avio_r8(pb);
+ value = avio_r8(pb);
av_dlog(NULL, "pixel layout: code %#x\n", code);
if (ofs < 16) {
@@ -547,51 +547,51 @@ static void mxf_read_pixel_layout(ByteIOContext *pb, MXFDescriptor *descriptor)
ff_mxf_decode_pixel_layout(layout, &descriptor->pix_fmt);
}
-static int mxf_read_generic_descriptor(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFDescriptor *descriptor = arg;
switch(tag) {
case 0x3F01:
- descriptor->sub_descriptors_count = get_be32(pb);
+ descriptor->sub_descriptors_count = avio_rb32(pb);
if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID))
return -1;
descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID));
if (!descriptor->sub_descriptors_refs)
return -1;
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
+ avio_seek(pb, 4, SEEK_CUR); /* useless size of objects, always 16 according to specs */
+ avio_read(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
break;
case 0x3004:
- get_buffer(pb, descriptor->essence_container_ul, 16);
+ avio_read(pb, descriptor->essence_container_ul, 16);
break;
case 0x3006:
- descriptor->linked_track_id = get_be32(pb);
+ descriptor->linked_track_id = avio_rb32(pb);
break;
case 0x3201: /* PictureEssenceCoding */
- get_buffer(pb, descriptor->essence_codec_ul, 16);
+ avio_read(pb, descriptor->essence_codec_ul, 16);
break;
case 0x3203:
- descriptor->width = get_be32(pb);
+ descriptor->width = avio_rb32(pb);
break;
case 0x3202:
- descriptor->height = get_be32(pb);
+ descriptor->height = avio_rb32(pb);
break;
case 0x320E:
- descriptor->aspect_ratio.num = get_be32(pb);
- descriptor->aspect_ratio.den = get_be32(pb);
+ descriptor->aspect_ratio.num = avio_rb32(pb);
+ descriptor->aspect_ratio.den = avio_rb32(pb);
break;
case 0x3D03:
- descriptor->sample_rate.num = get_be32(pb);
- descriptor->sample_rate.den = get_be32(pb);
+ descriptor->sample_rate.num = avio_rb32(pb);
+ descriptor->sample_rate.den = avio_rb32(pb);
break;
case 0x3D06: /* SoundEssenceCompression */
- get_buffer(pb, descriptor->essence_codec_ul, 16);
+ avio_read(pb, descriptor->essence_codec_ul, 16);
break;
case 0x3D07:
- descriptor->channels = get_be32(pb);
+ descriptor->channels = avio_rb32(pb);
break;
case 0x3D01:
- descriptor->bits_per_sample = get_be32(pb);
+ descriptor->bits_per_sample = avio_rb32(pb);
break;
case 0x3401:
mxf_read_pixel_layout(pb, descriptor);
@@ -603,7 +603,7 @@ static int mxf_read_generic_descriptor(void *arg, ByteIOContext *pb, int tag, in
if (!descriptor->extradata)
return -1;
descriptor->extradata_size = size;
- get_buffer(pb, descriptor->extradata, size);
+ avio_read(pb, descriptor->extradata, size);
}
break;
}
@@ -864,15 +864,15 @@ static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = {
static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadFunc *read_child, int ctx_size, enum MXFMetadataSetType type)
{
- ByteIOContext *pb = mxf->fc->pb;
+ AVIOContext *pb = mxf->fc->pb;
MXFMetadataSet *ctx = ctx_size ? av_mallocz(ctx_size) : mxf;
uint64_t klv_end = url_ftell(pb) + klv->length;
if (!ctx)
return -1;
while (url_ftell(pb) + 4 < klv_end) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* KLV specified by 0x53 */
+ int tag = avio_rb16(pb);
+ int size = avio_rb16(pb); /* KLV specified by 0x53 */
uint64_t next = url_ftell(pb) + size;
UID uid = {0};
@@ -893,11 +893,11 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadF
}
}
if (ctx_size && tag == 0x3C0A)
- get_buffer(pb, ctx->uid, 16);
+ avio_read(pb, ctx->uid, 16);
else if (read_child(ctx, pb, tag, size, uid) < 0)
return -1;
- url_fseek(pb, next, SEEK_SET);
+ avio_seek(pb, next, SEEK_SET);
}
if (ctx_size) ctx->type = type;
return ctx_size ? mxf_add_metadata_set(mxf, ctx) : 0;
@@ -912,7 +912,7 @@ static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
av_log(s, AV_LOG_ERROR, "could not find header partition pack key\n");
return -1;
}
- url_fseek(s->pb, -14, SEEK_CUR);
+ avio_seek(s->pb, -14, SEEK_CUR);
mxf->fc = s;
while (!url_feof(s->pb)) {
const MXFMetadataReadTableEntry *metadata;
@@ -924,7 +924,7 @@ static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key) ||
IS_KLV_KEY(klv.key, mxf_essence_element_key)) {
/* FIXME avoid seek */
- url_fseek(s->pb, klv.offset, SEEK_SET);
+ avio_seek(s->pb, klv.offset, SEEK_SET);
break;
}
@@ -943,7 +943,7 @@ static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
}
if (!metadata->read)
- url_fskip(s->pb, klv.length);
+ avio_seek(s->pb, klv.length, SEEK_CUR);
}
return mxf_parse_structural_metadata(mxf);
}
@@ -1009,7 +1009,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
if (sample_time < 0)
sample_time = 0;
seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den);
- url_fseek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET);
+ avio_seek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET);
av_update_cur_dts(s, st, sample_time);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/mxfenc.c b/mplayer/ffmpeg/libavformat/mxfenc.c
index 8a8d7dda..395d7c39 100644
--- a/mplayer/ffmpeg/libavformat/mxfenc.c
+++ b/mplayer/ffmpeg/libavformat/mxfenc.c
@@ -305,26 +305,26 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
{ 0x3D0A, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x02,0x03,0x02,0x01,0x00,0x00,0x00}}, /* Block Align */
};
-static void mxf_write_uuid(ByteIOContext *pb, enum MXFMetadataSetType type, int value)
+static void mxf_write_uuid(AVIOContext *pb, enum MXFMetadataSetType type, int value)
{
- put_buffer(pb, uuid_base, 12);
- put_be16(pb, type);
- put_be16(pb, value);
+ avio_write(pb, uuid_base, 12);
+ avio_wb16(pb, type);
+ avio_wb16(pb, value);
}
static void mxf_write_umid(AVFormatContext *s, int type)
{
MXFContext *mxf = s->priv_data;
- put_buffer(s->pb, umid_ul, 13);
- put_be24(s->pb, mxf->instance_number);
- put_buffer(s->pb, mxf->umid, 15);
- put_byte(s->pb, type);
+ avio_write(s->pb, umid_ul, 13);
+ avio_wb24(s->pb, mxf->instance_number);
+ avio_write(s->pb, mxf->umid, 15);
+ avio_w8(s->pb, type);
}
-static void mxf_write_refs_count(ByteIOContext *pb, int ref_count)
+static void mxf_write_refs_count(AVIOContext *pb, int ref_count)
{
- put_be32(pb, ref_count);
- put_be32(pb, 16);
+ avio_wb32(pb, ref_count);
+ avio_wb32(pb, 16);
}
static int klv_ber_length(uint64_t len)
@@ -335,31 +335,31 @@ static int klv_ber_length(uint64_t len)
return (av_log2(len) >> 3) + 2;
}
-static int klv_encode_ber_length(ByteIOContext *pb, uint64_t len)
+static int klv_encode_ber_length(AVIOContext *pb, uint64_t len)
{
// Determine the best BER size
int size;
if (len < 128) {
//short form
- put_byte(pb, len);
+ avio_w8(pb, len);
return 1;
}
size = (av_log2(len) >> 3) + 1;
// long form
- put_byte(pb, 0x80 + size);
+ avio_w8(pb, 0x80 + size);
while(size) {
size--;
- put_byte(pb, len >> 8 * size & 0xff);
+ avio_w8(pb, len >> 8 * size & 0xff);
}
return 0;
}
-static void klv_encode_ber4_length(ByteIOContext *pb, int len)
+static void klv_encode_ber4_length(AVIOContext *pb, int len)
{
- put_byte(pb, 0x80 + 3);
- put_be24(pb, len);
+ avio_w8(pb, 0x80 + 3);
+ avio_wb24(pb, len);
}
/*
@@ -376,33 +376,33 @@ static int mxf_get_essence_container_ul_index(enum CodecID id)
static void mxf_write_primer_pack(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int local_tag_number, i = 0;
local_tag_number = FF_ARRAY_ELEMS(mxf_local_tag_batch);
- put_buffer(pb, primer_pack_key, 16);
+ avio_write(pb, primer_pack_key, 16);
klv_encode_ber_length(pb, local_tag_number * 18 + 8);
- put_be32(pb, local_tag_number); // local_tag num
- put_be32(pb, 18); // item size, always 18 according to the specs
+ avio_wb32(pb, local_tag_number); // local_tag num
+ avio_wb32(pb, 18); // item size, always 18 according to the specs
for (i = 0; i < local_tag_number; i++) {
- put_be16(pb, mxf_local_tag_batch[i].local_tag);
- put_buffer(pb, mxf_local_tag_batch[i].uid, 16);
+ avio_wb16(pb, mxf_local_tag_batch[i].local_tag);
+ avio_write(pb, mxf_local_tag_batch[i].uid, 16);
}
}
-static void mxf_write_local_tag(ByteIOContext *pb, int size, int tag)
+static void mxf_write_local_tag(AVIOContext *pb, int size, int tag)
{
- put_be16(pb, tag);
- put_be16(pb, size);
+ avio_wb16(pb, tag);
+ avio_wb16(pb, size);
}
-static void mxf_write_metadata_key(ByteIOContext *pb, unsigned int value)
+static void mxf_write_metadata_key(AVIOContext *pb, unsigned int value)
{
- put_buffer(pb, header_metadata_key, 13);
- put_be24(pb, value);
+ avio_write(pb, header_metadata_key, 13);
+ avio_wb24(pb, value);
}
static void mxf_free(AVFormatContext *s)
@@ -429,21 +429,21 @@ static const MXFCodecUL *mxf_get_data_definition_ul(int type)
static void mxf_write_essence_container_refs(AVFormatContext *s)
{
MXFContext *c = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int i;
mxf_write_refs_count(pb, c->essence_container_count);
av_log(s,AV_LOG_DEBUG, "essence container count:%d\n", c->essence_container_count);
for (i = 0; i < c->essence_container_count; i++) {
MXFStreamContext *sc = s->streams[i]->priv_data;
- put_buffer(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
+ avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
}
}
static void mxf_write_preface(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
mxf_write_metadata_key(pb, 0x012f00);
PRINT_KEY(s, "preface key", pb->buf_ptr - 16);
@@ -456,11 +456,11 @@ static void mxf_write_preface(AVFormatContext *s)
// last modified date
mxf_write_local_tag(pb, 8, 0x3B02);
- put_be64(pb, mxf->timestamp);
+ avio_wb64(pb, mxf->timestamp);
// write version
mxf_write_local_tag(pb, 2, 0x3B05);
- put_be16(pb, 258); // v1.2
+ avio_wb16(pb, 258); // v1.2
// write identification_refs
mxf_write_local_tag(pb, 16 + 8, 0x3B06);
@@ -473,7 +473,7 @@ static void mxf_write_preface(AVFormatContext *s)
// operational pattern
mxf_write_local_tag(pb, 16, 0x3B09);
- put_buffer(pb, op1a_ul, 16);
+ avio_write(pb, op1a_ul, 16);
// write essence_container_refs
mxf_write_local_tag(pb, 8 + 16 * mxf->essence_container_count, 0x3B0A);
@@ -481,24 +481,24 @@ static void mxf_write_preface(AVFormatContext *s)
// write dm_scheme_refs
mxf_write_local_tag(pb, 8, 0x3B0B);
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
}
/*
* Write a local tag containing an ascii string as utf-16
*/
-static void mxf_write_local_tag_utf16(ByteIOContext *pb, int tag, const char *value)
+static void mxf_write_local_tag_utf16(AVIOContext *pb, int tag, const char *value)
{
int i, size = strlen(value);
mxf_write_local_tag(pb, size*2, tag);
for (i = 0; i < size; i++)
- put_be16(pb, value[i]);
+ avio_wb16(pb, value[i]);
}
static void mxf_write_identification(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
const char *company = "FFmpeg";
const char *product = "OP1a Muxer";
const char *version;
@@ -531,12 +531,12 @@ static void mxf_write_identification(AVFormatContext *s)
// modification date
mxf_write_local_tag(pb, 8, 0x3C06);
- put_be64(pb, mxf->timestamp);
+ avio_wb64(pb, mxf->timestamp);
}
static void mxf_write_content_storage(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
mxf_write_metadata_key(pb, 0x011800);
PRINT_KEY(s, "content storage key", pb->buf_ptr - 16);
@@ -562,7 +562,7 @@ static void mxf_write_content_storage(AVFormatContext *s)
static void mxf_write_track(AVFormatContext *s, AVStream *st, enum MXFMetadataSetType type)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
MXFStreamContext *sc = st->priv_data;
mxf_write_metadata_key(pb, 0x013b00);
@@ -576,22 +576,22 @@ static void mxf_write_track(AVFormatContext *s, AVStream *st, enum MXFMetadataSe
// write track id
mxf_write_local_tag(pb, 4, 0x4801);
- put_be32(pb, st->index+2);
+ avio_wb32(pb, st->index+2);
// write track number
mxf_write_local_tag(pb, 4, 0x4804);
if (type == MaterialPackage)
- put_be32(pb, 0); // track number of material package is 0
+ avio_wb32(pb, 0); // track number of material package is 0
else
- put_buffer(pb, sc->track_essence_element_key + 12, 4);
+ avio_write(pb, sc->track_essence_element_key + 12, 4);
mxf_write_local_tag(pb, 8, 0x4B01);
- put_be32(pb, mxf->time_base.den);
- put_be32(pb, mxf->time_base.num);
+ avio_wb32(pb, mxf->time_base.den);
+ avio_wb32(pb, mxf->time_base.num);
// write origin
mxf_write_local_tag(pb, 8, 0x4B02);
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
// write sequence refs
mxf_write_local_tag(pb, 16, 0x4803);
@@ -603,26 +603,26 @@ static const uint8_t smpte_12m_timecode_track_data_ul[] = { 0x06,0x0E,0x2B,0x34,
static void mxf_write_common_fields(AVFormatContext *s, AVStream *st)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
// find data define uls
mxf_write_local_tag(pb, 16, 0x0201);
if (st == mxf->timecode_track)
- put_buffer(pb, smpte_12m_timecode_track_data_ul, 16);
+ avio_write(pb, smpte_12m_timecode_track_data_ul, 16);
else {
const MXFCodecUL *data_def_ul = mxf_get_data_definition_ul(st->codec->codec_type);
- put_buffer(pb, data_def_ul->uid, 16);
+ avio_write(pb, data_def_ul->uid, 16);
}
// write duration
mxf_write_local_tag(pb, 8, 0x0202);
- put_be64(pb, mxf->duration);
+ avio_wb64(pb, mxf->duration);
}
static void mxf_write_sequence(AVFormatContext *s, AVStream *st, enum MXFMetadataSetType type)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
enum MXFMetadataSetType component;
mxf_write_metadata_key(pb, 0x010f00);
@@ -650,7 +650,7 @@ static void mxf_write_sequence(AVFormatContext *s, AVStream *st, enum MXFMetadat
static void mxf_write_timecode_component(AVFormatContext *s, AVStream *st, enum MXFMetadataSetType type)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
mxf_write_metadata_key(pb, 0x011400);
klv_encode_ber_length(pb, 75);
@@ -664,20 +664,20 @@ static void mxf_write_timecode_component(AVFormatContext *s, AVStream *st, enum
// Start Time Code
mxf_write_local_tag(pb, 8, 0x1501);
- put_be64(pb, mxf->timecode_start);
+ avio_wb64(pb, mxf->timecode_start);
// Rounded Time Code Base
mxf_write_local_tag(pb, 2, 0x1502);
- put_be16(pb, mxf->timecode_base);
+ avio_wb16(pb, mxf->timecode_base);
// Drop Frame
mxf_write_local_tag(pb, 1, 0x1503);
- put_byte(pb, mxf->timecode_drop_frame);
+ avio_w8(pb, mxf->timecode_drop_frame);
}
static void mxf_write_structural_component(AVFormatContext *s, AVStream *st, enum MXFMetadataSetType type)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int i;
mxf_write_metadata_key(pb, 0x011100);
@@ -693,28 +693,28 @@ static void mxf_write_structural_component(AVFormatContext *s, AVStream *st, enu
// write start_position
mxf_write_local_tag(pb, 8, 0x1201);
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
// write source package uid, end of the reference
mxf_write_local_tag(pb, 32, 0x1101);
if (type == SourcePackage) {
for (i = 0; i < 4; i++)
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
} else
mxf_write_umid(s, 1);
// write source track id
mxf_write_local_tag(pb, 4, 0x1102);
if (type == SourcePackage)
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
else
- put_be32(pb, st->index+2);
+ avio_wb32(pb, st->index+2);
}
static void mxf_write_multi_descriptor(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
const uint8_t *ul;
int i;
@@ -728,8 +728,8 @@ static void mxf_write_multi_descriptor(AVFormatContext *s)
// write sample rate
mxf_write_local_tag(pb, 8, 0x3001);
- put_be32(pb, mxf->time_base.den);
- put_be32(pb, mxf->time_base.num);
+ avio_wb32(pb, mxf->time_base.den);
+ avio_wb32(pb, mxf->time_base.num);
// write essence container ul
mxf_write_local_tag(pb, 16, 0x3004);
@@ -739,7 +739,7 @@ static void mxf_write_multi_descriptor(AVFormatContext *s)
MXFStreamContext *sc = s->streams[0]->priv_data;
ul = mxf_essence_container_uls[sc->index].container_ul;
}
- put_buffer(pb, ul, 16);
+ avio_write(pb, ul, 16);
// write sub descriptor refs
mxf_write_local_tag(pb, s->nb_streams * 16 + 8, 0x3F01);
@@ -752,23 +752,23 @@ static void mxf_write_generic_desc(AVFormatContext *s, AVStream *st, const UID k
{
MXFContext *mxf = s->priv_data;
MXFStreamContext *sc = st->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
- put_buffer(pb, key, 16);
+ avio_write(pb, key, 16);
klv_encode_ber4_length(pb, size+20+8+12+20);
mxf_write_local_tag(pb, 16, 0x3C0A);
mxf_write_uuid(pb, SubDescriptor, st->index);
mxf_write_local_tag(pb, 4, 0x3006);
- put_be32(pb, st->index+2);
+ avio_wb32(pb, st->index+2);
mxf_write_local_tag(pb, 8, 0x3001);
- put_be32(pb, mxf->time_base.den);
- put_be32(pb, mxf->time_base.num);
+ avio_wb32(pb, mxf->time_base.den);
+ avio_wb32(pb, mxf->time_base.num);
mxf_write_local_tag(pb, 16, 0x3004);
- put_buffer(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
+ avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
}
static const UID mxf_mpegvideo_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 };
@@ -780,7 +780,7 @@ static const UID mxf_generic_sound_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0
static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID key, unsigned size)
{
MXFStreamContext *sc = st->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int stored_height = (st->codec->height+15)/16*16;
int display_height;
int f1, f2;
@@ -788,13 +788,13 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
mxf_write_generic_desc(s, st, key, size+8+8+8+8+8+8+5+16+sc->interlaced*4+12+20);
mxf_write_local_tag(pb, 4, 0x3203);
- put_be32(pb, st->codec->width);
+ avio_wb32(pb, st->codec->width);
mxf_write_local_tag(pb, 4, 0x3202);
- put_be32(pb, stored_height>>sc->interlaced);
+ avio_wb32(pb, stored_height>>sc->interlaced);
mxf_write_local_tag(pb, 4, 0x3209);
- put_be32(pb, st->codec->width);
+ avio_wb32(pb, st->codec->width);
if (st->codec->height == 608) // PAL + VBI
display_height = 576;
@@ -804,19 +804,19 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
display_height = st->codec->height;
mxf_write_local_tag(pb, 4, 0x3208);
- put_be32(pb, display_height>>sc->interlaced);
+ avio_wb32(pb, display_height>>sc->interlaced);
// component depth
mxf_write_local_tag(pb, 4, 0x3301);
- put_be32(pb, 8);
+ avio_wb32(pb, 8);
// horizontal subsampling
mxf_write_local_tag(pb, 4, 0x3302);
- put_be32(pb, 2);
+ avio_wb32(pb, 2);
// frame layout
mxf_write_local_tag(pb, 1, 0x320C);
- put_byte(pb, sc->interlaced);
+ avio_w8(pb, sc->interlaced);
// video line map
switch (st->codec->height) {
@@ -835,18 +835,18 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
}
mxf_write_local_tag(pb, 12+sc->interlaced*4, 0x320D);
- put_be32(pb, sc->interlaced ? 2 : 1);
- put_be32(pb, 4);
- put_be32(pb, f1);
+ avio_wb32(pb, sc->interlaced ? 2 : 1);
+ avio_wb32(pb, 4);
+ avio_wb32(pb, f1);
if (sc->interlaced)
- put_be32(pb, f2);
+ avio_wb32(pb, f2);
mxf_write_local_tag(pb, 8, 0x320E);
- put_be32(pb, sc->aspect_ratio.num);
- put_be32(pb, sc->aspect_ratio.den);
+ avio_wb32(pb, sc->aspect_ratio.num);
+ avio_wb32(pb, sc->aspect_ratio.den);
mxf_write_local_tag(pb, 16, 0x3201);
- put_buffer(pb, *sc->codec_ul, 16);
+ avio_write(pb, *sc->codec_ul, 16);
}
static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st)
@@ -856,56 +856,56 @@ static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st)
static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int profile_and_level = (st->codec->profile<<4) | st->codec->level;
mxf_write_cdci_common(s, st, mxf_mpegvideo_descriptor_key, 8+5);
// bit rate
mxf_write_local_tag(pb, 4, 0x8000);
- put_be32(pb, st->codec->bit_rate);
+ avio_wb32(pb, st->codec->bit_rate);
// profile and level
mxf_write_local_tag(pb, 1, 0x8007);
if (!st->codec->profile)
profile_and_level |= 0x80; // escape bit
- put_byte(pb, profile_and_level);
+ avio_w8(pb, profile_and_level);
}
static void mxf_write_generic_sound_common(AVFormatContext *s, AVStream *st, const UID key, unsigned size)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
mxf_write_generic_desc(s, st, key, size+5+12+8+8);
// audio locked
mxf_write_local_tag(pb, 1, 0x3D02);
- put_byte(pb, 1);
+ avio_w8(pb, 1);
// write audio sampling rate
mxf_write_local_tag(pb, 8, 0x3D03);
- put_be32(pb, st->codec->sample_rate);
- put_be32(pb, 1);
+ avio_wb32(pb, st->codec->sample_rate);
+ avio_wb32(pb, 1);
mxf_write_local_tag(pb, 4, 0x3D07);
- put_be32(pb, st->codec->channels);
+ avio_wb32(pb, st->codec->channels);
mxf_write_local_tag(pb, 4, 0x3D01);
- put_be32(pb, av_get_bits_per_sample(st->codec->codec_id));
+ avio_wb32(pb, av_get_bits_per_sample(st->codec->codec_id));
}
static void mxf_write_wav_common(AVFormatContext *s, AVStream *st, const UID key, unsigned size)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
mxf_write_generic_sound_common(s, st, key, size+6+8);
mxf_write_local_tag(pb, 2, 0x3D0A);
- put_be16(pb, st->codec->block_align);
+ avio_wb16(pb, st->codec->block_align);
// avg bytes per sec
mxf_write_local_tag(pb, 4, 0x3D09);
- put_be32(pb, st->codec->block_align*st->codec->sample_rate);
+ avio_wb32(pb, st->codec->block_align*st->codec->sample_rate);
}
static void mxf_write_wav_desc(AVFormatContext *s, AVStream *st)
@@ -926,7 +926,7 @@ static void mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st)
static void mxf_write_package(AVFormatContext *s, enum MXFMetadataSetType type)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int i, track_count = s->nb_streams+1;
if (type == MaterialPackage) {
@@ -952,11 +952,11 @@ static void mxf_write_package(AVFormatContext *s, enum MXFMetadataSetType type)
// package creation date
mxf_write_local_tag(pb, 8, 0x4405);
- put_be64(pb, mxf->timestamp);
+ avio_wb64(pb, mxf->timestamp);
// package modified date
mxf_write_local_tag(pb, 8, 0x4404);
- put_be64(pb, mxf->timestamp);
+ avio_wb64(pb, mxf->timestamp);
// write track refs
mxf_write_local_tag(pb, track_count*16 + 8, 0x4403);
@@ -996,7 +996,7 @@ static void mxf_write_package(AVFormatContext *s, enum MXFMetadataSetType type)
static int mxf_write_essence_container_data(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
mxf_write_metadata_key(pb, 0x012300);
klv_encode_ber_length(pb, 72);
@@ -1008,10 +1008,10 @@ static int mxf_write_essence_container_data(AVFormatContext *s)
mxf_write_umid(s, 1);
mxf_write_local_tag(pb, 4, 0x3F07); // BodySID
- put_be32(pb, 1);
+ avio_wb32(pb, 1);
mxf_write_local_tag(pb, 4, 0x3F06); // IndexSID
- put_be32(pb, 2);
+ avio_wb32(pb, 2);
return 0;
}
@@ -1039,7 +1039,7 @@ static unsigned klv_fill_size(uint64_t size)
static void mxf_write_index_table_segment(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int i, j, temporal_reordering = 0;
int key_index = mxf->last_key_index;
@@ -1048,7 +1048,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
if (!mxf->edit_units_count && !mxf->edit_unit_byte_count)
return;
- put_buffer(pb, index_table_segment_key, 16);
+ avio_write(pb, index_table_segment_key, 16);
if (mxf->edit_unit_byte_count) {
klv_encode_ber_length(pb, 80);
@@ -1063,65 +1063,65 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
// index edit rate
mxf_write_local_tag(pb, 8, 0x3F0B);
- put_be32(pb, mxf->time_base.den);
- put_be32(pb, mxf->time_base.num);
+ avio_wb32(pb, mxf->time_base.den);
+ avio_wb32(pb, mxf->time_base.num);
// index start position
mxf_write_local_tag(pb, 8, 0x3F0C);
- put_be64(pb, mxf->last_indexed_edit_unit);
+ avio_wb64(pb, mxf->last_indexed_edit_unit);
// index duration
mxf_write_local_tag(pb, 8, 0x3F0D);
if (mxf->edit_unit_byte_count)
- put_be64(pb, 0); // index table covers whole container
+ avio_wb64(pb, 0); // index table covers whole container
else
- put_be64(pb, mxf->edit_units_count);
+ avio_wb64(pb, mxf->edit_units_count);
// edit unit byte count
mxf_write_local_tag(pb, 4, 0x3F05);
- put_be32(pb, mxf->edit_unit_byte_count);
+ avio_wb32(pb, mxf->edit_unit_byte_count);
// index sid
mxf_write_local_tag(pb, 4, 0x3F06);
- put_be32(pb, 2);
+ avio_wb32(pb, 2);
// body sid
mxf_write_local_tag(pb, 4, 0x3F07);
- put_be32(pb, 1);
+ avio_wb32(pb, 1);
if (!mxf->edit_unit_byte_count) {
// real slice count - 1
mxf_write_local_tag(pb, 1, 0x3F08);
- put_byte(pb, mxf->slice_count);
+ avio_w8(pb, mxf->slice_count);
// delta entry array
mxf_write_local_tag(pb, 8 + (s->nb_streams+1)*6, 0x3F09);
- put_be32(pb, s->nb_streams+1); // num of entries
- put_be32(pb, 6); // size of one entry
+ avio_wb32(pb, s->nb_streams+1); // num of entries
+ avio_wb32(pb, 6); // size of one entry
// write system item delta entry
- put_byte(pb, 0);
- put_byte(pb, 0); // slice entry
- put_be32(pb, 0); // element delta
+ avio_w8(pb, 0);
+ avio_w8(pb, 0); // slice entry
+ avio_wb32(pb, 0); // element delta
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
MXFStreamContext *sc = st->priv_data;
- put_byte(pb, sc->temporal_reordering);
+ avio_w8(pb, sc->temporal_reordering);
if (sc->temporal_reordering)
temporal_reordering = 1;
if (i == 0) { // video track
- put_byte(pb, 0); // slice number
- put_be32(pb, KAG_SIZE); // system item size including klv fill
+ avio_w8(pb, 0); // slice number
+ avio_wb32(pb, KAG_SIZE); // system item size including klv fill
} else { // audio track
unsigned audio_frame_size = sc->aic.samples[0]*sc->aic.sample_size;
audio_frame_size += klv_fill_size(audio_frame_size);
- put_byte(pb, 1);
- put_be32(pb, (i-1)*audio_frame_size); // element delta
+ avio_w8(pb, 1);
+ avio_wb32(pb, (i-1)*audio_frame_size); // element delta
}
}
mxf_write_local_tag(pb, 8 + mxf->edit_units_count*(11+mxf->slice_count*4), 0x3F0A);
- put_be32(pb, mxf->edit_units_count); // num of entries
- put_be32(pb, 11+mxf->slice_count*4); // size of one entry
+ avio_wb32(pb, mxf->edit_units_count); // num of entries
+ avio_wb32(pb, 11+mxf->slice_count*4); // size of one entry
for (i = 0; i < mxf->edit_units_count; i++) {
int temporal_offset = 0;
@@ -1143,12 +1143,12 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
temporal_offset = j - key_index - pic_num_in_gop;
}
}
- put_byte(pb, temporal_offset);
+ avio_w8(pb, temporal_offset);
if ((mxf->index_entries[i].flags & 0x30) == 0x30) { // back and forward prediction
- put_byte(pb, mxf->last_key_index - i);
+ avio_w8(pb, mxf->last_key_index - i);
} else {
- put_byte(pb, key_index - i); // key frame offset
+ avio_w8(pb, key_index - i); // key frame offset
if ((mxf->index_entries[i].flags & 0x20) == 0x20) // only forward
mxf->last_key_index = key_index;
}
@@ -1156,11 +1156,11 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
if (!(mxf->index_entries[i].flags & 0x33) && // I frame
mxf->index_entries[i].flags & 0x40 && !temporal_offset)
mxf->index_entries[i].flags |= 0x80; // random access
- put_byte(pb, mxf->index_entries[i].flags);
+ avio_w8(pb, mxf->index_entries[i].flags);
// stream offset
- put_be64(pb, mxf->index_entries[i].offset);
+ avio_wb64(pb, mxf->index_entries[i].offset);
if (s->nb_streams > 1)
- put_be32(pb, mxf->index_entries[i].slice_offset);
+ avio_wb32(pb, mxf->index_entries[i].slice_offset);
}
mxf->last_key_index = key_index - mxf->edit_units_count;
@@ -1173,11 +1173,11 @@ static void mxf_write_klv_fill(AVFormatContext *s)
{
unsigned pad = klv_fill_size(url_ftell(s->pb));
if (pad) {
- put_buffer(s->pb, klv_fill_key, 16);
+ avio_write(s->pb, klv_fill_key, 16);
pad -= 16 + 4;
klv_encode_ber4_length(s->pb, pad);
for (; pad; pad--)
- put_byte(s->pb, 0);
+ avio_w8(s->pb, 0);
assert(!(url_ftell(s->pb) & (KAG_SIZE-1)));
}
}
@@ -1187,7 +1187,7 @@ static void mxf_write_partition(AVFormatContext *s, int bodysid,
const uint8_t *key, int write_metadata)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t header_byte_count_offset;
unsigned index_byte_count = 0;
uint64_t partition_offset = url_ftell(pb);
@@ -1213,43 +1213,43 @@ static void mxf_write_partition(AVFormatContext *s, int bodysid,
}
// write klv
- put_buffer(pb, key, 16);
+ avio_write(pb, key, 16);
klv_encode_ber_length(pb, 88 + 16 * mxf->essence_container_count);
// write partition value
- put_be16(pb, 1); // majorVersion
- put_be16(pb, 2); // minorVersion
- put_be32(pb, KAG_SIZE); // KAGSize
+ avio_wb16(pb, 1); // majorVersion
+ avio_wb16(pb, 2); // minorVersion
+ avio_wb32(pb, KAG_SIZE); // KAGSize
- put_be64(pb, partition_offset); // ThisPartition
+ avio_wb64(pb, partition_offset); // ThisPartition
if (!memcmp(key, body_partition_key, 16) && mxf->body_partitions_count > 1)
- put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]); // PreviousPartition
+ avio_wb64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]); // PreviousPartition
else if (!memcmp(key, footer_partition_key, 16) && mxf->body_partitions_count)
- put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]); // PreviousPartition
+ avio_wb64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]); // PreviousPartition
else
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
- put_be64(pb, mxf->footer_partition_offset); // footerPartition
+ avio_wb64(pb, mxf->footer_partition_offset); // footerPartition
// set offset
header_byte_count_offset = url_ftell(pb);
- put_be64(pb, 0); // headerByteCount, update later
+ avio_wb64(pb, 0); // headerByteCount, update later
// indexTable
- put_be64(pb, index_byte_count); // indexByteCount
- put_be32(pb, index_byte_count ? indexsid : 0); // indexSID
+ avio_wb64(pb, index_byte_count); // indexByteCount
+ avio_wb32(pb, index_byte_count ? indexsid : 0); // indexSID
// BodyOffset
if (bodysid && mxf->edit_units_count && mxf->body_partitions_count) {
- put_be64(pb, mxf->body_offset);
+ avio_wb64(pb, mxf->body_offset);
} else
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
- put_be32(pb, bodysid); // bodySID
+ avio_wb32(pb, bodysid); // bodySID
// operational pattern
- put_buffer(pb, op1a_ul, 16);
+ avio_write(pb, op1a_ul, 16);
// essence container
mxf_write_essence_container_refs(s);
@@ -1267,9 +1267,9 @@ static void mxf_write_partition(AVFormatContext *s, int bodysid,
header_byte_count = pos - start + klv_fill_size(pos);
// update header_byte_count
- url_fseek(pb, header_byte_count_offset, SEEK_SET);
- put_be64(pb, header_byte_count);
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, header_byte_count_offset, SEEK_SET);
+ avio_wb64(pb, header_byte_count);
+ avio_seek(pb, pos, SEEK_SET);
}
put_flush_packet(pb);
@@ -1557,48 +1557,48 @@ static uint32_t ff_framenum_to_12m_time_code(unsigned frame, int drop, int fps)
static void mxf_write_system_item(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned frame;
uint32_t time_code;
frame = mxf->timecode_start + mxf->last_indexed_edit_unit + mxf->edit_units_count;
// write system metadata pack
- put_buffer(pb, system_metadata_pack_key, 16);
+ avio_write(pb, system_metadata_pack_key, 16);
klv_encode_ber4_length(pb, 57);
- put_byte(pb, 0x5c); // UL, user date/time stamp, picture and sound item present
- put_byte(pb, 0x04); // content package rate
- put_byte(pb, 0x00); // content package type
- put_be16(pb, 0x00); // channel handle
- put_be16(pb, frame); // continuity count
+ avio_w8(pb, 0x5c); // UL, user date/time stamp, picture and sound item present
+ avio_w8(pb, 0x04); // content package rate
+ avio_w8(pb, 0x00); // content package type
+ avio_wb16(pb, 0x00); // channel handle
+ avio_wb16(pb, frame); // continuity count
if (mxf->essence_container_count > 1)
- put_buffer(pb, multiple_desc_ul, 16);
+ avio_write(pb, multiple_desc_ul, 16);
else {
MXFStreamContext *sc = s->streams[0]->priv_data;
- put_buffer(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
+ avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
}
- put_byte(pb, 0);
- put_be64(pb, 0);
- put_be64(pb, 0); // creation date/time stamp
+ avio_w8(pb, 0);
+ avio_wb64(pb, 0);
+ avio_wb64(pb, 0); // creation date/time stamp
- put_byte(pb, 0x81); // SMPTE 12M time code
+ avio_w8(pb, 0x81); // SMPTE 12M time code
time_code = ff_framenum_to_12m_time_code(frame, mxf->timecode_drop_frame, mxf->timecode_base);
- put_be32(pb, time_code);
- put_be32(pb, 0); // binary group data
- put_be64(pb, 0);
+ avio_wb32(pb, time_code);
+ avio_wb32(pb, 0); // binary group data
+ avio_wb64(pb, 0);
// write system metadata package set
- put_buffer(pb, system_metadata_package_set_key, 16);
+ avio_write(pb, system_metadata_package_set_key, 16);
klv_encode_ber4_length(pb, 35);
- put_byte(pb, 0x83); // UMID
- put_be16(pb, 0x20);
+ avio_w8(pb, 0x83); // UMID
+ avio_wb16(pb, 0x20);
mxf_write_umid(s, 1);
}
static void mxf_write_d10_video_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int packet_size = (uint64_t)st->codec->bit_rate*mxf->time_base.num /
(8*mxf->time_base.den); // frame size
int pad;
@@ -1607,28 +1607,28 @@ static void mxf_write_d10_video_packet(AVFormatContext *s, AVStream *st, AVPacke
packet_size += klv_fill_size(packet_size);
klv_encode_ber4_length(pb, pkt->size);
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
// ensure CBR muxing by padding to correct video frame size
pad = packet_size - pkt->size - 16 - 4;
if (pad > 20) {
- put_buffer(s->pb, klv_fill_key, 16);
+ avio_write(s->pb, klv_fill_key, 16);
pad -= 16 + 4;
klv_encode_ber4_length(s->pb, pad);
for (; pad; pad--)
- put_byte(s->pb, 0);
+ avio_w8(s->pb, 0);
assert(!(url_ftell(s->pb) & (KAG_SIZE-1)));
} else {
av_log(s, AV_LOG_WARNING, "cannot fill d-10 video packet\n");
for (; pad > 0; pad--)
- put_byte(s->pb, 0);
+ avio_w8(s->pb, 0);
}
}
static void mxf_write_d10_audio_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int frame_size = pkt->size / st->codec->block_align;
uint8_t *samples = pkt->data;
uint8_t *end = pkt->data + pkt->size;
@@ -1636,9 +1636,9 @@ static void mxf_write_d10_audio_packet(AVFormatContext *s, AVStream *st, AVPacke
klv_encode_ber4_length(pb, 4 + frame_size*4*8);
- put_byte(pb, (frame_size == 1920 ? 0 : (mxf->edit_units_count-1) % 5 + 1));
- put_le16(pb, frame_size);
- put_byte(pb, (1<codec->channels)-1);
+ avio_w8(pb, (frame_size == 1920 ? 0 : (mxf->edit_units_count-1) % 5 + 1));
+ avio_wl16(pb, frame_size);
+ avio_w8(pb, (1<codec->channels)-1);
while (samples < end) {
for (i = 0; i < st->codec->channels; i++) {
@@ -1650,17 +1650,17 @@ static void mxf_write_d10_audio_packet(AVFormatContext *s, AVStream *st, AVPacke
sample = AV_RL16(samples)<<12;
samples += 2;
}
- put_le32(pb, sample | i);
+ avio_wl32(pb, sample | i);
}
for (; i < 8; i++)
- put_le32(pb, i);
+ avio_wl32(pb, i);
}
}
static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st = s->streams[pkt->stream_index];
MXFStreamContext *sc = st->priv_data;
MXFIndexEntry ie = {0};
@@ -1719,7 +1719,7 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
}
mxf_write_klv_fill(s);
- put_buffer(pb, sc->track_essence_element_key, 16); // write key
+ avio_write(pb, sc->track_essence_element_key, 16); // write key
if (s->oformat == &ff_mxf_d10_muxer) {
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
mxf_write_d10_video_packet(s, st, pkt);
@@ -1727,7 +1727,7 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
mxf_write_d10_audio_packet(s, st, pkt);
} else {
klv_encode_ber4_length(pb, pkt->size); // write length
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
mxf->body_offset += 16+4+pkt->size + klv_fill_size(16+4+pkt->size);
}
@@ -1739,34 +1739,34 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
static void mxf_write_random_index_pack(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint64_t pos = url_ftell(pb);
int i;
- put_buffer(pb, random_index_pack_key, 16);
+ avio_write(pb, random_index_pack_key, 16);
klv_encode_ber_length(pb, 28 + 12*mxf->body_partitions_count);
if (mxf->edit_unit_byte_count)
- put_be32(pb, 1); // BodySID of header partition
+ avio_wb32(pb, 1); // BodySID of header partition
else
- put_be32(pb, 0);
- put_be64(pb, 0); // offset of header partition
+ avio_wb32(pb, 0);
+ avio_wb64(pb, 0); // offset of header partition
for (i = 0; i < mxf->body_partitions_count; i++) {
- put_be32(pb, 1); // BodySID
- put_be64(pb, mxf->body_partition_offset[i]);
+ avio_wb32(pb, 1); // BodySID
+ avio_wb64(pb, mxf->body_partition_offset[i]);
}
- put_be32(pb, 0); // BodySID of footer partition
- put_be64(pb, mxf->footer_partition_offset);
+ avio_wb32(pb, 0); // BodySID of footer partition
+ avio_wb64(pb, mxf->footer_partition_offset);
- put_be32(pb, url_ftell(pb) - pos + 4);
+ avio_wb32(pb, url_ftell(pb) - pos + 4);
}
static int mxf_write_footer(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
mxf->duration = mxf->last_indexed_edit_unit + mxf->edit_units_count;
@@ -1785,7 +1785,7 @@ static int mxf_write_footer(AVFormatContext *s)
mxf_write_random_index_pack(s);
if (!url_is_streamed(s->pb)) {
- url_fseek(pb, 0, SEEK_SET);
+ avio_seek(pb, 0, SEEK_SET);
if (mxf->edit_unit_byte_count) {
mxf_write_partition(s, 1, 2, header_closed_partition_key, 1);
mxf_write_klv_fill(s);
diff --git a/mplayer/ffmpeg/libavformat/mxg.c b/mplayer/ffmpeg/libavformat/mxg.c
index 9be97d0d..81ffec69 100644
--- a/mplayer/ffmpeg/libavformat/mxg.c
+++ b/mplayer/ffmpeg/libavformat/mxg.c
@@ -115,7 +115,7 @@ static int mxg_update_cache(AVFormatContext *s, unsigned int cache_size)
if (mxg->soi_ptr) mxg->soi_ptr = mxg->buffer + soi_pos;
/* get data */
- ret = get_buffer(s->pb, mxg->buffer_ptr + mxg->cache_size,
+ ret = avio_read(s->pb, mxg->buffer_ptr + mxg->cache_size,
cache_size - mxg->cache_size);
if (ret < 0)
return ret;
diff --git a/mplayer/ffmpeg/libavformat/ncdec.c b/mplayer/ffmpeg/libavformat/ncdec.c
index 1472d15c..79a4dbaf 100644
--- a/mplayer/ffmpeg/libavformat/ncdec.c
+++ b/mplayer/ffmpeg/libavformat/ncdec.c
@@ -68,12 +68,12 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt)
while (state != NC_VIDEO_FLAG) {
if (url_feof(s->pb))
return AVERROR(EIO);
- state = (state<<8) + get_byte(s->pb);
+ state = (state<<8) + avio_r8(s->pb);
}
- get_byte(s->pb);
- size = get_le16(s->pb);
- url_fskip(s->pb, 9);
+ avio_r8(s->pb);
+ size = avio_rl16(s->pb);
+ avio_seek(s->pb, 9, SEEK_CUR);
if (size == 0) {
av_log(s, AV_LOG_DEBUG, "Next packet size is zero\n");
diff --git a/mplayer/ffmpeg/libavformat/network.h b/mplayer/ffmpeg/libavformat/network.h
index eda6a8ef..1e80f1d2 100644
--- a/mplayer/ffmpeg/libavformat/network.h
+++ b/mplayer/ffmpeg/libavformat/network.h
@@ -27,31 +27,60 @@
#include
#include
-#define ff_neterrno() (-WSAGetLastError())
-#define FF_NETERROR(err) (-WSA##err)
-#define WSAEAGAIN WSAEWOULDBLOCK
+#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
+#define ETIMEDOUT WSAETIMEDOUT
+#define ECONNREFUSED WSAECONNREFUSED
+#define EINPROGRESS WSAEINPROGRESS
+
+static inline int ff_neterrno() {
+ int err = WSAGetLastError();
+ switch (err) {
+ case WSAEWOULDBLOCK:
+ return AVERROR(EAGAIN);
+ case WSAEINTR:
+ return AVERROR(EINTR);
+ }
+ return -err;
+}
#else
-#ifndef GEKKO
#include
+#if !defined(GEKKO)
#include
#include
#include
#else
#include
-#define INADDR_LOOPBACK ((unsigned long) 0x7f000001) /* 127.0.0.1 */
-#define send net_send
-#define sendto net_sendto
-#define recv net_recv
-#define select net_select
-#define socket net_socket
-#define gethostbyname net_gethostbyname
-#define setsockopt net_setsockopt
-#define bind net_bind
-#define connect net_connect
+
+#define INADDR_LOOPBACK 0x7f000001
+
+static inline int _net_result(s32 ret)
+{
+ if (ret < 0) errno = AVUNERROR(ret);
+ return ret < 0 ? SOCKET_ERROR : ret;
+}
+
+#define socket(domain, type, protocol) \
+ _net_result(net_socket(domain, type, IPPROTO_IP))
+#define bind(sockfd, my_addr, addrlen) \
+ _net_result(net_bind(sockfd, my_addr, addrlen))
+#define connect(sockfd, serv_addr, addrlen) \
+ _net_result(net_connect(sockfd, serv_addr, addrlen))
+#define send(s, buf, len, flags) \
+ _net_result(net_send(s, buf, len, flags))
+#define sendto(s, buf, len, flags, to, tolen) \
+ _net_result(net_sendto(s, buf, len, flags, to, tolen))
+#define recv(s, buf, len, flags) \
+ _net_result(net_recv(s, buf, len, flags))
+#define closesocket(sockfd) \
+ _net_result(net_close(sockfd))
+#define setsockopt(s, level, optname, optval, optlen) \
+ _net_result(net_setsockopt(s, level, optname, optval, optlen))
+#define poll(fds, nfds, timeout) \
+ _net_result(net_poll((struct pollsd *)fds, nfds, timeout))
+#define gethostbyname(name) net_gethostbyname(name)
#endif
#define ff_neterrno() AVERROR(errno)
-#define FF_NETERROR(err) AVERROR(err)
#endif
#if HAVE_ARPA_INET_H
diff --git a/mplayer/ffmpeg/libavformat/nsvdec.c b/mplayer/ffmpeg/libavformat/nsvdec.c
index e15d6e28..cc0c5d7c 100644
--- a/mplayer/ffmpeg/libavformat/nsvdec.c
+++ b/mplayer/ffmpeg/libavformat/nsvdec.c
@@ -81,12 +81,6 @@
* - seek
*/
-#ifdef DEBUG
-#define PRINT(_v) printf _v
-#else
-#define PRINT(_v)
-#endif
-
#if 0
struct NSVf_header {
uint32_t chunk_tag; /* 'NSVf' */
@@ -216,102 +210,96 @@ static const AVCodecTag nsv_codec_audio_tags[] = {
//static int nsv_load_index(AVFormatContext *s);
static int nsv_read_chunk(AVFormatContext *s, int fill_header);
-#ifdef DEBUG
-static void print_tag(const char *str, unsigned int tag, int size)
-{
- printf("%s: tag=%c%c%c%c\n",
- str, tag & 0xff,
- (tag >> 8) & 0xff,
- (tag >> 16) & 0xff,
- (tag >> 24) & 0xff);
-}
-#endif
+#define print_tag(str, tag, size) \
+ av_dlog(NULL, "%s: tag=%c%c%c%c\n", \
+ str, tag & 0xff, \
+ (tag >> 8) & 0xff, \
+ (tag >> 16) & 0xff, \
+ (tag >> 24) & 0xff);
/* try to find something we recognize, and set the state accordingly */
static int nsv_resync(AVFormatContext *s)
{
NSVContext *nsv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint32_t v = 0;
int i;
- PRINT(("%s(), offset = %"PRId64", state = %d\n", __FUNCTION__, url_ftell(pb), nsv->state));
+ av_dlog(s, "%s(), offset = %"PRId64", state = %d\n", __FUNCTION__, url_ftell(pb), nsv->state);
//nsv->state = NSV_UNSYNC;
for (i = 0; i < NSV_MAX_RESYNC; i++) {
if (url_feof(pb)) {
- PRINT(("NSV EOF\n"));
+ av_dlog(s, "NSV EOF\n");
nsv->state = NSV_UNSYNC;
return -1;
}
v <<= 8;
- v |= get_byte(pb);
-/*
+ v |= avio_r8(pb);
if (i < 8) {
- PRINT(("NSV resync: [%d] = %02x\n", i, v & 0x0FF));
+ av_dlog(s, "NSV resync: [%d] = %02x\n", i, v & 0x0FF);
}
-*/
if ((v & 0x0000ffff) == 0xefbe) { /* BEEF */
- PRINT(("NSV resynced on BEEF after %d bytes\n", i+1));
+ av_dlog(s, "NSV resynced on BEEF after %d bytes\n", i+1);
nsv->state = NSV_FOUND_BEEF;
return 0;
}
/* we read as big endian, thus the MK*BE* */
if (v == TB_NSVF) { /* NSVf */
- PRINT(("NSV resynced on NSVf after %d bytes\n", i+1));
+ av_dlog(s, "NSV resynced on NSVf after %d bytes\n", i+1);
nsv->state = NSV_FOUND_NSVF;
return 0;
}
if (v == MKBETAG('N', 'S', 'V', 's')) { /* NSVs */
- PRINT(("NSV resynced on NSVs after %d bytes\n", i+1));
+ av_dlog(s, "NSV resynced on NSVs after %d bytes\n", i+1);
nsv->state = NSV_FOUND_NSVS;
return 0;
}
}
- PRINT(("NSV sync lost\n"));
+ av_dlog(s, "NSV sync lost\n");
return -1;
}
static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
{
NSVContext *nsv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int file_size, size;
int64_t duration;
int strings_size;
int table_entries;
int table_entries_used;
- PRINT(("%s()\n", __FUNCTION__));
+ av_dlog(s, "%s()\n", __FUNCTION__);
nsv->state = NSV_UNSYNC; /* in case we fail */
- size = get_le32(pb);
+ size = avio_rl32(pb);
if (size < 28)
return -1;
nsv->NSVf_end = size;
- //s->file_size = (uint32_t)get_le32(pb);
- file_size = (uint32_t)get_le32(pb);
- PRINT(("NSV NSVf chunk_size %u\n", size));
- PRINT(("NSV NSVf file_size %u\n", file_size));
+ //s->file_size = (uint32_t)avio_rl32(pb);
+ file_size = (uint32_t)avio_rl32(pb);
+ av_dlog(s, "NSV NSVf chunk_size %u\n", size);
+ av_dlog(s, "NSV NSVf file_size %u\n", file_size);
- nsv->duration = duration = get_le32(pb); /* in ms */
- PRINT(("NSV NSVf duration %"PRId64" ms\n", duration));
+ nsv->duration = duration = avio_rl32(pb); /* in ms */
+ av_dlog(s, "NSV NSVf duration %"PRId64" ms\n", duration);
// XXX: store it in AVStreams
- strings_size = get_le32(pb);
- table_entries = get_le32(pb);
- table_entries_used = get_le32(pb);
- PRINT(("NSV NSVf info-strings size: %d, table entries: %d, bis %d\n",
- strings_size, table_entries, table_entries_used));
+ strings_size = avio_rl32(pb);
+ table_entries = avio_rl32(pb);
+ table_entries_used = avio_rl32(pb);
+ av_dlog(s, "NSV NSVf info-strings size: %d, table entries: %d, bis %d\n",
+ strings_size, table_entries, table_entries_used);
if (url_feof(pb))
return -1;
- PRINT(("NSV got header; filepos %"PRId64"\n", url_ftell(pb)));
+ av_dlog(s, "NSV got header; filepos %"PRId64"\n", url_ftell(pb));
if (strings_size > 0) {
char *strings; /* last byte will be '\0' to play safe with str*() */
@@ -321,7 +309,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
p = strings = av_mallocz(strings_size + 1);
endp = strings + strings_size;
- get_buffer(pb, strings, strings_size);
+ avio_read(pb, strings, strings_size);
while (p < endp) {
while (*p == ' ')
p++; /* strip out spaces */
@@ -338,7 +326,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
if (!p || p >= endp)
break;
*p++ = '\0';
- PRINT(("NSV NSVf INFO: %s='%s'\n", token, value));
+ av_dlog(s, "NSV NSVf INFO: %s='%s'\n", token, value);
av_metadata_set2(&s->metadata, token, value, 0);
}
av_free(strings);
@@ -346,7 +334,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
if (url_feof(pb))
return -1;
- PRINT(("NSV got infos; filepos %"PRId64"\n", url_ftell(pb)));
+ av_dlog(s, "NSV got infos; filepos %"PRId64"\n", url_ftell(pb));
if (table_entries_used > 0) {
int i;
@@ -356,39 +344,39 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
nsv->nsvs_file_offset = av_malloc((unsigned)table_entries_used * sizeof(uint32_t));
for(i=0;insvs_file_offset[i] = get_le32(pb) + size;
+ nsv->nsvs_file_offset[i] = avio_rl32(pb) + size;
if(table_entries > table_entries_used &&
- get_le32(pb) == MKTAG('T','O','C','2')) {
+ avio_rl32(pb) == MKTAG('T','O','C','2')) {
nsv->nsvs_timestamps = av_malloc((unsigned)table_entries_used*sizeof(uint32_t));
for(i=0;insvs_timestamps[i] = get_le32(pb);
+ nsv->nsvs_timestamps[i] = avio_rl32(pb);
}
}
}
- PRINT(("NSV got index; filepos %"PRId64"\n", url_ftell(pb)));
+ av_dlog(s, "NSV got index; filepos %"PRId64"\n", url_ftell(pb));
#ifdef DEBUG_DUMP_INDEX
#define V(v) ((v<0x20 || v > 127)?'.':v)
/* dump index */
- PRINT(("NSV %d INDEX ENTRIES:\n", table_entries));
- PRINT(("NSV [dataoffset][fileoffset]\n", table_entries));
+ av_dlog(s, "NSV %d INDEX ENTRIES:\n", table_entries);
+ av_dlog(s, "NSV [dataoffset][fileoffset]\n", table_entries);
for (i = 0; i < table_entries; i++) {
unsigned char b[8];
- url_fseek(pb, size + nsv->nsvs_file_offset[i], SEEK_SET);
- get_buffer(pb, b, 8);
- PRINT(("NSV [0x%08lx][0x%08lx]: %02x %02x %02x %02x %02x %02x %02x %02x"
+ avio_seek(pb, size + nsv->nsvs_file_offset[i], SEEK_SET);
+ avio_read(pb, b, 8);
+ av_dlog(s, "NSV [0x%08lx][0x%08lx]: %02x %02x %02x %02x %02x %02x %02x %02x"
"%c%c%c%c%c%c%c%c\n",
nsv->nsvs_file_offset[i], size + nsv->nsvs_file_offset[i],
b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],
- V(b[0]), V(b[1]), V(b[2]), V(b[3]), V(b[4]), V(b[5]), V(b[6]), V(b[7]) ));
+ V(b[0]), V(b[1]), V(b[2]), V(b[3]), V(b[4]), V(b[5]), V(b[6]), V(b[7]) );
}
- //url_fseek(pb, size, SEEK_SET); /* go back to end of header */
+ //avio_seek(pb, size, SEEK_SET); /* go back to end of header */
#undef V
#endif
- url_fseek(pb, nsv->base_offset + size, SEEK_SET); /* required for dumbdriving-271.nsv (2 extra bytes) */
+ avio_seek(pb, nsv->base_offset + size, SEEK_SET); /* required for dumbdriving-271.nsv (2 extra bytes) */
if (url_feof(pb))
return -1;
@@ -399,22 +387,22 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap)
{
NSVContext *nsv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint32_t vtag, atag;
uint16_t vwidth, vheight;
AVRational framerate;
int i;
AVStream *st;
NSVStream *nst;
- PRINT(("%s()\n", __FUNCTION__));
+ av_dlog(s, "%s()\n", __FUNCTION__);
- vtag = get_le32(pb);
- atag = get_le32(pb);
- vwidth = get_le16(pb);
- vheight = get_le16(pb);
- i = get_byte(pb);
+ vtag = avio_rl32(pb);
+ atag = avio_rl32(pb);
+ vwidth = avio_rl16(pb);
+ vheight = avio_rl16(pb);
+ i = avio_r8(pb);
- PRINT(("NSV NSVs framerate code %2x\n", i));
+ av_dlog(s, "NSV NSVs framerate code %2x\n", i);
if(i&0x80) { /* odd way of giving native framerates from docs */
int t=(i & 0x7F)>>2;
if(t<16) framerate = (AVRational){1, t+1};
@@ -432,13 +420,12 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap)
else
framerate= (AVRational){i, 1};
- nsv->avsync = get_le16(pb);
+ nsv->avsync = avio_rl16(pb);
nsv->framerate = framerate;
-#ifdef DEBUG
+
print_tag("NSV NSVs vtag", vtag, 0);
print_tag("NSV NSVs atag", atag, 0);
- PRINT(("NSV NSVs vsize %dx%d\n", vwidth, vheight));
-#endif
+ av_dlog(s, "NSV NSVs vsize %dx%d\n", vwidth, vheight);
/* XXX change to ap != NULL ? */
if (s->nb_streams == 0) { /* streams not yet published, let's do that */
@@ -502,7 +489,7 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap)
#ifdef CHECK_SUBSEQUENT_NSVS
} else {
if (nsv->vtag != vtag || nsv->atag != atag || nsv->vwidth != vwidth || nsv->vheight != vwidth) {
- PRINT(("NSV NSVs header values differ from the first one!!!\n"));
+ av_dlog(s, "NSV NSVs header values differ from the first one!!!\n");
//return -1;
}
#endif /* CHECK_SUBSEQUENT_NSVS */
@@ -521,8 +508,8 @@ static int nsv_read_header(AVFormatContext *s, AVFormatParameters *ap)
NSVContext *nsv = s->priv_data;
int i, err;
- PRINT(("%s()\n", __FUNCTION__));
- PRINT(("filename '%s'\n", s->filename));
+ av_dlog(s, "%s()\n", __FUNCTION__);
+ av_dlog(s, "filename '%s'\n", s->filename);
nsv->state = NSV_UNSYNC;
nsv->ahead[0].data = nsv->ahead[1].data = NULL;
@@ -543,14 +530,14 @@ static int nsv_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* now read the first chunk, so we can attempt to decode more info */
err = nsv_read_chunk(s, 1);
- PRINT(("parsed header\n"));
+ av_dlog(s, "parsed header\n");
return 0;
}
static int nsv_read_chunk(AVFormatContext *s, int fill_header)
{
NSVContext *nsv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st[2] = {NULL, NULL};
NSVStream *nst;
AVPacket *pkt;
@@ -561,7 +548,7 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header)
uint16_t auxsize;
uint32_t auxtag;
- PRINT(("%s(%d)\n", __FUNCTION__, fill_header));
+ av_dlog(s, "%s(%d)\n", __FUNCTION__, fill_header);
if (nsv->ahead[0].data || nsv->ahead[1].data)
return 0; //-1; /* hey! eat what you've in your plate first! */
@@ -581,23 +568,23 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header)
if (nsv->state != NSV_HAS_READ_NSVS && nsv->state != NSV_FOUND_BEEF)
return -1;
- auxcount = get_byte(pb);
- vsize = get_le16(pb);
- asize = get_le16(pb);
+ auxcount = avio_r8(pb);
+ vsize = avio_rl16(pb);
+ asize = avio_rl16(pb);
vsize = (vsize << 4) | (auxcount >> 4);
auxcount &= 0x0f;
- PRINT(("NSV CHUNK %d aux, %u bytes video, %d bytes audio\n", auxcount, vsize, asize));
+ av_dlog(s, "NSV CHUNK %d aux, %u bytes video, %d bytes audio\n", auxcount, vsize, asize);
/* skip aux stuff */
for (i = 0; i < auxcount; i++) {
- auxsize = get_le16(pb);
- auxtag = get_le32(pb);
- PRINT(("NSV aux data: '%c%c%c%c', %d bytes\n",
+ auxsize = avio_rl16(pb);
+ auxtag = avio_rl32(pb);
+ av_dlog(s, "NSV aux data: '%c%c%c%c', %d bytes\n",
(auxtag & 0x0ff),
((auxtag >> 8) & 0x0ff),
((auxtag >> 16) & 0x0ff),
((auxtag >> 24) & 0x0ff),
- auxsize));
- url_fskip(pb, auxsize);
+ auxsize);
+ avio_seek(pb, auxsize, SEEK_CUR);
vsize -= auxsize + sizeof(uint16_t) + sizeof(uint32_t); /* that's becoming braindead */
}
@@ -621,10 +608,8 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header)
pkt->stream_index = st[NSV_ST_VIDEO]->index;//NSV_ST_VIDEO;
pkt->dts = nst->frame_offset;
pkt->flags |= nsv->state == NSV_HAS_READ_NSVS ? AV_PKT_FLAG_KEY : 0; /* keyframe only likely on a sync frame */
-/*
- for (i = 0; i < MIN(8, vsize); i++)
- PRINT(("NSV video: [%d] = %02x\n", i, pkt->data[i]));
-*/
+ for (i = 0; i < FFMIN(8, vsize); i++)
+ av_dlog(s, "NSV video: [%d] = %02x\n", i, pkt->data[i]);
}
if(st[NSV_ST_VIDEO])
((NSVStream*)st[NSV_ST_VIDEO]->priv_data)->frame_offset++;
@@ -638,15 +623,15 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header)
uint8_t bps;
uint8_t channels;
uint16_t samplerate;
- bps = get_byte(pb);
- channels = get_byte(pb);
- samplerate = get_le16(pb);
+ bps = avio_r8(pb);
+ channels = avio_r8(pb);
+ samplerate = avio_rl16(pb);
asize-=4;
- PRINT(("NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate));
+ av_dlog(s, "NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate);
if (fill_header) {
st[NSV_ST_AUDIO]->need_parsing = AVSTREAM_PARSE_NONE; /* we know everything */
if (bps != 16) {
- PRINT(("NSV AUDIO bit/sample != 16 (%d)!!!\n", bps));
+ av_dlog(s, "NSV AUDIO bit/sample != 16 (%d)!!!\n", bps);
}
bps /= channels; // ???
if (bps == 8)
@@ -655,7 +640,7 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header)
channels = 1;
st[NSV_ST_AUDIO]->codec->channels = channels;
st[NSV_ST_AUDIO]->codec->sample_rate = samplerate;
- PRINT(("NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate));
+ av_dlog(s, "NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate);
}
}
av_get_packet(pb, pkt, asize);
@@ -666,7 +651,7 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header)
pkt->dts = (((NSVStream*)st[NSV_ST_VIDEO]->priv_data)->frame_offset-1);
pkt->dts *= (int64_t)1000 * nsv->framerate.den;
pkt->dts += (int64_t)nsv->avsync * nsv->framerate.num;
- PRINT(("NSV AUDIO: sync:%d, dts:%"PRId64, nsv->avsync, pkt->dts));
+ av_dlog(s, "NSV AUDIO: sync:%d, dts:%"PRId64, nsv->avsync, pkt->dts);
}
nst->frame_offset++;
}
@@ -681,7 +666,7 @@ static int nsv_read_packet(AVFormatContext *s, AVPacket *pkt)
NSVContext *nsv = s->priv_data;
int i, err = 0;
- PRINT(("%s()\n", __FUNCTION__));
+ av_dlog(s, "%s()\n", __FUNCTION__);
/* in case we don't already have something to eat ... */
if (nsv->ahead[0].data == NULL && nsv->ahead[1].data == NULL)
@@ -692,7 +677,7 @@ static int nsv_read_packet(AVFormatContext *s, AVPacket *pkt)
/* now pick one of the plates */
for (i = 0; i < 2; i++) {
if (nsv->ahead[i].data) {
- PRINT(("%s: using cached packet[%d]\n", __FUNCTION__, i));
+ av_dlog(s, "%s: using cached packet[%d]\n", __FUNCTION__, i);
/* avoid the cost of new_packet + memcpy(->data) */
memcpy(pkt, &nsv->ahead[i], sizeof(AVPacket));
nsv->ahead[i].data = NULL; /* we ate that one */
@@ -715,7 +700,7 @@ static int nsv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
if(index < 0)
return -1;
- url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET);
+ avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET);
nst->frame_offset = st->index_entries[index].timestamp;
nsv->state = NSV_UNSYNC;
return 0;
@@ -752,7 +737,7 @@ static int nsv_read_close(AVFormatContext *s)
static int nsv_probe(AVProbeData *p)
{
int i;
-// PRINT(("nsv_probe(), buf_size %d\n", p->buf_size));
+ av_dlog(NULL, "nsv_probe(), buf_size %d\n", p->buf_size);
/* check file header */
/* streamed files might not have any header */
if (p->buf[0] == 'N' && p->buf[1] == 'S' &&
diff --git a/mplayer/ffmpeg/libavformat/nutdec.c b/mplayer/ffmpeg/libavformat/nutdec.c
index 6ca6be83..57e77586 100644
--- a/mplayer/ffmpeg/libavformat/nutdec.c
+++ b/mplayer/ffmpeg/libavformat/nutdec.c
@@ -37,13 +37,13 @@
#define NUT_MAX_STREAMS 256 /* arbitrary sanity check value */
#endif
-static int get_str(ByteIOContext *bc, char *string, unsigned int maxlen){
+static int get_str(AVIOContext *bc, char *string, unsigned int maxlen){
unsigned int len= ff_get_v(bc);
if(len && maxlen)
- get_buffer(bc, string, FFMIN(len, maxlen));
+ avio_read(bc, string, FFMIN(len, maxlen));
while(len > maxlen){
- get_byte(bc);
+ avio_r8(bc);
len--;
}
@@ -56,37 +56,37 @@ static int get_str(ByteIOContext *bc, char *string, unsigned int maxlen){
return 0;
}
-static int64_t get_s(ByteIOContext *bc){
+static int64_t get_s(AVIOContext *bc){
int64_t v = ff_get_v(bc) + 1;
if (v&1) return -(v>>1);
else return (v>>1);
}
-static uint64_t get_fourcc(ByteIOContext *bc){
+static uint64_t get_fourcc(AVIOContext *bc){
unsigned int len= ff_get_v(bc);
- if (len==2) return get_le16(bc);
- else if(len==4) return get_le32(bc);
+ if (len==2) return avio_rl16(bc);
+ else if(len==4) return avio_rl32(bc);
else return -1;
}
#ifdef TRACE
-static inline uint64_t get_v_trace(ByteIOContext *bc, char *file, char *func, int line){
+static inline uint64_t get_v_trace(AVIOContext *bc, char *file, char *func, int line){
uint64_t v= ff_get_v(bc);
av_log(NULL, AV_LOG_DEBUG, "get_v %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
return v;
}
-static inline int64_t get_s_trace(ByteIOContext *bc, char *file, char *func, int line){
+static inline int64_t get_s_trace(AVIOContext *bc, char *file, char *func, int line){
int64_t v= get_s(bc);
av_log(NULL, AV_LOG_DEBUG, "get_s %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
return v;
}
-static inline uint64_t get_vb_trace(ByteIOContext *bc, char *file, char *func, int line){
+static inline uint64_t get_vb_trace(AVIOContext *bc, char *file, char *func, int line){
uint64_t v= get_vb(bc);
av_log(NULL, AV_LOG_DEBUG, "get_vb %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
@@ -97,7 +97,7 @@ static inline uint64_t get_vb_trace(ByteIOContext *bc, char *file, char *func, i
#define get_vb(bc) get_vb_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__)
#endif
-static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_checksum, uint64_t startcode)
+static int get_packetheader(NUTContext *nut, AVIOContext *bc, int calculate_checksum, uint64_t startcode)
{
int64_t size;
// start= url_ftell(bc) - 8;
@@ -108,7 +108,7 @@ static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_ch
init_checksum(bc, ff_crc04C11DB7_update, startcode);
size= ff_get_v(bc);
if(size > 4096)
- get_be32(bc);
+ avio_rb32(bc);
if(get_checksum(bc) && size > 4096)
return -1;
@@ -117,14 +117,14 @@ static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_ch
return size;
}
-static uint64_t find_any_startcode(ByteIOContext *bc, int64_t pos){
+static uint64_t find_any_startcode(AVIOContext *bc, int64_t pos){
uint64_t state=0;
if(pos >= 0)
- url_fseek(bc, pos, SEEK_SET); //note, this may fail if the stream is not seekable, but that should not matter, as in this case we simply start where we currently are
+ avio_seek(bc, pos, SEEK_SET); //note, this may fail if the stream is not seekable, but that should not matter, as in this case we simply start where we currently are
while(!url_feof(bc)){
- state= (state<<8) | get_byte(bc);
+ state= (state<<8) | avio_r8(bc);
if((state>>56) != 'N')
continue;
switch(state){
@@ -146,7 +146,7 @@ static uint64_t find_any_startcode(ByteIOContext *bc, int64_t pos){
* @param pos the start position of the search, or -1 if the current position
* @return the position of the startcode or -1 if not found
*/
-static int64_t find_startcode(ByteIOContext *bc, uint64_t code, int64_t pos){
+static int64_t find_startcode(AVIOContext *bc, uint64_t code, int64_t pos){
for(;;){
uint64_t startcode= find_any_startcode(bc, pos);
if(startcode == code)
@@ -177,21 +177,21 @@ static int nut_probe(AVProbeData *p){
}\
dst= tmp;
-static int skip_reserved(ByteIOContext *bc, int64_t pos){
+static int skip_reserved(AVIOContext *bc, int64_t pos){
pos -= url_ftell(bc);
if(pos<0){
- url_fseek(bc, pos, SEEK_CUR);
+ avio_seek(bc, pos, SEEK_CUR);
return -1;
}else{
while(pos--)
- get_byte(bc);
+ avio_r8(bc);
return 0;
}
}
static int decode_main_header(NUTContext *nut){
AVFormatContext *s= nut->avf;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
uint64_t tmp, end;
unsigned int stream_count;
int i, j, tmp_stream, tmp_mul, tmp_pts, tmp_size, count, tmp_res, tmp_head_idx;
@@ -281,7 +281,7 @@ static int decode_main_header(NUTContext *nut){
return AVERROR_INVALIDDATA;
}
nut->header[i]= av_malloc(nut->header_len[i]);
- get_buffer(bc, nut->header[i], nut->header_len[i]);
+ avio_read(bc, nut->header[i], nut->header_len[i]);
}
assert(nut->header_len[0]==0);
}
@@ -301,7 +301,7 @@ static int decode_main_header(NUTContext *nut){
static int decode_stream_header(NUTContext *nut){
AVFormatContext *s= nut->avf;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
StreamContext *stc;
int class, stream_id;
uint64_t tmp, end;
@@ -357,7 +357,7 @@ static int decode_stream_header(NUTContext *nut){
GET_V(st->codec->extradata_size, tmp < (1<<30));
if(st->codec->extradata_size){
st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(bc, st->codec->extradata, st->codec->extradata_size);
+ avio_read(bc, st->codec->extradata, st->codec->extradata_size);
}
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
@@ -399,7 +399,7 @@ static void set_disposition_bits(AVFormatContext* avf, char* value, int stream_i
static int decode_info_header(NUTContext *nut){
AVFormatContext *s= nut->avf;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
uint64_t tmp, chapter_start, chapter_len;
unsigned int stream_id_plus1, count;
int chapter_id, i;
@@ -479,7 +479,7 @@ static int decode_info_header(NUTContext *nut){
static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
AVFormatContext *s= nut->avf;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
int64_t end, tmp;
nut->last_syncpoint_pos= url_ftell(bc)-8;
@@ -507,7 +507,7 @@ static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
static int find_and_decode_index(NUTContext *nut){
AVFormatContext *s= nut->avf;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
uint64_t tmp, end;
int i, j, syncpoint_count;
int64_t filesize= url_fsize(bc);
@@ -515,9 +515,9 @@ static int find_and_decode_index(NUTContext *nut){
int8_t *has_keyframe;
int ret= -1;
- url_fseek(bc, filesize-12, SEEK_SET);
- url_fseek(bc, filesize-get_be64(bc), SEEK_SET);
- if(get_be64(bc) != INDEX_STARTCODE){
+ avio_seek(bc, filesize-12, SEEK_SET);
+ avio_seek(bc, filesize-avio_rb64(bc), SEEK_SET);
+ if(avio_rb64(bc) != INDEX_STARTCODE){
av_log(s, AV_LOG_ERROR, "no index at the end\n");
return -1;
}
@@ -605,7 +605,7 @@ static int find_and_decode_index(NUTContext *nut){
static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
NUTContext *nut = s->priv_data;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
int64_t pos;
int initialized_stream_count;
@@ -657,7 +657,7 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
if(!url_is_streamed(bc)){
int64_t orig_pos= url_ftell(bc);
find_and_decode_index(nut);
- url_fseek(bc, orig_pos, SEEK_SET);
+ avio_seek(bc, orig_pos, SEEK_SET);
}
assert(nut->next_startcode == SYNCPOINT_STARTCODE);
@@ -668,7 +668,7 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, uint8_t *header_idx, int frame_code){
AVFormatContext *s= nut->avf;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
StreamContext *stc;
int size, flags, size_mul, pts_delta, i, reserved_count;
uint64_t tmp;
@@ -724,7 +724,7 @@ static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, ui
size -= nut->header_len[*header_idx];
if(flags&FLAG_CHECKSUM){
- get_be32(bc); //FIXME check this
+ avio_rb32(bc); //FIXME check this
}else if(size > 2*nut->max_distance || FFABS(stc->last_pts - *pts) > stc->max_pts_distance){
av_log(s, AV_LOG_ERROR, "frame size > 2max_distance and no checksum\n");
return AVERROR_INVALIDDATA;
@@ -738,7 +738,7 @@ static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, ui
static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
AVFormatContext *s= nut->avf;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
int size, stream_id, discard;
int64_t pts, last_IP_pts;
StreamContext *stc;
@@ -759,14 +759,14 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)
|| discard >= AVDISCARD_ALL
|| stc->skip_until_key_frame){
- url_fskip(bc, size);
+ avio_seek(bc, size, SEEK_CUR);
return 1;
}
av_new_packet(pkt, size + nut->header_len[header_idx]);
memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
pkt->pos= url_ftell(bc); //FIXME
- get_buffer(bc, pkt->data + nut->header_len[header_idx], size);
+ avio_read(bc, pkt->data + nut->header_len[header_idx], size);
pkt->stream_index = stream_id;
if (stc->last_flags & FLAG_KEY)
@@ -779,7 +779,7 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
{
NUTContext *nut = s->priv_data;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
int i, frame_code=0, ret, skip;
int64_t ts, back_ptr;
@@ -791,13 +791,13 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
if(tmp){
pos-=8;
}else{
- frame_code = get_byte(bc);
+ frame_code = avio_r8(bc);
if(url_feof(bc))
return -1;
if(frame_code == 'N'){
tmp= frame_code;
for(i=1; i<8; i++)
- tmp = (tmp<<8) + get_byte(bc);
+ tmp = (tmp<<8) + avio_r8(bc);
}
}
switch(tmp){
@@ -805,7 +805,7 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
case STREAM_STARTCODE:
case INDEX_STARTCODE:
skip= get_packetheader(nut, bc, 0, tmp);
- url_fseek(bc, skip, SEEK_CUR);
+ avio_seek(bc, skip, SEEK_CUR);
break;
case INFO_STARTCODE:
if(decode_info_header(nut)<0)
@@ -814,7 +814,7 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
case SYNCPOINT_STARTCODE:
if(decode_syncpoint(nut, &ts, &back_ptr)<0)
goto resync;
- frame_code = get_byte(bc);
+ frame_code = avio_r8(bc);
case 0:
ret= decode_frame(nut, pkt, frame_code);
if(ret==0)
@@ -835,7 +835,7 @@ av_log(s, AV_LOG_DEBUG, "sync\n");
static int64_t nut_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos_arg, int64_t pos_limit){
NUTContext *nut = s->priv_data;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
int64_t pos, pts, back_ptr;
av_log(s, AV_LOG_DEBUG, "read_timestamp(X,%d,%"PRId64",%"PRId64")\n", stream_index, *pos_arg, pos_limit);
@@ -902,7 +902,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flag
}
av_log(NULL, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos2);
pos= find_startcode(s->pb, SYNCPOINT_STARTCODE, pos2);
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
av_log(NULL, AV_LOG_DEBUG, "SP: %"PRId64"\n", pos);
if(pos2 > pos || pos2 + 15 < pos){
av_log(NULL, AV_LOG_ERROR, "no syncpoint at backptr pos\n");
diff --git a/mplayer/ffmpeg/libavformat/nutenc.c b/mplayer/ffmpeg/libavformat/nutenc.c
index 288e4bd4..078ffac0 100644
--- a/mplayer/ffmpeg/libavformat/nutenc.c
+++ b/mplayer/ffmpeg/libavformat/nutenc.c
@@ -241,7 +241,7 @@ static void build_frame_code(AVFormatContext *s){
nut->frame_code['N'].flags= FLAG_INVALID;
}
-static void put_tt(NUTContext *nut, StreamContext *nus, ByteIOContext *bc, uint64_t val){
+static void put_tt(NUTContext *nut, StreamContext *nus, AVIOContext *bc, uint64_t val){
val *= nut->time_base_count;
val += nus->time_base - nut->time_base;
ff_put_v(bc, val);
@@ -250,25 +250,25 @@ static void put_tt(NUTContext *nut, StreamContext *nus, ByteIOContext *bc, uint6
/**
* Store a string as vb.
*/
-static void put_str(ByteIOContext *bc, const char *string){
+static void put_str(AVIOContext *bc, const char *string){
int len= strlen(string);
ff_put_v(bc, len);
- put_buffer(bc, string, len);
+ avio_write(bc, string, len);
}
-static void put_s(ByteIOContext *bc, int64_t val){
+static void put_s(AVIOContext *bc, int64_t val){
ff_put_v(bc, 2*FFABS(val) - (val>0));
}
#ifdef TRACE
-static inline void ff_put_v_trace(ByteIOContext *bc, uint64_t v, char *file, char *func, int line){
+static inline void ff_put_v_trace(AVIOContext *bc, uint64_t v, char *file, char *func, int line){
av_log(NULL, AV_LOG_DEBUG, "ff_put_v %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
ff_put_v(bc, v);
}
-static inline void put_s_trace(ByteIOContext *bc, int64_t v, char *file, char *func, int line){
+static inline void put_s_trace(AVIOContext *bc, int64_t v, char *file, char *func, int line){
av_log(NULL, AV_LOG_DEBUG, "put_s %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
put_s(bc, v);
@@ -278,28 +278,28 @@ static inline void put_s_trace(ByteIOContext *bc, int64_t v, char *file, char *f
#endif
//FIXME remove calculate_checksum
-static void put_packet(NUTContext *nut, ByteIOContext *bc, ByteIOContext *dyn_bc, int calculate_checksum, uint64_t startcode){
+static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, int calculate_checksum, uint64_t startcode){
uint8_t *dyn_buf=NULL;
int dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf);
int forw_ptr= dyn_size + 4*calculate_checksum;
if(forw_ptr > 4096)
init_checksum(bc, ff_crc04C11DB7_update, 0);
- put_be64(bc, startcode);
+ avio_wb64(bc, startcode);
ff_put_v(bc, forw_ptr);
if(forw_ptr > 4096)
- put_le32(bc, get_checksum(bc));
+ avio_wl32(bc, get_checksum(bc));
if(calculate_checksum)
init_checksum(bc, ff_crc04C11DB7_update, 0);
- put_buffer(bc, dyn_buf, dyn_size);
+ avio_write(bc, dyn_buf, dyn_size);
if(calculate_checksum)
- put_le32(bc, get_checksum(bc));
+ avio_wl32(bc, get_checksum(bc));
av_free(dyn_buf);
}
-static void write_mainheader(NUTContext *nut, ByteIOContext *bc){
+static void write_mainheader(NUTContext *nut, AVIOContext *bc){
int i, j, tmp_pts, tmp_flags, tmp_stream, tmp_mul, tmp_size, tmp_fields, tmp_head_idx;
int64_t tmp_match;
@@ -366,11 +366,11 @@ static void write_mainheader(NUTContext *nut, ByteIOContext *bc){
ff_put_v(bc, nut->header_count-1);
for(i=1; iheader_count; i++){
ff_put_v(bc, nut->header_len[i]);
- put_buffer(bc, nut->header[i], nut->header_len[i]);
+ avio_write(bc, nut->header[i], nut->header_len[i]);
}
}
-static int write_streamheader(AVFormatContext *avctx, ByteIOContext *bc, AVStream *st, int i){
+static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc, AVStream *st, int i){
NUTContext *nut = avctx->priv_data;
AVCodecContext *codec = st->codec;
ff_put_v(bc, i);
@@ -382,7 +382,7 @@ static int write_streamheader(AVFormatContext *avctx, ByteIOContext *bc, AVStrea
}
ff_put_v(bc, 4);
if (codec->codec_tag){
- put_le32(bc, codec->codec_tag);
+ avio_wl32(bc, codec->codec_tag);
} else {
av_log(avctx, AV_LOG_ERROR, "No codec tag defined for stream %d\n", i);
return AVERROR(EINVAL);
@@ -392,10 +392,10 @@ static int write_streamheader(AVFormatContext *avctx, ByteIOContext *bc, AVStrea
ff_put_v(bc, nut->stream[i].msb_pts_shift);
ff_put_v(bc, nut->stream[i].max_pts_distance);
ff_put_v(bc, codec->has_b_frames);
- put_byte(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
+ avio_w8(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
ff_put_v(bc, codec->extradata_size);
- put_buffer(bc, codec->extradata, codec->extradata_size);
+ avio_write(bc, codec->extradata, codec->extradata_size);
switch(codec->codec_type){
case AVMEDIA_TYPE_AUDIO:
@@ -422,17 +422,17 @@ static int write_streamheader(AVFormatContext *avctx, ByteIOContext *bc, AVStrea
return 0;
}
-static int add_info(ByteIOContext *bc, const char *type, const char *value){
+static int add_info(AVIOContext *bc, const char *type, const char *value){
put_str(bc, type);
put_s(bc, -1);
put_str(bc, value);
return 1;
}
-static int write_globalinfo(NUTContext *nut, ByteIOContext *bc){
+static int write_globalinfo(NUTContext *nut, AVIOContext *bc){
AVFormatContext *s= nut->avf;
AVMetadataTag *t = NULL;
- ByteIOContext *dyn_bc;
+ AVIOContext *dyn_bc;
uint8_t *dyn_buf=NULL;
int count=0, dyn_size;
int ret = url_open_dyn_buf(&dyn_bc);
@@ -450,15 +450,15 @@ static int write_globalinfo(NUTContext *nut, ByteIOContext *bc){
ff_put_v(bc, count);
dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf);
- put_buffer(bc, dyn_buf, dyn_size);
+ avio_write(bc, dyn_buf, dyn_size);
av_free(dyn_buf);
return 0;
}
-static int write_streaminfo(NUTContext *nut, ByteIOContext *bc, int stream_id){
+static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id){
AVFormatContext *s= nut->avf;
AVStream* st = s->streams[stream_id];
- ByteIOContext *dyn_bc;
+ AVIOContext *dyn_bc;
uint8_t *dyn_buf=NULL;
int count=0, dyn_size, i;
int ret = url_open_dyn_buf(&dyn_bc);
@@ -479,16 +479,16 @@ static int write_streaminfo(NUTContext *nut, ByteIOContext *bc, int stream_id){
ff_put_v(bc, count);
- put_buffer(bc, dyn_buf, dyn_size);
+ avio_write(bc, dyn_buf, dyn_size);
}
av_free(dyn_buf);
return count;
}
-static int write_headers(AVFormatContext *avctx, ByteIOContext *bc){
+static int write_headers(AVFormatContext *avctx, AVIOContext *bc){
NUTContext *nut = avctx->priv_data;
- ByteIOContext *dyn_bc;
+ AVIOContext *dyn_bc;
int i, ret;
ff_metadata_conv_ctx(avctx, ff_nut_metadata_conv, NULL);
@@ -537,7 +537,7 @@ static int write_headers(AVFormatContext *avctx, ByteIOContext *bc){
static int write_header(AVFormatContext *s){
NUTContext *nut = s->priv_data;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
int i, j, ret;
nut->avf= s;
@@ -575,8 +575,8 @@ static int write_header(AVFormatContext *s){
build_frame_code(s);
assert(nut->frame_code['N'].flags == FLAG_INVALID);
- put_buffer(bc, ID_STRING, strlen(ID_STRING));
- put_byte(bc, 0);
+ avio_write(bc, ID_STRING, strlen(ID_STRING));
+ avio_w8(bc, 0);
if ((ret = write_headers(s, bc)) < 0)
return ret;
@@ -628,7 +628,7 @@ static int find_best_header_idx(NUTContext *nut, AVPacket *pkt){
static int write_packet(AVFormatContext *s, AVPacket *pkt){
NUTContext *nut = s->priv_data;
StreamContext *nus= &nut->stream[pkt->stream_index];
- ByteIOContext *bc = s->pb, *dyn_bc;
+ AVIOContext *bc = s->pb, *dyn_bc;
FrameCode *fc;
int64_t coded_pts;
int best_length, frame_code, flags, needed_flags, i, header_idx, best_header_idx;
@@ -749,7 +749,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){
header_idx= fc->header_idx;
init_checksum(bc, ff_crc04C11DB7_update, 0);
- put_byte(bc, frame_code);
+ avio_w8(bc, frame_code);
if(flags & FLAG_CODED){
ff_put_v(bc, (flags^needed_flags) & ~(FLAG_CODED));
flags = needed_flags;
@@ -759,10 +759,10 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){
if(flags & FLAG_SIZE_MSB) ff_put_v(bc, pkt->size / fc->size_mul);
if(flags & FLAG_HEADER_IDX) ff_put_v(bc, header_idx= best_header_idx);
- if(flags & FLAG_CHECKSUM) put_le32(bc, get_checksum(bc));
+ if(flags & FLAG_CHECKSUM) avio_wl32(bc, get_checksum(bc));
else get_checksum(bc);
- put_buffer(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
+ avio_write(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
nus->last_flags= flags;
nus->last_pts= pkt->pts;
@@ -781,7 +781,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){
static int write_trailer(AVFormatContext *s){
NUTContext *nut= s->priv_data;
- ByteIOContext *bc= s->pb;
+ AVIOContext *bc= s->pb;
while(nut->header_count<3)
write_headers(s, bc);
diff --git a/mplayer/ffmpeg/libavformat/nuv.c b/mplayer/ffmpeg/libavformat/nuv.c
index 58a00dfa..6c7c563b 100644
--- a/mplayer/ffmpeg/libavformat/nuv.c
+++ b/mplayer/ffmpeg/libavformat/nuv.c
@@ -55,100 +55,100 @@ static int nuv_probe(AVProbeData *p) {
* \param myth set if this is a MythTVVideo format file
* \return 1 if all required codec data was found
*/
-static int get_codec_data(ByteIOContext *pb, AVStream *vst,
+static int get_codec_data(AVIOContext *pb, AVStream *vst,
AVStream *ast, int myth) {
nuv_frametype frametype;
if (!vst && !myth)
return 1; // no codec data needed
while (!url_feof(pb)) {
int size, subtype;
- frametype = get_byte(pb);
+ frametype = avio_r8(pb);
switch (frametype) {
case NUV_EXTRADATA:
- subtype = get_byte(pb);
- url_fskip(pb, 6);
- size = PKTSIZE(get_le32(pb));
+ subtype = avio_r8(pb);
+ avio_seek(pb, 6, SEEK_CUR);
+ size = PKTSIZE(avio_rl32(pb));
if (vst && subtype == 'R') {
vst->codec->extradata_size = size;
vst->codec->extradata = av_malloc(size);
- get_buffer(pb, vst->codec->extradata, size);
+ avio_read(pb, vst->codec->extradata, size);
size = 0;
if (!myth)
return 1;
}
break;
case NUV_MYTHEXT:
- url_fskip(pb, 7);
- size = PKTSIZE(get_le32(pb));
+ avio_seek(pb, 7, SEEK_CUR);
+ size = PKTSIZE(avio_rl32(pb));
if (size != 128 * 4)
break;
- get_le32(pb); // version
+ avio_rl32(pb); // version
if (vst) {
- vst->codec->codec_tag = get_le32(pb);
+ vst->codec->codec_tag = avio_rl32(pb);
vst->codec->codec_id =
ff_codec_get_id(ff_codec_bmp_tags, vst->codec->codec_tag);
if (vst->codec->codec_tag == MKTAG('R', 'J', 'P', 'G'))
vst->codec->codec_id = CODEC_ID_NUV;
} else
- url_fskip(pb, 4);
+ avio_seek(pb, 4, SEEK_CUR);
if (ast) {
- ast->codec->codec_tag = get_le32(pb);
- ast->codec->sample_rate = get_le32(pb);
- ast->codec->bits_per_coded_sample = get_le32(pb);
- ast->codec->channels = get_le32(pb);
+ ast->codec->codec_tag = avio_rl32(pb);
+ ast->codec->sample_rate = avio_rl32(pb);
+ ast->codec->bits_per_coded_sample = avio_rl32(pb);
+ ast->codec->channels = avio_rl32(pb);
ast->codec->codec_id =
ff_wav_codec_get_id(ast->codec->codec_tag,
ast->codec->bits_per_coded_sample);
ast->need_parsing = AVSTREAM_PARSE_FULL;
} else
- url_fskip(pb, 4 * 4);
+ avio_seek(pb, 4 * 4, SEEK_CUR);
size -= 6 * 4;
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
return 1;
case NUV_SEEKP:
size = 11;
break;
default:
- url_fskip(pb, 7);
- size = PKTSIZE(get_le32(pb));
+ avio_seek(pb, 7, SEEK_CUR);
+ size = PKTSIZE(avio_rl32(pb));
break;
}
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
}
return 0;
}
static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) {
NUVContext *ctx = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
char id_string[12];
double aspect, fps;
int is_mythtv, width, height, v_packs, a_packs;
int stream_nr = 0;
AVStream *vst = NULL, *ast = NULL;
- get_buffer(pb, id_string, 12);
+ avio_read(pb, id_string, 12);
is_mythtv = !memcmp(id_string, "MythTVVideo", 12);
- url_fskip(pb, 5); // version string
- url_fskip(pb, 3); // padding
- width = get_le32(pb);
- height = get_le32(pb);
- get_le32(pb); // unused, "desiredwidth"
- get_le32(pb); // unused, "desiredheight"
- get_byte(pb); // 'P' == progressive, 'I' == interlaced
- url_fskip(pb, 3); // padding
- aspect = av_int2dbl(get_le64(pb));
+ avio_seek(pb, 5, SEEK_CUR); // version string
+ avio_seek(pb, 3, SEEK_CUR); // padding
+ width = avio_rl32(pb);
+ height = avio_rl32(pb);
+ avio_rl32(pb); // unused, "desiredwidth"
+ avio_rl32(pb); // unused, "desiredheight"
+ avio_r8(pb); // 'P' == progressive, 'I' == interlaced
+ avio_seek(pb, 3, SEEK_CUR); // padding
+ aspect = av_int2dbl(avio_rl64(pb));
if (aspect > 0.9999 && aspect < 1.0001)
aspect = 4.0 / 3.0;
- fps = av_int2dbl(get_le64(pb));
+ fps = av_int2dbl(avio_rl64(pb));
// number of packets per stream type, -1 means unknown, e.g. streaming
- v_packs = get_le32(pb);
- a_packs = get_le32(pb);
- get_le32(pb); // text
+ v_packs = avio_rl32(pb);
+ a_packs = avio_rl32(pb);
+ avio_rl32(pb); // text
- get_le32(pb); // keyframe distance (?)
+ avio_rl32(pb); // keyframe distance (?)
if (v_packs) {
ctx->v_id = stream_nr++;
@@ -191,14 +191,14 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) {
static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
NUVContext *ctx = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
uint8_t hdr[HDRSIZE];
nuv_frametype frametype;
int ret, size;
while (!url_feof(pb)) {
int copyhdrsize = ctx->rtjpg_video ? HDRSIZE : 0;
uint64_t pos = url_ftell(pb);
- ret = get_buffer(pb, hdr, HDRSIZE);
+ ret = avio_read(pb, hdr, HDRSIZE);
if (ret < HDRSIZE)
return ret < 0 ? ret : AVERROR(EIO);
frametype = hdr[0];
@@ -206,13 +206,13 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
switch (frametype) {
case NUV_EXTRADATA:
if (!ctx->rtjpg_video) {
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
break;
}
case NUV_VIDEO:
if (ctx->v_id < 0) {
av_log(s, AV_LOG_ERROR, "Video packet in file without video stream!\n");
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
break;
}
ret = av_new_packet(pkt, copyhdrsize + size);
@@ -225,7 +225,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
pkt->pts = AV_RL32(&hdr[4]);
pkt->stream_index = ctx->v_id;
memcpy(pkt->data, hdr, copyhdrsize);
- ret = get_buffer(pb, pkt->data + copyhdrsize, size);
+ ret = avio_read(pb, pkt->data + copyhdrsize, size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
@@ -236,7 +236,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
case NUV_AUDIO:
if (ctx->a_id < 0) {
av_log(s, AV_LOG_ERROR, "Audio packet in file without audio stream!\n");
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
break;
}
ret = av_get_packet(pb, pkt, size);
@@ -250,7 +250,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
// contains no data, size value is invalid
break;
default:
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
break;
}
}
diff --git a/mplayer/ffmpeg/libavformat/oggdec.c b/mplayer/ffmpeg/libavformat/oggdec.c
index 1b4553c7..af9860bf 100644
--- a/mplayer/ffmpeg/libavformat/oggdec.c
+++ b/mplayer/ffmpeg/libavformat/oggdec.c
@@ -84,7 +84,7 @@ static int
ogg_restore (AVFormatContext * s, int discard)
{
struct ogg *ogg = s->priv_data;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
struct ogg_state *ost = ogg->state;
int i;
@@ -97,7 +97,7 @@ ogg_restore (AVFormatContext * s, int discard)
for (i = 0; i < ogg->nstreams; i++)
av_free (ogg->streams[i].buf);
- url_fseek (bc, ost->pos, SEEK_SET);
+ avio_seek (bc, ost->pos, SEEK_SET);
ogg->curidx = ost->curidx;
ogg->nstreams = ost->nstreams;
memcpy(ogg->streams, ost->streams,
@@ -194,7 +194,7 @@ ogg_new_buf(struct ogg *ogg, int idx)
static int
ogg_read_page (AVFormatContext * s, int *str)
{
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
struct ogg *ogg = s->priv_data;
struct ogg_stream *os;
int i = 0;
@@ -207,7 +207,7 @@ ogg_read_page (AVFormatContext * s, int *str)
uint8_t sync[4];
int sp = 0;
- if (get_buffer (bc, sync, 4) < 4)
+ if (avio_read (bc, sync, 4) < 4)
return -1;
do{
@@ -233,10 +233,10 @@ ogg_read_page (AVFormatContext * s, int *str)
return -1;
flags = url_fgetc (bc);
- gp = get_le64 (bc);
- serial = get_le32 (bc);
- seq = get_le32 (bc);
- crc = get_le32 (bc);
+ gp = avio_rl64 (bc);
+ serial = avio_rl32 (bc);
+ seq = avio_rl32 (bc);
+ crc = avio_rl32 (bc);
nsegs = url_fgetc (bc);
idx = ogg_find_stream (ogg, serial);
@@ -252,7 +252,7 @@ ogg_read_page (AVFormatContext * s, int *str)
if(os->psize > 0)
ogg_new_buf(ogg, idx);
- if (get_buffer (bc, os->segments, nsegs) < nsegs)
+ if (avio_read (bc, os->segments, nsegs) < nsegs)
return -1;
os->nsegs = nsegs;
@@ -284,7 +284,7 @@ ogg_read_page (AVFormatContext * s, int *str)
os->buf = nb;
}
- if (get_buffer (bc, os->buf + os->bufpos, size) < size)
+ if (avio_read (bc, os->buf + os->bufpos, size) < size)
return -1;
os->bufpos += size;
@@ -374,20 +374,20 @@ ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize, int64_t *fpo
os->segp = segp;
os->psize = psize;
- // We have reached the first non-header packet. All header
- // packets must be complete before the first non-header
- // one, so everything that follows must be non-header.
+ // We have reached the first non-header packet in this stream.
+ // Unfortunately more header packets may still follow for others,
+ // so we reset this later unless we are done with the headers
+ // for all streams.
ogg->headers = 1;
// Update the header state for all streams and
// compute the data_offset.
- s->data_offset = os->sync_pos;
+ if (!s->data_offset)
+ s->data_offset = os->sync_pos;
for (i = 0; i < ogg->nstreams; i++) {
struct ogg_stream *cur_os = ogg->streams + i;
- // Set stream header state to 0 if its last packet
- // was a header.
if (cur_os->header > 0)
- cur_os->header = 0;
+ ogg->headers = 0;
// if we have a partial non-header packet, its start is
// obviously at or after the data start
@@ -468,7 +468,7 @@ ogg_get_length (AVFormatContext * s)
end = size > MAX_PAGE_SIZE? size - MAX_PAGE_SIZE: 0;
ogg_save (s);
- url_fseek (s->pb, end, SEEK_SET);
+ avio_seek (s->pb, end, SEEK_SET);
while (!ogg_read_page (s, &i)){
if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
@@ -601,10 +601,10 @@ ogg_read_timestamp (AVFormatContext * s, int stream_index, int64_t * pos_arg,
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + stream_index;
- ByteIOContext *bc = s->pb;
+ AVIOContext *bc = s->pb;
int64_t pts = AV_NOPTS_VALUE;
int i;
- url_fseek(bc, *pos_arg, SEEK_SET);
+ avio_seek(bc, *pos_arg, SEEK_SET);
ogg_reset(ogg);
while (url_ftell(bc) < pos_limit && !ogg_packet(s, &i, NULL, NULL, pos_arg)) {
diff --git a/mplayer/ffmpeg/libavformat/oggenc.c b/mplayer/ffmpeg/libavformat/oggenc.c
index 4c2a9d6a..92591dde 100644
--- a/mplayer/ffmpeg/libavformat/oggenc.c
+++ b/mplayer/ffmpeg/libavformat/oggenc.c
@@ -25,6 +25,7 @@
#include "libavcodec/bytestream.h"
#include "libavcodec/flac.h"
#include "avformat.h"
+#include "avio_internal.h"
#include "internal.h"
#include "vorbiscomment.h"
@@ -64,19 +65,19 @@ typedef struct {
OGGPageList *page_list;
} OGGContext;
-static void ogg_update_checksum(AVFormatContext *s, ByteIOContext *pb, int64_t crc_offset)
+static void ogg_update_checksum(AVFormatContext *s, AVIOContext *pb, int64_t crc_offset)
{
int64_t pos = url_ftell(pb);
uint32_t checksum = get_checksum(pb);
- url_fseek(pb, crc_offset, SEEK_SET);
- put_be32(pb, checksum);
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, crc_offset, SEEK_SET);
+ avio_wb32(pb, checksum);
+ avio_seek(pb, pos, SEEK_SET);
}
static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
{
OGGStreamContext *oggstream = s->streams[page->stream_index]->priv_data;
- ByteIOContext *pb;
+ AVIOContext *pb;
int64_t crc_offset;
int ret, size;
uint8_t *buf;
@@ -85,17 +86,17 @@ static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
if (ret < 0)
return ret;
init_checksum(pb, ff_crc04C11DB7_update, 0);
- put_tag(pb, "OggS");
- put_byte(pb, 0);
- put_byte(pb, page->flags | extra_flags);
- put_le64(pb, page->granule);
- put_le32(pb, oggstream->serial_num);
- put_le32(pb, oggstream->page_counter++);
+ ffio_wfourcc(pb, "OggS");
+ avio_w8(pb, 0);
+ avio_w8(pb, page->flags | extra_flags);
+ avio_wl64(pb, page->granule);
+ avio_wl32(pb, oggstream->serial_num);
+ avio_wl32(pb, oggstream->page_counter++);
crc_offset = url_ftell(pb);
- put_le32(pb, 0); // crc
- put_byte(pb, page->segments_count);
- put_buffer(pb, page->segments, page->segments_count);
- put_buffer(pb, page->data, page->size);
+ avio_wl32(pb, 0); // crc
+ avio_w8(pb, page->segments_count);
+ avio_write(pb, page->segments, page->segments_count);
+ avio_write(pb, page->data, page->size);
ogg_update_checksum(s, pb, crc_offset);
put_flush_packet(pb);
@@ -104,7 +105,7 @@ static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
if (size < 0)
return size;
- put_buffer(s->pb, buf, size);
+ avio_write(s->pb, buf, size);
put_flush_packet(s->pb);
av_free(buf);
oggstream->page_count--;
diff --git a/mplayer/ffmpeg/libavformat/oggparsedirac.c b/mplayer/ffmpeg/libavformat/oggparsedirac.c
index a7f0401f..b8ce4fe2 100644
--- a/mplayer/ffmpeg/libavformat/oggparsedirac.c
+++ b/mplayer/ffmpeg/libavformat/oggparsedirac.c
@@ -42,7 +42,7 @@ static int dirac_header(AVFormatContext *s, int idx)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_DIRAC;
// dirac in ogg always stores timestamps as though the video were interlaced
- st->time_base = (AVRational){st->codec->time_base.num, 2*st->codec->time_base.den};
+ av_set_pts_info(st, 64, st->codec->time_base.num, 2*st->codec->time_base.den);
return 1;
}
@@ -79,8 +79,7 @@ static int old_dirac_header(AVFormatContext *s, int idx)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_DIRAC;
- st->time_base.den = AV_RB32(buf+8);
- st->time_base.num = AV_RB32(buf+12);
+ av_set_pts_info(st, 64, AV_RB32(buf+12), AV_RB32(buf+8));
return 1;
}
diff --git a/mplayer/ffmpeg/libavformat/oggparseflac.c b/mplayer/ffmpeg/libavformat/oggparseflac.c
index e5034af3..a51a8554 100644
--- a/mplayer/ffmpeg/libavformat/oggparseflac.c
+++ b/mplayer/ffmpeg/libavformat/oggparseflac.c
@@ -65,8 +65,7 @@ flac_header (AVFormatContext * s, int idx)
memcpy(st->codec->extradata, streaminfo_start, FLAC_STREAMINFO_SIZE);
st->codec->extradata_size = FLAC_STREAMINFO_SIZE;
- st->time_base.num = 1;
- st->time_base.den = st->codec->sample_rate;
+ av_set_pts_info(st, 64, 1, st->codec->sample_rate);
} else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
ff_vorbis_comment (s, &st->metadata, os->buf + os->pstart + 4, os->psize - 4);
}
diff --git a/mplayer/ffmpeg/libavformat/oggparseogm.c b/mplayer/ffmpeg/libavformat/oggparseogm.c
index e1d046f2..dda5be60 100644
--- a/mplayer/ffmpeg/libavformat/oggparseogm.c
+++ b/mplayer/ffmpeg/libavformat/oggparseogm.c
@@ -83,14 +83,13 @@ ogm_header(AVFormatContext *s, int idx)
st->codec->height = bytestream_get_le32(&p);
st->codec->time_base.den = spu * 10000000;
st->codec->time_base.num = time_unit;
- st->time_base = st->codec->time_base;
+ av_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den);
} else {
st->codec->channels = bytestream_get_le16(&p);
p += 2; /* block_align */
st->codec->bit_rate = bytestream_get_le32(&p) * 8;
st->codec->sample_rate = spu * 10000000 / time_unit;
- st->time_base.num = 1;
- st->time_base.den = st->codec->sample_rate;
+ av_set_pts_info(st, 64, 1, st->codec->sample_rate);
}
} else if (*p == 3) {
if (os->psize > 8)
diff --git a/mplayer/ffmpeg/libavformat/oggparseskeleton.c b/mplayer/ffmpeg/libavformat/oggparseskeleton.c
index ad0dded0..e318e9e7 100644
--- a/mplayer/ffmpeg/libavformat/oggparseskeleton.c
+++ b/mplayer/ffmpeg/libavformat/oggparseskeleton.c
@@ -60,8 +60,9 @@ static int skeleton_header(AVFormatContext *s, int idx)
start_den = AV_RL64(buf+20);
if (start_den) {
- av_reduce(&start_time, &st->time_base.den, start_num, start_den, INT_MAX);
- st->time_base.num = 1;
+ int base_den;
+ av_reduce(&start_time, &base_den, start_num, start_den, INT_MAX);
+ av_set_pts_info(st, 64, 1, base_den);
os->lastpts =
st->start_time = start_time;
}
diff --git a/mplayer/ffmpeg/libavformat/oggparsespeex.c b/mplayer/ffmpeg/libavformat/oggparsespeex.c
index 936b37e9..80b2001d 100644
--- a/mplayer/ffmpeg/libavformat/oggparsespeex.c
+++ b/mplayer/ffmpeg/libavformat/oggparsespeex.c
@@ -72,8 +72,7 @@ static int speex_header(AVFormatContext *s, int idx) {
+ FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(st->codec->extradata, p, st->codec->extradata_size);
- st->time_base.num = 1;
- st->time_base.den = st->codec->sample_rate;
+ av_set_pts_info(st, 64, 1, st->codec->sample_rate);
} else
ff_vorbis_comment(s, &st->metadata, p, os->psize);
diff --git a/mplayer/ffmpeg/libavformat/oggparsetheora.c b/mplayer/ffmpeg/libavformat/oggparsetheora.c
index 2299f550..d02781f2 100644
--- a/mplayer/ffmpeg/libavformat/oggparsetheora.c
+++ b/mplayer/ffmpeg/libavformat/oggparsetheora.c
@@ -91,7 +91,7 @@ theora_header (AVFormatContext * s, int idx)
st->codec->time_base.num = 1;
st->codec->time_base.den = 25;
}
- st->time_base = st->codec->time_base;
+ av_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den);
st->sample_aspect_ratio.num = get_bits_long(&gb, 24);
st->sample_aspect_ratio.den = get_bits_long(&gb, 24);
diff --git a/mplayer/ffmpeg/libavformat/oggparsevorbis.c b/mplayer/ffmpeg/libavformat/oggparsevorbis.c
index d743d25e..830f0bca 100644
--- a/mplayer/ffmpeg/libavformat/oggparsevorbis.c
+++ b/mplayer/ffmpeg/libavformat/oggparsevorbis.c
@@ -28,6 +28,7 @@
#include "libavcodec/get_bits.h"
#include "libavcodec/bytestream.h"
#include "avformat.h"
+#include "internal.h"
#include "oggdec.h"
#include "vorbiscomment.h"
@@ -252,12 +253,19 @@ vorbis_header (AVFormatContext * s, int idx)
if (srate > 0) {
st->codec->sample_rate = srate;
- st->time_base.num = 1;
- st->time_base.den = srate;
+ av_set_pts_info(st, 64, 1, srate);
}
} else if (os->buf[os->pstart] == 3) {
- if (os->psize > 8)
- ff_vorbis_comment (s, &st->metadata, os->buf + os->pstart + 7, os->psize - 8);
+ if (os->psize > 8 &&
+ ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7, os->psize - 8) >= 0) {
+ // drop all metadata we parsed and which is not required by libvorbis
+ unsigned new_len = 7 + 4 + AV_RL32(priv->packet[1] + 7) + 4 + 1;
+ if (new_len >= 16 && new_len < os->psize) {
+ AV_WL32(priv->packet[1] + new_len - 5, 0);
+ priv->packet[1][new_len - 1] = 1;
+ priv->len[1] = new_len;
+ }
+ }
} else {
st->codec->extradata_size =
fixup_vorbis_headers(s, priv, &st->codec->extradata);
diff --git a/mplayer/ffmpeg/libavformat/oma.c b/mplayer/ffmpeg/libavformat/oma.c
index 158ed117..03dc1e9d 100644
--- a/mplayer/ffmpeg/libavformat/oma.c
+++ b/mplayer/ffmpeg/libavformat/oma.c
@@ -79,7 +79,7 @@ static int oma_read_header(AVFormatContext *s,
AVStream *st;
ff_id3v2_read(s, ID3v2_EA3_MAGIC);
- ret = get_buffer(s->pb, buf, EA3_HEADER_SIZE);
+ ret = avio_read(s->pb, buf, EA3_HEADER_SIZE);
if (memcmp(buf, ((const uint8_t[]){'E', 'A', '3'}),3) || buf[4] != 0 || buf[5] != EA3_HEADER_SIZE) {
av_log(s, AV_LOG_ERROR, "Couldn't find the EA3 header !\n");
diff --git a/mplayer/ffmpeg/libavformat/os_support.c b/mplayer/ffmpeg/libavformat/os_support.c
index de0dd527..45667dfb 100644
--- a/mplayer/ffmpeg/libavformat/os_support.c
+++ b/mplayer/ffmpeg/libavformat/os_support.c
@@ -179,7 +179,7 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen,
return EAI_NONAME;
if (host && hostlen > 0) {
- #ifndef GEKKO
+#if !defined(GEKKO)
struct hostent *ent = NULL;
uint32_t a;
if (!(flags & NI_NUMERICHOST))
@@ -196,17 +196,17 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen,
((a >> 24) & 0xff), ((a >> 16) & 0xff),
((a >> 8) & 0xff), ( a & 0xff));
}
- #else
+#else
uint32_t a;
a = ntohl(sin->sin_addr.s_addr);
snprintf(host, hostlen, "%d.%d.%d.%d",
((a >> 24) & 0xff), ((a >> 16) & 0xff),
((a >> 8) & 0xff), ( a & 0xff));
- #endif
+#endif
}
if (serv && servlen > 0) {
- #ifndef GEKKO
+#if !defined(GEKKO)
struct servent *ent = NULL;
if (!(flags & NI_NUMERICSERV))
ent = getservbyport(sin->sin_port, flags & NI_DGRAM ? "udp" : "tcp");
@@ -214,7 +214,7 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen,
if (ent) {
snprintf(serv, servlen, "%s", ent->s_name);
} else
- #endif
+#endif
snprintf(serv, servlen, "%d", ntohs(sin->sin_port));
}
@@ -237,15 +237,19 @@ int ff_socket_nonblock(int socket, int enable)
{
#if HAVE_WINSOCK2_H
return ioctlsocket(socket, FIONBIO, &enable);
+#else
+#if defined(GEKKO)
+ return net_ioctl(socket, FIONBIO, &enable);
#else
if (enable)
return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);
else
return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK);
#endif
+#endif
}
-#if !HAVE_POLL_H
+#if !HAVE_POLL_H && !defined(GEKKO)
int poll(struct pollfd *fds, nfds_t numfds, int timeout)
{
fd_set read_set;
@@ -302,7 +306,7 @@ int poll(struct pollfd *fds, nfds_t numfds, int timeout)
if (rc < 0)
return rc;
- for(i = 0; i < (nfds_t) n; i++) {
+ for(i = 0; i < numfds; i++) {
fds[i].revents = 0;
if (FD_ISSET(fds[i].fd, &read_set)) fds[i].revents |= POLLIN;
diff --git a/mplayer/ffmpeg/libavformat/os_support.h b/mplayer/ffmpeg/libavformat/os_support.h
index df321511..1f186060 100644
--- a/mplayer/ffmpeg/libavformat/os_support.h
+++ b/mplayer/ffmpeg/libavformat/os_support.h
@@ -64,6 +64,7 @@ struct pollfd {
short revents; /* events that occurred */
};
+#if !defined(GEKKO)
/* events & revents */
#define POLLIN 0x0001 /* any readable data available */
#define POLLOUT 0x0002 /* file descriptor is writeable */
@@ -80,6 +81,7 @@ struct pollfd {
int poll(struct pollfd *fds, nfds_t numfds, int timeout);
+#endif
#endif /* HAVE_POLL_H */
#endif /* CONFIG_NETWORK */
diff --git a/mplayer/ffmpeg/libavformat/output-example.c b/mplayer/ffmpeg/libavformat/output-example.c
index 06207edd..b6be2b97 100644
--- a/mplayer/ffmpeg/libavformat/output-example.c
+++ b/mplayer/ffmpeg/libavformat/output-example.c
@@ -481,7 +481,7 @@ int main(int argc, char **argv)
exit(1);
}
- dump_format(oc, 0, filename, 1);
+ av_dump_format(oc, 0, filename, 1);
/* now that all the parameters are set, we can open the audio and
video codecs and allocate the necessary encode buffers */
@@ -492,7 +492,7 @@ int main(int argc, char **argv)
/* open the output file, if needed */
if (!(fmt->flags & AVFMT_NOFILE)) {
- if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0) {
+ if (avio_open(&oc->pb, filename, URL_WRONLY) < 0) {
fprintf(stderr, "Could not open '%s'\n", filename);
exit(1);
}
@@ -545,7 +545,7 @@ int main(int argc, char **argv)
if (!(fmt->flags & AVFMT_NOFILE)) {
/* close the output file */
- url_fclose(oc->pb);
+ avio_close(oc->pb);
}
/* free the stream */
diff --git a/mplayer/ffmpeg/libavformat/pcm.c b/mplayer/ffmpeg/libavformat/pcm.c
index 5de23af1..def183c5 100644
--- a/mplayer/ffmpeg/libavformat/pcm.c
+++ b/mplayer/ffmpeg/libavformat/pcm.c
@@ -49,7 +49,7 @@ int pcm_read_seek(AVFormatContext *s,
/* recompute exact position */
st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
- if ((ret = url_fseek(s->pb, pos + s->data_offset, SEEK_SET)) < 0)
+ if ((ret = avio_seek(s->pb, pos + s->data_offset, SEEK_SET)) < 0)
return ret;
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/psxstr.c b/mplayer/ffmpeg/libavformat/psxstr.c
index 4b3d0f3a..a0dc531a 100644
--- a/mplayer/ffmpeg/libavformat/psxstr.c
+++ b/mplayer/ffmpeg/libavformat/psxstr.c
@@ -98,21 +98,21 @@ static int str_probe(AVProbeData *p)
static int str_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
StrDemuxContext *str = s->priv_data;
unsigned char sector[RAW_CD_SECTOR_SIZE];
int start;
int i;
/* skip over any RIFF header */
- if (get_buffer(pb, sector, RIFF_HEADER_SIZE) != RIFF_HEADER_SIZE)
+ if (avio_read(pb, sector, RIFF_HEADER_SIZE) != RIFF_HEADER_SIZE)
return AVERROR(EIO);
if (AV_RL32(§or[0]) == RIFF_TAG)
start = RIFF_HEADER_SIZE;
else
start = 0;
- url_fseek(pb, start, SEEK_SET);
+ avio_seek(pb, start, SEEK_SET);
for(i=0; i<32; i++){
str->channels[i].video_stream_index=
@@ -127,7 +127,7 @@ static int str_read_header(AVFormatContext *s,
static int str_read_packet(AVFormatContext *s,
AVPacket *ret_pkt)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
StrDemuxContext *str = s->priv_data;
unsigned char sector[RAW_CD_SECTOR_SIZE];
int channel;
@@ -136,7 +136,7 @@ static int str_read_packet(AVFormatContext *s,
while (1) {
- if (get_buffer(pb, sector, RAW_CD_SECTOR_SIZE) != RAW_CD_SECTOR_SIZE)
+ if (avio_read(pb, sector, RAW_CD_SECTOR_SIZE) != RAW_CD_SECTOR_SIZE)
return AVERROR(EIO);
channel = sector[0x11];
diff --git a/mplayer/ffmpeg/libavformat/pva.c b/mplayer/ffmpeg/libavformat/pva.c
index 544fc7d0..8091baae 100644
--- a/mplayer/ffmpeg/libavformat/pva.c
+++ b/mplayer/ffmpeg/libavformat/pva.c
@@ -67,7 +67,7 @@ static int pva_read_header(AVFormatContext *s, AVFormatParameters *ap) {
static int read_part_of_packet(AVFormatContext *s, int64_t *pts,
int *len, int *strid, int read_packet) {
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
PVAContext *pvactx = s->priv_data;
int syncword, streamid, reserved, flags, length, pts_flag;
int64_t pva_pts = AV_NOPTS_VALUE, startpos;
@@ -75,12 +75,12 @@ static int read_part_of_packet(AVFormatContext *s, int64_t *pts,
recover:
startpos = url_ftell(pb);
- syncword = get_be16(pb);
- streamid = get_byte(pb);
- get_byte(pb); /* counter not used */
- reserved = get_byte(pb);
- flags = get_byte(pb);
- length = get_be16(pb);
+ syncword = avio_rb16(pb);
+ streamid = avio_r8(pb);
+ avio_r8(pb); /* counter not used */
+ reserved = avio_r8(pb);
+ flags = avio_r8(pb);
+ length = avio_rb16(pb);
pts_flag = flags & 0x10;
@@ -101,7 +101,7 @@ static int read_part_of_packet(AVFormatContext *s, int64_t *pts,
}
if (streamid == PVA_VIDEO_PAYLOAD && pts_flag) {
- pva_pts = get_be32(pb);
+ pva_pts = avio_rb32(pb);
length -= 4;
} else if (streamid == PVA_AUDIO_PAYLOAD) {
/* PVA Audio Packets either start with a signaled PES packet or
@@ -113,22 +113,22 @@ static int read_part_of_packet(AVFormatContext *s, int64_t *pts,
pes_flags;
unsigned char pes_header_data[256];
- pes_signal = get_be24(pb);
- get_byte(pb);
- pes_packet_length = get_be16(pb);
- pes_flags = get_be16(pb);
- pes_header_data_length = get_byte(pb);
+ pes_signal = avio_rb24(pb);
+ avio_r8(pb);
+ pes_packet_length = avio_rb16(pb);
+ pes_flags = avio_rb16(pb);
+ pes_header_data_length = avio_r8(pb);
if (pes_signal != 1) {
pva_log(s, AV_LOG_WARNING, "expected signaled PES packet, "
"trying to recover\n");
- url_fskip(pb, length - 9);
+ avio_seek(pb, length - 9, SEEK_CUR);
if (!read_packet)
return AVERROR(EIO);
goto recover;
}
- get_buffer(pb, pes_header_data, pes_header_data_length);
+ avio_read(pb, pes_header_data, pes_header_data_length);
length -= 9 + pes_header_data_length;
pes_packet_length -= 3 + pes_header_data_length;
@@ -157,7 +157,7 @@ static int read_part_of_packet(AVFormatContext *s, int64_t *pts,
}
static int pva_read_packet(AVFormatContext *s, AVPacket *pkt) {
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pva_pts;
int ret, length, streamid;
@@ -173,7 +173,7 @@ static int pva_read_packet(AVFormatContext *s, AVPacket *pkt) {
static int64_t pva_read_timestamp(struct AVFormatContext *s, int stream_index,
int64_t *pos, int64_t pos_limit) {
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
PVAContext *pvactx = s->priv_data;
int length, streamid;
int64_t res = AV_NOPTS_VALUE;
@@ -182,7 +182,7 @@ static int64_t pva_read_timestamp(struct AVFormatContext *s, int stream_index,
while (*pos < pos_limit) {
res = AV_NOPTS_VALUE;
- url_fseek(pb, *pos, SEEK_SET);
+ avio_seek(pb, *pos, SEEK_SET);
pvactx->continue_pes = 0;
if (read_part_of_packet(s, &res, &length, &streamid, 0)) {
diff --git a/mplayer/ffmpeg/libavformat/qcp.c b/mplayer/ffmpeg/libavformat/qcp.c
index 7bc32b97..6222bd5d 100644
--- a/mplayer/ffmpeg/libavformat/qcp.c
+++ b/mplayer/ffmpeg/libavformat/qcp.c
@@ -82,7 +82,7 @@ static int qcp_probe(AVProbeData *pd)
static int qcp_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
QCPContext *c = s->priv_data;
AVStream *st = av_new_stream(s, 0);
uint8_t buf[16];
@@ -91,13 +91,13 @@ static int qcp_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (!st)
return AVERROR(ENOMEM);
- get_be32(pb); // "RIFF"
- s->file_size = get_le32(pb) + 8;
- url_fskip(pb, 8 + 4 + 1 + 1); // "QLCMfmt " + chunk-size + major-version + minor-version
+ avio_rb32(pb); // "RIFF"
+ s->file_size = avio_rl32(pb) + 8;
+ avio_seek(pb, 8 + 4 + 1 + 1, SEEK_CUR); // "QLCMfmt " + chunk-size + major-version + minor-version
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->channels = 1;
- get_buffer(pb, buf, 16);
+ avio_read(pb, buf, 16);
if (is_qcelp_13k_guid(buf)) {
st->codec->codec_id = CODEC_ID_QCELP;
} else if (!memcmp(buf, guid_evrc, 16)) {
@@ -110,39 +110,39 @@ static int qcp_read_header(AVFormatContext *s, AVFormatParameters *ap)
av_log(s, AV_LOG_ERROR, "Unknown codec GUID.\n");
return AVERROR_INVALIDDATA;
}
- url_fskip(pb, 2 + 80); // codec-version + codec-name
- st->codec->bit_rate = get_le16(pb);
+ avio_seek(pb, 2 + 80, SEEK_CUR); // codec-version + codec-name
+ st->codec->bit_rate = avio_rl16(pb);
- s->packet_size = get_le16(pb);
- url_fskip(pb, 2); // block-size
- st->codec->sample_rate = get_le16(pb);
- url_fskip(pb, 2); // sample-size
+ s->packet_size = avio_rl16(pb);
+ avio_seek(pb, 2, SEEK_CUR); // block-size
+ st->codec->sample_rate = avio_rl16(pb);
+ avio_seek(pb, 2, SEEK_CUR); // sample-size
memset(c->rates_per_mode, -1, sizeof(c->rates_per_mode));
- nb_rates = get_le32(pb);
+ nb_rates = avio_rl32(pb);
nb_rates = FFMIN(nb_rates, 8);
for (i=0; i QCP_MAX_MODE) {
av_log(s, AV_LOG_WARNING, "Unknown entry %d=>%d in rate-map-table.\n ", mode, size);
} else
c->rates_per_mode[mode] = size;
}
- url_fskip(pb, 16 - 2*nb_rates + 20); // empty entries of rate-map-table + reserved
+ avio_seek(pb, 16 - 2*nb_rates + 20, SEEK_CUR); // empty entries of rate-map-table + reserved
return 0;
}
static int qcp_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
QCPContext *c = s->priv_data;
unsigned int chunk_size, tag;
while(!url_feof(pb)) {
if (c->data_size) {
- int pkt_size, ret, mode = get_byte(pb);
+ int pkt_size, ret, mode = avio_r8(pb);
if (s->packet_size) {
pkt_size = s->packet_size - 1;
@@ -165,23 +165,23 @@ static int qcp_read_packet(AVFormatContext *s, AVPacket *pkt)
return ret;
}
- if (url_ftell(pb) & 1 && get_byte(pb))
+ if (url_ftell(pb) & 1 && avio_r8(pb))
av_log(s, AV_LOG_WARNING, "Padding should be 0.\n");
- tag = get_le32(pb);
- chunk_size = get_le32(pb);
+ tag = avio_rl32(pb);
+ chunk_size = avio_rl32(pb);
switch (tag) {
case MKTAG('v', 'r', 'a', 't'):
- if (get_le32(pb)) // var-rate-flag
+ if (avio_rl32(pb)) // var-rate-flag
s->packet_size = 0;
- url_fskip(pb, 4); // size-in-packets
+ avio_seek(pb, 4, SEEK_CUR); // size-in-packets
break;
case MKTAG('d', 'a', 't', 'a'):
c->data_size = chunk_size;
break;
default:
- url_fskip(pb, chunk_size);
+ avio_seek(pb, chunk_size, SEEK_CUR);
}
}
return AVERROR_EOF;
diff --git a/mplayer/ffmpeg/libavformat/r3d.c b/mplayer/ffmpeg/libavformat/r3d.c
index 9c9fa1bb..0e103b6a 100644
--- a/mplayer/ffmpeg/libavformat/r3d.c
+++ b/mplayer/ffmpeg/libavformat/r3d.c
@@ -39,10 +39,10 @@ typedef struct {
static int read_atom(AVFormatContext *s, Atom *atom)
{
atom->offset = url_ftell(s->pb);
- atom->size = get_be32(s->pb);
+ atom->size = avio_rb32(s->pb);
if (atom->size < 8)
return -1;
- atom->tag = get_le32(s->pb);
+ atom->tag = avio_rl32(s->pb);
av_dlog(s, "atom %d %.4s offset %#llx\n",
atom->size, (char*)&atom->tag, atom->offset);
return atom->size;
@@ -59,31 +59,31 @@ static int r3d_read_red1(AVFormatContext *s)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_JPEG2000;
- tmp = get_byte(s->pb); // major version
- tmp2 = get_byte(s->pb); // minor version
+ tmp = avio_r8(s->pb); // major version
+ tmp2 = avio_r8(s->pb); // minor version
av_dlog(s, "version %d.%d\n", tmp, tmp2);
- tmp = get_be16(s->pb); // unknown
+ tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown1 %d\n", tmp);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_set_pts_info(st, 32, 1, tmp);
- tmp = get_be32(s->pb); // filenum
+ tmp = avio_rb32(s->pb); // filenum
av_dlog(s, "filenum %d\n", tmp);
- url_fskip(s->pb, 32); // unknown
+ avio_seek(s->pb, 32, SEEK_CUR); // unknown
- st->codec->width = get_be32(s->pb);
- st->codec->height = get_be32(s->pb);
+ st->codec->width = avio_rb32(s->pb);
+ st->codec->height = avio_rb32(s->pb);
- tmp = get_be16(s->pb); // unknown
+ tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown2 %d\n", tmp);
- st->codec->time_base.den = get_be16(s->pb);
- st->codec->time_base.num = get_be16(s->pb);
+ st->codec->time_base.den = avio_rb16(s->pb);
+ st->codec->time_base.num = avio_rb16(s->pb);
- tmp = get_byte(s->pb); // audio channels
+ tmp = avio_r8(s->pb); // audio channels
av_dlog(s, "audio channels %d\n", tmp);
if (tmp > 0) {
AVStream *ast = av_new_stream(s, 1);
@@ -95,7 +95,7 @@ static int r3d_read_red1(AVFormatContext *s)
av_set_pts_info(ast, 32, 1, st->time_base.den);
}
- get_buffer(s->pb, filename, 257);
+ avio_read(s->pb, filename, 257);
filename[sizeof(filename)-1] = 0;
av_metadata_set2(&st->metadata, "filename", filename, 0);
@@ -120,7 +120,7 @@ static int r3d_read_rdvo(AVFormatContext *s, Atom *atom)
return AVERROR(ENOMEM);
for (i = 0; i < r3d->video_offsets_count; i++) {
- r3d->video_offsets[i] = get_be32(s->pb);
+ r3d->video_offsets[i] = avio_rb32(s->pb);
if (!r3d->video_offsets[i]) {
r3d->video_offsets_count = i;
break;
@@ -141,18 +141,18 @@ static void r3d_read_reos(AVFormatContext *s)
R3DContext *r3d = s->priv_data;
int tmp;
- r3d->rdvo_offset = get_be32(s->pb);
- get_be32(s->pb); // rdvs offset
- get_be32(s->pb); // rdao offset
- get_be32(s->pb); // rdas offset
+ r3d->rdvo_offset = avio_rb32(s->pb);
+ avio_rb32(s->pb); // rdvs offset
+ avio_rb32(s->pb); // rdao offset
+ avio_rb32(s->pb); // rdas offset
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "num video chunks %d\n", tmp);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "num audio chunks %d\n", tmp);
- url_fskip(s->pb, 6*4);
+ avio_seek(s->pb, 6*4, SEEK_CUR);
}
static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap)
@@ -180,7 +180,7 @@ static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (url_is_streamed(s->pb))
return 0;
// find REOB/REOF/REOS to load index
- url_fseek(s->pb, url_fsize(s->pb)-48-8, SEEK_SET);
+ avio_seek(s->pb, url_fsize(s->pb)-48-8, SEEK_SET);
if (read_atom(s, &atom) < 0)
av_log(s, AV_LOG_ERROR, "error reading end atom\n");
@@ -192,7 +192,7 @@ static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap)
r3d_read_reos(s);
if (r3d->rdvo_offset) {
- url_fseek(s->pb, r3d->rdvo_offset, SEEK_SET);
+ avio_seek(s->pb, r3d->rdvo_offset, SEEK_SET);
if (read_atom(s, &atom) < 0)
av_log(s, AV_LOG_ERROR, "error reading 'rdvo' atom\n");
if (atom.tag == MKTAG('R','D','V','O')) {
@@ -202,7 +202,7 @@ static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
out:
- url_fseek(s->pb, s->data_offset, SEEK_SET);
+ avio_seek(s->pb, s->data_offset, SEEK_SET);
return 0;
}
@@ -214,31 +214,31 @@ static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
unsigned dts;
int ret;
- dts = get_be32(s->pb);
+ dts = avio_rb32(s->pb);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "frame num %d\n", tmp);
- tmp = get_byte(s->pb); // major version
- tmp2 = get_byte(s->pb); // minor version
+ tmp = avio_r8(s->pb); // major version
+ tmp2 = avio_r8(s->pb); // minor version
av_dlog(s, "version %d.%d\n", tmp, tmp2);
- tmp = get_be16(s->pb); // unknown
+ tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown %d\n", tmp);
if (tmp > 4) {
- tmp = get_be16(s->pb); // unknown
+ tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown %d\n", tmp);
- tmp = get_be16(s->pb); // unknown
+ tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown %d\n", tmp);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "width %d\n", tmp);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "height %d\n", tmp);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "metadata len %d\n", tmp);
}
tmp = atom->size - 8 - (url_ftell(s->pb) - pos);
@@ -268,23 +268,23 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
unsigned dts;
int ret;
- dts = get_be32(s->pb);
+ dts = avio_rb32(s->pb);
- st->codec->sample_rate = get_be32(s->pb);
+ st->codec->sample_rate = avio_rb32(s->pb);
- samples = get_be32(s->pb);
+ samples = avio_rb32(s->pb);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "packet num %d\n", tmp);
- tmp = get_be16(s->pb); // unkown
+ tmp = avio_rb16(s->pb); // unkown
av_dlog(s, "unknown %d\n", tmp);
- tmp = get_byte(s->pb); // major version
- tmp2 = get_byte(s->pb); // minor version
+ tmp = avio_r8(s->pb); // major version
+ tmp2 = avio_r8(s->pb); // minor version
av_dlog(s, "version %d.%d\n", tmp, tmp2);
- tmp = get_be32(s->pb); // unknown
+ tmp = avio_rb32(s->pb); // unknown
av_dlog(s, "unknown %d\n", tmp);
size = atom->size - 8 - (url_ftell(s->pb) - pos);
@@ -332,7 +332,7 @@ static int r3d_read_packet(AVFormatContext *s, AVPacket *pkt)
break;
default:
skip:
- url_fskip(s->pb, atom.size-8);
+ avio_seek(s->pb, atom.size-8, SEEK_CUR);
}
}
return err;
@@ -359,7 +359,7 @@ static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, i
av_dlog(s, "seek frame num %d timestamp %lld\n", frame_num, sample_time);
if (frame_num < r3d->video_offsets_count) {
- url_fseek(s->pb, r3d->video_offsets_count, SEEK_SET);
+ avio_seek(s->pb, r3d->video_offsets_count, SEEK_SET);
} else {
av_log(s, AV_LOG_ERROR, "could not seek to frame %d\n", frame_num);
return -1;
diff --git a/mplayer/ffmpeg/libavformat/rawdec.c b/mplayer/ffmpeg/libavformat/rawdec.c
index 4f830e3c..1c2f1211 100644
--- a/mplayer/ffmpeg/libavformat/rawdec.c
+++ b/mplayer/ffmpeg/libavformat/rawdec.c
@@ -21,6 +21,7 @@
*/
#include "avformat.h"
+#include "avio_internal.h"
#include "rawdec.h"
/* raw input */
@@ -81,7 +82,7 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos= url_ftell(s->pb);
pkt->stream_index = 0;
- ret = get_partial_buffer(s->pb, pkt->data, size);
+ ret = ffio_read_partial(s->pb, pkt->data, size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
diff --git a/mplayer/ffmpeg/libavformat/rawenc.c b/mplayer/ffmpeg/libavformat/rawenc.c
index 6f9fdce4..20ddfd56 100644
--- a/mplayer/ffmpeg/libavformat/rawenc.c
+++ b/mplayer/ffmpeg/libavformat/rawenc.c
@@ -25,7 +25,7 @@
int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/rdt.c b/mplayer/ffmpeg/libavformat/rdt.c
index 3428b4d3..ce398963 100644
--- a/mplayer/ffmpeg/libavformat/rdt.c
+++ b/mplayer/ffmpeg/libavformat/rdt.c
@@ -33,6 +33,7 @@
#include "libavutil/md5.h"
#include "rm.h"
#include "internal.h"
+#include "avio_internal.h"
#include "libavcodec/get_bits.h"
struct RDTDemuxContext {
@@ -63,7 +64,7 @@ ff_rdt_parse_open(AVFormatContext *ic, int first_stream_of_set_idx,
do {
s->n_streams++;
} while (first_stream_of_set_idx + s->n_streams < ic->nb_streams &&
- s->streams[s->n_streams]->priv_data == s->streams[0]->priv_data);
+ s->streams[s->n_streams]->id == s->streams[0]->id);
s->prev_set_id = -1;
s->prev_stream_id = -1;
s->prev_timestamp = -1;
@@ -76,11 +77,6 @@ ff_rdt_parse_open(AVFormatContext *ic, int first_stream_of_set_idx,
void
ff_rdt_parse_close(RDTDemuxContext *s)
{
- int i;
-
- for (i = 1; i < s->n_streams; i++)
- s->streams[i]->priv_data = NULL;
-
av_free(s);
}
@@ -135,7 +131,7 @@ ff_rdt_calc_response_and_checksum(char response[41], char chksum[9],
static int
rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr)
{
- ByteIOContext pb;
+ AVIOContext pb;
int size;
uint32_t tag;
@@ -155,30 +151,30 @@ rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr)
*/
if (!rdt->mlti_data)
return -1;
- init_put_byte(&pb, rdt->mlti_data, rdt->mlti_data_size, 0,
+ ffio_init_context(&pb, rdt->mlti_data, rdt->mlti_data_size, 0,
NULL, NULL, NULL, NULL);
- tag = get_le32(&pb);
+ tag = avio_rl32(&pb);
if (tag == MKTAG('M', 'L', 'T', 'I')) {
int num, chunk_nr;
/* read index of MDPR chunk numbers */
- num = get_be16(&pb);
+ num = avio_rb16(&pb);
if (rule_nr < 0 || rule_nr >= num)
return -1;
- url_fskip(&pb, rule_nr * 2);
- chunk_nr = get_be16(&pb);
- url_fskip(&pb, (num - 1 - rule_nr) * 2);
+ avio_seek(&pb, rule_nr * 2, SEEK_CUR);
+ chunk_nr = avio_rb16(&pb);
+ avio_seek(&pb, (num - 1 - rule_nr) * 2, SEEK_CUR);
/* read MDPR chunks */
- num = get_be16(&pb);
+ num = avio_rb16(&pb);
if (chunk_nr >= num)
return -1;
while (chunk_nr--)
- url_fskip(&pb, get_be32(&pb));
- size = get_be32(&pb);
+ avio_seek(&pb, avio_rb32(&pb), SEEK_CUR);
+ size = avio_rb32(&pb);
} else {
size = rdt->mlti_data_size;
- url_fseek(&pb, 0, SEEK_SET);
+ avio_seek(&pb, 0, SEEK_SET);
}
if (ff_rm_read_mdpr_codecdata(rdt->rmctx, &pb, st, rdt->rmst[st->index], size) < 0)
return -1;
@@ -300,12 +296,12 @@ rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st,
const uint8_t *buf, int len, int flags)
{
int seq = 1, res;
- ByteIOContext pb;
+ AVIOContext pb;
if (rdt->audio_pkt_cnt == 0) {
int pos;
- init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
flags = (flags & RTP_FLAG_KEY) ? 2 : 0;
res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[st->index], len, pkt,
&seq, flags, *timestamp);
@@ -315,7 +311,7 @@ rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st,
if (res > 0) {
if (st->codec->codec_id == CODEC_ID_AAC) {
memcpy (rdt->buffer, buf + pos, len - pos);
- rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
+ rdt->rmctx->pb = avio_alloc_context (rdt->buffer, len - pos, 0,
NULL, NULL, NULL, NULL);
}
goto get_cache;
@@ -422,7 +418,7 @@ rdt_parse_sdp_line (AVFormatContext *s, int st_index,
int n, first = -1;
for (n = 0; n < s->nb_streams; n++)
- if (s->streams[n]->priv_data == stream->priv_data) {
+ if (s->streams[n]->id == stream->id) {
int count = s->streams[n]->index + 1;
if (first == -1) first = n;
if (rdt->nb_rmst < count) {
@@ -463,10 +459,9 @@ add_dstream(AVFormatContext *s, AVStream *orig_st)
{
AVStream *st;
- if (!(st = av_new_stream(s, 0)))
+ if (!(st = av_new_stream(s, orig_st->id)))
return NULL;
st->codec->codec_type = orig_st->codec->codec_type;
- st->priv_data = orig_st->priv_data;
st->first_dts = orig_st->first_dts;
return st;
@@ -559,7 +554,7 @@ static RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \
.open = rdt_new_context, \
.close = rdt_free_context, \
.parse_packet = rdt_parse_packet \
-};
+}
RDT_HANDLER(live_video, "x-pn-multirate-realvideo-live", AVMEDIA_TYPE_VIDEO);
RDT_HANDLER(live_audio, "x-pn-multirate-realaudio-live", AVMEDIA_TYPE_AUDIO);
diff --git a/mplayer/ffmpeg/libavformat/riff.c b/mplayer/ffmpeg/libavformat/riff.c
index 4edccced..709aaad2 100644
--- a/mplayer/ffmpeg/libavformat/riff.c
+++ b/mplayer/ffmpeg/libavformat/riff.c
@@ -21,6 +21,7 @@
#include "libavcodec/avcodec.h"
#include "avformat.h"
+#include "avio_internal.h"
#include "riff.h"
#include "libavcodec/bytestream.h"
@@ -319,26 +320,26 @@ const AVCodecTag ff_codec_wav_tags[] = {
};
#if CONFIG_MUXERS
-int64_t ff_start_tag(ByteIOContext *pb, const char *tag)
+int64_t ff_start_tag(AVIOContext *pb, const char *tag)
{
- put_tag(pb, tag);
- put_le32(pb, 0);
+ ffio_wfourcc(pb, tag);
+ avio_wl32(pb, 0);
return url_ftell(pb);
}
-void ff_end_tag(ByteIOContext *pb, int64_t start)
+void ff_end_tag(AVIOContext *pb, int64_t start)
{
int64_t pos;
pos = url_ftell(pb);
- url_fseek(pb, start - 4, SEEK_SET);
- put_le32(pb, (uint32_t)(pos - start));
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, start - 4, SEEK_SET);
+ avio_wl32(pb, (uint32_t)(pos - start));
+ avio_seek(pb, pos, SEEK_SET);
}
/* WAVEFORMATEX header */
/* returns the size or -1 on error */
-int ff_put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
+int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
{
int bps, blkalign, bytespersec;
int hdrsize = 18;
@@ -354,12 +355,12 @@ int ff_put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
|| av_get_bits_per_sample(enc->codec_id) > 16;
if (waveformatextensible) {
- put_le16(pb, 0xfffe);
+ avio_wl16(pb, 0xfffe);
} else {
- put_le16(pb, enc->codec_tag);
+ avio_wl16(pb, enc->codec_tag);
}
- put_le16(pb, enc->channels);
- put_le32(pb, enc->sample_rate);
+ avio_wl16(pb, enc->channels);
+ avio_wl32(pb, enc->sample_rate);
if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3 || enc->codec_id == CODEC_ID_GSM_MS) {
bps = 0;
} else if (enc->codec_id == CODEC_ID_ADPCM_G726) {
@@ -393,9 +394,9 @@ int ff_put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
} else {
bytespersec = enc->bit_rate / 8;
}
- put_le32(pb, bytespersec); /* bytes per second */
- put_le16(pb, blkalign); /* block align */
- put_le16(pb, bps); /* bits per sample */
+ avio_wl32(pb, bytespersec); /* bytes per second */
+ avio_wl16(pb, blkalign); /* block align */
+ avio_wl16(pb, bps); /* bits per sample */
if (enc->codec_id == CODEC_ID_MP3) {
hdrsize += 12;
bytestream_put_le16(&riff_extradata, 1); /* wID */
@@ -425,47 +426,47 @@ int ff_put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
}
if(waveformatextensible) { /* write WAVEFORMATEXTENSIBLE extensions */
hdrsize += 22;
- put_le16(pb, riff_extradata - riff_extradata_start + 22); /* 22 is WAVEFORMATEXTENSIBLE size */
- put_le16(pb, enc->bits_per_coded_sample); /* ValidBitsPerSample || SamplesPerBlock || Reserved */
- put_le32(pb, enc->channel_layout); /* dwChannelMask */
- put_le32(pb, enc->codec_tag); /* GUID + next 3 */
- put_le32(pb, 0x00100000);
- put_le32(pb, 0xAA000080);
- put_le32(pb, 0x719B3800);
+ avio_wl16(pb, riff_extradata - riff_extradata_start + 22); /* 22 is WAVEFORMATEXTENSIBLE size */
+ avio_wl16(pb, enc->bits_per_coded_sample); /* ValidBitsPerSample || SamplesPerBlock || Reserved */
+ avio_wl32(pb, enc->channel_layout); /* dwChannelMask */
+ avio_wl32(pb, enc->codec_tag); /* GUID + next 3 */
+ avio_wl32(pb, 0x00100000);
+ avio_wl32(pb, 0xAA000080);
+ avio_wl32(pb, 0x719B3800);
} else if(riff_extradata - riff_extradata_start) {
- put_le16(pb, riff_extradata - riff_extradata_start);
+ avio_wl16(pb, riff_extradata - riff_extradata_start);
}
- put_buffer(pb, riff_extradata_start, riff_extradata - riff_extradata_start);
+ avio_write(pb, riff_extradata_start, riff_extradata - riff_extradata_start);
if(hdrsize&1){
hdrsize++;
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
return hdrsize;
}
/* BITMAPINFOHEADER header */
-void ff_put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf)
+void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf)
{
- put_le32(pb, 40 + enc->extradata_size); /* size */
- put_le32(pb, enc->width);
+ avio_wl32(pb, 40 + enc->extradata_size); /* size */
+ avio_wl32(pb, enc->width);
//We always store RGB TopDown
- put_le32(pb, enc->codec_tag ? enc->height : -enc->height);
- put_le16(pb, 1); /* planes */
+ avio_wl32(pb, enc->codec_tag ? enc->height : -enc->height);
+ avio_wl16(pb, 1); /* planes */
- put_le16(pb, enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24); /* depth */
+ avio_wl16(pb, enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24); /* depth */
/* compression type */
- put_le32(pb, enc->codec_tag);
- put_le32(pb, enc->width * enc->height * 3);
- put_le32(pb, 0);
- put_le32(pb, 0);
- put_le32(pb, 0);
- put_le32(pb, 0);
+ avio_wl32(pb, enc->codec_tag);
+ avio_wl32(pb, enc->width * enc->height * 3);
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
- put_buffer(pb, enc->extradata, enc->extradata_size);
+ avio_write(pb, enc->extradata, enc->extradata_size);
if (!for_asf && enc->extradata_size & 1)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
#endif //CONFIG_MUXERS
@@ -477,43 +478,43 @@ void ff_put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag
* WAVEFORMATEX adds 'WORD cbSize' and basically makes itself
* an openended structure.
*/
-void ff_get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size)
+void ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
{
int id;
- id = get_le16(pb);
+ id = avio_rl16(pb);
codec->codec_type = AVMEDIA_TYPE_AUDIO;
codec->codec_tag = id;
- codec->channels = get_le16(pb);
- codec->sample_rate = get_le32(pb);
- codec->bit_rate = get_le32(pb) * 8;
- codec->block_align = get_le16(pb);
+ codec->channels = avio_rl16(pb);
+ codec->sample_rate = avio_rl32(pb);
+ codec->bit_rate = avio_rl32(pb) * 8;
+ codec->block_align = avio_rl16(pb);
if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */
codec->bits_per_coded_sample = 8;
}else
- codec->bits_per_coded_sample = get_le16(pb);
+ codec->bits_per_coded_sample = avio_rl16(pb);
if (size >= 18) { /* We're obviously dealing with WAVEFORMATEX */
- int cbSize = get_le16(pb); /* cbSize */
+ int cbSize = avio_rl16(pb); /* cbSize */
size -= 18;
cbSize = FFMIN(size, cbSize);
if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
- codec->bits_per_coded_sample = get_le16(pb);
- codec->channel_layout = get_le32(pb); /* dwChannelMask */
- id = get_le32(pb); /* 4 first bytes of GUID */
- url_fskip(pb, 12); /* skip end of GUID */
+ codec->bits_per_coded_sample = avio_rl16(pb);
+ codec->channel_layout = avio_rl32(pb); /* dwChannelMask */
+ id = avio_rl32(pb); /* 4 first bytes of GUID */
+ avio_seek(pb, 12, SEEK_CUR); /* skip end of GUID */
cbSize -= 22;
size -= 22;
}
codec->extradata_size = cbSize;
if (cbSize > 0) {
codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(pb, codec->extradata, codec->extradata_size);
+ avio_read(pb, codec->extradata, codec->extradata_size);
size -= cbSize;
}
/* It is possible for the chunk to contain garbage at the end */
if (size > 0)
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
}
codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample);
if (codec->codec_id == CODEC_ID_AAC_LATM) {
@@ -544,20 +545,20 @@ enum CodecID ff_wav_codec_get_id(unsigned int tag, int bps)
return id;
}
-int ff_get_bmp_header(ByteIOContext *pb, AVStream *st)
+int ff_get_bmp_header(AVIOContext *pb, AVStream *st)
{
int tag1;
- get_le32(pb); /* size */
- st->codec->width = get_le32(pb);
- st->codec->height = (int32_t)get_le32(pb);
- get_le16(pb); /* planes */
- st->codec->bits_per_coded_sample= get_le16(pb); /* depth */
- tag1 = get_le32(pb);
- get_le32(pb); /* ImageSize */
- get_le32(pb); /* XPelsPerMeter */
- get_le32(pb); /* YPelsPerMeter */
- get_le32(pb); /* ClrUsed */
- get_le32(pb); /* ClrImportant */
+ avio_rl32(pb); /* size */
+ st->codec->width = avio_rl32(pb);
+ st->codec->height = (int32_t)avio_rl32(pb);
+ avio_rl16(pb); /* planes */
+ st->codec->bits_per_coded_sample= avio_rl16(pb); /* depth */
+ tag1 = avio_rl32(pb);
+ avio_rl32(pb); /* ImageSize */
+ avio_rl32(pb); /* XPelsPerMeter */
+ avio_rl32(pb); /* YPelsPerMeter */
+ avio_rl32(pb); /* ClrUsed */
+ avio_rl32(pb); /* ClrImportant */
return tag1;
}
#endif // CONFIG_DEMUXERS
diff --git a/mplayer/ffmpeg/libavformat/riff.h b/mplayer/ffmpeg/libavformat/riff.h
index 5045abcd..5a45a38e 100644
--- a/mplayer/ffmpeg/libavformat/riff.h
+++ b/mplayer/ffmpeg/libavformat/riff.h
@@ -32,20 +32,20 @@
#include "avio.h"
#include "internal.h"
-int64_t ff_start_tag(ByteIOContext *pb, const char *tag);
-void ff_end_tag(ByteIOContext *pb, int64_t start);
+int64_t ff_start_tag(AVIOContext *pb, const char *tag);
+void ff_end_tag(AVIOContext *pb, int64_t start);
/**
* Read BITMAPINFOHEADER structure and set AVStream codec width, height and
* bits_per_encoded_sample fields. Does not read extradata.
* @return codec tag
*/
-int ff_get_bmp_header(ByteIOContext *pb, AVStream *st);
+int ff_get_bmp_header(AVIOContext *pb, AVStream *st);
-void ff_put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf);
-int ff_put_wav_header(ByteIOContext *pb, AVCodecContext *enc);
+void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf);
+int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc);
enum CodecID ff_wav_codec_get_id(unsigned int tag, int bps);
-void ff_get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size);
+void ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size);
extern const AVCodecTag ff_codec_bmp_tags[];
extern const AVCodecTag ff_codec_wav_tags[];
diff --git a/mplayer/ffmpeg/libavformat/rl2.c b/mplayer/ffmpeg/libavformat/rl2.c
index ed1fb232..4538d5c5 100644
--- a/mplayer/ffmpeg/libavformat/rl2.c
+++ b/mplayer/ffmpeg/libavformat/rl2.c
@@ -74,7 +74,7 @@ static int rl2_probe(AVProbeData *p)
static av_cold int rl2_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
unsigned int frame_count;
unsigned int audio_frame_counter = 0;
@@ -95,21 +95,21 @@ static av_cold int rl2_read_header(AVFormatContext *s,
int i;
int ret = 0;
- url_fskip(pb,4); /* skip FORM tag */
- back_size = get_le32(pb); /**< get size of the background frame */
- signature = get_be32(pb);
- data_size = get_be32(pb);
- frame_count = get_le32(pb);
+ avio_seek(pb,4, SEEK_CUR); /* skip FORM tag */
+ back_size = avio_rl32(pb); /**< get size of the background frame */
+ signature = avio_rb32(pb);
+ data_size = avio_rb32(pb);
+ frame_count = avio_rl32(pb);
/* disallow back_sizes and frame_counts that may lead to overflows later */
if(back_size > INT_MAX/2 || frame_count > INT_MAX / sizeof(uint32_t))
return AVERROR_INVALIDDATA;
- encoding_method = get_le16(pb);
- sound_rate = get_le16(pb);
- rate = get_le16(pb);
- channels = get_le16(pb);
- def_sound_size = get_le16(pb);
+ encoding_method = avio_rl16(pb);
+ sound_rate = avio_rl16(pb);
+ rate = avio_rl16(pb);
+ channels = avio_rl16(pb);
+ def_sound_size = avio_rl16(pb);
/** setup video stream */
st = av_new_stream(s, 0);
@@ -133,7 +133,7 @@ static av_cold int rl2_read_header(AVFormatContext *s,
if(!st->codec->extradata)
return AVERROR(ENOMEM);
- if(get_buffer(pb,st->codec->extradata,st->codec->extradata_size) !=
+ if(avio_read(pb,st->codec->extradata,st->codec->extradata_size) !=
st->codec->extradata_size)
return AVERROR(EIO);
@@ -173,11 +173,11 @@ static av_cold int rl2_read_header(AVFormatContext *s,
/** read offset and size tables */
for(i=0; i < frame_count;i++)
- chunk_size[i] = get_le32(pb);
+ chunk_size[i] = avio_rl32(pb);
for(i=0; i < frame_count;i++)
- chunk_offset[i] = get_le32(pb);
+ chunk_offset[i] = avio_rl32(pb);
for(i=0; i < frame_count;i++)
- audio_size[i] = get_le32(pb) & 0xFFFF;
+ audio_size[i] = avio_rl32(pb) & 0xFFFF;
/** build the sample index */
for(i=0;ipriv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVIndexEntry *sample = NULL;
int i;
int ret = 0;
@@ -237,7 +237,7 @@ static int rl2_read_packet(AVFormatContext *s,
++rl2->index_pos[stream_id];
/** position the stream (will probably be there anyway) */
- url_fseek(pb, sample->pos, SEEK_SET);
+ avio_seek(pb, sample->pos, SEEK_SET);
/** fill the packet */
ret = av_get_packet(pb, pkt, sample->size);
diff --git a/mplayer/ffmpeg/libavformat/rm.h b/mplayer/ffmpeg/libavformat/rm.h
index 2d4656aa..6de10924 100644
--- a/mplayer/ffmpeg/libavformat/rm.h
+++ b/mplayer/ffmpeg/libavformat/rm.h
@@ -41,7 +41,7 @@ extern AVInputFormat ff_rdt_demuxer;
* Read the MDPR chunk, which contains stream-specific codec initialization
* parameters.
*
- * @param s context containing RMContext and ByteIOContext for stream reading
+ * @param s context containing RMContext and AVIOContext for stream reading
* @param pb context to read the data from
* @param st the stream that the MDPR chunk belongs to and where to store the
* parameters read from the chunk into
@@ -49,14 +49,14 @@ extern AVInputFormat ff_rdt_demuxer;
* @param codec_data_size size of the MDPR chunk
* @return 0 on success, errno codes on error
*/
-int ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
+int ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb,
AVStream *st, RMStream *rst,
int codec_data_size);
/**
* Parse one rm-stream packet from the input bytestream.
*
- * @param s context containing RMContext and ByteIOContext for stream reading
+ * @param s context containing RMContext and AVIOContext for stream reading
* @param pb context to read the data from
* @param st stream to which the packet to be read belongs
* @param rst Real-specific stream information
@@ -70,7 +70,7 @@ int ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
* value >0 means that no data was placed in pkt, but that cached
* data is available by calling ff_rm_retrieve_cache().
*/
-int ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
+int ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb,
AVStream *st, RMStream *rst, int len,
AVPacket *pkt, int *seq, int flags, int64_t ts);
@@ -82,7 +82,7 @@ int ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
* a positive number, the amount of cached packets. Using this function, each
* of those packets can be retrieved sequentially.
*
- * @param s context containing RMContext and ByteIOContext for stream reading
+ * @param s context containing RMContext and AVIOContext for stream reading
* @param pb context to read the data from
* @param st stream that this packet belongs to
* @param rst Real-specific stream information
@@ -90,7 +90,7 @@ int ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
* @return the number of samples left for subsequent calls to this same
* function, or 0 if all samples have been retrieved.
*/
-int ff_rm_retrieve_cache (AVFormatContext *s, ByteIOContext *pb,
+int ff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb,
AVStream *st, RMStream *rst, AVPacket *pkt);
/**
diff --git a/mplayer/ffmpeg/libavformat/rmdec.c b/mplayer/ffmpeg/libavformat/rmdec.c
index da7e6b23..23f20759 100644
--- a/mplayer/ffmpeg/libavformat/rmdec.c
+++ b/mplayer/ffmpeg/libavformat/rmdec.c
@@ -64,33 +64,33 @@ static const unsigned char sipr_swaps[38][2] = {
const unsigned char ff_sipr_subpk_size[4] = { 29, 19, 37, 20 };
-static inline void get_strl(ByteIOContext *pb, char *buf, int buf_size, int len)
+static inline void get_strl(AVIOContext *pb, char *buf, int buf_size, int len)
{
int i;
char *q, r;
q = buf;
for(i=0;i 0) *q = '\0';
}
-static void get_str8(ByteIOContext *pb, char *buf, int buf_size)
+static void get_str8(AVIOContext *pb, char *buf, int buf_size)
{
- get_strl(pb, buf, buf_size, get_byte(pb));
+ get_strl(pb, buf, buf_size, avio_r8(pb));
}
-static int rm_read_extradata(ByteIOContext *pb, AVCodecContext *avctx, unsigned size)
+static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned size)
{
if (size >= 1<<24)
return -1;
avctx->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata)
return AVERROR(ENOMEM);
- avctx->extradata_size = get_buffer(pb, avctx->extradata, size);
+ avctx->extradata_size = avio_read(pb, avctx->extradata, size);
memset(avctx->extradata + avctx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
if (avctx->extradata_size != size)
return AVERROR(EIO);
@@ -102,7 +102,7 @@ static void rm_read_metadata(AVFormatContext *s, int wide)
char buf[1024];
int i;
for (i=0; ipb) : get_byte(s->pb);
+ int len = wide ? avio_rb16(s->pb) : avio_r8(s->pb);
get_strl(s->pb, buf, sizeof(buf), len);
av_metadata_set2(&s->metadata, ff_rm_metadata[i], buf, 0);
}
@@ -120,7 +120,7 @@ void ff_rm_free_rmstream (RMStream *rms)
av_free_packet(&rms->pkt);
}
-static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
+static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
AVStream *st, RMStream *ast, int read_all)
{
char buf[256];
@@ -128,20 +128,20 @@ static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
int ret;
/* ra type header */
- version = get_be16(pb); /* version */
+ version = avio_rb16(pb); /* version */
if (version == 3) {
- int header_size = get_be16(pb);
+ int header_size = avio_rb16(pb);
int64_t startpos = url_ftell(pb);
- url_fskip(pb, 14);
+ avio_seek(pb, 14, SEEK_CUR);
rm_read_metadata(s, 0);
if ((startpos + header_size) >= url_ftell(pb) + 2) {
// fourcc (should always be "lpcJ")
- get_byte(pb);
+ avio_r8(pb);
get_str8(pb, buf, sizeof(buf));
}
// Skip extra header crap (this should never happen)
if ((startpos + header_size) > url_ftell(pb))
- url_fskip(pb, header_size + startpos - url_ftell(pb));
+ avio_seek(pb, header_size + startpos - url_ftell(pb), SEEK_CUR);
st->codec->sample_rate = 8000;
st->codec->channels = 1;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -150,29 +150,29 @@ static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
int flavor, sub_packet_h, coded_framesize, sub_packet_size;
int codecdata_length;
/* old version (4) */
- url_fskip(pb, 2); /* unused */
- get_be32(pb); /* .ra4 */
- get_be32(pb); /* data size */
- get_be16(pb); /* version2 */
- get_be32(pb); /* header size */
- flavor= get_be16(pb); /* add codec info / flavor */
- ast->coded_framesize = coded_framesize = get_be32(pb); /* coded frame size */
- get_be32(pb); /* ??? */
- get_be32(pb); /* ??? */
- get_be32(pb); /* ??? */
- ast->sub_packet_h = sub_packet_h = get_be16(pb); /* 1 */
- st->codec->block_align= get_be16(pb); /* frame size */
- ast->sub_packet_size = sub_packet_size = get_be16(pb); /* sub packet size */
- get_be16(pb); /* ??? */
+ avio_seek(pb, 2, SEEK_CUR); /* unused */
+ avio_rb32(pb); /* .ra4 */
+ avio_rb32(pb); /* data size */
+ avio_rb16(pb); /* version2 */
+ avio_rb32(pb); /* header size */
+ flavor= avio_rb16(pb); /* add codec info / flavor */
+ ast->coded_framesize = coded_framesize = avio_rb32(pb); /* coded frame size */
+ avio_rb32(pb); /* ??? */
+ avio_rb32(pb); /* ??? */
+ avio_rb32(pb); /* ??? */
+ ast->sub_packet_h = sub_packet_h = avio_rb16(pb); /* 1 */
+ st->codec->block_align= avio_rb16(pb); /* frame size */
+ ast->sub_packet_size = sub_packet_size = avio_rb16(pb); /* sub packet size */
+ avio_rb16(pb); /* ??? */
if (version == 5) {
- get_be16(pb); get_be16(pb); get_be16(pb);
+ avio_rb16(pb); avio_rb16(pb); avio_rb16(pb);
}
- st->codec->sample_rate = get_be16(pb);
- get_be32(pb);
- st->codec->channels = get_be16(pb);
+ st->codec->sample_rate = avio_rb16(pb);
+ avio_rb32(pb);
+ st->codec->channels = avio_rb16(pb);
if (version == 5) {
- get_be32(pb);
- get_buffer(pb, buf, 4);
+ avio_rb32(pb);
+ avio_read(pb, buf, 4);
buf[4] = 0;
} else {
get_str8(pb, buf, sizeof(buf)); /* desc */
@@ -201,10 +201,10 @@ static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
case CODEC_ID_COOK:
case CODEC_ID_ATRAC3:
case CODEC_ID_SIPR:
- get_be16(pb); get_byte(pb);
+ avio_rb16(pb); avio_r8(pb);
if (version == 5)
- get_byte(pb);
- codecdata_length = get_be32(pb);
+ avio_r8(pb);
+ codecdata_length = avio_rb32(pb);
if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
return -1;
@@ -236,16 +236,16 @@ static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
av_new_packet(&ast->pkt, ast->audio_framesize * sub_packet_h);
break;
case CODEC_ID_AAC:
- get_be16(pb); get_byte(pb);
+ avio_rb16(pb); avio_r8(pb);
if (version == 5)
- get_byte(pb);
- codecdata_length = get_be32(pb);
+ avio_r8(pb);
+ codecdata_length = avio_rb32(pb);
if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
return -1;
}
if (codecdata_length >= 1) {
- get_byte(pb);
+ avio_r8(pb);
if ((ret = rm_read_extradata(pb, st->codec, codecdata_length - 1)) < 0)
return ret;
}
@@ -254,9 +254,9 @@ static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
av_strlcpy(st->codec->codec_name, buf, sizeof(st->codec->codec_name));
}
if (read_all) {
- get_byte(pb);
- get_byte(pb);
- get_byte(pb);
+ avio_r8(pb);
+ avio_r8(pb);
+ avio_r8(pb);
rm_read_metadata(s, 0);
}
}
@@ -264,7 +264,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
}
int
-ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
+ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb,
AVStream *st, RMStream *rst, int codec_data_size)
{
unsigned int v;
@@ -274,32 +274,32 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
av_set_pts_info(st, 64, 1, 1000);
codec_pos = url_ftell(pb);
- v = get_be32(pb);
+ v = avio_rb32(pb);
if (v == MKTAG(0xfd, 'a', 'r', '.')) {
/* ra type header */
if (rm_read_audio_stream_info(s, pb, st, rst, 0))
return -1;
} else {
int fps, fps2;
- if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
+ if (avio_rl32(pb) != MKTAG('V', 'I', 'D', 'O')) {
fail1:
av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
goto skip;
}
- st->codec->codec_tag = get_le32(pb);
+ st->codec->codec_tag = avio_rl32(pb);
st->codec->codec_id = ff_codec_get_id(ff_rm_codec_tags,
st->codec->codec_tag);
// av_log(s, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));
if (st->codec->codec_id == CODEC_ID_NONE)
goto fail1;
- st->codec->width = get_be16(pb);
- st->codec->height = get_be16(pb);
+ st->codec->width = avio_rb16(pb);
+ st->codec->height = avio_rb16(pb);
st->codec->time_base.num= 1;
- fps= get_be16(pb);
+ fps= avio_rb16(pb);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- get_be32(pb);
- fps2= get_be16(pb);
- get_be16(pb);
+ avio_rb32(pb);
+ fps2= avio_rb16(pb);
+ avio_rb16(pb);
if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (url_ftell(pb) - codec_pos))) < 0)
return ret;
@@ -321,7 +321,7 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
skip:
/* skip codec info */
size = url_ftell(pb) - codec_pos;
- url_fskip(pb, codec_data_size - size);
+ avio_seek(pb, codec_data_size - size, SEEK_CUR);
return 0;
}
@@ -330,20 +330,20 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
* of the INDX chunk, and will bail out if not. */
static int rm_read_index(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int size, n_pkts, str_id, next_off, n, pos, pts;
AVStream *st;
do {
- if (get_le32(pb) != MKTAG('I','N','D','X'))
+ if (avio_rl32(pb) != MKTAG('I','N','D','X'))
return -1;
- size = get_be32(pb);
+ size = avio_rb32(pb);
if (size < 20)
return -1;
- url_fskip(pb, 2);
- n_pkts = get_be32(pb);
- str_id = get_be16(pb);
- next_off = get_be32(pb);
+ avio_seek(pb, 2, SEEK_CUR);
+ n_pkts = avio_rb32(pb);
+ str_id = avio_rb16(pb);
+ next_off = avio_rb32(pb);
for (n = 0; n < s->nb_streams; n++)
if (s->streams[n]->id == str_id) {
st = s->streams[n];
@@ -353,17 +353,17 @@ static int rm_read_index(AVFormatContext *s)
goto skip;
for (n = 0; n < n_pkts; n++) {
- url_fskip(pb, 2);
- pts = get_be32(pb);
- pos = get_be32(pb);
- url_fskip(pb, 4); /* packet no. */
+ avio_seek(pb, 2, SEEK_CUR);
+ pts = avio_rb32(pb);
+ pos = avio_rb32(pb);
+ avio_seek(pb, 4, SEEK_CUR); /* packet no. */
av_add_index_entry(st, pos, pts, 0, 0, AVINDEX_KEYFRAME);
}
skip:
if (next_off && url_ftell(pb) != next_off &&
- url_fseek(pb, next_off, SEEK_SET) < 0)
+ avio_seek(pb, next_off, SEEK_SET) < 0)
return -1;
} while (next_off);
@@ -387,7 +387,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
RMDemuxContext *rm = s->priv_data;
AVStream *st;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int tag;
int tag_size;
unsigned int start_time, duration;
@@ -395,7 +395,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
char buf[128];
int flags = 0;
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag == MKTAG('.', 'r', 'a', 0xfd)) {
/* very old .ra format */
return rm_read_header_old(s, ap);
@@ -403,17 +403,17 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR(EIO);
}
- get_be32(pb); /* header size */
- get_be16(pb);
- get_be32(pb);
- get_be32(pb); /* number of headers */
+ avio_rb32(pb); /* header size */
+ avio_rb16(pb);
+ avio_rb32(pb);
+ avio_rb32(pb); /* number of headers */
for(;;) {
if (url_feof(pb))
return -1;
- tag = get_le32(pb);
- tag_size = get_be32(pb);
- get_be16(pb);
+ tag = avio_rl32(pb);
+ tag_size = avio_rb32(pb);
+ avio_rb16(pb);
#if 0
printf("tag=%c%c%c%c (%08x) size=%d\n",
(tag) & 0xff,
@@ -428,17 +428,17 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
switch(tag) {
case MKTAG('P', 'R', 'O', 'P'):
/* file header */
- get_be32(pb); /* max bit rate */
- get_be32(pb); /* avg bit rate */
- get_be32(pb); /* max packet size */
- get_be32(pb); /* avg packet size */
- get_be32(pb); /* nb packets */
- get_be32(pb); /* duration */
- get_be32(pb); /* preroll */
- indx_off = get_be32(pb); /* index offset */
- data_off = get_be32(pb); /* data offset */
- get_be16(pb); /* nb streams */
- flags = get_be16(pb); /* flags */
+ avio_rb32(pb); /* max bit rate */
+ avio_rb32(pb); /* avg bit rate */
+ avio_rb32(pb); /* max packet size */
+ avio_rb32(pb); /* avg packet size */
+ avio_rb32(pb); /* nb packets */
+ avio_rb32(pb); /* duration */
+ avio_rb32(pb); /* preroll */
+ indx_off = avio_rb32(pb); /* index offset */
+ data_off = avio_rb32(pb); /* data offset */
+ avio_rb16(pb); /* nb streams */
+ flags = avio_rb16(pb); /* flags */
break;
case MKTAG('C', 'O', 'N', 'T'):
rm_read_metadata(s, 1);
@@ -447,14 +447,14 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
- st->id = get_be16(pb);
- get_be32(pb); /* max bit rate */
- st->codec->bit_rate = get_be32(pb); /* bit rate */
- get_be32(pb); /* max packet size */
- get_be32(pb); /* avg packet size */
- start_time = get_be32(pb); /* start time */
- get_be32(pb); /* preroll */
- duration = get_be32(pb); /* duration */
+ st->id = avio_rb16(pb);
+ avio_rb32(pb); /* max bit rate */
+ st->codec->bit_rate = avio_rb32(pb); /* bit rate */
+ avio_rb32(pb); /* max packet size */
+ avio_rb32(pb); /* avg packet size */
+ start_time = avio_rb32(pb); /* start time */
+ avio_rb32(pb); /* preroll */
+ duration = avio_rb32(pb); /* duration */
st->start_time = start_time;
st->duration = duration;
get_str8(pb, buf, sizeof(buf)); /* desc */
@@ -462,45 +462,45 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_type = AVMEDIA_TYPE_DATA;
st->priv_data = ff_rm_alloc_rmstream();
if (ff_rm_read_mdpr_codecdata(s, s->pb, st, st->priv_data,
- get_be32(pb)) < 0)
+ avio_rb32(pb)) < 0)
return -1;
break;
case MKTAG('D', 'A', 'T', 'A'):
goto header_end;
default:
/* unknown tag: skip it */
- url_fskip(pb, tag_size - 10);
+ avio_seek(pb, tag_size - 10, SEEK_CUR);
break;
}
}
header_end:
- rm->nb_packets = get_be32(pb); /* number of packets */
+ rm->nb_packets = avio_rb32(pb); /* number of packets */
if (!rm->nb_packets && (flags & 4))
rm->nb_packets = 3600 * 25;
- get_be32(pb); /* next data header */
+ avio_rb32(pb); /* next data header */
if (!data_off)
data_off = url_ftell(pb) - 18;
if (indx_off && !url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_IGNIDX) &&
- url_fseek(pb, indx_off, SEEK_SET) >= 0) {
+ avio_seek(pb, indx_off, SEEK_SET) >= 0) {
rm_read_index(s);
- url_fseek(pb, data_off + 18, SEEK_SET);
+ avio_seek(pb, data_off + 18, SEEK_SET);
}
return 0;
}
-static int get_num(ByteIOContext *pb, int *len)
+static int get_num(AVIOContext *pb, int *len)
{
int n, n1;
- n = get_be16(pb);
+ n = avio_rb16(pb);
(*len)-=2;
n &= 0x7FFF;
if (n >= 0x4000) {
return n - 0x4000;
} else {
- n1 = get_be16(pb);
+ n1 = avio_rb16(pb);
(*len)-=2;
return (n << 16) | n1;
}
@@ -511,7 +511,7 @@ static int get_num(ByteIOContext *pb, int *len)
static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos){
RMDemuxContext *rm = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
uint32_t state=0xFFFFFFFF;
@@ -524,13 +524,13 @@ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_
*timestamp = AV_NOPTS_VALUE;
*flags= 0;
}else{
- state= (state<<8) + get_byte(pb);
+ state= (state<<8) + avio_r8(pb);
if(state == MKBETAG('I', 'N', 'D', 'X')){
int n_pkts, expected_len;
- len = get_be32(pb);
- url_fskip(pb, 2);
- n_pkts = get_be32(pb);
+ len = avio_rb32(pb);
+ avio_seek(pb, 2, SEEK_CUR);
+ n_pkts = avio_rb32(pb);
expected_len = 20 + n_pkts * 14;
if (len == 20)
/* some files don't add index entries to chunk size... */
@@ -553,10 +553,10 @@ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_
len=state - 12;
state= 0xFFFFFFFF;
- num = get_be16(pb);
- *timestamp = get_be32(pb);
- get_byte(pb); /* reserved */
- *flags = get_byte(pb); /* flags */
+ num = avio_rb16(pb);
+ *timestamp = avio_rb32(pb);
+ avio_r8(pb); /* reserved */
+ *flags = avio_r8(pb); /* flags */
}
for(i=0;inb_streams;i++) {
st = s->streams[i];
@@ -566,7 +566,7 @@ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_
if (i == s->nb_streams) {
skip:
/* skip packet if unknown number */
- url_fskip(pb, len);
+ avio_seek(pb, len, SEEK_CUR);
rm->remaining_len = 0;
continue;
}
@@ -577,23 +577,23 @@ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_
return -1;
}
-static int rm_assemble_video_frame(AVFormatContext *s, ByteIOContext *pb,
+static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb,
RMDemuxContext *rm, RMStream *vst,
AVPacket *pkt, int len, int *pseq)
{
int hdr, seq, pic_num, len2, pos;
int type;
- hdr = get_byte(pb); len--;
+ hdr = avio_r8(pb); len--;
type = hdr >> 6;
if(type != 3){ // not frame as a part of packet
- seq = get_byte(pb); len--;
+ seq = avio_r8(pb); len--;
}
if(type != 1){ // not whole frame
len2 = get_num(pb, &len);
pos = get_num(pb, &len);
- pic_num = get_byte(pb); len--;
+ pic_num = avio_r8(pb); len--;
}
if(len<0)
return -1;
@@ -609,7 +609,7 @@ static int rm_assemble_video_frame(AVFormatContext *s, ByteIOContext *pb,
pkt->data[0] = 0;
AV_WL32(pkt->data + 1, 1);
AV_WL32(pkt->data + 5, 0);
- get_buffer(pb, pkt->data + 9, len);
+ avio_read(pb, pkt->data + 9, len);
return 0;
}
//now we have to deal with single slice
@@ -635,7 +635,7 @@ static int rm_assemble_video_frame(AVFormatContext *s, ByteIOContext *pb,
AV_WL32(vst->pkt.data - 3 + 8*vst->cur_slice, vst->videobufpos - 8*vst->slices - 1);
if(vst->videobufpos + len > vst->videobufsize)
return 1;
- if (get_buffer(pb, vst->pkt.data + vst->videobufpos, len) != len)
+ if (avio_read(pb, vst->pkt.data + vst->videobufpos, len) != len)
return AVERROR(EIO);
vst->videobufpos += len;
rm->remaining_len-= len;
@@ -700,7 +700,7 @@ void ff_rm_reorder_sipr_data(uint8_t *buf, int sub_packet_h, int framesize)
}
int
-ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
+ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb,
AVStream *st, RMStream *ast, int len, AVPacket *pkt,
int *seq, int flags, int64_t timestamp)
{
@@ -730,15 +730,15 @@ ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
switch(st->codec->codec_id) {
case CODEC_ID_RA_288:
for (x = 0; x < h/2; x++)
- get_buffer(pb, ast->pkt.data+x*2*w+y*cfs, cfs);
+ avio_read(pb, ast->pkt.data+x*2*w+y*cfs, cfs);
break;
case CODEC_ID_ATRAC3:
case CODEC_ID_COOK:
for (x = 0; x < w/sps; x++)
- get_buffer(pb, ast->pkt.data+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
+ avio_read(pb, ast->pkt.data+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
break;
case CODEC_ID_SIPR:
- get_buffer(pb, ast->pkt.data + y * w, w);
+ avio_read(pb, ast->pkt.data + y * w, w);
break;
}
@@ -753,10 +753,10 @@ ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
} else if (st->codec->codec_id == CODEC_ID_AAC) {
int x;
rm->audio_stream_num = st->index;
- ast->sub_packet_cnt = (get_be16(pb) & 0xf0) >> 4;
+ ast->sub_packet_cnt = (avio_rb16(pb) & 0xf0) >> 4;
if (ast->sub_packet_cnt) {
for (x = 0; x < ast->sub_packet_cnt; x++)
- ast->sub_packet_lengths[x] = get_be16(pb);
+ ast->sub_packet_lengths[x] = avio_rb16(pb);
rm->audio_pkt_cnt = ast->sub_packet_cnt;
ast->audiotimestamp = timestamp;
} else
@@ -791,7 +791,7 @@ ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
}
int
-ff_rm_retrieve_cache (AVFormatContext *s, ByteIOContext *pb,
+ff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb,
AVStream *st, RMStream *ast, AVPacket *pkt)
{
RMDemuxContext *rm = s->priv_data;
@@ -904,7 +904,7 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
if(rm->old_format)
return AV_NOPTS_VALUE;
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
rm->remaining_len=0;
for(;;){
int seq=1;
@@ -916,9 +916,9 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
st = s->streams[stream_index2];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- h= get_byte(s->pb); len--;
+ h= avio_r8(s->pb); len--;
if(!(h & 0x40)){
- seq = get_byte(s->pb); len--;
+ seq = avio_r8(s->pb); len--;
}
}
@@ -929,7 +929,7 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
break;
}
- url_fskip(s->pb, len);
+ avio_seek(s->pb, len, SEEK_CUR);
}
*ppos = pos;
return dts;
diff --git a/mplayer/ffmpeg/libavformat/rmenc.c b/mplayer/ffmpeg/libavformat/rmenc.c
index 5670d95e..8a608861 100644
--- a/mplayer/ffmpeg/libavformat/rmenc.c
+++ b/mplayer/ffmpeg/libavformat/rmenc.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
+#include "avio_internal.h"
#include "rm.h"
typedef struct {
@@ -44,19 +45,19 @@ typedef struct {
#define BUFFER_DURATION 0
-static void put_str(ByteIOContext *s, const char *tag)
+static void put_str(AVIOContext *s, const char *tag)
{
- put_be16(s,strlen(tag));
+ avio_wb16(s,strlen(tag));
while (*tag) {
- put_byte(s, *tag++);
+ avio_w8(s, *tag++);
}
}
-static void put_str8(ByteIOContext *s, const char *tag)
+static void put_str8(AVIOContext *s, const char *tag)
{
- put_byte(s, strlen(tag));
+ avio_w8(s, strlen(tag));
while (*tag) {
- put_byte(s, *tag++);
+ avio_w8(s, *tag++);
}
}
@@ -64,7 +65,7 @@ static int rv10_write_header(AVFormatContext *ctx,
int data_size, int index_pos)
{
RMMuxContext *rm = ctx->priv_data;
- ByteIOContext *s = ctx->pb;
+ AVIOContext *s = ctx->pb;
StreamInfo *stream;
unsigned char *data_offset_ptr, *start_ptr;
const char *desc, *mimetype;
@@ -74,15 +75,15 @@ static int rv10_write_header(AVFormatContext *ctx,
start_ptr = s->buf_ptr;
- put_tag(s, ".RMF");
- put_be32(s,18); /* header size */
- put_be16(s,0);
- put_be32(s,0);
- put_be32(s,4 + ctx->nb_streams); /* num headers */
+ ffio_wfourcc(s, ".RMF");
+ avio_wb32(s,18); /* header size */
+ avio_wb16(s,0);
+ avio_wb32(s,0);
+ avio_wb32(s,4 + ctx->nb_streams); /* num headers */
- put_tag(s,"PROP");
- put_be32(s, 50);
- put_be16(s, 0);
+ ffio_wfourcc(s,"PROP");
+ avio_wb32(s, 50);
+ avio_wb16(s, 0);
packet_max_size = 0;
packet_total_size = 0;
nb_packets = 0;
@@ -100,37 +101,37 @@ static int rv10_write_header(AVFormatContext *ctx,
if (v > duration)
duration = v;
}
- put_be32(s, bit_rate); /* max bit rate */
- put_be32(s, bit_rate); /* avg bit rate */
- put_be32(s, packet_max_size); /* max packet size */
+ avio_wb32(s, bit_rate); /* max bit rate */
+ avio_wb32(s, bit_rate); /* avg bit rate */
+ avio_wb32(s, packet_max_size); /* max packet size */
if (nb_packets > 0)
packet_avg_size = packet_total_size / nb_packets;
else
packet_avg_size = 0;
- put_be32(s, packet_avg_size); /* avg packet size */
- put_be32(s, nb_packets); /* num packets */
- put_be32(s, duration); /* duration */
- put_be32(s, BUFFER_DURATION); /* preroll */
- put_be32(s, index_pos); /* index offset */
+ avio_wb32(s, packet_avg_size); /* avg packet size */
+ avio_wb32(s, nb_packets); /* num packets */
+ avio_wb32(s, duration); /* duration */
+ avio_wb32(s, BUFFER_DURATION); /* preroll */
+ avio_wb32(s, index_pos); /* index offset */
/* computation of data the data offset */
data_offset_ptr = s->buf_ptr;
- put_be32(s, 0); /* data offset : will be patched after */
- put_be16(s, ctx->nb_streams); /* num streams */
+ avio_wb32(s, 0); /* data offset : will be patched after */
+ avio_wb16(s, ctx->nb_streams); /* num streams */
flags = 1 | 2; /* save allowed & perfect play */
if (url_is_streamed(s))
flags |= 4; /* live broadcast */
- put_be16(s, flags);
+ avio_wb16(s, flags);
/* comments */
- put_tag(s,"CONT");
+ ffio_wfourcc(s,"CONT");
size = 4 * 2 + 10;
for(i=0; imetadata, ff_rm_metadata[i], NULL, 0);
if(tag) size += strlen(tag->value);
}
- put_be32(s,size);
- put_be16(s,0);
+ avio_wb32(s,size);
+ avio_wb16(s,0);
for(i=0; imetadata, ff_rm_metadata[i], NULL, 0);
put_str(s, tag ? tag->value : "");
@@ -151,31 +152,31 @@ static int rv10_write_header(AVFormatContext *ctx,
codec_data_size = 34;
}
- put_tag(s,"MDPR");
+ ffio_wfourcc(s,"MDPR");
size = 10 + 9 * 4 + strlen(desc) + strlen(mimetype) + codec_data_size;
- put_be32(s, size);
- put_be16(s, 0);
+ avio_wb32(s, size);
+ avio_wb16(s, 0);
- put_be16(s, i); /* stream number */
- put_be32(s, stream->bit_rate); /* max bit rate */
- put_be32(s, stream->bit_rate); /* avg bit rate */
- put_be32(s, stream->packet_max_size); /* max packet size */
+ avio_wb16(s, i); /* stream number */
+ avio_wb32(s, stream->bit_rate); /* max bit rate */
+ avio_wb32(s, stream->bit_rate); /* avg bit rate */
+ avio_wb32(s, stream->packet_max_size); /* max packet size */
if (stream->nb_packets > 0)
packet_avg_size = stream->packet_total_size /
stream->nb_packets;
else
packet_avg_size = 0;
- put_be32(s, packet_avg_size); /* avg packet size */
- put_be32(s, 0); /* start time */
- put_be32(s, BUFFER_DURATION); /* preroll */
+ avio_wb32(s, packet_avg_size); /* avg packet size */
+ avio_wb32(s, 0); /* start time */
+ avio_wb32(s, BUFFER_DURATION); /* preroll */
/* duration */
if (url_is_streamed(s) || !stream->total_frames)
- put_be32(s, (int)(3600 * 1000));
+ avio_wb32(s, (int)(3600 * 1000));
else
- put_be32(s, (int)(stream->total_frames * 1000 / stream->frame_rate));
+ avio_wb32(s, (int)(stream->total_frames * 1000 / stream->frame_rate));
put_str8(s, desc);
put_str8(s, mimetype);
- put_be32(s, codec_data_size);
+ avio_wb32(s, codec_data_size);
if (stream->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
int coded_frame_size, fscode, sample_rate;
@@ -183,13 +184,13 @@ static int rv10_write_header(AVFormatContext *ctx,
coded_frame_size = (stream->enc->bit_rate *
stream->enc->frame_size) / (8 * sample_rate);
/* audio codec info */
- put_tag(s, ".ra");
- put_byte(s, 0xfd);
- put_be32(s, 0x00040000); /* version */
- put_tag(s, ".ra4");
- put_be32(s, 0x01b53530); /* stream length */
- put_be16(s, 4); /* unknown */
- put_be32(s, 0x39); /* header size */
+ avio_write(s, ".ra", 3);
+ avio_w8(s, 0xfd);
+ avio_wb32(s, 0x00040000); /* version */
+ ffio_wfourcc(s, ".ra4");
+ avio_wb32(s, 0x01b53530); /* stream length */
+ avio_wb16(s, 4); /* unknown */
+ avio_wb32(s, 0x39); /* header size */
switch(sample_rate) {
case 48000:
@@ -208,56 +209,57 @@ static int rv10_write_header(AVFormatContext *ctx,
case 8000:
fscode = 3;
}
- put_be16(s, fscode); /* codec additional info, for AC-3, seems
+ avio_wb16(s, fscode); /* codec additional info, for AC-3, seems
to be a frequency code */
/* special hack to compensate rounding errors... */
if (coded_frame_size == 557)
coded_frame_size--;
- put_be32(s, coded_frame_size); /* frame length */
- put_be32(s, 0x51540); /* unknown */
- put_be32(s, 0x249f0); /* unknown */
- put_be32(s, 0x249f0); /* unknown */
- put_be16(s, 0x01);
+ avio_wb32(s, coded_frame_size); /* frame length */
+ avio_wb32(s, 0x51540); /* unknown */
+ avio_wb32(s, 0x249f0); /* unknown */
+ avio_wb32(s, 0x249f0); /* unknown */
+ avio_wb16(s, 0x01);
/* frame length : seems to be very important */
- put_be16(s, coded_frame_size);
- put_be32(s, 0); /* unknown */
- put_be16(s, stream->enc->sample_rate); /* sample rate */
- put_be32(s, 0x10); /* unknown */
- put_be16(s, stream->enc->channels);
+ avio_wb16(s, coded_frame_size);
+ avio_wb32(s, 0); /* unknown */
+ avio_wb16(s, stream->enc->sample_rate); /* sample rate */
+ avio_wb32(s, 0x10); /* unknown */
+ avio_wb16(s, stream->enc->channels);
put_str8(s, "Int0"); /* codec name */
if (stream->enc->codec_tag) {
- put_byte(s, 4); /* tag length */
- put_le32(s, stream->enc->codec_tag);
+ avio_w8(s, 4); /* tag length */
+ avio_wl32(s, stream->enc->codec_tag);
} else {
av_log(ctx, AV_LOG_ERROR, "Invalid codec tag\n");
return -1;
}
- put_be16(s, 0); /* title length */
- put_be16(s, 0); /* author length */
- put_be16(s, 0); /* copyright length */
- put_byte(s, 0); /* end of header */
+ avio_wb16(s, 0); /* title length */
+ avio_wb16(s, 0); /* author length */
+ avio_wb16(s, 0); /* copyright length */
+ avio_w8(s, 0); /* end of header */
} else {
/* video codec info */
- put_be32(s,34); /* size */
+ avio_wb32(s,34); /* size */
+ ffio_wfourcc(s, "VIDO");
if(stream->enc->codec_id == CODEC_ID_RV10)
- put_tag(s,"VIDORV10");
+ ffio_wfourcc(s,"RV10");
else
- put_tag(s,"VIDORV20");
- put_be16(s, stream->enc->width);
- put_be16(s, stream->enc->height);
- put_be16(s, (int) stream->frame_rate); /* frames per seconds ? */
- put_be32(s,0); /* unknown meaning */
- put_be16(s, (int) stream->frame_rate); /* unknown meaning */
- put_be32(s,0); /* unknown meaning */
- put_be16(s, 8); /* unknown meaning */
+ ffio_wfourcc(s,"RV20");
+ avio_wb16(s, stream->enc->width);
+ avio_wb16(s, stream->enc->height);
+ avio_wb16(s, (int) stream->frame_rate); /* frames per seconds ? */
+ avio_wb32(s,0); /* unknown meaning */
+ avio_wb16(s, (int) stream->frame_rate); /* unknown meaning */
+ avio_wb32(s,0); /* unknown meaning */
+ avio_wb16(s, 8); /* unknown meaning */
/* Seems to be the codec version: only use basic H263. The next
versions seems to add a diffential DC coding as in
MPEG... nothing new under the sun */
if(stream->enc->codec_id == CODEC_ID_RV10)
- put_be32(s,0x10000000);
+ avio_wb32(s,0x10000000);
else
- put_be32(s,0x20103001);
- //put_be32(s,0x10003000);
+ avio_wb32(s,0x20103001);
+ //avio_wb32(s,0x10003000);
}
}
@@ -270,12 +272,12 @@ static int rv10_write_header(AVFormatContext *ctx,
data_offset_ptr[3] = data_pos;
/* data stream */
- put_tag(s,"DATA");
- put_be32(s,data_size + 10 + 8);
- put_be16(s,0);
+ ffio_wfourcc(s, "DATA");
+ avio_wb32(s,data_size + 10 + 8);
+ avio_wb16(s,0);
- put_be32(s, nb_packets); /* number of packets */
- put_be32(s,0); /* next data header */
+ avio_wb32(s, nb_packets); /* number of packets */
+ avio_wb32(s,0); /* next data header */
return 0;
}
@@ -283,20 +285,20 @@ static void write_packet_header(AVFormatContext *ctx, StreamInfo *stream,
int length, int key_frame)
{
int timestamp;
- ByteIOContext *s = ctx->pb;
+ AVIOContext *s = ctx->pb;
stream->nb_packets++;
stream->packet_total_size += length;
if (length > stream->packet_max_size)
stream->packet_max_size = length;
- put_be16(s,0); /* version */
- put_be16(s,length + 12);
- put_be16(s, stream->num); /* stream number */
+ avio_wb16(s,0); /* version */
+ avio_wb16(s,length + 12);
+ avio_wb16(s, stream->num); /* stream number */
timestamp = (1000 * (float)stream->nb_frames) / stream->frame_rate;
- put_be32(s, timestamp); /* timestamp */
- put_byte(s, 0); /* reserved */
- put_byte(s, key_frame ? 2 : 0); /* flags */
+ avio_wb32(s, timestamp); /* timestamp */
+ avio_w8(s, 0); /* reserved */
+ avio_w8(s, key_frame ? 2 : 0); /* flags */
}
static int rm_write_header(AVFormatContext *s)
@@ -347,7 +349,7 @@ static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int
{
uint8_t *buf1;
RMMuxContext *rm = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
StreamInfo *stream = rm->audio_stream;
int i;
@@ -362,9 +364,9 @@ static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int
buf1[i] = buf[i+1];
buf1[i+1] = buf[i];
}
- put_buffer(pb, buf1, size);
+ avio_write(pb, buf1, size);
} else {
- put_buffer(pb, buf, size);
+ avio_write(pb, buf, size);
}
put_flush_packet(pb);
stream->nb_frames++;
@@ -375,7 +377,7 @@ static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int
static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int flags)
{
RMMuxContext *rm = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
StreamInfo *stream = rm->video_stream;
int key_frame = !!(flags & AV_PKT_FLAG_KEY);
@@ -386,31 +388,31 @@ static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int
#if 1
write_packet_header(s, stream, size + 7 + (size >= 0x4000)*4, key_frame);
/* bit 7: '1' if final packet of a frame converted in several packets */
- put_byte(pb, 0x81);
+ avio_w8(pb, 0x81);
/* bit 7: '1' if I frame. bits 6..0 : sequence number in current
frame starting from 1 */
if (key_frame) {
- put_byte(pb, 0x81);
+ avio_w8(pb, 0x81);
} else {
- put_byte(pb, 0x01);
+ avio_w8(pb, 0x01);
}
if(size >= 0x4000){
- put_be32(pb, size); /* total frame size */
- put_be32(pb, size); /* offset from the start or the end */
+ avio_wb32(pb, size); /* total frame size */
+ avio_wb32(pb, size); /* offset from the start or the end */
}else{
- put_be16(pb, 0x4000 | size); /* total frame size */
- put_be16(pb, 0x4000 | size); /* offset from the start or the end */
+ avio_wb16(pb, 0x4000 | size); /* total frame size */
+ avio_wb16(pb, 0x4000 | size); /* offset from the start or the end */
}
#else
/* full frame */
write_packet_header(s, size + 6);
- put_byte(pb, 0xc0);
- put_be16(pb, 0x4000 + size); /* total frame size */
- put_be16(pb, 0x4000 + packet_number * 126); /* position in stream */
+ avio_w8(pb, 0xc0);
+ avio_wb16(pb, 0x4000 + size); /* total frame size */
+ avio_wb16(pb, 0x4000 + packet_number * 126); /* position in stream */
#endif
- put_byte(pb, stream->nb_frames & 0xff);
+ avio_w8(pb, stream->nb_frames & 0xff);
- put_buffer(pb, buf, size);
+ avio_write(pb, buf, size);
put_flush_packet(pb);
stream->nb_frames++;
@@ -430,27 +432,27 @@ static int rm_write_trailer(AVFormatContext *s)
{
RMMuxContext *rm = s->priv_data;
int data_size, index_pos, i;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
if (!url_is_streamed(s->pb)) {
/* end of file: finish to write header */
- index_pos = url_fseek(pb, 0, SEEK_CUR);
+ index_pos = avio_seek(pb, 0, SEEK_CUR);
data_size = index_pos - rm->data_pos;
/* FIXME: write index */
/* undocumented end header */
- put_be32(pb, 0);
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
- url_fseek(pb, 0, SEEK_SET);
+ avio_seek(pb, 0, SEEK_SET);
for(i=0;inb_streams;i++)
rm->streams[i].total_frames = rm->streams[i].nb_frames;
rv10_write_header(s, data_size, 0);
} else {
/* undocumented end header */
- put_be32(pb, 0);
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
}
put_flush_packet(pb);
return 0;
diff --git a/mplayer/ffmpeg/libavformat/rpl.c b/mplayer/ffmpeg/libavformat/rpl.c
index 241b541b..9702fc70 100644
--- a/mplayer/ffmpeg/libavformat/rpl.c
+++ b/mplayer/ffmpeg/libavformat/rpl.c
@@ -47,11 +47,11 @@ typedef struct RPLContext {
uint32_t frame_in_part;
} RPLContext;
-static int read_line(ByteIOContext * pb, char* line, int bufsize)
+static int read_line(AVIOContext * pb, char* line, int bufsize)
{
int i;
for (i = 0; i < bufsize - 1; i++) {
- int b = get_byte(pb);
+ int b = avio_r8(pb);
if (b == 0)
break;
if (b == '\n') {
@@ -76,7 +76,7 @@ static int32_t read_int(const char* line, const char** endptr, int* error)
return result;
}
-static int32_t read_line_and_int(ByteIOContext * pb, int* error)
+static int32_t read_line_and_int(AVIOContext * pb, int* error)
{
char line[RPL_LINE_LENGTH];
const char *endptr;
@@ -110,7 +110,7 @@ static AVRational read_fps(const char* line, int* error)
static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
RPLContext *rpl = s->priv_data;
AVStream *vst = NULL, *ast = NULL;
int total_audio_size;
@@ -250,7 +250,7 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap)
error |= read_line(pb, line, sizeof(line)); // offset to key frame list
// Read the index
- url_fseek(pb, chunk_catalog_offset, SEEK_SET);
+ avio_seek(pb, chunk_catalog_offset, SEEK_SET);
total_audio_size = 0;
for (i = 0; i < number_of_chunks; i++) {
int64_t offset, video_size, audio_size;
@@ -274,7 +274,7 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
{
RPLContext *rpl = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream* stream;
AVIndexEntry* index_entry;
uint32_t ret;
@@ -292,7 +292,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
index_entry = &stream->index_entries[rpl->chunk_number];
if (rpl->frame_in_part == 0)
- if (url_fseek(pb, index_entry->pos, SEEK_SET) < 0)
+ if (avio_seek(pb, index_entry->pos, SEEK_SET) < 0)
return AVERROR(EIO);
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
@@ -301,9 +301,9 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
// multiple frames per chunk in Escape 124 samples.
uint32_t frame_size, frame_flags;
- frame_flags = get_le32(pb);
- frame_size = get_le32(pb);
- if (url_fseek(pb, -8, SEEK_CUR) < 0)
+ frame_flags = avio_rl32(pb);
+ frame_size = avio_rl32(pb);
+ if (avio_seek(pb, -8, SEEK_CUR) < 0)
return AVERROR(EIO);
ret = av_get_packet(pb, pkt, frame_size);
diff --git a/mplayer/ffmpeg/libavformat/rsodec.c b/mplayer/ffmpeg/libavformat/rsodec.c
index 698f82ed..a34be80c 100644
--- a/mplayer/ffmpeg/libavformat/rsodec.c
+++ b/mplayer/ffmpeg/libavformat/rsodec.c
@@ -29,16 +29,16 @@
static int rso_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int id, rate, bps;
unsigned int size;
enum CodecID codec;
AVStream *st;
- id = get_be16(pb);
- size = get_be16(pb);
- rate = get_be16(pb);
- get_be16(pb); /* play mode ? (0x0000 = don't loop) */
+ id = avio_rb16(pb);
+ size = avio_rb16(pb);
+ rate = avio_rb16(pb);
+ avio_rb16(pb); /* play mode ? (0x0000 = don't loop) */
codec = ff_codec_get_id(ff_codec_rso_tags, id);
diff --git a/mplayer/ffmpeg/libavformat/rsoenc.c b/mplayer/ffmpeg/libavformat/rsoenc.c
index 7b138986..c776a1ac 100644
--- a/mplayer/ffmpeg/libavformat/rsoenc.c
+++ b/mplayer/ffmpeg/libavformat/rsoenc.c
@@ -27,7 +27,7 @@
static int rso_write_header(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
if (!enc->codec_tag)
@@ -55,10 +55,10 @@ static int rso_write_header(AVFormatContext *s)
}
/* format header */
- put_be16(pb, enc->codec_tag); /* codec ID */
- put_be16(pb, 0); /* data size, will be written at EOF */
- put_be16(pb, enc->sample_rate);
- put_be16(pb, 0x0000); /* play mode ? (0x0000 = don't loop) */
+ avio_wb16(pb, enc->codec_tag); /* codec ID */
+ avio_wb16(pb, 0); /* data size, will be written at EOF */
+ avio_wb16(pb, enc->sample_rate);
+ avio_wb16(pb, 0x0000); /* play mode ? (0x0000 = don't loop) */
put_flush_packet(pb);
@@ -67,13 +67,13 @@ static int rso_write_header(AVFormatContext *s)
static int rso_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
return 0;
}
static int rso_write_trailer(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t file_size;
uint16_t coded_file_size;
@@ -91,9 +91,9 @@ static int rso_write_trailer(AVFormatContext *s)
}
/* update file size */
- url_fseek(pb, 2, SEEK_SET);
- put_be16(pb, coded_file_size);
- url_fseek(pb, file_size, SEEK_SET);
+ avio_seek(pb, 2, SEEK_SET);
+ avio_wb16(pb, coded_file_size);
+ avio_seek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
diff --git a/mplayer/ffmpeg/libavformat/rtmpproto.c b/mplayer/ffmpeg/libavformat/rtmpproto.c
index 3ad49d62..748aab33 100644
--- a/mplayer/ffmpeg/libavformat/rtmpproto.c
+++ b/mplayer/ffmpeg/libavformat/rtmpproto.c
@@ -923,9 +923,9 @@ static int rtmp_read(URLContext *s, uint8_t *buf, int size)
return orig_size;
}
-static int rtmp_write(URLContext *h, const uint8_t *buf, int size)
+static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
{
- RTMPContext *rt = h->priv_data;
+ RTMPContext *rt = s->priv_data;
int size_temp = size;
int pktsize, pkttype;
uint32_t ts;
diff --git a/mplayer/ffmpeg/libavformat/rtpdec.c b/mplayer/ffmpeg/libavformat/rtpdec.c
index c81ba1cd..b4b8ffcd 100644
--- a/mplayer/ffmpeg/libavformat/rtpdec.c
+++ b/mplayer/ffmpeg/libavformat/rtpdec.c
@@ -237,7 +237,7 @@ static void rtcp_update_jitter(RTPStatistics *s, uint32_t sent_timestamp, uint32
int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
{
- ByteIOContext *pb;
+ AVIOContext *pb;
uint8_t *buf;
int len;
int rtcp_bytes;
@@ -268,12 +268,12 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
return -1;
// Receiver Report
- put_byte(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
- put_byte(pb, RTCP_RR);
- put_be16(pb, 7); /* length in words - 1 */
+ avio_w8(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
+ avio_w8(pb, RTCP_RR);
+ avio_wb16(pb, 7); /* length in words - 1 */
// our own SSRC: we use the server's SSRC + 1 to avoid conflicts
- put_be32(pb, s->ssrc + 1);
- put_be32(pb, s->ssrc); // server SSRC
+ avio_wb32(pb, s->ssrc + 1);
+ avio_wb32(pb, s->ssrc); // server SSRC
// some placeholders we should really fill...
// RFC 1889/p64
extended_max= stats->cycles + stats->max_seq;
@@ -290,34 +290,34 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
fraction= (fraction<<24) | lost;
- put_be32(pb, fraction); /* 8 bits of fraction, 24 bits of total packets lost */
- put_be32(pb, extended_max); /* max sequence received */
- put_be32(pb, stats->jitter>>4); /* jitter */
+ avio_wb32(pb, fraction); /* 8 bits of fraction, 24 bits of total packets lost */
+ avio_wb32(pb, extended_max); /* max sequence received */
+ avio_wb32(pb, stats->jitter>>4); /* jitter */
if(s->last_rtcp_ntp_time==AV_NOPTS_VALUE)
{
- put_be32(pb, 0); /* last SR timestamp */
- put_be32(pb, 0); /* delay since last SR */
+ avio_wb32(pb, 0); /* last SR timestamp */
+ avio_wb32(pb, 0); /* delay since last SR */
} else {
uint32_t middle_32_bits= s->last_rtcp_ntp_time>>16; // this is valid, right? do we need to handle 64 bit values special?
uint32_t delay_since_last= ntp_time - s->last_rtcp_ntp_time;
- put_be32(pb, middle_32_bits); /* last SR timestamp */
- put_be32(pb, delay_since_last); /* delay since last SR */
+ avio_wb32(pb, middle_32_bits); /* last SR timestamp */
+ avio_wb32(pb, delay_since_last); /* delay since last SR */
}
// CNAME
- put_byte(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
- put_byte(pb, RTCP_SDES);
+ avio_w8(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
+ avio_w8(pb, RTCP_SDES);
len = strlen(s->hostname);
- put_be16(pb, (6 + len + 3) / 4); /* length in words - 1 */
- put_be32(pb, s->ssrc);
- put_byte(pb, 0x01);
- put_byte(pb, len);
- put_buffer(pb, s->hostname, len);
+ avio_wb16(pb, (6 + len + 3) / 4); /* length in words - 1 */
+ avio_wb32(pb, s->ssrc);
+ avio_w8(pb, 0x01);
+ avio_w8(pb, len);
+ avio_write(pb, s->hostname, len);
// padding
for (len = (6 + len) % 4; len % 4; len++) {
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
put_flush_packet(pb);
@@ -334,7 +334,7 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
void rtp_send_punch_packets(URLContext* rtp_handle)
{
- ByteIOContext *pb;
+ AVIOContext *pb;
uint8_t *buf;
int len;
@@ -342,11 +342,11 @@ void rtp_send_punch_packets(URLContext* rtp_handle)
if (url_open_dyn_buf(&pb) < 0)
return;
- put_byte(pb, (RTP_VERSION << 6));
- put_byte(pb, 0); /* Payload type */
- put_be16(pb, 0); /* Seq */
- put_be32(pb, 0); /* Timestamp */
- put_be32(pb, 0); /* SSRC */
+ avio_w8(pb, (RTP_VERSION << 6));
+ avio_w8(pb, 0); /* Payload type */
+ avio_wb16(pb, 0); /* Seq */
+ avio_wb32(pb, 0); /* Timestamp */
+ avio_wb32(pb, 0); /* SSRC */
put_flush_packet(pb);
len = url_close_dyn_buf(pb, &buf);
@@ -358,10 +358,10 @@ void rtp_send_punch_packets(URLContext* rtp_handle)
if (url_open_dyn_buf(&pb) < 0)
return;
- put_byte(pb, (RTP_VERSION << 6));
- put_byte(pb, RTCP_RR); /* receiver report */
- put_be16(pb, 1); /* length in words - 1 */
- put_be32(pb, 0); /* our own SSRC */
+ avio_w8(pb, (RTP_VERSION << 6));
+ avio_w8(pb, RTCP_RR); /* receiver report */
+ avio_wb16(pb, 1); /* length in words - 1 */
+ avio_wb32(pb, 0); /* our own SSRC */
put_flush_packet(pb);
len = url_close_dyn_buf(pb, &buf);
diff --git a/mplayer/ffmpeg/libavformat/rtpdec_asf.c b/mplayer/ffmpeg/libavformat/rtpdec_asf.c
index db09f8f3..7d0bf672 100644
--- a/mplayer/ffmpeg/libavformat/rtpdec_asf.c
+++ b/mplayer/ffmpeg/libavformat/rtpdec_asf.c
@@ -32,6 +32,7 @@
#include "rtpdec_formats.h"
#include "rtsp.h"
#include "asf.h"
+#include "avio_internal.h"
/**
* From MSDN 2.2.1.4, we learn that ASF data packets over RTP should not
@@ -72,7 +73,7 @@ static int rtp_asf_fix_header(uint8_t *buf, int len)
}
/**
- * The following code is basically a buffered ByteIOContext,
+ * The following code is basically a buffered AVIOContext,
* with the added benefit of returning -EAGAIN (instead of 0)
* on packet boundaries, such that the ASF demuxer can return
* safely and resume business at the next packet.
@@ -82,9 +83,9 @@ static int packetizer_read(void *opaque, uint8_t *buf, int buf_size)
return AVERROR(EAGAIN);
}
-static void init_packetizer(ByteIOContext *pb, uint8_t *buf, int len)
+static void init_packetizer(AVIOContext *pb, uint8_t *buf, int len)
{
- init_put_byte(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL);
+ ffio_init_context(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL);
/* this "fills" the buffer with its current content */
pb->pos = len;
@@ -95,7 +96,7 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
{
int ret = 0;
if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) {
- ByteIOContext pb;
+ AVIOContext pb;
RTSPState *rt = s->priv_data;
int len = strlen(p) * 6 / 8;
char *buf = av_mallocz(len);
@@ -147,7 +148,7 @@ static int asfrtp_parse_sdp_line(AVFormatContext *s, int stream_index,
}
struct PayloadContext {
- ByteIOContext *pktbuf, pb;
+ AVIOContext *pktbuf, pb;
uint8_t *buf;
};
@@ -161,7 +162,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
uint32_t *timestamp,
const uint8_t *buf, int len, int flags)
{
- ByteIOContext *pb = &asf->pb;
+ AVIOContext *pb = &asf->pb;
int res, mflags, len_off;
RTSPState *rt = s->priv_data;
@@ -176,21 +177,21 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
av_freep(&asf->buf);
- init_put_byte(pb, buf, len, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(pb, buf, len, 0, NULL, NULL, NULL, NULL);
while (url_ftell(pb) + 4 < len) {
int start_off = url_ftell(pb);
- mflags = get_byte(pb);
+ mflags = avio_r8(pb);
if (mflags & 0x80)
flags |= RTP_FLAG_KEY;
- len_off = get_be24(pb);
+ len_off = avio_rb24(pb);
if (mflags & 0x20) /**< relative timestamp */
- url_fskip(pb, 4);
+ avio_seek(pb, 4, SEEK_CUR);
if (mflags & 0x10) /**< has duration */
- url_fskip(pb, 4);
+ avio_seek(pb, 4, SEEK_CUR);
if (mflags & 0x8) /**< has location ID */
- url_fskip(pb, 4);
+ avio_seek(pb, 4, SEEK_CUR);
off = url_ftell(pb);
if (!(mflags & 0x40)) {
@@ -212,8 +213,8 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
if (!asf->pktbuf)
return AVERROR(EIO);
- put_buffer(asf->pktbuf, buf + off, len - off);
- url_fskip(pb, len - off);
+ avio_write(asf->pktbuf, buf + off, len - off);
+ avio_seek(pb, len - off, SEEK_CUR);
if (!(flags & RTP_FLAG_MARKER))
return -1;
out_len = url_close_dyn_buf(asf->pktbuf, &asf->buf);
@@ -233,7 +234,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
asf->buf = av_realloc(asf->buf, out_len);
memcpy(asf->buf + prev_len, buf + off,
FFMIN(cur_len, len - off));
- url_fskip(pb, cur_len);
+ avio_seek(pb, cur_len, SEEK_CUR);
}
}
@@ -288,7 +289,7 @@ RTPDynamicProtocolHandler ff_ms_rtp_ ## n ## _handler = { \
.open = asfrtp_new_context, \
.close = asfrtp_free_context, \
.parse_packet = asfrtp_parse_packet, \
-};
+}
RTP_ASF_HANDLER(asf_pfv, "x-asf-pf", AVMEDIA_TYPE_VIDEO);
RTP_ASF_HANDLER(asf_pfa, "x-asf-pf", AVMEDIA_TYPE_AUDIO);
diff --git a/mplayer/ffmpeg/libavformat/rtpdec_latm.c b/mplayer/ffmpeg/libavformat/rtpdec_latm.c
index 8ed42a7a..c6d865a6 100644
--- a/mplayer/ffmpeg/libavformat/rtpdec_latm.c
+++ b/mplayer/ffmpeg/libavformat/rtpdec_latm.c
@@ -26,7 +26,7 @@
#include
struct PayloadContext {
- ByteIOContext *dyn_buf;
+ AVIOContext *dyn_buf;
uint8_t *buf;
int pos, len;
uint32_t timestamp;
@@ -68,7 +68,7 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data,
if ((ret = url_open_dyn_buf(&data->dyn_buf)) < 0)
return ret;
}
- put_buffer(data->dyn_buf, buf, len);
+ avio_write(data->dyn_buf, buf, len);
if (!(flags & RTP_FLAG_MARKER))
return AVERROR(EAGAIN);
diff --git a/mplayer/ffmpeg/libavformat/rtpdec_mpeg4.c b/mplayer/ffmpeg/libavformat/rtpdec_mpeg4.c
index 137dbd26..5498d1c4 100644
--- a/mplayer/ffmpeg/libavformat/rtpdec_mpeg4.c
+++ b/mplayer/ffmpeg/libavformat/rtpdec_mpeg4.c
@@ -111,8 +111,7 @@ static int parse_fmtp_config(AVCodecContext * codec, char *value)
{
/* decode the hexa encoded parameter */
int len = ff_hex_to_data(NULL, value);
- if (codec->extradata)
- av_free(codec->extradata);
+ av_free(codec->extradata);
codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (!codec->extradata)
return AVERROR(ENOMEM);
diff --git a/mplayer/ffmpeg/libavformat/rtpdec_qt.c b/mplayer/ffmpeg/libavformat/rtpdec_qt.c
index 5cca0760..5cf5223c 100644
--- a/mplayer/ffmpeg/libavformat/rtpdec_qt.c
+++ b/mplayer/ffmpeg/libavformat/rtpdec_qt.c
@@ -26,6 +26,7 @@
*/
#include "avformat.h"
+#include "avio_internal.h"
#include "rtp.h"
#include "rtpdec.h"
#include "isom.h"
@@ -42,7 +43,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt,
uint32_t *timestamp, const uint8_t *buf,
int len, int flags)
{
- ByteIOContext pb;
+ AVIOContext pb;
GetBitContext gb;
int packing_scheme, has_payload_desc, has_packet_info, alen,
has_marker_bit = flags & RTP_FLAG_MARKER;
@@ -69,7 +70,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt,
* http://developer.apple.com/quicktime/icefloe/dispatch026.html
*/
init_get_bits(&gb, buf, len << 3);
- init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
if (len < 4)
return AVERROR_INVALIDDATA;
@@ -102,21 +103,21 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt,
skip_bits(&gb, 12); // reserved
data_len = get_bits(&gb, 16);
- url_fseek(&pb, pos + 4, SEEK_SET);
- tag = get_le32(&pb);
- if ((st->codec->codec_type == CODEC_TYPE_VIDEO &&
+ avio_seek(&pb, pos + 4, SEEK_SET);
+ tag = avio_rl32(&pb);
+ if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
tag != MKTAG('v','i','d','e')) ||
- (st->codec->codec_type == CODEC_TYPE_AUDIO &&
+ (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
tag != MKTAG('s','o','u','n')))
return AVERROR_INVALIDDATA;
- av_set_pts_info(st, 32, 1, get_be32(&pb));
+ av_set_pts_info(st, 32, 1, avio_rb32(&pb));
if (pos + data_len > len)
return AVERROR_INVALIDDATA;
/* TLVs */
while (url_ftell(&pb) + 4 < pos + data_len) {
- int tlv_len = get_be16(&pb);
- tag = get_le16(&pb);
+ int tlv_len = avio_rb16(&pb);
+ tag = avio_rl16(&pb);
if (url_ftell(&pb) + tlv_len > pos + data_len)
return AVERROR_INVALIDDATA;
@@ -148,15 +149,15 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt,
break;
}
default:
- url_fskip(&pb, tlv_len);
+ avio_seek(&pb, tlv_len, SEEK_CUR);
break;
}
}
/* 32-bit alignment */
- url_fskip(&pb, ((url_ftell(&pb) + 3) & ~3) - url_ftell(&pb));
+ avio_seek(&pb, ((url_ftell(&pb) + 3) & ~3) - url_ftell(&pb), SEEK_CUR);
} else
- url_fseek(&pb, 4, SEEK_SET);
+ avio_seek(&pb, 4, SEEK_SET);
if (has_packet_info) {
av_log_missing_feature(s, "RTP-X-QT with packet specific info", 1);
@@ -246,9 +247,9 @@ RTPDynamicProtocolHandler ff_ ## m ## _rtp_ ## n ## _handler = { \
.open = qt_rtp_new, \
.close = qt_rtp_free, \
.parse_packet = qt_rtp_parse_packet, \
-};
+}
-RTP_QT_HANDLER(qt, vid, "X-QT", CODEC_TYPE_VIDEO);
-RTP_QT_HANDLER(qt, aud, "X-QT", CODEC_TYPE_AUDIO);
-RTP_QT_HANDLER(quicktime, vid, "X-QUICKTIME", CODEC_TYPE_VIDEO);
-RTP_QT_HANDLER(quicktime, aud, "X-QUICKTIME", CODEC_TYPE_AUDIO);
+RTP_QT_HANDLER(qt, vid, "X-QT", AVMEDIA_TYPE_VIDEO);
+RTP_QT_HANDLER(qt, aud, "X-QT", AVMEDIA_TYPE_AUDIO);
+RTP_QT_HANDLER(quicktime, vid, "X-QUICKTIME", AVMEDIA_TYPE_VIDEO);
+RTP_QT_HANDLER(quicktime, aud, "X-QUICKTIME", AVMEDIA_TYPE_AUDIO);
diff --git a/mplayer/ffmpeg/libavformat/rtpdec_svq3.c b/mplayer/ffmpeg/libavformat/rtpdec_svq3.c
index 79a57758..a4fad1cc 100644
--- a/mplayer/ffmpeg/libavformat/rtpdec_svq3.c
+++ b/mplayer/ffmpeg/libavformat/rtpdec_svq3.c
@@ -33,7 +33,7 @@
#include "rtpdec_formats.h"
struct PayloadContext {
- ByteIOContext *pktbuf;
+ AVIOContext *pktbuf;
int64_t timestamp;
};
@@ -94,7 +94,7 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv,
if (!sv->pktbuf)
return AVERROR_INVALIDDATA;
- put_buffer(sv->pktbuf, buf, len);
+ avio_write(sv->pktbuf, buf, len);
if (end_packet) {
av_init_packet(pkt);
diff --git a/mplayer/ffmpeg/libavformat/rtpdec_vp8.c b/mplayer/ffmpeg/libavformat/rtpdec_vp8.c
index b18017b2..3b1ee137 100644
--- a/mplayer/ffmpeg/libavformat/rtpdec_vp8.c
+++ b/mplayer/ffmpeg/libavformat/rtpdec_vp8.c
@@ -31,7 +31,7 @@
#include "rtpdec_formats.h"
struct PayloadContext {
- ByteIOContext *data;
+ AVIOContext *data;
uint32_t timestamp;
int is_keyframe;
};
@@ -111,7 +111,7 @@ static int vp8_handle_packet(AVFormatContext *ctx,
}
}
- put_buffer(vp8->data, buf, au_len);
+ avio_write(vp8->data, buf, au_len);
buf += au_len;
len -= au_len;
}
diff --git a/mplayer/ffmpeg/libavformat/rtpdec_xiph.c b/mplayer/ffmpeg/libavformat/rtpdec_xiph.c
index fe17a42b..37e57f50 100644
--- a/mplayer/ffmpeg/libavformat/rtpdec_xiph.c
+++ b/mplayer/ffmpeg/libavformat/rtpdec_xiph.c
@@ -42,7 +42,7 @@
struct PayloadContext {
unsigned ident; ///< 24-bit stream configuration identifier
uint32_t timestamp;
- ByteIOContext* fragment; ///< buffer for split payloads
+ AVIOContext* fragment; ///< buffer for split payloads
uint8_t *split_buf;
int split_pos, split_buf_len, split_buf_size;
int split_pkts;
@@ -179,7 +179,7 @@ static int xiph_handle_packet(AVFormatContext * ctx,
if((res = url_open_dyn_buf(&data->fragment)) < 0)
return res;
- put_buffer(data->fragment, buf, pkt_len);
+ avio_write(data->fragment, buf, pkt_len);
data->timestamp = *timestamp;
} else {
@@ -198,7 +198,7 @@ static int xiph_handle_packet(AVFormatContext * ctx,
}
// copy data to fragment buffer
- put_buffer(data->fragment, buf, pkt_len);
+ avio_write(data->fragment, buf, pkt_len);
if (fragmented == 3) {
// end of xiph data packet
diff --git a/mplayer/ffmpeg/libavformat/rtpenc.c b/mplayer/ffmpeg/libavformat/rtpenc.c
index 22e68bac..b32a9a40 100644
--- a/mplayer/ffmpeg/libavformat/rtpenc.c
+++ b/mplayer/ffmpeg/libavformat/rtpenc.c
@@ -197,15 +197,15 @@ static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time)
s->last_rtcp_ntp_time = ntp_time;
rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, (AVRational){1, 1000000},
s1->streams[0]->time_base) + s->base_timestamp;
- put_byte(s1->pb, (RTP_VERSION << 6));
- put_byte(s1->pb, RTCP_SR);
- put_be16(s1->pb, 6); /* length in words - 1 */
- put_be32(s1->pb, s->ssrc);
- put_be32(s1->pb, ntp_time / 1000000);
- put_be32(s1->pb, ((ntp_time % 1000000) << 32) / 1000000);
- put_be32(s1->pb, rtp_ts);
- put_be32(s1->pb, s->packet_count);
- put_be32(s1->pb, s->octet_count);
+ avio_w8(s1->pb, (RTP_VERSION << 6));
+ avio_w8(s1->pb, RTCP_SR);
+ avio_wb16(s1->pb, 6); /* length in words - 1 */
+ avio_wb32(s1->pb, s->ssrc);
+ avio_wb32(s1->pb, ntp_time / 1000000);
+ avio_wb32(s1->pb, ((ntp_time % 1000000) << 32) / 1000000);
+ avio_wb32(s1->pb, rtp_ts);
+ avio_wb32(s1->pb, s->packet_count);
+ avio_wb32(s1->pb, s->octet_count);
put_flush_packet(s1->pb);
}
@@ -218,13 +218,13 @@ void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m)
av_dlog(s1, "rtp_send_data size=%d\n", len);
/* build the RTP header */
- put_byte(s1->pb, (RTP_VERSION << 6));
- put_byte(s1->pb, (s->payload_type & 0x7f) | ((m & 0x01) << 7));
- put_be16(s1->pb, s->seq);
- put_be32(s1->pb, s->timestamp);
- put_be32(s1->pb, s->ssrc);
+ avio_w8(s1->pb, (RTP_VERSION << 6));
+ avio_w8(s1->pb, (s->payload_type & 0x7f) | ((m & 0x01) << 7));
+ avio_wb16(s1->pb, s->seq);
+ avio_wb32(s1->pb, s->timestamp);
+ avio_wb32(s1->pb, s->ssrc);
- put_buffer(s1->pb, buf1, len);
+ avio_write(s1->pb, buf1, len);
put_flush_packet(s1->pb);
s->seq++;
diff --git a/mplayer/ffmpeg/libavformat/rtpenc_chain.c b/mplayer/ffmpeg/libavformat/rtpenc_chain.c
index 10d9df20..84611e69 100644
--- a/mplayer/ffmpeg/libavformat/rtpenc_chain.c
+++ b/mplayer/ffmpeg/libavformat/rtpenc_chain.c
@@ -50,11 +50,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
/* Set the synchronized start time. */
rtpctx->start_time_realtime = s->start_time_realtime;
- /* Remove the local codec, link to the original codec
- * context instead, to give the rtp muxer access to
- * codec parameters. */
- av_free(rtpctx->streams[0]->codec);
- rtpctx->streams[0]->codec = st->codec;
+ avcodec_copy_context(rtpctx->streams[0]->codec, st->codec);
if (handle) {
url_fdopen(&rtpctx->pb, handle);
@@ -64,19 +60,16 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
if (ret) {
if (handle) {
- url_fclose(rtpctx->pb);
+ avio_close(rtpctx->pb);
} else {
uint8_t *ptr;
url_close_dyn_buf(rtpctx->pb, &ptr);
av_free(ptr);
}
- av_free(rtpctx->streams[0]);
- av_free(rtpctx);
+ avformat_free_context(rtpctx);
return NULL;
}
- /* Copy the RTP AVStream timebase back to the original AVStream */
- st->time_base = rtpctx->streams[0]->time_base;
return rtpctx;
}
diff --git a/mplayer/ffmpeg/libavformat/rtpproto.c b/mplayer/ffmpeg/libavformat/rtpproto.c
index aa2cc377..269b1b27 100644
--- a/mplayer/ffmpeg/libavformat/rtpproto.c
+++ b/mplayer/ffmpeg/libavformat/rtpproto.c
@@ -24,6 +24,7 @@
* RTP protocol
*/
+#include "libavutil/parseutils.h"
#include "libavutil/avstring.h"
#include "avformat.h"
#include "rtpdec.h"
@@ -161,25 +162,25 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
p = strchr(uri, '?');
if (p) {
- if (find_info_tag(buf, sizeof(buf), "ttl", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
ttl = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "rtcpport", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "rtcpport", p)) {
rtcp_port = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "localport", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
local_rtp_port = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "localrtpport", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "localrtpport", p)) {
local_rtp_port = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "localrtcpport", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "localrtcpport", p)) {
local_rtcp_port = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
max_packet_size = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "connect", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
connect = strtol(buf, NULL, 10);
}
}
@@ -230,8 +231,8 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
len = recvfrom (s->rtp_fd, buf, size, 0,
(struct sockaddr *)&from, &from_len);
if (len < 0) {
- if (ff_neterrno() == FF_NETERROR(EAGAIN) ||
- ff_neterrno() == FF_NETERROR(EINTR))
+ if (ff_neterrno() == AVERROR(EAGAIN) ||
+ ff_neterrno() == AVERROR(EINTR))
continue;
return AVERROR(EIO);
}
@@ -250,8 +251,8 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
len = recvfrom (s->rtcp_fd, buf, size, 0,
(struct sockaddr *)&from, &from_len);
if (len < 0) {
- if (ff_neterrno() == FF_NETERROR(EAGAIN) ||
- ff_neterrno() == FF_NETERROR(EINTR))
+ if (ff_neterrno() == AVERROR(EAGAIN) ||
+ ff_neterrno() == AVERROR(EINTR))
continue;
return AVERROR(EIO);
}
@@ -263,15 +264,15 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
len = recvfrom (s->rtp_fd, buf, size, 0,
(struct sockaddr *)&from, &from_len);
if (len < 0) {
- if (ff_neterrno() == FF_NETERROR(EAGAIN) ||
- ff_neterrno() == FF_NETERROR(EINTR))
+ if (ff_neterrno() == AVERROR(EAGAIN) ||
+ ff_neterrno() == AVERROR(EINTR))
continue;
return AVERROR(EIO);
}
break;
}
} else if (n < 0) {
- if (ff_neterrno() == FF_NETERROR(EINTR))
+ if (ff_neterrno() == AVERROR(EINTR))
continue;
return AVERROR(EIO);
}
diff --git a/mplayer/ffmpeg/libavformat/rtsp.c b/mplayer/ffmpeg/libavformat/rtsp.c
index 9a6d6ad2..a24f12ba 100644
--- a/mplayer/ffmpeg/libavformat/rtsp.c
+++ b/mplayer/ffmpeg/libavformat/rtsp.c
@@ -22,8 +22,10 @@
#include "libavutil/base64.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/parseutils.h"
#include "libavutil/random_seed.h"
#include "avformat.h"
+#include "avio_internal.h"
#include
#if HAVE_POLL_H
@@ -99,11 +101,11 @@ static void rtsp_parse_range_npt(const char *p, int64_t *start, int64_t *end)
*end = AV_NOPTS_VALUE;
get_word_sep(buf, sizeof(buf), "-", &p);
- *start = parse_date(buf, 1);
+ av_parse_time(start, buf, 1);
if (*p == '-') {
p++;
get_word_sep(buf, sizeof(buf), "-", &p);
- *end = parse_date(buf, 1);
+ av_parse_time(end, buf, 1);
}
// av_log(NULL, AV_LOG_DEBUG, "Range Start: %lld\n", *start);
// av_log(NULL, AV_LOG_DEBUG, "Range End: %lld\n", *end);
@@ -273,8 +275,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
s1->default_ip = sdp_ip;
s1->default_ttl = ttl;
} else {
- st = s->streams[s->nb_streams - 1];
- rtsp_st = st->priv_data;
+ rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
rtsp_st->sdp_ip = sdp_ip;
rtsp_st->sdp_ttl = ttl;
}
@@ -323,10 +324,9 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
if (!strcmp(ff_rtp_enc_name(rtsp_st->sdp_payload_type), "MP2T")) {
/* no corresponding stream */
} else {
- st = av_new_stream(s, 0);
+ st = av_new_stream(s, rt->nb_rtsp_streams - 1);
if (!st)
return;
- st->priv_data = rtsp_st;
rtsp_st->stream_index = st->index;
st->codec->codec_type = codec_type;
if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) {
@@ -355,8 +355,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
} else {
char proto[32];
/* get the control url */
- st = s->streams[s->nb_streams - 1];
- rtsp_st = st->priv_data;
+ rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
/* XXX: may need to add full url resolution */
av_url_split(proto, sizeof(proto), NULL, 0, NULL, 0,
@@ -377,7 +376,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
get_word(buf1, sizeof(buf1), &p);
payload_type = atoi(buf1);
st = s->streams[s->nb_streams - 1];
- rtsp_st = st->priv_data;
+ rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p);
} else if (av_strstart(p, "fmtp:", &p) ||
av_strstart(p, "framesize:", &p)) {
@@ -385,9 +384,8 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
// let dynamic protocol handlers have a stab at the line.
get_word(buf1, sizeof(buf1), &p);
payload_type = atoi(buf1);
- for (i = 0; i < s->nb_streams; i++) {
- st = s->streams[i];
- rtsp_st = st->priv_data;
+ for (i = 0; i < rt->nb_rtsp_streams; i++) {
+ rtsp_st = rt->rtsp_streams[i];
if (rtsp_st->sdp_payload_type == payload_type &&
rtsp_st->dynamic_handler &&
rtsp_st->dynamic_handler->parse_sdp_a_line)
@@ -417,7 +415,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
if (rt->server_type == RTSP_SERVER_REAL)
ff_real_parse_sdp_a_line(s, s->nb_streams - 1, p);
- rtsp_st = s->streams[s->nb_streams - 1]->priv_data;
+ rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
if (rtsp_st->dynamic_handler &&
rtsp_st->dynamic_handler->parse_sdp_a_line)
rtsp_st->dynamic_handler->parse_sdp_a_line(s,
@@ -500,12 +498,9 @@ void ff_rtsp_undo_setup(AVFormatContext *s)
url_close_dyn_buf(rtpctx->pb, &ptr);
av_free(ptr);
} else {
- url_fclose(rtpctx->pb);
+ avio_close(rtpctx->pb);
}
- av_metadata_free(&rtpctx->streams[0]->metadata);
- av_metadata_free(&rtpctx->metadata);
- av_free(rtpctx->streams[0]);
- av_free(rtpctx);
+ avformat_free_context(rtpctx);
} else if (rt->transport == RTSP_TRANSPORT_RDT && CONFIG_RTPDEC)
ff_rdt_parse_close(rtsp_st->transport_priv);
else if (CONFIG_RTPDEC)
@@ -532,6 +527,7 @@ void ff_rtsp_close_streams(AVFormatContext *s)
if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
rtsp_st->dynamic_handler->close(
rtsp_st->dynamic_protocol_context);
+ av_free(rtsp_st);
}
}
av_free(rt->rtsp_streams);
@@ -1532,7 +1528,7 @@ int ff_rtsp_connect(AVFormatContext *s)
goto fail;
lower_transport_mask &= ~(1 << lower_transport);
if (lower_transport_mask == 0 && err == 1) {
- err = FF_NETERROR(EPROTONOSUPPORT);
+ err = AVERROR(EPROTONOSUPPORT);
goto fail;
}
} while (err);
@@ -1619,7 +1615,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
}
#endif
} else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) {
- return FF_NETERROR(ETIMEDOUT);
+ return AVERROR(ETIMEDOUT);
} else if (n < 0 && errno != EINTR)
return AVERROR(errno);
}
@@ -1687,7 +1683,7 @@ int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt)
case RTSP_LOWER_TRANSPORT_UDP:
case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
len = udp_read_packet(s, &rtsp_st, rt->recvbuf, RECVBUF_SIZE, wait_end);
- if (len >=0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
+ if (len > 0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
rtp_check_and_send_back_rr(rtsp_st->transport_priv, len);
break;
}
@@ -1788,7 +1784,7 @@ static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* read the whole sdp file */
/* XXX: better loading */
content = av_malloc(SDP_MAX_SIZE);
- size = get_buffer(s->pb, content, SDP_MAX_SIZE - 1);
+ size = avio_read(s->pb, content, SDP_MAX_SIZE - 1);
if (size <= 0) {
av_free(content);
return AVERROR_INVALIDDATA;
@@ -1860,7 +1856,7 @@ static int rtp_read_header(AVFormatContext *s,
int payload_type;
AVCodecContext codec;
struct sockaddr_storage addr;
- ByteIOContext pb;
+ AVIOContext pb;
socklen_t addrlen = sizeof(addr);
if (!ff_network_init())
@@ -1918,7 +1914,7 @@ static int rtp_read_header(AVFormatContext *s,
port, payload_type);
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
- init_put_byte(&pb, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
s->pb = &pb;
/* sdp_read_header initializes this again */
diff --git a/mplayer/ffmpeg/libavformat/rtsp.h b/mplayer/ffmpeg/libavformat/rtsp.h
index 14d3f41e..0fec3cc9 100644
--- a/mplayer/ffmpeg/libavformat/rtsp.h
+++ b/mplayer/ffmpeg/libavformat/rtsp.h
@@ -193,7 +193,7 @@ enum RTSPServerType {
/**
* Private data for the RTSP demuxer.
*
- * @todo Use ByteIOContext instead of URLContext
+ * @todo Use AVIOContext instead of URLContext
*/
typedef struct RTSPState {
URLContext *rtsp_hd; /* RTSP TCP connection handle */
@@ -218,7 +218,7 @@ typedef struct RTSPState {
int64_t seek_timestamp;
/* XXX: currently we use unbuffered input */
- // ByteIOContext rtsp_gb;
+ // AVIOContext rtsp_gb;
int seq; /**< RTSP command sequence number */
diff --git a/mplayer/ffmpeg/libavformat/rtspdec.c b/mplayer/ffmpeg/libavformat/rtspdec.c
index 45ed7bb9..95b8690f 100644
--- a/mplayer/ffmpeg/libavformat/rtspdec.c
+++ b/mplayer/ffmpeg/libavformat/rtspdec.c
@@ -283,7 +283,7 @@ static int rtsp_read_packet(AVFormatContext *s, AVPacket *pkt)
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rule_nr = 0;
for (r = 0; r < s->nb_streams; r++) {
- if (s->streams[r]->priv_data == rt->rtsp_streams[i]) {
+ if (s->streams[r]->id == i) {
if (s->streams[r]->discard != AVDISCARD_ALL) {
if (!first)
av_strlcat(rt->last_subscription, ",",
@@ -311,7 +311,7 @@ static int rtsp_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = ff_rtsp_fetch_packet(s, pkt);
if (ret < 0) {
- if (ret == FF_NETERROR(ETIMEDOUT) && !rt->packets) {
+ if (ret == AVERROR(ETIMEDOUT) && !rt->packets) {
if (rt->lower_transport == RTSP_LOWER_TRANSPORT_UDP &&
rt->lower_transport_mask & (1 << RTSP_LOWER_TRANSPORT_TCP)) {
RTSPMessageHeader reply1, *reply = &reply1;
@@ -382,7 +382,7 @@ static int rtsp_read_close(AVFormatContext *s)
#if 0
/* NOTE: it is valid to flush the buffer here */
if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) {
- url_fclose(&rt->rtsp_gb);
+ avio_close(&rt->rtsp_gb);
}
#endif
ff_rtsp_send_cmd_async(s, "TEARDOWN", rt->control_uri, NULL);
diff --git a/mplayer/ffmpeg/libavformat/rtspenc.c b/mplayer/ffmpeg/libavformat/rtspenc.c
index d54be1a5..34deeeb6 100644
--- a/mplayer/ffmpeg/libavformat/rtspenc.c
+++ b/mplayer/ffmpeg/libavformat/rtspenc.c
@@ -79,14 +79,12 @@ int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr)
/* Set up the RTSPStreams for each AVStream */
for (i = 0; i < s->nb_streams; i++) {
RTSPStream *rtsp_st;
- AVStream *st = s->streams[i];
rtsp_st = av_mallocz(sizeof(RTSPStream));
if (!rtsp_st)
return AVERROR(ENOMEM);
dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st);
- st->priv_data = rtsp_st;
rtsp_st->stream_index = i;
av_strlcpy(rtsp_st->control_url, rt->control_uri, sizeof(rtsp_st->control_url));
diff --git a/mplayer/ffmpeg/libavformat/sapdec.c b/mplayer/ffmpeg/libavformat/sapdec.c
index 73525f5d..e3cdcea6 100644
--- a/mplayer/ffmpeg/libavformat/sapdec.c
+++ b/mplayer/ffmpeg/libavformat/sapdec.c
@@ -25,6 +25,7 @@
#include "network.h"
#include "os_support.h"
#include "internal.h"
+#include "avio_internal.h"
#if HAVE_POLL_H
#include
#endif
@@ -33,7 +34,7 @@
struct SAPState {
URLContext *ann_fd;
AVFormatContext *sdp_ctx;
- ByteIOContext sdp_pb;
+ AVIOContext sdp_pb;
uint16_t hash;
char *sdp;
int eof;
@@ -142,7 +143,7 @@ static int sap_read_header(AVFormatContext *s,
}
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sap->sdp);
- init_put_byte(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL,
+ ffio_init_context(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL,
NULL, NULL);
infmt = av_find_input_format("sdp");
diff --git a/mplayer/ffmpeg/libavformat/sapenc.c b/mplayer/ffmpeg/libavformat/sapenc.c
index b14c511c..bc66adcd 100644
--- a/mplayer/ffmpeg/libavformat/sapenc.c
+++ b/mplayer/ffmpeg/libavformat/sapenc.c
@@ -20,6 +20,7 @@
*/
#include "avformat.h"
+#include "libavutil/parseutils.h"
#include "libavutil/random_seed.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
@@ -45,11 +46,8 @@ static int sap_write_close(AVFormatContext *s)
if (!rtpctx)
continue;
av_write_trailer(rtpctx);
- url_fclose(rtpctx->pb);
- av_metadata_free(&rtpctx->streams[0]->metadata);
- av_metadata_free(&rtpctx->metadata);
- av_free(rtpctx->streams[0]);
- av_free(rtpctx);
+ avio_close(rtpctx->pb);
+ avformat_free_context(rtpctx);
s->streams[i]->priv_data = NULL;
}
@@ -90,16 +88,16 @@ static int sap_write_header(AVFormatContext *s)
option_list = strrchr(path, '?');
if (option_list) {
char buf[50];
- if (find_info_tag(buf, sizeof(buf), "announce_port", option_list)) {
+ if (av_find_info_tag(buf, sizeof(buf), "announce_port", option_list)) {
port = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "same_port", option_list)) {
+ if (av_find_info_tag(buf, sizeof(buf), "same_port", option_list)) {
same_port = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "ttl", option_list)) {
+ if (av_find_info_tag(buf, sizeof(buf), "ttl", option_list)) {
ttl = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "announce_addr", option_list)) {
+ if (av_find_info_tag(buf, sizeof(buf), "announce_addr", option_list)) {
av_strlcpy(announce_addr, buf, sizeof(announce_addr));
}
}
@@ -242,7 +240,7 @@ static int sap_write_packet(AVFormatContext *s, AVPacket *pkt)
if (!sap->last_time || now - sap->last_time > 5000000) {
int ret = url_write(sap->ann_fd, sap->ann, sap->ann_size);
/* Don't abort even if we get "Destination unreachable" */
- if (ret < 0 && ret != FF_NETERROR(ECONNREFUSED))
+ if (ret < 0 && ret != AVERROR(ECONNREFUSED))
return ret;
sap->last_time = now;
}
diff --git a/mplayer/ffmpeg/libavformat/sauce.c b/mplayer/ffmpeg/libavformat/sauce.c
index 4972d339..ba737df1 100644
--- a/mplayer/ffmpeg/libavformat/sauce.c
+++ b/mplayer/ffmpeg/libavformat/sauce.c
@@ -30,19 +30,19 @@
int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int get_height)
{
- ByteIOContext *pb = avctx->pb;
+ AVIOContext *pb = avctx->pb;
char buf[36];
int datatype, filetype, t1, t2, nb_comments, flags;
uint64_t start_pos = url_fsize(pb) - 128;
- url_fseek(pb, start_pos, SEEK_SET);
- if (get_buffer(pb, buf, 7) != 7)
+ avio_seek(pb, start_pos, SEEK_SET);
+ if (avio_read(pb, buf, 7) != 7)
return -1;
if (memcmp(buf, "SAUCE00", 7))
return -1;
#define GET_SAUCE_META(name,size) \
- if (get_buffer(pb, buf, size) == size && buf[0]) { \
+ if (avio_read(pb, buf, size) == size && buf[0]) { \
buf[size] = 0; \
av_metadata_set2(&avctx->metadata, name, buf, 0); \
}
@@ -51,14 +51,14 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g
GET_SAUCE_META("artist", 20)
GET_SAUCE_META("publisher", 20)
GET_SAUCE_META("date", 8)
- url_fskip(pb, 4);
- datatype = get_byte(pb);
- filetype = get_byte(pb);
- t1 = get_le16(pb);
- t2 = get_le16(pb);
- nb_comments = get_byte(pb);
- flags = get_byte(pb);
- url_fskip(pb, 4);
+ avio_seek(pb, 4, SEEK_CUR);
+ datatype = avio_r8(pb);
+ filetype = avio_r8(pb);
+ t1 = avio_rl16(pb);
+ t2 = avio_rl16(pb);
+ nb_comments = avio_r8(pb);
+ flags = avio_r8(pb);
+ avio_seek(pb, 4, SEEK_CUR);
GET_SAUCE_META("encoder", 22);
if (got_width && datatype && filetype) {
@@ -82,15 +82,15 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g
*fsize -= 128;
if (nb_comments > 0) {
- url_fseek(pb, start_pos - 64*nb_comments - 5, SEEK_SET);
- if (get_buffer(pb, buf, 5) == 5 && !memcmp(buf, "COMNT", 5)) {
+ avio_seek(pb, start_pos - 64*nb_comments - 5, SEEK_SET);
+ if (avio_read(pb, buf, 5) == 5 && !memcmp(buf, "COMNT", 5)) {
int i;
char *str = av_malloc(65*nb_comments + 1);
*fsize -= 64*nb_comments + 5;
if (!str)
return 0;
for (i = 0; i < nb_comments; i++) {
- if (get_buffer(pb, str + 65*i, 64) != 64)
+ if (avio_read(pb, str + 65*i, 64) != 64)
break;
str[65*i + 64] = '\n';
}
diff --git a/mplayer/ffmpeg/libavformat/sdp.c b/mplayer/ffmpeg/libavformat/sdp.c
index 872e76c5..2a882181 100644
--- a/mplayer/ffmpeg/libavformat/sdp.c
+++ b/mplayer/ffmpeg/libavformat/sdp.c
@@ -21,6 +21,7 @@
#include
#include "libavutil/avstring.h"
#include "libavutil/base64.h"
+#include "libavutil/parseutils.h"
#include "libavcodec/xiph.h"
#include "avformat.h"
#include "internal.h"
@@ -136,7 +137,7 @@ static int sdp_get_address(char *dest_addr, int size, int *ttl, const char *url)
if (p) {
char buff[64];
- if (find_info_tag(buff, sizeof(buff), "ttl", p)) {
+ if (av_find_info_tag(buff, sizeof(buff), "ttl", p)) {
*ttl = strtol(buff, NULL, 10);
} else {
*ttl = 5;
diff --git a/mplayer/ffmpeg/libavformat/seek.c b/mplayer/ffmpeg/libavformat/seek.c
index 26b622f0..9fee9110 100644
--- a/mplayer/ffmpeg/libavformat/seek.c
+++ b/mplayer/ffmpeg/libavformat/seek.c
@@ -313,7 +313,7 @@ int64_t ff_gen_syncpoint_search(AVFormatContext *s,
step = s->pb->buffer_size;
curpos = FFMAX(pos - step / 2, 0);
for (;;) {
- url_fseek(s->pb, curpos, SEEK_SET);
+ avio_seek(s->pb, curpos, SEEK_SET);
search_hi_lo_keyframes(s,
ts, time_base,
flags,
@@ -385,7 +385,7 @@ int64_t ff_gen_syncpoint_search(AVFormatContext *s,
}
}
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
av_free(sync);
return pos;
}
@@ -456,7 +456,7 @@ void ff_restore_parser_state(AVFormatContext *s, AVParserState *state)
if (!state)
return;
- url_fseek(s->pb, state->fpos, SEEK_SET);
+ avio_seek(s->pb, state->fpos, SEEK_SET);
// copy context structures
s->cur_st = state->cur_st;
diff --git a/mplayer/ffmpeg/libavformat/segafilm.c b/mplayer/ffmpeg/libavformat/segafilm.c
index 4f3e5b93..7b689906 100644
--- a/mplayer/ffmpeg/libavformat/segafilm.c
+++ b/mplayer/ffmpeg/libavformat/segafilm.c
@@ -77,7 +77,7 @@ static int film_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
FilmDemuxContext *film = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
unsigned char scratch[256];
int i;
@@ -89,7 +89,7 @@ static int film_read_header(AVFormatContext *s,
film->stereo_buffer_size = 0;
/* load the main FILM header */
- if (get_buffer(pb, scratch, 16) != 16)
+ if (avio_read(pb, scratch, 16) != 16)
return AVERROR(EIO);
data_offset = AV_RB32(&scratch[4]);
film->version = AV_RB32(&scratch[8]);
@@ -97,7 +97,7 @@ static int film_read_header(AVFormatContext *s,
/* load the FDSC chunk */
if (film->version == 0) {
/* special case for Lemmings .film files; 20-byte header */
- if (get_buffer(pb, scratch, 20) != 20)
+ if (avio_read(pb, scratch, 20) != 20)
return AVERROR(EIO);
/* make some assumptions about the audio parameters */
film->audio_type = CODEC_ID_PCM_S8;
@@ -106,7 +106,7 @@ static int film_read_header(AVFormatContext *s,
film->audio_bits = 8;
} else {
/* normal Saturn .cpk files; 32-byte header */
- if (get_buffer(pb, scratch, 32) != 32)
+ if (avio_read(pb, scratch, 32) != 32)
return AVERROR(EIO);
film->audio_samplerate = AV_RB16(&scratch[24]);
film->audio_channels = scratch[21];
@@ -158,7 +158,7 @@ static int film_read_header(AVFormatContext *s,
}
/* load the sample table */
- if (get_buffer(pb, scratch, 16) != 16)
+ if (avio_read(pb, scratch, 16) != 16)
return AVERROR(EIO);
if (AV_RB32(&scratch[0]) != STAB_TAG)
return AVERROR_INVALIDDATA;
@@ -174,7 +174,7 @@ static int film_read_header(AVFormatContext *s,
audio_frame_counter = 0;
for (i = 0; i < film->sample_count; i++) {
/* load the next sample record and transfer it to an internal struct */
- if (get_buffer(pb, scratch, 16) != 16) {
+ if (avio_read(pb, scratch, 16) != 16) {
av_free(film->sample_table);
return AVERROR(EIO);
}
@@ -205,7 +205,7 @@ static int film_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
FilmDemuxContext *film = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
film_sample *sample;
int ret = 0;
int i;
@@ -217,7 +217,7 @@ static int film_read_packet(AVFormatContext *s,
sample = &film->sample_table[film->current_sample];
/* position the stream (will probably be there anyway) */
- url_fseek(pb, sample->sample_offset, SEEK_SET);
+ avio_seek(pb, sample->sample_offset, SEEK_SET);
/* do a special song and dance when loading FILM Cinepak chunks */
if ((sample->stream == film->video_stream_index) &&
@@ -225,7 +225,7 @@ static int film_read_packet(AVFormatContext *s,
pkt->pos= url_ftell(pb);
if (av_new_packet(pkt, sample->sample_size))
return AVERROR(ENOMEM);
- get_buffer(pb, pkt->data, sample->sample_size);
+ avio_read(pb, pkt->data, sample->sample_size);
} else if ((sample->stream == film->audio_stream_index) &&
(film->audio_channels == 2)) {
/* stereo PCM needs to be interleaved */
@@ -241,7 +241,7 @@ static int film_read_packet(AVFormatContext *s,
}
pkt->pos= url_ftell(pb);
- ret = get_buffer(pb, film->stereo_buffer, sample->sample_size);
+ ret = avio_read(pb, film->stereo_buffer, sample->sample_size);
if (ret != sample->sample_size)
ret = AVERROR(EIO);
diff --git a/mplayer/ffmpeg/libavformat/sierravmd.c b/mplayer/ffmpeg/libavformat/sierravmd.c
index 98fe95a5..77874659 100644
--- a/mplayer/ffmpeg/libavformat/sierravmd.c
+++ b/mplayer/ffmpeg/libavformat/sierravmd.c
@@ -81,7 +81,7 @@ static int vmd_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
VmdDemuxContext *vmd = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st = NULL, *vst;
unsigned int toc_offset;
unsigned char *raw_frame_table;
@@ -95,8 +95,8 @@ static int vmd_read_header(AVFormatContext *s,
int sound_buffers;
/* fetch the main header, including the 2 header length bytes */
- url_fseek(pb, 0, SEEK_SET);
- if (get_buffer(pb, vmd->vmd_header, VMD_HEADER_SIZE) != VMD_HEADER_SIZE)
+ avio_seek(pb, 0, SEEK_SET);
+ if (avio_read(pb, vmd->vmd_header, VMD_HEADER_SIZE) != VMD_HEADER_SIZE)
return AVERROR(EIO);
if(vmd->vmd_header[16] == 'i' && vmd->vmd_header[17] == 'v' && vmd->vmd_header[18] == '3')
@@ -155,7 +155,7 @@ static int vmd_read_header(AVFormatContext *s,
toc_offset = AV_RL32(&vmd->vmd_header[812]);
vmd->frame_count = AV_RL16(&vmd->vmd_header[6]);
vmd->frames_per_block = AV_RL16(&vmd->vmd_header[18]);
- url_fseek(pb, toc_offset, SEEK_SET);
+ avio_seek(pb, toc_offset, SEEK_SET);
raw_frame_table = NULL;
vmd->frame_table = NULL;
@@ -172,7 +172,7 @@ static int vmd_read_header(AVFormatContext *s,
av_free(vmd->frame_table);
return AVERROR(ENOMEM);
}
- if (get_buffer(pb, raw_frame_table, raw_frame_table_size) !=
+ if (avio_read(pb, raw_frame_table, raw_frame_table_size) !=
raw_frame_table_size) {
av_free(raw_frame_table);
av_free(vmd->frame_table);
@@ -189,7 +189,7 @@ static int vmd_read_header(AVFormatContext *s,
int type;
uint32_t size;
- get_buffer(pb, chunk, BYTES_PER_FRAME_RECORD);
+ avio_read(pb, chunk, BYTES_PER_FRAME_RECORD);
type = chunk[0];
size = AV_RL32(&chunk[2]);
if(!size && type != 1)
@@ -234,7 +234,7 @@ static int vmd_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
VmdDemuxContext *vmd = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret = 0;
vmd_frame *frame;
@@ -243,16 +243,16 @@ static int vmd_read_packet(AVFormatContext *s,
frame = &vmd->frame_table[vmd->current_frame];
/* position the stream (will probably be there already) */
- url_fseek(pb, frame->frame_offset, SEEK_SET);
+ avio_seek(pb, frame->frame_offset, SEEK_SET);
if (av_new_packet(pkt, frame->frame_size + BYTES_PER_FRAME_RECORD))
return AVERROR(ENOMEM);
pkt->pos= url_ftell(pb);
memcpy(pkt->data, frame->frame_record, BYTES_PER_FRAME_RECORD);
if(vmd->is_indeo3)
- ret = get_buffer(pb, pkt->data, frame->frame_size);
+ ret = avio_read(pb, pkt->data, frame->frame_size);
else
- ret = get_buffer(pb, pkt->data + BYTES_PER_FRAME_RECORD,
+ ret = avio_read(pb, pkt->data + BYTES_PER_FRAME_RECORD,
frame->frame_size);
if (ret != frame->frame_size) {
diff --git a/mplayer/ffmpeg/libavformat/siff.c b/mplayer/ffmpeg/libavformat/siff.c
index 5219368f..880132ff 100644
--- a/mplayer/ffmpeg/libavformat/siff.c
+++ b/mplayer/ffmpeg/libavformat/siff.c
@@ -84,36 +84,36 @@ static int create_audio_stream(AVFormatContext *s, SIFFContext *c)
return 0;
}
-static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, ByteIOContext *pb)
+static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
{
AVStream *st;
int width, height;
- if (get_le32(pb) != TAG_VBHD){
+ if (avio_rl32(pb) != TAG_VBHD){
av_log(s, AV_LOG_ERROR, "Header chunk is missing\n");
return -1;
}
- if(get_be32(pb) != 32){
+ if(avio_rb32(pb) != 32){
av_log(s, AV_LOG_ERROR, "Header chunk size is incorrect\n");
return -1;
}
- if(get_le16(pb) != 1){
+ if(avio_rl16(pb) != 1){
av_log(s, AV_LOG_ERROR, "Incorrect header version\n");
return -1;
}
- width = get_le16(pb);
- height = get_le16(pb);
- url_fskip(pb, 4);
- c->frames = get_le16(pb);
+ width = avio_rl16(pb);
+ height = avio_rl16(pb);
+ avio_seek(pb, 4, SEEK_CUR);
+ c->frames = avio_rl16(pb);
if(!c->frames){
av_log(s, AV_LOG_ERROR, "File contains no frames ???\n");
return -1;
}
- c->bits = get_le16(pb);
- c->rate = get_le16(pb);
+ c->bits = avio_rl16(pb);
+ c->rate = avio_rl16(pb);
c->block_align = c->rate * (c->bits >> 3);
- url_fskip(pb, 16); //zeroes
+ avio_seek(pb, 16, SEEK_CUR); //zeroes
st = av_new_stream(s, 0);
if (!st)
@@ -135,33 +135,33 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, ByteIOContext *pb
return 0;
}
-static int siff_parse_soun(AVFormatContext *s, SIFFContext *c, ByteIOContext *pb)
+static int siff_parse_soun(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
{
- if (get_le32(pb) != TAG_SHDR){
+ if (avio_rl32(pb) != TAG_SHDR){
av_log(s, AV_LOG_ERROR, "Header chunk is missing\n");
return -1;
}
- if(get_be32(pb) != 8){
+ if(avio_rb32(pb) != 8){
av_log(s, AV_LOG_ERROR, "Header chunk size is incorrect\n");
return -1;
}
- url_fskip(pb, 4); //unknown value
- c->rate = get_le16(pb);
- c->bits = get_le16(pb);
+ avio_seek(pb, 4, SEEK_CUR); //unknown value
+ c->rate = avio_rl16(pb);
+ c->bits = avio_rl16(pb);
c->block_align = c->rate * (c->bits >> 3);
return create_audio_stream(s, c);
}
static int siff_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
SIFFContext *c = s->priv_data;
uint32_t tag;
- if (get_le32(pb) != TAG_SIFF)
+ if (avio_rl32(pb) != TAG_SIFF)
return -1;
- url_fskip(pb, 4); //ignore size
- tag = get_le32(pb);
+ avio_seek(pb, 4, SEEK_CUR); //ignore size
+ tag = avio_rl32(pb);
if (tag != TAG_VBV1 && tag != TAG_SOUN){
av_log(s, AV_LOG_ERROR, "Not a VBV file\n");
@@ -172,11 +172,11 @@ static int siff_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1;
if (tag == TAG_SOUN && siff_parse_soun(s, c, pb) < 0)
return -1;
- if (get_le32(pb) != MKTAG('B', 'O', 'D', 'Y')){
+ if (avio_rl32(pb) != MKTAG('B', 'O', 'D', 'Y')){
av_log(s, AV_LOG_ERROR, "'BODY' chunk is missing\n");
return -1;
}
- url_fskip(pb, 4); //ignore size
+ avio_seek(pb, 4, SEEK_CUR); //ignore size
return 0;
}
@@ -190,12 +190,12 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
if (c->cur_frame >= c->frames)
return AVERROR(EIO);
if (c->curstrm == -1){
- c->pktsize = get_le32(s->pb) - 4;
- c->flags = get_le16(s->pb);
+ c->pktsize = avio_rl32(s->pb) - 4;
+ c->flags = avio_rl16(s->pb);
c->gmcsize = (c->flags & VB_HAS_GMC) ? 4 : 0;
if (c->gmcsize)
- get_buffer(s->pb, c->gmc, c->gmcsize);
- c->sndsize = (c->flags & VB_HAS_AUDIO) ? get_le32(s->pb): 0;
+ avio_read(s->pb, c->gmc, c->gmcsize);
+ c->sndsize = (c->flags & VB_HAS_AUDIO) ? avio_rl32(s->pb): 0;
c->curstrm = !!(c->flags & VB_HAS_AUDIO);
}
@@ -206,7 +206,7 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
AV_WL16(pkt->data, c->flags);
if (c->gmcsize)
memcpy(pkt->data + 2, c->gmc, c->gmcsize);
- get_buffer(s->pb, pkt->data + 2 + c->gmcsize, size - c->gmcsize - 2);
+ avio_read(s->pb, pkt->data + 2 + c->gmcsize, size - c->gmcsize - 2);
pkt->stream_index = 0;
c->curstrm = -1;
}else{
diff --git a/mplayer/ffmpeg/libavformat/smacker.c b/mplayer/ffmpeg/libavformat/smacker.c
index 71a968ee..8feb4e5f 100644
--- a/mplayer/ffmpeg/libavformat/smacker.c
+++ b/mplayer/ffmpeg/libavformat/smacker.c
@@ -98,26 +98,26 @@ static int smacker_probe(AVProbeData *p)
static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
SmackerContext *smk = s->priv_data;
AVStream *st, *ast[7];
int i, ret;
int tbase;
/* read and check header */
- smk->magic = get_le32(pb);
+ smk->magic = avio_rl32(pb);
if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4'))
return -1;
- smk->width = get_le32(pb);
- smk->height = get_le32(pb);
- smk->frames = get_le32(pb);
- smk->pts_inc = (int32_t)get_le32(pb);
- smk->flags = get_le32(pb);
+ smk->width = avio_rl32(pb);
+ smk->height = avio_rl32(pb);
+ smk->frames = avio_rl32(pb);
+ smk->pts_inc = (int32_t)avio_rl32(pb);
+ smk->flags = avio_rl32(pb);
if(smk->flags & SMACKER_FLAG_RING_FRAME)
smk->frames++;
for(i = 0; i < 7; i++)
- smk->audio[i] = get_le32(pb);
- smk->treesize = get_le32(pb);
+ smk->audio[i] = avio_rl32(pb);
+ smk->treesize = avio_rl32(pb);
if(smk->treesize >= UINT_MAX/4){ // smk->treesize + 16 must not overflow (this check is probably redundant)
av_log(s, AV_LOG_ERROR, "treesize too large\n");
@@ -125,13 +125,13 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
//FIXME remove extradata "rebuilding"
- smk->mmap_size = get_le32(pb);
- smk->mclr_size = get_le32(pb);
- smk->full_size = get_le32(pb);
- smk->type_size = get_le32(pb);
+ smk->mmap_size = avio_rl32(pb);
+ smk->mclr_size = avio_rl32(pb);
+ smk->full_size = avio_rl32(pb);
+ smk->type_size = avio_rl32(pb);
for(i = 0; i < 7; i++)
- smk->rates[i] = get_le32(pb);
- smk->pad = get_le32(pb);
+ smk->rates[i] = avio_rl32(pb);
+ smk->pad = avio_rl32(pb);
/* setup data */
if(smk->frames > 0xFFFFFF) {
av_log(s, AV_LOG_ERROR, "Too many frames: %i\n", smk->frames);
@@ -144,10 +144,10 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* read frame info */
for(i = 0; i < smk->frames; i++) {
- smk->frm_size[i] = get_le32(pb);
+ smk->frm_size[i] = avio_rl32(pb);
}
for(i = 0; i < smk->frames; i++) {
- smk->frm_flags[i] = get_byte(pb);
+ smk->frm_flags[i] = avio_r8(pb);
}
/* init video codec */
@@ -207,7 +207,7 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap)
av_free(smk->frm_flags);
return -1;
}
- ret = get_buffer(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
+ ret = avio_read(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
if(ret != st->codec->extradata_size - 16){
av_free(smk->frm_size);
av_free(smk->frm_flags);
@@ -240,7 +240,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
/* if we demuxed all streams, pass another frame */
if(smk->curstream < 0) {
- url_fseek(s->pb, smk->nextpos, 0);
+ avio_seek(s->pb, smk->nextpos, 0);
frame_size = smk->frm_size[smk->cur_frame] & (~3);
flags = smk->frm_flags[smk->cur_frame];
/* handle palette change event */
@@ -251,19 +251,19 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
uint8_t oldpal[768];
memcpy(oldpal, pal, 768);
- size = get_byte(s->pb);
+ size = avio_r8(s->pb);
size = size * 4 - 1;
frame_size -= size;
frame_size--;
sz = 0;
pos = url_ftell(s->pb) + size;
while(sz < 256){
- t = get_byte(s->pb);
+ t = avio_r8(s->pb);
if(t & 0x80){ /* skip palette entries */
sz += (t & 0x7F) + 1;
pal += ((t & 0x7F) + 1) * 3;
} else if(t & 0x40){ /* copy with offset */
- off = get_byte(s->pb) * 3;
+ off = avio_r8(s->pb) * 3;
j = (t & 0x3F) + 1;
while(j-- && sz < 256) {
*pal++ = oldpal[off + 0];
@@ -274,12 +274,12 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
}
} else { /* new entries */
*pal++ = smk_pal[t];
- *pal++ = smk_pal[get_byte(s->pb) & 0x3F];
- *pal++ = smk_pal[get_byte(s->pb) & 0x3F];
+ *pal++ = smk_pal[avio_r8(s->pb) & 0x3F];
+ *pal++ = smk_pal[avio_r8(s->pb) & 0x3F];
sz++;
}
}
- url_fseek(s->pb, pos, 0);
+ avio_seek(s->pb, pos, 0);
palchange |= 1;
}
flags >>= 1;
@@ -288,13 +288,13 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
for(i = 0; i < 7; i++) {
if(flags & 1) {
int size;
- size = get_le32(s->pb) - 4;
+ size = avio_rl32(s->pb) - 4;
frame_size -= size;
frame_size -= 4;
smk->curstream++;
smk->bufs[smk->curstream] = av_realloc(smk->bufs[smk->curstream], size);
smk->buf_sizes[smk->curstream] = size;
- ret = get_buffer(s->pb, smk->bufs[smk->curstream], size);
+ ret = avio_read(s->pb, smk->bufs[smk->curstream], size);
if(ret != size)
return AVERROR(EIO);
smk->stream_id[smk->curstream] = smk->indexes[i];
@@ -307,7 +307,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
palchange |= 2;
pkt->data[0] = palchange;
memcpy(pkt->data + 1, smk->pal, 768);
- ret = get_buffer(s->pb, pkt->data + 769, frame_size);
+ ret = avio_read(s->pb, pkt->data + 769, frame_size);
if(ret != frame_size)
return AVERROR(EIO);
pkt->stream_index = smk->videoindex;
@@ -334,12 +334,9 @@ static int smacker_read_close(AVFormatContext *s)
int i;
for(i = 0; i < 7; i++)
- if(smk->bufs[i])
- av_free(smk->bufs[i]);
- if(smk->frm_size)
- av_free(smk->frm_size);
- if(smk->frm_flags)
- av_free(smk->frm_flags);
+ av_free(smk->bufs[i]);
+ av_free(smk->frm_size);
+ av_free(smk->frm_flags);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/sol.c b/mplayer/ffmpeg/libavformat/sol.c
index fd7eb662..7ad894e3 100644
--- a/mplayer/ffmpeg/libavformat/sol.c
+++ b/mplayer/ffmpeg/libavformat/sol.c
@@ -87,21 +87,21 @@ static int sol_read_header(AVFormatContext *s,
{
int size;
unsigned int magic,tag;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int id, channels, rate, type;
enum CodecID codec;
AVStream *st;
/* check ".snd" header */
- magic = get_le16(pb);
- tag = get_le32(pb);
+ magic = avio_rl16(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('S', 'O', 'L', 0))
return -1;
- rate = get_le16(pb);
- type = get_byte(pb);
- size = get_le32(pb);
+ rate = avio_rl16(pb);
+ type = avio_r8(pb);
+ size = avio_rl32(pb);
if (magic != 0x0B8D)
- get_byte(pb); /* newer SOLs contain padding byte */
+ avio_r8(pb); /* newer SOLs contain padding byte */
codec = sol_codec_id(magic, type);
channels = sol_channels(magic, type);
diff --git a/mplayer/ffmpeg/libavformat/soxdec.c b/mplayer/ffmpeg/libavformat/soxdec.c
index 0a57f489..6d99033f 100644
--- a/mplayer/ffmpeg/libavformat/soxdec.c
+++ b/mplayer/ffmpeg/libavformat/soxdec.c
@@ -44,7 +44,7 @@ static int sox_probe(AVProbeData *p)
static int sox_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned header_size, comment_size;
double sample_rate, sample_rate_frac;
AVStream *st;
@@ -55,20 +55,20 @@ static int sox_read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- if (get_le32(pb) == SOX_TAG) {
+ if (avio_rl32(pb) == SOX_TAG) {
st->codec->codec_id = CODEC_ID_PCM_S32LE;
- header_size = get_le32(pb);
- url_fskip(pb, 8); /* sample count */
- sample_rate = av_int2dbl(get_le64(pb));
- st->codec->channels = get_le32(pb);
- comment_size = get_le32(pb);
+ header_size = avio_rl32(pb);
+ avio_seek(pb, 8, SEEK_CUR); /* sample count */
+ sample_rate = av_int2dbl(avio_rl64(pb));
+ st->codec->channels = avio_rl32(pb);
+ comment_size = avio_rl32(pb);
} else {
st->codec->codec_id = CODEC_ID_PCM_S32BE;
- header_size = get_be32(pb);
- url_fskip(pb, 8); /* sample count */
- sample_rate = av_int2dbl(get_be64(pb));
- st->codec->channels = get_be32(pb);
- comment_size = get_be32(pb);
+ header_size = avio_rb32(pb);
+ avio_seek(pb, 8, SEEK_CUR); /* sample count */
+ sample_rate = av_int2dbl(avio_rb64(pb));
+ st->codec->channels = avio_rb32(pb);
+ comment_size = avio_rb32(pb);
}
if (comment_size > 0xFFFFFFFFU - SOX_FIXED_HDR - 4U) {
@@ -95,7 +95,7 @@ static int sox_read_header(AVFormatContext *s,
if (comment_size && comment_size < UINT_MAX) {
char *comment = av_malloc(comment_size+1);
- if (get_buffer(pb, comment, comment_size) != comment_size) {
+ if (avio_read(pb, comment, comment_size) != comment_size) {
av_freep(&comment);
return AVERROR(EIO);
}
@@ -105,7 +105,7 @@ static int sox_read_header(AVFormatContext *s,
AV_METADATA_DONT_STRDUP_VAL);
}
- url_fskip(pb, header_size - SOX_FIXED_HDR - comment_size);
+ avio_seek(pb, header_size - SOX_FIXED_HDR - comment_size, SEEK_CUR);
st->codec->sample_rate = sample_rate;
st->codec->bits_per_coded_sample = 32;
diff --git a/mplayer/ffmpeg/libavformat/soxenc.c b/mplayer/ffmpeg/libavformat/soxenc.c
index 413a5383..dbb2972e 100644
--- a/mplayer/ffmpeg/libavformat/soxenc.c
+++ b/mplayer/ffmpeg/libavformat/soxenc.c
@@ -31,6 +31,7 @@
#include "libavutil/intreadwrite.h"
#include "avformat.h"
+#include "avio_internal.h"
#include "sox.h"
typedef struct {
@@ -40,7 +41,7 @@ typedef struct {
static int sox_write_header(AVFormatContext *s)
{
SoXContext *sox = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
AVMetadataTag *comment;
size_t comment_len = 0, comment_size;
@@ -53,29 +54,29 @@ static int sox_write_header(AVFormatContext *s)
sox->header_size = SOX_FIXED_HDR + comment_size;
if (enc->codec_id == CODEC_ID_PCM_S32LE) {
- put_tag(pb, ".SoX");
- put_le32(pb, sox->header_size);
- put_le64(pb, 0); /* number of samples */
- put_le64(pb, av_dbl2int(enc->sample_rate));
- put_le32(pb, enc->channels);
- put_le32(pb, comment_size);
+ ffio_wfourcc(pb, ".SoX");
+ avio_wl32(pb, sox->header_size);
+ avio_wl64(pb, 0); /* number of samples */
+ avio_wl64(pb, av_dbl2int(enc->sample_rate));
+ avio_wl32(pb, enc->channels);
+ avio_wl32(pb, comment_size);
} else if (enc->codec_id == CODEC_ID_PCM_S32BE) {
- put_tag(pb, "XoS.");
- put_be32(pb, sox->header_size);
- put_be64(pb, 0); /* number of samples */
- put_be64(pb, av_dbl2int(enc->sample_rate));
- put_be32(pb, enc->channels);
- put_be32(pb, comment_size);
+ ffio_wfourcc(pb, "XoS.");
+ avio_wb32(pb, sox->header_size);
+ avio_wb64(pb, 0); /* number of samples */
+ avio_wb64(pb, av_dbl2int(enc->sample_rate));
+ avio_wb32(pb, enc->channels);
+ avio_wb32(pb, comment_size);
} else {
av_log(s, AV_LOG_ERROR, "invalid codec; use pcm_s32le or pcm_s32be\n");
return -1;
}
if (comment_len)
- put_buffer(pb, comment->value, comment_len);
+ avio_write(pb, comment->value, comment_len);
for ( ; comment_size > comment_len; comment_len++)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
put_flush_packet(pb);
@@ -84,27 +85,27 @@ static int sox_write_header(AVFormatContext *s)
static int sox_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
- put_buffer(pb, pkt->data, pkt->size);
+ AVIOContext *pb = s->pb;
+ avio_write(pb, pkt->data, pkt->size);
return 0;
}
static int sox_write_trailer(AVFormatContext *s)
{
SoXContext *sox = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
if (!url_is_streamed(s->pb)) {
/* update number of samples */
int64_t file_size = url_ftell(pb);
int64_t num_samples = (file_size - sox->header_size - 4LL) >> 2LL;
- url_fseek(pb, 8, SEEK_SET);
+ avio_seek(pb, 8, SEEK_SET);
if (enc->codec_id == CODEC_ID_PCM_S32LE) {
- put_le64(pb, num_samples);
+ avio_wl64(pb, num_samples);
} else
- put_be64(pb, num_samples);
- url_fseek(pb, file_size, SEEK_SET);
+ avio_wb64(pb, num_samples);
+ avio_seek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
}
diff --git a/mplayer/ffmpeg/libavformat/spdifdec.c b/mplayer/ffmpeg/libavformat/spdifdec.c
index 5c4dba08..b2194ea2 100644
--- a/mplayer/ffmpeg/libavformat/spdifdec.c
+++ b/mplayer/ffmpeg/libavformat/spdifdec.c
@@ -163,20 +163,20 @@ static int spdif_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
enum IEC61937DataType data_type;
enum CodecID codec_id;
uint32_t state = 0;
int pkt_size_bits, offset, ret;
while (state != (AV_BSWAP16C(SYNCWORD1) << 16 | AV_BSWAP16C(SYNCWORD2))) {
- state = (state << 8) | get_byte(pb);
+ state = (state << 8) | avio_r8(pb);
if (url_feof(pb))
return AVERROR_EOF;
}
- data_type = get_le16(pb);
- pkt_size_bits = get_le16(pb);
+ data_type = avio_rl16(pb);
+ pkt_size_bits = avio_rl16(pb);
if (pkt_size_bits % 16)
av_log_ask_for_sample(s, "Packet does not end to a 16-bit boundary.");
@@ -187,7 +187,7 @@ static int spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos = url_ftell(pb) - BURST_HEADER_SIZE;
- if (get_buffer(pb, pkt->data, pkt->size) < pkt->size) {
+ if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
av_free_packet(pkt);
return AVERROR_EOF;
}
@@ -201,7 +201,7 @@ static int spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
}
/* skip over the padding to the beginning of the next frame */
- url_fskip(pb, offset - pkt->size - BURST_HEADER_SIZE);
+ avio_seek(pb, offset - pkt->size - BURST_HEADER_SIZE, SEEK_CUR);
if (!s->nb_streams) {
/* first packet, create a stream */
diff --git a/mplayer/ffmpeg/libavformat/spdifenc.c b/mplayer/ffmpeg/libavformat/spdifenc.c
index 3eea31e9..b4111f62 100644
--- a/mplayer/ffmpeg/libavformat/spdifenc.c
+++ b/mplayer/ffmpeg/libavformat/spdifenc.c
@@ -45,12 +45,16 @@
*/
#include "avformat.h"
+#include "avio_internal.h"
#include "spdif.h"
#include "libavcodec/ac3.h"
#include "libavcodec/dca.h"
+#include "libavcodec/dcadata.h"
#include "libavcodec/aacadtsdec.h"
+#include "libavutil/opt.h"
typedef struct IEC61937Context {
+ const AVClass *av_class;
enum IEC61937DataType data_type;///< burst info - reference to type of payload of the data-burst
int length_code; ///< length code in bits or bytes, depending on data type
int pkt_offset; ///< data burst repetition period in bytes
@@ -68,11 +72,28 @@ typedef struct IEC61937Context {
int hd_buf_count; ///< number of frames in the hd audio buffer
int hd_buf_filled; ///< amount of bytes in the hd audio buffer
+ int dtshd_skip; ///< counter used for skipping DTS-HD frames
+
+ /* AVOptions: */
+ int dtshd_rate;
+ int dtshd_fallback;
+#define SPDIF_FLAG_BIGENDIAN 0x01
+ int spdif_flags;
+
/// function, which generates codec dependent header information.
/// Sets data_type and pkt_offset, and length_code, out_bytes, out_buf if necessary
int (*header_info) (AVFormatContext *s, AVPacket *pkt);
} IEC61937Context;
+static const AVOption options[] = {
+{ "spdif_flags", "IEC 61937 encapsulation flags", offsetof(IEC61937Context, spdif_flags), FF_OPT_TYPE_FLAGS, 0, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" },
+{ "be", "output in big-endian format (for use as s16be)", 0, FF_OPT_TYPE_CONST, SPDIF_FLAG_BIGENDIAN, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" },
+{ "dtshd_rate", "mux complete DTS frames in HD mode at the specified IEC958 rate (in Hz, default 0=disabled)", offsetof(IEC61937Context, dtshd_rate), FF_OPT_TYPE_INT, 0, 0, 768000, AV_OPT_FLAG_ENCODING_PARAM },
+{ "dtshd_fallback_time", "min secs to strip HD for after an overflow (-1: till the end, default 60)", offsetof(IEC61937Context, dtshd_fallback), FF_OPT_TYPE_INT, 60, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+{ NULL },
+};
+
+static const AVClass class = { "spdif", av_default_item_name, options, LIBAVUTIL_VERSION_INT };
static int spdif_header_ac3(AVFormatContext *s, AVPacket *pkt)
{
@@ -115,15 +136,116 @@ static int spdif_header_eac3(AVFormatContext *s, AVPacket *pkt)
return 0;
}
+/*
+ * DTS type IV (DTS-HD) can be transmitted with various frame repetition
+ * periods; longer repetition periods allow for longer packets and therefore
+ * higher bitrate. Longer repetition periods mean that the constant bitrate of
+ * the outputted IEC 61937 stream is higher.
+ * The repetition period is measured in IEC 60958 frames (4 bytes).
+ */
+static int spdif_dts4_subtype(int period)
+{
+ switch (period) {
+ case 512: return 0x0;
+ case 1024: return 0x1;
+ case 2048: return 0x2;
+ case 4096: return 0x3;
+ case 8192: return 0x4;
+ case 16384: return 0x5;
+ }
+ return -1;
+}
+
+static int spdif_header_dts4(AVFormatContext *s, AVPacket *pkt, int core_size,
+ int sample_rate, int blocks)
+{
+ IEC61937Context *ctx = s->priv_data;
+ static const char dtshd_start_code[10] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe };
+ int pkt_size = pkt->size;
+ int period;
+ int subtype;
+
+ if (!core_size) {
+ av_log(s, AV_LOG_ERROR, "HD mode not supported for this format\n");
+ return AVERROR(EINVAL);
+ }
+
+ if (!sample_rate) {
+ av_log(s, AV_LOG_ERROR, "Unknown DTS sample rate for HD\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ period = ctx->dtshd_rate * (blocks << 5) / sample_rate;
+ subtype = spdif_dts4_subtype(period);
+
+ if (subtype < 0) {
+ av_log(s, AV_LOG_ERROR, "Specified HD rate of %d Hz would require an "
+ "impossible repetition period of %d for the current DTS stream"
+ " (blocks = %d, sample rate = %d)\n", ctx->dtshd_rate, period,
+ blocks << 5, sample_rate);
+ return AVERROR(EINVAL);
+ }
+
+ /* set pkt_offset and DTS IV subtype according to the requested output
+ * rate */
+ ctx->pkt_offset = period * 4;
+ ctx->data_type = IEC61937_DTSHD | subtype << 8;
+
+ /* If the bitrate is too high for transmitting at the selected
+ * repetition period setting, strip DTS-HD until a good amount
+ * of consecutive non-overflowing HD frames have been observed.
+ * This generally only happens if the caller is cramming a Master
+ * Audio stream into 192kHz IEC 60958 (which may or may not fit). */
+ if (sizeof(dtshd_start_code) + 2 + pkt_size
+ > ctx->pkt_offset - BURST_HEADER_SIZE && core_size) {
+ if (!ctx->dtshd_skip)
+ av_log(s, AV_LOG_WARNING, "DTS-HD bitrate too high, "
+ "temporarily sending core only\n");
+ if (ctx->dtshd_fallback > 0)
+ ctx->dtshd_skip = sample_rate * ctx->dtshd_fallback / (blocks << 5);
+ else
+ /* skip permanently (dtshd_fallback == -1) or just once
+ * (dtshd_fallback == 0) */
+ ctx->dtshd_skip = 1;
+ }
+ if (ctx->dtshd_skip && core_size) {
+ pkt_size = core_size;
+ if (ctx->dtshd_fallback >= 0)
+ --ctx->dtshd_skip;
+ }
+
+ ctx->out_bytes = sizeof(dtshd_start_code) + 2 + pkt_size;
+ ctx->length_code = ctx->out_bytes;
+
+ av_fast_malloc(&ctx->hd_buf, &ctx->hd_buf_size, ctx->out_bytes);
+ if (!ctx->hd_buf)
+ return AVERROR(ENOMEM);
+
+ ctx->out_buf = ctx->hd_buf;
+
+ memcpy(ctx->hd_buf, dtshd_start_code, sizeof(dtshd_start_code));
+ AV_WB16(ctx->hd_buf + sizeof(dtshd_start_code), pkt_size);
+ memcpy(ctx->hd_buf + sizeof(dtshd_start_code) + 2, pkt->data, pkt_size);
+
+ return 0;
+}
+
static int spdif_header_dts(AVFormatContext *s, AVPacket *pkt)
{
IEC61937Context *ctx = s->priv_data;
uint32_t syncword_dts = AV_RB32(pkt->data);
int blocks;
+ int sample_rate = 0;
+ int core_size = 0;
+
+ if (pkt->size < 9)
+ return AVERROR_INVALIDDATA;
switch (syncword_dts) {
case DCA_MARKER_RAW_BE:
blocks = (AV_RB16(pkt->data + 4) >> 2) & 0x7f;
+ core_size = ((AV_RB24(pkt->data + 5) >> 4) & 0x3fff) + 1;
+ sample_rate = dca_sample_rates[(pkt->data[8] >> 2) & 0x0f];
break;
case DCA_MARKER_RAW_LE:
blocks = (AV_RL16(pkt->data + 4) >> 2) & 0x7f;
@@ -138,11 +260,22 @@ static int spdif_header_dts(AVFormatContext *s, AVPacket *pkt)
(((pkt->data[4] & 0x07) << 4) | ((pkt->data[7] & 0x3f) >> 2));
ctx->extra_bswap = 1;
break;
+ case DCA_HD_MARKER:
+ /* We only handle HD frames that are paired with core. However,
+ sometimes DTS-HD streams with core have a stray HD frame without
+ core in the beginning of the stream. */
+ av_log(s, AV_LOG_ERROR, "stray DTS-HD frame\n");
+ return AVERROR_INVALIDDATA;
default:
av_log(s, AV_LOG_ERROR, "bad DTS syncword 0x%x\n", syncword_dts);
return AVERROR_INVALIDDATA;
}
blocks++;
+
+ if (ctx->dtshd_rate)
+ /* DTS type IV output requested */
+ return spdif_header_dts4(s, pkt, core_size, sample_rate, blocks);
+
switch (blocks) {
case 512 >> 5: ctx->data_type = IEC61937_DTS1; break;
case 1024 >> 5: ctx->data_type = IEC61937_DTS2; break;
@@ -152,6 +285,13 @@ static int spdif_header_dts(AVFormatContext *s, AVPacket *pkt)
blocks << 5);
return AVERROR(ENOSYS);
}
+
+ /* discard extraneous data by default */
+ if (core_size && core_size < pkt->size) {
+ ctx->out_bytes = core_size;
+ ctx->length_code = core_size << 3;
+ }
+
ctx->pkt_offset = blocks << 7;
if (ctx->out_bytes == ctx->pkt_offset) {
@@ -159,6 +299,9 @@ static int spdif_header_dts(AVFormatContext *s, AVPacket *pkt)
* preamble as it would not fit in there. This is the case for dts
* discs and dts-in-wav. */
ctx->use_preamble = 0;
+ } else if (ctx->out_bytes > ctx->pkt_offset - BURST_HEADER_SIZE) {
+ av_log_ask_for_sample(s, "Unrecognized large DTS frame.");
+ /* This will fail with a "bitrate too high" in the caller */
}
return 0;
@@ -330,6 +473,15 @@ static int spdif_write_trailer(AVFormatContext *s)
return 0;
}
+static av_always_inline void spdif_put_16(IEC61937Context *ctx,
+ AVIOContext *pb, unsigned int val)
+{
+ if (ctx->spdif_flags & SPDIF_FLAG_BIGENDIAN)
+ avio_wb16(pb, val);
+ else
+ avio_wl16(pb, val);
+}
+
static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
IEC61937Context *ctx = s->priv_data;
@@ -354,26 +506,27 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
}
if (ctx->use_preamble) {
- put_le16(s->pb, SYNCWORD1); //Pa
- put_le16(s->pb, SYNCWORD2); //Pb
- put_le16(s->pb, ctx->data_type); //Pc
- put_le16(s->pb, ctx->length_code);//Pd
+ spdif_put_16(ctx, s->pb, SYNCWORD1); //Pa
+ spdif_put_16(ctx, s->pb, SYNCWORD2); //Pb
+ spdif_put_16(ctx, s->pb, ctx->data_type); //Pc
+ spdif_put_16(ctx, s->pb, ctx->length_code);//Pd
}
- if (HAVE_BIGENDIAN ^ ctx->extra_bswap) {
- put_buffer(s->pb, ctx->out_buf, ctx->out_bytes & ~1);
+ if (ctx->extra_bswap ^ (ctx->spdif_flags & SPDIF_FLAG_BIGENDIAN)) {
+ avio_write(s->pb, ctx->out_buf, ctx->out_bytes & ~1);
} else {
av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + FF_INPUT_BUFFER_PADDING_SIZE);
if (!ctx->buffer)
return AVERROR(ENOMEM);
ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
- put_buffer(s->pb, ctx->buffer, ctx->out_bytes & ~1);
+ avio_write(s->pb, ctx->buffer, ctx->out_bytes & ~1);
}
+ /* a final lone byte has to be MSB aligned */
if (ctx->out_bytes & 1)
- put_be16(s->pb, ctx->out_buf[ctx->out_bytes - 1]);
+ spdif_put_16(ctx, s->pb, ctx->out_buf[ctx->out_bytes - 1] << 8);
- put_nbyte(s->pb, 0, padding);
+ ffio_fill(s->pb, 0, padding);
av_log(s, AV_LOG_DEBUG, "type=%x len=%i pkt_offset=%i\n",
ctx->data_type, ctx->out_bytes, ctx->pkt_offset);
@@ -393,4 +546,6 @@ AVOutputFormat ff_spdif_muxer = {
spdif_write_header,
spdif_write_packet,
spdif_write_trailer,
+ .flags = AVFMT_NOTIMESTAMPS,
+ .priv_class = &class,
};
diff --git a/mplayer/ffmpeg/libavformat/swfdec.c b/mplayer/ffmpeg/libavformat/swfdec.c
index d2a84f0c..b96b2291 100644
--- a/mplayer/ffmpeg/libavformat/swfdec.c
+++ b/mplayer/ffmpeg/libavformat/swfdec.c
@@ -23,18 +23,18 @@
#include "libavutil/intreadwrite.h"
#include "swf.h"
-static int get_swf_tag(ByteIOContext *pb, int *len_ptr)
+static int get_swf_tag(AVIOContext *pb, int *len_ptr)
{
int tag, len;
if (url_feof(pb))
return -1;
- tag = get_le16(pb);
+ tag = avio_rl16(pb);
len = tag & 0x3f;
tag = tag >> 6;
if (len == 0x3f) {
- len = get_le32(pb);
+ len = avio_rl32(pb);
}
// av_log(NULL, AV_LOG_DEBUG, "Tag: %d - Len: %d\n", tag, len);
*len_ptr = len;
@@ -55,10 +55,10 @@ static int swf_probe(AVProbeData *p)
static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
SWFContext *swf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int nbits, len, tag;
- tag = get_be32(pb) & 0xffffff00;
+ tag = avio_rb32(pb) & 0xffffff00;
if (tag == MKBETAG('C', 'W', 'S', 0)) {
av_log(s, AV_LOG_ERROR, "Compressed SWF format not supported\n");
@@ -66,13 +66,13 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
if (tag != MKBETAG('F', 'W', 'S', 0))
return AVERROR(EIO);
- get_le32(pb);
+ avio_rl32(pb);
/* skip rectangle size */
- nbits = get_byte(pb) >> 3;
+ nbits = avio_r8(pb) >> 3;
len = (4 * nbits - 3 + 7) / 8;
- url_fskip(pb, len);
- swf->frame_rate = get_le16(pb); /* 8.8 fixed */
- get_le16(pb); /* frame count */
+ avio_seek(pb, len, SEEK_CUR);
+ swf->frame_rate = avio_rl16(pb); /* 8.8 fixed */
+ avio_rl16(pb); /* frame count */
swf->samples_per_frame = 0;
s->ctx_flags |= AVFMTCTX_NOHEADER;
@@ -82,7 +82,7 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
{
SWFContext *swf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *vst = NULL, *ast = NULL, *st = 0;
int tag, len, i, frame, v;
@@ -92,7 +92,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
if (tag < 0)
return AVERROR(EIO);
if (tag == TAG_VIDEOSTREAM) {
- int ch_id = get_le16(pb);
+ int ch_id = avio_rl16(pb);
len -= 2;
for (i=0; inb_streams; i++) {
@@ -101,16 +101,16 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
goto skip;
}
- get_le16(pb);
- get_le16(pb);
- get_le16(pb);
- get_byte(pb);
+ avio_rl16(pb);
+ avio_rl16(pb);
+ avio_rl16(pb);
+ avio_r8(pb);
/* Check for FLV1 */
vst = av_new_stream(s, ch_id);
if (!vst)
return -1;
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, get_byte(pb));
+ vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, avio_r8(pb));
av_set_pts_info(vst, 16, 256, swf->frame_rate);
vst->codec->time_base = (AVRational){ 256, swf->frame_rate };
len -= 8;
@@ -124,9 +124,9 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
goto skip;
}
- get_byte(pb);
- v = get_byte(pb);
- swf->samples_per_frame = get_le16(pb);
+ avio_r8(pb);
+ v = avio_r8(pb);
+ swf->samples_per_frame = avio_rl16(pb);
ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */
if (!ast)
return -1;
@@ -141,12 +141,12 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
len -= 4;
} else if (tag == TAG_VIDEOFRAME) {
- int ch_id = get_le16(pb);
+ int ch_id = avio_rl16(pb);
len -= 2;
for(i=0; inb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) {
- frame = get_le16(pb);
+ frame = avio_rl16(pb);
av_get_packet(pb, pkt, len-2);
pkt->pos = pos;
pkt->pts = frame;
@@ -159,7 +159,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) {
if (st->codec->codec_id == CODEC_ID_MP3) {
- url_fskip(pb, 4);
+ avio_seek(pb, 4, SEEK_CUR);
av_get_packet(pb, pkt, len-4);
} else { // ADPCM, PCM
av_get_packet(pb, pkt, len);
@@ -185,24 +185,24 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
vst->codec->time_base = (AVRational){ 256, swf->frame_rate };
st = vst;
}
- get_le16(pb); /* BITMAP_ID */
+ avio_rl16(pb); /* BITMAP_ID */
av_new_packet(pkt, len-2);
- get_buffer(pb, pkt->data, 4);
+ avio_read(pb, pkt->data, 4);
if (AV_RB32(pkt->data) == 0xffd8ffd9 ||
AV_RB32(pkt->data) == 0xffd9ffd8) {
/* old SWF files containing SOI/EOI as data start */
/* files created by swink have reversed tag */
pkt->size -= 4;
- get_buffer(pb, pkt->data, pkt->size);
+ avio_read(pb, pkt->data, pkt->size);
} else {
- get_buffer(pb, pkt->data + 4, pkt->size - 4);
+ avio_read(pb, pkt->data + 4, pkt->size - 4);
}
pkt->pos = pos;
pkt->stream_index = st->index;
return pkt->size;
}
skip:
- url_fskip(pb, len);
+ avio_seek(pb, len, SEEK_CUR);
}
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/swfenc.c b/mplayer/ffmpeg/libavformat/swfenc.c
index 1ade1bf2..c898c0ec 100644
--- a/mplayer/ffmpeg/libavformat/swfenc.c
+++ b/mplayer/ffmpeg/libavformat/swfenc.c
@@ -27,39 +27,39 @@
static void put_swf_tag(AVFormatContext *s, int tag)
{
SWFContext *swf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
swf->tag_pos = url_ftell(pb);
swf->tag = tag;
/* reserve some room for the tag */
if (tag & TAG_LONG) {
- put_le16(pb, 0);
- put_le32(pb, 0);
+ avio_wl16(pb, 0);
+ avio_wl32(pb, 0);
} else {
- put_le16(pb, 0);
+ avio_wl16(pb, 0);
}
}
static void put_swf_end_tag(AVFormatContext *s)
{
SWFContext *swf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t pos;
int tag_len, tag;
pos = url_ftell(pb);
tag_len = pos - swf->tag_pos - 2;
tag = swf->tag;
- url_fseek(pb, swf->tag_pos, SEEK_SET);
+ avio_seek(pb, swf->tag_pos, SEEK_SET);
if (tag & TAG_LONG) {
tag &= ~TAG_LONG;
- put_le16(pb, (tag << 6) | 0x3f);
- put_le32(pb, tag_len - 4);
+ avio_wl16(pb, (tag << 6) | 0x3f);
+ avio_wl32(pb, tag_len - 4);
} else {
assert(tag_len < 0x3f);
- put_le16(pb, (tag << 6) | tag_len);
+ avio_wl16(pb, (tag << 6) | tag_len);
}
- url_fseek(pb, pos, SEEK_SET);
+ avio_seek(pb, pos, SEEK_SET);
}
static inline void max_nbits(int *nbits_ptr, int val)
@@ -78,7 +78,7 @@ static inline void max_nbits(int *nbits_ptr, int val)
*nbits_ptr = n;
}
-static void put_swf_rect(ByteIOContext *pb,
+static void put_swf_rect(AVIOContext *pb,
int xmin, int xmax, int ymin, int ymax)
{
PutBitContext p;
@@ -102,7 +102,7 @@ static void put_swf_rect(ByteIOContext *pb,
put_bits(&p, nbits, ymax & mask);
flush_put_bits(&p);
- put_buffer(pb, buf, put_bits_ptr(&p) - p.buf);
+ avio_write(pb, buf, put_bits_ptr(&p) - p.buf);
}
static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
@@ -134,7 +134,7 @@ static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
#define FRAC_BITS 16
-static void put_swf_matrix(ByteIOContext *pb,
+static void put_swf_matrix(AVIOContext *pb,
int a, int b, int c, int d, int tx, int ty)
{
PutBitContext p;
@@ -167,13 +167,13 @@ static void put_swf_matrix(ByteIOContext *pb,
put_bits(&p, nbits, ty);
flush_put_bits(&p);
- put_buffer(pb, buf, put_bits_ptr(&p) - p.buf);
+ avio_write(pb, buf, put_bits_ptr(&p) - p.buf);
}
static int swf_write_header(AVFormatContext *s)
{
SWFContext *swf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
PutBitContext p;
uint8_t buf1[256];
int i, width, height, rate, rate_base;
@@ -229,7 +229,7 @@ static int swf_write_header(AVFormatContext *s)
else
swf->samples_per_frame = (swf->audio_enc->sample_rate * rate_base) / rate;
- put_tag(pb, "FWS");
+ avio_write(pb, "FWS", 3);
if (!strcmp("avm2", s->oformat->name))
version = 9;
@@ -239,20 +239,20 @@ static int swf_write_header(AVFormatContext *s)
version = 6; /* version 6 and above support FLV1 codec */
else
version = 4; /* version 4 for mpeg audio support */
- put_byte(pb, version);
+ avio_w8(pb, version);
- put_le32(pb, DUMMY_FILE_SIZE); /* dummy size
+ avio_wl32(pb, DUMMY_FILE_SIZE); /* dummy size
(will be patched if not streamed) */
put_swf_rect(pb, 0, width * 20, 0, height * 20);
- put_le16(pb, (rate * 256) / rate_base); /* frame rate */
+ avio_wl16(pb, (rate * 256) / rate_base); /* frame rate */
swf->duration_pos = url_ftell(pb);
- put_le16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */
+ avio_wl16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */
/* avm2/swf v9 (also v8?) files require a file attribute tag */
if (version == 9) {
put_swf_tag(s, TAG_FILEATTRIBUTES);
- put_le32(pb, 1<<3); /* set ActionScript v3/AVM2 flag */
+ avio_wl32(pb, 1<<3); /* set ActionScript v3/AVM2 flag */
put_swf_end_tag(s);
}
@@ -260,17 +260,17 @@ static int swf_write_header(AVFormatContext *s)
if (swf->video_enc && swf->video_enc->codec_id == CODEC_ID_MJPEG) {
put_swf_tag(s, TAG_DEFINESHAPE);
- put_le16(pb, SHAPE_ID); /* ID of shape */
+ avio_wl16(pb, SHAPE_ID); /* ID of shape */
/* bounding rectangle */
put_swf_rect(pb, 0, width, 0, height);
/* style info */
- put_byte(pb, 1); /* one fill style */
- put_byte(pb, 0x41); /* clipped bitmap fill */
- put_le16(pb, BITMAP_ID); /* bitmap ID */
+ avio_w8(pb, 1); /* one fill style */
+ avio_w8(pb, 0x41); /* clipped bitmap fill */
+ avio_wl16(pb, BITMAP_ID); /* bitmap ID */
/* position of the bitmap */
put_swf_matrix(pb, (int)(1.0 * (1 << FRAC_BITS)), 0,
0, (int)(1.0 * (1 << FRAC_BITS)), 0, 0);
- put_byte(pb, 0); /* no line style */
+ avio_w8(pb, 0); /* no line style */
/* shape drawing */
init_put_bits(&p, buf1, sizeof(buf1));
@@ -295,7 +295,7 @@ static int swf_write_header(AVFormatContext *s)
put_bits(&p, 5, 0);
flush_put_bits(&p);
- put_buffer(pb, buf1, put_bits_ptr(&p) - p.buf);
+ avio_write(pb, buf1, put_bits_ptr(&p) - p.buf);
put_swf_end_tag(s);
}
@@ -317,11 +317,11 @@ static int swf_write_header(AVFormatContext *s)
v |= 0x02; /* 16 bit playback */
if (swf->audio_enc->channels == 2)
v |= 0x01; /* stereo playback */
- put_byte(s->pb, v);
+ avio_w8(s->pb, v);
v |= 0x20; /* mp3 compressed */
- put_byte(s->pb, v);
- put_le16(s->pb, swf->samples_per_frame); /* avg samples per frame */
- put_le16(s->pb, 0);
+ avio_w8(s->pb, v);
+ avio_wl16(s->pb, swf->samples_per_frame); /* avg samples per frame */
+ avio_wl16(s->pb, 0);
put_swf_end_tag(s);
}
@@ -334,7 +334,7 @@ static int swf_write_video(AVFormatContext *s,
AVCodecContext *enc, const uint8_t *buf, int size)
{
SWFContext *swf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
/* Flash Player limit */
if (swf->swf_frame_number == 16000)
@@ -345,70 +345,70 @@ static int swf_write_video(AVFormatContext *s,
if (swf->video_frame_number == 0) {
/* create a new video object */
put_swf_tag(s, TAG_VIDEOSTREAM);
- put_le16(pb, VIDEO_ID);
+ avio_wl16(pb, VIDEO_ID);
swf->vframes_pos = url_ftell(pb);
- put_le16(pb, 15000); /* hard flash player limit */
- put_le16(pb, enc->width);
- put_le16(pb, enc->height);
- put_byte(pb, 0);
- put_byte(pb,ff_codec_get_tag(swf_codec_tags,enc->codec_id));
+ avio_wl16(pb, 15000); /* hard flash player limit */
+ avio_wl16(pb, enc->width);
+ avio_wl16(pb, enc->height);
+ avio_w8(pb, 0);
+ avio_w8(pb,ff_codec_get_tag(swf_codec_tags,enc->codec_id));
put_swf_end_tag(s);
/* place the video object for the first time */
put_swf_tag(s, TAG_PLACEOBJECT2);
- put_byte(pb, 0x36);
- put_le16(pb, 1);
- put_le16(pb, VIDEO_ID);
+ avio_w8(pb, 0x36);
+ avio_wl16(pb, 1);
+ avio_wl16(pb, VIDEO_ID);
put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0);
- put_le16(pb, swf->video_frame_number);
- put_tag(pb, "video");
- put_byte(pb, 0x00);
+ avio_wl16(pb, swf->video_frame_number);
+ avio_write(pb, "video", 5);
+ avio_w8(pb, 0x00);
put_swf_end_tag(s);
} else {
/* mark the character for update */
put_swf_tag(s, TAG_PLACEOBJECT2);
- put_byte(pb, 0x11);
- put_le16(pb, 1);
- put_le16(pb, swf->video_frame_number);
+ avio_w8(pb, 0x11);
+ avio_wl16(pb, 1);
+ avio_wl16(pb, swf->video_frame_number);
put_swf_end_tag(s);
}
/* set video frame data */
put_swf_tag(s, TAG_VIDEOFRAME | TAG_LONG);
- put_le16(pb, VIDEO_ID);
- put_le16(pb, swf->video_frame_number++);
- put_buffer(pb, buf, size);
+ avio_wl16(pb, VIDEO_ID);
+ avio_wl16(pb, swf->video_frame_number++);
+ avio_write(pb, buf, size);
put_swf_end_tag(s);
} else if (enc->codec_id == CODEC_ID_MJPEG) {
if (swf->swf_frame_number > 0) {
/* remove the shape */
put_swf_tag(s, TAG_REMOVEOBJECT);
- put_le16(pb, SHAPE_ID); /* shape ID */
- put_le16(pb, 1); /* depth */
+ avio_wl16(pb, SHAPE_ID); /* shape ID */
+ avio_wl16(pb, 1); /* depth */
put_swf_end_tag(s);
/* free the bitmap */
put_swf_tag(s, TAG_FREECHARACTER);
- put_le16(pb, BITMAP_ID);
+ avio_wl16(pb, BITMAP_ID);
put_swf_end_tag(s);
}
put_swf_tag(s, TAG_JPEG2 | TAG_LONG);
- put_le16(pb, BITMAP_ID); /* ID of the image */
+ avio_wl16(pb, BITMAP_ID); /* ID of the image */
/* a dummy jpeg header seems to be required */
- put_be32(pb, 0xffd8ffd9);
+ avio_wb32(pb, 0xffd8ffd9);
/* write the jpeg image */
- put_buffer(pb, buf, size);
+ avio_write(pb, buf, size);
put_swf_end_tag(s);
/* draw the shape */
put_swf_tag(s, TAG_PLACEOBJECT);
- put_le16(pb, SHAPE_ID); /* shape ID */
- put_le16(pb, 1); /* depth */
+ avio_wl16(pb, SHAPE_ID); /* shape ID */
+ avio_wl16(pb, 1); /* depth */
put_swf_matrix(pb, 20 << FRAC_BITS, 0, 0, 20 << FRAC_BITS, 0, 0);
put_swf_end_tag(s);
}
@@ -419,9 +419,9 @@ static int swf_write_video(AVFormatContext *s,
if (swf->audio_enc && av_fifo_size(swf->audio_fifo)) {
int frame_size = av_fifo_size(swf->audio_fifo);
put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG);
- put_le16(pb, swf->sound_samples);
- put_le16(pb, 0); // seek samples
- av_fifo_generic_read(swf->audio_fifo, pb, frame_size, &put_buffer);
+ avio_wl16(pb, swf->sound_samples);
+ avio_wl16(pb, 0); // seek samples
+ av_fifo_generic_read(swf->audio_fifo, pb, frame_size, &avio_write);
put_swf_end_tag(s);
/* update FIFO */
@@ -473,7 +473,7 @@ static int swf_write_packet(AVFormatContext *s, AVPacket *pkt)
static int swf_write_trailer(AVFormatContext *s)
{
SWFContext *swf = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *enc, *video_enc;
int file_size, i;
@@ -494,13 +494,13 @@ static int swf_write_trailer(AVFormatContext *s)
/* patch file size and number of frames if not streamed */
if (!url_is_streamed(s->pb) && video_enc) {
file_size = url_ftell(pb);
- url_fseek(pb, 4, SEEK_SET);
- put_le32(pb, file_size);
- url_fseek(pb, swf->duration_pos, SEEK_SET);
- put_le16(pb, swf->video_frame_number);
- url_fseek(pb, swf->vframes_pos, SEEK_SET);
- put_le16(pb, swf->video_frame_number);
- url_fseek(pb, file_size, SEEK_SET);
+ avio_seek(pb, 4, SEEK_SET);
+ avio_wl32(pb, file_size);
+ avio_seek(pb, swf->duration_pos, SEEK_SET);
+ avio_wl16(pb, swf->video_frame_number);
+ avio_seek(pb, swf->vframes_pos, SEEK_SET);
+ avio_wl16(pb, swf->video_frame_number);
+ avio_seek(pb, file_size, SEEK_SET);
}
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/tcp.c b/mplayer/ffmpeg/libavformat/tcp.c
index 3ee114a9..ce19c9cf 100644
--- a/mplayer/ffmpeg/libavformat/tcp.c
+++ b/mplayer/ffmpeg/libavformat/tcp.c
@@ -72,13 +72,13 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
ret = connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen);
if (ret < 0) {
struct pollfd p = {fd, POLLOUT, 0};
- if (ff_neterrno() == FF_NETERROR(EINTR)) {
+ if (ff_neterrno() == AVERROR(EINTR)) {
if (url_interrupt_cb())
goto fail1;
goto redo;
}
- if (ff_neterrno() != FF_NETERROR(EINPROGRESS) &&
- ff_neterrno() != FF_NETERROR(EAGAIN))
+ if (ff_neterrno() != AVERROR(EINPROGRESS) &&
+ ff_neterrno() != AVERROR(EAGAIN))
goto fail;
/* wait until we are connected or until abort */
@@ -87,22 +87,31 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
ret = AVERROR(EINTR);
goto fail1;
}
+#if defined(GEKKO)
+ usleep(1000);
+ connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen);
+ if (ff_neterrno() != AVERROR(EALREADY))
+ break;
+#else
ret = poll(&p, 1, 100);
if (ret > 0)
break;
+#endif
}
-#if !defined(GEKKO)
/* test error */
+#if defined(GEKKO)
+ if (ff_neterrno() != AVERROR(EISCONN)) {
+#else
optlen = sizeof(ret);
getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
if (ret != 0) {
+#endif
av_log(NULL, AV_LOG_ERROR,
"TCP connection to %s:%d failed: %s\n",
hostname, port, strerror(ret));
goto fail;
}
-#endif
}
s = av_malloc(sizeof(TCPContext));
if (!s) {
@@ -131,59 +140,46 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
return ret;
}
+static int tcp_wait_fd(int fd, int write)
+{
+ int ev = write ? POLLOUT : POLLIN;
+ struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
+ int ret;
+
+ ret = poll(&p, 1, 100);
+ return ret < 0 ? ff_neterrno() : p.revents & ev ? 0 : AVERROR(EAGAIN);
+}
+
static int tcp_read(URLContext *h, uint8_t *buf, int size)
{
TCPContext *s = h->priv_data;
- struct pollfd p = {s->fd, POLLIN, 0};
- int len, ret;
-
- for (;;) {
- if (url_interrupt_cb())
- return AVERROR(EINTR);
- ret = poll(&p, 1, 100);
- if (ret == 1 && p.revents & POLLIN) {
- len = recv(s->fd, buf, size, 0);
- if (len < 0) {
- if (ff_neterrno() != FF_NETERROR(EINTR) &&
- ff_neterrno() != FF_NETERROR(EAGAIN))
- return ff_neterrno();
- } else return len;
- } else if (ret < 0) {
- if (ff_neterrno() == FF_NETERROR(EINTR))
- continue;
- return -1;
- }
+ int ret;
+
+#if !defined(GEKKO)
+ if (!(h->flags & URL_FLAG_NONBLOCK)) {
+ ret = tcp_wait_fd(s->fd, 0);
+ if (ret < 0)
+ return ret;
}
+#endif
+ ret = recv(s->fd, buf, size, 0);
+ return ret < 0 ? ff_neterrno() : ret;
}
static int tcp_write(URLContext *h, const uint8_t *buf, int size)
{
TCPContext *s = h->priv_data;
- int ret, size1, len;
- struct pollfd p = {s->fd, POLLOUT, 0};
-
- size1 = size;
- while (size > 0) {
- if (url_interrupt_cb())
- return AVERROR(EINTR);
- ret = poll(&p, 1, 100);
- if (ret == 1 && p.revents & POLLOUT) {
- len = send(s->fd, buf, size, 0);
- if (len < 0) {
- if (ff_neterrno() != FF_NETERROR(EINTR) &&
- ff_neterrno() != FF_NETERROR(EAGAIN))
- return ff_neterrno();
- continue;
- }
- size -= len;
- buf += len;
- } else if (ret < 0) {
- if (ff_neterrno() == FF_NETERROR(EINTR))
- continue;
- return -1;
- }
+ int ret;
+
+#if !defined(GEKKO)
+ if (!(h->flags & URL_FLAG_NONBLOCK)) {
+ ret = tcp_wait_fd(s->fd, 1);
+ if (ret < 0)
+ return ret;
}
- return size1 - size;
+#endif
+ ret = send(s->fd, buf, size, 0);
+ return ret < 0 ? ff_neterrno() : ret;
}
static int tcp_close(URLContext *h)
diff --git a/mplayer/ffmpeg/libavformat/thp.c b/mplayer/ffmpeg/libavformat/thp.c
index 226f2fd2..2d1f74e3 100644
--- a/mplayer/ffmpeg/libavformat/thp.c
+++ b/mplayer/ffmpeg/libavformat/thp.c
@@ -57,35 +57,35 @@ static int thp_read_header(AVFormatContext *s,
{
ThpDemuxContext *thp = s->priv_data;
AVStream *st;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int i;
/* Read the file header. */
- get_be32(pb); /* Skip Magic. */
- thp->version = get_be32(pb);
+ avio_rb32(pb); /* Skip Magic. */
+ thp->version = avio_rb32(pb);
- get_be32(pb); /* Max buf size. */
- get_be32(pb); /* Max samples. */
+ avio_rb32(pb); /* Max buf size. */
+ avio_rb32(pb); /* Max samples. */
- thp->fps = av_d2q(av_int2flt(get_be32(pb)), INT_MAX);
- thp->framecnt = get_be32(pb);
- thp->first_framesz = get_be32(pb);
- get_be32(pb); /* Data size. */
+ thp->fps = av_d2q(av_int2flt(avio_rb32(pb)), INT_MAX);
+ thp->framecnt = avio_rb32(pb);
+ thp->first_framesz = avio_rb32(pb);
+ avio_rb32(pb); /* Data size. */
- thp->compoff = get_be32(pb);
- get_be32(pb); /* offsetDataOffset. */
- thp->first_frame = get_be32(pb);
- thp->last_frame = get_be32(pb);
+ thp->compoff = avio_rb32(pb);
+ avio_rb32(pb); /* offsetDataOffset. */
+ thp->first_frame = avio_rb32(pb);
+ thp->last_frame = avio_rb32(pb);
thp->next_framesz = thp->first_framesz;
thp->next_frame = thp->first_frame;
/* Read the component structure. */
- url_fseek (pb, thp->compoff, SEEK_SET);
- thp->compcount = get_be32(pb);
+ avio_seek (pb, thp->compoff, SEEK_SET);
+ thp->compcount = avio_rb32(pb);
/* Read the list of component types. */
- get_buffer(pb, thp->components, 16);
+ avio_read(pb, thp->components, 16);
for (i = 0; i < thp->compcount; i++) {
if (thp->components[i] == 0) {
@@ -103,14 +103,14 @@ static int thp_read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_THP;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = get_be32(pb);
- st->codec->height = get_be32(pb);
+ st->codec->width = avio_rb32(pb);
+ st->codec->height = avio_rb32(pb);
st->codec->sample_rate = av_q2d(thp->fps);
thp->vst = st;
thp->video_stream_index = st->index;
if (thp->version == 0x11000)
- get_be32(pb); /* Unknown. */
+ avio_rb32(pb); /* Unknown. */
} else if (thp->components[i] == 1) {
if (thp->has_audio != 0)
break;
@@ -123,8 +123,8 @@ static int thp_read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_ADPCM_THP;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->channels = get_be32(pb); /* numChannels. */
- st->codec->sample_rate = get_be32(pb); /* Frequency. */
+ st->codec->channels = avio_rb32(pb); /* numChannels. */
+ st->codec->sample_rate = avio_rb32(pb); /* Frequency. */
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
@@ -140,7 +140,7 @@ static int thp_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
ThpDemuxContext *thp = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int size;
int ret;
@@ -149,19 +149,19 @@ static int thp_read_packet(AVFormatContext *s,
if (thp->frame >= thp->framecnt)
return AVERROR(EIO);
- url_fseek(pb, thp->next_frame, SEEK_SET);
+ avio_seek(pb, thp->next_frame, SEEK_SET);
/* Locate the next frame and read out its size. */
thp->next_frame += thp->next_framesz;
- thp->next_framesz = get_be32(pb);
+ thp->next_framesz = avio_rb32(pb);
- get_be32(pb); /* Previous total size. */
- size = get_be32(pb); /* Total size of this frame. */
+ avio_rb32(pb); /* Previous total size. */
+ size = avio_rb32(pb); /* Total size of this frame. */
/* Store the audiosize so the next time this function is called,
the audio can be read. */
if (thp->has_audio)
- thp->audiosize = get_be32(pb); /* Audio size. */
+ thp->audiosize = avio_rb32(pb); /* Audio size. */
else
thp->frame++;
diff --git a/mplayer/ffmpeg/libavformat/tiertexseq.c b/mplayer/ffmpeg/libavformat/tiertexseq.c
index 2992fa1b..f8a5db18 100644
--- a/mplayer/ffmpeg/libavformat/tiertexseq.c
+++ b/mplayer/ffmpeg/libavformat/tiertexseq.c
@@ -78,15 +78,15 @@ static int seq_probe(AVProbeData *p)
return AVPROBE_SCORE_MAX / 4;
}
-static int seq_init_frame_buffers(SeqDemuxContext *seq, ByteIOContext *pb)
+static int seq_init_frame_buffers(SeqDemuxContext *seq, AVIOContext *pb)
{
int i, sz;
TiertexSeqFrameBuffer *seq_buffer;
- url_fseek(pb, 256, SEEK_SET);
+ avio_seek(pb, 256, SEEK_SET);
for (i = 0; i < SEQ_NUM_FRAME_BUFFERS; i++) {
- sz = get_le16(pb);
+ sz = avio_rl16(pb);
if (sz == 0)
break;
else {
@@ -102,7 +102,7 @@ static int seq_init_frame_buffers(SeqDemuxContext *seq, ByteIOContext *pb)
return 0;
}
-static int seq_fill_buffer(SeqDemuxContext *seq, ByteIOContext *pb, int buffer_num, unsigned int data_offs, int data_size)
+static int seq_fill_buffer(SeqDemuxContext *seq, AVIOContext *pb, int buffer_num, unsigned int data_offs, int data_size)
{
TiertexSeqFrameBuffer *seq_buffer;
@@ -113,25 +113,25 @@ static int seq_fill_buffer(SeqDemuxContext *seq, ByteIOContext *pb, int buffer_n
if (seq_buffer->fill_size + data_size > seq_buffer->data_size || data_size <= 0)
return AVERROR_INVALIDDATA;
- url_fseek(pb, seq->current_frame_offs + data_offs, SEEK_SET);
- if (get_buffer(pb, seq_buffer->data + seq_buffer->fill_size, data_size) != data_size)
+ avio_seek(pb, seq->current_frame_offs + data_offs, SEEK_SET);
+ if (avio_read(pb, seq_buffer->data + seq_buffer->fill_size, data_size) != data_size)
return AVERROR(EIO);
seq_buffer->fill_size += data_size;
return 0;
}
-static int seq_parse_frame_data(SeqDemuxContext *seq, ByteIOContext *pb)
+static int seq_parse_frame_data(SeqDemuxContext *seq, AVIOContext *pb)
{
unsigned int offset_table[4], buffer_num[4];
TiertexSeqFrameBuffer *seq_buffer;
int i, e, err;
seq->current_frame_offs += SEQ_FRAME_SIZE;
- url_fseek(pb, seq->current_frame_offs, SEEK_SET);
+ avio_seek(pb, seq->current_frame_offs, SEEK_SET);
/* sound data */
- seq->current_audio_data_offs = get_le16(pb);
+ seq->current_audio_data_offs = avio_rl16(pb);
if (seq->current_audio_data_offs) {
seq->current_audio_data_size = SEQ_AUDIO_BUFFER_SIZE * 2;
} else {
@@ -139,7 +139,7 @@ static int seq_parse_frame_data(SeqDemuxContext *seq, ByteIOContext *pb)
}
/* palette data */
- seq->current_pal_data_offs = get_le16(pb);
+ seq->current_pal_data_offs = avio_rl16(pb);
if (seq->current_pal_data_offs) {
seq->current_pal_data_size = 768;
} else {
@@ -148,10 +148,10 @@ static int seq_parse_frame_data(SeqDemuxContext *seq, ByteIOContext *pb)
/* video data */
for (i = 0; i < 4; i++)
- buffer_num[i] = get_byte(pb);
+ buffer_num[i] = avio_r8(pb);
for (i = 0; i < 4; i++)
- offset_table[i] = get_le16(pb);
+ offset_table[i] = avio_rl16(pb);
for (i = 0; i < 3; i++) {
if (offset_table[i]) {
@@ -184,7 +184,7 @@ static int seq_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
int i, rc;
SeqDemuxContext *seq = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
/* init internal buffers */
@@ -241,7 +241,7 @@ static int seq_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int rc;
SeqDemuxContext *seq = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
if (!seq->audio_buffer_full) {
rc = seq_parse_frame_data(seq, pb);
@@ -256,8 +256,8 @@ static int seq_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[0] = 0;
if (seq->current_pal_data_size) {
pkt->data[0] |= 1;
- url_fseek(pb, seq->current_frame_offs + seq->current_pal_data_offs, SEEK_SET);
- if (get_buffer(pb, &pkt->data[1], seq->current_pal_data_size) != seq->current_pal_data_size)
+ avio_seek(pb, seq->current_frame_offs + seq->current_pal_data_offs, SEEK_SET);
+ if (avio_read(pb, &pkt->data[1], seq->current_pal_data_size) != seq->current_pal_data_size)
return AVERROR(EIO);
}
if (seq->current_video_data_size) {
@@ -279,7 +279,7 @@ static int seq_read_packet(AVFormatContext *s, AVPacket *pkt)
if (seq->current_audio_data_offs == 0) /* end of data reached */
return AVERROR(EIO);
- url_fseek(pb, seq->current_frame_offs + seq->current_audio_data_offs, SEEK_SET);
+ avio_seek(pb, seq->current_frame_offs + seq->current_audio_data_offs, SEEK_SET);
rc = av_get_packet(pb, pkt, seq->current_audio_data_size);
if (rc < 0)
return rc;
diff --git a/mplayer/ffmpeg/libavformat/tmv.c b/mplayer/ffmpeg/libavformat/tmv.c
index 72d0f294..c632988e 100644
--- a/mplayer/ffmpeg/libavformat/tmv.c
+++ b/mplayer/ffmpeg/libavformat/tmv.c
@@ -65,12 +65,12 @@ static int tmv_probe(AVProbeData *p)
static int tmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
TMVContext *tmv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *vst, *ast;
AVRational fps;
unsigned comp_method, char_cols, char_rows, features;
- if (get_le32(pb) != TMV_TAG)
+ if (avio_rl32(pb) != TMV_TAG)
return -1;
if (!(vst = av_new_stream(s, 0)))
@@ -79,30 +79,30 @@ static int tmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (!(ast = av_new_stream(s, 0)))
return AVERROR(ENOMEM);
- ast->codec->sample_rate = get_le16(pb);
+ ast->codec->sample_rate = avio_rl16(pb);
if (!ast->codec->sample_rate) {
av_log(s, AV_LOG_ERROR, "invalid sample rate\n");
return -1;
}
- tmv->audio_chunk_size = get_le16(pb);
+ tmv->audio_chunk_size = avio_rl16(pb);
if (!tmv->audio_chunk_size) {
av_log(s, AV_LOG_ERROR, "invalid audio chunk size\n");
return -1;
}
- comp_method = get_byte(pb);
+ comp_method = avio_r8(pb);
if (comp_method) {
av_log(s, AV_LOG_ERROR, "unsupported compression method %d\n",
comp_method);
return -1;
}
- char_cols = get_byte(pb);
- char_rows = get_byte(pb);
+ char_cols = avio_r8(pb);
+ char_rows = avio_r8(pb);
tmv->video_chunk_size = char_cols * char_rows * 2;
- features = get_byte(pb);
+ features = avio_r8(pb);
if (features & ~(TMV_PADDING | TMV_STEREO)) {
av_log(s, AV_LOG_ERROR, "unsupported features 0x%02x\n",
features & ~(TMV_PADDING | TMV_STEREO));
@@ -142,7 +142,7 @@ static int tmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int tmv_read_packet(AVFormatContext *s, AVPacket *pkt)
{
TMVContext *tmv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret, pkt_size = tmv->stream_index ?
tmv->audio_chunk_size : tmv->video_chunk_size;
@@ -152,7 +152,7 @@ static int tmv_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = av_get_packet(pb, pkt, pkt_size);
if (tmv->stream_index)
- url_fskip(pb, tmv->padding);
+ avio_seek(pb, tmv->padding, SEEK_CUR);
pkt->stream_index = tmv->stream_index;
tmv->stream_index ^= 1;
@@ -173,7 +173,7 @@ static int tmv_read_seek(AVFormatContext *s, int stream_index,
pos = timestamp *
(tmv->audio_chunk_size + tmv->video_chunk_size + tmv->padding);
- url_fseek(s->pb, pos + TMV_HEADER_SIZE, SEEK_SET);
+ avio_seek(s->pb, pos + TMV_HEADER_SIZE, SEEK_SET);
tmv->stream_index = 0;
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/tta.c b/mplayer/ffmpeg/libavformat/tta.c
index 21b7538d..221cdf3e 100644
--- a/mplayer/ffmpeg/libavformat/tta.c
+++ b/mplayer/ffmpeg/libavformat/tta.c
@@ -47,25 +47,25 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
ff_id3v1_read(s);
start_offset = url_ftell(s->pb);
- if (get_le32(s->pb) != AV_RL32("TTA1"))
+ if (avio_rl32(s->pb) != AV_RL32("TTA1"))
return -1; // not tta file
- url_fskip(s->pb, 2); // FIXME: flags
- channels = get_le16(s->pb);
- bps = get_le16(s->pb);
- samplerate = get_le32(s->pb);
+ avio_seek(s->pb, 2, SEEK_CUR); // FIXME: flags
+ channels = avio_rl16(s->pb);
+ bps = avio_rl16(s->pb);
+ samplerate = avio_rl32(s->pb);
if(samplerate <= 0 || samplerate > 1000000){
av_log(s, AV_LOG_ERROR, "nonsense samplerate\n");
return -1;
}
- datalen = get_le32(s->pb);
+ datalen = avio_rl32(s->pb);
if(datalen < 0){
av_log(s, AV_LOG_ERROR, "nonsense datalen\n");
return -1;
}
- url_fskip(s->pb, 4); // header crc
+ avio_seek(s->pb, 4, SEEK_CUR); // header crc
framelen = samplerate*256/245;
c->totalframes = datalen / framelen + ((datalen % framelen) ? 1 : 0);
@@ -87,11 +87,11 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
framepos = url_ftell(s->pb) + 4*c->totalframes + 4;
for (i = 0; i < c->totalframes; i++) {
- uint32_t size = get_le32(s->pb);
+ uint32_t size = avio_rl32(s->pb);
av_add_index_entry(st, framepos, i*framelen, size, 0, AVINDEX_KEYFRAME);
framepos += size;
}
- url_fskip(s->pb, 4); // seektable crc
+ avio_seek(s->pb, 4, SEEK_CUR); // seektable crc
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_TTA;
@@ -101,13 +101,13 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->extradata_size = url_ftell(s->pb) - start_offset;
if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){
- //this check is redundant as get_buffer should fail
+ //this check is redundant as avio_read should fail
av_log(s, AV_LOG_ERROR, "extradata_size too large\n");
return -1;
}
st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
- url_fseek(s->pb, start_offset, SEEK_SET);
- get_buffer(s->pb, st->codec->extradata, st->codec->extradata_size);
+ avio_seek(s->pb, start_offset, SEEK_SET);
+ avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
return 0;
}
@@ -138,7 +138,7 @@ static int tta_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
return -1;
c->currentframe = index;
- url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET);
+ avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/tty.c b/mplayer/ffmpeg/libavformat/tty.c
index 0adbaf1f..74750584 100644
--- a/mplayer/ffmpeg/libavformat/tty.c
+++ b/mplayer/ffmpeg/libavformat/tty.c
@@ -42,19 +42,19 @@ typedef struct {
static int efi_read(AVFormatContext *avctx, uint64_t start_pos)
{
TtyDemuxContext *s = avctx->priv_data;
- ByteIOContext *pb = avctx->pb;
+ AVIOContext *pb = avctx->pb;
char buf[37];
int len;
- url_fseek(pb, start_pos, SEEK_SET);
- if (get_byte(pb) != 0x1A)
+ avio_seek(pb, start_pos, SEEK_SET);
+ if (avio_r8(pb) != 0x1A)
return -1;
#define GET_EFI_META(name,size) \
- len = get_byte(pb); \
+ len = avio_r8(pb); \
if (len < 1 || len > size) \
return -1; \
- if (get_buffer(pb, buf, size) == size) { \
+ if (avio_read(pb, buf, size) == size) { \
buf[len] = 0; \
av_metadata_set2(&avctx->metadata, name, buf, 0); \
}
@@ -95,7 +95,7 @@ static int read_header(AVFormatContext *avctx,
if (ff_sauce_read(avctx, &s->fsize, 0, 0) < 0)
efi_read(avctx, s->fsize - 51);
- url_fseek(avctx->pb, 0, SEEK_SET);
+ avio_seek(avctx->pb, 0, SEEK_SET);
}
return 0;
@@ -120,7 +120,7 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
pkt->size = av_get_packet(avctx->pb, pkt, n);
if (pkt->size <= 0)
return AVERROR(EIO);
- pkt->flags |= PKT_FLAG_KEY;
+ pkt->flags |= AV_PKT_FLAG_KEY;
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/txd.c b/mplayer/ffmpeg/libavformat/txd.c
index eb5e8b33..22dcfdbe 100644
--- a/mplayer/ffmpeg/libavformat/txd.c
+++ b/mplayer/ffmpeg/libavformat/txd.c
@@ -52,14 +52,14 @@ static int txd_read_header(AVFormatContext *s, AVFormatParameters *ap) {
}
static int txd_read_packet(AVFormatContext *s, AVPacket *pkt) {
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int id, chunk_size, marker;
int ret;
next_chunk:
- id = get_le32(pb);
- chunk_size = get_le32(pb);
- marker = get_le32(pb);
+ id = avio_rl32(pb);
+ chunk_size = avio_rl32(pb);
+ marker = avio_rl32(pb);
if (url_feof(s->pb))
return AVERROR_EOF;
@@ -73,7 +73,7 @@ static int txd_read_packet(AVFormatContext *s, AVPacket *pkt) {
if (chunk_size > 100)
break;
case TXD_EXTRA:
- url_fskip(s->pb, chunk_size);
+ avio_seek(s->pb, chunk_size, SEEK_CUR);
case TXD_FILE:
case TXD_TEXTURE:
goto next_chunk;
diff --git a/mplayer/ffmpeg/libavformat/udp.c b/mplayer/ffmpeg/libavformat/udp.c
index aa17c979..01965732 100644
--- a/mplayer/ffmpeg/libavformat/udp.c
+++ b/mplayer/ffmpeg/libavformat/udp.c
@@ -27,6 +27,7 @@
#define _BSD_SOURCE /* Needed for using struct ip_mreq with recent glibc */
#define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */
#include "avformat.h"
+#include "libavutil/parseutils.h"
#include
#include "internal.h"
#include "network.h"
@@ -259,7 +260,7 @@ int udp_set_remote_url(URLContext *h, const char *uri)
s->is_multicast = ff_is_multicast_address((struct sockaddr*) &s->dest_addr);
p = strchr(uri, '?');
if (p) {
- if (find_info_tag(buf, sizeof(buf), "connect", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
int was_connected = s->is_connected;
s->is_connected = strtol(buf, NULL, 10);
if (s->is_connected && !was_connected) {
@@ -313,6 +314,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
char buf[256];
struct sockaddr_storage my_addr;
int len;
+ int reuse_specified = 0;
h->is_streamed = 1;
h->max_packet_size = 1472;
@@ -329,20 +331,27 @@ static int udp_open(URLContext *h, const char *uri, int flags)
p = strchr(uri, '?');
if (p) {
- s->reuse_socket = find_info_tag(buf, sizeof(buf), "reuse", p);
- if (find_info_tag(buf, sizeof(buf), "ttl", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) {
+ const char *endptr=NULL;
+ s->reuse_socket = strtol(buf, &endptr, 10);
+ /* assume if no digits were found it is a request to enable it */
+ if (buf == endptr)
+ s->reuse_socket = 1;
+ reuse_specified = 1;
+ }
+ if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
s->ttl = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "localport", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
s->local_port = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
h->max_packet_size = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "buffer_size", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "buffer_size", p)) {
s->buffer_size = strtol(buf, NULL, 10);
}
- if (find_info_tag(buf, sizeof(buf), "connect", p)) {
+ if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
s->is_connected = strtol(buf, NULL, 10);
}
}
@@ -366,9 +375,14 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (udp_fd < 0)
goto fail;
- if (s->reuse_socket)
+ /* Follow the requested reuse option, unless it's multicast in which
+ * case enable reuse unless explicitely disabled.
+ */
+ if (s->reuse_socket || (s->is_multicast && !reuse_specified)) {
+ s->reuse_socket = 1;
if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
goto fail;
+ }
/* the bind is needed to give a port to the socket now */
/* if multicast, try the multicast address bind first */
@@ -441,7 +455,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
return AVERROR(EINTR);
ret = poll(&p, 1, 100);
if (ret < 0) {
- if (ff_neterrno() == FF_NETERROR(EINTR))
+ if (ff_neterrno() == AVERROR(EINTR))
continue;
return AVERROR(EIO);
}
@@ -449,8 +463,8 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
continue;
len = recv(s->udp_fd, buf, size, 0);
if (len < 0) {
- if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
- ff_neterrno() != FF_NETERROR(EINTR))
+ if (ff_neterrno() != AVERROR(EAGAIN) &&
+ ff_neterrno() != AVERROR(EINTR))
return AVERROR(EIO);
} else {
break;
@@ -472,8 +486,8 @@ static int udp_write(URLContext *h, const uint8_t *buf, int size)
} else
ret = send(s->udp_fd, buf, size, 0);
if (ret < 0) {
- if (ff_neterrno() != FF_NETERROR(EINTR) &&
- ff_neterrno() != FF_NETERROR(EAGAIN))
+ if (ff_neterrno() != AVERROR(EINTR) &&
+ ff_neterrno() != AVERROR(EAGAIN))
return ff_neterrno();
} else {
break;
diff --git a/mplayer/ffmpeg/libavformat/utils.c b/mplayer/ffmpeg/libavformat/utils.c
index 5cd23c8e..a86dffe3 100644
--- a/mplayer/ffmpeg/libavformat/utils.c
+++ b/mplayer/ffmpeg/libavformat/utils.c
@@ -325,7 +325,7 @@ FF_SYMVER(void, av_init_packet, (AVPacket *pkt), "LIBAVFORMAT_52")
}
#endif
-int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size)
+int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
{
int ret= av_new_packet(pkt, size);
@@ -334,7 +334,7 @@ int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size)
pkt->pos= url_ftell(s);
- ret= get_buffer(s, pkt->data, size);
+ ret= avio_read(s, pkt->data, size);
if(ret<=0)
av_free_packet(pkt);
else
@@ -343,7 +343,7 @@ int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size)
return ret;
}
-int av_append_packet(ByteIOContext *s, AVPacket *pkt, int size)
+int av_append_packet(AVIOContext *s, AVPacket *pkt, int size)
{
int ret;
int old_size;
@@ -353,7 +353,7 @@ int av_append_packet(ByteIOContext *s, AVPacket *pkt, int size)
ret = av_grow_packet(pkt, size);
if (ret < 0)
return ret;
- ret = get_buffer(s, pkt->data + old_size, size);
+ ret = avio_read(s, pkt->data + old_size, size);
av_shrink_packet(pkt, old_size + FFMAX(ret, 0));
return ret;
}
@@ -444,7 +444,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, AVProbeDa
* Open a media file from an IO stream. 'fmt' must be specified.
*/
int av_open_input_stream(AVFormatContext **ic_ptr,
- ByteIOContext *pb, const char *filename,
+ AVIOContext *pb, const char *filename,
AVInputFormat *fmt, AVFormatParameters *ap)
{
int err;
@@ -481,7 +481,7 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
ic->priv_data = NULL;
}
- // e.g. AVFMT_NOFILE formats will not have a ByteIOContext
+ // e.g. AVFMT_NOFILE formats will not have a AVIOContext
if (ic->pb)
ff_id3v2_read(ic, ID3v2_DEFAULT_MAGIC);
@@ -526,7 +526,7 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
#define PROBE_BUF_MIN 2048
#define PROBE_BUF_MAX (1<<20)
-int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,
+int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
const char *filename, void *logctx,
unsigned int offset, unsigned int max_probe_size)
{
@@ -557,7 +557,7 @@ int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,
/* read probe data */
buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE);
- if ((ret = get_buffer(*pb, buf + buf_offset, probe_size - buf_offset)) < 0) {
+ if ((ret = avio_read(pb, buf + buf_offset, probe_size - buf_offset)) < 0) {
/* fail if error was not end of file, otherwise, lower score */
if (ret != AVERROR_EOF) {
av_free(buf);
@@ -587,7 +587,7 @@ int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,
}
/* rewind. reuse probe buffer to avoid seeking */
- if ((ret = ff_rewind_with_probe_data(*pb, buf, pd.buf_size)) < 0)
+ if ((ret = ff_rewind_with_probe_data(pb, buf, pd.buf_size)) < 0)
av_free(buf);
return ret;
@@ -600,7 +600,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
{
int err;
AVProbeData probe_data, *pd = &probe_data;
- ByteIOContext *pb = NULL;
+ AVIOContext *pb = NULL;
void *logctx= ap && ap->prealloced_context ? *ic_ptr : NULL;
pd->filename = "";
@@ -618,13 +618,13 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
hack needed to handle RTSP/TCP */
if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {
/* if no file needed do not try to open one */
- if ((err=url_fopen(&pb, filename, URL_RDONLY)) < 0) {
+ if ((err=avio_open(&pb, filename, URL_RDONLY)) < 0) {
goto fail;
}
if (buf_size > 0) {
url_setbufsize(pb, buf_size);
}
- if (!fmt && (err = ff_probe_input_buffer(&pb, &fmt, filename, logctx, 0, logctx ? (*ic_ptr)->probesize : 0)) < 0) {
+ if (!fmt && (err = av_probe_input_buffer(pb, &fmt, filename, logctx, 0, logctx ? (*ic_ptr)->probesize : 0)) < 0) {
goto fail;
}
}
@@ -649,7 +649,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
fail:
av_freep(&pd->buf);
if (pb)
- url_fclose(pb);
+ avio_close(pb);
if (ap && ap->prealloced_context)
av_free(*ic_ptr);
*ic_ptr = NULL;
@@ -932,6 +932,12 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
/* do we have a video B-frame ? */
delay= st->codec->has_b_frames;
presentation_delayed = 0;
+
+ // ignore delay caused by frame threading so that the mpeg2-without-dts
+ // warning will not trigger
+ if (delay && st->codec->active_thread_type&FF_THREAD_FRAME)
+ delay -= st->codec->thread_count-1;
+
/* XXX: need has_b_frame, but cannot get it if the codec is
not initialized */
if (delay &&
@@ -1372,28 +1378,30 @@ void ff_reduce_index(AVFormatContext *s, int stream_index)
}
}
-int av_add_index_entry(AVStream *st,
- int64_t pos, int64_t timestamp, int size, int distance, int flags)
+int ff_add_index_entry(AVIndexEntry **index_entries,
+ int *nb_index_entries,
+ unsigned int *index_entries_allocated_size,
+ int64_t pos, int64_t timestamp, int size, int distance, int flags)
{
AVIndexEntry *entries, *ie;
int index;
- if((unsigned)st->nb_index_entries + 1 >= UINT_MAX / sizeof(AVIndexEntry))
+ if((unsigned)*nb_index_entries + 1 >= UINT_MAX / sizeof(AVIndexEntry))
return -1;
- entries = av_fast_realloc(st->index_entries,
- &st->index_entries_allocated_size,
- (st->nb_index_entries + 1) *
+ entries = av_fast_realloc(*index_entries,
+ index_entries_allocated_size,
+ (*nb_index_entries + 1) *
sizeof(AVIndexEntry));
if(!entries)
return -1;
- st->index_entries= entries;
+ *index_entries= entries;
- index= av_index_search_timestamp(st, timestamp, AVSEEK_FLAG_ANY);
+ index= ff_index_search_timestamp(*index_entries, *nb_index_entries, timestamp, AVSEEK_FLAG_ANY);
if(index<0){
- index= st->nb_index_entries++;
+ index= (*nb_index_entries)++;
ie= &entries[index];
assert(index==0 || ie[-1].timestamp < timestamp);
}else{
@@ -1401,8 +1409,8 @@ int av_add_index_entry(AVStream *st,
if(ie->timestamp != timestamp){
if(ie->timestamp <= timestamp)
return -1;
- memmove(entries + index + 1, entries + index, sizeof(AVIndexEntry)*(st->nb_index_entries - index));
- st->nb_index_entries++;
+ memmove(entries + index + 1, entries + index, sizeof(AVIndexEntry)*(*nb_index_entries - index));
+ (*nb_index_entries)++;
}else if(ie->pos == pos && distance < ie->min_distance) //do not reduce the distance
distance= ie->min_distance;
}
@@ -1416,11 +1424,17 @@ int av_add_index_entry(AVStream *st,
return index;
}
-int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp,
- int flags)
+int av_add_index_entry(AVStream *st,
+ int64_t pos, int64_t timestamp, int size, int distance, int flags)
+{
+ return ff_add_index_entry(&st->index_entries, &st->nb_index_entries,
+ &st->index_entries_allocated_size, pos,
+ timestamp, size, distance, flags);
+}
+
+int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries,
+ int64_t wanted_timestamp, int flags)
{
- AVIndexEntry *entries= st->index_entries;
- int nb_entries= st->nb_index_entries;
int a, b, m;
int64_t timestamp;
@@ -1452,6 +1466,13 @@ int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp,
return m;
}
+int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp,
+ int flags)
+{
+ return ff_index_search_timestamp(st->index_entries, st->nb_index_entries,
+ wanted_timestamp, flags);
+}
+
#define DEBUG_SEEK
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){
@@ -1512,7 +1533,7 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts
return -1;
/* do the seek */
- if ((ret = url_fseek(s->pb, pos, SEEK_SET)) < 0)
+ if ((ret = avio_seek(s->pb, pos, SEEK_SET)) < 0)
return ret;
av_update_cur_dts(s, st, ts);
@@ -1652,7 +1673,7 @@ static int av_seek_frame_byte(AVFormatContext *s, int stream_index, int64_t pos,
if (pos < pos_min) pos= pos_min;
else if(pos > pos_max) pos= pos_max;
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
#if 0
av_update_cur_dts(s, st, ts);
@@ -1682,11 +1703,11 @@ static int av_seek_frame_generic(AVFormatContext *s,
if(st->nb_index_entries){
assert(st->index_entries);
ie= &st->index_entries[st->nb_index_entries-1];
- if ((ret = url_fseek(s->pb, ie->pos, SEEK_SET)) < 0)
+ if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0)
return ret;
av_update_cur_dts(s, st, ie->timestamp);
}else{
- if ((ret = url_fseek(s->pb, s->data_offset, SEEK_SET)) < 0)
+ if ((ret = avio_seek(s->pb, s->data_offset, SEEK_SET)) < 0)
return ret;
}
for(i=0;; i++) {
@@ -1713,7 +1734,7 @@ static int av_seek_frame_generic(AVFormatContext *s,
return 0;
}
ie = &st->index_entries[index];
- if ((ret = url_fseek(s->pb, ie->pos, SEEK_SET)) < 0)
+ if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0)
return ret;
av_update_cur_dts(s, st, ie->timestamp);
@@ -1937,7 +1958,7 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset
if (offset < 0)
offset = 0;
- url_fseek(ic->pb, offset, SEEK_SET);
+ avio_seek(ic->pb, offset, SEEK_SET);
read_size = 0;
for(;;) {
if (read_size >= DURATION_MAX_READ_SIZE<<(FFMAX(retry-1,0)))
@@ -1972,7 +1993,7 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset
fill_all_stream_timings(ic);
- url_fseek(ic->pb, old_offset, SEEK_SET);
+ avio_seek(ic->pb, old_offset, SEEK_SET);
for (i=0; inb_streams; i++) {
st= ic->streams[i];
st->cur_dts= st->first_dts;
@@ -2497,6 +2518,8 @@ int av_find_best_stream(AVFormatContext *ic,
continue;
if (wanted_stream_nb >= 0 && stream_number++ != wanted_stream_nb)
continue;
+ if (st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_VISUAL_IMPAIRED))
+ continue;
if (decoder_ret) {
decoder = avcodec_find_decoder(ic->streams[i]->codec->codec_id);
if (!decoder) {
@@ -2508,7 +2531,7 @@ int av_find_best_stream(AVFormatContext *ic,
if (best_count >= st->codec_info_nb_frames)
continue;
best_count = st->codec_info_nb_frames;
- ret = i;
+ ret = program ? program[i] : i;
best_decoder = decoder;
if (program && i == nb_streams - 1 && ret < 0) {
program = NULL;
@@ -2543,12 +2566,17 @@ int av_read_pause(AVFormatContext *s)
void av_close_input_stream(AVFormatContext *s)
{
- int i;
- AVStream *st;
-
flush_packet_queue(s);
if (s->iformat->read_close)
s->iformat->read_close(s);
+ avformat_free_context(s);
+}
+
+void avformat_free_context(AVFormatContext *s)
+{
+ int i;
+ AVStream *st;
+
for(i=0;inb_streams;i++) {
/* free all data in a stream component */
st = s->streams[i];
@@ -2594,10 +2622,10 @@ void av_close_input_stream(AVFormatContext *s)
void av_close_input_file(AVFormatContext *s)
{
- ByteIOContext *pb = s->iformat->flags & AVFMT_NOFILE ? NULL : s->pb;
+ AVIOContext *pb = s->iformat->flags & AVFMT_NOFILE ? NULL : s->pb;
av_close_input_stream(s);
if (pb)
- url_fclose(pb);
+ avio_close(pb);
}
AVStream *av_new_stream(AVFormatContext *s, int id)
@@ -3211,14 +3239,44 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out
if(st->codec->time_base.den && st->codec->time_base.num)
print_fps(1/av_q2d(st->codec->time_base), "tbc");
}
+ if (st->disposition & AV_DISPOSITION_DEFAULT)
+ av_log(NULL, AV_LOG_INFO, " (default)");
+ if (st->disposition & AV_DISPOSITION_DUB)
+ av_log(NULL, AV_LOG_INFO, " (dub)");
+ if (st->disposition & AV_DISPOSITION_ORIGINAL)
+ av_log(NULL, AV_LOG_INFO, " (original)");
+ if (st->disposition & AV_DISPOSITION_COMMENT)
+ av_log(NULL, AV_LOG_INFO, " (comment)");
+ if (st->disposition & AV_DISPOSITION_LYRICS)
+ av_log(NULL, AV_LOG_INFO, " (lyrics)");
+ if (st->disposition & AV_DISPOSITION_KARAOKE)
+ av_log(NULL, AV_LOG_INFO, " (karaoke)");
+ if (st->disposition & AV_DISPOSITION_FORCED)
+ av_log(NULL, AV_LOG_INFO, " (forced)");
+ if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
+ av_log(NULL, AV_LOG_INFO, " (hearing impaired)");
+ if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
+ av_log(NULL, AV_LOG_INFO, " (visual impaired)");
+ if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
+ av_log(NULL, AV_LOG_INFO, " (clean effects)");
av_log(NULL, AV_LOG_INFO, "\n");
dump_metadata(NULL, st->metadata, " ");
}
+#if FF_API_DUMP_FORMAT
void dump_format(AVFormatContext *ic,
int index,
const char *url,
int is_output)
+{
+ av_dump_format(ic, index, url, is_output);
+}
+#endif
+
+void av_dump_format(AVFormatContext *ic,
+ int index,
+ const char *url,
+ int is_output)
{
int i;
uint8_t *printed = av_mallocz(ic->nb_streams);
@@ -3295,7 +3353,7 @@ void dump_format(AVFormatContext *ic,
}
#if FF_API_PARSE_FRAME_PARAM
-#include "libavcore/parseutils.h"
+#include "libavutil/parseutils.h"
int parse_image_size(int *width_ptr, int *height_ptr, const char *str)
{
@@ -3324,163 +3382,25 @@ uint64_t ff_ntp_time(void)
return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;
}
-int64_t parse_date(const char *datestr, int duration)
-{
- const char *p;
- int64_t t;
- struct tm dt;
- int i;
- static const char * const date_fmt[] = {
- "%Y-%m-%d",
- "%Y%m%d",
- };
- static const char * const time_fmt[] = {
- "%H:%M:%S",
- "%H%M%S",
- };
- const char *q;
- int is_utc, len;
- char lastch;
- int negative = 0;
-
-#undef time
- time_t now = time(0);
-
- len = strlen(datestr);
- if (len > 0)
- lastch = datestr[len - 1];
- else
- lastch = '\0';
- is_utc = (lastch == 'z' || lastch == 'Z');
-
- memset(&dt, 0, sizeof(dt));
-
- p = datestr;
- q = NULL;
- if (!duration) {
- if (!strncasecmp(datestr, "now", len))
- return (int64_t) now * 1000000;
-
- /* parse the year-month-day part */
- for (i = 0; i < FF_ARRAY_ELEMS(date_fmt); i++) {
- q = small_strptime(p, date_fmt[i], &dt);
- if (q) {
- break;
- }
- }
-
- /* if the year-month-day part is missing, then take the
- * current year-month-day time */
- if (!q) {
- if (is_utc) {
- dt = *gmtime(&now);
- } else {
- dt = *localtime(&now);
- }
- dt.tm_hour = dt.tm_min = dt.tm_sec = 0;
- } else {
- p = q;
- }
-
- if (*p == 'T' || *p == 't' || *p == ' ')
- p++;
-
- /* parse the hour-minute-second part */
- for (i = 0; i < FF_ARRAY_ELEMS(time_fmt); i++) {
- q = small_strptime(p, time_fmt[i], &dt);
- if (q) {
- break;
- }
- }
- } else {
- /* parse datestr as a duration */
- if (p[0] == '-') {
- negative = 1;
- ++p;
- }
- /* parse datestr as HH:MM:SS */
- q = small_strptime(p, time_fmt[0], &dt);
- if (!q) {
- /* parse datestr as S+ */
- dt.tm_sec = strtol(p, (char **)&q, 10);
- if (q == p)
- /* the parsing didn't succeed */
- return INT64_MIN;
- dt.tm_min = 0;
- dt.tm_hour = 0;
- }
- }
-
- /* Now we have all the fields that we can get */
- if (!q) {
- return INT64_MIN;
- }
-
- if (duration) {
- t = dt.tm_hour * 3600 + dt.tm_min * 60 + dt.tm_sec;
- } else {
- dt.tm_isdst = -1; /* unknown */
- if (is_utc) {
- t = mktimegm(&dt);
- } else {
- t = mktime(&dt);
- }
- }
-
- t *= 1000000;
+#if FF_API_PARSE_DATE
+#include "libavutil/parseutils.h"
- /* parse the .m... part */
- if (*q == '.') {
- int val, n;
- q++;
- for (val = 0, n = 100000; n >= 1; n /= 10, q++) {
- if (!isdigit(*q))
- break;
- val += n * (*q - '0');
- }
- t += val;
- }
- return negative ? -t : t;
+int64_t parse_date(const char *timestr, int duration)
+{
+ int64_t timeval;
+ av_parse_time(&timeval, timestr, duration);
+ return timeval;
}
+#endif
+
+#if FF_API_FIND_INFO_TAG
+#include "libavutil/parseutils.h"
int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
{
- const char *p;
- char tag[128], *q;
-
- p = info;
- if (*p == '?')
- p++;
- for(;;) {
- q = tag;
- while (*p != '\0' && *p != '=' && *p != '&') {
- if ((q - tag) < sizeof(tag) - 1)
- *q++ = *p;
- p++;
- }
- *q = '\0';
- q = arg;
- if (*p == '=') {
- p++;
- while (*p != '&' && *p != '\0') {
- if ((q - arg) < arg_size - 1) {
- if (*p == '+')
- *q++ = ' ';
- else
- *q++ = *p;
- }
- p++;
- }
- }
- *q = '\0';
- if (!strcmp(tag, tag1))
- return 1;
- if (*p != '&')
- break;
- p++;
- }
- return 0;
+ return av_find_info_tag(arg, arg_size, tag1, info);
}
+#endif
int av_get_frame_filename(char *buf, int buf_size,
const char *path, int number)
@@ -3576,26 +3496,25 @@ void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size)
hex_dump_internal(avcl, NULL, level, buf, size);
}
- //FIXME needs to know the time_base
-static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt, int dump_payload)
+static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt, int dump_payload, AVRational time_base)
{
#undef fprintf
#define PRINT(...) do { if (!f) av_log(avcl, level, __VA_ARGS__); else fprintf(f, __VA_ARGS__); } while(0)
PRINT("stream #%d:\n", pkt->stream_index);
PRINT(" keyframe=%d\n", ((pkt->flags & AV_PKT_FLAG_KEY) != 0));
- PRINT(" duration=%0.3f\n", (double)pkt->duration / AV_TIME_BASE);
+ PRINT(" duration=%0.3f\n", pkt->duration * av_q2d(time_base));
/* DTS is _always_ valid after av_read_frame() */
PRINT(" dts=");
if (pkt->dts == AV_NOPTS_VALUE)
PRINT("N/A");
else
- PRINT("%0.3f", (double)pkt->dts / AV_TIME_BASE);
+ PRINT("%0.3f", pkt->dts * av_q2d(time_base));
/* PTS may not be known if B-frames are present. */
PRINT(" pts=");
if (pkt->pts == AV_NOPTS_VALUE)
PRINT("N/A");
else
- PRINT("%0.3f", (double)pkt->pts / AV_TIME_BASE);
+ PRINT("%0.3f", pkt->pts * av_q2d(time_base));
PRINT("\n");
PRINT(" size=%d\n", pkt->size);
#undef PRINT
@@ -3605,12 +3524,25 @@ static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt, int
void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload)
{
- pkt_dump_internal(NULL, f, 0, pkt, dump_payload);
+ AVRational tb = { 1, AV_TIME_BASE };
+ pkt_dump_internal(NULL, f, 0, pkt, dump_payload, tb);
+}
+
+void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st)
+{
+ pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base);
}
void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload)
{
- pkt_dump_internal(avcl, NULL, level, pkt, dump_payload);
+ AVRational tb = { 1, AV_TIME_BASE };
+ pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, tb);
+}
+
+void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
+ AVStream *st)
+{
+ pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base);
}
#if FF_API_URL_SPLIT
@@ -3744,16 +3676,19 @@ int ff_hex_to_data(uint8_t *data, const char *p)
void av_set_pts_info(AVStream *s, int pts_wrap_bits,
unsigned int pts_num, unsigned int pts_den)
{
- s->pts_wrap_bits = pts_wrap_bits;
-
- if(av_reduce(&s->time_base.num, &s->time_base.den, pts_num, pts_den, INT_MAX)){
- if(s->time_base.num != pts_num)
- av_log(NULL, AV_LOG_DEBUG, "st:%d removing common factor %d from timebase\n", s->index, pts_num/s->time_base.num);
+ AVRational new_tb;
+ if(av_reduce(&new_tb.num, &new_tb.den, pts_num, pts_den, INT_MAX)){
+ if(new_tb.num != pts_num)
+ av_log(NULL, AV_LOG_DEBUG, "st:%d removing common factor %d from timebase\n", s->index, pts_num/new_tb.num);
}else
av_log(NULL, AV_LOG_WARNING, "st:%d has too large timebase, reducing\n", s->index);
- if(!s->time_base.num || !s->time_base.den)
- s->time_base.num= s->time_base.den= 0;
+ if(new_tb.num <= 0 || new_tb.den <= 0) {
+ av_log(NULL, AV_LOG_ERROR, "Ignoring attempt to set invalid timebase for st:%d\n", s->index);
+ return;
+ }
+ s->time_base = new_tb;
+ s->pts_wrap_bits = pts_wrap_bits;
}
int ff_url_join(char *str, int size, const char *proto,
diff --git a/mplayer/ffmpeg/libavformat/vc1test.c b/mplayer/ffmpeg/libavformat/vc1test.c
index 8dd735da..2f84b526 100644
--- a/mplayer/ffmpeg/libavformat/vc1test.c
+++ b/mplayer/ffmpeg/libavformat/vc1test.c
@@ -44,13 +44,13 @@ static int vc1t_probe(AVProbeData *p)
static int vc1t_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
int frames;
uint32_t fps;
- frames = get_le24(pb);
- if(get_byte(pb) != 0xC5 || get_le32(pb) != 4)
+ frames = avio_rl24(pb);
+ if(avio_r8(pb) != 0xC5 || avio_rl32(pb) != 4)
return -1;
/* init video codec */
@@ -63,13 +63,13 @@ static int vc1t_read_header(AVFormatContext *s,
st->codec->extradata = av_malloc(VC1_EXTRADATA_SIZE);
st->codec->extradata_size = VC1_EXTRADATA_SIZE;
- get_buffer(pb, st->codec->extradata, VC1_EXTRADATA_SIZE);
- st->codec->height = get_le32(pb);
- st->codec->width = get_le32(pb);
- if(get_le32(pb) != 0xC)
+ avio_read(pb, st->codec->extradata, VC1_EXTRADATA_SIZE);
+ st->codec->height = avio_rl32(pb);
+ st->codec->width = avio_rl32(pb);
+ if(avio_rl32(pb) != 0xC)
return -1;
- url_fskip(pb, 8);
- fps = get_le32(pb);
+ avio_seek(pb, 8, SEEK_CUR);
+ fps = avio_rl32(pb);
if(fps == 0xFFFFFFFF)
av_set_pts_info(st, 32, 1, 1000);
else{
@@ -87,7 +87,7 @@ static int vc1t_read_header(AVFormatContext *s,
static int vc1t_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int frame_size;
int keyframe = 0;
uint32_t pts;
@@ -95,10 +95,10 @@ static int vc1t_read_packet(AVFormatContext *s,
if(url_feof(pb))
return AVERROR(EIO);
- frame_size = get_le24(pb);
- if(get_byte(pb) & 0x80)
+ frame_size = avio_rl24(pb);
+ if(avio_r8(pb) & 0x80)
keyframe = 1;
- pts = get_le32(pb);
+ pts = avio_rl32(pb);
if(av_get_packet(pb, pkt, frame_size) < 0)
return AVERROR(EIO);
if(s->streams[0]->time_base.den == 1000)
diff --git a/mplayer/ffmpeg/libavformat/vc1testenc.c b/mplayer/ffmpeg/libavformat/vc1testenc.c
index 507b332a..65ac6029 100644
--- a/mplayer/ffmpeg/libavformat/vc1testenc.c
+++ b/mplayer/ffmpeg/libavformat/vc1testenc.c
@@ -27,26 +27,27 @@ typedef struct RCVContext {
static int vc1test_write_header(AVFormatContext *s)
{
AVCodecContext *avc = s->streams[0]->codec;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
if (avc->codec_id != CODEC_ID_WMV3) {
av_log(s, AV_LOG_ERROR, "Only WMV3 is accepted!\n");
return -1;
}
- put_le24(pb, 0); //frames count will be here
- put_byte(pb, 0xC5);
- put_le32(pb, 4);
- put_buffer(pb, avc->extradata, 4);
- put_le32(pb, avc->height);
- put_le32(pb, avc->width);
- put_le32(pb, 0xC);
- put_le24(pb, 0); // hrd_buffer
- put_byte(pb, 0x80); // level|cbr|res1
- put_le32(pb, 0); // hrd_rate
+ avio_wl24(pb, 0); //frames count will be here
+ avio_w8(pb, 0xC5);
+ avio_wl32(pb, 4);
+ avio_write(pb, avc->extradata, 4);
+ avio_wl32(pb, avc->height);
+ avio_wl32(pb, avc->width);
+ avio_wl32(pb, 0xC);
+ avio_wl24(pb, 0); // hrd_buffer
+ avio_w8(pb, 0x80); // level|cbr|res1
+ avio_wl32(pb, 0); // hrd_rate
if (s->streams[0]->r_frame_rate.den && s->streams[0]->r_frame_rate.num == 1)
- put_le32(pb, s->streams[0]->r_frame_rate.den);
+ avio_wl32(pb, s->streams[0]->r_frame_rate.den);
else
- put_le32(pb, 0xFFFFFFFF); //variable framerate
+ avio_wl32(pb, 0xFFFFFFFF); //variable framerate
+ av_set_pts_info(s->streams[0], 32, 1, 1000);
return 0;
}
@@ -54,13 +55,13 @@ static int vc1test_write_header(AVFormatContext *s)
static int vc1test_write_packet(AVFormatContext *s, AVPacket *pkt)
{
RCVContext *ctx = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
if (!pkt->size)
return 0;
- put_le32(pb, pkt->size | ((pkt->flags & AV_PKT_FLAG_KEY) ? 0x80000000 : 0));
- put_le32(pb, pkt->pts);
- put_buffer(pb, pkt->data, pkt->size);
+ avio_wl32(pb, pkt->size | ((pkt->flags & AV_PKT_FLAG_KEY) ? 0x80000000 : 0));
+ avio_wl32(pb, pkt->pts);
+ avio_write(pb, pkt->data, pkt->size);
put_flush_packet(pb);
ctx->frames++;
@@ -70,11 +71,11 @@ static int vc1test_write_packet(AVFormatContext *s, AVPacket *pkt)
static int vc1test_write_trailer(AVFormatContext *s)
{
RCVContext *ctx = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
if (!url_is_streamed(s->pb)) {
- url_fseek(pb, 0, SEEK_SET);
- put_le24(pb, ctx->frames);
+ avio_seek(pb, 0, SEEK_SET);
+ avio_wl24(pb, ctx->frames);
put_flush_packet(pb);
}
return 0;
diff --git a/mplayer/ffmpeg/libavformat/version.h b/mplayer/ffmpeg/libavformat/version.h
index 9a902aa4..494cf11a 100644
--- a/mplayer/ffmpeg/libavformat/version.h
+++ b/mplayer/ffmpeg/libavformat/version.h
@@ -24,7 +24,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 52
-#define LIBAVFORMAT_VERSION_MINOR 94
+#define LIBAVFORMAT_VERSION_MINOR 102
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -89,5 +89,17 @@
#ifndef FF_API_OLD_AVIO
#define FF_API_OLD_AVIO (LIBAVFORMAT_VERSION_MAJOR < 53)
#endif
+#ifndef FF_API_INDEX_BUILT
+#define FF_API_INDEX_BUILT (LIBAVFORMAT_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_DUMP_FORMAT
+#define FF_API_DUMP_FORMAT (LIBAVFORMAT_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_PARSE_DATE
+#define FF_API_PARSE_DATE (LIBAVFORMAT_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_FIND_INFO_TAG
+#define FF_API_FIND_INFO_TAG (LIBAVFORMAT_VERSION_MAJOR < 54)
+#endif
#endif //AVFORMAT_VERSION_H
diff --git a/mplayer/ffmpeg/libavformat/vocdec.c b/mplayer/ffmpeg/libavformat/vocdec.c
index 7ef29d8d..cb496bf7 100644
--- a/mplayer/ffmpeg/libavformat/vocdec.c
+++ b/mplayer/ffmpeg/libavformat/vocdec.c
@@ -41,17 +41,17 @@ static int voc_probe(AVProbeData *p)
static int voc_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
VocDecContext *voc = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int header_size;
AVStream *st;
- url_fskip(pb, 20);
- header_size = get_le16(pb) - 22;
+ avio_seek(pb, 20, SEEK_CUR);
+ header_size = avio_rl16(pb) - 22;
if (header_size != 4) {
av_log(s, AV_LOG_ERROR, "unknown header size: %d\n", header_size);
return AVERROR(ENOSYS);
}
- url_fskip(pb, header_size);
+ avio_seek(pb, header_size, SEEK_CUR);
st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
@@ -66,17 +66,17 @@ voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
{
VocDecContext *voc = s->priv_data;
AVCodecContext *dec = st->codec;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
VocType type;
int size, tmp_codec=-1;
int sample_rate = 0;
int channels = 1;
while (!voc->remaining_size) {
- type = get_byte(pb);
+ type = avio_r8(pb);
if (type == VOC_TYPE_EOF)
return AVERROR(EIO);
- voc->remaining_size = get_le24(pb);
+ voc->remaining_size = avio_rl24(pb);
if (!voc->remaining_size) {
if (url_is_streamed(s->pb))
return AVERROR(EIO);
@@ -86,11 +86,11 @@ voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
switch (type) {
case VOC_TYPE_VOICE_DATA:
- dec->sample_rate = 1000000 / (256 - get_byte(pb));
+ dec->sample_rate = 1000000 / (256 - avio_r8(pb));
if (sample_rate)
dec->sample_rate = sample_rate;
dec->channels = channels;
- tmp_codec = get_byte(pb);
+ tmp_codec = avio_r8(pb);
dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id);
voc->remaining_size -= 2;
max_size -= 2;
@@ -101,26 +101,26 @@ voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
break;
case VOC_TYPE_EXTENDED:
- sample_rate = get_le16(pb);
- get_byte(pb);
- channels = get_byte(pb) + 1;
+ sample_rate = avio_rl16(pb);
+ avio_r8(pb);
+ channels = avio_r8(pb) + 1;
sample_rate = 256000000 / (channels * (65536 - sample_rate));
voc->remaining_size = 0;
max_size -= 4;
break;
case VOC_TYPE_NEW_VOICE_DATA:
- dec->sample_rate = get_le32(pb);
- dec->bits_per_coded_sample = get_byte(pb);
- dec->channels = get_byte(pb);
- tmp_codec = get_le16(pb);
- url_fskip(pb, 4);
+ dec->sample_rate = avio_rl32(pb);
+ dec->bits_per_coded_sample = avio_r8(pb);
+ dec->channels = avio_r8(pb);
+ tmp_codec = avio_rl16(pb);
+ avio_seek(pb, 4, SEEK_CUR);
voc->remaining_size -= 12;
max_size -= 12;
break;
default:
- url_fskip(pb, voc->remaining_size);
+ avio_seek(pb, voc->remaining_size, SEEK_CUR);
max_size -= voc->remaining_size;
voc->remaining_size = 0;
break;
diff --git a/mplayer/ffmpeg/libavformat/vocenc.c b/mplayer/ffmpeg/libavformat/vocenc.c
index 8d181de7..74cd4790 100644
--- a/mplayer/ffmpeg/libavformat/vocenc.c
+++ b/mplayer/ffmpeg/libavformat/vocenc.c
@@ -29,7 +29,7 @@ typedef struct voc_enc_context {
static int voc_write_header(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
const int header_size = 26;
const int version = 0x0114;
@@ -37,10 +37,10 @@ static int voc_write_header(AVFormatContext *s)
|| s->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO)
return AVERROR_PATCHWELCOME;
- put_buffer(pb, ff_voc_magic, sizeof(ff_voc_magic) - 1);
- put_le16(pb, header_size);
- put_le16(pb, version);
- put_le16(pb, ~version + 0x1234);
+ avio_write(pb, ff_voc_magic, sizeof(ff_voc_magic) - 1);
+ avio_wl16(pb, header_size);
+ avio_wl16(pb, version);
+ avio_wl16(pb, ~version + 0x1234);
return 0;
}
@@ -49,43 +49,43 @@ static int voc_write_packet(AVFormatContext *s, AVPacket *pkt)
{
VocEncContext *voc = s->priv_data;
AVCodecContext *enc = s->streams[0]->codec;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
if (!voc->param_written) {
if (enc->codec_tag > 0xFF) {
- put_byte(pb, VOC_TYPE_NEW_VOICE_DATA);
- put_le24(pb, pkt->size + 12);
- put_le32(pb, enc->sample_rate);
- put_byte(pb, enc->bits_per_coded_sample);
- put_byte(pb, enc->channels);
- put_le16(pb, enc->codec_tag);
- put_le32(pb, 0);
+ avio_w8(pb, VOC_TYPE_NEW_VOICE_DATA);
+ avio_wl24(pb, pkt->size + 12);
+ avio_wl32(pb, enc->sample_rate);
+ avio_w8(pb, enc->bits_per_coded_sample);
+ avio_w8(pb, enc->channels);
+ avio_wl16(pb, enc->codec_tag);
+ avio_wl32(pb, 0);
} else {
if (s->streams[0]->codec->channels > 1) {
- put_byte(pb, VOC_TYPE_EXTENDED);
- put_le24(pb, 4);
- put_le16(pb, 65536-256000000/(enc->sample_rate*enc->channels));
- put_byte(pb, enc->codec_tag);
- put_byte(pb, enc->channels - 1);
+ avio_w8(pb, VOC_TYPE_EXTENDED);
+ avio_wl24(pb, 4);
+ avio_wl16(pb, 65536-256000000/(enc->sample_rate*enc->channels));
+ avio_w8(pb, enc->codec_tag);
+ avio_w8(pb, enc->channels - 1);
}
- put_byte(pb, VOC_TYPE_VOICE_DATA);
- put_le24(pb, pkt->size + 2);
- put_byte(pb, 256 - 1000000 / enc->sample_rate);
- put_byte(pb, enc->codec_tag);
+ avio_w8(pb, VOC_TYPE_VOICE_DATA);
+ avio_wl24(pb, pkt->size + 2);
+ avio_w8(pb, 256 - 1000000 / enc->sample_rate);
+ avio_w8(pb, enc->codec_tag);
}
voc->param_written = 1;
} else {
- put_byte(pb, VOC_TYPE_VOICE_DATA_CONT);
- put_le24(pb, pkt->size);
+ avio_w8(pb, VOC_TYPE_VOICE_DATA_CONT);
+ avio_wl24(pb, pkt->size);
}
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
return 0;
}
static int voc_write_trailer(AVFormatContext *s)
{
- put_byte(s->pb, 0);
+ avio_w8(s->pb, 0);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/vqf.c b/mplayer/ffmpeg/libavformat/vqf.c
index 9cf0c3a6..fb440af2 100644
--- a/mplayer/ffmpeg/libavformat/vqf.c
+++ b/mplayer/ffmpeg/libavformat/vqf.c
@@ -54,7 +54,7 @@ static void add_metadata(AVFormatContext *s, const char *tag,
buf = av_malloc(len+1);
if (!buf)
return;
- get_buffer(s->pb, buf, len);
+ avio_read(s->pb, buf, len);
buf[len] = 0;
av_metadata_set2(&s->metadata, tag, buf, AV_METADATA_DONT_STRDUP_VAL);
}
@@ -72,9 +72,9 @@ static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (!st)
return AVERROR(ENOMEM);
- url_fskip(s->pb, 12);
+ avio_seek(s->pb, 12, SEEK_CUR);
- header_size = get_be32(s->pb);
+ header_size = avio_rb32(s->pb);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_TWINVQ;
@@ -82,12 +82,12 @@ static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap)
do {
int len;
- chunk_tag = get_le32(s->pb);
+ chunk_tag = avio_rl32(s->pb);
if (chunk_tag == MKTAG('D','A','T','A'))
break;
- len = get_be32(s->pb);
+ len = avio_rb32(s->pb);
if ((unsigned) len > INT_MAX/2) {
av_log(s, AV_LOG_ERROR, "Malformed header\n");
@@ -98,10 +98,10 @@ static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap)
switch(chunk_tag){
case MKTAG('C','O','M','M'):
- st->codec->channels = get_be32(s->pb) + 1;
- read_bitrate = get_be32(s->pb);
- rate_flag = get_be32(s->pb);
- url_fskip(s->pb, len-12);
+ st->codec->channels = avio_rb32(s->pb) + 1;
+ read_bitrate = avio_rb32(s->pb);
+ rate_flag = avio_rb32(s->pb);
+ avio_seek(s->pb, len-12, SEEK_CUR);
st->codec->bit_rate = read_bitrate*1000;
st->codec->bits_per_coded_sample = 16;
@@ -140,7 +140,7 @@ static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap)
av_log(s, AV_LOG_ERROR, "Unknown chunk: %c%c%c%c\n",
((char*)&chunk_tag)[0], ((char*)&chunk_tag)[1],
((char*)&chunk_tag)[2], ((char*)&chunk_tag)[3]);
- url_fskip(s->pb, FFMIN(len, header_size));
+ avio_seek(s->pb, FFMIN(len, header_size), SEEK_CUR);
break;
}
@@ -208,7 +208,7 @@ static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[0] = 8 - c->remaining_bits; // Number of bits to skip
pkt->data[1] = c->last_frame_bits;
- ret = get_buffer(s->pb, pkt->data+2, size);
+ ret = avio_read(s->pb, pkt->data+2, size);
if (ret<=0) {
av_free_packet(pkt);
@@ -240,7 +240,7 @@ static int vqf_read_seek(AVFormatContext *s,
st->cur_dts = av_rescale(pos, st->time_base.den,
st->codec->bit_rate * (int64_t)st->time_base.num);
- if ((ret = url_fseek(s->pb, ((pos-7) >> 3) + s->data_offset, SEEK_SET)) < 0)
+ if ((ret = avio_seek(s->pb, ((pos-7) >> 3) + s->data_offset, SEEK_SET)) < 0)
return ret;
c->remaining_bits = -7 - ((pos-7)&7);
diff --git a/mplayer/ffmpeg/libavformat/wav.c b/mplayer/ffmpeg/libavformat/wav.c
index 4cf138c7..d6329e32 100644
--- a/mplayer/ffmpeg/libavformat/wav.c
+++ b/mplayer/ffmpeg/libavformat/wav.c
@@ -23,6 +23,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
+#include "avio_internal.h"
#include "pcm.h"
#include "riff.h"
@@ -39,12 +40,12 @@ typedef struct {
static int wav_write_header(AVFormatContext *s)
{
WAVContext *wav = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int64_t fmt, fact;
- put_tag(pb, "RIFF");
- put_le32(pb, 0); /* file length */
- put_tag(pb, "WAVE");
+ ffio_wfourcc(pb, "RIFF");
+ avio_wl32(pb, 0); /* file length */
+ ffio_wfourcc(pb, "WAVE");
/* format header */
fmt = ff_start_tag(pb, "fmt ");
@@ -59,7 +60,7 @@ static int wav_write_header(AVFormatContext *s)
if (s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */
&& !url_is_streamed(s->pb)) {
fact = ff_start_tag(pb, "fact");
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
ff_end_tag(pb, fact);
}
@@ -77,9 +78,9 @@ static int wav_write_header(AVFormatContext *s)
static int wav_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
WAVContext *wav = s->priv_data;
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
if(pkt->pts != AV_NOPTS_VALUE) {
wav->minpts = FFMIN(wav->minpts, pkt->pts);
wav->maxpts = FFMAX(wav->maxpts, pkt->pts);
@@ -91,7 +92,7 @@ static int wav_write_packet(AVFormatContext *s, AVPacket *pkt)
static int wav_write_trailer(AVFormatContext *s)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
WAVContext *wav = s->priv_data;
int64_t file_size;
@@ -102,9 +103,9 @@ static int wav_write_trailer(AVFormatContext *s)
/* update file size */
file_size = url_ftell(pb);
- url_fseek(pb, 4, SEEK_SET);
- put_le32(pb, (uint32_t)(file_size - 8));
- url_fseek(pb, file_size, SEEK_SET);
+ avio_seek(pb, 4, SEEK_SET);
+ avio_wl32(pb, (uint32_t)(file_size - 8));
+ avio_seek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
@@ -114,9 +115,9 @@ static int wav_write_trailer(AVFormatContext *s)
number_of_samples = av_rescale(wav->maxpts - wav->minpts + wav->last_duration,
s->streams[0]->codec->sample_rate * (int64_t)s->streams[0]->time_base.num,
s->streams[0]->time_base.den);
- url_fseek(pb, wav->data-12, SEEK_SET);
- put_le32(pb, number_of_samples);
- url_fseek(pb, file_size, SEEK_SET);
+ avio_seek(pb, wav->data-12, SEEK_SET);
+ avio_wl32(pb, number_of_samples);
+ avio_seek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
}
}
@@ -141,14 +142,14 @@ AVOutputFormat ff_wav_muxer = {
#if CONFIG_WAV_DEMUXER
-static int64_t next_tag(ByteIOContext *pb, unsigned int *tag)
+static int64_t next_tag(AVIOContext *pb, unsigned int *tag)
{
- *tag = get_le32(pb);
- return get_le32(pb);
+ *tag = avio_rl32(pb);
+ return avio_rl32(pb);
}
/* return the size of the found tag */
-static int64_t find_tag(ByteIOContext *pb, uint32_t tag1)
+static int64_t find_tag(AVIOContext *pb, uint32_t tag1)
{
unsigned int tag;
int64_t size;
@@ -159,7 +160,7 @@ static int64_t find_tag(ByteIOContext *pb, uint32_t tag1)
size = next_tag(pb, &tag);
if (tag == tag1)
break;
- url_fseek(pb, size, SEEK_CUR);
+ avio_seek(pb, size, SEEK_CUR);
}
return size;
}
@@ -192,31 +193,31 @@ static int wav_read_header(AVFormatContext *s,
int64_t sample_count=0;
int rf64;
unsigned int tag;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
WAVContext *wav = s->priv_data;
/* check RIFF header */
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
rf64 = tag == MKTAG('R', 'F', '6', '4');
if (!rf64 && tag != MKTAG('R', 'I', 'F', 'F'))
return -1;
- get_le32(pb); /* file size */
- tag = get_le32(pb);
+ avio_rl32(pb); /* file size */
+ tag = avio_rl32(pb);
if (tag != MKTAG('W', 'A', 'V', 'E'))
return -1;
if (rf64) {
- if (get_le32(pb) != MKTAG('d', 's', '6', '4'))
+ if (avio_rl32(pb) != MKTAG('d', 's', '6', '4'))
return -1;
- size = get_le32(pb);
+ size = avio_rl32(pb);
if (size < 16)
return -1;
- get_le64(pb); /* RIFF size */
- data_size = get_le64(pb);
- sample_count = get_le64(pb);
- url_fskip(pb, size - 16); /* skip rest of ds64 chunk */
+ avio_rl64(pb); /* RIFF size */
+ data_size = avio_rl64(pb);
+ sample_count = avio_rl64(pb);
+ avio_seek(pb, size - 16, SEEK_CUR); /* skip rest of ds64 chunk */
}
/* parse fmt header */
@@ -239,10 +240,10 @@ static int wav_read_header(AVFormatContext *s,
if (tag == MKTAG('d', 'a', 't', 'a')){
break;
}else if (tag == MKTAG('f','a','c','t') && !sample_count){
- sample_count = get_le32(pb);
+ sample_count = avio_rl32(pb);
size -= 4;
}
- url_fseek(pb, size, SEEK_CUR);
+ avio_seek(pb, size, SEEK_CUR);
}
if (rf64)
size = data_size;
@@ -263,19 +264,19 @@ static int wav_read_header(AVFormatContext *s,
/** Find chunk with w64 GUID by skipping over other chunks
* @return the size of the found chunk
*/
-static int64_t find_guid(ByteIOContext *pb, const uint8_t guid1[16])
+static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16])
{
uint8_t guid[16];
int64_t size;
while (!url_feof(pb)) {
- get_buffer(pb, guid, 16);
- size = get_le64(pb);
+ avio_read(pb, guid, 16);
+ size = avio_rl64(pb);
if (size <= 24)
return -1;
if (!memcmp(guid, guid1, 16))
return size;
- url_fskip(pb, FFALIGN(size, INT64_C(8)) - 24);
+ avio_seek(pb, FFALIGN(size, INT64_C(8)) - 24, SEEK_CUR);
}
return -1;
}
@@ -379,19 +380,19 @@ static int w64_probe(AVProbeData *p)
static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
int64_t size;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
WAVContext *wav = s->priv_data;
AVStream *st;
uint8_t guid[16];
- get_buffer(pb, guid, 16);
+ avio_read(pb, guid, 16);
if (memcmp(guid, guid_riff, 16))
return -1;
- if (get_le64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */
+ if (avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */
return -1;
- get_buffer(pb, guid, 16);
+ avio_read(pb, guid, 16);
if (memcmp(guid, guid_wave, 16)) {
av_log(s, AV_LOG_ERROR, "could not find wave guid\n");
return -1;
@@ -409,7 +410,7 @@ static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* subtract chunk header size - normal wav file doesn't count it */
ff_get_wav_header(pb, st->codec, size - 24);
- url_fskip(pb, FFALIGN(size, INT64_C(8)) - size);
+ avio_seek(pb, FFALIGN(size, INT64_C(8)) - size, SEEK_CUR);
st->need_parsing = AVSTREAM_PARSE_FULL;
diff --git a/mplayer/ffmpeg/libavformat/wc3movie.c b/mplayer/ffmpeg/libavformat/wc3movie.c
index 17571599..a4dd26b4 100644
--- a/mplayer/ffmpeg/libavformat/wc3movie.c
+++ b/mplayer/ffmpeg/libavformat/wc3movie.c
@@ -85,7 +85,7 @@ static int wc3_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
Wc3DemuxContext *wc3 = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int fourcc_tag;
unsigned int size;
AVStream *st;
@@ -101,12 +101,12 @@ static int wc3_read_header(AVFormatContext *s,
wc3->vpkt.data = NULL; wc3->vpkt.size = 0;
/* skip the first 3 32-bit numbers */
- url_fseek(pb, 12, SEEK_CUR);
+ avio_seek(pb, 12, SEEK_CUR);
/* traverse through the chunks and load the header information before
* the first BRCH tag */
- fourcc_tag = get_le32(pb);
- size = (get_be32(pb) + 1) & (~1);
+ fourcc_tag = avio_rl32(pb);
+ size = (avio_rb32(pb) + 1) & (~1);
do {
switch (fourcc_tag) {
@@ -114,12 +114,12 @@ static int wc3_read_header(AVFormatContext *s,
case SOND_TAG:
case INDX_TAG:
/* SOND unknown, INDX unnecessary; ignore both */
- url_fseek(pb, size, SEEK_CUR);
+ avio_seek(pb, size, SEEK_CUR);
break;
case PC__TAG:
/* number of palettes, unneeded */
- url_fseek(pb, 12, SEEK_CUR);
+ avio_seek(pb, 12, SEEK_CUR);
break;
case BNAM_TAG:
@@ -127,7 +127,7 @@ static int wc3_read_header(AVFormatContext *s,
buffer = av_malloc(size+1);
if (!buffer)
return AVERROR(ENOMEM);
- if ((ret = get_buffer(pb, buffer, size)) != size)
+ if ((ret = avio_read(pb, buffer, size)) != size)
return AVERROR(EIO);
buffer[size] = 0;
av_metadata_set2(&s->metadata, "title", buffer,
@@ -136,13 +136,13 @@ static int wc3_read_header(AVFormatContext *s,
case SIZE_TAG:
/* video resolution override */
- wc3->width = get_le32(pb);
- wc3->height = get_le32(pb);
+ wc3->width = avio_rl32(pb);
+ wc3->height = avio_rl32(pb);
break;
case PALT_TAG:
/* one of several palettes */
- url_fseek(pb, -8, SEEK_CUR);
+ avio_seek(pb, -8, SEEK_CUR);
av_append_packet(pb, &wc3->vpkt, 8 + PALETTE_SIZE);
break;
@@ -154,9 +154,9 @@ static int wc3_read_header(AVFormatContext *s,
break;
}
- fourcc_tag = get_le32(pb);
+ fourcc_tag = avio_rl32(pb);
/* chunk sizes are 16-bit aligned */
- size = (get_be32(pb) + 1) & (~1);
+ size = (avio_rb32(pb) + 1) & (~1);
if (url_feof(pb))
return AVERROR(EIO);
@@ -196,7 +196,7 @@ static int wc3_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
Wc3DemuxContext *wc3 = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int fourcc_tag;
unsigned int size;
int packet_read = 0;
@@ -205,9 +205,9 @@ static int wc3_read_packet(AVFormatContext *s,
while (!packet_read) {
- fourcc_tag = get_le32(pb);
+ fourcc_tag = avio_rl32(pb);
/* chunk sizes are 16-bit aligned */
- size = (get_be32(pb) + 1) & (~1);
+ size = (avio_rb32(pb) + 1) & (~1);
if (url_feof(pb))
return AVERROR(EIO);
@@ -219,13 +219,13 @@ static int wc3_read_packet(AVFormatContext *s,
case SHOT_TAG:
/* load up new palette */
- url_fseek(pb, -8, SEEK_CUR);
+ avio_seek(pb, -8, SEEK_CUR);
av_append_packet(pb, &wc3->vpkt, 8 + 4);
break;
case VGA__TAG:
/* send out video chunk */
- url_fseek(pb, -8, SEEK_CUR);
+ avio_seek(pb, -8, SEEK_CUR);
ret= av_append_packet(pb, &wc3->vpkt, 8 + size);
// ignore error if we have some data
if (wc3->vpkt.size > 0)
@@ -240,9 +240,9 @@ static int wc3_read_packet(AVFormatContext *s,
case TEXT_TAG:
/* subtitle chunk */
#if 0
- url_fseek(pb, size, SEEK_CUR);
+ avio_seek(pb, size, SEEK_CUR);
#else
- if ((unsigned)size > sizeof(text) || (ret = get_buffer(pb, text, size)) != size)
+ if ((unsigned)size > sizeof(text) || (ret = avio_read(pb, text, size)) != size)
ret = AVERROR(EIO);
else {
int i = 0;
diff --git a/mplayer/ffmpeg/libavformat/westwood.c b/mplayer/ffmpeg/libavformat/westwood.c
index 85d2056b..adb35319 100644
--- a/mplayer/ffmpeg/libavformat/westwood.c
+++ b/mplayer/ffmpeg/libavformat/westwood.c
@@ -126,11 +126,11 @@ static int wsaud_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
WsAudDemuxContext *wsaud = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
unsigned char header[AUD_HEADER_SIZE];
- if (get_buffer(pb, header, AUD_HEADER_SIZE) != AUD_HEADER_SIZE)
+ if (avio_read(pb, header, AUD_HEADER_SIZE) != AUD_HEADER_SIZE)
return AVERROR(EIO);
wsaud->audio_samplerate = AV_RL16(&header[0]);
if (header[11] == 99)
@@ -168,12 +168,12 @@ static int wsaud_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
WsAudDemuxContext *wsaud = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned char preamble[AUD_CHUNK_PREAMBLE_SIZE];
unsigned int chunk_size;
int ret = 0;
- if (get_buffer(pb, preamble, AUD_CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, preamble, AUD_CHUNK_PREAMBLE_SIZE) !=
AUD_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
@@ -213,7 +213,7 @@ static int wsvqa_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
WsVqaDemuxContext *wsvqa = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
unsigned char *header;
unsigned char scratch[VQA_PREAMBLE_SIZE];
@@ -231,13 +231,13 @@ static int wsvqa_read_header(AVFormatContext *s,
st->codec->codec_tag = 0; /* no fourcc */
/* skip to the start of the VQA header */
- url_fseek(pb, 20, SEEK_SET);
+ avio_seek(pb, 20, SEEK_SET);
/* the VQA header needs to go to the decoder */
st->codec->extradata_size = VQA_HEADER_SIZE;
st->codec->extradata = av_mallocz(VQA_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
header = (unsigned char *)st->codec->extradata;
- if (get_buffer(pb, st->codec->extradata, VQA_HEADER_SIZE) !=
+ if (avio_read(pb, st->codec->extradata, VQA_HEADER_SIZE) !=
VQA_HEADER_SIZE) {
av_free(st->codec->extradata);
return AVERROR(EIO);
@@ -277,7 +277,7 @@ static int wsvqa_read_header(AVFormatContext *s,
/* there are 0 or more chunks before the FINF chunk; iterate until
* FINF has been skipped and the file will be ready to be demuxed */
do {
- if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) {
+ if (avio_read(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) {
av_free(st->codec->extradata);
return AVERROR(EIO);
}
@@ -303,7 +303,7 @@ static int wsvqa_read_header(AVFormatContext *s,
break;
}
- url_fseek(pb, chunk_size, SEEK_CUR);
+ avio_seek(pb, chunk_size, SEEK_CUR);
} while (chunk_tag != FINF_TAG);
return 0;
@@ -313,14 +313,14 @@ static int wsvqa_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
WsVqaDemuxContext *wsvqa = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret = -1;
unsigned char preamble[VQA_PREAMBLE_SIZE];
unsigned int chunk_type;
unsigned int chunk_size;
int skip_byte;
- while (get_buffer(pb, preamble, VQA_PREAMBLE_SIZE) == VQA_PREAMBLE_SIZE) {
+ while (avio_read(pb, preamble, VQA_PREAMBLE_SIZE) == VQA_PREAMBLE_SIZE) {
chunk_type = AV_RB32(&preamble[0]);
chunk_size = AV_RB32(&preamble[4]);
skip_byte = chunk_size & 0x01;
@@ -329,7 +329,7 @@ static int wsvqa_read_packet(AVFormatContext *s,
if (av_new_packet(pkt, chunk_size))
return AVERROR(EIO);
- ret = get_buffer(pb, pkt->data, chunk_size);
+ ret = avio_read(pb, pkt->data, chunk_size);
if (ret != chunk_size) {
av_free_packet(pkt);
return AVERROR(EIO);
@@ -348,7 +348,7 @@ static int wsvqa_read_packet(AVFormatContext *s,
}
/* stay on 16-bit alignment */
if (skip_byte)
- url_fseek(pb, 1, SEEK_CUR);
+ avio_seek(pb, 1, SEEK_CUR);
return ret;
} else {
@@ -359,7 +359,7 @@ static int wsvqa_read_packet(AVFormatContext *s,
default:
av_log(s, AV_LOG_INFO, "Skipping unknown chunk 0x%08X\n", chunk_type);
}
- url_fseek(pb, chunk_size + skip_byte, SEEK_CUR);
+ avio_seek(pb, chunk_size + skip_byte, SEEK_CUR);
}
}
diff --git a/mplayer/ffmpeg/libavformat/wtv.c b/mplayer/ffmpeg/libavformat/wtv.c
index 816c4062..6b8a58da 100644
--- a/mplayer/ffmpeg/libavformat/wtv.c
+++ b/mplayer/ffmpeg/libavformat/wtv.c
@@ -1,6 +1,6 @@
/*
* Windows Television (WTV) demuxer
- * Copyright (c) 2010 Peter Ross
+ * Copyright (c) 2010-2011 Peter Ross
*
* This file is part of FFmpeg.
*
@@ -26,10 +26,13 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavutil/intfloat_readwrite.h"
#include "avformat.h"
+#include "internal.h"
#include "riff.h"
#include "asf.h"
#include "mpegts.h"
+#include
/* Macros for formating GUIDs */
#define PRI_GUID \
@@ -37,22 +40,294 @@
#define ARG_GUID(g) \
g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],g[8],g[9],g[10],g[11],g[12],g[13],g[14],g[15]
+#define PRI_PRETTY_GUID \
+ "%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x"
+#define ARG_PRETTY_GUID(g) \
+ AV_RL32(g),AV_RL16(g+4),AV_RL16(g+6),g[8],g[9],g[10],g[11],g[12],g[13],g[14],g[15]
+#define LEN_PRETTY_GUID 34
+
+/*
+ *
+ * File system routines
+ *
+ */
+
+#define WTV_SECTOR_BITS 12
+#define WTV_SECTOR_SIZE (1 << WTV_SECTOR_BITS)
+#define WTV_BIGSECTOR_BITS 18
+
typedef struct {
- int seen_data;
-} WtvStream;
+ AVIOContext *pb_filesystem; /** file system (AVFormatContext->pb) */
-typedef struct WtvContext {
- uint64_t pts;
-} WtvContext;
+ int sector_bits; /** sector shift bits; used to convert sector number into pb_filesystem offset */
+ uint32_t *sectors; /** file allocation table */
+ int nb_sectors; /** number of sectors */
+
+ int error;
+ int64_t position;
+ int64_t length;
+} WtvFile;
+
+/**
+ * @return bytes read, 0 on end of file, or <0 on error
+ */
+static int wtvfile_read_packet(void *opaque, uint8_t *buf, int buf_size)
+{
+ WtvFile *wf = opaque;
+ AVIOContext *pb = wf->pb_filesystem;
+ int nread = 0;
+
+ if (wf->error || url_ferror(pb))
+ return -1;
+ if (wf->position >= wf->length || url_feof(pb))
+ return 0;
+
+ buf_size = FFMIN(buf_size, wf->length - wf->position);
+ while(nread < buf_size) {
+ int n;
+ int remaining_in_sector = (1 << wf->sector_bits) - (wf->position & ((1 << wf->sector_bits) - 1));
+ int read_request = FFMIN(buf_size - nread, remaining_in_sector);
+
+ n = avio_read(pb, buf, read_request);
+ if (n <= 0)
+ break;
+ nread += n;
+ buf += n;
+ wf->position += n;
+ if (n == remaining_in_sector) {
+ int i = wf->position >> wf->sector_bits;
+ if (i >= wf->nb_sectors ||
+ (wf->sectors[i] != wf->sectors[i - 1] + (1 << (wf->sector_bits - WTV_SECTOR_BITS)) &&
+ avio_seek(pb, (int64_t)wf->sectors[i] << WTV_SECTOR_BITS, SEEK_SET) < 0)) {
+ wf->error = 1;
+ break;
+ }
+ }
+ }
+ return nread;
+}
+
+/**
+ * @return position (or file length)
+ */
+static int64_t wtvfile_seek(void *opaque, int64_t offset, int whence)
+{
+ WtvFile *wf = opaque;
+ AVIOContext *pb = wf->pb_filesystem;
+
+ if (whence == AVSEEK_SIZE)
+ return wf->length;
+ else if (whence == SEEK_CUR)
+ offset = wf->position + offset;
+ else if (whence == SEEK_END)
+ offset = wf->length;
+
+ wf->error = offset < 0 || offset >= wf->length ||
+ avio_seek(pb, ((int64_t)wf->sectors[offset >> wf->sector_bits] << WTV_SECTOR_BITS)
+ + (offset & ((1 << wf->sector_bits) - 1)), SEEK_SET) < 0;
+ wf->position = offset;
+ return offset;
+}
+
+/**
+ * read non-zero integers (le32) from input stream
+ * @param pb
+ * @param[out] data destination
+ * @param count maximum number of integers to read
+ * @return total number of integers read
+ */
+static int read_ints(AVIOContext *pb, uint32_t *data, int count)
+{
+ int i, total = 0;
+ for (i = 0; i < count; i++) {
+ if ((data[total] = avio_rl32(pb)))
+ total++;
+ }
+ return total;
+}
+
+/**
+ * Open file
+ * @param first_sector First sector
+ * @param length Length of file (bytes)
+ * @param depth File allocation table depth
+ * @return NULL on error
+ */
+static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int depth, AVFormatContext *s)
+{
+ AVIOContext *pb;
+ WtvFile *wf;
+ uint8_t *buffer;
+
+ if (avio_seek(s->pb, first_sector << WTV_SECTOR_BITS, SEEK_SET) < 0)
+ return NULL;
+
+ wf = av_mallocz(sizeof(WtvFile));
+ if (!wf)
+ return NULL;
+
+ if (depth == 0) {
+ wf->sectors = av_malloc(sizeof(uint32_t));
+ if (!wf->sectors) {
+ av_free(wf);
+ return NULL;
+ }
+ wf->sectors[0] = first_sector;
+ wf->nb_sectors = 1;
+ wf->sector_bits = WTV_SECTOR_BITS;
+ } else if (depth == 1) {
+ wf->sectors = av_malloc(WTV_SECTOR_SIZE);
+ if (!wf->sectors) {
+ av_free(wf);
+ return NULL;
+ }
+ wf->nb_sectors = read_ints(s->pb, wf->sectors, WTV_SECTOR_SIZE / 4);
+ wf->sector_bits = length & (1ULL<<63) ? WTV_SECTOR_BITS : WTV_BIGSECTOR_BITS;
+ } else if (depth == 2) {
+ uint32_t sectors1[WTV_SECTOR_SIZE / 4];
+ int nb_sectors1 = read_ints(s->pb, sectors1, WTV_SECTOR_SIZE / 4);
+ int i;
-static int is_zero(uint8_t *v, int n)
+ wf->sectors = av_malloc(nb_sectors1 << WTV_SECTOR_BITS);
+ if (!wf->sectors) {
+ av_free(wf);
+ return NULL;
+ }
+ wf->nb_sectors = 0;
+ for (i = 0; i < nb_sectors1; i++) {
+ if (avio_seek(s->pb, (int64_t)sectors1[i] << WTV_SECTOR_BITS, SEEK_SET) < 0)
+ break;
+ wf->nb_sectors += read_ints(s->pb, wf->sectors + i * WTV_SECTOR_SIZE / 4, WTV_SECTOR_SIZE / 4);
+ }
+ wf->sector_bits = length & (1ULL<<63) ? WTV_SECTOR_BITS : WTV_BIGSECTOR_BITS;
+ } else {
+ av_log(s, AV_LOG_ERROR, "unsupported file allocation table depth (0x%x)\n", depth);
+ av_free(wf);
+ return NULL;
+ }
+
+ if (!wf->nb_sectors) {
+ av_free(wf->sectors);
+ av_free(wf);
+ return NULL;
+ }
+
+ /* check length */
+ length &= 0xFFFFFFFFFFFF;
+ if (length > ((int64_t)wf->nb_sectors << wf->sector_bits)) {
+ av_log(s, AV_LOG_WARNING, "reported file length (0x%"PRIx64") exceeds number of available sectors (0x%"PRIx64")\n", length, (int64_t)wf->nb_sectors << wf->sector_bits);
+ length = (int64_t)wf->nb_sectors << wf->sector_bits;
+ }
+ wf->length = length;
+
+ /* seek to intial sector */
+ wf->position = 0;
+ if (avio_seek(s->pb, (int64_t)wf->sectors[0] << WTV_SECTOR_BITS, SEEK_SET) < 0) {
+ av_free(wf->sectors);
+ av_free(wf);
+ return NULL;
+ }
+
+ wf->pb_filesystem = s->pb;
+ buffer = av_malloc(1 << wf->sector_bits);
+ if (!buffer) {
+ av_free(wf->sectors);
+ av_free(wf);
+ return NULL;
+ }
+
+ pb = avio_alloc_context(buffer, 1 << wf->sector_bits, 0, wf,
+ wtvfile_read_packet, NULL, wtvfile_seek);
+ if (!pb) {
+ av_free(buffer);
+ av_free(wf->sectors);
+ av_free(wf);
+ }
+ return pb;
+}
+
+static const ff_asf_guid dir_entry_guid =
+ {0x92,0xB7,0x74,0x91,0x59,0x70,0x70,0x44,0x88,0xDF,0x06,0x3B,0x82,0xCC,0x21,0x3D};
+
+/**
+ * Open file using filename
+ * @param[in] buf directory buffer
+ * @param buf_size directory buffer size
+ * @param[in] filename
+ * @param filename_size size of filename
+ * @return NULL on error
+ */
+static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int buf_size, const uint8_t *filename, int filename_size)
+{
+ const uint8_t *buf_end = buf + buf_size;
+
+ while(buf + 48 <= buf_end) {
+ int dir_length, name_size, first_sector, depth;
+ uint64_t file_length;
+ const uint8_t *name;
+ if (ff_guidcmp(buf, dir_entry_guid)) {
+ av_log(s, AV_LOG_ERROR, "unknown guid "PRI_GUID", expected dir_entry_guid; "
+ "remaining directory entries ignored\n", ARG_GUID(buf));
+ break;
+ }
+ dir_length = AV_RL16(buf + 16);
+ file_length = AV_RL64(buf + 24);
+ name_size = 2 * AV_RL32(buf + 32);
+ if (buf + 48 + name_size > buf_end) {
+ av_log(s, AV_LOG_ERROR, "filename exceeds buffer size; remaining directory entries ignored\n");
+ break;
+ }
+ first_sector = AV_RL32(buf + 40 + name_size);
+ depth = AV_RL32(buf + 44 + name_size);
+
+ /* compare file name; test optional null terminator */
+ name = buf + 40;
+ if (name_size >= filename_size &&
+ !memcmp(name, filename, filename_size) &&
+ (name_size < filename_size + 2 || !AV_RN16(name + filename_size)))
+ return wtvfile_open_sector(first_sector, file_length, depth, s);
+
+ buf += dir_length;
+ }
+ return 0;
+}
+
+#define wtvfile_open(s, buf, buf_size, filename) \
+ wtvfile_open2(s, buf, buf_size, filename, sizeof(filename))
+
+/**
+ * Close file opened with wtvfile_open_sector(), or wtv_open()
+ */
+static void wtvfile_close(AVIOContext *pb)
{
- int i;
- for (i = 0; i < n; i++)
- if (v[i]) return 0;
- return 1;
+ WtvFile *wf = pb->opaque;
+ av_free(wf->sectors);
+ av_free(pb);
}
+/*
+ *
+ * Main demuxer
+ *
+ */
+
+typedef struct {
+ int seen_data;
+} WtvStream;
+
+typedef struct {
+ AVIOContext *pb; /** timeline file */
+ int64_t epoch;
+ int64_t pts; /** pts for next data chunk */
+ int64_t last_valid_pts; /** latest valid pts, used for interative seeking */
+
+ /* maintain private seek index, as the AVIndexEntry->pos is relative to the
+ start of the 'timeline' file, not the file system (AVFormatContext->pb) */
+ AVIndexEntry *index_entries;
+ int nb_index_entries;
+ unsigned int index_entries_allocated_size;
+} WtvContext;
+
typedef struct {
enum CodecID id;
ff_asf_guid guid;
@@ -71,7 +346,7 @@ static enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid g
/* WTV GUIDs */
static const ff_asf_guid wtv_guid =
{0xB7,0xD8,0x00,0x20,0x37,0x49,0xDA,0x11,0xA6,0x4E,0x00,0x07,0xE9,0x5E,0xAD,0x8D};
-static const ff_asf_guid meta_guid =
+static const ff_asf_guid metadata_guid =
{0x5A,0xFE,0xD7,0x6D,0xC8,0x1D,0x8F,0x4A,0x99,0x22,0xFA,0xB1,0x1C,0x38,0x14,0x53};
static const ff_asf_guid timestamp_guid =
{0x5B,0x05,0xE6,0x1B,0x97,0xA9,0x49,0x43,0x88,0x17,0x1A,0x65,0x5A,0x29,0x8A,0x97};
@@ -97,6 +372,8 @@ static const ff_asf_guid EVENTID_StreamIDSpanningEvent =
{0x68,0xAB,0xF1,0xCA,0x53,0xE1,0x41,0x4D,0xA6,0xB3,0xA7,0xC9,0x98,0xDB,0x75,0xEE};
static const ff_asf_guid EVENTID_TeletextSpanningEvent =
{0x50,0xD9,0x99,0x95,0x33,0x5F,0x17,0x46,0xAF,0x7C,0x1E,0x54,0xB5,0x10,0xDA,0xA3};
+static const ff_asf_guid EVENTID_AudioTypeSpanningEvent =
+ {0xBE,0xBF,0x1C,0x50,0x49,0xB8,0xCE,0x42,0x9B,0xE9,0x3D,0xB8,0x69,0xFB,0x82,0xB3};
/* Windows media GUIDs */
@@ -158,15 +435,154 @@ static int read_probe(AVProbeData *p)
return ff_guidcmp(p->buf, wtv_guid) ? 0 : AVPROBE_SCORE_MAX;
}
+/**
+ * Convert win32 FILETIME to ISO-8601 string
+ */
+static void filetime_to_iso8601(char *buf, int buf_size, int64_t value)
+{
+ time_t t = (value / 10000000LL) - 11644473600LL;
+ strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+}
+
+/**
+ * Convert crazy time (100ns since 1 Jan 0001) to ISO-8601 string
+ */
+static void crazytime_to_iso8601(char *buf, int buf_size, int64_t value)
+{
+ time_t t = (value / 10000000LL) - 719162LL*86400LL;
+ strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+}
+
+/**
+ * Convert OLE DATE to ISO-8601 string
+ */
+static void oledate_to_iso8601(char *buf, int buf_size, int64_t value)
+{
+ time_t t = 631112400LL + 86400*av_int2dbl(value);
+ strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+}
+
+static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length)
+{
+ char mime[1024];
+ char description[1024];
+ unsigned int filesize;
+ AVStream *st;
+ int64_t pos = url_ftell(pb);
+
+ avio_get_str16le(pb, INT_MAX, mime, sizeof(mime));
+ if (strcmp(mime, "image/jpeg"))
+ goto done;
+
+ avio_r8(pb);
+ avio_get_str16le(pb, INT_MAX, description, sizeof(description));
+ filesize = avio_rl32(pb);
+ if (!filesize)
+ goto done;
+
+ st = av_new_stream(s, 0);
+ if (!st)
+ goto done;
+ av_metadata_set2(&st->metadata, "title", description, 0);
+ st->codec->codec_id = CODEC_ID_MJPEG;
+ st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
+ st->codec->extradata = av_mallocz(filesize);
+ if (!st->codec->extradata)
+ goto done;
+ st->codec->extradata_size = filesize;
+ avio_read(pb, st->codec->extradata, filesize);
+done:
+ avio_seek(pb, pos + length, SEEK_SET);
+}
+
+static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int type, int length)
+{
+ int buf_size = FFMAX(2*length, LEN_PRETTY_GUID) + 1;
+ char *buf = av_malloc(buf_size);
+ if (!buf)
+ return;
+
+ if (type == 0 && length == 4) {
+ snprintf(buf, buf_size, "%"PRIi32, avio_rl32(pb));
+ } else if (type == 1) {
+ avio_get_str16le(pb, length, buf, buf_size);
+ if (!strlen(buf)) {
+ av_free(buf);
+ return;
+ }
+ } else if (type == 3 && length == 4) {
+ strcpy(buf, avio_rl32(pb) ? "true" : "false");
+ } else if (type == 4 && length == 8) {
+ int64_t num = avio_rl64(pb);
+ if (!strcmp(key, "WM/EncodingTime") ||
+ !strcmp(key, "WM/MediaOriginalBroadcastDateTime"))
+ filetime_to_iso8601(buf, buf_size, num);
+ else if (!strcmp(key, "WM/WMRVEncodeTime") ||
+ !strcmp(key, "WM/WMRVEndTime"))
+ crazytime_to_iso8601(buf, buf_size, num);
+ else if (!strcmp(key, "WM/WMRVExpirationDate"))
+ oledate_to_iso8601(buf, buf_size, num);
+ else if (!strcmp(key, "WM/WMRVBitrate"))
+ snprintf(buf, buf_size, "%f", av_int2dbl(num));
+ else
+ snprintf(buf, buf_size, "%"PRIi64, num);
+ } else if (type == 5 && length == 2) {
+ snprintf(buf, buf_size, "%"PRIi16, avio_rl16(pb));
+ } else if (type == 6 && length == 16) {
+ ff_asf_guid guid;
+ avio_read(pb, guid, 16);
+ snprintf(buf, buf_size, PRI_PRETTY_GUID, ARG_PRETTY_GUID(guid));
+ } else if (type == 2 && !strcmp(key, "WM/Picture")) {
+ get_attachment(s, pb, length);
+ av_freep(&buf);
+ return;
+ } else {
+ av_freep(&buf);
+ av_log(s, AV_LOG_WARNING, "unsupported metadata entry; key:%s, type:%d, length:0x%x\n", key, type, length);
+ avio_seek(pb, length, SEEK_CUR);
+ return;
+ }
+
+ av_metadata_set2(&s->metadata, key, buf, 0);
+ av_freep(&buf);
+}
+
+/**
+ * Parse metadata entries
+ */
+static void parse_legacy_attrib(AVFormatContext *s, AVIOContext *pb)
+{
+ ff_asf_guid guid;
+ int length, type;
+ while(!url_feof(pb)) {
+ char key[1024];
+ ff_get_guid(pb, &guid);
+ type = avio_rl32(pb);
+ length = avio_rl32(pb);
+ if (!length)
+ break;
+ if (ff_guidcmp(&guid, metadata_guid)) {
+ av_log(s, AV_LOG_WARNING, "unknown guid "PRI_GUID", expected metadata_guid; "
+ "remaining metadata entries ignored\n", ARG_GUID(guid));
+ break;
+ }
+ avio_get_str16le(pb, INT_MAX, key, sizeof(key));
+ get_tag(s, pb, key, type, length);
+ }
+
+ ff_metadata_conv(&s->metadata, NULL, ff_asf_metadata_conv);
+}
+
/**
* parse VIDEOINFOHEADER2 structure
* @return bytes consumed
*/
static int parse_videoinfoheader2(AVFormatContext *s, AVStream *st)
{
- ByteIOContext *pb = s->pb;
+ WtvContext *wtv = s->priv_data;
+ AVIOContext *pb = wtv->pb;
- url_fskip(pb, 72); // picture aspect ratio is unreliable
+ avio_seek(pb, 72, SEEK_CUR); // picture aspect ratio is unreliable
ff_get_bmp_header(pb, st);
return 72 + 40;
@@ -233,7 +649,8 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
ff_asf_guid mediatype, ff_asf_guid subtype,
ff_asf_guid formattype, int size)
{
- ByteIOContext *pb = s->pb;
+ WtvContext *wtv = s->priv_data;
+ AVIOContext *pb = wtv->pb;
if (!ff_guidcmp(subtype, mediasubtype_cpfilters_processed) &&
!ff_guidcmp(formattype, format_cpfilters_processed)) {
ff_asf_guid actual_subtype;
@@ -241,17 +658,17 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
if (size < 32) {
av_log(s, AV_LOG_WARNING, "format buffer size underflow\n");
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
return NULL;
}
- url_fskip(pb, size - 32);
+ avio_seek(pb, size - 32, SEEK_CUR);
ff_get_guid(pb, &actual_subtype);
ff_get_guid(pb, &actual_formattype);
- url_fseek(pb, -size, SEEK_CUR);
+ avio_seek(pb, -size, SEEK_CUR);
st = parse_media_type(s, st, sid, mediatype, actual_subtype, actual_formattype, size - 32);
- url_fskip(pb, 32);
+ avio_seek(pb, 32, SEEK_CUR);
return st;
} else if (!ff_guidcmp(mediatype, mediatype_audio)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_AUDIO);
@@ -262,7 +679,7 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
} else {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
}
if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {
@@ -284,14 +701,14 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
return NULL;
if (!ff_guidcmp(formattype, format_videoinfo2)) {
int consumed = parse_videoinfoheader2(s, st);
- url_fskip(pb, FFMAX(size - consumed, 0));
+ avio_seek(pb, FFMAX(size - consumed, 0), SEEK_CUR);
} else if (!ff_guidcmp(formattype, format_mpeg2_video)) {
int consumed = parse_videoinfoheader2(s, st);
- url_fskip(pb, FFMAX(size - consumed, 0));
+ avio_seek(pb, FFMAX(size - consumed, 0), SEEK_CUR);
} else {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
}
if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {
@@ -309,7 +726,7 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
return NULL;
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
st->codec->codec_id = CODEC_ID_DVB_SUBTITLE;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mstvcaption) &&
@@ -319,87 +736,76 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
return NULL;
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
st->codec->codec_id = CODEC_ID_DVB_TELETEXT;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) &&
!ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
return NULL;
}
av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"PRI_GUID
", subtype:"PRI_GUID", formattype:"PRI_GUID"\n",
ARG_GUID(mediatype), ARG_GUID(subtype), ARG_GUID(formattype));
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
return NULL;
}
enum {
SEEK_TO_DATA = 0,
- SEEK_TO_BYTE,
SEEK_TO_PTS,
};
/**
* Parse WTV chunks
- * @param mode SEEK_TO_DATA, SEEK_TO_BYTE, SEEK_TO_PTS
- * @param seekts either byte position or timestamp
+ * @param mode SEEK_TO_DATA or SEEK_TO_PTS
+ * @param seekts timestamp
* @param[out] len Length of data chunk
* @return stream index of data chunk, or <0 on error
*/
static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_ptr)
{
WtvContext *wtv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = wtv->pb;
while (!url_feof(pb)) {
ff_asf_guid g;
int len, sid, consumed;
- if (mode == SEEK_TO_BYTE && url_ftell(pb) >= seekts)
- return 0;
-
ff_get_guid(pb, &g);
- if (is_zero(g, sizeof(ff_asf_guid)))
- return AVERROR_EOF;
-
- len = get_le32(pb);
+ len = avio_rl32(pb);
if (len < 32)
break;
- sid = get_le32(pb) & 0x7FFF;
- url_fskip(pb, 8);
+ sid = avio_rl32(pb) & 0x7FFF;
+ avio_seek(pb, 8, SEEK_CUR);
consumed = 32;
if (!ff_guidcmp(g, stream_guid)) {
if (ff_find_stream_index(s, sid) < 0) {
ff_asf_guid mediatype, subtype, formattype;
int size;
- consumed += 20;
- url_fskip(pb, 16);
- if (get_le32(pb)) {
- url_fskip(pb, 8);
- ff_get_guid(pb, &mediatype);
- ff_get_guid(pb, &subtype);
- url_fskip(pb, 12);
- ff_get_guid(pb, &formattype);
- size = get_le32(pb);
- parse_media_type(s, 0, sid, mediatype, subtype, formattype, size);
- consumed += 72 + size;
- }
+ avio_seek(pb, 28, SEEK_CUR);
+ ff_get_guid(pb, &mediatype);
+ ff_get_guid(pb, &subtype);
+ avio_seek(pb, 12, SEEK_CUR);
+ ff_get_guid(pb, &formattype);
+ size = avio_rl32(pb);
+ parse_media_type(s, 0, sid, mediatype, subtype, formattype, size);
+ consumed += 92 + size;
}
} else if (!ff_guidcmp(g, stream2_guid)) {
int stream_index = ff_find_stream_index(s, sid);
if (stream_index >= 0 && !((WtvStream*)s->streams[stream_index]->priv_data)->seen_data) {
ff_asf_guid mediatype, subtype, formattype;
int size;
- url_fskip(pb, 12);
+ avio_seek(pb, 12, SEEK_CUR);
ff_get_guid(pb, &mediatype);
ff_get_guid(pb, &subtype);
- url_fskip(pb, 12);
+ avio_seek(pb, 12, SEEK_CUR);
ff_get_guid(pb, &formattype);
- size = get_le32(pb);
+ size = avio_rl32(pb);
parse_media_type(s, s->streams[stream_index], sid, mediatype, subtype, formattype, size);
consumed += 76 + size;
}
@@ -416,24 +822,37 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
const uint8_t *pbuf = buf;
int buf_size;
- url_fskip(pb, 8);
+ avio_seek(pb, 8, SEEK_CUR);
consumed += 8;
if (!ff_guidcmp(g, EVENTID_CtxADescriptorSpanningEvent) ||
!ff_guidcmp(g, EVENTID_CSDescriptorSpanningEvent)) {
- url_fskip(pb, 6);
+ avio_seek(pb, 6, SEEK_CUR);
consumed += 6;
}
buf_size = FFMIN(len - consumed, sizeof(buf));
- get_buffer(pb, buf, buf_size);
+ avio_read(pb, buf, buf_size);
consumed += buf_size;
ff_parse_mpeg2_descriptor(s, st, 0, &pbuf, buf + buf_size, 0, 0, 0, 0);
}
+ } else if (!ff_guidcmp(g, EVENTID_AudioTypeSpanningEvent)) {
+ int stream_index = ff_find_stream_index(s, sid);
+ if (stream_index >= 0) {
+ AVStream *st = s->streams[stream_index];
+ int audio_type;
+ avio_seek(pb, 8, SEEK_CUR);
+ audio_type = avio_r8(pb);
+ if (audio_type == 2)
+ st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED;
+ else if (audio_type == 3)
+ st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED;
+ consumed += 9;
+ }
} else if (!ff_guidcmp(g, EVENTID_DVBScramblingControlSpanningEvent)) {
int stream_index = ff_find_stream_index(s, sid);
if (stream_index >= 0) {
- url_fskip(pb, 12);
- if (get_le32(pb))
+ avio_seek(pb, 12, SEEK_CUR);
+ if (avio_rl32(pb))
av_log(s, AV_LOG_WARNING, "DVB scrambled stream detected (st:%d), decoding will likely fail\n", stream_index);
consumed += 16;
}
@@ -442,38 +861,43 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
if (stream_index >= 0) {
AVStream *st = s->streams[stream_index];
uint8_t language[4];
- url_fskip(pb, 12);
- get_buffer(pb, language, 3);
+ avio_seek(pb, 12, SEEK_CUR);
+ avio_read(pb, language, 3);
if (language[0]) {
language[3] = 0;
av_metadata_set2(&st->metadata, "language", language, 0);
+ if (!strcmp(language, "nar") || !strcmp(language, "NAR"))
+ st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED;
}
consumed += 15;
}
} else if (!ff_guidcmp(g, timestamp_guid)) {
int stream_index = ff_find_stream_index(s, sid);
if (stream_index >= 0) {
- url_fskip(pb, 8);
- wtv->pts = get_le64(pb);
+ avio_seek(pb, 8, SEEK_CUR);
+ wtv->pts = avio_rl64(pb);
consumed += 16;
if (wtv->pts == -1)
wtv->pts = AV_NOPTS_VALUE;
+ else {
+ wtv->last_valid_pts = wtv->pts;
+ if (wtv->epoch == AV_NOPTS_VALUE || wtv->pts < wtv->epoch)
+ wtv->epoch = wtv->pts;
if (mode == SEEK_TO_PTS && wtv->pts >= seekts) {
#define WTV_PAD8(x) (((x) + 7) & ~7)
- url_fskip(pb, WTV_PAD8(len) - consumed);
+ avio_seek(pb, WTV_PAD8(len) - consumed, SEEK_CUR);
return 0;
}
+ }
}
} else if (!ff_guidcmp(g, data_guid)) {
int stream_index = ff_find_stream_index(s, sid);
- if (mode == SEEK_TO_DATA && stream_index >= 0) {
+ if (mode == SEEK_TO_DATA && stream_index >= 0 && len > 32) {
WtvStream *wst = s->streams[stream_index]->priv_data;
wst->seen_data = 1;
if (len_ptr) {
*len_ptr = len;
}
- if (wtv->pts != AV_NOPTS_VALUE)
- av_add_index_entry(s->streams[stream_index], url_ftell(pb) - consumed, wtv->pts, 0, 0, AVINDEX_KEYFRAME);
return stream_index;
}
} else if (
@@ -481,7 +905,6 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
!ff_guidcmp(g, /* DSATTRIB_PicSampleSeq */ (const ff_asf_guid){0x02,0xAE,0x5B,0x2F,0x8F,0x7B,0x60,0x4F,0x82,0xD6,0xE4,0xEA,0x2F,0x1F,0x4C,0x99}) ||
!ff_guidcmp(g, /* DSATTRIB_TRANSPORT_PROPERTIES */ (const ff_asf_guid){0x12,0xF6,0x22,0xB6,0xAD,0x47,0x71,0x46,0xAD,0x6C,0x05,0xA9,0x8E,0x65,0xDE,0x3A}) ||
!ff_guidcmp(g, /* dvr_ms_vid_frame_rep_data */ (const ff_asf_guid){0xCC,0x32,0x64,0xDD,0x29,0xE2,0xDB,0x40,0x80,0xF6,0xD2,0x63,0x28,0xD2,0x76,0x1F}) ||
- !ff_guidcmp(g, /* EVENTID_AudioTypeSpanningEvent */ (const ff_asf_guid){0xBE,0xBF,0x1C,0x50,0x49,0xB8,0xCE,0x42,0x9B,0xE9,0x3D,0xB8,0x69,0xFB,0x82,0xB3}) ||
!ff_guidcmp(g, /* EVENTID_ChannelChangeSpanningEvent */ (const ff_asf_guid){0xE5,0xC5,0x67,0x90,0x5C,0x4C,0x05,0x42,0x86,0xC8,0x7A,0xFE,0x20,0xFE,0x1E,0xFA}) ||
!ff_guidcmp(g, /* EVENTID_ChannelInfoSpanningEvent */ (const ff_asf_guid){0x80,0x6D,0xF3,0x41,0x32,0x41,0xC2,0x4C,0xB1,0x21,0x01,0xA4,0x32,0x19,0xD8,0x1B}) ||
!ff_guidcmp(g, /* EVENTID_ChannelTypeSpanningEvent */ (const ff_asf_guid){0x51,0x1D,0xAB,0x72,0xD2,0x87,0x9B,0x48,0xBA,0x11,0x0E,0x08,0xDC,0x21,0x02,0x43}) ||
@@ -500,31 +923,119 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
} else
av_log(s, AV_LOG_WARNING, "unsupported chunk:"PRI_GUID"\n", ARG_GUID(g));
- url_fskip(pb, WTV_PAD8(len) - consumed);
+ avio_seek(pb, WTV_PAD8(len) - consumed, SEEK_CUR);
}
return AVERROR_EOF;
}
-#define WTV_CHUNK_START 0x40000
+/* declare utf16le strings */
+#define _ , 0,
+static const uint8_t timeline_le16[] =
+ {'t'_'i'_'m'_'e'_'l'_'i'_'n'_'e', 0};
+static const uint8_t table_0_entries_legacy_attrib_le16[] =
+ {'t'_'a'_'b'_'l'_'e'_'.'_'0'_'.'_'e'_'n'_'t'_'r'_'i'_'e'_'s'_'.'_'l'_'e'_'g'_'a'_'c'_'y'_'_'_'a'_'t'_'t'_'r'_'i'_'b', 0};
+static const uint8_t table_0_entries_time_le16[] =
+ {'t'_'a'_'b'_'l'_'e'_'.'_'0'_'.'_'e'_'n'_'t'_'r'_'i'_'e'_'s'_'.'_'t'_'i'_'m'_'e', 0};
+static const uint8_t timeline_table_0_entries_Events_le16[] =
+ {'t'_'i'_'m'_'e'_'l'_'i'_'n'_'e'_'.'_'t'_'a'_'b'_'l'_'e'_'.'_'0'_'.'_'e'_'n'_'t'_'r'_'i'_'e'_'s'_'.'_'E'_'v'_'e'_'n'_'t'_'s', 0};
+#undef _
static int read_header(AVFormatContext *s, AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ WtvContext *wtv = s->priv_data;
+ int root_sector, root_size;
+ uint8_t root[WTV_SECTOR_SIZE];
+ AVIOContext *pb;
+ int64_t timeline_pos;
int ret;
- url_fseek(pb, WTV_CHUNK_START, SEEK_SET);
+ wtv->epoch =
+ wtv->pts =
+ wtv->last_valid_pts = AV_NOPTS_VALUE;
+
+ /* read root directory sector */
+ avio_seek(s->pb, 0x30, SEEK_CUR);
+ root_size = avio_rl32(s->pb);
+ if (root_size > sizeof(root)) {
+ av_log(s, AV_LOG_ERROR, "root directory size exceeds sector size\n");
+ return AVERROR_INVALIDDATA;
+ }
+ avio_seek(s->pb, 4, SEEK_CUR);
+ root_sector = avio_rl32(s->pb);
+
+ avio_seek(s->pb, root_sector << WTV_SECTOR_BITS, SEEK_SET);
+ root_size = avio_read(s->pb, root, root_size);
+ if (root_size < 0)
+ return AVERROR_INVALIDDATA;
+
+ /* parse chunks up until first data chunk */
+ wtv->pb = wtvfile_open(s, root, root_size, timeline_le16);
+ if (!wtv->pb) {
+ av_log(s, AV_LOG_ERROR, "timeline data missing\n");
+ return AVERROR_INVALIDDATA;
+ }
+
ret = parse_chunks(s, SEEK_TO_DATA, 0, 0);
if (ret < 0)
return ret;
+ avio_seek(wtv->pb, -32, SEEK_CUR);
+
+ timeline_pos = url_ftell(s->pb); // save before opening another file
- url_fseek(pb, -32, SEEK_CUR);
+ /* read metadata */
+ pb = wtvfile_open(s, root, root_size, table_0_entries_legacy_attrib_le16);
+ if (pb) {
+ parse_legacy_attrib(s, pb);
+ wtvfile_close(pb);
+ }
+
+ /* read seek index */
+ if (s->nb_streams) {
+ AVStream *st = s->streams[0];
+ pb = wtvfile_open(s, root, root_size, table_0_entries_time_le16);
+ if (pb) {
+ while(1) {
+ uint64_t timestamp = avio_rl64(pb);
+ uint64_t frame_nb = avio_rl64(pb);
+ if (url_feof(pb))
+ break;
+ ff_add_index_entry(&wtv->index_entries, &wtv->nb_index_entries, &wtv->index_entries_allocated_size,
+ 0, timestamp, frame_nb, 0, AVINDEX_KEYFRAME);
+ }
+ wtvfile_close(pb);
+
+ if (wtv->nb_index_entries) {
+ pb = wtvfile_open(s, root, root_size, timeline_table_0_entries_Events_le16);
+ if (pb) {
+ int i;
+ while (1) {
+ uint64_t frame_nb = avio_rl64(pb);
+ uint64_t position = avio_rl64(pb);
+ if (url_feof(pb))
+ break;
+ for (i = wtv->nb_index_entries - 1; i >= 0; i--) {
+ AVIndexEntry *e = wtv->index_entries + i;
+ if (frame_nb > e->size)
+ break;
+ if (position > e->pos)
+ e->pos = position;
+ }
+ }
+ wtvfile_close(pb);
+ st->duration = wtv->index_entries[wtv->nb_index_entries - 1].timestamp;
+ }
+ }
+ }
+ }
+
+ avio_seek(s->pb, timeline_pos, SEEK_SET);
return 0;
}
static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
WtvContext *wtv = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = wtv->pb;
int stream_index, len, ret;
stream_index = parse_chunks(s, SEEK_TO_DATA, 0, &len);
@@ -536,63 +1047,51 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return ret;
pkt->stream_index = stream_index;
pkt->pts = wtv->pts;
- url_fskip(pb, WTV_PAD8(len) - len);
+ avio_seek(pb, WTV_PAD8(len) - len, SEEK_CUR);
return 0;
}
-static int read_seek2(AVFormatContext *s, int stream_index,
- int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
+static int read_seek(AVFormatContext *s, int stream_index,
+ int64_t ts, int flags)
{
WtvContext *wtv = s->priv_data;
- ByteIOContext *pb = s->pb;
- AVStream *st;
+ AVIOContext *pb = wtv->pb;
+ AVStream *st = s->streams[0];
+ int64_t ts_relative;
int i;
- if (stream_index < 0) {
- stream_index = av_find_default_stream_index(s);
- if (stream_index < 0)
- return -1;
- }
- st = s->streams[stream_index];
-
- if ((flags & AVSEEK_FLAG_FRAME)) {
+ if ((flags & AVSEEK_FLAG_FRAME) || (flags & AVSEEK_FLAG_BYTE))
return AVERROR_NOTSUPP;
- } else if ((flags & AVSEEK_FLAG_BYTE)) {
- if (ts < url_ftell(pb)) {
- for (i = st->nb_index_entries - 1; i >= 0; i--) {
- if (st->index_entries[i].pos <= ts) {
- wtv->pts = st->index_entries[i].timestamp;
- url_fseek(pb, st->index_entries[i].pos, SEEK_SET);
- break;
- }
- }
- if (i < 0) {
- wtv->pts = 0;
- url_fseek(pb, WTV_CHUNK_START, SEEK_SET);
- }
- }
- if (parse_chunks(s, SEEK_TO_BYTE, ts, 0) < 0)
+
+ /* timestamp adjustment is required because wtv->pts values are absolute,
+ * whereas AVIndexEntry->timestamp values are relative to epoch. */
+ ts_relative = ts;
+ if (wtv->epoch != AV_NOPTS_VALUE)
+ ts_relative -= wtv->epoch;
+
+ i = ff_index_search_timestamp(wtv->index_entries, wtv->nb_index_entries, ts_relative, flags);
+ if (i < 0) {
+ if (wtv->last_valid_pts == AV_NOPTS_VALUE || ts < wtv->last_valid_pts)
+ avio_seek(pb, 0, SEEK_SET);
+ else if (st->duration != AV_NOPTS_VALUE && ts_relative > st->duration && wtv->nb_index_entries)
+ avio_seek(pb, wtv->index_entries[wtv->nb_index_entries - 1].pos, SEEK_SET);
+ if (parse_chunks(s, SEEK_TO_PTS, ts, 0) < 0)
return AVERROR(ERANGE);
return 0;
- } else {
- ts *= 10;
- i = av_index_search_timestamp(st, ts, flags);
- if (i < 0) {
- if (st->nb_index_entries > 0) {
- wtv->pts = st->index_entries[st->nb_index_entries - 1].timestamp;
- url_fseek(pb, st->index_entries[st->nb_index_entries - 1].pos, SEEK_SET);
- } else {
- wtv->pts = 0;
- url_fseek(pb, WTV_CHUNK_START, SEEK_SET);
- }
- if (parse_chunks(s, SEEK_TO_PTS, ts, 0) < 0)
- return AVERROR(ERANGE);
- return 0;
- }
- wtv->pts = st->index_entries[i].timestamp;
- url_fseek(pb, st->index_entries[i].pos, SEEK_SET);
- return 0;
}
+ wtv->pts = wtv->index_entries[i].timestamp;
+ if (wtv->epoch != AV_NOPTS_VALUE)
+ wtv->pts += wtv->epoch;
+ wtv->last_valid_pts = wtv->pts;
+ avio_seek(pb, wtv->index_entries[i].pos, SEEK_SET);
+ return 0;
+}
+
+static int read_close(AVFormatContext *s)
+{
+ WtvContext *wtv = s->priv_data;
+ wtvfile_close(wtv->pb);
+ return 0;
}
AVInputFormat ff_wtv_demuxer = {
@@ -602,6 +1101,7 @@ AVInputFormat ff_wtv_demuxer = {
.read_probe = read_probe,
.read_header = read_header,
.read_packet = read_packet,
- .read_seek2 = read_seek2,
- .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT,
+ .read_seek = read_seek,
+ .read_close = read_close,
+ .flags = AVFMT_SHOW_IDS,
};
diff --git a/mplayer/ffmpeg/libavformat/wv.c b/mplayer/ffmpeg/libavformat/wv.c
index 667ae2e6..7a2c855f 100644
--- a/mplayer/ffmpeg/libavformat/wv.c
+++ b/mplayer/ffmpeg/libavformat/wv.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/audioconvert.h"
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "apetag.h"
@@ -75,7 +76,7 @@ static int wv_probe(AVProbeData *p)
return 0;
}
-static int wv_read_block_header(AVFormatContext *ctx, ByteIOContext *pb, int append)
+static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb, int append)
{
WVContext *wc = ctx->priv_data;
uint32_t tag, ver;
@@ -85,25 +86,25 @@ static int wv_read_block_header(AVFormatContext *ctx, ByteIOContext *pb, int app
wc->pos = url_ftell(pb);
if(!append){
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('w', 'v', 'p', 'k'))
return -1;
- size = get_le32(pb);
+ size = avio_rl32(pb);
if(size < 24 || size > WV_BLOCK_LIMIT){
av_log(ctx, AV_LOG_ERROR, "Incorrect block size %i\n", size);
return -1;
}
wc->blksize = size;
- ver = get_le16(pb);
+ ver = avio_rl16(pb);
if(ver < 0x402 || ver > 0x410){
av_log(ctx, AV_LOG_ERROR, "Unsupported version %03X\n", ver);
return -1;
}
- get_byte(pb); // track no
- get_byte(pb); // track sub index
- wc->samples = get_le32(pb); // total samples in file
- wc->soff = get_le32(pb); // offset in samples of current block
- get_buffer(pb, wc->extra, WV_EXTRA_SIZE);
+ avio_r8(pb); // track no
+ avio_r8(pb); // track sub index
+ wc->samples = avio_rl32(pb); // total samples in file
+ wc->soff = avio_rl32(pb); // offset in samples of current block
+ avio_read(pb, wc->extra, WV_EXTRA_SIZE);
}else{
size = wc->blksize;
}
@@ -111,7 +112,7 @@ static int wv_read_block_header(AVFormatContext *ctx, ByteIOContext *pb, int app
//parse flags
bpp = ((wc->flags & 3) + 1) << 3;
chan = 1 + !(wc->flags & WV_MONO);
- chmask = wc->flags & WV_MONO ? CH_LAYOUT_MONO : CH_LAYOUT_STEREO;
+ chmask = wc->flags & WV_MONO ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
rate = wv_rates[(wc->flags >> 23) & 0xF];
wc->multichannel = !!((wc->flags & WV_SINGLE_BLOCK) != WV_SINGLE_BLOCK);
if(wc->multichannel){
@@ -126,8 +127,8 @@ static int wv_read_block_header(AVFormatContext *ctx, ByteIOContext *pb, int app
}
while(url_ftell(pb) < block_end){
int id, size;
- id = get_byte(pb);
- size = (id & 0x80) ? get_le24(pb) : get_byte(pb);
+ id = avio_r8(pb);
+ size = (id & 0x80) ? avio_rl24(pb) : avio_r8(pb);
size <<= 1;
if(id&0x40)
size--;
@@ -137,24 +138,24 @@ static int wv_read_block_header(AVFormatContext *ctx, ByteIOContext *pb, int app
av_log(ctx, AV_LOG_ERROR, "Insufficient channel information\n");
return -1;
}
- chan = get_byte(pb);
+ chan = avio_r8(pb);
switch(size - 2){
case 0:
- chmask = get_byte(pb);
+ chmask = avio_r8(pb);
break;
case 1:
- chmask = get_le16(pb);
+ chmask = avio_rl16(pb);
break;
case 2:
- chmask = get_le24(pb);
+ chmask = avio_rl24(pb);
break;
case 3:
- chmask = get_le32(pb);
+ chmask = avio_rl32(pb);
break;
case 5:
- url_fskip(pb, 1);
- chan |= (get_byte(pb) & 0xF) << 8;
- chmask = get_le24(pb);
+ avio_seek(pb, 1, SEEK_CUR);
+ chan |= (avio_r8(pb) & 0xF) << 8;
+ chmask = avio_rl24(pb);
break;
default:
av_log(ctx, AV_LOG_ERROR, "Invalid channel info size %d\n", size);
@@ -162,19 +163,19 @@ static int wv_read_block_header(AVFormatContext *ctx, ByteIOContext *pb, int app
}
break;
case 0x27:
- rate = get_le24(pb);
+ rate = avio_rl24(pb);
break;
default:
- url_fskip(pb, size);
+ avio_seek(pb, size, SEEK_CUR);
}
if(id&0x40)
- url_fskip(pb, 1);
+ avio_seek(pb, 1, SEEK_CUR);
}
if(rate == -1){
av_log(ctx, AV_LOG_ERROR, "Cannot determine custom sampling rate\n");
return -1;
}
- url_fseek(pb, block_end - wc->blksize + 24, SEEK_SET);
+ avio_seek(pb, block_end - wc->blksize + 24, SEEK_SET);
}
if(!wc->bpp) wc->bpp = bpp;
if(!wc->chan) wc->chan = chan;
@@ -200,7 +201,7 @@ static int wv_read_block_header(AVFormatContext *ctx, ByteIOContext *pb, int app
static int wv_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
WVContext *wc = s->priv_data;
AVStream *st;
@@ -227,7 +228,7 @@ static int wv_read_header(AVFormatContext *s,
ff_ape_parse_tag(s);
if(!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
ff_id3v1_read(s);
- url_fseek(s->pb, cur, SEEK_SET);
+ avio_seek(s->pb, cur, SEEK_SET);
}
return 0;
@@ -253,13 +254,13 @@ static int wv_read_packet(AVFormatContext *s,
if(wc->multichannel)
AV_WL32(pkt->data, wc->blksize + WV_EXTRA_SIZE + 12);
memcpy(pkt->data + off, wc->extra, WV_EXTRA_SIZE);
- ret = get_buffer(s->pb, pkt->data + WV_EXTRA_SIZE + off, wc->blksize);
+ ret = avio_read(s->pb, pkt->data + WV_EXTRA_SIZE + off, wc->blksize);
if(ret != wc->blksize){
av_free_packet(pkt);
return AVERROR(EIO);
}
while(!(wc->flags & WV_END_BLOCK)){
- if(get_le32(s->pb) != MKTAG('w', 'v', 'p', 'k')){
+ if(avio_rl32(s->pb) != MKTAG('w', 'v', 'p', 'k')){
av_free_packet(pkt);
return -1;
}
@@ -274,16 +275,16 @@ static int wv_read_packet(AVFormatContext *s,
return -1;
}
wc->blksize = size;
- ver = get_le16(s->pb);
+ ver = avio_rl16(s->pb);
if(ver < 0x402 || ver > 0x410){
av_free_packet(pkt);
av_log(s, AV_LOG_ERROR, "Unsupported version %03X\n", ver);
return -1;
}
- get_byte(s->pb); // track no
- get_byte(s->pb); // track sub index
- wc->samples = get_le32(s->pb); // total samples in file
- wc->soff = get_le32(s->pb); // offset in samples of current block
+ avio_r8(s->pb); // track no
+ avio_r8(s->pb); // track sub index
+ wc->samples = avio_rl32(s->pb); // total samples in file
+ wc->soff = avio_rl32(s->pb); // offset in samples of current block
if((ret = av_append_packet(s->pb, pkt, WV_EXTRA_SIZE)) < 0){
av_free_packet(pkt);
return ret;
@@ -319,7 +320,7 @@ static int wv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
/* if found, seek there */
if (index >= 0){
wc->block_parsed = 1;
- url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET);
+ avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET);
return 0;
}
/* if timestamp is out of bounds, return error */
@@ -330,7 +331,7 @@ static int wv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
do{
ret = av_read_frame(s, pkt);
if (ret < 0){
- url_fseek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos, SEEK_SET);
return -1;
}
pts = pkt->pts;
diff --git a/mplayer/ffmpeg/libavformat/xa.c b/mplayer/ffmpeg/libavformat/xa.c
index 21a6b26e..17cf237a 100644
--- a/mplayer/ffmpeg/libavformat/xa.c
+++ b/mplayer/ffmpeg/libavformat/xa.c
@@ -66,7 +66,7 @@ static int xa_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
MaxisXADemuxContext *xa = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVStream *st;
/*Set up the XA Audio Decoder*/
@@ -76,15 +76,15 @@ static int xa_read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_ADPCM_EA_MAXIS_XA;
- url_fskip(pb, 4); /* Skip the XA ID */
- xa->out_size = get_le32(pb);
- url_fskip(pb, 2); /* Skip the tag */
- st->codec->channels = get_le16(pb);
- st->codec->sample_rate = get_le32(pb);
+ avio_seek(pb, 4, SEEK_CUR); /* Skip the XA ID */
+ xa->out_size = avio_rl32(pb);
+ avio_seek(pb, 2, SEEK_CUR); /* Skip the tag */
+ st->codec->channels = avio_rl16(pb);
+ st->codec->sample_rate = avio_rl32(pb);
/* Value in file is average byte rate*/
- st->codec->bit_rate = get_le32(pb) * 8;
- st->codec->block_align = get_le16(pb);
- st->codec->bits_per_coded_sample = get_le16(pb);
+ st->codec->bit_rate = avio_rl32(pb) * 8;
+ st->codec->block_align = avio_rl16(pb);
+ st->codec->bits_per_coded_sample = avio_rl16(pb);
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
@@ -96,7 +96,7 @@ static int xa_read_packet(AVFormatContext *s,
{
MaxisXADemuxContext *xa = s->priv_data;
AVStream *st = s->streams[0];
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
unsigned int packet_size;
int ret;
diff --git a/mplayer/ffmpeg/libavformat/yop.c b/mplayer/ffmpeg/libavformat/yop.c
index ae909254..e4437b7a 100644
--- a/mplayer/ffmpeg/libavformat/yop.c
+++ b/mplayer/ffmpeg/libavformat/yop.c
@@ -50,7 +50,7 @@ static int yop_probe(AVProbeData *probe_packet)
static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
YopDecContext *yop = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVCodecContext *audio_dec, *video_dec;
AVStream *audio_stream, *video_stream;
@@ -81,16 +81,16 @@ static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap)
video_dec->codec_type = AVMEDIA_TYPE_VIDEO;
video_dec->codec_id = CODEC_ID_YOP;
- url_fskip(pb, 6);
+ avio_seek(pb, 6, SEEK_CUR);
- frame_rate = get_byte(pb);
- yop->frame_size = get_byte(pb) * 2048;
- video_dec->width = get_le16(pb);
- video_dec->height = get_le16(pb);
+ frame_rate = avio_r8(pb);
+ yop->frame_size = avio_r8(pb) * 2048;
+ video_dec->width = avio_rl16(pb);
+ video_dec->height = avio_rl16(pb);
video_stream->sample_aspect_ratio = (AVRational){1, 2};
- ret = get_buffer(pb, video_dec->extradata, 8);
+ ret = avio_read(pb, video_dec->extradata, 8);
if (ret < 8)
return ret < 0 ? ret : AVERROR_EOF;
@@ -104,7 +104,7 @@ static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR_INVALIDDATA;
}
- url_fseek(pb, 2048, SEEK_SET);
+ avio_seek(pb, 2048, SEEK_SET);
av_set_pts_info(video_stream, 32, 1, frame_rate);
@@ -114,7 +114,7 @@ static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int yop_read_packet(AVFormatContext *s, AVPacket *pkt)
{
YopDecContext *yop = s->priv_data;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int ret;
int actual_video_data_size = yop->frame_size -
@@ -138,7 +138,7 @@ static int yop_read_packet(AVFormatContext *s, AVPacket *pkt)
yop->video_packet.pos = url_ftell(pb);
- ret = get_buffer(pb, yop->video_packet.data, yop->palette_size);
+ ret = avio_read(pb, yop->video_packet.data, yop->palette_size);
if (ret < 0) {
goto err_out;
}else if (ret < yop->palette_size) {
@@ -153,9 +153,9 @@ static int yop_read_packet(AVFormatContext *s, AVPacket *pkt)
// Set position to the start of the frame
pkt->pos = yop->video_packet.pos;
- url_fskip(pb, yop->audio_block_length - ret);
+ avio_seek(pb, yop->audio_block_length - ret, SEEK_CUR);
- ret = get_buffer(pb, yop->video_packet.data + yop->palette_size,
+ ret = avio_read(pb, yop->video_packet.data + yop->palette_size,
actual_video_data_size);
if (ret < 0)
goto err_out;
@@ -198,7 +198,7 @@ static int yop_read_seek(AVFormatContext *s, int stream_index,
frame_pos = timestamp * yop->frame_size + pos_min;
yop->odd_frame = timestamp & 1;
- url_fseek(s->pb, frame_pos, SEEK_SET);
+ avio_seek(s->pb, frame_pos, SEEK_SET);
return 0;
}
diff --git a/mplayer/ffmpeg/libavformat/yuv4mpeg.c b/mplayer/ffmpeg/libavformat/yuv4mpeg.c
index 6c763986..01366b08 100644
--- a/mplayer/ffmpeg/libavformat/yuv4mpeg.c
+++ b/mplayer/ffmpeg/libavformat/yuv4mpeg.c
@@ -90,7 +90,7 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf)
static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVStream *st = s->streams[pkt->stream_index];
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
AVPicture *picture;
int* first_pkt = s->priv_data;
int width, height, h_chroma_shift, v_chroma_shift;
@@ -108,21 +108,21 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
av_log(s, AV_LOG_ERROR, "Error. YUV4MPEG stream header write failed.\n");
return AVERROR(EIO);
} else {
- put_buffer(pb, buf2, strlen(buf2));
+ avio_write(pb, buf2, strlen(buf2));
}
}
/* construct frame header */
m = snprintf(buf1, sizeof(buf1), "%s\n", Y4M_FRAME_MAGIC);
- put_buffer(pb, buf1, strlen(buf1));
+ avio_write(pb, buf1, strlen(buf1));
width = st->codec->width;
height = st->codec->height;
ptr = picture->data[0];
for(i=0;ilinesize[0];
}
@@ -135,11 +135,11 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
ptr1 = picture->data[1];
ptr2 = picture->data[2];
for(i=0;ilinesize[1];
}
for(i=0;ilinesize[2];
}
}
@@ -192,7 +192,7 @@ static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap)
char header[MAX_YUV4_HEADER+10]; // Include headroom for the longest option
char *tokstart,*tokend,*header_end;
int i;
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
int width=-1, height=-1, raten=0, rated=0, aspectn=0, aspectd=0;
enum PixelFormat pix_fmt=PIX_FMT_NONE,alt_pix_fmt=PIX_FMT_NONE;
enum AVChromaLocation chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED;
@@ -200,7 +200,7 @@ static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap)
struct frame_attributes *s1 = s->priv_data;
for (i=0; ipriv_data;
for (i=0; ipb);
+ header[i] = avio_r8(s->pb);
if (header[i] == '\n') {
header[i+1] = 0;
break;
diff --git a/mplayer/ffmpeg/libavutil/Makefile b/mplayer/ffmpeg/libavutil/Makefile
index fe0302c3..300acb18 100644
--- a/mplayer/ffmpeg/libavutil/Makefile
+++ b/mplayer/ffmpeg/libavutil/Makefile
@@ -4,6 +4,7 @@ NAME = avutil
HEADERS = adler32.h \
attributes.h \
+ audioconvert.h \
avassert.h \
avstring.h \
avutil.h \
@@ -16,6 +17,7 @@ HEADERS = adler32.h \
eval.h \
fifo.h \
file.h \
+ imgutils.h \
intfloat_readwrite.h \
intreadwrite.h \
lfg.h \
@@ -25,16 +27,19 @@ HEADERS = adler32.h \
md5.h \
mem.h \
opt.h \
+ parseutils.h \
pixdesc.h \
pixfmt.h \
random_seed.h \
rational.h \
+ samplefmt.h \
sha1.h \
BUILT_HEADERS = avconfig.h
OBJS = adler32.o \
aes.o \
+ audioconvert.o \
avstring.o \
base64.o \
cpu.o \
@@ -44,6 +49,7 @@ OBJS = adler32.o \
eval.o \
fifo.o \
file.o \
+ imgutils.o \
intfloat_readwrite.o \
inverse.o \
lfg.o \
@@ -54,10 +60,12 @@ OBJS = adler32.o \
md5.o \
mem.o \
opt.o \
+ parseutils.o \
pixdesc.o \
random_seed.o \
rational.o \
rc4.o \
+ samplefmt.o \
sha.o \
tree.o \
utils.o \
diff --git a/mplayer/ffmpeg/libavutil/arm/intmath.h b/mplayer/ffmpeg/libavutil/arm/intmath.h
index 2c0aa3b1..8f03d4bf 100644
--- a/mplayer/ffmpeg/libavutil/arm/intmath.h
+++ b/mplayer/ffmpeg/libavutil/arm/intmath.h
@@ -31,7 +31,7 @@
#if HAVE_ARMV6
#define FASTDIV FASTDIV
-static inline av_const int FASTDIV(int a, int b)
+static av_always_inline av_const int FASTDIV(int a, int b)
{
int r, t;
__asm__ volatile("cmp %3, #2 \n\t"
@@ -43,7 +43,7 @@ static inline av_const int FASTDIV(int a, int b)
}
#define av_clip_uint8 av_clip_uint8_arm
-static inline av_const uint8_t av_clip_uint8_arm(int a)
+static av_always_inline av_const uint8_t av_clip_uint8_arm(int a)
{
unsigned x;
__asm__ volatile ("usat %0, #8, %1" : "=r"(x) : "r"(a));
@@ -51,7 +51,7 @@ static inline av_const uint8_t av_clip_uint8_arm(int a)
}
#define av_clip_int8 av_clip_int8_arm
-static inline av_const uint8_t av_clip_int8_arm(int a)
+static av_always_inline av_const uint8_t av_clip_int8_arm(int a)
{
unsigned x;
__asm__ volatile ("ssat %0, #8, %1" : "=r"(x) : "r"(a));
@@ -59,7 +59,7 @@ static inline av_const uint8_t av_clip_int8_arm(int a)
}
#define av_clip_uint16 av_clip_uint16_arm
-static inline av_const uint16_t av_clip_uint16_arm(int a)
+static av_always_inline av_const uint16_t av_clip_uint16_arm(int a)
{
unsigned x;
__asm__ volatile ("usat %0, #16, %1" : "=r"(x) : "r"(a));
@@ -67,7 +67,7 @@ static inline av_const uint16_t av_clip_uint16_arm(int a)
}
#define av_clip_int16 av_clip_int16_arm
-static inline av_const int16_t av_clip_int16_arm(int a)
+static av_always_inline av_const int16_t av_clip_int16_arm(int a)
{
int x;
__asm__ volatile ("ssat %0, #16, %1" : "=r"(x) : "r"(a));
@@ -77,7 +77,7 @@ static inline av_const int16_t av_clip_int16_arm(int a)
#else /* HAVE_ARMV6 */
#define FASTDIV FASTDIV
-static inline av_const int FASTDIV(int a, int b)
+static av_always_inline av_const int FASTDIV(int a, int b)
{
int r, t;
__asm__ volatile("umull %1, %0, %2, %3"
@@ -88,7 +88,7 @@ static inline av_const int FASTDIV(int a, int b)
#endif /* HAVE_ARMV6 */
#define av_clipl_int32 av_clipl_int32_arm
-static inline av_const int32_t av_clipl_int32_arm(int64_t a)
+static av_always_inline av_const int32_t av_clipl_int32_arm(int64_t a)
{
int x, y;
__asm__ volatile ("adds %1, %R2, %Q2, lsr #31 \n\t"
diff --git a/mplayer/ffmpeg/libavutil/attributes.h b/mplayer/ffmpeg/libavutil/attributes.h
index d93f4609..65a9249c 100644
--- a/mplayer/ffmpeg/libavutil/attributes.h
+++ b/mplayer/ffmpeg/libavutil/attributes.h
@@ -96,6 +96,19 @@
#endif
#endif
+/**
+ * Mark a variable as used and prevent the compiler from optimizing it
+ * away. This is useful for variables accessed only from inline
+ * assembler without the compiler being aware.
+ */
+#ifndef av_used
+#if AV_GCC_VERSION_AT_LEAST(3,1)
+# define av_used __attribute__((used))
+#else
+# define av_used
+#endif
+#endif
+
#ifndef av_alias
#if (!defined(__ICC) || __ICC > 1200) && AV_GCC_VERSION_AT_LEAST(3,3)
# define av_alias __attribute__((may_alias))
diff --git a/mplayer/ffmpeg/libavcore/audioconvert.c b/mplayer/ffmpeg/libavutil/audioconvert.c
similarity index 99%
rename from mplayer/ffmpeg/libavcore/audioconvert.c
rename to mplayer/ffmpeg/libavutil/audioconvert.c
index c7207338..8bc43f89 100644
--- a/mplayer/ffmpeg/libavcore/audioconvert.c
+++ b/mplayer/ffmpeg/libavutil/audioconvert.c
@@ -23,6 +23,7 @@
* audio conversion routines
*/
+#include "libavutil/avutil.h"
#include "libavutil/avstring.h"
#include "audioconvert.h"
diff --git a/mplayer/ffmpeg/libavcore/audioconvert.h b/mplayer/ffmpeg/libavutil/audioconvert.h
similarity index 97%
rename from mplayer/ffmpeg/libavcore/audioconvert.h
rename to mplayer/ffmpeg/libavutil/audioconvert.h
index 89e9c55d..134c6107 100644
--- a/mplayer/ffmpeg/libavcore/audioconvert.h
+++ b/mplayer/ffmpeg/libavutil/audioconvert.h
@@ -19,16 +19,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCORE_AUDIOCONVERT_H
-#define AVCORE_AUDIOCONVERT_H
+#ifndef AVUTIL_AUDIOCONVERT_H
+#define AVUTIL_AUDIOCONVERT_H
+
+#include
/**
* @file
* audio conversion routines
*/
-#include "avcore.h"
-
/* Audio channel masks */
#define AV_CH_FRONT_LEFT 0x00000001
#define AV_CH_FRONT_RIGHT 0x00000002
@@ -92,4 +92,4 @@ void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int6
*/
int av_get_channel_layout_nb_channels(int64_t channel_layout);
-#endif /* AVCORE_AUDIOCONVERT_H */
+#endif /* AVUTIL_AUDIOCONVERT_H */
diff --git a/mplayer/ffmpeg/libavutil/avutil.h b/mplayer/ffmpeg/libavutil/avutil.h
index 74c2b5ef..e887c4d5 100644
--- a/mplayer/ffmpeg/libavutil/avutil.h
+++ b/mplayer/ffmpeg/libavutil/avutil.h
@@ -40,7 +40,7 @@
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
#define LIBAVUTIL_VERSION_MAJOR 50
-#define LIBAVUTIL_VERSION_MINOR 36
+#define LIBAVUTIL_VERSION_MINOR 39
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -93,6 +93,18 @@ enum AVMediaType {
#define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
+#define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
+#define AV_TIME_BASE 1000000
+#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
+
+/**
+ * Those FF_API_* defines are not part of public API.
+ * They may change, break or disappear at any time.
+ */
+#ifndef FF_API_OLD_IMAGE_NAMES
+#define FF_API_OLD_IMAGE_NAMES (LIBAVUTIL_VERSION_MAJOR < 51)
+#endif
+
#include "common.h"
#include "error.h"
#include "mathematics.h"
diff --git a/mplayer/ffmpeg/libavutil/common.h b/mplayer/ffmpeg/libavutil/common.h
index 6404076a..5814297c 100644
--- a/mplayer/ffmpeg/libavutil/common.h
+++ b/mplayer/ffmpeg/libavutil/common.h
@@ -64,7 +64,7 @@ extern const uint8_t ff_log2_tab[256];
extern const uint8_t av_reverse[256];
-static inline av_const int av_log2_c(unsigned int v)
+static av_always_inline av_const int av_log2_c(unsigned int v)
{
int n = 0;
if (v & 0xffff0000) {
@@ -80,7 +80,7 @@ static inline av_const int av_log2_c(unsigned int v)
return n;
}
-static inline av_const int av_log2_16bit_c(unsigned int v)
+static av_always_inline av_const int av_log2_16bit_c(unsigned int v)
{
int n = 0;
if (v & 0xff00) {
@@ -107,7 +107,7 @@ static inline av_const int av_log2_16bit_c(unsigned int v)
* @param amax maximum value of the clip range
* @return clipped value
*/
-static inline av_const int av_clip_c(int a, int amin, int amax)
+static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
{
if (a < amin) return amin;
else if (a > amax) return amax;
@@ -119,7 +119,7 @@ static inline av_const int av_clip_c(int a, int amin, int amax)
* @param a value to clip
* @return clipped value
*/
-static inline av_const uint8_t av_clip_uint8_c(int a)
+static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
{
if (a&(~0xFF)) return (-a)>>31;
else return a;
@@ -130,7 +130,7 @@ static inline av_const uint8_t av_clip_uint8_c(int a)
* @param a value to clip
* @return clipped value
*/
-static inline av_const int8_t av_clip_int8_c(int a)
+static av_always_inline av_const int8_t av_clip_int8_c(int a)
{
if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F;
else return a;
@@ -141,7 +141,7 @@ static inline av_const int8_t av_clip_int8_c(int a)
* @param a value to clip
* @return clipped value
*/
-static inline av_const uint16_t av_clip_uint16_c(int a)
+static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
{
if (a&(~0xFFFF)) return (-a)>>31;
else return a;
@@ -152,7 +152,7 @@ static inline av_const uint16_t av_clip_uint16_c(int a)
* @param a value to clip
* @return clipped value
*/
-static inline av_const int16_t av_clip_int16_c(int a)
+static av_always_inline av_const int16_t av_clip_int16_c(int a)
{
if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF;
else return a;
@@ -163,7 +163,7 @@ static inline av_const int16_t av_clip_int16_c(int a)
* @param a value to clip
* @return clipped value
*/
-static inline av_const int32_t av_clipl_int32_c(int64_t a)
+static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
{
if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF;
else return a;
@@ -176,7 +176,7 @@ static inline av_const int32_t av_clipl_int32_c(int64_t a)
* @param amax maximum value of the clip range
* @return clipped value
*/
-static inline av_const float av_clipf_c(float a, float amin, float amax)
+static av_always_inline av_const float av_clipf_c(float a, float amin, float amax)
{
if (a < amin) return amin;
else if (a > amax) return amax;
@@ -187,7 +187,7 @@ static inline av_const float av_clipf_c(float a, float amin, float amax)
* @param x value used to compute ceil(log2(x))
* @return computed ceiling of log2(x)
*/
-static inline av_const int av_ceil_log2_c(int x)
+static av_always_inline av_const int av_ceil_log2_c(int x)
{
return av_log2((x - 1) << 1);
}
@@ -197,7 +197,7 @@ static inline av_const int av_ceil_log2_c(int x)
* @param x value to count bits of
* @return the number of bits set to one in x
*/
-static inline av_const int av_popcount_c(uint32_t x)
+static av_always_inline av_const int av_popcount_c(uint32_t x)
{
x -= (x >> 1) & 0x55555555;
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
diff --git a/mplayer/ffmpeg/libavutil/cpu.c b/mplayer/ffmpeg/libavutil/cpu.c
index 1e034914..3459ce43 100644
--- a/mplayer/ffmpeg/libavutil/cpu.c
+++ b/mplayer/ffmpeg/libavutil/cpu.c
@@ -44,7 +44,7 @@ int main(void)
int cpu_flags = av_get_cpu_flags();
printf("cpu_flags = 0x%08X\n", cpu_flags);
- printf("cpu_flags = %s%s%s%s%s%s%s%s%s%s%s%s\n",
+ printf("cpu_flags = %s%s%s%s%s%s%s%s%s%s%s%s%s\n",
#if ARCH_ARM
cpu_flags & AV_CPU_FLAG_IWMMXT ? "IWMMXT " : "",
#elif ARCH_PPC
@@ -60,6 +60,7 @@ int main(void)
cpu_flags & AV_CPU_FLAG_SSSE3 ? "SSSE3 " : "",
cpu_flags & AV_CPU_FLAG_SSE4 ? "SSE4.1 " : "",
cpu_flags & AV_CPU_FLAG_SSE42 ? "SSE4.2 " : "",
+ cpu_flags & AV_CPU_FLAG_AVX ? "AVX " : "",
cpu_flags & AV_CPU_FLAG_3DNOW ? "3DNow " : "",
cpu_flags & AV_CPU_FLAG_3DNOWEXT ? "3DNowExt " : "");
#endif
diff --git a/mplayer/ffmpeg/libavutil/cpu.h b/mplayer/ffmpeg/libavutil/cpu.h
index 71cc2652..d60e062e 100644
--- a/mplayer/ffmpeg/libavutil/cpu.h
+++ b/mplayer/ffmpeg/libavutil/cpu.h
@@ -36,6 +36,7 @@
#define AV_CPU_FLAG_SSSE3 0x0080 ///< Conroe SSSE3 functions
#define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions
#define AV_CPU_FLAG_SSE42 0x0200 ///< Nehalem SSE4.2 functions
+#define AV_CPU_FLAG_AVX 0x4000 ///< AVX functions: requires OS support even if YMM registers aren't used
#define AV_CPU_FLAG_IWMMXT 0x0100 ///< XScale IWMMXT
#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard
diff --git a/mplayer/ffmpeg/libavcore/imgutils.c b/mplayer/ffmpeg/libavutil/imgutils.c
similarity index 100%
rename from mplayer/ffmpeg/libavcore/imgutils.c
rename to mplayer/ffmpeg/libavutil/imgutils.c
diff --git a/mplayer/ffmpeg/libavcore/imgutils.h b/mplayer/ffmpeg/libavutil/imgutils.h
similarity index 96%
rename from mplayer/ffmpeg/libavcore/imgutils.h
rename to mplayer/ffmpeg/libavutil/imgutils.h
index 6c39d531..c1818635 100644
--- a/mplayer/ffmpeg/libavcore/imgutils.h
+++ b/mplayer/ffmpeg/libavutil/imgutils.h
@@ -16,8 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCORE_IMGUTILS_H
-#define AVCORE_IMGUTILS_H
+#ifndef AVUTIL_IMGUTILS_H
+#define AVUTIL_IMGUTILS_H
/**
* @file
@@ -25,7 +25,7 @@
*/
#include "libavutil/pixdesc.h"
-#include "avcore.h"
+#include "avutil.h"
/**
* Compute the max pixel step for each plane of an image with a
@@ -125,6 +125,8 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
*/
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
+int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt);
+
#if FF_API_OLD_IMAGE_NAMES
attribute_deprecated
void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
@@ -144,4 +146,4 @@ attribute_deprecated
int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
#endif
-#endif /* AVCORE_IMGUTILS_H */
+#endif /* AVUTIL_IMGUTILS_H */
diff --git a/mplayer/ffmpeg/libavutil/internal.h b/mplayer/ffmpeg/libavutil/internal.h
index 748a823a..4c98a129 100644
--- a/mplayer/ffmpeg/libavutil/internal.h
+++ b/mplayer/ffmpeg/libavutil/internal.h
@@ -46,20 +46,6 @@
#endif
#endif
-
-/**
- * Mark a variable as used and prevent the compiler from optimizing it away.
- * This is useful for asm that accesses varibles in ways that the compiler does not
- * understand
- */
-#ifndef attribute_used
-#if AV_GCC_VERSION_AT_LEAST(3,1)
-# define attribute_used __attribute__((used))
-#else
-# define attribute_used
-#endif
-#endif
-
#ifndef INT16_MIN
#define INT16_MIN (-0x7fff - 1)
#endif
@@ -224,4 +210,15 @@
type ff_##name args
#endif
+/**
+ * Returns NULL if a threading library has not been enabled.
+ * Used to disable threading functions in AVCodec definitions
+ * when not needed.
+ */
+#if HAVE_THREADS
+# define ONLY_IF_THREADS_ENABLED(x) x
+#else
+# define ONLY_IF_THREADS_ENABLED(x) NULL
+#endif
+
#endif /* AVUTIL_INTERNAL_H */
diff --git a/mplayer/ffmpeg/libavutil/mem.c b/mplayer/ffmpeg/libavutil/mem.c
index 91d50066..33f0b385 100644
--- a/mplayer/ffmpeg/libavutil/mem.c
+++ b/mplayer/ffmpeg/libavutil/mem.c
@@ -138,12 +138,11 @@ void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size)
void av_free(void *ptr)
{
- /* XXX: this test should not be needed on most libcs */
- if (ptr)
#if CONFIG_MEMALIGN_HACK
+ if (ptr)
free((char*)ptr - ((char*)ptr)[-1]);
#else
- free(ptr);
+ free(ptr);
#endif
}
diff --git a/mplayer/ffmpeg/libavutil/mem.h b/mplayer/ffmpeg/libavutil/mem.h
index ab73a323..33ab48f8 100644
--- a/mplayer/ffmpeg/libavutil/mem.h
+++ b/mplayer/ffmpeg/libavutil/mem.h
@@ -41,7 +41,7 @@
static const t __attribute__((aligned(n))) v
#elif defined(__GNUC__)
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
- #define DECLARE_ASM_CONST(n,t,v) static const t attribute_used __attribute__ ((aligned (n))) v
+ #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v
#elif defined(_MSC_VER)
#define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
#define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
diff --git a/mplayer/ffmpeg/libavcore/parseutils.c b/mplayer/ffmpeg/libavutil/parseutils.c
similarity index 71%
rename from mplayer/ffmpeg/libavcore/parseutils.c
rename to mplayer/ffmpeg/libavutil/parseutils.c
index 795aefda..61a1e225 100644
--- a/mplayer/ffmpeg/libavcore/parseutils.c
+++ b/mplayer/ffmpeg/libavutil/parseutils.c
@@ -18,12 +18,14 @@
/**
* @file
- * misc parsing utilities for libavcore
+ * misc parsing utilities
*/
#ifndef GEKKO
#include
#endif
+#include
+#include
#include "parseutils.h"
#include "libavutil/avutil.h"
#include "libavutil/eval.h"
@@ -373,6 +375,280 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
return 0;
}
+/* get a positive number between n_min and n_max, for a maximum length
+ of len_max. Return -1 if error. */
+static int date_get_num(const char **pp,
+ int n_min, int n_max, int len_max)
+{
+ int i, val, c;
+ const char *p;
+
+ p = *pp;
+ val = 0;
+ for(i = 0; i < len_max; i++) {
+ c = *p;
+ if (!isdigit(c))
+ break;
+ val = (val * 10) + c - '0';
+ p++;
+ }
+ /* no number read ? */
+ if (p == *pp)
+ return -1;
+ if (val < n_min || val > n_max)
+ return -1;
+ *pp = p;
+ return val;
+}
+
+/* small strptime for ffmpeg */
+static
+const char *small_strptime(const char *p, const char *fmt,
+ struct tm *dt)
+{
+ int c, val;
+
+ for(;;) {
+ c = *fmt++;
+ if (c == '\0') {
+ return p;
+ } else if (c == '%') {
+ c = *fmt++;
+ switch(c) {
+ case 'H':
+ val = date_get_num(&p, 0, 23, 2);
+ if (val == -1)
+ return NULL;
+ dt->tm_hour = val;
+ break;
+ case 'M':
+ val = date_get_num(&p, 0, 59, 2);
+ if (val == -1)
+ return NULL;
+ dt->tm_min = val;
+ break;
+ case 'S':
+ val = date_get_num(&p, 0, 59, 2);
+ if (val == -1)
+ return NULL;
+ dt->tm_sec = val;
+ break;
+ case 'Y':
+ val = date_get_num(&p, 0, 9999, 4);
+ if (val == -1)
+ return NULL;
+ dt->tm_year = val - 1900;
+ break;
+ case 'm':
+ val = date_get_num(&p, 1, 12, 2);
+ if (val == -1)
+ return NULL;
+ dt->tm_mon = val - 1;
+ break;
+ case 'd':
+ val = date_get_num(&p, 1, 31, 2);
+ if (val == -1)
+ return NULL;
+ dt->tm_mday = val;
+ break;
+ case '%':
+ goto match;
+ default:
+ return NULL;
+ }
+ } else {
+ match:
+ if (c != *p)
+ return NULL;
+ p++;
+ }
+ }
+ return p;
+}
+
+static time_t mktimegm(struct tm *tm)
+{
+ time_t t;
+
+ int y = tm->tm_year + 1900, m = tm->tm_mon + 1, d = tm->tm_mday;
+
+ if (m < 3) {
+ m += 12;
+ y--;
+ }
+
+ t = 86400 *
+ (d + (153 * m - 457) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 719469);
+
+ t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
+
+ return t;
+}
+
+int av_parse_time(int64_t *timeval, const char *datestr, int duration)
+{
+ const char *p;
+ int64_t t;
+ struct tm dt;
+ int i;
+ static const char * const date_fmt[] = {
+ "%Y-%m-%d",
+ "%Y%m%d",
+ };
+ static const char * const time_fmt[] = {
+ "%H:%M:%S",
+ "%H%M%S",
+ };
+ const char *q;
+ int is_utc, len;
+ char lastch;
+ int negative = 0;
+
+#undef time
+ time_t now = time(0);
+
+ len = strlen(datestr);
+ if (len > 0)
+ lastch = datestr[len - 1];
+ else
+ lastch = '\0';
+ is_utc = (lastch == 'z' || lastch == 'Z');
+
+ memset(&dt, 0, sizeof(dt));
+
+ p = datestr;
+ q = NULL;
+ if (!duration) {
+ if (!strncasecmp(datestr, "now", len)) {
+ *timeval = (int64_t) now * 1000000;
+ return 0;
+ }
+
+ /* parse the year-month-day part */
+ for (i = 0; i < FF_ARRAY_ELEMS(date_fmt); i++) {
+ q = small_strptime(p, date_fmt[i], &dt);
+ if (q) {
+ break;
+ }
+ }
+
+ /* if the year-month-day part is missing, then take the
+ * current year-month-day time */
+ if (!q) {
+ if (is_utc) {
+ dt = *gmtime(&now);
+ } else {
+ dt = *localtime(&now);
+ }
+ dt.tm_hour = dt.tm_min = dt.tm_sec = 0;
+ } else {
+ p = q;
+ }
+
+ if (*p == 'T' || *p == 't' || *p == ' ')
+ p++;
+
+ /* parse the hour-minute-second part */
+ for (i = 0; i < FF_ARRAY_ELEMS(time_fmt); i++) {
+ q = small_strptime(p, time_fmt[i], &dt);
+ if (q) {
+ break;
+ }
+ }
+ } else {
+ /* parse datestr as a duration */
+ if (p[0] == '-') {
+ negative = 1;
+ ++p;
+ }
+ /* parse datestr as HH:MM:SS */
+ q = small_strptime(p, time_fmt[0], &dt);
+ if (!q) {
+ /* parse datestr as S+ */
+ dt.tm_sec = strtol(p, (char **)&q, 10);
+ if (q == p) {
+ /* the parsing didn't succeed */
+ *timeval = INT64_MIN;
+ return AVERROR(EINVAL);
+ }
+ dt.tm_min = 0;
+ dt.tm_hour = 0;
+ }
+ }
+
+ /* Now we have all the fields that we can get */
+ if (!q) {
+ *timeval = INT64_MIN;
+ return AVERROR(EINVAL);
+ }
+
+ if (duration) {
+ t = dt.tm_hour * 3600 + dt.tm_min * 60 + dt.tm_sec;
+ } else {
+ dt.tm_isdst = -1; /* unknown */
+ if (is_utc) {
+ t = mktimegm(&dt);
+ } else {
+ t = mktime(&dt);
+ }
+ }
+
+ t *= 1000000;
+
+ /* parse the .m... part */
+ if (*q == '.') {
+ int val, n;
+ q++;
+ for (val = 0, n = 100000; n >= 1; n /= 10, q++) {
+ if (!isdigit(*q))
+ break;
+ val += n * (*q - '0');
+ }
+ t += val;
+ }
+ *timeval = negative ? -t : t;
+ return 0;
+}
+
+int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
+{
+ const char *p;
+ char tag[128], *q;
+
+ p = info;
+ if (*p == '?')
+ p++;
+ for(;;) {
+ q = tag;
+ while (*p != '\0' && *p != '=' && *p != '&') {
+ if ((q - tag) < sizeof(tag) - 1)
+ *q++ = *p;
+ p++;
+ }
+ *q = '\0';
+ q = arg;
+ if (*p == '=') {
+ p++;
+ while (*p != '&' && *p != '\0') {
+ if ((q - arg) < arg_size - 1) {
+ if (*p == '+')
+ *q++ = ' ';
+ else
+ *q++ = *p;
+ }
+ p++;
+ }
+ }
+ *q = '\0';
+ if (!strcmp(tag, tag1))
+ return 1;
+ if (*p != '&')
+ break;
+ p++;
+ }
+ return 0;
+}
+
#ifdef TEST
#undef printf
diff --git a/mplayer/ffmpeg/libavcore/parseutils.h b/mplayer/ffmpeg/libavutil/parseutils.h
similarity index 63%
rename from mplayer/ffmpeg/libavcore/parseutils.h
rename to mplayer/ffmpeg/libavutil/parseutils.h
index 052427bb..c3986af2 100644
--- a/mplayer/ffmpeg/libavcore/parseutils.h
+++ b/mplayer/ffmpeg/libavutil/parseutils.h
@@ -16,14 +16,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCORE_PARSEUTILS_H
-#define AVCORE_PARSEUTILS_H
+#ifndef AVUTIL_PARSEUTILS_H
+#define AVUTIL_PARSEUTILS_H
#include "libavutil/rational.h"
/**
* @file
- * misc parsing utilities for libavcore
+ * misc parsing utilities
*/
/**
@@ -72,4 +72,46 @@ int av_parse_video_rate(AVRational *rate, const char *str);
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
void *log_ctx);
-#endif /* AVCORE_PARSEUTILS_H */
+/**
+ * Parses timestr and returns in *time a corresponding number of
+ * microseconds.
+ *
+ * @param timeval puts here the number of microseconds corresponding
+ * to the string in timestr. If the string represents a duration, it
+ * is the number of microseconds contained in the time interval. If
+ * the string is a date, is the number of microseconds since 1st of
+ * January, 1970 up to the time of the parsed date. If timestr cannot
+ * be successfully parsed, set *time to INT64_MIN.
+
+ * @param datestr a string representing a date or a duration.
+ * - If a date the syntax is:
+ * @code
+ * [{YYYY-MM-DD|YYYYMMDD}[T|t| ]]{{HH[:MM[:SS[.m...]]]}|{HH[MM[SS[.m...]]]}}[Z]
+ * now
+ * @endcode
+ * If the value is "now" it takes the current time.
+ * Time is local time unless Z is appended, in which case it is
+ * interpreted as UTC.
+ * If the year-month-day part is not specified it takes the current
+ * year-month-day.
+ * - If a duration the syntax is:
+ * @code
+ * [-]HH[:MM[:SS[.m...]]]
+ * [-]S+[.m...]
+ * @endcode
+ * @param duration flag which tells how to interpret timestr, if not
+ * zero timestr is interpreted as a duration, otherwise as a date
+ * @return 0 in case of success, a negative value corresponding to an
+ * AVERROR code otherwise
+ */
+int av_parse_time(int64_t *timeval, const char *timestr, int duration);
+
+/**
+ * Attempt to find a specific tag in a URL.
+ *
+ * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
+ * Return 1 if found.
+ */
+int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
+
+#endif /* AVUTIL_PARSEUTILS_H */
diff --git a/mplayer/ffmpeg/libavutil/ppc/bswap.h b/mplayer/ffmpeg/libavutil/ppc/bswap.h
index 043a595b..4721e919 100644
--- a/mplayer/ffmpeg/libavutil/ppc/bswap.h
+++ b/mplayer/ffmpeg/libavutil/ppc/bswap.h
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/mplayer/ffmpeg/libavutil/ppc/intmath.h b/mplayer/ffmpeg/libavutil/ppc/intmath.h
index 0596aeb5..525e37b2 100644
--- a/mplayer/ffmpeg/libavutil/ppc/intmath.h
+++ b/mplayer/ffmpeg/libavutil/ppc/intmath.h
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/mplayer/ffmpeg/libavutil/ppc/paired.h b/mplayer/ffmpeg/libavutil/ppc/paired.h
index 92ad4a69..eb9fdbb7 100644
--- a/mplayer/ffmpeg/libavutil/ppc/paired.h
+++ b/mplayer/ffmpeg/libavutil/ppc/paired.h
@@ -4,7 +4,7 @@
* MPlayer CE 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* MPlayer CE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/mplayer/ffmpeg/libavcore/samplefmt.c b/mplayer/ffmpeg/libavutil/samplefmt.c
similarity index 97%
rename from mplayer/ffmpeg/libavcore/samplefmt.c
rename to mplayer/ffmpeg/libavutil/samplefmt.c
index 532acd95..c9ffd1ac 100644
--- a/mplayer/ffmpeg/libavcore/samplefmt.c
+++ b/mplayer/ffmpeg/libavutil/samplefmt.c
@@ -16,9 +16,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "avcore.h"
#include "samplefmt.h"
+#include
+#include
+#include
+
typedef struct SampleFmtInfo {
const char *name;
int bits;
diff --git a/mplayer/ffmpeg/libavcore/samplefmt.h b/mplayer/ffmpeg/libavutil/samplefmt.h
similarity index 93%
rename from mplayer/ffmpeg/libavcore/samplefmt.h
rename to mplayer/ffmpeg/libavutil/samplefmt.h
index 9701efe7..0604580a 100644
--- a/mplayer/ffmpeg/libavcore/samplefmt.h
+++ b/mplayer/ffmpeg/libavutil/samplefmt.h
@@ -16,10 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCORE_SAMPLEFMT_H
-#define AVCORE_SAMPLEFMT_H
-
-#include "avcore.h"
+#ifndef AVUTIL_SAMPLEFMT_H
+#define AVUTIL_SAMPLEFMT_H
/**
* all in native-endian format
@@ -31,7 +29,7 @@ enum AVSampleFormat {
AV_SAMPLE_FMT_S32, ///< signed 32 bits
AV_SAMPLE_FMT_FLT, ///< float
AV_SAMPLE_FMT_DBL, ///< double
- AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcore
+ AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically
};
/**
@@ -69,4 +67,4 @@ char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat samp
*/
int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
-#endif /* AVCORE_SAMPLEFMT_H */
+#endif /* AVUTIL_SAMPLEFMT_H */
diff --git a/mplayer/ffmpeg/libavutil/tree.h b/mplayer/ffmpeg/libavutil/tree.h
index bf09fd0b..8c7de2ff 100644
--- a/mplayer/ffmpeg/libavutil/tree.h
+++ b/mplayer/ffmpeg/libavutil/tree.h
@@ -67,7 +67,7 @@ void *av_tree_find(const struct AVTreeNode *root, void *key, int (*cmp)(void *ke
* return av_tree_insert(rootp, key, cmp, next);
* }
* void *tree_remove(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b, AVTreeNode **next)){
- * if(*next) av_freep(next);
+ * av_freep(next);
* return av_tree_insert(rootp, key, cmp, next);
* }
* @endcode
diff --git a/mplayer/ffmpeg/libavutil/x86/cpu.c b/mplayer/ffmpeg/libavutil/x86/cpu.c
index 4b6cb0df..14d0fe10 100644
--- a/mplayer/ffmpeg/libavutil/x86/cpu.c
+++ b/mplayer/ffmpeg/libavutil/x86/cpu.c
@@ -35,6 +35,9 @@
"=c" (ecx), "=d" (edx)\
: "0" (index));
+#define xgetbv(index,eax,edx) \
+ __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index))
+
/* Function to test if multimedia instructions are supported... */
int ff_get_cpu_flags_x86(void)
{
@@ -93,6 +96,15 @@ int ff_get_cpu_flags_x86(void)
rval |= AV_CPU_FLAG_SSE4;
if (ecx & 0x00100000 )
rval |= AV_CPU_FLAG_SSE42;
+#if HAVE_AVX
+ /* Check OXSAVE and AVX bits */
+ if ((ecx & 0x18000000) == 0x18000000) {
+ /* Check for OS support */
+ xgetbv(0, eax, edx);
+ if ((eax & 0x6) == 0x6)
+ rval |= AV_CPU_FLAG_AVX;
+ }
+#endif
#endif
;
}
@@ -109,13 +121,28 @@ int ff_get_cpu_flags_x86(void)
rval |= AV_CPU_FLAG_MMX;
if (ext_caps & (1<<22))
rval |= AV_CPU_FLAG_MMX2;
+
+ /* Allow for selectively disabling SSE2 functions on AMD processors
+ with SSE2 support but not SSE4a. This includes Athlon64, some
+ Opteron, and some Sempron processors. MMX, SSE, or 3DNow! are faster
+ than SSE2 often enough to utilize this special-case flag.
+ AV_CPU_FLAG_SSE2 and AV_CPU_FLAG_SSE2SLOW are both set in this case
+ so that SSE2 is used unless explicitly disabled by checking
+ AV_CPU_FLAG_SSE2SLOW. */
+ if (!strncmp(vendor.c, "AuthenticAMD", 12) &&
+ rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) {
+ rval |= AV_CPU_FLAG_SSE2SLOW;
+ }
}
if (!strncmp(vendor.c, "GenuineIntel", 12) &&
family == 6 && (model == 9 || model == 13 || model == 14)) {
/* 6/9 (pentium-m "banias"), 6/13 (pentium-m "dothan"), and 6/14 (core1 "yonah")
* theoretically support sse2, but it's usually slower than mmx,
- * so let's just pretend they don't. */
+ * so let's just pretend they don't. AV_CPU_FLAG_SSE2 is disabled and
+ * AV_CPU_FLAG_SSE2SLOW is enabled so that SSE2 is not used unless
+ * explicitly enabled by checking AV_CPU_FLAG_SSE2SLOW. The same
+ * situation applies for AV_CPU_FLAG_SSE3 and AV_CPU_FLAG_SSE3SLOW. */
if (rval & AV_CPU_FLAG_SSE2) rval ^= AV_CPU_FLAG_SSE2SLOW|AV_CPU_FLAG_SSE2;
if (rval & AV_CPU_FLAG_SSE3) rval ^= AV_CPU_FLAG_SSE3SLOW|AV_CPU_FLAG_SSE3;
}
diff --git a/mplayer/ffmpeg/libswscale/Makefile b/mplayer/ffmpeg/libswscale/Makefile
index 8c5c4b9d..69760796 100644
--- a/mplayer/ffmpeg/libswscale/Makefile
+++ b/mplayer/ffmpeg/libswscale/Makefile
@@ -20,4 +20,3 @@ TESTPROGS = colorspace swscale
DIRS = bfin mlib ppc sparc x86
include $(SUBDIR)../subdir.mak
-$(SUBDIR)swscale-test$(EXESUF): ELIBS = -lavcore
diff --git a/mplayer/ffmpeg/libswscale/swscale-test.c b/mplayer/ffmpeg/libswscale/swscale-test.c
index ae5f8b70..7f171ea7 100644
--- a/mplayer/ffmpeg/libswscale/swscale-test.c
+++ b/mplayer/ffmpeg/libswscale/swscale-test.c
@@ -25,7 +25,7 @@
#include
#undef HAVE_AV_CONFIG_H
-#include "libavcore/imgutils.h"
+#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/avutil.h"
#include "libavutil/crc.h"
@@ -104,8 +104,7 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
int p;
for (p = 0; p < 4; p++)
- if (src[p])
- av_freep(&src[p]);
+ av_freep(&src[p]);
av_image_fill_linesizes(srcStride, srcFormat, srcW);
for (p = 0; p < 4; p++) {
diff --git a/mplayer/ffmpeg/libswscale/swscale_template.c b/mplayer/ffmpeg/libswscale/swscale_template.c
index 9da6b41f..9863a7c9 100644
--- a/mplayer/ffmpeg/libswscale/swscale_template.c
+++ b/mplayer/ffmpeg/libswscale/swscale_template.c
@@ -1883,7 +1883,7 @@ static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, long w
static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, long width, enum PixelFormat srcFormat)
{
__asm__ volatile(
- "movq 24+%4, %%mm6 \n\t"
+ "movq 24(%4), %%mm6 \n\t"
"mov %3, %%"REG_a" \n\t"
"pxor %%mm7, %%mm7 \n\t"
"1: \n\t"
@@ -1894,9 +1894,9 @@ static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uin
"punpcklbw %%mm7, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
- "pmaddwd %4, %%mm0 \n\t"
- "pmaddwd 8+%4, %%mm1 \n\t"
- "pmaddwd 16+%4, %%mm2 \n\t"
+ "pmaddwd (%4), %%mm0 \n\t"
+ "pmaddwd 8(%4), %%mm1 \n\t"
+ "pmaddwd 16(%4), %%mm2 \n\t"
"pmaddwd %%mm6, %%mm3 \n\t"
"paddd %%mm1, %%mm0 \n\t"
"paddd %%mm3, %%mm2 \n\t"
@@ -1908,9 +1908,9 @@ static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uin
"punpcklbw %%mm7, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
- "pmaddwd %4, %%mm1 \n\t"
- "pmaddwd 8+%4, %%mm3 \n\t"
- "pmaddwd 16+%4, %%mm4 \n\t"
+ "pmaddwd (%4), %%mm1 \n\t"
+ "pmaddwd 8(%4), %%mm3 \n\t"
+ "pmaddwd 16(%4), %%mm4 \n\t"
"pmaddwd %%mm6, %%mm5 \n\t"
"paddd %%mm3, %%mm1 \n\t"
"paddd %%mm5, %%mm4 \n\t"
@@ -1933,7 +1933,7 @@ static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uin
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: "+r" (src)
- : "r" (dstU+width), "r" (dstV+width), "g" ((x86_reg)-width), "m"(ff_bgr24toUV[srcFormat == PIX_FMT_RGB24][0])
+ : "r" (dstU+width), "r" (dstV+width), "g" ((x86_reg)-width), "r"(ff_bgr24toUV[srcFormat == PIX_FMT_RGB24])
: "%"REG_a
);
}
diff --git a/mplayer/ffmpeg/tests/codec-regression.sh b/mplayer/ffmpeg/tests/codec-regression.sh
index 71d50a12..b705bc18 100644
--- a/mplayer/ffmpeg/tests/codec-regression.sh
+++ b/mplayer/ffmpeg/tests/codec-regression.sh
@@ -249,8 +249,8 @@ do_video_decoding "" "-pix_fmt yuv420p"
fi
if [ -n "$do_qtrle" ] ; then
-do_video_encoding qtrle.mov "" ""
-do_video_decoding "" ""
+do_video_encoding qtrle.mov "" "-an -vcodec qtrle"
+do_video_decoding "" "-pix_fmt yuv420p"
fi
if [ -n "$do_rgb" ] ; then
diff --git a/mplayer/ffmpeg/tests/ref/acodec/ac3_fixed b/mplayer/ffmpeg/tests/ref/acodec/ac3_fixed
index 17159e18..f32443d3 100644
--- a/mplayer/ffmpeg/tests/ref/acodec/ac3_fixed
+++ b/mplayer/ffmpeg/tests/ref/acodec/ac3_fixed
@@ -1,2 +1,2 @@
-9823c8f74097eab5d148cf0536ae932e *./tests/data/acodec/ac3.rm
+07bd593823ebd721b3a32ef298bdfc20 *./tests/data/acodec/ac3.rm
98751 ./tests/data/acodec/ac3.rm
diff --git a/mplayer/ffmpeg/tests/ref/fate/bink-demux-video b/mplayer/ffmpeg/tests/ref/fate/bink-demux-video
index 22fb3c5a..f3adf76b 100644
--- a/mplayer/ffmpeg/tests/ref/fate/bink-demux-video
+++ b/mplayer/ffmpeg/tests/ref/fate/bink-demux-video
@@ -13,8 +13,8 @@
0, 72000, 460800, 0x71c0f48e
0, 78000, 460800, 0x5fc8f783
0, 84000, 460800, 0xd23d336a
-0, 90000, 460800, 0xa7aca9e0
-0, 96000, 460800, 0x1dff2144
-0, 102000, 460800, 0x82cf8b2b
-0, 108000, 460800, 0x4cbe3544
+0, 90000, 460800, 0xadcfa9e0
+0, 96000, 460800, 0x24222144
+0, 102000, 460800, 0x88f28b2b
+0, 108000, 460800, 0x52e13544
0, 114000, 460800, 0x7e724731
diff --git a/mplayer/ffmpeg/tests/ref/fate/sierra-vmd b/mplayer/ffmpeg/tests/ref/fate/sierra-vmd
index 4d9e4cdd..91a8e465 100644
--- a/mplayer/ffmpeg/tests/ref/fate/sierra-vmd
+++ b/mplayer/ffmpeg/tests/ref/fate/sierra-vmd
@@ -1,5 +1,5 @@
0, 0, 230400, 0x0224ab01
-1, 0, 123480, 0xc1059826
+1, 0, 123480, 0x3a794c13
0, 9000, 230400, 0x449e4d81
0, 18000, 230400, 0x3e15e07a
0, 27000, 230400, 0xdabe4172
@@ -27,277 +27,306 @@
0, 225000, 230400, 0x76aebdae
0, 234000, 230400, 0x81357545
0, 243000, 230400, 0x38baeebd
-1, 252000, 4410, 0x261a09c0
+1, 252000, 4410, 0x109d04e0
0, 252000, 230400, 0x1c5c44d4
-1, 261000, 4410, 0x68e9489e
+1, 261000, 4410, 0x224d244f
0, 261000, 230400, 0x60e189cc
-1, 270000, 4410, 0xb830827a
+1, 270000, 4410, 0xbb72413d
0, 270000, 230400, 0xb1f4381c
-1, 279000, 4410, 0xb053b70c
+1, 279000, 4410, 0xaa5f5b86
0, 279000, 230400, 0xb5048fed
-1, 288000, 4410, 0xd8845d5d
+1, 288000, 4410, 0x94e7aea7
0, 288000, 230400, 0xc947c30e
-1, 297000, 4410, 0xd741f940
+1, 297000, 4410, 0xad497ca0
0, 297000, 230400, 0xe8e31c07
-1, 306000, 4410, 0x4860193c
+1, 306000, 4410, 0x1de10c9e
0, 306000, 230400, 0x6d49dd02
-1, 315000, 4410, 0x2e70df5f
+1, 315000, 4410, 0x9f55efa8
0, 315000, 230400, 0x293e15d3
-1, 324000, 4410, 0x4b3e0e54
+1, 324000, 4410, 0x220a072a
0, 324000, 230400, 0x354d792e
-1, 333000, 4410, 0x4afbf661
+1, 333000, 4410, 0xa7dafb29
0, 333000, 230400, 0x35468780
-1, 342000, 4410, 0x485c3903
+1, 342000, 4410, 0xd5e29c7a
0, 342000, 230400, 0x365d3991
-1, 351000, 4410, 0xc0a1a00c
+1, 351000, 4410, 0xb8465006
0, 351000, 230400, 0xc9debef2
-1, 360000, 4410, 0x0ce2d38e
+1, 360000, 4410, 0x518669c7
0, 360000, 230400, 0x4c4634c2
-1, 369000, 4410, 0x5b52dfa3
+1, 369000, 4410, 0xb5b5efca
0, 369000, 230400, 0x347c2dca
-1, 378000, 4410, 0x0d6c02ba
+1, 378000, 4410, 0x8600015d
0, 378000, 230400, 0x1efa0aaa
-1, 387000, 4410, 0x55f31fe1
+1, 387000, 4410, 0xe2f68fe9
0, 387000, 230400, 0xa79a0b5a
-1, 396000, 4410, 0x7350b1b2
+1, 396000, 4410, 0x8d3458d9
0, 396000, 230400, 0xfdb2dcdb
-1, 405000, 4410, 0x2b918eea
+1, 405000, 4410, 0xf1ff4775
0, 405000, 230400, 0x42dbea33
-1, 414000, 4410, 0x6df6cf92
+1, 414000, 4410, 0x830f67c9
0, 414000, 230400, 0x2a207e43
-1, 423000, 4410, 0x2ddd1782
+1, 423000, 4410, 0x110e0bc1
0, 423000, 230400, 0x86573783
-1, 432000, 4410, 0x12265e8e
+1, 432000, 4410, 0x71682f47
0, 432000, 230400, 0xc3968473
-1, 441000, 4410, 0x00c62139
+1, 441000, 4410, 0x38119095
0, 441000, 230400, 0x8f62a7b4
-1, 450000, 4410, 0xf2579b6c
+1, 450000, 4410, 0xd2494db6
0, 450000, 230400, 0x5a2e3073
-1, 459000, 4410, 0x3bc24a12
+1, 459000, 4410, 0x8b552509
0, 459000, 230400, 0xd24f5e2c
-1, 468000, 4410, 0x0ce25212
+1, 468000, 4410, 0x71e52909
0, 468000, 230400, 0x1df3c67d
-1, 477000, 4410, 0xad70de9a
+1, 477000, 4410, 0x9f0a6f4d
0, 477000, 230400, 0xe4fd884d
-1, 486000, 4410, 0x232705e4
+1, 486000, 4410, 0x901302f2
0, 486000, 230400, 0x9a228555
-1, 495000, 4410, 0x5ceba444
+1, 495000, 4410, 0x855d5222
0, 495000, 230400, 0x9eba8ed5
-1, 504000, 4410, 0x17a3660b
+1, 504000, 4410, 0x324bb2fe
0, 504000, 230400, 0x3d808a3d
-1, 513000, 4410, 0x291bb07e
+1, 513000, 4410, 0xe85f583f
0, 513000, 230400, 0xf57e866d
-1, 522000, 4410, 0xc13ccf88
+1, 522000, 4410, 0x2cbc67c4
0, 522000, 230400, 0x85f594f5
-1, 531000, 4410, 0xfb0cd542
+1, 531000, 4410, 0xc82e6aa1
0, 531000, 230400, 0xb09f99dd
-1, 540000, 4410, 0xb6438478
+1, 540000, 4410, 0xb9fc423c
0, 540000, 230400, 0x2b368475
-1, 549000, 4410, 0x263e9df2
+1, 549000, 4410, 0x6b9b4ef9
0, 549000, 230400, 0xa2417afd
-1, 558000, 4410, 0x81621e20
+1, 558000, 4410, 0x39290f10
0, 558000, 230400, 0x590b709d
-1, 567000, 4410, 0xe9a51d77
+1, 567000, 4410, 0xad718eb4
0, 567000, 230400, 0x5d617705
-1, 576000, 4410, 0x69a3c758
+1, 576000, 4410, 0x82f463ac
0, 576000, 230400, 0xabf981ad
-1, 585000, 4410, 0x725af958
+1, 585000, 4410, 0xfac87cac
0, 585000, 230400, 0x5a8590cd
-1, 594000, 4410, 0x09db995d
+1, 594000, 4410, 0x9e8bcca7
0, 594000, 230400, 0x1bff853d
-1, 603000, 4410, 0x42963941
+1, 603000, 4410, 0x52f79c99
0, 603000, 230400, 0x71d08055
-1, 612000, 4410, 0x33a29bc4
+1, 612000, 4410, 0xf2d14de2
0, 612000, 230400, 0x2ebd817d
-1, 621000, 4410, 0x02ee2bd1
+1, 621000, 4410, 0x367f95e1
0, 621000, 230400, 0x6e838255
-1, 630000, 4410, 0xda968535
+1, 630000, 4410, 0x8bfac293
0, 630000, 230400, 0x043984cd
-1, 639000, 4410, 0x5414a080
+1, 639000, 4410, 0x01ea5040
0, 639000, 230400, 0x7ff18495
-1, 648000, 4410, 0x021ac433
+1, 648000, 4410, 0x8ff5e212
0, 648000, 230400, 0xa43b8385
-1, 657000, 4410, 0x50195048
+1, 657000, 4410, 0x93f32824
0, 657000, 230400, 0x72b5825d
-1, 666000, 4410, 0xc40921c7
+1, 666000, 4410, 0x998f90dc
0, 666000, 230400, 0x3a178085
-1, 675000, 4410, 0xdbb622e0
+1, 675000, 4410, 0x65231170
0, 675000, 230400, 0x67748245
-1, 684000, 4410, 0xc8d07342
+1, 684000, 4410, 0xc79039a1
0, 684000, 230400, 0xeddf81d5
-1, 693000, 4410, 0x6ed9b17a
+1, 693000, 4410, 0x0b0e58bd
0, 693000, 230400, 0x8b088665
-1, 702000, 4410, 0x39ac6a03
+1, 702000, 4410, 0xc24ab4fa
0, 702000, 230400, 0x6c408e15
-1, 711000, 4410, 0x119ed51c
+1, 711000, 4410, 0xd3796a8e
0, 711000, 230400, 0x81f196dd
-1, 720000, 4410, 0xc9a20539
+1, 720000, 4410, 0xa37f8295
0, 720000, 230400, 0xab9f953d
-1, 729000, 4410, 0x6db5fdbd
+1, 729000, 4410, 0xb760fed7
0, 729000, 230400, 0xa5f69795
-1, 738000, 4410, 0x64c6b468
+1, 738000, 4410, 0x05495a34
0, 738000, 230400, 0xa772950d
-1, 747000, 4410, 0x1286686e
+1, 747000, 4410, 0x6f203437
0, 747000, 230400, 0x6a5596d5
-1, 756000, 4410, 0x76632813
+1, 756000, 4410, 0x71299402
0, 756000, 230400, 0x1355958d
-1, 765000, 4410, 0x9923669b
+1, 765000, 4410, 0x72e7b346
0, 765000, 230400, 0x4134981d
-1, 774000, 4410, 0x1cf31b5c
+1, 774000, 4410, 0x879b0dae
0, 774000, 230400, 0x8b929515
-1, 783000, 4410, 0xa9f14389
+1, 783000, 4410, 0x041aa1bd
0, 783000, 230400, 0x482f95c5
-1, 792000, 4410, 0x9438c5cc
+1, 792000, 4410, 0x18a962e6
0, 792000, 230400, 0x7a9795d5
-1, 801000, 4410, 0x48dd0a72
+1, 801000, 4410, 0x21d20539
0, 801000, 230400, 0x21c29abd
-1, 810000, 4410, 0xb0fe24dd
+1, 810000, 4410, 0x8f449267
0, 810000, 230400, 0x9ae6a475
-1, 819000, 4410, 0xdb9d03ac
+1, 819000, 4410, 0xecdc01d6
0, 819000, 230400, 0x3734aee5
-1, 828000, 4410, 0x487d7ac3
+1, 828000, 4410, 0x458abd5a
0, 828000, 230400, 0xa0a1b365
-1, 837000, 4410, 0x2b61d4d5
+1, 837000, 4410, 0xa070ea63
0, 837000, 230400, 0x2dcab1c5
-1, 846000, 4410, 0xab934d9c
+1, 846000, 4410, 0xc25b26ce
0, 846000, 230400, 0x9c8b6c44
-1, 855000, 4410, 0xd2ee6f94
+1, 855000, 4410, 0x4d9237ca
0, 855000, 230400, 0x5da75feb
-1, 864000, 4410, 0x012c3002
+1, 864000, 4410, 0x748e1801
0, 864000, 230400, 0x4d02f8e3
-1, 873000, 4410, 0xfccbd3cc
+1, 873000, 4410, 0xc96b69e6
0, 873000, 230400, 0x66824f3a
-1, 882000, 4410, 0xe53230d8
+1, 882000, 4410, 0x6663186c
0, 882000, 230400, 0x0c9257e2
-1, 891000, 4410, 0x2f6a6102
+1, 891000, 4410, 0x7f6d3081
0, 891000, 230400, 0xb2927092
-1, 900000, 4410, 0x77bb876a
+1, 900000, 4410, 0x1a0343b5
0, 900000, 230400, 0xb5dc6e9a
-1, 909000, 4410, 0xbcb76718
+1, 909000, 4410, 0xc48e338c
0, 909000, 230400, 0x6e567bc6
-1, 918000, 4410, 0x51c00790
+1, 918000, 4410, 0x26fc03c8
0, 918000, 230400, 0xbf9e0f7a
-1, 927000, 4410, 0x51b8fc5a
+1, 927000, 4410, 0x69be7e2d
0, 927000, 230400, 0xb16f684a
-1, 936000, 4410, 0x20fe9b42
+1, 936000, 4410, 0x69a74da1
0, 936000, 230400, 0xf9e55e81
-1, 945000, 4410, 0x363c5566
+1, 945000, 4410, 0x85bd2ab3
0, 945000, 230400, 0xd8d0bcba
-1, 954000, 4410, 0x3424a84c
+1, 954000, 4410, 0xeff05426
0, 954000, 230400, 0x44720ac0
-1, 963000, 4410, 0x7c3053c0
+1, 963000, 4410, 0x292829e0
0, 963000, 230400, 0x7d4c2058
-1, 972000, 4410, 0x368f2f30
+1, 972000, 4410, 0x8f741798
0, 972000, 230400, 0xb0973eb9
-1, 981000, 4410, 0x0f1e6fd2
+1, 981000, 4410, 0x6b9337e9
0, 981000, 230400, 0x405a13ce
-1, 990000, 4410, 0x3a1fe07e
+1, 990000, 4410, 0xe4e1703f
0, 990000, 230400, 0x6422f00a
-1, 999000, 4410, 0x74afd86a
+1, 999000, 4410, 0x043d6c35
0, 999000, 230400, 0x924b6c1e
-1, 1008000, 4410, 0xfdf911dd
+1, 1008000, 4410, 0x3a8988e7
0, 1008000, 230400, 0xcf7809c0
-1, 1017000, 4410, 0x1206a561
+1, 1017000, 4410, 0x1fa7d2a9
0, 1017000, 230400, 0x883a3863
-1, 1026000, 4410, 0x5f0f33d5
+1, 1026000, 4410, 0xe28799e3
0, 1026000, 230400, 0x6adc9e03
-1, 1035000, 4410, 0xca3d88e0
+1, 1035000, 4410, 0xc2df4470
0, 1035000, 230400, 0x4f5ab7a8
-1, 1044000, 4410, 0xdf8f19ea
+1, 1044000, 4410, 0x694d0cf5
0, 1044000, 230400, 0xdc0aab94
-1, 1053000, 4410, 0xe3275b9e
-1, 1062000, 4410, 0xee1945c5
-1, 1071000, 4410, 0x0afbd006
-1, 1080000, 4410, 0x90ff8f14
-1, 1089000, 4410, 0xfc0c887a
-1, 1098000, 4410, 0xae9bc232
-1, 1107000, 4410, 0x5f688eb8
-1, 1116000, 4410, 0x9a307469
-1, 1125000, 4410, 0x27f1e324
-1, 1134000, 4410, 0x0c0d4ca2
-1, 1143000, 4410, 0xd7e8ce74
-1, 1152000, 4410, 0x16a4bfd6
-1, 1161000, 4410, 0xbfb02f6d
-1, 1170000, 4410, 0xf4b81a79
-1, 1179000, 4410, 0x05d97288
-1, 1188000, 4410, 0x3a7db4be
-1, 1197000, 4410, 0xc6bea83e
-1, 1206000, 4410, 0x436f62ed
-1, 1215000, 4410, 0x6fabea0c
-1, 1224000, 4410, 0x954878aa
-1, 1233000, 4410, 0x4d10f579
-1, 1242000, 4410, 0xac65932a
-1, 1251000, 4410, 0x6889f957
-1, 1260000, 4410, 0x65cf5830
-1, 1269000, 4410, 0x87a7af71
-1, 1278000, 4410, 0x82378c13
-1, 1287000, 4410, 0x88ab6bd5
-1, 1296000, 4410, 0xf90a3342
-1, 1305000, 4410, 0xd790a1bc
-1, 1314000, 4410, 0x89919d7c
-1, 1323000, 4410, 0x7ffb22bf
-1, 1332000, 4410, 0xfefbcce3
-1, 1341000, 4410, 0x07714e80
-1, 1350000, 4410, 0x73078f53
-1, 1359000, 4410, 0x35c23078
-1, 1368000, 4410, 0x452538bb
-1, 1377000, 4410, 0x61493f33
-1, 1386000, 4410, 0x2137c390
-1, 1395000, 4410, 0x78c9393f
-1, 1404000, 4410, 0x7aeaf8e1
-1, 1413000, 4410, 0x4bb8da1c
-1, 1422000, 4410, 0x5995dfc2
-1, 1431000, 4410, 0xccce8872
-1, 1440000, 4410, 0xca2753a4
-1, 1449000, 4410, 0x4296ff6d
-1, 1458000, 4410, 0xe582d191
-1, 1467000, 4410, 0xc40268da
-1, 1476000, 4410, 0xda1d475e
-1, 1485000, 4410, 0x5e91e4e0
-1, 1494000, 4410, 0xfeb44475
-1, 1503000, 4410, 0x17ff8e38
-1, 1512000, 4410, 0x3bd58bcf
-1, 1521000, 4410, 0x9476e23c
-1, 1530000, 4410, 0x440651ab
-1, 1539000, 4410, 0xb08cdc74
-1, 1548000, 4410, 0x6fc3031f
-1, 1557000, 4410, 0x197ab39a
-1, 1566000, 4410, 0xf92f0e3d
-1, 1575000, 4410, 0xd5f6b678
-1, 1584000, 4410, 0x8af127a6
-1, 1593000, 4410, 0xe22f585e
-1, 1602000, 4410, 0x67515610
-1, 1611000, 4410, 0x21569d7a
-1, 1620000, 4410, 0x114597d8
-1, 1629000, 4410, 0xba213fb6
-1, 1638000, 4410, 0x1aca9fee
-1, 1647000, 4410, 0x48cdd264
-1, 1656000, 4410, 0x533619ec
-1, 1665000, 4410, 0x21466244
-1, 1674000, 4410, 0x26e00e88
-1, 1683000, 4410, 0x8e51d07c
-1, 1692000, 4410, 0xa6c4048a
-1, 1701000, 4410, 0x98ce10e4
-1, 1710000, 4410, 0x379bc8c2
-1, 1719000, 4410, 0x404b09c6
-1, 1728000, 4410, 0xfc89da8a
-1, 1737000, 4410, 0xbdbe6914
-1, 1746000, 4410, 0x2cb09f08
-1, 1755000, 4410, 0x835bf2d9
-1, 1764000, 4410, 0xa4611790
-1, 1773000, 4410, 0x67740896
-1, 1782000, 4410, 0x489f6bd0
-1, 1791000, 4410, 0x072bae9c
-1, 1800000, 4410, 0xadce5a89
-1, 1809000, 4410, 0x209f2c2c
-1, 1818000, 4410, 0xf5706665
-1, 1827000, 4410, 0x631841cb
-1, 1836000, 4410, 0xa1a2c65f
-1, 1845000, 4410, 0x8818b96b
-1, 1854000, 4410, 0x63158025
-1, 1863000, 4410, 0xf6ae79f5
-1, 1872000, 4410, 0xb3dcd214
-1, 1881000, 4410, 0x7a745449
-1, 1890000, 4410, 0x5d2b15f4
-1, 1899000, 4410, 0x48764b7c
-1, 1908000, 4410, 0x1294e119
+1, 1053000, 4410, 0x5aac2dcf
+1, 1062000, 4410, 0x259fa2db
+1, 1071000, 4410, 0xd16d6803
+1, 1080000, 4410, 0xa4b3478a
+1, 1089000, 4410, 0xdbe0443d
+1, 1098000, 4410, 0x26c16119
+1, 1107000, 4410, 0x0c06475c
+1, 1116000, 4410, 0x6ffaba2d
+1, 1125000, 4410, 0x5b287192
+1, 1134000, 4410, 0xf2cf2651
+1, 1143000, 4410, 0x3857673a
+1, 1152000, 4410, 0x5b555feb
+1, 1161000, 4410, 0x93f997af
+1, 1170000, 4410, 0xb3ba8d35
+1, 1179000, 4410, 0x66433944
+1, 1188000, 4410, 0xf0005a5f
+1, 1197000, 4410, 0xb948541f
+1, 1206000, 4410, 0xc8f1b16f
+1, 1215000, 4410, 0x7d4b7506
+1, 1224000, 4410, 0xac723c55
+1, 1233000, 4410, 0x2926fab5
+1, 1242000, 4410, 0x31684995
+1, 1251000, 4410, 0x35ebfca4
+1, 1260000, 4410, 0x9cd42c18
+1, 1269000, 4410, 0xd7ecd7b1
+1, 1278000, 4410, 0x5e13c602
+1, 1287000, 4410, 0xe955b5e3
+1, 1296000, 4410, 0xefad19a1
+1, 1305000, 4410, 0x435950de
+1, 1314000, 4410, 0x9d624ebe
+1, 1323000, 4410, 0x774a9158
+1, 1332000, 4410, 0x8c41e66a
+1, 1341000, 4410, 0x70112740
+1, 1350000, 4410, 0x55abc7a2
+1, 1359000, 4410, 0x0ec3183c
+1, 1368000, 4410, 0x54609c56
+1, 1377000, 4410, 0x60d49f92
+1, 1386000, 4410, 0x5fb061c8
+1, 1395000, 4410, 0x6e119c98
+1, 1404000, 4410, 0x3f39fc69
+1, 1413000, 4410, 0xef466d0e
+1, 1422000, 4410, 0xf4cb6fe1
+1, 1431000, 4410, 0xc4434439
+1, 1440000, 4410, 0xd02329d2
+1, 1449000, 4410, 0x216cffaf
+1, 1458000, 4410, 0x7e59e8c1
+1, 1467000, 4410, 0xc7c3346d
+1, 1476000, 4410, 0x5b3723af
+1, 1485000, 4410, 0x76097270
+1, 1494000, 4410, 0xae39a233
+1, 1503000, 4410, 0x686a471c
+1, 1512000, 4410, 0x3af3c5e0
+1, 1521000, 4410, 0x11ac711e
+1, 1530000, 4410, 0xcd8da8ce
+1, 1539000, 4410, 0x21296e3a
+1, 1548000, 4410, 0x77168188
+1, 1557000, 4410, 0x5fcf59cd
+1, 1566000, 4410, 0x390c8717
+1, 1575000, 4410, 0x3d5d5b3c
+1, 1584000, 4410, 0x3b8f13d3
+1, 1593000, 4410, 0x5b002c2f
+1, 1602000, 4410, 0x9e1d2b08
+1, 1611000, 4410, 0x69454ebd
+1, 1620000, 4410, 0x62a54bec
+1, 1629000, 4410, 0x4d231fdb
+1, 1638000, 4410, 0x65624ff7
+1, 1647000, 4410, 0x6fc66932
+1, 1656000, 4410, 0x23200cf6
+1, 1665000, 4410, 0xf8033122
+1, 1674000, 4410, 0x0fce0744
+1, 1683000, 4410, 0x9302683e
+1, 1692000, 4410, 0xd2380245
+1, 1701000, 4410, 0x482e0872
+1, 1710000, 4410, 0xe98e6461
+1, 1719000, 4410, 0x1db404e3
+1, 1728000, 4410, 0x47a26d45
+1, 1737000, 4410, 0x449a348a
+1, 1746000, 4410, 0xee874f84
+1, 1755000, 4410, 0xc4ecf965
+1, 1764000, 4410, 0xcc450bc8
+1, 1773000, 4410, 0xb18d044b
+1, 1782000, 4410, 0x895435e8
+1, 1791000, 4410, 0x57e7574e
+1, 1800000, 4410, 0x8041ad3d
+1, 1809000, 4410, 0x853d1616
+1, 1818000, 4410, 0xa11bb32b
+1, 1827000, 4410, 0xe10ea0de
+1, 1836000, 4410, 0xdf2ee328
+1, 1845000, 4410, 0xd5a6dcae
+1, 1854000, 4410, 0xd176c00b
+1, 1863000, 4410, 0x9cd6bcf3
+1, 1872000, 4410, 0x2569690a
+1, 1881000, 4410, 0x6824aa1d
+1, 1890000, 4410, 0xa9110afa
+1, 1899000, 4410, 0x115c25be
+1, 1908000, 4410, 0x1100f085
+1, 1917000, 4410, 0x00000000
+1, 1926000, 4410, 0x00000000
+1, 1935000, 4410, 0x00000000
+1, 1944000, 4410, 0x00000000
+1, 1953000, 4410, 0x00000000
+1, 1962000, 4410, 0x00000000
+1, 1971000, 4410, 0x00000000
+1, 1980000, 4410, 0x00000000
+1, 1989000, 4410, 0x00000000
+1, 1998000, 4410, 0x00000000
+1, 2007000, 4410, 0x00000000
+1, 2016000, 4410, 0x00000000
+1, 2025000, 4410, 0x00000000
+1, 2034000, 4410, 0x00000000
+1, 2043000, 4410, 0x00000000
+1, 2052000, 4410, 0x00000000
+1, 2061000, 4410, 0x00000000
+1, 2070000, 4410, 0x00000000
+1, 2079000, 4410, 0x00000000
+1, 2088000, 4410, 0x00000000
+1, 2097000, 4410, 0x00000000
+1, 2106000, 4410, 0x00000000
+1, 2115000, 4410, 0x00000000
+1, 2124000, 4410, 0x00000000
+1, 2133000, 4410, 0x00000000
+1, 2142000, 4410, 0x00000000
+1, 2151000, 4410, 0x00000000
+1, 2160000, 4410, 0x00000000
+1, 2169000, 4410, 0x00000000
diff --git a/mplayer/ffmpeg/tests/ref/lavf/rm b/mplayer/ffmpeg/tests/ref/lavf/rm
index d9ec51e5..b8bf2207 100644
--- a/mplayer/ffmpeg/tests/ref/lavf/rm
+++ b/mplayer/ffmpeg/tests/ref/lavf/rm
@@ -1,2 +1,2 @@
-e1990def7b195a568340f2c1a89d6587 *./tests/data/lavf/lavf.rm
+d149fc272dfd21fb8908ee21d7b1651b *./tests/data/lavf/lavf.rm
346706 ./tests/data/lavf/lavf.rm
diff --git a/mplayer/ffmpeg/tests/ref/seek/ac3_rm b/mplayer/ffmpeg/tests/ref/seek/ac3_rm
index 7b7d5b0b..07fcfa1e 100644
--- a/mplayer/ffmpeg/tests/ref/seek/ac3_rm
+++ b/mplayer/ffmpeg/tests/ref/seek/ac3_rm
@@ -1,13 +1,17 @@
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
-ret:-1 st:-1 flags:1 ts: 1.894167
-ret:-1 st: 0 flags:0 ts: 0.788000
+ret: 0 st:-1 flags:1 ts: 1.894167
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
+ret: 0 st: 0 flags:0 ts: 0.788000
+ret: 0 st: 0 flags:1 dts:4160806.587000 pts:4160806.587000 pos: 3883 size: 116
ret: 0 st: 0 flags:1 ts:-0.317000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
-ret:-1 st:-1 flags:0 ts: 2.576668
+ret: 0 st:-1 flags:0 ts: 2.576668
+ret: 0 st: 0 flags:1 dts:4160806.587000 pts:4160806.587000 pos: 3883 size: 116
ret:-1 st:-1 flags:1 ts: 1.470835
-ret:-1 st: 0 flags:0 ts: 0.365000
+ret: 0 st: 0 flags:0 ts: 0.365000
+ret: 0 st: 0 flags:1 dts:4160806.587000 pts:4160806.587000 pos: 3883 size: 116
ret: 0 st: 0 flags:1 ts:-0.741000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret:-1 st:-1 flags:0 ts: 2.153336
@@ -16,20 +20,26 @@ ret: 0 st: 0 flags:0 ts:-0.058000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret:-1 st: 0 flags:1 ts: 2.836000
ret:-1 st:-1 flags:0 ts: 1.730004
-ret:-1 st:-1 flags:1 ts: 0.624171
+ret: 0 st:-1 flags:1 ts: 0.624171
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret: 0 st: 0 flags:0 ts:-0.482000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
-ret:-1 st: 0 flags:1 ts: 2.413000
+ret: 0 st: 0 flags:1 ts: 2.413000
+ret: 0 st: 0 flags:1 dts: 2.229000 pts: 2.229000 pos: 36705 size: 556
ret:-1 st:-1 flags:0 ts: 1.306672
-ret:-1 st:-1 flags:1 ts: 0.200839
+ret: 0 st:-1 flags:1 ts: 0.200839
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret: 0 st: 0 flags:0 ts:-0.905000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
ret:-1 st: 0 flags:1 ts: 1.989000
-ret:-1 st:-1 flags:0 ts: 0.883340
+ret: 0 st:-1 flags:0 ts: 0.883340
+ret: 0 st: 0 flags:1 dts:4160806.587000 pts:4160806.587000 pos: 3883 size: 116
ret: 0 st:-1 flags:1 ts:-0.222493
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
-ret:-1 st: 0 flags:0 ts: 2.672000
+ret: 0 st: 0 flags:0 ts: 2.672000
+ret: 0 st: 0 flags:1 dts:6354.691000 pts:6354.691000 pos: 10783 size: 304
ret:-1 st: 0 flags:1 ts: 1.566000
-ret:-1 st:-1 flags:0 ts: 0.460008
+ret: 0 st:-1 flags:0 ts: 0.460008
+ret: 0 st: 0 flags:1 dts:4160806.587000 pts:4160806.587000 pos: 3883 size: 116
ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
diff --git a/mplayer/ffmpeg/tests/ref/vsynth1/qtrle b/mplayer/ffmpeg/tests/ref/vsynth1/qtrle
index 8aa578fc..9988897b 100644
--- a/mplayer/ffmpeg/tests/ref/vsynth1/qtrle
+++ b/mplayer/ffmpeg/tests/ref/vsynth1/qtrle
@@ -1,4 +1,4 @@
-3f070779d7deb54626515ac7f7002e63 *./tests/data/vsynth1/qtrle.mov
-387772 ./tests/data/vsynth1/qtrle.mov
-a3c2610e2c069c3ad22ec03da83f774f *./tests/data/qtrle.vsynth1.out.yuv
-stddev: 15.14 PSNR: 24.53 MAXDIFF: 174 bytes: 7603200/ 7603200
+d14041925ce5ec5001dc519276b1a1ab *./tests/data/vsynth1/qtrle.mov
+15263232 ./tests/data/vsynth1/qtrle.mov
+243325fb2cae1a9245efd49aff936327 *./tests/data/qtrle.vsynth1.out.yuv
+stddev: 3.42 PSNR: 37.43 MAXDIFF: 48 bytes: 7603200/ 7603200
diff --git a/mplayer/ffmpeg/tests/ref/vsynth2/qtrle b/mplayer/ffmpeg/tests/ref/vsynth2/qtrle
index 756ed693..6b2a0116 100644
--- a/mplayer/ffmpeg/tests/ref/vsynth2/qtrle
+++ b/mplayer/ffmpeg/tests/ref/vsynth2/qtrle
@@ -1,4 +1,4 @@
-5346bba8e03e7de72b482efbcf712a2e *./tests/data/vsynth2/qtrle.mov
-141533 ./tests/data/vsynth2/qtrle.mov
-f967b290c7e6d015c0e78175db828249 *./tests/data/qtrle.vsynth2.out.yuv
-stddev: 5.75 PSNR: 32.93 MAXDIFF: 92 bytes: 7603200/ 7603200
+d8c1604dc46d9aa4ec0385e6722c6989 *./tests/data/vsynth2/qtrle.mov
+14798419 ./tests/data/vsynth2/qtrle.mov
+b2418e0e3a9a8619b31219cbcf24dc82 *./tests/data/qtrle.vsynth2.out.yuv
+stddev: 1.26 PSNR: 46.06 MAXDIFF: 13 bytes: 7603200/ 7603200
diff --git a/mplayer/ffmpeg/tools/graph2dot.c b/mplayer/ffmpeg/tools/graph2dot.c
index 5e0da9a5..b67e5970 100644
--- a/mplayer/ffmpeg/tools/graph2dot.c
+++ b/mplayer/ffmpeg/tools/graph2dot.c
@@ -22,6 +22,7 @@
#undef HAVE_AV_CONFIG_H
#include "libavutil/pixdesc.h"
+#include "libavutil/audioconvert.h"
#include "libavfilter/avfiltergraph.h"
static void usage(void)
@@ -67,10 +68,18 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph)
dst_filter_ctx->filter->name);
fprintf(outfile, "\"%s\" -> \"%s\"", filter_ctx_label, dst_filter_ctx_label);
- fprintf(outfile, " [ label= \"fmt:%s w:%d h:%d tb:%d/%d\" ];\n",
- link->type == AVMEDIA_TYPE_VIDEO ? av_pix_fmt_descriptors[link->format].name :
- link->type == AVMEDIA_TYPE_AUDIO ? av_get_sample_fmt_name(link->format) : "unknown",
- link->w, link->h, link->time_base.num, link->time_base.den);
+ if (link->type == AVMEDIA_TYPE_VIDEO) {
+ fprintf(outfile, " [ label= \"fmt:%s w:%d h:%d tb:%d/%d\" ]",
+ av_pix_fmt_descriptors[link->format].name,
+ link->w, link->h, link->time_base.num, link->time_base.den);
+ } else if (link->type == AVMEDIA_TYPE_AUDIO) {
+ char buf[255];
+ av_get_channel_layout_string(buf, sizeof(buf), -1, link->channel_layout);
+ fprintf(outfile, " [ label= \"fmt:%s sr:%"PRId64" cl:%s\" ]",
+ av_get_sample_fmt_name(link->format),
+ link->sample_rate, buf);
+ }
+ fprintf(outfile, ";\n");
}
}
}
diff --git a/mplayer/ffmpeg/version.sh b/mplayer/ffmpeg/version.sh
index 3269e038..b34ee2c8 100644
--- a/mplayer/ffmpeg/version.sh
+++ b/mplayer/ffmpeg/version.sh
@@ -1,21 +1,8 @@
#!/bin/sh
-# check for SVN revision number
revision=$(cd "$1" && cat snapshot_version 2> /dev/null)
-test "$revision" || revision=$(cd "$1" && LC_ALL=C svn info 2> /dev/null | grep "Last Changed Rev" | cut -d' ' -f4)
-test "$revision" || revision=$(cd "$1" && grep committed-rev .svn/entries 2>/dev/null | head -n 1 | cut -d '"' -f2)
-test "$revision" || revision=$(cd "$1" && sed -n -e '/^dir$/{n
-p
-q
-}' .svn/entries 2>/dev/null)
test "$revision" && revision=SVN-r$revision
-# check for git svn revision number
-if ! test "$revision"; then
- revision=$(cd "$1" && git svn find-rev HEAD 2> /dev/null)
- test "$revision" && revision=git-svn-r$revision
-fi
-
# check for git short hash
if ! test "$revision"; then
revision=$(cd "$1" && git describe --always 2> /dev/null)
diff --git a/mplayer/fmt-conversion.c b/mplayer/fmt-conversion.c
index 9e881009..f55b46b0 100644
--- a/mplayer/fmt-conversion.c
+++ b/mplayer/fmt-conversion.c
@@ -19,6 +19,8 @@
#include "mp_msg.h"
#include "libavutil/avutil.h"
#include "libmpcodecs/img_format.h"
+#include "libavutil/samplefmt.h"
+#include "libaf/af_format.h"
#include "fmt-conversion.h"
static const struct {
@@ -123,3 +125,42 @@ int pixfmt2imgfmt(enum PixelFormat pix_fmt)
mp_msg(MSGT_GLOBAL, MSGL_ERR, "Unsupported PixelFormat %i\n", pix_fmt);
return fmt;
}
+
+static const struct {
+ int fmt;
+ enum AVSampleFormat sample_fmt;
+} samplefmt_conversion_map[] = {
+ {AF_FORMAT_U8, AV_SAMPLE_FMT_U8},
+ {AF_FORMAT_S16_NE, AV_SAMPLE_FMT_S16},
+ {AF_FORMAT_S32_NE, AV_SAMPLE_FMT_S32},
+ {AF_FORMAT_FLOAT_NE, AV_SAMPLE_FMT_FLT},
+ {0, AV_SAMPLE_FMT_NONE}
+};
+
+enum AVSampleFormat affmt2samplefmt(int fmt)
+{
+ char str[50];
+ int i;
+ enum AVSampleFormat sample_fmt;
+ for (i = 0; samplefmt_conversion_map[i].fmt; i++)
+ if (samplefmt_conversion_map[i].fmt == fmt)
+ break;
+ sample_fmt = samplefmt_conversion_map[i].sample_fmt;
+ if (sample_fmt == AV_SAMPLE_FMT_NONE)
+ mp_msg(MSGT_GLOBAL, MSGL_ERR, "Unsupported format %s\n",
+ af_fmt2str(fmt, str, sizeof(str)));
+ return sample_fmt;
+}
+
+int samplefmt2affmt(enum AVSampleFormat sample_fmt)
+{
+ int i;
+ int fmt;
+ for (i = 0; samplefmt_conversion_map[i].sample_fmt != AV_SAMPLE_FMT_NONE; i++)
+ if (samplefmt_conversion_map[i].sample_fmt == sample_fmt)
+ break;
+ fmt = samplefmt_conversion_map[i].fmt;
+ if (!fmt)
+ mp_msg(MSGT_GLOBAL, MSGL_ERR, "Unsupported AVSampleFormat %i\n", sample_fmt);
+ return fmt;
+}
diff --git a/mplayer/fmt-conversion.h b/mplayer/fmt-conversion.h
index 9e133a82..811b5e9d 100644
--- a/mplayer/fmt-conversion.h
+++ b/mplayer/fmt-conversion.h
@@ -21,8 +21,11 @@
#include "config.h"
#include "libavutil/avutil.h"
+#include "libavutil/samplefmt.h"
enum PixelFormat imgfmt2pixfmt(int fmt);
int pixfmt2imgfmt(enum PixelFormat pix_fmt);
+enum AVSampleFormat affmt2samplefmt(int fmt);
+int samplefmt2affmt(enum AVSampleFormat sample_fmt);
#endif /* MPLAYER_FMT_CONVERSION_H */
diff --git a/mplayer/gui/app.c b/mplayer/gui/app.c
index 35e745d6..b5bf5a03 100644
--- a/mplayer/gui/app.c
+++ b/mplayer/gui/app.c
@@ -16,225 +16,204 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include
-#include
-#include
-
-#include "config.h"
-#include "mp_msg.h"
-#include "help_mp.h"
-
#include "app.h"
-#include "wm/wskeys.h"
-#include "skin/skin.h"
-#include "mplayer/gmplayer.h"
+
+#include "gui/skin/font.h"
#include "interface.h"
-static const evName evNames[] =
- {
- { evNone, "evNone" },
- { evPlay, "evPlay" },
- { evStop, "evStop" },
- { evPause, "evPause" },
- { evPrev, "evPrev" },
- { evNext, "evNext" },
- { evLoad, "evLoad" },
- { evEqualizer, "evEqualizer" },
- { evEqualizer, "evEqualeaser" },
- { evPlayList, "evPlaylist" },
- { evExit, "evExit" },
- { evIconify, "evIconify" },
- { evIncBalance, "evIncBalance" },
- { evDecBalance, "evDecBalance" },
- { evFullScreen, "evFullScreen" },
- { evFName, "evFName" },
- { evMovieTime, "evMovieTime" },
- { evAbout, "evAbout" },
- { evLoadPlay, "evLoadPlay" },
- { evPreferences, "evPreferences" },
- { evSkinBrowser, "evSkinBrowser" },
- { evBackward10sec, "evBackward10sec" },
- { evForward10sec, "evForward10sec" },
- { evBackward1min, "evBackward1min" },
- { evForward1min, "evForward1min" },
- { evBackward10min, "evBackward10min" },
- { evForward10min, "evForward10min" },
- { evIncVolume, "evIncVolume" },
- { evDecVolume, "evDecVolume" },
- { evMute, "evMute" },
- { evIncAudioBufDelay, "evIncAudioBufDelay" },
- { evDecAudioBufDelay, "evDecAudioBufDelay" },
- { evPlaySwitchToPause, "evPlaySwitchToPause" },
- { evPauseSwitchToPlay, "evPauseSwitchToPlay" },
- { evNormalSize, "evHalfSize" },
- { evNormalSize, "evNormalSize" },
- { evDoubleSize, "evDoubleSize" },
- { evSetMoviePosition, "evSetMoviePosition" },
- { evSetVolume, "evSetVolume" },
- { evSetBalance, "evSetBalance" },
- { evHelp, "evHelp" },
- { evLoadSubtitle, "evLoadSubtitle" },
- { evPlayDVD, "evPlayDVD" },
- { evPlayVCD, "evPlayVCD" },
- { evSetURL, "evSetURL" },
- { evLoadAudioFile, "evLoadAudioFile" },
- { evDropSubtitle, "evDropSubtitle" },
- { evSetAspect, "evSetAspect" }
- };
-
-static const int evBoxs = sizeof( evNames ) / sizeof( evName );
-
-// ---
-
-listItems appMPlayer;
-
-/* FIXME: Eventually remove the obsolete directory names. */
-char * skinDirInHome=NULL;
-char * skinDirInHome_obsolete=NULL;
-char * skinMPlayerDir=NULL;
-char * skinMPlayerDir_obsolete=NULL;
-char * skinName = NULL;
-
-void appClearItem( wItem * item )
+listItems appMPlayer;
+
+static const evName evNames[] = {
+ { evNone, "evNone" },
+ { evPlay, "evPlay" },
+ { evStop, "evStop" },
+ { evPause, "evPause" },
+ { evPrev, "evPrev" },
+ { evNext, "evNext" },
+ { evLoad, "evLoad" },
+ { evEqualizer, "evEqualizer" },
+ { evEqualizer, "evEqualeaser" }, // NOTE TO MYSELF: any skin using this?
+ { evPlayList, "evPlaylist" },
+ { evExit, "evExit" },
+ { evIconify, "evIconify" },
+ { evIncBalance, "evIncBalance" }, // NOTE TO MYSELF: not all of these events
+ { evDecBalance, "evDecBalance" }, // are actually implemented, and update doc
+ { evFullScreen, "evFullScreen" },
+ { evFName, "evFName" },
+ { evMovieTime, "evMovieTime" },
+ { evAbout, "evAbout" },
+ { evLoadPlay, "evLoadPlay" },
+ { evPreferences, "evPreferences" },
+ { evSkinBrowser, "evSkinBrowser" },
+ { evBackward10sec, "evBackward10sec" },
+ { evForward10sec, "evForward10sec" },
+ { evBackward1min, "evBackward1min" },
+ { evForward1min, "evForward1min" },
+ { evBackward10min, "evBackward10min" },
+ { evForward10min, "evForward10min" },
+ { evIncVolume, "evIncVolume" },
+ { evDecVolume, "evDecVolume" },
+ { evMute, "evMute" },
+ { evIncAudioBufDelay, "evIncAudioBufDelay" },
+ { evDecAudioBufDelay, "evDecAudioBufDelay" },
+ { evPlaySwitchToPause, "evPlaySwitchToPause" },
+ { evPauseSwitchToPlay, "evPauseSwitchToPlay" },
+ { evNormalSize, "evHalfSize" },
+ { evNormalSize, "evNormalSize" },
+ { evDoubleSize, "evDoubleSize" },
+ { evSetMoviePosition, "evSetMoviePosition" },
+ { evSetVolume, "evSetVolume" },
+ { evSetBalance, "evSetBalance" },
+ { evHelp, "evHelp" },
+ { evLoadSubtitle, "evLoadSubtitle" },
+ { evPlayDVD, "evPlayDVD" },
+ { evPlayVCD, "evPlayVCD" },
+ { evSetURL, "evSetURL" },
+ { evLoadAudioFile, "evLoadAudioFile" },
+ { evDropSubtitle, "evDropSubtitle" },
+ { evSetAspect, "evSetAspect" }
+};
+
+static const int EVENTS = sizeof(evNames) / sizeof(evName);
+
+static void appClearItem(wItem *item)
{
- item->type=0;
-// ---
- item->x=0; item->y=0; item->width=0; item->height=0;
-// ---
- item->px=0; item->py=0; item->psx=0; item->psy=0;
-// ---
- item->msg=0; item->msg2=0;
- item->pressed=btnReleased;
- item->tmp=0;
- item->key=0; item->key2=0;
- item->Bitmap.Width=0; item->Bitmap.Height=0; item->Bitmap.BPP=0; item->Bitmap.ImageSize=0;
- free(item->Bitmap.Image);
- item->Bitmap.Image=NULL;
-// ---
- item->fontid=0;
- free(item->label);
- item->label=NULL;
- item->event=0;
+ item->type = itNone;
+ item->x = 0;
+ item->y = 0;
+ item->width = 0;
+ item->height = 0;
+ bpFree(&item->Bitmap);
+ bpFree(&item->Mask);
+ item->fontid = 0;
+ item->align = fntAlignLeft;
+ gfree((void **)&item->label);
+ item->pwidth = 0;
+ item->pheight = 0;
+ item->numphases = 0;
+ item->value = 0;
+ item->message = evNone;
+ item->R = 0;
+ item->G = 0;
+ item->B = 0;
+ gfree((void **)&item->text);
+ item->textwidth = 0;
+ item->starttime = 0;
+ item->last_x = 0;
+ item->pressed = btnDisabled;
+ item->tmp = 0;
}
-void appCopy( listItems * dest,listItems * source )
+void appResetStruct(void)
{
- dest->NumberOfItems=source->NumberOfItems;
- memcpy( &dest->Items,&source->Items,128 * sizeof( wItem ) );
-
- dest->NumberOfMenuItems=source->NumberOfMenuItems;
- memcpy( &dest->MenuItems,&source->MenuItems,32 * sizeof( wItem ) );
+ appMPlayer.IndexOfMainItems = -1;
+ appMPlayer.IndexOfBarItems = -1;
+ appMPlayer.IndexOfMenuItems = -1;
- memcpy( &dest->main,&source->main,sizeof( wItem ) );
- memcpy( &dest->sub,&source->sub,sizeof( wItem ) );
- memcpy( &dest->menuBase,&source->menuBase,sizeof( wItem ) );
- memcpy( &dest->menuSelected,&source->menuSelected,sizeof( wItem ) );
+ appMPlayer.sub.x = -1; // NOTE TO MYSELF: is this really necessary?
+ appMPlayer.sub.y = -1; // NOTE TO MYSELF: is this really necessary?
}
-void appInitStruct( listItems * item )
+void appFreeStruct(void)
{
- int i;
- for ( i=0;iNumberOfItems;i++ )
- appClearItem( &item->Items[i] );
- for ( i=0;iNumberOfMenuItems;i++ )
- appClearItem( &item->MenuItems[i] );
- for ( i=0;iNumberOfBarItems;i++ )
- appClearItem( &item->barItems[i] );
-
- item->NumberOfItems=-1;
- memset( item->Items,0,256 * sizeof( wItem ) );
- item->NumberOfMenuItems=-1;
- memset( item->MenuItems,0,64 * sizeof( wItem ) );
- item->NumberOfBarItems=-1;
- memset( item->barItems,0,256 * sizeof( wItem ) );
-
- appClearItem( &item->main );
- item->mainDecoration=0;
- appClearItem( &item->sub );
- item->sub.width=0; item->sub.height=0;
- item->sub.x=-1; item->sub.y=-1;
- appClearItem( &item->menuBase );
- appClearItem( &item->menuSelected );
- item->sub.R=item->sub.G=item->sub.B=0;
- item->bar.R=item->bar.G=item->bar.B=0;
- item->main.R=item->main.G=item->main.B=0;
- item->barIsPresent=0;
- item->menuIsPresent=0;
-}
+ int i;
-int appFindKey( unsigned char * name )
-{
- int i;
- for ( i=0;i 100.f ) state=100.0f;
- appMPlayer.Items[j].value=state;
- break;
- }
- }
-
- for ( j=0;j < appMPlayer.NumberOfBarItems + 1;j++ )
- if ( appMPlayer.barItems[j].msg == event )
- {
- switch ( appMPlayer.barItems[j].type )
- {
- case itButton:
- appMPlayer.barItems[j].pressed=(int)state;
- appMPlayer.barItems[j].tmp=(int)state;
- break;
- case itPotmeter:
- case itVPotmeter:
- case itHPotmeter:
- if ( state < 0.0f ) state=0.0f;
- if ( state > 100.f ) state=100.0f;
- appMPlayer.barItems[j].value=state;
- break;
- }
- }
+ int i;
+
+ for (i = 0; i < EVENTS; i++)
+ if (!strcmp(evNames[i].name, str))
+ return evNames[i].message;
+
+ return -1;
}
-float btnGetValue( int event )
+void btnModify(int event, float state)
{
- int j;
- for ( j=0;j 100.0)
+ state = 100.0;
+ appMPlayer.mainItems[i].value = state;
+ break;
+ }
+ }
+ }
+
+ for (i = 0; i <= appMPlayer.IndexOfBarItems; i++) {
+ if (appMPlayer.barItems[i].message == event) {
+ switch (appMPlayer.barItems[i].type) {
+ case itButton:
+ appMPlayer.barItems[i].pressed = (int)state;
+ appMPlayer.barItems[i].tmp = (int)state;
+ break;
+
+ case itPotmeter:
+ case itVPotmeter:
+ case itHPotmeter:
+ if (state < 0.0)
+ state = 0.0;
+ if (state > 100.0)
+ state = 100.0;
+ appMPlayer.barItems[i].value = state;
+ break;
+ }
+ }
+ }
}
-void btnSet( int event,int set )
+void btnSet(int event, int set)
{
- int j;
- for ( j=0;j
#include
-#include "mp_msg.h"
-#include "help_mp.h"
#include "bitmap.h"
+
+#include "help_mp.h"
#include "libavcodec/avcodec.h"
#include "libavutil/intreadwrite.h"
#include "libvo/fastmemcpy.h"
+#include "mp_msg.h"
-static int pngRead( unsigned char * fname,txSample * bf )
+static int pngRead(unsigned char *fname, txSample *bf)
{
- int decode_ok;
- void *data;
- int len;
- AVCodecContext *avctx;
- AVFrame *frame;
- AVPacket pkt;
-
- FILE *fp=fopen( fname,"rb" );
- if ( !fp )
- {
- mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] file read error ( %s )\n",fname );
- return 1;
- }
-
- fseek(fp, 0, SEEK_END);
- len = ftell(fp);
- if (len > 50 * 1024 * 1024) return 2;
- data = av_malloc(len + FF_INPUT_BUFFER_PADDING_SIZE);
- fseek(fp, 0, SEEK_SET);
- fread(data, len, 1, fp);
- fclose(fp);
- avctx = avcodec_alloc_context();
- frame = avcodec_alloc_frame();
- avcodec_register_all();
- avcodec_open(avctx, avcodec_find_decoder(CODEC_ID_PNG));
- av_init_packet(&pkt);
- pkt.data = data;
- pkt.size = len;
- // HACK: make PNGs decode normally instead of as CorePNG delta frames
- pkt.flags = PKT_FLAG_KEY;
- avcodec_decode_video2(avctx, frame, &decode_ok, &pkt);
- memset(bf, 0, sizeof(*bf));
- switch (avctx->pix_fmt) {
- case PIX_FMT_GRAY8: bf->BPP = 8; break;
- case PIX_FMT_GRAY16BE: bf->BPP = 16; break;
- case PIX_FMT_RGB24: bf->BPP = 24; break;
- case PIX_FMT_BGRA:
- case PIX_FMT_ARGB: bf->BPP = 32; break;
- default: bf->BPP = 0; break;
- }
- if (decode_ok && bf->BPP) {
- int bpl;
- bf->Width = avctx->width; bf->Height = avctx->height;
- bpl = bf->Width * (bf->BPP / 8);
- bf->ImageSize = bpl * bf->Height;
- bf->Image = malloc(bf->ImageSize);
- memcpy_pic(bf->Image, frame->data[0], bpl, bf->Height, bpl, frame->linesize[0]);
- }
- avcodec_close(avctx);
- av_freep(&frame);
- av_freep(&avctx);
- av_freep(&data);
-
- mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] filename: %s.\n",fname );
- mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] size: %dx%d bits: %d\n",bf->Width,bf->Height,bf->BPP );
- mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] imagesize: %lu\n",bf->ImageSize );
- return !(decode_ok && bf->BPP);
+ FILE *fp;
+ int decode_ok;
+ void *data;
+ int len;
+ AVCodecContext *avctx;
+ AVFrame *frame;
+ AVPacket pkt;
+
+ fp = fopen(fname, "rb");
+
+ if (!fp) {
+ mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[png] file read error ( %s )\n", fname);
+ return 1;
+ }
+
+ fseek(fp, 0, SEEK_END);
+ len = ftell(fp);
+
+ if (len > 50 * 1024 * 1024) {
+ fclose(fp);
+ return 2;
+ }
+
+ data = av_malloc(len + FF_INPUT_BUFFER_PADDING_SIZE);
+
+ fseek(fp, 0, SEEK_SET);
+ fread(data, len, 1, fp);
+ fclose(fp);
+
+ avctx = avcodec_alloc_context();
+ frame = avcodec_alloc_frame();
+ avcodec_register_all();
+ avcodec_open(avctx, avcodec_find_decoder(CODEC_ID_PNG));
+ av_init_packet(&pkt);
+ pkt.data = data;
+ pkt.size = len;
+ // HACK: make PNGs decode normally instead of as CorePNG delta frames
+ pkt.flags = AV_PKT_FLAG_KEY;
+ avcodec_decode_video2(avctx, frame, &decode_ok, &pkt);
+ memset(bf, 0, sizeof(*bf));
+
+ switch (avctx->pix_fmt) {
+ case PIX_FMT_GRAY8:
+ bf->BPP = 8;
+ break;
+
+ case PIX_FMT_GRAY16BE:
+ bf->BPP = 16;
+ break;
+
+ case PIX_FMT_RGB24:
+ bf->BPP = 24;
+ break;
+
+ case PIX_FMT_BGRA:
+ case PIX_FMT_ARGB:
+ bf->BPP = 32;
+ break;
+
+ default:
+ bf->BPP = 0;
+ break;
+ }
+
+ if (decode_ok && bf->BPP) {
+ int bpl;
+
+ bf->Width = avctx->width;
+ bf->Height = avctx->height;
+ bpl = bf->Width * (bf->BPP / 8);
+ bf->ImageSize = bpl * bf->Height;
+ bf->Image = malloc(bf->ImageSize);
+ memcpy_pic(bf->Image, frame->data[0], bpl, bf->Height, bpl, frame->linesize[0]);
+ }
+
+ avcodec_close(avctx);
+ av_freep(&frame);
+ av_freep(&avctx);
+ av_freep(&data);
+
+ mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[png] filename: %s.\n", fname);
+ mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[png] size: %lux%lu bits: %u\n", bf->Width, bf->Height, bf->BPP);
+ mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[png] imagesize: %lu\n", bf->ImageSize);
+
+ return !(decode_ok && bf->BPP);
}
-static int conv24to32( txSample * bf )
+static int conv24to32(txSample *bf)
{
- unsigned char * tmpImage;
- int i,c;
-
- if ( bf->BPP == 24 )
- {
- tmpImage=bf->Image;
- bf->ImageSize=bf->Width * bf->Height * 4;
- bf->BPP=32;
- if ( ( bf->Image=calloc( 1, bf->ImageSize ) ) == NULL )
- {
- free( tmpImage );
- mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] not enough memory for image\n" );
- return 1;
- }
- for ( c=0,i=0; c < bf->ImageSize; c += 4, i += 3)
- {
- *(uint32_t *)&bf->Image[c] = AV_RB24(&tmpImage[i]);
+ unsigned char *tmpImage;
+ unsigned int i, c;
+
+ if (bf->BPP == 24) {
+ tmpImage = bf->Image;
+ bf->BPP = 32;
+ bf->ImageSize = bf->Width * bf->Height * 4;
+ bf->Image = calloc(1, bf->ImageSize);
+
+ if (!bf->Image) {
+ free(tmpImage);
+ mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] not enough memory for image\n");
+ return 1;
+ }
+
+ for (c = 0, i = 0; c < bf->ImageSize; c += 4, i += 3)
+ *(uint32_t *)&bf->Image[c] = AV_RB24(&tmpImage[i]);
+
+ free(tmpImage);
}
- free( tmpImage );
- }
- return 0;
+
+ return 0;
}
-static void Normalize( txSample * bf )
+static void Normalize(txSample *bf)
{
- int i;
+ int i;
+
+ for (i = 0; i < (int)bf->ImageSize; i += 4)
#if !HAVE_BIGENDIAN
- for ( i=0;i < (int)bf->ImageSize;i+=4 ) bf->Image[i+3]=0;
+ bf->Image[i + 3] = 0;
#else
- for ( i=0;i < (int)bf->ImageSize;i+=4 ) bf->Image[i]=0;
+ bf->Image[i] = 0;
#endif
}
-static unsigned char tmp[512];
+static unsigned char *fExist(unsigned char *fname)
+{
+ static unsigned char tmp[512];
+ FILE *fl;
+ unsigned char ext[][6] = { ".png\0", ".PNG\0" };
+ int i;
+
+ fl = fopen(fname, "rb");
+
+ if (fl != NULL) {
+ fclose(fl);
+ return fname;
+ }
-static unsigned char * fExist( unsigned char * fname )
+ for (i = 0; i < 2; i++) {
+ snprintf(tmp, sizeof(tmp), "%s%s", fname, ext[i]);
+ fl = fopen(tmp, "rb");
+
+ if (fl != NULL) {
+ fclose(fl);
+ return tmp;
+ }
+ }
+
+ return NULL;
+}
+
+int bpRead(char *fname, txSample *bf)
{
- FILE * fl;
- unsigned char ext[][6] = { ".png\0",".PNG\0" };
- int i;
-
- fl=fopen( fname,"rb" );
- if ( fl != NULL )
- {
- fclose( fl );
- return fname;
- }
- for ( i=0;i<2;i++ )
- {
- snprintf( tmp,511,"%s%s",fname,ext[i] );
- fl=fopen( tmp,"rb" );
- if ( fl != NULL )
- {
- fclose( fl );
- return tmp;
+ fname = fExist(fname);
+
+ if (fname == NULL)
+ return -2;
+
+ if (pngRead(fname, bf)) {
+ mp_dbg(MSGT_GPLAYER, MSGL_FATAL, "[bitmap] unknown file type ( %s )\n", fname);
+ return -5;
+ }
+
+ if (bf->BPP < 24) {
+ mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] Sorry, only 24 and 32 bpp bitmaps are supported.\n");
+ return -1;
}
- }
- return NULL;
+
+ if (conv24to32(bf))
+ return -8;
+
+ Normalize(bf);
+ return 0;
}
-int bpRead( char * fname, txSample * bf )
+void bpFree(txSample *bf)
{
- fname=fExist( fname );
- if ( fname == NULL ) return -2;
- if ( pngRead( fname,bf ) )
- {
- mp_dbg( MSGT_GPLAYER,MSGL_FATAL,"[bitmap] unknown file type ( %s )\n",fname );
- return -5;
- }
- if ( bf->BPP < 24 )
- {
- mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] Sorry, only 24 and 32 bpp bitmaps are supported.\n" );
- return -1;
- }
- if ( conv24to32( bf ) ) return -8;
- Normalize( bf );
- return 0;
+ free(bf->Image);
+ memset(bf, 0, sizeof(*bf));
}
-void Convert32to1( txSample * in,txSample * out,int adaptivlimit )
+void Convert32to1(txSample *in, txSample *out, int adaptivlimit)
{
- out->Width=in->Width;
- out->Height=in->Height;
- out->BPP=1;
- out->ImageSize=(out->Width * out->Height + 7) / 8;
- mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c32to1] imagesize: %d\n",out->ImageSize );
- out->Image=calloc( 1,out->ImageSize );
- if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotEnoughMemoryC32To1 );
- {
- int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1;
- buf=(unsigned int *)in->Image;
- for ( b=0,i=0;i < (int)(out->Width * out->Height);i++ )
- {
- if ( (int)buf[i] != adaptivlimit ) tmp=( tmp >> 1 )|128;
- else { tmp=tmp >> 1; buf[i]=nothaveshape=0; }
- if ( b++ == 7 ) { out->Image[c++]=tmp; tmp=b=0; }
- }
- if ( b ) out->Image[c]=tmp;
- if ( nothaveshape ) { free( out->Image ); out->Image=NULL; }
- }
+ out->Width = in->Width;
+ out->Height = in->Height;
+ out->BPP = 1;
+ out->ImageSize = (out->Width * out->Height + 7) / 8;
+
+ mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[c32to1] imagesize: %lu\n", out->ImageSize);
+
+ out->Image = calloc(1, out->ImageSize);
+
+ if (out->Image == NULL)
+ mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_NotEnoughMemoryC32To1);
+ {
+ int i, b, c = 0;
+ unsigned int *buf = NULL;
+ unsigned char tmp = 0;
+ int nothaveshape = 1;
+
+ buf = (unsigned int *)in->Image;
+
+ for (b = 0, i = 0; i < (int)(out->Width * out->Height); i++) {
+ if ((int)buf[i] != adaptivlimit)
+ tmp = (tmp >> 1) | 128;
+ else {
+ tmp = tmp >> 1;
+ buf[i] = nothaveshape = 0;
+ }
+
+ if (b++ == 7) {
+ out->Image[c++] = tmp;
+ tmp = b = 0;
+ }
+ }
+
+ if (b)
+ out->Image[c] = tmp;
+
+ if (nothaveshape) {
+ free(out->Image);
+ out->Image = NULL;
+ }
+ }
}
diff --git a/mplayer/gui/bitmap.h b/mplayer/gui/bitmap.h
index 092f5156..bb3fce37 100644
--- a/mplayer/gui/bitmap.h
+++ b/mplayer/gui/bitmap.h
@@ -19,16 +19,16 @@
#ifndef MPLAYER_GUI_BITMAP_H
#define MPLAYER_GUI_BITMAP_H
-typedef struct txSample
-{
- unsigned long Width;
- unsigned long Height;
- unsigned int BPP;
- unsigned long ImageSize;
- char * Image;
+typedef struct {
+ unsigned long Width;
+ unsigned long Height;
+ unsigned int BPP;
+ unsigned long ImageSize;
+ char *Image;
} txSample;
-int bpRead( char * fname, txSample * bf );
-void Convert32to1( txSample * in,txSample * out,int adaptivlimit );
+void bpFree(txSample *);
+int bpRead(char *, txSample *);
+void Convert32to1(txSample *, txSample *, int);
#endif /* MPLAYER_GUI_BITMAP_H */
diff --git a/mplayer/gui/interface.c b/mplayer/gui/interface.c
index 11aab59a..0ea05952 100644
--- a/mplayer/gui/interface.c
+++ b/mplayer/gui/interface.c
@@ -76,6 +76,10 @@ int vcd_seek_to_track(void *vcd, int track);
guiInterface_t guiIntfStruct;
int guiWinID=-1;
+char *skinName;
+char *skinDirInHome;
+char *skinMPlayerDir;
+
int gstrcmp( const char * a,const char * b )
{
if ( !a && !b ) return 0;
@@ -159,6 +163,8 @@ void guiInit( void )
guiIntfStruct.Balance=50.0f;
guiIntfStruct.StreamType=-1;
+ appResetStruct();
+
memset( >kEquChannels,0,sizeof( gtkEquChannels ) );
#ifdef CONFIG_DXR3
if ( !gtkDXR3Device ) gtkDXR3Device=strdup( "/dev/em8300-0" );
@@ -179,13 +185,9 @@ void guiInit( void )
wsXInit( (void *)mDisplay );
// --- load skin
skinDirInHome=get_path("skins");
- skinDirInHome_obsolete=get_path("Skin");
skinMPlayerDir=MPLAYER_DATADIR "/skins";
- skinMPlayerDir_obsolete=MPLAYER_DATADIR "/Skin";
mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 1: '%s'\n",skinDirInHome);
- mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 1 (obsolete): '%s'\n",skinDirInHome_obsolete);
mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 2: '%s'\n",skinMPlayerDir);
- mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 2 (obsolete): '%s'\n",skinMPlayerDir_obsolete);
if ( !skinName ) skinName=strdup( "default" );
i = skinRead( skinName );
if ((i == -1) && strcmp(skinName,"default"))
@@ -441,14 +443,24 @@ void guiLoadSubtitle( char * name )
static void add_vf( char * str )
{
- mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_AddingVideoFilter,str );
+ void *p;
+
if ( vf_settings )
{
int i = 0;
while ( vf_settings[i].name ) if ( !gstrcmp( vf_settings[i++].name,str ) ) { i=-1; break; }
if ( i != -1 )
- { vf_settings=realloc( vf_settings,( i + 2 ) * sizeof( m_obj_settings_t ) ); vf_settings[i].name=strdup( str );vf_settings[i].attribs = NULL; vf_settings[i+1].name=NULL; }
- } else { vf_settings=malloc( 2 * sizeof( m_obj_settings_t ) ); vf_settings[0].name=strdup( str );vf_settings[0].attribs = NULL; vf_settings[1].name=NULL; }
+ {
+ if ( !( p=realloc( vf_settings,( i + 2 ) * sizeof( m_obj_settings_t ) ) ) ) return;
+ vf_settings=p;
+ vf_settings[i].name=strdup( str );
+ vf_settings[i].attribs = NULL;
+ vf_settings[i+1].name=NULL;
+ }
+ }
+ else { vf_settings=malloc( 2 * sizeof( m_obj_settings_t ) ); vf_settings[0].name=strdup( str );vf_settings[0].attribs = NULL; vf_settings[1].name=NULL; }
+
+ mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_AddingVideoFilter,str );
}
static void remove_vf( char * str )
diff --git a/mplayer/gui/interface.h b/mplayer/gui/interface.h
index e3ee37df..ffeb4f7f 100644
--- a/mplayer/gui/interface.h
+++ b/mplayer/gui/interface.h
@@ -185,6 +185,9 @@ typedef struct urlItem
} URLItem;
extern char * skinName;
+extern char * skinDirInHome;
+extern char * skinMPlayerDir;
+
extern plItem * plList;
extern plItem * plCurrent;
extern plItem * plLastPlayed;
diff --git a/mplayer/gui/mplayer/gtk/about.c b/mplayer/gui/mplayer/gtk/about.c
index c5529705..e1d6441c 100644
--- a/mplayer/gui/mplayer/gtk/about.c
+++ b/mplayer/gui/mplayer/gtk/about.c
@@ -73,7 +73,7 @@ GtkWidget * create_About( void )
vbox=AddVBox( AddDialogFrame( About ),0 );
pixmapstyle=gtk_widget_get_style( About );
- pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( About->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],about_xpm );
+ pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( About->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],(gchar **) about_xpm );
pixmap1=gtk_pixmap_new( pixmapwid,mask );
gtk_widget_set_name( pixmap1,"pixmap1" );
diff --git a/mplayer/gui/mplayer/gtk/fs.c b/mplayer/gui/mplayer/gtk/fs.c
index fe86c965..fd7fa158 100644
--- a/mplayer/gui/mplayer/gtk/fs.c
+++ b/mplayer/gui/mplayer/gtk/fs.c
@@ -48,6 +48,7 @@ char * get_current_dir_name( void );
#endif
gchar * fsSelectedFile = NULL;
+gchar * fsSelectedFileUtf8 = NULL;
gchar * fsSelectedDirectory = NULL;
unsigned char * fsThatDir = ".";
const gchar * fsFilter = "*";
@@ -155,6 +156,16 @@ GdkPixmap * fpixmap;
GdkBitmap * dmask;
GdkBitmap * fmask;
+static char * get_current_dir_name_utf8( void )
+{
+ char * dir, * utf8dir;
+ dir = get_current_dir_name();
+ utf8dir = g_filename_to_utf8( dir, -1, NULL, NULL, NULL );
+ if ( !utf8dir ) utf8dir = g_strdup( dir );
+ free( dir );
+ return utf8dir;
+}
+
static char * Filter( const char * name )
{
static char tmp[32];
@@ -171,14 +182,16 @@ static char * Filter( const char * name )
static void clist_append_fname(GtkWidget * list, char *fname,
GdkPixmap *pixmap, GdkPixmap *mask) {
gint pos;
- gchar *str[2];
+ gchar *filename, *str[2];
+ filename = g_filename_to_utf8(fname, -1, NULL, NULL, NULL);
str[0] = NULL;
- str[1] = fname;
+ str[1] = filename ? filename : fname;
pos = gtk_clist_append(GTK_CLIST(list), str);
gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask);
+ g_free(filename);
}
-static void CheckDir( GtkWidget * list,char * directory )
+static void CheckDir( GtkWidget * list )
{
struct stat fs;
int i;
@@ -324,7 +337,7 @@ void ShowFileSelect( int type,int modal )
for ( i=0;i < fsPersistant_MaxPos;i++ )
if ( fsHistory[i] ) { fsTopList_items=g_list_append( fsTopList_items,fsHistory[i] ); c=0; }
}
- if ( c ) fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name() );
+ if ( c ) fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name_utf8() );
}
if ( getenv( "HOME" ) ) fsTopList_items=g_list_append( fsTopList_items,getenv( "HOME" ) );
fsTopList_items=g_list_append( fsTopList_items,"/home" );
@@ -367,7 +380,7 @@ static void fs_fsFilterCombo_activate( GtkEditable * editable,
gpointer user_data )
{
fsFilter=gtk_entry_get_text( GTK_ENTRY( user_data ) );
- CheckDir( fsFNameList,get_current_dir_name() );
+ CheckDir( fsFNameList );
}
static void fs_fsFilterCombo_changed( GtkEditable * editable,
@@ -407,33 +420,39 @@ static void fs_fsFilterCombo_changed( GtkEditable * editable,
break;
default: return;
}
- CheckDir( fsFNameList,get_current_dir_name() );
+ CheckDir( fsFNameList );
}
static void fs_fsPathCombo_activate( GtkEditable * editable,
gpointer user_data )
{
const unsigned char * str;
+ gchar * dirname;
str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
- if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() );
+ dirname = g_filename_from_utf8( str, -1, NULL, NULL, NULL );
+ if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList );
+ g_free( dirname );
}
static void fs_fsPathCombo_changed( GtkEditable * editable,
gpointer user_data )
{
const unsigned char * str;
+ gchar * dirname;
str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
- if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() );
+ dirname = g_filename_from_utf8( str, -1, NULL, NULL, NULL );
+ if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList );
+ g_free( dirname );
}
static void fs_Up_released( GtkButton * button, gpointer user_data )
{
chdir( ".." );
fsSelectedFile=fsThatDir;
- CheckDir( fsFNameList,get_current_dir_name() );
- gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() );
+ CheckDir( fsFNameList );
+ gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name_utf8() );
return;
}
@@ -448,8 +467,8 @@ static void fs_Ok_released( GtkButton * button, gpointer user_data )
{
chdir( fsSelectedFile );
fsSelectedFile=fsThatDir;
- CheckDir( fsFNameList,get_current_dir_name() );
- gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() );
+ CheckDir( fsFNameList );
+ gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name_utf8() );
return;
}
@@ -462,7 +481,7 @@ static void fs_Ok_released( GtkButton * button, gpointer user_data )
guiIntfStruct.FilenameChanged=1; sub_fps=0;
gfree( (void **)&guiIntfStruct.AudioFile );
gfree( (void **)&guiIntfStruct.Subtitlename );
- fs_PersistantHistory( fsSelectedDirectory ); //totem, write into history
+ fs_PersistantHistory( get_current_dir_name_utf8() ); //totem, write into history
break;
case fsSubtitleSelector:
guiSetDF( guiIntfStruct.Subtitlename,fsSelectedDirectory,fsSelectedFile );
@@ -489,7 +508,7 @@ static void fs_Ok_released( GtkButton * button, gpointer user_data )
if ( !strcmp( item->data,fsSelectedDirectory ) ) i=0;
item=item->next;
}
- if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name() );
+ if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name_utf8() );
if ( mplMainAutoPlay ) { mplMainAutoPlay=0; mplEventHandling( evPlay,0 ); }
else guiGetEvent( guiCEvent,guiSetStop );
}
@@ -497,13 +516,16 @@ static void fs_Ok_released( GtkButton * button, gpointer user_data )
static void fs_Cancel_released( GtkButton * button,gpointer user_data )
{
HideFileSelect();
- fs_PersistantHistory( get_current_dir_name() ); //totem, write into history file
+ fs_PersistantHistory( get_current_dir_name_utf8() ); //totem, write into history file
}
static void fs_fsFNameList_select_row( GtkWidget * widget, gint row, gint column,
GdkEventButton *bevent, gpointer user_data)
{
gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile );
+ g_free( fsSelectedFileUtf8 );
+ fsSelectedFileUtf8 = g_filename_from_utf8( fsSelectedFile, -1, NULL, NULL, NULL );
+ if ( fsSelectedFileUtf8 ) fsSelectedFile = fsSelectedFileUtf8;
if( bevent && bevent->type == GDK_BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) );
}
@@ -526,6 +548,13 @@ static gboolean on_FileSelect_key_release_event( GtkWidget * widget,
return FALSE;
}
+static void fs_Destroy( void )
+{
+ g_free( fsSelectedFileUtf8 );
+ fsSelectedFileUtf8 = NULL;
+ WidgetDestroy( fsFileSelect, &fsFileSelect );
+}
+
GtkWidget * create_FileSelect( void )
{
GtkWidget * vbox4;
@@ -635,7 +664,7 @@ GtkWidget * create_FileSelect( void )
fsOk=AddButton( MSGTR_Ok,hbuttonbox3 );
fsCancel=AddButton( MSGTR_Cancel,hbuttonbox3 );
- gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&fsFileSelect );
+ gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( fs_Destroy ), NULL );
gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL );
gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),fsFilterCombo );
diff --git a/mplayer/gui/mplayer/gtk/opts.c b/mplayer/gui/mplayer/gtk/opts.c
index 6d628ead..14fae9f1 100644
--- a/mplayer/gui/mplayer/gtk/opts.c
+++ b/mplayer/gui/mplayer/gtk/opts.c
@@ -1557,33 +1557,33 @@ static void audioButton(GtkButton *button, gpointer user_data) {
case 1:
#ifdef CONFIG_OSS_AUDIO
if (strncmp(ao_driver[0], "oss", 3) == 0) {
- gfree(>kAOOSSDevice);
+ gfree((void **) >kAOOSSDevice);
gtkAOOSSDevice = gstrdup(getGtkEntryText(CEAudioDevice));
- gfree(>kAOOSSMixer);
+ gfree((void **) >kAOOSSMixer);
gtkAOOSSMixer = gstrdup(getGtkEntryText(CEAudioMixer));
- gfree(>kAOOSSMixerChannel);
+ gfree((void **) >kAOOSSMixerChannel);
gtkAOOSSMixerChannel = gstrdup(getGtkEntryText(CEAudioMixerChannel));
}
#endif
#ifdef CONFIG_ALSA
if (strncmp(ao_driver[0], "alsa", 4) == 0) {
- gfree(>kAOALSADevice);
+ gfree((void **) >kAOALSADevice);
gtkAOALSADevice = gstrdup(getGtkEntryText(CEAudioDevice));
- gfree(>kAOALSAMixer);
+ gfree((void **) >kAOALSAMixer);
gtkAOALSAMixer = gstrdup(getGtkEntryText(CEAudioMixer));
- gfree(>kAOALSAMixerChannel);
+ gfree((void **) >kAOALSAMixerChannel);
gtkAOALSAMixerChannel = gstrdup(getGtkEntryText(CEAudioMixerChannel));
}
#endif
#ifdef CONFIG_SDL
if (strncmp(ao_driver[0], "sdl", 3) == 0) {
- gfree(>kAOSDLDriver);
+ gfree((void **) >kAOSDLDriver);
gtkAOSDLDriver = gstrdup(getGtkEntryText(CEAudioDevice));
}
#endif
#ifdef CONFIG_ESD
if (strncmp(ao_driver[0], "esd", 3) == 0) {
- gfree(>kAOESDDevice);
+ gfree((void **) >kAOESDDevice);
gtkAOESDDevice = gstrdup(getGtkEntryText(CEAudioDevice));
}
#endif
diff --git a/mplayer/gui/mplayer/gtk/pl.c b/mplayer/gui/mplayer/gtk/pl.c
index 6aad6fd3..9e033449 100644
--- a/mplayer/gui/mplayer/gtk/pl.c
+++ b/mplayer/gui/mplayer/gtk/pl.c
@@ -174,13 +174,18 @@ void ShowPlayList( void )
gtk_clist_clear( GTK_CLIST( CLSelected ) );
if ( plList )
{
+ gchar * name, * path;
plItem * next = plList;
while ( next || next->next )
{
char * text[1][3]; text[0][2]="";
- text[0][0]=next->name;
- text[0][1]=next->path;
+ name = g_filename_to_utf8( next->name, -1, NULL, NULL, NULL );
+ path = g_filename_to_utf8( next->path, -1, NULL, NULL, NULL );
+ text[0][0]=name ? name : next->name;
+ text[0][1]=path ? path : next->path;
gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
+ g_free( path );
+ g_free( name );
NrOfSelected++;
if ( next->next ) next=next->next; else break;
}
@@ -236,8 +241,10 @@ static void plButtonReleased( GtkButton * button,gpointer user_data )
item=calloc( 1,sizeof( plItem ) );
gtk_clist_get_text( GTK_CLIST( CLSelected ),i,0,&text[0] );
gtk_clist_get_text( GTK_CLIST( CLSelected ),i,1,&text[1] );
- item->name=strdup( text[0] );
- item->path=strdup( text[1] );
+ item->name=g_filename_from_utf8( text[0], -1, NULL, NULL, NULL );
+ if ( !item->name ) item->name = strdup( text[0] );
+ item->path=g_filename_from_utf8( text[1], -1, NULL, NULL, NULL );
+ if ( !item->path ) item->path = strdup( text[1] );
gtkSet( gtkAddPlItem,0,(void*)item );
}
if ( plCurrent )
@@ -278,19 +285,28 @@ static void plButtonReleased( GtkButton * button,gpointer user_data )
case 3: // add
{
int i;
+ void *p;
char * itext[1][2];
+ gchar * cpath;
char * text[1][3]; text[0][2]="";
gtk_clist_freeze( GTK_CLIST( CLSelected ) );
for ( i=0;id_name );
else sprintf( path,"%s/%s",current_path,dirent->d_name );
text=dirent->d_name;
+ g_free( name );
+ name=g_filename_to_utf8( text, -1, NULL, NULL, NULL );
if ( stat( path,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) && dirent->d_name[0] != '.' )
{
DirNode=malloc( sizeof( DirNodeType ) ); DirNode->scaned=0; DirNode->path=strdup( path );
subdir=check_for_subdir( path );
- node=gtk_ctree_insert_node( ctree,parent_node,NULL,&text,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE );
+ node=gtk_ctree_insert_node( ctree,parent_node,NULL,(name ? &name : &text ),4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE );
gtk_ctree_node_set_row_data_full( ctree,node,DirNode,NULL );
if ( subdir ) node=gtk_ctree_insert_node( ctree,node,NULL,&dummy,4,NULL,NULL,NULL,NULL,FALSE,FALSE );
}
@@ -369,6 +387,8 @@ static void plCTree( GtkCTree * ctree,GtkCTreeNode * parent_node,gpointer user_d
gtk_ctree_sort_node( ctree,parent_node );
gtk_clist_thaw( GTK_CLIST( ctree ) );
}
+
+ g_free( name );
}
static void scan_dir( char * path )
@@ -377,6 +397,7 @@ static void scan_dir( char * path )
char * curr;
struct dirent * dirent;
struct stat statbuf;
+ gchar * name;
char * text[1][2]; text[0][1]="";
gtk_clist_clear( GTK_CLIST( CLFiles ) );
@@ -388,8 +409,10 @@ static void scan_dir( char * path )
curr=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); sprintf( curr,"%s/%s",path,dirent->d_name );
if ( stat( curr,&statbuf ) != -1 && ( S_ISREG( statbuf.st_mode ) || S_ISLNK( statbuf.st_mode ) ) )
{
- text[0][0]=dirent->d_name;
- gtk_clist_append( GTK_CLIST( CLFiles ),text[0] );
+ name=g_filename_to_utf8( dirent->d_name, -1, NULL, NULL, NULL );
+ text[0][0]=name ? name : dirent->d_name;
+ gtk_clist_append( GTK_CLIST( CLFiles ), text[0] );
+ g_free( name );
NrOfEntrys++;
}
free( curr );
diff --git a/mplayer/gui/mplayer/gtk/sb.c b/mplayer/gui/mplayer/gtk/sb.c
index e17b17b9..a4321f66 100644
--- a/mplayer/gui/mplayer/gtk/sb.c
+++ b/mplayer/gui/mplayer/gtk/sb.c
@@ -34,11 +34,8 @@
GtkWidget * SkinList = NULL;
char * sbSelectedSkin=NULL;
-/* FIXME: Eventually remove the obsolete directory names. */
char * sbMPlayerDirInHome=NULL;
-char * sbMPlayerDirInHome_obsolete=NULL;
char * sbMPlayerPrefixDir=NULL;
-char * sbMPlayerPrefixDir_obsolete=NULL;
char * gtkOldSkin=NULL;
static char * prev=NULL;
@@ -101,7 +98,7 @@ static void prButton( GtkObject * object,gpointer user_data )
if ( strcmp( sbSelectedSkin,gtkOldSkin ) ) ChangeSkin( gtkOldSkin );
break;
case 1: // ok
- ChangeSkin( sbSelectedSkin );
+ ChangeSkin( sbSelectedSkin ); // NOTE TO MYSELF: skin already changed!
free( skinName );
skinName=strdup( sbSelectedSkin );
break;
@@ -195,12 +192,8 @@ GtkWidget * create_SkinBrowser( void )
gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void *)1 );
gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void *)0 );
- if ( ( sbMPlayerDirInHome_obsolete=calloc( 1,strlen( skinDirInHome_obsolete ) + 4 ) ) != NULL )
- { strcpy( sbMPlayerDirInHome_obsolete,skinDirInHome_obsolete ); strcat( sbMPlayerDirInHome_obsolete,"/*" ); }
if ( ( sbMPlayerDirInHome=calloc( 1,strlen( skinDirInHome ) + 4 ) ) != NULL )
{ strcpy( sbMPlayerDirInHome,skinDirInHome ); strcat( sbMPlayerDirInHome,"/*" ); }
- if ( ( sbMPlayerPrefixDir_obsolete=calloc( 1,strlen( skinMPlayerDir ) + 4 ) ) != NULL )
- { strcpy( sbMPlayerPrefixDir_obsolete,skinMPlayerDir ); strcat( sbMPlayerPrefixDir_obsolete,"/*" ); }
if ( ( sbMPlayerPrefixDir=calloc( 1,strlen( skinMPlayerDir ) + 4 ) ) != NULL )
{ strcpy( sbMPlayerPrefixDir,skinMPlayerDir ); strcat( sbMPlayerPrefixDir,"/*" ); }
diff --git a/mplayer/gui/mplayer/gui_common.c b/mplayer/gui/mplayer/gui_common.c
index ff7557af..e82375ec 100644
--- a/mplayer/gui/mplayer/gui_common.c
+++ b/mplayer/gui/mplayer/gui_common.c
@@ -54,6 +54,7 @@ static inline void TranslateFilename( int c,char * tmp,size_t tmplen )
{
int i;
char * p;
+ size_t len;
switch ( guiIntfStruct.StreamType )
{
@@ -67,8 +68,10 @@ static inline void TranslateFilename( int c,char * tmp,size_t tmplen )
av_strlcpy(tmp, p + 1, tmplen);
else
av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
- if ( tmp[strlen( tmp ) - 4] == '.' ) tmp[strlen( tmp ) - 4]=0;
- if ( tmp[strlen( tmp ) - 5] == '.' ) tmp[strlen( tmp ) - 5]=0;
+ len=strlen( tmp );
+ if ( ( len > 3 )&&( tmp[len - 3] == '.' ) ) tmp[len - 3]=0;
+ else if ( ( len > 4 )&&( tmp[len - 4] == '.' ) ) tmp[len - 4]=0;
+ else if ( ( len > 5 )&&( tmp[len - 5] == '.' ) ) tmp[len - 5]=0;
} else av_strlcpy( tmp,MSGTR_NoFileLoaded,tmplen );
break;
#ifdef CONFIG_DVDREAD
@@ -259,7 +262,7 @@ void Render( wsTWindow * window,wItem * Items,int nrItems,char * db,int size )
{
wItem * item;
txSample * image = NULL;
- int i;
+ int i, ofs;
image_buffer=db;
image_width=window->Width;
@@ -267,38 +270,63 @@ void Render( wsTWindow * window,wItem * Items,int nrItems,char * db,int size )
for( i=0;i < nrItems + 1;i++ )
{
item=&Items[i];
+ ofs = (item->pressed == btnPressed ? 0 : (item->pressed == btnReleased ? 1 : 2));
switch( item->type )
{
case itButton:
- PutImage( &item->Bitmap,item->x,item->y,3,item->pressed );
+ PutImage( &item->Bitmap,item->x,item->y,3,ofs );
break;
case itPotmeter:
- if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
- else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) );
+ if (item->numphases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
+ else PutImage( &item->Bitmap,item->x,item->y,item->numphases,( item->numphases - 1 ) * ( item->value / 100.0f ) );
break;
case itHPotmeter:
- if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
- else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) );
- PutImage( &item->Mask,item->x + (int)( ( item->width - item->psx ) * item->value / 100.0f ),item->y,3,item->pressed );
+ if (item->numphases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
+ else PutImage( &item->Bitmap,item->x,item->y,item->numphases,( item->numphases - 1 ) * ( item->value / 100.0f ) );
+ PutImage( &item->Mask,item->x + (int)( ( item->width - item->pwidth ) * item->value / 100.0f ),item->y,3,ofs );
break;
case itVPotmeter:
PutImage( &item->Bitmap,
item->x,item->y,
- item->phases,
- item->phases * ( 1. - item->value / 100.0f ) );
+ item->numphases,
+ item->numphases * ( 1. - item->value / 100.0f ) );
PutImage( &item->Mask,
- item->x,item->y + (int)( ( item->height - item->psy ) * ( 1. - item->value / 100.0f ) ),
- 3,item->pressed );
+ item->x,item->y + (int)( ( item->height - item->pheight ) * ( 1. - item->value / 100.0f ) ),
+ 3,ofs );
break;
case itSLabel:
- image=fntRender( item,0,"%s",item->label );
+ image=fntRender( item,0,item->label );
if ( image ) PutImage( image,item->x,item->y,1,0 );
case itDLabel:
{
+ int x;
+ unsigned int d;
char * t = Translate( item->label );
- int l = fntTextWidth( item->fontid,t );
- l=(l?l:item->width);
- image=fntRender( item,l-(GetTimerMS() / 20)%l,"%s",t );
+ if ( g_strcmp0( item->text, t ) != 0 )
+ {
+ g_free( item->text );
+ item->text = g_strdup( t );
+ item->textwidth = fntTextWidth( item->fontid, t );
+ item->starttime = GetTimerMS();
+ item->last_x = 0;
+ }
+ d = GetTimerMS() - item->starttime;
+ if ( d < DELAYTIME ) x = item->last_x; // don't scroll yet
+ else
+ {
+ int l;
+ char c[2];
+ l = (item->textwidth ? item->textwidth : item->width);
+ x = l - ((d - DELAYTIME) / 20) % l - 1;
+ c[0] = *item->text;
+ c[1] = '\0';
+ if ( x < (fntTextWidth( item->fontid, c ) + 1) >> 1)
+ {
+ item->starttime = GetTimerMS(); // stop again
+ item->last_x = x; // at current x pos
+ }
+ }
+ image = fntRender( item, x, t );
}
if ( image ) PutImage( image,item->x,item->y,1,0 );
break;
diff --git a/mplayer/gui/mplayer/gui_common.h b/mplayer/gui/mplayer/gui_common.h
index 94336c1c..ffb8b0b3 100644
--- a/mplayer/gui/mplayer/gui_common.h
+++ b/mplayer/gui/mplayer/gui_common.h
@@ -29,6 +29,8 @@
#include "gui/bitmap.h"
#include "gui/wm/ws.h"
+#define DELAYTIME 2500 // in milliseconds
+
char * Translate( char * str );
void PutImage( txSample * bf,int x, int y, int max, int ofs );
void SimplePotmeterPutImage( txSample * bf, int x, int y, float frac );
diff --git a/mplayer/gui/mplayer/menu.c b/mplayer/gui/mplayer/menu.c
index d33b8168..cae59cfb 100644
--- a/mplayer/gui/mplayer/menu.c
+++ b/mplayer/gui/mplayer/menu.c
@@ -52,8 +52,8 @@ static void mplMenuDraw( void )
{
buf=(uint32_t *)mplMenuDrawBuffer;
drw=(uint32_t *)appMPlayer.menuSelected.Bitmap.Image;
- for ( y=appMPlayer.MenuItems[ mplMenuItem ].y; y < appMPlayer.MenuItems[ mplMenuItem ].y + appMPlayer.MenuItems[ mplMenuItem ].height; y++ )
- for ( x=appMPlayer.MenuItems[ mplMenuItem ].x; x < appMPlayer.MenuItems[ mplMenuItem ].x + appMPlayer.MenuItems[ mplMenuItem ].width; x++ )
+ for ( y=appMPlayer.menuItems[ mplMenuItem ].y; y < appMPlayer.menuItems[ mplMenuItem ].y + appMPlayer.menuItems[ mplMenuItem ].height; y++ )
+ for ( x=appMPlayer.menuItems[ mplMenuItem ].x; x < appMPlayer.menuItems[ mplMenuItem ].x + appMPlayer.menuItems[ mplMenuItem ].width; x++ )
{
tmp=drw[ y * appMPlayer.menuSelected.width + x ];
if ( tmp != 0x00ff00ff ) buf[ y * appMPlayer.menuBase.width + x ]=tmp;
@@ -82,11 +82,11 @@ void mplMenuMouseHandle( int X,int Y,int RX,int RY )
return;
}
- for( i=0;i<=appMPlayer.NumberOfMenuItems;i++ )
+ for( i=0;i<=appMPlayer.IndexOfMenuItems;i++ )
{
if ( wgIsRect( x,y,
- appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,
- appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) ) { mplMenuItem=i; break; }
+ appMPlayer.menuItems[i].x,appMPlayer.menuItems[i].y,
+ appMPlayer.menuItems[i].x+appMPlayer.menuItems[i].width,appMPlayer.menuItems[i].y+appMPlayer.menuItems[i].height ) ) { mplMenuItem=i; break; }
}
wsPostRedisplay( &appMPlayer.menuWindow );
}
@@ -130,13 +130,13 @@ void mplHideMenu( int mx,int my,int w )
if ( ( x < 0 ) || ( y < 0 ) ) return;
// printf( "---------> %d %d,%d\n",i,x,y );
-// printf( "--------> mi: %d,%d %dx%d\n",appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].height );
+// printf( "--------> mi: %d,%d %dx%d\n",appMPlayer.menuItems[i].x,appMPlayer.menuItems[i].y,appMPlayer.menuItems[i].width,appMPlayer.menuItems[i].height );
if ( wgIsRect( x,y,
- appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,
- appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,
- appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) )
+ appMPlayer.menuItems[i].x,appMPlayer.menuItems[i].y,
+ appMPlayer.menuItems[i].x+appMPlayer.menuItems[i].width,
+ appMPlayer.menuItems[i].y+appMPlayer.menuItems[i].height ) )
{
- mplEventHandling( appMPlayer.MenuItems[i].msg,(float)w );
+ mplEventHandling( appMPlayer.menuItems[i].message,(float)w );
}
}
diff --git a/mplayer/gui/mplayer/mw.c b/mplayer/gui/mplayer/mw.c
index 4f652a83..316ca6ff 100644
--- a/mplayer/gui/mplayer/mw.c
+++ b/mplayer/gui/mplayer/mw.c
@@ -31,6 +31,7 @@
#include "gui/skin/font.h"
#include "gui/skin/skin.h"
#include "gui/wm/ws.h"
+#include "gui/wm/wskeys.h"
#include "help_mp.h"
#include "libvo/x11_common.h"
@@ -87,7 +88,7 @@ void mplMainDraw( void )
btnModify( evSetVolume,guiIntfStruct.Volume );
fast_memcpy( mplDrawBuffer,appMPlayer.main.Bitmap.Image,appMPlayer.main.Bitmap.ImageSize );
- Render( &appMPlayer.mainWindow,appMPlayer.Items,appMPlayer.NumberOfItems,mplDrawBuffer,appMPlayer.main.Bitmap.ImageSize );
+ Render( &appMPlayer.mainWindow,appMPlayer.mainItems,appMPlayer.IndexOfMainItems,mplDrawBuffer,appMPlayer.main.Bitmap.ImageSize );
mplMainRender=0;
}
wsPutImage( &appMPlayer.mainWindow );
@@ -392,9 +393,6 @@ void mplEventHandling( int msg,float param )
}
}
-#define itPLMButton (itNULL - 1)
-#define itPRMButton (itNULL - 2)
-
void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY )
{
static int itemtype = 0;
@@ -405,9 +403,9 @@ void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY )
static int SelectedItem = -1;
int currentselected = -1;
- for ( i=0;i < appMPlayer.NumberOfItems + 1;i++ )
- if ( ( appMPlayer.Items[i].pressed != btnDisabled )&&
- ( wgIsRect( X,Y,appMPlayer.Items[i].x,appMPlayer.Items[i].y,appMPlayer.Items[i].x+appMPlayer.Items[i].width,appMPlayer.Items[i].y+appMPlayer.Items[i].height ) ) )
+ for ( i=0;i <= appMPlayer.IndexOfMainItems;i++ )
+ if ( ( appMPlayer.mainItems[i].pressed != btnDisabled )&&
+ ( wgIsRect( X,Y,appMPlayer.mainItems[i].x,appMPlayer.mainItems[i].y,appMPlayer.mainItems[i].x+appMPlayer.mainItems[i].width,appMPlayer.mainItems[i].y+appMPlayer.mainItems[i].height ) ) )
{ currentselected=i; break; }
switch ( Button )
@@ -427,22 +425,22 @@ void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY )
SelectedItem=currentselected;
if ( SelectedItem == -1 ) break;
boxMoved=0;
- item=&appMPlayer.Items[SelectedItem];
+ item=&appMPlayer.mainItems[SelectedItem];
itemtype=item->type;
item->pressed=btnPressed;
switch( item->type )
{
case itButton:
if ( ( SelectedItem > -1 ) &&
- ( ( ( item->msg == evPlaySwitchToPause && item->msg == evPauseSwitchToPlay ) ) ||
- ( ( item->msg == evPauseSwitchToPlay && item->msg == evPlaySwitchToPause ) ) ) )
+ ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) ||
+ ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) )
{ item->pressed=btnDisabled; }
break;
}
break;
case wsRLMouseButton:
boxMoved=0;
- item=&appMPlayer.Items[SelectedItem];
+ item=&appMPlayer.mainItems[SelectedItem];
item->pressed=btnReleased;
SelectedItem=-1;
if ( currentselected == - 1 ) { itemtype=0; break; }
@@ -451,17 +449,17 @@ void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY )
{
case itPotmeter:
case itHPotmeter:
- btnModify( item->msg,(float)( X - item->x ) / item->width * 100.0f );
- mplEventHandling( item->msg,item->value );
+ btnModify( item->message,(float)( X - item->x ) / item->width * 100.0f );
+ mplEventHandling( item->message,item->value );
value=item->value;
break;
case itVPotmeter:
- btnModify( item->msg, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f );
- mplEventHandling( item->msg,item->value );
+ btnModify( item->message, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f );
+ mplEventHandling( item->message,item->value );
value=item->value;
break;
}
- mplEventHandling( item->msg,value );
+ mplEventHandling( item->message,value );
itemtype=0;
break;
@@ -473,18 +471,18 @@ void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY )
case wsP5MouseButton: value=-2.5f; goto rollerhandled;
case wsP4MouseButton: value= 2.5f;
rollerhandled:
- item=&appMPlayer.Items[currentselected];
+ item=&appMPlayer.mainItems[currentselected];
if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) )
{
item->value+=value;
- btnModify( item->msg,item->value );
- mplEventHandling( item->msg,item->value );
+ btnModify( item->message,item->value );
+ mplEventHandling( item->message,item->value );
}
break;
// --- moving
case wsMoveMouse:
- item=&appMPlayer.Items[SelectedItem];
+ item=&appMPlayer.mainItems[SelectedItem];
switch ( itemtype )
{
case itPLMButton:
@@ -505,7 +503,7 @@ void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY )
potihandled:
if ( item->value > 100.0f ) item->value=100.0f;
if ( item->value < 0.0f ) item->value=0.0f;
- mplEventHandling( item->msg,item->value );
+ mplEventHandling( item->message,item->value );
break;
}
break;
diff --git a/mplayer/gui/mplayer/pb.c b/mplayer/gui/mplayer/pb.c
index 2810a0a9..30a9ea80 100644
--- a/mplayer/gui/mplayer/pb.c
+++ b/mplayer/gui/mplayer/pb.c
@@ -106,15 +106,12 @@ static void mplPBDraw( void )
vo_mouse_autohide=0;
fast_memcpy( mplPBDrawBuffer,appMPlayer.bar.Bitmap.Image,appMPlayer.bar.Bitmap.ImageSize );
- Render( &appMPlayer.barWindow,appMPlayer.barItems,appMPlayer.NumberOfBarItems,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize );
+ Render( &appMPlayer.barWindow,appMPlayer.barItems,appMPlayer.IndexOfBarItems,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize );
wsConvert( &appMPlayer.barWindow,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize );
}
wsPutImage( &appMPlayer.barWindow );
}
-#define itPLMButton (itNULL - 1)
-#define itPRMButton (itNULL - 2)
-
static void mplPBMouseHandle( int Button, int X, int Y, int RX, int RY )
{
static int itemtype = 0;
@@ -125,7 +122,7 @@ static void mplPBMouseHandle( int Button, int X, int Y, int RX, int RY )
static int SelectedItem = -1;
int currentselected = -1;
- for ( i=0;i < appMPlayer.NumberOfBarItems + 1;i++ )
+ for ( i=0;i <= appMPlayer.IndexOfBarItems;i++ )
if ( ( appMPlayer.barItems[i].pressed != btnDisabled )&&
( wgIsRect( X,Y,appMPlayer.barItems[i].x,appMPlayer.barItems[i].y,appMPlayer.barItems[i].x+appMPlayer.barItems[i].width,appMPlayer.barItems[i].y+appMPlayer.barItems[i].height ) ) )
{ currentselected=i; break; }
@@ -155,8 +152,8 @@ static void mplPBMouseHandle( int Button, int X, int Y, int RX, int RY )
{
case itButton:
if ( ( SelectedItem > -1 ) &&
- ( ( ( item->msg == evPlaySwitchToPause && item->msg == evPauseSwitchToPlay ) ) ||
- ( ( item->msg == evPauseSwitchToPlay && item->msg == evPlaySwitchToPause ) ) ) )
+ ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) ||
+ ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) )
{ item->pressed=btnDisabled; }
break;
}
@@ -173,17 +170,17 @@ static void mplPBMouseHandle( int Button, int X, int Y, int RX, int RY )
{
case itPotmeter:
case itHPotmeter:
- btnModify( item->msg,(float)( X - item->x ) / item->width * 100.0f );
- mplEventHandling( item->msg,item->value );
+ btnModify( item->message,(float)( X - item->x ) / item->width * 100.0f );
+ mplEventHandling( item->message,item->value );
value=item->value;
break;
case itVPotmeter:
- btnModify( item->msg, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f );
- mplEventHandling( item->msg,item->value );
+ btnModify( item->message, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f );
+ mplEventHandling( item->message,item->value );
value=item->value;
break;
}
- mplEventHandling( item->msg,value );
+ mplEventHandling( item->message,value );
itemtype=0;
break;
@@ -195,8 +192,8 @@ static void mplPBMouseHandle( int Button, int X, int Y, int RX, int RY )
if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) )
{
item->value+=value;
- btnModify( item->msg,item->value );
- mplEventHandling( item->msg,item->value );
+ btnModify( item->message,item->value );
+ mplEventHandling( item->message,item->value );
}
break;
// ---
@@ -218,7 +215,7 @@ static void mplPBMouseHandle( int Button, int X, int Y, int RX, int RY )
potihandled:
if ( item->value > 100.0f ) item->value=100.0f;
if ( item->value < 0.0f ) item->value=0.0f;
- mplEventHandling( item->msg,item->value );
+ mplEventHandling( item->message,item->value );
break;
}
break;
diff --git a/mplayer/gui/mplayer/play.c b/mplayer/gui/mplayer/play.c
index c29edb27..c0021c6b 100644
--- a/mplayer/gui/mplayer/play.c
+++ b/mplayer/gui/mplayer/play.c
@@ -16,371 +16,442 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include
#include
-#include
#include
-#include
-#include
+#include "play.h"
+#include "gmplayer.h"
+#include "gui/app.h"
+#include "gui/interface.h"
+#include "gui/skin/font.h"
+#include "gui/skin/skin.h"
+#include "gui/wm/wsxdnd.h"
+#include "widgets.h"
#include "config.h"
#include "help_mp.h"
-#include "mp_core.h"
+#include "input/input.h"
#include "libmpcodecs/vd.h"
-#include "libvo/x11_common.h"
#include "libvo/video_out.h"
-#include "input/input.h"
+#include "mp_core.h"
+#include "stream/stream.h"
-#include "gui/wm/ws.h"
-#include "gui/wm/wsxdnd.h"
+int mplGotoTheNext = 1;
-#include "gui/app.h"
-#include "gui/wm/wskeys.h"
-#include "gui/interface.h"
+void mplFullScreen(void)
+{
+ if (guiIntfStruct.NoWindow && guiIntfStruct.Playing)
+ return;
+
+ if (guiIntfStruct.Playing && appMPlayer.subWindow.isFullScreen) {
+ appMPlayer.subWindow.OldWidth = guiIntfStruct.MovieWidth;
+ appMPlayer.subWindow.OldHeight = guiIntfStruct.MovieHeight;
+
+ switch (appMPlayer.sub.x) {
+ case -1:
+ appMPlayer.subWindow.OldX = wsMaxX / 2 - appMPlayer.subWindow.OldWidth / 2 + wsOrgX;
+ break;
+
+ case -2:
+ appMPlayer.subWindow.OldX = wsMaxX - appMPlayer.subWindow.OldWidth + wsOrgX;
+ break;
+
+ default:
+ appMPlayer.subWindow.OldX = appMPlayer.sub.x;
+ break;
+ }
+
+ switch (appMPlayer.sub.y) {
+ case -1:
+ appMPlayer.subWindow.OldY = wsMaxY / 2 - appMPlayer.subWindow.OldHeight / 2 + wsOrgY;
+ break;
+
+ case -2:
+ appMPlayer.subWindow.OldY = wsMaxY - appMPlayer.subWindow.OldHeight + wsOrgY;
+ break;
+
+ default:
+ appMPlayer.subWindow.OldY = appMPlayer.sub.y;
+ break;
+ }
+ }
-#include "widgets.h"
-#include "gmplayer.h"
-#include "play.h"
+ if (guiIntfStruct.Playing || gtkShowVideoWindow)
+ wsFullScreen(&appMPlayer.subWindow);
-#include "gui/skin/skin.h"
-#include "gui/skin/font.h"
+ fullscreen = vo_fs = appMPlayer.subWindow.isFullScreen;
+ wsSetLayer(wsDisplay, appMPlayer.mainWindow.WindowID, appMPlayer.subWindow.isFullScreen);
-#include "stream/stream.h"
+ if (appMPlayer.menuIsPresent)
+ wsSetLayer(wsDisplay, appMPlayer.menuWindow.WindowID, appMPlayer.subWindow.isFullScreen);
-int mplGotoTheNext = 1;
-
-void mplFullScreen( void )
-{
- if ( guiIntfStruct.NoWindow && guiIntfStruct.Playing ) return;
-
- if ( ( guiIntfStruct.Playing )&&( appMPlayer.subWindow.isFullScreen ) )
- {
- appMPlayer.subWindow.OldWidth=guiIntfStruct.MovieWidth; appMPlayer.subWindow.OldHeight=guiIntfStruct.MovieHeight;
- switch ( appMPlayer.sub.x )
- {
- case -1: appMPlayer.subWindow.OldX=( wsMaxX / 2 ) - ( appMPlayer.subWindow.OldWidth / 2 ) + wsOrgX; break;
- case -2: appMPlayer.subWindow.OldX=wsMaxX - appMPlayer.subWindow.OldWidth + wsOrgX; break;
- default: appMPlayer.subWindow.OldX=appMPlayer.sub.x; break;
- }
- switch ( appMPlayer.sub.y )
- {
- case -1: appMPlayer.subWindow.OldY=( wsMaxY / 2 ) - ( appMPlayer.subWindow.OldHeight / 2 ) + wsOrgY; break;
- case -2: appMPlayer.subWindow.OldY=wsMaxY - appMPlayer.subWindow.OldHeight + wsOrgY; break;
- default: appMPlayer.subWindow.OldY=appMPlayer.sub.y; break;
- }
- }
- if ( guiIntfStruct.Playing || gtkShowVideoWindow ) wsFullScreen( &appMPlayer.subWindow );
- fullscreen=vo_fs=appMPlayer.subWindow.isFullScreen;
- wsSetLayer( wsDisplay,appMPlayer.mainWindow.WindowID,appMPlayer.subWindow.isFullScreen );
- if ( appMPlayer.menuIsPresent ) wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,appMPlayer.subWindow.isFullScreen );
-
- if ( guiIntfStruct.Playing ) wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 );
- else wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.sub.R,appMPlayer.sub.G,appMPlayer.sub.B );
+ if (guiIntfStruct.Playing)
+ wsSetBackgroundRGB(&appMPlayer.subWindow, 0, 0, 0);
+ else
+ wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B);
}
-void mplEnd( void )
+void mplEnd(void)
{
- plItem * next;
-
- if ( !mplGotoTheNext && guiIntfStruct.Playing) { mplGotoTheNext=1; return; }
-
- if ( guiIntfStruct.Playing && (next=gtkSet( gtkGetNextPlItem,0,NULL )) && plLastPlayed != next )
- {
- plLastPlayed=next;
- guiSetDF( guiIntfStruct.Filename,next->path,next->name );
- guiIntfStruct.StreamType=STREAMTYPE_FILE;
- guiIntfStruct.FilenameChanged=guiIntfStruct.NewPlay=1;
- gfree( (void **)&guiIntfStruct.AudioFile );
- gfree( (void **)&guiIntfStruct.Subtitlename );
- }
- else
- {
- if ( guiIntfStruct.FilenameChanged || guiIntfStruct.NewPlay ) return;
-
- guiIntfStruct.TimeSec=0;
- guiIntfStruct.Position=0;
- guiIntfStruct.AudioType=0;
- guiIntfStruct.NoWindow=False;
+ plItem *next;
+
+ if (!mplGotoTheNext && guiIntfStruct.Playing) {
+ mplGotoTheNext = 1;
+ return;
+ }
+
+ if (guiIntfStruct.Playing && (next = gtkSet(gtkGetNextPlItem, 0, NULL)) && (plLastPlayed != next)) {
+ plLastPlayed = next;
+ guiSetDF(guiIntfStruct.Filename, next->path, next->name);
+ guiIntfStruct.StreamType = STREAMTYPE_FILE;
+ guiIntfStruct.FilenameChanged = guiIntfStruct.NewPlay = 1;
+ gfree((void **)&guiIntfStruct.AudioFile);
+ gfree((void **)&guiIntfStruct.Subtitlename);
+ } else {
+ if (guiIntfStruct.FilenameChanged || guiIntfStruct.NewPlay)
+ return;
+
+ guiIntfStruct.TimeSec = 0;
+ guiIntfStruct.Position = 0;
+ guiIntfStruct.AudioType = 0;
+ guiIntfStruct.NoWindow = False;
#ifdef CONFIG_DVDREAD
- guiIntfStruct.DVD.current_title=1;
- guiIntfStruct.DVD.current_chapter=1;
- guiIntfStruct.DVD.current_angle=1;
+ guiIntfStruct.DVD.current_title = 1;
+ guiIntfStruct.DVD.current_chapter = 1;
+ guiIntfStruct.DVD.current_angle = 1;
#endif
- if ( !appMPlayer.subWindow.isFullScreen && gtkShowVideoWindow)
- {
- wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height );
- wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y );
- }
- else wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow );
- guiGetEvent( guiCEvent,guiSetStop );
- mplSubRender=1;
- wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.sub.R,appMPlayer.sub.G,appMPlayer.sub.B );
- wsClearWindow( appMPlayer.subWindow );
- wsPostRedisplay( &appMPlayer.subWindow );
+ if (!appMPlayer.subWindow.isFullScreen && gtkShowVideoWindow) {
+ wsResizeWindow(&appMPlayer.subWindow, appMPlayer.sub.width, appMPlayer.sub.height);
+ wsMoveWindow(&appMPlayer.subWindow, True, appMPlayer.sub.x, appMPlayer.sub.y);
+ } else
+ wsVisibleWindow(&appMPlayer.subWindow, wsHideWindow);
+
+ guiGetEvent(guiCEvent, guiSetStop);
+ mplSubRender = 1;
+ wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B);
+ wsClearWindow(appMPlayer.subWindow);
+ wsPostRedisplay(&appMPlayer.subWindow);
}
}
-void mplPlay( void )
+void mplPlay(void)
{
- if ( ( !guiIntfStruct.Filename )||
- ( guiIntfStruct.Filename[0] == 0 )||
- ( guiIntfStruct.Playing == 1 ) ) return;
- if ( guiIntfStruct.Playing == 2 ) { mplPause(); return; }
- guiGetEvent( guiCEvent,(void *)guiSetPlay );
- mplSubRender=0;
- wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 );
- wsClearWindow( appMPlayer.subWindow );
+ if (!guiIntfStruct.Filename ||
+ (guiIntfStruct.Filename[0] == 0) ||
+ (guiIntfStruct.Playing == 1))
+ return;
+
+ if (guiIntfStruct.Playing == 2) {
+ mplPause();
+ return;
+ }
+
+ guiGetEvent(guiCEvent, (void *)guiSetPlay);
+ mplSubRender = 0;
+ wsSetBackgroundRGB(&appMPlayer.subWindow, 0, 0, 0);
+ wsClearWindow(appMPlayer.subWindow);
}
-void mplPause( void )
+void mplPause(void)
{
- if ( !guiIntfStruct.Playing ) return;
- if ( guiIntfStruct.Playing == 1 )
- {
- mp_cmd_t * cmd = calloc( 1,sizeof( *cmd ) );
- cmd->id=MP_CMD_PAUSE;
- cmd->name=strdup("pause");
- mp_input_queue_cmd(cmd);
- } else guiIntfStruct.Playing=1;
+ if (!guiIntfStruct.Playing)
+ return;
+
+ if (guiIntfStruct.Playing == 1) {
+ mp_cmd_t *cmd = calloc(1, sizeof(*cmd));
+ cmd->id = MP_CMD_PAUSE;
+ cmd->name = strdup("pause");
+ mp_input_queue_cmd(cmd);
+ } else
+ guiIntfStruct.Playing = 1;
}
-void mplState( void )
+void mplState(void)
{
- if ( ( guiIntfStruct.Playing == 0 )||( guiIntfStruct.Playing == 2 ) )
- {
- btnModify( evPlaySwitchToPause,btnReleased );
- btnModify( evPauseSwitchToPlay,btnDisabled );
- }
- else
- {
- btnModify( evPlaySwitchToPause,btnDisabled );
- btnModify( evPauseSwitchToPlay,btnReleased );
- }
+ if (guiIntfStruct.Playing == 0 || guiIntfStruct.Playing == 2) {
+ btnModify(evPlaySwitchToPause, btnReleased);
+ btnModify(evPauseSwitchToPlay, btnDisabled);
+ } else {
+ btnModify(evPlaySwitchToPause, btnDisabled);
+ btnModify(evPauseSwitchToPlay, btnReleased);
+ }
}
-float mplGetPosition( void )
-{ // return 0.0 ... 100.0
- return guiIntfStruct.Position;
+void mplRelSeek(float s)
+{
+ rel_seek_secs = s; // -+s
+ abs_seek_pos = 0;
}
-void mplRelSeek( float s )
-{ // -+s
- rel_seek_secs=s; abs_seek_pos=0;
-}
+void mplAbsSeek(float s)
+{
+ if (guiIntfStruct.StreamType == STREAMTYPE_STREAM)
+ return;
-void mplAbsSeek( float s )
-{ // 0.0 ... 100.0
- if ( guiIntfStruct.StreamType == STREAMTYPE_STREAM ) return;
- rel_seek_secs=0.01*s; abs_seek_pos=3;
+ rel_seek_secs = 0.01 * s; // 0.0..100.0
+ abs_seek_pos = 3;
}
-listItems tmpList;
-
-void ChangeSkin( char * name )
+void ChangeSkin(char *name)
{
- int ret;
- int prev = appMPlayer.menuIsPresent;
- int bprev = appMPlayer.barIsPresent;
-
- mainVisible=0;
-
- appInitStruct( &tmpList );
- skinAppMPlayer=&tmpList;
- fntFreeFont();
- ret=skinRead( name );
-
- appInitStruct( &tmpList );
- skinAppMPlayer=&appMPlayer;
- appInitStruct( &appMPlayer );
- if ( ret ) name=skinName;
- if ( skinRead( name ) )
- {
- mainVisible=1;
- return;
- }
-
-// --- reload menu window
-
- if ( prev && appMPlayer.menuIsPresent )
- {
- free( mplMenuDrawBuffer );
- if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL )
- { mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_NEMDB ); return; }
- wsResizeWindow( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height );
- wsResizeImage( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height );
- wsSetShape( &appMPlayer.menuWindow,appMPlayer.menuBase.Mask.Image );
- wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow );
- } else { mplMenuInit(); }
-
-// --- reload sub window
- if ( appMPlayer.sub.Bitmap.Image ) wsResizeImage( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Width,appMPlayer.sub.Bitmap.Height );
- if ( ( !appMPlayer.subWindow.isFullScreen )&&( !guiIntfStruct.Playing ) )
- {
- wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height );
- wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y );
- }
- if ( appMPlayer.sub.Bitmap.Image ) wsConvert( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Image,appMPlayer.sub.Bitmap.ImageSize );
- if ( !guiIntfStruct.Playing )
- {
- mplSubRender=1;
- wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.sub.R,appMPlayer.sub.G,appMPlayer.sub.B );
- wsClearWindow( appMPlayer.subWindow );
- wsPostRedisplay( &appMPlayer.subWindow );
- }
-
-// --- reload play bar
- if ( bprev ) wsDestroyWindow( &appMPlayer.barWindow );
- mplPBInit();
-
-// --- reload main window
- free( mplDrawBuffer );
- if ( ( mplDrawBuffer = calloc( 1,appMPlayer.main.Bitmap.ImageSize ) ) == NULL )
- { mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_NEMDB ); return; }
-
- wsDestroyWindow( &appMPlayer.mainWindow );
-
- wsCreateWindow( &appMPlayer.mainWindow,
- appMPlayer.main.x,appMPlayer.main.y,appMPlayer.main.width,appMPlayer.main.height,
- wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsShowFrame|wsMaxSize|wsHideWindow,"MPlayer" );
- wsCreateImage( &appMPlayer.mainWindow,appMPlayer.main.Bitmap.Width,appMPlayer.main.Bitmap.Height );
- wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image );
- wsSetIcon( wsDisplay,appMPlayer.mainWindow.WindowID,guiIcon,guiIconMask );
-
- appMPlayer.mainWindow.ReDraw=(void *)mplMainDraw;
- appMPlayer.mainWindow.MouseHandler=mplMainMouseHandle;
- appMPlayer.mainWindow.KeyHandler=mplMainKeyHandle;
- appMPlayer.mainWindow.DandDHandler=mplDandDHandler;
-
- wsXDNDMakeAwareness( &appMPlayer.mainWindow );
- if ( !appMPlayer.mainDecoration ) wsWindowDecoration( &appMPlayer.mainWindow,0 );
- wsVisibleWindow( &appMPlayer.mainWindow,wsShowWindow );
- mainVisible=1;
-// ---
-
- btnModify( evSetVolume,guiIntfStruct.Volume );
- btnModify( evSetBalance,guiIntfStruct.Balance );
- btnModify( evSetMoviePosition,guiIntfStruct.Position );
- btnModify( evFullScreen,!appMPlayer.subWindow.isFullScreen );
-
- wsSetLayer( wsDisplay,appMPlayer.mainWindow.WindowID,appMPlayer.subWindow.isFullScreen );
- wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,appMPlayer.subWindow.isFullScreen );
+ int prev, bprev;
+
+ prev = appMPlayer.menuIsPresent;
+ bprev = appMPlayer.barIsPresent;
+
+ mainVisible = 0;
+
+ if (skinRead(name) != 0) {
+ if (skinRead(skinName) != 0) {
+ mainVisible = 1;
+ return;
+ }
+ }
+
+ // reload menu window
+
+ if (prev && appMPlayer.menuIsPresent) {
+ free(mplMenuDrawBuffer);
+ mplMenuDrawBuffer = calloc(1, appMPlayer.menuBase.Bitmap.ImageSize);
+
+ if (!mplMenuDrawBuffer) {
+ mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_NEMDB);
+ return;
+ }
+
+ wsResizeWindow(&appMPlayer.menuWindow, appMPlayer.menuBase.width, appMPlayer.menuBase.height);
+ wsResizeImage(&appMPlayer.menuWindow, appMPlayer.menuBase.width, appMPlayer.menuBase.height);
+ wsSetShape(&appMPlayer.menuWindow, appMPlayer.menuBase.Mask.Image);
+ wsVisibleWindow(&appMPlayer.menuWindow, wsHideWindow);
+ } else
+ mplMenuInit();
+
+ // reload sub window
+
+ if (appMPlayer.sub.Bitmap.Image)
+ wsResizeImage(&appMPlayer.subWindow, appMPlayer.sub.Bitmap.Width, appMPlayer.sub.Bitmap.Height);
+
+ if (!appMPlayer.subWindow.isFullScreen && !guiIntfStruct.Playing) {
+ wsResizeWindow(&appMPlayer.subWindow, appMPlayer.sub.width, appMPlayer.sub.height);
+ wsMoveWindow(&appMPlayer.subWindow, True, appMPlayer.sub.x, appMPlayer.sub.y);
+ }
+
+ if (appMPlayer.sub.Bitmap.Image)
+ wsConvert(&appMPlayer.subWindow, appMPlayer.sub.Bitmap.Image, appMPlayer.sub.Bitmap.ImageSize);
+ if (!guiIntfStruct.Playing) {
+ mplSubRender = 1;
+ wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B);
+ wsClearWindow(appMPlayer.subWindow);
+ wsPostRedisplay(&appMPlayer.subWindow);
+ }
+
+ // reload play bar
+
+ if (bprev)
+ wsDestroyWindow(&appMPlayer.barWindow);
+
+ mplPBInit();
+
+ // reload main window
+
+ free(mplDrawBuffer);
+ mplDrawBuffer = calloc(1, appMPlayer.main.Bitmap.ImageSize);
+
+ if (!mplDrawBuffer) {
+ mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_NEMDB);
+ return;
+ }
+
+ wsDestroyWindow(&appMPlayer.mainWindow);
+
+ wsCreateWindow(&appMPlayer.mainWindow, appMPlayer.main.x, appMPlayer.main.y, appMPlayer.main.width, appMPlayer.main.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsMaxSize | wsHideWindow, "MPlayer");
+ wsCreateImage(&appMPlayer.mainWindow, appMPlayer.main.Bitmap.Width, appMPlayer.main.Bitmap.Height);
+ wsSetShape(&appMPlayer.mainWindow, appMPlayer.main.Mask.Image);
+ wsSetIcon(wsDisplay, appMPlayer.mainWindow.WindowID, guiIcon, guiIconMask);
+
+ appMPlayer.mainWindow.ReDraw = (void *)mplMainDraw;
+ appMPlayer.mainWindow.MouseHandler = mplMainMouseHandle;
+ appMPlayer.mainWindow.KeyHandler = mplMainKeyHandle;
+ appMPlayer.mainWindow.DandDHandler = mplDandDHandler;
+
+ wsXDNDMakeAwareness(&appMPlayer.mainWindow);
+
+ if (!appMPlayer.mainDecoration)
+ wsWindowDecoration(&appMPlayer.mainWindow, 0);
+
+ wsVisibleWindow(&appMPlayer.mainWindow, wsShowWindow);
+ mainVisible = 1;
+
+ btnModify(evSetVolume, guiIntfStruct.Volume);
+ btnModify(evSetBalance, guiIntfStruct.Balance);
+ btnModify(evSetMoviePosition, guiIntfStruct.Position);
+ btnModify(evFullScreen, !appMPlayer.subWindow.isFullScreen);
+
+ wsSetLayer(wsDisplay, appMPlayer.mainWindow.WindowID, appMPlayer.subWindow.isFullScreen);
+ wsSetLayer(wsDisplay, appMPlayer.menuWindow.WindowID, appMPlayer.subWindow.isFullScreen);
}
-void mplSetFileName( char * dir,char * name,int type )
+void mplSetFileName(char *dir, char *name, int type)
{
- if ( !name ) return;
+ if (!name)
+ return;
- if ( !dir ) guiSetFilename( guiIntfStruct.Filename,name )
- else guiSetDF( guiIntfStruct.Filename,dir,name );
+ if (!dir)
+ guiSetFilename(guiIntfStruct.Filename, name)
+ else
+ guiSetDF(guiIntfStruct.Filename, dir, name)
-// filename=guiIntfStruct.Filename;
- guiIntfStruct.StreamType=type;
- gfree( (void **)&guiIntfStruct.AudioFile );
- gfree( (void **)&guiIntfStruct.Subtitlename );
+ guiIntfStruct.StreamType = type;
+ gfree((void **)&guiIntfStruct.AudioFile);
+ gfree((void **)&guiIntfStruct.Subtitlename);
}
-void mplCurr( void )
+void mplCurr(void)
{
- plItem * curr;
- int stop = 0;
+ plItem *curr;
+ int stop = 0;
- if ( guiIntfStruct.Playing == 2 ) return;
- switch ( guiIntfStruct.StreamType )
- {
+ if (guiIntfStruct.Playing == 2)
+ return;
+
+ switch (guiIntfStruct.StreamType) {
#ifdef CONFIG_DVDREAD
- case STREAMTYPE_DVD:
- break;
+ case STREAMTYPE_DVD:
+ break;
+
#endif
#ifdef CONFIG_VCD
- case STREAMTYPE_VCD:
- break;
+ case STREAMTYPE_VCD:
+ break;
+
#endif
- default:
- if ( (curr=gtkSet( gtkGetCurrPlItem,0,NULL)) )
- {
- mplSetFileName( curr->path,curr->name,STREAMTYPE_FILE );
- mplGotoTheNext=0;
- break;
- }
- return;
- }
- if ( stop ) mplEventHandling( evStop,0 );
- if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evPlay,0 );
-}
+ default:
+
+ curr = gtkSet(gtkGetCurrPlItem, 0, NULL);
+
+ if (curr) {
+ mplSetFileName(curr->path, curr->name, STREAMTYPE_FILE);
+ mplGotoTheNext = 0;
+ break;
+ }
+
+ return;
+ }
+
+ if (stop)
+ mplEventHandling(evStop, 0);
+ if (guiIntfStruct.Playing == 1)
+ mplEventHandling(evPlay, 0);
+}
-void mplPrev( void )
+void mplPrev(void)
{
- plItem * prev;
- int stop = 0;
+ plItem *prev;
+ int stop = 0;
+
+ if (guiIntfStruct.Playing == 2)
+ return;
- if ( guiIntfStruct.Playing == 2 ) return;
- switch ( guiIntfStruct.StreamType )
- {
+ switch (guiIntfStruct.StreamType) {
#ifdef CONFIG_DVDREAD
- case STREAMTYPE_DVD:
- if ( --guiIntfStruct.DVD.current_chapter == 0 )
- {
- guiIntfStruct.DVD.current_chapter=1;
- if ( --guiIntfStruct.DVD.current_title <= 0 ) { guiIntfStruct.DVD.current_title=1; stop=1; }
- }
- guiIntfStruct.Track=guiIntfStruct.DVD.current_title;
- break;
+ case STREAMTYPE_DVD:
+
+ if (--guiIntfStruct.DVD.current_chapter == 0) {
+ guiIntfStruct.DVD.current_chapter = 1;
+
+ if (--guiIntfStruct.DVD.current_title <= 0) {
+ guiIntfStruct.DVD.current_title = 1;
+ stop = 1;
+ }
+ }
+
+ guiIntfStruct.Track = guiIntfStruct.DVD.current_title;
+ break;
+
#endif
#ifdef CONFIG_VCD
- case STREAMTYPE_VCD:
- if ( --guiIntfStruct.Track == 0 ) { guiIntfStruct.Track=1; stop=1; }
- break;
+ case STREAMTYPE_VCD:
+ if (--guiIntfStruct.Track == 0) {
+ guiIntfStruct.Track = 1;
+ stop = 1;
+ }
+ break;
+
#endif
- default:
- if ( (prev=gtkSet( gtkGetPrevPlItem,0,NULL)) )
- {
- mplSetFileName( prev->path,prev->name,STREAMTYPE_FILE );
- mplGotoTheNext=0;
- break;
- }
- return;
- }
- if ( stop ) mplEventHandling( evStop,0 );
- if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evPlay,0 );
+ default:
+
+ prev = gtkSet(gtkGetPrevPlItem, 0, NULL);
+
+ if (prev) {
+ mplSetFileName(prev->path, prev->name, STREAMTYPE_FILE);
+ mplGotoTheNext = 0;
+ break;
+ }
+
+ return;
+ }
+
+ if (stop)
+ mplEventHandling(evStop, 0);
+
+ if (guiIntfStruct.Playing == 1)
+ mplEventHandling(evPlay, 0);
}
-void mplNext( void )
+void mplNext(void)
{
- int stop = 0;
- plItem * next;
+ int stop = 0;
+ plItem *next;
- if ( guiIntfStruct.Playing == 2 ) return;
- switch ( guiIntfStruct.StreamType )
- {
+ if (guiIntfStruct.Playing == 2)
+ return;
+
+ switch (guiIntfStruct.StreamType) {
#ifdef CONFIG_DVDREAD
- case STREAMTYPE_DVD:
- if ( guiIntfStruct.DVD.current_chapter++ == guiIntfStruct.DVD.chapters )
- {
- guiIntfStruct.DVD.current_chapter=1;
- if ( ++guiIntfStruct.DVD.current_title > guiIntfStruct.DVD.titles ) { guiIntfStruct.DVD.current_title=guiIntfStruct.DVD.titles; stop=1; }
- }
- guiIntfStruct.Track=guiIntfStruct.DVD.current_title;
- break;
+ case STREAMTYPE_DVD:
+
+ if (guiIntfStruct.DVD.current_chapter++ == guiIntfStruct.DVD.chapters) {
+ guiIntfStruct.DVD.current_chapter = 1;
+
+ if (++guiIntfStruct.DVD.current_title > guiIntfStruct.DVD.titles) {
+ guiIntfStruct.DVD.current_title = guiIntfStruct.DVD.titles;
+ stop = 1;
+ }
+ }
+
+ guiIntfStruct.Track = guiIntfStruct.DVD.current_title;
+ break;
+
#endif
#ifdef CONFIG_VCD
- case STREAMTYPE_VCD:
- if ( ++guiIntfStruct.Track > guiIntfStruct.VCDTracks ) { guiIntfStruct.Track=guiIntfStruct.VCDTracks; stop=1; }
- break;
+ case STREAMTYPE_VCD:
+ if (++guiIntfStruct.Track > guiIntfStruct.VCDTracks) {
+ guiIntfStruct.Track = guiIntfStruct.VCDTracks;
+ stop = 1;
+ }
+ break;
+
#endif
- default:
- if ( (next=gtkSet( gtkGetNextPlItem,0,NULL)) )
- {
- mplSetFileName( next->path,next->name,STREAMTYPE_FILE );
- mplGotoTheNext=0;
- break;
- }
- return;
- }
- if ( stop ) mplEventHandling( evStop,0 );
- if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evPlay,0 );
+ default:
+
+ next = gtkSet(gtkGetNextPlItem, 0, NULL);
+
+ if (next) {
+ mplSetFileName(next->path, next->name, STREAMTYPE_FILE);
+ mplGotoTheNext = 0;
+ break;
+ }
+
+ return;
+ }
+
+ if (stop)
+ mplEventHandling(evStop, 0);
+
+ if (guiIntfStruct.Playing == 1)
+ mplEventHandling(evPlay, 0);
}
diff --git a/mplayer/gui/mplayer/play.h b/mplayer/gui/mplayer/play.h
index 8d41a085..38c92f2f 100644
--- a/mplayer/gui/mplayer/play.h
+++ b/mplayer/gui/mplayer/play.h
@@ -21,29 +21,17 @@
extern int mplGotoTheNext;
-void mplEnd( void );
-void mplFullScreen( void );
-void mplPlay( void );
-void mplPause( void );
-void mplState( void );
-void mplPrev( void );
-void mplNext( void );
-void mplCurr( void );
-
-void mplIncAudioBufDelay( void );
-void mplDecAudioBufDelay( void );
-
-void mplRelSeek( float s );
-void mplAbsSeek( float s );
-float mplGetPosition( void );
-
-void mplPlayFork( void );
-void mplSigHandler( int s );
-void mplPlayerThread( void );
-
-void ChangeSkin( char * name );
-void EventHandling( void );
-
-void mplSetFileName( char * dir, char * name, int type );
+void ChangeSkin(char *);
+void mplAbsSeek(float);
+void mplCurr(void);
+void mplEnd(void);
+void mplFullScreen(void);
+void mplNext(void);
+void mplPause(void);
+void mplPlay(void);
+void mplPrev(void);
+void mplRelSeek(float);
+void mplSetFileName(char *, char *, int);
+void mplState(void);
#endif /* MPLAYER_GUI_PLAY_H */
diff --git a/mplayer/gui/mplayer/widgets.c b/mplayer/gui/mplayer/widgets.c
index abfc46f1..9eac5583 100644
--- a/mplayer/gui/mplayer/widgets.c
+++ b/mplayer/gui/mplayer/widgets.c
@@ -86,7 +86,7 @@ void gtkInit( void )
win=gtk_window_new( GTK_WINDOW_TOPLEVEL );
if ( !gtkIcon )
- gtkIcon=gdk_pixmap_colormap_create_from_xpm_d( win->window,gdk_colormap_get_system(),>kIconMask,&win->style->bg[GTK_STATE_NORMAL],MPlayer_mini_xpm );
+ gtkIcon=gdk_pixmap_colormap_create_from_xpm_d( win->window,gdk_colormap_get_system(),>kIconMask,&win->style->bg[GTK_STATE_NORMAL],(gchar **) MPlayer_mini_xpm );
guiIcon=GDK_WINDOW_XWINDOW( gtkIcon );
guiIconMask=GDK_WINDOW_XWINDOW( gtkIconMask );
@@ -185,9 +185,7 @@ void gtkShow( int type,char * param )
ShowSkinBrowser();
// gtkClearList( SkinList );
if ( gtkFillSkinList( sbMPlayerPrefixDir ) &&
- gtkFillSkinList( sbMPlayerPrefixDir_obsolete ) &&
- gtkFillSkinList( sbMPlayerDirInHome ) &&
- gtkFillSkinList( sbMPlayerDirInHome_obsolete ) )
+ gtkFillSkinList( sbMPlayerDirInHome ) )
{
gtkSetDefaultToCList( SkinList,param );
gtk_clist_sort( GTK_CLIST( SkinList ) );
diff --git a/mplayer/gui/mplayer/widgets.h b/mplayer/gui/mplayer/widgets.h
index 3fb178de..46cc20ba 100644
--- a/mplayer/gui/mplayer/widgets.h
+++ b/mplayer/gui/mplayer/widgets.h
@@ -52,8 +52,6 @@ extern int gtkPopupMenuParam;
extern char * sbMPlayerDirInHome;
extern char * sbMPlayerPrefixDir;
-extern char * sbMPlayerDirInHome_obsolete;
-extern char * sbMPlayerPrefixDir_obsolete;
extern GdkPixmap * gtkIcon;
extern GdkBitmap * gtkIconMask;
diff --git a/mplayer/gui/skin/cut.c b/mplayer/gui/skin/cut.c
index 536b1720..b1bda822 100644
--- a/mplayer/gui/skin/cut.c
+++ b/mplayer/gui/skin/cut.c
@@ -16,39 +16,33 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include
#include
+#include
#include "cut.h"
-void cutItem( char * in,char * out,char sep,int num )
+void cutItemString(char *in, char *out, char sep, int num, size_t maxout)
{
- int i,n,c;
- for ( c=0,n=0,i=0;i= num && in[i] != sep ) out[c++]=in[i];
- if ( n >= num && in[i+1] == sep ) { out[c]=0; return; }
- }
- out[c]=0;
-}
+ int n;
+ unsigned int i, c;
-int cutItemToInt( char * in,char sep,int num )
-{
- char tmp[512];
- cutItem( in,tmp,sep,num );
- return atoi( tmp );
-}
+ for (c = 0, n = 0, i = 0; i < strlen(in); i++) {
+ if (in[i] == sep)
+ n++;
+ if (n >= num && in[i] != sep && c + 1 < maxout)
+ out[c++] = in[i];
+ if (n >= num && in[i + 1] == sep)
+ break;
+ }
-float cutItemToFloat( char * in,char sep,int num )
-{
- char tmp[512];
- cutItem( in,tmp,sep,num );
- return atof( tmp );
+ if (c < maxout)
+ out[c] = 0;
}
-void cutChunk( char * in,char * s1 )
+int cutItemToInt(char *in, char sep, int num)
{
- cutItem( in,s1,'=',0 );
- memmove( in,strchr( in,'=' )+1,strlen( in ) - strlen( s1 ) );
+ char tmp[64];
+
+ cutItem(in, tmp, sep, num);
+ return atoi(tmp);
}
diff --git a/mplayer/gui/skin/cut.h b/mplayer/gui/skin/cut.h
index 5aff48d8..172db7e3 100644
--- a/mplayer/gui/skin/cut.h
+++ b/mplayer/gui/skin/cut.h
@@ -19,9 +19,11 @@
#ifndef MPLAYER_GUI_CUT_H
#define MPLAYER_GUI_CUT_H
-void cutItem( char * in, char * out, char sep, int num );
-int cutItemToInt( char * in, char sep, int num );
-float cutItemToFloat( char * in, char sep, int num );
-void cutChunk( char * in, char * s1 );
+#include
+
+#define cutItem(in, out, sep, num) cutItemString(in, out, sep, num, sizeof(out))
+
+void cutItemString(char *, char *, char, int, size_t);
+int cutItemToInt(char *, char, int);
#endif /* MPLAYER_GUI_CUT_H */
diff --git a/mplayer/gui/skin/font.c b/mplayer/gui/skin/font.c
index 74322d4c..4ae4b3a1 100644
--- a/mplayer/gui/skin/font.c
+++ b/mplayer/gui/skin/font.c
@@ -16,254 +16,391 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include
+#include
#include
-#include