[FFmpeg-cvslog] configure: Extend the neon intrinsics check

2014-07-22 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Jul 22 
15:09:43 2014 +0300| [06a1d1323bc8afd03f085ae98d9b74e431b3534e] | committer: 
Martin Storsjö

configure: Extend the neon intrinsics check

Check for an instruction that causes the (very old) Apple GCC 4.2
to error out (unrecognizable insn).

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=06a1d1323bc8afd03f085ae98d9b74e431b3534e
---

 configure |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 6736f76..3c1c520 100755
--- a/configure
+++ b/configure
@@ -3935,7 +3935,7 @@ EOF
 
 fi
 
-check_code cc arm_neon.h int64x2_t test  enable intrinsics_neon
+check_code cc arm_neon.h int16x8_t test = vdupq_n_s16(0)  enable 
intrinsics_neon
 
 check_ldflags -Wl,--as-needed
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] librtmp: Don't free the temp url at the end of rtmp_open

2014-07-30 Thread Martin Storsjö
ffmpeg | branch: release/2.2 | Martin Storsjö mar...@martin.st | Fri Jul  4 
22:13:39 2014 +0300| [f6b3dce952d66f87883a50d90d6e98416ee397df] | committer: 
Reinhard Tartler

librtmp: Don't free the temp url at the end of rtmp_open

librtmp can keep pointers to this string internally, and may
use them at shutdown as well.

CC: libav-sta...@libav.org
Signed-off-by: Martin Storsjö mar...@martin.st
(cherry picked from commit 865461099e062de5a3a109c2a5be98004c11d8bd)
Signed-off-by: Reinhard Tartler siret...@tauware.de

Conflicts:
libavformat/librtmp.c

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f6b3dce952d66f87883a50d90d6e98416ee397df
---

 libavformat/librtmp.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
index 7133bd6..5682c9c 100644
--- a/libavformat/librtmp.c
+++ b/libavformat/librtmp.c
@@ -38,6 +38,7 @@ typedef struct LibRTMPContext {
 RTMP rtmp;
 char *app;
 char *playpath;
+char *temp_filename;
 } LibRTMPContext;
 
 static void rtmp_log(int level, const char *fmt, va_list args)
@@ -62,6 +63,7 @@ static int rtmp_close(URLContext *s)
 RTMP *r = ctx-rtmp;
 
 RTMP_Close(r);
+av_freep(ctx-temp_filename);
 return 0;
 }
 
@@ -101,7 +103,7 @@ static int rtmp_open(URLContext *s, const char *uri, int 
flags)
 if (ctx-app)  len += strlen(ctx-app)  + sizeof( app=);
 if (ctx-playpath) len += strlen(ctx-playpath) + sizeof( playpath=);
 
-if (!(filename = av_malloc(len)))
+if (!(ctx-temp_filename = filename = av_malloc(len)))
 return AVERROR(ENOMEM);
 
 av_strlcpy(filename, s-filename, len);
@@ -130,10 +132,9 @@ static int rtmp_open(URLContext *s, const char *uri, int 
flags)
 }
 
 s-is_streamed = 1;
-rc = 0;
+return 0;
 fail:
-if (filename != s-filename)
-av_freep(filename);
+av_freep(ctx-temp_filename);
 return rc;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] adpcm: Write the proper predictor in trellis mode in IMA QT

2014-08-08 Thread Martin Storsjö
ffmpeg | branch: release/1.1 | Martin Storsjö mar...@martin.st | Thu Jun  5 
14:49:14 2014 +0300| [21d3e0ac9e1719d8444b3f5466983587ac0ad240] | committer: 
Luca Barbato

adpcm: Write the proper predictor in trellis mode in IMA QT

The actual predictor value, set by the trellis code, never
was written back into the variable that was written into
the block header. This was accidentally removed in b304244b.

This significantly improves the audio quality of the trellis
case, which was plain broken since b304244b.

Encoding IMA QT with trellis still actually gives a slightly
worse quality than without trellis, since the trellis encoder
doesn't use the exact same way of rounding as in
adpcm_ima_qt_compress_sample and adpcm_ima_qt_expand_nibble.

CC: libav-sta...@libav.org
Signed-off-by: Martin Storsjö mar...@martin.st
(cherry picked from commit 0776e0ef6ba4160281ef3fabea43e670f3792b4a)
Signed-off-by: Luca Barbato lu_z...@gentoo.org

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=21d3e0ac9e1719d8444b3f5466983587ac0ad240
---

 libavcodec/adpcmenc.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 116458b..aa88395 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -561,6 +561,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
64, 1);
 for (i = 0; i  64; i++)
 put_bits(pb, 4, buf[i ^ 1]);
+status-prev_sample = status-predictor;
 } else {
 for (i = 0; i  64; i += 2) {
 int t1, t2;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] configure: Add probe identification of MS armasm

2014-08-10 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sat Aug  9 
22:25:44 2014 +0300| [f4312352fc52cc47c1ba398a33f629d32a737e91] | committer: 
Martin Storsjö

configure: Add probe identification of MS armasm

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f4312352fc52cc47c1ba398a33f629d32a737e91
---

 configure |5 +
 1 file changed, 5 insertions(+)

diff --git a/configure b/configure
index c128b29..b9626e7 100755
--- a/configure
+++ b/configure
@@ -2883,6 +2883,11 @@ probe_cc(){
 _cflags_size=-O2 -Munroll=c:1 $opt_common
 _cflags_noopt=-O1
 _flags_filter=pgi_flags
+elif $_cc 21 | grep -q 'Microsoft.*ARM.*Assembler'; then
+_type=armasm
+_ident=$($_cc | head -n1)
+# 4509: This form of conditional instruction is deprecated
+_flags=-nologo -ignore 4509
 elif $_cc 21 | grep -q Microsoft; then
 _type=msvc
 _ident=$($cc 21 | head -n1)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] configure: Don't pass MSVC compiler options -M[TD] to armasm

2014-08-10 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Aug 10 
14:40:09 2014 +0300| [08b94f160a2c966bb83e32bde0e52246fafa2155] | committer: 
Martin Storsjö

configure: Don't pass MSVC compiler options -M[TD] to armasm

The -MD option (for enabling a dynamically linked crt) gets interpreted
as a cpp option for generating dependency information (into a file named
'-.d', when preprocessing to a pipe). We shouldn't be passing
any and all C compiler flags to armasm (which is a plain assembler,
only with cpp bolted on via gas-preprocessor), but these are the
main conflicting ones.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=08b94f160a2c966bb83e32bde0e52246fafa2155
---

 configure |   12 
 1 file changed, 12 insertions(+)

diff --git a/configure b/configure
index 411af5e..a5ad34c 100755
--- a/configure
+++ b/configure
@@ -2614,6 +2614,17 @@ EOF
 die Sanity test failed.
 fi
 
+armasm_flags(){
+for flag; do
+case $flag in
+# Filter out MSVC cl.exe options from cflags that shouldn't
+# be passed to gas-preprocessor
+-M[TD]*);;
+*)  echo $flag  ;;
+esac
+   done
+}
+
 ccc_flags(){
 for flag; do
 case $flag in
@@ -2886,6 +2897,7 @@ probe_cc(){
 _ident=$($_cc | head -n1)
 # 4509: This form of conditional instruction is deprecated
 _flags=-nologo -ignore 4509
+_flags_filter=armasm_flags
 elif $_cc 21 | grep -q Microsoft; then
 _type=msvc
 _ident=$($cc 21 | head -n1)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] configure: Check for nanosleep in headers as well, not only in libs

2014-08-12 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Aug 12 
11:23:38 2014 +0200| [223c374a9d977fdfe9af94858693c632f644aac7] | committer: 
Michael Niedermayer

configure: Check for nanosleep in headers as well, not only in libs

On mingw64 with c++11 support, the link libraries do contain a
nanosleep function, while it isn't exposed via the headers. Using
check_func_headers instead of a plain check_func fixes this
misdetection.

Suggested-by: Hendrik Leppkes h.lepp...@gmail.com
See: [FFmpeg-devel] [PATCH] fix: 'make' with mingw32
Signed-off-by: Michael Niedermayer michae...@gmx.at

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=223c374a9d977fdfe9af94858693c632f644aac7
---

 configure |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 0ac6132..7e6fe0a 100755
--- a/configure
+++ b/configure
@@ -4659,7 +4659,7 @@ check_func  mkstemp
 check_func  mmap
 check_func  mprotect
 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
-check_func  nanosleep || { check_func nanosleep -lrt  add_extralibs -lrt; }
+check_func_headers time.h nanosleep || { check_func_headers time.h nanosleep 
-lrt  add_extralibs -lrt; }
 check_func  sched_getaffinity
 check_func  setrlimit
 check_struct sys/stat.h struct stat st_mtim.tv_nsec -D_BSD_SOURCE

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] configure: Check for -Werror parameters on clang

2014-08-12 Thread Martin Storsjö
ffmpeg | branch: release/0.10 | Martin Storsjö mar...@martin.st | Tue Nov 13 
19:01:51 2012 +0200| [c98d164a6a2c3d93bfb10d44c946bc3ed56f14e7] | committer: 
Luca Barbato

configure: Check for -Werror parameters on clang

Signed-off-by: Martin Storsjö mar...@martin.st
(cherry picked from commit 9eded0fe412e610ee8944681d5c554b723463e96)
Signed-off-by: Luca Barbato lu_z...@gentoo.org

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c98d164a6a2c3d93bfb10d44c946bc3ed56f14e7
---

 configure |2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure b/configure
index 13066e2..e12b88d 100755
--- a/configure
+++ b/configure
@@ -3141,6 +3141,8 @@ elif enabled llvm_gcc; then
 elif enabled clang; then
 check_cflags -mllvm -stack-alignment=16
 check_cflags -Qunused-arguments
+check_cflags -Werror=implicit-function-declaration
+check_cflags -Werror=missing-prototypes
 elif enabled armcc; then
 # 2523: use of inline assembler is deprecated
 add_cflags -W${armcc_opt},--diag_suppress=2523

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] http: Stop reading after receiving the whole file for non-chunked transfers

2014-08-13 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Aug 11 
10:18:28 2014 +0300| [8bf3bf69ad7333bf0c45f4d2797fc2c61bc8922f] | committer: 
Martin Storsjö

http: Stop reading after receiving the whole file for non-chunked transfers

Previously this logic was only used if the server didn't
respond with Connection: close, but use it even for that case,
if the server response is non-chunked.

Originally the http code has relied on Connection: close to close
the socket when the file/stream is received - the http protocol
code just kept reading from the socket until the socket was closed.
In f240ed18 we added a check for the file size, because some
http servers didn't respond with Connection: close (and wouldn't
close the socket) even though we requested it, which meant that the
http protocol blocked for a long time at the end of files, waiting
for a socket level timeout.

When reading over tls, trying to read at the end of the connection,
when the peer has closed the connection, can produce spurious (but
harmless) warnings. Therefore always voluntarily stop reading when
the specified file size has been received, if not using a chunked
transfer encoding. (For chunked transfers, we already return 0
as soon as we get the chunk header indicating end of stream.)

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8bf3bf69ad7333bf0c45f4d2797fc2c61bc8922f
---

 libavformat/http.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index ee7dbb3..b2e07b4 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -699,7 +699,8 @@ static int http_buf_read(URLContext *h, uint8_t *buf, int 
size)
 memcpy(buf, s-buf_ptr, len);
 s-buf_ptr += len;
 } else {
-if (!s-willclose  s-filesize = 0  s-off = s-filesize)
+if ((!s-willclose || s-chunksize  0) 
+s-filesize = 0  s-off = s-filesize)
 return AVERROR_EOF;
 len = ffurl_read(s-hd, buf, size);
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] w32threads: Use newer thread synchronization functions when targeting Vista

2014-08-13 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Aug  6 
09:52:38 2014 +0300| [428b0578c64241fc677fed7083cc8fe65e10f32e] | committer: 
Martin Storsjö

w32threads: Use newer thread synchronization functions when targeting Vista

When explicitly targeting Vista or newer (which only happens if the
caller explicitly sets _WIN32_WINNT to a high enough value via the
extra cflags option - otherwise configure script sets
-D_WIN32_WINNT=0x0502), we already unconditionally link to the
ConditionVariable functions, since 4622f11f9.

Similarly use the newer -Ex versions of CreateEvent, CreateSemaphore,
InitializeCriticalSection and WaitForSingleObject, that all appeared
in Vista. When building Windows Store applications, the older versions
of these functions aren't available, only the -Ex functions. When
doing such a build, the user can set -D_WIN32_WINNT=0x0600 to
forcibly use the newer functions instead.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=428b0578c64241fc677fed7083cc8fe65e10f32e
---

 compat/w32pthreads.h |   12 
 1 file changed, 12 insertions(+)

diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
index be275ed..7f4e6c9 100644
--- a/compat/w32pthreads.h
+++ b/compat/w32pthreads.h
@@ -72,6 +72,18 @@ static BOOL (WINAPI *cond_wait)(pthread_cond_t *cond, 
pthread_mutex_t *mutex,
 #define cond_broadcast WakeAllConditionVariable
 #define cond_signalWakeConditionVariable
 #define cond_wait  SleepConditionVariableCS
+
+#define CreateEvent(a, reset, init, name)   \
+CreateEventEx(a, name,  \
+  (reset ? CREATE_EVENT_MANUAL_RESET : 0) | \
+  (init ? CREATE_EVENT_INITIAL_SET : 0),\
+  EVENT_ALL_ACCESS)
+// CreateSemaphoreExA seems to be desktop-only, but as long as we don't
+// use named semaphores, it doesn't matter if we use the W version.
+#define CreateSemaphore(a, b, c, d) \
+CreateSemaphoreExW(a, b, c, d, 0, SEMAPHORE_ALL_ACCESS)
+#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
+#define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
 #endif
 
 static unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] configure: Check for nanosleep in headers as well, not only in libs

2014-08-13 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Aug 11 
15:02:28 2014 +0300| [72199e1041b4052544e181ad90b431ca6704da12] | committer: 
Martin Storsjö

configure: Check for nanosleep in headers as well, not only in libs

On mingw64 with c++11 support, the link libraries do contain a
nanosleep function, while it isn't exposed via the headers. Using
check_func_headers instead of a plain check_func fixes this
misdetection.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=72199e1041b4052544e181ad90b431ca6704da12
---

 configure |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index a5ad34c..c073f30 100755
--- a/configure
+++ b/configure
@@ -4046,7 +4046,7 @@ check_func  mkstemp
 check_func  mmap
 check_func  mprotect
 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
-check_func  nanosleep || { check_func nanosleep -lrt  add_extralibs -lrt; }
+check_func_headers time.h nanosleep || { check_func_headers time.h nanosleep 
-lrt  add_extralibs -lrt; }
 check_func  sched_getaffinity
 check_func  setrlimit
 check_func  strerror_r

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] http: Fix authentication, broken since 6a463e7fb

2014-08-13 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Aug 13 
14:32:52 2014 +0300| [4e629ef80e62a54636cb46033998177dd08cf3ad] | committer: 
Martin Storsjö

http: Fix authentication, broken since 6a463e7fb

The cur_*auth_type variables were set before the http_connect call
prior to 6a463e7fb - their sole purpose is to record the
authentication type used to do the latest request, since parsing
the http response sets the new type in the auth state.

CC: libav-sta...@libav.org
Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4e629ef80e62a54636cb46033998177dd08cf3ad
---

 libavformat/http.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 98f41c0..377d30e 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -201,14 +201,14 @@ static int http_open_cnx(URLContext *h, AVDictionary 
**options)
 HTTPContext *s = h-priv_data;
 int location_changed, attempts = 0, redirects = 0;
 redo:
+cur_auth_type   = s-auth_state.auth_type;
+cur_proxy_auth_type = s-auth_state.auth_type;
+
 location_changed = http_open_cnx_internal(h, options);
 if (location_changed  0)
 goto fail;
 
 attempts++;
-cur_auth_type   = s-auth_state.auth_type;
-cur_proxy_auth_type = s-auth_state.auth_type;
-
 if (s-http_code == 401) {
 if ((cur_auth_type == HTTP_AUTH_NONE || s-auth_state.stale) 
 s-auth_state.auth_type != HTTP_AUTH_NONE  attempts  4) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavformat: Check mkdir return error codes

2014-09-07 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Sep  5 
22:45:11 2014 +0300| [803e82276b3716bf6012ec69e8854dae14a4fd2b] | committer: 
Martin Storsjö

libavformat: Check mkdir return error codes

Previously, the returned error codes were intentionally ignored
(see fadd3a68213), to avoid aborting if the directory already
existed. If the mkdir actually failed, this was caught when
opening files within the directory fails anyway.

By handling the error code here (but explicitly ignoring EEXIST),
the error messages and return codes in these cases are more
appropriate and less confusing.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=803e82276b3716bf6012ec69e8854dae14a4fd2b
---

 libavformat/hdsenc.c |5 -
 libavformat/smoothstreamingenc.c |   10 --
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 6217c1f..882f157 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -323,7 +323,10 @@ static int hds_write_header(AVFormatContext *s)
 int ret = 0, i;
 AVOutputFormat *oformat;
 
-mkdir(s-filename, 0777);
+if (mkdir(s-filename, 0777) == -1  errno != EEXIST) {
+ret = AVERROR(errno);
+goto fail;
+}
 
 oformat = av_guess_format(flv, NULL, NULL);
 if (!oformat) {
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index 457472d..d955b343 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -292,7 +292,10 @@ static int ism_write_header(AVFormatContext *s)
 int ret = 0, i;
 AVOutputFormat *oformat;
 
-mkdir(s-filename, 0777);
+if (mkdir(s-filename, 0777) == -1  errno != EEXIST) {
+ret = AVERROR(errno);
+goto fail;
+}
 
 oformat = av_guess_format(ismv, NULL, NULL);
 if (!oformat) {
@@ -319,7 +322,10 @@ static int ism_write_header(AVFormatContext *s)
 goto fail;
 }
 snprintf(os-dirname, sizeof(os-dirname), %s/QualityLevels(%d), 
s-filename, s-streams[i]-codec-bit_rate);
-mkdir(os-dirname, 0777);
+if (mkdir(os-dirname, 0777) == -1  errno != EEXIST) {
+ret = AVERROR(errno);
+goto fail;
+}
 
 ctx = avformat_alloc_context();
 if (!ctx) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] ismindex: Avoid writing ismf files if no base name has been specified

2014-09-07 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Sep  5 
22:50:24 2014 +0300| [fcf597625c7a991ca389f3a9b8ff4f5e383301c0] | committer: 
Martin Storsjö

ismindex: Avoid writing ismf files if no base name has been specified

Previously, this could create files named (null).ismf, if the -ismf
parameter is specified (before an input file name), but without
specifying any base name.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fcf597625c7a991ca389f3a9b8ff4f5e383301c0
---

 tools/ismindex.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/ismindex.c b/tools/ismindex.c
index bc98226..aa862f8 100644
--- a/tools/ismindex.c
+++ b/tools/ismindex.c
@@ -679,6 +679,8 @@ int main(int argc, char **argv)
 } else if (argv[i][0] == '-') {
 return usage(argv[0], 1);
 } else {
+if (!basename)
+ismf = 0;
 if (handle_file(tracks, argv[i], split, ismf,
 basename, output_prefix))
 return 1;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavformat: Move avc mp4 startcode parsing to a shared file

2014-09-24 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Sep 24 
11:17:04 2014 +0300| [a2efbecc4ed12d287cf29856418c4da4a7648d95] | committer: 
Martin Storsjö

libavformat: Move avc mp4 startcode parsing to a shared file

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a2efbecc4ed12d287cf29856418c4da4a7648d95
---

 libavformat/avc.c |   17 +
 libavformat/avc.h |3 +++
 libavformat/rtpenc_h264.c |   19 ++-
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/libavformat/avc.c b/libavformat/avc.c
index 2fd5ac8..e639ed5 100644
--- a/libavformat/avc.c
+++ b/libavformat/avc.c
@@ -191,3 +191,20 @@ int ff_avc_write_annexb_extradata(const uint8_t *in, 
uint8_t **buf, int *size)
 *size = out_size;
 return 0;
 }
+
+const uint8_t *ff_avc_mp4_find_startcode(const uint8_t *start,
+ const uint8_t *end,
+ int nal_length_size)
+{
+unsigned int res = 0;
+
+if (end - start  nal_length_size)
+return NULL;
+while (nal_length_size--)
+res = (res  8) | *start++;
+
+if (res  end - start)
+return NULL;
+
+return start + res;
+}
diff --git a/libavformat/avc.h b/libavformat/avc.h
index 579756e..2442e5f 100644
--- a/libavformat/avc.h
+++ b/libavformat/avc.h
@@ -30,5 +30,8 @@ int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t 
**buf, int *size);
 int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len);
 const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end);
 int ff_avc_write_annexb_extradata(const uint8_t *in, uint8_t **buf, int *size);
+const uint8_t *ff_avc_mp4_find_startcode(const uint8_t *start,
+ const uint8_t *end,
+ int nal_length_size);
 
 #endif /* AVFORMAT_AVC_H */
diff --git a/libavformat/rtpenc_h264.c b/libavformat/rtpenc_h264.c
index 206d9ba..395c3a4 100644
--- a/libavformat/rtpenc_h264.c
+++ b/libavformat/rtpenc_h264.c
@@ -29,21 +29,6 @@
 #include avc.h
 #include rtpenc.h
 
-static const uint8_t *avc_mp4_find_startcode(const uint8_t *start, const 
uint8_t *end, int nal_length_size)
-{
-unsigned int res = 0;
-
-if (end - start  nal_length_size)
-return NULL;
-while (nal_length_size--)
-res = (res  8) | *start++;
-
-if (res  end - start)
-return NULL;
-
-return start + res;
-}
-
 static void nal_send(AVFormatContext *s1, const uint8_t *buf, int size, int 
last)
 {
 RTPMuxContext *s = s1-priv_data;
@@ -88,14 +73,14 @@ void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t 
*buf1, int size)
 
 s-timestamp = s-cur_timestamp;
 if (s-nal_length_size)
-r = avc_mp4_find_startcode(buf1, end, s-nal_length_size) ? buf1 : end;
+r = ff_avc_mp4_find_startcode(buf1, end, s-nal_length_size) ? buf1 : 
end;
 else
 r = ff_avc_find_startcode(buf1, end);
 while (r  end) {
 const uint8_t *r1;
 
 if (s-nal_length_size) {
-r1 = avc_mp4_find_startcode(r, end, s-nal_length_size);
+r1 = ff_avc_mp4_find_startcode(r, end, s-nal_length_size);
 if (!r1)
 r1 = end;
 r += s-nal_length_size;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec: Fix a doxy comment to refer to the right function

2014-09-25 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Sep 24 
23:31:43 2014 +0300| [d07ddc93e29a4fdf12cd426953a7ecd5abe5e36d] | committer: 
Martin Storsjö

avcodec: Fix a doxy comment to refer to the right function

CC: libav-sta...@libav.org
Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d07ddc93e29a4fdf12cd426953a7ecd5abe5e36d
---

 libavcodec/avcodec.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 253e45a..bc5f134 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -473,7 +473,7 @@ enum AVCodecID {
 /**
  * This struct describes the properties of a single codec described by an
  * AVCodecID.
- * @see avcodec_get_descriptor()
+ * @see avcodec_descriptor_get()
  */
 typedef struct AVCodecDescriptor {
 enum AVCodecID id;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] sdp: Simplify parsing/conversion of H264 extradata

2014-10-06 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Oct  3 
20:49:01 2014 +0300| [b76249443864c88ffb2d41ab8d1de7432e985dc7] | committer: 
Martin Storsjö

sdp: Simplify parsing/conversion of H264 extradata

By using ff_avc_write_annexb_extradata instead of the h264_mp4toannexb
BSF, the code for doing the conversion itself is kept much shorter,
there's less state to restore at the end, we don't risk leaving the
AVCodecContext in an inconsistent state if returning early due to
errors, etc.

Also add a missing free if the base64 encoding fails.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b76249443864c88ffb2d41ab8d1de7432e985dc7
---

 libavformat/sdp.c |   42 --
 1 file changed, 12 insertions(+), 30 deletions(-)

diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index eccd676..43a50d4 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -156,8 +156,9 @@ static char *extradata2psets(AVCodecContext *c)
 const uint8_t *r;
 static const char pset_string[] = ; sprop-parameter-sets=;
 static const char profile_string[] = ; profile-level-id=;
-uint8_t *orig_extradata = NULL;
-int orig_extradata_size = 0;
+uint8_t *extradata = c-extradata;
+int extradata_size = c-extradata_size;
+uint8_t *tmpbuf = NULL;
 const uint8_t *sps = NULL, *sps_end;
 
 if (c-extradata_size  MAX_EXTRADATA_SIZE) {
@@ -166,44 +167,28 @@ static char *extradata2psets(AVCodecContext *c)
 return NULL;
 }
 if (c-extradata[0] == 1) {
-uint8_t *dummy_p;
-int dummy_int;
-AVBitStreamFilterContext *bsfc= 
av_bitstream_filter_init(h264_mp4toannexb);
-
-if (!bsfc) {
-av_log(c, AV_LOG_ERROR, Cannot open the h264_mp4toannexb BSF!\n);
-
+if (ff_avc_write_annexb_extradata(c-extradata, extradata,
+  extradata_size))
 return NULL;
-}
-
-orig_extradata_size = c-extradata_size;
-orig_extradata = av_mallocz(orig_extradata_size +
-FF_INPUT_BUFFER_PADDING_SIZE);
-if (!orig_extradata) {
-av_bitstream_filter_close(bsfc);
-return NULL;
-}
-memcpy(orig_extradata, c-extradata, orig_extradata_size);
-av_bitstream_filter_filter(bsfc, c, NULL, dummy_p, dummy_int, NULL, 
0, 0);
-av_bitstream_filter_close(bsfc);
+tmpbuf = extradata;
 }
 
 psets = av_mallocz(MAX_PSET_SIZE);
 if (!psets) {
 av_log(c, AV_LOG_ERROR, Cannot allocate memory for the parameter 
sets.\n);
-av_free(orig_extradata);
+av_free(tmpbuf);
 return NULL;
 }
 memcpy(psets, pset_string, strlen(pset_string));
 p = psets + strlen(pset_string);
-r = ff_avc_find_startcode(c-extradata, c-extradata + c-extradata_size);
-while (r  c-extradata + c-extradata_size) {
+r = ff_avc_find_startcode(extradata, extradata + extradata_size);
+while (r  extradata + extradata_size) {
 const uint8_t *r1;
 uint8_t nal_type;
 
 while (!*(r++));
 nal_type = *r  0x1f;
-r1 = ff_avc_find_startcode(r, c-extradata + c-extradata_size);
+r1 = ff_avc_find_startcode(r, extradata + extradata_size);
 if (nal_type != 7  nal_type != 8) { /* Only output SPS and PPS */
 r = r1;
 continue;
@@ -219,6 +204,7 @@ static char *extradata2psets(AVCodecContext *c)
 if (!av_base64_encode(p, MAX_PSET_SIZE - (p - psets), r, r1 - r)) {
 av_log(c, AV_LOG_ERROR, Cannot Base64-encode %td %td!\n, 
MAX_PSET_SIZE - (p - psets), r1 - r);
 av_free(psets);
+av_free(tmpbuf);
 
 return NULL;
 }
@@ -231,11 +217,7 @@ static char *extradata2psets(AVCodecContext *c)
 ff_data_to_hex(p, sps + 1, 3, 0);
 p[6] = '\0';
 }
-if (orig_extradata) {
-av_free(c-extradata);
-c-extradata  = orig_extradata;
-c-extradata_size = orig_extradata_size;
-}
+av_free(tmpbuf);
 
 return psets;
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavf: Set the stream time base hint properly for chained muxers

2014-10-06 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Oct  6 
11:41:33 2014 +0300| [28816050e47b6dba430a52e429d21a864cffda8e] | committer: 
Martin Storsjö

lavf: Set the stream time base hint properly for chained muxers

This avoids warnings about using the codec time base as time
base hint.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=28816050e47b6dba430a52e429d21a864cffda8e
---

 libavformat/hdsenc.c |1 +
 libavformat/hlsenc.c |1 +
 libavformat/mpegtsenc.c  |1 +
 libavformat/segment.c|1 +
 libavformat/smoothstreamingenc.c |1 +
 5 files changed, 5 insertions(+)

diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 882f157..53fef33 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -398,6 +398,7 @@ static int hds_write_header(AVFormatContext *s)
 }
 avcodec_copy_context(st-codec, s-streams[i]-codec);
 st-sample_aspect_ratio = s-streams[i]-sample_aspect_ratio;
+st-time_base = s-streams[i]-time_base;
 }
 if (c-streams[c-nb_streams].ctx)
 c-nb_streams++;
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 5d18d13..ad53df5 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -80,6 +80,7 @@ static int hls_mux_init(AVFormatContext *s)
 return AVERROR(ENOMEM);
 avcodec_copy_context(st-codec, s-streams[i]-codec);
 st-sample_aspect_ratio = s-streams[i]-sample_aspect_ratio;
+st-time_base = s-streams[i]-time_base;
 }
 
 return 0;
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 7621103..1082650 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -604,6 +604,7 @@ static int mpegts_write_header(AVFormatContext *s)
 ret = avcodec_copy_context(ast-codec, st-codec);
 if (ret != 0)
 goto fail;
+ast-time_base = st-time_base;
 ret = avformat_write_header(ts_st-amux, NULL);
 if (ret  0)
 goto fail;
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 9c757e4..52da6b9 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -74,6 +74,7 @@ static int segment_mux_init(AVFormatContext *s)
 return AVERROR(ENOMEM);
 avcodec_copy_context(st-codec, s-streams[i]-codec);
 st-sample_aspect_ratio = s-streams[i]-sample_aspect_ratio;
+st-time_base = s-streams[i]-time_base;
 }
 
 return 0;
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index d955b343..b9f1dcb 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -342,6 +342,7 @@ static int ism_write_header(AVFormatContext *s)
 }
 avcodec_copy_context(st-codec, s-streams[i]-codec);
 st-sample_aspect_ratio = s-streams[i]-sample_aspect_ratio;
