[FFmpeg-cvslog] avformat/mpegts: fix memory leak with merge_pmt_versions=1

2018-05-21 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Mon May 21 12:13:06 2018 
-0700| [70d25268c21cbee5f08304da95be1f647c630c15] | committer: Aman Gupta

avformat/mpegts: fix memory leak with merge_pmt_versions=1

Signed-off-by: Aman Gupta 

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

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

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index e39c927441..5f53f77d89 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -247,6 +247,7 @@ typedef struct PESContext {
 uint8_t header[MAX_PES_HEADER_SIZE];
 AVBufferRef *buffer;
 SLConfigDescr sl;
+int merged_st;
 } PESContext;
 
 extern AVInputFormat ff_mpegts_demuxer;
@@ -550,8 +551,8 @@ static void mpegts_close_filter(MpegTSContext *ts, 
MpegTSFilter *filter)
 PESContext *pes = filter->u.pes_filter.opaque;
 av_buffer_unref(&pes->buffer);
 /* referenced private data will be freed later in
- * avformat_close_input */
-if (!((PESContext *)filter->u.pes_filter.opaque)->st) {
+ * avformat_close_input (pes->st->priv_data == pes) */
+if (!pes->st || pes->merged_st) {
 av_freep(&filter->u.pes_filter.opaque);
 }
 }
