Re: [FFmpeg-devel] [PATCH] lavf/movdec: add position_order option

2019-09-22 Thread Rodger Combs


> On Sep 22, 2019, at 03:19, Andreas Rheinhardt  
> wrote:
> 
> Rodger Combs:
>> This allows reading packets linearly, which prevents large numbers of
>> unnecessary seeks in poorly-interleaved files with consumer software that
>> handles those cases well on its own.
>> ---
> 
> Did you test whether this fixes tickets #7592 and #7891?
> 
> - Andreas

Tested just now; I can't validate 7592 as the sample link is dead, but playback 
of the files in 7891 over network (in either mpv or ffplay) improves 
dramatically with this option set.

> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] lavf/mp3dec: increase probe score of buffers entirely composed of valid packets

2019-09-21 Thread Rodger Combs
Fixes some files misdetecting as MPEG PS
---
 libavformat/mp3dec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 258f19174b..d9aaee50b9 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -100,13 +100,13 @@ static int mp3_read_probe(const AVProbeData *p)
 max_framesizes = FFMAX(max_framesizes, framesizes);
 if(buf == buf0) {
 first_frames= frames;
-if (buf2 == end + sizeof(uint32_t))
+if (buf2 >= end + sizeof(uint32_t))
 whole_used = 1;
 }
 }
 // keep this in sync with ac3 probe, both need to avoid
 // issues with MPEG-files!
-if   (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1;
+if   (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1 + whole_used * 
FFMIN(first_frames / 2, 5);
 else if(max_frames>200 && p->buf_size < 2*max_framesizes)return 
AVPROBE_SCORE_EXTENSION;
 else if(max_frames>=4 && p->buf_size < 2*max_framesizes) return 
AVPROBE_SCORE_EXTENSION / 2;
 else if(ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC) && 
2*ff_id3v2_tag_len(buf0) >= p->buf_size)
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] lavf/tcp: add resolve_hosts option

2019-09-21 Thread Rodger Combs
This can be used to resolve particular hosts offline without affecting
HTTP headers, TLS SNI, or cross-domain redirects. It works similarly to
curl's --resolve option, but without port-specific handling.
---
 libavformat/tcp.c | 27 +++
 libavformat/version.h |  2 +-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 2198e0f00e..e4c439ee56 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -45,6 +45,7 @@ typedef struct TCPContext {
 #if !HAVE_WINSOCK2_H
 int tcp_mss;
 #endif /* !HAVE_WINSOCK2_H */
+char *resolve_hosts;
 } TCPContext;
 
 #define OFFSET(x) offsetof(TCPContext, x)
@@ -60,6 +61,7 @@ static const AVOption options[] = {
 #if !HAVE_WINSOCK2_H
 { "tcp_mss", "Maximum segment size for outgoing TCP packets",  
OFFSET(tcp_mss), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, 
.flags = D|E },
 #endif /* !HAVE_WINSOCK2_H */
+{ "resolve_hosts", "Comma-separated host resolutions, in the form 
host:ip", OFFSET(resolve_hosts), AV_OPT_TYPE_STRING, { .str = NULL },  0, 0,
   .flags = D|E },
 { NULL }
 };
 
@@ -99,6 +101,27 @@ static void customize_fd(void *ctx, int fd)
 #endif /* !HAVE_WINSOCK2_H */
 }
 
+static int lookup_host(URLContext *h, char *hostname, size_t hostname_size)
+{
+TCPContext *s = h->priv_data;
+if (hostname[0]) {
+size_t hostlen = strlen(hostname);
+for (const char *addr = s->resolve_hosts; addr; addr = strchr(addr, 
','), addr && addr++) {
+if (!strncmp(addr, hostname, hostlen) && addr[hostlen] == ':') {
+addr += hostlen + 1;
+const char *end = strchr(addr, ',');
+size_t len = end ? end - addr : strlen(addr);
+if (len >= hostname_size - 1)
+return AVERROR(ENOMEM);
+memcpy(hostname, addr, len);
+hostname[len] = 0;
+return 0;
+}
+}
+}
+return 0;
+}
+
 /* return non zero if error */
 static int tcp_open(URLContext *h, const char *uri, int flags)
 {
@@ -120,6 +143,10 @@ static int tcp_open(URLContext *h, const char *uri, int 
flags)
 av_log(h, AV_LOG_ERROR, "Port missing in uri\n");
 return AVERROR(EINVAL);
 }