+st-time_base = s-streams[i]-time_base;
 
 ctx-pb = avio_alloc_context(os-iobuf, sizeof(os-iobuf), 
AVIO_FLAG_WRITE, os, NULL, ism_write, ism_seek);
 if (!ctx-pb) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] smoothstreamingenc: Simplify code by removing a redundant variable

2014-10-12 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Oct  6 
10:06:37 2014 +0300| [8bef43388132b53f59a6e90add18900a3bb4cc60] | committer: 
Martin Storsjö

smoothstreamingenc: Simplify code by removing a redundant variable

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8bef43388132b53f59a6e90add18900a3bb4cc60
---

 libavformat/smoothstreamingenc.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index b9f1dcb..a6d0a36 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -516,7 +516,7 @@ static int ism_flush(AVFormatContext *s, int final)
 for (i = 0; i  s-nb_streams; i++) {
 OutputStream *os = c-streams[i];
 char filename[1024], target_filename[1024], header_filename[1024];
-int64_t start_pos = os-tail_pos, size;
+int64_t size;
 int64_t start_ts, duration, moof_size;
 if (!os-packets_written)
 continue;
@@ -534,14 +534,15 @@ static int ism_flush(AVFormatContext *s, int final)
 
 ffurl_close(os-out);
 os-out = NULL;
-size = os-tail_pos - start_pos;
+size = os-tail_pos - os-cur_start_pos;
 if ((ret = parse_fragment(s, filename, start_ts, duration, 
moof_size, size))  0)
 break;
 snprintf(header_filename, sizeof(header_filename), 
%s/FragmentInfo(%s=%PRIu64), os-dirname, os-stream_type_tag, start_ts);
 snprintf(target_filename, sizeof(target_filename), 
%s/Fragments(%s=%PRIu64), os-dirname, os-stream_type_tag, start_ts);
 copy_moof(s, filename, header_filename, moof_size);
 rename(filename, target_filename);
-add_fragment(os, target_filename, header_filename, start_ts, duration, 
start_pos, size);
+add_fragment(os, target_filename, header_filename, start_ts, duration,
+ os-cur_start_pos, size);
 }
 
 if (c-window_size || (final  c-remove_at_exit)) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Write edit lists for fragmented files as well, if necessary

2014-10-12 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Oct 12 
00:03:25 2014 +0300| [dbb472cb2f2f799295a12b4922a6a8be2cccfdee] | committer: 
Martin Storsjö

movenc: Write edit lists for fragmented files as well, if necessary

This is necessary to get the right timestamp offset for content
that starts with dts != 0.

This currently only helps when writing fragmented files with a non-empty
moov atom. When writing an empty moov atom, we don't have any packets
yet, so we don't know the starting dts for the tracks.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dbb472cb2f2f799295a12b4922a6a8be2cccfdee
---

 libavformat/movenc.c |   13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 218aa50..be11cfa 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1595,7 +1595,8 @@ static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack 
*track)
 }
 
 // This box seems important for the psp playback ... without it the movie 
seems to hang
-static int mov_write_edts_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
+  MOVTrack *track)
 {
 int64_t duration = av_rescale_rnd(track-track_duration, MOV_TIMESCALE,
   track-timescale, AV_ROUND_UP);
@@ -1645,6 +1646,13 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVTrack 
*track)
 duration += delay;
 }
 
+/* For fragmented files, we don't know the full length yet. Setting
+ * duration to 0 allows us to only specify the offset, including
+ * the rest of the content (from all future fragments) without specifying
+ * an explicit duration. */
+if (mov-flags  FF_MOV_FLAG_FRAGMENT)
+duration = 0;
+
 /* duration */
 if (version == 1) {
 avio_wb64(pb, duration);
@@ -1758,8 +1766,7 @@ static int mov_write_trak_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 if (track-mode == MODE_PSP || track-flags  MOV_TRACK_CTTS ||
 (track-entry  track-cluster[0].dts) ||
 is_clcp_track(track)) {
-if (!(mov-flags  FF_MOV_FLAG_FRAGMENT))
-mov_write_edts_tag(pb, track);  // PSP Movies require edts box
+mov_write_edts_tag(pb, mov, track);  // PSP Movies require edts box
 }
 if (track-tref_tag)
 mov_write_tref_tag(pb, track);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Print a warning for an unhandled case of nonzero start dts with empty_moov

2014-10-12 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Oct 12 
00:33:24 2014 +0300| [dad12ce452a9d69c0d9d53c375003947d5f1b02e] | committer: 
Martin Storsjö

movenc: Print a warning for an unhandled case of nonzero start dts with 
empty_moov

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dad12ce452a9d69c0d9d53c375003947d5f1b02e
---

 libavformat/movenc.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index be11cfa..66e3c03 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3115,8 +3115,14 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  * of this packet to be what the previous packets duration implies. */
 trk-cluster[trk-entry].dts = trk-start_dts + trk-track_duration;
 }
-if (trk-start_dts == AV_NOPTS_VALUE)
+if (trk-start_dts == AV_NOPTS_VALUE) {
 trk-start_dts = pkt-dts;
+if (pkt-dts  mov-flags  FF_MOV_FLAG_EMPTY_MOOV)
+av_log(s, AV_LOG_WARNING,
+   Track %d starts with a nonzero dts %PRId64. This 
+   currently isn't handled correctly in combination with 
+   empty_moov.\n, pkt-stream_index, pkt-dts);
+}
 trk-track_duration = pkt-dts - trk-start_dts + pkt-duration;
 
 if (pkt-pts == AV_NOPTS_VALUE) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] mov: Handle tfdt atoms

2014-10-14 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Oct 12 
01:24:26 2014 +0300| [a74f8121d88e0bdf0d69c22e4b3713032da9300a] | committer: 
Martin Storsjö

mov: Handle tfdt atoms

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a74f8121d88e0bdf0d69c22e4b3713032da9300a
---

 libavformat/mov.c |   31 +++
 1 file changed, 31 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index d4281dc..2b64cbf 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2618,6 +2618,36 @@ static int mov_read_trex(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 
+static int mov_read_tfdt(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+MOVFragment *frag = c-fragment;
+AVStream *st = NULL;
+MOVStreamContext *sc;
+int version, i;
+
+for (i = 0; i  c-fc-nb_streams; i++) {
+if (c-fc-streams[i]-id == frag-track_id) {
+st = c-fc-streams[i];
+break;
+}
+}
+if (!st) {
+av_log(c-fc, AV_LOG_ERROR, could not find corresponding track id 
%d\n, frag-track_id);
+return AVERROR_INVALIDDATA;
+}
+sc = st-priv_data;
+if (sc-pseudo_stream_id + 1 != frag-stsd_id)
+return 0;
+version = avio_r8(pb);
+avio_rb24(pb); /* flags */
+if (version) {
+sc-track_end = avio_rb64(pb);
+} else {
+sc-track_end = avio_rb32(pb);
+}
+return 0;
+}
+
 static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 MOVFragment *frag = c-fragment;
@@ -2870,6 +2900,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('s','t','t','s'), mov_read_stts },
 { MKTAG('s','t','z','2'), mov_read_stsz }, /* compact sample size */
 { MKTAG('t','k','h','d'), mov_read_tkhd }, /* track header */
+{ MKTAG('t','f','d','t'), mov_read_tfdt },
 { MKTAG('t','f','h','d'), mov_read_tfhd }, /* track fragment header */
 { MKTAG('t','r','a','k'), mov_read_trak },
 { MKTAG('t','r','a','f'), mov_read_default },

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtpdec_hevc: Parse out of band vps/sps/pps/sei from fmtp lines

2014-10-15 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Oct  3 
21:40:13 2014 +0300| [9b7f932ee568cadfc0f556a061fcc00cb63f9780] | committer: 
Martin Storsjö

rtpdec_hevc: Parse out of band vps/sps/pps/sei from fmtp lines

These are assembled into extradata in the order vps/sps/pps/sei.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b7f932ee568cadfc0f556a061fcc00cb63f9780
---

 libavformat/rtpdec_hevc.c |   99 -
 1 file changed, 97 insertions(+), 2 deletions(-)

diff --git a/libavformat/rtpdec_hevc.c b/libavformat/rtpdec_hevc.c
index 0ff30e2..1bf3c1a 100644
--- a/libavformat/rtpdec_hevc.c
+++ b/libavformat/rtpdec_hevc.c
@@ -21,6 +21,7 @@
  */
 
 #include libavutil/avstring.h
+#include libavutil/base64.h
 
 #include avformat.h
 #include rtpdec.h
@@ -34,6 +35,8 @@
 struct PayloadContext {
 int using_donl_field;
 int profile_id;
+uint8_t *sps, *pps, *vps, *sei;
+int sps_size, pps_size, vps_size, sei_size;
 };
 
 static const uint8_t start_sequence[] = { 0x00, 0x00, 0x00, 0x01 };