@@ -2190,6 +2191,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 if (st) {
 pes->st = st;
 pes->stream_type = stream_type;
+pes->merged_st = 1;
 }
 }
 if (!pes->st) {
@@ -2211,6 +2213,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 if (st) {
 pes->st = st;
 pes->stream_type = stream_type;
+pes->merged_st = 1;
 }
 }
 if (pes && !pes->st) {

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


[FFmpeg-cvslog] avformat/mpegts: rename variable to clarify meaning

2018-05-21 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Mon May 21 12:11:45 2018 
-0700| [64680fff3bcfbb69c7effbea52e41a2c583d903f] | committer: Aman Gupta

avformat/mpegts: rename variable to clarify meaning

Both stream_id and stream_identifier are used in this file,
and have different meanings. The latter comes from the
stream_identifier_descriptor.

Signed-off-by: Aman Gupta 

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

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

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 0c9847f85b..e39c927441 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2008,7 +2008,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 }
 
 static AVStream *find_matching_stream(MpegTSContext *ts, int pid,
-  int stream_id, int pmt_stream_idx)
+  int stream_identifier, int 
pmt_stream_idx)
 {
 AVFormatContext *s = ts->stream;
 int i;
@@ -2016,8 +2016,8 @@ static AVStream *find_matching_stream(MpegTSContext *ts, 
int pid,
 
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *st = s->streams[i];
-if (stream_id != -1) { /* match based on "stream identifier 
descriptor" if present */
-if (st->stream_identifier == stream_id+1) {
+if (stream_identifier != -1) { /* match based on "stream identifier 
descriptor" if present */
+if (st->stream_identifier == stream_identifier+1) {
 found = st;
 break;
 }
@@ -2090,7 +2090,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 int program_info_length, pcr_pid, pid, stream_type;
 int desc_list_len;
 uint32_t prog_reg_desc = 0; /* registration descriptor */
-int stream_id = -1;
+int stream_identifier = -1;
 
 int mp4_descr_count = 0;
 Mp4Descr mp4_descr[MAX_MP4_DESCR_COUNT] = { { 0 } };
@@ -2180,13 +2180,13 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 goto out;
 
 if (ts->merge_pmt_versions)
-stream_id = parse_stream_identifier_desc(p, p_end);
+stream_identifier = parse_stream_identifier_desc(p, p_end);
 
 /* now create stream */
 if (ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES) {
 pes = ts->pids[pid]->u.pes_filter.opaque;
 if (ts->merge_pmt_versions && !pes->st) {
-st = find_matching_stream(ts, pid, stream_id, i);
+st = find_matching_stream(ts, pid, stream_identifier, i);
 if (st) {
 pes->st = st;
 pes->stream_type = stream_type;
@@ -2207,7 +2207,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 mpegts_close_filter(ts, ts->pids[pid]); // wrongly added sdt 
filter probably
 pes = add_pes_stream(ts, pid, pcr_pid);
 if (ts->merge_pmt_versions && pes && !pes->st) {
-st = find_matching_stream(ts, pid, stream_id, i);
+st = find_matching_stream(ts, pid, stream_identifier, i);
 if (st) {
 pes->st = st;
 pes->stream_type = stream_type;
@@ -2228,7 +2228,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 st = ts->stream->streams[idx];
 }
 if (ts->merge_pmt_versions && !st) {
-st = find_matching_stream(ts, pid, stream_id, i);
+st = find_matching_stream(ts, pid, stream_identifier, i);
 }
 if (!st) {
 st = avformat_new_stream(ts->stream, NULL);

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


[FFmpeg-cvslog] doc: remove AVStream private fields from APIchanges

2018-05-21 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Mon May 21 12:12:46 2018 
-0700| [fc2daf36f926d393e7d27bc574adb9cb09b6c8db] | committer: Aman Gupta

doc: remove AVStream private fields from APIchanges

Signed-off-by: Aman Gupta 

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

 doc/APIchanges | 1 -
 1 file changed, 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index a592073ca5..efe15ba4e0 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -17,7 +17,6 @@ API changes, most recent first:
 
 2018-05-xx - xx - lavf 58.15.100 - avformat.h
   Add pmt_version field to AVProgram
-  Add program_num, pmt_version, pmt_stream_idx to AVStream
 
 2018-05-xx - xx - lavf 58.14.100 - avformat.h
   Add AV_DISPOSITION_STILL_IMAGE

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


[FFmpeg-cvslog] hwcontext: Add test for device creation and derivation

2018-05-21 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Tue May 15 23:15:03 
2018 +0100| [ba7d1377e85662f7b4ae728719c10d5427cc6b9b] | committer: Mark 
Thompson

hwcontext: Add test for device creation and derivation

This uses any devices it can find on the host system - on a system with no
hardware device support or in builds with no support included it will do
nothing and pass.

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

 libavutil/Makefile |   1 +
 libavutil/tests/.gitignore |   1 +
 libavutil/tests/hwdevice.c | 226 +
 tests/Makefile |   5 +
 tests/fate/hw.mak  |   6 ++
 5 files changed, 239 insertions(+)

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 4fe470748c..d0632f16a6 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -206,6 +206,7 @@ TESTPROGS = adler32 
\
 fifo\
 hash\
 hmac\
+hwdevice\
 integer \
 imgutils\
 lfg \
diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore
index 8ede070887..71f75a8ee9 100644
--- a/libavutil/tests/.gitignore
+++ b/libavutil/tests/.gitignore
@@ -22,6 +22,7 @@
 /file
 /hash
 /hmac
+/hwdevice
 /imgutils
 /lfg
 /lls
diff --git a/libavutil/tests/hwdevice.c b/libavutil/tests/hwdevice.c
new file mode 100644
index 00..7eb355c988
--- /dev/null
+++ b/libavutil/tests/hwdevice.c
@@ -0,0 +1,226 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavutil/hwcontext.h"
+
+static int test_derivation(AVBufferRef *src_ref, const char *src_name)
+{
+enum AVHWDeviceType derived_type;
+const char *derived_name;
+AVBufferRef *derived_ref = NULL, *back_ref = NULL;
+AVHWDeviceContext *src_dev, *derived_dev;
+int err;
+
+src_dev = (AVHWDeviceContext*)src_ref->data;
+
+derived_type = AV_HWDEVICE_TYPE_NONE;
+while (1) {
+derived_type = av_hwdevice_iterate_types(derived_type);
+if (derived_type == AV_HWDEVICE_TYPE_NONE)
+break;
+
+derived_name = av_hwdevice_get_type_name(derived_type);
+
+err = av_hwdevice_ctx_create_derived(&derived_ref, derived_type,
+ src_ref, 0);
+if (err < 0) {
+fprintf(stderr, "Unable to derive %s -> %s: %d.\n",
+src_name, derived_name, err);
+continue;
+}
+
+derived_dev = (AVHWDeviceContext*)derived_ref->data;
+if (derived_dev->type != derived_type) {
+fprintf(stderr, "Device derived as type %d has type %d.\n",
+derived_type, derived_dev->type);
+goto fail;
+}
+
+if (derived_type == src_dev->type) {
+if (derived_dev != src_dev) {
+fprintf(stderr, "Derivation of %s from itself succeeded "
+"but did not return the same device.\n", src_name);
+goto fail;
+}
+av_buffer_unref(&derived_ref);
+continue;
+}
+
+err = av_hwdevice_ctx_create_derived(&back_ref, src_dev->type,
+ derived_ref, 0);
+if (err < 0) {
+fprintf(stderr, "Derivation %s to %s succeeded, but derivation "
+"back again failed: %d.\n",
+src_name, derived_name, err);
+goto fail;
+}
+
+if (back_ref->data != src_ref->data) {
+fprintf(stderr, "Derivation %s to %s succeeded, but derivation "
+"back again did not return the original device.\n",
+   src_name, derived_name);
+goto fail;
+}
+
+fprintf(stderr, "Successfully tested derivatio

[FFmpeg-cvslog] libavformat: add mbedTLS based TLS

2018-05-21 Thread Thomas Volkert
ffmpeg | branch: master | Thomas Volkert  | Sat 
Apr 21 15:53:31 2018 +0200| [c24d247e2c2ccd13fda09fe4194bf2ff0eb42256] | 
committer: James Almer

libavformat: add mbedTLS based TLS

Signed-off-by: James Almer 

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

 Changelog |   1 +
 configure |  29 ++--
 libavformat/Makefile  |   1 +
 libavformat/rtmpdh.c  |  55 
 libavformat/rtmpdh.h  |   5 +
 libavformat/tls_mbedtls.c | 351 ++
 libavformat/version.h |   2 +-
 7 files changed, 435 insertions(+), 9 deletions(-)

diff --git a/Changelog b/Changelog
index 562fbc49e8..3d2556448e 100644
--- a/Changelog
+++ b/Changelog
@@ -8,6 +8,7 @@ version :
 - fftdnoiz filter
 - aderivative and aintegral audio filters
 - pal75bars and pal100bars video filter sources
+- support mbedTLS based TLS
 
 
 version 4.0:
diff --git a/configure b/configure
index e52f8f850b..09ff0c55e2 100755
--- a/configure
+++ b/configure
@@ -213,7 +213,7 @@ External library support:
   --enable-gmp enable gmp, needed for rtmp(t)e support
if openssl or librtmp is not used [no]
   --enable-gnutls  enable gnutls, needed for https support
-   if openssl or libtls is not used [no]
+   if openssl, libtls or mbedtls is not used [no]
   --disable-iconv  disable iconv [autodetect]
   --enable-jni enable JNI support [no]
   --enable-ladspa  enable LADSPA audio filtering [no]
@@ -262,7 +262,7 @@ External library support:
   --enable-libtesseractenable Tesseract, needed for ocr filter [no]
   --enable-libtheora   enable Theora encoding via libtheora [no]
   --enable-libtls  enable LibreSSL (via libtls), needed for https 
support
-   if openssl or gnutls is not used [no]
+   if openssl, gnutls or mbedtls is not used [no]
   --enable-libtwolame  enable MP2 encoding via libtwolame [no]
   --enable-libv4l2 enable libv4l2/v4l-utils [no]
   --enable-libvidstab  enable video stabilization using vid.stab [no]
@@ -291,13 +291,15 @@ External library support:
   --disable-lzma   disable lzma [autodetect]
   --enable-decklinkenable Blackmagic DeckLink I/O support [no]
   --enable-libndi_newtek   enable Newteck NDI I/O support [no]
+  --enable-mbedtls enable mbedTLS, needed for https support
+   if openssl, gnutls or libtls is not used [no]
   --enable-mediacodec  enable Android MediaCodec support [no]
   --enable-libmysofa   enable libmysofa, needed for sofalizer filter [no]
   --enable-openal  enable OpenAL 1.1 capture support [no]
   --enable-opencl  enable OpenCL processing [no]
   --enable-opengl  enable OpenGL rendering [no]
   --enable-openssl enable openssl, needed for https support
-   if gnutls or libtls is not used [no]
+   if gnutls, libtls or mbedtls is not used [no]
   --disable-sndio  disable sndio support [autodetect]
   --disable-schannel   disable SChannel SSP, needed for TLS support on
Windows if openssl and gnutls are not used 
[autodetect]
@@ -1656,6 +1658,7 @@ EXTERNAL_LIBRARY_VERSION3_LIST="
 libopencore_amrwb
 libvmaf
 libvo_amrwbenc
+mbedtls
 rkmpp
 "
 
@@ -3235,7 +3238,7 @@ xv_outdev_deps="xlib"
 async_protocol_deps="threads"
 bluray_protocol_deps="libbluray"
 ffrtmpcrypt_protocol_conflict="librtmp_protocol"
-ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl"
+ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl mbedtls"
 ffrtmpcrypt_protocol_select="tcp_protocol"
 ffrtmphttp_protocol_conflict="librtmp_protocol"
 ffrtmphttp_protocol_select="http_protocol"
@@ -3255,7 +3258,7 @@ librtmpt_protocol_deps="librtmp"
 librtmpte_protocol_deps="librtmp"
 libsmbclient_protocol_deps="libsmbclient gplv3"
 libssh_protocol_deps="libssh"
-libtls_conflict="openssl gnutls"
+libtls_conflict="openssl gnutls mbedtls"
 mmsh_protocol_select="http_protocol"
 mmst_protocol_select="network"
 libsrt_protocol_deps="libsrt"
@@ -3275,13 +3278,13 @@ rtmpte_protocol_suggest="zlib"
 rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
 rtmpts_protocol_suggest="zlib"
 rtp_protocol_select="udp_protocol"
-schannel_conflict="openssl gnutls libtls"
+schannel_conflict="openssl gnutls libtls mbedtls"
 sctp_protocol_deps="struct_sctp_event_subscribe struct_msghdr_msg_flags"
 sctp_protocol_select="network"
-securetransport_conflict="openssl gnutls libtls"
+securetransport_conflict="openssl gnutls libtls mbedtls"
 srtp_protocol_select="rtp_protocol srtp"
 tcp_protocol_select="network"
-tls_protocol_deps_any="gnutls openssl schannel securetransport libtls"
+tls_protocol_deps_any="gnutls openssl schannel securetransport libtls mbedtls"
 tls_prot

[FFmpeg-cvslog] avcodec/libvpxenc: fix setting amount of threads used for encoding

2018-05-21 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat May 19 15:01:56 
2018 -0300| [27df34bf1f7a113086ba5c68d2a58b7c430c301f] | committer: James Almer

avcodec/libvpxenc: fix setting amount of threads used for encoding

The libvpx doxy says that a value of 0 for the g_threads field is
equivalent to a value of 1, whereas for avctx->thread_count it means
the maximum amount of threads possible for the host system.

Use av_cpu_count() to get the correct thread count when auto threads
is requested.

Reviewed-by: James Zern 
Signed-off-by: James Almer 

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

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

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index d0bd1e997a..09f7a88452 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -493,7 +493,7 @@ static av_cold int vpx_init(AVCodecContext *avctx,
 enccfg.g_h= avctx->height;
 enccfg.g_timebase.num = avctx->time_base.num;
 enccfg.g_timebase.den = avctx->time_base.den;
-enccfg.g_threads  = avctx->thread_count;
+enccfg.g_threads  = avctx->thread_count ? avctx->thread_count : 
av_cpu_count();
 enccfg.g_lag_in_frames= ctx->lag_in_frames;
 
 if (avctx->flags & AV_CODEC_FLAG_PASS1)

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