+
+if ((ret = lookup_host(h, hostname, sizeof(hostname))) < 0)
+return ret;
+
 p = strchr(uri, '?');
 if (p) {
 if (av_find_info_tag(buf, sizeof(buf), "listen", p)) {
diff --git a/libavformat/version.h b/libavformat/version.h
index 2eb14659d0..d1dbb1e2d1 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
 #define LIBAVFORMAT_VERSION_MINOR  32
-#define LIBAVFORMAT_VERSION_MICRO 105
+#define LIBAVFORMAT_VERSION_MICRO 106
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] lavf/movdec: add position_order option

2019-09-21 Thread Rodger Combs
This allows reading packets linearly, which prevents large numbers of
unnecessary seeks in poorly-interleaved files with consumer software that
handles those cases well on its own.
---
 libavformat/isom.h|  1 +
 libavformat/mov.c | 11 +++
 libavformat/version.h |  2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 69452cae8e..3e29e9877d 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -288,6 +288,7 @@ typedef struct MOVContext {
 int decryption_key_len;
 int enable_drefs;
 int32_t movie_display_matrix[3][3]; ///< display matrix from mvhd
+int position_order;
 } MOVContext;
 
 int ff_mp4_read_descr_len(AVIOContext *pb);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 675b915906..a1559b8a8f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7626,8 +7626,10 @@ static int mov_read_header(AVFormatContext *s)
 
 static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st)
 {
+MOVContext *mov = s->priv_data;
 AVIndexEntry *sample = NULL;
 int64_t best_dts = INT64_MAX;
+int use_pos = mov->position_order || !(s->pb->seekable & 
AVIO_SEEKABLE_NORMAL);
 int i;
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *avst = s->streams[i];
@@ -7636,11 +7638,10 @@ static AVIndexEntry 
*mov_find_next_sample(AVFormatContext *s, AVStream **st)
 AVIndexEntry *current_sample = 
>index_entries[msc->current_sample];
 int64_t dts = av_rescale(current_sample->timestamp, AV_TIME_BASE, 
msc->time_scale);
 av_log(s, AV_LOG_TRACE, "stream %d, sample %d, dts %"PRId64"\n", 
i, msc->current_sample, dts);
-if (!sample || (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && 
current_sample->pos < sample->pos) ||
-((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
- ((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb &&
+if (!sample || (use_pos ? (current_sample->pos < sample->pos) :
+(((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb &&
  ((FFABS(best_dts - dts) <= AV_TIME_BASE && 
current_sample->pos < sample->pos) ||
-  (FFABS(best_dts - dts) > AV_TIME_BASE && dts < 
best_dts)) {
+  (FFABS(best_dts - dts) > AV_TIME_BASE && dts < 
best_dts))) {
 sample = current_sample;
 best_dts = dts;
 *st = avst;
@@ -8017,6 +8018,8 @@ static const AVOption mov_options[] = {
 { "decryption_key", "The media decryption key (hex)", 
OFFSET(decryption_key), AV_OPT_TYPE_BINARY, .flags = AV_OPT_FLAG_DECODING_PARAM 
},
 { "enable_drefs", "Enable external track support.", OFFSET(enable_drefs), 
AV_OPT_TYPE_BOOL,
 {.i64 = 0}, 0, 1, FLAGS },
+{ "position_order", "Read packets in position order (rather than timestamp 
order)",
+OFFSET(position_order), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
 
 { NULL },
 };
diff --git a/libavformat/version.h b/libavformat/version.h
index edfa73fb97..2eb14659d0 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
 #define LIBAVFORMAT_VERSION_MINOR  32
-#define LIBAVFORMAT_VERSION_MICRO 104
+#define LIBAVFORMAT_VERSION_MICRO 105
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: update crop width/height when mapping frames

2019-09-13 Thread Rodger Combs
This happens with any use of the hwmap filter in the derive_device 
configuration with input being HEVC decoded via dxva2 with dimensions that 
aren't 128-pixel-aligned and output being QSV; eg:
ffmpeg.exe -codec:0 hevc -hwaccel:0 dxva2 -hwaccel_output_format:0 dxva2_vld 
test.mkv -filter_complex 
'[0:0]hwmap=derive_device=qsv[0];[0]scale_qsv=format=nv12[1]' -map[1] -codec:0 
h264_qsv output.mkv

> On Sep 12, 2019, at 07:59, Li, Zhong  wrote:
> 
>> From: ffmpeg-devel  On Behalf Of Rodger
>> Combs
>> Sent: Thursday, September 12, 2019 11:59 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: update crop width/height
>> when mapping frames
>> 
>> This fixes an issue where the context could be configured with one 
>> resolution, but
>> incoming frames could have another, and our output AVFrames wouldn't match
>> the underlying surfaces' resolution, which is usually the value that MFX 
>> code uses.
>> 
>> In particular, this would happen when mapping from DXVA2 decoders, since
>> DXVA2 aligns the width/height fields in its context to the required 
>> alignment for
>> the particular codec being used, and those values are then propagated into 
>> the
>> QSV context, rather than the crop dimensions.
>> ---
>> libavutil/hwcontext_qsv.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
>> 8f9838d7d8..fe5a705c19 100644
>> --- a/libavutil/hwcontext_qsv.c
>> +++ b/libavutil/hwcontext_qsv.c
>> @@ -1031,8 +1031,8 @@ static int qsv_map_to(AVHWFramesContext *dst_ctx,
>> if (err)
>> return err;
>> 
>> -dst->width   = src->width;
>> -dst->height  = src->height;
>> +hwctx->surfaces[i].Info.CropW = dst->width  = src->width;
>> +hwctx->surfaces[i].Info.CropH = dst->height = src->height;
>> dst->data[3] = (uint8_t*)>surfaces[i];
>> 
>> return 0;
>> --
>> 2.21.0
> 
> Patch looks good. 
> Could you please share detailed command line and clip to reproduce the issue?
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: update crop width/height when mapping frames

2019-09-11 Thread Rodger Combs
This fixes an issue where the context could be configured with one resolution,
but incoming frames could have another, and our output AVFrames wouldn't match
the underlying surfaces' resolution, which is usually the value that MFX code
uses.

In particular, this would happen when mapping from DXVA2 decoders, since DXVA2
aligns the width/height fields in its context to the required alignment for
the particular codec being used, and those values are then propagated into the
QSV context, rather than the crop dimensions.
---
 libavutil/hwcontext_qsv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 8f9838d7d8..fe5a705c19 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1031,8 +1031,8 @@ static int qsv_map_to(AVHWFramesContext *dst_ctx,
 if (err)
 return err;
 
-dst->width   = src->width;
-dst->height  = src->height;
+hwctx->surfaces[i].Info.CropW = dst->width  = src->width;
+hwctx->surfaces[i].Info.CropH = dst->height = src->height;
 dst->data[3] = (uint8_t*)>surfaces[i];
 
 return 0;
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] lavc/videotoolboxdec: fix crop handling when multithreaded

2019-09-06 Thread Rodger Combs
This was partially fixed by 233cd89, but it made changes to AVFrame fields
from within end_frame, which doesn't work consistently when multithreading
is enabled. This is what the post_process function is for.
---
 libavcodec/videotoolbox.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index c718e82cc5..7948d21bcc 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -91,6 +91,11 @@ static int videotoolbox_postproc_frame(void *avctx, AVFrame 
*frame)
 return AVERROR_EXTERNAL;
 }
 
+frame->crop_right = 0;
+frame->crop_left = 0;
+frame->crop_top = 0;
+frame->crop_bottom = 0;
+
 frame->data[3] = (uint8_t*)ref->pixbuf;
 
 if (ref->hw_frames_ctx) {
@@ -898,11 +903,6 @@ static int videotoolbox_common_end_frame(AVCodecContext 
*avctx, AVFrame *frame)
 AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx);
 VTContext *vtctx = avctx->internal->hwaccel_priv_data;
 
-frame->crop_right = 0;
-frame->crop_left = 0;
-frame->crop_top = 0;
-frame->crop_bottom = 0;
-
 if (vtctx->reconfig_needed == true) {
 vtctx->reconfig_needed = false;
 av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox decoder needs reconfig, 
restarting..\n");
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] lavfi/vf_thumbnail_cuda: fix operator precedence bug

2019-07-30 Thread Rodger Combs
Discovered via a warning when building with clang
---
 libavfilter/vf_thumbnail_cuda.cu | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_thumbnail_cuda.cu b/libavfilter/vf_thumbnail_cuda.cu
index c73e49fbc6..d4d4d791f6 100644
--- a/libavfilter/vf_thumbnail_cuda.cu
+++ b/libavfilter/vf_thumbnail_cuda.cu
@@ -71,7 +71,7 @@ __global__ void Thumbnail_ushort2(cudaTextureObject_t 
ushort2_tex,
 {
 ushort2 pixel = tex2D(ushort2_tex, x, y);
 atomicAdd([(pixel.x + 128) >> 8], 1);
-atomicAdd([256 + (pixel.y + 128) >> 8], 1);
+atomicAdd([256 + ((pixel.y + 128) >> 8)], 1);
 }
 }
 
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] build: add support for building CUDA files with clang

2019-07-30 Thread Rodger Combs
This avoids using the CUDA SDK at all; instead, we provide a minimal
reimplementation of the basic functionality that lavfi actually uses.
It generates very similar code to what NVCC produces.

The header contains no implementation code derived from the SDK.
The function and type declarations are derived from the SDK only to the
extent required to build a compatible implementation. This is generally
accepted to qualify as fair use.

Because this option does not require the proprietary SDK, it does not require
the "--enable-nonfree" flag in configure.
---
 compat/cuda/cuda_runtime.h | 131 +
 configure  |  49 +-
 ffbuild/common.mak |   3 +-
 3 files changed, 166 insertions(+), 17 deletions(-)
 create mode 100644 compat/cuda/cuda_runtime.h

diff --git a/compat/cuda/cuda_runtime.h b/compat/cuda/cuda_runtime.h
new file mode 100644
index 00..dbe50f8711
--- /dev/null
+++ b/compat/cuda/cuda_runtime.h
@@ -0,0 +1,131 @@
+/*
+ * Minimum CUDA compatibility definitions header
+ *
+ * Copyright (c) 2019 Rodger Combs
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AV_COMPAT_CUDA_CUDA_RUNTIME_H
+#define AV_COMPAT_CUDA_CUDA_RUNTIME_H
+
+// Common macros
+#define __global__ __attribute__((global))
+#define __device__ __attribute__((device))
+#define __device_builtin__ __attribute__((device_builtin))
+#define __align__(N) __attribute__((aligned(N)))
+#define __inline__ __inline__ __attribute__((always_inline))
+
+#define max(a, b) ((a) > (b) ? (a) : (b))
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#define abs(x) ((x) < 0 ? -(x) : (x))
+
+#define atomicAdd(a, b) (__atomic_fetch_add(a, b, __ATOMIC_SEQ_CST))
+
+// Basic typedefs
+typedef __device_builtin__ unsigned long long cudaTextureObject_t;
+
+typedef struct __device_builtin__ __align__(2) uchar2
+{
+unsigned char x, y;
+} uchar2;
+
+typedef struct __device_builtin__ __align__(4) ushort2
+{
+unsigned short x, y;
+} ushort2;
+
+typedef struct __device_builtin__ uint3
+{
+unsigned int x, y, z;
+} uint3;
+
+typedef struct uint3 dim3;
+
+typedef struct __device_builtin__ __align__(8) int2
+{
+int x, y;
+} int2;
+
+typedef struct __device_builtin__ __align__(4) uchar4
+{
+unsigned char x, y, z, w;
+} uchar4;
+
+typedef struct __device_builtin__ __align__(8) ushort4
+{
+unsigned char x, y, z, w;
+} ushort4;
+
+typedef struct __device_builtin__ __align__(16) int4
+{
+int x, y, z, w;
+} int4;
+
+// Accessors for special registers
+#define GETCOMP(reg, comp) \
+asm("mov.u32 %0, %%" #reg "." #comp ";" : "=r"(tmp)); \
+ret.comp = tmp;
+
+#define GET(name, reg) static inline __device__ uint3 name() {\
+uint3 ret; \
+unsigned tmp; \
+GETCOMP(reg, x) \
+GETCOMP(reg, y) \
+GETCOMP(reg, z) \
+return ret; \
+}
+
+GET(getBlockIdx, ctaid)
+GET(getBlockDim, ntid)
+GET(getThreadIdx, tid)
+
+// Instead of externs for these registers, we turn access to them into calls 
into trivial ASM
+#define blockIdx (getBlockIdx())
+#define blockDim (getBlockDim())
+#define threadIdx (getThreadIdx())
+
+// Basic initializers (simple macros rather than inline functions)
+#define make_uchar2(a, b) ((uchar2){.x = a, .y = b})
+#define make_ushort2(a, b) ((ushort2){.x = a, .y = b})
+#define make_uchar4(a, b, c, d) ((uchar4){.x = a, .y = b, .z = c, .w = d})
+#define make_ushort4(a, b, c, d) ((ushort4){.x = a, .y = b, .z = c, .w = d})
+
+// Conversions from the tex instruction's 4-register output to various types
+#define TEX2D(type, ret) static inline __device__ void conv(type* out, 
unsigned a, unsigned b, unsigned c, unsigned d) {*out = (ret);}
+
+TEX2D(unsigned char, a & 0xFF)
+TEX2D(unsigned short, a & 0x)
+TEX2D(uchar2, make_uchar2(a & 0xFF, b & 0xFF))
+TEX2D(ushort2, make_ushort2(a & 0x, b & 0x))
+TEX2D(uchar4, make_uchar4(a & 0xFF, b & 0xFF, c & 0xFF, d & 0xFF))
+TEX2D(ushort4, make_ushort4(a & 0x, b & 0x, c & 0x, d & 0x))
+
+// Template calling tex instruction and converting the output to the selected 
type
+template 
+static inline __device__ T tex2D(cudaTextureObject_t texObject, float x, 

[FFmpeg-devel] [PATCH 2/6] lavf/tls_apple: factor loading SecItemIdentity into its own (Mac-only) function

2019-06-11 Thread Rodger Combs
This allows us to easily reuse this function with NWF
---
 libavformat/tls_apple.c | 34 +-
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/libavformat/tls_apple.c b/libavformat/tls_apple.c
index 37380541b1..2ff6622565 100644
--- a/libavformat/tls_apple.c
+++ b/libavformat/tls_apple.c
@@ -150,28 +150,46 @@ end:
 return ret;
 }
 
-static int load_cert(URLContext *h)
+static int load_identity(URLContext *h, SecIdentityRef *identity, CFArrayRef 
*certArray)
 {
+#if !HAVE_SECITEMIMPORT
+return AVERROR_PATCHWELCOME;
+#else
 TLSContext *c = h->priv_data;
 int ret = 0;
-CFArrayRef certArray = NULL;
 CFArrayRef keyArray = NULL;
-SecIdentityRef id = NULL;
-CFMutableArrayRef outArray = NULL;
 
-if ((ret = import_pem(h, c->tls_shared.cert_file, )) < 0)
+if ((ret = import_pem(h, c->tls_shared.cert_file, certArray)) < 0)
 goto end;
 
 if ((ret = import_pem(h, c->tls_shared.key_file, )) < 0)
 goto end;
 
-if (!(id = SecIdentityCreate(kCFAllocatorDefault,
- 
(SecCertificateRef)CFArrayGetValueAtIndex(certArray, 0),
+if (!(*identity = SecIdentityCreate(kCFAllocatorDefault,
+ 
(SecCertificateRef)CFArrayGetValueAtIndex(*certArray, 0),
  (SecKeyRef)CFArrayGetValueAtIndex(keyArray, 
0 {
 ret = AVERROR_UNKNOWN;
 goto end;
 }
 
+end:
+if (keyArray)
+CFRelease(keyArray);
+return ret;
+#endif
+}
+
+static int load_cert(URLContext *h)
+{
+TLSContext *c = h->priv_data;
+int ret = 0;
+SecIdentityRef id = NULL;
+CFArrayRef certArray = NULL;
+CFMutableArrayRef outArray = NULL;
+
+if ((ret = load_identity(h, , )) < 0)
+goto end;
+
 if (!(outArray = CFArrayCreateMutableCopy(kCFAllocatorDefault, 0, 
certArray))) {
 ret = AVERROR(ENOMEM);
 goto end;
@@ -184,8 +202,6 @@ static int load_cert(URLContext *h)
 end:
 if (certArray)
 CFRelease(certArray);
-if (keyArray)
-CFRelease(keyArray);
 if (outArray)
 CFRelease(outArray);
 if (id)
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 5/6] lavf/tls: factor ff_tls_process_underlying into its own function

2019-06-11 Thread Rodger Combs
---
 libavformat/tls.c | 45 +++--
 libavformat/tls.h |  1 +
 2 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/libavformat/tls.c b/libavformat/tls.c
index 10e0792e29..ccd551061d 100644
--- a/libavformat/tls.c
+++ b/libavformat/tls.c
@@ -51,6 +51,29 @@ static void set_options(TLSShared *c, const char *uri)
 
 if (!c->key_file && av_find_info_tag(buf, sizeof(buf), "key", p))
 c->key_file = av_strdup(buf);
+
+if (av_find_info_tag(buf, sizeof(buf), "listen", p))
+c->listen = 1;
+}
+
+int ff_tls_process_underlying(TLSShared *c, URLContext *parent, const char 
*uri, int *port)
+{
+struct addrinfo hints = { 0 }, *ai = NULL;
+
+set_options(c, uri);
+
+av_url_split(NULL, 0, NULL, 0, c->underlying_host, 
sizeof(c->underlying_host), port, NULL, 0, uri);
+
+hints.ai_flags = AI_NUMERICHOST;
+if (!getaddrinfo(c->underlying_host, NULL, , )) {
+c->numerichost = 1;
+freeaddrinfo(ai);
+}
+
+if (!c->host && !(c->host = av_strdup(c->underlying_host)))
+return AVERROR(ENOMEM);
+
+  return 0;
 }
 
 int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, 
AVDictionary **options)
@@ -58,37 +81,23 @@ int ff_tls_open_underlying(TLSShared *c, URLContext 
*parent, const char *uri, AV
 int port;
 const char *p;
 char buf[200], opts[50] = "";
-struct addrinfo hints = { 0 }, *ai = NULL;
 const char *proxy_path;
 int use_proxy;
+int ret;
 
-set_options(c, uri);
+if ((ret = ff_tls_process_underlying(c, parent, uri, )) < 0)
+return ret;
 
 if (c->listen)
 snprintf(opts, sizeof(opts), "?listen=1");
 
-av_url_split(NULL, 0, NULL, 0, c->underlying_host, 
sizeof(c->underlying_host), , NULL, 0, uri);
-
 p = strchr(uri, '?');
 
-if (!p) {
+if (!p)
 p = opts;
-} else {
-if (av_find_info_tag(opts, sizeof(opts), "listen", p))
-c->listen = 1;
-}
 
 ff_url_join(buf, sizeof(buf), "tcp", NULL, c->underlying_host, port, "%s", 
p);
 
-hints.ai_flags = AI_NUMERICHOST;
-if (!getaddrinfo(c->underlying_host, NULL, , )) {
-c->numerichost = 1;
-freeaddrinfo(ai);
-}
-
-if (!c->host && !(c->host = av_strdup(c->underlying_host)))
-return AVERROR(ENOMEM);
-
 proxy_path = getenv("http_proxy");
 use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), 
c->underlying_host) &&
 proxy_path && av_strstart(proxy_path, "http://;, NULL);
diff --git a/libavformat/tls.h b/libavformat/tls.h
index beb19d6d55..a954f51733 100644
--- a/libavformat/tls.h
+++ b/libavformat/tls.h
@@ -51,6 +51,7 @@ typedef struct TLSShared {
 {"listen", "Listen for incoming connections", offsetof(pstruct, 
options_field . listen),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = 
TLS_OPTFL }, \
 {"verifyhost", "Verify against a specific hostname",  offsetof(pstruct, 
options_field . host),  AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }
 
+int ff_tls_process_underlying(TLSShared *c, URLContext *parent, const char 
*uri, int *port);
 int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, 
AVDictionary **options);
 
 void ff_gnutls_init(void);
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/6] lavf/tls_apple: fix crash on unexpected PEM types

2019-06-11 Thread Rodger Combs
---
 libavformat/tls_apple.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/tls_apple.c b/libavformat/tls_apple.c
index 2ff6622565..37d63f3b27 100644
--- a/libavformat/tls_apple.c
+++ b/libavformat/tls_apple.c
@@ -165,6 +165,12 @@ static int load_identity(URLContext *h, SecIdentityRef 
*identity, CFArrayRef *ce
 if ((ret = import_pem(h, c->tls_shared.key_file, )) < 0)
 goto end;
 
+if (CFGetTypeID(CFArrayGetValueAtIndex(*certArray, 0)) != 
SecCertificateGetTypeID() ||
+CFGetTypeID(CFArrayGetValueAtIndex(keyArray, 0)) != SecKeyGetTypeID()) 
{
+ret = AVERROR_INVALIDDATA;
+goto end;
+}
+
 if (!(*identity = SecIdentityCreate(kCFAllocatorDefault,
  
(SecCertificateRef)CFArrayGetValueAtIndex(*certArray, 0),
  (SecKeyRef)CFArrayGetValueAtIndex(keyArray, 
0 {
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 6/6] lavf/tls_apple: add support for the new Network framework

2019-06-11 Thread Rodger Combs
Network.framework was added in macOS 10.14/iOS 12, replacing Secure Transport.
Its TLS functionality is (currently) implemented on top of BoringSSL.
Secure Transport is deprecated as of macOS 10.15/iOS 13. It'll likely remain
available for the forseeable future, but it's considered "legacy" and won't
receive new features; most significantly, TLS 1.3. Network.framework also adds
additional functionality (like multipath TCP) that ffmpeg may eventually want
to support.

The new code is behind compile-time checks for header availability, as well
as runtime checks for OS version. The framework is linked weakly, so ffmpeg
built with Network.framework support will continue to work normally on OS
versions prior to macOS 10.14/iOS 12, with the Secure Transport code path
being taken.

Currently, it's not possible to build tls_apple without support for Secure
Transport. I'm not sure if that's a useful case currently, though I suppose
if its headers are ever removed then we'll need to add some compile-time
conditionals.
---
 configure   |  11 +-
 libavformat/Makefile|   1 +
 libavformat/tls_apple.c | 401 +++-
 3 files changed, 404 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 32fc26356c..81be23a54f 100755
--- a/configure
+++ b/configure
@@ -301,6 +301,8 @@ External library support:
   --enable-mbedtls enable mbedTLS, needed for https support
if openssl, gnutls or libtls is not used [no]
   --enable-mediacodec  enable Android MediaCodec support [no]
+  --disable-nwfdisable Apple Network.framework, needed for TLS 
support
+   on macOS if openssl and gnutls are not used 
[autodetect]
   --enable-libmysofa   enable libmysofa, needed for sofalizer filter [no]
   --enable-openal  enable OpenAL 1.1 capture support [no]
   --enable-opencl  enable OpenCL processing [no]
@@ -1693,6 +1695,7 @@ EXTERNAL_AUTODETECT_LIBRARY_LIST="
 libxcb_shape
 libxcb_xfixes
 lzma
+nwf
 schannel
 sdl2
 securetransport
@@ -3357,6 +3360,7 @@ https_protocol_suggest="zlib"
 icecast_protocol_select="http_protocol"
 mmsh_protocol_select="http_protocol"
 mmst_protocol_select="network"
+nwf_conflict="openssl gnutls libtls mbedtls"
 rtmp_protocol_conflict="librtmp_protocol"
 rtmp_protocol_select="tcp_protocol"
 rtmp_protocol_suggest="zlib"
@@ -3378,7 +3382,7 @@ sctp_protocol_select="network"
 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 mbedtls"
+tls_protocol_deps_any="gnutls nwf openssl schannel securetransport libtls 
mbedtls"
 tls_protocol_select="tcp_protocol"
 udp_protocol_select="network"
 udplite_protocol_select="network"
@@ -6353,8 +6357,11 @@ if enabled decklink; then
 esac
 fi
 
+enabled nwf &&
+check_lib nwf "Network/Network.h" "nw_connection_create" 
"-Wl,-framework,CoreFoundation -Wl,-framework,Security 
-Wl,-weak_framework,Network" ||
+disable nwf
+
 enabled securetransport &&
-check_func SecIdentityCreate "-Wl,-framework,CoreFoundation 
-Wl,-framework,Security" &&
 check_lib securetransport "Security/SecureTransport.h Security/Security.h" 
"SSLCreateContext" "-Wl,-framework,CoreFoundation -Wl,-framework,Security" ||
 disable securetransport
 
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 358d4abf49..fdf981bedc 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -613,6 +613,7 @@ OBJS-$(CONFIG_TCP_PROTOCOL)  += tcp.o
 TLS-OBJS-$(CONFIG_GNUTLS)+= tls_gnutls.o
 TLS-OBJS-$(CONFIG_LIBTLS)+= tls_libtls.o
 TLS-OBJS-$(CONFIG_MBEDTLS)   += tls_mbedtls.o
+TLS-OBJS-$(CONFIG_NWF)   += tls_apple.o
 TLS-OBJS-$(CONFIG_OPENSSL)   += tls_openssl.o
 TLS-OBJS-$(CONFIG_SECURETRANSPORT)   += tls_apple.o
 TLS-OBJS-$(CONFIG_SCHANNEL)  += tls_schannel.o
diff --git a/libavformat/tls_apple.c b/libavformat/tls_apple.c
index 23042eb8ee..dd202eb9c0 100644
--- a/libavformat/tls_apple.c
+++ b/libavformat/tls_apple.c
@@ -19,7 +19,7 @@
  */
 
 #include 
-
+#include 
 
 #include "avformat.h"
 #include "avio_internal.h"
@@ -37,18 +37,88 @@
 #include 
 #include 
 
+#if CONFIG_NWF
+#include 
+#endif
+
 // We use a private API call here; it's good enough for WebKit.
 SecIdentityRef __attribute__((weak)) SecIdentityCreate(CFAllocatorRef 
allocator, SecCertificateRef certificate, SecKeyRef privateKey);
 #define ioErr -36
 
+#define NWF_CHECK __builtin_available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 
12.0, *)
+
 typedef struct TLSContext {
 const AVClass *class;
 TLSShared tls_shared;
 SSLContextRef ssl_context;
 CFArrayRef ca_array;
 int lastErr;
+#if CONFIG_NWF
+nw_connection_t nw_conn;
+dispatch_semaphore_t semaphore;
+

[FFmpeg-devel] [PATCH 4/6] lavf/tls_apple: link to SecIdentityCreate weakly

2019-06-11 Thread Rodger Combs
This is a private API, so it might go away in a future macOS version.
Linking to it weakly means that if it does, we won't crash during symbol lookup.
---
 libavformat/tls_apple.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/tls_apple.c b/libavformat/tls_apple.c
index 37d63f3b27..23042eb8ee 100644
--- a/libavformat/tls_apple.c
+++ b/libavformat/tls_apple.c
@@ -38,7 +38,7 @@
 #include 
 
 // We use a private API call here; it's good enough for WebKit.
-SecIdentityRef SecIdentityCreate(CFAllocatorRef allocator, SecCertificateRef 
certificate, SecKeyRef privateKey);
+SecIdentityRef __attribute__((weak)) SecIdentityCreate(CFAllocatorRef 
allocator, SecCertificateRef certificate, SecKeyRef privateKey);
 #define ioErr -36
 
 typedef struct TLSContext {
@@ -165,6 +165,11 @@ static int load_identity(URLContext *h, SecIdentityRef 
*identity, CFArrayRef *ce
 if ((ret = import_pem(h, c->tls_shared.key_file, )) < 0)
 goto end;
 
+if (!SecIdentityCreate) {
+ret = AVERROR_PATCHWELCOME;
+goto end;
+}
+
 if (CFGetTypeID(CFArrayGetValueAtIndex(*certArray, 0)) != 
SecCertificateGetTypeID() ||
 CFGetTypeID(CFArrayGetValueAtIndex(keyArray, 0)) != SecKeyGetTypeID()) 
{
 ret = AVERROR_INVALIDDATA;
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/6] lavf: rename tls_securetransport to tls_apple

2019-06-11 Thread Rodger Combs
---
 libavformat/Makefile   | 2 +-
 libavformat/{tls_securetransport.c => tls_apple.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename libavformat/{tls_securetransport.c => tls_apple.c} (100%)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index df87c54a58..358d4abf49 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -614,7 +614,7 @@ TLS-OBJS-$(CONFIG_GNUTLS)+= tls_gnutls.o
 TLS-OBJS-$(CONFIG_LIBTLS)+= tls_libtls.o
 TLS-OBJS-$(CONFIG_MBEDTLS)   += tls_mbedtls.o
 TLS-OBJS-$(CONFIG_OPENSSL)   += tls_openssl.o
-TLS-OBJS-$(CONFIG_SECURETRANSPORT)   += tls_securetransport.o
+TLS-OBJS-$(CONFIG_SECURETRANSPORT)   += tls_apple.o
 TLS-OBJS-$(CONFIG_SCHANNEL)  += tls_schannel.o
 OBJS-$(CONFIG_TLS_PROTOCOL)  += tls.o $(TLS-OBJS-yes)
 OBJS-$(CONFIG_UDP_PROTOCOL)  += udp.o ip.o
diff --git a/libavformat/tls_securetransport.c b/libavformat/tls_apple.c
similarity index 100%
rename from libavformat/tls_securetransport.c
rename to libavformat/tls_apple.c
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] lavf/mp3dec: increase probe score of buffers entirely composed of valid packets

2019-03-16 Thread Rodger Combs
Fixes some files misdetecting as MPEG PS
---
 libavformat/mp3dec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index ef884934e1..81da0c6090 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -100,13 +100,13 @@ static int mp3_read_probe(AVProbeData *p)
 max_framesizes = FFMAX(max_framesizes, framesizes);
 if(buf == buf0) {
 first_frames= frames;
-if (buf2 == end + sizeof(uint32_t))
+if (buf2 >= end + sizeof(uint32_t))
 whole_used = 1;
 }
 }
 // keep this in sync with ac3 probe, both need to avoid
 // issues with MPEG-files!
-if   (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1;
+if   (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1 + whole_used * 
FFMIN(first_frames / 2, 5);
 else if(max_frames>200 && p->buf_size < 2*max_framesizes)return 
AVPROBE_SCORE_EXTENSION;
 else if(max_frames>=4 && p->buf_size < 2*max_framesizes) return 
AVPROBE_SCORE_EXTENSION / 2;
 else if(ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC) && 
2*ff_id3v2_tag_len(buf0) >= p->buf_size)
-- 
2.20.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] lavf/movdec: use a more appropriate error code for bad trun atoms

2019-03-16 Thread Rodger Combs
---
 libavformat/mov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 0dfee2e7c4..9ed109962f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4785,7 +4785,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n");
 }
 if (entries <= 0)
-return -1;
+return AVERROR_INVALIDDATA;
 
 requested_size = (st->nb_index_entries + entries) * sizeof(AVIndexEntry);
 new_entries = av_fast_realloc(st->index_entries,
-- 
2.20.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] lavf/movdec: fix demuxing files with 0-entry trun atoms

2019-03-16 Thread Rodger Combs
Regressed in 4a9d32baca3af0d1831f9556a922c7ab5b426b10
---
 libavformat/mov.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a7d444b0ee..0dfee2e7c4 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4739,6 +4739,8 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 flags = avio_rb24(pb);
 entries = avio_rb32(pb);
 av_log(c->fc, AV_LOG_TRACE, "flags 0x%x entries %u\n", flags, entries);
+if (entries == 0)
+return 0;
 
 if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data))
 return AVERROR_INVALIDDATA;
-- 
2.20.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/hlsdec: fix support for large initialization segments

2019-02-28 Thread Rodger Combs
---
 libavformat/hls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index fc9110356d..c56ead507b 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1553,7 +1553,7 @@ reload:
 if (v->init_sec_buf_read_offset < v->init_sec_data_len) {
 /* Push init section out first before first actual segment */
 int copy_size = FFMIN(v->init_sec_data_len - 
v->init_sec_buf_read_offset, buf_size);
-memcpy(buf, v->init_sec_buf, copy_size);
+memcpy(buf, v->init_sec_buf + v->init_sec_buf_read_offset, copy_size);
 v->init_sec_buf_read_offset += copy_size;
 return copy_size;
 }
-- 
2.20.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/3] tests/checkasm: add vf_yadif tests

2019-01-22 Thread Rodger Combs
---
 libavfilter/vf_yadif.c|  23 ---
 libavfilter/yadif.h   |   2 +
 tests/checkasm/Makefile   |   1 +
 tests/checkasm/checkasm.c |   3 +
 tests/checkasm/checkasm.h |   1 +
 tests/checkasm/vf_yadif.c | 137 ++
 6 files changed, 158 insertions(+), 9 deletions(-)
 create mode 100644 tests/checkasm/vf_yadif.c

diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
index 3107924932..575b5a421e 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -311,6 +311,19 @@ static int query_formats(AVFilterContext *ctx)
 return ff_set_common_formats(ctx, fmts_list);
 }
 
+void ff_yadif_init(YADIFContext *s) {
+if (s->csp->comp[0].depth > 8) {
+s->filter_line  = filter_line_c_16bit;
+s->filter_edges = filter_edges_16bit;
+} else {
+s->filter_line  = filter_line_c;
+s->filter_edges = filter_edges;
+}
+
+if (ARCH_X86)
+ff_yadif_init_x86(s);
+}
+
 static int config_props(AVFilterLink *link)
 {
 AVFilterContext *ctx = link->src;
@@ -332,16 +345,8 @@ static int config_props(AVFilterLink *link)
 
 s->csp = av_pix_fmt_desc_get(link->format);
 s->filter = filter;
-if (s->csp->comp[0].depth > 8) {
-s->filter_line  = filter_line_c_16bit;
-s->filter_edges = filter_edges_16bit;
-} else {
-s->filter_line  = filter_line_c;
-s->filter_edges = filter_edges;
-}
 
-if (ARCH_X86)
-ff_yadif_init_x86(s);
+ff_yadif_init(s);
 
 return 0;
 }
diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h
index c928911b35..aa0ae744f2 100644
--- a/libavfilter/yadif.h
+++ b/libavfilter/yadif.h
@@ -86,6 +86,8 @@ typedef struct YADIFContext {
 int current_field;  ///< YADIFCurrentField
 } YADIFContext;
 
+void ff_yadif_init(YADIFContext *s);
+
 void ff_yadif_init_x86(YADIFContext *yadif);
 
 int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame);
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 47b7b06d28..eb1ac06151 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -37,6 +37,7 @@ AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o
 AVFILTEROBJS-$(CONFIG_HFLIP_FILTER)  += vf_hflip.o
 AVFILTEROBJS-$(CONFIG_THRESHOLD_FILTER)  += vf_threshold.o
 AVFILTEROBJS-$(CONFIG_NLMEANS_FILTER)+= vf_nlmeans.o
+AVFILTEROBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o
 
 CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes)
 
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index c3f5160132..23cdcb27ae 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -168,6 +168,9 @@ static const struct {
 #if CONFIG_THRESHOLD_FILTER
 { "vf_threshold", checkasm_check_vf_threshold },
 #endif
+#if CONFIG_YADIF_FILTER
+{ "vf_yadif", checkasm_check_vf_yadif },
+#endif
 #endif
 #if CONFIG_SWSCALE
 { "sw_rgb", checkasm_check_sw_rgb },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 9e8e879fd3..a5c593e7b9 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -72,6 +72,7 @@ void checkasm_check_utvideodsp(void);
 void checkasm_check_v210enc(void);
 void checkasm_check_vf_hflip(void);
 void checkasm_check_vf_threshold(void);
+void checkasm_check_vf_yadif(void);
 void checkasm_check_vp8dsp(void);
 void checkasm_check_vp9dsp(void);
 void checkasm_check_videodsp(void);
diff --git a/tests/checkasm/vf_yadif.c b/tests/checkasm/vf_yadif.c
new file mode 100644
index 00..d011a2771d
--- /dev/null
+++ b/tests/checkasm/vf_yadif.c
@@ -0,0 +1,137 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 "checkasm.h"
+#include "libavfilter/yadif.h"
+#include "libavutil/intreadwrite.h"
+
+#define WIDTH 64
+#define HEIGHT 4
+#define SIZE WIDTH * HEIGHT + 32
+
+#define randomize_buffers(buf, size)  \
+do {  \
+int j;\
+uint8_t *tmp_buf = (uint8_t*)buf; \
+for (j = 0; j < size; j++)\
+tmp_buf[j] = rnd() & 0xFF;\
+} while (0)
+
+#define randomize_buffers_10(buf, size)\
+do {   \
+int j; \
+uint16_t *tmp_buf = 

[FFmpeg-devel] [PATCH 2/3] FATE/filter-video: fix high-bit-depth yadif tests

2019-01-22 Thread Rodger Combs
These previously upconverted the video _after_ applying the filter, so they
didn't actually test the high-bit-depth code paths at all, which is why the
PMINSD issue in the previous commit wasn't caught. I also added variants with
the spatial check enabled and disabled, so both of those paths are tested (as
with the 8-bit path).

The chroma upconversion to 4:4:4 is deliberate; the upscale results in some
non-multiple-of-4 input values in the 10-bit case, and non-multiple-of-256
values in the 16-bit case, so that the tests would catch problems resulting in
lossy output in the low bits.
---
 tests/fate/filter-video.mak | 10 -
 tests/ref/fate/filter-yadif10   | 60 -
 tests/ref/fate/filter-yadif10-nospatial | 35 +++
 tests/ref/fate/filter-yadif16   | 60 -
 tests/ref/fate/filter-yadif16-nospatial | 35 +++
 5 files changed, 138 insertions(+), 62 deletions(-)
 create mode 100644 tests/ref/fate/filter-yadif10-nospatial
 create mode 100644 tests/ref/fate/filter-yadif16-nospatial

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 1042e96e54..a71ad318b1 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -15,10 +15,16 @@ FATE_YADIF += fate-filter-yadif-mode1
 fate-filter-yadif-mode1: CMD = framecrc -flags bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -frames:v 59 -vf yadif=1
 
 FATE_YADIF += fate-filter-yadif10
-fate-filter-yadif10: CMD = framecrc -flags bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -flags bitexact -pix_fmt 
yuv420p10le -frames:v 30 -vf yadif=0
+fate-filter-yadif10: CMD = framecrc -flags bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -flags bitexact -frames:v 30 
-vf format=pix_fmts=yuv444p10,yadif=send_frame
+
+FATE_YADIF += fate-filter-yadif10-nospatial
+fate-filter-yadif10-nospatial: CMD = framecrc -flags bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -flags bitexact -frames:v 30 
-vf format=pix_fmts=yuv444p10,yadif=send_frame_nospatial
 
 FATE_YADIF += fate-filter-yadif16
-fate-filter-yadif16: CMD = framecrc -flags bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -flags bitexact -pix_fmt 
yuv420p16le -frames:v 30 -vf yadif=0
+fate-filter-yadif16: CMD = framecrc -flags bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -flags bitexact -frames:v 30 
-vf format=pix_fmts=yuv444p16,yadif=send_frame
+
+FATE_YADIF += fate-filter-yadif16-nospatial
+fate-filter-yadif16-nospatial: CMD = framecrc -flags bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -flags bitexact -frames:v 30 
-vf format=pix_fmts=yuv444p16,yadif=send_frame_nospatial
 
 FATE_FILTER_SAMPLES-$(call FILTERDEMDEC, YADIF, MPEGTS, MPEG2VIDEO) += 
$(FATE_YADIF)
 
diff --git a/tests/ref/fate/filter-yadif10 b/tests/ref/fate/filter-yadif10
index 28e799fc1f..fe59198a28 100644
--- a/tests/ref/fate/filter-yadif10
+++ b/tests/ref/fate/filter-yadif10
@@ -3,33 +3,33 @@
 #codec_id 0: rawvideo
 #dimensions 0: 720x576
 #sar 0: 16/15
-0,  9,  9,1,  1244160, 0xe0c2231b
-0, 10, 10,1,  1244160, 0xdc7caa43
-0, 11, 11,1,  1244160, 0x52c4dfbf
-0, 12, 12,1,  1244160, 0x7c577f07
-0, 13, 13,1,  1244160, 0x5b6ad7ce
-0, 14, 14,1,  1244160, 0x6f15ce76
-0, 15, 15,1,  1244160, 0xf120034a
-0, 16, 16,1,  1244160, 0x9c65ba64
-0, 17, 17,1,  1244160, 0x883b237e
-0, 18, 18,1,  1244160, 0xb8292e0d
-0, 19, 19,1,  1244160, 0xbc392721
-0, 20, 20,1,  1244160, 0x7cd82ec9
-0, 21, 21,1,  1244160, 0x167325eb
-0, 22, 22,1,  1244160, 0x49bafa73
-0, 23, 23,1,  1244160, 0xe1ff6dbf
-0, 24, 24,1,  1244160, 0x85f710b6
-0, 25, 25,1,  1244160, 0xd1fd4cdb
-0, 26, 26,1,  1244160, 0xafee03c5
-0, 27, 27,1,  1244160, 0x566be070
-0, 28, 28,1,  1244160, 0xb6abbd01
-0, 29, 29,1,  1244160, 0xa98f38fd
-0, 30, 30,1,  1244160, 0x00f4736b
-0, 31, 31,1,  1244160, 0x6b0f9dd2
-0, 32, 32,1,  1244160, 0x15810b92
-0, 33, 33,1,  1244160, 0x0b516465
-0, 34, 34,1,  1244160, 0x927d15e6
-0, 35, 35,1,  1244160, 0xd102f2bf
-0, 36, 36,1,  1244160, 0xdd8b3b20
-0, 37, 37,1,  1244160, 0x229ac529
-0, 38, 38,1,  1244160, 0xf844e0a2
+0,  9,  9,1,  2488320, 

[FFmpeg-devel] [PATCH 1/3] lavu/x86util: make imprecise PMINSD implementation opt-in

2019-01-22 Thread Rodger Combs
This caused rounding errors when values that can't be expressed exactly as
32-bit floats were passed in, which could happen in 16-bit yadif

swscale's call is opted in, under the assumption that it never uses values
large enough to run into this (i.e. within 2^24)
---
 libavutil/x86/x86util.asm | 4 ++--
 libswscale/x86/scale.asm  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavutil/x86/x86util.asm b/libavutil/x86/x86util.asm
index d7cd996842..c96afb6ef1 100644
--- a/libavutil/x86/x86util.asm
+++ b/libavutil/x86/x86util.asm
@@ -799,10 +799,10 @@
 pminsw %1, %3
 %endmacro
 
-%macro PMINSD 3 ; dst, src, tmp/unused
+%macro PMINSD 3-4 ; dst, src, tmp/unused, rounding-allowed
 %if cpuflag(sse4)
 pminsd%1, %2
-%elif cpuflag(sse2)
+%elif cpuflag(sse2) && (%0 > 3)
 cvtdq2ps  %1, %1
 minps %1, %2
 cvtps2dq  %1, %1
diff --git a/libswscale/x86/scale.asm b/libswscale/x86/scale.asm
index 83cabff722..914fd1ada4 100644
--- a/libswscale/x86/scale.asm
+++ b/libswscale/x86/scale.asm
@@ -364,7 +364,7 @@ cglobal hscale%1to%2_%4, %5, 10, %6, pos0, dst, w, srcmem, 
filter, fltpos, fltsi
 movd [dstq+wq*2], m0
 %endif ; %3 ==/!= X
 %else ; %2 == 19
-PMINSDm0, m2, m4
+PMINSDm0, m2, m4, 1
 %ifnidn %3, X
 mova [dstq+wq*(4>>wshr)], m0
 %else ; %3 == X
-- 
2.19.1

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


Re: [FFmpeg-devel] [PATCH 5/5] lavf/tls: enable server verification by default when not on mbedtls

2019-01-18 Thread Rodger Combs


> On Jan 18, 2019, at 05:41, Carl Eugen Hoyos  wrote:
> 
> 2019-01-18 9:46 GMT+01:00, Rodger Combs :
>> All other TLS wrappers now have a mechanism to load a system trust store
>> by default, without setting the cafile option. For Secure Transport and
>> Secure Channel, it's the OS. For OpenSSL and libtls, it's a path set at
>> compile-time. For GNUTLS, it's either a path set at compile-time, or the
>> OS trust store (if on macOS, iOS, or Windows). It's possible to configure
>> OpenSSL, GNUTLS, and libtls without a working trust store, but these are
>> broken configurations and I don't have a problem with requiring users with
>> that kind of install to either fix it, or explicitly opt in to insecure
>> behavior. mbedtls doesn't have a default trust store (it's assumed that the
>> application will provide one), so it continues to require the user to pass
>> in a path and enable verification manually.
> 
> I believe the current behaviour is more desirable as default for a multimedia
> library.

That's patent nonsense. Requests for media are as likely to contain 
authentication tokens as anything else today, and users have as much of a right 
to privacy in the specific media they consume as in anything else they use 
online. Without any verification of peer certificates, our current defaults are 
little better than using plaintext.

> 
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 4/5] lavf/tls: apply numerichost check to verifyhost

2019-01-18 Thread Rodger Combs
---
 libavformat/tls.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/tls.c b/libavformat/tls.c
index 10e0792e29..a6dcd3cc96 100644
--- a/libavformat/tls.c
+++ b/libavformat/tls.c
@@ -80,15 +80,15 @@ int ff_tls_open_underlying(TLSShared *c, URLContext 
*parent, const char *uri, AV
 
 ff_url_join(buf, sizeof(buf), "tcp", NULL, c->underlying_host, port, "%s", 
p);
 
+if (!c->host && !(c->host = av_strdup(c->underlying_host)))
+return AVERROR(ENOMEM);
+
 hints.ai_flags = AI_NUMERICHOST;
-if (!getaddrinfo(c->underlying_host, NULL, , )) {
+if (!getaddrinfo(c->host, NULL, , )) {
 c->numerichost = 1;
 freeaddrinfo(ai);
 }
 
-if (!c->host && !(c->host = av_strdup(c->underlying_host)))
-return AVERROR(ENOMEM);
-
 proxy_path = getenv("http_proxy");
 use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), 
c->underlying_host) &&
 proxy_path && av_strstart(proxy_path, "http://;, NULL);
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 5/5] lavf/tls: enable server verification by default when not on mbedtls

2019-01-18 Thread Rodger Combs
All other TLS wrappers now have a mechanism to load a system trust store
by default, without setting the cafile option. For Secure Transport and
Secure Channel, it's the OS. For OpenSSL and libtls, it's a path set at
compile-time. For GNUTLS, it's either a path set at compile-time, or the
OS trust store (if on macOS, iOS, or Windows). It's possible to configure
OpenSSL, GNUTLS, and libtls without a working trust store, but these are
broken configurations and I don't have a problem with requiring users with
that kind of install to either fix it, or explicitly opt in to insecure
behavior. mbedtls doesn't have a default trust store (it's assumed that the
application will provide one), so it continues to require the user to pass
in a path and enable verification manually.
---
 libavformat/tls.c | 3 +++
 libavformat/tls.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/tls.c b/libavformat/tls.c
index a6dcd3cc96..c564b1252b 100644
--- a/libavformat/tls.c
+++ b/libavformat/tls.c
@@ -62,6 +62,9 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, 
const char *uri, AV
 const char *proxy_path;
 int use_proxy;
 
+if (c->verify == -1)
+c->verify = !c->listen && !CONFIG_MBEDTLS;
+
 set_options(c, uri);
 
 if (c->listen)
diff --git a/libavformat/tls.h b/libavformat/tls.h
index beb19d6d55..bc4ee1c216 100644
--- a/libavformat/tls.h
+++ b/libavformat/tls.h
@@ -45,7 +45,7 @@ typedef struct TLSShared {
 #define TLS_COMMON_OPTIONS(pstruct, options_field) \
 {"ca_file","Certificate Authority database file", offsetof(pstruct, 
options_field . ca_file),   AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
 {"cafile", "Certificate Authority database file", offsetof(pstruct, 
options_field . ca_file),   AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
-{"tls_verify", "Verify the peer certificate", offsetof(pstruct, 
options_field . verify),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = 
TLS_OPTFL }, \
+{"tls_verify", "Verify the peer certificate", offsetof(pstruct, 
options_field . verify),AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, .flags = 
TLS_OPTFL }, \
 {"cert_file",  "Certificate file",offsetof(pstruct, 
options_field . cert_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
 {"key_file",   "Private key file",offsetof(pstruct, 
options_field . key_file),  AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
 {"listen", "Listen for incoming connections", offsetof(pstruct, 
options_field . listen),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = 
TLS_OPTFL }, \
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 3/5] lavf/tls_openssl: on 1.1 or later, verify the server's hostname

2019-01-18 Thread Rodger Combs
---
 libavformat/tls_openssl.c | 22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index ae3fd6e236..ba233c0229 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int openssl_init;
 
@@ -269,8 +270,6 @@ static int tls_open(URLContext *h, const char *uri, int 
flags, AVDictionary **op
 ret = AVERROR(EIO);
 goto fail;
 }
-// Note, this doesn't check that the peer certificate actually matches
-// the requested hostname.
 if (c->verify)
 SSL_CTX_set_verify(p->ctx, 
SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
 p->ssl = SSL_new(p->ctx);
@@ -294,8 +293,23 @@ static int tls_open(URLContext *h, const char *uri, int 
flags, AVDictionary **op
 bio->ptr = c->tcp;
 #endif
 SSL_set_bio(p->ssl, bio, bio);
-if (!c->listen && !c->numerichost)
-SSL_set_tlsext_host_name(p->ssl, c->host);
+if (!c->listen && !c->numerichost) {
+#if OPENSSL_VERSION_NUMBER >= 0x101fL
+X509_VERIFY_PARAM *param = SSL_get0_param(p->ssl);
+X509_VERIFY_PARAM_set_hostflags(param, 
X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
+#endif
+if (
+#if OPENSSL_VERSION_NUMBER >= 0x101fL
+// Note, if on OpenSSL prior to 1.1.0, we won't check that
+// the peer certificate actually matches the requested hostname.
+!X509_VERIFY_PARAM_set1_host(param, c->host, 0) ||
+#endif
+!SSL_set_tlsext_host_name(p->ssl, c->host)) {
+av_log(h, AV_LOG_ERROR, "%s\n", ERR_error_string(ERR_get_error(), 
NULL));
+ret = AVERROR(EIO);
+goto fail;
+}
+}
 ret = c->listen ? SSL_accept(p->ssl) : SSL_connect(p->ssl);
 if (ret == 0) {
 av_log(h, AV_LOG_ERROR, "Unable to negotiate TLS/SSL session\n");
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 1/5] lavf/tls_openssl: disable obsolete locking code on OpenSSL 1.1 and later

2019-01-18 Thread Rodger Combs
These functions are now all no-ops and locking is handled internally.
This fixes a small memory leak on init.
---
 libavformat/tls_openssl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 7ae71bdaf3..9dd53c6fc0 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -48,7 +48,7 @@ typedef struct TLSContext {
 #endif
 } TLSContext;
 
-#if HAVE_THREADS
+#if HAVE_THREADS && (OPENSSL_VERSION_NUMBER < 0x101fL)
 #include 
 pthread_mutex_t *openssl_mutexes;
 static void openssl_lock(int mode, int type, const char *file, int line)
@@ -72,7 +72,7 @@ int ff_openssl_init(void)
 if (!openssl_init) {
 SSL_library_init();
 SSL_load_error_strings();
-#if HAVE_THREADS
+#if HAVE_THREADS && (OPENSSL_VERSION_NUMBER < 0x101fL)
 if (!CRYPTO_get_locking_callback()) {
 int i;
 openssl_mutexes = av_malloc_array(sizeof(pthread_mutex_t), 
CRYPTO_num_locks());
@@ -101,7 +101,7 @@ void ff_openssl_deinit(void)
 ff_lock_avformat();
 openssl_init--;
 if (!openssl_init) {
-#if HAVE_THREADS
+#if HAVE_THREADS && (OPENSSL_VERSION_NUMBER < 0x101fL)
 if (CRYPTO_get_locking_callback() == openssl_lock) {
 int i;
 CRYPTO_set_locking_callback(NULL);
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 2/5] lavf/tls_openssl: if no CA path is set, use the system default

2019-01-18 Thread Rodger Combs
This is consistent with the other TLS wrappers
---
 libavformat/tls_openssl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 9dd53c6fc0..ae3fd6e236 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -253,6 +253,9 @@ static int tls_open(URLContext *h, const char *uri, int 
flags, AVDictionary **op
 if (c->ca_file) {
 if (!SSL_CTX_load_verify_locations(p->ctx, c->ca_file, NULL))
 av_log(h, AV_LOG_ERROR, "SSL_CTX_load_verify_locations %s\n", 
ERR_error_string(ERR_get_error(), NULL));
+} else {
+if (!SSL_CTX_set_default_verify_paths(p->ctx))
+av_log(h, AV_LOG_ERROR, "SSL_CTX_set_default_verify_paths %s\n", 
ERR_error_string(ERR_get_error(), NULL));
 }
 if (c->cert_file && !SSL_CTX_use_certificate_chain_file(p->ctx, 
c->cert_file)) {
 av_log(h, AV_LOG_ERROR, "Unable to load cert file %s: %s\n",
-- 
2.19.1

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


Re: [FFmpeg-devel] [PATCH 3/4] lavf/tls_openssl: on 1.1 or later, verify the server's hostname

2019-01-17 Thread Rodger Combs


> On Jan 17, 2019, at 03:09, Nicolas George  wrote:
> 
> Signed PGP part
> Rodger Combs (12019-01-17):
>> ---
>> libavformat/tls_openssl.c | 22 ++
>> 1 file changed, 18 insertions(+), 4 deletions(-)
>> 
>> diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
>> index 493f43e610..bdc4985bad 100644
>> --- a/libavformat/tls_openssl.c
>> +++ b/libavformat/tls_openssl.c
>> @@ -35,6 +35,7 @@
>> #include 
>> #include 
>> #include 
>> +#include 
>> 
>> static int openssl_init;
>> 
>> @@ -269,8 +270,6 @@ static int tls_open(URLContext *h, const char *uri, int 
>> flags, AVDictionary **op
>> ret = AVERROR(EIO);
>> goto fail;
>> }
>> -// Note, this doesn't check that the peer certificate actually matches
>> -// the requested hostname.
>> if (c->verify)
>> SSL_CTX_set_verify(p->ctx, 
>> SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
>> p->ssl = SSL_new(p->ctx);
>> @@ -294,8 +293,23 @@ static int tls_open(URLContext *h, const char *uri, int 
>> flags, AVDictionary **op
>> bio->ptr = c->tcp;
>> #endif
>> SSL_set_bio(p->ssl, bio, bio);
>> -if (!c->listen && !c->numerichost)
>> -SSL_set_tlsext_host_name(p->ssl, c->host);
> 
>> +if (!c->listen && !c->numerichost) {
>> +#if OPENSSL_VERSION_NUMBER >= 0x101fL
>> +X509_VERIFY_PARAM *param = SSL_get0_param(p->ssl);
>> +X509_VERIFY_PARAM_set_hostflags(param, 
>> X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
>> +#endif
>> +if (
>> +#if OPENSSL_VERSION_NUMBER >= 0x101fL
>> +// Note, if on OpenSSL prior to 1.1.0, we won't check that
>> +// the peer certificate actually matches the requested hostname.
>> +!X509_VERIFY_PARAM_set1_host(param, c->host, 0) ||
>> +#endif
>> +!SSL_set_tlsext_host_name(p->ssl, c->host)) {
>> +av_log(h, AV_LOG_ERROR, "%s\n", 
>> ERR_error_string(ERR_get_error(), NULL));
>> +ret = AVERROR(EIO);
>> +goto fail;
>> +}
>> +}
> 
> I think AVERROR(EIO) is not the best choice. EPROTO would seem obvious,
> but not supported on windows. Otherwise EPERM.
> 
> More importantly: with this change, users will no longer be able to
> access misconfigured servers. An option to let them bypass the test
> would be necessary.

What kind of misconfiguration are you referring to? The actual verification is 
still gated behind the tls_verify option; if that's set to 0, this won't 
actually do anything. (Well, it'll result in OpenSSL potentially generating a 
different error code internally, and then discarding it because we didn't 
enable verification).

> 
>> ret = c->listen ? SSL_accept(p->ssl) : SSL_connect(p->ssl);
>> if (ret == 0) {
>> av_log(h, AV_LOG_ERROR, "Unable to negotiate TLS/SSL session\n");
> 
> Regards,
> 
> --
>  Nicolas George
> 
> 



signature.asc
Description: Message signed with OpenPGP
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/4] lavf/tls_openssl: silence warning on OpenSSL 1.1 and later

2019-01-17 Thread Rodger Combs


> On Jan 17, 2019, at 03:12, Nicolas George  wrote:
> 
> Signed PGP part
> Rodger Combs (12019-01-17):
>> ---
>> libavformat/tls_openssl.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
>> index 7ae71bdaf3..faa5b8636e 100644
>> --- a/libavformat/tls_openssl.c
>> +++ b/libavformat/tls_openssl.c
>> @@ -102,7 +102,7 @@ void ff_openssl_deinit(void)
>> openssl_init--;
>> if (!openssl_init) {
>> #if HAVE_THREADS
> 
>> -if (CRYPTO_get_locking_callback() == openssl_lock) {
>> +if (CRYPTO_get_locking_callback() == _lock) {
> 
> Using the & operator on a function seems strange. What warnings is it
> supposed to fix, and why?

CRYPTO_get_locking_callback is a macro returning NULL on 1.1 and later. This 
triggers -Wtautological-pointer-compare ("comparison of function 'openssl_lock' 
equal to a null pointer is always false"), which suggests "prefix with the 
address-of operator to silence this warning", so I did that. We could 
alternately wrap this code in an OpenSSL version check, but this seemed easier.

> 
>> int i;
>> CRYPTO_set_locking_callback(NULL);
>> for (i = 0; i < CRYPTO_num_locks(); i++)
> 
> Regards,
> 
> --
>  Nicolas George
> 
> 



signature.asc
Description: Message signed with OpenPGP
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/4] lavf/tls_openssl: silence warning on OpenSSL 1.1 and later

2019-01-17 Thread Rodger Combs
---
 libavformat/tls_openssl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 7ae71bdaf3..faa5b8636e 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -102,7 +102,7 @@ void ff_openssl_deinit(void)
 openssl_init--;
 if (!openssl_init) {
 #if HAVE_THREADS
-if (CRYPTO_get_locking_callback() == openssl_lock) {
+if (CRYPTO_get_locking_callback() == _lock) {
 int i;
 CRYPTO_set_locking_callback(NULL);
 for (i = 0; i < CRYPTO_num_locks(); i++)
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 2/4] lavf/tls_openssl: if no CA path is set, use the system default

2019-01-17 Thread Rodger Combs
This is consistent with the other TLS wrappers
---
 libavformat/tls_openssl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index faa5b8636e..493f43e610 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -253,6 +253,9 @@ static int tls_open(URLContext *h, const char *uri, int 
flags, AVDictionary **op
 if (c->ca_file) {
 if (!SSL_CTX_load_verify_locations(p->ctx, c->ca_file, NULL))
 av_log(h, AV_LOG_ERROR, "SSL_CTX_load_verify_locations %s\n", 
ERR_error_string(ERR_get_error(), NULL));
+} else {
+if (!SSL_CTX_set_default_verify_paths(p->ctx))
+av_log(h, AV_LOG_ERROR, "SSL_CTX_set_default_verify_paths %s\n", 
ERR_error_string(ERR_get_error(), NULL));
 }
 if (c->cert_file && !SSL_CTX_use_certificate_chain_file(p->ctx, 
c->cert_file)) {
 av_log(h, AV_LOG_ERROR, "Unable to load cert file %s: %s\n",
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 4/4] lavf/tls: enable server verification by default when not on mbedtls

2019-01-17 Thread Rodger Combs
All other TLS wrappers now have a mechanism to load a system trust store
by default, without setting the cafile option. For Secure Transport and
Secure Channel, it's the OS. For OpenSSL and libtls, it's a path set at
compile-time. For GNUTLS, it's either a path set at compile-time, or the
OS trust store (if on macOS, iOS, or Windows). It's possible to configure
OpenSSL, GNUTLS, and libtls without a working trust store, but these are
broken configurations and I don't have a problem with requiring users with
that kind of install to either fix it, or explicitly opt in to insecure
behavior. mbedtls doesn't have a default trust store (it's assumed that the
application will provide one), so it continues to require the user to pass
in a path and enable verification manually.
---
 libavformat/tls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/tls.h b/libavformat/tls.h
index beb19d6d55..988085173e 100644
--- a/libavformat/tls.h
+++ b/libavformat/tls.h
@@ -45,7 +45,7 @@ typedef struct TLSShared {
 #define TLS_COMMON_OPTIONS(pstruct, options_field) \
 {"ca_file","Certificate Authority database file", offsetof(pstruct, 
options_field . ca_file),   AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
 {"cafile", "Certificate Authority database file", offsetof(pstruct, 
options_field . ca_file),   AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
-{"tls_verify", "Verify the peer certificate", offsetof(pstruct, 
options_field . verify),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = 
TLS_OPTFL }, \
+{"tls_verify", "Verify the peer certificate", offsetof(pstruct, 
options_field . verify),AV_OPT_TYPE_INT, { .i64 = !CONFIG_MBEDTLS }, 0, 1, 
.flags = TLS_OPTFL }, \
 {"cert_file",  "Certificate file",offsetof(pstruct, 
options_field . cert_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
 {"key_file",   "Private key file",offsetof(pstruct, 
options_field . key_file),  AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
 {"listen", "Listen for incoming connections", offsetof(pstruct, 
options_field . listen),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = 
TLS_OPTFL }, \
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 3/4] lavf/tls_openssl: on 1.1 or later, verify the server's hostname

2019-01-17 Thread Rodger Combs
---
 libavformat/tls_openssl.c | 22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 493f43e610..bdc4985bad 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int openssl_init;
 
@@ -269,8 +270,6 @@ static int tls_open(URLContext *h, const char *uri, int 
flags, AVDictionary **op
 ret = AVERROR(EIO);
 goto fail;
 }
-// Note, this doesn't check that the peer certificate actually matches
-// the requested hostname.
 if (c->verify)
 SSL_CTX_set_verify(p->ctx, 
SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
 p->ssl = SSL_new(p->ctx);
@@ -294,8 +293,23 @@ static int tls_open(URLContext *h, const char *uri, int 
flags, AVDictionary **op
 bio->ptr = c->tcp;
 #endif
 SSL_set_bio(p->ssl, bio, bio);
-if (!c->listen && !c->numerichost)
-SSL_set_tlsext_host_name(p->ssl, c->host);
+if (!c->listen && !c->numerichost) {
+#if OPENSSL_VERSION_NUMBER >= 0x101fL
+X509_VERIFY_PARAM *param = SSL_get0_param(p->ssl);
+X509_VERIFY_PARAM_set_hostflags(param, 
X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
+#endif
+if (
+#if OPENSSL_VERSION_NUMBER >= 0x101fL
+// Note, if on OpenSSL prior to 1.1.0, we won't check that
+// the peer certificate actually matches the requested hostname.
+!X509_VERIFY_PARAM_set1_host(param, c->host, 0) ||
+#endif
+!SSL_set_tlsext_host_name(p->ssl, c->host)) {
+av_log(h, AV_LOG_ERROR, "%s\n", ERR_error_string(ERR_get_error(), 
NULL));
+ret = AVERROR(EIO);
+goto fail;
+}
+}
 ret = c->listen ? SSL_accept(p->ssl) : SSL_connect(p->ssl);
 if (ret == 0) {
 av_log(h, AV_LOG_ERROR, "Unable to negotiate TLS/SSL session\n");
-- 
2.19.1

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


[FFmpeg-devel] [PATCH] lavc: vt_hevc: fix crash if vps_list[0] or sps_list[0] are null

2019-01-09 Thread Rodger Combs
Instead of assuming id 0 is used, use the same logic as used for PPS,
where all available entries in the list are emitted.
---
 libavcodec/videotoolbox.c | 86 ++-
 1 file changed, 40 insertions(+), 46 deletions(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index da7236f100..fb3501f413 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -176,26 +176,31 @@ CFDataRef 
ff_videotoolbox_avcc_extradata_create(AVCodecContext *avctx)
 CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
 {
 HEVCContext *h = avctx->priv_data;
-const HEVCVPS *vps = (const HEVCVPS *)h->ps.vps_list[0]->data;
-const HEVCSPS *sps = (const HEVCSPS *)h->ps.sps_list[0]->data;
-int i, num_pps = 0;
+int i, num_vps = 0, num_sps = 0, num_pps = 0;
+const HEVCVPS *vps = h->ps.vps;
+const HEVCSPS *sps = h->ps.sps;
 const HEVCPPS *pps = h->ps.pps;
 PTLCommon ptlc = vps->ptl.general_ptl;
 VUI vui = sps->vui;
 uint8_t parallelismType;
 CFDataRef data = NULL;
 uint8_t *p;
-int vt_extradata_size = 23 + 5 + vps->data_size + 5 + sps->data_size + 3;
+int vt_extradata_size = 23 + 3 + 3 + 3;
 uint8_t *vt_extradata;
 
-for (i = 0; i < HEVC_MAX_PPS_COUNT; i++) {
-if (h->ps.pps_list[i]) {
-const HEVCPPS *pps = (const HEVCPPS *)h->ps.pps_list[i]->data;
-vt_extradata_size += 2 + pps->data_size;
-num_pps++;
-}
+#define COUNT_SIZE_PS(T, t) \
+for (i = 0; i < HEVC_MAX_##T##PS_COUNT; i++) { \
+if (h->ps.t##ps_list[i]) { \
+const HEVC##T##PS *lps = (const HEVC##T##PS 
*)h->ps.t##ps_list[i]->data; \
+vt_extradata_size += 2 + lps->data_size; \
+num_##t##ps++; \
+} \
 }
 
+COUNT_SIZE_PS(V, v)
+COUNT_SIZE_PS(S, s)
+COUNT_SIZE_PS(P, p)
+
 vt_extradata = av_malloc(vt_extradata_size);
 if (!vt_extradata)
 return NULL;
@@ -286,44 +291,33 @@ CFDataRef 
ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
 AV_W8(p + 22, 3);
 
 p += 23;
-/* vps */
-/*
- * bit(1) array_completeness;
- * unsigned int(1) reserved = 0;
- * unsigned int(6) NAL_unit_type;
- */
-AV_W8(p, 1 << 7 |
- HEVC_NAL_VPS & 0x3f);
-/* unsigned int(16) numNalus; */
-AV_WB16(p + 1, 1);
-/* unsigned int(16) nalUnitLength; */
-AV_WB16(p + 3, vps->data_size);
-/* bit(8*nalUnitLength) nalUnit; */
-memcpy(p + 5, vps->data, vps->data_size);
-p += 5 + vps->data_size;
-
-/* sps */
-AV_W8(p, 1 << 7 |
- HEVC_NAL_SPS & 0x3f);
-AV_WB16(p + 1, 1);
-AV_WB16(p + 3, sps->data_size);
-memcpy(p + 5, sps->data, sps->data_size);
-p += 5 + sps->data_size;
-
-/* pps */
-AV_W8(p, 1 << 7 |
- HEVC_NAL_PPS & 0x3f);
-AV_WB16(p + 1, num_pps);
-p += 3;
-for (i = 0; i < HEVC_MAX_PPS_COUNT; i++) {
-if (h->ps.pps_list[i]) {
-const HEVCPPS *pps = (const HEVCPPS *)h->ps.pps_list[i]->data;
-AV_WB16(p, pps->data_size);
-memcpy(p + 2, pps->data, pps->data_size);
-p += 2 + pps->data_size;
-}
+
+#define APPEND_PS(T, t) \
+/* \
+ * bit(1) array_completeness; \
+ * unsigned int(1) reserved = 0; \
+ * unsigned int(6) NAL_unit_type; \
+ */ \
+AV_W8(p, 1 << 7 | \
+ HEVC_NAL_##T##PS & 0x3f); \
+/* unsigned int(16) numNalus; */ \
+AV_WB16(p + 1, num_##t##ps); \
+p += 3; \
+for (i = 0; i < HEVC_MAX_##T##PS_COUNT; i++) { \
+if (h->ps.t##ps_list[i]) { \
+const HEVC##T##PS *lps = (const HEVC##T##PS 
*)h->ps.t##ps_list[i]->data; \
+/* unsigned int(16) nalUnitLength; */ \
+AV_WB16(p, lps->data_size); \
+/* bit(8*nalUnitLength) nalUnit; */ \
+memcpy(p + 2, lps->data, lps->data_size); \
+p += 2 + lps->data_size; \
+} \
 }
 
+APPEND_PS(V, v)
+APPEND_PS(S, s)
+APPEND_PS(P, p)
+
 av_assert0(p - vt_extradata == vt_extradata_size);
 
 data = CFDataCreate(kCFAllocatorDefault, vt_extradata, vt_extradata_size);
-- 
2.19.1

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


[FFmpeg-devel] [PATCH] lavc/samidec: don't error on empty packets

2018-11-30 Thread Rodger Combs
No change to output; just prevents error spam
---
 libavcodec/samidec.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c
index e32f238c62..7ea67b5597 100644
--- a/libavcodec/samidec.c
+++ b/libavcodec/samidec.c
@@ -38,6 +38,7 @@ typedef struct {
 int readorder;
 } SAMIContext;
 
+// Returns 1 if valid content was decoded; 0 if none; <0 if error
 static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
 {
 SAMIContext *sami = avctx->priv_data;
@@ -84,7 +85,7 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const 
char *src)
 while (av_isspace(*p))
 p++;
 if (!strncmp(p, "", 6)) {
-ret = -1;
+ret = 0;
 goto end;
 }
 
@@ -126,6 +127,8 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, 
const char *src)
 goto end;
 av_bprintf(>full, "%s", sami->encoded_content.str);
 
+ret = 1;
+
 end:
 av_free(dupsrc);
 return ret;
@@ -142,10 +145,12 @@ static int sami_decode_frame(AVCodecContext *avctx,
 int ret = sami_paragraph_to_ass(avctx, ptr);
 if (ret < 0)
 return ret;
-// TODO: pass escaped sami->encoded_source.str as source
-ret = ff_ass_add_rect(sub, sami->full.str, sami->readorder++, 0, NULL, 
NULL);
-if (ret < 0)
-return ret;
+if (ret > 0) {
+// TODO: pass escaped sami->encoded_source.str as source
+ret = ff_ass_add_rect(sub, sami->full.str, sami->readorder++, 0, 
NULL, NULL);
+if (ret < 0)
+return ret;
+}
 }
 *got_sub_ptr = sub->num_rects > 0;
 return avpkt->size;
-- 
2.19.1

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


Re: [FFmpeg-devel] [PATCH 1/3] lavf/matroskadec: don't treat I/O errors as EOF

2018-11-28 Thread Rodger Combs


> On Nov 28, 2018, at 13:19, Marton Balint  wrote:
> 
> 
> 
> On Wed, 28 Nov 2018, Rodger Combs wrote:
> 
>> pb->eof_reached is set on error, so we need to check pb->error,
>> even after checking pb->eof_reached or avio_feof(pb), or else we
>> can end up returning AVERROR_EOF instead of the actual error code.
> 
> Why eof_reached is set in the first place on error? Why does avio_feof() 
> return nonzero if we are not at the end of file? That is strictly against its 
> documentation.

Looks like it's been like that since at least 2002. It's probably because a lot 
of code that loops on e.g. avio_r8 checks for EOF, but doesn't explicitly check 
for error, so if errors didn't set the EOF flag, they'd just loop forever. 
Either way, that code needs to be updated to return errors properly, so I don't 
think removing the EOF-on-error behavior is helpful (it'd just make existing 
problem cases worse).

> 
> Seems like a fine mess, let's think about how we will resolve this in a 
> generic way.

I don't think this can really be resolved generically, since all the places 
that currently just return AVERROR_EOF in this case will need updating to read 
the error from AVIOContext regardless.

> 
> Thanks,
> Marton
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 3/3] lavf/movdec: don't treat I/O errors as EOF

2018-11-27 Thread Rodger Combs
---
 libavformat/mov.c | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 542e92ec00..607ce30178 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -645,7 +645,7 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 for (type = 0; type != -1 && avio_tell(pb) < next; ) {
 if(avio_feof(pb))
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 type = avio_rb16(pb);
 len = avio_rb16(pb);
 av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);
@@ -2001,9 +2001,9 @@ static int mov_read_stco(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 sc->chunk_count = i;
 
-if (pb->eof_reached) {
+if (avio_feof(pb)) {
 av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STCO atom\n");
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 }
 
 return 0;
@@ -2535,9 +2535,9 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext 
*pb, int entries)
 sc->stsd_count++;
 }
 
-if (pb->eof_reached) {
+if (avio_feof(pb)) {
 av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STSD atom\n");
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 }
 
 return 0;
@@ -2669,9 +2669,9 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 }
 }
 
-if (pb->eof_reached) {
+if (avio_feof(pb)) {
 av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STSC atom\n");
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 }
 
 return 0;
@@ -2723,9 +2723,9 @@ static int mov_read_stps(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 sc->stps_count = i;
 
-if (pb->eof_reached) {
+if (avio_feof(pb)) {
 av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STPS atom\n");
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 }
 
 return 0;
@@ -2772,9 +2772,9 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 sc->keyframe_count = i;
 
-if (pb->eof_reached) {
+if (avio_feof(pb)) {
 av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STSS atom\n");
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 }
 
 return 0;
@@ -2860,9 +2860,9 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 av_free(buf);
 
-if (pb->eof_reached) {
+if (avio_feof(pb)) {
 av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STSZ atom\n");
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 }
 
 return 0;
@@ -2938,9 +2938,9 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 sc->nb_frames_for_fps += total_sample_count;
 }
 
-if (pb->eof_reached) {
+if (avio_feof(pb)) {
 av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STTS atom\n");
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 }
 
 st->nb_frames= total_sample_count;
@@ -3017,7 +3017,7 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 sc->ctts_count = ctts_count;
 
-if (pb->eof_reached) {
+if (avio_feof(pb)) {
 av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted CTTS atom\n");
 return AVERROR_EOF;
 }
@@ -3066,9 +3066,9 @@ static int mov_read_sbgp(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 sc->rap_group_count = i;
 
-if (pb->eof_reached) {
+if (avio_feof(pb)) {
 av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted SBGP atom\n");
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 }
 
 return 0;
@@ -4912,9 +4912,9 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 fix_frag_index_entries(>frag_index, next_frag_index,
frag->track_id, entries);
 
-if (pb->eof_reached) {
+if (avio_feof(pb)) {
 av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted TRUN atom\n");
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 }
 
 frag->implicit_offset = offset;
@@ -7627,7 +7627,7 @@ static int mov_switch_root(AVFormatContext *s, int64_t 
target, int index)
 if (ret < 0)
 return ret;
 if (avio_feof(s->pb))
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 av_log(s, AV_LOG_TRACE, "read fragments, offset 0x%"PRIx64"\n", 
avio_tell(s->pb));
 
 return 1;
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 1/3] lavf/matroskadec: don't treat I/O errors as EOF

2018-11-27 Thread Rodger Combs
pb->eof_reached is set on error, so we need to check pb->error,
even after checking pb->eof_reached or avio_feof(pb), or else we
can end up returning AVERROR_EOF instead of the actual error code.
---
 libavformat/matroskadec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index d3c9c33720..2774ccabb2 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -789,7 +789,7 @@ static int matroska_resync(MatroskaDemuxContext *matroska, 
int64_t last_pos)
 }
 
 matroska->done = 1;
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 }
 
 /*
@@ -836,7 +836,7 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, 
AVIOContext *pb,
pos, pos);
 return pb->error ? pb->error : AVERROR(EIO);
 }
-return AVERROR_EOF;
+return pb->error ? pb->error : AVERROR_EOF;
 }
 
 /* get the length of the EBML number */
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 2/3] lavf/avidec: don't treat I/O errors as EOF

2018-11-27 Thread Rodger Combs
---
 libavformat/avidec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 3f074795a7..1d131b299c 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1383,8 +1383,8 @@ static int ni_prepare_read(AVFormatContext *s)
 if (i >= 0) {
 int64_t pos = best_st->index_entries[i].pos;
 pos += best_ast->packet_size - best_ast->remaining;
-if (avio_seek(s->pb, pos + 8, SEEK_SET) < 0)
-  return AVERROR_EOF;
+if ((pos = avio_seek(s->pb, pos + 8, SEEK_SET)) < 0)
+  return pos;
 
 av_assert0(best_ast->remaining <= best_ast->packet_size);
 
-- 
2.19.1

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


[FFmpeg-devel] [PATCH] lavf/isom: add "dvhe" fourCC for HEVC

2018-11-05 Thread Rodger Combs
This refers to "Dolby Vision", which can have some additional extensions,
but (usually?) is also valid HEVC.
---
 libavformat/isom.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index ca9d22e4f7..fbfa0dc057 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -163,6 +163,7 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 
 { AV_CODEC_ID_HEVC, MKTAG('h', 'e', 'v', '1') }, /* HEVC/H.265 which 
indicates parameter sets may be in ES */
 { AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') }, /* HEVC/H.265 which 
indicates parameter sets shall not be in ES */
+{ AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC/H.265 with Dolby 
Vision extensions */
 
 { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */
 { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '2') },
-- 
2.19.1

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


[FFmpeg-devel] [PATCH] lavf/mpegtsdec: fix AVPacket.pos when FEC/DVHS/BDAV data is present

2018-08-30 Thread Rodger Combs
We previously set pos to several bytes before the actual packet sync byte,
which meant that seeking to pos relied on resync working, which can fail
if there are 0x47 bytes in the additional data.

The resync issue should probably also be fixed separately.
---
 libavformat/mpegts.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index a5cb17ac16..881708b42d 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2581,10 +2581,9 @@ static int handle_packet(MpegTSContext *ts, const 
uint8_t *packet)
 
 } else {
 int ret;
-// Note: The position here points actually behind the current packet.
 if (tss->type == MPEGTS_PES) {
 if ((ret = tss->u.pes_filter.pes_cb(tss, p, p_end - p, is_start,
-pos - ts->raw_packet_size)) < 
0)
+pos - TS_PACKET_SIZE)) < 0)
 return ret;
 }
 }
-- 
2.18.0

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


Re: [FFmpeg-devel] [PATCH] lavf/mpegts: improve read error handling

2018-08-24 Thread Rodger Combs


> On Aug 24, 2018, at 03:44, Hendrik Leppkes  wrote:
> 
> On Fri, Aug 24, 2018 at 5:01 AM myp...@gmail.com <mailto:myp...@gmail.com> 
> mailto:myp...@gmail.com>> wrote:
>> 
>> On Fri, Aug 24, 2018 at 5:38 AM Rodger Combs  wrote:
>>> 
>>> We previously could fail to check errors entirely, or misinterpret read
>> errors
>>> as normal EOFs.
>>> ---
>>> libavformat/mpegts.c | 13 +++--
>>> 1 file changed, 11 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
>>> index 37a6aa8bff..1350213d39 100644
>>> --- a/libavformat/mpegts.c
>>> +++ b/libavformat/mpegts.c
>>> @@ -2475,6 +2475,8 @@ static int mpegts_resync(AVFormatContext *s, int
>> seekback, const uint8_t *curren
>>> 
>>> for (i = 0; i < ts->resync_size; i++) {
>>> c = avio_r8(pb);
>>> +if (pb->error)
>>> +return pb->error;
>>> if (avio_feof(pb))
>>> return AVERROR_EOF;
>>> if (c == 0x47) {
>>> @@ -2498,8 +2500,13 @@ static int read_packet(AVFormatContext *s, uint8_t
>> *buf, int raw_packet_size,
>>> 
>>> for (;;) {
>>> len = ffio_read_indirect(pb, buf, TS_PACKET_SIZE, data);
>>> -if (len != TS_PACKET_SIZE)
>>> -return len < 0 ? len : AVERROR_EOF;
>>> +if (len != TS_PACKET_SIZE) {
>>> +if (len < 0)
>>> +return len;
>>> +if (pb->error)
>>> +return pb->error;
>>> +return AVERROR_EOF;
>>> +}
>>> /* check packet sync byte */
>>> if ((*data)[0] != 0x47) {
>>> /* find a new packet start */
>>> @@ -2670,6 +2677,8 @@ static int mpegts_read_header(AVFormatContext *s)
>>> /* read the first 8192 bytes to get packet size */
>>> pos = avio_tell(pb);
>>> len = avio_read(pb, buf, sizeof(buf));
>>> +if (len < 0)
>>> +return len;
>>> ts->raw_packet_size = get_packet_size(buf, len);
>>> if (ts->raw_packet_size <= 0) {
>>> av_log(s, AV_LOG_WARNING, "Could not detect TS packet size,
>> defaulting to non-FEC/DVHS\n");
>>> --
>> As I understand, only after avio_xxx return < 0 to check pb->error, now we
>> coding like:
>>   len = avio_xxx(pb);
>>   if (len < 0)
>>return len;
>>if (pb->error)
>>return pb->error;
>> 
>> It's stranger way for me, consider Unix API read(2), we just check the
>> error after -1 is returned
>> (
>> http://man7.org/linux/man-pages/man2/read.2.html
>> )
>> 
>> we usually catch the error
>> / error
>> number like:
>> 
> 
> The reason for this is to be able to differentiate between EOF and
> read errors. In case of a read error, partial data may still be
> returned, and any short read is otherwise considered EOF before this
> patch.
> The alternative to this would be checking pb->eof_reached, which would
> do the same thing,  just flip the logic on its head.

I'd actually sort of prefer that, since it'd let me call avio_feof() instead of 
doing a direct member access, but it turns out that eof_reached is set to 1 in 
error cases as well.

> 
> - Hendrik
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel 
> <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] lavc/hevc_mp4toannexb_bsf: don't fail on extradata with too few arrays

2018-08-23 Thread Rodger Combs
I've been given a sample that does this. Not sure exactly why, but the decoder
ignores it and plays normally.
---
 libavcodec/hevc_mp4toannexb_bsf.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/hevc_mp4toannexb_bsf.c 
b/libavcodec/hevc_mp4toannexb_bsf.c
index 09bce5b34c..fb4ea34a93 100644
--- a/libavcodec/hevc_mp4toannexb_bsf.c
+++ b/libavcodec/hevc_mp4toannexb_bsf.c
@@ -52,6 +52,11 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx)
 num_arrays  = bytestream2_get_byte();
 
 for (i = 0; i < num_arrays; i++) {
+if (bytestream2_get_bytes_left() < 3) {
+av_log(ctx, AV_LOG_WARNING, "Extradata contained fewer arrays than 
indicated\n");
+break;
+}
+
 int type = bytestream2_get_byte() & 0x3f;
 int cnt  = bytestream2_get_be16();
 
-- 
2.18.0

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


[FFmpeg-devel] [PATCH 2/2] lavc/hevc_mp4toannexb_bsf: warn if a NAL size would overflow the buffer

2018-08-23 Thread Rodger Combs
This didn't actually cause a buffer overread previously, but it could result
in the end of a NAL being filled with zeros silently.
---
 libavcodec/hevc_mp4toannexb_bsf.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/hevc_mp4toannexb_bsf.c 
b/libavcodec/hevc_mp4toannexb_bsf.c
index fb4ea34a93..c40308f367 100644
--- a/libavcodec/hevc_mp4toannexb_bsf.c
+++ b/libavcodec/hevc_mp4toannexb_bsf.c
@@ -70,6 +70,10 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx)
 
 for (j = 0; j < cnt; j++) {
 int nalu_len = bytestream2_get_be16();
+if (nalu_len < 1 || bytestream2_get_bytes_left() < nalu_len) {
+av_log(ctx, AV_LOG_WARNING, "Extradata NAL ended 
prematurely\n");
+goto done;
+}
 
 if (4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - 
new_extradata_size) {
 ret = AVERROR_INVALIDDATA;
@@ -86,6 +90,7 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx)
 }
 }
 
+done:
 av_freep(>par_out->extradata);
 ctx->par_out->extradata  = new_extradata;
 ctx->par_out->extradata_size = new_extradata_size;
-- 
2.18.0

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


[FFmpeg-devel] [PATCH] lavf/mpegts: improve read error handling

2018-08-23 Thread Rodger Combs
We previously could fail to check errors entirely, or misinterpret read errors
as normal EOFs.
---
 libavformat/mpegts.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 37a6aa8bff..1350213d39 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2475,6 +2475,8 @@ static int mpegts_resync(AVFormatContext *s, int 
seekback, const uint8_t *curren
 
 for (i = 0; i < ts->resync_size; i++) {
 c = avio_r8(pb);
+if (pb->error)
+return pb->error;
 if (avio_feof(pb))
 return AVERROR_EOF;
 if (c == 0x47) {
@@ -2498,8 +2500,13 @@ static int read_packet(AVFormatContext *s, uint8_t *buf, 
int raw_packet_size,
 
 for (;;) {
 len = ffio_read_indirect(pb, buf, TS_PACKET_SIZE, data);
-if (len != TS_PACKET_SIZE)
-return len < 0 ? len : AVERROR_EOF;
+if (len != TS_PACKET_SIZE) {
+if (len < 0)
+return len;
+if (pb->error)
+return pb->error;
+return AVERROR_EOF;
+}
 /* check packet sync byte */
 if ((*data)[0] != 0x47) {
 /* find a new packet start */
@@ -2670,6 +2677,8 @@ static int mpegts_read_header(AVFormatContext *s)
 /* read the first 8192 bytes to get packet size */
 pos = avio_tell(pb);
 len = avio_read(pb, buf, sizeof(buf));
+if (len < 0)
+return len;
 ts->raw_packet_size = get_packet_size(buf, len);
 if (ts->raw_packet_size <= 0) {
 av_log(s, AV_LOG_WARNING, "Could not detect TS packet size, defaulting 
to non-FEC/DVHS\n");
-- 
2.18.0

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


Re: [FFmpeg-devel] [PATCH] avcodec/videotoolbox: fix kVTCouldNotFindVideoDecoderErr trying to decode HEVC on iOS

2018-04-20 Thread Rodger Combs
If there was a way to indicate this to consumers, or expose an option to turn 
this off, I'd say it should have that... but there's no good infrastructure to 
do that in an hwaccel, so whatever.
One nit; otherwise LGTM.

> On Apr 19, 2018, at 17:34, Aman Gupta  wrote:
> 
> From: Aman Gupta 
> 
> Older iOS devices don't have a hardware HEVC decoder, but the
> software decoder offered by VideoToolbox is well-optimized and
> performs much better than the ffmpeg decoder.
> ---
> libavcodec/videotoolbox.c | 12 ++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
> index 57b6698e1b..8671608a35 100644
> --- a/libavcodec/videotoolbox.c
> +++ b/libavcodec/videotoolbox.c
> @@ -36,6 +36,9 @@
> #ifndef kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder
> #  define kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder 
> CFSTR("RequireHardwareAcceleratedVideoDecoder")
> #endif
> +#ifndef kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder
> +#  define kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder 
> CFSTR("EnableHardwareAcceleratedVideoDecoder")
> +#endif
> 
> #if !HAVE_KCMVIDEOCODECTYPE_HEVC
> enum { kCMVideoCodecType_HEVC = 'hvc1' };
> @@ -709,7 +712,9 @@ static CFDictionaryRef 
> videotoolbox_decoder_config_create(CMVideoCodecType codec
>
> );
> 
> CFDictionarySetValue(config_info,
> - 
> kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder,
> + codec_type == kCMVideoCodecType_HEVC ?
> +
> kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder :
> +
> kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder,
>  kCFBooleanTrue);
> 
> CFMutableDictionaryRef avc_info;
> @@ -833,6 +838,9 @@ static int videotoolbox_start(AVCodecContext *avctx)
> case kVTVideoDecoderUnsupportedDataFormatErr:
> av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox does not support this 
> format.\n");
> return AVERROR(ENOSYS);
> +case kVTCouldNotFindVideoDecoderErr:
> +av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox decoder for this format 
> not found.\n");
> +return AVERROR(ENOSYS);
> case kVTVideoDecoderMalfunctionErr:
> av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox malfunction.\n");
> return AVERROR(EINVAL);
> @@ -842,7 +850,7 @@ static int videotoolbox_start(AVCodecContext *avctx)
> case 0:
> return 0;
> default:
> -av_log(avctx, AV_LOG_VERBOSE, "Unknown VideoToolbox session creation 
> error %u\n", (unsigned)status);
> +av_log(avctx, AV_LOG_VERBOSE, "Unknown VideoToolbox session creation 
> error %d\n", (int)status);

Bit tangential; should be its own commit. Maybe just combine the two logging 
changes.

> return AVERROR_UNKNOWN;
> }
> }
> -- 
> 2.14.2
> 

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


Re: [FFmpeg-devel] [PATCH v2 2/2] avformat/utils: refactor upstream_stream_timings

2018-04-20 Thread Rodger Combs
Both patches LGTM.

> On Apr 19, 2018, at 18:51, Aman Gupta  wrote:
> 
> From: Aman Gupta 
> 
> ---
> libavformat/utils.c | 21 ++---
> 1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 705b79031d..c25eab4d49 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -2620,7 +2620,6 @@ static void update_stream_timings(AVFormatContext *ic)
> int64_t start_time, start_time1, start_time_text, end_time, end_time1, 
> end_time_text;
> int64_t duration, duration1, duration_text, filesize;
> int i;
> -AVStream *st;
> AVProgram *p;
> 
> start_time = INT64_MAX;
> @@ -2631,21 +2630,22 @@ static void update_stream_timings(AVFormatContext *ic)
> duration_text = INT64_MIN;
> 
> for (i = 0; i < ic->nb_streams; i++) {
> -st = ic->streams[i];
> +AVStream *st = ic->streams[i];
> +int is_text = st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE ||
> +  st->codecpar->codec_type == AVMEDIA_TYPE_DATA;
> if (st->start_time != AV_NOPTS_VALUE && st->time_base.den) {
> start_time1 = av_rescale_q(st->start_time, st->time_base,
>AV_TIME_BASE_Q);
> -if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || 
> st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
> -if (start_time1 < start_time_text)
> -start_time_text = start_time1;
> -} else
> +if (is_text)
> +start_time_text = FFMIN(start_time_text, start_time1);
> +else
> start_time = FFMIN(start_time, start_time1);
> end_time1 = av_rescale_q_rnd(st->duration, st->time_base,
>  AV_TIME_BASE_Q,
>  
> AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
> if (end_time1 != AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 
> <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) {
> end_time1 += start_time1;
> -if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || 
> st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
> +if (is_text)
> end_time_text = FFMAX(end_time_text, end_time1);
> else
> end_time = FFMAX(end_time, end_time1);
> @@ -2660,7 +2660,7 @@ static void update_stream_timings(AVFormatContext *ic)
> if (st->duration != AV_NOPTS_VALUE) {
> duration1 = av_rescale_q(st->duration, st->time_base,
>  AV_TIME_BASE_Q);
> -if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || 
> st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
> +if (is_text)
> duration_text = FFMAX(duration_text, duration1);
> else
> duration = FFMAX(duration, duration1);
> @@ -2671,11 +2671,10 @@ static void update_stream_timings(AVFormatContext *ic)
> else if (start_time > start_time_text)
> av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream 
> starttime %f\n", start_time_text / (float)AV_TIME_BASE);
> 
> -if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text 
> - (uint64_t)end_time < AV_TIME_BASE)) {
> +if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text 
> - (uint64_t)end_time < AV_TIME_BASE))
> end_time = end_time_text;
> -} else if (end_time < end_time_text) {
> +else if (end_time < end_time_text)
> av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream 
> endtime %f\n", end_time_text / (float)AV_TIME_BASE);
> -}
> 
>  if (duration == INT64_MIN || (duration < duration_text && duration_text 
> - duration < AV_TIME_BASE))
>  duration = duration_text;
> -- 
> 2.14.2
> 

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


[FFmpeg-devel] [PATCH] lavc/videotoolbox: fix failure to decode PAFF

2018-03-28 Thread Rodger Combs
---
 libavcodec/videotoolbox.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index f82c31c5df..57b6698e1b 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -326,11 +326,8 @@ static int videotoolbox_set_frame(AVCodecContext *avctx, 
AVFrame *frame)
 
 CVPixelBufferRef *ref = (CVPixelBufferRef *)frame->buf[0]->data;
 
-if (*ref) {
-av_log(avctx, AV_LOG_ERROR, "videotoolbox: frame already set?\n");
-av_frame_unref(frame);
-return AVERROR_EXTERNAL;
-}
+if (*ref)
+CVPixelBufferRelease(*ref);
 
 *ref = vtctx->frame;
 vtctx->frame = NULL;
-- 
2.16.2

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


Re: [FFmpeg-devel] [PATCH 05/10] lavf/dashenc: don't call flush_init_segment before avformat_write_header

2018-03-18 Thread Rodger Combs


> On Mar 18, 2018, at 02:16, Jeyapal, Karthick <kjeya...@akamai.com> wrote:
> 
> 
> 
> On 3/14/18 11:54 AM, Rodger Combs wrote:
>> Fixes crash when muxing MKV-in-DASH
>> ---
>> libavformat/dashenc.c | 10 +++---
>> 1 file changed, 3 insertions(+), 7 deletions(-)
>> 
>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> index 5689aef811..63ff827583 100644
>> --- a/libavformat/dashenc.c
>> +++ b/libavformat/dashenc.c
>> @@ -985,13 +985,6 @@ static int dash_init(AVFormatContext *s)
>> 
>> av_log(s, AV_LOG_VERBOSE, "Representation %d init segment will be 
>> written to: %s\n", i, filename);
>> 
>> -// Flush init segment
>> -// except for mp4, since delay_moov is set and the init segment
>> -// is then flushed after the first packets
>> -if (strcmp(os->format_name, "mp4")) {
>> -flush_init_segment(s, os);
>> -}
>> -
>> s->streams[i]->time_base = st->time_base;
>> // If the muxer wants to shift timestamps, request to have them 
>> shifted
>> // already before being handed to this muxer, so we don't have 
>> mismatches
>> @@ -1032,6 +1025,9 @@ static int dash_write_header(AVFormatContext *s)
>> OutputStream *os = >streams[i];
>> if ((ret = avformat_write_header(os->ctx, NULL)) < 0)
>> return ret;
>> +
>> +if ((ret = flush_init_segment(s, os)) < 0)
>> +return ret;
> I am fine with moving this here. But you have removed the strcmp for mp4 
> files.
> Have you analyzed the impact of this change for mp4 files. Looks like 
> something might break for mp4 files.
> I would be more comfortable, if the strcmp and its related comment is also 
> moved here.

After some more testing, I think you're correct. I'll resend with it moved.

>> }
>> ret = write_manifest(s, 0);
>> if (!ret)
> 
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel 
> <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 07/10] lavf: document that AVStream::codecpar may be modified by lavf after avformat_write_header(). This is assumed not to break API because it's already true (see e.g. matr

2018-03-16 Thread Rodger Combs
Could we just declare that lavf can update extradata (and nothing else) if it 
gets packets with new-extradata side-data? If not, I suppose we could either 
add something to AVStreamInternal, or do something internal in check_bitstream 
(and update movenc and matroskaenc, as both exhibit this behavior right now).

> On Mar 15, 2018, at 20:04, Hendrik Leppkes <h.lepp...@gmail.com> wrote:
> 
> On Fri, Mar 16, 2018 at 12:29 AM, Michael Niedermayer
> <mich...@niedermayer.cc <mailto:mich...@niedermayer.cc>> wrote:
>> On Wed, Mar 14, 2018 at 01:24:42AM -0500, Rodger Combs wrote:
>>> ---
>>> libavformat/avformat.h | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>>> index 9e87d6cdac..5f0ebfc114 100644
>>> --- a/libavformat/avformat.h
>>> +++ b/libavformat/avformat.h
>>> @@ -1006,7 +1006,8 @@ typedef struct AVStream {
>>>  *
>>>  * - demuxing: filled by libavformat on stream creation or in
>>>  * avformat_find_stream_info()
>>> - * - muxing: filled by the caller before avformat_write_header()
>>> + * - muxing: filled by the caller before avformat_write_header();
>>> + * - may be modified by libavformat afterwards
>>>  */
>> 
>> a generic "anything can change" is not really practical
>> a user app would have to check every field of codecpar and possibly insert
>> video scalers if resoluton changed, or all kinds of other filters and even
>> different encoders if codec_id was adjusted ...
>> 
> 
> I generally don't like this either. codecpar describes the codec as
> given to the muxer by the user. The muxer has no business changing
> things around in it.
> If it can derive better values somehow, let it store it internally somewhere.
> 
> - Hendrik
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel 
> <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 08/10] lavf/matroskaenc: don't rewrite extradata if we already have some

2018-03-15 Thread Rodger Combs


> On Mar 15, 2018, at 17:36, James Almer <jamr...@gmail.com> wrote:
> 
> On 3/14/2018 3:24 AM, Rodger Combs wrote:
>> matroska doesn't support mid-stream extradata changes
> 
> How so? We update flac extradata as sent by the encoder in the last
> packet as side data.

Right, but the format itself doesn't support changing mid-stream; we handle 
that case by rewriting the header.

> 
>> , and rewriting
>> the same extradata already written in write_header would cause errors
>> since we previously didn't write a filler void.
> 
> When would this happen? What sets both extradata in codecpar then sends
> new one as packet side data for AAC audio?

Happens after the subsequent patch ("lavf/mux: propagate extradata changes 
before we call write_header to codecpar").

> 
>> ---
>> libavformat/matroskaenc.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
>> index 5950b4de44..e4db5a9a1c 100644
>> --- a/libavformat/matroskaenc.c
>> +++ b/libavformat/matroskaenc.c
>> @@ -2266,7 +2266,8 @@ static int mkv_check_new_extra_data(AVFormatContext 
>> *s, AVPacket *pkt)
>> 
>> switch (par->codec_id) {
>> case AV_CODEC_ID_AAC:
>> -if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && 
>> !mkv->is_live) {
>> +if (side_data_size && !par->extradata_size &&
>> +(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) {
>> int filler, output_sample_rate = 0;
>> int64_t curpos;
>> ret = get_aac_sample_rates(s, side_data, side_data_size, 
>> >sample_rate,
>> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel 
> <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 10/10] lavf/movenc: handle AC3 and EAC3 data extraction in check_bitstream

2018-03-14 Thread Rodger Combs
This allows us to write AC3 and EAC3 data to the header even in non-seekable
output, like with segment.c (which I add tests for).
---
 libavformat/movenc.c | 64 +---
 tests/fate/avformat.mak  | 60 +-
 tests/ref/fate/segment-ac3-to-mp4-header-000 | 38 ++
 tests/ref/fate/segment-ac3-to-mp4-header-001 | 30 +++
 tests/ref/fate/segment-ac3-to-mp4-header-all | 62 +++
 tests/ref/fate/segment-ac3-to-mp4-header-md5sum  |  1 +
 tests/ref/fate/segment-eac3-to-mp4-header-000| 38 ++
 tests/ref/fate/segment-eac3-to-mp4-header-001| 21 
 tests/ref/fate/segment-eac3-to-mp4-header-all| 53 
 tests/ref/fate/segment-eac3-to-mp4-header-md5sum |  1 +
 10 files changed, 348 insertions(+), 20 deletions(-)
 create mode 100644 tests/ref/fate/segment-ac3-to-mp4-header-000
 create mode 100644 tests/ref/fate/segment-ac3-to-mp4-header-001
 create mode 100644 tests/ref/fate/segment-ac3-to-mp4-header-all
 create mode 100644 tests/ref/fate/segment-ac3-to-mp4-header-md5sum
 create mode 100644 tests/ref/fate/segment-eac3-to-mp4-header-000
 create mode 100644 tests/ref/fate/segment-eac3-to-mp4-header-001
 create mode 100644 tests/ref/fate/segment-eac3-to-mp4-header-all
 create mode 100644 tests/ref/fate/segment-eac3-to-mp4-header-md5sum

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index b5ef09c4c7..1f15d244ed 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -368,11 +368,11 @@ struct eac3_info {
 };
 
 #if CONFIG_AC3_PARSER
-static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
+static int parse_eac3(MOVMuxContext *mov, const AVPacket *pkt, MOVTrack 
*track, int *num_blocks)
 {
 AC3HeaderInfo *hdr = NULL;
 struct eac3_info *info;
-int num_blocks, ret;
+int ret = 1;
 
 if (!track->eac3_priv && !(track->eac3_priv = av_mallocz(sizeof(*info
 return AVERROR(ENOMEM);
@@ -389,7 +389,8 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, 
MOVTrack *track)
 }
 
 info->data_rate = FFMAX(info->data_rate, hdr->bit_rate / 1000);
-num_blocks = hdr->num_blocks;
+if (num_blocks)
+*num_blocks = hdr->num_blocks;
 
 if (!info->ec3_done) {
 /* AC-3 substream must be the first one */
@@ -415,7 +416,7 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, 
MOVTrack *track)
 } else if (hdr->substreamid < info->num_ind_sub ||
hdr->substreamid == 0 && info->substream[0].bsid) {
 info->ec3_done = 1;
-goto concatenate;
+goto end;
 }
 }
 
@@ -465,44 +466,53 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, 
MOVTrack *track)
 }
 }
 
-concatenate:
+end:
+av_free(hdr);
+
+return ret;
+}
+
+static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
+{
+int num_blocks;
+struct eac3_info *info;
+int ret = parse_eac3(mov, pkt, track, _blocks);
+if (ret <= 0)
+return ret;
+
+info = track->eac3_priv;
+
 if (!info->num_blocks && num_blocks == 6) {
-ret = pkt->size;
-goto end;
+return pkt->size;
 }
 else if (info->num_blocks + num_blocks > 6) {
-ret = AVERROR_INVALIDDATA;
-goto end;
+return AVERROR_INVALIDDATA;
 }
 
 if (!info->num_blocks) {
 ret = av_packet_ref(>pkt, pkt);
 if (!ret)
 info->num_blocks = num_blocks;
-goto end;
+return ret;
 } else {
 if ((ret = av_grow_packet(>pkt, pkt->size)) < 0)
-goto end;
+return ret;
 memcpy(info->pkt.data + info->pkt.size - pkt->size, pkt->data, 
pkt->size);
 info->num_blocks += num_blocks;
 info->pkt.duration += pkt->duration;
 if ((ret = av_copy_packet_side_data(>pkt, pkt)) < 0)
-goto end;
+return ret;
 if (info->num_blocks != 6)
-goto end;
+return ret;
 av_packet_unref(pkt);
 ret = av_packet_ref(pkt, >pkt);
 if (ret < 0)
-goto end;
+return ret;
 av_packet_unref(>pkt);
 info->num_blocks = 0;
 }
-ret = pkt->size;
-
-end:
-av_free(hdr);
 
-return ret;
+return pkt->size;
 }
 #endif
 
@@ -6572,12 +6582,28 @@ static int mov_check_bitstream(struct AVFormatContext 
*s, const AVPacket *pkt)
 {
 int ret = 1;
 AVStream *st = s->streams[pkt->stream_index];
+MOVMuxContext *mov = s->priv_data;
+MOVTrack *trk = >tracks[pkt->stream_index];
 
 if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
 if (pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0)
 ret = ff_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL);
 } else if (st->codecpar->codec_id == AV_CODEC_ID_VP9) {
 ret = 

[FFmpeg-devel] [PATCH 06/10] Revert "avformat/mux: stop delaying writing the header"

2018-03-14 Thread Rodger Combs
This reverts commit d6d605eb05c3ca32f591016c345eb2ad9e81c554.
---
 libavformat/avformat.h |  2 +-
 libavformat/internal.h |  6 +
 libavformat/mux.c  | 52 ++
 libavformat/options_table.h|  2 +-
 libavformat/tests/fifo_muxer.c | 52 ++
 tests/ref/fate/fifo-muxer-tst  |  1 +
 tests/ref/fate/rgb24-mkv   |  4 ++--
 7 files changed, 105 insertions(+), 14 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index a2fe7c6bb2..9e87d6cdac 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1482,7 +1482,7 @@ typedef struct AVFormatContext {
 #endif
 #define AVFMT_FLAG_FAST_SEEK   0x8 ///< Enable fast, but inaccurate seeks 
for some formats
 #define AVFMT_FLAG_SHORTEST   0x10 ///< Stop muxing when the shortest 
stream stops.
-#define AVFMT_FLAG_AUTO_BSF   0x20 ///< Add bitstream filters as requested 
by the muxer
+#define AVFMT_FLAG_AUTO_BSF   0x20 ///< Wait for packet data before 
writing a header, and add bitstream filters as requested by the muxer
 
 /**
  * Maximum size of the data read from input for determining
diff --git a/libavformat/internal.h b/libavformat/internal.h
index a020b1b417..666e2054a7 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -120,6 +120,12 @@ struct AVFormatInternal {
 
 int avoid_negative_ts_use_pts;
 
+/**
+ * Whether or not a header has already been written
+ */
+int header_written;
+int write_header_ret;
+
 /**
  * Timestamp of the end of the shortest stream.
  */
diff --git a/libavformat/mux.c b/libavformat/mux.c
index a13f0e3a1b..5fdc9275cc 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -485,6 +485,25 @@ static void flush_if_needed(AVFormatContext *s)
 }
 }
 
+static int write_header_internal(AVFormatContext *s)
+{
+if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
+avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_HEADER);
+if (s->oformat->write_header) {
+int ret = s->oformat->write_header(s);
+if (ret >= 0 && s->pb && s->pb->error < 0)
+ret = s->pb->error;
+s->internal->write_header_ret = ret;
+if (ret < 0)
+return ret;
+flush_if_needed(s);
+}
+s->internal->header_written = 1;
+if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
+avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_UNKNOWN);
+return 0;
+}
+
 int avformat_init_output(AVFormatContext *s, AVDictionary **options)
 {
 int ret = 0;
@@ -515,18 +534,11 @@ int avformat_write_header(AVFormatContext *s, 
AVDictionary **options)
 if ((ret = avformat_init_output(s, options)) < 0)
 return ret;
 
-if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
-avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_HEADER);
-if (s->oformat->write_header) {
-ret = s->oformat->write_header(s);
-if (ret >= 0 && s->pb && s->pb->error < 0)
-ret = s->pb->error;
+if (!(s->oformat->check_bitstream && s->flags & AVFMT_FLAG_AUTO_BSF)) {
+ret = write_header_internal(s);
 if (ret < 0)
 goto fail;
-flush_if_needed(s);
 }
-if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
-avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_UNKNOWN);
 
 if (!s->internal->streams_initialized) {
 if ((ret = init_pts(s)) < 0)
@@ -738,6 +750,12 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 }
 }
 
+if (!s->internal->header_written) {
+ret = s->internal->write_header_ret ? s->internal->write_header_ret : 
write_header_internal(s);
+if (ret < 0)
+goto fail;
+}
+
 if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) {
 AVFrame *frame = (AVFrame *)pkt->data;
 av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
@@ -753,6 +771,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 ret = s->pb->error;
 }
 
+fail:
+
 if (ret < 0) {
 pkt->pts = pts_backup;
 pkt->dts = dts_backup;
@@ -885,6 +905,11 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
 
 if (!pkt) {
 if (s->oformat->flags & AVFMT_ALLOW_FLUSH) {
+if (!s->internal->header_written) {
+ret = s->internal->write_header_ret ? 
s->internal->write_header_ret : write_header_internal(s);
+if (ret < 0)
+return ret;
+}
 ret = s->oformat->write_packet(s, NULL);
 flush_if_needed(s);
 if (ret >= 0 && s->pb && s->pb->error < 0)
@@ -1268,8 +1293,14 @@ int av_write_trailer(AVFormatContext *s)
 goto fail;
 }
 
+if (!s->internal->header_written) {
+ret = s->internal->write_header_ret ? s->internal->write_header_ret : 
write_header_internal(s);
+if (ret < 0)

[FFmpeg-devel] [PATCH 09/10] lavf/mux: propagate extradata changes before we call write_header to codecpar

2018-03-14 Thread Rodger Combs
This includes extradata generated by an encoder post-init, or extradata
generated by automatically-added bsfs.

This fixes remuxing ADTS to non-seekable MKV, which had been broken in
f63c3516577d605e51cf16358cbdfa0bc97565d8, so the tests modified there
are restored.

This moves extradata writing in aac-autobsf-adtstoasc to write_header,
resulting in a smaller file since we don't write a padding void, so
that test reference is also updated.
---
 libavformat/mux.c| 14 ++
 tests/fate/avformat.mak  |  4 ++--
 tests/ref/fate/aac-autobsf-adtstoasc |  4 ++--
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 5fdc9275cc..611a3c0f15 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -892,6 +892,20 @@ static int do_packet_auto_bsf(AVFormatContext *s, AVPacket 
*pkt) {
 return 0;
 }
 }
+
+if (!s->internal->header_written) {
+int side_size;
+uint8_t *side = av_packet_get_side_data(pkt, 
AV_PKT_DATA_NEW_EXTRADATA, _size);
+if (side && side_size > 0 && (side_size != 
st->codecpar->extradata_size ||
+  memcmp(side, st->codecpar->extradata, 
side_size))) {
+av_freep(>codecpar->extradata);
+if ((ret = ff_alloc_extradata(st->codecpar, side_size)) < 0)
+return ret;
+memcpy(st->codecpar->extradata, side, side_size);
+st->codecpar->extradata_size = side_size;
+}
+}
+
 return 1;
 }
 
diff --git a/tests/fate/avformat.mak b/tests/fate/avformat.mak
index 346a4b4509..35a75c68c0 100644
--- a/tests/fate/avformat.mak
+++ b/tests/fate/avformat.mak
@@ -95,14 +95,14 @@ tests/data/mp4-to-ts.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | 
tests/data
 tests/data/adts-to-mkv.m3u8: TAG = GEN
 tests/data/adts-to-mkv.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
$(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
--i $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_lc.m4a \
+-i $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_lc.adts 
\
 -f segment -segment_time 1 -map 0 -flags +bitexact -codec copy 
-segment_format_options live=1 \
 -segment_list $(TARGET_PATH)/$@ -y 
$(TARGET_PATH)/tests/data/adts-to-mkv-%03d.mkv -nostdin 2>/dev/null
 
 tests/data/adts-to-mkv-header.mkv: TAG = GEN
 tests/data/adts-to-mkv-header.mkv: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
$(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
--i $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_lc.m4a \
+-i $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_lc.adts 
\
 -f segment -segment_time 1 -map 0 -flags +bitexact -codec copy 
-segment_format_options live=1 \
 -segment_header_filename 
$(TARGET_PATH)/tests/data/adts-to-mkv-header.mkv \
 -y $(TARGET_PATH)/tests/data/adts-to-mkv-header-%03d.mkv -nostdin 
2>/dev/null
diff --git a/tests/ref/fate/aac-autobsf-adtstoasc 
b/tests/ref/fate/aac-autobsf-adtstoasc
index 9ca8e7ed9e..d5dfbabe5f 100644
--- a/tests/ref/fate/aac-autobsf-adtstoasc
+++ b/tests/ref/fate/aac-autobsf-adtstoasc
@@ -1,5 +1,5 @@
-b0375ba00bcbd55023a176255b8d4ba2 
*tests/data/fate/aac-autobsf-adtstoasc.matroska
-6728 tests/data/fate/aac-autobsf-adtstoasc.matroska
+1bd4a110db26231cade5344de302254e 
*tests/data/fate/aac-autobsf-adtstoasc.matroska
+6396 tests/data/fate/aac-autobsf-adtstoasc.matroska
 #extradata 0:2, 0x0030001c
 #tb 0: 1/1000
 #media_type 0: audio
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 08/10] lavf/matroskaenc: don't rewrite extradata if we already have some

2018-03-14 Thread Rodger Combs
matroska doesn't support mid-stream extradata changes, and rewriting
the same extradata already written in write_header would cause errors
since we previously didn't write a filler void.
---
 libavformat/matroskaenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 5950b4de44..e4db5a9a1c 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2266,7 +2266,8 @@ static int mkv_check_new_extra_data(AVFormatContext *s, 
AVPacket *pkt)
 
 switch (par->codec_id) {
 case AV_CODEC_ID_AAC:
-if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && 
!mkv->is_live) {
+if (side_data_size && !par->extradata_size &&
+(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) {
 int filler, output_sample_rate = 0;
 int64_t curpos;
 ret = get_aac_sample_rates(s, side_data, side_data_size, 
>sample_rate,
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 04/10] lavf/dashenc: remove unneeded call to dash_free

2018-03-14 Thread Rodger Combs
---
 libavformat/dashenc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 79d63e52d4..5689aef811 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1030,10 +1030,8 @@ static int dash_write_header(AVFormatContext *s)
 int i, ret;
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = >streams[i];
-if ((ret = avformat_write_header(os->ctx, NULL)) < 0) {
-dash_free(s);
+if ((ret = avformat_write_header(os->ctx, NULL)) < 0)
 return ret;
-}
 }
 ret = write_manifest(s, 0);
 if (!ret)
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 07/10] lavf: document that AVStream::codecpar may be modified by lavf after avformat_write_header(). This is assumed not to break API because it's already true (see e.g. matroska

2018-03-14 Thread Rodger Combs
---
 libavformat/avformat.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 9e87d6cdac..5f0ebfc114 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1006,7 +1006,8 @@ typedef struct AVStream {
  *
  * - demuxing: filled by libavformat on stream creation or in
  * avformat_find_stream_info()
- * - muxing: filled by the caller before avformat_write_header()
+ * - muxing: filled by the caller before avformat_write_header();
+ * - may be modified by libavformat afterwards
  */
 AVCodecParameters *codecpar;
 
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 05/10] lavf/dashenc: don't call flush_init_segment before avformat_write_header

2018-03-14 Thread Rodger Combs
Fixes crash when muxing MKV-in-DASH
---
 libavformat/dashenc.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5689aef811..63ff827583 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -985,13 +985,6 @@ static int dash_init(AVFormatContext *s)
 
 av_log(s, AV_LOG_VERBOSE, "Representation %d init segment will be 
written to: %s\n", i, filename);
 
-// Flush init segment
-// except for mp4, since delay_moov is set and the init segment
-// is then flushed after the first packets
-if (strcmp(os->format_name, "mp4")) {
-flush_init_segment(s, os);
-}
-
 s->streams[i]->time_base = st->time_base;
 // If the muxer wants to shift timestamps, request to have them shifted
 // already before being handed to this muxer, so we don't have 
mismatches
@@ -1032,6 +1025,9 @@ static int dash_write_header(AVFormatContext *s)
 OutputStream *os = >streams[i];
 if ((ret = avformat_write_header(os->ctx, NULL)) < 0)
 return ret;
+
+if ((ret = flush_init_segment(s, os)) < 0)
+return ret;
 }
 ret = write_manifest(s, 0);
 if (!ret)
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 01/10] FATE: add -nostdin to remaining ffmpeg CLI invocations

2018-03-14 Thread Rodger Combs
This prevents ffmpeg from modifying terminal parameters, which resulted in
broken terminals after tests nondeterministically when multiple processes
attempted to save and restore the state at the same time.
---
 tests/fate/avformat.mak | 6 +++---
 tests/fate/filter-audio.mak | 4 ++--
 tests/fate/filter-video.mak | 4 ++--
 tests/fate/fits.mak | 4 ++--
 tests/fate/flvenc.mak   | 2 +-
 tests/fate/hevc.mak | 2 +-
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/tests/fate/avformat.mak b/tests/fate/avformat.mak
index a12f9ccc71..346a4b4509 100644
--- a/tests/fate/avformat.mak
+++ b/tests/fate/avformat.mak
@@ -90,14 +90,14 @@ tests/data/mp4-to-ts.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | 
tests/data
$(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
 -i $(TARGET_SAMPLES)/h264/interlaced_crop.mp4 \
 -f ssegment -segment_time 1 -map 0 -flags +bitexact -codec copy \
--segment_list $(TARGET_PATH)/$@ -y 
$(TARGET_PATH)/tests/data/mp4-to-ts-%03d.ts 2>/dev/null
+-segment_list $(TARGET_PATH)/$@ -y 
$(TARGET_PATH)/tests/data/mp4-to-ts-%03d.ts -nostdin 2>/dev/null
 
 tests/data/adts-to-mkv.m3u8: TAG = GEN
 tests/data/adts-to-mkv.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
$(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
 -i $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_lc.m4a \
 -f segment -segment_time 1 -map 0 -flags +bitexact -codec copy 
-segment_format_options live=1 \
--segment_list $(TARGET_PATH)/$@ -y 
$(TARGET_PATH)/tests/data/adts-to-mkv-%03d.mkv 2>/dev/null
+-segment_list $(TARGET_PATH)/$@ -y 
$(TARGET_PATH)/tests/data/adts-to-mkv-%03d.mkv -nostdin 2>/dev/null
 
 tests/data/adts-to-mkv-header.mkv: TAG = GEN
 tests/data/adts-to-mkv-header.mkv: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
@@ -105,7 +105,7 @@ tests/data/adts-to-mkv-header.mkv: 
ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
 -i $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_lc.m4a \
 -f segment -segment_time 1 -map 0 -flags +bitexact -codec copy 
-segment_format_options live=1 \
 -segment_header_filename 
$(TARGET_PATH)/tests/data/adts-to-mkv-header.mkv \
--y $(TARGET_PATH)/tests/data/adts-to-mkv-header-%03d.mkv 2>/dev/null
+-y $(TARGET_PATH)/tests/data/adts-to-mkv-header-%03d.mkv -nostdin 
2>/dev/null
 
 tests/data/adts-to-mkv-header-%.mkv: tests/data/adts-to-mkv-header.mkv ;
 
diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index 2a3ba1992f..5c5a762f09 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -181,7 +181,7 @@ tests/data/hls-list.m3u8: TAG = GEN
 tests/data/hls-list.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
$(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
 -f lavfi -i "aevalsrc=cos(2*PI*t)*sin(2*PI*(440+4*t)*t):d=20" -f 
segment -segment_time 10 -map 0 -flags +bitexact -codec:a mp2fixed \
--segment_list $(TARGET_PATH)/$@ -y 
$(TARGET_PATH)/tests/data/hls-out-%03d.ts 2>/dev/null
+-segment_list $(TARGET_PATH)/$@ -y 
$(TARGET_PATH)/tests/data/hls-out-%03d.ts -nostdin 2>/dev/null
 
 FATE_AFILTER-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
AEVALSRC_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += fate-filter-hls
 fate-filter-hls: tests/data/hls-list.m3u8
@@ -195,7 +195,7 @@ tests/data/hls-list-append.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) 
| tests/data
 $(TARGET_EXEC) $(TARGET_PATH)/$< \
 -f lavfi -i "aevalsrc=cos(2*PI*t)*sin(2*PI*(440+4*t)*t):d=20" -f hls 
-hls_time 10 -map 0 -flags +bitexact \
 -hls_flags append_list -codec:a mp2fixed -hls_segment_filename 
$(TARGET_PATH)/tests/data/hls-append-out-%03d.ts \
-$(TARGET_PATH)/tests/data/hls-list-append.m3u8 2>/dev/null
+$(TARGET_PATH)/tests/data/hls-list-append.m3u8 -nostdin 2>/dev/null
 
 FATE_AFILTER-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
AEVALSRC_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += fate-filter-hls-append
 fate-filter-hls-append: tests/data/hls-list-append.m3u8
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 07572143a8..5814bc8551 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -611,7 +611,7 @@ fate-filter-tile: CMD = video_filter 
"tile=3x3:nb_frames=5:padding=7:margin=2"
 tests/pixfmts.mak: TAG = GEN
 tests/pixfmts.mak: ffmpeg$(PROGSSUF)$(EXESUF) | tests
$(M)printf "PIXFMTS = " > $@
-   $(Q)$(TARGET_EXEC) $(TARGET_PATH)/$< -pix_fmts list 2> /dev/null | awk 
'NR > 8 && /^IO/ { printf $$2 " " }' >> $@
+   $(Q)$(TARGET_EXEC) $(TARGET_PATH)/$< -pix_fmts list -nostdin 2> 
/dev/null | awk 'NR > 8 && /^IO/ { printf $$2 " " }' >> $@
$(Q)printf "\n" >> $@
 
 RUNNING_PIXFMTS_TESTS := $(filter check fate fate-list fate-filter 
fate-vfilter fate-filter-pixdesc%,$(MAKECMDGOALS))
@@ -758,7 +758,7 @@ fate-filter-metadata-avf-aphase-meter-out-of-phase: CMD = 
run $(FILTER_METADATA_
 tests/data/file4560-override2rotate0.mov: TAG = GEN
 

[FFmpeg-devel] [PATCH 03/10] lavf/movenc: keep eac3_priv around; fixes eac3 in DASH

2018-03-14 Thread Rodger Combs
DASH muxing sometimes calls mov_write_eac3_tag multiple times on the same 
stream.
We need to keep this data around so it's available in the second call, else we
won't write the data QuickTime needs.
---
 libavformat/movenc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index accab417f6..b5ef09c4c7 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -554,7 +554,6 @@ static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack 
*track)
 
 end:
 av_packet_unref(>pkt);
-av_freep(>eac3_priv);
 
 return size;
 }
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 02/10] lavf/movenc: fix leak of eac3_priv

2018-03-14 Thread Rodger Combs
This could previously happen in error or early-exit cases. The next commit
would make it happen in all cases.
---
 libavformat/movenc.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 5b1e66c897..accab417f6 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5773,6 +5773,12 @@ static void mov_free(AVFormatContext *s)
 av_freep(>tracks[i].cluster);
 av_freep(>tracks[i].frag_info);
 
+if (mov->tracks[i].eac3_priv) {
+struct eac3_info *info = mov->tracks[i].eac3_priv;
+av_packet_unref(>pkt);
+av_freep(>tracks[i].eac3_priv);
+}
+
 if (mov->tracks[i].vos_len)
 av_freep(>tracks[i].vos_data);
 
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 2/4] lavf/movenc: keep eac3_priv around; fixes eac3 in DASH

2018-03-12 Thread Rodger Combs
DASH muxing sometimes calls mov_write_eac3_tag multiple times on the same 
stream.
We need to keep this data around so it's available in the second call, else we
won't write the data QuickTime needs.
---
 libavformat/movenc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 353a42ae2c..d4bc4e8995 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -554,7 +554,6 @@ static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack 
*track)
 
 end:
 av_packet_unref(>pkt);
-av_freep(>eac3_priv);
 
 return size;
 }
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 4/4] lavf/dashenc: don't call flush_init_segment before avformat_write_header

2018-03-12 Thread Rodger Combs
Fixes crash when muxing MKV-in-DASH
---
 libavformat/dashenc.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5689aef811..63ff827583 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -985,13 +985,6 @@ static int dash_init(AVFormatContext *s)
 
 av_log(s, AV_LOG_VERBOSE, "Representation %d init segment will be 
written to: %s\n", i, filename);
 
-// Flush init segment
-// except for mp4, since delay_moov is set and the init segment
-// is then flushed after the first packets
-if (strcmp(os->format_name, "mp4")) {
-flush_init_segment(s, os);
-}
-
 s->streams[i]->time_base = st->time_base;
 // If the muxer wants to shift timestamps, request to have them shifted
 // already before being handed to this muxer, so we don't have 
mismatches
@@ -1032,6 +1025,9 @@ static int dash_write_header(AVFormatContext *s)
 OutputStream *os = >streams[i];
 if ((ret = avformat_write_header(os->ctx, NULL)) < 0)
 return ret;
+
+if ((ret = flush_init_segment(s, os)) < 0)
+return ret;
 }
 ret = write_manifest(s, 0);
 if (!ret)
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 1/4] lavf/movenc: fix leak of eac3_priv

2018-03-12 Thread Rodger Combs
This could previously happen in error or early-exit cases. The next commit
would make it happen in all cases.
---
 libavformat/movenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 5b1e66c897..353a42ae2c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5772,6 +5772,7 @@ static void mov_free(AVFormatContext *s)
 av_freep(>tracks[i].par);
 av_freep(>tracks[i].cluster);
 av_freep(>tracks[i].frag_info);
+av_freep(>tracks[i].eac3_priv);
 
 if (mov->tracks[i].vos_len)
 av_freep(>tracks[i].vos_data);
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 3/4] lavf/dashenc: remove unneeded call to dash_free

2018-03-12 Thread Rodger Combs
---
 libavformat/dashenc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 79d63e52d4..5689aef811 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1030,10 +1030,8 @@ static int dash_write_header(AVFormatContext *s)
 int i, ret;
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = >streams[i];
-if ((ret = avformat_write_header(os->ctx, NULL)) < 0) {
-dash_free(s);
+if ((ret = avformat_write_header(os->ctx, NULL)) < 0)
 return ret;
-}
 }
 ret = write_manifest(s, 0);
 if (!ret)
-- 
2.16.2

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


Re: [FFmpeg-devel] [PATCH] lavf/movenc: keep eac3_priv around; fixes eac3 in DASH

2018-03-08 Thread Rodger Combs
Muxing DASH may involve calling mov_write_eac3_tag multiple times on the same 
stream. If we destroy eac3_priv after the first call, we don't have it  later, 
so we end up not writing that data. This is fine for lavf (since everything in 
that atom is redundant), but some other players require it.

> On Mar 8, 2018, at 05:46, Derek Buitenhuis <derek.buitenh...@gmail.com> wrote:
> 
> On 3/8/2018 5:10 AM, Rodger Combs wrote:
>> ---
>> libavformat/movenc.c | 1 -
>> 1 file changed, 1 deletion(-)
> 
> Er, how/why?
> 
> No info is provided in this commit message.
> 
> - Derek
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] lavf/movenc: keep eac3_priv around; fixes eac3 in DASH

2018-03-07 Thread Rodger Combs
---
 libavformat/movenc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 5b1e66c897..fb8462ed9a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -554,7 +554,6 @@ static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack 
*track)
 
 end:
 av_packet_unref(>pkt);
-av_freep(>eac3_priv);
 
 return size;
 }
-- 
2.16.2

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


[FFmpeg-devel] [PATCH] lavfi/vf_transpose: fix regression with semiplanar formats

2018-02-21 Thread Rodger Combs
(e.g. nv12)

Regression since 7b19e76aeb0ace57b99aaef156bbfe592e43e65e
---
 libavfilter/vf_transpose.c  | 50 +++--
 tests/ref/fate/filter-pixfmts-transpose |  8 +++---
 2 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index 3ff4cb4249..74a4bbcf58 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -52,6 +52,14 @@ enum TransposeDir {
 TRANSPOSE_CLOCK_FLIP,
 };
 
+typedef struct TransVtable {
+void (*transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize,
+  uint8_t *dst, ptrdiff_t dst_linesize);
+void (*transpose_block)(uint8_t *src, ptrdiff_t src_linesize,
+uint8_t *dst, ptrdiff_t dst_linesize,
+int w, int h);
+} TransVtable;
+
 typedef struct TransContext {
 const AVClass *class;
 int hsub, vsub;
@@ -61,11 +69,7 @@ typedef struct TransContext {
 int passthrough;///< PassthroughType, landscape passthrough mode 
enabled
 int dir;///< TransposeDir
 
-void (*transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize,
-  uint8_t *dst, ptrdiff_t dst_linesize);
-void (*transpose_block)(uint8_t *src, ptrdiff_t src_linesize,
-uint8_t *dst, ptrdiff_t dst_linesize,
-int w, int h);
+TransVtable vtables[4];
 } TransContext;
 
 static int query_formats(AVFilterContext *ctx)
@@ -233,19 +237,22 @@ static int config_props_output(AVFilterLink *outlink)
 else
 outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
 
-switch (s->pixsteps[0]) {
-case 1: s->transpose_block = transpose_block_8_c;
-s->transpose_8x8   = transpose_8x8_8_c;  break;
-case 2: s->transpose_block = transpose_block_16_c;
-s->transpose_8x8   = transpose_8x8_16_c; break;
-case 3: s->transpose_block = transpose_block_24_c;
-s->transpose_8x8   = transpose_8x8_24_c; break;
-case 4: s->transpose_block = transpose_block_32_c;
-s->transpose_8x8   = transpose_8x8_32_c; break;
-case 6: s->transpose_block = transpose_block_48_c;
-s->transpose_8x8   = transpose_8x8_48_c; break;
-case 8: s->transpose_block = transpose_block_64_c;
-s->transpose_8x8   = transpose_8x8_64_c; break;
+for (int i = 0; i < 4; i++) {
+TransVtable *v = >vtables[i];
+switch (s->pixsteps[i]) {
+case 1: v->transpose_block = transpose_block_8_c;
+v->transpose_8x8   = transpose_8x8_8_c;  break;
+case 2: v->transpose_block = transpose_block_16_c;
+v->transpose_8x8   = transpose_8x8_16_c; break;
+case 3: v->transpose_block = transpose_block_24_c;
+v->transpose_8x8   = transpose_8x8_24_c; break;
+case 4: v->transpose_block = transpose_block_32_c;
+v->transpose_8x8   = transpose_8x8_32_c; break;
+case 6: v->transpose_block = transpose_block_48_c;
+v->transpose_8x8   = transpose_8x8_48_c; break;
+case 8: v->transpose_block = transpose_block_64_c;
+v->transpose_8x8   = transpose_8x8_64_c; break;
+}
 }
 
 av_log(ctx, AV_LOG_VERBOSE,
@@ -290,6 +297,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
int jobnr,
 uint8_t *dst, *src;
 int dstlinesize, srclinesize;
 int x, y;
+TransVtable *v = >vtables[plane];
 
 dstlinesize = out->linesize[plane];
 dst = out->data[plane] + start * dstlinesize;
@@ -308,20 +316,20 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
int jobnr,
 
 for (y = start; y < end - 7; y += 8) {
 for (x = 0; x < outw - 7; x += 8) {
-s->transpose_8x8(src + x * srclinesize + y * pixstep,
+v->transpose_8x8(src + x * srclinesize + y * pixstep,
  srclinesize,
  dst + (y - start) * dstlinesize + x * pixstep,
  dstlinesize);
 }
 if (outw - x > 0 && end - y > 0)
-s->transpose_block(src + x * srclinesize + y * pixstep,
+v->transpose_block(src + x * srclinesize + y * pixstep,
srclinesize,
dst + (y - start) * dstlinesize + x * 
pixstep,
dstlinesize, outw - x, end - y);
 }
 
 if (end - y > 0)
-s->transpose_block(src + 0 * srclinesize + y * pixstep,
+v->transpose_block(src + 0 * srclinesize + y * pixstep,
srclinesize,
dst + (y - start) * dstlinesize + 0 * pixstep,
dstlinesize, outw, end - y);
diff --git a/tests/ref/fate/filter-pixfmts-transpose 

[FFmpeg-devel] [PATCH] lavc/videotoolbox: fix threaded decoding

2018-02-02 Thread Rodger Combs
AVHWAccel.end_frame can run on a worker thread. The assumption of the
frame threading code is that the worker thread will change the AVFrame
image data, not the AVFrame fields. So the AVFrame fields are not synced
back to the main thread. But this breaks videotoolbox due to its special
requirements (everything else is fine). It actually wants to update
AVFrame fields.

The actual videotoolbox frame is now stored in the dummy AVBufferRef, so
it mimics what happens in non-videotoolbox cases. (Changing the
AVBufferRef contents is a bit like changing the image data.) The
post_process callback copies that reference to the proper AVFrame field.

Based on a patch by wm4.
---
 libavcodec/h264dec.c  |  3 ---
 libavcodec/videotoolbox.c | 68 +++
 libavcodec/vt_internal.h  |  1 -
 3 files changed, 51 insertions(+), 21 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 8c9c6d9f3b..7494c7a8f2 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -838,9 +838,6 @@ static int output_frame(H264Context *h, AVFrame *dst, 
H264Picture *srcp)
 AVFrame *src = srcp->f;
 int ret;
 
-if (src->format == AV_PIX_FMT_VIDEOTOOLBOX && src->buf[0]->size == 1)
-return AVERROR_INVALIDDATA;
-
 ret = av_frame_ref(dst, src);
 if (ret < 0)
 return ret;
diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index afec1edf3f..f82c31c5df 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -45,8 +45,10 @@ enum { kCMVideoCodecType_HEVC = 'hvc1' };
 
 static void videotoolbox_buffer_release(void *opaque, uint8_t *data)
 {
-CVPixelBufferRef cv_buffer = (CVImageBufferRef)data;
+CVPixelBufferRef cv_buffer = *(CVPixelBufferRef *)data;
 CVPixelBufferRelease(cv_buffer);
+
+av_free(data);
 }
 
 static int videotoolbox_buffer_copy(VTContext *vtctx,
@@ -69,19 +71,47 @@ static int videotoolbox_buffer_copy(VTContext *vtctx,
 return 0;
 }
 
+static int videotoolbox_postproc_frame(void *avctx, AVFrame *frame)
+{
+CVPixelBufferRef ref = *(CVPixelBufferRef *)frame->buf[0]->data;
+
+if (!ref) {
+av_log(avctx, AV_LOG_ERROR, "No frame decoded?\n");
+av_frame_unref(frame);
+return AVERROR_EXTERNAL;
+}
+
+frame->data[3] = (uint8_t*)ref;
+
+return 0;
+}
+
 int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
 {
+size_t  size = sizeof(CVPixelBufferRef);
+uint8_t*data = NULL;
+AVBufferRef *buf = NULL;
 int ret = ff_attach_decode_data(frame);
+FrameDecodeData *fdd;
 if (ret < 0)
 return ret;
 
+data = av_mallocz(size);
+if (!data)
+return AVERROR(ENOMEM);
+buf = av_buffer_create(data, size, videotoolbox_buffer_release, NULL, 0);
+if (!buf) {
+av_freep();
+return AVERROR(ENOMEM);
+}
+frame->buf[0] = buf;
+
+fdd = (FrameDecodeData*)frame->private_ref->data;
+fdd->post_process = videotoolbox_postproc_frame;
+
 frame->width  = avctx->width;
 frame->height = avctx->height;
 frame->format = avctx->pix_fmt;
-frame->buf[0] = av_buffer_alloc(1);
-
-if (!frame->buf[0])
-return AVERROR(ENOMEM);
 
 return 0;
 }
@@ -285,20 +315,24 @@ CFDataRef 
ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
 return data;
 }
 
-int ff_videotoolbox_buffer_create(VTContext *vtctx, AVFrame *frame)
+static int videotoolbox_set_frame(AVCodecContext *avctx, AVFrame *frame)
 {
-av_buffer_unref(>buf[0]);
-
-frame->buf[0] = av_buffer_create((uint8_t*)vtctx->frame,
- sizeof(vtctx->frame),
- videotoolbox_buffer_release,
- NULL,
- AV_BUFFER_FLAG_READONLY);
-if (!frame->buf[0]) {
-return AVERROR(ENOMEM);
+VTContext *vtctx = avctx->internal->hwaccel_priv_data;
+if (!frame->buf[0] || frame->data[3]) {
+av_log(avctx, AV_LOG_ERROR, "videotoolbox: invalid state\n");
+av_frame_unref(frame);
+return AVERROR_EXTERNAL;
+}
+
+CVPixelBufferRef *ref = (CVPixelBufferRef *)frame->buf[0]->data;
+
+if (*ref) {
+av_log(avctx, AV_LOG_ERROR, "videotoolbox: frame already set?\n");
+av_frame_unref(frame);
+return AVERROR_EXTERNAL;
 }
 
-frame->data[3] = (uint8_t*)vtctx->frame;
+*ref = vtctx->frame;
 vtctx->frame = NULL;
 
 return 0;
@@ -406,7 +440,7 @@ static int videotoolbox_buffer_create(AVCodecContext 
*avctx, AVFrame *frame)
 AVHWFramesContext *cached_frames;
 int ret;
 
-ret = ff_videotoolbox_buffer_create(vtctx, frame);
+ret = videotoolbox_set_frame(avctx, frame);
 if (ret < 0)
 return ret;
 
diff --git a/libavcodec/vt_internal.h b/libavcodec/vt_internal.h
index 929fe423fc..fb64735b8c 100644
--- a/libavcodec/vt_internal.h
+++ b/libavcodec/vt_internal.h
@@ -46,7 +46,6 @@ typedef 

[FFmpeg-devel] [PATCH] lavc/aarch64/sbrdsp_neon: fix build on old binutils

2018-01-25 Thread Rodger Combs
---
 libavcodec/aarch64/sbrdsp_neon.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aarch64/sbrdsp_neon.S b/libavcodec/aarch64/sbrdsp_neon.S
index d1d79b749c..d23717e760 100644
--- a/libavcodec/aarch64/sbrdsp_neon.S
+++ b/libavcodec/aarch64/sbrdsp_neon.S
@@ -287,7 +287,7 @@ endfunc
 zip1v4.4S, v4.4S, v4.4S
 fmlav6.4S, v1.4S, v3.4S
 fmlav2.4S, v5.4S, v4.4S
-fcmeq   v7.4S, v3.4S, #0.0
+fcmeq   v7.4S, v3.4S, #0
 bif v2.16B, v6.16B, v7.16B
 st1 {v2.4S}, [x0], #16
 subsx5, x5, #2
-- 
2.15.1

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


[FFmpeg-devel] [PATCH] lavfi/vf_scale_vaapi: set output SAR

2018-01-12 Thread Rodger Combs
---
 libavfilter/vf_scale_vaapi.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index 22e928c..4bead5a 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -240,6 +240,11 @@ static int scale_vaapi_config_output(AVFilterLink *outlink)
 goto fail;
 }
 
+if (inlink->sample_aspect_ratio.num)
+outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * 
inlink->w, outlink->w * inlink->h}, inlink->sample_aspect_ratio);
+else
+outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
+
 av_freep();
 av_hwframe_constraints_free();
 return 0;
-- 
2.6.4

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


[FFmpeg-devel] [PATCH] lavc/libx265: support all color parameters that x265 does

2017-12-18 Thread Rodger Combs
---
 libavcodec/libx265.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 25ccb02fcb..14710f8de0 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -115,11 +115,11 @@ static av_cold int libx265_encode_init(AVCodecContext 
*avctx)
 ctx->params->sourceHeight= avctx->height;
 ctx->params->bEnablePsnr = !!(avctx->flags & AV_CODEC_FLAG_PSNR);
 
-if ((avctx->color_primaries <= AVCOL_PRI_BT2020 &&
+if ((avctx->color_primaries <= AVCOL_PRI_SMPTE432 &&
  avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) ||
-(avctx->color_trc <= AVCOL_TRC_BT2020_12 &&
+(avctx->color_trc <= AVCOL_TRC_ARIB_STD_B67 &&
  avctx->color_trc != AVCOL_TRC_UNSPECIFIED) ||
-(avctx->colorspace <= AVCOL_SPC_BT2020_CL &&
+(avctx->colorspace <= AVCOL_SPC_ICTCP &&
  avctx->colorspace != AVCOL_SPC_UNSPECIFIED)) {
 
 ctx->params->vui.bEnableVideoSignalTypePresentFlag  = 1;
-- 
2.15.1

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


Re: [FFmpeg-devel] [RFC] [Vote] Drop Windows XP support

2017-12-14 Thread Rodger Combs


> On Dec 14, 2017, at 07:26, wm4  wrote:
> 
> I propose that FFmpeg sets the minimum supported Windows version to
> Windows Vista (or maybe Windows 7). This would remove Windows XP
> support.
> 
> The reason is that Windows XP does not provide certain convenient APIs,
> in particular locking primitives that map well to pthread. There are
> other problems, such as upstream projects dropping XP support, and
> developers not being able to test.
> 
> Dropping it has advantages for us. For example, it would allow is to
> rewrite the messy locking code for AVCodec registration, which has been
> a topic recently.
> 
> Microsoft ended all support for Windows XP on January 31, 2009. That's
> almost a decade ago. There is a lack of security updates, which makes
> merely using Windows XP dangerous. There is no reason to put so much
> effort into supporting an old, unsupported OS.
> 
> We should drop XP support, and allow unconditional use of Windows Vista
> APIs.
> 
> I'm also casting an internal vote to probe for support (this vote is
> meant for members of the FFmpeg voting committee only).
> 
> The subject of the vote is:
> 
>  Should we drop support for Windows XP starting in git master and the
>  next FFmpeg major release?

Yes.

> 
> Current release branches are explicitly unaffected.
> 
> My own vote on this issue is "yes" (assuming I still have a right for a
> vote, I really don't know).
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 3/4] lavf/utils: add flag to discard timestamps on corrupted frames

2017-12-13 Thread Rodger Combs
---
 libavformat/avformat.h  | 1 +
 libavformat/options_table.h | 1 +
 libavformat/utils.c | 8 
 3 files changed, 10 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 4f2798a871..d10d583dff 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1450,6 +1450,7 @@ typedef struct AVFormatContext {
 #define AVFMT_FLAG_FAST_SEEK   0x8 ///< Enable fast, but inaccurate seeks 
for some formats
 #define AVFMT_FLAG_SHORTEST   0x10 ///< Stop muxing when the shortest 
stream stops.
 #define AVFMT_FLAG_AUTO_BSF   0x20 ///< Add bitstream filters as requested 
by the muxer
+#define AVFMT_FLAG_DISCARD_CORRUPT_TS 0x40 ///< Discard timestamps of 
frames marked corrupt
 
 /**
  * Maximum size of the data read from input for determining
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index b8fa47c6fd..515574d3e0 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -58,6 +58,7 @@ static const AVOption avformat_options[] = {
 {"bitexact", "do not write random/volatile data", 0, AV_OPT_TYPE_CONST, { .i64 
= AVFMT_FLAG_BITEXACT }, 0, 0, E, "fflags" },
 {"shortest", "stop muxing with the shortest stream", 0, AV_OPT_TYPE_CONST, { 
.i64 = AVFMT_FLAG_SHORTEST }, 0, 0, E, "fflags" },
 {"autobsf", "add needed bsfs automatically", 0, AV_OPT_TYPE_CONST, { .i64 = 
AVFMT_FLAG_AUTO_BSF }, 0, 0, E, "fflags" },
+{"discardcorruptts", "discard timestamps on corrupted frames", 0, 
AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_DISCARD_CORRUPT_TS }, 0, 0, E, "fflags" 
},
 {"analyzeduration", "specify how many microseconds are analyzed to probe the 
input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, 
INT64_MAX, D},
 {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 
0, 0, D},
 {"indexmem", "max memory used for timestamp index (per stream)", 
OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8d49348d9e..2e15f34469 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -873,6 +873,14 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
 st->cur_dts = wrap_timestamp(st, st->cur_dts);
 }
 
+if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT_TS) &&
+(pkt->flags & AV_PKT_FLAG_HEADER_CORRUPT)) {
+pkt->pts = pkt->dts = AV_NOPTS_VALUE;
+av_log(s, AV_LOG_WARNING,
+   "Discarded timestamp on corrupted packet (stream = %d)\n",
+   pkt->stream_index);
+}
+
 pkt->dts = wrap_timestamp(st, pkt->dts);
 pkt->pts = wrap_timestamp(st, pkt->pts);
 
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 2/4] lavc+lavf: split AV_PKG_FLAG_CORRUPT into more specific flags

2017-12-13 Thread Rodger Combs
This maintains AV_PKG_FLAG_CORRUPT as a mask of the 3 new flags.
Requires a major bump in both libraries.
---
 libavcodec/avcodec.h   | 29 -
 libavcodec/trace_headers_bsf.c | 10 --
 libavcodec/version.h   |  3 +++
 libavformat/aiffdec.c  |  2 +-
 libavformat/apc.c  |  2 +-
 libavformat/iv8.c  |  2 +-
 libavformat/jvdec.c|  2 +-
 libavformat/mp3dec.c   |  2 +-
 libavformat/mpegts.c   |  6 +++---
 libavformat/oggparseopus.c |  2 +-
 libavformat/oggparsevorbis.c   |  4 ++--
 libavformat/omadec.c   |  4 ++--
 libavformat/pcm.c  |  2 +-
 libavformat/sdsdec.c   |  2 +-
 libavformat/sol.c  |  2 +-
 libavformat/utils.c|  2 +-
 16 files changed, 56 insertions(+), 20 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 5db6a81320..b00e851ccb 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1430,7 +1430,11 @@ typedef struct AVPacket {
 #endif
 } AVPacket;
 #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
-#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
+/**
+ * The packet's data is corrupted (as opposed to the headers being corrupted,
+ * or the data being truncated).
+ */
+#define AV_PKT_FLAG_DATA_CORRUPT 0x0002
 /**
  * Flag is used to discard packets which are required to maintain valid
  * decoder state but are not required for output and should be dropped
@@ -1449,6 +1453,29 @@ typedef struct AVPacket {
  * be discarded by the decoder.  I.e. Non-reference frames.
  */
 #define AV_PKT_FLAG_DISPOSABLE 0x0010
+#if !FF_API_SINGLE_CORRUPT_FLAG
+/**
+ * The packet's contents are truncated.
+ */
+#define AV_PKT_FLAG_DATA_TRUNCATED 0x0020
+/**
+ * The packet's headers (most notably including the timestamps) are corrupted.
+ */
+#define AV_PKT_FLAG_HEADER_CORRUPT 0x0040
+
+/**
+ * The packet's data or headers are corrupted or truncated.
+ * Bit-combination of AV_PKT_FLAG_DATA_CORRUPT, AV_PKT_FLAG_DATA_TRUNCATED, and
+ * AV_PKT_FLAG_HEADER_CORRUPT.
+ * Can be set to indicate corruption that may affect data or headers, or cause 
truncation.
+ * Can be masked against to check for any kind of corruption.
+ */
+#define AV_PKT_FLAG_CORRUPT 
(AV_PKT_FLAG_DATA_CORRUPT|AV_PKT_FLAG_DATA_TRUNCATED|AV_PKT_FLAG_HEADER_CORRUPT)
+#else
+#define AV_PKT_FLAG_CORRUPT AV_PKT_FLAG_DATA_CORRUPT
+#define AV_PKT_FLAG_DATA_TRUNCATED AV_PKT_FLAG_DATA_CORRUPT
+#define AV_PKT_FLAG_HEADER_CORRUPT AV_PKT_FLAG_DATA_CORRUPT
+#endif
 
 
 enum AVSideDataParamChangeFlags {
diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
index 93d04cb509..cbea9cdf1c 100644
--- a/libavcodec/trace_headers_bsf.c
+++ b/libavcodec/trace_headers_bsf.c
@@ -81,8 +81,14 @@ static int trace_headers(AVBSFContext *bsf, AVPacket *out)
 
 if (in->flags & AV_PKT_FLAG_KEY)
 av_strlcat(tmp, ", key frame", sizeof(tmp));
-if (in->flags & AV_PKT_FLAG_CORRUPT)
-av_strlcat(tmp, ", corrupt", sizeof(tmp));
+if (in->flags & AV_PKT_FLAG_DATA_CORRUPT)
+av_strlcat(tmp, ", data corrupt", sizeof(tmp));
+#if !FF_API_SINGLE_CORRUPT_FLAG
+if (in->flags & AV_PKT_FLAG_DATA_TRUNCATED)
+av_strlcat(tmp, ", truncated", sizeof(tmp));
+if (in->flags & AV_PKT_FLAG_HEADER_CORRUPT)
+av_strlcat(tmp, ", header corrupt", sizeof(tmp));
+#endif
 
 if (in->pts != AV_NOPTS_VALUE)
 av_strlcatf(tmp, sizeof(tmp), ", pts %"PRId64, in->pts);
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 3b5c3000be..2673d8528c 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -126,6 +126,9 @@
 #ifndef FF_API_USER_VISIBLE_AVHWACCEL
 #define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_SINGLE_CORRUPT_FLAG
+#define FF_API_SINGLE_CORRUPT_FLAG (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 
 
 #endif /* AVCODEC_VERSION_H */
diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 99e05c78ec..efe6ce3c42 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -396,7 +396,7 @@ static int aiff_read_packet(AVFormatContext *s,
 return res;
 
 if (size >= st->codecpar->block_align)
-pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
+pkt->flags &= ~AV_PKT_FLAG_DATA_TRUNCATED;
 /* Only one stream in an AIFF file */
 pkt->stream_index = 0;
 pkt->duration = (res / st->codecpar->block_align) * 
aiff->block_duration;
diff --git a/libavformat/apc.c b/libavformat/apc.c
index b180a50c9b..63a9c9 100644
--- a/libavformat/apc.c
+++ b/libavformat/apc.c
@@ -78,7 +78,7 @@ static int apc_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
 if (av_get_packet(s->pb, pkt, MAX_READ_SIZE) <= 0)
 return AVERROR(EIO);
-pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
+pkt->flags &= ~AV_PKT_FLAG_DATA_TRUNCATED;
 pkt->stream_index = 0;
 return 0;
 }
diff --git a/libavformat/iv8.c b/libavformat/iv8.c

[FFmpeg-devel] [PATCH 4/4] lavf/utils: add flag to fill unset timestamps from wallclock offset

2017-12-13 Thread Rodger Combs
---
 libavformat/avformat.h  |  1 +
 libavformat/internal.h  |  5 +
 libavformat/options_table.h |  1 +
 libavformat/utils.c | 12 
 4 files changed, 19 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index d10d583dff..a039a2764d 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1451,6 +1451,7 @@ typedef struct AVFormatContext {
 #define AVFMT_FLAG_SHORTEST   0x10 ///< Stop muxing when the shortest 
stream stops.
 #define AVFMT_FLAG_AUTO_BSF   0x20 ///< Add bitstream filters as requested 
by the muxer
 #define AVFMT_FLAG_DISCARD_CORRUPT_TS 0x40 ///< Discard timestamps of 
frames marked corrupt
+#define AVFMT_FLAG_FILL_WALLCLOCK_DTS 0x80 ///< Fill missing or discarded 
DTS values from wallclock (for live streams)
 
 /**
  * Maximum size of the data read from input for determining
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 36a57214ce..3abf1dc720 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -192,6 +192,11 @@ struct AVStreamInternal {
 int need_context_update;
 
 FFFrac *priv_pts;
+
+/**
+ * The wallclock timestamp of the most recent read packet (if 
AVFMT_FLAG_FILL_WALLCLOCK_DTS is set)
+ */
+int64_t cur_wallclock_time;
 };
 
 #ifdef __GNUC__
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 515574d3e0..64febc7a21 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -59,6 +59,7 @@ static const AVOption avformat_options[] = {
 {"shortest", "stop muxing with the shortest stream", 0, AV_OPT_TYPE_CONST, { 
.i64 = AVFMT_FLAG_SHORTEST }, 0, 0, E, "fflags" },
 {"autobsf", "add needed bsfs automatically", 0, AV_OPT_TYPE_CONST, { .i64 = 
AVFMT_FLAG_AUTO_BSF }, 0, 0, E, "fflags" },
 {"discardcorruptts", "discard timestamps on corrupted frames", 0, 
AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_DISCARD_CORRUPT_TS }, 0, 0, E, "fflags" 
},
+{"fillwallclockdts", "fill missing or discarded DTS values from wallclock (for 
live streams)", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_FILL_WALLCLOCK_DTS }, 
0, 0, E, "fflags" },
 {"analyzeduration", "specify how many microseconds are analyzed to probe the 
input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, 
INT64_MAX, D},
 {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 
0, 0, D},
 {"indexmem", "max memory used for timestamp index (per stream)", 
OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 2e15f34469..9704f2ae29 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -881,6 +881,18 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index);
 }
 
+if (s->flags & AVFMT_FLAG_FILL_WALLCLOCK_DTS) {
+int64_t cur_wallclock_time = av_gettime_relative();
+if (pkt->dts == AV_NOPTS_VALUE && st->cur_dts != AV_NOPTS_VALUE && 
st->internal->cur_wallclock_time) {
+int64_t wallclock_offset = 
av_rescale_q(st->internal->cur_wallclock_time - cur_wallclock_time, 
AV_TIME_BASE_Q, st->time_base);
+pkt->dts = st->cur_dts + FFMAX(wallclock_offset, 1);
+av_log(s, AV_LOG_VERBOSE,
+   "Filled timestamp from wallclock (stream = %d; last = 
%"PRId64"; val = %"PRId64")\n",
+   pkt->stream_index, st->cur_dts, pkt->dts);
+}
+st->internal->cur_wallclock_time = cur_wallclock_time;
+}
+
 pkt->dts = wrap_timestamp(st, pkt->dts);
 pkt->pts = wrap_timestamp(st, pkt->pts);
 
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 1/4] lavf/mpegts: mark packets with TEI flag as corrupted

2017-12-13 Thread Rodger Combs
---
 libavformat/mpegts.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 53cbcfb543..0a3ad05726 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2296,6 +2296,14 @@ static int handle_packet(MpegTSContext *ts, const 
uint8_t *packet)
 }
 }
 
+if (packet[1] & 0x80) {
+av_log(ts->stream, AV_LOG_DEBUG, "Packet had TEI flag set; marking as 
corrupt\n");
+if (tss->type == MPEGTS_PES) {
+PESContext *pc = tss->u.pes_filter.opaque;
+pc->flags |= AV_PKT_FLAG_CORRUPT;
+}
+}
+
 p = packet + 4;
 if (has_adaptation) {
 int64_t pcr_h;
-- 
2.15.1

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


Re: [FFmpeg-devel] [PATCH] avcodec: add properties for lossless to AVCodecParameters

2017-12-13 Thread Rodger Combs


> On May 9, 2016, at 08:28, Hendrik Leppkes  wrote:
> 
> On Mon, May 9, 2016 at 3:26 PM, Derek Buitenhuis
>  wrote:
>> On 5/9/2016 2:22 PM, Paul B Mahol wrote:
>>> Once st->codec is gone, how would this lossless info be gathered back?
>> 
>> As myself and others have said above: decode a frame.
> 
> And before people argue that avformat does this anyway today - one of
> the hopes is to make it stop doing that for many "simple" codecs where
> this is just not necessary, and say a parser could extract all the
> important information with much less overhead.

(necroing old thread because this came up elsewhere)

I can understand the argument that lavf shouldn't return all of this by 
_default_, but not providing a mechanism at all forces a lot of additional 
boilerplate onto the consumer. It'd be convenient to have an API that does the 
equivalent of what avformat_find_stream_info currently does (determine all 
relevant stream information for all streams, either using parsers or decoders 
as necessary, running through as many frames as necessary to gather the info, 
up to timestamp- and size-based limits).
If you don't think this fits well in lavf, there could be a higher-level lib on 
top of lavf+lavc that handles this sort of thing (potentially the 
"ffmpeg.c-as-a-library" concept I've thought about for a while, with 
ffprobe-like functionality as well), but the simplest way to do it is just to 
have avformat_find_stream_info continue to perform that function, perhaps 
behind a "gather more info than what lavf itself needs" flag.

> 
> - Hendrik
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/3] lavf/utils: add flag to discard timestamps on corrupted frames

2017-12-13 Thread Rodger Combs


> On Dec 10, 2017, at 09:27, Michael Niedermayer <mich...@niedermayer.cc> wrote:
> 
> On Sun, Dec 10, 2017 at 05:17:44AM -0600, Rodger Combs wrote:
>> 
>> 
>>> On Dec 9, 2017, at 12:19, Michael Niedermayer <mich...@niedermayer.cc> 
>>> wrote:
>>> 
>>> On Fri, Dec 08, 2017 at 10:34:39PM -0600, Rodger Combs wrote:
>>>> 
>>>> 
>>>>> On Dec 8, 2017, at 11:06, Michael Niedermayer <mich...@niedermayer.cc> 
>>>>> wrote:
>>>>> 
>>>>> On Thu, Dec 07, 2017 at 10:23:15PM -0600, Rodger Combs wrote:
>>>>>> ---
>>>>>> libavformat/avformat.h  | 1 +
>>>>>> libavformat/options_table.h | 1 +
>>>>>> libavformat/utils.c | 8 
>>>>>> 3 files changed, 10 insertions(+)
>>>>>> 
>>>>>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>>>>>> index 4f2798a871..d10d583dff 100644
>>>>>> --- a/libavformat/avformat.h
>>>>>> +++ b/libavformat/avformat.h
>>>>>> @@ -1450,6 +1450,7 @@ typedef struct AVFormatContext {
>>>>>> #define AVFMT_FLAG_FAST_SEEK   0x8 ///< Enable fast, but inaccurate 
>>>>>> seeks for some formats
>>>>>> #define AVFMT_FLAG_SHORTEST   0x10 ///< Stop muxing when the 
>>>>>> shortest stream stops.
>>>>>> #define AVFMT_FLAG_AUTO_BSF   0x20 ///< Add bitstream filters as 
>>>>>> requested by the muxer
>>>>>> +#define AVFMT_FLAG_DISCARD_CORRUPT_TS 0x40 ///< Discard timestamps 
>>>>>> of frames marked corrupt
>>>>>> 
>>>>>>   /**
>>>>>>* Maximum size of the data read from input for determining
>>>>>> diff --git a/libavformat/options_table.h b/libavformat/options_table.h
>>>>>> index b8fa47c6fd..515574d3e0 100644
>>>>>> --- a/libavformat/options_table.h
>>>>>> +++ b/libavformat/options_table.h
>>>>>> @@ -58,6 +58,7 @@ static const AVOption avformat_options[] = {
>>>>>> {"bitexact", "do not write random/volatile data", 0, AV_OPT_TYPE_CONST, 
>>>>>> { .i64 = AVFMT_FLAG_BITEXACT }, 0, 0, E, "fflags" },
>>>>>> {"shortest", "stop muxing with the shortest stream", 0, 
>>>>>> AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_SHORTEST }, 0, 0, E, "fflags" },
>>>>>> {"autobsf", "add needed bsfs automatically", 0, AV_OPT_TYPE_CONST, { 
>>>>>> .i64 = AVFMT_FLAG_AUTO_BSF }, 0, 0, E, "fflags" },
>>>>>> +{"discardcorruptts", "discard timestamps on corrupted frames", 0, 
>>>>>> AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_DISCARD_CORRUPT_TS }, 0, 0, E, 
>>>>>> "fflags" },
>>>>>> {"analyzeduration", "specify how many microseconds are analyzed to probe 
>>>>>> the input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT64, {.i64 = 0 
>>>>>> }, 0, INT64_MAX, D},
>>>>>> {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 
>>>>>> 0}, 0, 0, D},
>>>>>> {"indexmem", "max memory used for timestamp index (per stream)", 
>>>>>> OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
>>>>>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>>>>>> index 84e49208b8..98af941e9f 100644
>>>>>> --- a/libavformat/utils.c
>>>>>> +++ b/libavformat/utils.c
>>>>> 
>>>>>> @@ -873,6 +873,14 @@ int ff_read_packet(AVFormatContext *s, AVPacket 
>>>>>> *pkt)
>>>>>>   st->cur_dts = wrap_timestamp(st, st->cur_dts);
>>>>>>   }
>>>>>> 
>>>>>> +if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT_TS) &&
>>>>>> +(pkt->flags & AV_PKT_FLAG_CORRUPT)) {
>>>>>> +pkt->pts = pkt->dts = AV_NOPTS_VALUE;
>>>>>> +av_log(s, AV_LOG_WARNING,
>>>>>> +   "Discarded timestamp on corrupted packet (stream = 
>>>>>> %d)\n",
>>>>>> +   pkt->stream_index);
>>>&

Re: [FFmpeg-devel] [PATCH 1/3] lavf/matroskadec: resync if cluster parsing fails while seeking

2017-12-10 Thread Rodger Combs


> On Dec 10, 2017, at 08:08, Nicolas George <geo...@nsup.org> wrote:
> 
> Rodger Combs (2017-12-08):
>> ---
>> libavformat/matroskadec.c | 8 ++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>> 
>> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>> index 496499b553..b51f67af00 100644
>> --- a/libavformat/matroskadec.c
>> +++ b/libavformat/matroskadec.c
>> @@ -3528,9 +3528,13 @@ static int matroska_read_seek(AVFormatContext *s, int 
>> stream_index,
>>   SEEK_SET);
>> matroska->current_id = 0;
>> while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0 
>> || index == st->nb_index_entries - 1) {
>> +int ret;
>> +int64_t pos = avio_tell(matroska->ctx->pb);
>> matroska_clear_queue(matroska);
>> -if (matroska_parse_cluster(matroska) < 0)
>> -break;
>> +if ((ret = matroska_parse_cluster(matroska)) < 0) {
> 
>> +if ((ret == AVERROR_EOF) || matroska_resync(matroska, pos) 
>> < 0)
> 
> This is discarding the actual error code from matroska_resync().

This is the old read_seek API, so nothing looks at its actual return code 
(apart to check if it's >=0). In the new API, we'd want this, but I think 
moving to that is out of scope for this change.

> 
>> +break;
>> +}
>> }
>> }
>> 
> 
> Regards,
> 
> -- 
>  Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel 
> <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] lavf/utils: add flag to fill unset timestamps from wallclock offset

2017-12-10 Thread Rodger Combs


> On Dec 10, 2017, at 05:40, Nicolas George <geo...@nsup.org> wrote:
> 
> Rodger Combs (2017-12-10):
>> The goal is to use this in conjunction with the previous patches in
>> the set to deal with live broadcast streams coming off a tuner. The
>> first patch sets the CORRUPT flag when the TEI bit is set in a TS
>> packet (indicating that the tuner detected uncorrectable errors), the
>> second clears the PTS and DTS in response to that flag (since a bit
>> flip that causes a too-high timestamp can throw off the whole stream,
>> since ffmpeg.c enforces monotonicity), and the third re-generates DTSs
>> by interpolating from the previous packet's receipt time.
> 
> You did not give enough details to judge, but I will try to extrapolate.
> 
> This change would be useful for an application that receives live
> broadcast streams, from a source that may be corrupted, but that uses
> wallclock timestamps, synchronized with the client application and with
> no network delay, and that cannot fiddle with timestamps itself.

Not exactly. I'm not using actual wallclock timestamps anywhere; just _offsets_ 
of timestamps.
My application uses ffmpeg.c to record OTA and cable broadcasts (which may have 
corruption) to segments on-disk, which are later either concatenated, or 
streamed to client devices, or both. In either case, it's preferable to have 
timestamps be approximately correct in the event of corruption (as this patch 
produces), rather than entirely absent, or approximated from frame rate (which 
would produce incorrect values if frames were missing). I think the "remux a 
broadcast stream to disk" use-case is fairly common.

> 
> It seems awfully specific. Too specific for a change in the core
> workings of the library.
> 
>> In my target use-case
> 
> Stop. We are not speaking of your target use case, we are speaking of a
> change in the core components of the library. It should be designed to
> be useful for more than your own use case.

As described above, I think the use-case I'm referring to is fairly common and 
worth supporting.

> 
> Regards,
> 
> -- 
>  Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/3] lavf/utils: add flag to discard timestamps on corrupted frames

2017-12-10 Thread Rodger Combs


> On Dec 9, 2017, at 12:19, Michael Niedermayer <mich...@niedermayer.cc> wrote:
> 
> On Fri, Dec 08, 2017 at 10:34:39PM -0600, Rodger Combs wrote:
>> 
>> 
>>> On Dec 8, 2017, at 11:06, Michael Niedermayer <mich...@niedermayer.cc> 
>>> wrote:
>>> 
>>> On Thu, Dec 07, 2017 at 10:23:15PM -0600, Rodger Combs wrote:
>>>> ---
>>>> libavformat/avformat.h  | 1 +
>>>> libavformat/options_table.h | 1 +
>>>> libavformat/utils.c | 8 
>>>> 3 files changed, 10 insertions(+)
>>>> 
>>>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>>>> index 4f2798a871..d10d583dff 100644
>>>> --- a/libavformat/avformat.h
>>>> +++ b/libavformat/avformat.h
>>>> @@ -1450,6 +1450,7 @@ typedef struct AVFormatContext {
>>>> #define AVFMT_FLAG_FAST_SEEK   0x8 ///< Enable fast, but inaccurate 
>>>> seeks for some formats
>>>> #define AVFMT_FLAG_SHORTEST   0x10 ///< Stop muxing when the shortest 
>>>> stream stops.
>>>> #define AVFMT_FLAG_AUTO_BSF   0x20 ///< Add bitstream filters as 
>>>> requested by the muxer
>>>> +#define AVFMT_FLAG_DISCARD_CORRUPT_TS 0x40 ///< Discard timestamps of 
>>>> frames marked corrupt
>>>> 
>>>>/**
>>>> * Maximum size of the data read from input for determining
>>>> diff --git a/libavformat/options_table.h b/libavformat/options_table.h
>>>> index b8fa47c6fd..515574d3e0 100644
>>>> --- a/libavformat/options_table.h
>>>> +++ b/libavformat/options_table.h
>>>> @@ -58,6 +58,7 @@ static const AVOption avformat_options[] = {
>>>> {"bitexact", "do not write random/volatile data", 0, AV_OPT_TYPE_CONST, { 
>>>> .i64 = AVFMT_FLAG_BITEXACT }, 0, 0, E, "fflags" },
>>>> {"shortest", "stop muxing with the shortest stream", 0, AV_OPT_TYPE_CONST, 
>>>> { .i64 = AVFMT_FLAG_SHORTEST }, 0, 0, E, "fflags" },
>>>> {"autobsf", "add needed bsfs automatically", 0, AV_OPT_TYPE_CONST, { .i64 
>>>> = AVFMT_FLAG_AUTO_BSF }, 0, 0, E, "fflags" },
>>>> +{"discardcorruptts", "discard timestamps on corrupted frames", 0, 
>>>> AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_DISCARD_CORRUPT_TS }, 0, 0, E, 
>>>> "fflags" },
>>>> {"analyzeduration", "specify how many microseconds are analyzed to probe 
>>>> the input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT64, {.i64 = 0 }, 
>>>> 0, INT64_MAX, D},
>>>> {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 
>>>> 0}, 0, 0, D},
>>>> {"indexmem", "max memory used for timestamp index (per stream)", 
>>>> OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
>>>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>>>> index 84e49208b8..98af941e9f 100644
>>>> --- a/libavformat/utils.c
>>>> +++ b/libavformat/utils.c
>>> 
>>>> @@ -873,6 +873,14 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
>>>>st->cur_dts = wrap_timestamp(st, st->cur_dts);
>>>>}
>>>> 
>>>> +if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT_TS) &&
>>>> +(pkt->flags & AV_PKT_FLAG_CORRUPT)) {
>>>> +pkt->pts = pkt->dts = AV_NOPTS_VALUE;
>>>> +av_log(s, AV_LOG_WARNING,
>>>> +   "Discarded timestamp on corrupted packet (stream = 
>>>> %d)\n",
>>>> +   pkt->stream_index);
>>>> +}
>>> 
>>> how many of the cases that set AV_PKT_FLAG_CORRUPT can even be due to
>>> the timestamp ?
>> 
>> Pretty much just the new TEI check, or potentially other CRC checks. I don't 
>> _think_ the continuity-counter check failing could indicate an incorrect 
>> timestamp. I suppose we could add a second flag just for corruption that 
>> could affect timestamps?
> 
> I think thats a great idea, maybe if we already change it we should
> also split the truncated case out as it is very common.
> 
> AV_PKT_FLAG_DATA_CORRUPT// the packet data may be corrupted
> AV_PKT_FLAG_DATA_TRUNCATED  // the packet size may be corrupted, 
> data available is undamaged unless another flag indicates otherwise. Any 
> headers or sub-packets which are complete are non corrupted-
> AV_PKT_FLAG_TS_CORRUPT  // the packets timestamps and or 
> duration may be corrupted
> 
> #define AV_PKT_FLAG_CORRUPT (AV_PKT_FLAG_DATA_CORRUPT | 
> AV_PKT_FLAG_DATA_TRUNCATED | AV_PKT_FLAG_TS_CORRUPT)

What kind of API bump would be needed to make this kind of change?

> 
> or some variation of this
> 
> Thanks
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> There will always be a question for which you do not know the correct answer.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel 
> <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/3] lavf/utils: add flag to discard timestamps on corrupted frames

2017-12-08 Thread Rodger Combs


> On Dec 8, 2017, at 11:06, Michael Niedermayer <mich...@niedermayer.cc> wrote:
> 
> On Thu, Dec 07, 2017 at 10:23:15PM -0600, Rodger Combs wrote:
>> ---
>> libavformat/avformat.h  | 1 +
>> libavformat/options_table.h | 1 +
>> libavformat/utils.c | 8 
>> 3 files changed, 10 insertions(+)
>> 
>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>> index 4f2798a871..d10d583dff 100644
>> --- a/libavformat/avformat.h
>> +++ b/libavformat/avformat.h
>> @@ -1450,6 +1450,7 @@ typedef struct AVFormatContext {
>> #define AVFMT_FLAG_FAST_SEEK   0x8 ///< Enable fast, but inaccurate 
>> seeks for some formats
>> #define AVFMT_FLAG_SHORTEST   0x10 ///< Stop muxing when the shortest 
>> stream stops.
>> #define AVFMT_FLAG_AUTO_BSF   0x20 ///< Add bitstream filters as 
>> requested by the muxer
>> +#define AVFMT_FLAG_DISCARD_CORRUPT_TS 0x40 ///< Discard timestamps of 
>> frames marked corrupt
>> 
>> /**
>>  * Maximum size of the data read from input for determining
>> diff --git a/libavformat/options_table.h b/libavformat/options_table.h
>> index b8fa47c6fd..515574d3e0 100644
>> --- a/libavformat/options_table.h
>> +++ b/libavformat/options_table.h
>> @@ -58,6 +58,7 @@ static const AVOption avformat_options[] = {
>> {"bitexact", "do not write random/volatile data", 0, AV_OPT_TYPE_CONST, { 
>> .i64 = AVFMT_FLAG_BITEXACT }, 0, 0, E, "fflags" },
>> {"shortest", "stop muxing with the shortest stream", 0, AV_OPT_TYPE_CONST, { 
>> .i64 = AVFMT_FLAG_SHORTEST }, 0, 0, E, "fflags" },
>> {"autobsf", "add needed bsfs automatically", 0, AV_OPT_TYPE_CONST, { .i64 = 
>> AVFMT_FLAG_AUTO_BSF }, 0, 0, E, "fflags" },
>> +{"discardcorruptts", "discard timestamps on corrupted frames", 0, 
>> AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_DISCARD_CORRUPT_TS }, 0, 0, E, 
>> "fflags" },
>> {"analyzeduration", "specify how many microseconds are analyzed to probe the 
>> input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, 
>> INT64_MAX, D},
>> {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 
>> 0, 0, D},
>> {"indexmem", "max memory used for timestamp index (per stream)", 
>> OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>> index 84e49208b8..98af941e9f 100644
>> --- a/libavformat/utils.c
>> +++ b/libavformat/utils.c
> 
>> @@ -873,6 +873,14 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
>> st->cur_dts = wrap_timestamp(st, st->cur_dts);
>> }
>> 
>> +if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT_TS) &&
>> +(pkt->flags & AV_PKT_FLAG_CORRUPT)) {
>> +pkt->pts = pkt->dts = AV_NOPTS_VALUE;
>> +av_log(s, AV_LOG_WARNING,
>> +   "Discarded timestamp on corrupted packet (stream = 
>> %d)\n",
>> +   pkt->stream_index);
>> +}
> 
> how many of the cases that set AV_PKT_FLAG_CORRUPT can even be due to
> the timestamp ?

Pretty much just the new TEI check, or potentially other CRC checks. I don't 
_think_ the continuity-counter check failing could indicate an incorrect 
timestamp. I suppose we could add a second flag just for corruption that could 
affect timestamps?

> 
> We set this for truncated / EOF cases and all kinds of stuff that
> are known to be unrelated to the timestamps
> 
> 
> [...]
> 
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> The real ebay dictionary, page 1
> "Used only once"- "Some unspecified defect prevented a second use"
> "In good condition" - "Can be repaird by experienced expert"
> "As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel 
> <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/3] lavf/matroskadec: resync if cluster parsing fails while seeking

2017-12-08 Thread Rodger Combs
---
 libavformat/matroskadec.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 496499b553..b51f67af00 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3528,9 +3528,13 @@ static int matroska_read_seek(AVFormatContext *s, int 
stream_index,
   SEEK_SET);
 matroska->current_id = 0;
 while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0 
|| index == st->nb_index_entries - 1) {
+int ret;
+int64_t pos = avio_tell(matroska->ctx->pb);
 matroska_clear_queue(matroska);
-if (matroska_parse_cluster(matroska) < 0)
-break;
+if ((ret = matroska_parse_cluster(matroska)) < 0) {
+if ((ret == AVERROR_EOF) || matroska_resync(matroska, pos) < 0)
+break;
+}
 }
 }
 
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 2/3] lavf/matroskadec: fallback to generic seeking if resyncing fails while seeking

2017-12-08 Thread Rodger Combs
---
 libavformat/matroskadec.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index b51f67af00..944ed795d5 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3532,8 +3532,12 @@ static int matroska_read_seek(AVFormatContext *s, int 
stream_index,
 int64_t pos = avio_tell(matroska->ctx->pb);
 matroska_clear_queue(matroska);
 if ((ret = matroska_parse_cluster(matroska)) < 0) {
-if ((ret == AVERROR_EOF) || matroska_resync(matroska, pos) < 0)
+if (ret == AVERROR_EOF) {
 break;
+} else if(matroska_resync(matroska, pos) < 0) {
+index = -1;
+break;
+}
 }
 }
 }
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 3/3] lavf/matroskadec: log when falling back to generic seeking

2017-12-08 Thread Rodger Combs
---
 libavformat/matroskadec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 944ed795d5..fb1a27f4a8 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3570,6 +3570,7 @@ static int matroska_read_seek(AVFormatContext *s, int 
stream_index,
 ff_update_cur_dts(s, st, st->index_entries[index].timestamp);
 return 0;
 err:
+av_log(s, AV_LOG_VERBOSE, "Failed to seek using index; falling back to 
generic seek");
 // slightly hackish but allows proper fallback to
 // the generic seeking code.
 matroska_clear_queue(matroska);
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 3/3] lavf/matroskadec: log when falling back to generic seeking

2017-12-08 Thread Rodger Combs
---
 libavformat/matroskadec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 2d23f2ee84..f023e94e70 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3567,6 +3567,7 @@ static int matroska_read_seek(AVFormatContext *s, int 
stream_index,
 ff_update_cur_dts(s, st, st->index_entries[index].timestamp);
 return 0;
 err:
+av_log(s, AV_LOG_VERBOSE, "Failed to seek using index; falling back to 
generic seek");
 // slightly hackish but allows proper fallback to
 // the generic seeking code.
 matroska_clear_queue(matroska);
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 2/3] lavf/matroskadec: fallback to generic seeking if resyncing fails while seeking

2017-12-08 Thread Rodger Combs
---
 libavformat/matroskadec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 93a3ec4a07..2d23f2ee84 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3531,8 +3531,10 @@ static int matroska_read_seek(AVFormatContext *s, int 
stream_index,
 int64_t pos = avio_tell(matroska->ctx->pb);
 matroska_clear_queue(matroska);
 if (matroska_parse_cluster(matroska) < 0) {
-if (matroska_resync(matroska, pos) < 0)
+if (matroska_resync(matroska, pos) < 0) {
+index = -1;
 break;
+}
 }
 }
 }
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 1/3] lavf/matroskadec: resync if cluster parsing fails while seeking

2017-12-08 Thread Rodger Combs
---
 libavformat/matroskadec.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 496499b553..93a3ec4a07 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3528,9 +3528,12 @@ static int matroska_read_seek(AVFormatContext *s, int 
stream_index,
   SEEK_SET);
 matroska->current_id = 0;
 while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0 
|| index == st->nb_index_entries - 1) {
+int64_t pos = avio_tell(matroska->ctx->pb);
 matroska_clear_queue(matroska);
-if (matroska_parse_cluster(matroska) < 0)
-break;
+if (matroska_parse_cluster(matroska) < 0) {
+if (matroska_resync(matroska, pos) < 0)
+break;
+}
 }
 }
 
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 3/3] lavf/utils: add flag to fill unset timestamps from wallclock offset

2017-12-07 Thread Rodger Combs
---
 libavformat/avformat.h  |  1 +
 libavformat/internal.h  |  5 +
 libavformat/options_table.h |  1 +
 libavformat/utils.c | 12 
 4 files changed, 19 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index d10d583dff..a039a2764d 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1451,6 +1451,7 @@ typedef struct AVFormatContext {
 #define AVFMT_FLAG_SHORTEST   0x10 ///< Stop muxing when the shortest 
stream stops.
 #define AVFMT_FLAG_AUTO_BSF   0x20 ///< Add bitstream filters as requested 
by the muxer
 #define AVFMT_FLAG_DISCARD_CORRUPT_TS 0x40 ///< Discard timestamps of 
frames marked corrupt
+#define AVFMT_FLAG_FILL_WALLCLOCK_DTS 0x80 ///< Fill missing or discarded 
DTS values from wallclock (for live streams)
 
 /**
  * Maximum size of the data read from input for determining
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 36a57214ce..3abf1dc720 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -192,6 +192,11 @@ struct AVStreamInternal {
 int need_context_update;
 
 FFFrac *priv_pts;
+
+/**
+ * The wallclock timestamp of the most recent read packet (if 
AVFMT_FLAG_FILL_WALLCLOCK_DTS is set)
+ */
+int64_t cur_wallclock_time;
 };
 
 #ifdef __GNUC__
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 515574d3e0..64febc7a21 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -59,6 +59,7 @@ static const AVOption avformat_options[] = {
 {"shortest", "stop muxing with the shortest stream", 0, AV_OPT_TYPE_CONST, { 
.i64 = AVFMT_FLAG_SHORTEST }, 0, 0, E, "fflags" },
 {"autobsf", "add needed bsfs automatically", 0, AV_OPT_TYPE_CONST, { .i64 = 
AVFMT_FLAG_AUTO_BSF }, 0, 0, E, "fflags" },
 {"discardcorruptts", "discard timestamps on corrupted frames", 0, 
AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_DISCARD_CORRUPT_TS }, 0, 0, E, "fflags" 
},
+{"fillwallclockdts", "fill missing or discarded DTS values from wallclock (for 
live streams)", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_FILL_WALLCLOCK_DTS }, 
0, 0, E, "fflags" },
 {"analyzeduration", "specify how many microseconds are analyzed to probe the 
input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, 
INT64_MAX, D},
 {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 
0, 0, D},
 {"indexmem", "max memory used for timestamp index (per stream)", 
OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 98af941e9f..22cefb2975 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -881,6 +881,18 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index);
 }
 
+if (s->flags & AVFMT_FLAG_FILL_WALLCLOCK_DTS) {
+int64_t cur_wallclock_time = av_gettime_relative();
+if (pkt->dts == AV_NOPTS_VALUE && st->cur_dts != AV_NOPTS_VALUE && 
st->internal->cur_wallclock_time) {
+int64_t wallclock_offset = 
av_rescale_q(st->internal->cur_wallclock_time - cur_wallclock_time, 
AV_TIME_BASE_Q, st->time_base);
+pkt->dts = st->cur_dts + FFMAX(wallclock_offset, 1);
+av_log(s, AV_LOG_VERBOSE,
+   "Filled timestamp from wallclock (stream = %d; last = 
%"PRId64"; val = %"PRId64")\n",
+   pkt->stream_index, st->cur_dts, pkt->dts);
+}
+st->internal->cur_wallclock_time = cur_wallclock_time;
+}
+
 pkt->dts = wrap_timestamp(st, pkt->dts);
 pkt->pts = wrap_timestamp(st, pkt->pts);
 
-- 
2.14.3

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


[FFmpeg-devel] [PATCH 1/3] lavf/mpegts: mark packets with TEI flag as corrupted

2017-12-07 Thread Rodger Combs
---
 libavformat/mpegts.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 53cbcfb543..0a3ad05726 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2296,6 +2296,14 @@ static int handle_packet(MpegTSContext *ts, const 
uint8_t *packet)
 }
 }
 
+if (packet[1] & 0x80) {
+av_log(ts->stream, AV_LOG_DEBUG, "Packet had TEI flag set; marking as 
corrupt\n");
+if (tss->type == MPEGTS_PES) {
+PESContext *pc = tss->u.pes_filter.opaque;
+pc->flags |= AV_PKT_FLAG_CORRUPT;
+}
+}
+
 p = packet + 4;
 if (has_adaptation) {
 int64_t pcr_h;
-- 
2.14.3

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


[FFmpeg-devel] [PATCH 2/3] lavf/utils: add flag to discard timestamps on corrupted frames

2017-12-07 Thread Rodger Combs
---
 libavformat/avformat.h  | 1 +
 libavformat/options_table.h | 1 +
 libavformat/utils.c | 8 
 3 files changed, 10 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 4f2798a871..d10d583dff 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1450,6 +1450,7 @@ typedef struct AVFormatContext {
 #define AVFMT_FLAG_FAST_SEEK   0x8 ///< Enable fast, but inaccurate seeks 
for some formats
 #define AVFMT_FLAG_SHORTEST   0x10 ///< Stop muxing when the shortest 
stream stops.
 #define AVFMT_FLAG_AUTO_BSF   0x20 ///< Add bitstream filters as requested 
by the muxer
+#define AVFMT_FLAG_DISCARD_CORRUPT_TS 0x40 ///< Discard timestamps of 
frames marked corrupt
 
 /**
  * Maximum size of the data read from input for determining
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index b8fa47c6fd..515574d3e0 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -58,6 +58,7 @@ static const AVOption avformat_options[] = {
 {"bitexact", "do not write random/volatile data", 0, AV_OPT_TYPE_CONST, { .i64 
= AVFMT_FLAG_BITEXACT }, 0, 0, E, "fflags" },
 {"shortest", "stop muxing with the shortest stream", 0, AV_OPT_TYPE_CONST, { 
.i64 = AVFMT_FLAG_SHORTEST }, 0, 0, E, "fflags" },
 {"autobsf", "add needed bsfs automatically", 0, AV_OPT_TYPE_CONST, { .i64 = 
AVFMT_FLAG_AUTO_BSF }, 0, 0, E, "fflags" },
+{"discardcorruptts", "discard timestamps on corrupted frames", 0, 
AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_DISCARD_CORRUPT_TS }, 0, 0, E, "fflags" 
},
 {"analyzeduration", "specify how many microseconds are analyzed to probe the 
input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, 
INT64_MAX, D},
 {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 
0, 0, D},
 {"indexmem", "max memory used for timestamp index (per stream)", 
OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 84e49208b8..98af941e9f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -873,6 +873,14 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
 st->cur_dts = wrap_timestamp(st, st->cur_dts);
 }
 
+if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT_TS) &&
+(pkt->flags & AV_PKT_FLAG_CORRUPT)) {
+pkt->pts = pkt->dts = AV_NOPTS_VALUE;
+av_log(s, AV_LOG_WARNING,
+   "Discarded timestamp on corrupted packet (stream = %d)\n",
+   pkt->stream_index);
+}
+
 pkt->dts = wrap_timestamp(st, pkt->dts);
 pkt->pts = wrap_timestamp(st, pkt->pts);
 
-- 
2.14.3

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


Re: [FFmpeg-devel] [PATCH 2/2] lavf/utils: add flag to discard timestamps on corrupted frames

2017-12-07 Thread Rodger Combs


> On Dec 7, 2017, at 16:53, Hendrik Leppkes <h.lepp...@gmail.com> wrote:
> 
> On Thu, Dec 7, 2017 at 9:46 PM, Michael Niedermayer
> <mich...@niedermayer.cc <mailto:mich...@niedermayer.cc>> wrote:
>> On Thu, Dec 07, 2017 at 03:37:38AM -0600, Rodger Combs wrote:
>>> ---
>>> libavformat/avformat.h  |  1 +
>>> libavformat/internal.h  |  5 +
>>> libavformat/options_table.h |  1 +
>>> libavformat/utils.c | 12 
>>> 4 files changed, 19 insertions(+)
>>> 
>>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>>> index 4f2798a871..e2d88280a8 100644
>>> --- a/libavformat/avformat.h
>>> +++ b/libavformat/avformat.h
>>> @@ -1450,6 +1450,7 @@ typedef struct AVFormatContext {
>>> #define AVFMT_FLAG_FAST_SEEK   0x8 ///< Enable fast, but inaccurate 
>>> seeks for some formats
>>> #define AVFMT_FLAG_SHORTEST   0x10 ///< Stop muxing when the shortest 
>>> stream stops.
>>> #define AVFMT_FLAG_AUTO_BSF   0x20 ///< Add bitstream filters as 
>>> requested by the muxer
>>> +#define AVFMT_FLAG_DISCARD_CORRUPT_TS 0x40 ///< Discard timestamps of 
>>> frames marked corrupt (replacing with wallclock offset from last 
>>> non-corrupt frame)
>> 
>> Using wallclock to fill in timestamps feels wrong
>> if you discard a timestamp it should be set to AV_NOPTS_VALUE or
>> recomputed based on information from the specification where this is
>> possible, fps when constant or other hard information.
>> 
> 
> I agree, discard should be just that, set it to invalid. Wallclock is
> meaningless on anything but a live stream.

My intended use-case is live streams, where wallclock can be more useful than 
deriving from fps if e.g. entire packets are dropped. I could have one flag to 
unset timestamps on corrupt packets, and another to fill unset DTS from 
wallclock?

> 
> - Hendrik
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel 
> <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavc/libopenjpeg: support version 2.3.0 and later

2017-12-07 Thread Rodger Combs
Yup, I did.

> On Dec 7, 2017, at 08:04, James Almer <jamr...@gmail.com> wrote:
> 
> On 12/7/2017 6:17 AM, Rodger Combs wrote:
>> ---
>> configure   |  2 ++
>> libavcodec/libopenjpegdec.c | 29 +++--
>> libavcodec/libopenjpegenc.c | 29 +++--
>> 3 files changed, 48 insertions(+), 12 deletions(-)
> 
> ?
> 
> Did you send an old patchset by mistake?
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 1/2] lavf/mpegts: mark packets with TEI flag as corrupted

2017-12-07 Thread Rodger Combs
---
 libavformat/mpegts.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 53cbcfb543..0a3ad05726 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2296,6 +2296,14 @@ static int handle_packet(MpegTSContext *ts, const 
uint8_t *packet)
 }
 }
 
+if (packet[1] & 0x80) {
+av_log(ts->stream, AV_LOG_DEBUG, "Packet had TEI flag set; marking as 
corrupt\n");
+if (tss->type == MPEGTS_PES) {
+PESContext *pc = tss->u.pes_filter.opaque;
+pc->flags |= AV_PKT_FLAG_CORRUPT;
+}
+}
+
 p = packet + 4;
 if (has_adaptation) {
 int64_t pcr_h;
-- 
2.14.3

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


[FFmpeg-devel] [PATCH 2/2] lavf/utils: add flag to discard timestamps on corrupted frames

2017-12-07 Thread Rodger Combs
---
 libavformat/avformat.h  |  1 +
 libavformat/internal.h  |  5 +
 libavformat/options_table.h |  1 +
 libavformat/utils.c | 12 
 4 files changed, 19 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 4f2798a871..e2d88280a8 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1450,6 +1450,7 @@ typedef struct AVFormatContext {
 #define AVFMT_FLAG_FAST_SEEK   0x8 ///< Enable fast, but inaccurate seeks 
for some formats
 #define AVFMT_FLAG_SHORTEST   0x10 ///< Stop muxing when the shortest 
stream stops.
 #define AVFMT_FLAG_AUTO_BSF   0x20 ///< Add bitstream filters as requested 
by the muxer
+#define AVFMT_FLAG_DISCARD_CORRUPT_TS 0x40 ///< Discard timestamps of 
frames marked corrupt (replacing with wallclock offset from last non-corrupt 
frame)
 
 /**
  * Maximum size of the data read from input for determining
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 36a57214ce..39a69cf630 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -192,6 +192,11 @@ struct AVStreamInternal {
 int need_context_update;
 
 FFFrac *priv_pts;
+
+/**
+ * The wallclock timestamp of the most recent read packet (if 
AVFMT_FLAG_DISCARD_CORRUPT_TS is set)
+ */
+int64_t cur_wallclock_time;
 };
 
 #ifdef __GNUC__
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index b8fa47c6fd..515574d3e0 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -58,6 +58,7 @@ static const AVOption avformat_options[] = {
 {"bitexact", "do not write random/volatile data", 0, AV_OPT_TYPE_CONST, { .i64 
= AVFMT_FLAG_BITEXACT }, 0, 0, E, "fflags" },
 {"shortest", "stop muxing with the shortest stream", 0, AV_OPT_TYPE_CONST, { 
.i64 = AVFMT_FLAG_SHORTEST }, 0, 0, E, "fflags" },
 {"autobsf", "add needed bsfs automatically", 0, AV_OPT_TYPE_CONST, { .i64 = 
AVFMT_FLAG_AUTO_BSF }, 0, 0, E, "fflags" },
+{"discardcorruptts", "discard timestamps on corrupted frames", 0, 
AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_DISCARD_CORRUPT_TS }, 0, 0, E, "fflags" 
},
 {"analyzeduration", "specify how many microseconds are analyzed to probe the 
input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, 
INT64_MAX, D},
 {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 
0, 0, D},
 {"indexmem", "max memory used for timestamp index (per stream)", 
OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 84e49208b8..1adb007244 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -873,6 +873,18 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
 st->cur_dts = wrap_timestamp(st, st->cur_dts);
 }
 
+if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT_TS)) {
+int64_t cur_wallclock_time = av_gettime_relative();
+if (pkt->flags & AV_PKT_FLAG_CORRUPT) {
+int64_t wallclock_offset = 
av_rescale_q(st->internal->cur_wallclock_time - cur_wallclock_time, 
AV_TIME_BASE_Q, st->time_base);
+pkt->pts = pkt->dts = st->cur_dts + FFMAX(wallclock_offset, 1);
+av_log(s, AV_LOG_WARNING,
+   "Discarded timestamp on corrupted packet (stream = 
%d)\n",
+   pkt->stream_index);
+}
+st->internal->cur_wallclock_time = cur_wallclock_time;
+}
+
 pkt->dts = wrap_timestamp(st, pkt->dts);
 pkt->pts = wrap_timestamp(st, pkt->pts);
 
-- 
2.14.3

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


[FFmpeg-devel] [PATCH] lavc/libopenjpeg: support version 2.3.0 and later

2017-12-07 Thread Rodger Combs
---
 configure   |  2 ++
 libavcodec/libopenjpegdec.c | 29 +++--
 libavcodec/libopenjpegenc.c | 29 +++--
 3 files changed, 48 insertions(+), 12 deletions(-)

diff --git a/configure b/configure
index ae0eddac6c..27bed3a20d 100755
--- a/configure
+++ b/configure
@@ -1934,6 +1934,7 @@ HEADERS_LIST="
 openjpeg_2_1_openjpeg_h
 openjpeg_2_0_openjpeg_h
 openjpeg_1_5_openjpeg_h
+opj_config_h
 OpenGL_gl3_h
 poll_h
 soundcard_h
@@ -5972,6 +5973,7 @@ enabled libopenjpeg   && { { check_lib libopenjpeg 
openjpeg-2.2/openjpeg.h o
{ check_lib libopenjpeg openjpeg-2.0/openjpeg.h 
opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
{ check_lib libopenjpeg openjpeg-1.5/openjpeg.h 
opj_version -lopenjpeg -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
{ check_lib libopenjpeg openjpeg.h opj_version 
-lopenjpeg -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
+   { use_pkg_config libopenjpeg libopenjp2 
openjpeg.h opj_version && check_header opj_config.h; } ||
die "ERROR: libopenjpeg not found"; }
 enabled libopenmpt&& require_pkg_config libopenmpt "libopenmpt >= 
0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create
 enabled libopus   && {
diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index 1210123265..822140c181 100644
--- a/libavcodec/libopenjpegdec.c
+++ b/libavcodec/libopenjpegdec.c
@@ -36,18 +36,37 @@
 
 #if HAVE_OPENJPEG_2_2_OPENJPEG_H
 #  include 
+#  define OPJ_VERSION_INT AV_VERSION_INT(2, 2, 0)
 #elif HAVE_OPENJPEG_2_1_OPENJPEG_H
 #  include 
+#  define OPJ_VERSION_INT AV_VERSION_INT(2, 1, 0)
 #elif HAVE_OPENJPEG_2_0_OPENJPEG_H
 #  include 
+#  define OPJ_VERSION_INT AV_VERSION_INT(2, 0, 0)
 #elif HAVE_OPENJPEG_1_5_OPENJPEG_H
 #  include 
+#  define OPJ_VERSION_INT AV_VERSION_INT(1, 5, 0)
 #else
 #  include 
 #endif
 
-#if HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H || 
HAVE_OPENJPEG_2_0_OPENJPEG_H
-#  define OPENJPEG_MAJOR_VERSION 2
+#if HAVE_OPJ_CONFIG_H
+#  include 
+#  ifndef OPJ_VERSION_INT
+#define OPJ_VERSION_INT AV_VERSION_INT(OPJ_VERSION_MAJOR, 
OPJ_VERSION_MINOR, OPJ_VERSION_BUILD)
+#  endif
+#endif
+
+#ifndef OPJ_VERSION_INT
+#  define OPJ_VERSION_INT AV_VERSION_INT(1, 0, 0)
+#endif
+
+#ifndef OPJ_VERSION_MAJOR
+#  define AV_VERSION_MAJOR AV_VERSION_MAJOR(OPJ_VERSION_INT)
+#endif
+
+#if OPJ_VERSION_MAJOR >= 2
+#  define OPENJPEG_MAJOR_VERSION OPJ_VERSION_MAJOR
 #  define OPJ(x) OPJ_##x
 #else
 #  define OPENJPEG_MAJOR_VERSION 1
@@ -431,12 +450,10 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
 opj_stream_set_read_function(stream, stream_read);
 opj_stream_set_skip_function(stream, stream_skip);
 opj_stream_set_seek_function(stream, stream_seek);
-#if HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H
+#if OPJ_VERSION_INT >= AV_VERSION_INT(2, 1, 0)
 opj_stream_set_user_data(stream, , NULL);
-#elif HAVE_OPENJPEG_2_0_OPENJPEG_H
-opj_stream_set_user_data(stream, );
 #else
-#error Missing call to opj_stream_set_user_data
+opj_stream_set_user_data(stream, );
 #endif
 opj_stream_set_user_data_length(stream, avpkt->size);
 // Decode the header only.
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index b67e533d1d..6c2e4c5ea6 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -34,18 +34,37 @@
 
 #if HAVE_OPENJPEG_2_2_OPENJPEG_H
 #  include 
+#  define OPJ_VERSION_INT AV_VERSION_INT(2, 2, 0)
 #elif HAVE_OPENJPEG_2_1_OPENJPEG_H
 #  include 
+#  define OPJ_VERSION_INT AV_VERSION_INT(2, 1, 0)
 #elif HAVE_OPENJPEG_2_0_OPENJPEG_H
 #  include 
+#  define OPJ_VERSION_INT AV_VERSION_INT(2, 0, 0)
 #elif HAVE_OPENJPEG_1_5_OPENJPEG_H
 #  include 
+#  define OPJ_VERSION_INT AV_VERSION_INT(1, 5, 0)
 #else
 #  include 
 #endif
 
-#if HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H || 
HAVE_OPENJPEG_2_0_OPENJPEG_H
-#  define OPENJPEG_MAJOR_VERSION 2
+#if HAVE_OPJ_CONFIG_H
+#  include 
+#  ifndef OPJ_VERSION_INT
+#define OPJ_VERSION_INT AV_VERSION_INT(OPJ_VERSION_MAJOR, 
OPJ_VERSION_MINOR, OPJ_VERSION_BUILD)
+#  endif
+#endif
+
+#ifndef OPJ_VERSION_INT
+#  define OPJ_VERSION_INT AV_VERSION_INT(1, 0, 0)
+#endif
+
+#ifndef OPJ_VERSION_MAJOR
+#  define AV_VERSION_MAJOR AV_VERSION_MAJOR(OPJ_VERSION_INT)
+#endif
+
+#if OPJ_VERSION_MAJOR >= 2
+#  define OPENJPEG_MAJOR_VERSION OPJ_VERSION_MAJOR
 #  define OPJ(x) OPJ_##x
 #else
 #  define OPENJPEG_MAJOR_VERSION 1
@@ -771,12 +790,10 @@ static int libopenjpeg_encode_frame(AVCodecContext 
*avctx, AVPacket *pkt,
 opj_stream_set_write_function(stream, stream_write);
 opj_stream_set_skip_function(stream, stream_skip);
 opj_stream_set_seek_function(stream, stream_seek);
-#if HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H

[FFmpeg-devel] [PATCH] build: fix build with OpenCL

2017-12-07 Thread Rodger Combs
---
 fftools/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/Makefile b/fftools/Makefile
index 094f6d6265..9b211aa4d5 100644
--- a/fftools/Makefile
+++ b/fftools/Makefile
@@ -21,7 +21,7 @@ OBJS-ffserver  += 
fftools/ffserver_config.o
 
 define DOFFTOOL
 OBJS-$(1)-$(CONFIG_OPENCL) += fftools/cmdutils_opencl.o
-OBJS-$(1) += fftools/cmdutils.o fftools/$(1).o $(OBJS-$(1)-yes)
+OBJS-$(1) += fftools/cmdutils.o fftools/$(1).o $$(OBJS-$(1)-yes)
 $(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
 $$(OBJS-$(1)): | fftools
 $$(OBJS-$(1)): CFLAGS  += $(CFLAGS-$(1))
-- 
2.14.3

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


[FFmpeg-devel] [PATCH] lavu/hwcontext_opencl.h: fix build on macOS

2017-11-27 Thread Rodger Combs
---
 libavutil/hwcontext_opencl.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavutil/hwcontext_opencl.h b/libavutil/hwcontext_opencl.h
index 8e34df44cd..ef54486c95 100644
--- a/libavutil/hwcontext_opencl.h
+++ b/libavutil/hwcontext_opencl.h
@@ -19,7 +19,11 @@
 #ifndef AVUTIL_HWCONTEXT_OPENCL_H
 #define AVUTIL_HWCONTEXT_OPENCL_H
 
+#ifdef __APPLE__
+#include 
+#else
 #include 
+#endif
 
 #include "frame.h"
 
-- 
2.14.3

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


  1   2   3   4   5   6   7   >