@@ -85,6 +88,65 @@ static av_cold int 
hevc_sdp_parse_fmtp_config(AVFormatContext *s,
 /* sprop-sps: [base64] */
 /* sprop-pps: [base64] */
 /* sprop-sei: [base64] */
+if (!strcmp(attr, sprop-vps) || !strcmp(attr, sprop-sps) ||
+!strcmp(attr, sprop-pps) || !strcmp(attr, sprop-sei)) {
+uint8_t **data_ptr;
+int *size_ptr;
+if (!strcmp(attr, sprop-vps)) {
+data_ptr = hevc_data-vps;
+size_ptr = hevc_data-vps_size;
+} else if (!strcmp(attr, sprop-sps)) {
+data_ptr = hevc_data-sps;
+size_ptr = hevc_data-sps_size;
+} else if (!strcmp(attr, sprop-pps)) {
+data_ptr = hevc_data-pps;
+size_ptr = hevc_data-pps_size;
+} else if (!strcmp(attr, sprop-sei)) {
+data_ptr = hevc_data-sei;
+size_ptr = hevc_data-sei_size;
+}
+
+while (*value) {
+char base64packet[1024];
+uint8_t decoded_packet[1024];
+int packet_size;
+char *dst = base64packet;
+
+while (*value  *value != ',' 
+   (dst - base64packet)  sizeof(base64packet) - 1) {
+*dst++ = *value++;
+}
+*dst++ = '\0';
+
+if (*value == ',')
+value++;
+
+packet_size = av_base64_decode(decoded_packet, base64packet,
+   sizeof(decoded_packet));
+if (packet_size  0) {
+uint8_t *dest = av_malloc(packet_size + sizeof(start_sequence) 
+
+  *size_ptr);
+if (!dest) {
+av_log(s, AV_LOG_ERROR,
+   Unable to allocate memory for extradata!\n);
+return AVERROR(ENOMEM);
+}
+if (*size_ptr) {
+memcpy(dest, *data_ptr, *size_ptr);
+av_free(*data_ptr);
+}
+
+memcpy(dest + *size_ptr, start_sequence,
+   sizeof(start_sequence));
+memcpy(dest + *size_ptr + sizeof(start_sequence),
+   decoded_packet, packet_size);
+
+*data_ptr  = dest;
+*size_ptr += sizeof(start_sequence) + packet_size;
+}
+}
+}
+
 /* max-lsr, max-lps, max-cpb, max-dpb, max-br, max-tr, max-tc */
 /* max-fps */
 
@@ -162,8 +224,41 @@ static av_cold int hevc_parse_sdp_line(AVFormatContext 
*ctx, int st_index,
 /* jump beyond the - and determine the height value */
 codec-height  = atoi(sdp_line_ptr + 1);
 } else if (av_strstart(sdp_line_ptr, fmtp:, sdp_line_ptr)) {
-return ff_parse_fmtp(ctx, current_stream, hevc_data, sdp_line_ptr,
- hevc_sdp_parse_fmtp_config);
+int ret = ff_parse_fmtp(ctx, current_stream, hevc_data, sdp_line_ptr,
+hevc_sdp_parse_fmtp_config);
+if (hevc_data-vps_size || hevc_data-sps_size ||
+hevc_data-pps_size || hevc_data-sei_size) {
+av_freep(codec-extradata);
+codec-extradata_size = hevc_data-vps_size + hevc_data-sps_size +
+hevc_data-pps_size + hevc_data-sei_size;
+codec-extradata = av_malloc(codec-extradata_size +
+ FF_INPUT_BUFFER_PADDING_SIZE);
+if (!codec-extradata) {
+ret = AVERROR(ENOMEM);
+codec-extradata_size = 0;
+} else {
+int pos = 0;
+memcpy(codec-extradata + pos, hevc_data-vps, 
hevc_data-vps_size);
+pos += hevc_data-vps_size;
+memcpy(codec-extradata + pos, hevc_data-sps, 
hevc_data-sps_size);
+pos

[FFmpeg-cvslog] sdp: Provide out of bound parameter sets for HEVC if extradata is set

2014-10-15 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Oct  3 
23:25:37 2014 +0300| [e5cfc8fdad901c9487fe896421972852f38bcf5b] | committer: 
Martin Storsjö

sdp: Provide out of bound parameter sets for HEVC if extradata is set

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e5cfc8fdad901c9487fe896421972852f38bcf5b
---

 libavformat/sdp.c |  108 -
 1 file changed, 106 insertions(+), 2 deletions(-)

diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index 43a50d4..a14a239 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -29,6 +29,7 @@
 #include avformat.h
 #include internal.h
 #include avc.h
+#include hevc.h
 #include rtp.h
 #if CONFIG_NETWORK
 #include network.h
@@ -222,6 +223,107 @@ static char *extradata2psets(AVCodecContext *c)
 return psets;
 }
 
+static char *extradata2psets_hevc(AVCodecContext *c)
+{
+char *psets;
+uint8_t *extradata = c-extradata;
+int extradata_size = c-extradata_size;
+uint8_t *tmpbuf = NULL;
+int ps_pos[3] = { 0 };
+static const char * const ps_names[3] = { vps, sps, pps };
+int num_arrays, num_nalus;
+int pos, i, j;
+
+// Convert to hvcc format. Since we need to group multiple NALUs of
+// the same type, and we might need to convert from one format to the
+// other anyway, we get away with a little less work by using the hvcc
+// format.
+if (c-extradata[0] != 1) {
+AVIOContext *pb;
+if (avio_open_dyn_buf(pb)  0)
+return NULL;
+if (ff_isom_write_hvcc(pb, c-extradata, c-extradata_size, 0)  0) {
+avio_close_dyn_buf(pb, tmpbuf);
+goto err;
+}
+extradata_size = avio_close_dyn_buf(pb, extradata);
+tmpbuf = extradata;
+}
+
+if (extradata_size  23)
+goto err;
+
+num_arrays = extradata[22];
+pos = 23;
+for (i = 0; i  num_arrays; i++) {
+int num_nalus, nalu_type;
+if (pos + 3  extradata_size)
+goto err;
+nalu_type = extradata[pos]  0x3f;
+// Not including libavcodec/hevc.h to avoid confusion between
+// NAL_* with the same name for both H264 and HEVC.
+if (nalu_type == 32) // VPS
+ps_pos[0] = pos;
+else if (nalu_type == 33) // SPS
+ps_pos[1] = pos;
+else if (nalu_type == 34) // PPS
+ps_pos[2] = pos;
+num_nalus = AV_RB16(extradata[pos + 1]);
+pos += 3;
+for (j = 0; j  num_nalus; j++) {
+int len;
+if (pos + 2  extradata_size)
+goto err;
+len = AV_RB16(extradata[pos]);
+pos += 2;
+if (pos + len  extradata_size)
+goto err;
+pos += len;
+}
+}
+if (!ps_pos[0] || !ps_pos[1] || !ps_pos[2])
+goto err;
+
+psets = av_mallocz(MAX_PSET_SIZE);
+if (!psets)
+goto err;
+psets[0] = '\0';
+
+for (i = 0; i  3; i++) {
+pos = ps_pos[i];
+
+if (i  0)
+av_strlcat(psets, ; , MAX_PSET_SIZE);
+av_strlcatf(psets, MAX_PSET_SIZE, sprop-%s=, ps_names[i]);
+
+// Skipping boundary checks in the input here; we've already traversed
+// the whole hvcc structure above without issues
+num_nalus = AV_RB16(extradata[pos + 1]);
+pos += 3;
+for (j = 0; j  num_nalus; j++) {
+int len = AV_RB16(extradata[pos]);
+int strpos;
+pos += 2;
+if (j  0)
+av_strlcat(psets, ,, MAX_PSET_SIZE);
+strpos = strlen(psets);
+if (!av_base64_encode(psets + strpos, MAX_PSET_SIZE - strpos,
+  extradata[pos], len)) {
+av_free(psets);
+goto err;
+}
+pos += len;
+}
+}
+av_free(tmpbuf);
+
+return psets;
+
+err:
+av_free(tmpbuf);
+return NULL;
+}
+
 static char *extradata2config(AVCodecContext *c)
 {
 char *config;
@@ -412,9 +514,11 @@ static char *sdp_write_media_attributes(char *buff, int 
size, AVCodecContext *c,
 break;
 case AV_CODEC_ID_HEVC:
 if (c-extradata_size)
-av_log(NULL, AV_LOG_WARNING, HEVC extradata not currently 
- passed properly through SDP\n);
+config = extradata2psets_hevc(c);
 av_strlcatf(buff, size, a=rtpmap:%d H265/9\r\n, 
payload_type);
+if (config)
+av_strlcatf(buff, size, a=fmtp:%d %s\r\n,
+ payload_type, config);
 break;
 case AV_CODEC_ID_MPEG4:
 if (c-extradata_size) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtpdec_hevc: Rename a variable for clarity

2014-10-15 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Oct 15 
16:14:28 2014 +0300| [752e71e74f50e7a6f9a19edb8e775b2ea2fb94d8] | committer: 
Martin Storsjö

rtpdec_hevc: Rename a variable for clarity

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=752e71e74f50e7a6f9a19edb8e775b2ea2fb94d8
---

 libavformat/rtpdec_hevc.c |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtpdec_hevc.c b/libavformat/rtpdec_hevc.c
index 1bf3c1a..72bf775 100644
--- a/libavformat/rtpdec_hevc.c
+++ b/libavformat/rtpdec_hevc.c
@@ -109,7 +109,7 @@ static av_cold int 
hevc_sdp_parse_fmtp_config(AVFormatContext *s,
 while (*value) {
 char base64packet[1024];
 uint8_t decoded_packet[1024];
-int packet_size;
+int decoded_packet_size;
 char *dst = base64packet;
 
 while (*value  *value != ',' 
@@ -121,11 +121,11 @@ static av_cold int 
hevc_sdp_parse_fmtp_config(AVFormatContext *s,
 if (*value == ',')
 value++;
 
-packet_size = av_base64_decode(decoded_packet, base64packet,
-   sizeof(decoded_packet));
-if (packet_size  0) {
-uint8_t *dest = av_malloc(packet_size + sizeof(start_sequence) 
+
-  *size_ptr);
+decoded_packet_size = av_base64_decode(decoded_packet, 
base64packet,
+   sizeof(decoded_packet));
+if (decoded_packet_size  0) {
+uint8_t *dest = av_malloc(decoded_packet_size +
+  sizeof(start_sequence) + *size_ptr);
 if (!dest) {
 av_log(s, AV_LOG_ERROR,
Unable to allocate memory for extradata!\n);
@@ -139,10 +139,10 @@ static av_cold int 
hevc_sdp_parse_fmtp_config(AVFormatContext *s,
 memcpy(dest + *size_ptr, start_sequence,
sizeof(start_sequence));
 memcpy(dest + *size_ptr + sizeof(start_sequence),
-   decoded_packet, packet_size);
+   decoded_packet, decoded_packet_size);
 
 *data_ptr  = dest;
-*size_ptr += sizeof(start_sequence) + packet_size;
+*size_ptr += sizeof(start_sequence) + decoded_packet_size;
 }
 }
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtpdec_hevc: Use av_realloc instead of av_malloc+memcpy

2014-10-15 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Oct 15 
16:21:27 2014 +0300| [ced7238cd01cc2199acf9225305628641a27c1d7] | committer: 
Martin Storsjö

rtpdec_hevc: Use av_realloc instead of av_malloc+memcpy

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ced7238cd01cc2199acf9225305628641a27c1d7
---

 libavformat/rtpdec_hevc.c |   14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/libavformat/rtpdec_hevc.c b/libavformat/rtpdec_hevc.c
index 72bf775..49789b0 100644
--- a/libavformat/rtpdec_hevc.c
+++ b/libavformat/rtpdec_hevc.c
@@ -124,24 +124,20 @@ static av_cold int 
hevc_sdp_parse_fmtp_config(AVFormatContext *s,
 decoded_packet_size = av_base64_decode(decoded_packet, 
base64packet,
sizeof(decoded_packet));
 if (decoded_packet_size  0) {
-uint8_t *dest = av_malloc(decoded_packet_size +
+uint8_t *tmp = av_realloc(*data_ptr, decoded_packet_size +
   sizeof(start_sequence) + *size_ptr);
-if (!dest) {
+if (!tmp) {
 av_log(s, AV_LOG_ERROR,
Unable to allocate memory for extradata!\n);
 return AVERROR(ENOMEM);
 }
-if (*size_ptr) {
-memcpy(dest, *data_ptr, *size_ptr);
-av_free(*data_ptr);
-}
+*data_ptr = tmp;
 
-memcpy(dest + *size_ptr, start_sequence,
+memcpy(*data_ptr + *size_ptr, start_sequence,
sizeof(start_sequence));
-memcpy(dest + *size_ptr + sizeof(start_sequence),
+memcpy(*data_ptr + *size_ptr + sizeof(start_sequence),
decoded_packet, decoded_packet_size);
 
-*data_ptr  = dest;
 *size_ptr += sizeof(start_sequence) + decoded_packet_size;
 }
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtmpproto: Fix a typo

2014-10-15 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Oct 15 
13:41:33 2014 +0300| [79dd756e143a54efc25d64e90505f0dca6cbc4ec] | committer: 
Martin Storsjö

rtmpproto: Fix a typo

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=79dd756e143a54efc25d64e90505f0dca6cbc4ec
---

 libavformat/rtmpproto.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 4aaa420..ea15ccb 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -505,7 +505,7 @@ static int read_connect(URLContext *s, RTMPContext *rt)
 if (ret  0)
 return ret;
 
-// Send result_ NetConnection.Connect.Success to connect
+// Send _result NetConnection.Connect.Success to connect
 if ((ret = ff_rtmp_packet_create(pkt, RTMP_SYSTEM_CHANNEL,
  RTMP_PT_INVOKE, 0,
  RTMP_PKTDATA_DEFAULT_SIZE))  0)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avplay: Use av_gettime_relative

2014-10-24 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Oct 22 
12:23:08 2014 +0300| [248d8fb60c59c8e044d9c8f78f23383b7cdecf72] | committer: 
Martin Storsjö

avplay: Use av_gettime_relative

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=248d8fb60c59c8e044d9c8f78f23383b7cdecf72
---

 avplay.c |   24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/avplay.c b/avplay.c
index 58da984..9148c04 100644
--- a/avplay.c
+++ b/avplay.c
@@ -101,7 +101,7 @@ typedef struct PacketQueue {
 
 typedef struct VideoPicture {
 double pts; // presentation timestamp for this picture
-double target_clock;// av_gettime() time at which this should be 
displayed ideally
+double target_clock;// av_gettime_relative() time at which this should 
be displayed ideally
 int64_t pos;// byte position in file
 SDL_Overlay *bmp;
 int width, height; /* source height  width */
@@ -197,7 +197,7 @@ typedef struct VideoState {
 AVStream *video_st;
 PacketQueue videoq;
 double video_current_pts;   // current displayed pts (different from 
video_clock if frame fifos are used)
-double video_current_pts_drift; // video_current_pts - time (av_gettime) 
at which we updated video_current_pts - used to have running video pts
+double video_current_pts_drift; // video_current_pts - time 
(av_gettime_relative) at which we updated video_current_pts - used to have 
running video pts
 int64_t video_current_pos;  // current displayed file pos
 VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];
 int pictq_size, pictq_rindex, pictq_windex;
@@ -754,7 +754,7 @@ static void video_audio_display(VideoState *s)
 /* to be more precise, we take into account the time spent since
the last buffer computation */
 if (audio_callback_time) {
-time_diff = av_gettime() - audio_callback_time;
+time_diff = av_gettime_relative() - audio_callback_time;
 delay -= (time_diff * s-sdl_sample_rate) / 100;
 }
 
@@ -972,7 +972,7 @@ static double get_video_clock(VideoState *is)
 if (is-paused) {
 return is-video_current_pts;
 } else {
-return is-video_current_pts_drift + av_gettime() / 100.0;
+return is-video_current_pts_drift + av_gettime_relative() / 100.0;
 }
 }
 
@@ -980,7 +980,7 @@ static double get_video_clock(VideoState *is)
 static double get_external_clock(VideoState *is)
 {
 int64_t ti;
-ti = av_gettime();
+ti = av_gettime_relative();
 return is-external_clock + ((ti - is-external_clock_time) * 1e-6);
 }
 
@@ -1022,11 +1022,11 @@ static void stream_seek(VideoState *is, int64_t pos, 
int64_t rel, int seek_by_by
 static void stream_pause(VideoState *is)
 {
 if (is-paused) {
-is-frame_timer += av_gettime() / 100.0 + 
is-video_current_pts_drift - is-video_current_pts;
+is-frame_timer += av_gettime_relative() / 100.0 + 
is-video_current_pts_drift - is-video_current_pts;
 if (is-read_pause_return != AVERROR(ENOSYS)) {
-is-video_current_pts = is-video_current_pts_drift + av_gettime() 
/ 100.0;
+is-video_current_pts = is-video_current_pts_drift + 
av_gettime_relative() / 100.0;
 }
-is-video_current_pts_drift = is-video_current_pts - av_gettime() / 
100.0;
+is-video_current_pts_drift = is-video_current_pts - 
av_gettime_relative() / 100.0;
 }
 is-paused = !is-paused;
 }
@@ -1084,7 +1084,7 @@ retry:
 if (is-pictq_size == 0) {
 // nothing to do, no picture to display in the que
 } else {
-double time = av_gettime() / 100.0;
+double time = av_gettime_relative() / 100.0;
 double next_target;
 /* dequeue the picture */
 vp = is-pictq[is-pictq_rindex];
@@ -1190,7 +1190,7 @@ retry:
 int aqsize, vqsize, sqsize;
 double av_diff;
 
-cur_time = av_gettime();
+cur_time = av_gettime_relative();
 if (!last_time || (cur_time - last_time) = 3) {
 aqsize = 0;
 vqsize = 0;
@@ -1464,7 +1464,7 @@ static int get_video_frame(VideoState *is, AVFrame 
*frame, int64_t *pts, AVPacke
 init_pts_correction(is-pts_ctx);
 is-frame_last_pts = AV_NOPTS_VALUE;
 is-frame_last_delay = 0;
-is-frame_timer = (double)av_gettime() / 100.0;
+is-frame_timer = (double)av_gettime_relative() / 100.0;
 is-skip_frames = 1;
 is-skip_frames_index = 0;
 return 0;
@@ -1993,7 +1993,7 @@ static void sdl_audio_callback(void *opaque, Uint8 
*stream, int len)
 int audio_size, len1;
 double pts;
 
-audio_callback_time = av_gettime();
+audio_callback_time = av_gettime_relative();
 
 while (len  0) {
 if (is-audio_buf_index = is-audio_buf_size

[FFmpeg-cvslog] avconv: Use av_gettime_relative

2014-10-24 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Oct 22 
12:25:23 2014 +0300| [d0c093021943e9b9c23528b12cd61ca2a5b01b4f] | committer: 
Martin Storsjö

avconv: Use av_gettime_relative

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d0c093021943e9b9c23528b12cd61ca2a5b01b4f
---

 avconv.c |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/avconv.c b/avconv.c
index dc21aff..23f69cb 100644
--- a/avconv.c
+++ b/avconv.c
@@ -876,7 +876,7 @@ static void print_report(int is_last_report, int64_t 
timer_start)
 if (!is_last_report) {
 int64_t cur_time;
 /* display the report every 0.5 seconds */
-cur_time = av_gettime();
+cur_time = av_gettime_relative();
 if (last_time == -1) {
 last_time = cur_time;
 return;
@@ -913,7 +913,7 @@ static void print_report(int is_last_report, int64_t 
timer_start)
 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), q=%2.1f , 
q);
 }
 if (!vid  enc-codec_type == AVMEDIA_TYPE_VIDEO) {
-float t = (av_gettime() - timer_start) / 100.0;
+float t = (av_gettime_relative() - timer_start) / 100.0;
 
 frame_number = ost-frame_number;
 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), frame=%5d 
fps=%3d q=%3.1f ,
@@ -1673,7 +1673,7 @@ static int transcode_init(void)
 InputFile *ifile = input_files[i];
 if (ifile-rate_emu)
 for (j = 0; j  ifile-nb_streams; j++)
-input_streams[j + ifile-ist_index]-start = av_gettime();
+input_streams[j + ifile-ist_index]-start = 
av_gettime_relative();
 }
 
 /* output stream init */
@@ -2281,7 +2281,7 @@ static int get_input_packet(InputFile *f, AVPacket *pkt)
 for (i = 0; i  f-nb_streams; i++) {
 InputStream *ist = input_streams[f-ist_index + i];
 int64_t pts = av_rescale(ist-last_dts, 100, AV_TIME_BASE);
-int64_t now = av_gettime() - ist-start;
+int64_t now = av_gettime_relative() - ist-start;
 if (pts  now)
 return AVERROR(EAGAIN);
 }
@@ -2471,7 +2471,7 @@ static int transcode(void)
 av_log(NULL, AV_LOG_INFO, Press ctrl-c to stop encoding\n);
 term_init();
 
-timer_start = av_gettime();
+timer_start = av_gettime_relative();
 
 #if HAVE_PTHREADS
 if ((ret = init_input_threads())  0)
@@ -2586,7 +2586,7 @@ static int64_t getutime(void)
 GetProcessTimes(proc, c, e, k, u);
 return ((int64_t) u.dwHighDateTime  32 | u.dwLowDateTime) / 10;
 #else
-return av_gettime();
+return av_gettime_relative();
 #endif
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavu: Provide fallbacks for gmtime_r and localtime_r

2014-10-25 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Oct 24 
10:33:19 2014 +0300| [3f8f1c6ff24ee858eb5b0bf47ef6d4605299a87e] | committer: 
Martin Storsjö

lavu: Provide fallbacks for gmtime_r and localtime_r

This allows writing most code as if they always are is available.

These are ok to use from other libraries even though it's not a
public header, since they only provide an inline declaration, and
doesn't add an actual dependency on lavu internals. (This can be
considered more a build system compatibility fallback than a
libavutil feature.)

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3f8f1c6ff24ee858eb5b0bf47ef6d4605299a87e
---

 configure |2 ++
 libavutil/time_internal.h |   47 +
 2 files changed, 49 insertions(+)

diff --git a/configure b/configure
index a82bef7..f53332d 100755
--- a/configure
+++ b/configure
@@ -1453,6 +1453,7 @@ SYSTEM_FUNCS=
 getservbyport
 GetSystemTimeAsFileTime
 gettimeofday
+gmtime_r
 inet_aton
 isatty
 jack_port_get_latency_range
@@ -4062,6 +4063,7 @@ check_func  gethrtime
 check_func  getopt
 check_func  getrusage
 check_func  gettimeofday
+check_func  gmtime_r
 check_func  isatty
 check_func  localtime_r
 check_func  mach_absolute_time
diff --git a/libavutil/time_internal.h b/libavutil/time_internal.h
new file mode 100644
index 000..829fefb
--- /dev/null
+++ b/libavutil/time_internal.h
@@ -0,0 +1,47 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_TIME_INTERNAL_H
+#define AVUTIL_TIME_INTERNAL_H
+
+#include time.h
+#include config.h
+
+#if !HAVE_GMTIME_R
+static inline struct tm *gmtime_r(const time_t* clock, struct tm *result)
+{
+struct tm *ptr = gmtime(clock);
+if (!ptr)
+return NULL;
+*result = *ptr;
+return result;
+}
+#endif
+
+#if !HAVE_LOCALTIME_R
+static inline struct tm *localtime_r(const time_t* clock, struct tm *result)
+{
+struct tm *ptr = localtime(clock);
+if (!ptr)
+return NULL;
+*result = *ptr;
+return result;
+}
+#endif
+
+#endif /* AVUTIL_TIME_INTERNAL_H */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] drawtext: Remove the ifdef for localtime_r

2014-10-25 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Oct 24 
10:59:34 2014 +0300| [6b9b42cc5576e1819ad1e29d98940066fd14b2d6] | committer: 
Martin Storsjö

drawtext: Remove the ifdef for localtime_r

If it isn't available in the system, we've got a fallback to
the normal localtime function, so normal code can assume it is
available as long as time_internal.h is included.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6b9b42cc5576e1819ad1e29d98940066fd14b2d6
---

 libavfilter/vf_drawtext.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index d954fdf..54a8847 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -47,6 +47,7 @@
 #include libavutil/random_seed.h
 #include libavutil/parseutils.h
 #include libavutil/pixdesc.h
+#include libavutil/time_internal.h
 #include libavutil/tree.h
 #include libavutil/lfg.h
 #include avfilter.h
@@ -535,8 +536,6 @@ static int dtext_prepare_text(AVFilterContext *ctx)
 Glyph dummy = { 0 };
 int width  = ctx-inputs[0]-w;
 int height = ctx-inputs[0]-h;
-
-#if HAVE_LOCALTIME_R
 time_t now = time(0);
 struct tm ltime;
 uint8_t *buf = s-expanded_text;
@@ -558,7 +557,6 @@ static int dtext_prepare_text(AVFilterContext *ctx)
 return AVERROR(ENOMEM);
 text = s-expanded_text = buf;
 s-expanded_text_size = buf_size;
-#endif
 
 if ((len = strlen(text))  s-nb_positions) {
 FT_Vector *p = av_realloc(s-positions,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Don't check the custom IO flag when using faststart

2014-10-29 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Oct 21 
10:44:38 2014 +0300| [b2b79eca6fae2466a53c5daa163a37e2474364fc] | committer: 
Martin Storsjö

movenc: Don't check the custom IO flag when using faststart

The custom IO flag actually never is set for muxers, only for
demuxers, so the check was pointless (unless a user intentionally
would set the flag to signal using custom IO).

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b2b79eca6fae2466a53c5daa163a37e2474364fc
---

 libavformat/movenc.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 43b03c5..ccd310c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3437,10 +3437,9 @@ static int mov_write_header(AVFormatContext *s)
 
 /* faststart: moov at the beginning of the file, if supported */
 if (mov-flags  FF_MOV_FLAG_FASTSTART) {
-if ((mov-flags  FF_MOV_FLAG_FRAGMENT) ||
-(s-flags  AVFMT_FLAG_CUSTOM_IO)) {
+if (mov-flags  FF_MOV_FLAG_FRAGMENT) {
 av_log(s, AV_LOG_WARNING, The faststart flag is incompatible 
-   with fragmentation and custom IO, disabling faststart\n);
+   with fragmentation, disabling faststart\n);
 mov-flags = ~FF_MOV_FLAG_FASTSTART;
 }
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Use a local variable consistently

2014-10-29 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Oct 21 
11:36:22 2014 +0300| [1e0b81abe86dc09dd34d60d57f92de5f12d65818] | committer: 
Martin Storsjö

movenc: Use a local variable consistently

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1e0b81abe86dc09dd34d60d57f92de5f12d65818
---

 libavformat/movenc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index ccd310c..c50adb6 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3766,7 +3766,7 @@ static int mov_write_trailer(AVFormatContext *s)
 av_log(s, AV_LOG_INFO, Starting second pass: moving the moov atom 
to the beginning of the file\n);
 res = shift_data(s);
 if (res == 0) {
-avio_seek(s-pb, mov-reserved_moov_pos, SEEK_SET);
+avio_seek(pb, mov-reserved_moov_pos, SEEK_SET);
 mov_write_moov_tag(pb, mov, s);
 }
 } else {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Signal iso6 in compatible_brands when using tfdt

2014-10-29 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Oct 29 
17:00:38 2014 +0200| [600d5ee6b12bad144756b0772319bb04796bc528] | committer: 
Martin Storsjö

movenc: Signal iso6 in compatible_brands when using tfdt

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=600d5ee6b12bad144756b0772319bb04796bc528
---

 libavformat/movenc.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index c50adb6..1f5d972 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2742,6 +2742,11 @@ static int mov_write_ftyp_tag(AVIOContext *pb, 
AVFormatContext *s)
 ffio_wfourcc(pb, avc1);
 }
 
+// We add tfdt atoms when fragmenting, signal this with the iso6 compatible
+// brand. This is compatible with users that don't understand tfdt.
+if (mov-flags  FF_MOV_FLAG_FRAGMENT)
+ffio_wfourcc(pb, iso6);
+
 if (mov-mode == MODE_3GP)
 ffio_wfourcc(pb, has_h264 ? 3gp6:3gp4);
 else if (mov-mode  MODE_3G2)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Add a flag for using default-base-is-moof in tfhd atoms

2014-10-30 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Oct 29 
11:53:21 2014 +0200| [cf589faa5b7aed3bb38e08dcd00bd951e69686d1] | committer: 
Martin Storsjö

movenc: Add a flag for using default-base-is-moof in tfhd atoms

Similarly to the omit_tfhd_offset flag added in e7bf085b, this
avoids writing absolute byte positions to the file, making them
more easily streamable.

This is a new feature from 14496-12:2012, so application support
isn't necessarily too widespread yet (support for it in libav was
added in 20f95f21f in July 2014).

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cf589faa5b7aed3bb38e08dcd00bd951e69686d1
---

 doc/muxers.texi   |7 +++
 libavformat/movenc.c  |   14 +++---
 libavformat/movenc.h  |1 +
 libavformat/version.h |2 +-
 4 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 7c7e27c..6d2c495 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -340,6 +340,13 @@ cause failures when the file is reprocessed with certain 
tagging programs.
 @item -movflags omit_tfhd_offset
 Do not write any absolute base_data_offset in tfhd atoms. This avoids
 tying fragments to absolute byte positions in the file/streams.
+@item -movflags default_base_moof
+Similarly to the omit_tfhd_offset, this flag avoids writing the
+absolute base_data_offset field in tfhd atoms, but does so by using
+the new default-base-is-moof flag instead. This flag is new from
+14496-12:2012. This may make the fragments easier to parse in certain
+circumstances (avoiding basing track fragment location calculations
+on the implicit end of the previous track fragment).
 @end table
 
 Smooth Streaming content can be pushed in real time to a publishing
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1f5d972..39d2946 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -58,6 +58,7 @@ static const AVOption options[] = {
 { faststart, Run a second pass to put the index (moov atom) at the 
beginning of the file, 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FASTSTART}, 
INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, movflags },
 { omit_tfhd_offset, Omit the base data offset in tfhd atoms, 0, 
AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_OMIT_TFHD_OFFSET}, INT_MIN, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM, movflags },
 { disable_chpl, Disable Nero chapter atom, 0, AV_OPT_TYPE_CONST, {.i64 
= FF_MOV_FLAG_DISABLE_CHPL}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 
movflags },
+{ default_base_moof, Set the default-base-is-moof flag in tfhd atoms, 
0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DEFAULT_BASE_MOOF}, INT_MIN, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM, movflags },
 FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags),
 { skip_iods, Skip writing iods atom., offsetof(MOVMuxContext, 
iods_skip), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
 { iods_audio_profile, iods audio profile atom., 
offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 
255, AV_OPT_FLAG_ENCODING_PARAM},
@@ -2386,6 +2387,10 @@ static int mov_write_tfhd_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 }
 if (mov-flags  FF_MOV_FLAG_OMIT_TFHD_OFFSET)
 flags = ~MOV_TFHD_BASE_DATA_OFFSET;
+if (mov-flags  FF_MOV_FLAG_DEFAULT_BASE_MOOF) {
+flags = ~MOV_TFHD_BASE_DATA_OFFSET;
+flags |= MOV_TFHD_DEFAULT_BASE_IS_MOOF;
+}
 
 /* Don't set a default sample size, the silverlight player refuses
  * to play files with that set. Don't set a default sample duration,
@@ -2457,7 +2462,7 @@ static int mov_write_trun_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 
 avio_wb32(pb, track-entry); /* sample count */
 if (mov-flags  FF_MOV_FLAG_OMIT_TFHD_OFFSET 
-!(mov-flags  FF_MOV_FLAG_SEPARATE_MOOF) 
+!(mov-flags  (FF_MOV_FLAG_SEPARATE_MOOF | 
FF_MOV_FLAG_DEFAULT_BASE_MOOF)) 
 !mov-first_trun)
 avio_wb32(pb, 0); /* Later tracks follow immediately after the 
previous one */
 else
@@ -2717,6 +2722,8 @@ static int mov_write_ftyp_tag(AVIOContext *pb, 
AVFormatContext *s)
 minor = has_h264 ? 0x2 : 0x1;
 } else if (mov-mode == MODE_PSP)
 ffio_wfourcc(pb, MSNV);
+else if (mov-mode == MODE_MP4  mov-flags  
FF_MOV_FLAG_DEFAULT_BASE_MOOF)
+ffio_wfourcc(pb, iso5); // Required when using default-base-is-moof
 else if (mov-mode == MODE_MP4)
 ffio_wfourcc(pb, isom);
 else if (mov-mode == MODE_IPOD)
@@ -2734,8 +2741,9 @@ static int mov_write_ftyp_tag(AVIOContext *pb, 
AVFormatContext *s)
 ffio_wfourcc(pb, qt  );
 else if (mov-mode == MODE_ISM) {
 ffio_wfourcc(pb, piff);
-ffio_wfourcc(pb, iso2);
-} else {
+if (!(mov-flags  FF_MOV_FLAG_DEFAULT_BASE_MOOF))
+ffio_wfourcc(pb, iso2);
+} else if (!(mov-flags  FF_MOV_FLAG_DEFAULT_BASE_MOOF)) {
 ffio_wfourcc(pb, isom);
 ffio_wfourcc(pb

[FFmpeg-cvslog] movenc: Write a 0 duration in mdhd and tkhd for an empty initial moov

2014-10-30 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Oct 29 
22:51:29 2014 +0200| [00c67fe1d0bc7c2ce49daac9c80ea39d5a663b73] | committer: 
Martin Storsjö

movenc: Write a 0 duration in mdhd and tkhd for an empty initial moov

ISO/IEC 14496-12:2012/Cor 1:2013 is explicit about how this should be
handled. All zeros doesn't mean that the full file has got a zero
duration, only that the track samples described within the initial moov
have got zero duration. An all ones duration means an indeterminate
duration.

Keep writing a duration consisting of all ones for the ISM mode -
older windows media player versions won't play a file if this is
zero. (Newer windows media player versions play either version fine.)

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=00c67fe1d0bc7c2ce49daac9c80ea39d5a663b73
---

 libavformat/movenc.c |   18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 39d2946..6184101 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1434,7 +1434,8 @@ static int mov_write_minf_tag(AVIOContext *pb, MOVTrack 
*track)
 return update_size(pb, pos);
 }
 
-static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_mdhd_tag(AVIOContext *pb, MOVMuxContext *mov,
+  MOVTrack *track)
 {
 int version = track-track_duration  INT32_MAX ? 0 : 1;
 
@@ -1453,8 +1454,10 @@ static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack 
*track)
 avio_wb32(pb, track-time); /* modification time */
 }
 avio_wb32(pb, track-timescale); /* time scale (sample rate for audio) */
-if (!track-entry)
+if (!track-entry  mov-mode == MODE_ISM)
 (version == 1) ? avio_wb64(pb, UINT64_C(0x)) : 
avio_wb32(pb, 0x);
+else if (!track-entry)
+(version == 1) ? avio_wb64(pb, 0) : avio_wb32(pb, 0);
 else
 (version == 1) ? avio_wb64(pb, track-track_duration) : avio_wb32(pb, 
track-track_duration); /* duration */
 avio_wb16(pb, track-language); /* language */
@@ -1470,12 +1473,13 @@ static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack 
*track)
 return 32;
 }
 
-static int mov_write_mdia_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_mdia_tag(AVIOContext *pb, MOVMuxContext *mov,
+  MOVTrack *track)
 {
 int64_t pos = avio_tell(pb);
 avio_wb32(pb, 0); /* size */
 ffio_wfourcc(pb, mdia);
-mov_write_mdhd_tag(pb, track);
+mov_write_mdhd_tag(pb, mov, track);
 mov_write_hdlr_tag(pb, track);
 mov_write_minf_tag(pb, track);
 return update_size(pb, pos);
@@ -1517,8 +1521,10 @@ static int mov_write_tkhd_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 }
 avio_wb32(pb, track-track_id); /* track-id */
 avio_wb32(pb, 0); /* reserved */
-if (!track-entry)
+if (!track-entry  mov-mode == MODE_ISM)
 (version == 1) ? avio_wb64(pb, UINT64_C(0x)) : 
avio_wb32(pb, 0x);
+else if (!track-entry)
+(version == 1) ? avio_wb64(pb, 0) : avio_wb32(pb, 0);
 else
 (version == 1) ? avio_wb64(pb, duration) : avio_wb32(pb, duration);
 
@@ -1771,7 +1777,7 @@ static int mov_write_trak_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 }
 if (track-tref_tag)
 mov_write_tref_tag(pb, track);
-mov_write_mdia_tag(pb, track);
+mov_write_mdia_tag(pb, mov, track);
 if (track-mode == MODE_PSP)
 mov_write_uuid_tag_psp(pb, track); // PSP Movies require this uuid box
 if (track-tag == MKTAG('r','t','p',' '))

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Don't write any iso brands in ismv files

2014-10-30 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Oct 29 
22:55:23 2014 +0200| [aae6b3b918b4133b8cc2d1631196c1d406d0351a] | committer: 
Martin Storsjö

movenc: Don't write any iso brands in ismv files

We deviate slightly from the iso specs for these files.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aae6b3b918b4133b8cc2d1631196c1d406d0351a
---

 libavformat/movenc.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index d79607b..80a44cf 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2748,8 +2748,6 @@ static int mov_write_ftyp_tag(AVIOContext *pb, 
AVFormatContext *s)
 ffio_wfourcc(pb, qt  );
 else if (mov-mode == MODE_ISM) {
 ffio_wfourcc(pb, piff);
-if (!(mov-flags  FF_MOV_FLAG_DEFAULT_BASE_MOOF))
-ffio_wfourcc(pb, iso2);
 } else if (!(mov-flags  FF_MOV_FLAG_DEFAULT_BASE_MOOF)) {
 ffio_wfourcc(pb, isom);
 ffio_wfourcc(pb, iso2);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Define the flag bits using shifts instead of as decimal numbers

2014-11-03 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Nov  2 
17:01:10 2014 +0200| [2f221b6a9365aa400061e16266f2d1242f7169f8] | committer: 
Martin Storsjö

movenc: Define the flag bits using shifts instead of as decimal numbers

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f221b6a9365aa400061e16266f2d1242f7169f8
---

 libavformat/movenc.h |   22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 56e2647..e905627 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -168,17 +168,17 @@ typedef struct MOVMuxContext {
 AVFormatContext *fc;
 } MOVMuxContext;
 
-#define FF_MOV_FLAG_RTP_HINT 1
-#define FF_MOV_FLAG_FRAGMENT 2
-#define FF_MOV_FLAG_EMPTY_MOOV 4
-#define FF_MOV_FLAG_FRAG_KEYFRAME 8
-#define FF_MOV_FLAG_SEPARATE_MOOF 16
-#define FF_MOV_FLAG_FRAG_CUSTOM 32
-#define FF_MOV_FLAG_ISML 64
-#define FF_MOV_FLAG_FASTSTART 128
-#define FF_MOV_FLAG_OMIT_TFHD_OFFSET 256
-#define FF_MOV_FLAG_DISABLE_CHPL 512
-#define FF_MOV_FLAG_DEFAULT_BASE_MOOF 1024
+#define FF_MOV_FLAG_RTP_HINT  (1   0)
+#define FF_MOV_FLAG_FRAGMENT  (1   1)
+#define FF_MOV_FLAG_EMPTY_MOOV(1   2)
+#define FF_MOV_FLAG_FRAG_KEYFRAME (1   3)
+#define FF_MOV_FLAG_SEPARATE_MOOF (1   4)
+#define FF_MOV_FLAG_FRAG_CUSTOM   (1   5)
+#define FF_MOV_FLAG_ISML  (1   6)
+#define FF_MOV_FLAG_FASTSTART (1   7)
+#define FF_MOV_FLAG_OMIT_TFHD_OFFSET  (1   8)
+#define FF_MOV_FLAG_DISABLE_CHPL  (1   9)
+#define FF_MOV_FLAG_DEFAULT_BASE_MOOF (1  10)
 
 int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Remove a now redundant check

2014-11-07 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Oct 29 
23:26:40 2014 +0200| [e7d20f12c5eff5570cd897f3ce3a88456024036b] | committer: 
Martin Storsjö

movenc: Remove a now redundant check

When using the new first_trun flag instead of checking the track id,
we don't need to have a special case for the separate_moof flag
any longer.

This simplifies the complicated codepath ever so slightly.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e7d20f12c5eff5570cd897f3ce3a88456024036b
---

 libavformat/movenc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 7a0d9f1..96bb885 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2473,7 +2473,7 @@ static int mov_write_trun_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 
 avio_wb32(pb, track-entry); /* sample count */
 if (mov-flags  FF_MOV_FLAG_OMIT_TFHD_OFFSET 
-!(mov-flags  (FF_MOV_FLAG_SEPARATE_MOOF | 
FF_MOV_FLAG_DEFAULT_BASE_MOOF)) 
+!(mov-flags  FF_MOV_FLAG_DEFAULT_BASE_MOOF) 
 !mov-first_trun)
 avio_wb32(pb, 0); /* Later tracks follow immediately after the 
previous one */
 else

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Write correct presentation timestamps in tfra

2014-11-07 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Oct 12 
00:24:31 2014 +0300| [9cbf70fa0e44613590b019cef1fe99aa3f3c5d9d] | committer: 
Martin Storsjö

movenc: Write correct presentation timestamps in tfra

Previously we wrote decoding timestamps here, while the specs
say it should be presentation timestamps.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9cbf70fa0e44613590b019cef1fe99aa3f3c5d9d
---

 libavformat/movenc.c  |   11 +++
 libavformat/version.h |2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 96bb885..3b7f5ae 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3018,6 +3018,17 @@ static int mov_flush_fragment(AVFormatContext *s)
 info = track-frag_info[track-nb_frag_info - 1];
 info-offset   = avio_tell(s-pb);
 info-time = track-frag_start;
+if (track-entry) {
+// Try to recreate the original pts for the first packet
+// from the fields we have stored
+info-time = track-start_dts + track-frag_start +
+ track-cluster[0].cts;
+// If the pts is less than zero, we will have trimmed
+// away parts of the media track using an edit list,
+// and the corresponding start presentation time is zero.
+if (info-time  0)
+info-time = 0;
+}
 info-duration = duration;
 mov_write_tfrf_tags(s-pb, mov, track);
 
diff --git a/libavformat/version.h b/libavformat/version.h
index c477d5d..f8c5edb 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFORMAT_VERSION_MAJOR 56
 #define LIBAVFORMAT_VERSION_MINOR  6
-#define LIBAVFORMAT_VERSION_MICRO  3
+#define LIBAVFORMAT_VERSION_MICRO  4
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Avoid leaking locally allocated data when returning on errors

2014-11-08 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Nov  2 
23:50:47 2014 +0200| [8cb7b7b461b52898765b38e3eff68c0ce88347f3] | committer: 
Martin Storsjö

movenc: Avoid leaking locally allocated data when returning on errors

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8cb7b7b461b52898765b38e3eff68c0ce88347f3
---

 libavformat/movenc.c |   18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index e2a6bbc..bb1dc8a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3065,7 +3065,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
 MOVTrack *trk = mov-tracks[pkt-stream_index];
 AVCodecContext *enc = trk-enc;
 unsigned int samples_in_chunk = 0;
-int size = pkt-size;
+int size = pkt-size, ret = 0;
 uint8_t *reformatted_data = NULL;
 
 if (mov-flags  FF_MOV_FLAG_FRAGMENT) {
@@ -3139,16 +3139,20 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 /* copy frame to create needed atoms */
 trk-vos_len  = size;
 trk-vos_data = av_malloc(size);
-if (!trk-vos_data)
-return AVERROR(ENOMEM);
+if (!trk-vos_data) {
+ret = AVERROR(ENOMEM);
+goto err;
+}
 memcpy(trk-vos_data, pkt-data, size);
 }
 
 if (trk-entry = trk-cluster_capacity) {
 unsigned new_capacity = 2 * (trk-entry + MOV_INDEX_CLUSTER_SIZE);
 if (av_reallocp_array(trk-cluster, new_capacity,
-  sizeof(*trk-cluster)))
-return AVERROR(ENOMEM);
+  sizeof(*trk-cluster))) {
+ret = AVERROR(ENOMEM);
+goto err;
+}
 trk-cluster_capacity = new_capacity;
 }
 
@@ -3212,8 +3216,10 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (trk-hint_track = 0  trk-hint_track  mov-nb_streams)
 ff_mov_add_hinted_packet(s, pkt, trk-hint_track, trk-entry,
  reformatted_data, size);
+
+err:
 av_free(reformatted_data);
-return 0;
+return ret;
 }
 
 static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Require samples before trying to write edts

2014-11-08 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov  3 
20:13:36 2014 +0200| [9a5ac36b69ede4563e9ecd734141b12ea3280fbc] | committer: 
Martin Storsjö

movenc: Require samples before trying to write edts

This avoids a potential crash if writing a fragmented psp mp4
(which probably is only a hypothetical scenario).

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9a5ac36b69ede4563e9ecd734141b12ea3280fbc
---

 libavformat/movenc.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index bb1dc8a..fa5fdad 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1771,9 +1771,9 @@ static int mov_write_trak_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 avio_wb32(pb, 0); /* size */
 ffio_wfourcc(pb, trak);
 mov_write_tkhd_tag(pb, mov, track, st);
-if (track-mode == MODE_PSP || track-flags  MOV_TRACK_CTTS ||
-(track-entry  track-cluster[0].dts) ||
-is_clcp_track(track)) {
+if (track-entry 
+(track-mode == MODE_PSP || track-flags  MOV_TRACK_CTTS ||
+track-cluster[0].dts || is_clcp_track(track))) {
 if (mov-use_editlist)
 mov_write_edts_tag(pb, mov, track);  // PSP Movies require edts box
 else if ((track-entry  track-cluster[0].dts) || track-mode == 
MODE_PSP || is_clcp_track(track))

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libfdk-aacdec: Support building with the latest version of fdk-aac

2014-11-09 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sat Nov  8 
22:39:44 2014 +0200| [b44a242c3dfa1225ca4e75135ed5fbe7f0e3c378] | committer: 
Michael Niedermayer

libfdk-aacdec: Support building with the latest version of fdk-aac

The latest fdk-aac code drop (from android 5.0) changed the channel
layout enums (changing the value of existing enum constants), and
renamed the option for downmixing.

The failsafe comparison between ctype and FF_ARRAY_ELEMS(channel_counts)
can trigger warnings (-Wtautological-constant-out-of-range-compare)
when building with the old FDK AAC releases, where it can't be
out of range with the enum values used there.

Signed-off-by: Michael Niedermayer michae...@gmx.at

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b44a242c3dfa1225ca4e75135ed5fbe7f0e3c378
---

 libavcodec/libfdk-aacdec.c |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c
index e4bae1a..90cd956 100644
--- a/libavcodec/libfdk-aacdec.c
+++ b/libavcodec/libfdk-aacdec.c
@@ -25,6 +25,12 @@
 #include avcodec.h
 #include internal.h
 
+/* The version macro is introduced the same time as the setting enum was
+ * changed, so this check should suffice. */
+#ifndef AACDECODER_LIB_VL0
+#define AAC_PCM_MAX_OUTPUT_CHANNELS AAC_PCM_OUTPUT_CHANNELS
+#endif
+
 enum ConcealMethod {
 CONCEAL_METHOD_SPECTRAL_MUTING  =  0,
 CONCEAL_METHOD_NOISE_SUBSTITUTION   =  1,
@@ -76,7 +82,7 @@ static int get_stream_info(AVCodecContext *avctx)
 {
 FDKAACDecContext *s   = avctx-priv_data;
 CStreamInfo *info = aacDecoder_GetStreamInfo(s-handle);
-int channel_counts[9] = { 0 };
+int channel_counts[0x24] = { 0 };
 int i, ch_error   = 0;
 uint64_t ch_layout= 0;
 
@@ -94,7 +100,7 @@ static int get_stream_info(AVCodecContext *avctx)
 
 for (i = 0; i  info-numChannels; i++) {
 AUDIO_CHANNEL_TYPE ctype = info-pChannelType[i];
-if (ctype = ACT_NONE || ctype  ACT_TOP) {
+if (ctype = ACT_NONE || ctype  FF_ARRAY_ELEMS(channel_counts)) {
 av_log(avctx, AV_LOG_WARNING, unknown channel type\n);
 break;
 }
@@ -239,7 +245,7 @@ static av_cold int fdk_aac_decode_init(AVCodecContext 
*avctx)
 }
 
 if (downmix_channels != -1) {
-if (aacDecoder_SetParam(s-handle, AAC_PCM_OUTPUT_CHANNELS,
+if (aacDecoder_SetParam(s-handle, AAC_PCM_MAX_OUTPUT_CHANNELS,
 downmix_channels) != AAC_DEC_OK) {
av_log(avctx, AV_LOG_WARNING, Unable to set output channels in 
the decoder\n);
 } else {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libfdk-aacdec: Support building with the latest version of fdk-aac

2014-11-10 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Nov  4 
10:22:05 2014 +0200| [28396d17ff1c1493b78d6eece484ffc27ed86d0d] | committer: 
Martin Storsjö

libfdk-aacdec: Support building with the latest version of fdk-aac

The latest fdk-aac code drop (from android 5.0) changed the channel
layout enums (changing the value of existing enum constants), and
renamed the option for downmixing.

The failsafe comparison between ctype and FF_ARRAY_ELEMS(channel_counts)
can trigger warnings (-Wtautological-constant-out-of-range-compare)
when building with the old FDK AAC releases, where it can't be
out of range with the enum values used there.

CC: libav-sta...@libav.org
Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=28396d17ff1c1493b78d6eece484ffc27ed86d0d
---

 libavcodec/libfdk-aacdec.c |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c
index b054ebe..2c2abae 100644
--- a/libavcodec/libfdk-aacdec.c
+++ b/libavcodec/libfdk-aacdec.c
@@ -25,6 +25,12 @@
 #include avcodec.h
 #include internal.h
 
+/* The version macro is introduced the same time as the setting enum was
+ * changed, so this check should suffice. */
+#ifndef AACDECODER_LIB_VL0
+#define AAC_PCM_MAX_OUTPUT_CHANNELS AAC_PCM_OUTPUT_CHANNELS
+#endif
+
 enum ConcealMethod {
 CONCEAL_METHOD_SPECTRAL_MUTING  =  0,
 CONCEAL_METHOD_NOISE_SUBSTITUTION   =  1,
@@ -76,7 +82,7 @@ static int get_stream_info(AVCodecContext *avctx)
 {
 FDKAACDecContext *s   = avctx-priv_data;
 CStreamInfo *info = aacDecoder_GetStreamInfo(s-handle);
-int channel_counts[9] = { 0 };
+int channel_counts[0x24] = { 0 };
 int i, ch_error   = 0;
 uint64_t ch_layout= 0;
 
@@ -94,7 +100,7 @@ static int get_stream_info(AVCodecContext *avctx)
 
 for (i = 0; i  info-numChannels; i++) {
 AUDIO_CHANNEL_TYPE ctype = info-pChannelType[i];
-if (ctype = ACT_NONE || ctype  ACT_TOP) {
+if (ctype = ACT_NONE || ctype  FF_ARRAY_ELEMS(channel_counts)) {
 av_log(avctx, AV_LOG_WARNING, unknown channel type\n);
 break;
 }
@@ -239,7 +245,7 @@ static av_cold int fdk_aac_decode_init(AVCodecContext 
*avctx)
 }
 
 if (downmix_channels != -1) {
-if (aacDecoder_SetParam(s-handle, AAC_PCM_OUTPUT_CHANNELS,
+if (aacDecoder_SetParam(s-handle, AAC_PCM_MAX_OUTPUT_CHANNELS,
 downmix_channels) != AAC_DEC_OK) {
av_log(avctx, AV_LOG_WARNING, Unable to set output channels in 
the decoder\n);
 } else {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] v4l2: Unify one instance of reading/storing errno

2014-11-11 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov 10 
09:49:01 2014 +0200| [b776113e5d4a56759615196de98efe802e95a6b6] | committer: 
Martin Storsjö

v4l2: Unify one instance of reading/storing errno

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b776113e5d4a56759615196de98efe802e95a6b6
---

 libavdevice/v4l2.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index fdec0ec..302639d 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -348,14 +348,14 @@ static int mmap_init(AVFormatContext *ctx)
 
 res = ioctl(s-fd, VIDIOC_REQBUFS, req);
 if (res  0) {
-res = errno;
-if (errno == EINVAL) {
+res = AVERROR(errno);
+if (res == AVERROR(EINVAL)) {
 av_log(ctx, AV_LOG_ERROR, Device does not support mmap\n);
 } else {
 av_log(ctx, AV_LOG_ERROR, ioctl(VIDIOC_REQBUFS)\n);
 }
 
-return AVERROR(res);
+return res;
 }
 
 if (req.count  2) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavcodec: Unconditionally build xiph.o

2014-11-11 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov 10 
10:14:45 2014 +0200| [52f954da7594c31ad94c9bcb54290145b59b27f5] | committer: 
Martin Storsjö

libavcodec: Unconditionally build xiph.o

vorbis_parser.o is built unconditionally since 5e80fb7ff, and the
unconditionally built parts of it depend on xiph.o.

This fixes builds with --disable-everything.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=52f954da7594c31ad94c9bcb54290145b59b27f5
---

 libavcodec/Makefile |   21 +
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6270997..66aa0ce 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -27,6 +27,7 @@ OBJS = allcodecs.o
  \
raw.o\
utils.o  \
vorbis_parser.o  \
+   xiph.o   \
 
 # subsystems
 OBJS-$(CONFIG_AANDCTTABLES)+= aandcttab.o
@@ -369,7 +370,6 @@ OBJS-$(CONFIG_SVQ3_DECODER)+= svq3.o svq13.o 
mpegutils.o
 OBJS-$(CONFIG_TAK_DECODER) += takdec.o tak.o
 OBJS-$(CONFIG_TARGA_DECODER)   += targa.o
 OBJS-$(CONFIG_TARGA_ENCODER)   += targaenc.o rle.o
-OBJS-$(CONFIG_THEORA_DECODER)  += xiph.o
 OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
 OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o
 OBJS-$(CONFIG_TIFF_ENCODER)+= tiffenc.o rle.o lzwenc.o
@@ -401,7 +401,7 @@ OBJS-$(CONFIG_VMDAUDIO_DECODER)+= vmdaudio.o
 OBJS-$(CONFIG_VMDVIDEO_DECODER)+= vmdvideo.o
 OBJS-$(CONFIG_VMNC_DECODER)+= vmnc.o
 OBJS-$(CONFIG_VORBIS_DECODER)  += vorbisdec.o vorbisdsp.o vorbis.o \
-  vorbis_data.o xiph.o
+  vorbis_data.o
 OBJS-$(CONFIG_VORBIS_ENCODER)  += vorbisenc.o vorbis.o \
   vorbis_data.o
 OBJS-$(CONFIG_VP3_DECODER) += vp3.o
@@ -573,12 +573,11 @@ OBJS-$(CONFIG_GXF_DEMUXER) += mpeg12data.o
 OBJS-$(CONFIG_IFF_DEMUXER) += iff.o
 OBJS-$(CONFIG_ISMV_MUXER)  += mpeg4audio.o mpegaudiodata.o
 OBJS-$(CONFIG_LATM_MUXER)  += mpeg4audio.o
-OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)+= xiph.o mpeg4audio.o   \
+OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)+= mpeg4audio.o  \
   flac.o flacdata.o
-OBJS-$(CONFIG_MATROSKA_DEMUXER)+= mpeg4audio.o mpegaudiodata.o  \
-  xiph.o
+OBJS-$(CONFIG_MATROSKA_DEMUXER)+= mpeg4audio.o mpegaudiodata.o
 OBJS-$(CONFIG_MATROSKA_MUXER)  += mpeg4audio.o mpegaudiodata.o  \
-  flac.o flacdata.o xiph.o
+  flac.o flacdata.o
 OBJS-$(CONFIG_MP2_MUXER)   += mpegaudiodata.o mpegaudiodecheader.o
 OBJS-$(CONFIG_MP3_MUXER)   += mpegaudiodata.o mpegaudiodecheader.o
 OBJS-$(CONFIG_MOV_DEMUXER) += mpeg4audio.o mpegaudiodata.o ac3tab.o
@@ -586,17 +585,16 @@ OBJS-$(CONFIG_MOV_MUXER)   += mpeg4audio.o 
mpegaudiodata.o
 OBJS-$(CONFIG_MPEGTS_MUXER)+= mpeg4audio.o
 OBJS-$(CONFIG_MPEGTS_DEMUXER)  += mpeg4audio.o mpegaudiodata.o
 OBJS-$(CONFIG_NUT_MUXER)   += mpegaudiodata.o
-OBJS-$(CONFIG_OGG_DEMUXER) += xiph.o   \
-  mpeg12data.o \
+OBJS-$(CONFIG_OGG_DEMUXER) += mpeg12data.o \
   dirac.o
-OBJS-$(CONFIG_OGG_MUXER)   += xiph.o flac.o flacdata.o
-OBJS-$(CONFIG_RTP_MUXER)   += mpeg4audio.o xiph.o
+OBJS-$(CONFIG_OGG_MUXER)   += flac.o flacdata.o
+OBJS-$(CONFIG_RTP_MUXER)   += mpeg4audio.o
 OBJS-$(CONFIG_RTPDEC)  += mjpeg.o
 OBJS-$(CONFIG_SPDIF_DEMUXER)   += aacadtsdec.o mpeg4audio.o
 OBJS-$(CONFIG_SPDIF_MUXER) += dca.o
 OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
 OBJS-$(CONFIG_WEBM_MUXER)  += mpeg4audio.o mpegaudiodata.o  \
-  xiph.o flac.o flacdata.o
+  flac.o flacdata.o
 OBJS-$(CONFIG_WTV_DEMUXER) += mpeg4audio.o mpegaudiodata.o
 
 # external codec libraries
@@ -681,7 +679,6 @@ OBJS-$(CONFIG_TAK_PARSER)  += tak_parser.o tak.o
 OBJS-$(CONFIG_VC1_PARSER)  += vc1_parser.o vc1.o vc1data.o 
vc1dsp.o \
   msmpeg4.o msmpeg4data.o mpeg4video.o 
\
   h263.o
-OBJS-$(CONFIG_VORBIS_PARSER

[FFmpeg-cvslog] aarch64: Make the function pointer tables position independent

2014-11-15 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Nov 12 
00:00:04 2014 +0200| [c00365b46d464ce47716315c1801818d811bdb9a] | committer: 
Martin Storsjö

aarch64: Make the function pointer tables position independent

This allows running the code on android, where 64 bit binaries with
text relocations aren't allowed to be loaded.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c00365b46d464ce47716315c1801818d811bdb9a
---

 libavcodec/aarch64/fft_neon.S|   33 +
 libavcodec/aarch64/opus_imdct_neon.S |   18 +-
 2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/libavcodec/aarch64/fft_neon.S b/libavcodec/aarch64/fft_neon.S
index 5f88bed..ae9e1c6 100644
--- a/libavcodec/aarch64/fft_neon.S
+++ b/libavcodec/aarch64/fft_neon.S
@@ -376,7 +376,8 @@ function ff_fft_calc_neon, export=1
 ld1 {v30.16b}, [x10]
 mov x7,  #-8
 movrel  x12, pmmp
-ldr x3,  [x3, x2, lsl #3]
+ldr x4,  [x3, x2, lsl #3]
+add x3,  x3,  x4
 movrel  x13, mppm
 movrel  x14, X(ff_cos_16)
 ld1 {v31.16b}, [x11]
@@ -416,21 +417,21 @@ function ff_fft_permute_neon, export=1
 endfunc
 
 const   fft_tab_neon
-.quad fft4_neon
-.quad fft8_neon
-.quad fft16_neon
-.quad fft32_neon
-.quad fft64_neon
-.quad fft128_neon
-.quad fft256_neon
-.quad fft512_neon
-.quad fft1024_neon
-.quad fft2048_neon
-.quad fft4096_neon
-.quad fft8192_neon
-.quad fft16384_neon
-.quad fft32768_neon
-.quad fft65536_neon
+.quad fft4_neon - fft_tab_neon
+.quad fft8_neon - fft_tab_neon
+.quad fft16_neon- fft_tab_neon
+.quad fft32_neon- fft_tab_neon
+.quad fft64_neon- fft_tab_neon
+.quad fft128_neon   - fft_tab_neon
+.quad fft256_neon   - fft_tab_neon
+.quad fft512_neon   - fft_tab_neon
+.quad fft1024_neon  - fft_tab_neon
+.quad fft2048_neon  - fft_tab_neon
+.quad fft4096_neon  - fft_tab_neon
+.quad fft8192_neon  - fft_tab_neon
+.quad fft16384_neon - fft_tab_neon
+.quad fft32768_neon - fft_tab_neon
+.quad fft65536_neon - fft_tab_neon
 endconst
 
 const   pmmp, align=4
diff --git a/libavcodec/aarch64/opus_imdct_neon.S 
b/libavcodec/aarch64/opus_imdct_neon.S
index 5f6c502..c98931c 100644
--- a/libavcodec/aarch64/opus_imdct_neon.S
+++ b/libavcodec/aarch64/opus_imdct_neon.S
@@ -438,8 +438,8 @@ function fft_b15_calc_neon
 uzp1v12.4s, v4.4s,  v5.4s   // exp[11 - 14].re
 uzp2v13.4s, v4.4s,  v5.4s   // exp[11 - 14].im
 zip1v14.4s, v6.4s,  v7.4s   // exp[5,10].re/exp[5,10].im
-add x5,  x5,  x3,  lsl #3
-ldr x5,  [x5]
+ldr x6,  [x5, x3, lsl #3]
+add x5,  x5,  x6
 mov x10, x0
 blr x5
 ldp x20, x30, [sp]
@@ -452,13 +452,13 @@ function fft_b15_calc_neon
 endfunc
 
 const   fft_tab_neon
-.quad fft15_neon
-.quad fft30_neon
-.quad fft60_neon
-.quad fft120_neon
-.quad fft240_neon
-.quad fft480_neon
-.quad fft960_neon
+.quad fft15_neon  - fft_tab_neon
+.quad fft30_neon  - fft_tab_neon
+.quad fft60_neon  - fft_tab_neon
+.quad fft120_neon - fft_tab_neon
+.quad fft240_neon - fft_tab_neon
+.quad fft480_neon - fft_tab_neon
+.quad fft960_neon - fft_tab_neon
 endconst
 
 function ff_celt_imdct_half_neon, export=1

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavf: Add an MPEG-DASH ISOFF segmenting muxer

2014-11-17 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Oct  6 
11:36:17 2014 +0300| [fe5e6e34c05e274f98528be4f77f3c474473f977] | committer: 
Martin Storsjö

lavf: Add an MPEG-DASH ISOFF segmenting muxer

This is mostly to serve as a reference example on how to segment
the output from the mp4 muxer, capable of writing the segment
list in four different ways:
- SegmentTemplate with SegmentTimeline
- SegmentTemplate with implicit segments
- SegmentList with individual files
- SegmentList with one single file per track, and byte ranges

The muxer is able to serve live content (with optional windowing)
or create a static segmented MPD.

In advanced cases, users will probably want to do the segmenting
in their own application code.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fe5e6e34c05e274f98528be4f77f3c474473f977
---

 Changelog|2 +-
 configure|1 +
 libavformat/Makefile |1 +
 libavformat/allformats.c |1 +
 libavformat/dashenc.c|  773 ++
 libavformat/version.h|4 +-
 6 files changed, 779 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index ecec401..6af2e8a 100644
--- a/Changelog
+++ b/Changelog
@@ -6,7 +6,7 @@ version next:
 - HEVC/H.265 RTP payload format (draft v6) packetizer and depacketizer
 - avplay now exits by default at the end of playback
 - XCB-based screen-grabber
-- creating DASH compatible fragmented MP4
+- creating DASH compatible fragmented MP4, MPEG-DASH segmenting muxer
 
 
 version 11:
diff --git a/configure b/configure
index 766f9c2..4b0ef22 100755
--- a/configure
+++ b/configure
@@ -2039,6 +2039,7 @@ avi_muxer_select=riffenc
 avisynth_demuxer_deps=avisynth
 avisynth_demuxer_select=riffdec
 caf_demuxer_select=riffdec
+dash_muxer_select=mp4_muxer
 dirac_demuxer_select=dirac_parser
 dv_demuxer_select=dvprofile
 dv_muxer_select=dvprofile
diff --git a/libavformat/Makefile b/libavformat/Makefile
index ff887f0..7ed53a7 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -91,6 +91,7 @@ OBJS-$(CONFIG_CAVSVIDEO_MUXER)   += rawenc.o
 OBJS-$(CONFIG_CDG_DEMUXER)   += cdg.o
 OBJS-$(CONFIG_CDXL_DEMUXER)  += cdxl.o
 OBJS-$(CONFIG_CRC_MUXER) += crcenc.o
+OBJS-$(CONFIG_DASH_MUXER)+= dashenc.o isom.o
 OBJS-$(CONFIG_DAUD_DEMUXER)  += dauddec.o
 OBJS-$(CONFIG_DAUD_MUXER)+= daudenc.o
 OBJS-$(CONFIG_DFA_DEMUXER)   += dfa.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index bef155f..7868e3e 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -88,6 +88,7 @@ void av_register_all(void)
 REGISTER_DEMUXER (CDG,  cdg);
 REGISTER_DEMUXER (CDXL, cdxl);
 REGISTER_MUXER   (CRC,  crc);
+REGISTER_MUXER   (DASH, dash);
 REGISTER_MUXDEMUX(DAUD, daud);
 REGISTER_DEMUXER (DFA,  dfa);
 REGISTER_MUXDEMUX(DIRAC,dirac);
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
new file mode 100644
index 000..cacaf92
--- /dev/null
+++ b/libavformat/dashenc.c
@@ -0,0 +1,773 @@
+/*
+ * MPEG-DASH ISO BMFF segmenter
+ * Copyright (c) 2014 Martin Storsjo
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include config.h
+#if HAVE_UNISTD_H
+#include unistd.h
+#endif
+
+#include libavutil/avstring.h
+#include libavutil/intreadwrite.h
+#include libavutil/mathematics.h
+#include libavutil/opt.h
+#include libavutil/time_internal.h
+
+#include avc.h
+#include avformat.h
+#include avio_internal.h
+#include internal.h
+#include isom.h
+#include os_support.h
+#include url.h
+
+typedef struct Segment {
+char file[1024];
+int64_t start_pos;
+int range_length, index_length;
+int64_t time;
+int duration;
+int n;
+} Segment;
+
+typedef struct OutputStream {
+AVFormatContext *ctx;
+int ctx_inited;
+uint8_t iobuf[32768];
+URLContext *out;
+int packets_written;
+char initfile[1024];
+int64_t init_start_pos;
+int init_range_length;
+int nb_segments, segments_size, segment_index;
+Segment **segments;
+int64_t

[FFmpeg-cvslog] movenc: Allow writing a DASH sidx atom at the start of files

2014-11-17 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Oct 21 
11:42:27 2014 +0300| [40ed1cbf147d09fc0894bee160f0b6b6d9159fc5] | committer: 
Martin Storsjö

movenc: Allow writing a DASH sidx atom at the start of files

This is mapped to the faststart flag (which in this case
perhaps should be called shift and write index at the
start of the file), which for fragmented files will
write a sidx index at the start.

When segmenting DASH into files, there's usually one sidx
at the start of each segment (although it's not clear to me
whether that actually is necessary). When storing all of it
in one file, the MPD doesn't necessarily need to describe
the individual segments, but the offsets of the fragments can be
fetched from one large sidx atom at the start of the file. This
allows creating files for the DASH ISO BMFF on-demand profile.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=40ed1cbf147d09fc0894bee160f0b6b6d9159fc5
---

 libavformat/movenc.c |  117 +++---
 libavformat/movenc.h |1 +
 2 files changed, 92 insertions(+), 26 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 27b6ef1..3ba1cc8 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2568,7 +2568,8 @@ static int mov_write_tfrf_tags(AVIOContext *pb, 
MOVMuxContext *mov,
 return 0;
 }
 
-static int mov_add_tfra_entries(AVIOContext *pb, MOVMuxContext *mov, int 
tracks)
+static int mov_add_tfra_entries(AVIOContext *pb, MOVMuxContext *mov, int 
tracks,
+int size)
 {
 int i;
 for (i = 0; i  mov-nb_streams; i++) {
@@ -2587,6 +2588,7 @@ static int mov_add_tfra_entries(AVIOContext *pb, 
MOVMuxContext *mov, int tracks)
 }
 info = track-frag_info[track-nb_frag_info - 1];
 info-offset   = avio_tell(pb);
+info-size = size;
 // Try to recreate the original pts for the first packet
 // from the fields we have stored
 info-time = track-start_dts + track-frag_start +
@@ -2676,12 +2678,20 @@ static int mov_write_sidx_tag(AVIOContext *pb,
   MOVTrack *track, int ref_size, int 
total_sidx_size)
 {
 int64_t pos = avio_tell(pb), offset_pos, end_pos;
-int64_t presentation_time = track-start_dts + track-frag_start +
-track-cluster[0].cts;
-int64_t duration = track-start_dts + track-track_duration -
-   track-cluster[0].dts;
-int64_t offset;
-int starts_with_SAP = track-cluster[0].flags  MOV_SYNC_SAMPLE;
+int64_t presentation_time, duration, offset;
+int starts_with_SAP, i, entries;
+
+if (track-entry) {
+entries = 1;
+presentation_time = track-start_dts + track-frag_start +
+track-cluster[0].cts;
+duration = track-start_dts + track-track_duration -
+   track-cluster[0].dts;
+starts_with_SAP = track-cluster[0].flags  MOV_SYNC_SAMPLE;
+} else {
+entries = track-nb_frag_info;
+presentation_time = track-frag_info[0].time;
+}
 
 // pts0 should be cut away using edts
 if (presentation_time  0)
@@ -2697,10 +2707,21 @@ static int mov_write_sidx_tag(AVIOContext *pb,
 offset_pos = avio_tell(pb);
 avio_wb64(pb, 0); /* first_offset (offset to referenced moof) */
 avio_wb16(pb, 0); /* reserved */
-avio_wb16(pb, 1); /* reference_count */
-avio_wb32(pb, (0  31) | (ref_size  0x7fff)); /* reference_type (0 = 
media) | referenced_size */
-avio_wb32(pb, duration); /* subsegment_duration */
-avio_wb32(pb, (starts_with_SAP  31) | (0  28) | 0); /* starts_with_SAP 
| SAP_type | SAP_delta_time */
+
+avio_wb16(pb, entries); /* reference_count */
+for (i = 0; i  entries; i++) {
+if (!track-entry) {
+if (i  1  track-frag_info[i].offset != track-frag_info[i - 
1].offset + track-frag_info[i - 1].size) {
+   av_log(NULL, AV_LOG_ERROR, Non-consecutive fragments, writing 
incorrect sidx\n);
+}
+duration = track-frag_info[i].duration;
+ref_size = track-frag_info[i].size;
+starts_with_SAP = 1;
+}
+avio_wb32(pb, (0  31) | (ref_size  0x7fff)); /* reference_type 
(0 = media) | referenced_size */
+avio_wb32(pb, duration); /* subsegment_duration */
+avio_wb32(pb, (starts_with_SAP  31) | (0  28) | 0); /* 
starts_with_SAP | SAP_type | SAP_delta_time */
+}
 
 end_pos = avio_tell(pb);
 offset = pos + total_sidx_size - end_pos;
@@ -2731,7 +2752,10 @@ static int mov_write_sidx_tags(AVIOContext *pb, 
MOVMuxContext *mov,
 MOVTrack *track = mov-tracks[i];
 if (tracks = 0  i != tracks)
 continue;
-if (!track-entry)
+// When writing a sidx for the full file, entry is 0, but
+// we want to include all

[FFmpeg-cvslog] tools: Add a sidxindex tool

2014-11-17 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Oct 29 
11:43:34 2014 +0200| [c302d034ba2690a935df8bf7e4f5d44ed86e8d5c] | committer: 
Martin Storsjö

tools: Add a sidxindex tool

This tool can write an MPD file for fragmented MP4 files with
a sidx index at the start of the file.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c302d034ba2690a935df8bf7e4f5d44ed86e8d5c
---

 libavformat/Makefile |1 +
 tools/sidxindex.c|  410 ++
 2 files changed, 411 insertions(+)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 7ed53a7..15f205a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -412,3 +412,4 @@ TOOLS = aviocat 
\
 ismindex\
 pktdumper   \
 probetest   \
+sidxindex   \
diff --git a/tools/sidxindex.c b/tools/sidxindex.c
new file mode 100644
index 000..da41d09
--- /dev/null
+++ b/tools/sidxindex.c
@@ -0,0 +1,410 @@
+/*
+ * Copyright (c) 2014 Martin Storsjo
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include stdio.h
+#include string.h
+
+#include libavformat/avformat.h
+#include libavutil/avstring.h
+#include libavutil/intreadwrite.h
+#include libavutil/mathematics.h
+
+static int usage(const char *argv0, int ret)
+{
+fprintf(stderr, %s -out foo.mpd file1\n, argv0);
+return ret;
+}
+
+struct Track {
+const char *name;
+int64_t duration;
+int bitrate;
+int track_id;
+int is_audio, is_video;
+int width, height;
+int sample_rate, channels;
+int timescale;
+char codec_str[30];
+int64_t sidx_start, sidx_length;
+int64_t  earliest_presentation;
+uint32_t earliest_presentation_timescale;
+};
+
+struct Tracks {
+int nb_tracks;
+int64_t duration;
+struct Track **tracks;
+int multiple_tracks_per_file;
+};
+
+static void set_codec_str(AVCodecContext *codec, char *str, int size)
+{
+switch (codec-codec_id) {
+case AV_CODEC_ID_H264:
+snprintf(str, size, avc1);
+if (codec-extradata_size = 4  codec-extradata[0] == 1) {
+av_strlcatf(str, size, .%02x%02x%02x,
+codec-extradata[1], codec-extradata[2], 
codec-extradata[3]);
+}
+break;
+case AV_CODEC_ID_AAC:
+snprintf(str, size, mp4a.40); // 0x40 is the mp4 object type for AAC
+if (codec-extradata_size = 2) {
+int aot = codec-extradata[0]  3;
+if (aot == 31)
+aot = ((AV_RB16(codec-extradata)  5)  0x3f) + 32;
+av_strlcatf(str, size, .%d, aot);
+}
+break;
+}
+}
+
+static int find_sidx(struct Tracks *tracks, int start_index,
+ const char *file)
+{
+int err = 0;
+AVIOContext *f = NULL;
+int i;
+
+if ((err = avio_open2(f, file, AVIO_FLAG_READ, NULL, NULL))  0)
+goto fail;
+
+while (!f-eof_reached) {
+int64_t pos = avio_tell(f);
+int32_t size, tag;
+
+size = avio_rb32(f);
+tag  = avio_rb32(f);
+if (size  8)
+break;
+if (tag == MKBETAG('s', 'i', 'd', 'x')) {
+int version, track_id;
+uint32_t timescale;
+int64_t earliest_presentation;
+version = avio_r8(f);
+avio_rb24(f); /* flags */
+track_id = avio_rb32(f);
+timescale = avio_rb32(f);
+earliest_presentation = version ? avio_rb64(f) : avio_rb32(f);
+for (i = start_index; i  tracks-nb_tracks; i++) {
+struct Track *track = tracks-tracks[i];
+if (!track-sidx_start) {
+track-sidx_start  = pos;
+track-sidx_length = size;
+} else if (pos == track-sidx_start + track-sidx_length) {
+track-sidx_length = pos + size - track-sidx_start;
+}
+if (track-track_id == track_id

[FFmpeg-cvslog] lavf: Only initialize s- offset once when using avoid_negative_ts make_zero

2014-11-17 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov 17 
13:31:47 2014 +0200| [9257692ac15eff7b07540c1f61cebde0d8823fbd] | committer: 
Martin Storsjö

lavf: Only initialize s-offset once when using avoid_negative_ts make_zero

When given a stream starting at dts=0, it would previously consider
s-offset as uninitialized and set an offset when the second packet
was written, ending up writing two packets with dts=0. By initializing
this field to AV_NOPTS_VALUE, we make sure that we only initialize it
once, on the first packet.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9257692ac15eff7b07540c1f61cebde0d8823fbd
---

 libavformat/mux.c |4 ++--
 libavformat/options.c |1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 87220ec..9aee224 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -329,12 +329,12 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 AVRational time_base = s-streams[pkt-stream_index]-time_base;
 int64_t offset = 0;
 
-if (!s-offset  pkt-dts != AV_NOPTS_VALUE 
+if (s-offset == AV_NOPTS_VALUE  pkt-dts != AV_NOPTS_VALUE 
 (pkt-dts  0 || s-avoid_negative_ts == 
AVFMT_AVOID_NEG_TS_MAKE_ZERO)) {
 s-offset = -pkt-dts;
 s-offset_timebase = time_base;
 }
-if (s-offset)
+if (s-offset != AV_NOPTS_VALUE)
 offset = av_rescale_q(s-offset, s-offset_timebase, time_base);
 
 if (pkt-dts != AV_NOPTS_VALUE)
diff --git a/libavformat/options.c b/libavformat/options.c
index a5646df..ad47004 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -101,6 +101,7 @@ AVFormatContext *avformat_alloc_context(void)
 ic = av_malloc(sizeof(AVFormatContext));
 if (!ic) return ic;
 avformat_get_context_defaults(ic);
+ic-offset = AV_NOPTS_VALUE;
 
 ic-internal = av_mallocz(sizeof(*ic-internal));
 if (!ic-internal) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] hdsenc: Use the right filename in an error message

2014-11-19 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Nov 18 
14:16:41 2014 +0200| [f918b8a2933a65020cbe490ec637d5485c11a692] | committer: 
Martin Storsjö

hdsenc: Use the right filename in an error message

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f918b8a2933a65020cbe490ec637d5485c11a692
---

 libavformat/hdsenc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index ae9275c..012de60 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -174,7 +174,7 @@ static int write_manifest(AVFormatContext *s, int final)
 ret = avio_open2(out, temp_filename, AVIO_FLAG_WRITE,
  s-interrupt_callback, NULL);
 if (ret  0) {
-av_log(s, AV_LOG_ERROR, Unable to open %s for writing\n, filename);
+av_log(s, AV_LOG_ERROR, Unable to open %s for writing\n, 
temp_filename);
 return ret;
 }
 avio_printf(out, ?xml version=\1.0\ encoding=\utf-8\?\n);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] hdsenc: Clear the previous codec tag when setting up the chained muxer

2014-11-19 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Nov 18 
14:28:50 2014 +0200| [7fd10f66b722eccc2ada9128766d002f6d751f79] | committer: 
Martin Storsjö

hdsenc: Clear the previous codec tag when setting up the chained muxer

The chained flv muxer wants one set of tags - normally this set
could be signaled via the AVOutputFormat codec_tag field (as
smoothstreamingenc and dashenc do). hdsenc doesn't signal it, since
the FLV codec tag arrays aren't exported from flvenc.c. This can
lead to the caller keeping an original codec tag from the originating
container here, which would then be a mismatch for the FLV muxer.
Since we don't really care about what codec tag the caller might
have set, just clear it and let the lavf muxer layer set the right
one for the chained FLV muxer later instead.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7fd10f66b722eccc2ada9128766d002f6d751f79
---

 libavformat/hdsenc.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 012de60..d96a3d5 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -395,6 +395,7 @@ static int hds_write_header(AVFormatContext *s)
 goto fail;
 }
 avcodec_copy_context(st-codec, s-streams[i]-codec);
+st-codec-codec_tag = 0;
 st-sample_aspect_ratio = s-streams[i]-sample_aspect_ratio;
 st-time_base = s-streams[i]-time_base;
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavc: Move the libtwolame encoder registration to the list for external libraries

2014-11-21 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Nov 21 
14:23:02 2014 +0200| [aa8b39d999589154f79300de9038994d0093cd34] | committer: 
Vittorio Giovara

lavc: Move the libtwolame encoder registration to the list for external 
libraries

This makes sure the default behaviour of using the internal encoder
stays the same regardless if libtwolame is enabled or not (as for
any external library).

This fixes fate-lavf-mpg if libav is built with libtwolame enabled.

CC: libav-sta...@libav.org
Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa8b39d999589154f79300de9038994d0093cd34
---

 libavcodec/allcodecs.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index bd74e0b..6a71b2c 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -240,7 +240,6 @@ void avcodec_register_all(void)
 REGISTER_DECODER(SVQ3,  svq3);
 REGISTER_ENCDEC (TARGA, targa);
 REGISTER_DECODER(THEORA,theora);
-REGISTER_ENCODER(LIBTWOLAME,libtwolame);
 REGISTER_DECODER(THP,   thp);
 REGISTER_DECODER(TIERTEXSEQVIDEO,   tiertexseqvideo);
 REGISTER_ENCDEC (TIFF,  tiff);
@@ -448,6 +447,7 @@ void avcodec_register_all(void)
 REGISTER_ENCDEC (LIBSCHROEDINGER,   libschroedinger);
 REGISTER_ENCDEC (LIBSPEEX,  libspeex);
 REGISTER_ENCODER(LIBTHEORA, libtheora);
+REGISTER_ENCODER(LIBTWOLAME,libtwolame);
 REGISTER_ENCODER(LIBVO_AACENC,  libvo_aacenc);
 REGISTER_ENCODER(LIBVO_AMRWBENC,libvo_amrwbenc);
 REGISTER_ENCODER(LIBVORBIS, libvorbis);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavf: Remove a redundant include of sys/stat.h

2014-11-22 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Nov 18 
09:57:07 2014 +0200| [eec7f032a903e06d249d1e8aa6630b65292bf40f] | committer: 
Martin Storsjö

lavf: Remove a redundant include of sys/stat.h

The same file already includes this header a few lines further
above.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eec7f032a903e06d249d1e8aa6630b65292bf40f
---

 libavformat/os_support.h |2 --
 1 file changed, 2 deletions(-)

diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index f751d41..068abdf 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -48,8 +48,6 @@
 #include io.h
 #endif
 #define mkdir(a, b) _mkdir(a)
-#else
-#include sys/stat.h
 #endif
 
 static inline int is_dos_path(const char *path)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] sidxindex: Write mimeType=audio/mp4 for audio-only representations

2014-11-24 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Nov 23 
17:30:35 2014 +0200| [6f26f14f134e753d6168591f30815b1c08c1498b] | committer: 
Martin Storsjö

sidxindex: Write mimeType=audio/mp4 for audio-only representations

This fixes playback with dash.js, when the input is one separate
mp4 file per track.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6f26f14f134e753d6168591f30815b1c08c1498b
---

 tools/sidxindex.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/sidxindex.c b/tools/sidxindex.c
index da41d09..62f021f 100644
--- a/tools/sidxindex.c
+++ b/tools/sidxindex.c
@@ -327,7 +327,7 @@ static int output_mpd(struct Tracks *tracks, const char 
*filename)
 for (i = 0; i  nb_tracks[set]; ) {
 struct Track *first_track = adaptation_sets[set][i];
 int width = 0, height = 0, sample_rate = 0, channels = 0, bitrate 
= 0;
-fprintf(out, \t\t\tRepresentation id=\%d\ 
mimeType=\video/mp4\ codecs=\, i);
+fprintf(out, \t\t\tRepresentation id=\%d\ codecs=\, i);
 for (j = i; j  nb_tracks[set]; j++) {
 struct Track *track = adaptation_sets[set][j];
 if (strcmp(track-name, first_track-name))
@@ -345,7 +345,8 @@ static int output_mpd(struct Tracks *tracks, const char 
*filename)
 fprintf(out, ,);
 fprintf(out, %s, track-codec_str);
 }
-fprintf(out, \ bandwidth=\%d\, bitrate);
+fprintf(out, \ mimeType=\%s/mp4\ bandwidth=\%d\,
+width ? video : audio, bitrate);
 if (width  0  height  0)
 fprintf(out,  width=\%d\ height=\%d\, width, height);
 if (sample_rate  0)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] dashenc: Don't segment all video streams when one stream gets a keyframe

2014-11-24 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov 17 
15:26:17 2014 +0200| [fe42f94ce1023f9c2f7e86404c60afcee5b078a9] | committer: 
Martin Storsjö

dashenc: Don't segment all video streams when one stream gets a keyframe

This makes sure that segments actually start at a keyframe (and
makes sure we don't split segments twice in a row, with one segment
consisting of only a handful of packets), when one stream uses b-frames
while another one doesn't.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fe42f94ce1023f9c2f7e86404c60afcee5b078a9
---

 libavformat/dashenc.c |   25 +++--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 41caf6d..0654661 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -75,7 +75,6 @@ typedef struct DASHContext {
 int single_file;
 OutputStream *streams;
 int has_video, has_audio;
-int nb_segments;
 int last_duration;
 int total_duration;
 char availability_start_time[100];
@@ -595,10 +594,13 @@ static void find_index_range(AVFormatContext *s, const 
char *dirname,
 *index_length = AV_RB32(buf[0]);
 }
 
-static int dash_flush(AVFormatContext *s, int final)
+static int dash_flush(AVFormatContext *s, int final, int stream)
 {
 DASHContext *c = s-priv_data;
 int i, ret = 0;
+int cur_flush_segment_index = 0;
+if (stream = 0)
+cur_flush_segment_index = c-streams[stream].segment_index;
 
 for (i = 0; i  s-nb_streams; i++) {
 OutputStream *os = c-streams[i];
@@ -609,6 +611,18 @@ static int dash_flush(AVFormatContext *s, int final)
 if (!os-packets_written)
 continue;
 
+// Flush the single stream that got a keyframe right now.
+// Flush all audio streams as well, in sync with video keyframes,
+// but not the other video streams.
+if (stream = 0  i != stream) {
+if (s-streams[i]-codec-codec_type != AVMEDIA_TYPE_AUDIO)
+continue;
+// Make sure we don't flush audio streams multiple times, when
+// all video streams are flushed one at a time.
+if (c-has_video  os-segment_index  cur_flush_segment_index)
+continue;
+}
+
 if (!c-single_file) {
 snprintf(filename, sizeof(filename), chunk-stream%d-%05d.m4s, i, 
os-segment_index);
 snprintf(full_path, sizeof(full_path), %s%s, c-dirname, 
filename);
@@ -665,7 +679,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 DASHContext *c = s-priv_data;
 AVStream *st = s-streams[pkt-stream_index];
 OutputStream *os = c-streams[pkt-stream_index];
-int64_t seg_end_duration = (c-nb_segments + 1) * (int64_t) 
c-min_seg_duration;
+int64_t seg_end_duration = (os-segment_index) * (int64_t) 
c-min_seg_duration;
 int ret;
 
 // If forcing the stream to start at 0, the mp4 muxer will set the start
@@ -701,9 +715,8 @@ static int dash_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 }
 
-if ((ret = dash_flush(s, 0))  0)
+if ((ret = dash_flush(s, 0, pkt-stream_index))  0)
 return ret;
-c-nb_segments++;
 }
 
 if (!os-packets_written)
@@ -729,7 +742,7 @@ static int dash_write_trailer(AVFormatContext *s)
  s-streams[0]-time_base,
  AV_TIME_BASE_Q);
 }
-dash_flush(s, 1);
+dash_flush(s, 1, -1);
 
 if (c-remove_at_exit) {
 char filename[1024];

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavf: Don't try to update files atomically with renames on windows

2014-11-24 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Nov 18 
14:06:19 2014 +0200| [b9d08c77a44390b0848c06f20bc0e9e951ba6a3c] | committer: 
Martin Storsjö

lavf: Don't try to update files atomically with renames on windows

On windows, rename(2) will fail if the target file exists. On
unix this trick is used to make sure that people reading the file
either will get the full previous file, or the full new version
of the file, but no intermediate version.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b9d08c77a44390b0848c06f20bc0e9e951ba6a3c
---

 libavformat/dashenc.c|   14 +-
 libavformat/hdsenc.c |   16 ++--
 libavformat/internal.h   |6 ++
 libavformat/smoothstreamingenc.c |8 +---
 4 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 0654661..57ce85f 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -296,13 +296,15 @@ static int write_manifest(AVFormatContext *s, int final)
 DASHContext *c = s-priv_data;
 AVIOContext *out;
 char temp_filename[1024];
+const char *write_filename;
 int ret, i;
 AVDictionaryEntry *title = av_dict_get(s-metadata, title, NULL, 0);
 
 snprintf(temp_filename, sizeof(temp_filename), %s.tmp, s-filename);
-ret = avio_open2(out, temp_filename, AVIO_FLAG_WRITE, 
s-interrupt_callback, NULL);
+write_filename = USE_RENAME_REPLACE ? temp_filename : s-filename;
+ret = avio_open2(out, write_filename, AVIO_FLAG_WRITE, 
s-interrupt_callback, NULL);
 if (ret  0) {
-av_log(s, AV_LOG_ERROR, Unable to open %s for writing\n, 
temp_filename);
+av_log(s, AV_LOG_ERROR, Unable to open %s for writing\n, 
write_filename);
 return ret;
 }
 avio_printf(out, ?xml version=\1.0\ encoding=\utf-8\?\n);
@@ -392,7 +394,7 @@ static int write_manifest(AVFormatContext *s, int final)
 avio_printf(out, /MPD\n);
 avio_flush(out);
 avio_close(out);
-return ff_rename(temp_filename, s-filename);
+return USE_RENAME_REPLACE ? ff_rename(temp_filename, s-filename) : 0;
 }
 
 static int dash_write_header(AVFormatContext *s)
@@ -605,6 +607,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 for (i = 0; i  s-nb_streams; i++) {
 OutputStream *os = c-streams[i];
 char filename[1024] = , full_path[1024], temp_path[1024];
+const char *write_path;
 int64_t start_pos = avio_tell(os-ctx-pb);
 int range_length, index_length = 0;
 
@@ -627,7 +630,8 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 snprintf(filename, sizeof(filename), chunk-stream%d-%05d.m4s, i, 
os-segment_index);
 snprintf(full_path, sizeof(full_path), %s%s, c-dirname, 
filename);
 snprintf(temp_path, sizeof(temp_path), %s.tmp, full_path);
-ret = ffurl_open(os-out, temp_path, AVIO_FLAG_WRITE, 
s-interrupt_callback, NULL);
+write_path = USE_RENAME_REPLACE ? temp_path : full_path;
+ret = ffurl_open(os-out, write_path, AVIO_FLAG_WRITE, 
s-interrupt_callback, NULL);
 if (ret  0)
 break;
 write_styp(os-ctx-pb);
@@ -642,7 +646,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 } else {
 ffurl_close(os-out);
 os-out = NULL;
-ret = ff_rename(temp_path, full_path);
+ret = USE_RENAME_REPLACE ? ff_rename(temp_path, full_path) : 0;
 if (ret  0)
 break;
 }
diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index d96a3d5..326f886 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -163,6 +163,7 @@ static int write_manifest(AVFormatContext *s, int final)
 HDSContext *c = s-priv_data;
 AVIOContext *out;
 char filename[1024], temp_filename[1024];
+const char *write_filename;
 int ret, i;
 float duration = 0;
 
@@ -171,10 +172,11 @@ static int write_manifest(AVFormatContext *s, int final)
 
 snprintf(filename, sizeof(filename), %s/index.f4m, s-filename);
 snprintf(temp_filename, sizeof(temp_filename), %s/index.f4m.tmp, 
s-filename);
-ret = avio_open2(out, temp_filename, AVIO_FLAG_WRITE,
+write_filename = USE_RENAME_REPLACE ? temp_filename : filename;
+ret = avio_open2(out, write_filename, AVIO_FLAG_WRITE,
  s-interrupt_callback, NULL);
 if (ret  0) {
-av_log(s, AV_LOG_ERROR, Unable to open %s for writing\n, 
temp_filename);
+av_log(s, AV_LOG_ERROR, Unable to open %s for writing\n, 
write_filename);
 return ret;
 }
 avio_printf(out, ?xml version=\1.0\ encoding=\utf-8\?\n);
@@ -204,7 +206,7 @@ static int write_manifest(AVFormatContext *s, int final)
 avio_printf(out, /manifest\n);
 avio_flush(out);
 avio_close(out);
-return ff_rename

[FFmpeg-cvslog] lavf: Use wchar functions for filenames on windows for mkdir/rmdir/rename/ unlink

2014-11-24 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov 17 
23:08:15 2014 +0200| [960aff379da46dcaff61504a57714d4d4e758e41] | committer: 
Martin Storsjö

lavf: Use wchar functions for filenames on windows for mkdir/rmdir/rename/unlink

This makes sure that the internal utf8 path names are handled
properly - the normal file handling functions assume path names
are in the native codepage, which isn't utf8.

This assumes that the tools outside of lavf don't use the mkdir
definition. (The tools don't do the same reading of command line
parameters as wchar either - they probably won't handle all possible
unicode file parameters properly, but at least work more predictably
if no utf8/wchar conversion is involved.)

This is moved further down in os_support.h, since windows.h shouldn't
be included before winsock2.h, while io.h needs to be included before
the manual defines for lseek functions.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=960aff379da46dcaff61504a57714d4d4e758e41
---

 libavformat/internal.h   |1 +
 libavformat/os_support.h |  100 +-
 2 files changed, 92 insertions(+), 9 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 5feb0f8..d69ce49 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -23,6 +23,7 @@
 
 #include stdint.h
 #include avformat.h
+#include os_support.h
 
 #define MAX_URL_SIZE 4096
 
diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 068abdf..50846d0 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -31,6 +31,15 @@
 
 #include sys/stat.h
 
+#ifdef _WIN32
+#if HAVE_DIRECT_H
+#include direct.h
+#endif
+#if HAVE_IO_H
+#include io.h
+#endif
+#endif
+
 #if defined(_WIN32)  !defined(__MINGW32CE__)
 #  include fcntl.h
 #  undef lseek
@@ -41,15 +50,6 @@
 #  define fstat(f,s) _fstati64((f), (s))
 #endif /* defined(_WIN32)  !defined(__MINGW32CE__) */
 
-#ifdef _WIN32
-#if HAVE_DIRECT_H
-#include direct.h
-#elif HAVE_IO_H
-#include io.h
-#endif
-#define mkdir(a, b) _mkdir(a)
-#endif
-
 static inline int is_dos_path(const char *path)
 {
 #if HAVE_DOS_PATHS
@@ -122,4 +122,86 @@ int ff_poll(struct pollfd *fds, nfds_t numfds, int 
timeout);
 #endif /* HAVE_POLL_H */
 #endif /* CONFIG_NETWORK */
 
+#if defined(__MINGW32CE__)
+#define mkdir(a, b) _mkdir(a)
+#elif defined(_WIN32)
+#include stdio.h
+#include windows.h
+#include libavutil/mem.h
+
+static inline int utf8towchar(const char *filename_utf8, wchar_t **filename_w)
+{
+int num_chars;
+num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, 
filename_utf8, -1, NULL, 0);
+if (num_chars = 0) {
+*filename_w = NULL;
+return 0;
+}
+*filename_w = av_mallocz(sizeof(wchar_t) * num_chars);
+if (!*filename_w) {
+errno = ENOMEM;
+return -1;
+}
+MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, *filename_w, num_chars);
+return 0;
+}
+
+#define DEF_FS_FUNCTION(name, wfunc, afunc)   \
+static inline int win32_##name(const char *filename_utf8) \
+{ \
+wchar_t *filename_w;  \
+int ret;  \
+  \
+if (utf8towchar(filename_utf8, filename_w))  \
+return -1;\
+if (!filename_w)  \
+goto fallback;\
+  \
+ret = wfunc(filename_w);  \
+av_free(filename_w);  \
+return ret;   \
+  \
+fallback: \
+/* filename may be be in CP_ACP */\
+return afunc(filename_utf8);  \
+}
+
+DEF_FS_FUNCTION(unlink, _wunlink, _unlink)
+DEF_FS_FUNCTION(mkdir,  _wmkdir,  _mkdir)
+DEF_FS_FUNCTION(rmdir,  _wrmdir , _rmdir)
+
+static inline int win32_rename(const char *src_utf8, const char *dest_utf8)
+{
+wchar_t *src_w, *dest_w;
+int ret;
+
+if (utf8towchar(src_utf8, src_w))
+return -1;
+if (utf8towchar(dest_utf8, dest_w)) {
+av_free(src_w);
+return -1;
+}
+if (!src_w || !dest_w) {
+av_free(src_w);
+av_free(dest_w);
+goto fallback;
+}
+
+ret = _wrename(src_w, dest_w);
+av_free(src_w);
+av_free(dest_w);
+return ret;
+
+fallback:
+/* filename may be be in CP_ACP */
+return rename(src_utf8, dest_utf8);
+}
+
+#define mkdir(a, b) win32_mkdir(a)
+#define rename  win32_rename
+#define rmdir   win32_rmdir
+#define unlink  win32_unlink
+
+#endif
+
 #endif

[FFmpeg-cvslog] vorbis_parser: Include stdint.h in the header, to make it work standalone

2014-11-25 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Nov 25 
10:43:55 2014 +0200| [f20141d73f08ed0c8e875bd993a7143e19b266e3] | committer: 
Martin Storsjö

vorbis_parser: Include stdint.h in the header, to make it work standalone

This fixes make checkheaders.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f20141d73f08ed0c8e875bd993a7143e19b266e3
---

 libavcodec/vorbis_parser.h |2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/vorbis_parser.h b/libavcodec/vorbis_parser.h
index 7b12900..9ae1630 100644
--- a/libavcodec/vorbis_parser.h
+++ b/libavcodec/vorbis_parser.h
@@ -27,6 +27,8 @@
 #ifndef AVCODEC_VORBIS_PARSE_H
 #define AVCODEC_VORBIS_PARSE_H
 
+#include stdint.h
+
 typedef struct AVVorbisParseContext AVVorbisParseContext;
 
 /**

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Add a flag for indicating a discontinuous fragment

2014-11-26 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Thu Nov 20 
09:51:05 2014 +0200| [ee37620b6ae4783cda637408422044b2d14a688c] | committer: 
Martin Storsjö

movenc: Add a flag for indicating a discontinuous fragment

This allows creating a later mp4 fragment without sequentially
writing the earlier ones before (when called from a segmenter).

Normally when writing a fragmented mp4 file sequentially, the
first timestamps of a fragment are adjusted to match the
end of the previous fragment, to make sure the timestamp is the
same, even if it is calculated as the sum of previous fragment
durations. (And for the first packet in a file, the offset of
the first packet is written using an edit list.)

When writing an individual mp4 fragment discontinuously like this
(with potentially writing the earlier fragments separately later),
there's a risk of getting a gap in the timeline if the duration
field of the last packet in the previous fragment doesn't match up
with the start time of the next fragment.

Using this requires setting -avoid_negative_ts make_non_negative
(or -avoid_negative_ts 0).

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ee37620b6ae4783cda637408422044b2d14a688c
---

 libavformat/movenc.c |   34 --
 libavformat/movenc.h |2 ++
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 3ba1cc8..80531d0 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -60,6 +60,7 @@ static const AVOption options[] = {
 { disable_chpl, Disable Nero chapter atom, 0, AV_OPT_TYPE_CONST, {.i64 
= FF_MOV_FLAG_DISABLE_CHPL}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 
movflags },
 { default_base_moof, Set the default-base-is-moof flag in tfhd atoms, 
0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DEFAULT_BASE_MOOF}, INT_MIN, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM, movflags },
 { dash, Write DASH compatible fragmented MP4, 0, AV_OPT_TYPE_CONST, 
{.i64 = FF_MOV_FLAG_DASH}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 
movflags },
+{ frag_discont, Signal that the next fragment is discontinuous from 
earlier ones, 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_DISCONT}, 
INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, movflags },
 FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags),
 { skip_iods, Skip writing iods atom., offsetof(MOVMuxContext, 
iods_skip), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
 { iods_audio_profile, iods audio profile atom., 
offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 
255, AV_OPT_FLAG_ENCODING_PARAM},
@@ -3282,11 +3283,19 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 trk-cluster[trk-entry].entries  = samples_in_chunk;
 trk-cluster[trk-entry].dts  = pkt-dts;
 if (!trk-entry  trk-start_dts != AV_NOPTS_VALUE) {
-/* First packet of a new fragment. We already wrote the duration
- * of the last packet of the previous fragment based on track_duration,
- * which might not exactly match our dts. Therefore adjust the dts
- * of this packet to be what the previous packets duration implies. */
-trk-cluster[trk-entry].dts = trk-start_dts + trk-track_duration;
+if (!trk-frag_discont) {
+/* First packet of a new fragment. We already wrote the duration
+ * of the last packet of the previous fragment based on 
track_duration,
+ * which might not exactly match our dts. Therefore adjust the dts
+ * of this packet to be what the previous packets duration 
implies. */
+trk-cluster[trk-entry].dts = trk-start_dts + 
trk-track_duration;
+} else {
+/* New fragment, but discontinuous from previous fragments.
+ * Pretend the duration sum of the earlier fragments is
+ * pkt-dts - trk-start_dts. */
+trk-frag_start = pkt-dts - trk-start_dts;
+trk-frag_discont = 0;
+}
 }
 if (!trk-entry  trk-start_dts == AV_NOPTS_VALUE  !mov-use_editlist 

 s-avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) {
@@ -3299,7 +3308,13 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 if (trk-start_dts == AV_NOPTS_VALUE) {
 trk-start_dts = pkt-dts;
-if (pkt-dts  mov-flags  FF_MOV_FLAG_EMPTY_MOOV)
+if (trk-frag_discont) {
+/* Pretend the whole stream started at dts=0, with earlier 
framgents
+ * already written, with a duration summing up to pkt-dts. */
+trk-frag_start   = pkt-dts;
+trk-start_dts= 0;
+trk-frag_discont = 0;
+} else if (pkt-dts  mov-flags  FF_MOV_FLAG_EMPTY_MOOV)
 av_log(s, AV_LOG_WARNING,
Track %d starts with a nonzero dts %PRId64. This 
currently isn't handled correctly

[FFmpeg-cvslog] movenc: Expose the fragment index as an avoption

2014-11-26 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov  3 
22:38:09 2014 +0200| [234fb81e3145e9c9aec4ec16266676fab7dc21fa] | committer: 
Martin Storsjö

movenc: Expose the fragment index as an avoption

This allows setting the right fragment number if doing
random-access writing of fragments, and also allows reading the
current sequence number.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=234fb81e3145e9c9aec4ec16266676fab7dc21fa
---

 libavformat/movenc.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 80531d0..f6109e6 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -71,6 +71,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},
 { brand,Override major brand, offsetof(MOVMuxContext, 
major_brand),   AV_OPT_TYPE_STRING, {.str = NULL}, .flags = 
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},
+{ fragment_index, Fragment number of the next fragment, 
offsetof(MOVMuxContext, fragments), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM},
 { NULL },
 };
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Share the utf8 to wchar conversion routine between lavf and lavu

2014-11-27 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Nov 25 
10:39:50 2014 +0200| [9326d64ed1baadd7af60df6bbcc59cf1fefede48] | committer: 
Martin Storsjö

Share the utf8 to wchar conversion routine between lavf and lavu

This doesn't add any dependency on library internals, since this
only is a static inline function that gets built into each of the
calling functions - this is only to reduce the code duplication.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9326d64ed1baadd7af60df6bbcc59cf1fefede48
---

 libavformat/os_support.h   |   19 +--
 libavutil/file_open.c  |   13 -
 libavutil/wchar_filename.h |   44 
 3 files changed, 49 insertions(+), 27 deletions(-)

diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 50846d0..4aa98bd 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -127,24 +127,7 @@ int ff_poll(struct pollfd *fds, nfds_t numfds, int 
timeout);
 #elif defined(_WIN32)
 #include stdio.h
 #include windows.h
-#include libavutil/mem.h
-
-static inline int utf8towchar(const char *filename_utf8, wchar_t **filename_w)
-{
-int num_chars;
-num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, 
filename_utf8, -1, NULL, 0);
-if (num_chars = 0) {
-*filename_w = NULL;
-return 0;
-}
-*filename_w = av_mallocz(sizeof(wchar_t) * num_chars);
-if (!*filename_w) {
-errno = ENOMEM;
-return -1;
-}
-MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, *filename_w, num_chars);
-return 0;
-}
+#include libavutil/wchar_filename.h
 
 #define DEF_FS_FUNCTION(name, wfunc, afunc)   \
 static inline int win32_##name(const char *filename_utf8) \
diff --git a/libavutil/file_open.c b/libavutil/file_open.c
index 765eb60..f14ea70 100644
--- a/libavutil/file_open.c
+++ b/libavutil/file_open.c
@@ -37,23 +37,18 @@
 #include windows.h
 #include share.h
 #include errno.h
+#include wchar_filename.h
 
 static int win32_open(const char *filename_utf8, int oflag, int pmode)
 {
 int fd;
-int num_chars;
 wchar_t *filename_w;
 
 /* convert UTF-8 to wide chars */
-num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, 
filename_utf8, -1, NULL, 0);
-if (num_chars = 0)
-goto fallback;
-filename_w = av_mallocz(sizeof(wchar_t) * num_chars);
-if (!filename_w) {
-errno = ENOMEM;
+if (utf8towchar(filename_utf8, filename_w))
 return -1;
-}
-MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, filename_w, num_chars);
+if (!filename_w)
+goto fallback;
 
 fd = _wsopen(filename_w, oflag, SH_DENYNO, pmode);
 av_freep(filename_w);
diff --git a/libavutil/wchar_filename.h b/libavutil/wchar_filename.h
new file mode 100644
index 000..2781773
--- /dev/null
+++ b/libavutil/wchar_filename.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_WCHAR_FILENAME_H
+#define AVUTIL_WCHAR_FILENAME_H
+
+#if defined(_WIN32)  !defined(__MINGW32CE__)
+#include windows.h
+#include mem.h
+
+static inline int utf8towchar(const char *filename_utf8, wchar_t **filename_w)
+{
+int num_chars;
+num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, 
filename_utf8, -1, NULL, 0);
+if (num_chars = 0) {
+*filename_w = NULL;
+return 0;
+}
+*filename_w = av_mallocz(sizeof(wchar_t) * num_chars);
+if (!*filename_w) {
+errno = ENOMEM;
+return -1;
+}
+MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, *filename_w, num_chars);
+return 0;
+}
+#endif
+
+#endif /* AVUTIL_WCHAR_FILENAME_H */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavf: Use MoveFileEx instead of rename/_wrename on windows

2014-11-27 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Nov 25 
11:08:59 2014 +0200| [79fd186a5035cf16fc0ab288d8f59da8b1ba2c0e] | committer: 
Martin Storsjö

lavf: Use MoveFileEx instead of rename/_wrename on windows

This allows getting the normal unix semantics, where a rename
allows replacing an existing file.

Based on a suggestion by Reimar Döffinger.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=79fd186a5035cf16fc0ab288d8f59da8b1ba2c0e
---

 configure|2 ++
 libavformat/os_support.h |   21 +++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 7b3faae..355a95b 100755
--- a/configure
+++ b/configure
@@ -1466,6 +1466,7 @@ SYSTEM_FUNCS=
 localtime_r
 mach_absolute_time
 MapViewOfFile
+MoveFileExA
 memalign
 mkstemp
 mmap
@@ -4096,6 +4097,7 @@ check_func_headers windows.h GetProcessAffinityMask
 check_func_headers windows.h GetProcessTimes
 check_func_headers windows.h GetSystemTimeAsFileTime
 check_func_headers windows.h MapViewOfFile
+check_func_headers windows.h MoveFileExA
 check_func_headers windows.h SetConsoleTextAttribute
 check_func_headers windows.h Sleep
 check_func_headers windows.h VirtualAlloc
diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 4aa98bd..4949065 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -170,14 +170,31 @@ static inline int win32_rename(const char *src_utf8, 
const char *dest_utf8)
 goto fallback;
 }
 
-ret = _wrename(src_w, dest_w);
+ret = MoveFileExW(src_w, dest_w, MOVEFILE_REPLACE_EXISTING);
 av_free(src_w);
 av_free(dest_w);
+// Lacking proper mapping from GetLastError() error codes to errno codes
+if (ret)
+errno = EPERM;
 return ret;
 
 fallback:
 /* filename may be be in CP_ACP */
-return rename(src_utf8, dest_utf8);
+#if HAVE_MOVEFILEEXA
+ret = MoveFileExA(src_utf8, dest_utf8, MOVEFILE_REPLACE_EXISTING);
+if (ret)
+errno = EPERM;
+#else
+/* Windows Phone doesn't have MoveFileExA. However, it's unlikely
+ * that anybody would input filenames in CP_ACP there, so this
+ * fallback is kept mostly for completeness. Alternatively we could
+ * do MultiByteToWideChar(CP_ACP) and use MoveFileExW, but doing
+ * explicit conversions with CP_ACP is allegedly forbidden in windows
+ * store apps (or windows phone), and the notion of a native code page
+ * doesn't make much sense there. */
+ret = rename(src_utf8, dest_utf8);
+#endif
+return ret;
 }
 
 #define mkdir(a, b) win32_mkdir(a)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Revert lavf: Don't try to update files atomically with renames on windows

2014-11-27 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Nov 25 
10:51:23 2014 +0200| [675ac56b7ee0f204963fde55295197c5df80aa91] | committer: 
Martin Storsjö

Revert lavf: Don't try to update files atomically with renames on windows

This reverts commit b9d08c77a44390b0848c06f20bc0e9e951ba6a3c.

After taking MoveFileEx into use, we can replace files with renames
on windows as well.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=675ac56b7ee0f204963fde55295197c5df80aa91
---

 libavformat/dashenc.c|   14 +-
 libavformat/hdsenc.c |   16 ++--
 libavformat/internal.h   |6 --
 libavformat/smoothstreamingenc.c |8 +++-
 4 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 57ce85f..0654661 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -296,15 +296,13 @@ static int write_manifest(AVFormatContext *s, int final)
 DASHContext *c = s-priv_data;
 AVIOContext *out;
 char temp_filename[1024];
-const char *write_filename;
 int ret, i;
 AVDictionaryEntry *title = av_dict_get(s-metadata, title, NULL, 0);
 
 snprintf(temp_filename, sizeof(temp_filename), %s.tmp, s-filename);
-write_filename = USE_RENAME_REPLACE ? temp_filename : s-filename;
-ret = avio_open2(out, write_filename, AVIO_FLAG_WRITE, 
s-interrupt_callback, NULL);
+ret = avio_open2(out, temp_filename, AVIO_FLAG_WRITE, 
s-interrupt_callback, NULL);
 if (ret  0) {
-av_log(s, AV_LOG_ERROR, Unable to open %s for writing\n, 
write_filename);
+av_log(s, AV_LOG_ERROR, Unable to open %s for writing\n, 
temp_filename);
 return ret;
 }
 avio_printf(out, ?xml version=\1.0\ encoding=\utf-8\?\n);
@@ -394,7 +392,7 @@ static int write_manifest(AVFormatContext *s, int final)
 avio_printf(out, /MPD\n);
 avio_flush(out);
 avio_close(out);
-return USE_RENAME_REPLACE ? ff_rename(temp_filename, s-filename) : 0;
+return ff_rename(temp_filename, s-filename);
 }
 
 static int dash_write_header(AVFormatContext *s)
@@ -607,7 +605,6 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 for (i = 0; i  s-nb_streams; i++) {
 OutputStream *os = c-streams[i];
 char filename[1024] = , full_path[1024], temp_path[1024];
-const char *write_path;
 int64_t start_pos = avio_tell(os-ctx-pb);
 int range_length, index_length = 0;
 
@@ -630,8 +627,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 snprintf(filename, sizeof(filename), chunk-stream%d-%05d.m4s, i, 
os-segment_index);
 snprintf(full_path, sizeof(full_path), %s%s, c-dirname, 
filename);
 snprintf(temp_path, sizeof(temp_path), %s.tmp, full_path);
-write_path = USE_RENAME_REPLACE ? temp_path : full_path;
-ret = ffurl_open(os-out, write_path, AVIO_FLAG_WRITE, 
s-interrupt_callback, NULL);
+ret = ffurl_open(os-out, temp_path, AVIO_FLAG_WRITE, 
s-interrupt_callback, NULL);
 if (ret  0)
 break;
 write_styp(os-ctx-pb);
@@ -646,7 +642,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 } else {
 ffurl_close(os-out);
 os-out = NULL;
-ret = USE_RENAME_REPLACE ? ff_rename(temp_path, full_path) : 0;
+ret = ff_rename(temp_path, full_path);
 if (ret  0)
 break;
 }
diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 326f886..d96a3d5 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -163,7 +163,6 @@ static int write_manifest(AVFormatContext *s, int final)
 HDSContext *c = s-priv_data;
 AVIOContext *out;
 char filename[1024], temp_filename[1024];
-const char *write_filename;
 int ret, i;
 float duration = 0;
 
@@ -172,11 +171,10 @@ static int write_manifest(AVFormatContext *s, int final)
 
 snprintf(filename, sizeof(filename), %s/index.f4m, s-filename);
 snprintf(temp_filename, sizeof(temp_filename), %s/index.f4m.tmp, 
s-filename);
-write_filename = USE_RENAME_REPLACE ? temp_filename : filename;
-ret = avio_open2(out, write_filename, AVIO_FLAG_WRITE,
+ret = avio_open2(out, temp_filename, AVIO_FLAG_WRITE,
  s-interrupt_callback, NULL);
 if (ret  0) {
-av_log(s, AV_LOG_ERROR, Unable to open %s for writing\n, 
write_filename);
+av_log(s, AV_LOG_ERROR, Unable to open %s for writing\n, 
temp_filename);
 return ret;
 }
 avio_printf(out, ?xml version=\1.0\ encoding=\utf-8\?\n);
@@ -206,7 +204,7 @@ static int write_manifest(AVFormatContext *s, int final)
 avio_printf(out, /manifest\n);
 avio_flush(out);
 avio_close(out);
-return USE_RENAME_REPLACE ? ff_rename(temp_filename, filename) : 0;
+return ff_rename

[FFmpeg-cvslog] rtmpproto: Clarify a comment

2014-11-28 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov 24 
10:02:11 2014 +0200| [857e6667f9061ae261c0b951113e4efc4329b05e] | committer: 
Martin Storsjö

rtmpproto: Clarify a comment

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=857e6667f9061ae261c0b951113e4efc4329b05e
---

 libavformat/rtmpproto.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 9511946..824a100 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2968,7 +2968,6 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
 if (pkttype == RTMP_PT_VIDEO)
 channel = RTMP_VIDEO_CHANNEL;
 
-//force 12bytes header
 if (((pkttype == RTMP_PT_VIDEO || pkttype == RTMP_PT_AUDIO)  ts 
== 0) ||
 pkttype == RTMP_PT_NOTIFY) {
 if (pkttype == RTMP_PT_NOTIFY)
@@ -2977,6 +2976,9 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
  rt-nb_prev_pkt[1],
  channel))  0)
 return ret;
+// Force sending a full 12 bytes header by cleaing the
+// channel id, to make it not match a potential earlier
+// packet in the same channel.
 rt-prev_pkt[1][channel].channel_id = 0;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtmpproto: Simplify code for copying data into the output packet

2014-11-28 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov 24 
10:17:20 2014 +0200| [3c3b8003a13d9c3668c0bb6d79d2376da3b2b352] | committer: 
Martin Storsjö

rtmpproto: Simplify code for copying data into the output packet

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3c3b8003a13d9c3668c0bb6d79d2376da3b2b352
---

 libavformat/rtmpproto.c |   17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 824a100..bcd5644 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2933,7 +2933,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
 {
 RTMPContext *rt = s-priv_data;
 int size_temp = size;
-int pktsize, pkttype;
+int pktsize, pkttype, copy;
 uint32_t ts;
 const uint8_t *buf_temp = buf;
 uint8_t c;
@@ -2950,8 +2950,8 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
 
 if (rt-flv_header_bytes  RTMP_HEADER) {
 const uint8_t *header = rt-flv_header;
-int copy = FFMIN(RTMP_HEADER - rt-flv_header_bytes, size_temp);
 int channel = RTMP_AUDIO_CHANNEL;
+copy = FFMIN(RTMP_HEADER - rt-flv_header_bytes, size_temp);
 bytestream_get_buffer(buf_temp, rt-flv_header + 
rt-flv_header_bytes, copy);
 rt-flv_header_bytes += copy;
 size_temp-= copy;
@@ -2994,15 +2994,10 @@ static int rtmp_write(URLContext *s, const uint8_t 
*buf, int size)
 ff_amf_write_string(rt-flv_data, @setDataFrame);
 }
 
-if (rt-flv_size - rt-flv_off  size_temp) {
-bytestream_get_buffer(buf_temp, rt-flv_data + rt-flv_off, 
size_temp);
-rt-flv_off += size_temp;
-size_temp = 0;
-} else {
-bytestream_get_buffer(buf_temp, rt-flv_data + rt-flv_off, 
rt-flv_size - rt-flv_off);
-size_temp   -= rt-flv_size - rt-flv_off;
-rt-flv_off += rt-flv_size - rt-flv_off;
-}
+copy = FFMIN(rt-flv_size - rt-flv_off, size_temp);
+bytestream_get_buffer(buf_temp, rt-flv_data + rt-flv_off, copy);
+rt-flv_off += copy;
+size_temp   -= copy;
 
 if (rt-flv_off == rt-flv_size) {
 rt-skip_bytes = 4;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtmppkt: Make pkt-data reallocable

2014-11-28 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov 24 
10:41:34 2014 +0200| [44127b157e9f8acb837d4bb3a094f56b40da3ef5] | committer: 
Martin Storsjö

rtmppkt: Make pkt-data reallocable

We try to avoid mixing av_malloc with av_realloc, since av_malloc
may be implemented with functions that can't (formally) be mixed
with the functions used in av_realloc.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=44127b157e9f8acb837d4bb3a094f56b40da3ef5
---

 libavformat/rtmppkt.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 37fbb5f..e952091 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -395,7 +395,7 @@ int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, 
RTMPPacketType type,
   int timestamp, int size)
 {
 if (size) {
-pkt-data = av_malloc(size);
+pkt-data = av_realloc(NULL, size);
 if (!pkt-data)
 return AVERROR(ENOMEM);
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtmpproto: Only prepend @setDataFrame for onMetaData and |RtmpSampleAccess

2014-11-28 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov 24 
10:51:46 2014 +0200| [01eac895ab350027467ffbe7278740f89ae8be75] | committer: 
Martin Storsjö

rtmpproto: Only prepend @setDataFrame for onMetaData and |RtmpSampleAccess

Currently, when streaming to an RTMP server, any time a packet of type
RTMP_PT_NOTIFY is encountered, the packet is prepended with @setDataFrame
before it gets sent to the server. This is incorrect; only packets for
onMetaData and |RtmpSampleAccess should invoke @setDataFrame on the RTMP
server. Specifically, the current bug manifests itself when trying to
stream onTextData or onCuePoint invocations.

This fix addresses that problem and ensures that the @setDataFrame is
only prepended for onMetaData and |RtmpSampleAccess.

Since data is fed to the rtmp_write function in smaller pieces (depending
on the calling IO buffer size), we can't generally assume that the
whole packet (or even the whole command string) is available at once,
therefore we can only check the command string once the full packet
has been transferred to us for sending.

Based on a patch by Jeffrey Wescott.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=01eac895ab350027467ffbe7278740f89ae8be75
---

 libavformat/rtmpproto.c |   32 +++-
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index bcd5644..c23db06 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2970,8 +2970,6 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
 
 if (((pkttype == RTMP_PT_VIDEO || pkttype == RTMP_PT_AUDIO)  ts 
== 0) ||
 pkttype == RTMP_PT_NOTIFY) {
-if (pkttype == RTMP_PT_NOTIFY)
-pktsize += 16;
 if ((ret = ff_rtmp_check_alloc_array(rt-prev_pkt[1],
  rt-nb_prev_pkt[1],
  channel))  0)
@@ -2989,9 +2987,6 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
 
 rt-out_pkt.extra = rt-stream_id;
 rt-flv_data = rt-out_pkt.data;
-
-if (pkttype == RTMP_PT_NOTIFY)
-ff_amf_write_string(rt-flv_data, @setDataFrame);
 }
 
 copy = FFMIN(rt-flv_size - rt-flv_off, size_temp);
@@ -3002,6 +2997,33 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
 if (rt-flv_off == rt-flv_size) {
 rt-skip_bytes = 4;
 
+if (rt-out_pkt.type == RTMP_PT_NOTIFY) {
+// For onMetaData and |RtmpSampleAccess packets, we want
+// @setDataFrame prepended to the packet before it gets sent.
+// However, not all RTMP_PT_NOTIFY packets (e.g., onTextData
+// and onCuePoint).
+uint8_t commandbuffer[64];
+int stringlen = 0;
+GetByteContext gbc;
+
+bytestream2_init(gbc, rt-flv_data, rt-flv_size);
+if (!ff_amf_read_string(gbc, commandbuffer, 
sizeof(commandbuffer),
+stringlen)) {
+if (!strcmp(commandbuffer, onMetaData) ||
+!strcmp(commandbuffer, |RtmpSampleAccess)) {
+uint8_t *ptr;
+if ((ret = av_reallocp(rt-out_pkt.data, 
rt-out_pkt.size + 16))  0) {
+rt-flv_size = rt-flv_off = rt-flv_header_bytes 
= 0;
+return ret;
+}
+memmove(rt-out_pkt.data + 16, rt-out_pkt.data, 
rt-out_pkt.size);
+rt-out_pkt.size += 16;
+ptr = rt-out_pkt.data;
+ff_amf_write_string(ptr, @setDataFrame);
+}
+}
+}
+
 if ((ret = rtmp_send_packet(rt, rt-out_pkt, 0))  0)
 return ret;
 rt-flv_size = 0;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] dashenc: Avoid a VLA-like construct

2014-11-28 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Nov 28 
11:51:05 2014 +0200| [fcae9f212a6001d966c52dc22cd4b22e9851b428] | committer: 
Martin Storsjö

dashenc: Avoid a VLA-like construct

This fixes the build on compilers that interpreted the earlier
code as a variable length array (which we intentionally disallow).

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fcae9f212a6001d966c52dc22cd4b22e9851b428
---

 libavformat/dashenc.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9a8169e..b3b1ac1 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -308,8 +308,7 @@ static void dash_fill_tmpl_params(char *dst, size_t 
buffer_size,
 int dst_pos = 0;
 const char *t_cur = template;
 while (dst_pos  buffer_size - 1  *t_cur) {
-int format_tag_size = 7;
-char format_tag[format_tag_size]; // May be %d, %0Xd, or %0Xlld 
(for $Time$), where X is in [0-9]
+char format_tag[7]; // May be %d, %0Xd, or %0Xlld (for $Time$), 
where X is in [0-9]
 int n = 0;
 DASHTmplId id_type;
 const char *t_next = strchr(t_cur, '$'); // copy over everything up to 
the first '$' character
@@ -328,7 +327,7 @@ static void dash_fill_tmpl_params(char *dst, size_t 
buffer_size,
 break;
 
 // t_cur is now pointing to a '$' character
-id_type = dash_read_tmpl_id(t_cur, format_tag, format_tag_size, 
t_next);
+id_type = dash_read_tmpl_id(t_cur, format_tag, sizeof(format_tag), 
t_next);
 switch (id_type) {
 case DASH_TMPL_ID_ESCAPE:
 av_strlcpy(dst[dst_pos], $, 2);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtpproto: Write a warning if the input data written isn't RTP packetized

2014-12-08 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Dec  7 
01:42:06 2014 +0200| [29bc7bfba288ff8572ed967a8752a1dbde7b724b] | committer: 
Martin Storsjö

rtpproto: Write a warning if the input data written isn't RTP packetized

Tell the user that the RTP muxer needs to be used to packetize
the data - using the RTP protocol on its own isn't enough.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=29bc7bfba288ff8572ed967a8752a1dbde7b724b
---

 libavformat/rtpproto.c |4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index d5ecfc8..1171fc2 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -411,6 +411,10 @@ static int rtp_write(URLContext *h, const uint8_t *buf, 
int size)
 if (size  2)
 return AVERROR(EINVAL);
 
+if (buf[0] != (RTP_VERSION  6))
+av_log(h, AV_LOG_WARNING, Data doesn't look like RTP packets, 
+  make sure the RTP muxer is used\n);
+
 if (s-write_to_source) {
 int fd;
 struct sockaddr_storage *source, temp_source;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] arm: fft_vfp: Add a missing endconst when building in thumb mode

2014-12-08 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Nov 16 
12:38:53 2014 +0200| [ae81576414f2d2083d3118fb4abe1ebc5a7a4c54] | committer: 
Martin Storsjö

arm: fft_vfp: Add a missing endconst when building in thumb mode

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae81576414f2d2083d3118fb4abe1ebc5a7a4c54
---

 libavcodec/arm/fft_vfp.S |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/arm/fft_vfp.S b/libavcodec/arm/fft_vfp.S
index 130d529..91b833b 100644
--- a/libavcodec/arm/fft_vfp.S
+++ b/libavcodec/arm/fft_vfp.S
@@ -54,6 +54,7 @@ T const fft_tab_vfp
 .word   fft32768_vfp
 .word   fft65536_vfp
 A endfunc
+T endconst
 
 function fft4_vfp
 vldrd0, [a1, #0*2*4]   @ s0,s1   = z[0]

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] arm: fft_vfp: Unify the behaviour in ff_fft_calc_vfp between arm/thumb

2014-12-08 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Nov 16 
12:46:51 2014 +0200| [b280c6202b28b371a8d96850194fd69d7ad5dcc0] | committer: 
Martin Storsjö

arm: fft_vfp: Unify the behaviour in ff_fft_calc_vfp between arm/thumb

Don't include the function pointer table in the code segment
in arm mode.

This shouldn't have any significant performance effect. It does
end up as a few more instructions than before, for ARM, but
only at the entry to this function, not within the fft functions
themselves.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b280c6202b28b371a8d96850194fd69d7ad5dcc0
---

 libavcodec/arm/fft_vfp.S |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/libavcodec/arm/fft_vfp.S b/libavcodec/arm/fft_vfp.S
index 91b833b..9c7b54e 100644
--- a/libavcodec/arm/fft_vfp.S
+++ b/libavcodec/arm/fft_vfp.S
@@ -30,14 +30,10 @@
 function ff_fft_calc_vfp, export=1
 ldr ip, [a1, #0]@ nbits
 mov a1, a2
-A   ldr pc, [pc, ip, lsl #2]
-A   .word   0
-A   .word   0
-A   .word   0
-T   movrel  a2, (fft_tab_vfp - 8)
-T   ldr pc, [a2, ip, lsl #2]
-T endfunc
-T const fft_tab_vfp
+movrel  a2, (fft_tab_vfp - 8)
+ldr pc, [a2, ip, lsl #2]
+endfunc
+const fft_tab_vfp
 .word   fft4_vfp
 .word   fft8_vfp
 .word   X(ff_fft16_vfp) @ this one alone is exported
@@ -53,8 +49,7 @@ T const fft_tab_vfp
 .word   fft16384_vfp
 .word   fft32768_vfp
 .word   fft65536_vfp
-A endfunc
-T endconst
+endconst
 
 function fft4_vfp
 vldrd0, [a1, #0*2*4]   @ s0,s1   = z[0]

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] arm: Use .data.rel.ro for const data with relocations

2014-12-09 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Nov 16 
12:51:54 2014 +0200| [f963f80399deb1a2b44c1bac3af7123e8a0c9e46] | committer: 
Martin Storsjö

arm: Use .data.rel.ro for const data with relocations

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f963f80399deb1a2b44c1bac3af7123e8a0c9e46
---

 configure   |3 +++
 libavcodec/arm/fft_fixed_neon.S |2 +-
 libavcodec/arm/fft_neon.S   |2 +-
 libavcodec/arm/fft_vfp.S|2 +-
 libavutil/arm/asm.S |6 +-
 5 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 9ac4a8e..ed8316f 100755
--- a/configure
+++ b/configure
@@ -1543,6 +1543,7 @@ HAVE_LIST=
 libdc1394_1
 libdc1394_2
 sdl
+section_data_rel_ro
 threads
 vdpau_x11
 xlib
@@ -3415,6 +3416,7 @@ case $target_os in
 ;;
 android)
 disable symver
+enable section_data_rel_ro
 SLIB_INSTALL_NAME='$(SLIBNAME)'
 SLIB_INSTALL_LINKS=
 # soname not set on purpose
@@ -3549,6 +3551,7 @@ case $target_os in
 ;;
 linux)
 enable dv1394
+enable section_data_rel_ro
 ;;
 irix*)
 target_os=irix
diff --git a/libavcodec/arm/fft_fixed_neon.S b/libavcodec/arm/fft_fixed_neon.S
index faddc00..c70a189 100644
--- a/libavcodec/arm/fft_fixed_neon.S
+++ b/libavcodec/arm/fft_fixed_neon.S
@@ -242,7 +242,7 @@ function ff_fft_fixed_calc_neon, export=1
 bx  r3
 endfunc
 
-const   fft_fixed_tab_neon
+const   fft_fixed_tab_neon, relocate=1
 .word fft4_neon
 .word fft8_neon
 .word fft16_neon
diff --git a/libavcodec/arm/fft_neon.S b/libavcodec/arm/fft_neon.S
index c4d8918..b161015 100644
--- a/libavcodec/arm/fft_neon.S
+++ b/libavcodec/arm/fft_neon.S
@@ -348,7 +348,7 @@ function ff_fft_permute_neon, export=1
 pop {r4,pc}
 endfunc
 
-const   fft_tab_neon
+const   fft_tab_neon, relocate=1
 .word fft4_neon
 .word fft8_neon
 .word fft16_neon
diff --git a/libavcodec/arm/fft_vfp.S b/libavcodec/arm/fft_vfp.S
index 9c7b54e..c2801fa 100644
--- a/libavcodec/arm/fft_vfp.S
+++ b/libavcodec/arm/fft_vfp.S
@@ -33,7 +33,7 @@ function ff_fft_calc_vfp, export=1
 movrel  a2, (fft_tab_vfp - 8)
 ldr pc, [a2, ip, lsl #2]
 endfunc
-const fft_tab_vfp
+const   fft_tab_vfp, relocate=1
 .word   fft4_vfp
 .word   fft8_vfp
 .word   X(ff_fft16_vfp) @ this one alone is exported
diff --git a/libavutil/arm/asm.S b/libavutil/arm/asm.S
index 93d74b6..8479304 100644
--- a/libavutil/arm/asm.S
+++ b/libavutil/arm/asm.S
@@ -89,12 +89,16 @@ FUNC.func   \name
 .endif
 .endm
 
-.macro  const   name, align=2
+.macro  const   name, align=2, relocate=0
 .macro endconst
 ELF .size   \name, . - \name
 .purgem endconst
 .endm
+.if HAVE_SECTION_DATA_REL_RO  \relocate
+.section.data.rel.ro
+.else
 .section.rodata
+.endif
 .align  \align
 \name:
 .endm

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] aarch64: Use .data.rel.ro for const data with relocations

2014-12-09 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Nov 16 
12:52:21 2014 +0200| [780cd20b00a69e26bbfffbb8eec16fbe999ea793] | committer: 
Martin Storsjö

aarch64: Use .data.rel.ro for const data with relocations

This reverts commit c00365b46d464ce47716315c1801818d811bdb9a
in addition to using a different section.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=780cd20b00a69e26bbfffbb8eec16fbe999ea793
---

 libavcodec/aarch64/fft_neon.S|   35 +-
 libavcodec/aarch64/opus_imdct_neon.S |   20 +--
 libavutil/aarch64/asm.S  |   10 --
 3 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/libavcodec/aarch64/fft_neon.S b/libavcodec/aarch64/fft_neon.S
index ae9e1c6..e205e23 100644
--- a/libavcodec/aarch64/fft_neon.S
+++ b/libavcodec/aarch64/fft_neon.S
@@ -376,8 +376,7 @@ function ff_fft_calc_neon, export=1
 ld1 {v30.16b}, [x10]
 mov x7,  #-8
 movrel  x12, pmmp
-ldr x4,  [x3, x2, lsl #3]
-add x3,  x3,  x4
+ldr x3,  [x3, x2, lsl #3]
 movrel  x13, mppm
 movrel  x14, X(ff_cos_16)
 ld1 {v31.16b}, [x11]
@@ -416,22 +415,22 @@ function ff_fft_permute_neon, export=1
 ret
 endfunc
 
-const   fft_tab_neon
-.quad fft4_neon - fft_tab_neon
-.quad fft8_neon - fft_tab_neon
-.quad fft16_neon- fft_tab_neon
-.quad fft32_neon- fft_tab_neon
-.quad fft64_neon- fft_tab_neon
-.quad fft128_neon   - fft_tab_neon
-.quad fft256_neon   - fft_tab_neon
-.quad fft512_neon   - fft_tab_neon
-.quad fft1024_neon  - fft_tab_neon
-.quad fft2048_neon  - fft_tab_neon
-.quad fft4096_neon  - fft_tab_neon
-.quad fft8192_neon  - fft_tab_neon
-.quad fft16384_neon - fft_tab_neon
-.quad fft32768_neon - fft_tab_neon
-.quad fft65536_neon - fft_tab_neon
+const   fft_tab_neon, relocate=1
+.quad fft4_neon
+.quad fft8_neon
+.quad fft16_neon
+.quad fft32_neon
+.quad fft64_neon
+.quad fft128_neon
+.quad fft256_neon
+.quad fft512_neon
+.quad fft1024_neon
+.quad fft2048_neon
+.quad fft4096_neon
+.quad fft8192_neon
+.quad fft16384_neon
+.quad fft32768_neon
+.quad fft65536_neon
 endconst
 
 const   pmmp, align=4
diff --git a/libavcodec/aarch64/opus_imdct_neon.S 
b/libavcodec/aarch64/opus_imdct_neon.S
index c98931c..d99edf4 100644
--- a/libavcodec/aarch64/opus_imdct_neon.S
+++ b/libavcodec/aarch64/opus_imdct_neon.S
@@ -438,8 +438,8 @@ function fft_b15_calc_neon
 uzp1v12.4s, v4.4s,  v5.4s   // exp[11 - 14].re
 uzp2v13.4s, v4.4s,  v5.4s   // exp[11 - 14].im
 zip1v14.4s, v6.4s,  v7.4s   // exp[5,10].re/exp[5,10].im
-ldr x6,  [x5, x3, lsl #3]
-add x5,  x5,  x6
+add x5,  x5,  x3,  lsl #3
+ldr x5,  [x5]
 mov x10, x0
 blr x5
 ldp x20, x30, [sp]
@@ -451,14 +451,14 @@ function fft_b15_calc_neon
 ret
 endfunc
 
-const   fft_tab_neon
-.quad fft15_neon  - fft_tab_neon
-.quad fft30_neon  - fft_tab_neon
-.quad fft60_neon  - fft_tab_neon
-.quad fft120_neon - fft_tab_neon
-.quad fft240_neon - fft_tab_neon
-.quad fft480_neon - fft_tab_neon
-.quad fft960_neon - fft_tab_neon
+const   fft_tab_neon, relocate=1
+.quad fft15_neon
+.quad fft30_neon
+.quad fft60_neon
+.quad fft120_neon
+.quad fft240_neon
+.quad fft480_neon
+.quad fft960_neon
 endconst
 
 function ff_celt_imdct_half_neon, export=1
diff --git a/libavutil/aarch64/asm.S b/libavutil/aarch64/asm.S
index b766e67..6a7f506 100644
--- a/libavutil/aarch64/asm.S
+++ b/libavutil/aarch64/asm.S
@@ -52,12 +52,18 @@ FUNC.func   \name
 .endif
 .endm
 
-.macro  const   name, align=2
+.macro  const   name, align=2, relocate=0
 .macro endconst
 ELF .size   \name, . - \name
 .purgem endconst
 .endm
-#ifndef __MACH__
+#if HAVE_SECTION_DATA_REL_RO
+.if \relocate
+.section.data.rel.ro
+.else
+.section.rodata
+.endif
+#elif !defined(__MACH__)
 .section.rodata
 #else
 .const_data

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtpproto: Fix the input RTP data format check

2014-12-09 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Tue Dec  9 
16:05:14 2014 +0200| [95d880fa6436f3b557a9c060428a04b9e4d552df] | committer: 
Martin Storsjö

rtpproto: Fix the input RTP data format check

Only the upper 2 bits of the first byte are known to be
a fixed value.

The lower bits in the first byte of a RTP packet could be set
if the input is from another RTP packetizers than libavformat's,
but for RTCP packets, they would also be set when sending RTCP RR
packets, triggering false warnings about incorrect input format
to the protocol.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=95d880fa6436f3b557a9c060428a04b9e4d552df
---

 libavformat/rtpproto.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index 1171fc2..5bff00e 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -411,7 +411,7 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int 
size)
 if (size  2)
 return AVERROR(EINVAL);
 
-if (buf[0] != (RTP_VERSION  6))
+if ((buf[0]  0xc0) != (RTP_VERSION  6))
 av_log(h, AV_LOG_WARNING, Data doesn't look like RTP packets, 
   make sure the RTP muxer is used\n);
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] dashenc: Change the duration fields to 64 bit

2014-12-10 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Dec 10 
08:08:59 2014 +0200| [e737a4aaafcb1d761b7f96043c2f83ce742c64ae] | committer: 
Martin Storsjö

dashenc: Change the duration fields to 64 bit

For the last_duration field, it's mostly theoretical, but the
total_duration field more probably may need to actually be 64 bit.

Bug-Id: CID 1254944
Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e737a4aaafcb1d761b7f96043c2f83ce742c64ae
---

 libavformat/dashenc.c |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 07dd673..3308c05 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -86,8 +86,8 @@ typedef struct DASHContext {
 int single_file;
 OutputStream *streams;
 int has_video, has_audio;
-int last_duration;
-int total_duration;
+int64_t last_duration;
+int64_t total_duration;
 char availability_start_time[100];
 char dirname[1024];
 const char *single_file_name;
@@ -205,7 +205,7 @@ static void output_segment_list(OutputStream *os, 
AVIOContext *out, DASHContext
 int timescale = c-use_timeline ? os-ctx-streams[0]-time_base.den : 
AV_TIME_BASE;
 avio_printf(out, \t\t\t\tSegmentTemplate timescale=\%d\ , 
timescale);
 if (!c-use_timeline)
-avio_printf(out, duration=\%d\ , c-last_duration);
+avio_printf(out, duration=\%PRId64\ , c-last_duration);
 avio_printf(out, initialization=\%s\ media=\%s\ 
startNumber=\%d\\n, c-init_seg_name, c-media_seg_name, c-use_timeline ? 
start_number : 1);
 if (c-use_timeline) {
 avio_printf(out, \t\t\t\t\tSegmentTimeline\n);
@@ -228,7 +228,7 @@ static void output_segment_list(OutputStream *os, 
AVIOContext *out, DASHContext
 avio_printf(out, \t\t\t\t/SegmentTemplate\n);
 } else if (c-single_file) {
 avio_printf(out, \t\t\t\tBaseURL%s/BaseURL\n, os-initfile);
-avio_printf(out, \t\t\t\tSegmentList timescale=\%d\ 
duration=\%d\ startNumber=\%d\\n, AV_TIME_BASE, c-last_duration, 
start_number);
+avio_printf(out, \t\t\t\tSegmentList timescale=\%d\ 
duration=\%PRId64\ startNumber=\%d\\n, AV_TIME_BASE, c-last_duration, 
start_number);
 avio_printf(out, \t\t\t\t\tInitialization 
range=\%PRId64-%PRId64\ /\n, os-init_start_pos, os-init_start_pos + 
os-init_range_length - 1);
 for (i = start_index; i  os-nb_segments; i++) {
 Segment *seg = os-segments[i];
@@ -239,7 +239,7 @@ static void output_segment_list(OutputStream *os, 
AVIOContext *out, DASHContext
 }
 avio_printf(out, \t\t\t\t/SegmentList\n);
 } else {
-avio_printf(out, \t\t\t\tSegmentList timescale=\%d\ 
duration=\%d\ startNumber=\%d\\n, AV_TIME_BASE, c-last_duration, 
start_number);
+avio_printf(out, \t\t\t\tSegmentList timescale=\%d\ 
duration=\%PRId64\ startNumber=\%d\\n, AV_TIME_BASE, c-last_duration, 
start_number);
 avio_printf(out, \t\t\t\t\tInitialization sourceURL=\%s\ /\n, 
os-initfile);
 for (i = start_index; i  os-nb_segments; i++) {
 Segment *seg = os-segments[i];
@@ -444,11 +444,11 @@ static int write_manifest(AVFormatContext *s, int final)
 write_time(out, c-total_duration);
 avio_printf(out, \\n);
 } else {
-int update_period = c-last_duration / AV_TIME_BASE;
+int64_t update_period = c-last_duration / AV_TIME_BASE;
 if (c-use_template  !c-use_timeline)
 update_period = 500;
-avio_printf(out, \tminimumUpdatePeriod=\PT%dS\\n, update_period);
-avio_printf(out, \tsuggestedPresentationDelay=\PT%dS\\n, 
c-last_duration / AV_TIME_BASE);
+avio_printf(out, \tminimumUpdatePeriod=\PT%PRId64S\\n, 
update_period);
+avio_printf(out, \tsuggestedPresentationDelay=\PT%PRId64S\\n, 
c-last_duration / AV_TIME_BASE);
 if (!c-availability_start_time[0]  s-nb_streams  0  
c-streams[0].nb_segments  0) {
 time_t t = time(NULL);
 struct tm *ptm, tmbuf;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] mov: Fix handling of zero-length metadata values

2014-12-15 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Dec 15 
12:09:10 2014 +0200| [6f4364aba9d70dc5fd9f1c88b9c03bf9ea893d40] | committer: 
Martin Storsjö

mov: Fix handling of zero-length metadata values

Since 3cec81f4d4, a zero-length metadata value would try to
allocate 2*0 bytes, where av_malloc() returns NULL.

Always add one to the allocated length, to allow space for
a null terminator in the zero-length case.

Incidentally, this fixes fate-alac on RVCT 4.0, where a compiler
bug seems to mess up the mov muxer to the point that it writes
the wrong sort of metadata. Previously this bug was undetected,
but since 3cec81f4d4 such mov files started returning
AVERROR(ENOMEM) in the mov demuxer.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6f4364aba9d70dc5fd9f1c88b9c03bf9ea893d40
---

 libavformat/mov.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a64ff4f..4590a2d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -383,7 +383,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return AVERROR_INVALIDDATA;
 
 // allocate twice as much as worst-case
-str_size_alloc = raw ? str_size + 1 : str_size * 2;
+str_size_alloc = (raw ? str_size : str_size * 2) + 1;
 str = av_malloc(str_size_alloc);
 if (!str)
 return AVERROR(ENOMEM);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] dashenc: Write segment timelines properly if the timeline has gaps

2014-12-17 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Nov 28 
10:40:05 2014 +0200| [2f628d5943c12389c07d652d23d3916997f9f0f6] | committer: 
Martin Storsjö

dashenc: Write segment timelines properly if the timeline has gaps

Write a new start time if the duration of the previous segment
didn't match the start of the next one. Check that segments
actually are continuous before writing a repeat count.

This makes sure timestamps deduced from the timeline actually
match the real start timestamp as written in filenames (if
using a template containing $Time$).

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f628d5943c12389c07d652d23d3916997f9f0f6
---

 libavformat/dashenc.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 3308c05..a55cd67 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -208,20 +208,24 @@ static void output_segment_list(OutputStream *os, 
AVIOContext *out, DASHContext
 avio_printf(out, duration=\%PRId64\ , c-last_duration);
 avio_printf(out, initialization=\%s\ media=\%s\ 
startNumber=\%d\\n, c-init_seg_name, c-media_seg_name, c-use_timeline ? 
start_number : 1);
 if (c-use_timeline) {
+int64_t cur_time = 0;
 avio_printf(out, \t\t\t\t\tSegmentTimeline\n);
 for (i = start_index; i  os-nb_segments; ) {
 Segment *seg = os-segments[i];
 int repeat = 0;
 avio_printf(out, \t\t\t\t\t\tS );
-if (i == start_index)
+if (i == start_index || seg-time != cur_time)
 avio_printf(out, t=\%PRId64\ , seg-time);
 avio_printf(out, d=\%d\ , seg-duration);
-while (i + repeat + 1  os-nb_segments  os-segments[i + 
repeat + 1]-duration == seg-duration)
+while (i + repeat + 1  os-nb_segments 
+   os-segments[i + repeat + 1]-duration == seg-duration 

+   os-segments[i + repeat + 1]-time == os-segments[i + 
repeat]-time + os-segments[i + repeat]-duration)
 repeat++;
 if (repeat  0)
 avio_printf(out, r=\%d\ , repeat);
 avio_printf(out, /\n);
 i += 1 + repeat;
+cur_time += (1 + repeat) * seg-duration;
 }
 avio_printf(out, \t\t\t\t\t/SegmentTimeline\n);
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] dashenc: Adjust the start time of a segment to the end of the previous segment

2014-12-17 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Nov 28 
10:43:53 2014 +0200| [456e93bfdd4cbc5e995dea415019abd0703d0e16] | committer: 
Martin Storsjö

dashenc: Adjust the start time of a segment to the end of the previous segment

This is the same adjustment that the mp4 muxer does to the start
timestamp of fragments, since the timestamp of a sample in an mp4
file is implicit from the sum of earlier sample durations.

This avoids gaps in the timeline (which can stop dash.js from
playing it back), and makes sure the timestamp on the segmenter
level matches what the mp4 muxer actually writes into the segments.

This is only an issue if the AVPacket duration of the last
packet of a segment doesn't point to the actual start timestamp
of the next packet (the first in the next segment).

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=456e93bfdd4cbc5e995dea415019abd0703d0e16
---

 libavformat/dashenc.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index a55cd67..b4fd194 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -652,6 +652,7 @@ static int dash_write_header(AVFormatContext *s)
 
 set_codec_str(s, os-ctx-streams[0]-codec, os-codec_str, 
sizeof(os-codec_str));
 os-first_dts = AV_NOPTS_VALUE;
+os-end_dts = AV_NOPTS_VALUE;
 os-segment_index = 1;
 }
 
@@ -861,8 +862,15 @@ static int dash_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 return ret;
 }
 
-if (!os-packets_written)
-os-start_dts = pkt-dts;
+if (!os-packets_written) {
+// If we wrote a previous segment, adjust the start time of the segment
+// to the end of the previous one (which is the same as the mp4 muxer
+// does). This avoids gaps in the timeline.
+if (os-end_dts != AV_NOPTS_VALUE)
+os-start_dts = os-end_dts;
+else
+os-start_dts = pkt-dts;
+}
 os-end_dts = pkt-dts + pkt-duration;
 os-packets_written++;
 return ff_write_chained(os-ctx, 0, pkt, s);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtpenc: Set the AVFMT_TS_NONSTRICT flag

2014-12-18 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Dec 12 
18:57:38 2014 +0200| [42181740a3972e17d0097d28fabc9a1a60322d47] | committer: 
Martin Storsjö

rtpenc: Set the AVFMT_TS_NONSTRICT flag

In particular, when packetizing mpegts into rtp, the input packet
timestamp may come from more than one stream, which could cause
multiple packets be written with the same timestamp.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=42181740a3972e17d0097d28fabc9a1a60322d47
---

 libavformat/rtpenc.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 6262d55..dafe3a0 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -632,4 +632,5 @@ AVOutputFormat ff_rtp_muxer = {
 .write_packet  = rtp_write_packet,
 .write_trailer = rtp_write_trailer,
 .priv_class= rtp_muxer_class,
+.flags = AVFMT_TS_NONSTRICT,
 };

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtpdec_h263_rfc2190: Clear the stored bits if discarding buffered data

2014-12-18 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Dec 17 
13:50:06 2014 +0200| [df07c07b3de0a5e8890078944de1eb5cb8372ef8] | committer: 
Martin Storsjö

rtpdec_h263_rfc2190: Clear the stored bits if discarding buffered data

If we throw away the buffered incomplete frame, make sure to also
throw away the buffered bits of an incomplete byte at the same
time.

CC: libav-sta...@libav.org
Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=df07c07b3de0a5e8890078944de1eb5cb8372ef8
---

 libavformat/rtpdec_h263_rfc2190.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/rtpdec_h263_rfc2190.c 
b/libavformat/rtpdec_h263_rfc2190.c
index 116db75..d507ef7 100644
--- a/libavformat/rtpdec_h263_rfc2190.c
+++ b/libavformat/rtpdec_h263_rfc2190.c
@@ -83,6 +83,7 @@ static int h263_handle_packet(AVFormatContext *ctx, 
PayloadContext *data,
 avio_close_dyn_buf(data-buf, p);
 av_free(p);
 data-buf = NULL;
+data-endbyte_bits = 0;
 }
 
 if (len  4) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] h261enc: Disallow sliced encoding

2014-12-18 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Wed Dec 17 
12:18:03 2014 +0200| [91bfac759dfd536e439ad3e35964705012c6a5a7] | committer: 
Martin Storsjö

h261enc: Disallow sliced encoding

This avoids trying to do sliced encoding, even if a slice/packet
size is requested (via the -ps option or the rtp_payload_size
field), since the encoder currently doesn't support it (or at least
our decoder can't decode it, even if the h261_encode_gob_header
function is hooked up to be called from the slicing part in
mpegvideo_enc.c).

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=91bfac759dfd536e439ad3e35964705012c6a5a7
---

 libavcodec/mpegvideo_enc.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 8775eac..8abbcf5 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -590,6 +590,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 s-out_format = FMT_H261;
 avctx-delay  = 0;
 s-low_delay  = 1;
+s-rtp_mode   = 0; /* Sliced encoding not supported */
 break;
 case AV_CODEC_ID_H263:
 if (!CONFIG_H263_ENCODER)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtpenc: Avoid brittle switch fallthroughs

2014-12-18 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Thu Dec 18 
12:20:11 2014 +0200| [adc214e6797750285a5e62634b8521db521162ad] | committer: 
Martin Storsjö

rtpenc: Avoid brittle switch fallthroughs

Instead explicitly jump to the default case in the cases where
it is wanted, and avoid fallthrough between different codecs,
which could easily introduce bugs if people editing the code
aren't careful.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=adc214e6797750285a5e62634b8521db521162ad
---

 libavformat/rtpenc.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index dafe3a0..e5dc805 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -255,8 +255,11 @@ static int rtp_write_header(AVFormatContext *s1)
 av_log(s1, AV_LOG_ERROR, Only mono is supported\n);
 goto fail;
 }
+s-num_frames = 0;
+goto defaultcase;
 case AV_CODEC_ID_AAC:
 s-num_frames = 0;
+goto defaultcase;
 default:
 defaultcase:
 if (st-codec-codec_type == AVMEDIA_TYPE_AUDIO) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavformat: Add a muxer wrapping mpegts encoding into RTP

2014-12-18 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon May  9 
16:44:54 2011 +0300| [8a70ef94b9c377293b3dfa7d92cdc81a4fe1543a] | committer: 
Martin Storsjö

libavformat: Add a muxer wrapping mpegts encoding into RTP

Since this structurally is quite different from normal RTP
(multiple streams are muxed into one single mpegts stream,
which is packetized into one single RTP session), it is kept
as a separate muxer.

Since this structurally also behaves differently than normal
RTP, all of the other muxers that do chained RTP muxing
(rtsp, sap, mp4) would need to be updated similarly to handle
this - in particular, creating one single rtp_mpegts muxer
for the whole presentation instead of one rtp muxer per stream.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a70ef94b9c377293b3dfa7d92cdc81a4fe1543a
---

 Changelog   |1 +
 libavformat/Makefile|1 +
 libavformat/allformats.c|1 +
 libavformat/rtpenc_mpegts.c |  165 +++
 libavformat/version.h   |2 +-
 5 files changed, 169 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 85fb678..2d367a5 100644
--- a/Changelog
+++ b/Changelog
@@ -8,6 +8,7 @@ version next:
 - XCB-based screen-grabber
 - creating DASH compatible fragmented MP4, MPEG-DASH segmenting muxer
 - H.261 RTP payload format (RFC 4587) depacketizer and experimental packetizer
+- RTP/mpegts muxer
 
 
 version 11:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index affb95a..1c5b04a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -287,6 +287,7 @@ OBJS-$(CONFIG_ROQ_MUXER) += idroqenc.o 
rawenc.o
 OBJS-$(CONFIG_RSO_DEMUXER)   += rsodec.o rso.o pcm.o
 OBJS-$(CONFIG_RSO_MUXER) += rsoenc.o rso.o
 OBJS-$(CONFIG_RPL_DEMUXER)   += rpl.o
+OBJS-$(CONFIG_RTP_MPEGTS_MUXER)  += rtpenc_mpegts.o
 OBJS-$(CONFIG_RTP_MUXER) += rtp.o \
 rtpenc_aac.o \
 rtpenc_latm.o\
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 7868e3e..cb22ae3 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -212,6 +212,7 @@ void av_register_all(void)
 REGISTER_DEMUXER (RPL,  rpl);
 REGISTER_MUXDEMUX(RSO,  rso);
 REGISTER_MUXDEMUX(RTP,  rtp);
+REGISTER_MUXER   (RTP_MPEGTS,   rtp_mpegts);
 REGISTER_MUXDEMUX(RTSP, rtsp);
 REGISTER_MUXDEMUX(SAP,  sap);
 REGISTER_DEMUXER (SDP,  sdp);
diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c
new file mode 100644
index 000..4e243f0
--- /dev/null
+++ b/libavformat/rtpenc_mpegts.c
@@ -0,0 +1,165 @@
+/*
+ * RTP/mpegts muxer
+ * Copyright (c) 2011 Martin Storsjo
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include libavutil/mathematics.h
+#include avformat.h
+
+struct MuxChain {
+AVFormatContext *mpegts_ctx;
+AVFormatContext *rtp_ctx;
+};
+
+static int rtp_mpegts_write_close(AVFormatContext *s)
+{
+struct MuxChain *chain = s-priv_data;
+
+if (chain-mpegts_ctx) {
+if (!chain-mpegts_ctx-pb)
+avio_open_dyn_buf(chain-mpegts_ctx-pb);
+if (chain-mpegts_ctx-pb) {
+uint8_t *buf;
+av_write_trailer(chain-mpegts_ctx);
+avio_close_dyn_buf(chain-mpegts_ctx-pb, buf);
+av_free(buf);
+}
+avformat_free_context(chain-mpegts_ctx);
+}
+if (chain-rtp_ctx) {
+av_write_trailer(chain-rtp_ctx);
+avformat_free_context(chain-rtp_ctx);
+}
+return 0;
+}
+
+static int rtp_mpegts_write_header(AVFormatContext *s)
+{
+struct MuxChain *chain = s-priv_data;
+AVFormatContext *mpegts_ctx = NULL, *rtp_ctx = NULL;
+AVOutputFormat *mpegts_format = av_guess_format(mpegts, NULL, NULL);
+AVOutputFormat *rtp_format= av_guess_format(rtp, NULL, NULL);
+int i, ret = AVERROR(ENOMEM);
+AVStream *st;
+
+if (!mpegts_format || !rtp_format)
+return AVERROR(ENOSYS);
+mpegts_ctx = avformat_alloc_context

[FFmpeg-cvslog] movenc: Adjust the pts of new fragments similarly to what is done for dts

2014-12-18 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Sun Nov 23 
23:23:43 2014 +0200| [59f0275dd0a42a7f90271a83a78e9ca5e69ff5b0] | committer: 
Martin Storsjö

movenc: Adjust the pts of new fragments similarly to what is done for dts

The pts and the corresponding duration is written in sidx
atoms, thus make sure these match up correctly.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=59f0275dd0a42a7f90271a83a78e9ca5e69ff5b0
---

 libavformat/movenc.c |9 +
 libavformat/movenc.h |1 +
 2 files changed, 10 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index f6109e6..a809c36 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3290,6 +3290,11 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  * which might not exactly match our dts. Therefore adjust the dts
  * of this packet to be what the previous packets duration 
implies. */
 trk-cluster[trk-entry].dts = trk-start_dts + 
trk-track_duration;
+/* We also may have written the pts and the corresponding duration
+ * in sidx tags; make sure the sidx pts and duration match up with
+ * the next fragment. This means the cts of the first sample must
+ * be the same in all fragments. */
+pkt-pts = pkt-dts + trk-start_cts;
 } else {
 /* New fragment, but discontinuous from previous fragments.
  * Pretend the duration sum of the earlier fragments is
@@ -3331,6 +3336,9 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
 trk-flags |= MOV_TRACK_CTTS;
 trk-cluster[trk-entry].cts   = pkt-pts - pkt-dts;
 trk-cluster[trk-entry].flags = 0;
+if (trk-start_cts == AV_NOPTS_VALUE)
+trk-start_cts = pkt-pts - pkt-dts;
+
 if (enc-codec_id == AV_CODEC_ID_VC1) {
 mov_parse_vc1_frame(pkt, trk, mov-fragments);
 } else if (pkt-flags  AV_PKT_FLAG_KEY) {
@@ -3708,6 +3716,7 @@ static int mov_write_header(AVFormatContext *s)
  * this is updated. */
 track-hint_track = -1;
 track-start_dts  = AV_NOPTS_VALUE;
+track-start_cts  = AV_NOPTS_VALUE;
 if (st-codec-codec_type == AVMEDIA_TYPE_VIDEO) {
 if (track-tag == MKTAG('m','x','3','p') || track-tag == 
MKTAG('m','x','3','n') ||
 track-tag == MKTAG('m','x','4','p') || track-tag == 
MKTAG('m','x','4','n') ||
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index c13a834..97c0583 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -104,6 +104,7 @@ typedef struct MOVTrack {
 uint32_ttref_tag;
 int tref_id; /// trackID of the referenced track
 int64_t start_dts;
+int64_t start_cts;
 
 int hint_track;   /// the track that hints this track, -1 if no 
hint track is set
 int src_track;/// the track that this hint track describes

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavformat: Allow calling av_write_trailer with a NULL AVIOContext

2014-12-19 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Dec 19 
15:40:02 2014 +0200| [4895aa65c6ddec2e33ec3c023f221b1bafcbaf9f] | committer: 
Martin Storsjö

libavformat: Allow calling av_write_trailer with a NULL AVIOContext

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4895aa65c6ddec2e33ec3c023f221b1bafcbaf9f
---

 libavformat/mux.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 9aee224..2a28fd6 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -624,7 +624,7 @@ int av_write_trailer(AVFormatContext *s)
 if (s-oformat-write_trailer)
 ret = s-oformat-write_trailer(s);
 
-if (!(s-oformat-flags  AVFMT_NOFILE))
+if (!(s-oformat-flags  AVFMT_NOFILE)  s-pb)
 avio_flush(s-pb);
 
 fail:

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavformat: Allow calling av_write_trailer with a NULL AVIOContext

2014-12-19 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Dec 19 
15:40:02 2014 +0200| [4895aa65c6ddec2e33ec3c023f221b1bafcbaf9f] | committer: 
Martin Storsjö

libavformat: Allow calling av_write_trailer with a NULL AVIOContext

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4895aa65c6ddec2e33ec3c023f221b1bafcbaf9f
---

 libavformat/mux.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 9aee224..2a28fd6 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -624,7 +624,7 @@ int av_write_trailer(AVFormatContext *s)
 if (s-oformat-write_trailer)
 ret = s-oformat-write_trailer(s);
 
-if (!(s-oformat-flags  AVFMT_NOFILE))
+if (!(s-oformat-flags  AVFMT_NOFILE)  s-pb)
 avio_flush(s-pb);
 
 fail:

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] mpegts: Support running the write_trailer function without an AVIOContext

2014-12-19 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Dec 19 
15:23:06 2014 +0200| [e2ce16392205d8efe9143329ed3fb5fcb15498fa] | committer: 
Martin Storsjö

mpegts: Support running the write_trailer function without an AVIOContext

If opening and closing dynamic buffers as AVIOContext, we may
not have any AVIOContext available when wanting to close and
deallocate the muxer. Allow calling write_trailer despite this.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e2ce16392205d8efe9143329ed3fb5fcb15498fa
---

 libavformat/mpegtsenc.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 8fa1c3e..1be4e55 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1192,7 +1192,8 @@ static int mpegts_write_end(AVFormatContext *s)
 MpegTSService *service;
 int i;
 
-mpegts_write_flush(s);
+if (s-pb)
+mpegts_write_flush(s);
 
 for (i = 0; i  s-nb_streams; i++) {
 AVStream *st = s-streams[i];

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] rtpenc_mpegts: Call write_trailer for the mpegts muxer even if no output buffer exists

2014-12-19 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Dec 19 
15:26:23 2014 +0200| [fc308b30bb24e623fed042ec78b10803b2362a18] | committer: 
Martin Storsjö

rtpenc_mpegts: Call write_trailer for the mpegts muxer even if no output buffer 
exists

Since the mpegts muxer now can handle being called with a NULL
AVIOContext, we don't need to try to allocate one before calling
write_trailer.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fc308b30bb24e623fed042ec78b10803b2362a18
---

 libavformat/rtpenc_mpegts.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c
index 4e243f0..f170f97 100644
--- a/libavformat/rtpenc_mpegts.c
+++ b/libavformat/rtpenc_mpegts.c
@@ -32,11 +32,9 @@ static int rtp_mpegts_write_close(AVFormatContext *s)
 struct MuxChain *chain = s-priv_data;
 
 if (chain-mpegts_ctx) {
-if (!chain-mpegts_ctx-pb)
-avio_open_dyn_buf(chain-mpegts_ctx-pb);
+av_write_trailer(chain-mpegts_ctx);
 if (chain-mpegts_ctx-pb) {
 uint8_t *buf;
-av_write_trailer(chain-mpegts_ctx);
 avio_close_dyn_buf(chain-mpegts_ctx-pb, buf);
 av_free(buf);
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavformat: Only use MoveFileExA when targeting the desktop API subset

2014-12-19 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Dec 15 
23:55:30 2014 +0200| [8ebf02f8f530240edf7e45f35f7647ef9dd44a58] | committer: 
Martin Storsjö

libavformat: Only use MoveFileExA when targeting the desktop API subset

The MoveFileExA is available in the headers regardless which API
subset is targeted, but it is missing in the Windows Phone link
libraries. When targeting Windows Store apps, the function is
available both in the headers and in the link libraries, and thus
there is no indication for the build system that this function
should be avoided - such an indication is only given by the
Windows App Certification Kit, which forbids using the MoveFileExA
function.

Therefore check the WINAPI_FAMILY defines instead, to figure out
which API subset is targeted.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8ebf02f8f530240edf7e45f35f7647ef9dd44a58
---

 configure|2 --
 libavformat/os_support.h |   19 ---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index ed8316f..48669a0 100755
--- a/configure
+++ b/configure
@@ -1466,7 +1466,6 @@ SYSTEM_FUNCS=
 localtime_r
 mach_absolute_time
 MapViewOfFile
-MoveFileExA
 memalign
 mkstemp
 mmap
@@ -4100,7 +4099,6 @@ check_func_headers windows.h GetProcessAffinityMask
 check_func_headers windows.h GetProcessTimes
 check_func_headers windows.h GetSystemTimeAsFileTime
 check_func_headers windows.h MapViewOfFile
-check_func_headers windows.h MoveFileExA
 check_func_headers windows.h SetConsoleTextAttribute
 check_func_headers windows.h Sleep
 check_func_headers windows.h VirtualAlloc
diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 4949065..6cc6d9a 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -129,6 +129,18 @@ int ff_poll(struct pollfd *fds, nfds_t numfds, int 
timeout);
 #include windows.h
 #include libavutil/wchar_filename.h
 
+#ifdef WINAPI_FAMILY
+#include winapifamily.h
+// If a WINAPI_FAMILY is defined, check that the desktop API subset
+// is enabled
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#define USE_MOVEFILEEXA
+#endif
+#else
+// If no WINAPI_FAMILY is defined, assume the full API subset
+#define USE_MOVEFILEEXA
+#endif
+
 #define DEF_FS_FUNCTION(name, wfunc, afunc)   \
 static inline int win32_##name(const char *filename_utf8) \
 { \
@@ -180,13 +192,14 @@ static inline int win32_rename(const char *src_utf8, 
const char *dest_utf8)
 
 fallback:
 /* filename may be be in CP_ACP */
-#if HAVE_MOVEFILEEXA
+#ifdef USE_MOVEFILEEXA
 ret = MoveFileExA(src_utf8, dest_utf8, MOVEFILE_REPLACE_EXISTING);
 if (ret)
 errno = EPERM;
 #else
-/* Windows Phone doesn't have MoveFileExA. However, it's unlikely
- * that anybody would input filenames in CP_ACP there, so this
+/* Windows Phone doesn't have MoveFileExA, and for Windows Store apps,
+ * it is available but not allowed by the app certification kit. However,
+ * it's unlikely that anybody would input filenames in CP_ACP there, so 
this
  * fallback is kept mostly for completeness. Alternatively we could
  * do MultiByteToWideChar(CP_ACP) and use MoveFileExW, but doing
  * explicit conversions with CP_ACP is allegedly forbidden in windows

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] fate: Use bitexact conversions in the dpxparser test

2014-12-29 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Dec 29 
00:20:08 2014 +0200| [50036c30df83b609bc5a95276f1287f8b9b8bdd6] | committer: 
Martin Storsjö

fate: Use bitexact conversions in the dpxparser test

This fixes fate on e.g. ppc.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=50036c30df83b609bc5a95276f1287f8b9b8bdd6
---

 tests/fate/image.mak |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 3864896..3d8f6a8 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -34,7 +34,7 @@ FATE_SAMPLES_AVCONV-$(call DEMDEC, IMAGE2, DPX) += fate-dpx
 fate-dpx: CMD = framecrc -i $(TARGET_SAMPLES)/dpx/lighthouse_rgb48.dpx
 
 FATE_SAMPLES_AVCONV-$(call PARSERDEMDEC, DPX, IMAGE2PIPE, DPX) += 
fate-dpxparser
-fate-dpxparser: CMD = framecrc -f image2pipe -i 
$(TARGET_SAMPLES)/dpx/libav_4x_concat.dpx
+fate-dpxparser: CMD = framecrc -f image2pipe -i 
$(TARGET_SAMPLES)/dpx/libav_4x_concat.dpx -sws_flags +accurate_rnd+bitexact
 
 FATE_EXR += fate-exr-slice-raw
 fate-exr-slice-raw: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgba_slice_raw.exr 
-pix_fmt rgba64le

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] dashenc: Fix writing of timelines that don't start at t=0

2014-12-29 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Dec 29 
15:39:23 2014 +0200| [b91a5757fcbf723da99b05b298a6f820271dbc2b] | committer: 
Martin Storsjö

dashenc: Fix writing of timelines that don't start at t=0

When writing an explicit time, reset the cur_time variable to this
value as well. This avoids writing excessive time attributes for each
segment in the timeline, as long as the segments are continuous.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b91a5757fcbf723da99b05b298a6f820271dbc2b
---

 libavformat/dashenc.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index b4fd194..7dd08ec 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -214,8 +214,10 @@ static void output_segment_list(OutputStream *os, 
AVIOContext *out, DASHContext
 Segment *seg = os-segments[i];
 int repeat = 0;
 avio_printf(out, \t\t\t\t\t\tS );
-if (i == start_index || seg-time != cur_time)
+if (i == start_index || seg-time != cur_time) {
+cur_time = seg-time;
 avio_printf(out, t=\%PRId64\ , seg-time);
+}
 avio_printf(out, d=\%d\ , seg-duration);
 while (i + repeat + 1  os-nb_segments 
os-segments[i + repeat + 1]-duration == seg-duration 


___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] dashenc: Remove some stray double spaces

2014-12-29 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Dec 29 
14:57:05 2014 +0200| [8d54bacb789c7d37ca3cf48d9ac13083ad0c1ba7] | committer: 
Martin Storsjö

dashenc: Remove some stray double spaces

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d54bacb789c7d37ca3cf48d9ac13083ad0c1ba7
---

 libavformat/dashenc.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 7dd08ec..2a404b6 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -922,8 +922,8 @@ static const AVOption options[] = {
 { use_timeline, Use SegmentTimeline in SegmentTemplate, 
OFFSET(use_timeline), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, E },
 { single_file, Store all segments in one file, accessed using byte 
ranges, OFFSET(single_file), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, E },
 { single_file_name, DASH-templated name to be used for baseURL. Implies 
storing all segments in one file, accessed using byte ranges, 
OFFSET(single_file_name), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
-{ init_seg_name, DASH-templated name to used for the initialization 
segment, OFFSET(init_seg_name), AV_OPT_TYPE_STRING, {.str = 
init-stream$RepresentationID$.m4s},  0, 0, E },
-{ media_seg_name, DASH-templated name to used for the media segments, 
OFFSET(media_seg_name), AV_OPT_TYPE_STRING, {.str = 
chunk-stream$RepresentationID$-$Number%05d$.m4s},  0, 0, E },
+{ init_seg_name, DASH-templated name to used for the initialization 
segment, OFFSET(init_seg_name), AV_OPT_TYPE_STRING, {.str = 
init-stream$RepresentationID$.m4s}, 0, 0, E },
+{ media_seg_name, DASH-templated name to used for the media segments, 
OFFSET(media_seg_name), AV_OPT_TYPE_STRING, {.str = 
chunk-stream$RepresentationID$-$Number%05d$.m4s}, 0, 0, E },
 { NULL },
 };
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Add an option for delaying writing the moov with empty_moov

2015-01-02 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov  3 
16:09:15 2014 +0200| [847bf5988fec1d3e65c1d8cf0cdb8caf0cfd0c1b] | committer: 
Martin Storsjö

movenc: Add an option for delaying writing the moov with empty_moov

This delays writing the moov until the first fragment is written,
or can be flushed by the caller explicitly when wanted. If the first
sample in all streams is available at this point, we can write
a proper editlist at this point, allowing streams to start at
something else than dts=0. For AC3 and DNXHD, a packet is
needed in order to write the moov header properly.

This isn't added to the normal behaviour for empty_moov, since
the behaviour that ftyp+moov is written during avformat_write_header
would be changed. Callers that split the output stream into header+segments
(either by flushing manually, with the custom_frag flag set, or by
just differentiating between data written during avformat_write_header
and the rest) will need to be adjusted to take this option into use.

For handling streams that start at something else than dts=0, an
alternative would be to use different kinds of heuristics for
guessing the start dts (using AVCodecContext delay or has_b_frames
together with the frame rate), but this is not reliable and doesn't
necessarily work well with stream copy, and wouldn't work for getting
the right initialization data for AC3 or DNXHD either.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=847bf5988fec1d3e65c1d8cf0cdb8caf0cfd0c1b
---

 libavformat/movenc.c  |   71 -
 libavformat/movenc.h  |1 +
 libavformat/version.h |2 +-
 3 files changed, 60 insertions(+), 14 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 22ba3fd..9cc43ae 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -61,6 +61,7 @@ static const AVOption options[] = {
 { default_base_moof, Set the default-base-is-moof flag in tfhd atoms, 
0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DEFAULT_BASE_MOOF}, INT_MIN, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM, movflags },
 { dash, Write DASH compatible fragmented MP4, 0, AV_OPT_TYPE_CONST, 
{.i64 = FF_MOV_FLAG_DASH}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 
movflags },
 { frag_discont, Signal that the next fragment is discontinuous from 
earlier ones, 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_DISCONT}, 
INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, movflags },
+{ delay_moov, Delay writing the initial moov until the first fragment 
is cut, or until the first fragment flush, 0, AV_OPT_TYPE_CONST, {.i64 = 
FF_MOV_FLAG_DELAY_MOOV}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 
movflags },
 FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags),
 { skip_iods, Skip writing iods atom., offsetof(MOVMuxContext, 
iods_skip), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
 { iods_audio_profile, iods audio profile atom., 
offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 
255, AV_OPT_FLAG_ENCODING_PARAM},
@@ -1260,7 +1261,7 @@ static int mov_write_stbl_tag(AVIOContext *pb, MOVTrack 
*track)
 if (track-mode == MODE_MOV  track-flags  MOV_TRACK_STPS)
 mov_write_stss_tag(pb, track, MOV_PARTIAL_SYNC_SAMPLE);
 if (track-enc-codec_type == AVMEDIA_TYPE_VIDEO 
-track-flags  MOV_TRACK_CTTS)
+track-flags  MOV_TRACK_CTTS  track-entry)
 mov_write_ctts_tag(pb, track);
 mov_write_stsc_tag(pb, track);
 mov_write_stsz_tag(pb, track);
@@ -1771,6 +1772,12 @@ static int mov_write_trak_tag(AVIOContext *pb, 
MOVMuxContext *mov,
   MOVTrack *track, AVStream *st)
 {
 int64_t pos = avio_tell(pb);
+int entry_backup = track-entry;
+/* If we want to have an empty moov, but some samples already have been
+ * buffered (delay_moov), pretend that no samples have been written yet. */
+if (mov-flags  FF_MOV_FLAG_EMPTY_MOOV)
+track-entry = 0;
+
 avio_wb32(pb, 0); /* size */
 ffio_wfourcc(pb, trak);
 mov_write_tkhd_tag(pb, mov, track, st);
@@ -1802,6 +1809,7 @@ static int mov_write_trak_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 }
 }
 mov_write_track_udta_tag(pb, mov, st);
+track-entry = entry_backup;
 return update_size(pb, pos);
 }
 
@@ -1876,6 +1884,12 @@ static int mov_write_mvhd_tag(AVIOContext *pb, 
MOVMuxContext *mov)
 max_track_id = mov-tracks[i].track_id;
 }
 }
+/* If using delay_moov, make sure the output is the same as if no
+ * samples had been written yet. */
+if (mov-flags  FF_MOV_FLAG_EMPTY_MOOV) {
+max_track_len = 0;
+max_track_id  = 1;
+}
 
 version = max_track_len  UINT32_MAX ? 0 : 1;
 (version == 1) ? avio_wb32(pb, 120) : avio_wb32(pb, 108); /* size */
@@ -3110,8 +3124,18 @@ static int mov_flush_fragment(AVFormatContext *s)
 for (i = 0; i  mov-nb_streams; i

[FFmpeg-cvslog] movenc: Get rid of a hack for updating the dvc1 atom

2015-01-02 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Dec 29 
13:32:21 2014 +0200| [b3b0b35db2f3b61bf2f0f4fa85f5b6267d83c8fe] | committer: 
Martin Storsjö

movenc: Get rid of a hack for updating the dvc1 atom

Use the more generic approach with the delay_moov flag, instead of
having a update mechanism specific to this one single atom.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b3b0b35db2f3b61bf2f0f4fa85f5b6267d83c8fe
---

 libavformat/movenc.c |   20 
 libavformat/movenc.h |1 -
 2 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 9cc43ae..75c2d27 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -447,9 +447,11 @@ static int mov_write_dvc1_structs(MOVTrack *track, uint8_t 
*buf)
 
 if (track-start_dts == AV_NOPTS_VALUE) {
 /* No packets written yet, vc1_info isn't authoritative yet. */
-/* Assume inline sequence and entry headers. This will be
- * overwritten at the end if the file is seekable. */
+/* Assume inline sequence and entry headers. */
 packet_seq = packet_entry = 1;
+av_log(NULL, AV_LOG_WARNING,
+   moov atom written before any packets, unable to write correct 
+   dvc1 atom. Set the delay_moov flag to fix this.\n);
 }
 
 unescaped = av_mallocz(track-vos_len + FF_INPUT_BUFFER_PADDING_SIZE);
@@ -525,7 +527,6 @@ static int mov_write_dvc1_tag(AVIOContext *pb, MOVTrack 
*track)
 
 avio_wb32(pb, track-vos_len + 8 + sizeof(buf));
 ffio_wfourcc(pb, dvc1);
-track-vc1_info.struct_offset = avio_tell(pb);
 avio_write(pb, buf, sizeof(buf));
 avio_write(pb, track-vos_data, track-vos_len);
 
@@ -4088,19 +4089,6 @@ static int mov_write_trailer(AVFormatContext *s)
 }
 }
 
-for (i = 0; i  mov-nb_streams; i++) {
-if (mov-flags  FF_MOV_FLAG_FRAGMENT 
-mov-tracks[i].vc1_info.struct_offset  s-pb-seekable) {
-int64_t off = avio_tell(pb);
-uint8_t buf[7];
-if (mov_write_dvc1_structs(mov-tracks[i], buf) = 0) {
-avio_seek(pb, mov-tracks[i].vc1_info.struct_offset, SEEK_SET);
-avio_write(pb, buf, 7);
-avio_seek(pb, off, SEEK_SET);
-}
-}
-}
-
 error:
 mov_free(s);
 
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 8b1084e..682820e 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -129,7 +129,6 @@ typedef struct MOVTrack {
 unsignedfrag_info_capacity;
 
 struct {
-int64_t struct_offset;
 int first_packet_seq;
 int first_packet_entry;
 int packet_seq;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Remove an unnecessary condition when flushing fragments

2015-01-02 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Thu Dec 18 
23:59:27 2014 +0200| [724cbea7193945fe5a5b4dea8ede344803572844] | committer: 
Martin Storsjö

movenc: Remove an unnecessary condition when flushing fragments

If fragments == 0 it means we haven't written any moov atom yet.
If the empty_moov flag is set, we already have written an empty moov
atom at startup. Thus, the check for empty_moov is redundant.

This is in preparation for allowing writing the moov atom later,
even when using the empty moov flag.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=724cbea7193945fe5a5b4dea8ede344803572844
---

 libavformat/movenc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 3f5a6ae..fe5f5ed 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3089,7 +3089,7 @@ static int mov_flush_fragment(AVFormatContext *s)
 if (!(mov-flags  FF_MOV_FLAG_FRAGMENT))
 return 0;
 
-if (!(mov-flags  FF_MOV_FLAG_EMPTY_MOOV)  mov-fragments == 0) {
+if (mov-fragments == 0) {
 int64_t pos = avio_tell(s-pb);
 int ret;
 AVIOContext *moov_buf;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] movenc: Factorize writing ftyp and other identification tags to a separate function

2015-01-02 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Thu Dec 18 
23:52:42 2014 +0200| [355d01a1bf55297b1d1f04e4bfbf0ddc93b6247e] | committer: 
Martin Storsjö

movenc: Factorize writing ftyp and other identification tags to a separate 
function

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=355d01a1bf55297b1d1f04e4bfbf0ddc93b6247e
---

 libavformat/movenc.c |   26 +-
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index a809c36..3f5a6ae 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2988,6 +2988,20 @@ static void mov_write_uuidprof_tag(AVIOContext *pb, 
AVFormatContext *s)
 avio_wb32(pb, 0x010001); /* ? */
 }
 
+static int mov_write_identification(AVIOContext *pb, AVFormatContext *s)
+{
+MOVMuxContext *mov = s-priv_data;
+mov_write_ftyp_tag(pb,s);
+if (mov-mode == MODE_PSP) {
+if (s-nb_streams != 2) {
+av_log(s, AV_LOG_ERROR, PSP mode need one video and one audio 
stream\n);
+return AVERROR(EINVAL);
+}
+mov_write_uuidprof_tag(pb, s);
+}
+return 0;
+}
+
 static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags)
 {
 uint32_t c = -1;
@@ -3605,7 +3619,7 @@ static int mov_write_header(AVFormatContext *s)
 AVIOContext *pb = s-pb;
 MOVMuxContext *mov = s-priv_data;
 AVDictionaryEntry *t;
-int i, hint_track = 0;
+int i, ret, hint_track = 0;
 
 mov-fc = s;
 
@@ -3664,14 +3678,8 @@ static int mov_write_header(AVFormatContext *s)
 }
 
 
-mov_write_ftyp_tag(pb,s);
-if (mov-mode == MODE_PSP) {
-if (s-nb_streams != 2) {
-av_log(s, AV_LOG_ERROR, PSP mode need one video and one audio 
stream\n);
-return AVERROR(EINVAL);
-}
-mov_write_uuidprof_tag(pb, s);
-}
+if ((ret = mov_write_identification(pb, s))  0)
+return ret;
 
 mov-nb_streams = s-nb_streams;
 if (mov-mode  (MODE_MP4|MODE_MOV|MODE_IPOD)  s-nb_chapters)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] dashenc: Use pts for MPD timeline timestamps

2015-01-02 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov 17 
14:34:46 2014 +0200| [7a1a63e34fa46af18311c2493fdaec9a93bdb750] | committer: 
Martin Storsjö

dashenc: Use pts for MPD timeline timestamps

This should be more correct. This also should give more sensible
switching between video streams with different amount of b-frame
delay.

The current dash.js release (1.2.0) fails to start playback of
such files from the start (if the start pts is  0), but this has
been fixed in the current git version of dash.js.

Also enable the use of edit lists, so that streams in many cases
start at pts=0.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7a1a63e34fa46af18311c2493fdaec9a93bdb750
---

 libavformat/dashenc.c |   40 +++-
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5afc40b..5e06e35 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -68,7 +68,7 @@ typedef struct OutputStream {
 int init_range_length;
 int nb_segments, segments_size, segment_index;
 Segment **segments;
-int64_t first_dts, start_dts, end_dts;
+int64_t first_pts, start_pts, max_pts;
 int bit_rate;
 char bandwidth_str[64];
 
@@ -627,6 +627,7 @@ static int dash_write_header(AVFormatContext *s)
 os-init_start_pos = 0;
 
 av_dict_set(opts, movflags, frag_custom+dash+delay_moov, 0);
+av_dict_set(opts, use_editlist, 1, 0);
 if ((ret = avformat_write_header(ctx, opts))  0) {
  goto fail;
 }
@@ -647,8 +648,8 @@ static int dash_write_header(AVFormatContext *s)
 c-has_audio = 1;
 
 set_codec_str(s, os-ctx-streams[0]-codec, os-codec_str, 
sizeof(os-codec_str));
-os-first_dts = AV_NOPTS_VALUE;
-os-end_dts = AV_NOPTS_VALUE;
+os-first_pts = AV_NOPTS_VALUE;
+os-max_pts = AV_NOPTS_VALUE;
 os-segment_index = 1;
 }
 
@@ -687,6 +688,8 @@ static int add_segment(OutputStream *os, const char *file,
 return AVERROR(ENOMEM);
 av_strlcpy(seg-file, file, sizeof(seg-file));
 seg-time = time;
+if (seg-time  0) // If pts0, it is expected to be cut away with an edit 
list
+seg-time = 0;
 seg-duration = duration;
 seg-start_pos = start_pos;
 seg-range_length = range_length;
@@ -770,7 +773,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 start_pos = avio_tell(os-ctx-pb);
 
 if (!c-single_file) {
-dash_fill_tmpl_params(filename, sizeof(filename), 
c-media_seg_name, i, os-segment_index, os-bit_rate, os-start_dts);
+dash_fill_tmpl_params(filename, sizeof(filename), 
c-media_seg_name, i, os-segment_index, os-bit_rate, os-start_pts);
 snprintf(full_path, sizeof(full_path), %s%s, c-dirname, 
filename);
 snprintf(temp_path, sizeof(temp_path), %s.tmp, full_path);
 ret = ffurl_open(os-out, temp_path, AVIO_FLAG_WRITE, 
s-interrupt_callback, NULL);
@@ -795,7 +798,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 if (ret  0)
 break;
 }
-add_segment(os, filename, os-start_dts, os-end_dts - os-start_dts, 
start_pos, range_length, index_length);
+add_segment(os, filename, os-start_pts, os-max_pts - os-start_pts, 
start_pos, range_length, index_length);
 av_log(s, AV_LOG_VERBOSE, Representation %d media segment %d written 
to: %s\n, i, os-segment_index, full_path);
 }
 
@@ -834,25 +837,25 @@ static int dash_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 // If forcing the stream to start at 0, the mp4 muxer will set the start
 // timestamps to 0. Do the same here, to avoid mismatches in 
duration/timestamps.
-if (os-first_dts == AV_NOPTS_VALUE 
+if (os-first_pts == AV_NOPTS_VALUE 
 s-avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) {
 pkt-pts -= pkt-dts;
 pkt-dts  = 0;
 }
 
-if (os-first_dts == AV_NOPTS_VALUE)
-os-first_dts = pkt-dts;
+if (os-first_pts == AV_NOPTS_VALUE)
+os-first_pts = pkt-pts;
 
 if ((!c-has_video || st-codec-codec_type == AVMEDIA_TYPE_VIDEO) 
 pkt-flags  AV_PKT_FLAG_KEY  os-packets_written 
-av_compare_ts(pkt-dts - os-first_dts, st-time_base,
+av_compare_ts(pkt-pts - os-first_pts, st-time_base,
   seg_end_duration, AV_TIME_BASE_Q) = 0) {
 int64_t prev_duration = c-last_duration;
 
-c-last_duration = av_rescale_q(pkt-dts - os-start_dts,
+c-last_duration = av_rescale_q(pkt-pts - os-start_pts,
 st-time_base,
 AV_TIME_BASE_Q);
-c-total_duration = av_rescale_q(pkt-dts - os-first_dts,
+c-total_duration = av_rescale_q(pkt-pts - os-first_pts,
  st

[FFmpeg-cvslog] dashenc: Use delay_moov

2015-01-02 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Mon Nov  3 
21:42:09 2014 +0200| [c5e7ea13d2d4da0c5da91973a547afff6fe9e011] | committer: 
Martin Storsjö

dashenc: Use delay_moov

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c5e7ea13d2d4da0c5da91973a547afff6fe9e011
---

 libavformat/dashenc.c |   23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 2a404b6..5afc40b 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -626,7 +626,7 @@ static int dash_write_header(AVFormatContext *s)
 goto fail;
 os-init_start_pos = 0;
 
-av_dict_set(opts, movflags, frag_custom+dash, 0);
+av_dict_set(opts, movflags, frag_custom+dash+delay_moov, 0);
 if ((ret = avformat_write_header(ctx, opts))  0) {
  goto fail;
 }
@@ -634,13 +634,7 @@ static int dash_write_header(AVFormatContext *s)
 avio_flush(ctx-pb);
 av_dict_free(opts);
 
-if (c-single_file) {
-os-init_range_length = avio_tell(ctx-pb);
-} else {
-ffurl_close(os-out);
-os-out = NULL;
-}
-av_log(s, AV_LOG_VERBOSE, Representation %d init segment written to: 
%s\n, i, filename);
+av_log(s, AV_LOG_VERBOSE, Representation %d init segment will be 
written to: %s\n, i, filename);
 
 s-streams[i]-time_base = st-time_base;
 // If the muxer wants to shift timestamps, request to have them shifted
@@ -746,7 +740,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 for (i = 0; i  s-nb_streams; i++) {
 OutputStream *os = c-streams[i];
 char filename[1024] = , full_path[1024], temp_path[1024];
-int64_t start_pos = avio_tell(os-ctx-pb);
+int64_t start_pos;
 int range_length, index_length = 0;
 
 if (!os-packets_written)
@@ -764,6 +758,17 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 continue;
 }
 
+if (!os-init_range_length) {
+av_write_frame(os-ctx, NULL);
+os-init_range_length = avio_tell(os-ctx-pb);
+if (!c-single_file) {
+ffurl_close(os-out);
+os-out = NULL;
+}
+}
+
+start_pos = avio_tell(os-ctx-pb);
+
 if (!c-single_file) {
 dash_fill_tmpl_params(filename, sizeof(filename), 
c-media_seg_name, i, os-segment_index, os-bit_rate, os-start_dts);
 snprintf(full_path, sizeof(full_path), %s%s, c-dirname, 
filename);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] sidxindex: Don' t adjust the Period start time depending on the track start time

2015-01-02 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö mar...@martin.st | Fri Nov 28 
09:40:31 2014 +0200| [5cf6bda6e2eae496e8eb2bb06c96852d59a58b8a] | committer: 
Martin Storsjö

sidxindex: Don't adjust the Period start time depending on the track start time

This was only necessary to get playback to start with dash.js 1.2.0,
it has been fixed in the git version.

The previous behaviour was incorrect - the Period's start time
is irrespective of the actual first timestamp of the contents
within the period. The Period start time only says when, within the
global timeline, this particular piece should start to be played
back.

Signed-off-by: Martin Storsjö mar...@martin.st

 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5cf6bda6e2eae496e8eb2bb06c96852d59a58b8a
---

 tools/sidxindex.c |   13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/tools/sidxindex.c b/tools/sidxindex.c
index 62f021f..6c6b3a4 100644
--- a/tools/sidxindex.c
+++ b/tools/sidxindex.c
@@ -252,7 +252,6 @@ static int output_mpd(struct Tracks *tracks, const char 
*filename)
 int nb_tracks_buf[2] = { 0 };
 int *nb_tracks;
 int set, nb_sets;
-int64_t latest_start = 0;
 
 if (!tracks-multiple_tracks_per_file) {
 adaptation_sets = adaptation_sets_buf;
@@ -299,17 +298,7 @@ static int output_mpd(struct Tracks *tracks, const char 
*filename)
 fprintf(out, \\n);
 fprintf(out, \tminBufferTime=\PT5S\\n);
 
-for (i = 0; i  tracks-nb_tracks; i++) {
-int64_t start = 
av_rescale_rnd(tracks-tracks[i]-earliest_presentation,
-   AV_TIME_BASE,
-   
tracks-tracks[i]-earliest_presentation_timescale,
-   AV_ROUND_UP);
-latest_start = FFMAX(start, latest_start);
-}
-fprintf(out, \tPeriod start=\);
-write_time(out, latest_start, 3, AV_ROUND_UP);
-fprintf(out, \\n);
-
+fprintf(out, \tPeriod start=\PT0.0S\\n);
 
 for (set = 0; set  nb_sets; set++) {
 if (nb_tracks[set] == 0)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


  1   2   3   4   5   6   7   8   9   10   >