Compare commits
290 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c2eb668617 | ||
![]() |
c9c223ba00 | ||
![]() |
9d0ff6436e | ||
![]() |
02b7b125b5 | ||
![]() |
5643668308 | ||
![]() |
2d18e7f3ef | ||
![]() |
f1b5830182 | ||
![]() |
c588316555 | ||
![]() |
afd1f61944 | ||
![]() |
16a9c5ea9e | ||
![]() |
83fb31a76d | ||
![]() |
fc5b32877a | ||
![]() |
10e023c4fa | ||
![]() |
27a3a59428 | ||
![]() |
8ab849cddc | ||
![]() |
5191b00155 | ||
![]() |
1131e7a1a4 | ||
![]() |
26becbcd2a | ||
![]() |
366cdd3548 | ||
![]() |
e3b08b3ad4 | ||
![]() |
fa16440659 | ||
![]() |
c36fd16aaa | ||
![]() |
8c5897632a | ||
![]() |
b34fce9c54 | ||
![]() |
742f9aa879 | ||
![]() |
79041d92ee | ||
![]() |
82cebc0e05 | ||
![]() |
09abca6802 | ||
![]() |
43d64829e6 | ||
![]() |
4a479fd3e6 | ||
![]() |
4f41717d01 | ||
![]() |
6896dcbf5f | ||
![]() |
14404170b9 | ||
![]() |
e9e42beed2 | ||
![]() |
abd6decd55 | ||
![]() |
0385c824f1 | ||
![]() |
c4e764aa69 | ||
![]() |
9d02e38d3f | ||
![]() |
30cf47c6f0 | ||
![]() |
b45cd17d29 | ||
![]() |
26b6d70c72 | ||
![]() |
32919db4fb | ||
![]() |
56f44c26f0 | ||
![]() |
fe87a40de6 | ||
![]() |
0f6e309b97 | ||
![]() |
96e13c9897 | ||
![]() |
e72c0a0466 | ||
![]() |
dfddefa13a | ||
![]() |
ce94955b3c | ||
![]() |
dde95268cc | ||
![]() |
d20ac551a8 | ||
![]() |
352b0969e2 | ||
![]() |
b479b42b26 | ||
![]() |
36cab9c408 | ||
![]() |
34592d04fb | ||
![]() |
544accc895 | ||
![]() |
f41622ecb4 | ||
![]() |
fc8eb4c1f9 | ||
![]() |
02bae9f013 | ||
![]() |
5cb2a1c3f0 | ||
![]() |
a221c9bd76 | ||
![]() |
b2583c2b62 | ||
![]() |
bd553941ae | ||
![]() |
e0aa76d38a | ||
![]() |
a014b9614e | ||
![]() |
31c21d2f69 | ||
![]() |
3cd1c8653b | ||
![]() |
194485cfba | ||
![]() |
81cfe39113 | ||
![]() |
ef0c503d37 | ||
![]() |
1103aec1df | ||
![]() |
b40ab81d1f | ||
![]() |
314f055c29 | ||
![]() |
2c566744c4 | ||
![]() |
adad1ba5d8 | ||
![]() |
a80a7131d1 | ||
![]() |
3ab63abbd4 | ||
![]() |
d2c76782e0 | ||
![]() |
4dc8b4d7d0 | ||
![]() |
9ff0467566 | ||
![]() |
4407b38b28 | ||
![]() |
8caaf260a6 | ||
![]() |
e1f51bbd1f | ||
![]() |
4b7c149306 | ||
![]() |
e8919d6522 | ||
![]() |
b017785fa5 | ||
![]() |
01507eb1f8 | ||
![]() |
938ff93710 | ||
![]() |
0c88d539f8 | ||
![]() |
e39a992bd1 | ||
![]() |
72a12f61ef | ||
![]() |
30ae080e9d | ||
![]() |
dca463b728 | ||
![]() |
25b462cab9 | ||
![]() |
7c6a8afa7e | ||
![]() |
b052525f9b | ||
![]() |
90c7bfb9be | ||
![]() |
7bdd348e58 | ||
![]() |
af3d003658 | ||
![]() |
c00beff5e0 | ||
![]() |
57a43142ba | ||
![]() |
99905118a8 | ||
![]() |
dcf560204c | ||
![]() |
5b0e2eb041 | ||
![]() |
d461e077a5 | ||
![]() |
9a884b7b97 | ||
![]() |
9abe0bfb7f | ||
![]() |
13682b48e9 | ||
![]() |
f25e6e0c25 | ||
![]() |
80239a8bb1 | ||
![]() |
26bbc1c242 | ||
![]() |
efe259a27e | ||
![]() |
49f11e12d5 | ||
![]() |
d130fae519 | ||
![]() |
dde996bf99 | ||
![]() |
cad2958fd7 | ||
![]() |
29d61d73b1 | ||
![]() |
9a6a710998 | ||
![]() |
daaef403d1 | ||
![]() |
207f5a138a | ||
![]() |
e9c8a9aaa6 | ||
![]() |
7b7d8b8794 | ||
![]() |
90d6b563fe | ||
![]() |
dce2f820e9 | ||
![]() |
4aab3f868f | ||
![]() |
48609236da | ||
![]() |
d8fe695779 | ||
![]() |
0f42e06651 | ||
![]() |
230c4c6ad9 | ||
![]() |
f4489c9558 | ||
![]() |
0e5d9fe2a7 | ||
![]() |
9ae2aaea50 | ||
![]() |
2513314912 | ||
![]() |
e727cbf0be | ||
![]() |
bcc25353cf | ||
![]() |
6a10263f16 | ||
![]() |
bcc6429c01 | ||
![]() |
bdb219435e | ||
![]() |
a7338ae8ac | ||
![]() |
6776c2c04f | ||
![]() |
facd3dbc6e | ||
![]() |
8796c3b7d3 | ||
![]() |
7430f3064f | ||
![]() |
eac281b06c | ||
![]() |
b5210f4eae | ||
![]() |
10379d50be | ||
![]() |
cd874cf8e6 | ||
![]() |
82a3e469c6 | ||
![]() |
f859fed03d | ||
![]() |
991e6fa35b | ||
![]() |
09dca51066 | ||
![]() |
40de74d0eb | ||
![]() |
e2811c2ede | ||
![]() |
25d14b716a | ||
![]() |
f1de93dec3 | ||
![]() |
738d68de85 | ||
![]() |
00ecce5c8b | ||
![]() |
6ba07e9948 | ||
![]() |
125bea15d1 | ||
![]() |
70e3cc282b | ||
![]() |
242df26b44 | ||
![]() |
46c2dba20e | ||
![]() |
3caa6a5a57 | ||
![]() |
bf08665e2e | ||
![]() |
c4f5f4dbd3 | ||
![]() |
29df24252a | ||
![]() |
b920c1d5ad | ||
![]() |
2b9ee7d5b9 | ||
![]() |
f800cacada | ||
![]() |
5227eac5b0 | ||
![]() |
bb40f8f5e2 | ||
![]() |
ad8bf22086 | ||
![]() |
7f8804296d | ||
![]() |
f67e75b5dc | ||
![]() |
35e63f35b0 | ||
![]() |
3bfb7a2537 | ||
![]() |
4a1e7a6fb7 | ||
![]() |
ff1e982205 | ||
![]() |
bb116e6ba3 | ||
![]() |
ebe356bf1c | ||
![]() |
30099413ec | ||
![]() |
186e0ff067 | ||
![]() |
2642ad9f55 | ||
![]() |
95ddd2227b | ||
![]() |
3faebed6fa | ||
![]() |
3aee1fa5b6 | ||
![]() |
89a9c84ebb | ||
![]() |
0adde39e04 | ||
![]() |
03ae616b19 | ||
![]() |
830c3058ff | ||
![]() |
b12c5cbbb2 | ||
![]() |
82c96b5ad8 | ||
![]() |
3e4b957847 | ||
![]() |
cbabbe8220 | ||
![]() |
80122a3af3 | ||
![]() |
a475755b3a | ||
![]() |
66030e8133 | ||
![]() |
46f8d838b3 | ||
![]() |
bc3648d4b4 | ||
![]() |
27e6b4a3ff | ||
![]() |
b82860caa7 | ||
![]() |
3d05625136 | ||
![]() |
ddd3301bad | ||
![]() |
123981930f | ||
![]() |
3171e2360a | ||
![]() |
3533a850e7 | ||
![]() |
6d56bc9a6d | ||
![]() |
2c5e1d0933 | ||
![]() |
b37b83214a | ||
![]() |
6d7ab09788 | ||
![]() |
227cfc1f10 | ||
![]() |
416847d195 | ||
![]() |
bd4ad1a1d5 | ||
![]() |
6230de03aa | ||
![]() |
45acc228a6 | ||
![]() |
d37fac6dbb | ||
![]() |
7940306a47 | ||
![]() |
eabefe83f4 | ||
![]() |
eaa79b79b2 | ||
![]() |
c761379825 | ||
![]() |
ea3309eba7 | ||
![]() |
1c1e252cd1 | ||
![]() |
ca2c9d6b9b | ||
![]() |
fa6b99d351 | ||
![]() |
d79cb6947e | ||
![]() |
5aa4b29bbe | ||
![]() |
e4cbd0d6e5 | ||
![]() |
0ede7b5344 | ||
![]() |
5b933be089 | ||
![]() |
f2693e98b4 | ||
![]() |
c3861e14ce | ||
![]() |
daa5a988e2 | ||
![]() |
db67b7c31b | ||
![]() |
a643a47d41 | ||
![]() |
23af29e882 | ||
![]() |
7d995cd1b8 | ||
![]() |
72a58c0772 | ||
![]() |
d525423006 | ||
![]() |
4b476e6aa4 | ||
![]() |
124c78fd44 | ||
![]() |
a1ab3300c8 | ||
![]() |
1af235f6b3 | ||
![]() |
82031e41f8 | ||
![]() |
222e7549a7 | ||
![]() |
eb2244ece9 | ||
![]() |
b967c10029 | ||
![]() |
7ff4cd2acc | ||
![]() |
c4149c4d54 | ||
![]() |
8ad2f45964 | ||
![]() |
5df52b0131 | ||
![]() |
596d3e20ae | ||
![]() |
00d5ff6431 | ||
![]() |
437179e9c8 | ||
![]() |
031d3b66c2 | ||
![]() |
b76871d870 | ||
![]() |
15ae305007 | ||
![]() |
3c72204ae0 | ||
![]() |
ba21499648 | ||
![]() |
7933039ade | ||
![]() |
4015829acc | ||
![]() |
39dc4a6bb3 | ||
![]() |
a6a2d8eb8f | ||
![]() |
58556826a8 | ||
![]() |
bc2c9a479a | ||
![]() |
9cc22be032 | ||
![]() |
33e1bca651 | ||
![]() |
9841617b7f | ||
![]() |
2897481f64 | ||
![]() |
646c564de5 | ||
![]() |
cd6281abef | ||
![]() |
697be8173b | ||
![]() |
1853d8bb7a | ||
![]() |
1779cd7695 | ||
![]() |
bb4820727f | ||
![]() |
affc7687d3 | ||
![]() |
3569470693 | ||
![]() |
1d1df82093 | ||
![]() |
de187e3e9e | ||
![]() |
7754d48381 | ||
![]() |
63169474b3 | ||
![]() |
b3f106cb1f | ||
![]() |
9b6ccf0f24 | ||
![]() |
298d66c8de | ||
![]() |
4be1b68d52 | ||
![]() |
92edc13d69 | ||
![]() |
c9f015f1c6 | ||
![]() |
db6b2ca0b3 | ||
![]() |
3503ec8461 | ||
![]() |
ecc5e42d92 | ||
![]() |
f87ce262f6 |
@@ -1,9 +1,6 @@
|
||||
Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
version <next>
|
||||
|
||||
|
||||
version 2.2:
|
||||
|
||||
- HNM version 4 demuxer and video decoder
|
||||
@@ -31,6 +28,7 @@ version 2.2:
|
||||
- Support DNx444
|
||||
- libx265 encoder
|
||||
- dejudder filter
|
||||
- Autodetect VDA like all other hardware accelerations
|
||||
|
||||
|
||||
version 2.1:
|
||||
|
11
configure
vendored
11
configure
vendored
@@ -149,7 +149,7 @@ Component options:
|
||||
Hardware accelerators:
|
||||
--disable-dxva2 disable DXVA2 code [autodetect]
|
||||
--disable-vaapi disable VAAPI code [autodetect]
|
||||
--enable-vda enable VDA code
|
||||
--disable-vda disable VDA code [autodetect]
|
||||
--disable-vdpau disable VDPAU code [autodetect]
|
||||
|
||||
Individual component options:
|
||||
@@ -2504,7 +2504,7 @@ enable static
|
||||
enable swscale_alpha
|
||||
|
||||
# Enable hwaccels by default.
|
||||
enable dxva2 vaapi vdpau xvmc
|
||||
enable dxva2 vaapi vda vdpau xvmc
|
||||
|
||||
# build settings
|
||||
SHFLAGS='-shared -Wl,-soname,$$(@F)'
|
||||
@@ -3324,6 +3324,9 @@ if test -n "$sysroot"; then
|
||||
gcc|llvm_gcc|clang)
|
||||
add_cppflags --sysroot="$sysroot"
|
||||
add_ldflags --sysroot="$sysroot"
|
||||
# On Darwin --sysroot may be ignored, -isysroot always affects headers and linking
|
||||
add_cppflags -isysroot "$sysroot"
|
||||
add_ldflags -isysroot "$sysroot"
|
||||
;;
|
||||
tms470)
|
||||
add_cppflags -I"$sysinclude"
|
||||
@@ -3661,6 +3664,10 @@ case "$arch" in
|
||||
check_64bit ppc ppc64 'sizeof(void *) > 4'
|
||||
spic=$shared
|
||||
;;
|
||||
s390)
|
||||
check_64bit s390 s390x 'sizeof(void *) > 4'
|
||||
spic=$shared
|
||||
;;
|
||||
sparc)
|
||||
check_64bit sparc sparc64 'sizeof(void *) > 4'
|
||||
spic=$shared
|
||||
|
@@ -15,6 +15,9 @@ libavutil: 2012-10-22
|
||||
|
||||
API changes, most recent first:
|
||||
|
||||
2014-03-18 - e9c8a9a - lsws 2.5.102
|
||||
Make gray16 full-scale.
|
||||
|
||||
2014-xx-xx - xxxxxxx - lavu 53.05.0 - frame.h
|
||||
Add av_frame_copy() for copying the frame data.
|
||||
|
||||
|
@@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER =
|
||||
PROJECT_NUMBER = 2.2.2
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify a logo or icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
@@ -62,7 +62,7 @@ AC-3 audio decoder.
|
||||
This decoder implements part of ATSC A/52:2010 and ETSI TS 102 366, as well as
|
||||
the undocumented RealAudio 3 (a.k.a. dnet).
|
||||
|
||||
@subsubsection AC-3 Decoder Options
|
||||
@subsection AC-3 Decoder Options
|
||||
|
||||
@table @option
|
||||
|
||||
|
@@ -1271,7 +1271,7 @@ Requires the presence of the libtheora headers and library during
|
||||
configuration. You need to explicitly configure the build with
|
||||
@code{--enable-libtheora}.
|
||||
|
||||
For more informations about the libtheora project see
|
||||
For more information about the libtheora project see
|
||||
@url{http://www.theora.org/}.
|
||||
|
||||
@subsection Options
|
||||
|
@@ -119,8 +119,10 @@ int main(int argc, char *argv[])
|
||||
end:
|
||||
avformat_close_input(&fmt_ctx);
|
||||
/* note: the internal buffer could have changed, and be != avio_ctx_buffer */
|
||||
av_freep(&avio_ctx->buffer);
|
||||
av_freep(&avio_ctx);
|
||||
if (avio_ctx) {
|
||||
av_freep(&avio_ctx->buffer);
|
||||
av_freep(&avio_ctx);
|
||||
}
|
||||
av_file_unmap(buffer, buffer_size);
|
||||
|
||||
if (ret < 0) {
|
||||
|
@@ -111,7 +111,7 @@ must be configured in the stream configuration. They are sent to
|
||||
the @command{ffmpeg} encoders.
|
||||
|
||||
The @command{ffmpeg} @option{override_ffserver} commandline option
|
||||
allows to override the encoding parameters set by the server.
|
||||
allows one to override the encoding parameters set by the server.
|
||||
|
||||
Multiple streams can be connected to the same feed.
|
||||
|
||||
|
@@ -162,6 +162,27 @@ libzvbi is licensed under the GNU General Public License Version 2 or later
|
||||
you must upgrade FFmpeg's license to GPL in order to use it.
|
||||
@end float
|
||||
|
||||
@section AviSynth
|
||||
|
||||
FFmpeg can read AviSynth scripts as input. To enable support, pass
|
||||
@code{--enable-avisynth} to configure. The correct headers are
|
||||
included in compat/avisynth/, which allows the user to enable support
|
||||
without needing to search for these headers themselves.
|
||||
|
||||
For Windows, supported AviSynth variants are
|
||||
@url{http://avisynth.nl, AviSynth 2.5 or 2.6} for 32-bit builds and
|
||||
@url{http://avs-plus.net, AviSynth+ 0.1} for 32-bit and 64-bit builds.
|
||||
|
||||
For Linux and OS X, the supported AviSynth variant is
|
||||
@url{https://github.com/avxsynth/avxsynth, AvxSynth}.
|
||||
|
||||
@float NOTE
|
||||
AviSynth and AvxSynth are loaded dynamically. Distributors can build FFmpeg
|
||||
with @code{--enable-avisynth}, and the binaries will work regardless of the
|
||||
end user having AviSynth or AvxSynth installed - they'll only need to be
|
||||
installed to use AviSynth scripts (obviously).
|
||||
@end float
|
||||
|
||||
|
||||
@chapter Supported File Formats, Codecs or Features
|
||||
|
||||
|
@@ -216,7 +216,7 @@ OpenGL output device.
|
||||
|
||||
To enable this output device you need to configure FFmpeg with @code{--enable-opengl}.
|
||||
|
||||
Device allows to render to OpenGL context.
|
||||
This output device allows one to render to OpenGL context.
|
||||
Context may be provided by application or default SDL window is created.
|
||||
|
||||
When device renders to external context, application must implement handlers for following messages:
|
||||
|
@@ -51,8 +51,9 @@ The toolchain provided with Xcode is sufficient to build the basic
|
||||
unacelerated code.
|
||||
|
||||
Mac OS X on PowerPC or ARM (iPhone) requires a preprocessor from
|
||||
@url{https://github.com/FFmpeg/gas-preprocessor} or
|
||||
@url{http://github.com/yuvi/gas-preprocessor} to build the optimized
|
||||
assembler functions. Just download the Perl script and put it somewhere
|
||||
assembler functions. Put the Perl script somewhere
|
||||
in your PATH, FFmpeg's configure will pick it up automatically.
|
||||
|
||||
Mac OS X on amd64 and x86 requires @command{yasm} to build most of the
|
||||
|
@@ -213,7 +213,7 @@ m3u8 files.
|
||||
|
||||
HTTP (Hyper Text Transfer Protocol).
|
||||
|
||||
This protocol accepts the following options.
|
||||
This protocol accepts the following options:
|
||||
|
||||
@table @option
|
||||
@item seekable
|
||||
@@ -223,32 +223,33 @@ if set to -1 it will try to autodetect if it is seekable. Default
|
||||
value is -1.
|
||||
|
||||
@item chunked_post
|
||||
If set to 1 use chunked transfer-encoding for posts, default is 1.
|
||||
If set to 1 use chunked Transfer-Encoding for posts, default is 1.
|
||||
|
||||
@item content_type
|
||||
Set a specific content type for the POST messages.
|
||||
|
||||
@item headers
|
||||
Set custom HTTP headers, can override built in default headers. The
|
||||
value must be a string encoding the headers.
|
||||
|
||||
@item content_type
|
||||
Force a content type.
|
||||
|
||||
@item user-agent
|
||||
Override User-Agent header. If not specified the protocol will use a
|
||||
string describing the libavformat build.
|
||||
|
||||
@item multiple_requests
|
||||
Use persistent connections if set to 1. By default it is 0.
|
||||
Use persistent connections if set to 1, default is 0.
|
||||
|
||||
@item post_data
|
||||
Set custom HTTP post data.
|
||||
|
||||
@item user-agent
|
||||
@item user_agent
|
||||
Override the User-Agent header. If not specified the protocol will use a
|
||||
string describing the libavformat build. ("Lavf/<version>")
|
||||
|
||||
@item timeout
|
||||
Set timeout of socket I/O operations used by the underlying low level
|
||||
operation. By default it is set to -1, which means that the timeout is
|
||||
not specified.
|
||||
|
||||
@item mime_type
|
||||
Set MIME type.
|
||||
Export the MIME type.
|
||||
|
||||
@item icy
|
||||
If set to 1 request ICY (SHOUTcast) metadata from the server. If the server
|
||||
@@ -257,17 +258,25 @@ the @option{icy_metadata_headers} and @option{icy_metadata_packet} options.
|
||||
The default is 0.
|
||||
|
||||
@item icy_metadata_headers
|
||||
If the server supports ICY metadata, this contains the ICY specific HTTP reply
|
||||
headers, separated with newline characters.
|
||||
If the server supports ICY metadata, this contains the ICY-specific HTTP reply
|
||||
headers, separated by newline characters.
|
||||
|
||||
@item icy_metadata_packet
|
||||
If the server supports ICY metadata, and @option{icy} was set to 1, this
|
||||
contains the last non-empty metadata packet sent by the server.
|
||||
contains the last non-empty metadata packet sent by the server. It should be
|
||||
polled in regular intervals by applications interested in mid-stream metadata
|
||||
updates.
|
||||
|
||||
@item cookies
|
||||
Set the cookies to be sent in future requests. The format of each cookie is the
|
||||
same as the value of a Set-Cookie HTTP response field. Multiple cookies can be
|
||||
delimited by a newline character.
|
||||
|
||||
@item offset
|
||||
Set initial byte offset.
|
||||
|
||||
@item end_offset
|
||||
Try to limit the request to bytes preceding this offset.
|
||||
@end table
|
||||
|
||||
@subsection HTTP Cookies
|
||||
|
@@ -35,7 +35,7 @@ Select nearest neighbor rescaling algorithm.
|
||||
@item area
|
||||
Select averaging area rescaling algorithm.
|
||||
|
||||
@item bicubiclin
|
||||
@item bicublin
|
||||
Select bicubic scaling algorithm for the luma component, bilinear for
|
||||
chroma components.
|
||||
|
||||
|
@@ -327,10 +327,11 @@ die "No filename or title\n" unless defined $fn && defined $tl;
|
||||
$chapters{NAME} = "$fn \- $tl\n";
|
||||
$chapters{FOOTNOTES} .= "=back\n" if exists $chapters{FOOTNOTES};
|
||||
|
||||
# always use utf8
|
||||
print "=encoding utf8\n\n";
|
||||
|
||||
unshift @chapters_sequence, "NAME";
|
||||
for $chapter (@chapters_sequence) {
|
||||
# always use utf8
|
||||
print "=encoding utf8\n";
|
||||
if (exists $chapters{$chapter}) {
|
||||
$head = uc($chapter);
|
||||
print "=head1 $head\n\n";
|
||||
|
4
ffmpeg.c
4
ffmpeg.c
@@ -323,7 +323,7 @@ sigterm_handler(int sig)
|
||||
received_nb_signals++;
|
||||
term_exit();
|
||||
if(received_nb_signals > 3)
|
||||
exit_program(123);
|
||||
exit(123);
|
||||
}
|
||||
|
||||
void term_init(void)
|
||||
@@ -514,6 +514,8 @@ static void ffmpeg_cleanup(int ret)
|
||||
if (received_sigterm) {
|
||||
av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n",
|
||||
(int) received_sigterm);
|
||||
} else if (ret) {
|
||||
av_log(NULL, AV_LOG_INFO, "Conversion failed!\n");
|
||||
}
|
||||
term_exit();
|
||||
}
|
||||
|
@@ -44,12 +44,15 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum AVPixelFo
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(target);
|
||||
int has_alpha = desc ? desc->nb_components % 2 == 0 : 0;
|
||||
enum AVPixelFormat best= AV_PIX_FMT_NONE;
|
||||
const enum AVPixelFormat mjpeg_formats[] = { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };
|
||||
const enum AVPixelFormat ljpeg_formats[] = { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };
|
||||
|
||||
if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
|
||||
if (st->codec->codec_id == AV_CODEC_ID_MJPEG) {
|
||||
p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };
|
||||
p = mjpeg_formats;
|
||||
} else if (st->codec->codec_id == AV_CODEC_ID_LJPEG) {
|
||||
p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };
|
||||
p =ljpeg_formats;
|
||||
}
|
||||
}
|
||||
for (; *p != AV_PIX_FMT_NONE; p++) {
|
||||
|
@@ -1821,7 +1821,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
||||
|
||||
/* subtitles: pick first */
|
||||
MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s");
|
||||
if (!o->subtitle_disable && (oc->oformat->subtitle_codec != AV_CODEC_ID_NONE || subtitle_codec_name)) {
|
||||
if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) {
|
||||
for (i = 0; i < nb_input_streams; i++)
|
||||
if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
||||
new_subtitle_stream(o, oc, i);
|
||||
|
@@ -246,6 +246,7 @@ static char *value_string(char *buf, int buf_size, struct unit_value uv)
|
||||
vald /= pow(10, index * 3);
|
||||
prefix_string = decimal_unit_prefixes[index];
|
||||
}
|
||||
vali = vald;
|
||||
}
|
||||
|
||||
if (show_float || (use_value_prefix && vald != (long long int)vald))
|
||||
@@ -336,7 +337,7 @@ static const AVOption writer_options[] = {
|
||||
{ "replace", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = WRITER_STRING_VALIDATION_REPLACE}, .unit = "sv" },
|
||||
{ "fail", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = WRITER_STRING_VALIDATION_FAIL}, .unit = "sv" },
|
||||
{ "string_validation_replacement", "set string validation replacement string", OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, {.str=""}},
|
||||
{ "svr", "set string validation replacement string", OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, {.str=""}},
|
||||
{ "svr", "set string validation replacement string", OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, {.str="\xEF\xBF\xBD"}},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
@@ -119,7 +119,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
}
|
||||
|
||||
if ((avctx->bits_per_coded_sample & 0x1f) <= 8) {
|
||||
if (avctx->bits_per_coded_sample <= 8) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt,
|
||||
AV_PKT_DATA_PALETTE,
|
||||
NULL);
|
||||
|
@@ -26,7 +26,6 @@ OBJS = allcodecs.o \
|
||||
options.o \
|
||||
parser.o \
|
||||
raw.o \
|
||||
rawdec.o \
|
||||
resample.o \
|
||||
resample2.o \
|
||||
utils.o \
|
||||
|
@@ -471,9 +471,11 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_
|
||||
* @param[out] coded_samples set to the number of samples as coded in the
|
||||
* packet, or 0 if the codec does not encode the
|
||||
* number of samples in each frame.
|
||||
* @param[out] approx_nb_samples set to non-zero if the number of samples
|
||||
* returned is an approximation.
|
||||
*/
|
||||
static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
int buf_size, int *coded_samples)
|
||||
int buf_size, int *coded_samples, int *approx_nb_samples)
|
||||
{
|
||||
ADPCMDecodeContext *s = avctx->priv_data;
|
||||
int nb_samples = 0;
|
||||
@@ -482,6 +484,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
int header_size;
|
||||
|
||||
*coded_samples = 0;
|
||||
*approx_nb_samples = 0;
|
||||
|
||||
if(ch <= 0)
|
||||
return 0;
|
||||
@@ -552,10 +555,12 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
case AV_CODEC_ID_ADPCM_EA_R2:
|
||||
header_size = 4 + 5 * ch;
|
||||
*coded_samples = bytestream2_get_le32(gb);
|
||||
*approx_nb_samples = 1;
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_EA_R3:
|
||||
header_size = 4 + 5 * ch;
|
||||
*coded_samples = bytestream2_get_be32(gb);
|
||||
*approx_nb_samples = 1;
|
||||
break;
|
||||
}
|
||||
*coded_samples -= *coded_samples % 28;
|
||||
@@ -663,11 +668,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
int16_t **samples_p;
|
||||
int st; /* stereo */
|
||||
int count1, count2;
|
||||
int nb_samples, coded_samples, ret;
|
||||
int nb_samples, coded_samples, approx_nb_samples, ret;
|
||||
GetByteContext gb;
|
||||
|
||||
bytestream2_init(&gb, buf, buf_size);
|
||||
nb_samples = get_nb_samples(avctx, &gb, buf_size, &coded_samples);
|
||||
nb_samples = get_nb_samples(avctx, &gb, buf_size, &coded_samples, &approx_nb_samples);
|
||||
if (nb_samples <= 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -683,7 +688,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
/* use coded_samples when applicable */
|
||||
/* it is always <= nb_samples, so the output buffer will be large enough */
|
||||
if (coded_samples) {
|
||||
if (coded_samples != nb_samples)
|
||||
if (!approx_nb_samples && coded_samples != nb_samples)
|
||||
av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
|
||||
frame->nb_samples = nb_samples = coded_samples;
|
||||
}
|
||||
@@ -917,6 +922,9 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
*samples++ = c->status[0].predictor + c->status[1].predictor;
|
||||
*samples++ = c->status[0].predictor - c->status[1].predictor;
|
||||
}
|
||||
|
||||
if ((bytestream2_tell(&gb) & 1))
|
||||
bytestream2_skip(&gb, 1);
|
||||
break;
|
||||
}
|
||||
case AV_CODEC_ID_ADPCM_IMA_ISS:
|
||||
|
@@ -144,10 +144,11 @@ function ff_put_pixels8_y2_armv6, export=1
|
||||
eor r7, r5, r7
|
||||
uadd8 r10, r10, r6
|
||||
and r7, r7, r12
|
||||
ldr_pre r6, r1, r2
|
||||
ldrc_pre ne, r6, r1, r2
|
||||
uadd8 r11, r11, r7
|
||||
strd_post r8, r9, r0, r2
|
||||
ldr r7, [r1, #4]
|
||||
it ne
|
||||
ldrne r7, [r1, #4]
|
||||
strd_post r10, r11, r0, r2
|
||||
bne 1b
|
||||
|
||||
@@ -196,9 +197,10 @@ function ff_put_pixels8_y2_no_rnd_armv6, export=1
|
||||
uhadd8 r9, r5, r7
|
||||
ldr r5, [r1, #4]
|
||||
uhadd8 r12, r4, r6
|
||||
ldr_pre r6, r1, r2
|
||||
ldrc_pre ne, r6, r1, r2
|
||||
uhadd8 r14, r5, r7
|
||||
ldr r7, [r1, #4]
|
||||
it ne
|
||||
ldrne r7, [r1, #4]
|
||||
stm r0, {r8,r9}
|
||||
add r0, r0, r2
|
||||
stm r0, {r12,r14}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
void ff_vp3_idct_put_neon(uint8_t *dest, int line_size, int16_t *data);
|
||||
void ff_vp3_idct_add_neon(uint8_t *dest, int line_size, int16_t *data);
|
||||
void ff_vp3_idct_dc_add_neon(uint8_t *dest, int line_size, const int16_t *data);
|
||||
void ff_vp3_idct_dc_add_neon(uint8_t *dest, int line_size, int16_t *data);
|
||||
|
||||
void ff_vp3_v_loop_filter_neon(uint8_t *, int, int *);
|
||||
void ff_vp3_h_loop_filter_neon(uint8_t *, int, int *);
|
||||
|
@@ -1204,7 +1204,7 @@ function ff_put_vp8_\name\size\()_\hv\()_armv6, export=1
|
||||
mov r4, #\size
|
||||
stm r12, {r4, r5}
|
||||
orr r12, r6, r7
|
||||
b vp8_put_\name\()_\hv\()_armv6 + 4
|
||||
b bl_put_\name\()_\hv\()_armv6
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
@@ -1300,6 +1300,7 @@ vp8_mc_hv bilin, 4, h, v, 2
|
||||
|
||||
function vp8_put_epel_h6_armv6
|
||||
push {r1, r4-r11, lr}
|
||||
bl_put_epel_h6_armv6:
|
||||
sub r2, r2, #2
|
||||
movrel lr, sixtap_filters_13245600 - 16
|
||||
add lr, lr, r12, lsl #3
|
||||
@@ -1358,6 +1359,7 @@ endfunc
|
||||
|
||||
function vp8_put_epel_v6_armv6
|
||||
push {r1, r4-r11, lr}
|
||||
bl_put_epel_v6_armv6:
|
||||
movrel lr, sixtap_filters_13245600 - 16
|
||||
add lr, lr, r12, lsl #3
|
||||
str r3, [sp, #48]
|
||||
@@ -1437,6 +1439,7 @@ endfunc
|
||||
|
||||
function vp8_put_epel_h4_armv6
|
||||
push {r1, r4-r11, lr}
|
||||
bl_put_epel_h4_armv6:
|
||||
subs r2, r2, #1
|
||||
movrel lr, fourtap_filters_1324 - 4
|
||||
add lr, lr, r12, lsl #2
|
||||
@@ -1483,6 +1486,7 @@ endfunc
|
||||
|
||||
function vp8_put_epel_v4_armv6
|
||||
push {r1, r4-r11, lr}
|
||||
bl_put_epel_v4_armv6:
|
||||
movrel lr, fourtap_filters_1324 - 4
|
||||
add lr, lr, r12, lsl #2
|
||||
ldm lr, {r5, r6}
|
||||
@@ -1544,6 +1548,7 @@ endfunc
|
||||
|
||||
function vp8_put_bilin_h_armv6
|
||||
push {r1, r4-r11, lr}
|
||||
bl_put_bilin_h_armv6:
|
||||
rsb r5, r12, r12, lsl #16
|
||||
ldr r12, [sp, #44]
|
||||
sub r3, r3, r4
|
||||
@@ -1589,6 +1594,7 @@ endfunc
|
||||
|
||||
function vp8_put_bilin_v_armv6
|
||||
push {r1, r4-r11, lr}
|
||||
bl_put_bilin_v_armv6:
|
||||
rsb r5, r12, r12, lsl #16
|
||||
ldr r12, [sp, #44]
|
||||
add r5, r5, #8
|
||||
|
@@ -1370,7 +1370,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
|
||||
* Decode VQ encoded high frequencies
|
||||
*/
|
||||
if (s->subband_activity[k] > s->vq_start_subband[k]) {
|
||||
if (!s->debug_flag & 0x01) {
|
||||
if (!(s->debug_flag & 0x01)) {
|
||||
av_log(s->avctx, AV_LOG_DEBUG,
|
||||
"Stream with high frequencies VQ coding\n");
|
||||
s->debug_flag |= 0x01;
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#ifndef AVCODEC_DIRAC_ARITH_H
|
||||
#define AVCODEC_DIRAC_ARITH_H
|
||||
|
||||
#include "libavutil/x86/asm.h"
|
||||
#include "bytestream.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
@@ -134,7 +135,7 @@ static inline int dirac_get_arith_bit(DiracArith *c, int ctx)
|
||||
|
||||
range_times_prob = (c->range * prob_zero) >> 16;
|
||||
|
||||
#if HAVE_FAST_CMOV && HAVE_INLINE_ASM
|
||||
#if HAVE_FAST_CMOV && HAVE_INLINE_ASM && HAVE_6REGS
|
||||
low -= range_times_prob << 16;
|
||||
range -= range_times_prob;
|
||||
bit = 0;
|
||||
|
@@ -1355,8 +1355,8 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
|
||||
motion_y >>= s->chroma_y_shift;
|
||||
}
|
||||
|
||||
mx = motion_x & ~(-1 << s->mv_precision);
|
||||
my = motion_y & ~(-1 << s->mv_precision);
|
||||
mx = motion_x & ~(-1U << s->mv_precision);
|
||||
my = motion_y & ~(-1U << s->mv_precision);
|
||||
motion_x >>= s->mv_precision;
|
||||
motion_y >>= s->mv_precision;
|
||||
/* normalize subpel coordinates to epel */
|
||||
|
@@ -166,6 +166,10 @@ static int fic_decode_frame(AVCodecContext *avctx, void *data,
|
||||
if (memcmp(src, fic_header, 7))
|
||||
av_log(avctx, AV_LOG_WARNING, "Invalid FIC Header.\n");
|
||||
|
||||
/* Is it a skip frame? */
|
||||
if (src[17])
|
||||
goto skip;
|
||||
|
||||
nslices = src[13];
|
||||
if (!nslices) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Zero slices found.\n");
|
||||
@@ -242,10 +246,11 @@ static int fic_decode_frame(AVCodecContext *avctx, void *data,
|
||||
ctx->slice_data[slice].y_off = y_off;
|
||||
}
|
||||
|
||||
if (ret = avctx->execute(avctx, fic_decode_slice, ctx->slice_data,
|
||||
NULL, nslices, sizeof(ctx->slice_data[0])) < 0)
|
||||
if ((ret = avctx->execute(avctx, fic_decode_slice, ctx->slice_data,
|
||||
NULL, nslices, sizeof(ctx->slice_data[0]))) < 0)
|
||||
return ret;
|
||||
|
||||
skip:
|
||||
*got_frame = 1;
|
||||
if ((ret = av_frame_ref(data, ctx->frame)) < 0)
|
||||
return ret;
|
||||
|
@@ -691,6 +691,7 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
switch (chunk_type) {
|
||||
case DISPLAY_INFO:
|
||||
got_header =
|
||||
c->got_header = 0;
|
||||
if (chunk_size < 21) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid display info size %d\n",
|
||||
@@ -717,7 +718,8 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Unknown compression method %d\n",
|
||||
c->compression);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
ret = AVERROR_PATCHWELCOME;
|
||||
goto header_fail;
|
||||
}
|
||||
c->tile_width = bytestream2_get_be32(&bc);
|
||||
c->tile_height = bytestream2_get_be32(&bc);
|
||||
@@ -737,7 +739,8 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
|
||||
(chunk_size - 21) < 16 ) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Display info: missing bitmasks!\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto header_fail;
|
||||
}
|
||||
r_mask = bytestream2_get_be32(&bc);
|
||||
g_mask = bytestream2_get_be32(&bc);
|
||||
@@ -746,11 +749,13 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Invalid or unsupported bitmasks: R=%X, G=%X, B=%X\n",
|
||||
r_mask, g_mask, b_mask);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
ret = AVERROR_PATCHWELCOME;
|
||||
goto header_fail;
|
||||
}
|
||||
} else {
|
||||
avpriv_request_sample(avctx, "bpp=%d", c->bpp);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
ret = AVERROR_PATCHWELCOME;
|
||||
goto header_fail;
|
||||
}
|
||||
if (g2m_init_buffers(c)) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
|
@@ -2285,7 +2285,8 @@ static int pack_bitstream(G723_1_Context *p, unsigned char *frame, int size)
|
||||
if (p->cur_rate == RATE_6300) {
|
||||
info_bits = 0;
|
||||
put_bits(&pb, 2, info_bits);
|
||||
}
|
||||
}else
|
||||
av_assert0(0);
|
||||
|
||||
put_bits(&pb, 8, p->lsp_index[2]);
|
||||
put_bits(&pb, 8, p->lsp_index[1]);
|
||||
|
@@ -214,6 +214,18 @@ static inline int get_se_golomb(GetBitContext *gb)
|
||||
}
|
||||
}
|
||||
|
||||
static inline int get_se_golomb_long(GetBitContext *gb)
|
||||
{
|
||||
unsigned int buf = get_ue_golomb_long(gb);
|
||||
|
||||
if (buf & 1)
|
||||
buf = (buf + 1) >> 1;
|
||||
else
|
||||
buf = -(buf >> 1);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static inline int svq3_get_se_golomb(GetBitContext *gb)
|
||||
{
|
||||
unsigned int buf;
|
||||
|
@@ -1813,6 +1813,7 @@ static int decode_update_thread_context(AVCodecContext *dst,
|
||||
memset(&h->mb, 0, sizeof(h->mb));
|
||||
memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
|
||||
memset(&h->mb_padding, 0, sizeof(h->mb_padding));
|
||||
memset(&h->cur_pic, 0, sizeof(h->cur_pic));
|
||||
|
||||
h->avctx = dst;
|
||||
h->DPB = NULL;
|
||||
@@ -3444,6 +3445,17 @@ int ff_set_ref_count(H264Context *h)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static enum AVPixelFormat non_j_pixfmt(enum AVPixelFormat a)
|
||||
{
|
||||
switch (a) {
|
||||
case AV_PIX_FMT_YUVJ420P: return AV_PIX_FMT_YUV420P;
|
||||
case AV_PIX_FMT_YUVJ422P: return AV_PIX_FMT_YUV422P;
|
||||
case AV_PIX_FMT_YUVJ444P: return AV_PIX_FMT_YUV444P;
|
||||
default:
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a slice header.
|
||||
* This will (re)intialize the decoder and call h264_frame_start() as needed.
|
||||
@@ -3573,7 +3585,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
|| h->mb_width != h->sps.mb_width
|
||||
|| h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag)
|
||||
));
|
||||
if (h0->avctx->pix_fmt != get_pixel_format(h0, 0))
|
||||
if (non_j_pixfmt(h0->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h0, 0)))
|
||||
must_reinit = 1;
|
||||
|
||||
h->mb_width = h->sps.mb_width;
|
||||
|
@@ -175,7 +175,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
|
||||
goto fail;
|
||||
|
||||
/* prepend only to the first type 5 NAL unit of an IDR picture */
|
||||
if (ctx->first_idr && unit_type == 5) {
|
||||
if (ctx->first_idr && (unit_type == 5 || unit_type == 7 || unit_type == 8)) {
|
||||
if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
|
||||
avctx->extradata, avctx->extradata_size,
|
||||
buf, nal_size)) < 0)
|
||||
|
@@ -283,7 +283,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
|
||||
static int set_sps(HEVCContext *s, const HEVCSPS *sps)
|
||||
{
|
||||
int ret;
|
||||
unsigned num = 0, den = 0;
|
||||
unsigned int num = 0, den = 0;
|
||||
|
||||
pic_arrays_free(s);
|
||||
ret = pic_arrays_init(s, sps);
|
||||
|
@@ -461,7 +461,7 @@ typedef struct HEVCSPS {
|
||||
} HEVCSPS;
|
||||
|
||||
typedef struct HEVCPPS {
|
||||
unsigned sps_id; ///< seq_parameter_set_id
|
||||
unsigned int sps_id; ///< seq_parameter_set_id
|
||||
|
||||
uint8_t sign_data_hiding_flag;
|
||||
|
||||
|
@@ -611,8 +611,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
|
||||
{
|
||||
const AVPixFmtDescriptor *desc;
|
||||
GetBitContext *gb = &s->HEVClc->gb;
|
||||
int ret = 0;
|
||||
int sps_id = 0;
|
||||
int ret = 0;
|
||||
unsigned int sps_id = 0;
|
||||
int log2_diff_max_min_transform_block_size;
|
||||
int bit_depth_chroma, start, vui_present, sublayer_ordering_info;
|
||||
int i;
|
||||
@@ -993,8 +993,8 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
|
||||
int pic_area_in_ctbs, pic_area_in_min_cbs, pic_area_in_min_tbs;
|
||||
int log2_diff_ctb_min_tb_size;
|
||||
int i, j, x, y, ctb_addr_rs, tile_id;
|
||||
int ret = 0;
|
||||
int pps_id = 0;
|
||||
int ret = 0;
|
||||
unsigned int pps_id = 0;
|
||||
|
||||
AVBufferRef *pps_buf;
|
||||
HEVCPPS *pps = av_mallocz(sizeof(*pps));
|
||||
|
@@ -35,6 +35,12 @@
|
||||
|
||||
#define FF_SANE_NB_CHANNELS 63U
|
||||
|
||||
#if HAVE_NEON || ARCH_PPC || HAVE_MMX
|
||||
# define STRIDE_ALIGN 16
|
||||
#else
|
||||
# define STRIDE_ALIGN 8
|
||||
#endif
|
||||
|
||||
typedef struct FramePool {
|
||||
/**
|
||||
* Pools for each data plane. For audio all the planes have the same size,
|
||||
|
@@ -391,19 +391,6 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
||||
|
||||
OPT_STR("level", x4->level);
|
||||
|
||||
if(x4->x264opts){
|
||||
const char *p= x4->x264opts;
|
||||
while(p){
|
||||
char param[256]={0}, val[256]={0};
|
||||
if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){
|
||||
OPT_STR(param, "1");
|
||||
}else
|
||||
OPT_STR(param, val);
|
||||
p= strchr(p, ':');
|
||||
p+=!!p;
|
||||
}
|
||||
}
|
||||
|
||||
if (avctx->i_quant_factor > 0)
|
||||
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
|
||||
|
||||
@@ -589,6 +576,19 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
||||
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
|
||||
x4->params.b_repeat_headers = 0;
|
||||
|
||||
if(x4->x264opts){
|
||||
const char *p= x4->x264opts;
|
||||
while(p){
|
||||
char param[256]={0}, val[256]={0};
|
||||
if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){
|
||||
OPT_STR(param, "1");
|
||||
}else
|
||||
OPT_STR(param, val);
|
||||
p= strchr(p, ':');
|
||||
p+=!!p;
|
||||
}
|
||||
}
|
||||
|
||||
if (x4->x264_params) {
|
||||
AVDictionary *dict = NULL;
|
||||
AVDictionaryEntry *en = NULL;
|
||||
|
@@ -81,6 +81,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
|
||||
libx265Context *ctx = avctx->priv_data;
|
||||
x265_nal *nal;
|
||||
uint8_t *buf;
|
||||
char sar[10];
|
||||
int sar_num, sar_den;
|
||||
int nnal;
|
||||
int ret;
|
||||
@@ -121,11 +122,11 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
|
||||
av_reduce(&sar_num, &sar_den,
|
||||
avctx->sample_aspect_ratio.num,
|
||||
avctx->sample_aspect_ratio.den, 4096);
|
||||
ctx->params->bEnableVuiParametersPresentFlag = 1;
|
||||
ctx->params->bEnableAspectRatioIdc = 1;
|
||||
ctx->params->aspectRatioIdc = 255;
|
||||
ctx->params->sarWidth = sar_num;
|
||||
ctx->params->sarHeight = sar_den;
|
||||
snprintf(sar, sizeof(sar), "%d:%d", sar_num, sar_den);
|
||||
if (x265_param_parse(ctx->params, "sar", sar) == X265_PARAM_BAD_VALUE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid SAR: %d:%d.\n", sar_num, sar_den);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (x265_max_bit_depth == 8)
|
||||
ctx->params->internalBitDepth = 8;
|
||||
@@ -190,7 +191,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
|
||||
for (i = 0; i < nnal; i++)
|
||||
ctx->header_size += nal[i].sizeBytes;
|
||||
|
||||
ctx->header = av_malloc(ctx->header_size);
|
||||
ctx->header = av_malloc(ctx->header_size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!ctx->header) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Cannot allocate HEVC header of size %d.\n", ctx->header_size);
|
||||
@@ -204,6 +205,13 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
|
||||
buf += nal[i].sizeBytes;
|
||||
}
|
||||
|
||||
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
|
||||
avctx->extradata_size = ctx->header_size;
|
||||
avctx->extradata = ctx->header;
|
||||
ctx->header_size = 0;
|
||||
ctx->header = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -83,6 +83,17 @@ static void build_basic_mjpeg_vlc(MJpegDecodeContext *s)
|
||||
avpriv_mjpeg_val_ac_chrominance, 251, 0, 0);
|
||||
}
|
||||
|
||||
static void parse_avid(MJpegDecodeContext *s, uint8_t *buf, int len)
|
||||
{
|
||||
s->buggy_avid = 1;
|
||||
if (len > 14 && buf[12] == 1) /* 1 - NTSC */
|
||||
s->interlace_polarity = 1;
|
||||
if (len > 14 && buf[12] == 2) /* 2 - PAL */
|
||||
s->interlace_polarity = 0;
|
||||
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
|
||||
av_log(s->avctx, AV_LOG_INFO, "AVID: len:%d %d\n", len, len > 14 ? buf[12] : -1);
|
||||
}
|
||||
|
||||
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
MJpegDecodeContext *s = avctx->priv_data;
|
||||
@@ -120,7 +131,17 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
|
||||
if (avctx->field_order == AV_FIELD_BB) { /* quicktime icefloe 019 */
|
||||
s->interlace_polarity = 1; /* bottom field first */
|
||||
av_log(avctx, AV_LOG_DEBUG, "bottom field first\n");
|
||||
} else if (avctx->field_order == AV_FIELD_UNKNOWN) {
|
||||
if (avctx->codec_tag == AV_RL32("MJPG"))
|
||||
s->interlace_polarity = 1;
|
||||
}
|
||||
|
||||
if ( avctx->extradata_size > 8
|
||||
&& AV_RL32(avctx->extradata) == 0x2C
|
||||
&& AV_RL32(avctx->extradata+4) == 0x18) {
|
||||
parse_avid(s, avctx->extradata, avctx->extradata_size);
|
||||
}
|
||||
|
||||
if (avctx->codec->id == AV_CODEC_ID_AMV)
|
||||
s->flipped = 1;
|
||||
|
||||
@@ -1230,7 +1251,7 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
|
||||
}
|
||||
|
||||
if (!Al) {
|
||||
s->coefs_finished[c] |= (1LL << (se + 1)) - (1LL << ss);
|
||||
s->coefs_finished[c] |= (2LL << se) - (1LL << ss);
|
||||
last_scan = !~s->coefs_finished[c];
|
||||
}
|
||||
|
||||
@@ -1694,9 +1715,7 @@ static int mjpeg_decode_com(MJpegDecodeContext *s)
|
||||
|
||||
/* buggy avid, it puts EOI only at every 10th frame */
|
||||
if (!strncmp(cbuf, "AVID", 4)) {
|
||||
s->buggy_avid = 1;
|
||||
if (len > 14 && cbuf[12] == 1) /* 1 - NTSC, 2 - PAL */
|
||||
s->interlace_polarity = 1;
|
||||
parse_avid(s, cbuf, len);
|
||||
} else if (!strcmp(cbuf, "CS=ITU601"))
|
||||
s->cs_itu601 = 1;
|
||||
else if ((!strncmp(cbuf, "Intel(R) JPEG Library, version 1", 32)) ||
|
||||
|
@@ -487,7 +487,7 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n)
|
||||
put_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]);
|
||||
}
|
||||
|
||||
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[6][64])
|
||||
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64])
|
||||
{
|
||||
int i;
|
||||
if (s->chroma_format == CHROMA_444) {
|
||||
|
@@ -61,6 +61,6 @@ void ff_mjpeg_encode_stuffing(MpegEncContext *s);
|
||||
void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[3], int vsample[3]);
|
||||
void ff_mjpeg_encode_dc(PutBitContext *pb, int val,
|
||||
uint8_t *huff_size, uint16_t *huff_code);
|
||||
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[6][64]);
|
||||
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]);
|
||||
|
||||
#endif /* AVCODEC_MJPEGENC_H */
|
||||
|
@@ -1774,7 +1774,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!avctx->hwaccel) {
|
||||
if (!avctx->hwaccel && !(avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)) {
|
||||
for(i=0; i<avctx->height; i++)
|
||||
memset(s->last_picture_ptr->f.data[0] + s->last_picture_ptr->f.linesize[0]*i,
|
||||
0x80, avctx->width);
|
||||
|
@@ -99,6 +99,7 @@ struct MpegEncContext;
|
||||
*/
|
||||
typedef struct Picture{
|
||||
struct AVFrame f;
|
||||
uint8_t avframe_padding[1024]; // hack to allow linking to a avutil with larger AVFrame
|
||||
ThreadFrame tf;
|
||||
|
||||
AVBufferRef *qscale_table_buf;
|
||||
@@ -195,8 +196,8 @@ typedef struct Picture{
|
||||
int mbaff; ///< h264 1 -> MBAFF frame 0-> not MBAFF
|
||||
int field_picture; ///< whether or not the picture was encoded in separate fields
|
||||
|
||||
int mb_var_sum; ///< sum of MB variance for current frame
|
||||
int mc_mb_var_sum; ///< motion compensated MB variance for current frame
|
||||
int64_t mb_var_sum; ///< sum of MB variance for current frame
|
||||
int64_t mc_mb_var_sum; ///< motion compensated MB variance for current frame
|
||||
|
||||
int b_frame_score;
|
||||
int needs_realloc; ///< Picture needs to be reallocated (eg due to a frame size change)
|
||||
@@ -251,8 +252,8 @@ typedef struct MotionEstContext{
|
||||
int stride;
|
||||
int uvstride;
|
||||
/* temp variables for picture complexity calculation */
|
||||
int mc_mb_var_sum_temp;
|
||||
int mb_var_sum_temp;
|
||||
int64_t mc_mb_var_sum_temp;
|
||||
int64_t mb_var_sum_temp;
|
||||
int scene_change_score;
|
||||
/* cmp, chroma_cmp;*/
|
||||
op_pixels_func (*hpel_put)[4];
|
||||
|
@@ -1039,6 +1039,10 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
|
||||
direct = 0;
|
||||
if ((s->width & 15) || (s->height & 15))
|
||||
direct = 0;
|
||||
if (((intptr_t)(pic_arg->data[0])) & (STRIDE_ALIGN-1))
|
||||
direct = 0;
|
||||
if (s->linesize & (STRIDE_ALIGN-1))
|
||||
direct = 0;
|
||||
|
||||
av_dlog(s->avctx, "%d %d %td %td\n", pic_arg->linesize[0],
|
||||
pic_arg->linesize[1], s->linesize, s->uvlinesize);
|
||||
@@ -3439,7 +3443,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
|
||||
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
|
||||
if(s->msmpeg4_version >= 3)
|
||||
s->no_rounding=1;
|
||||
av_dlog(s, "Scene change detected, encoding as I Frame %d %d\n",
|
||||
av_dlog(s, "Scene change detected, encoding as I Frame %"PRId64" %"PRId64"\n",
|
||||
s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum);
|
||||
}
|
||||
|
||||
|
@@ -55,7 +55,7 @@ static av_cold int msrle_decode_init(AVCodecContext *avctx)
|
||||
|
||||
s->avctx = avctx;
|
||||
|
||||
switch (avctx->bits_per_coded_sample & 0x1f) {
|
||||
switch (avctx->bits_per_coded_sample) {
|
||||
case 1:
|
||||
avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
|
||||
break;
|
||||
@@ -116,6 +116,9 @@ static int msrle_decode_frame(AVCodecContext *avctx,
|
||||
uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
|
||||
int i, j;
|
||||
|
||||
if (linesize < 0)
|
||||
return linesize;
|
||||
|
||||
for (i = 0; i < avctx->height; i++) {
|
||||
if (avctx->bits_per_coded_sample == 4) {
|
||||
for (j = 0; j < avctx->width - 1; j += 2) {
|
||||
|
@@ -317,6 +317,7 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
|
||||
FrameThreadContext *fctx = p->parent;
|
||||
PerThreadContext *prev_thread = fctx->prev_thread;
|
||||
const AVCodec *codec = p->avctx->codec;
|
||||
int ret;
|
||||
|
||||
if (!avpkt->size && !(codec->capabilities & CODEC_CAP_DELAY)) return 0;
|
||||
|
||||
@@ -340,6 +341,7 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
|
||||
}
|
||||
}
|
||||
|
||||
av_packet_free_side_data(&p->avpkt);
|
||||
av_buffer_unref(&p->avpkt.buf);
|
||||
p->avpkt = *avpkt;
|
||||
if (avpkt->buf)
|
||||
@@ -354,6 +356,10 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
|
||||
memcpy(p->buf, avpkt->data, avpkt->size);
|
||||
memset(p->buf + avpkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
}
|
||||
if ((ret = av_copy_packet_side_data(&p->avpkt, avpkt)) < 0) {
|
||||
pthread_mutex_unlock(&p->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
p->state = STATE_SETTING_UP;
|
||||
pthread_cond_signal(&p->input_cond);
|
||||
@@ -592,6 +598,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
|
||||
pthread_cond_destroy(&p->input_cond);
|
||||
pthread_cond_destroy(&p->progress_cond);
|
||||
pthread_cond_destroy(&p->output_cond);
|
||||
av_packet_free_side_data(&p->avpkt);
|
||||
av_buffer_unref(&p->avpkt.buf);
|
||||
av_freep(&p->buf);
|
||||
av_freep(&p->released_buffers);
|
||||
@@ -727,8 +734,6 @@ void ff_thread_flush(AVCodecContext *avctx)
|
||||
if (fctx->prev_thread) {
|
||||
if (fctx->prev_thread != &fctx->threads[0])
|
||||
update_context_from_thread(fctx->threads[0].avctx, fctx->prev_thread->avctx, 0);
|
||||
if (avctx->codec->flush)
|
||||
avctx->codec->flush(fctx->threads[0].avctx);
|
||||
}
|
||||
|
||||
fctx->next_decoding = fctx->next_finished = 0;
|
||||
@@ -741,6 +746,9 @@ void ff_thread_flush(AVCodecContext *avctx)
|
||||
av_frame_unref(p->frame);
|
||||
|
||||
release_delayed_buffers(p);
|
||||
|
||||
if (avctx->codec->flush)
|
||||
avctx->codec->flush(p->avctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ void ff_write_pass1_stats(MpegEncContext *s)
|
||||
{
|
||||
snprintf(s->avctx->stats_out, 256,
|
||||
"in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d "
|
||||
"fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d;\n",
|
||||
"fcode:%d bcode:%d mc-var:%"PRId64" var:%"PRId64" icount:%d skipcount:%d hbits:%d;\n",
|
||||
s->current_picture_ptr->f.display_picture_number,
|
||||
s->current_picture_ptr->f.coded_picture_number,
|
||||
s->pict_type,
|
||||
@@ -206,7 +206,7 @@ av_cold int ff_rate_control_init(MpegEncContext *s)
|
||||
assert(picture_number < rcc->num_entries);
|
||||
rce = &rcc->entry[picture_number];
|
||||
|
||||
e += sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d",
|
||||
e += sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%"SCNd64" var:%"SCNd64" icount:%d skipcount:%d hbits:%d",
|
||||
&rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits,
|
||||
&rce->mv_bits, &rce->misc_bits,
|
||||
&rce->f_code, &rce->b_code,
|
||||
@@ -753,7 +753,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
|
||||
RateControlEntry local_rce, *rce;
|
||||
double bits;
|
||||
double rate_factor;
|
||||
int var;
|
||||
int64_t var;
|
||||
const int pict_type = s->pict_type;
|
||||
Picture * const pic = &s->current_picture;
|
||||
emms_c();
|
||||
@@ -769,8 +769,9 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
|
||||
fps = get_fps(s->avctx);
|
||||
/* update predictors */
|
||||
if (picture_number > 2 && !dry_run) {
|
||||
const int last_var = s->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum
|
||||
: rcc->last_mc_mb_var_sum;
|
||||
const int64_t last_var =
|
||||
s->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum
|
||||
: rcc->last_mc_mb_var_sum;
|
||||
av_assert1(s->frame_bits >= s->stuffing_bits);
|
||||
update_predictor(&rcc->pred[s->last_pict_type],
|
||||
rcc->last_qscale,
|
||||
@@ -817,7 +818,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
|
||||
assert(pict_type == rce->new_pict_type);
|
||||
|
||||
q = rce->new_qscale / br_compensation;
|
||||
av_dlog(s, "%f %f %f last:%d var:%d type:%d//\n", q, rce->new_qscale,
|
||||
av_dlog(s, "%f %f %f last:%d var:%"PRId64" type:%d//\n", q, rce->new_qscale,
|
||||
br_compensation, s->frame_bits, var, pict_type);
|
||||
} else {
|
||||
rce->pict_type =
|
||||
@@ -879,7 +880,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
|
||||
if (s->avctx->debug & FF_DEBUG_RC) {
|
||||
av_log(s->avctx, AV_LOG_DEBUG,
|
||||
"%c qp:%d<%2.1f<%d %d want:%d total:%d comp:%f st_q:%2.2f "
|
||||
"size:%d var:%d/%d br:%d fps:%d\n",
|
||||
"size:%d var:%"PRId64"/%"PRId64" br:%d fps:%d\n",
|
||||
av_get_picture_type_char(pict_type),
|
||||
qmin, q, qmax, picture_number,
|
||||
(int)wanted_bits / 1000, (int)s->total_bits / 1000,
|
||||
|
@@ -49,8 +49,8 @@ typedef struct RateControlEntry{
|
||||
uint64_t expected_bits;
|
||||
int new_pict_type;
|
||||
float new_qscale;
|
||||
int mc_mb_var_sum;
|
||||
int mb_var_sum;
|
||||
int64_t mc_mb_var_sum;
|
||||
int64_t mb_var_sum;
|
||||
int i_count;
|
||||
int skip_count;
|
||||
int f_code;
|
||||
@@ -71,8 +71,8 @@ typedef struct RateControlContext{
|
||||
double pass1_wanted_bits; ///< bits which should have been outputed by the pass1 code (including complexity init)
|
||||
double last_qscale;
|
||||
double last_qscale_for[5]; ///< last qscale for a specific pict type, used for max_diff & ipb factor stuff
|
||||
int last_mc_mb_var_sum;
|
||||
int last_mb_var_sum;
|
||||
int64_t last_mc_mb_var_sum;
|
||||
int64_t last_mb_var_sum;
|
||||
uint64_t i_cplx_sum[5];
|
||||
uint64_t p_cplx_sum[5];
|
||||
uint64_t mv_bits_sum[5];
|
||||
|
@@ -83,17 +83,6 @@ static const PixelFormatTag pix_fmt_bps_mov[] = {
|
||||
{ AV_PIX_FMT_NONE, 0 },
|
||||
};
|
||||
|
||||
enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags,
|
||||
unsigned int fourcc)
|
||||
{
|
||||
while (tags->pix_fmt >= 0) {
|
||||
if (tags->fourcc == fourcc)
|
||||
return tags->pix_fmt;
|
||||
tags++;
|
||||
}
|
||||
return AV_PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 55
|
||||
enum AVPixelFormat ff_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc)
|
||||
{
|
||||
@@ -109,7 +98,7 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
|
||||
if ( avctx->codec_tag == MKTAG('r','a','w',' ')
|
||||
|| avctx->codec_tag == MKTAG('N','O','1','6'))
|
||||
avctx->pix_fmt = avpriv_find_pix_fmt(pix_fmt_bps_mov,
|
||||
avctx->bits_per_coded_sample & 0x1f);
|
||||
avctx->bits_per_coded_sample);
|
||||
else if (avctx->codec_tag == MKTAG('W', 'R', 'A', 'W'))
|
||||
avctx->pix_fmt = avpriv_find_pix_fmt(pix_fmt_bps_avi,
|
||||
avctx->bits_per_coded_sample);
|
||||
@@ -135,7 +124,7 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
|
||||
memset(context->palette->data, 0, AVPALETTE_SIZE);
|
||||
}
|
||||
|
||||
if (((avctx->bits_per_coded_sample & 0x1f) == 4 || (avctx->bits_per_coded_sample & 0x1f) == 2) &&
|
||||
if ((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) &&
|
||||
avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
|
||||
(!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))) {
|
||||
context->is_2_4_bpp = 1;
|
||||
@@ -209,14 +198,14 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
int i;
|
||||
uint8_t *dst = frame->buf[0]->data;
|
||||
buf_size = context->frame_size - AVPALETTE_SIZE;
|
||||
if ((avctx->bits_per_coded_sample & 0x1f) == 4) {
|
||||
if (avctx->bits_per_coded_sample == 4) {
|
||||
for (i = 0; 2 * i + 1 < buf_size && i<avpkt->size; i++) {
|
||||
dst[2 * i + 0] = buf[i] >> 4;
|
||||
dst[2 * i + 1] = buf[i] & 15;
|
||||
}
|
||||
linesize_align = 8;
|
||||
} else {
|
||||
av_assert0((avctx->bits_per_coded_sample & 0x1f) == 2);
|
||||
av_assert0(avctx->bits_per_coded_sample == 2);
|
||||
for (i = 0; 4 * i + 3 < buf_size && i<avpkt->size; i++) {
|
||||
dst[4 * i + 0] = buf[i] >> 6;
|
||||
dst[4 * i + 1] = buf[i] >> 4 & 3;
|
||||
|
@@ -730,7 +730,10 @@ static int rv10_decode_frame(AVCodecContext *avctx,
|
||||
offset + FFMAX(size, size2) > buf_size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (rv10_decode_packet(avctx, buf + offset, size, size2) > 8 * size)
|
||||
if ((ret = rv10_decode_packet(avctx, buf + offset, size, size2)) < 0)
|
||||
return ret;
|
||||
|
||||
if (ret > 8 * size)
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@@ -1502,8 +1502,8 @@ static int ratecontrol_1pass(SnowContext *s, AVFrame *pict)
|
||||
}
|
||||
|
||||
/* ugly, ratecontrol just takes a sqrt again */
|
||||
coef_sum = (uint64_t)coef_sum * coef_sum >> 16;
|
||||
av_assert0(coef_sum < INT_MAX);
|
||||
coef_sum = (uint64_t)coef_sum * coef_sum >> 16;
|
||||
|
||||
if(pict->pict_type == AV_PICTURE_TYPE_I){
|
||||
s->m.current_picture.mb_var_sum= coef_sum;
|
||||
|
@@ -46,6 +46,7 @@
|
||||
#include "thread.h"
|
||||
#include "frame_thread_encoder.h"
|
||||
#include "internal.h"
|
||||
#include "raw.h"
|
||||
#include "bytestream.h"
|
||||
#include "version.h"
|
||||
#include <stdlib.h>
|
||||
@@ -274,12 +275,6 @@ int ff_side_data_update_matrix_encoding(AVFrame *frame,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if HAVE_NEON || ARCH_PPC || HAVE_MMX
|
||||
# define STRIDE_ALIGN 16
|
||||
#else
|
||||
# define STRIDE_ALIGN 8
|
||||
#endif
|
||||
|
||||
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
||||
int linesize_align[AV_NUM_DATA_POINTERS])
|
||||
{
|
||||
@@ -813,6 +808,7 @@ int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame)
|
||||
typedef struct CompatReleaseBufPriv {
|
||||
AVCodecContext avctx;
|
||||
AVFrame frame;
|
||||
uint8_t avframe_padding[1024]; // hack to allow linking to a avutil with larger AVFrame
|
||||
} CompatReleaseBufPriv;
|
||||
|
||||
static void compat_free_buffer(void *opaque, uint8_t *data)
|
||||
@@ -1076,6 +1072,17 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2,
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags,
|
||||
unsigned int fourcc)
|
||||
{
|
||||
while (tags->pix_fmt >= 0) {
|
||||
if (tags->fourcc == fourcc)
|
||||
return tags->pix_fmt;
|
||||
tags++;
|
||||
}
|
||||
return AV_PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
static int is_hwaccel_pix_fmt(enum AVPixelFormat pix_fmt)
|
||||
{
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
|
||||
@@ -1621,7 +1628,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
|
||||
const AVFrame *frame,
|
||||
int *got_packet_ptr)
|
||||
{
|
||||
AVFrame tmp;
|
||||
AVFrame *extended_frame = NULL;
|
||||
AVFrame *padded_frame = NULL;
|
||||
int ret;
|
||||
AVPacket user_pkt = *avpkt;
|
||||
@@ -1646,9 +1653,13 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
|
||||
}
|
||||
av_log(avctx, AV_LOG_WARNING, "extended_data is not set.\n");
|
||||
|
||||
tmp = *frame;
|
||||
tmp.extended_data = tmp.data;
|
||||
frame = &tmp;
|
||||
extended_frame = av_frame_alloc();
|
||||
if (!extended_frame)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
memcpy(extended_frame, frame, sizeof(AVFrame));
|
||||
extended_frame->extended_data = extended_frame->data;
|
||||
frame = extended_frame;
|
||||
}
|
||||
|
||||
/* check for valid frame size */
|
||||
@@ -1656,14 +1667,15 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
|
||||
if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
|
||||
if (frame->nb_samples > avctx->frame_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "more samples than frame size (avcodec_encode_audio2)\n");
|
||||
return AVERROR(EINVAL);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto end;
|
||||
}
|
||||
} else if (!(avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) {
|
||||
if (frame->nb_samples < avctx->frame_size &&
|
||||
!avctx->internal->last_audio_frame) {
|
||||
ret = pad_last_frame(avctx, &padded_frame, frame);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
frame = padded_frame;
|
||||
avctx->internal->last_audio_frame = 1;
|
||||
@@ -1735,6 +1747,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
|
||||
|
||||
end:
|
||||
av_frame_free(&padded_frame);
|
||||
av_free(extended_frame);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@@ -1912,9 +1912,10 @@ static void vc1_interp_mc(VC1Context *v)
|
||||
uvmx = (mx + ((mx & 3) == 3)) >> 1;
|
||||
uvmy = (my + ((my & 3) == 3)) >> 1;
|
||||
if (v->field_mode) {
|
||||
if (v->cur_field_type != v->ref_field_type[1])
|
||||
if (v->cur_field_type != v->ref_field_type[1]) {
|
||||
my = my - 2 + 4 * v->cur_field_type;
|
||||
uvmy = uvmy - 2 + 4 * v->cur_field_type;
|
||||
}
|
||||
}
|
||||
if (v->fastuvmc) {
|
||||
uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
|
||||
|
@@ -85,6 +85,11 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
|
||||
|
||||
++p;
|
||||
|
||||
for (i = p; (bits[i] == 0) && (i < num); ++i)
|
||||
;
|
||||
if (i == num)
|
||||
return 0;
|
||||
|
||||
for (; p < num; ++p) {
|
||||
if (bits[p] > 32)
|
||||
return 1;
|
||||
|
@@ -151,7 +151,7 @@ typedef struct vorbis_context_s {
|
||||
uint8_t mode_count;
|
||||
vorbis_mode *modes;
|
||||
uint8_t mode_number; // mode number for the current packet
|
||||
uint8_t previous_window;
|
||||
int8_t previous_window;
|
||||
float *channel_residues;
|
||||
float *saved;
|
||||
} vorbis_context;
|
||||
@@ -701,8 +701,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
|
||||
res_setup->partition_size = get_bits(gb, 24) + 1;
|
||||
/* Validations to prevent a buffer overflow later. */
|
||||
if (res_setup->begin>res_setup->end ||
|
||||
res_setup->end > (res_setup->type == 2 ? vc->audio_channels : 1) * vc->blocksize[1] / 2 ||
|
||||
(res_setup->end-res_setup->begin) / res_setup->partition_size > V_MAX_PARTITIONS) {
|
||||
(res_setup->end-res_setup->begin) / res_setup->partition_size > FFMIN(V_MAX_PARTITIONS, 65535)) {
|
||||
av_log(vc->avctx, AV_LOG_ERROR,
|
||||
"partition out of bounds: type, begin, end, size, blocksize: %"PRIu16", %"PRIu32", %"PRIu32", %u, %"PRIu32"\n",
|
||||
res_setup->type, res_setup->begin, res_setup->end,
|
||||
@@ -989,7 +988,7 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
|
||||
if (!vc->channel_residues || !vc->saved)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
vc->previous_window = 0;
|
||||
vc->previous_window = -1;
|
||||
|
||||
ff_mdct_init(&vc->mdct[0], bl0, 1, -1.0);
|
||||
ff_mdct_init(&vc->mdct[1], bl1, 1, -1.0);
|
||||
@@ -1372,6 +1371,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
|
||||
unsigned pass, ch_used, i, j, k, l;
|
||||
unsigned max_output = (ch - 1) * vlen;
|
||||
int ptns_to_read = vr->ptns_to_read;
|
||||
int libvorbis_bug = 0;
|
||||
|
||||
if (vr_type == 2) {
|
||||
for (j = 1; j < ch; ++j)
|
||||
@@ -1386,8 +1386,13 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
|
||||
}
|
||||
|
||||
if (max_output > ch_left * vlen) {
|
||||
av_log(vc->avctx, AV_LOG_ERROR, "Insufficient output buffer\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (max_output <= ch_left * vlen + vr->partition_size*ch_used/ch) {
|
||||
ptns_to_read--;
|
||||
libvorbis_bug = 1;
|
||||
} else {
|
||||
av_log(vc->avctx, AV_LOG_ERROR, "Insufficient output buffer\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
|
||||
av_dlog(NULL, " residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c);
|
||||
@@ -1496,6 +1501,14 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
|
||||
voffset += vr->partition_size;
|
||||
}
|
||||
}
|
||||
if (libvorbis_bug && !pass) {
|
||||
for (j = 0; j < ch_used; ++j) {
|
||||
if (!do_not_decode[j]) {
|
||||
get_vlc2(&vc->gb, vc->codebooks[vr->classbook].vlc.table,
|
||||
vc->codebooks[vr->classbook].nb_bits, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1548,7 +1561,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
|
||||
{
|
||||
GetBitContext *gb = &vc->gb;
|
||||
FFTContext *mdct;
|
||||
unsigned previous_window = vc->previous_window;
|
||||
int previous_window = vc->previous_window;
|
||||
unsigned mode_number, blockflag, blocksize;
|
||||
int i, j;
|
||||
uint8_t no_residue[255];
|
||||
@@ -1581,9 +1594,11 @@ static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
|
||||
blocksize = vc->blocksize[blockflag];
|
||||
vlen = blocksize / 2;
|
||||
if (blockflag) {
|
||||
previous_window = get_bits(gb, 1);
|
||||
skip_bits1(gb); // next_window
|
||||
}
|
||||
int code = get_bits(gb, 2);
|
||||
if (previous_window < 0)
|
||||
previous_window = code>>1;
|
||||
} else if (previous_window < 0)
|
||||
previous_window = 0;
|
||||
|
||||
memset(ch_res_ptr, 0, sizeof(float) * vc->audio_channels * vlen); //FIXME can this be removed ?
|
||||
for (i = 0; i < vc->audio_channels; ++i)
|
||||
@@ -1812,7 +1827,7 @@ static av_cold void vorbis_decode_flush(AVCodecContext *avctx)
|
||||
memset(vc->saved, 0, (vc->blocksize[1] / 4) * vc->audio_channels *
|
||||
sizeof(*vc->saved));
|
||||
}
|
||||
vc->previous_window = 0;
|
||||
vc->previous_window = -1;
|
||||
}
|
||||
|
||||
AVCodec ff_vorbis_decoder = {
|
||||
|
@@ -386,9 +386,9 @@ int ff_wma_end(AVCodecContext *avctx)
|
||||
}
|
||||
for (i = 0; i < 2; i++) {
|
||||
ff_free_vlc(&s->coef_vlc[i]);
|
||||
av_free(s->run_table[i]);
|
||||
av_free(s->level_table[i]);
|
||||
av_free(s->int_table[i]);
|
||||
av_freep(&s->run_table[i]);
|
||||
av_freep(&s->level_table[i]);
|
||||
av_freep(&s->int_table[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@@ -343,7 +343,7 @@ DECLARE_ASM_CONST(16, int32_t, walkenIdctRounders)[] = {
|
||||
"movdqa %%xmm6, 4*16("dct") \n\t" \
|
||||
"movdqa "SREG2", 7*16("dct") \n\t"
|
||||
|
||||
inline void ff_idct_xvid_sse2(short *block)
|
||||
av_extern_inline void ff_idct_xvid_sse2(short *block)
|
||||
{
|
||||
__asm__ volatile(
|
||||
"movq "MANGLE(m127)", %%mm0 \n\t"
|
||||
|
@@ -216,7 +216,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
|
||||
"psubusw "MM"1, "MM"4 \n\t"
|
||||
"packuswb "MM"4, "MM"4 \n\t"
|
||||
#if COMPILE_TEMPLATE_SSE2
|
||||
"packuswb "MM"4, "MM"4 \n\t"
|
||||
"packsswb "MM"4, "MM"4 \n\t"
|
||||
#endif
|
||||
"movd "MM"4, %0 \n\t" // *overflow
|
||||
: "=g" (*overflow)
|
||||
|
@@ -102,7 +102,7 @@ static int iec61883_callback(unsigned char *data, int length,
|
||||
DVPacket *packet;
|
||||
int ret;
|
||||
|
||||
#ifdef THREADS
|
||||
#if THREADS
|
||||
pthread_mutex_lock(&dv->mutex);
|
||||
#endif
|
||||
|
||||
@@ -139,7 +139,7 @@ static int iec61883_callback(unsigned char *data, int length,
|
||||
ret = 0;
|
||||
|
||||
exit:
|
||||
#ifdef THREADS
|
||||
#if THREADS
|
||||
pthread_cond_broadcast(&dv->cond);
|
||||
pthread_mutex_unlock(&dv->mutex);
|
||||
#endif
|
||||
@@ -151,7 +151,7 @@ static void *iec61883_receive_task(void *opaque)
|
||||
struct iec61883_data *dv = (struct iec61883_data *)opaque;
|
||||
int result;
|
||||
|
||||
#ifdef THREADS
|
||||
#if THREADS
|
||||
while (dv->thread_loop)
|
||||
#endif
|
||||
{
|
||||
@@ -168,7 +168,7 @@ static void *iec61883_receive_task(void *opaque)
|
||||
raw1394_loop_iterate(dv->raw1394);
|
||||
} else if (dv->receiving) {
|
||||
av_log(NULL, AV_LOG_ERROR, "No more input data available\n");
|
||||
#ifdef THREADS
|
||||
#if THREADS
|
||||
pthread_mutex_lock(&dv->mutex);
|
||||
dv->eof = 1;
|
||||
pthread_cond_broadcast(&dv->cond);
|
||||
@@ -413,7 +413,7 @@ static int iec61883_read_packet(AVFormatContext *context, AVPacket *pkt)
|
||||
* Try to parse frames from queue
|
||||
*/
|
||||
|
||||
#ifdef THREADS
|
||||
#if THREADS
|
||||
pthread_mutex_lock(&dv->mutex);
|
||||
while ((size = dv->parse_queue(dv, pkt)) == -1)
|
||||
if (!dv->eof)
|
||||
|
@@ -1204,6 +1204,8 @@ static int opengl_draw(AVFormatContext *h, void *input, int repaint, int is_pkt)
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if (!repaint) {
|
||||
if (is_pkt)
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
LOAD_TEXTURE_DATA(0, 0)
|
||||
if (desc->flags & AV_PIX_FMT_FLAG_PLANAR) {
|
||||
LOAD_TEXTURE_DATA(1, 1)
|
||||
|
@@ -130,8 +130,15 @@ static int xv_write_header(AVFormatContext *s)
|
||||
xv->image_width = encctx->width;
|
||||
xv->image_height = encctx->height;
|
||||
if (!xv->window_width && !xv->window_height) {
|
||||
AVRational sar = encctx->sample_aspect_ratio;
|
||||
xv->window_width = encctx->width;
|
||||
xv->window_height = encctx->height;
|
||||
if (sar.num) {
|
||||
if (sar.num > sar.den)
|
||||
xv->window_width = av_rescale(xv->window_width, sar.num, sar.den);
|
||||
if (sar.num < sar.den)
|
||||
xv->window_height = av_rescale(xv->window_height, sar.den, sar.num);
|
||||
}
|
||||
}
|
||||
xv->window = XCreateSimpleWindow(xv->display, DefaultRootWindow(xv->display),
|
||||
xv->window_x, xv->window_y,
|
||||
|
@@ -1058,11 +1058,11 @@ static int push_samples(ATempoContext *atempo,
|
||||
outlink->time_base);
|
||||
|
||||
ret = ff_filter_frame(outlink, atempo->dst_buffer);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
atempo->dst_buffer = NULL;
|
||||
atempo->dst = NULL;
|
||||
atempo->dst_end = NULL;
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
atempo->nsamples_out += n_out;
|
||||
return 0;
|
||||
|
@@ -184,7 +184,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
|
||||
s->map[i].out_channel_idx = i;
|
||||
break;
|
||||
case MAP_ONE_STR:
|
||||
if (!get_channel(&mapping, &in_ch, separator)) {
|
||||
if (get_channel(&mapping, &in_ch, separator) < 0) {
|
||||
av_log(ctx, AV_LOG_ERROR, err);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
@@ -279,7 +279,7 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *frame)
|
||||
p2 += 8 * linesize;
|
||||
}
|
||||
emms_c();
|
||||
mafd = nb_sad ? sad / nb_sad : 0;
|
||||
mafd = nb_sad ? (double)sad / nb_sad : 0;
|
||||
diff = fabs(mafd - select->prev_mafd);
|
||||
ret = av_clipf(FFMIN(mafd, diff) / 100., 0, 1);
|
||||
select->prev_mafd = mafd;
|
||||
|
@@ -38,7 +38,7 @@ static void print_formats(AVFilterContext *filter_ctx)
|
||||
for (j = 0; j < fmts->nb_formats; j++) \
|
||||
if(av_get_pix_fmt_name(fmts->formats[j])) \
|
||||
printf(#INOUT "PUT[%d] %s: fmt:%s\n", \
|
||||
i, filter_ctx->filter->inout##puts[i].name, \
|
||||
i, filter_ctx->inout##put_pads[i].name, \
|
||||
av_get_pix_fmt_name(fmts->formats[j])); \
|
||||
} else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \
|
||||
AVFilterFormats *fmts; \
|
||||
@@ -47,7 +47,7 @@ static void print_formats(AVFilterContext *filter_ctx)
|
||||
fmts = filter_ctx->inout##puts[i]->outin##_formats; \
|
||||
for (j = 0; j < fmts->nb_formats; j++) \
|
||||
printf(#INOUT "PUT[%d] %s: fmt:%s\n", \
|
||||
i, filter_ctx->filter->inout##puts[i].name, \
|
||||
i, filter_ctx->inout##put_pads[i].name, \
|
||||
av_get_sample_fmt_name(fmts->formats[j])); \
|
||||
\
|
||||
layouts = filter_ctx->inout##puts[i]->outin##_channel_layouts; \
|
||||
@@ -56,7 +56,7 @@ static void print_formats(AVFilterContext *filter_ctx)
|
||||
av_get_channel_layout_string(buf, sizeof(buf), -1, \
|
||||
layouts->channel_layouts[j]); \
|
||||
printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \
|
||||
i, filter_ctx->filter->inout##puts[i].name, buf); \
|
||||
i, filter_ctx->inout##put_pads[i].name, buf); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
@@ -113,12 +113,12 @@ int main(int argc, char **argv)
|
||||
/* create a link for each of the input pads */
|
||||
for (i = 0; i < filter_ctx->nb_inputs; i++) {
|
||||
AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
|
||||
link->type = filter_ctx->filter->inputs[i].type;
|
||||
link->type = filter_ctx->input_pads[i].type;
|
||||
filter_ctx->inputs[i] = link;
|
||||
}
|
||||
for (i = 0; i < filter_ctx->nb_outputs; i++) {
|
||||
AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
|
||||
link->type = filter_ctx->filter->outputs[i].type;
|
||||
link->type = filter_ctx->output_pads[i].type;
|
||||
filter_ctx->outputs[i] = link;
|
||||
}
|
||||
|
||||
|
@@ -31,9 +31,10 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link)
|
||||
{
|
||||
char *format;
|
||||
char layout[64];
|
||||
AVBPrint dummy_buffer = { 0 };
|
||||
|
||||
if (!buf)
|
||||
buf = &(AVBPrint){ 0 }; /* dummy buffer */
|
||||
buf = &dummy_buffer;
|
||||
switch (link->type) {
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
format = av_x_if_null(av_get_pix_fmt_name(link->format), "?");
|
||||
|
@@ -306,8 +306,8 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
|
||||
//av_log(NULL, AV_LOG_ERROR, "\n");
|
||||
}
|
||||
|
||||
p_x = (center_x - width / 2);
|
||||
p_y = (center_y - height / 2);
|
||||
p_x = (center_x - width / 2.0);
|
||||
p_y = (center_y - height / 2.0);
|
||||
t->vector.x += (cos(t->angle)-1)*p_x - sin(t->angle)*p_y;
|
||||
t->vector.y += sin(t->angle)*p_x + (cos(t->angle)-1)*p_y;
|
||||
|
||||
|
@@ -81,7 +81,7 @@ static void *load_sym(AVFilterContext *ctx, const char *sym_name)
|
||||
Frei0rContext *s = ctx->priv;
|
||||
void *sym = dlsym(s->dl_handle, sym_name);
|
||||
if (!sym)
|
||||
av_log(ctx, AV_LOG_ERROR, "Could not find symbol '%s' in loaded module\n", sym_name);
|
||||
av_log(ctx, AV_LOG_ERROR, "Could not find symbol '%s' in loaded module.\n", sym_name);
|
||||
return sym;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, cha
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
av_log(ctx, AV_LOG_ERROR, "Invalid value '%s' for parameter '%s'\n",
|
||||
av_log(ctx, AV_LOG_ERROR, "Invalid value '%s' for parameter '%s'.\n",
|
||||
param, info.name);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
@@ -202,11 +202,11 @@ static int set_params(AVFilterContext *ctx, const char *params)
|
||||
default: /* F0R_PARAM_STRING */
|
||||
v = s;
|
||||
s->get_param_value(s->instance, v, i);
|
||||
av_log(ctx, AV_LOG_DEBUG, "'%s'\n", s);
|
||||
av_log(ctx, AV_LOG_DEBUG, "'%s'", s);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
av_log(ctx, AV_LOG_VERBOSE, "\n");
|
||||
av_log(ctx, AV_LOG_VERBOSE, ".\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -217,7 +217,7 @@ static int load_path(AVFilterContext *ctx, void **handle_ptr, const char *prefix
|
||||
char *path = av_asprintf("%s%s%s", prefix, name, SLIBSUF);
|
||||
if (!path)
|
||||
return AVERROR(ENOMEM);
|
||||
av_log(ctx, AV_LOG_DEBUG, "Looking for frei0r effect in '%s'\n", path);
|
||||
av_log(ctx, AV_LOG_DEBUG, "Looking for frei0r effect in '%s'.\n", path);
|
||||
*handle_ptr = dlopen(path, RTLD_NOW|RTLD_LOCAL);
|
||||
av_free(path);
|
||||
return 0;
|
||||
@@ -288,7 +288,7 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
|
||||
return ret;
|
||||
}
|
||||
if (!s->dl_handle) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Could not find module '%s'\n", dl_name);
|
||||
av_log(ctx, AV_LOG_ERROR, "Could not find module '%s'.\n", dl_name);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
if (f0r_init() < 0) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Could not init the frei0r module\n");
|
||||
av_log(ctx, AV_LOG_ERROR, "Could not init the frei0r module.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
|
||||
pi = &s->plugin_info;
|
||||
if (pi->plugin_type != type) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"Invalid type '%s' for the plugin\n",
|
||||
"Invalid type '%s' for this plugin\n",
|
||||
pi->plugin_type == F0R_PLUGIN_TYPE_FILTER ? "filter" :
|
||||
pi->plugin_type == F0R_PLUGIN_TYPE_SOURCE ? "source" :
|
||||
pi->plugin_type == F0R_PLUGIN_TYPE_MIXER2 ? "mixer2" :
|
||||
@@ -359,7 +359,7 @@ static int config_input_props(AVFilterLink *inlink)
|
||||
if (s->destruct && s->instance)
|
||||
s->destruct(s->instance);
|
||||
if (!(s->instance = s->construct(inlink->w, inlink->h))) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance\n");
|
||||
av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
@@ -476,7 +476,11 @@ static int source_config_props(AVFilterLink *outlink)
|
||||
if (s->destruct && s->instance)
|
||||
s->destruct(s->instance);
|
||||
if (!(s->instance = s->construct(outlink->w, outlink->h))) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance\n");
|
||||
av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (!s->params) {
|
||||
av_log(ctx, AV_LOG_ERROR, "frei0r filter parameters not set.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
|
@@ -126,20 +126,21 @@ static int alloc_metrics(PullupContext *s, PullupField *f)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void free_field_queue(PullupField *head, PullupField **last)
|
||||
static void free_field_queue(PullupField *head)
|
||||
{
|
||||
PullupField *f = head;
|
||||
while (f) {
|
||||
do {
|
||||
PullupField *next;
|
||||
if (!f)
|
||||
break;
|
||||
av_free(f->diffs);
|
||||
av_free(f->combs);
|
||||
av_free(f->vars);
|
||||
if (f == *last) {
|
||||
av_freep(last);
|
||||
break;
|
||||
}
|
||||
f = f->next;
|
||||
av_freep(&f->prev);
|
||||
};
|
||||
next = f->next;
|
||||
memset(f, 0, sizeof(*f));
|
||||
av_free(f);
|
||||
f = next;
|
||||
} while (f != head);
|
||||
}
|
||||
|
||||
static PullupField *make_field_queue(PullupContext *s, int len)
|
||||
@@ -158,14 +159,14 @@ static PullupField *make_field_queue(PullupContext *s, int len)
|
||||
for (; len > 0; len--) {
|
||||
f->next = av_mallocz(sizeof(*f->next));
|
||||
if (!f->next) {
|
||||
free_field_queue(head, &f);
|
||||
free_field_queue(head);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f->next->prev = f;
|
||||
f = f->next;
|
||||
if (alloc_metrics(s, f) < 0) {
|
||||
free_field_queue(head, &f);
|
||||
free_field_queue(head);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -255,6 +256,8 @@ static int alloc_buffer(PullupContext *s, PullupBuffer *b)
|
||||
for (i = 0; i < s->nb_planes; i++) {
|
||||
b->planes[i] = av_malloc(s->planeheight[i] * s->planewidth[i]);
|
||||
}
|
||||
if (s->nb_planes == 1)
|
||||
b->planes[1] = av_malloc(4*256);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -736,7 +739,8 @@ static av_cold void uninit(AVFilterContext *ctx)
|
||||
PullupContext *s = ctx->priv;
|
||||
int i;
|
||||
|
||||
free_field_queue(s->head, &s->last);
|
||||
free_field_queue(s->head);
|
||||
s->last = NULL;
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(s->buffers); i++) {
|
||||
av_freep(&s->buffers[i].planes[0]);
|
||||
|
@@ -50,7 +50,7 @@ OBJS-$(CONFIG_RTPDEC) += rdt.o \
|
||||
rtpdec_xiph.o \
|
||||
srtp.o
|
||||
OBJS-$(CONFIG_RTPENC_CHAIN) += rtpenc_chain.o rtp.o
|
||||
OBJS-$(CONFIG_SHARED) += log2_tab.o
|
||||
OBJS-$(CONFIG_SHARED) += log2_tab.o golomb_tab.o
|
||||
|
||||
# muxers/demuxers
|
||||
OBJS-$(CONFIG_A64_MUXER) += a64.o rawenc.o
|
||||
@@ -84,7 +84,7 @@ OBJS-$(CONFIG_AST_MUXER) += ast.o astenc.o
|
||||
OBJS-$(CONFIG_AU_DEMUXER) += au.o pcm.o
|
||||
OBJS-$(CONFIG_AU_MUXER) += au.o rawenc.o
|
||||
OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o
|
||||
OBJS-$(CONFIG_AVI_MUXER) += avienc.o
|
||||
OBJS-$(CONFIG_AVI_MUXER) += avienc.o avlanguage.o
|
||||
OBJS-$(CONFIG_AVISYNTH) += avisynth.o
|
||||
OBJS-$(CONFIG_AVM2_MUXER) += swfenc.o swf.o
|
||||
OBJS-$(CONFIG_AVR_DEMUXER) += avr.o pcm.o
|
||||
@@ -203,7 +203,7 @@ OBJS-$(CONFIG_M4V_MUXER) += rawenc.o
|
||||
OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \
|
||||
isom.o rmsipr.o
|
||||
OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o \
|
||||
isom.o avc.o \
|
||||
isom.o avc.o hevc.o \
|
||||
flacenc_header.o avlanguage.o wv.o
|
||||
OBJS-$(CONFIG_MD5_MUXER) += md5enc.o
|
||||
OBJS-$(CONFIG_MGSTS_DEMUXER) += mgsts.o
|
||||
@@ -217,7 +217,7 @@ OBJS-$(CONFIG_MM_DEMUXER) += mm.o
|
||||
OBJS-$(CONFIG_MMF_DEMUXER) += mmf.o
|
||||
OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
|
||||
OBJS-$(CONFIG_MOV_DEMUXER) += mov.o isom.o mov_chan.o
|
||||
OBJS-$(CONFIG_MOV_MUXER) += movenc.o isom.o avc.o \
|
||||
OBJS-$(CONFIG_MOV_MUXER) += movenc.o isom.o avc.o hevc.o \
|
||||
movenchint.o mov_chan.o rtp.o
|
||||
OBJS-$(CONFIG_MP2_MUXER) += mp3enc.o rawenc.o id3v2enc.o
|
||||
OBJS-$(CONFIG_MP3_DEMUXER) += mp3dec.o
|
||||
|
@@ -237,7 +237,7 @@ static int aiff_read_header(AVFormatContext *s)
|
||||
break;
|
||||
case MKTAG('I', 'D', '3', ' '):
|
||||
position = avio_tell(pb);
|
||||
ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
|
||||
ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, size);
|
||||
if (id3v2_extra_meta)
|
||||
if ((ret = ff_id3v2_parse_apic(s, &id3v2_extra_meta)) < 0) {
|
||||
ff_id3v2_free_extra_meta(&id3v2_extra_meta);
|
||||
|
@@ -266,7 +266,7 @@ static void get_id3_tag(AVFormatContext *s, int len)
|
||||
{
|
||||
ID3v2ExtraMeta *id3v2_extra_meta = NULL;
|
||||
|
||||
ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
|
||||
ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, len);
|
||||
if (id3v2_extra_meta)
|
||||
ff_id3v2_parse_apic(s, &id3v2_extra_meta);
|
||||
ff_id3v2_free_extra_meta(&id3v2_extra_meta);
|
||||
|
@@ -611,6 +611,7 @@ static int asf_write_header(AVFormatContext *s)
|
||||
ASFContext *asf = s->priv_data;
|
||||
|
||||
s->packet_size = PACKET_SIZE;
|
||||
s->max_interleave_delta = 0;
|
||||
asf->nb_packets = 0;
|
||||
|
||||
asf->index_ptr = av_malloc(sizeof(ASFIndex) * ASF_INDEX_BLOCK);
|
||||
|
@@ -844,6 +844,12 @@ typedef struct AVStream {
|
||||
double (*duration_error)[2][MAX_STD_TIMEBASES];
|
||||
int64_t codec_info_duration;
|
||||
int64_t codec_info_duration_fields;
|
||||
|
||||
/**
|
||||
* 0 -> decoder has not been searched for yet.
|
||||
* >0 -> decoder found
|
||||
* <0 -> decoder with codec_id == -found_decoder has not been found
|
||||
*/
|
||||
int found_decoder;
|
||||
|
||||
int64_t last_duration;
|
||||
@@ -988,6 +994,13 @@ typedef struct AVStream {
|
||||
int64_t pts_reorder_error[MAX_REORDER_DELAY+1];
|
||||
uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1];
|
||||
|
||||
/**
|
||||
* Internal data to analyze DTS and detect faulty mpeg streams
|
||||
*/
|
||||
int64_t last_dts_for_order_check;
|
||||
uint8_t dts_ordered;
|
||||
uint8_t dts_misordered;
|
||||
|
||||
} AVStream;
|
||||
|
||||
AVRational av_stream_get_r_frame_rate(const AVStream *s);
|
||||
|
@@ -1315,7 +1315,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
AVIndexEntry *e;
|
||||
int index;
|
||||
|
||||
index = av_index_search_timestamp(st, ast->frame_offset, 0);
|
||||
index = av_index_search_timestamp(st, ast->frame_offset, AVSEEK_FLAG_ANY);
|
||||
e = &st->index_entries[index];
|
||||
|
||||
if (index >= 0 && e->timestamp == ast->frame_offset) {
|
||||
|
@@ -201,12 +201,14 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
|
||||
int64_t offset1;
|
||||
int64_t pos;
|
||||
int force = whence & AVSEEK_FORCE;
|
||||
int buffer_size;
|
||||
whence &= ~AVSEEK_FORCE;
|
||||
|
||||
if(!s)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
pos = s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer));
|
||||
buffer_size = s->buf_end - s->buffer;
|
||||
pos = s->pos - (s->write_flag ? 0 : buffer_size);
|
||||
|
||||
if (whence != SEEK_CUR && whence != SEEK_SET)
|
||||
return AVERROR(EINVAL);
|
||||
@@ -219,7 +221,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
|
||||
}
|
||||
offset1 = offset - pos;
|
||||
if (!s->must_flush && (!s->direct || !s->seek) &&
|
||||
offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) {
|
||||
offset1 >= 0 && offset1 <= buffer_size) {
|
||||
/* can do the seek inside the buffer */
|
||||
s->buf_ptr = s->buffer + offset1;
|
||||
} else if ((!s->seekable ||
|
||||
@@ -232,9 +234,20 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
|
||||
if (s->eof_reached)
|
||||
return AVERROR_EOF;
|
||||
s->buf_ptr = s->buf_end + offset - s->pos;
|
||||
} else {
|
||||
} else if(!s->write_flag && offset1 < 0 && -offset1 < buffer_size>>1 && s->seek && offset > 0) {
|
||||
int64_t res;
|
||||
|
||||
pos -= FFMIN(buffer_size>>1, pos);
|
||||
if ((res = s->seek(s->opaque, pos, SEEK_SET)) < 0)
|
||||
return res;
|
||||
s->buf_end =
|
||||
s->buf_ptr = s->buffer;
|
||||
s->pos = pos;
|
||||
s->eof_reached = 0;
|
||||
fill_buffer(s);
|
||||
return avio_seek(s, offset, SEEK_SET | force);
|
||||
} else {
|
||||
int64_t res;
|
||||
if (s->write_flag) {
|
||||
flush_buffer(s);
|
||||
s->must_flush = 1;
|
||||
|
1
libavformat/golomb_tab.c
Normal file
1
libavformat/golomb_tab.c
Normal file
@@ -0,0 +1 @@
|
||||
#include "libavcodec/golomb.c"
|
@@ -35,7 +35,7 @@ static int h263_probe(AVProbeData *p)
|
||||
for(i=0; i<p->buf_size; i++){
|
||||
code = (code<<8) + p->buf[i];
|
||||
if ((code & 0xfffffc0000) == 0x800000) {
|
||||
src_fmt= (code>>2)&3;
|
||||
src_fmt= (code>>2)&7;
|
||||
if( src_fmt != last_src_fmt
|
||||
&& last_src_fmt>0 && last_src_fmt<6
|
||||
&& src_fmt<6)
|
||||
|
1140
libavformat/hevc.c
Normal file
1140
libavformat/hevc.c
Normal file
File diff suppressed because it is too large
Load Diff
98
libavformat/hevc.h
Normal file
98
libavformat/hevc.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* internal header for HEVC (de)muxer utilities
|
||||
*/
|
||||
|
||||
#ifndef AVFORMAT_HEVC_H
|
||||
#define AVFORMAT_HEVC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "avio.h"
|
||||
|
||||
/**
|
||||
* Writes Annex B formatted HEVC NAL units to the provided AVIOContext.
|
||||
*
|
||||
* The NAL units are converted to an MP4-compatible format (start code prefixes
|
||||
* are replaced by 4-byte size fields, as per ISO/IEC 14496-15).
|
||||
*
|
||||
* If filter_ps is non-zero, any HEVC parameter sets found in the input will be
|
||||
* discarded, and *ps_count will be set to the number of discarded PS NAL units.
|
||||
*
|
||||
* @param pb address of the AVIOContext where the data shall be written
|
||||
* @param buf_in address of the buffer holding the input data
|
||||
* @param size size (in bytes) of the input buffer
|
||||
* @param filter_ps whether to write parameter set NAL units to the output (0)
|
||||
* or to discard them (non-zero)
|
||||
* @param ps_count address of the variable where the number of discarded
|
||||
* parameter set NAL units shall be written, may be NULL
|
||||
* @return the amount (in bytes) of data written in case of success, a negative
|
||||
* value corresponding to an AVERROR code in case of failure
|
||||
*/
|
||||
int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in,
|
||||
int size, int filter_ps, int *ps_count);
|
||||
|
||||
/**
|
||||
* Writes Annex B formatted HEVC NAL units to a data buffer.
|
||||
*
|
||||
* The NAL units are converted to an MP4-compatible format (start code prefixes
|
||||
* are replaced by 4-byte size fields, as per ISO/IEC 14496-15).
|
||||
*
|
||||
* If filter_ps is non-zero, any HEVC parameter sets found in the input will be
|
||||
* discarded, and *ps_count will be set to the number of discarded PS NAL units.
|
||||
*
|
||||
* On output, *size holds the size (in bytes) of the output data buffer.
|
||||
*
|
||||
* @param buf_in address of the buffer holding the input data
|
||||
* @param size address of the variable holding the size (in bytes) of the input
|
||||
* buffer (on input) and of the output buffer (on output)
|
||||
* @param buf_out address of the variable holding the address of the output
|
||||
* buffer
|
||||
* @param filter_ps whether to write parameter set NAL units to the output (0)
|
||||
* or to discard them (non-zero)
|
||||
* @param ps_count address of the variable where the number of discarded
|
||||
* parameter set NAL units shall be written, may be NULL
|
||||
* @return the amount (in bytes) of data written in case of success, a negative
|
||||
* value corresponding to an AVERROR code in case of failure
|
||||
*/
|
||||
int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
|
||||
int *size, int filter_ps, int *ps_count);
|
||||
|
||||
/**
|
||||
* Writes HEVC extradata (parameter sets, declarative SEI NAL units) to the
|
||||
* provided AVIOContext.
|
||||
*
|
||||
* If the extradata is Annex B format, it gets converted to hvcC format before
|
||||
* writing.
|
||||
*
|
||||
* @param pb address of the AVIOContext where the hvcC shall be written
|
||||
* @param data address of the buffer holding the data needed to write the hvcC
|
||||
* @param size size (in bytes) of the data buffer
|
||||
* @param ps_array_completeness whether all parameter sets are in the hvcC (1)
|
||||
* or there may be additional parameter sets in the bitstream (0)
|
||||
* @return >=0 in case of success, a negative value corresponding to an AVERROR
|
||||
* code in case of failure
|
||||
*/
|
||||
int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
|
||||
int size, int ps_array_completeness);
|
||||
|
||||
#endif /* AVFORMAT_HEVC_H */
|
@@ -49,29 +49,37 @@ typedef struct {
|
||||
unsigned char buffer[BUFFER_SIZE], *buf_ptr, *buf_end;
|
||||
int line_count;
|
||||
int http_code;
|
||||
int64_t chunksize; /**< Used if "Transfer-Encoding: chunked" otherwise -1. */
|
||||
char *content_type;
|
||||
char *user_agent;
|
||||
int64_t off, filesize, req_end_offset;
|
||||
int icy_data_read; ///< how much data was read since last ICY metadata packet
|
||||
int icy_metaint; ///< after how many bytes of read data a new metadata packet will be found
|
||||
/* Used if "Transfer-Encoding: chunked" otherwise -1. */
|
||||
int64_t chunksize;
|
||||
int64_t off, end_off, filesize;
|
||||
char *location;
|
||||
HTTPAuthState auth_state;
|
||||
HTTPAuthState proxy_auth_state;
|
||||
char *headers;
|
||||
int willclose; /**< Set if the server correctly handles Connection: close and will close the connection after feeding us the content. */
|
||||
char *mime_type;
|
||||
char *user_agent;
|
||||
char *content_type;
|
||||
/* Set if the server correctly handles Connection: close and will close
|
||||
* the connection after feeding us the content. */
|
||||
int willclose;
|
||||
int seekable; /**< Control seekability, 0 = disable, 1 = enable, -1 = probe. */
|
||||
int chunked_post;
|
||||
int end_chunked_post; /**< A flag which indicates if the end of chunked encoding has been sent. */
|
||||
int end_header; /**< A flag which indicates we have finished to read POST reply. */
|
||||
int multiple_requests; /**< A flag which indicates if we use persistent connections. */
|
||||
/* A flag which indicates if the end of chunked encoding has been sent. */
|
||||
int end_chunked_post;
|
||||
/* A flag which indicates we have finished to read POST reply. */
|
||||
int end_header;
|
||||
/* A flag which indicates if we use persistent connections. */
|
||||
int multiple_requests;
|
||||
uint8_t *post_data;
|
||||
int post_datalen;
|
||||
int is_akamai;
|
||||
int is_mediagateway;
|
||||
char *mime_type;
|
||||
char *cookies; ///< holds newline (\n) delimited Set-Cookie header field values (without the "Set-Cookie: " field name)
|
||||
int icy;
|
||||
/* how much data was read since the last ICY metadata packet */
|
||||
int icy_data_read;
|
||||
/* after how many bytes of read data a new metadata packet will be found */
|
||||
int icy_metaint;
|
||||
char *icy_metadata_headers;
|
||||
char *icy_metadata_packet;
|
||||
#if CONFIG_ZLIB
|
||||
@@ -91,22 +99,23 @@ static const AVOption options[] = {
|
||||
{"seekable", "control seekability of connection", OFFSET(seekable), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, D },
|
||||
{"chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
|
||||
{"headers", "set custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
|
||||
{"content_type", "force a content type", OFFSET(content_type), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
|
||||
{"content_type", "set a specific content type for the POST messages", OFFSET(content_type), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
|
||||
{"user_agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = DEFAULT_USER_AGENT}, 0, 0, D },
|
||||
{"user-agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = DEFAULT_USER_AGENT}, 0, 0, D },
|
||||
{"multiple_requests", "use persistent connections", OFFSET(multiple_requests), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D|E },
|
||||
{"post_data", "set custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D|E },
|
||||
{"mime_type", "set MIME type", OFFSET(mime_type), AV_OPT_TYPE_STRING, {0}, 0, 0, 0 },
|
||||
{"mime_type", "export the MIME type", OFFSET(mime_type), AV_OPT_TYPE_STRING, {0}, 0, 0, AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY },
|
||||
{"cookies", "set cookies to be sent in applicable future requests, use newline delimited Set-Cookie HTTP field value syntax", OFFSET(cookies), AV_OPT_TYPE_STRING, {0}, 0, 0, D },
|
||||
{"icy", "request ICY metadata", OFFSET(icy), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D },
|
||||
{"icy_metadata_headers", "return ICY metadata headers", OFFSET(icy_metadata_headers), AV_OPT_TYPE_STRING, {0}, 0, 0, 0 },
|
||||
{"icy_metadata_packet", "return current ICY metadata packet", OFFSET(icy_metadata_packet), AV_OPT_TYPE_STRING, {0}, 0, 0, 0 },
|
||||
{"icy_metadata_headers", "return ICY metadata headers", OFFSET(icy_metadata_headers), AV_OPT_TYPE_STRING, {0}, 0, 0, AV_OPT_FLAG_EXPORT },
|
||||
{"icy_metadata_packet", "return current ICY metadata packet", OFFSET(icy_metadata_packet), AV_OPT_TYPE_STRING, {0}, 0, 0, AV_OPT_FLAG_EXPORT },
|
||||
{"auth_type", "HTTP authentication type", OFFSET(auth_state.auth_type), AV_OPT_TYPE_INT, {.i64 = HTTP_AUTH_NONE}, HTTP_AUTH_NONE, HTTP_AUTH_BASIC, D|E, "auth_type" },
|
||||
{"none", "No auth method set, autodetect", 0, AV_OPT_TYPE_CONST, {.i64 = HTTP_AUTH_NONE}, 0, 0, D|E, "auth_type" },
|
||||
{"basic", "HTTP basic authentication", 0, AV_OPT_TYPE_CONST, {.i64 = HTTP_AUTH_BASIC}, 0, 0, D|E, "auth_type" },
|
||||
{"send_expect_100", "Force sending an Expect: 100-continue header for POST", OFFSET(send_expect_100), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, E },
|
||||
{"location", "The actual location of the data received", OFFSET(location), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
|
||||
{"offset", "initial byte offset", OFFSET(off), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, D },
|
||||
{"end_offset", "try to limit the request to bytes preceding this offset", OFFSET(req_end_offset), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, D },
|
||||
{"end_offset", "try to limit the request to bytes preceding this offset", OFFSET(end_off), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, D },
|
||||
{NULL}
|
||||
};
|
||||
#define HTTP_CLASS(flavor)\
|
||||
@@ -287,7 +296,7 @@ static int http_getc(HTTPContext *s)
|
||||
if (len < 0) {
|
||||
return len;
|
||||
} else if (len == 0) {
|
||||
return -1;
|
||||
return AVERROR_EOF;
|
||||
} else {
|
||||
s->buf_ptr = s->buffer;
|
||||
s->buf_end = s->buffer + len;
|
||||
@@ -320,11 +329,110 @@ static int http_get_line(HTTPContext *s, char *line, int line_size)
|
||||
}
|
||||
}
|
||||
|
||||
static int check_http_code(URLContext *h, int http_code, const char *end)
|
||||
{
|
||||
HTTPContext *s = h->priv_data;
|
||||
/* error codes are 4xx and 5xx, but regard 401 as a success, so we
|
||||
* don't abort until all headers have been parsed. */
|
||||
if (http_code >= 400 && http_code < 600 &&
|
||||
(http_code != 401 || s->auth_state.auth_type != HTTP_AUTH_NONE) &&
|
||||
(http_code != 407 || s->proxy_auth_state.auth_type != HTTP_AUTH_NONE)) {
|
||||
end += strspn(end, SPACE_CHARS);
|
||||
av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n", http_code, end);
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_location(HTTPContext *s, const char *p)
|
||||
{
|
||||
char redirected_location[MAX_URL_SIZE], *new_loc;
|
||||
ff_make_absolute_url(redirected_location, sizeof(redirected_location),
|
||||
s->location, p);
|
||||
new_loc = av_strdup(redirected_location);
|
||||
if (!new_loc)
|
||||
return AVERROR(ENOMEM);
|
||||
av_free(s->location);
|
||||
s->location = new_loc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* "bytes $from-$to/$document_size" */
|
||||
static void parse_content_range(URLContext *h, const char *p)
|
||||
{
|
||||
HTTPContext *s = h->priv_data;
|
||||
const char *slash;
|
||||
|
||||
if (!strncmp(p, "bytes ", 6)) {
|
||||
p += 6;
|
||||
s->off = strtoll(p, NULL, 10);
|
||||
if ((slash = strchr(p, '/')) && strlen(slash) > 0)
|
||||
s->filesize = strtoll(slash+1, NULL, 10);
|
||||
}
|
||||
if (s->seekable == -1 && (!s->is_akamai || s->filesize != 2147483647))
|
||||
h->is_streamed = 0; /* we _can_ in fact seek */
|
||||
}
|
||||
|
||||
static int parse_content_encoding(URLContext *h, const char *p)
|
||||
{
|
||||
HTTPContext *s = h->priv_data;
|
||||
|
||||
if (!av_strncasecmp(p, "gzip", 4) ||
|
||||
!av_strncasecmp(p, "deflate", 7)) {
|
||||
#if CONFIG_ZLIB
|
||||
s->compressed = 1;
|
||||
inflateEnd(&s->inflate_stream);
|
||||
if (inflateInit2(&s->inflate_stream, 32 + 15) != Z_OK) {
|
||||
av_log(h, AV_LOG_WARNING, "Error during zlib initialisation: %s\n",
|
||||
s->inflate_stream.msg);
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
if (zlibCompileFlags() & (1 << 17)) {
|
||||
av_log(h, AV_LOG_WARNING,
|
||||
"Your zlib was compiled without gzip support.\n");
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
#else
|
||||
av_log(h, AV_LOG_WARNING,
|
||||
"Compressed (%s) content, need zlib with gzip support\n", p);
|
||||
return AVERROR(ENOSYS);
|
||||
#endif
|
||||
} else if (!av_strncasecmp(p, "identity", 8)) {
|
||||
// The normal, no-encoding case (although servers shouldn't include
|
||||
// the header at all if this is the case).
|
||||
} else {
|
||||
av_log(h, AV_LOG_WARNING, "Unknown content coding: %s\n", p);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Concat all Icy- header lines
|
||||
static int parse_icy(HTTPContext *s, const char *tag, const char *p)
|
||||
{
|
||||
int len = 4 + strlen(p) + strlen(tag);
|
||||
int is_first = !s->icy_metadata_headers;
|
||||
int ret;
|
||||
|
||||
if (s->icy_metadata_headers)
|
||||
len += strlen(s->icy_metadata_headers);
|
||||
|
||||
if ((ret = av_reallocp(&s->icy_metadata_headers, len)) < 0)
|
||||
return ret;
|
||||
|
||||
if (is_first)
|
||||
*s->icy_metadata_headers = '\0';
|
||||
|
||||
av_strlcatf(s->icy_metadata_headers, len, "%s: %s\n", tag, p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_line(URLContext *h, char *line, int line_count,
|
||||
int *new_location)
|
||||
{
|
||||
HTTPContext *s = h->priv_data;
|
||||
char *tag, *p, *end;
|
||||
int ret;
|
||||
|
||||
/* end of header */
|
||||
if (line[0] == '\0') {
|
||||
@@ -342,16 +450,8 @@ static int process_line(URLContext *h, char *line, int line_count,
|
||||
|
||||
av_log(h, AV_LOG_DEBUG, "http_code=%d\n", s->http_code);
|
||||
|
||||
/* error codes are 4xx and 5xx, but regard 401 as a success, so we
|
||||
* don't abort until all headers have been parsed. */
|
||||
if (s->http_code >= 400 && s->http_code < 600 && (s->http_code != 401
|
||||
|| s->auth_state.auth_type != HTTP_AUTH_NONE) &&
|
||||
(s->http_code != 407 || s->proxy_auth_state.auth_type != HTTP_AUTH_NONE)) {
|
||||
end += strspn(end, SPACE_CHARS);
|
||||
av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n",
|
||||
s->http_code, end);
|
||||
return -1;
|
||||
}
|
||||
if ((ret = check_http_code(h, s->http_code, end)) < 0)
|
||||
return ret;
|
||||
} else {
|
||||
while (*p != '\0' && *p != ':')
|
||||
p++;
|
||||
@@ -364,40 +464,28 @@ static int process_line(URLContext *h, char *line, int line_count,
|
||||
while (av_isspace(*p))
|
||||
p++;
|
||||
if (!av_strcasecmp(tag, "Location")) {
|
||||
char redirected_location[MAX_URL_SIZE], *new_loc;
|
||||
ff_make_absolute_url(redirected_location, sizeof(redirected_location),
|
||||
s->location, p);
|
||||
new_loc = av_strdup(redirected_location);
|
||||
if (!new_loc)
|
||||
return AVERROR(ENOMEM);
|
||||
av_free(s->location);
|
||||
s->location = new_loc;
|
||||
if ((ret = parse_location(s, p)) < 0)
|
||||
return ret;
|
||||
*new_location = 1;
|
||||
} else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) {
|
||||
} else if (!av_strcasecmp(tag, "Content-Length") && s->filesize == -1) {
|
||||
s->filesize = strtoll(p, NULL, 10);
|
||||
} else if (!av_strcasecmp (tag, "Content-Range")) {
|
||||
/* "bytes $from-$to/$document_size" */
|
||||
const char *slash;
|
||||
if (!strncmp (p, "bytes ", 6)) {
|
||||
p += 6;
|
||||
s->off = strtoll(p, NULL, 10);
|
||||
if ((slash = strchr(p, '/')) && strlen(slash) > 0)
|
||||
s->filesize = strtoll(slash+1, NULL, 10);
|
||||
}
|
||||
if (s->seekable == -1 && (!s->is_akamai || s->filesize != 2147483647))
|
||||
h->is_streamed = 0; /* we _can_ in fact seek */
|
||||
} else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5) && s->seekable == -1) {
|
||||
} else if (!av_strcasecmp(tag, "Content-Range")) {
|
||||
parse_content_range(h, p);
|
||||
} else if (!av_strcasecmp(tag, "Accept-Ranges") &&
|
||||
!strncmp(p, "bytes", 5) &&
|
||||
s->seekable == -1) {
|
||||
h->is_streamed = 0;
|
||||
} else if (!av_strcasecmp (tag, "Transfer-Encoding") && !av_strncasecmp(p, "chunked", 7)) {
|
||||
} else if (!av_strcasecmp(tag, "Transfer-Encoding") &&
|
||||
!av_strncasecmp(p, "chunked", 7)) {
|
||||
s->filesize = -1;
|
||||
s->chunksize = 0;
|
||||
} else if (!av_strcasecmp (tag, "WWW-Authenticate")) {
|
||||
} else if (!av_strcasecmp(tag, "WWW-Authenticate")) {
|
||||
ff_http_auth_handle_header(&s->auth_state, tag, p);
|
||||
} else if (!av_strcasecmp (tag, "Authentication-Info")) {
|
||||
} else if (!av_strcasecmp(tag, "Authentication-Info")) {
|
||||
ff_http_auth_handle_header(&s->auth_state, tag, p);
|
||||
} else if (!av_strcasecmp (tag, "Proxy-Authenticate")) {
|
||||
} else if (!av_strcasecmp(tag, "Proxy-Authenticate")) {
|
||||
ff_http_auth_handle_header(&s->proxy_auth_state, tag, p);
|
||||
} else if (!av_strcasecmp (tag, "Connection")) {
|
||||
} else if (!av_strcasecmp(tag, "Connection")) {
|
||||
if (!strcmp(p, "close"))
|
||||
s->willclose = 1;
|
||||
} else if (!av_strcasecmp (tag, "Server")) {
|
||||
@@ -407,7 +495,8 @@ static int process_line(URLContext *h, char *line, int line_count,
|
||||
s->is_mediagateway = 1;
|
||||
}
|
||||
} else if (!av_strcasecmp (tag, "Content-Type")) {
|
||||
av_free(s->mime_type); s->mime_type = av_strdup(p);
|
||||
av_free(s->mime_type);
|
||||
s->mime_type = av_strdup(p);
|
||||
} else if (!av_strcasecmp (tag, "Set-Cookie")) {
|
||||
if (!s->cookies) {
|
||||
if (!(s->cookies = av_strdup(p)))
|
||||
@@ -425,37 +514,11 @@ static int process_line(URLContext *h, char *line, int line_count,
|
||||
} else if (!av_strcasecmp (tag, "Icy-MetaInt")) {
|
||||
s->icy_metaint = strtoll(p, NULL, 10);
|
||||
} else if (!av_strncasecmp(tag, "Icy-", 4)) {
|
||||
// Concat all Icy- header lines
|
||||
char *buf = av_asprintf("%s%s: %s\n",
|
||||
s->icy_metadata_headers ? s->icy_metadata_headers : "", tag, p);
|
||||
if (!buf)
|
||||
return AVERROR(ENOMEM);
|
||||
av_freep(&s->icy_metadata_headers);
|
||||
s->icy_metadata_headers = buf;
|
||||
} else if (!av_strcasecmp (tag, "Content-Encoding")) {
|
||||
if (!av_strncasecmp(p, "gzip", 4) || !av_strncasecmp(p, "deflate", 7)) {
|
||||
#if CONFIG_ZLIB
|
||||
s->compressed = 1;
|
||||
inflateEnd(&s->inflate_stream);
|
||||
if (inflateInit2(&s->inflate_stream, 32 + 15) != Z_OK) {
|
||||
av_log(h, AV_LOG_WARNING, "Error during zlib initialisation: %s\n",
|
||||
s->inflate_stream.msg);
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
if (zlibCompileFlags() & (1 << 17)) {
|
||||
av_log(h, AV_LOG_WARNING, "Your zlib was compiled without gzip support.\n");
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
#else
|
||||
av_log(h, AV_LOG_WARNING, "Compressed (%s) content, need zlib with gzip support\n", p);
|
||||
return AVERROR(ENOSYS);
|
||||
#endif
|
||||
} else if (!av_strncasecmp(p, "identity", 8)) {
|
||||
// The normal, no-encoding case (although servers shouldn't include
|
||||
// the header at all if this is the case).
|
||||
} else {
|
||||
av_log(h, AV_LOG_WARNING, "Unknown content coding: %s\n", p);
|
||||
}
|
||||
if ((ret = parse_icy(s, tag, p)) < 0)
|
||||
return ret;
|
||||
} else if (!av_strcasecmp(tag, "Content-Encoding")) {
|
||||
if ((ret = parse_content_encoding(h, p)) < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@@ -648,12 +711,12 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
|
||||
// Note: we send this on purpose even when s->off is 0 when we're probing,
|
||||
// since it allows us to detect more reliably if a (non-conforming)
|
||||
// server supports seeking by analysing the reply headers.
|
||||
if (!has_header(s->headers, "\r\nRange: ") && !post && (s->off > 0 || s->req_end_offset || s->seekable == -1)) {
|
||||
if (!has_header(s->headers, "\r\nRange: ") && !post && (s->off > 0 || s->end_off || s->seekable == -1)) {
|
||||
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
||||
"Range: bytes=%"PRId64"-", s->off);
|
||||
if (s->req_end_offset)
|
||||
if (s->end_off)
|
||||
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
||||
"%"PRId64, s->req_end_offset - 1);
|
||||
"%"PRId64, s->end_off - 1);
|
||||
len += av_strlcpy(headers + len, "\r\n",
|
||||
sizeof(headers) - len);
|
||||
}
|
||||
@@ -677,6 +740,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
|
||||
if (!has_header(s->headers, "\r\nContent-Length: ") && s->post_data)
|
||||
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
||||
"Content-Length: %d\r\n", s->post_datalen);
|
||||
|
||||
if (!has_header(s->headers, "\r\nContent-Type: ") && s->content_type)
|
||||
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
||||
"Content-Type: %s\r\n", s->content_type);
|
||||
@@ -768,7 +832,6 @@ static int http_buf_read(URLContext *h, uint8_t *buf, int size)
|
||||
}
|
||||
if (len > 0) {
|
||||
s->off += len;
|
||||
s->icy_data_read += len;
|
||||
if (s->chunksize > 0)
|
||||
s->chunksize -= len;
|
||||
}
|
||||
@@ -807,7 +870,7 @@ static int http_buf_read_compressed(URLContext *h, uint8_t *buf, int size)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int http_read(URLContext *h, uint8_t *buf, int size)
|
||||
static int http_read_stream(URLContext *h, uint8_t *buf, int size)
|
||||
{
|
||||
HTTPContext *s = h->priv_data;
|
||||
int err, new_location;
|
||||
@@ -842,32 +905,6 @@ static int http_read(URLContext *h, uint8_t *buf, int size)
|
||||
}
|
||||
size = FFMIN(size, s->chunksize);
|
||||
}
|
||||
if (s->icy_metaint > 0) {
|
||||
int remaining = s->icy_metaint - s->icy_data_read; /* until next metadata packet */
|
||||
if (!remaining) {
|
||||
// The metadata packet is variable sized. It has a 1 byte header
|
||||
// which sets the length of the packet (divided by 16). If it's 0,
|
||||
// the metadata doesn't change. After the packet, icy_metaint bytes
|
||||
// of normal data follow.
|
||||
int ch = http_getc(s);
|
||||
if (ch < 0)
|
||||
return ch;
|
||||
if (ch > 0) {
|
||||
char data[255 * 16 + 1];
|
||||
int n;
|
||||
int ret;
|
||||
ch *= 16;
|
||||
for (n = 0; n < ch; n++)
|
||||
data[n] = http_getc(s);
|
||||
data[ch + 1] = 0;
|
||||
if ((ret = av_opt_set(s, "icy_metadata_packet", data, 0)) < 0)
|
||||
return ret;
|
||||
}
|
||||
s->icy_data_read = 0;
|
||||
remaining = s->icy_metaint;
|
||||
}
|
||||
size = FFMIN(size, remaining);
|
||||
}
|
||||
#if CONFIG_ZLIB
|
||||
if (s->compressed)
|
||||
return http_buf_read_compressed(h, buf, size);
|
||||
@@ -875,6 +912,72 @@ static int http_read(URLContext *h, uint8_t *buf, int size)
|
||||
return http_buf_read(h, buf, size);
|
||||
}
|
||||
|
||||
// Like http_read_stream(), but no short reads.
|
||||
// Assumes partial reads are an error.
|
||||
static int http_read_stream_all(URLContext *h, uint8_t *buf, int size)
|
||||
{
|
||||
int pos = 0;
|
||||
while (pos < size) {
|
||||
int len = http_read_stream(h, buf + pos, size - pos);
|
||||
if (len < 0)
|
||||
return len;
|
||||
pos += len;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int store_icy(URLContext *h, int size)
|
||||
{
|
||||
HTTPContext *s = h->priv_data;
|
||||
/* until next metadata packet */
|
||||
int remaining = s->icy_metaint - s->icy_data_read;
|
||||
|
||||
if (remaining < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (!remaining) {
|
||||
// The metadata packet is variable sized. It has a 1 byte header
|
||||
// which sets the length of the packet (divided by 16). If it's 0,
|
||||
// the metadata doesn't change. After the packet, icy_metaint bytes
|
||||
// of normal data follow.
|
||||
uint8_t ch;
|
||||
int len = http_read_stream_all(h, &ch, 1);
|
||||
if (len < 0)
|
||||
return len;
|
||||
if (ch > 0) {
|
||||
char data[255 * 16 + 1];
|
||||
int ret;
|
||||
len = ch * 16;
|
||||
ret = http_read_stream_all(h, data, len);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
data[len + 1] = 0;
|
||||
if ((ret = av_opt_set(s, "icy_metadata_packet", data, 0)) < 0)
|
||||
return ret;
|
||||
}
|
||||
s->icy_data_read = 0;
|
||||
remaining = s->icy_metaint;
|
||||
}
|
||||
|
||||
return FFMIN(size, remaining);
|
||||
}
|
||||
|
||||
static int http_read(URLContext *h, uint8_t *buf, int size)
|
||||
{
|
||||
HTTPContext *s = h->priv_data;
|
||||
|
||||
if (s->icy_metaint > 0) {
|
||||
size = store_icy(h, size);
|
||||
if (size < 0)
|
||||
return size;
|
||||
}
|
||||
|
||||
size = http_read_stream(h, buf, size);
|
||||
if (size > 0)
|
||||
s->icy_data_read += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
/* used only when posting data */
|
||||
static int http_write(URLContext *h, const uint8_t *buf, int size)
|
||||
{
|
||||
@@ -945,15 +1048,16 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
|
||||
URLContext *old_hd = s->hd;
|
||||
int64_t old_off = s->off;
|
||||
uint8_t old_buf[BUFFER_SIZE];
|
||||
int old_buf_size;
|
||||
int old_buf_size, ret;
|
||||
AVDictionary *options = NULL;
|
||||
|
||||
if (whence == AVSEEK_SIZE)
|
||||
return s->filesize;
|
||||
else if ((whence == SEEK_CUR && off == 0) || (whence == SEEK_SET && off == s->off))
|
||||
else if ((whence == SEEK_CUR && off == 0) ||
|
||||
(whence == SEEK_SET && off == s->off))
|
||||
return s->off;
|
||||
else if ((s->filesize == -1 && whence == SEEK_END) || h->is_streamed)
|
||||
return -1;
|
||||
return AVERROR(ENOSYS);
|
||||
|
||||
/* we save the old context in case the seek fails */
|
||||
old_buf_size = s->buf_end - s->buf_ptr;
|
||||
@@ -967,14 +1071,14 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
|
||||
|
||||
/* if it fails, continue on old connection */
|
||||
av_dict_copy(&options, s->chained_options, 0);
|
||||
if (http_open_cnx(h, &options) < 0) {
|
||||
if ((ret = http_open_cnx(h, &options)) < 0) {
|
||||
av_dict_free(&options);
|
||||
memcpy(s->buffer, old_buf, old_buf_size);
|
||||
s->buf_ptr = s->buffer;
|
||||
s->buf_end = s->buffer + old_buf_size;
|
||||
s->hd = old_hd;
|
||||
s->off = old_off;
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
av_dict_free(&options);
|
||||
ffurl_close(old_hd);
|
||||
|
@@ -878,16 +878,25 @@ error:
|
||||
|
||||
static void id3v2_read_internal(AVIOContext *pb, AVDictionary **metadata,
|
||||
AVFormatContext *s, const char *magic,
|
||||
ID3v2ExtraMeta **extra_meta)
|
||||
ID3v2ExtraMeta **extra_meta, int64_t max_search_size)
|
||||
{
|
||||
int len, ret;
|
||||
uint8_t buf[ID3v2_HEADER_SIZE];
|
||||
int found_header;
|
||||
int64_t off;
|
||||
int64_t start, off;
|
||||
|
||||
if (max_search_size && max_search_size < ID3v2_HEADER_SIZE)
|
||||
return;
|
||||
|
||||
start = avio_tell(pb);
|
||||
do {
|
||||
/* save the current offset in case there's nothing to read/skip */
|
||||
off = avio_tell(pb);
|
||||
if (max_search_size && off - start >= max_search_size - ID3v2_HEADER_SIZE) {
|
||||
avio_seek(pb, off, SEEK_SET);
|
||||
break;
|
||||
}
|
||||
|
||||
ret = avio_read(pb, buf, ID3v2_HEADER_SIZE);
|
||||
if (ret != ID3v2_HEADER_SIZE) {
|
||||
avio_seek(pb, off, SEEK_SET);
|
||||
@@ -914,13 +923,13 @@ static void id3v2_read_internal(AVIOContext *pb, AVDictionary **metadata,
|
||||
void ff_id3v2_read_dict(AVIOContext *pb, AVDictionary **metadata,
|
||||
const char *magic, ID3v2ExtraMeta **extra_meta)
|
||||
{
|
||||
id3v2_read_internal(pb, metadata, NULL, magic, extra_meta);
|
||||
id3v2_read_internal(pb, metadata, NULL, magic, extra_meta, 0);
|
||||
}
|
||||
|
||||
void ff_id3v2_read(AVFormatContext *s, const char *magic,
|
||||
ID3v2ExtraMeta **extra_meta)
|
||||
ID3v2ExtraMeta **extra_meta, unsigned int max_search_size)
|
||||
{
|
||||
id3v2_read_internal(s->pb, &s->metadata, s, magic, extra_meta);
|
||||
id3v2_read_internal(s->pb, &s->metadata, s, magic, extra_meta, max_search_size);
|
||||
}
|
||||
|
||||
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
|
||||
@@ -935,6 +944,8 @@ void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
|
||||
av_freep(¤t);
|
||||
current = next;
|
||||
}
|
||||
|
||||
*extra_meta = NULL;
|
||||
}
|
||||
|
||||
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
|
||||
|
@@ -112,8 +112,10 @@ void ff_id3v2_read_dict(AVIOContext *pb, AVDictionary **metadata, const char *ma
|
||||
*
|
||||
* @param extra_meta If not NULL, extra metadata is parsed into a list of
|
||||
* ID3v2ExtraMeta structs and *extra_meta points to the head of the list
|
||||
* @param[opt] max_search_search restrict ID3 magic number search (bytes from start)
|
||||
*/
|
||||
void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta);
|
||||
void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta,
|
||||
unsigned int max_search_size);
|
||||
|
||||
/**
|
||||
* Initialize an ID3v2 tag.
|
||||
|
@@ -33,6 +33,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
|
||||
{ AV_CODEC_ID_MOV_TEXT , 0x08 },
|
||||
{ AV_CODEC_ID_MPEG4 , 0x20 },
|
||||
{ AV_CODEC_ID_H264 , 0x21 },
|
||||
{ AV_CODEC_ID_HEVC , 0x23 },
|
||||
{ AV_CODEC_ID_AAC , 0x40 },
|
||||
{ AV_CODEC_ID_MP4ALS , 0x40 }, /* 14496-3 ALS */
|
||||
{ AV_CODEC_ID_MPEG2VIDEO , 0x61 }, /* MPEG2 Main */
|
||||
@@ -151,8 +152,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
|
||||
|
||||
{ AV_CODEC_ID_RAWVIDEO, MKTAG('W', 'R', 'A', 'W') },
|
||||
|
||||
{ AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') }, /* HEVC/H.265 which indicates parameter sets shall not be in ES */
|
||||
{ AV_CODEC_ID_HEVC, MKTAG('h', 'e', 'v', '1') }, /* HEVC/H.265 which indicates parameter sets may be in ES */
|
||||
{ AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') }, /* HEVC/H.265 which indicates parameter sets shall not be in ES */
|
||||
|
||||
{ AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */
|
||||
{ AV_CODEC_ID_H264, MKTAG('a', 'i', '5', 'p') }, /* AVC-Intra 50M 720p24/30/60 */
|
||||
|
@@ -22,6 +22,7 @@
|
||||
* @todo better probing than extensions matching
|
||||
*/
|
||||
|
||||
#define MODPLUG_STATIC
|
||||
#include <libmodplug/modplug.h>
|
||||
#include "libavutil/avstring.h"
|
||||
#include "libavutil/eval.h"
|
||||
|
@@ -35,7 +35,7 @@ const CodecTags ff_mkv_codec_tags[]={
|
||||
{"A_MPEG/L2" , AV_CODEC_ID_MP2},
|
||||
{"A_MPEG/L1" , AV_CODEC_ID_MP2},
|
||||
{"A_MPEG/L3" , AV_CODEC_ID_MP3},
|
||||
{"A_OPUS", AV_CODEC_ID_OPUS},
|
||||
{"A_OPUS" , AV_CODEC_ID_OPUS},
|
||||
{"A_OPUS/EXPERIMENTAL",AV_CODEC_ID_OPUS},
|
||||
{"A_PCM/FLOAT/IEEE" , AV_CODEC_ID_PCM_F32LE},
|
||||
{"A_PCM/FLOAT/IEEE" , AV_CODEC_ID_PCM_F64LE},
|
||||
|
@@ -44,6 +44,7 @@
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/avstring.h"
|
||||
#include "libavutil/lzo.h"
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "libavutil/dict.h"
|
||||
#if CONFIG_ZLIB
|
||||
#include <zlib.h>
|
||||
@@ -164,12 +165,12 @@ typedef struct {
|
||||
uint64_t default_duration;
|
||||
uint64_t flag_default;
|
||||
uint64_t flag_forced;
|
||||
uint64_t codec_delay;
|
||||
uint64_t seek_preroll;
|
||||
MatroskaTrackVideo video;
|
||||
MatroskaTrackAudio audio;
|
||||
MatroskaTrackOperation operation;
|
||||
EbmlList encodings;
|
||||
uint64_t codec_delay;
|
||||
|
||||
AVStream *stream;
|
||||
int64_t end_timecode;
|
||||
@@ -404,6 +405,7 @@ static EbmlSyntax matroska_track[] = {
|
||||
{ MATROSKA_ID_TRACKTYPE, EBML_UINT, 0, offsetof(MatroskaTrack,type) },
|
||||
{ MATROSKA_ID_CODECID, EBML_STR, 0, offsetof(MatroskaTrack,codec_id) },
|
||||
{ MATROSKA_ID_CODECPRIVATE, EBML_BIN, 0, offsetof(MatroskaTrack,codec_priv) },
|
||||
{ MATROSKA_ID_CODECDELAY, EBML_UINT, 0, offsetof(MatroskaTrack,codec_delay) },
|
||||
{ MATROSKA_ID_TRACKLANGUAGE, EBML_UTF8, 0, offsetof(MatroskaTrack,language), {.s="eng"} },
|
||||
{ MATROSKA_ID_TRACKDEFAULTDURATION, EBML_UINT, 0, offsetof(MatroskaTrack,default_duration) },
|
||||
{ MATROSKA_ID_TRACKTIMECODESCALE, EBML_FLOAT,0, offsetof(MatroskaTrack,time_scale), {.f=1.0} },
|
||||
@@ -414,7 +416,6 @@ static EbmlSyntax matroska_track[] = {
|
||||
{ MATROSKA_ID_TRACKOPERATION, EBML_NEST, 0, offsetof(MatroskaTrack,operation), {.n=matroska_track_operation} },
|
||||
{ MATROSKA_ID_TRACKCONTENTENCODINGS,EBML_NEST, 0, 0, {.n=matroska_track_encodings} },
|
||||
{ MATROSKA_ID_TRACKMAXBLKADDID, EBML_UINT, 0, offsetof(MatroskaTrack,max_block_additional_id) },
|
||||
{ MATROSKA_ID_CODECDELAY, EBML_UINT, 0, offsetof(MatroskaTrack,codec_delay) },
|
||||
{ MATROSKA_ID_SEEKPREROLL, EBML_UINT, 0, offsetof(MatroskaTrack,seek_preroll) },
|
||||
{ MATROSKA_ID_TRACKFLAGENABLED, EBML_NONE },
|
||||
{ MATROSKA_ID_TRACKFLAGLACING, EBML_NONE },
|
||||
@@ -1852,6 +1853,11 @@ static int matroska_read_header(AVFormatContext *s)
|
||||
track->time_scale = 1.0;
|
||||
avpriv_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000); /* 64 bit pts in ns */
|
||||
|
||||
/* convert the delay from ns to the track timebase */
|
||||
track->codec_delay = av_rescale_q(track->codec_delay,
|
||||
(AVRational){ 1, 1000000000 },
|
||||
st->time_base);
|
||||
|
||||
st->codec->codec_id = codec_id;
|
||||
|
||||
if (strcmp(track->language, "und"))
|
||||
@@ -1934,7 +1940,7 @@ static int matroska_read_header(AVFormatContext *s)
|
||||
st->need_parsing = AVSTREAM_PARSE_HEADERS;
|
||||
if (track->codec_delay > 0) {
|
||||
st->codec->delay = av_rescale_q(track->codec_delay,
|
||||
(AVRational){1, 1000000000},
|
||||
st->time_base,
|
||||
(AVRational){1, st->codec->sample_rate});
|
||||
}
|
||||
if (track->seek_preroll > 0) {
|
||||
@@ -2615,7 +2621,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
|
||||
|
||||
if (cluster_time != (uint64_t)-1
|
||||
&& (block_time >= 0 || cluster_time >= -block_time)) {
|
||||
timecode = cluster_time + block_time;
|
||||
timecode = cluster_time + block_time - track->codec_delay;
|
||||
if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE
|
||||
&& timecode < track->end_timecode)
|
||||
is_keyframe = 0; /* overlapping subtitles are not key frame */
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avc.h"
|
||||
#include "hevc.h"
|
||||
#include "avformat.h"
|
||||
#include "avio_internal.h"
|
||||
#include "avlanguage.h"
|
||||
@@ -532,6 +533,8 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo
|
||||
ret = put_wv_codecpriv(dyn_cp, codec);
|
||||
else if (codec->codec_id == AV_CODEC_ID_H264)
|
||||
ret = ff_isom_write_avcc(dyn_cp, codec->extradata, codec->extradata_size);
|
||||
else if (codec->codec_id == AV_CODEC_ID_HEVC)
|
||||
ret = ff_isom_write_hvcc(dyn_cp, codec->extradata, codec->extradata_size, 0);
|
||||
else if (codec->codec_id == AV_CODEC_ID_ALAC) {
|
||||
if (codec->extradata_size < 36) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
@@ -942,7 +945,9 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int eleme
|
||||
end_ebml_master(s->pb, targets);
|
||||
|
||||
while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX)))
|
||||
if (av_strcasecmp(t->key, "title") && av_strcasecmp(t->key, "stereo_mode"))
|
||||
if (av_strcasecmp(t->key, "title") &&
|
||||
av_strcasecmp(t->key, "stereo_mode") &&
|
||||
av_strcasecmp(t->key, "encoding_tool"))
|
||||
mkv_write_simpletag(s->pb, t);
|
||||
|
||||
end_ebml_master(s->pb, tag);
|
||||
@@ -1147,7 +1152,10 @@ static int mkv_write_header(AVFormatContext *s)
|
||||
segment_uid[i] = av_lfg_get(&lfg);
|
||||
|
||||
put_ebml_string(pb, MATROSKA_ID_MUXINGAPP , LIBAVFORMAT_IDENT);
|
||||
put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT);
|
||||
if ((tag = av_dict_get(s->metadata, "encoding_tool", NULL, 0)))
|
||||
put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, tag->value);
|
||||
else
|
||||
put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT);
|
||||
put_ebml_binary(pb, MATROSKA_ID_SEGMENTUID, segment_uid, 16);
|
||||
} else {
|
||||
const char *ident = "Lavf";
|
||||
@@ -1363,6 +1371,10 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
|
||||
if (codec->codec_id == AV_CODEC_ID_H264 && codec->extradata_size > 0 &&
|
||||
(AV_RB24(codec->extradata) == 1 || AV_RB32(codec->extradata) == 1))
|
||||
ff_avc_parse_nal_units_buf(pkt->data, &data, &size);
|
||||
else if (codec->codec_id == AV_CODEC_ID_HEVC && codec->extradata_size > 6 &&
|
||||
(AV_RB24(codec->extradata) == 1 || AV_RB32(codec->extradata) == 1))
|
||||
/* extradata is Annex B, assume the bitstream is too and convert it */
|
||||
ff_hevc_annexb2mp4_buf(pkt->data, &data, &size, 0, NULL);
|
||||
else if (codec->codec_id == AV_CODEC_ID_WAVPACK) {
|
||||
int ret = mkv_strip_wavpack(pkt->data, &data, &size);
|
||||
if (ret < 0) {
|
||||
|
@@ -1330,6 +1330,7 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb,
|
||||
if (color_greyscale) {
|
||||
int color_index, color_dec;
|
||||
/* compute the greyscale palette */
|
||||
st->codec->bits_per_coded_sample = color_depth;
|
||||
color_count = 1 << color_depth;
|
||||
color_index = 255;
|
||||
color_dec = 256 / (color_count - 1);
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/dict.h"
|
||||
#include "hevc.h"
|
||||
#include "rtpenc.h"
|
||||
#include "mov_chan.h"
|
||||
|
||||
@@ -66,6 +67,7 @@ static const AVOption options[] = {
|
||||
{ "ism_lookahead", "Number of lookahead entries for ISM files", offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
|
||||
{ "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM},
|
||||
{ "video_track_timescale", "set timescale of all video tracks", offsetof(MOVMuxContext, video_track_timescale), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
|
||||
{ "brand", "Override major brand", offsetof(MOVMuxContext, major_brand), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = AV_OPT_FLAG_ENCODING_PARAM },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
@@ -772,6 +774,16 @@ static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack *track)
|
||||
return update_size(pb, pos);
|
||||
}
|
||||
|
||||
static int mov_write_hvcc_tag(AVIOContext *pb, MOVTrack *track)
|
||||
{
|
||||
int64_t pos = avio_tell(pb);
|
||||
|
||||
avio_wb32(pb, 0);
|
||||
ffio_wfourcc(pb, "hvcC");
|
||||
ff_isom_write_hvcc(pb, track->vos_data, track->vos_len, 0);
|
||||
return update_size(pb, pos);
|
||||
}
|
||||
|
||||
/* also used by all avid codecs (dv, imx, meridien) and their variants */
|
||||
static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
|
||||
{
|
||||
@@ -828,6 +840,7 @@ static int mp4_get_codec_tag(AVFormatContext *s, MOVTrack *track)
|
||||
return 0;
|
||||
|
||||
if (track->enc->codec_id == AV_CODEC_ID_H264) tag = MKTAG('a','v','c','1');
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_HEVC) tag = MKTAG('h','e','v','1');
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_AC3) tag = MKTAG('a','c','-','3');
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_DIRAC) tag = MKTAG('d','r','a','c');
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_MOV_TEXT) tag = MKTAG('t','x','3','g');
|
||||
@@ -906,11 +919,14 @@ static AVRational find_fps(AVFormatContext *s, AVStream *st)
|
||||
|
||||
static int mov_get_mpeg2_xdcam_codec_tag(AVFormatContext *s, MOVTrack *track)
|
||||
{
|
||||
int tag = MKTAG('m', '2', 'v', '1'); //fallback tag
|
||||
int tag = track->enc->codec_tag;
|
||||
int interlaced = track->enc->field_order > AV_FIELD_PROGRESSIVE;
|
||||
AVStream *st = track->st;
|
||||
int rate = av_q2d(find_fps(s, st));
|
||||
|
||||
if (!tag)
|
||||
tag = MKTAG('m', '2', 'v', '1'); //fallback tag
|
||||
|
||||
if (track->enc->pix_fmt == AV_PIX_FMT_YUV420P) {
|
||||
if (track->enc->width == 1280 && track->enc->height == 720) {
|
||||
if (!interlaced) {
|
||||
@@ -1226,6 +1242,8 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
|
||||
avio_wb32(pb, 0);
|
||||
} else if (track->enc->codec_id == AV_CODEC_ID_DNXHD)
|
||||
mov_write_avid_tag(pb, track);
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_HEVC)
|
||||
mov_write_hvcc_tag(pb, track);
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_H264) {
|
||||
mov_write_avcc_tag(pb, track);
|
||||
if (track->mode == MODE_IPOD)
|
||||
@@ -2208,7 +2226,8 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
mov_write_string_metadata(s, pb, "\251wrt", "composer" , 1);
|
||||
mov_write_string_metadata(s, pb, "\251alb", "album" , 1);
|
||||
mov_write_string_metadata(s, pb, "\251day", "date" , 1);
|
||||
mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1);
|
||||
if (!mov_write_string_metadata(s, pb, "\251too", "encoding_tool", 1))
|
||||
mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1);
|
||||
mov_write_string_metadata(s, pb, "\251cmt", "comment" , 1);
|
||||
mov_write_string_metadata(s, pb, "\251gen", "genre" , 1);
|
||||
mov_write_string_metadata(s, pb, "\251cpy", "copyright", 1);
|
||||
@@ -2942,7 +2961,9 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
|
||||
avio_wb32(pb, 0); /* size */
|
||||
ffio_wfourcc(pb, "ftyp");
|
||||
|
||||
if (mov->mode == MODE_3GP) {
|
||||
if (mov->major_brand && strlen(mov->major_brand) >= 4)
|
||||
ffio_wfourcc(pb, mov->major_brand);
|
||||
else if (mov->mode == MODE_3GP) {
|
||||
ffio_wfourcc(pb, has_h264 ? "3gp6" : "3gp4");
|
||||
minor = has_h264 ? 0x100 : 0x200;
|
||||
} else if (mov->mode & MODE_3G2) {
|
||||
@@ -3337,6 +3358,15 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
} else {
|
||||
size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
|
||||
}
|
||||
} else if (enc->codec_id == AV_CODEC_ID_HEVC && trk->vos_len > 6 &&
|
||||
(AV_RB24(trk->vos_data) == 1 || AV_RB32(trk->vos_data) == 1)) {
|
||||
/* extradata is Annex B, assume the bitstream is too and convert it */
|
||||
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
|
||||
ff_hevc_annexb2mp4_buf(pkt->data, &reformatted_data, &size, 0, NULL);
|
||||
avio_write(pb, reformatted_data, size);
|
||||
} else {
|
||||
size = ff_hevc_annexb2mp4(pb, pkt->data, pkt->size, 0, NULL);
|
||||
}
|
||||
} else {
|
||||
avio_write(pb, pkt->data, size);
|
||||
}
|
||||
|
@@ -173,6 +173,8 @@ typedef struct MOVMuxContext {
|
||||
|
||||
int reserved_moov_size; ///< 0 for disabled, -1 for automatic, size otherwise
|
||||
int64_t reserved_moov_pos;
|
||||
|
||||
char *major_brand;
|
||||
} MOVMuxContext;
|
||||
|
||||
#define FF_MOV_FLAG_RTP_HINT 1
|
||||
|
@@ -318,6 +318,8 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dir < 0)
|
||||
avio_seek(s->pb, FFMAX(ie->pos - 4096, 0), SEEK_SET);
|
||||
ret = avio_seek(s->pb, ie->pos, SEEK_SET);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
@@ -116,15 +116,16 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
{
|
||||
MP3Context *mp3 = s->priv_data;
|
||||
AVCodecContext *codec = s->streams[mp3->audio_stream_idx]->codec;
|
||||
int bitrate_idx;
|
||||
int best_bitrate_idx = -1;
|
||||
int best_bitrate_error= INT_MAX;
|
||||
int xing_offset;
|
||||
int32_t header, mask;
|
||||
MPADecodeHeader c;
|
||||
int srate_idx, ver = 0, i, channels;
|
||||
int needed;
|
||||
const char *vendor = (codec->flags & CODEC_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT;
|
||||
int32_t header;
|
||||
MPADecodeHeader mpah;
|
||||
int srate_idx, i, channels;
|
||||
int bitrate_idx;
|
||||
int best_bitrate_idx = -1;
|
||||
int best_bitrate_error = INT_MAX;
|
||||
int xing_offset;
|
||||
int ver = 0;
|
||||
int bytes_needed, lsf;
|
||||
const char *vendor = (codec->flags & CODEC_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT;
|
||||
|
||||
if (!s->pb->seekable || !mp3->write_xing)
|
||||
return 0;
|
||||
@@ -156,28 +157,29 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
/* dummy MPEG audio header */
|
||||
header = 0xffU << 24; // sync
|
||||
header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16; // sync/audio-version/layer 3/no crc*/
|
||||
header |= (srate_idx << 2) << 8;
|
||||
header |= (srate_idx << 2) << 8;
|
||||
header |= channels << 6;
|
||||
|
||||
for (bitrate_idx=1; bitrate_idx<15; bitrate_idx++) {
|
||||
int error;
|
||||
avpriv_mpegaudio_decode_header(&c, header | (bitrate_idx << (4+8)));
|
||||
error= FFABS(c.bit_rate - codec->bit_rate);
|
||||
if(error < best_bitrate_error){
|
||||
best_bitrate_error= error;
|
||||
best_bitrate_idx = bitrate_idx;
|
||||
for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
|
||||
int bit_rate = 1000 * avpriv_mpa_bitrate_tab[lsf][3 - 1][bitrate_idx];
|
||||
int error = FFABS(bit_rate - codec->bit_rate);
|
||||
|
||||
if (error < best_bitrate_error) {
|
||||
best_bitrate_error = error;
|
||||
best_bitrate_idx = bitrate_idx;
|
||||
}
|
||||
}
|
||||
av_assert0(best_bitrate_idx >= 0);
|
||||
|
||||
for (bitrate_idx= best_bitrate_idx;; bitrate_idx++) {
|
||||
for (bitrate_idx = best_bitrate_idx; ; bitrate_idx++) {
|
||||
int32_t mask = bitrate_idx << (4 + 8);
|
||||
if (15 == bitrate_idx)
|
||||
return -1;
|
||||
mask = bitrate_idx << (4+8);
|
||||
header |= mask;
|
||||
avpriv_mpegaudio_decode_header(&c, header);
|
||||
xing_offset=xing_offtbl[c.lsf == 1][c.nb_channels == 1];
|
||||
needed = 4 // header
|
||||
|
||||
avpriv_mpegaudio_decode_header(&mpah, header);
|
||||
xing_offset=xing_offtbl[mpah.lsf == 1][mpah.nb_channels == 1];
|
||||
bytes_needed = 4 // header
|
||||
+ xing_offset
|
||||
+ 4 // xing tag
|
||||
+ 4 // frames/size/toc flags
|
||||
@@ -187,8 +189,9 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
+ 24
|
||||
;
|
||||
|
||||
if (needed <= c.frame_size)
|
||||
if (bytes_needed <= mpah.frame_size)
|
||||
break;
|
||||
|
||||
header &= ~mask;
|
||||
}
|
||||
|
||||
@@ -199,7 +202,7 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
ffio_wfourcc(s->pb, "Xing");
|
||||
avio_wb32(s->pb, 0x01 | 0x02 | 0x04); // frames / size / TOC
|
||||
|
||||
mp3->size = c.frame_size;
|
||||
mp3->size = mpah.frame_size;
|
||||
mp3->want=1;
|
||||
mp3->seen=0;
|
||||
mp3->pos=0;
|
||||
@@ -217,7 +220,7 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
avio_w8(s->pb, 0);
|
||||
avio_wb24(s->pb, FFMAX(codec->delay - 528 - 1, 0)<<12);
|
||||
|
||||
ffio_fill(s->pb, 0, c.frame_size - needed);
|
||||
ffio_fill(s->pb, 0, mpah.frame_size - bytes_needed);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -257,7 +260,7 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
MP3Context *mp3 = s->priv_data;
|
||||
|
||||
if (pkt->data && pkt->size >= 4) {
|
||||
MPADecodeHeader c;
|
||||
MPADecodeHeader mpah;
|
||||
int av_unused base;
|
||||
uint32_t head = AV_RB32(pkt->data);
|
||||
|
||||
@@ -266,16 +269,16 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
"is invalid, writing it anyway.\n", pkt->size, head);
|
||||
return ff_raw_write_packet(s, pkt);
|
||||
}
|
||||
avpriv_mpegaudio_decode_header(&c, head);
|
||||
avpriv_mpegaudio_decode_header(&mpah, head);
|
||||
|
||||
if (!mp3->initial_bitrate)
|
||||
mp3->initial_bitrate = c.bit_rate;
|
||||
if ((c.bit_rate == 0) || (mp3->initial_bitrate != c.bit_rate))
|
||||
mp3->initial_bitrate = mpah.bit_rate;
|
||||
if ((mpah.bit_rate == 0) || (mp3->initial_bitrate != mpah.bit_rate))
|
||||
mp3->has_variable_bitrate = 1;
|
||||
|
||||
#ifdef FILTER_VBR_HEADERS
|
||||
/* filter out XING and INFO headers. */
|
||||
base = 4 + xing_offtbl[c.lsf == 1][c.nb_channels == 1];
|
||||
base = 4 + xing_offtbl[mpah.lsf == 1][mpah.nb_channels == 1];
|
||||
|
||||
if (base + 4 <= pkt->size) {
|
||||
uint32_t v = AV_RB32(pkt->data + base);
|
||||
@@ -417,14 +420,14 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
if (mp3->pics_to_write) {
|
||||
/* buffer audio packets until we get all the pictures */
|
||||
AVPacketList *pktl = av_mallocz(sizeof(*pktl));
|
||||
int ret;
|
||||
if (!pktl)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
pktl->pkt = *pkt;
|
||||
pktl->pkt.buf = av_buffer_ref(pkt->buf);
|
||||
if (!pktl->pkt.buf) {
|
||||
ret = av_copy_packet(&pktl->pkt, pkt);
|
||||
if (ret < 0) {
|
||||
av_freep(&pktl);
|
||||
return AVERROR(ENOMEM);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (mp3->queue_end)
|
||||
|
@@ -996,10 +996,7 @@ static int mpegts_push_data(MpegTSFilter *filter,
|
||||
pes->pts = AV_NOPTS_VALUE;
|
||||
pes->dts = AV_NOPTS_VALUE;
|
||||
if ((flags & 0xc0) == 0x80) {
|
||||
pes->pts = ff_parse_pes_pts(r);
|
||||
/* video pts is not monotonic, can't be used for dts */
|
||||
if (pes->st->codec->codec_type != AVMEDIA_TYPE_VIDEO)
|
||||
pes->dts = pes->pts;
|
||||
pes->dts = pes->pts = ff_parse_pes_pts(r);
|
||||
r += 5;
|
||||
} else if ((flags & 0xc0) == 0xc0) {
|
||||
pes->pts = ff_parse_pes_pts(r);
|
||||
@@ -1373,7 +1370,7 @@ static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section, int section_le
|
||||
AVStream *st;
|
||||
if (ts->pids[pid]->es_id != mp4_descr[i].es_id)
|
||||
continue;
|
||||
if (!(ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES)) {
|
||||
if (ts->pids[pid]->type != MPEGTS_PES) {
|
||||
av_log(s, AV_LOG_ERROR, "pid %x is not PES\n", pid);
|
||||
continue;
|
||||
}
|
||||
|
@@ -435,6 +435,12 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
|
||||
av_dlog(s, "compute_pkt_fields2: pts:%s dts:%s cur_dts:%s b:%d size:%d st:%d\n",
|
||||
av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), delay, pkt->size, pkt->stream_index);
|
||||
|
||||
if (pkt->duration < 0 && st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) {
|
||||
av_log(s, AV_LOG_WARNING, "Packet with invalid duration %d in stream %d\n",
|
||||
pkt->duration, pkt->stream_index);
|
||||
pkt->duration = 0;
|
||||
}
|
||||
|
||||
/* duration field */
|
||||
if (pkt->duration == 0) {
|
||||
ff_compute_frame_duration(&num, &den, st, NULL, pkt);
|
||||
|
@@ -384,7 +384,7 @@ static int vorbis_packet(AVFormatContext *s, int idx)
|
||||
* here we parse the duration of each packet in the first page and compare
|
||||
* the total duration to the page granule to find the encoder delay and
|
||||
* set the first timestamp */
|
||||
if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) {
|
||||
if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS) && (int64_t)os->granule>=0) {
|
||||
int seg, d;
|
||||
uint8_t *last_pkt = os->buf + os->pstart;
|
||||
uint8_t *next_pkt = last_pkt;
|
||||
|
@@ -293,7 +293,7 @@ static int oma_read_header(AVFormatContext *s)
|
||||
ID3v2ExtraMeta *extra_meta = NULL;
|
||||
OMAContext *oc = s->priv_data;
|
||||
|
||||
ff_id3v2_read(s, ID3v2_EA3_MAGIC, &extra_meta);
|
||||
ff_id3v2_read(s, ID3v2_EA3_MAGIC, &extra_meta, 0);
|
||||
ret = avio_read(s->pb, buf, EA3_HEADER_SIZE);
|
||||
if (ret < EA3_HEADER_SIZE)
|
||||
return -1;
|
||||
@@ -448,7 +448,7 @@ static int oma_read_probe(AVProbeData *p)
|
||||
/* This check cannot overflow as tag_len has at most 28 bits */
|
||||
if (p->buf_size < tag_len + 5)
|
||||
/* EA3 header comes late, might be outside of the probe buffer */
|
||||
return tag_len ? AVPROBE_SCORE_EXTENSION : 0;
|
||||
return tag_len ? AVPROBE_SCORE_EXTENSION/2 : 0;
|
||||
|
||||
buf += tag_len;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user